1
/////////////////////////////////////////////////////////////////////////
3
// CSizingControlBarG Version 2.44
5
// Created: Jan 24, 1998 Last Modified: March 31, 2002
7
// See the official site at www.datamekanix.com for documentation and
10
/////////////////////////////////////////////////////////////////////////
11
// Copyright (C) 1998-2002 by Cristi Posea. All rights reserved.
13
// This code is free for personal and commercial use, providing this
14
// notice remains intact in the source files and all eventual changes are
15
// clearly marked with comments.
17
// You must obtain the author's consent before you can include this code
18
// in a software library.
20
// No warrantee of any kind, express or implied, is included with this
21
// software; use at your own risk, responsibility for damages (if any) to
22
// anyone resulting from the use of this software rests entirely with the
25
// Send bug reports, bug fixes, enhancements, requests, flames, etc. to
26
// cristi@datamekanix.com or post them at the message board at the site.
27
/////////////////////////////////////////////////////////////////////////
29
// sizecbar.cpp : implementation file
37
static char THIS_FILE[] = __FILE__;
40
/////////////////////////////////////////////////////////////////////////
43
IMPLEMENT_DYNAMIC(CSizingControlBarG, baseCSizingControlBarG);
45
CSizingControlBarG::CSizingControlBarG()
50
CSizingControlBarG::~CSizingControlBarG()
54
BEGIN_MESSAGE_MAP(CSizingControlBarG, baseCSizingControlBarG)
55
//{{AFX_MSG_MAP(CSizingControlBarG)
59
ON_MESSAGE(WM_SETTEXT, OnSetText)
62
/////////////////////////////////////////////////////////////////////////
63
// CSizingControlBarG message handlers
65
/////////////////////////////////////////////////////////////////////////
69
void CSizingControlBarG::OnNcLButtonUp(UINT nHitTest, CPoint point)
71
if (nHitTest == HTCLOSE)
72
m_pDockSite->ShowControlBar(this, FALSE, FALSE); // hide
74
baseCSizingControlBarG::OnNcLButtonUp(nHitTest, point);
77
void CSizingControlBarG::NcCalcClient(LPRECT pRc, UINT nDockBarID)
79
CRect rcBar(pRc); // save the bar rect
82
baseCSizingControlBarG::NcCalcClient(pRc, nDockBarID);
87
CRect rc(pRc); // the client rect as calculated by the base class
89
BOOL bHorz = (nDockBarID == AFX_IDW_DOCKBAR_TOP) ||
90
(nDockBarID == AFX_IDW_DOCKBAR_BOTTOM);
93
rc.DeflateRect(m_cyGripper, 0, 0, 0);
95
rc.DeflateRect(0, m_cyGripper, 0, 0);
97
// set position for the "x" (hide bar) button
100
ptOrgBtn = CPoint(rc.left - 13, rc.top);
102
ptOrgBtn = CPoint(rc.right - 12, rc.top - 13);
104
m_biHide.Move(ptOrgBtn - rcBar.TopLeft());
109
void CSizingControlBarG::NcPaintGripper(CDC* pDC, CRect rcClient)
114
// paints a simple "two raised lines" gripper
115
// override this if you want a more sophisticated gripper
116
CRect gripper = rcClient;
117
CRect rcbtn = m_biHide.GetRect();
118
BOOL bHorz = IsHorzDocked();
120
gripper.DeflateRect(1, 1);
123
gripper.left -= m_cyGripper;
124
gripper.right = gripper.left + 3;
125
gripper.top = rcbtn.bottom + 3;
129
gripper.top -= m_cyGripper;
130
gripper.bottom = gripper.top + 3;
131
gripper.right = rcbtn.left - 3;
134
pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
135
::GetSysColor(COLOR_BTNSHADOW));
137
gripper.OffsetRect(bHorz ? 3 : 0, bHorz ? 0 : 3);
139
pDC->Draw3dRect(gripper, ::GetSysColor(COLOR_BTNHIGHLIGHT),
140
::GetSysColor(COLOR_BTNSHADOW));
145
LRESULT CSizingControlBarG::OnNcHitTest(CPoint point)
148
GetWindowRect(rcBar);
150
UINT nRet = baseCSizingControlBarG::OnNcHitTest(point);
151
if (nRet != HTCLIENT)
154
CRect rc = m_biHide.GetRect();
155
rc.OffsetRect(rcBar.TopLeft());
156
if (rc.PtInRect(point))
162
/////////////////////////////////////////////////////////////////////////
163
// CSizingControlBarG implementation helpers
165
void CSizingControlBarG::OnUpdateCmdUI(CFrameWnd* pTarget,
166
BOOL bDisableIfNoHndler)
168
UNUSED_ALWAYS(bDisableIfNoHndler);
169
UNUSED_ALWAYS(pTarget);
174
BOOL bNeedPaint = FALSE;
178
BOOL bHit = (OnNcHitTest(pt) == HTCLOSE);
179
BOOL bLButtonDown = (::GetKeyState(VK_LBUTTON) < 0);
181
BOOL bWasPushed = m_biHide.bPushed;
182
m_biHide.bPushed = bHit && bLButtonDown;
184
BOOL bWasRaised = m_biHide.bRaised;
185
m_biHide.bRaised = bHit && !bLButtonDown;
187
bNeedPaint |= (m_biHide.bPushed ^ bWasPushed) ||
188
(m_biHide.bRaised ^ bWasRaised);
191
SendMessage(WM_NCPAINT);
194
/////////////////////////////////////////////////////////////////////////
197
CSCBButton::CSCBButton()
203
void CSCBButton::Paint(CDC* pDC)
205
CRect rc = GetRect();
208
pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNSHADOW),
209
::GetSysColor(COLOR_BTNHIGHLIGHT));
212
pDC->Draw3dRect(rc, ::GetSysColor(COLOR_BTNHIGHLIGHT),
213
::GetSysColor(COLOR_BTNSHADOW));
215
COLORREF clrOldTextColor = pDC->GetTextColor();
216
pDC->SetTextColor(::GetSysColor(COLOR_BTNTEXT));
217
int nPrevBkMode = pDC->SetBkMode(TRANSPARENT);
219
int ppi = pDC->GetDeviceCaps(LOGPIXELSX);
220
int pointsize = MulDiv(60, 96, ppi); // 6 points at 96 ppi
221
font.CreatePointFont(pointsize, _T("Marlett"));
222
CFont* oldfont = pDC->SelectObject(&font);
224
pDC->TextOut(ptOrg.x + 2, ptOrg.y + 2, CString(_T("r"))); // x-like
226
pDC->SelectObject(oldfont);
227
pDC->SetBkMode(nPrevBkMode);
228
pDC->SetTextColor(clrOldTextColor);
231
BOOL CSizingControlBarG::HasGripper() const
233
#if defined(_SCB_MINIFRAME_CAPTION) || !defined(_SCB_REPLACE_MINIFRAME)
234
// if the miniframe has a caption, don't display the gripper
237
#endif //_SCB_MINIFRAME_CAPTION
b'\\ No newline at end of file'