]>
Commit | Line | Data |
---|---|---|
8e08b761 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4cbc57f0 JS |
2 | // Name: panedrawpl.cpp |
3 | // Purpose: cbPaneDrawPlugin implementation. | |
8e08b761 JS |
4 | // Author: Aleksandras Gluchovas |
5 | // Modified by: | |
6 | // Created: 06/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Aleksandras Gluchovas | |
4cbc57f0 | 9 | // Licence: wxWindows licence |
8e08b761 JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "panedrawpl.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
24 | #include "wx/wx.h" | |
25 | #endif | |
26 | ||
27 | #include <math.h> | |
28 | #include <stdlib.h> | |
29 | ||
30 | #include "wx/utils.h" // import wxMin,wxMax macros | |
31 | ||
32 | #include "wx/fl/panedrawpl.h" | |
33 | ||
34 | // bitmap bits used by bar-resizing brush | |
35 | ||
36 | #define _IMG_A 0xAA // Note: modified from _A to _IMG_A, _A was already defined (cygwin) | |
37 | #define _IMG_B 0x00 // Note: modified from _B to _IMG_A, _B was already defined (cygwin) | |
38 | #define _IMG_C 0x55 // Note: modified from _C to _IMG_C, for consistency reasons. | |
39 | #define _IMG_D 0x00 // Note: modified from _D to _IMG_D, for consistency reasons. | |
40 | ||
41 | static const unsigned char _gCheckerImg[16] = { _IMG_A,_IMG_B,_IMG_C,_IMG_D, | |
4cbc57f0 JS |
42 | _IMG_A,_IMG_B,_IMG_C,_IMG_D, |
43 | _IMG_A,_IMG_B,_IMG_C,_IMG_D, | |
44 | _IMG_A,_IMG_B,_IMG_C,_IMG_D | |
45 | }; | |
8e08b761 JS |
46 | |
47 | // FIXME:: The below code somehow doesn't work - cursors remain unchanged | |
4cbc57f0 JS |
48 | // Used: controlbar.cpp(1268): set_cursor_bits( _gHorizCursorImg, bits, 32, 16 ); |
49 | // Used: controlbar.cpp(1272): set_cursor_bits( _gVertCursorImg, bits, 32, 16 ); | |
8e08b761 JS |
50 | /* |
51 | static void set_cursor_bits( const char** img, char* bits, int width, int height ) | |
52 | { | |
4cbc57f0 JS |
53 | for( int i = 0; i != (width*height)/8; ++i ) |
54 | bits[i] = 0; | |
8e08b761 | 55 | |
4cbc57f0 JS |
56 | for( int y = 0; y != height; ++y ) |
57 | { | |
58 | const char* row = img[0]; | |
8e08b761 | 59 | |
4cbc57f0 JS |
60 | for( int x = 0; x != width; ++x ) |
61 | { | |
62 | int bitNo = y*width + x; | |
8e08b761 | 63 | |
4cbc57f0 | 64 | char value = ( row[x] != '.' ) ? 1 : 0; |
8e08b761 | 65 | |
4cbc57f0 JS |
66 | bits[ bitNo / sizeof(char) ] |= |
67 | ( ( bitNo %sizeof(char) ) << value ); | |
68 | } | |
8e08b761 | 69 | |
4cbc57f0 JS |
70 | ++img; |
71 | } | |
8e08b761 JS |
72 | } |
73 | */ | |
74 | ||
75 | /***** Implementation for class cbPaneDrawPlugin *****/ | |
76 | ||
77 | IMPLEMENT_DYNAMIC_CLASS( cbPaneDrawPlugin, cbPluginBase ) | |
78 | ||
79 | BEGIN_EVENT_TABLE( cbPaneDrawPlugin, cbPluginBase ) | |
80 | ||
4cbc57f0 JS |
81 | EVT_PL_LEFT_DOWN ( cbPaneDrawPlugin::OnLButtonDown ) |
82 | EVT_PL_LEFT_UP ( cbPaneDrawPlugin::OnLButtonUp ) | |
83 | // EVT_PL_LEFT_DCLICK ( cbPaneDrawPlugin::OnLDblClick ) | |
84 | EVT_PL_RIGHT_UP ( cbPaneDrawPlugin::OnRButtonUp ) | |
85 | EVT_PL_MOTION ( cbPaneDrawPlugin::OnMouseMove ) | |
8e08b761 JS |
86 | |
87 | ||
4cbc57f0 JS |
88 | EVT_PL_DRAW_PANE_BKGROUND ( cbPaneDrawPlugin::OnDrawPaneBackground ) |
89 | EVT_PL_DRAW_PANE_DECOR ( cbPaneDrawPlugin::OnDrawPaneDecorations ) | |
8e08b761 | 90 | |
4cbc57f0 JS |
91 | EVT_PL_DRAW_ROW_DECOR ( cbPaneDrawPlugin::OnDrawRowDecorations ) |
92 | EVT_PL_DRAW_ROW_HANDLES ( cbPaneDrawPlugin::OnDrawRowHandles ) | |
93 | EVT_PL_DRAW_ROW_BKGROUND ( cbPaneDrawPlugin::OnDrawRowBackground ) | |
8e08b761 | 94 | |
4cbc57f0 JS |
95 | EVT_PL_SIZE_BAR_WND ( cbPaneDrawPlugin::OnSizeBarWindow ) |
96 | EVT_PL_DRAW_BAR_DECOR ( cbPaneDrawPlugin::OnDrawBarDecorations ) | |
97 | EVT_PL_DRAW_BAR_HANDLES ( cbPaneDrawPlugin::OnDrawBarHandles ) | |
8e08b761 | 98 | |
4cbc57f0 JS |
99 | EVT_PL_START_DRAW_IN_AREA ( cbPaneDrawPlugin::OnStartDrawInArea ) |
100 | EVT_PL_FINISH_DRAW_IN_AREA ( cbPaneDrawPlugin::OnFinishDrawInArea ) | |
8e08b761 JS |
101 | |
102 | END_EVENT_TABLE() | |
103 | ||
104 | cbPaneDrawPlugin::cbPaneDrawPlugin(void) | |
105 | ||
4cbc57f0 | 106 | : mResizeStarted ( FALSE ), |
8e08b761 | 107 | |
4cbc57f0 JS |
108 | mResizeCursorOn ( FALSE ), |
109 | mpDraggedBar ( NULL ), | |
110 | mpResizedRow ( NULL ), | |
8e08b761 JS |
111 | |
112 | mRowHandleHitted ( FALSE ), | |
4cbc57f0 JS |
113 | mIsUpperHandle ( FALSE ), |
114 | mBarHandleHitted ( FALSE ), | |
115 | mIsLeftHandle ( FALSE ), | |
116 | mBarContentHitted ( FALSE ), | |
8e08b761 | 117 | |
4cbc57f0 JS |
118 | mpClntDc ( NULL ), |
119 | mpPane ( NULL ) | |
8e08b761 JS |
120 | {} |
121 | ||
122 | cbPaneDrawPlugin::cbPaneDrawPlugin( wxFrameLayout* pPanel, int paneMask ) | |
123 | ||
4cbc57f0 JS |
124 | : cbPluginBase( pPanel, paneMask ), |
125 | ||
126 | // bar-row resizing state varaibles | |
8e08b761 | 127 | |
4cbc57f0 | 128 | mResizeStarted ( FALSE ), |
8e08b761 | 129 | |
4cbc57f0 JS |
130 | mResizeCursorOn ( FALSE ), |
131 | mpDraggedBar ( NULL ), | |
132 | mpResizedRow ( NULL ), | |
8e08b761 | 133 | |
4cbc57f0 JS |
134 | mRowHandleHitted ( FALSE ), |
135 | mIsUpperHandle ( FALSE ), | |
136 | mBarHandleHitted ( FALSE ), | |
137 | mIsLeftHandle ( FALSE ), | |
138 | mBarContentHitted ( FALSE ), | |
8e08b761 | 139 | |
4cbc57f0 JS |
140 | mpClntDc ( NULL ), |
141 | mpPane ( NULL ) | |
8e08b761 JS |
142 | {} |
143 | ||
144 | cbPaneDrawPlugin::~cbPaneDrawPlugin() | |
145 | { | |
4cbc57f0 JS |
146 | // DBG:: |
147 | wxASSERT( mpClntDc == NULL ); | |
8e08b761 JS |
148 | } |
149 | ||
150 | void cbPaneDrawPlugin::DrawDraggedHandle( const wxPoint& pos, cbDockPane& pane ) | |
151 | { | |
4cbc57f0 JS |
152 | wxScreenDC dc; |
153 | int ofsX = 0; | |
154 | int ofsY = 0; | |
8e08b761 | 155 | |
4cbc57f0 JS |
156 | wxPoint fpos = pos; |
157 | pane.PaneToFrame( &fpos.x, &fpos.y ); | |
8e08b761 | 158 | |
4cbc57f0 JS |
159 | // short-cut |
160 | int resizeHndSize = pane.mProps.mResizeHandleSize; | |
8e08b761 JS |
161 | |
162 | // "Required for X to specify that | |
163 | // that we wish to draw on top of all windows | |
164 | // - and we optimise by specifying the area | |
165 | // for creating the overlap window." --J.S. | |
166 | ||
4cbc57f0 | 167 | wxScreenDC::StartDrawingOnTop(&mpLayout->GetParentFrame()); |
8e08b761 | 168 | |
4cbc57f0 | 169 | mpLayout->GetParentFrame().ClientToScreen( &ofsX, &ofsY ); |
8e08b761 | 170 | |
4cbc57f0 | 171 | int prevLF = dc.GetLogicalFunction(); |
8e08b761 | 172 | |
4cbc57f0 JS |
173 | // BUG BUG BUG (wx):: somehow stippled brush works only |
174 | // when the bitmap created on stack, not | |
175 | // as a member of the class | |
8e08b761 | 176 | |
4cbc57f0 | 177 | wxBitmap checker( (const char*)_gCheckerImg, 8,8 ); |
8e08b761 | 178 | |
4cbc57f0 | 179 | wxBrush checkerBrush( checker ); |
8e08b761 | 180 | |
4cbc57f0 JS |
181 | dc.SetPen( mpLayout->mNullPen ); |
182 | dc.SetBrush( checkerBrush ); | |
183 | dc.SetLogicalFunction( wxXOR ); | |
8e08b761 | 184 | |
4cbc57f0 JS |
185 | if ( mHandleIsVertical ) |
186 | { | |
187 | int delta = pos.x - mDragOrigin.x; | |
8e08b761 | 188 | |
4cbc57f0 | 189 | if ( !pane.IsHorizontal() ) |
8e08b761 | 190 | |
4cbc57f0 | 191 | delta = pos.y - mDragOrigin.y; |
8e08b761 | 192 | |
4cbc57f0 JS |
193 | int realHndOfs; |
194 | realHndOfs = pane.mBoundsInParent.x + pane.mLeftMargin + mHandleOfs; | |
8e08b761 | 195 | |
4cbc57f0 | 196 | int newX = realHndOfs + delta; |
8e08b761 | 197 | |
4cbc57f0 | 198 | if ( newX + resizeHndSize > mHandleDragArea.x + mHandleDragArea.width ) |
8e08b761 | 199 | |
4cbc57f0 | 200 | newX = mHandleDragArea.x + mHandleDragArea.width - 1; |
8e08b761 | 201 | |
4cbc57f0 | 202 | if ( newX < mHandleDragArea.x ) |
8e08b761 | 203 | |
4cbc57f0 | 204 | newX = mHandleDragArea.x; |
8e08b761 | 205 | |
4cbc57f0 | 206 | mDraggedDelta = newX - realHndOfs; |
8e08b761 | 207 | |
4cbc57f0 JS |
208 | dc.DrawRectangle( newX + ofsX, mHandleDragArea.y + ofsY, |
209 | resizeHndSize + 1, | |
210 | mHandleDragArea.height+1 ); | |
211 | } | |
212 | else | |
213 | { | |
214 | // otherwise, draw horizontal handle | |
8e08b761 | 215 | |
4cbc57f0 | 216 | int delta = pos.y - mDragOrigin.y; |
8e08b761 | 217 | |
4cbc57f0 | 218 | if ( !pane.IsHorizontal() ) |
8e08b761 | 219 | |
4cbc57f0 | 220 | delta = pos.x - mDragOrigin.x; |
8e08b761 | 221 | |
4cbc57f0 JS |
222 | int realHndOfs; |
223 | realHndOfs = pane.mBoundsInParent.y + pane.mTopMargin + mHandleOfs; | |
8e08b761 | 224 | |
4cbc57f0 | 225 | int newY = realHndOfs + delta; |
8e08b761 | 226 | |
4cbc57f0 | 227 | if ( newY + resizeHndSize > mHandleDragArea.y + mHandleDragArea.height ) |
8e08b761 | 228 | |
4cbc57f0 | 229 | newY = mHandleDragArea.y + mHandleDragArea.height - 1; |
8e08b761 | 230 | |
4cbc57f0 | 231 | if ( newY < mHandleDragArea.y ) |
8e08b761 | 232 | |
4cbc57f0 | 233 | newY = mHandleDragArea.y; |
8e08b761 | 234 | |
4cbc57f0 | 235 | mDraggedDelta = newY - realHndOfs; |
8e08b761 | 236 | |
4cbc57f0 JS |
237 | dc.DrawRectangle( mHandleDragArea.x + ofsX, newY + ofsY, |
238 | mHandleDragArea.width + 1, | |
239 | resizeHndSize + 1 ); | |
240 | } | |
8e08b761 | 241 | |
4cbc57f0 | 242 | dc.SetLogicalFunction( prevLF ); |
8e08b761 JS |
243 | |
244 | // "End drawing on top (frees the window used for drawing | |
245 | // over the screen)" --J.S. | |
4cbc57f0 | 246 | wxScreenDC::EndDrawingOnTop(); |
8e08b761 JS |
247 | } |
248 | ||
249 | void cbPaneDrawPlugin::OnMouseMove( cbMotionEvent& event ) | |
250 | { | |
4cbc57f0 JS |
251 | if ( !mResizeStarted ) |
252 | { | |
253 | // if nothing is started, do hit-tests | |
8e08b761 | 254 | |
4cbc57f0 | 255 | bool prevWasRowHandle = mRowHandleHitted; |
8e08b761 | 256 | |
4cbc57f0 JS |
257 | mBarContentHitted = FALSE; |
258 | mBarHandleHitted = FALSE; | |
259 | mRowHandleHitted = FALSE; | |
8e08b761 | 260 | |
4cbc57f0 JS |
261 | int testResult = |
262 | event.mpPane->HitTestPaneItems( event.mPos, // in pane's coordiantes | |
263 | &mpResizedRow, | |
264 | &mpDraggedBar ); | |
8e08b761 | 265 | |
4cbc57f0 JS |
266 | if ( testResult != CB_NO_ITEMS_HITTED ) |
267 | { | |
268 | if ( testResult == CB_BAR_CONTENT_HITTED ) | |
269 | { | |
270 | // restore cursor, if non of the handles were hit | |
271 | if ( mResizeCursorOn ) | |
272 | { | |
273 | // remove resizing hints | |
8e08b761 | 274 | |
4cbc57f0 JS |
275 | mpLayout->ReleaseEventsFromPane( event.mpPane ); |
276 | mpLayout->ReleaseEventsFromPlugin( this ); | |
277 | ||
278 | mResizeCursorOn = FALSE; | |
8e08b761 | 279 | |
4cbc57f0 | 280 | mBarContentHitted = TRUE; |
8e08b761 | 281 | |
4cbc57f0 JS |
282 | mpLayout->GetParentFrame().SetCursor( *mpLayout->mpNormalCursor ); |
283 | } | |
8e08b761 | 284 | |
4cbc57f0 | 285 | // TBD:: fire something like "mouse-over-bar" event |
8e08b761 | 286 | |
4cbc57f0 JS |
287 | event.Skip(); // pass event to the next handler in the chain |
288 | return; | |
289 | } | |
8e08b761 | 290 | |
4cbc57f0 | 291 | wxCursor* pCurs = NULL; |
8e08b761 | 292 | |
4cbc57f0 JS |
293 | if ( testResult == CB_UPPER_ROW_HANDLE_HITTED || |
294 | testResult == CB_LOWER_ROW_HANDLE_HITTED) | |
295 | { | |
296 | if ( event.mpPane->IsHorizontal() ) | |
8e08b761 | 297 | |
4cbc57f0 JS |
298 | pCurs = mpLayout->mpVertCursor; |
299 | else | |
300 | pCurs = mpLayout->mpHorizCursor; | |
8e08b761 | 301 | |
4cbc57f0 JS |
302 | mRowHandleHitted = TRUE; |
303 | mIsUpperHandle = ( testResult == CB_UPPER_ROW_HANDLE_HITTED ); | |
304 | } | |
305 | else | |
306 | { | |
307 | // otherwise, if inter-bar handle was hitted | |
8e08b761 | 308 | |
4cbc57f0 | 309 | if ( event.mpPane->IsHorizontal() ) |
8e08b761 | 310 | |
4cbc57f0 JS |
311 | pCurs = mpLayout->mpHorizCursor; |
312 | else | |
313 | pCurs = mpLayout->mpVertCursor; | |
8e08b761 | 314 | |
4cbc57f0 JS |
315 | mBarHandleHitted = TRUE; |
316 | mIsLeftHandle = ( testResult == CB_LEFT_BAR_HANDLE_HITTED ); | |
317 | } | |
8e08b761 | 318 | |
4cbc57f0 | 319 | // avoid setting the same cursor twice |
8e08b761 | 320 | |
4cbc57f0 JS |
321 | if ( !mResizeCursorOn || prevWasRowHandle != mRowHandleHitted ) |
322 | { | |
323 | if ( !mResizeCursorOn ) | |
324 | { | |
325 | // caputre if not captured yet | |
326 | mpLayout->CaptureEventsForPane( event.mpPane ); | |
327 | mpLayout->CaptureEventsForPlugin( this ); | |
328 | } | |
8e08b761 | 329 | |
4cbc57f0 JS |
330 | mpLayout->GetParentFrame().SetCursor( *pCurs ); |
331 | } | |
8e08b761 | 332 | |
4cbc57f0 | 333 | mResizeCursorOn = TRUE; |
8e08b761 | 334 | |
4cbc57f0 | 335 | // handled is being dragged now, thus event is "eaten" by this plugin |
8e08b761 | 336 | |
4cbc57f0 | 337 | return; |
8e08b761 | 338 | |
4cbc57f0 | 339 | } // end of if (HitTestBarHandles()) |
8e08b761 | 340 | |
4cbc57f0 JS |
341 | // restore cursor, if non of the handles were hit |
342 | if ( mResizeCursorOn ) | |
343 | { | |
344 | mpLayout->ReleaseEventsFromPane( event.mpPane ); | |
345 | mpLayout->ReleaseEventsFromPlugin( this ); | |
8e08b761 | 346 | |
4cbc57f0 | 347 | mpLayout->GetParentFrame().SetCursor( *mpLayout->mpNormalCursor ); |
8e08b761 | 348 | |
4cbc57f0 JS |
349 | mResizeCursorOn = FALSE; |
350 | } | |
8e08b761 | 351 | |
4cbc57f0 JS |
352 | event.Skip(); // pass event to the next plugin |
353 | } | |
8e08b761 | 354 | |
4cbc57f0 | 355 | // othewise series of actions, if something has already started |
8e08b761 | 356 | |
4cbc57f0 JS |
357 | else |
358 | if ( mResizeStarted ) | |
359 | { | |
360 | // apply xor-mask twice | |
361 | DrawDraggedHandle( mPrevPos, *event.mpPane ); | |
8e08b761 | 362 | |
4cbc57f0 JS |
363 | // draw handle in the new position |
364 | DrawDraggedHandle( event.mPos, *event.mpPane ); | |
365 | mPrevPos = event.mPos; | |
8e08b761 | 366 | |
4cbc57f0 JS |
367 | // handled is dragged, thus event is "eaten" by this plugin |
368 | } | |
369 | else | |
370 | event.Skip(); // pass event to the next plugin | |
8e08b761 JS |
371 | } |
372 | ||
373 | void cbPaneDrawPlugin::OnLDblClick( cbLeftDClickEvent& event ) | |
374 | { | |
4cbc57f0 JS |
375 | if ( !mResizeCursorOn ) |
376 | { | |
377 | cbBarInfo* pBarToFloat; | |
378 | ||
379 | if ( event.mpPane->HitTestPaneItems( event.mPos, // in pane's coordiantes | |
380 | &mpResizedRow, | |
381 | &pBarToFloat ) == CB_BAR_CONTENT_HITTED | |
382 | ) | |
383 | { | |
384 | return; | |
385 | } | |
386 | ||
387 | event.Skip(); | |
388 | } | |
8e08b761 JS |
389 | } |
390 | ||
391 | void cbPaneDrawPlugin::OnLButtonDown( cbLeftDownEvent& event ) | |
392 | { | |
4cbc57f0 | 393 | wxASSERT( !mResizeStarted ); |
8e08b761 | 394 | |
4cbc57f0 JS |
395 | if ( mResizeCursorOn ) |
396 | { | |
397 | mResizeStarted = TRUE; | |
398 | mDragOrigin = event.mPos; | |
399 | ||
400 | // setup constraints for the dragging handle | |
8e08b761 | 401 | |
4cbc57f0 JS |
402 | int from, till; |
403 | mHandleOfs = 0; | |
404 | mHandleIsVertical = FALSE; | |
8e08b761 | 405 | |
4cbc57f0 | 406 | if ( mRowHandleHitted ) |
8e08b761 | 407 | |
4cbc57f0 JS |
408 | event.mpPane->GetRowResizeRange( mpResizedRow, &from, &till, mIsUpperHandle ); |
409 | else | |
410 | // otherwise if bar handle was hitted | |
411 | event.mpPane->GetBarResizeRange( mpDraggedBar, &from, &till, mIsLeftHandle ); | |
412 | ||
413 | if ( mRowHandleHitted ) | |
414 | { | |
415 | mHandleIsVertical = ( event.mpPane->IsHorizontal() ) ? FALSE : TRUE; | |
8e08b761 | 416 | |
4cbc57f0 JS |
417 | mHandleDragArea.x = 0; |
418 | mHandleDragArea.width = event.mpPane->mPaneWidth; | |
8e08b761 | 419 | |
4cbc57f0 JS |
420 | mHandleDragArea.y = from; |
421 | mHandleDragArea.height = till - from; | |
8e08b761 | 422 | |
4cbc57f0 | 423 | if ( mIsUpperHandle ) |
8e08b761 | 424 | |
4cbc57f0 JS |
425 | mHandleOfs = mpResizedRow->mRowY; |
426 | else | |
427 | mHandleOfs = mpResizedRow->mRowY + | |
428 | mpResizedRow->mRowHeight - | |
429 | event.mpPane->mProps.mResizeHandleSize; | |
430 | } | |
431 | else | |
432 | { | |
433 | // otehrwise if bar handle dragged | |
8e08b761 | 434 | |
4cbc57f0 JS |
435 | // cbRowInfo& rowInfo = *mpDraggedBar->mpRow; |
436 | wxRect& bounds = mpDraggedBar->mBounds; | |
8e08b761 | 437 | |
4cbc57f0 | 438 | mHandleIsVertical = ( event.mpPane->IsHorizontal() ) ? TRUE : FALSE; |
8e08b761 | 439 | |
4cbc57f0 JS |
440 | mHandleDragArea.x = from; |
441 | mHandleDragArea.width = till - from; | |
8e08b761 JS |
442 | |
443 | ||
4cbc57f0 JS |
444 | mHandleDragArea.y = bounds.y; |
445 | mHandleDragArea.height = bounds.height; | |
8e08b761 | 446 | |
4cbc57f0 JS |
447 | // left-side-handle mBounds |
448 | if ( mIsLeftHandle ) | |
8e08b761 | 449 | |
4cbc57f0 JS |
450 | mHandleOfs = bounds.x; |
451 | else | |
452 | mHandleOfs = bounds.x + | |
453 | bounds.width - event.mpPane->mProps.mResizeHandleSize; | |
8e08b761 | 454 | |
4cbc57f0 | 455 | } |
8e08b761 | 456 | |
4cbc57f0 JS |
457 | event.mpPane->PaneToFrame( &mHandleDragArea ); |
458 | DrawDraggedHandle(mDragOrigin, *event.mpPane); | |
8e08b761 | 459 | |
4cbc57f0 | 460 | mPrevPos = mDragOrigin; |
8e08b761 | 461 | |
4cbc57f0 JS |
462 | return; |
463 | // handled is dragged, thus event is "eaten" by this plugin | |
464 | } | |
465 | else | |
466 | { | |
467 | cbBarInfo* pDraggedBar; | |
8e08b761 | 468 | |
4cbc57f0 JS |
469 | if ( event.mpPane->HitTestPaneItems( event.mPos, // in pane's coordiantes |
470 | &mpResizedRow, | |
471 | &pDraggedBar ) == CB_BAR_CONTENT_HITTED | |
472 | ) | |
473 | { | |
474 | int x = event.mPos.x, | |
475 | y = event.mPos.y; | |
8e08b761 | 476 | |
4cbc57f0 | 477 | event.mpPane->PaneToFrame( &x, &y ); |
8e08b761 | 478 | |
4cbc57f0 | 479 | cbStartBarDraggingEvent dragEvt( pDraggedBar, wxPoint(x,y), event.mpPane ); |
8e08b761 | 480 | |
4cbc57f0 | 481 | mpLayout->FirePluginEvent( dragEvt ); |
8e08b761 | 482 | |
4cbc57f0 JS |
483 | return; // event is "eaten" by this plugin |
484 | } | |
485 | } | |
8e08b761 | 486 | |
4cbc57f0 | 487 | event.Skip(); // pass event to the next plugin in the chain |
8e08b761 JS |
488 | } |
489 | ||
490 | void cbPaneDrawPlugin::OnLButtonUp( cbLeftUpEvent& event ) | |
491 | { | |
4cbc57f0 JS |
492 | if ( mResizeStarted ) |
493 | { | |
494 | DrawDraggedHandle( event.mPos, *event.mpPane ); | |
8e08b761 | 495 | |
4cbc57f0 JS |
496 | mResizeStarted = FALSE; |
497 | mResizeCursorOn = FALSE; | |
8e08b761 | 498 | |
4cbc57f0 JS |
499 | mpLayout->ReleaseEventsFromPane( event.mpPane ); |
500 | mpLayout->ReleaseEventsFromPlugin( this ); | |
8e08b761 | 501 | |
4cbc57f0 | 502 | mpLayout->GetParentFrame().SetCursor( *mpLayout->mpNormalCursor ); |
8e08b761 | 503 | |
4cbc57f0 JS |
504 | if ( mRowHandleHitted ) |
505 | { | |
506 | event.mpPane->ResizeRow( mpResizedRow, | |
507 | mDraggedDelta, | |
508 | mIsUpperHandle ); | |
509 | } | |
510 | else | |
511 | { | |
512 | event.mpPane->ResizeBar( mpDraggedBar, | |
513 | mDraggedDelta, | |
514 | mIsLeftHandle ); | |
515 | } | |
8e08b761 | 516 | |
4cbc57f0 JS |
517 | mpDraggedBar = NULL; |
518 | mpResizedRow = NULL; | |
8e08b761 | 519 | |
4cbc57f0 JS |
520 | // handled dragging action was finished by this mouse-up, |
521 | // thus event is "eaten" by this plugin | |
8e08b761 | 522 | |
4cbc57f0 JS |
523 | return; |
524 | } | |
8e08b761 | 525 | |
4cbc57f0 | 526 | event.Skip(); // pass event to the next plugin |
8e08b761 JS |
527 | } |
528 | ||
529 | void cbPaneDrawPlugin::OnRButtonUp( cbRightUpEvent& event ) | |
530 | { | |
4cbc57f0 JS |
531 | wxPoint fpos = event.mPos; |
532 | event.mpPane->PaneToFrame( &fpos.x, &fpos.y ); | |
8e08b761 | 533 | |
4cbc57f0 | 534 | cbBarInfo* pDraggedBar; |
8e08b761 | 535 | |
4cbc57f0 | 536 | // user clicks inside the bar contnet, fire bar-customization event |
8e08b761 | 537 | |
4cbc57f0 JS |
538 | if ( event.mpPane->HitTestPaneItems( event.mPos, // in pane's coordiantes |
539 | &mpResizedRow, | |
540 | &pDraggedBar ) == CB_BAR_CONTENT_HITTED | |
541 | ) | |
542 | { | |
543 | cbCustomizeBarEvent cbEvt( pDraggedBar, fpos, event.mpPane ); | |
8e08b761 | 544 | |
4cbc57f0 | 545 | mpLayout->FirePluginEvent( cbEvt ); |
8e08b761 | 546 | |
4cbc57f0 JS |
547 | return; // event is "eaten" by this plugin |
548 | } | |
8e08b761 | 549 | |
4cbc57f0 | 550 | // otherwise fire whole-layout customization event |
8e08b761 | 551 | |
4cbc57f0 | 552 | cbCustomizeLayoutEvent csEvt( fpos ); |
8e08b761 | 553 | |
4cbc57f0 | 554 | mpLayout->FirePluginEvent( csEvt ); |
8e08b761 | 555 | |
4cbc57f0 | 556 | // event is "eaten" by this plugin |
8e08b761 JS |
557 | } |
558 | ||
559 | void cbPaneDrawPlugin::OnSizeBarWindow( cbSizeBarWndEvent& event ) | |
560 | { | |
4cbc57f0 JS |
561 | cbBarInfo& bar = *event.mpBar; |
562 | mpPane = event.mpPane; | |
8e08b761 | 563 | |
4cbc57f0 JS |
564 | // it's possible that a bar does not have it's own window! |
565 | if ( !bar.mpBarWnd ) return; | |
8e08b761 | 566 | |
4cbc57f0 | 567 | wxRect& bounds = event.mBoundsInParent; |
8e08b761 | 568 | |
4cbc57f0 JS |
569 | // check visibility |
570 | if ( bounds.height != 0 ) | |
571 | { | |
572 | // size smaller than bounds, to leave space for shade lines | |
8e08b761 | 573 | |
4cbc57f0 | 574 | // FIXME:: +/- 1s |
8e08b761 | 575 | |
4cbc57f0 JS |
576 | bar.mpBarWnd->wxWindow::SetSize( bounds.x + 1 + bar.mDimInfo.mHorizGap, |
577 | bounds.y + 1 + bar.mDimInfo.mVertGap, | |
578 | bounds.width - 2 - bar.mDimInfo.mHorizGap*2, | |
579 | bounds.height - 2 - bar.mDimInfo.mVertGap *2 , | |
580 | 0 | |
581 | ); | |
8e08b761 | 582 | |
4cbc57f0 | 583 | if ( !bar.mpBarWnd->IsShown() ) |
8e08b761 | 584 | |
4cbc57f0 JS |
585 | bar.mpBarWnd->Show( TRUE ); |
586 | } | |
587 | else | |
588 | // hide bar if not visible | |
589 | bar.mpBarWnd->Show( FALSE ); | |
8e08b761 | 590 | |
4cbc57f0 | 591 | event.Skip(); // pass event to the next plugin in the chain |
8e08b761 JS |
592 | } |
593 | ||
594 | void cbPaneDrawPlugin::OnDrawRowDecorations( cbDrawRowDecorEvent& event ) | |
595 | { | |
4cbc57f0 | 596 | DrawPaneShadeForRow( event.mpRow, *event.mpDc ); |
8e08b761 | 597 | |
4cbc57f0 | 598 | event.Skip(); // pass event to the next plugin |
8e08b761 JS |
599 | } |
600 | ||
601 | void cbPaneDrawPlugin::DrawUpperRowHandle( cbRowInfo* pRow, wxDC& dc ) | |
602 | { | |
4cbc57f0 JS |
603 | wxRect& bounds = pRow->mBoundsInParent; |
604 | ||
605 | if ( mpPane->IsHorizontal() ) | |
606 | { | |
607 | if ( pRow->mHasUpperHandle ) | |
608 | ||
609 | mpPane->DrawHorizHandle( dc, bounds.x, | |
610 | bounds.y-1, | |
611 | pRow->mRowWidth ); | |
612 | } | |
613 | else | |
614 | { | |
615 | if ( pRow->mHasUpperHandle ) | |
616 | ||
617 | mpPane->DrawVertHandle( dc, bounds.x-1, | |
618 | bounds.y, pRow->mRowWidth ); | |
619 | } | |
8e08b761 JS |
620 | } |
621 | ||
622 | void cbPaneDrawPlugin::DrawLowerRowHandle( cbRowInfo* pRow, wxDC& dc ) | |
623 | { | |
4cbc57f0 JS |
624 | wxRect& bounds = pRow->mBoundsInParent; |
625 | ||
626 | // check if iter-row handles present | |
627 | ||
628 | if ( mpPane->IsHorizontal() ) | |
629 | { | |
630 | if ( pRow->mHasLowerHandle ) | |
631 | ||
632 | mpPane->DrawHorizHandle( dc, bounds.x, bounds.y + bounds.height - mpPane->mProps.mResizeHandleSize - 1, | |
633 | pRow->mRowWidth ); | |
634 | } | |
635 | else | |
636 | { | |
637 | if ( pRow->mHasLowerHandle ) | |
638 | ||
639 | mpPane->DrawVertHandle( dc, bounds.x + bounds.width - mpPane->mProps.mResizeHandleSize - 1, | |
640 | bounds.y, pRow->mRowWidth ); | |
641 | } | |
8e08b761 JS |
642 | } |
643 | ||
644 | void cbPaneDrawPlugin::OnDrawRowHandles( cbDrawRowHandlesEvent& event ) | |
645 | { | |
4cbc57f0 JS |
646 | // short-cuts |
647 | cbRowInfo* pRow = event.mpRow; | |
648 | wxDC& dc = *event.mpDc; | |
649 | mpPane = event.mpPane; | |
8e08b761 | 650 | |
4cbc57f0 | 651 | // draw handles of surrounding rows first |
8e08b761 | 652 | |
4cbc57f0 | 653 | if ( pRow->mpPrev && pRow->mpPrev->mHasLowerHandle ) |
8e08b761 | 654 | |
4cbc57f0 | 655 | DrawLowerRowHandle( pRow->mpPrev, dc ); |
8e08b761 | 656 | |
4cbc57f0 | 657 | if ( pRow->mpNext && pRow->mpNext->mHasUpperHandle ) |
8e08b761 | 658 | |
4cbc57f0 | 659 | DrawUpperRowHandle( pRow->mpNext, dc ); |
8e08b761 | 660 | |
4cbc57f0 | 661 | // draw handles of the given row |
8e08b761 | 662 | |
4cbc57f0 JS |
663 | if ( pRow->mHasUpperHandle ) |
664 | ||
665 | DrawUpperRowHandle( pRow, dc ); | |
8e08b761 | 666 | |
4cbc57f0 | 667 | if ( pRow->mHasLowerHandle ) |
8e08b761 | 668 | |
4cbc57f0 | 669 | DrawLowerRowHandle( pRow, dc ); |
8e08b761 | 670 | |
4cbc57f0 | 671 | event.Skip(); // pass event to the next plugin |
8e08b761 JS |
672 | } |
673 | ||
674 | void cbPaneDrawPlugin::OnDrawPaneBackground ( cbDrawPaneBkGroundEvent& event ) | |
675 | { | |
4cbc57f0 JS |
676 | wxDC& dc = *event.mpDc; |
677 | mpPane = event.mpPane; | |
8e08b761 | 678 | |
4cbc57f0 JS |
679 | // FOR NOW:: hard-coded |
680 | wxBrush bkBrush( mpLayout->mBorderPen.GetColour(), wxSOLID ); | |
8e08b761 | 681 | |
4cbc57f0 JS |
682 | dc.SetBrush( bkBrush ); |
683 | dc.SetPen( mpLayout->mNullPen ); | |
8e08b761 | 684 | |
4cbc57f0 | 685 | wxRect& bounds = mpPane->mBoundsInParent; |
8e08b761 | 686 | |
4cbc57f0 JS |
687 | if ( mpPane->mTopMargin >= 1 ) |
688 | ||
689 | dc.DrawRectangle( bounds.x, bounds.y, | |
690 | bounds.width+1, | |
691 | mpPane->mTopMargin + 1); | |
8e08b761 JS |
692 | |
693 | ||
4cbc57f0 JS |
694 | if ( mpPane->mBottomMargin >= 1 ) |
695 | ||
696 | dc.DrawRectangle( bounds.x, | |
697 | bounds.y + bounds.height - mpPane->mBottomMargin, | |
698 | bounds.width + 1, | |
699 | mpPane->mBottomMargin + 1); | |
8e08b761 JS |
700 | |
701 | ||
4cbc57f0 JS |
702 | if ( mpPane->mLeftMargin >= 1 ) |
703 | ||
704 | dc.DrawRectangle( bounds.x, | |
705 | bounds.y + mpPane->mTopMargin - 1, | |
706 | mpPane->mLeftMargin + 1, | |
707 | bounds.height - mpPane->mTopMargin - mpPane->mBottomMargin + 2); | |
8e08b761 JS |
708 | |
709 | ||
4cbc57f0 JS |
710 | if ( mpPane->mRightMargin >= 1 ) |
711 | ||
712 | dc.DrawRectangle( bounds.x + bounds.width - mpPane->mRightMargin, | |
713 | bounds.y + mpPane->mTopMargin - 1, | |
714 | mpPane->mRightMargin + 1, | |
715 | bounds.height - mpPane->mTopMargin - mpPane->mBottomMargin + 2); | |
8e08b761 | 716 | |
4cbc57f0 | 717 | event.Skip(); // pass event to the next plugin |
8e08b761 JS |
718 | } |
719 | ||
720 | void cbPaneDrawPlugin::OnDrawRowBackground ( cbDrawRowBkGroundEvent& event ) | |
721 | { | |
4cbc57f0 JS |
722 | // short-cuts |
723 | cbRowInfo* pRow = event.mpRow; | |
724 | wxDC& dc = *event.mpDc; | |
725 | mpPane = event.mpPane; | |
726 | ||
727 | // get ready | |
728 | wxRect rowBounds = pRow->mBoundsInParent; | |
729 | bool isHorizontal = event.mpPane->IsHorizontal(); | |
730 | ||
731 | // int prevPos; | |
732 | ||
733 | if ( isHorizontal ) | |
734 | { | |
735 | // prevPos = rowBounds.x; | |
736 | // include one line above and below the row | |
737 | --rowBounds.y; | |
738 | rowBounds.height += 2; | |
739 | ||
740 | --rowBounds.x; | |
741 | rowBounds.width += 2; | |
742 | } | |
743 | else | |
744 | { | |
745 | // prevPos = rowBounds.y; | |
746 | // include one line above and below the row | |
747 | --rowBounds.x; | |
748 | rowBounds.width += 2; | |
749 | ||
750 | --rowBounds.y; | |
751 | rowBounds.height += 2; | |
752 | } | |
8e08b761 JS |
753 | |
754 | //#define TEST_BK_ERASING | |
755 | ||
756 | #ifdef TEST_BK_ERASING | |
757 | ||
4cbc57f0 JS |
758 | // DBG:: |
759 | wxBrush br0( wxColour(0,160,160), wxSOLID ); | |
760 | dc.SetBrush(br0); | |
761 | dc.SetPen ( mpLayout->mNullPen ); | |
762 | dc.DrawRectangle( rowBounds.x, rowBounds.y, | |
763 | rowBounds.width + 1, | |
764 | rowBounds.height + 1 ); | |
8e08b761 JS |
765 | #endif |
766 | ||
4cbc57f0 | 767 | wxBrush bkBrush( mpLayout->mGrayPen.GetColour(), wxSOLID ); |
8e08b761 | 768 | |
4cbc57f0 JS |
769 | dc.SetPen ( mpLayout->mNullPen ); |
770 | dc.SetBrush( bkBrush ); | |
8e08b761 | 771 | |
4cbc57f0 JS |
772 | // fill background-recatangle of entire row area |
773 | dc.DrawRectangle( rowBounds.x, rowBounds.y, | |
774 | rowBounds.width + 1, | |
775 | rowBounds.height + 1 ); | |
8e08b761 | 776 | |
4cbc57f0 | 777 | dc.SetBrush( wxNullBrush ); |
8e08b761 | 778 | |
4cbc57f0 JS |
779 | // draw "shaded-side-bars" for each bar |
780 | for( size_t i = 0; i != pRow->mBars.Count(); ++i ) | |
781 | { | |
782 | wxRect& bounds = pRow->mBars[i]->mBoundsInParent; | |
8e08b761 | 783 | |
4cbc57f0 JS |
784 | if ( isHorizontal ) |
785 | { | |
786 | DrawShade( 1, bounds, FL_ALIGN_LEFT, dc ); | |
787 | DrawShade( 1, bounds, FL_ALIGN_RIGHT, dc ); | |
788 | } | |
789 | else | |
790 | { | |
791 | DrawShade( 1, bounds, FL_ALIGN_TOP, dc ); | |
792 | DrawShade( 1, bounds, FL_ALIGN_BOTTOM, dc ); | |
793 | } | |
794 | } | |
8e08b761 | 795 | |
4cbc57f0 | 796 | // draw extra shades to simulate "glued-bricks" effect |
8e08b761 | 797 | |
4cbc57f0 JS |
798 | // TBD:: reduce exessive drawing of shades, when the |
799 | // row handle is present, and shades will be overr-drawn anyway | |
8e08b761 | 800 | |
4cbc57f0 | 801 | DrawUpperRowShades( pRow, dc, 1 ); // outer shade |
8e08b761 | 802 | |
4cbc57f0 JS |
803 | if ( pRow->mpPrev ) |
804 | { | |
805 | DrawLowerRowShades( pRow->mpPrev, dc, 1 ); // outter shade | |
806 | DrawLowerRowShades( pRow->mpPrev, dc, 0 ); // inner shade | |
807 | } | |
8e08b761 | 808 | |
4cbc57f0 | 809 | DrawLowerRowShades( pRow, dc, 1 ); |
8e08b761 | 810 | |
4cbc57f0 JS |
811 | if ( pRow->mpNext ) |
812 | { | |
813 | DrawUpperRowShades( pRow->mpNext, dc, 1 ); | |
814 | DrawUpperRowShades( pRow->mpNext, dc, 0 ); | |
815 | } | |
8e08b761 | 816 | |
4cbc57f0 | 817 | event.Skip(); // pass event to the next plugin |
8e08b761 JS |
818 | } |
819 | ||
820 | void cbPaneDrawPlugin::DrawUpperRowShades( cbRowInfo* pRow, wxDC& dc, int level ) | |
821 | { | |
4cbc57f0 JS |
822 | for( size_t i = 0; i != pRow->mBars.Count(); ++i ) |
823 | { | |
824 | wxRect& bounds = pRow->mBars[i]->mBoundsInParent; | |
825 | ||
826 | if ( mpPane->IsHorizontal() ) | |
827 | { | |
828 | DrawShade( level, bounds, FL_ALIGN_TOP, dc ); | |
829 | if ( level == 1 ) | |
830 | { | |
831 | dc.SetPen( mpLayout->mDarkPen ); | |
832 | dc.DrawPoint( bounds.x - 1, bounds.y ); | |
833 | dc.SetPen( mpLayout->mLightPen ); | |
834 | dc.DrawPoint( bounds.x + bounds.width , bounds.y ); | |
835 | } | |
836 | } | |
837 | else | |
838 | { | |
839 | DrawShade( level, bounds, FL_ALIGN_LEFT, dc ); | |
840 | if ( level == 1 ) | |
841 | { | |
842 | dc.SetPen( mpLayout->mDarkPen ); | |
843 | dc.DrawPoint( bounds.x, bounds.y -1 ); | |
844 | dc.SetPen( mpLayout->mLightPen ); | |
845 | dc.DrawPoint( bounds.x, bounds.y + bounds.height ); | |
846 | } | |
847 | } | |
848 | } | |
8e08b761 JS |
849 | } |
850 | ||
851 | void cbPaneDrawPlugin::DrawLowerRowShades( cbRowInfo* pRow, wxDC& dc, int level ) | |
852 | { | |
4cbc57f0 JS |
853 | for( size_t i = 0; i != pRow->mBars.Count(); ++i ) |
854 | { | |
855 | wxRect& bounds = pRow->mBars[i]->mBoundsInParent; | |
856 | ||
857 | if ( mpPane->IsHorizontal() ) | |
858 | { | |
859 | DrawShade( level, bounds, FL_ALIGN_BOTTOM, dc ); | |
860 | if ( level == 1 ) | |
861 | { | |
862 | dc.SetPen( mpLayout->mDarkPen ); | |
863 | dc.DrawPoint( bounds.x - 1, bounds.y + bounds.height -1 ); | |
864 | dc.SetPen( mpLayout->mLightPen ); | |
865 | dc.DrawPoint( bounds.x + bounds.width , bounds.y + bounds.height -1 ); | |
866 | } | |
867 | } | |
868 | else | |
869 | { | |
870 | DrawShade( level, bounds, FL_ALIGN_RIGHT, dc ); | |
871 | if ( level == 1 ) | |
872 | { | |
873 | dc.SetPen( mpLayout->mDarkPen ); | |
874 | dc.DrawPoint( bounds.x + bounds.width - 1, bounds.y -1 ); | |
875 | dc.SetPen( mpLayout->mLightPen ); | |
876 | dc.DrawPoint( bounds.x + bounds.width - 1, bounds.y + bounds.height ); | |
877 | } | |
878 | } | |
879 | } | |
8e08b761 JS |
880 | } |
881 | ||
882 | void cbPaneDrawPlugin::DrawBarInnerShadeRect( cbBarInfo* pBar, wxDC& dc ) | |
883 | { | |
4cbc57f0 JS |
884 | wxRect& bounds = pBar->mBoundsInParent; |
885 | ||
886 | dc.SetPen( mpLayout->mDarkPen ); | |
887 | ||
888 | dc.DrawLine( bounds.x + bounds.width - 1, | |
889 | bounds.y, | |
890 | bounds.x + bounds.width - 1, | |
891 | bounds.y + bounds.height ); | |
892 | ||
893 | dc.DrawLine( bounds.x, | |
894 | bounds.y + bounds.height - 1, | |
895 | bounds.x + bounds.width, | |
896 | bounds.y + bounds.height -1 ); | |
897 | ||
898 | dc.SetPen( mpLayout->mLightPen ); | |
899 | ||
900 | dc.DrawLine( bounds.x, | |
901 | bounds.y, | |
902 | bounds.x + bounds.width - 1, | |
903 | bounds.y ); | |
904 | ||
905 | dc.DrawLine( bounds.x, | |
906 | bounds.y, | |
907 | bounds.x, | |
908 | bounds.y + bounds.height - 1 ); | |
8e08b761 JS |
909 | } |
910 | ||
911 | void cbPaneDrawPlugin::DrawShade( int level, wxRect& rect, int alignment, wxDC& dc ) | |
912 | { | |
4cbc57f0 JS |
913 | // simulates "guled-bricks" appearence of control bars |
914 | ||
915 | if ( ( alignment == FL_ALIGN_TOP && level == 1 ) || | |
916 | ( alignment == FL_ALIGN_BOTTOM && level == 0 ) || | |
917 | ( alignment == FL_ALIGN_LEFT && level == 1 ) || | |
918 | ( alignment == FL_ALIGN_RIGHT && level == 0 ) | |
919 | ) | |
920 | ||
921 | dc.SetPen( mpLayout->mDarkPen ); | |
922 | else | |
923 | dc.SetPen( mpLayout->mLightPen ); | |
924 | ||
925 | if ( alignment == FL_ALIGN_TOP ) | |
926 | { | |
927 | if ( level == 0 ) | |
928 | ||
929 | dc.DrawLine( rect.x, | |
930 | rect.y, | |
931 | rect.x + rect.width - 1, | |
932 | rect.y ); | |
933 | else | |
934 | dc.DrawLine( rect.x - 1, | |
935 | rect.y - 1, | |
936 | rect.x + rect.width + 0, | |
937 | rect.y - 1 ); | |
938 | } | |
939 | else | |
940 | if ( alignment == FL_ALIGN_BOTTOM ) | |
941 | { | |
942 | if ( level == 0 ) | |
943 | ||
944 | dc.DrawLine( rect.x, | |
945 | rect.y + rect.height - 1, | |
946 | rect.x + rect.width, | |
947 | rect.y + rect.height - 1 ); | |
948 | else | |
949 | dc.DrawLine( rect.x - 1, | |
950 | rect.y + rect.height, | |
951 | rect.x + rect.width + 1, | |
952 | rect.y + rect.height ); | |
953 | } | |
954 | else | |
955 | if ( alignment == FL_ALIGN_LEFT ) | |
956 | { | |
957 | if ( level == 0 ) | |
958 | ||
959 | dc.DrawLine( rect.x, | |
960 | rect.y, | |
961 | rect.x, | |
962 | rect.y + rect.height - 1 ); | |
963 | else | |
964 | dc.DrawLine( rect.x - 1, | |
965 | rect.y - 1, | |
966 | rect.x - 1, | |
967 | rect.y + rect.height ); | |
968 | } | |
969 | else | |
970 | if ( alignment == FL_ALIGN_RIGHT ) | |
971 | { | |
972 | if ( level == 0 ) | |
973 | ||
974 | dc.DrawLine( rect.x + rect.width - 1, | |
975 | rect.y, | |
976 | rect.x + rect.width - 1, | |
977 | rect.y + rect.height ); | |
978 | else | |
979 | { | |
980 | dc.DrawLine( rect.x + rect.width, | |
981 | rect.y - 1, | |
982 | rect.x + rect.width, | |
983 | rect.y + rect.height + 1 ); | |
984 | } | |
985 | } | |
8e08b761 JS |
986 | } |
987 | ||
988 | void cbPaneDrawPlugin::DrawShade1( int level, wxRect& rect, int alignment, wxDC& dc ) | |
989 | { | |
4cbc57f0 JS |
990 | // simulates "guled-bricks" appearence of control bars |
991 | ||
992 | if ( ( alignment == FL_ALIGN_TOP && level == 1 ) || | |
993 | ( alignment == FL_ALIGN_BOTTOM && level == 0 ) || | |
994 | ( alignment == FL_ALIGN_LEFT && level == 1 ) || | |
995 | ( alignment == FL_ALIGN_RIGHT && level == 0 ) | |
996 | ) | |
997 | ||
998 | dc.SetPen( mpLayout->mDarkPen ); | |
999 | else | |
1000 | dc.SetPen( mpLayout->mLightPen ); | |
1001 | ||
1002 | if ( alignment == FL_ALIGN_TOP ) | |
1003 | { | |
1004 | if ( level == 0 ) | |
1005 | ||
1006 | dc.DrawLine( rect.x, | |
1007 | rect.y, | |
1008 | rect.x + rect.width, | |
1009 | rect.y ); | |
1010 | else | |
1011 | dc.DrawLine( rect.x, | |
1012 | rect.y - 1, | |
1013 | rect.x + rect.width, | |
1014 | rect.y - 1 ); | |
1015 | } | |
1016 | else | |
1017 | if ( alignment == FL_ALIGN_BOTTOM ) | |
1018 | { | |
1019 | if ( level == 0 ) | |
1020 | ||
1021 | dc.DrawLine( rect.x, | |
1022 | rect.y + rect.height - 1, | |
1023 | rect.x + rect.width, | |
1024 | rect.y + rect.height - 1 ); | |
1025 | else | |
1026 | dc.DrawLine( rect.x, | |
1027 | rect.y + rect.height, | |
1028 | rect.x + rect.width, | |
1029 | rect.y + rect.height ); | |
1030 | } | |
1031 | else | |
1032 | if ( alignment == FL_ALIGN_LEFT ) | |
1033 | { | |
1034 | if ( level == 0 ) | |
1035 | ||
1036 | dc.DrawLine( rect.x, | |
1037 | rect.y, | |
1038 | rect.x, | |
1039 | rect.y + rect.height ); | |
1040 | else | |
1041 | dc.DrawLine( rect.x - 1, | |
1042 | rect.y, | |
1043 | rect.x - 1, | |
1044 | rect.y + rect.height ); | |
1045 | } | |
1046 | else | |
1047 | if ( alignment == FL_ALIGN_RIGHT ) | |
1048 | { | |
1049 | if ( level == 0 ) | |
1050 | ||
1051 | dc.DrawLine( rect.x + rect.width - 1, | |
1052 | rect.y, | |
1053 | rect.x + rect.width - 1, | |
1054 | rect.y + rect.height ); | |
1055 | else | |
1056 | { | |
1057 | dc.DrawLine( rect.x + rect.width, | |
1058 | rect.y , | |
1059 | rect.x + rect.width, | |
1060 | rect.y + rect.height ); | |
1061 | } | |
1062 | } | |
8e08b761 JS |
1063 | } |
1064 | ||
1065 | void cbPaneDrawPlugin::DrawPaneShade( wxDC& dc, int alignment ) | |
1066 | { | |
4cbc57f0 | 1067 | if ( !mpPane->mProps.mShow3DPaneBorderOn ) return; |
8e08b761 | 1068 | |
4cbc57f0 | 1069 | wxRect bounds = mpPane->mBoundsInParent; |
8e08b761 | 1070 | |
4cbc57f0 JS |
1071 | bounds.x += mpPane->mLeftMargin; |
1072 | bounds.y += mpPane->mTopMargin; | |
1073 | bounds.width -= ( mpPane->mLeftMargin + mpPane->mRightMargin ); | |
1074 | bounds.height -= ( mpPane->mTopMargin + mpPane->mBottomMargin ); | |
8e08b761 | 1075 | |
4cbc57f0 JS |
1076 | DrawShade( 0, bounds, alignment, dc ); |
1077 | DrawShade( 1, bounds, alignment, dc ); | |
8e08b761 JS |
1078 | } |
1079 | ||
1080 | void cbPaneDrawPlugin::DrawPaneShadeForRow( cbRowInfo* pRow, wxDC& dc ) | |
1081 | { | |
4cbc57f0 | 1082 | if ( !mpPane->mProps.mShow3DPaneBorderOn ) return; |
8e08b761 | 1083 | |
4cbc57f0 JS |
1084 | // do not draw decoration, if pane has "vainished" |
1085 | if ( mpPane->mPaneWidth < 0 || | |
1086 | mpPane->mPaneHeight < 0 ) | |
8e08b761 | 1087 | |
4cbc57f0 | 1088 | return; |
8e08b761 | 1089 | |
4cbc57f0 | 1090 | wxRect bounds = pRow->mBoundsInParent; |
8e08b761 | 1091 | |
4cbc57f0 JS |
1092 | if ( mpPane->mAlignment == FL_ALIGN_TOP || |
1093 | mpPane->mAlignment == FL_ALIGN_BOTTOM ) | |
1094 | { | |
1095 | --bounds.y; | |
1096 | bounds.height += 2; | |
8e08b761 | 1097 | |
4cbc57f0 JS |
1098 | DrawShade1( 0, bounds, FL_ALIGN_LEFT, dc ); |
1099 | DrawShade1( 1, bounds, FL_ALIGN_LEFT, dc ); | |
1100 | DrawShade1( 0, bounds, FL_ALIGN_RIGHT, dc ); | |
1101 | DrawShade1( 1, bounds, FL_ALIGN_RIGHT, dc ); | |
8e08b761 | 1102 | |
4cbc57f0 JS |
1103 | if ( !pRow->mpNext ) |
1104 | DrawPaneShade( dc, FL_ALIGN_BOTTOM ); | |
8e08b761 | 1105 | |
4cbc57f0 JS |
1106 | if ( !pRow->mpPrev ) |
1107 | DrawPaneShade( dc, FL_ALIGN_TOP ); | |
1108 | } | |
1109 | else | |
1110 | { | |
1111 | --bounds.x; | |
1112 | bounds.width += 2; | |
8e08b761 | 1113 | |
4cbc57f0 JS |
1114 | DrawShade1( 0, bounds, FL_ALIGN_TOP, dc ); |
1115 | DrawShade1( 1, bounds, FL_ALIGN_TOP, dc ); | |
1116 | DrawShade1( 0, bounds, FL_ALIGN_BOTTOM, dc ); | |
1117 | DrawShade1( 1, bounds, FL_ALIGN_BOTTOM, dc ); | |
8e08b761 | 1118 | |
4cbc57f0 JS |
1119 | if ( !pRow->mpNext ) |
1120 | DrawPaneShade( dc, FL_ALIGN_RIGHT ); | |
8e08b761 | 1121 | |
4cbc57f0 JS |
1122 | if ( !pRow->mpPrev ) |
1123 | DrawPaneShade( dc, FL_ALIGN_LEFT ); | |
1124 | } | |
8e08b761 JS |
1125 | } |
1126 | ||
1127 | void cbPaneDrawPlugin::OnDrawPaneDecorations( cbDrawPaneDecorEvent& event ) | |
1128 | { | |
4cbc57f0 | 1129 | wxDC& dc = *event.mpDc; |
8e08b761 | 1130 | |
4cbc57f0 | 1131 | cbDockPane* pPane = event.mpPane; |
8e08b761 | 1132 | |
4cbc57f0 JS |
1133 | RowArrayT& lst = pPane->GetRowList(); |
1134 | ||
1135 | // FIXME:: this is a workaround for some glitches | |
8e08b761 | 1136 | |
4cbc57f0 JS |
1137 | if ( lst.Count() ) |
1138 | { | |
1139 | cbRowInfo* pLastRow = lst[ lst.Count() - 1 ]; | |
8e08b761 | 1140 | |
4cbc57f0 JS |
1141 | pPane->PaintRowBackground( pLastRow, dc ); |
1142 | pPane->PaintRowDecorations( pLastRow, dc ); | |
1143 | pPane->PaintRowHandles( pLastRow, dc ); | |
1144 | } | |
8e08b761 | 1145 | |
4cbc57f0 | 1146 | if ( !pPane->mProps.mShow3DPaneBorderOn ) return; |
8e08b761 | 1147 | |
4cbc57f0 JS |
1148 | // do not draw decoration, if pane is completely hidden |
1149 | if ( event.mpPane->mPaneWidth < 0 || | |
1150 | event.mpPane->mPaneHeight < 0 ) | |
8e08b761 | 1151 | |
4cbc57f0 | 1152 | return; |
8e08b761 | 1153 | |
4cbc57f0 JS |
1154 | DrawPaneShade( dc, FL_ALIGN_TOP ); |
1155 | DrawPaneShade( dc, FL_ALIGN_BOTTOM ); | |
1156 | DrawPaneShade( dc, FL_ALIGN_LEFT ); | |
1157 | DrawPaneShade( dc, FL_ALIGN_RIGHT ); | |
8e08b761 | 1158 | |
4cbc57f0 | 1159 | event.Skip(); // pass event to the next plugin |
8e08b761 JS |
1160 | } |
1161 | ||
1162 | // bar decoration/sizing handlers | |
1163 | ||
1164 | void cbPaneDrawPlugin::OnDrawBarDecorations( cbDrawBarDecorEvent& event ) | |
1165 | { | |
4cbc57f0 JS |
1166 | // cbBarInfo* pBar = event.mpBar; |
1167 | wxDC& dc = *event.mpDc; | |
8e08b761 | 1168 | |
4cbc57f0 | 1169 | // draw brick borders |
8e08b761 | 1170 | |
4cbc57f0 | 1171 | wxRect& rect = event.mBoundsInParent; |
8e08b761 | 1172 | |
4cbc57f0 | 1173 | dc.SetPen( mpLayout->mLightPen ); |
8e08b761 | 1174 | |
4cbc57f0 JS |
1175 | // horiz |
1176 | dc.DrawLine( rect.x, rect.y, | |
1177 | rect.x + rect.width-1, rect.y ); | |
8e08b761 | 1178 | |
4cbc57f0 JS |
1179 | // vert |
1180 | dc.DrawLine( rect.x, rect.y, | |
1181 | rect.x, rect.y + rect.height-1 ); | |
8e08b761 JS |
1182 | |
1183 | ||
4cbc57f0 | 1184 | dc.SetPen( mpLayout->mDarkPen ); |
8e08b761 | 1185 | |
4cbc57f0 JS |
1186 | // vert |
1187 | dc.DrawLine( rect.x + rect.width-1, rect.y, | |
1188 | rect.x + rect.width-1, rect.y + rect.height-1 ); | |
8e08b761 | 1189 | |
4cbc57f0 JS |
1190 | // horiz |
1191 | dc.DrawLine( rect.x, rect.y + rect.height-1, | |
1192 | rect.x + rect.width, rect.y + rect.height-1 ); | |
8e08b761 | 1193 | |
4cbc57f0 | 1194 | event.Skip(); // pass event to the next plugin |
8e08b761 JS |
1195 | } |
1196 | ||
1197 | void cbPaneDrawPlugin::OnDrawBarHandles( cbDrawBarHandlesEvent& event ) | |
1198 | { | |
4cbc57f0 JS |
1199 | // short-cuts |
1200 | cbBarInfo* pBar = event.mpBar; | |
1201 | wxDC& dc = *event.mpDc; | |
1202 | mpPane = event.mpPane; | |
8e08b761 | 1203 | |
4cbc57f0 | 1204 | // draw handles around the bar if present |
8e08b761 | 1205 | |
4cbc57f0 JS |
1206 | if ( pBar->mHasLeftHandle || |
1207 | pBar->mHasRightHandle ) | |
1208 | { | |
1209 | wxRect& bounds = pBar->mBoundsInParent; | |
8e08b761 | 1210 | |
4cbc57f0 JS |
1211 | if ( mpPane->IsHorizontal() ) |
1212 | { | |
1213 | if ( pBar->mHasLeftHandle ) | |
8e08b761 | 1214 | |
4cbc57f0 JS |
1215 | mpPane->DrawVertHandle( dc, bounds.x - mpPane->mProps.mResizeHandleSize -1, |
1216 | bounds.y, bounds.height ); | |
8e08b761 | 1217 | |
4cbc57f0 | 1218 | if ( pBar->mHasRightHandle ) |
8e08b761 | 1219 | |
4cbc57f0 JS |
1220 | mpPane->DrawVertHandle( dc, |
1221 | bounds.x + bounds.width -1, | |
1222 | bounds.y, bounds.height ); | |
1223 | } | |
1224 | else | |
1225 | { | |
1226 | if ( pBar->mHasLeftHandle ) | |
8e08b761 | 1227 | |
4cbc57f0 JS |
1228 | mpPane->DrawHorizHandle( dc, bounds.x, |
1229 | bounds.y - mpPane->mProps.mResizeHandleSize - 1, | |
1230 | bounds.width ); | |
8e08b761 | 1231 | |
4cbc57f0 | 1232 | if ( pBar->mHasRightHandle ) |
8e08b761 | 1233 | |
4cbc57f0 JS |
1234 | mpPane->DrawHorizHandle( dc, bounds.x, |
1235 | bounds.y + bounds.height - 1, | |
1236 | bounds.width ); | |
1237 | } | |
1238 | } | |
8e08b761 | 1239 | |
4cbc57f0 | 1240 | event.Skip(); // pass event to the next plugin |
8e08b761 JS |
1241 | } |
1242 | ||
1243 | void cbPaneDrawPlugin::OnStartDrawInArea( cbStartDrawInAreaEvent& event ) | |
1244 | { | |
4cbc57f0 JS |
1245 | // DBG:: |
1246 | wxASSERT( mpClntDc == NULL ); | |
8e08b761 | 1247 | |
4cbc57f0 JS |
1248 | // FOR NOW:: create/destroy client-dc upon each drawing |
1249 | mpClntDc = new wxClientDC( &mpLayout->GetParentFrame() ); | |
8e08b761 | 1250 | |
4cbc57f0 | 1251 | (*event.mppDc) = mpClntDc; |
8e08b761 | 1252 | |
4cbc57f0 JS |
1253 | mpClntDc->SetClippingRegion( event.mArea.x, event.mArea.y, |
1254 | event.mArea.width, event.mArea.height ); | |
8e08b761 JS |
1255 | } |
1256 | ||
1257 | void cbPaneDrawPlugin::OnFinishDrawInArea( cbFinishDrawInAreaEvent& event ) | |
1258 | { | |
4cbc57f0 JS |
1259 | // DBG:: |
1260 | wxASSERT( mpClntDc ); | |
8e08b761 | 1261 | |
4cbc57f0 | 1262 | delete mpClntDc; |
8e08b761 | 1263 | |
4cbc57f0 | 1264 | mpClntDc = NULL; |
8e08b761 JS |
1265 | } |
1266 |