Develop and Download Open Source Software

Browse CVS Repository

Contents of /satellite/neuromanager/neuromanager/scbarg.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Sat Feb 4 13:38:16 2006 UTC (18 years, 2 months ago) by orrisroot
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/x-c++src
moved main application sources to neuromanager directory.

1 /////////////////////////////////////////////////////////////////////////
2 //
3 // CSizingControlBarG Version 2.44
4 //
5 // Created: Jan 24, 1998 Last Modified: March 31, 2002
6 //
7 // See the official site at www.datamekanix.com for documentation and
8 // the latest news.
9 //
10 /////////////////////////////////////////////////////////////////////////
11 // Copyright (C) 1998-2002 by Cristi Posea. All rights reserved.
12 //
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.
16 //
17 // You must obtain the author's consent before you can include this code
18 // in a software library.
19 //
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
23 // user.
24 //
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 /////////////////////////////////////////////////////////////////////////
28
29 // sizecbar.cpp : implementation file
30 //
31
32 #include "stdafx.h"
33
34 #ifdef _DEBUG
35 #define new DEBUG_NEW
36 #undef THIS_FILE
37 static char THIS_FILE[] = __FILE__;
38 #endif
39
40 /////////////////////////////////////////////////////////////////////////
41 // CSizingControlBarG
42
43 IMPLEMENT_DYNAMIC( CSizingControlBarG, baseCSizingControlBarG );
44
45 CSizingControlBarG::CSizingControlBarG()
46 {
47 m_cyGripper = 12;
48 }
49
50 CSizingControlBarG::~CSizingControlBarG()
51 {}
52
53 BEGIN_MESSAGE_MAP( CSizingControlBarG, baseCSizingControlBarG )
54 //{{AFX_MSG_MAP(CSizingControlBarG)
55 ON_WM_NCLBUTTONUP()
56 ON_WM_NCHITTEST()
57 //}}AFX_MSG_MAP
58 ON_MESSAGE( WM_SETTEXT, OnSetText )
59 END_MESSAGE_MAP()
60
61 /////////////////////////////////////////////////////////////////////////
62 // CSizingControlBarG message handlers
63
64 /////////////////////////////////////////////////////////////////////////
65 // Mouse Handling
66 //
67
68 void CSizingControlBarG::OnNcLButtonUp( UINT nHitTest, CPoint point )
69 {
70 if ( nHitTest == HTCLOSE )
71 m_pDockSite->ShowControlBar( this, FALSE, FALSE ); // hide
72
73 baseCSizingControlBarG::OnNcLButtonUp( nHitTest, point );
74 }
75
76 void CSizingControlBarG::NcCalcClient( LPRECT pRc, UINT nDockBarID )
77 {
78 CRect rcBar( pRc ); // save the bar rect
79
80 // subtract edges
81 baseCSizingControlBarG::NcCalcClient( pRc, nDockBarID );
82
83 if ( !HasGripper() )
84 return ;
85
86 CRect rc( pRc ); // the client rect as calculated by the base class
87
88 BOOL bHorz = ( nDockBarID == AFX_IDW_DOCKBAR_TOP ) ||
89 ( nDockBarID == AFX_IDW_DOCKBAR_BOTTOM );
90
91 if ( bHorz )
92 rc.DeflateRect( m_cyGripper, 0, 0, 0 );
93 else
94 rc.DeflateRect( 0, m_cyGripper, 0, 0 );
95
96 // set position for the "x" (hide bar) button
97 CPoint ptOrgBtn;
98 if ( bHorz )
99 ptOrgBtn = CPoint( rc.left - 13, rc.top );
100 else
101 ptOrgBtn = CPoint( rc.right - 12, rc.top - 13 );
102
103 m_biHide.Move( ptOrgBtn - rcBar.TopLeft() );
104
105 *pRc = rc;
106 }
107
108 void CSizingControlBarG::NcPaintGripper( CDC* pDC, CRect rcClient )
109 {
110 if ( !HasGripper() )
111 return ;
112
113 // paints a simple "two raised lines" gripper
114 // override this if you want a more sophisticated gripper
115 CRect gripper = rcClient;
116 CRect rcbtn = m_biHide.GetRect();
117 BOOL bHorz = IsHorzDocked();
118
119 gripper.DeflateRect( 1, 1 );
120 if ( bHorz )
121 { // gripper at left
122 gripper.left -= m_cyGripper;
123 gripper.right = gripper.left + 3;
124 gripper.top = rcbtn.bottom + 3;
125 }
126 else
127 { // gripper at top
128 gripper.top -= m_cyGripper;
129 gripper.bottom = gripper.top + 3;
130 gripper.right = rcbtn.left - 3;
131 }
132
133 pDC->Draw3dRect( gripper, ::GetSysColor( COLOR_BTNHIGHLIGHT ),
134 ::GetSysColor( COLOR_BTNSHADOW ) );
135
136 gripper.OffsetRect( bHorz ? 3 : 0, bHorz ? 0 : 3 );
137
138 pDC->Draw3dRect( gripper, ::GetSysColor( COLOR_BTNHIGHLIGHT ),
139 ::GetSysColor( COLOR_BTNSHADOW ) );
140
141 m_biHide.Paint( pDC );
142 }
143
144 UINT CSizingControlBarG::OnNcHitTest( CPoint point )
145 {
146 CRect rcBar;
147 GetWindowRect( rcBar );
148
149 UINT nRet = baseCSizingControlBarG::OnNcHitTest( point );
150 if ( nRet != HTCLIENT )
151 return nRet;
152
153 CRect rc = m_biHide.GetRect();
154 rc.OffsetRect( rcBar.TopLeft() );
155 if ( rc.PtInRect( point ) )
156 return HTCLOSE;
157
158 return HTCLIENT;
159 }
160
161 /////////////////////////////////////////////////////////////////////////
162 // CSizingControlBarG implementation helpers
163
164 void CSizingControlBarG::OnUpdateCmdUI( CFrameWnd* pTarget,
165 BOOL bDisableIfNoHndler )
166 {
167 UNUSED_ALWAYS( bDisableIfNoHndler );
168 UNUSED_ALWAYS( pTarget );
169
170 if ( !HasGripper() )
171 return ;
172
173 BOOL bNeedPaint = FALSE;
174
175 CPoint pt;
176 ::GetCursorPos( &pt );
177 BOOL bHit = ( OnNcHitTest( pt ) == HTCLOSE );
178 BOOL bLButtonDown = ( ::GetKeyState( VK_LBUTTON ) < 0 );
179
180 BOOL bWasPushed = m_biHide.bPushed;
181 m_biHide.bPushed = bHit && bLButtonDown;
182
183 BOOL bWasRaised = m_biHide.bRaised;
184 m_biHide.bRaised = bHit && !bLButtonDown;
185
186 bNeedPaint |= ( m_biHide.bPushed ^ bWasPushed ) ||
187 ( m_biHide.bRaised ^ bWasRaised );
188
189 if ( bNeedPaint )
190 SendMessage( WM_NCPAINT );
191 }
192
193 /////////////////////////////////////////////////////////////////////////
194 // CSCBButton
195
196 CSCBButton::CSCBButton()
197 {
198 bRaised = FALSE;
199 bPushed = FALSE;
200 }
201
202 void CSCBButton::Paint( CDC* pDC )
203 {
204 CRect rc = GetRect();
205
206 if ( bPushed )
207 pDC->Draw3dRect( rc, ::GetSysColor( COLOR_BTNSHADOW ),
208 ::GetSysColor( COLOR_BTNHIGHLIGHT ) );
209 else
210 if ( bRaised )
211 pDC->Draw3dRect( rc, ::GetSysColor( COLOR_BTNHIGHLIGHT ),
212 ::GetSysColor( COLOR_BTNSHADOW ) );
213
214 COLORREF clrOldTextColor = pDC->GetTextColor();
215 pDC->SetTextColor( ::GetSysColor( COLOR_BTNTEXT ) );
216 int nPrevBkMode = pDC->SetBkMode( TRANSPARENT );
217 CFont font;
218 int ppi = pDC->GetDeviceCaps( LOGPIXELSX );
219 int pointsize = MulDiv( 60, 96, ppi ); // 6 points at 96 ppi
220 font.CreatePointFont( pointsize, _T( "Marlett" ) );
221 CFont* oldfont = pDC->SelectObject( &font );
222
223 pDC->TextOut( ptOrg.x + 2, ptOrg.y + 2, CString( _T( "r" ) ) ); // x-like
224
225 pDC->SelectObject( oldfont );
226 pDC->SetBkMode( nPrevBkMode );
227 pDC->SetTextColor( clrOldTextColor );
228 }
229
230 BOOL CSizingControlBarG::HasGripper() const
231 {
232 #if defined(_SCB_MINIFRAME_CAPTION) || !defined(_SCB_REPLACE_MINIFRAME)
233 // if the miniframe has a caption, don't display the gripper
234 if ( IsFloating() )
235 return FALSE;
236 #endif //_SCB_MINIFRAME_CAPTION
237
238 return TRUE;
239 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26