00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00028
00029
00030
00031
00032 #include "stdafx.h"
00033
00034 #include "scbarg.h"
00035
00036 #ifdef _DEBUG
00037 #define new DEBUG_NEW
00038 #undef THIS_FILE
00039 static char THIS_FILE[] = __FILE__;
00040 #endif
00041
00043
00044
00045 IMPLEMENT_DYNAMIC(CSizingControlBarG, baseCSizingControlBarG);
00046
00047 CSizingControlBarG::CSizingControlBarG()
00048 {
00049 m_cyGripper = 12;
00050 }
00051
00052 CSizingControlBarG::~CSizingControlBarG()
00053 {
00054 }
00055
00056 BEGIN_MESSAGE_MAP(CSizingControlBarG, baseCSizingControlBarG)
00057
00058 ON_WM_NCLBUTTONUP()
00059 ON_WM_NCHITTEST()
00060
00061 ON_MESSAGE(WM_SETTEXT, OnSetText)
00062 END_MESSAGE_MAP()
00063
00065
00066
00068
00069
00070
00071 void CSizingControlBarG::OnNcLButtonUp(UINT nHitTest, CPoint point)
00072 {
00073 if (nHitTest == HTCLOSE)
00074 m_pDockSite->ShowControlBar(this, FALSE, FALSE);
00075
00076 baseCSizingControlBarG::OnNcLButtonUp(nHitTest, point);
00077 }
00078
00079 void CSizingControlBarG::NcCalcClient(LPRECT pRc, UINT nDockBarID)
00080 {
00081 CRect rcBar(pRc);
00082
00083
00084 baseCSizingControlBarG::NcCalcClient(pRc, nDockBarID);
00085
00086 if (!HasGripper())
00087 return;
00088
00089 CRect rc(pRc);
00090
00091 BOOL bHorz = (nDockBarID == AFX_IDW_DOCKBAR_TOP) ||
00092 (nDockBarID == AFX_IDW_DOCKBAR_BOTTOM);
00093
00094 if (bHorz)
00095 rc.DeflateRect(m_cyGripper, 0, 0, 0);
00096 else
00097 rc.DeflateRect(0, m_cyGripper, 0, 0);
00098
00099
00100 CPoint ptOrgBtn;
00101 if (bHorz)
00102 ptOrgBtn = CPoint(rc.left - 13, rc.top);
00103 else
00104 ptOrgBtn = CPoint(rc.right - 12, rc.top - 13);
00105
00106 m_biHide.Move(ptOrgBtn - rcBar.TopLeft());
00107
00108 *pRc = rc;
00109 }
00110
00111 void CSizingControlBarG::NcPaintGripper(CDC* pDC, CRect rcClient)
00112 {
00113 if (!HasGripper())
00114 return;
00115
00116
00117
00118 CRect gripper = rcClient;
00119 CRect rcbtn = m_biHide.GetRect();
00120 BOOL bHorz = IsHorzDocked();
00121
00122 gripper.DeflateRect(1, 1);
00123 if (bHorz)
00124 {
00125 gripper.left -= m_cyGripper;
00126 gripper.right = gripper.left + 3;
00127 gripper.top = rcbtn.bottom + 3;
00128 }
00129 else
00130 {
00131 gripper.top -= m_cyGripper;
00132 gripper.bottom = gripper.top + 3;
00133 gripper.right = rcbtn.left - 3;
00134 }
00135
00136 pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
00137 ::GetSysColor(COLOR_BTNSHADOW));
00138
00139 gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3);
00140
00141 pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
00142 ::GetSysColor(COLOR_BTNSHADOW));
00143
00144 m_biHide.Paint(pDC);
00145 }
00146
00147 LRESULT CSizingControlBarG::OnNcHitTest(CPoint point)
00148 {
00149 CRect rcBar;
00150 GetWindowRect(rcBar);
00151
00152 LRESULT nRet = baseCSizingControlBarG::OnNcHitTest(point);
00153 if (nRet != HTCLIENT)
00154 return nRet;
00155
00156 CRect rc = m_biHide.GetRect();
00157 rc.OffsetRect(rcBar.TopLeft());
00158 if (rc.PtInRect(point))
00159 return HTCLOSE;
00160
00161 return HTCLIENT;
00162 }
00163
00165
00166
00167 void CSizingControlBarG::OnUpdateCmdUI(CFrameWnd* pTarget,
00168 BOOL bDisableIfNoHndler)
00169 {
00170 UNUSED_ALWAYS(bDisableIfNoHndler);
00171 UNUSED_ALWAYS(pTarget);
00172
00173 if (!HasGripper())
00174 return;
00175
00176 BOOL bNeedPaint = FALSE;
00177
00178 CPoint pt;
00179 ::GetCursorPos(&pt);
00180 BOOL bHit = (OnNcHitTest(pt) == HTCLOSE);
00181 BOOL bLButtonDown = (::GetKeyState(VK_LBUTTON) < 0);
00182
00183 BOOL bWasPushed = m_biHide.bPushed;
00184 m_biHide.bPushed = bHit && bLButtonDown;
00185
00186 BOOL bWasRaised = m_biHide.bRaised;
00187 m_biHide.bRaised = bHit && !bLButtonDown;
00188
00189 bNeedPaint |= (m_biHide.bPushed ^ bWasPushed) ||
00190 (m_biHide.bRaised ^ bWasRaised);
00191
00192 if (bNeedPaint)
00193 SendMessage(WM_NCPAINT);
00194 }
00195
00197
00198
00199 CSCBButton::CSCBButton()
00200 {
00201 bRaised = FALSE;
00202 bPushed = FALSE;
00203 }
00204
00205 void CSCBButton::Paint(CDC* pDC)
00206 {
00207 CRect rc = GetRect();
00208
00209 if (bPushed)
00210 pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNSHADOW),
00211 ::GetSysColor(COLOR_BTNHIGHLIGHT));
00212 else
00213 if (bRaised)
00214 pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNHIGHLIGHT),
00215 ::GetSysColor(COLOR_BTNSHADOW));
00216
00217 COLORREF clrOldTextColor = pDC->GetTextColor();
00218 pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT));
00219 int nPrevBkMode = pDC->SetBkMode(TRANSPARENT);
00220 CFont font;
00221 int ppi = pDC->GetDeviceCaps(LOGPIXELSX);
00222 int pointsize = MulDiv(60, 96, ppi);
00223 font.CreatePointFont(pointsize, _T("Marlett"));
00224 CFont* oldfont = pDC->SelectObject(&font);
00225
00226 pDC->TextOut(ptOrg.x + 2, ptOrg.y + 2, CString(_T("r")));
00227
00228 pDC->SelectObject(oldfont);
00229 pDC->SetBkMode(nPrevBkMode);
00230 pDC->SetTextColor(clrOldTextColor);
00231 }
00232
00233 BOOL CSizingControlBarG::HasGripper() const
00234 {
00235 #if defined(_SCB_MINIFRAME_CAPTION) || !defined(_SCB_REPLACE_MINIFRAME)
00236
00237 if (IsFloating())
00238 return FALSE;
00239 #endif //_SCB_MINIFRAME_CAPTION
00240
00241 return TRUE;
00242 }