Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Toolkit User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

21.5 Using the Advanced Docking Windows Architecture

The ADW feature is a component of Objective Toolkit. It is not included with the MFC Docking Window extensions in Objective Toolkit. To enable your library with ADW support, run the Objective Toolkit Build Configuration Wizard and select the Advanced Docking Window. If you want to use the customizable toolbars and menubars in Objective Toolkit, you must enable them explicitly through the Build Wizard.


At a lower level, the advanced docking architecture can be used to support any container window seamlessly. The API support is only available for docking inside frame windows.

21.5.1 To incorporate advanced docking windows into your application

You can use the advanced docking windows architecture to provide any frame window (CFrameWnd, CMDIFrameWnd, CMDIChildWnd, SECFrameWnd, SECMDIFrameWnd, SECWorkbookWnd, and more) with docking support.

  1. In your frame header, instantiate a docking feature (SECFrameDockingFeature) and a docking factory (SECLayoutDockFactory) object. The docking feature is the hook to enable the docking architecture for that window and the docking factory is a convenience object designed to simplify the process of creating dockable node participants. For example,

  2. In your frame window's OnCreate() handler, call EnableDocking() on the docking feature. Note that this is a member of SECFrameDockingFeatureBase. Do not confuse it with MFC's CFrameWnd::EnableDocking() member. The prototype for SECFrameDockingFeatureBase::EnableDocking() is as follows:

    The first parameter is a pointer to the frame window to participate in the docking architecture.

    You can apply a combination of zero or more of the following flags to the second parameter:

    Table 52: DockStyle Flags

    Docking style Behavior
    SEC_DOCK_LEFT Allows docking to left border.
    SEC_DOCK_RIGHT Allows docking to right border.
    SEC_DOCK_BOTTOM Allows docking to bottom border.
    SEC_DOCK_TOP Allows docking to top border.
    SEC_DOCK_ANY Allows docking to any border.

    The third parameter specifies whether to create a local docking manager or not. If a local docking manager is created, then nodes docked to this docking feature will not be able to dock to any other docking features. This is typically used inside MDI children, to prevent docking with other frame windows.

    The fourth parameter is a pointer to the docking manager to associate with this feature. You can use the same manager for multiple dock features (1 feature per frame) to configure docking between specific windows. If this parameter is defined, bCreateNewLocalDockMgr is ignored.

    An example:

      int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) {
      . . .
      
          m_dockFeat.EnableDocking(this);
      }
      
  3. Using the dock factory, create a dockable node for each entity (CWnd or DC image) you want to incorporate into the docking framework. For example,

      // Get the CWnd you want to wrap in a dockable node
      CWnd* pMyWnd=GetMyWndFromSomewhere();
      
      // Create the dockable node. The first parameter is the CWnd,
      // the second is the parent window, the third is the default
      // title string (displayed when floating) and the fourth 
      // signals that we want this node to automatically scale when
      // sized. Note that the factory performs all memory 
      // management, 
      // do not deallocate directly.
      SECLayoutNode* 
          pDockNode=m_LFactory.CreateDockableNodeWnd(pMyWnd,
                               this,_T("Dockable Node 1"),TRUE);
      
      // Or, you could create a dockable node window from a 
      // child control id:
      SECLayoutNode* 
          pDockNode=m_LFactory.CreateDockableNodeWnd(IDC_CHILDID,
                               this,_T("Dockable Node 2"));
      


    A similar procedure can be used for creating dockable Device Context Nodes. See
    Section 21.5.2, "To create dockable device context nodes."

  4. Now, use DockNode() or FloatNode() or both members of SECFrameDockingFeature to place your dockable nodes created in the previous step initially. Several overloaded varieties of these functions are available for use so consult the online help for a thorough description of each parameter. For example:

  5. The result of the preceding code would be a layout similar to the following figure:

    Figure 145: Sample Advanced Docking Windows application

Note you can apply the DockNode() and FloatNode() methods iteratively to reset the position of a particular dockable node throughout the lifetime of that particular node. In addition, you can use SECFrameDockingFeatureBase::ShowNode() to show or hide a docked node. For examples of configurations, Section 21.3.5, "Advanced Docking Configurations."

21.5.2 To create dockable device context nodes

The Advanced Docking architecture enables you to create lightweight, windowless (no HWND) dockable nodes based on Device Context drawing. This node type is ideal for rendered images, pictures, and MVC ViewPorts. To create a dockable DC node, do the following:

  1. Derive a class from SECReparentableNodeDC and then override the following protected virtual method:

  2. In your override, render your image to the DC passed in, given the bounding rect passed in. For example:

  3. Follow the procedure described in Section 21.5.1, with one exception. Instead of creating a dockable node, use the CreateDockableNodeDC() method of SECLayoutDockFactory. For example:

21.5.3 To use docking insertion constraints

The following code demonstrates one way you can use the SECDockInsertionConstraints object to create an advanced docking configuration.

The preceding constraints would create a layout similar to the following figure:

Figure 146: Objective Toolkit Advanced Docking Windows Sample

21.5.4 To adjust the border sizing

Use the SECFrameDockingFeature::SetBorderSizing() method to control sizing properties specific to each border docksite (top, bottom, left, and right) individually or as a group. This method provides the following support:

Table 53: SECSetBorderSizingParms Members

SECSetBorderSizingParms members Description
m_bSplitter If TRUE, the docksite will provide a sizing border to increase or decrease the border size. If FALSE, size will be fixed.
m_bSizeOnDock If TRUE, border will increase or decrease size to accommodate new line insertion or old line removal. If FALSE, border will remain fixed in size.
m_bRealtimeDrag If TRUE, border splitter will track instantly. If FALSE, splitter prediction tracker will be used.

For example:

In the following figure, the right border does not provide a sizing splitter. If nodes 5 or 6 or both were not dynamic (see SECDockInsertionConstraints::m_bDynamicNode in the Objective Toolkit Class Reference), there would not be a splitter between nodes 5 and 6.

Figure 147: Objective Toolkit Advanced Docking Windows Sample with no sizing splitter

21.5.5 To use 'real-time' drag mode

You can use this feature to enable or disable. Use the following static function:

21.5.6 To use floating multidock mode

By default, this support is enabled, you can disable via the following static function:

21.5.7 To use alternate border layout logic

By default, the frame docking feature is configured so that the top and bottom borders receives precedence over the left and right borders, (for example, the top/bottom always occupies the entire available client width and the left/right borders shrink to accommodate the height between the top/bottom borders). This mode is configurable so that the left/right borders can receive priority over the top/bottom.

The following function is provided to modify the border layout logic:

By default, the top and bottom dock sites receive precedence over the left and right dock sites. This behavior is the same as MFC's CDockbar layout algorithm's behavior. The following figure illustrates this layout:

Figure 148: Sample demonstrating top/bottom precedence

The following code can be used to toggle the border mode so that left/right receives priority over top/bottom.

This appears as follows. Notice how the left/right borders now occupy the entire height, whereas the bottom is shrunk to fit between. Note also the dockable toolbar and menubar are participants in MFC's controlbar architecture so they are not subject to this layout manipulation.

Figure 149: Sample Demonstrating Left/Right Precedence

21.5.8 To integrate a dockable node inside an MDI child frame

  1. Follow the steps as described in Section 21.5.1, "To incorporate advanced docking windows into your application." However, allocate and initialize inside your CChildFrame class instead of CMainFrame.


    The lifetime of dockable nodes associated with a MDI child frame can be shorter than that of your mainframe. By default, enabling a MDI childframe for docking using the procedure outlined above allows any dockable node on the mainframe to be docked to that MDI child, and vice versa. In addition, the MDI child nodes can be docked to other MDI child nodes. As a result, when the MDI child is closed, all contained nodes, regardless of their original parent, are destroyed as well. Avoid accessing node pointers that were destroyed with the destruction of a MDI childframe.

  2. If you want to limit the docking of a MDI child exclusively to that child, you must call EnableDocking() with the third parameter set to TRUE. For example:

The third parameter signals to the docking feature that all nodes initialized for that frame can only dock to that frame and no other. In addition, dockable nodes created for other frames do not participate with that MDI child in the docking operation (for example, you cannot dock a node from the mainframe to that child frame, or vice versa). This is similar to how MFC's controlbar architecture works.

For more information on defining a docking participant subset, please refer to Objective Toolkit Class Reference for SECFrameDockingFeature::EnableDocking().

The following figure illustrates an MDI childframe with docking windows. The same core docking logic is leveraged in both the mainframe and childframe.

Figure 150: Sample demonstrating an MDI childframe with docking windows



Previous fileTop of DocumentContentsNo linkNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.