Click here to Skip to main content
Click here to Skip to main content

Tab Controls And Splitters - Adding Some Dockable And Floating Sugar

, 6 Jan 2004
Rate this:
Please Sign up or sign in to vote.
Another implementation of dockable, floating, tabbing and splitting environment.

Tab Controls And Splitters - Adding Some Dockable And Floating Sugar

Introduction

In the previous article, I introduced SplitPane class that manages client view windows with splitters and tab panes and provides an interaction interface with the owner class. In this article, I would like to represent Frame class that extends SplitPane functionality with dockable and floating features. Also, I am going to consider that you know what dockable and floating windows are. Sure, the best example of those is Visual Studio .NET IDE. I guess you are also aware of an excellent job that has been done by Sergey Klimov and the further improvement by Daniel Bowen. This article is just an attempt to provide a simpler interface for the particular case, with a little bit different paradigm. I hope I have succeeded in it.

What it does

Briefly: Frame class provides dockable and floating environment for client views. There are three parts to this environment, the main pane, dock panes and float frames. All of them are owners of SplitPane, so you can split and tab all client views. Also, the client views are separated in two different groups, dockable views and document views. The difference is simple. The dockable views cannot be attached in the main pane but can be docked in one of the docked sides. The document views are unlike them, they can be attached in the main pane but cannot be docked. Both of them are able to become floating. That's the difference with Visual Studio .NET IDE. To prevent a floating window to get docked to any place, keep CTRL key pressed while dragging it.

Using the code

The use of Frame class can be as simple as the use of SplitPane class. It's also designed for SDI applications. I won't repeat all steps but a few points. With all include files mentioned in that, you will want to use DockTabFrame.h with the Frame class implementation. This is also in DockSplitTab namespace. There is a ClientView class that has all necessary properties for the client view windows. Frame class provides a communication interface for the interface with the owner or parent class. This is the FrameListener abstract class. clientDetached is the only function provided for this interface so far. Frame class calls it when a user closes a dock pane, a float frame or a tab. In other words, when he pushes a close button. There is a detachClientView function for Frame class that does the similar action but does not raise clientDetached event. Frame sends WM_CONTEXTMENU Windows message to the client views in appropriate cases. For instance, when you click a right mouse button on the tab.

Frame class

Public methods:

// creates a new Split Pane window with parentWnd and rect parameters
HWND create( parentWnd, rect);

// sets the keyboard focus to the specified client view window
bool setFocusTo( clientViewWnd) {

// retrieves the client view window that receives the keyboard focus
HWND focusedClientView();

// toggles client view state and move
// the client view to an appropriate pane
bool toggleClientViewState( clientViewWnd, ClientView::State);

// retrieves client view properties with client view window handle
ClientView* getClientView( clientViewWnd);

// adds a new client view
bool addClientView( clientView);

// adds a new client view and attach it to the specified dock pane
bool dockClientView( dockSide, clientView);

// shows/hides the specified dock pane
bool showDockPane( dockSide, show);

// retrieves the visibility state of the specified dock pane
bool dockPaneVisible( dockSide);

// retrieves the existence state of the specified dock pane
bool dockPaneExists( dockSide);

// float frame iterator functions
POSITION floatFrameStart()
HWND floatFrameNext( &position);

// adds a new client view and attach it to a new float frame
// with the specified location
HWND floatClientView( rect, clientView);

// retrieves the visibility state of the specified float frame
bool showFloatFrame( floatFrameWnd, show);

// check if a float frame is visible
bool floatFrameVisible( floatFrameWnd)

// check if a float frame exists
bool checkFloatFrame( floatFrameWnd);

// reattach the client view. the function uses
// the last location object propertes
void attachClientView( clientView);

// detaches the client view window 
// This method changes the parent window of the client
// view window to the Frame's parent.
ClientView* detachClientView( clientViewWnd);

// retrieves the visibility state of the specified client view window handle
bool clientViewVisible( clientViewWnd);

// checks if client view window is attached.
bool clientViewAttached( clientViewWnd);

// set and get Image List
void setImageList( imgList);
HIMAGELIST getImageList();

Inside of Frame class

There are implementations of two very important classes for Frame class. These are DockPane class and FloatFrame class. Each of them has its own SplitPane member. So you can split and tab client views inside of each DockPane or FloatFrame instance. Frame class itself also owns SplitPane instance. An objective of this instance is to keep document views. Frame class communicates with the float frames, dock panes and main pane via FloatDockFrameListener interface class that extends CallBackListener interface.

class DockPane - contains docked client views.
class FloatFrame - contains floating client views.
class FloatDockFrameListener - communication interface between float frames, dock panes and their owner. (Frame class)
class SplitPaneWrapper

- encapsulates common data and methods for split pane containers.

Used by FloatFrame class and DockPane class.

class FloatFrameDragContext - stores drag and drop context. Inherited from RectTracker class.
class DropParcel -the result of drag and drop operations.
class LayoutManager - layout implementation for Frame class.

What's the next

Two things are left to do: Serialization and Auto hide panes.

References

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Igor Katrayev
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralRe: rookie questions PinmemberDr.Rugelj17-Feb-04 3:47 
GeneralRe: rookie questions PinmemberJohnson zhong15-Aug-06 8:06 
GeneralRe: rookie questions Pinmemberweibin12326-Jun-14 16:05 
GeneralRe: rookie questions - II PinmemberDr.Rugelj17-Feb-04 3:41 
Problems, problems Cry | :((
 
If I use your latest version of the code, I get this kind of problems...
Still don't know where the problem is.
 
Thanks for any clue,
jOc
 
First error, which I repaired (sure hope I did) by changing the order of includes:
 

Compiling...
stdafx.cpp
c:\wtl71\include\atlddx.h(19) : fatal error C1189: #error : atlddx.h requires atlapp.h to be included first
 
Build log was saved at "file://g:\check.it.out\c\docktabframe_demo\DockTabFrameWork\Debug\BuildLog.htm"
DockTabFrameWork - 1 error(s), 0 warning(s)

 

Then this:
 

------ Build started: Project: DockTabFrameWork, Configuration: Debug Win32 ------
 
Compiling...
stdafx.cpp
Compiling...
DockTabFrameWork.cpp
g:\check.it.out\c\docktabframe_demo\include\CustomTabCtrl.h(255) : error C2872: 'CString' : ambiguous symbol
could be 'c:\wtl71\include\atlmisc.h(698) : WTL::CString'
or 'c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlstr.h(975) : ATL::CString'
g:\check.it.out\c\docktabframe_demo\include\CustomTabCtrl.h(256) : error C2872: 'CString' : ambiguous symbol
could be 'c:\wtl71\include\atlmisc.h(698) : WTL::CString'
or 'c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\atlstr.h(975) : ATL::CString'

GeneralRe: rookie questions - II PinmemberIgor Katrayev17-Feb-04 5:44 
GeneralRe: rookie questions PinmemberDr.Rugelj17-Feb-04 3:56 
GeneralRe: rookie questions PinmemberIgor Katrayev17-Feb-04 4:02 
GeneralA good Article Pinmembereriust17-Jan-04 3:22 
GeneralRe: A good Article PinmemberIgor Katrayev17-Jan-04 3:29 
QuestionCould you make a version for VC6? Pinmemberfreehawk12-Jan-04 21:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 7 Jan 2004
Article Copyright 2004 by Igor Katrayev
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid