home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / cmd / winfe / navfram.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  34.0 KB  |  1,152 lines

  1. /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  2.  *
  3.  * The contents of this file are subject to the Netscape Public License
  4.  * Version 1.0 (the "NPL"); you may not use this file except in
  5.  * compliance with the NPL.  You may obtain a copy of the NPL at
  6.  * http://www.mozilla.org/NPL/
  7.  *
  8.  * Software distributed under the NPL is distributed on an "AS IS" basis,
  9.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
  10.  * for the specific language governing rights and limitations under the
  11.  * NPL.
  12.  *
  13.  * The Initial Developer of this code under the NPL is Netscape
  14.  * Communications Corporation.  Portions created by Netscape are
  15.  * Copyright (C) 1998 Netscape Communications Corporation.  All Rights
  16.  * Reserved.
  17.  */
  18.  
  19. // navfram.cpp : implementation of the CNSNavFrame class
  20. //
  21.  
  22. #include "stdafx.h"
  23.  
  24. #include "navfram.h"
  25. #include "feimage.h"
  26. #include "cxicon.h"
  27. #include "prefapi.h"
  28. #include "xp_ncent.h"
  29. #include "navbar.h"
  30.  
  31. #ifdef _DEBUG
  32. #define new DEBUG_NEW
  33. #undef THIS_FILE
  34. static char THIS_FILE[] = __FILE__;
  35. #endif
  36.  
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CNSNavFrame
  40.  
  41. #ifndef _AFXDLL
  42. #undef new
  43. #endif
  44. IMPLEMENT_DYNCREATE(CNSNavFrame, CFrameWnd)
  45. #ifndef _AFXDLL
  46. #define new DEBUG_NEW
  47. #endif
  48.  
  49. BEGIN_MESSAGE_MAP(CNSNavFrame, CFrameWnd)
  50.     //{{AFX_MSG_MAP(CNSNavFrame)
  51.         // NOTE - the ClassWizard will add and remove mapping macros here.
  52.         //    DO NOT EDIT what you see in these blocks of generated code !
  53.     ON_WM_CREATE()
  54.     ON_WM_SIZE()
  55.     ON_WM_NCLBUTTONDOWN()
  56.     ON_WM_MOUSEMOVE()
  57.     ON_WM_LBUTTONUP()
  58.     ON_MESSAGE(WM_SIZEPARENT, OnSizeParent)
  59.     ON_WM_CLOSE()
  60.     ON_WM_PAINT()
  61.     //}}AFX_MSG_MAP
  62. END_MESSAGE_MAP()
  63. #define MFS_MOVEFRAME       0x00000800L // no sizing, just moving
  64. #define MFS_SYNCACTIVE      0x00000100L // synchronize activation w/ parent
  65. #define MFS_4THICKFRAME     0x00000200L // thick frame all around (no tiles)
  66. #define MFS_THICKFRAME      0x00000400L // use instead of WS_THICKFRAME
  67. #define MFS_MOVEFRAME       0x00000800L // no sizing, just moving
  68. #define MFS_BLOCKSYSMENU    0x00001000L // block hit testing on system menu
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // CNSNavFrame construction/destruction
  72.  
  73. CNSNavFrame::CNSNavFrame()
  74. {
  75.     m_pSelector = 0;
  76.     m_nsContent= 0;
  77.     m_bDragging = FALSE;
  78.     m_DragWnd = 0;
  79. }
  80.  
  81. CNSNavFrame::~CNSNavFrame()
  82. {
  83.     if (m_dwOverDockStyle != DOCKSTYLE_FLOATING)
  84.     {
  85.         PREF_SetIntPref(gPrefDockPercentage, m_DockSize);
  86.         PREF_SetIntPref(gPrefDockOrientation, m_dwOverDockStyle);
  87.     }
  88.     else
  89.     {
  90.         PREF_SetRectPref(gPrefFloatRect, (int16)m_rectFloat.left, (int16)m_rectFloat.top, (int16)m_rectFloat.right, (int16)m_rectFloat.bottom);
  91.     }
  92. }
  93.  
  94. void CNSNavFrame::UpdateTitleBar(HT_View pView)
  95. {
  96.     CString title("Navigation Center [");
  97.     title += HT_GetNodeName(HT_TopNode(pView));
  98.     title += "]";
  99.  
  100.     SetWindowText(title);
  101. }
  102.  
  103. void CNSNavFrame::OnClose( )
  104. {
  105.     CFrameWnd::OnClose();
  106. }
  107.  
  108.  
  109. int CNSNavFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  110. {
  111. #ifdef XP_WIN32
  112.     SetClassLong(GetSafeHwnd(), GCL_HICON,     (long)LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(2)));
  113. #else
  114.     SetClassWord(GetSafeHwnd(), GCW_HICON,     (WORD)LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(2)));
  115. #endif
  116.     LONG style =  ::GetWindowLong(GetSafeHwnd(), GWL_STYLE);
  117.     ::SetWindowLong(GetSafeHwnd(), GWL_STYLE,  style | WS_CLIPCHILDREN);
  118. #ifdef XP_WIN32
  119.     ::SetClassLong(GetSafeHwnd(), GCL_HBRBACKGROUND, (COLOR_BTNFACE + 1));
  120. #else
  121.     ::SetClassWord(GetSafeHwnd(), GCW_HBRBACKGROUND, (COLOR_BTNFACE + 1));
  122. #endif
  123.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  124.         return -1;
  125.     return 0;
  126. }
  127.  
  128. //------------------------------------------------------------------------
  129. // void CNSNavFrame::CreateNewNavCenter() 
  130. // Create a New NavCenter and Show it.
  131. //------------------------------------------------------------------------
  132. void CNSNavFrame::CreateNewNavCenter(CNSGenFrame* pParentFrame, BOOL useViewType, HT_ViewType viewType) 
  133. {
  134. // Read in our float rect pref.
  135.     int16 left,right,top, bottom;
  136.     PREF_GetRectPref(gPrefFloatRect,&left, &top, &right, &bottom);
  137.  
  138. // Create the window there.
  139.     m_rectFloat.SetRect(left, top, right, bottom);
  140.     m_rectDrag = m_rectFloat;
  141.  
  142.     CString title = "Navigation Center";
  143.     Create( NULL, title, WS_OVERLAPPEDWINDOW, m_rectFloat, NULL);
  144.  
  145. // Hide initially.
  146.     ShowWindow(SW_HIDE);
  147.     
  148. // Determine the pixels we should consume if docked
  149.     int32 width;
  150.     PREF_GetIntPref(gPrefDockPercentage, &width);
  151.     m_DockSize = (int)width;
  152.     
  153. // Read in our dockstyle
  154.     PREF_GetIntPref(gPrefDockOrientation, &m_dwOverDockStyle);
  155.  
  156. // Find out if a view should be displayed
  157.     
  158.     if (pParentFrame != NULL)
  159.     {    
  160.         // create a docked window
  161.         DockFrame(pParentFrame, m_dwOverDockStyle);
  162.     }
  163.     else 
  164.     {
  165.         // Create a floating window
  166.         m_dwOverDockStyle = DOCKSTYLE_FLOATING;
  167.     }
  168.  
  169. // Put the selector buttons into the pane.
  170.     m_pSelector->PopulatePane();
  171.  
  172. // Show the window.
  173.     ShowWindow(SW_SHOW);
  174.  
  175.     theApp.m_pRDFCX->TrackRDFWindow(this);
  176.  
  177.     if (useViewType)
  178.         HT_SetSelectedView(GetHTPane(), HT_GetViewType(GetHTPane(), viewType));
  179. }
  180.  
  181. void CNSNavFrame::DeleteNavCenter()
  182. {
  183.     CFrameWnd *pLayout = GetParentFrame();
  184.     
  185.     ShowWindow(SW_HIDE);
  186.     SetParent(NULL);
  187.     
  188.     // Tell ParentFrame that we are not docked anymore.
  189.     pLayout->RecalcLayout();
  190.  
  191.     if (m_DragWnd)
  192.         m_DragWnd->DestroyWindow();
  193.  
  194.     DestroyWindow();
  195. }
  196.  
  197. BOOL CNSNavFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
  198. {
  199.     m_pSelector = new CSelector();
  200.     m_nsContent = new CContentView();
  201.     m_pNavMenu = new CNavMenuBar();
  202.  
  203.     CRect  rect1;
  204.     rect1.left = rect1.top = 0;
  205.     rect1.right =  MIN_CATEGORY_WIDTH;
  206.     rect1.bottom = 1;
  207.     m_pSelector->Create( NULL, "", WS_CHILD | WS_VISIBLE, rect1, 
  208.         this, NC_IDW_SELECTOR, pContext );
  209.  
  210.     rect1.right = rect1.bottom = 1;
  211.     m_pNavMenu->Create(NULL, "", WS_CHILD | WS_VISIBLE, rect1, this, NC_IDW_NAVMENU, pContext);
  212.  
  213.     m_nsContent->Create( NULL, "", WS_CHILD | WS_VISIBLE, rect1, 
  214.         this, NC_IDW_MISCVIEW, pContext );
  215.  
  216.     return TRUE;
  217. }
  218.  
  219. void CNSNavFrame::OnSize( UINT nType, int cx, int cy )
  220. {
  221.     if(GetHTPane() && !XP_IsNavCenterDocked(GetHTPane())) 
  222.     {
  223.         // Make sure our float rect always matches our size when floating.
  224.         GetWindowRect(&m_rectFloat);
  225.     }
  226.     else
  227.     {
  228.         // Recompute our docked percentage if the tree is visible
  229.         CRect rect;
  230.         GetClientRect(&rect);
  231.         if (IsTreeVisible())
  232.         {
  233.             CalcClientArea(&m_parentRect);
  234.             if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT || m_dwOverDockStyle == DOCKSTYLE_VERTRIGHT)
  235.                 m_DockWidth = m_DockSize = rect.Width();
  236.             else m_DockHeight = m_DockSize = rect.Height();
  237.         }
  238.     }
  239.  
  240.     int top = 0;
  241.     if (m_dwOverDockStyle == DOCKSTYLE_FLOATING || m_dwOverDockStyle == DOCKSTYLE_VERTLEFT ||
  242.         m_dwOverDockStyle == DOCKSTYLE_VERTRIGHT) 
  243.     {
  244.         CRect tempRect;
  245.         // We want to handle the redraw ourself to reduce the flickering.  
  246.         m_pSelector->GetClientRect(&tempRect);
  247.         m_pSelector->MapWindowPoints( this, &tempRect);
  248.         m_pSelector->SetWindowPos( NULL, 0, top, MIN_CATEGORY_WIDTH, cy - STARTY - top, SWP_NOREPOSITION  | SWP_NOREDRAW);
  249.         if ((tempRect.Height()) < cy - STARTY) 
  250.         {
  251.             int orgHeight = tempRect.Height();
  252.             tempRect.top = tempRect.bottom;
  253.             tempRect.bottom =  tempRect.top + (cy - orgHeight);
  254.             MapWindowPoints(m_pSelector, &tempRect);
  255.             m_pSelector->InvalidateRect( &tempRect, TRUE);
  256.         }
  257.  
  258.         if (m_dwOverDockStyle == DOCKSTYLE_FLOATING)
  259.         {
  260.             m_pNavMenu->ShowWindow(SW_HIDE);
  261.             m_nsContent->SetWindowPos(NULL, MIN_CATEGORY_WIDTH+2, top, cx-MIN_CATEGORY_WIDTH-2, cy - STARTY - top, 0);
  262.         }
  263.         else
  264.         {
  265.             m_pNavMenu->ShowWindow(SW_SHOW);
  266.             m_pNavMenu->SetWindowPos(NULL, MIN_CATEGORY_WIDTH+2, top, cx - MIN_CATEGORY_WIDTH, NAVBAR_HEIGHT, SWP_NOREPOSITION);
  267.             m_nsContent->SetWindowPos( NULL, MIN_CATEGORY_WIDTH+2, top+NAVBAR_HEIGHT, cx - MIN_CATEGORY_WIDTH - 2, cy - STARTY - top - NAVBAR_HEIGHT, 0);
  268.         }
  269.     }
  270.     else 
  271.     {  //dock horiz.
  272.         CRect tempRect;
  273.         m_pSelector->GetClientRect(&tempRect);
  274.         m_pSelector->MapWindowPoints( this, &tempRect);
  275.         m_pSelector->SetWindowPos( NULL, STARTX, top, cx - STARTX, MIN_CATEGORY_HEIGHT, SWP_NOREPOSITION  | SWP_NOREDRAW);
  276.         if ((tempRect.Width()) < cx - STARTX) {
  277.             int orgWidth = tempRect.Width();
  278.             tempRect.right = tempRect.left;
  279.             tempRect.right =  tempRect.left + (cx - orgWidth);
  280.             MapWindowPoints(m_pSelector, &tempRect);
  281.             m_pSelector->InvalidateRect( &tempRect, FALSE);
  282.         }
  283.         m_nsContent->SetWindowPos( NULL, STARTX, MIN_CATEGORY_HEIGHT + 2 ,
  284.                         cx - STARTX, cy - MIN_CATEGORY_HEIGHT, SWP_NOREPOSITION | SWP_NOREDRAW);
  285.     }
  286.     ShowWindow(SW_SHOW);
  287.     if (m_DragWnd)
  288.         m_DragWnd->ShowWindow(SW_SHOW);
  289. }
  290.  
  291. BOOL CNSNavFrame::PreCreateWindow(CREATESTRUCT & cs)
  292. {
  293.  
  294.     cs.lpszClass = AfxRegisterWndClass( CS_DBLCLKS,
  295.                     theApp.LoadStandardCursor(IDC_ARROW), 
  296.                     (HBRUSH)(COLOR_BTNFACE + 1));
  297.     return (CFrameWnd::PreCreateWindow(cs));
  298. }
  299.  
  300. //------------------------------------------------------------------------------
  301. // void CNSNavFrame::StartDrag(CPoint pt)
  302. //    
  303. //------------------------------------------------------------------------------
  304.  
  305. void CNSNavFrame::StartDrag(CPoint pt, BOOL mapDesktop)
  306. {
  307.     GetWindowRect(&m_dockingDragRect);
  308.     CPoint cursorPt(pt);
  309.  
  310.     if (mapDesktop)
  311.         MapWindowPoints(NULL, &cursorPt, 1);    // Convert the point to screen coords.
  312.     
  313.     if (XP_IsNavCenterDocked(GetHTPane())) 
  314.     {
  315.         ForceFloat(FALSE);        
  316.     }
  317.     else ShowWindow(SW_HIDE);
  318.  
  319.     m_bDragging = TRUE;
  320.     InitLoop();
  321.     
  322.     m_rectDrag = m_rectFloat;
  323.   
  324.     CNSGenFrame* pFrame = NULL;
  325.     CFrameGlue *pGlue = CFrameGlue::GetLastActiveFrame(MWContextBrowser);
  326.     CFrameWnd *pBaseWnd = pGlue->GetFrameWnd();
  327.     if(pBaseWnd && pBaseWnd->IsKindOf(RUNTIME_CLASS(CNSGenFrame))) 
  328.     {
  329.        pFrame = (CNSGenFrame *)pBaseWnd;
  330.     }
  331.     CalcClientArea(&m_parentRect, pFrame);
  332.     pFrame->MapWindowPoints( NULL, &m_parentRect);
  333.  
  334.     // Cache the offset that we wish to preserve.
  335.     m_nXOffset = cursorPt.x - m_dockingDragRect.left;
  336.     m_nYOffset = cursorPt.y - m_dockingDragRect.top;
  337.  
  338.     // Compute the pixel sizes of vertically and horizontally docked windows
  339.     ComputeDockingSizes();
  340.  
  341.     // initialize tracking state and enter tracking loop
  342.     Move(cursorPt);   // call it here to handle special keys
  343.     Track();
  344. }
  345.  
  346. //------------------------------------------------------------------------------
  347. //  void CNSNavFrame::Move(CPoint pt)       
  348. //     called when we get WM_MOUSEMOVE message.
  349. //------------------------------------------------------------------------------
  350.  
  351. void CNSNavFrame::Move(CPoint pt)       // called when mouse has moved
  352. {
  353.     short dwOverDockStyle = CanDock(pt);
  354.     m_dockingDragRect =  m_parentRect;
  355.         
  356.     if (dwOverDockStyle == DOCKSTYLE_VERTLEFT ||
  357.         dwOverDockStyle == DOCKSTYLE_VERTRIGHT)
  358.     {
  359.         int height = m_dockingDragRect.Height();
  360.         m_dockingDragRect.right = m_dockingDragRect.left + m_DockWidth;
  361.         int yOffset = m_nYOffset;
  362.         if (yOffset > height)
  363.             yOffset = height;
  364.         m_dockingDragRect.top = pt.y - yOffset;
  365.         m_dockingDragRect.bottom = m_dockingDragRect.top + height;
  366.     }
  367.     else if (dwOverDockStyle == DOCKSTYLE_HORZTOP ||
  368.              dwOverDockStyle == DOCKSTYLE_HORZBOTTOM) 
  369.     {
  370.         m_dockingDragRect.top = pt.y - (int)m_DockHeight;
  371.         m_dockingDragRect.bottom = m_dockingDragRect.top + m_DockHeight;
  372.     }
  373.     else 
  374.     {
  375.         int height = m_rectDrag.Height();
  376.         int width = m_rectDrag.Width();
  377.         int xOffset = m_nXOffset;
  378.         int yOffset = m_nYOffset;
  379.         if (xOffset > width)
  380.             xOffset = width;
  381.         if (yOffset > height)
  382.             yOffset = height;
  383.  
  384.         m_rectDrag.left = pt.x - m_nXOffset;
  385.         m_rectDrag.top = pt.y - m_nYOffset;
  386.         m_rectDrag.bottom = m_rectDrag.top + height;
  387.         m_rectDrag.right = m_rectDrag.left + width;
  388.     }
  389.     
  390.     DrawFocusRect(dwOverDockStyle);
  391. }
  392.  
  393. //------------------------------------------------------------------------------
  394. //    static BOOL nsModifyStyle(HWND hWnd, int nStyleOffset,
  395. //        DWORD dwRemove, DWORD dwAdd, UINT nFlags)
  396. //------------------------------------------------------------------------------
  397.  
  398. BOOL nsModifyStyle(HWND hWnd, int nStyleOffset, DWORD dwRemove, DWORD dwAdd, UINT nFlags)
  399. {
  400.     ASSERT(hWnd != NULL);
  401.     DWORD dwStyle = ::GetWindowLong(hWnd, nStyleOffset);
  402.     DWORD dwNewStyle;
  403.     if (dwRemove != NULL)
  404.         dwNewStyle = dwStyle & ~dwRemove;
  405.     if (dwAdd != NULL)
  406.         dwNewStyle = dwNewStyle | dwAdd;
  407.     if (dwStyle == dwNewStyle)
  408.         return FALSE;
  409.  
  410.     ::SetWindowLong(hWnd, nStyleOffset, dwNewStyle);
  411.     if (nFlags != 0)
  412.     {
  413.         ::SetWindowPos(hWnd, NULL, 0, 0, 0, 0,
  414.             SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE | nFlags);
  415.     }
  416.     return TRUE;
  417. }
  418.  
  419.  
  420. //------------------------------------------------------------------------------
  421. //    void CNSNavFrame::CalcClientArea(RECT* lpRectClient)
  422. //  
  423. //    The function will return the the client area of CMainFrame minus any of the spaces
  424. //  occupied by the tool bar.
  425. //------------------------------------------------------------------------------
  426.  
  427. void CNSNavFrame::CalcClientArea(RECT* lpRectClient, CNSGenFrame * pParentFrame)
  428. {
  429.  
  430.     AFX_SIZEPARENTPARAMS layout;
  431.     HWND hWndLeftOver = NULL;
  432. #ifdef XP_WIN32
  433.     layout.bStretch = FALSE;
  434.     layout.sizeTotal.cx = layout.sizeTotal.cy = 0;
  435. #endif
  436.     CNSGenFrame* pFrame = NULL;
  437.     if (pParentFrame == NULL) {
  438.         CFrameGlue *pGlue = CFrameGlue::GetLastActiveFrame(MWContextBrowser);
  439.         CFrameWnd *pBaseWnd = pGlue->GetFrameWnd();
  440.         if(pBaseWnd && pBaseWnd->IsKindOf(RUNTIME_CLASS(CNSGenFrame))) {
  441.             pFrame = (CNSGenFrame *)pBaseWnd;
  442.         }
  443.     }
  444.     else {
  445.         pFrame = pParentFrame;
  446.     }
  447.     CNSNavFrame* pDockedFrame = pFrame->GetDockedNavCenter();
  448.     pFrame->GetClientRect(&layout.rect);    // starting rect comes from client rect
  449.     CWnd *pView = pFrame->GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE);
  450.     HWND hWnd = pView->GetSafeHwnd();
  451.     layout.hDWP = NULL; // not actually doing layout
  452.  
  453.     for (HWND hWndChild = ::GetTopWindow(pFrame->GetSafeHwnd()); hWndChild != NULL;
  454.         hWndChild = ::GetNextWindow(hWndChild, GW_HWNDNEXT))
  455.     {
  456.         if (hWndChild != hWnd && hWndChild != GetSafeHwnd() && hWndChild != pDockedFrame->GetSafeHwnd())
  457.             ::SendMessage(hWndChild, WM_SIZEPARENT, 0, (LPARAM)&layout);
  458.     }
  459.     lpRectClient->left = layout.rect.left;
  460.     lpRectClient->right = layout.rect.right;
  461.     lpRectClient->top = layout.rect.top;
  462.     lpRectClient->bottom = layout.rect.bottom;
  463. }
  464.  
  465.  
  466. //------------------------------------------------------------------------------
  467. // void CNSNavFrame::ForceFloat()
  468. // Force this frame to be a floated frame.
  469. //------------------------------------------------------------------------------
  470. void CNSNavFrame::ForceFloat(BOOL show)
  471. {
  472.     CFrameWnd *pLayout = GetParentFrame();
  473.     
  474.     nsModifyStyle( GetSafeHwnd(), GWL_STYLE, WS_CHILD, WS_OVERLAPPEDWINDOW);
  475.         
  476.     if (show)
  477.     {    
  478.         MoveWindow( m_rectDrag);
  479.     }
  480.     else ShowWindow(SW_HIDE);
  481.  
  482.     SetParent(NULL);
  483.     m_DragWnd->DestroyWindow();
  484.     m_DragWnd = NULL;
  485.  
  486.     m_dwOverDockStyle = DOCKSTYLE_FLOATING;
  487.     
  488.     if (show)
  489.         ShowWindow(SW_SHOW);
  490.     else ShowWindow(SW_HIDE);
  491.  
  492.     //  Tell XP NavCenter layer that we are no longer docked.
  493.     XP_UndockNavCenter(GetHTPane());
  494.     
  495.     // Tell ParentFrame that we are not docked anymore.
  496.     pLayout->RecalcLayout();
  497.  
  498.     // Select a new view if we were formerly collapsed.
  499.     if (m_pSelector->GetCurrentButton() == NULL)
  500.         m_pSelector->SelectNthView(0);
  501.  
  502.     if (show)
  503.     {
  504.         m_nsContent->ShowWindow(SW_SHOW);
  505.         m_nsContent->CalcChildSizes();
  506.     }
  507. }
  508.  
  509. void CNSNavFrame::ComputeDockingSizes()
  510. {
  511.     if (IsTreeVisible())
  512.     {
  513.         m_DockWidth = m_DockSize + 1;  // Not sure what the error is here yet.
  514.         m_DockHeight = m_DockSize + 1;
  515.     }
  516.     else
  517.     {
  518.  
  519.         m_DockWidth = MIN_CATEGORY_WIDTH + DRAGWIDTH;
  520.         m_DockHeight = MIN_CATEGORY_HEIGHT + DRAGWIDTH;
  521.     }
  522. }
  523.  
  524.  
  525. void CNSNavFrame::DockFrame(CNSGenFrame* pParent, short dockStyle)
  526. {
  527.         CWnd *pView = pParent->GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE);
  528.         CalcClientArea(&m_parentRect, pParent);
  529.         ComputeDockingSizes();
  530.  
  531.         if (GetHTPane() == NULL || XP_IsNavCenterDocked(GetHTPane()) == FALSE) 
  532.         { 
  533.             CNSNavFrame* pFrame = pParent->GetDockedNavCenter();
  534.             if (pFrame)    
  535.             { // if the parent frame has a docked frame, tell this frame to float.
  536.                 pFrame->DeleteNavCenter();
  537.             }
  538.             nsModifyStyle( GetSafeHwnd(), GWL_STYLE, WS_OVERLAPPEDWINDOW , WS_CHILD);
  539.             SetParent(pParent);
  540.  
  541.             //  Tell XP layer that we are now docked.
  542.             if(GetTopLevelFrame()) 
  543.             {
  544.                 CFrameGlue *pGlue = CFrameGlue::GetFrameGlue(GetTopLevelFrame());
  545.                 if(pGlue && pGlue->GetMainContext()) {
  546.                     XP_DockNavCenter(GetHTPane(), pGlue->GetMainContext()->GetContext());
  547.             }
  548.         }
  549.         
  550.         CRect rect = m_dockingDragRect;
  551.  
  552.         // Hide the window before we move it.
  553.         m_dwOverDockStyle = dockStyle;
  554.         if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT || m_dwOverDockStyle == DOCKSTYLE_VERTRIGHT) 
  555.         {
  556.             GetDesktopWindow()->MapWindowPoints( pView, &rect ); 
  557.             
  558.             // snap to right, when the drag rect is closer to the right edge.
  559.             if (rect.right > ((m_parentRect.right - m_parentRect.left) / 2)) 
  560.             {
  561.                 rect.right = m_parentRect.right;
  562.                 rect.left = rect.right - m_DockWidth;
  563.             }
  564.             else { // otherwise snap to the left.
  565.                 rect.left = m_parentRect.left;
  566.                 rect.right = rect.left + m_DockWidth;
  567.             }
  568.             rect.top = m_parentRect.top;
  569.             rect.bottom = m_parentRect.bottom;
  570.         }
  571.         else 
  572.         {
  573.             GetDesktopWindow()->MapWindowPoints( pView, &rect ); 
  574.             // snap to bottom, when the drag rect is closer to the bottom edge.
  575.             if (rect.bottom > ((m_parentRect.bottom - m_parentRect.top) / 2)) 
  576.             {
  577.                 rect.bottom = m_parentRect.bottom;
  578.                 rect.top = rect.bottom - m_DockHeight;
  579.             }
  580.             else { // otherwise snap to the left.
  581.                 rect.top = m_parentRect.top;
  582.                 rect.bottom = rect.top + m_DockHeight;
  583.             }
  584.             rect.left = m_parentRect.left;
  585.             rect.right = m_parentRect.right;
  586.         }
  587.  
  588.         // Now move the window to the correct location.
  589.         ShowWindow(SW_HIDE);
  590.         SetWindowPos( &wndBottom, rect.left, rect.top, rect.right - rect.left, 
  591.                                 rect.bottom - rect.top,0 );
  592.         
  593.         // Figure out the correct location to display the resize bar.
  594.         CRect dragBarRect(rect);
  595.         if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT) {
  596.             dragBarRect.left = rect.right;
  597.             dragBarRect.right = dragBarRect.left+ DRAGWIDTH;
  598.         }
  599.         else if (m_dwOverDockStyle == DOCKSTYLE_VERTRIGHT) {
  600.             dragBarRect.right = rect.left;
  601.             dragBarRect.left = dragBarRect.right - DRAGWIDTH;
  602.         }
  603.         else if (m_dwOverDockStyle == DOCKSTYLE_HORZTOP) {
  604.             dragBarRect.top = rect.bottom;
  605.             dragBarRect.bottom = dragBarRect.top + DRAGWIDTH;
  606.         }
  607.         else if (m_dwOverDockStyle == DOCKSTYLE_HORZBOTTOM) {
  608.             dragBarRect.bottom = rect.top;
  609.             dragBarRect.top = dragBarRect.bottom - DRAGWIDTH;
  610.         }
  611.         if (!m_DragWnd) {
  612.             m_DragWnd = new CDragBar(dragBarRect, this);
  613. #ifdef XP_WIN32
  614.             m_DragWnd->CreateEx(0, NULL, "GridEdge", WS_CHILD | WS_VISIBLE, 
  615.                      dragBarRect.left, dragBarRect.top, 
  616.                      dragBarRect.right - dragBarRect.left,
  617.                      dragBarRect.bottom - dragBarRect.top, 
  618.                      GetParentFrame()->GetSafeHwnd(), (HMENU)NC_IDW_DRAGEDGE, NULL);
  619. #else
  620.             m_DragWnd->Create(0, "GridEdge", WS_CHILD | WS_VISIBLE, 
  621.                      dragBarRect, 
  622.                      GetParentFrame(), NC_IDW_DRAGEDGE);
  623. #endif
  624.         }
  625.         // If we are not yet docked
  626.         m_DragWnd->SetOrientation(m_dwOverDockStyle);
  627.         m_DragWnd->SetParentFrame(GetParentFrame());
  628.         m_DragWnd->SetRect(dragBarRect); 
  629.         m_DragWnd->SetParent(GetParentFrame());
  630.  
  631.         m_DragWnd->ShowWindow(SW_SHOW);
  632.         ShowWindow(SW_SHOW);
  633.     }
  634.     
  635.     //  Have our frame parent recalc.
  636.     GetParentFrame()->RecalcLayout();
  637. }
  638. //------------------------------------------------------------------------------
  639. //    void CNSNavFrame::EndDrag(CPoint pt)             // drop
  640. //  
  641. //------------------------------------------------------------------------------
  642. void CNSNavFrame::EndDrag(CPoint pt)             // drop
  643. {
  644.     short dwOverDockStyle = CanDock(pt);
  645.     CancelLoop(dwOverDockStyle);
  646.     CRect rect;
  647.     CRect parentRect;
  648.  
  649.     if (dwOverDockStyle == DOCKSTYLE_VERTLEFT || dwOverDockStyle == DOCKSTYLE_VERTRIGHT ||
  650.         dwOverDockStyle == DOCKSTYLE_HORZTOP || dwOverDockStyle == DOCKSTYLE_HORZBOTTOM) 
  651.     {
  652.         CNSGenFrame* pFrame = NULL;
  653.         CFrameGlue *pGlue = CFrameGlue::GetLastActiveFrame(MWContextBrowser);
  654.         CFrameWnd *pBaseWnd = pGlue->GetFrameWnd();
  655.         if(pBaseWnd && pBaseWnd->IsKindOf(RUNTIME_CLASS(CNSGenFrame))) 
  656.         {
  657.             pFrame = (CNSGenFrame *)pBaseWnd;
  658.         }
  659.         DockFrame(pFrame, dwOverDockStyle);
  660.         m_nsContent->CalcChildSizes();
  661.     }
  662.     else 
  663.     {
  664.         // Float this frame.
  665.         MoveWindow( m_rectDrag);
  666.         m_nsContent->CalcChildSizes();
  667.     }
  668.  
  669.     ShowWindow(SW_SHOW);
  670. }
  671.  
  672.  
  673. void CNSNavFrame::InitLoop()
  674. {
  675.     // handle pending WM_PAINT messages
  676.     MSG msg;
  677.     while (::PeekMessage(&msg, NULL, WM_PAINT, WM_PAINT, PM_NOREMOVE))
  678.     {
  679.         if (!GetMessage(&msg, NULL, WM_PAINT, WM_PAINT))
  680.             return;
  681.         DispatchMessage(&msg);
  682.     }
  683.  
  684.  
  685.     // initialize state
  686.     m_rectLast.SetRectEmpty();
  687.     m_sizeLast.cx = m_sizeLast.cy = 0;
  688.     m_bDitherLast = FALSE;
  689.     CWnd* pWnd = CWnd::GetDesktopWindow();
  690.     if (pWnd->LockWindowUpdate())
  691.         m_pDC = pWnd->GetDCEx(NULL, DCX_WINDOW|DCX_CACHE|DCX_LOCKWINDOWUPDATE);
  692.     else
  693.         m_pDC = pWnd->GetDCEx(NULL, DCX_WINDOW|DCX_CACHE);
  694.     ASSERT(m_pDC != NULL);
  695. }
  696.  
  697.  
  698. void CNSNavFrame::CancelLoop(short dwDockStyle)
  699. {
  700.     DrawFocusRect(dwDockStyle, TRUE);    // gets rid of focus rect
  701.     ReleaseCapture();
  702.  
  703.     CWnd* pWnd = CWnd::GetDesktopWindow();
  704. #ifdef XP_WIN32
  705.     pWnd->UnlockWindowUpdate();
  706. #else
  707.     ASSERT(::IsWindow(m_hWnd));
  708.     ::LockWindowUpdate(NULL); 
  709. #endif
  710.     if (m_pDC != NULL)
  711.     {
  712.         pWnd->ReleaseDC(m_pDC);
  713.         m_pDC = NULL;
  714.     }
  715. }
  716.  
  717.  
  718. //---------------------------------------------------------------------------------
  719. //  void CNSNavFrame::DrawFocusRect(BOOL bRemoveRect)
  720. //
  721. //  Draw ghost selector rect.
  722. //---------------------------------------------------------------------------------
  723. void CNSNavFrame::DrawFocusRect(short dwOverDockStyle, BOOL bRemoveRect)
  724. {
  725.     ASSERT(m_pDC != NULL);
  726.  
  727.     // default to thin frame
  728.     CSize size(CX_BORDER, CY_BORDER);
  729.  
  730.     // determine new rect and size
  731.     CRect rect;
  732.     CBrush* pWhiteBrush = CBrush::FromHandle((HBRUSH)::GetStockObject(WHITE_BRUSH));
  733.     CBrush* pBrush = pWhiteBrush;
  734.     if (dwOverDockStyle == DOCKSTYLE_HORZTOP || dwOverDockStyle == DOCKSTYLE_HORZBOTTOM)    {
  735.         rect = m_dockingDragRect;
  736.     }
  737.     else if (dwOverDockStyle == DOCKSTYLE_VERTLEFT || dwOverDockStyle == DOCKSTYLE_VERTRIGHT) {
  738.         rect = m_dockingDragRect;
  739.     }
  740.     else {
  741.         rect = m_rectDrag;
  742.     }
  743.     if (bRemoveRect)
  744.         size.cx = size.cy = 0;
  745.  
  746. #ifdef XP_WIN32
  747.     CBrush* pDitherBrush = CDC::GetHalftoneBrush();
  748. #else
  749.     CBrush* pDitherBrush =  CBrush::FromHandle((HBRUSH)::GetStockObject(GRAY_BRUSH));
  750. #endif
  751.  
  752.     // draw it and remember last size
  753.     WFE_DrawDragRect(m_pDC, &rect, size, &m_rectLast, m_sizeLast,
  754.         pBrush, m_bDitherLast ? pDitherBrush : pWhiteBrush);
  755.     m_bDitherLast = (pBrush == pDitherBrush);
  756.     m_rectLast = rect;
  757.     m_sizeLast = size;
  758. }
  759.  
  760.  
  761. //---------------------------------------------------------------------------------
  762. //  short CNSNavFrame::CanDock(CPoint pt)
  763. //  Check whether we can dock to this frame.  If we can, return the dock orientation.
  764. //---------------------------------------------------------------------------------
  765. short CNSNavFrame::CanDock(CPoint pt, BOOL mapDesktop)
  766. {
  767.     short dockStyle = DOCKSTYLE_FLOATING;
  768.  
  769.     CNSGenFrame* pFrame = NULL;
  770.     CFrameGlue *pGlue = CFrameGlue::GetLastActiveFrame(MWContextBrowser);
  771.     CFrameWnd *pBaseWnd = pGlue->GetFrameWnd();
  772.     if(pBaseWnd && pBaseWnd->IsKindOf(RUNTIME_CLASS(CNSGenFrame))) {
  773.         pFrame = (CNSGenFrame *)pBaseWnd;
  774.     }
  775.  
  776.     if (mapDesktop) {
  777.  
  778.         CWnd *pView = pFrame->GetDescendantWindow(AFX_IDW_PANE_FIRST, TRUE);
  779.         if (XP_IsNavCenterDocked(GetHTPane()))    {
  780.             MapWindowPoints( pView, &pt, 1 );
  781.             pView->MapWindowPoints( GetDesktopWindow(), &pt, 1 );
  782.         }
  783.         else
  784.             MapWindowPoints( GetDesktopWindow(), &pt, 1 );
  785.     }
  786.  
  787.     // If the top most activated frame is not a Navigator window, do not dock.
  788.     if (pFrame->AllowDocking()) { 
  789.         if (m_parentRect.PtInRect(pt)) {
  790.             if ((pt.x < (m_parentRect.left +m_DockWidth)) &&
  791.                 pt.x > m_parentRect.left)
  792.                 dockStyle = DOCKSTYLE_VERTLEFT;
  793.         //    else if    (( pt.x > (m_parentRect.right - m_DockWidth)) &&
  794.         //        pt.x < m_parentRect.right)
  795.         //        dockStyle = DOCKSTYLE_VERTRIGHT;
  796.         //    else if ((pt.y < (m_parentRect.top +m_DockHeight)) &&
  797.         //         pt.y > m_parentRect.top)
  798.         //       dockStyle = DOCKSTYLE_HORZTOP;
  799.         //    else if    (( pt.y > (m_parentRect.bottom - m_DockHeight)) &&
  800.         //         pt.y < m_parentRect.bottom)
  801.         //       dockStyle = DOCKSTYLE_HORZBOTTOM;
  802.         }
  803.     }
  804.     else {
  805.         dockStyle = DOCKSTYLE_FLOATING;
  806.     }
  807.     
  808.     return dockStyle;
  809. }
  810.  
  811. //------------------------------------------------------------------------------
  812. // Track mouse movement after the LMouseDown.
  813. //------------------------------------------------------------------------------
  814.  
  815. BOOL CNSNavFrame::Track()
  816. {
  817.     // don't handle if capture already set
  818.     if (::GetCapture() != NULL)
  819.         return FALSE;
  820.  
  821.     // set capture to the window which received this message
  822.     SetCapture();
  823.  
  824.     // get messages until capture is lost or cancelled/accepted
  825.     while (CWnd::GetCapture() == this) {
  826.         MSG msg;
  827.         if (!::GetMessage(&msg, NULL, 0, 0))
  828.         {
  829. #ifdef XP_WIN32
  830.             AfxPostQuitMessage(msg.wParam);
  831. #endif
  832.             break;
  833.         }
  834.  
  835.         switch (msg.message)
  836.         {
  837.         case WM_LBUTTONUP:
  838.             if (m_bDragging)
  839.                 m_bDragging = FALSE;
  840.                 EndDrag(msg.pt);
  841.             return TRUE;
  842.         case WM_MOUSEMOVE:
  843.             if (m_bDragging)
  844.                 Move(msg.pt);
  845.             break;
  846.         // just dispatch rest of the messages
  847.         default:
  848.             DispatchMessage(&msg);
  849.             break;
  850.         }
  851.     }
  852.  
  853.     return FALSE;
  854. }
  855.  
  856.  
  857. //------------------------------------------------------------------------------
  858. // LRESULT CNSNavFrame::OnSizeParent(WPARAM, LPARAM lParam)
  859. //
  860. // This function will be called when the parent window calls recalcLayout().
  861. // It will subtract this window's client rect from lpLayout.  Parent uses this 
  862. // function to layout other window in the left over lpLayout.
  863. //
  864. //------------------------------------------------------------------------------
  865.  
  866. LRESULT CNSNavFrame::OnSizeParent(WPARAM, LPARAM lParam)
  867. {
  868.     AFX_SIZEPARENTPARAMS* lpLayout = (AFX_SIZEPARENTPARAMS*)lParam;
  869.  
  870.     // dragRect is in the parent window's coordinates(which is the main frame).
  871.     // the top and bottom coordinates of the dragRect should already be included
  872.     // in the toolbar.
  873.  
  874.     CRect oldRect;
  875.     GetWindowRect(&oldRect);
  876.     CRect resizeRect(lpLayout->rect);
  877.     CRect oldDragRect;
  878.     m_DragWnd->GetRect(oldDragRect);
  879.  
  880.     CRect dragRect(resizeRect);
  881.  
  882.     if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT) {
  883.         resizeRect.right = lpLayout->rect.left + oldRect.Width();
  884.         if (oldDragRect.left != resizeRect.right) // we move the drag bar.  Need to resize here.
  885.             resizeRect.right += oldDragRect.left - resizeRect.right;
  886.         dragRect.left = resizeRect.right;
  887.         dragRect.right = dragRect.left +  + DRAGWIDTH;
  888.         lpLayout->rect.left = resizeRect.right + DRAGWIDTH;
  889.         m_DragWnd->SetRect(dragRect);
  890.         m_DockWidth = resizeRect.Width();
  891.     }
  892.     else if (m_dwOverDockStyle == DOCKSTYLE_VERTRIGHT) {
  893.         resizeRect.left = lpLayout->rect.right - oldRect.Width();
  894.         if (oldDragRect.right != resizeRect.left) // we moved the drag bar.  Need to resize here.
  895.             resizeRect.left -= resizeRect.left - oldDragRect.right;
  896.         dragRect.right = resizeRect.left;
  897.         dragRect.left = dragRect.right - DRAGWIDTH;
  898.         lpLayout->rect.right = resizeRect.left - DRAGWIDTH;
  899.         m_DragWnd->SetRect(dragRect);
  900.         m_DockWidth = resizeRect.Width();
  901.     }
  902.     else if (m_dwOverDockStyle == DOCKSTYLE_HORZTOP) {
  903.         resizeRect.bottom = lpLayout->rect.top + oldRect.Height();
  904.         if (oldDragRect.top != resizeRect.bottom) // we moved the drag bar.  Need to resize here.
  905.             resizeRect.bottom += oldDragRect.top - resizeRect.bottom;
  906.         dragRect.top = resizeRect.bottom;
  907.         dragRect.bottom = dragRect.top + DRAGWIDTH;
  908.         lpLayout->rect.top = resizeRect.bottom + DRAGWIDTH;
  909.         m_DragWnd->SetRect(dragRect);
  910.         m_DockHeight = resizeRect.Height();
  911.     }
  912.     else if (m_dwOverDockStyle == DOCKSTYLE_HORZBOTTOM) {
  913.         resizeRect.top = lpLayout->rect.bottom - oldRect.Height();
  914.         if (oldDragRect.bottom != resizeRect.top) // we moved the drag bar.  Need to resize here.
  915.             resizeRect.top -= resizeRect.top - oldDragRect.bottom;
  916.         dragRect.bottom = resizeRect.top;
  917.         dragRect.top = dragRect.bottom - DRAGWIDTH;
  918.         lpLayout->rect.bottom = resizeRect.top - DRAGWIDTH;
  919.         m_DragWnd->SetRect(dragRect);
  920.         m_DockHeight = resizeRect.Height();
  921.     }
  922.     if (lpLayout->hDWP != NULL) {
  923.         // reposition our frame window.
  924.         SetWindowPos( &wndBottom, resizeRect.left, resizeRect.top, resizeRect.right - resizeRect.left, 
  925.                                 resizeRect.bottom - resizeRect.top, SWP_SHOWWINDOW );
  926.         m_dockingDragRect = resizeRect;
  927.         m_DragWnd->SetWindowPos( &wndBottom, dragRect.left, dragRect.top, dragRect.Width(), 
  928.                                 dragRect.Height(), SWP_SHOWWINDOW );
  929.  
  930.     }
  931.  
  932.     return 0;
  933. }
  934.  
  935. static void FillSolidRect(HDC hdc, RECT* rect, COLORREF clr)
  936. {
  937.     ::SetBkColor(hdc, clr);
  938.     ::ExtTextOut(hdc, 0, 0, ETO_OPAQUE, rect, NULL, 0, NULL);
  939. }
  940.  
  941.  
  942. //------------------------------------------------------------------------------
  943. // void CNSNavFrame::OnPaint( )
  944. //
  945. //    This function is used to paint the background on CNSNavFrame
  946. //------------------------------------------------------------------------------
  947.  
  948. void CNSNavFrame::OnPaint( )
  949. {
  950.     CRect rect;
  951.     GetClientRect(&rect);
  952.     CDC* pDC = GetDC();
  953.     HDC hdc = pDC->GetSafeHdc();
  954.     CRect rect1;
  955.     CRgn pRgn;
  956.     HBRUSH hBrush;
  957.  
  958.     HBRUSH hBr = ::CreateSolidBrush((COLORREF)GetSysColor(COLOR_3DSHADOW));
  959.     HPEN hPen = ::CreatePen(PS_SOLID, 1,(COLORREF)GetSysColor(COLOR_3DLIGHT)); 
  960.  
  961.     HPEN hOldPen;
  962.     hOldPen = (HPEN)::SelectObject(hdc, hPen);
  963.     if (m_dwOverDockStyle == DOCKSTYLE_FLOATING || 
  964.         m_dwOverDockStyle == DOCKSTYLE_VERTLEFT || 
  965.         m_dwOverDockStyle == DOCKSTYLE_VERTRIGHT) {
  966.  
  967.         // paint the div line between selector pane and content pane.
  968.         rect1 = rect;
  969.         rect1.left = rect.left + MIN_CATEGORY_WIDTH;
  970.         rect1.right = rect1.left + 2;
  971.         ::FillRect(hdc, &rect1, hBr);
  972.         ::SelectObject(pDC->GetSafeHdc(), (HPEN)::GetStockObject(WHITE_PEN));
  973.         ::MoveToEx(pDC->GetSafeHdc(), rect1.left+1, rect1.top, NULL);
  974.         ::LineTo(pDC->GetSafeHdc(), rect1.left+1, rect1.bottom);
  975.     }
  976.     else {
  977.  
  978.         // paint the div line between selector pane and content pane.
  979.         rect1 = rect;
  980.         rect1.top = rect.top + MIN_CATEGORY_HEIGHT;
  981.         rect1.bottom = rect1.top + 2;
  982.         ::FillRect(hdc, &rect1, hBr);
  983.         ::SelectObject(pDC->GetSafeHdc(), (HPEN)::GetStockObject(WHITE_PEN));
  984.         ::MoveToEx(pDC->GetSafeHdc(), rect1.left, rect1.top+1, NULL);
  985.         ::LineTo(pDC->GetSafeHdc(), rect1.right, rect1.top+1);
  986.     }
  987.     ::SelectObject(hdc, hOldPen);
  988.     ::DeleteObject(hPen);
  989.     ::DeleteObject(hBr);
  990.     ::DeleteObject(hBrush);
  991.     ReleaseDC(pDC);
  992.     CFrameWnd::OnPaint();
  993. }
  994.  
  995. void CNSNavFrame::CollapseWindow()
  996. {
  997.     if (m_dwOverDockStyle == DOCKSTYLE_FLOATING) {
  998.         // Handle floating window differently.  Floating window does not have
  999.         // m_DragWnd and m_pParent.
  1000.     }
  1001.     else 
  1002.     {    
  1003.         // Move m_DragWnd when we want to collapse docking window.
  1004.         CRect tempRect;
  1005.         GetWindowRect(&tempRect);;
  1006.         CRect dragBox;
  1007.         m_DragWnd->GetRect(dragBox);
  1008.     
  1009.         if (m_dwOverDockStyle == DOCKSTYLE_HORZTOP)
  1010.         {
  1011.             dragBox.top -= (tempRect.Height() - MIN_CATEGORY_HEIGHT - DRAGWIDTH);
  1012.             dragBox.bottom = dragBox.top + DRAGWIDTH;
  1013.         }
  1014.         else if (m_dwOverDockStyle == DOCKSTYLE_HORZBOTTOM)
  1015.         {
  1016.             dragBox.top += (tempRect.Height() - MIN_CATEGORY_HEIGHT - DRAGWIDTH);
  1017.             dragBox.bottom = dragBox.top + DRAGWIDTH;
  1018.         }
  1019.         else if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT)
  1020.         {
  1021.             dragBox.left -= (tempRect.Width() - MIN_CATEGORY_WIDTH - DRAGWIDTH);
  1022.             dragBox.right = dragBox.left + DRAGWIDTH;
  1023.         }
  1024.         else 
  1025.         {
  1026.             // docked to the right
  1027.             dragBox.left += (tempRect.Width() - MIN_CATEGORY_WIDTH - DRAGWIDTH);
  1028.             dragBox.right += dragBox.left + DRAGWIDTH;
  1029.         }
  1030.             
  1031.         m_pSelector->UnSelectAll();
  1032.  
  1033.         if (GetParentFrame()) 
  1034.         {
  1035.             m_DragWnd->SetRect(dragBox);
  1036.             m_DragWnd->MoveWindow(dragBox);
  1037.             GetParentFrame()->RecalcLayout();
  1038.         }
  1039.     }
  1040. }
  1041.  
  1042.  
  1043. void CNSNavFrame::ExpandWindow()
  1044. {
  1045.     if (m_dwOverDockStyle == DOCKSTYLE_FLOATING) {
  1046.         // Handle floating window differently.  Floating window does not have
  1047.         // m_DragWnd and  m_pParent.
  1048.     }
  1049.     else {    // Move m_DragWnd when we want to expand docking window.
  1050.     
  1051.         ComputeDockingSizes();
  1052.  
  1053.         CRect tempRect;
  1054.         GetClientRect(&tempRect);;
  1055.         CRect dragBox;
  1056.         m_DragWnd->GetRect(dragBox);
  1057.         int step = 0;
  1058.         if (m_dwOverDockStyle == DOCKSTYLE_HORZTOP || m_dwOverDockStyle == DOCKSTYLE_HORZBOTTOM)
  1059.             step = m_DockHeight - MIN_CATEGORY_HEIGHT;
  1060.         else
  1061.             step = m_DockWidth - MIN_CATEGORY_WIDTH;
  1062.  
  1063.         if (m_dwOverDockStyle == DOCKSTYLE_HORZTOP) 
  1064.         {
  1065.             dragBox.top += step;
  1066.             dragBox.bottom = dragBox.top + DRAGWIDTH;
  1067.         }
  1068.         else if (m_dwOverDockStyle == DOCKSTYLE_HORZBOTTOM) {
  1069.             dragBox.bottom -=  step;
  1070.             dragBox.top = dragBox.bottom - DRAGWIDTH;
  1071.         }
  1072.         else  if (m_dwOverDockStyle == DOCKSTYLE_VERTLEFT) {
  1073.             dragBox.left += step;
  1074.             dragBox.right = dragBox.left + DRAGWIDTH;
  1075.         }
  1076.         else  if (m_dwOverDockStyle == DOCKSTYLE_VERTRIGHT) {
  1077.             dragBox.right -= step;
  1078.             dragBox.left = dragBox.right - DRAGWIDTH;
  1079.         }
  1080.  
  1081.         if (GetParentFrame()) {
  1082.             m_DragWnd->ShowWindow(SW_HIDE);
  1083.             m_DragWnd->SetRect(dragBox);
  1084.             m_DragWnd->MoveWindow(dragBox);
  1085.             GetParentFrame()->RecalcLayout();
  1086.         }
  1087.     }
  1088. }
  1089.  
  1090. /////////////////////////////////////////////////////////////////////////////
  1091. // CNSNavFrame diagnostics
  1092.  
  1093. #ifdef _DEBUG
  1094. void CNSNavFrame::AssertValid() const
  1095. {
  1096.     CFrameWnd::AssertValid();
  1097. }
  1098.  
  1099. void CNSNavFrame::Dump(CDumpContext& dc) const
  1100. {
  1101.     CFrameWnd::Dump(dc);
  1102. }
  1103.  
  1104. #endif //_DEBUG
  1105.  
  1106. HT_Pane CNSNavFrame::GetHTPane()
  1107. {
  1108.     HT_Pane htRetval = NULL;
  1109.     if(m_pSelector) {
  1110.         htRetval = m_pSelector->GetHTPane();
  1111.     }
  1112.     return(htRetval);
  1113. }
  1114.  
  1115. void CNSNavFrame::OnNcLButtonDown( UINT nHitTest, CPoint point )
  1116. {
  1117.     if (nHitTest == HTCAPTION)
  1118.     {
  1119.         m_ptLast = point;
  1120.         SetCapture();
  1121.     }
  1122.  
  1123.     CWnd::OnNcLButtonDown(nHitTest, point);
  1124. }
  1125.  
  1126. void CNSNavFrame::OnLButtonUp( UINT nHitTest, CPoint point )
  1127. {
  1128.     if (GetCapture() == this) 
  1129.     {
  1130.         ReleaseCapture();
  1131.     }
  1132.  
  1133.     CWnd::OnNcLButtonUp(nHitTest, point);
  1134. }
  1135.  
  1136. void CNSNavFrame::OnMouseMove( UINT nHitTest, CPoint point )
  1137. {
  1138.     if (GetCapture() == this)
  1139.     {
  1140.         MapWindowPoints(NULL, &point, 1); 
  1141.         if (abs(point.x - m_ptLast.x) > 3 ||
  1142.             abs(point.y - m_ptLast.y) > 3)
  1143.         {
  1144.             ReleaseCapture();
  1145.             StartDrag(point, FALSE);
  1146.         }
  1147.     }
  1148.  
  1149.     CWnd::OnNcMouseMove(nHitTest, point);
  1150. }
  1151.  
  1152.