GuiOfficeBar.cpp
上传用户:wlkj888
上传日期:2022-08-01
资源大小:806k
文件大小:19k
源码类别:

对话框与窗口

开发平台:

Visual C++

  1. /****************************************************************************
  2.  * *  
  3.  * GuiToolKit   *
  4.  *  (MFC extension) *  
  5.  * Created by Francisco Campos G. www.beyondata.com fcampos@beyondata.com *
  6.  *--------------------------------------------------------------------------*    
  7.  * *
  8.  * This program is free software;so you are free to use it any of your *
  9.  * applications (Freeware, Shareware, Commercial),but leave this header *
  10.  * intact. *
  11.  * *
  12.  * These files are provided "as is" without warranty of any kind. *
  13.  * *
  14.  *        GuiToolKit is forever FREE CODE !!!!! *
  15.  * *
  16.  *--------------------------------------------------------------------------*
  17.  * Created by: Francisco Campos G. *
  18.  * Bug Fixes and improvements : (Add your name) *
  19.  * -Francisco Campos *
  20.  * *
  21.  ****************************************************************************/
  22. #include "stdafx.h"
  23. #include "Guiofficebar.h"
  24. #include "Guidrawlayer.h"
  25. #ifdef _DEBUG
  26. #define new DEBUG_NEW
  27. #undef THIS_FILE
  28. static char THIS_FILE[] = __FILE__;
  29. #endif
  30. #define HORZF(dw) (dw & CBRS_ORIENT_HORZ)
  31. #define VERTF(dw) (dw & CBRS_ORIENT_VERT)
  32. #define CX_BORDER   1
  33. #define CY_BORDER   1
  34. enum btn
  35. {
  36. HTBACK   = 520,
  37. HTFORWAR = 521,
  38. THMENU   = 522,
  39. HTCLOS   = 523
  40. };
  41. int ArrBtn[4]={HTBACK,HTFORWAR,THMENU,HTCLOS};
  42. void  _AfxAdjustRectangle(CRect& rect, CPoint pt)
  43. {
  44. int nXOffset = (pt.x < rect.left) ? (pt.x - rect.left) :
  45. (pt.x > rect.right) ? (pt.x - rect.right) : 0;
  46. int nYOffset = (pt.y < rect.top) ? (pt.y - rect.top) :
  47. (pt.y > rect.bottom) ? (pt.y - rect.bottom) : 0;
  48. rect.OffsetRect(nXOffset, nYOffset);
  49. }
  50. BEGIN_MESSAGE_MAP(CGuiOfficeBar,CGuiControlBar)
  51. ON_WM_CREATE()
  52. ON_WM_NCLBUTTONDOWN()
  53. ON_WM_NCLBUTTONUP()
  54. ON_WM_TIMER()
  55. ON_WM_NCMOUSEMOVE()
  56. ON_WM_NCHITTEST()
  57. ON_COMMAND(HTBACK,OnBack)
  58. ON_COMMAND(HTFORWAR,OnForWard)
  59. ON_COMMAND(THMENU,OnMenu)
  60. ON_WM_NCCALCSIZE()
  61. END_MESSAGE_MAP()
  62. CGuiOfficeBar::CGuiOfficeBar(void)
  63. {
  64. m_stateBtnBack=NORMAL;
  65. m_stateBtnClose=NORMAL;
  66. m_stateBtnFor=NORMAL;
  67. m_stateBtnMenu=NORMAL;
  68. m_StateBtn=NORMAL;
  69. m_nHits=-1;
  70. }
  71. CGuiOfficeBar::~CGuiOfficeBar(void)
  72. {
  73. }
  74. void CGuiOfficeBar::OnBack()
  75. {
  76. }
  77. void CGuiOfficeBar::OnForWard()
  78. {
  79. }
  80. void CGuiOfficeBar::OnMenu()
  81. {
  82. }
  83. int CGuiOfficeBar::OnCreate(LPCREATESTRUCT lpCreateStruct)
  84. {
  85. if (CGuiControlBar::OnCreate(lpCreateStruct) == -1)
  86. return -1;
  87. m_ArrButtons[0].SetData(1,_T("Back"));
  88. m_ArrButtons[0].SetImageList(IDB_GUI_DOCKBAROFFICE,16,7,RGB(255,0,255));
  89. m_ArrButtons[1].SetData(2,_T("Forward"));
  90. m_ArrButtons[1].SetImageList(IDB_GUI_DOCKBAROFFICE,16,7,RGB(255,0,255));
  91. m_ArrButtons[2].SetData(0,_T("Menu"));
  92. m_ArrButtons[2].SetImageList(IDB_GUI_DOCKBAROFFICE,16,7,RGB(255,0,255));
  93. m_ArrButtons[3].SetData(6,_T("Close"));
  94. m_ArrButtons[3].SetImageList(IDB_GUI_DOCKBAROFFICE,16,7,RGB(255,0,255));
  95. m_ArrButtons[0].SetTypeButton(CGuiControlBarButton::GUITOOLBUTTON);
  96. m_ArrButtons[1].SetTypeButton(CGuiControlBarButton::GUITOOLBUTTON);
  97. m_ArrButtons[2].SetTypeButton(CGuiControlBarButton::GUITOOLBUTTON);
  98. m_ArrButtons[3].SetTypeButton(CGuiControlBarButton::GUITOOLBUTTON);
  99. SetColorFondo(RGB(255,255,255));
  100. return 0;
  101. }
  102. CSize CGuiOfficeBar::CalcDynamicLayout(int nLength, DWORD nMode)
  103. {
  104. m_pDockSite->RecalcLayout();
  105. if (IsFloating())
  106. {
  107. // Enable diagonal arrow cursor for resizing
  108. //m_sizeVert=m_sizeHorz=CSize(200,200);
  109. GetParent()->GetParent()->ModifyStyle(MFS_4THICKFRAME|WS_CAPTION,0);
  110. if (nMode & (LM_HORZDOCK | LM_VERTDOCK)) 
  111. {
  112. m_pDockSite->DelayRecalcLayout();
  113. //obligar a reposicionar  la ventana, de lo contrario cuando vuelva de un doble click
  114. //desde la ventana CMiniFrameWnd queda sin area cliente
  115. SetWindowPos(NULL, 0, 0, 0, 0,
  116. SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER |
  117. SWP_NOACTIVATE | SWP_FRAMECHANGED|SWP_NOREDRAW);
  118.   return CControlBar::CalcDynamicLayout(nLength, nMode);
  119. }
  120. if (nMode & LM_MRUWIDTH)
  121.         return  m_sizeMinFloating;
  122.     if (nMode & LM_COMMIT)
  123.         return  m_sizeMinFloating ;
  124.     
  125. if (IsFloating())
  126. {
  127. CRect rcWin;
  128. POINT cpt;
  129. GetCursorPos(&cpt);
  130. GetParent()->GetParent()->GetWindowRect(&rcWin);
  131. int nXOffset=0;int nYOffset=0;
  132. switch (m_pDockContext->m_nHitTest)
  133. {
  134. //------------------------------------------------------------------
  135. case HTLEFT:
  136. m_pDockContext->m_rectFrameDragHorz= rcWin;
  137. m_pDockContext->m_rectFrameDragHorz.left = cpt.x;
  138. m_sizeMinFloating.cx = max(rcWin.right - cpt.x,32)-4 ;
  139. m_sizeMinFloating.cy = max((rcWin.bottom -rcWin.top)-nGapGripper-5,32)+2 ;
  140. return m_sizeMinFloating;
  141. break;
  142. case HTTOP:
  143. m_pDockContext->m_rectFrameDragHorz=rcWin;
  144. m_pDockContext->m_rectFrameDragHorz.top = cpt.y;
  145. m_sizeMinFloating.cx = max(rcWin.right-rcWin.left-2,32)-4 ;
  146. m_sizeMinFloating.cy = max((rcWin.bottom -nGapGripper-cpt.y-3),32) ;
  147. return m_sizeMinFloating;
  148. break;
  149. case HTRIGHT:
  150. m_pDockContext->m_rectFrameDragHorz=rcWin;
  151. m_pDockContext->m_rectFrameDragHorz.right = cpt.x;
  152. m_sizeMinFloating.cy = max(rcWin.bottom -rcWin.top-nGapGripper-3,32) ;
  153. m_sizeMinFloating.cx = max(cpt.x-rcWin.left-4,32);
  154. return m_sizeMinFloating;
  155. break;
  156. case HTBOTTOM:
  157. m_pDockContext->m_rectFrameDragHorz=rcWin;
  158. m_sizeMinFloating.cy = max(cpt.y-rcWin.top -nGapGripper-3,32) ;
  159. m_sizeMinFloating.cx = max(rcWin.right-rcWin.left-2,32)-4 ;
  160. m_pDockContext->m_rectFrameDragHorz.bottom = cpt.y-4;
  161. return m_sizeMinFloating;
  162. break;
  163. case HTTOPLEFT:
  164. //---------------------------------------------------------
  165. //En este caso crece la ventana a izquierda y hacia arriba
  166. //izquierda incrementa cx y top incrementa cy
  167. m_sizeMinFloating.cx = max(rcWin.right - cpt.x,32)-3 ;
  168. m_sizeMinFloating.cy = max(rcWin.bottom -nGapGripper-cpt.y,32)-2 ;
  169. m_pDockContext->m_rectFrameDragHorz.top = cpt.y-1;
  170. m_pDockContext->m_rectFrameDragHorz.left = cpt.x-2;
  171. return m_sizeMinFloating;
  172. break;
  173. case HTTOPRIGHT:
  174. m_sizeMinFloating.cx = max(cpt.x-rcWin.left,32)-4 ;
  175. m_sizeMinFloating.cy = max(rcWin.bottom -nGapGripper-cpt.y,32)-2 ;
  176. m_pDockContext->m_rectFrameDragHorz.top = cpt.y-1;
  177. m_pDockContext->m_rectFrameDragHorz.right = cpt.x-2;
  178. return m_sizeMinFloating;
  179. break;
  180. case HTBOTTOMLEFT:
  181. m_sizeMinFloating.cx = max(rcWin.right - cpt.x,32)-4;
  182. m_sizeMinFloating.cy = max(cpt.y-rcWin.top -nGapGripper,32)-2 ;
  183. m_pDockContext->m_rectFrameDragHorz.top = rcWin.top;
  184. m_pDockContext->m_rectFrameDragHorz.bottom = cpt.y-1;
  185. m_pDockContext->m_rectFrameDragHorz.left = cpt.x-2;
  186. return m_sizeMinFloating;
  187. break;
  188. case HTBOTTOMRIGHT:
  189. m_sizeMinFloating.cx = max(cpt.x-rcWin.left,32);
  190. m_sizeMinFloating.cy = max(cpt.y-rcWin.top -nGapGripper,32) ;
  191. m_pDockContext->m_rectFrameDragHorz.top = rcWin.top;
  192. m_pDockContext->m_rectFrameDragHorz.bottom = cpt.y+1;
  193. m_pDockContext->m_rectFrameDragHorz.right = cpt.x+2;
  194. return m_sizeMinFloating;
  195. break;
  196. }
  197. }
  198. if(nMode & LM_LENGTHY)
  199.  m_sizeMinFloating.cy = max(nLength,32);
  200. else
  201.      m_sizeMinFloating.cx = max(nLength,32);
  202. return m_sizeMinFloating;
  203. }
  204. void CGuiOfficeBar::OnNcCalcSize(BOOL /*bCalcValidRects*/, NCCALCSIZE_PARAMS* lpncsp)
  205. {
  206. // adjust non-client area for border space
  207. lpncsp->rgrc[0].left +=!IsFloating()?5:2;
  208. lpncsp->rgrc[0].top +=nGapGripper+3;
  209. lpncsp->rgrc[0].right -=!IsFloating()?IsVert()?7:4:2;
  210. lpncsp->rgrc[0].bottom -=!IsFloating()?3:2;
  211. }
  212. void CGuiOfficeBar::DrawGripper(CDC* pDC,CRect* rc)
  213. {
  214. CRect gripper = rc;
  215. gripper.top =3;
  216. gripper.left+=4;
  217. gripper.right-=IsVert()?5:4;
  218. gripper.bottom =gripper.top +nGapGripper-3;
  219. //si la ventana esta activa pintamos el caption o el area del titulo de color azul 
  220. CPen cp(PS_SOLID,1,::GetSysColor(COLOR_BTNHIGHLIGHT));
  221. CPen* cpold=pDC->SelectObject(&cp);
  222. //linea superior
  223. CBrush cb;
  224. cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace(GuiDrawLayer::m_Style));//GuiDrawLayer::GetRGBCaptionXP());
  225. pDC->FillRect(gripper,&cb);
  226. pDC->SelectObject(cpold);
  227. gripper.DeflateRect(1, 1);
  228. CString m_caption;
  229. GetWindowText(m_caption);
  230. CFont m_cfont;
  231. m_cfont.CreateFont(-11,0,0,0,FW_SEMIBOLD,0,0,0,0,1,2,1,34,_T("Microsoft Sans Serif"));
  232. CFont* m_fontOld=pDC->SelectObject(&m_cfont);
  233. int nMode = pDC->SetBkMode(TRANSPARENT);
  234. CSize SizeCad=pDC->GetTextExtent(m_caption);
  235. CRect rCText=gripper;
  236. rCText.top=6;
  237. rCText.bottom =rCText.top+14;
  238. rCText.left=34;
  239. int cont=SizeCad.cx;
  240. while(cont > 1 && gripper.Width()-60 > 0)
  241. {
  242. CSize coor=pDC->GetTextExtent(m_caption,m_caption.GetLength());
  243. if(coor.cx > gripper.Width()-60)
  244. {
  245. m_caption=m_caption.Left(m_caption.GetLength()-1);
  246. }
  247. else
  248. break;
  249. cont--;
  250. }
  251. //CRect gripper;
  252. //------------------------------------------------
  253. GetWindowRect( gripper );
  254. ScreenToClient( gripper );
  255. gripper.OffsetRect( -gripper.left, -gripper.top );
  256. //boton de Close
  257. m_ArrButtons[3].rcArea=gripper;
  258. m_ArrButtons[3].rcArea.left=m_ArrButtons[3].rcArea.right-20;
  259. m_ArrButtons[3].rcArea.right-=7;
  260. m_ArrButtons[3].rcArea.top+=4;
  261. m_ArrButtons[3].rcArea.bottom=m_ArrButtons[3].rcArea.top+13;
  262. //boton menu
  263. m_ArrButtons[2].rcArea=gripper;
  264. m_ArrButtons[2].rcArea.left=m_ArrButtons[3].rcArea.left-16;
  265. m_ArrButtons[2].rcArea.right=m_ArrButtons[2].rcArea.left+13;
  266. m_ArrButtons[2].rcArea.top+=4;
  267. m_ArrButtons[2].rcArea.bottom=m_ArrButtons[2].rcArea.top+13;
  268. //boton back
  269. m_ArrButtons[0].rcArea=gripper;
  270. m_ArrButtons[0].rcArea.left+=4;
  271. m_ArrButtons[0].rcArea.right=m_ArrButtons[0].rcArea.left+13;
  272. m_ArrButtons[0].rcArea.top+=4;
  273. m_ArrButtons[0].rcArea.bottom=m_ArrButtons[0].rcArea.top+13;
  274. //boton forward
  275. m_ArrButtons[1].rcArea=gripper;
  276. m_ArrButtons[1].rcArea.left+=m_ArrButtons[0].rcArea.right+2;
  277. m_ArrButtons[1].rcArea.right=m_ArrButtons[1].rcArea.left+13;
  278. m_ArrButtons[1].rcArea.top+=4;
  279. m_ArrButtons[1].rcArea.bottom=m_ArrButtons[1].rcArea.top+13;
  280. //m_rcCloseBtn.left-=4;
  281. //ClientToScreen(m_rcCloseBtn);
  282.  m_ArrButtons[0].Paint(pDC,m_stateBtnBack,m_ArrButtons[0].rcArea,GuiDrawLayer::GetRGBColorFace(GuiDrawLayer::m_Style));
  283.  m_ArrButtons[1].Paint(pDC,m_stateBtnFor,m_ArrButtons[1].rcArea,GuiDrawLayer::GetRGBColorFace(GuiDrawLayer::m_Style));
  284.  m_ArrButtons[2].Paint(pDC,m_stateBtnMenu,m_ArrButtons[2].rcArea,GuiDrawLayer::GetRGBColorFace(GuiDrawLayer::m_Style));
  285.  m_ArrButtons[3].Paint(pDC,m_stateBtnClose,m_ArrButtons[3].rcArea,GuiDrawLayer::GetRGBColorFace(GuiDrawLayer::m_Style));
  286. //------------------------------------------------
  287. if (gripper.Width() > 0 )
  288. pDC->TextOut(rCText.left+3,rCText.top,m_caption);
  289. //CRect gripper;
  290. //------------------------------------------------
  291. pDC->SetBkMode(nMode);
  292. pDC->SelectObject(m_fontOld);
  293. }
  294. void CGuiOfficeBar::ShowTitle(CString m_Caption)
  295. {
  296. SetWindowText(m_Caption);
  297. SendMessage(WM_COMMAND, ID_GUI_SHOWTITLE);
  298. }
  299. void CGuiOfficeBar::OnNcLButtonDown(UINT nHitTest, CPoint point)
  300. {
  301. // TODO: Add your message handler code here and/or call default
  302. if( m_nHits == HTCLOS || m_nHits == HTBACK || m_nHits == HTFORWAR|| m_nHits == THMENU)
  303. {
  304. if (m_nHits == HTCLOS)
  305. m_stateBtnClose=PRESS;
  306. else if (m_nHits == HTBACK)
  307. m_stateBtnBack=PRESS;
  308. else if(m_nHits == HTFORWAR)
  309. m_stateBtnFor=PRESS;
  310. else if(m_nHits == THMENU)
  311. m_stateBtnMenu=PRESS;
  312. m_StateBtn=PRESS;
  313. SendMessage(WM_NCPAINT);
  314. SetTimer(1,100,0);
  315. return;
  316. if (nHitTest == HTCAPTION)
  317. SetCursor(::LoadCursor(NULL,IDC_SIZEALL));
  318. CGuiControlBar::OnNcLButtonDown(nHitTest, point);
  319. }
  320. void CGuiOfficeBar::OnNcLButtonUp(UINT nHitTest, CPoint point)
  321. {
  322. // TODO: Add your message handler code here and/or call default
  323. CRect rcT;
  324. point.y+=23;
  325. point.x+=5;
  326. if (m_stateBtnBack!=NORMAL)
  327. rcT=m_ArrButtons[0].rcArea;
  328. else if(m_stateBtnFor!=NORMAL)
  329. rcT=m_ArrButtons[1].rcArea;
  330. else if(m_stateBtnMenu!=NORMAL)
  331. rcT=m_ArrButtons[2].rcArea;
  332. else if(m_stateBtnClose!=NORMAL)
  333. rcT=m_ArrButtons[3].rcArea;
  334. ClientToScreen(rcT);
  335. if (rcT.PtInRect(point))
  336. {
  337. if (m_StateBtn ==PRESS)
  338. {
  339. if(m_stateBtnClose!=NORMAL)
  340.  GetDockingFrame()->ShowControlBar(this, FALSE, FALSE);
  341. else
  342. {
  343. SendMessage (WM_COMMAND,m_nHits);
  344. AfxGetMainWnd()->SendMessage(WM_COMMAND,m_nHits);
  345. }
  346. m_StateBtn=NORMAL;
  347. m_stateBtnBack=NORMAL;
  348. m_stateBtnClose=NORMAL;
  349. m_stateBtnFor=NORMAL;
  350. m_stateBtnMenu=NORMAL;
  351. m_nHits=-1;
  352. KillTimer(1);
  353. }
  354. //SendMessage(WM_NCPAINT);
  355. return;
  356. }
  357. CGuiControlBar::OnNcLButtonUp(nHitTest, point);
  358. }
  359. void CGuiOfficeBar::OnTimer(UINT nIDEvent)
  360. {
  361. // TODO: Add your message handler code here and/or call default
  362. if (m_StateBtn==NORMAL) return;
  363. CRect rc;
  364. CPoint pt(GetMessagePos());
  365. CRect rcT=CRect(0,0,0,0);
  366. if (m_stateBtnBack!=NORMAL)
  367. rcT=m_ArrButtons[0].rcArea;
  368. else if(m_stateBtnFor!=NORMAL)
  369. rcT=m_ArrButtons[1].rcArea;
  370. else if(m_stateBtnMenu!=NORMAL)
  371. rcT=m_ArrButtons[2].rcArea;
  372. else if(m_stateBtnClose!=NORMAL)
  373. rcT=m_ArrButtons[3].rcArea;
  374. ClientToScreen(rcT);
  375. pt.y+=23;
  376. pt.x+=5;
  377. if (!rcT.PtInRect(pt))
  378. {
  379. m_StateBtn=NORMAL;
  380. m_stateBtnBack=NORMAL;
  381. m_stateBtnClose=NORMAL;
  382. m_stateBtnFor=NORMAL;
  383. m_stateBtnMenu=NORMAL;
  384. m_nHits=-1;
  385. KillTimer(1);
  386. SendMessage(WM_NCPAINT); 
  387. }
  388. CGuiControlBar::OnTimer(nIDEvent);
  389. }
  390. void CGuiOfficeBar::OnNcMouseMove(UINT nHitTest, CPoint point)
  391. {
  392. // TODO: Add your message handler code here and/or call default
  393. if (m_StateBtn != NORMAL) return;
  394. if (m_nHits == HTCLOS)
  395. {
  396. m_StateBtn=OVER;
  397. m_stateBtnClose=OVER;
  398. m_stateBtnBack=NORMAL;
  399. m_stateBtnFor=NORMAL;
  400. m_stateBtnMenu=NORMAL;
  401. SendMessage(WM_NCPAINT);
  402. SetTimer(1,100,0);
  403. return;
  404. }
  405. if (m_nHits == HTBACK)
  406. {
  407. m_stateBtnBack=OVER;
  408. m_stateBtnClose=NORMAL;
  409. m_stateBtnFor=NORMAL;
  410. m_stateBtnMenu=NORMAL;
  411. m_StateBtn=OVER;
  412. SendMessage(WM_NCPAINT);
  413. SetTimer(1,100,0);
  414. return;
  415. }
  416. if (m_nHits == HTFORWAR)
  417. {
  418. m_stateBtnBack=NORMAL;
  419. m_stateBtnClose=NORMAL;
  420. m_stateBtnFor=OVER;
  421. m_stateBtnMenu=NORMAL;
  422. m_StateBtn=OVER;
  423. SendMessage(WM_NCPAINT);
  424. SetTimer(1,100,0);
  425. return;
  426. }
  427. if (m_nHits == THMENU)
  428. {
  429. m_stateBtnBack=NORMAL;
  430. m_stateBtnClose=NORMAL;
  431. m_stateBtnFor=NORMAL;
  432. m_stateBtnMenu=OVER;
  433. m_StateBtn=OVER;
  434. SendMessage(WM_NCPAINT);
  435. SetTimer(1,100,0);
  436. return;
  437. }
  438. CGuiControlBar::OnNcMouseMove(nHitTest, point);
  439. }
  440. UINT CGuiOfficeBar::OnNcHitTest(CPoint point)
  441. {
  442. // TODO: Add your message handler code here and/or call default
  443. CRect rcWindow;
  444. //no se convierte las coordenadas de pantalla porque el punto
  445. //entregado por esta funci髇 esta dado en el mismo sentido.
  446. GetWindowRect(rcWindow);
  447. CPoint pt=point;
  448. pt.y+=23;
  449. pt.x+=5;
  450. for(int i=0; i < 4; i++)
  451. {
  452. CRect rcT=m_ArrButtons[i].rcArea;
  453. ClientToScreen(rcT);
  454. if (rcT.PtInRect(pt))
  455. return m_nHits=ArrBtn[i];
  456. }
  457. m_nHits=-1;
  458. return CGuiControlBar::OnNcHitTest(point);
  459. }
  460. CGuiDockContextOffice::~CGuiDockContextOffice()
  461. {
  462. }
  463. void CGuiDockContextOffice::StartDrag(CPoint pt)
  464. {
  465. ASSERT_VALID(m_pBar);
  466. m_bDragging = TRUE;
  467. InitLoop();
  468. // GetWindowRect returns screen coordinates(not mirrored),
  469. // so if the desktop is mirrored then turn off mirroring
  470. // for the desktop dc so that we get correct focus rect drawn.
  471. // This layout change should be remembered, just in case ...
  472. // if (m_pDC->GetLayout() & LAYOUT_RTL)
  473. // m_pDC->SetLayout(LAYOUT_LTR);
  474. if (m_pBar->m_dwStyle & CBRS_SIZE_DYNAMIC)
  475. {
  476. // get true bar size (including borders)
  477. CRect rect;
  478. m_pBar->GetWindowRect(rect);
  479. m_ptLast = pt;
  480. AdjustWindowForFloat(rect);
  481. CSize sizeHorz = m_pBar->CalcDynamicLayout(0, LM_HORZ | LM_HORZDOCK);
  482. CSize sizeVert = m_pBar->CalcDynamicLayout(0, LM_VERTDOCK);
  483. CSize sizeFloat = m_pBar->CalcDynamicLayout(0, LM_HORZ | LM_MRUWIDTH);
  484. m_rectDragHorz = CRect(rect.TopLeft(), sizeHorz);
  485. m_rectDragVert = CRect(rect.TopLeft(), sizeVert);
  486. // calculate frame dragging rectangle
  487. m_rectFrameDragHorz = CRect(rect.TopLeft(), sizeFloat);
  488. m_rectFrameDragVert = CRect(rect.TopLeft(), sizeFloat);
  489. CMiniFrameWnd::CalcBorders(&m_rectFrameDragHorz);
  490. CMiniFrameWnd::CalcBorders(&m_rectFrameDragVert);
  491. // m_rectFrameDragHorz.InflateRect(-afxData.cxBorder2, -afxData.cyBorder2);
  492. // m_rectFrameDragVert.InflateRect(-afxData.cxBorder2, -afxData.cyBorder2);
  493. }
  494. else if (m_pBar->m_dwStyle & CBRS_SIZE_FIXED)
  495. {
  496. // get true bar size (including borders)
  497. CRect rect;
  498. m_pBar->GetWindowRect(rect);
  499. AdjustWindowForFloat(rect);
  500. m_ptLast = pt;
  501. CSize sizeHorz = m_pBar->CalcDynamicLayout(-1, LM_HORZ | LM_HORZDOCK);
  502. CSize sizeVert = m_pBar->CalcDynamicLayout(-1, LM_VERTDOCK);
  503. // calculate frame dragging rectangle
  504. m_rectFrameDragHorz = m_rectDragHorz = CRect(rect.TopLeft(), sizeHorz);
  505. m_rectFrameDragVert = m_rectDragVert = CRect(rect.TopLeft(), sizeVert);
  506. CMiniFrameWnd::CalcBorders(&m_rectFrameDragHorz);
  507. CMiniFrameWnd::CalcBorders(&m_rectFrameDragVert);
  508. // m_rectFrameDragHorz.InflateRect(-afxData.cxBorder2, -afxData.cyBorder2);
  509. // m_rectFrameDragVert.InflateRect(-afxData.cxBorder2, -afxData.cyBorder2);
  510. }
  511. else
  512. {
  513. // get true bar size (including borders)
  514. CRect rect;
  515. m_pBar->GetWindowRect(rect);
  516. AdjustWindowForFloat(rect);
  517. m_ptLast = pt;
  518. BOOL bHorz = HORZF(m_dwStyle);
  519. DWORD dwMode = !bHorz ? (LM_HORZ | LM_HORZDOCK) : LM_VERTDOCK;
  520. CSize size = m_pBar->CalcDynamicLayout(-1, dwMode);
  521. // calculate inverted dragging rect
  522. if (bHorz)
  523. {
  524. m_rectDragHorz = rect;
  525. m_rectDragVert = CRect(CPoint(pt.x - rect.Height()/2, rect.top), size);
  526. }
  527. else // vertical orientation
  528. {
  529. m_rectDragVert = rect;
  530. m_rectDragHorz = CRect(CPoint(rect.left, pt.y - rect.Width()/2), size);
  531. }
  532. // calculate frame dragging rectangle
  533. m_rectFrameDragHorz = m_rectDragHorz;
  534. m_rectFrameDragVert = m_rectDragVert;
  535. CMiniFrameWnd::CalcBorders(&m_rectFrameDragHorz);
  536. CMiniFrameWnd::CalcBorders(&m_rectFrameDragVert);
  537. // m_rectFrameDragHorz.InflateRect(-afxData.cxBorder2, -afxData.cyBorder2);
  538. // m_rectFrameDragVert.InflateRect(-afxData.cxBorder2, -afxData.cyBorder2);
  539. }
  540. // adjust rectangles so that point is inside
  541. _AfxAdjustRectangle(m_rectDragHorz, pt);
  542. _AfxAdjustRectangle(m_rectDragVert, pt);
  543. _AfxAdjustRectangle(m_rectFrameDragHorz, pt);
  544. _AfxAdjustRectangle(m_rectFrameDragVert, pt);
  545. // initialize tracking state and enter tracking loop
  546. m_dwOverDockStyle = CanDock();
  547. Move(pt);   // call it here to handle special keys
  548. Track();
  549. }
  550. void CGuiDockContextOffice::AdjustWindowForFloat(CRect& rect)
  551. {
  552. if( m_pBar->IsFloating())
  553. rect.top+=(GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYFRAME));
  554. }