1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "panedrawpl.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
30 #include "wx/utils.h" // import wxMin,wxMax macros
32 #include "wx/fl/panedrawpl.h"
34 // bitmap bits used by bar-resizing brush
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.
41 static const unsigned char _gCheckerImg
[16] = { _IMG_A
,_IMG_B
,_IMG_C
,_IMG_D
,
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
47 // FIXME:: The below code somehow doesn't work - cursors remain unchanged
48 // Used: controlbar.cpp(1268): set_cursor_bits( _gHorizCursorImg, bits, 32, 16 );
49 // Used: controlbar.cpp(1272): set_cursor_bits( _gVertCursorImg, bits, 32, 16 );
51 static void set_cursor_bits( const char** img, char* bits, int width, int height )
53 for( int i = 0; i != (width*height)/8; ++i )
56 for( int y = 0; y != height; ++y )
58 const char* row = img[0];
60 for( int x = 0; x != width; ++x )
62 int bitNo = y*width + x;
64 char value = ( row[x] != '.' ) ? 1 : 0;
66 bits[ bitNo / sizeof(char) ] |=
67 ( ( bitNo %sizeof(char) ) << value );
75 /***** Implementation for class cbPaneDrawPlugin *****/
77 IMPLEMENT_DYNAMIC_CLASS( cbPaneDrawPlugin
, cbPluginBase
)
79 BEGIN_EVENT_TABLE( cbPaneDrawPlugin
, cbPluginBase
)
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
)
88 EVT_PL_DRAW_PANE_BKGROUND ( cbPaneDrawPlugin::OnDrawPaneBackground
)
89 EVT_PL_DRAW_PANE_DECOR ( cbPaneDrawPlugin::OnDrawPaneDecorations
)
91 EVT_PL_DRAW_ROW_DECOR ( cbPaneDrawPlugin::OnDrawRowDecorations
)
92 EVT_PL_DRAW_ROW_HANDLES ( cbPaneDrawPlugin::OnDrawRowHandles
)
93 EVT_PL_DRAW_ROW_BKGROUND ( cbPaneDrawPlugin::OnDrawRowBackground
)
95 EVT_PL_SIZE_BAR_WND ( cbPaneDrawPlugin::OnSizeBarWindow
)
96 EVT_PL_DRAW_BAR_DECOR ( cbPaneDrawPlugin::OnDrawBarDecorations
)
97 EVT_PL_DRAW_BAR_HANDLES ( cbPaneDrawPlugin::OnDrawBarHandles
)
99 EVT_PL_START_DRAW_IN_AREA ( cbPaneDrawPlugin::OnStartDrawInArea
)
100 EVT_PL_FINISH_DRAW_IN_AREA ( cbPaneDrawPlugin::OnFinishDrawInArea
)
104 cbPaneDrawPlugin::cbPaneDrawPlugin(void)
106 : mResizeStarted ( FALSE
),
108 mResizeCursorOn ( FALSE
),
109 mpDraggedBar ( NULL
),
110 mpResizedRow ( NULL
),
112 mRowHandleHitted ( FALSE
),
113 mIsUpperHandle ( FALSE
),
114 mBarHandleHitted ( FALSE
),
115 mIsLeftHandle ( FALSE
),
116 mBarContentHitted ( FALSE
),
122 cbPaneDrawPlugin::cbPaneDrawPlugin( wxFrameLayout
* pPanel
, int paneMask
)
124 : cbPluginBase( pPanel
, paneMask
),
126 // bar-row resizing state varaibles
128 mResizeStarted ( FALSE
),
130 mResizeCursorOn ( FALSE
),
131 mpDraggedBar ( NULL
),
132 mpResizedRow ( NULL
),
134 mRowHandleHitted ( FALSE
),
135 mIsUpperHandle ( FALSE
),
136 mBarHandleHitted ( FALSE
),
137 mIsLeftHandle ( FALSE
),
138 mBarContentHitted ( FALSE
),
144 cbPaneDrawPlugin::~cbPaneDrawPlugin()
147 wxASSERT( mpClntDc
== NULL
);
150 void cbPaneDrawPlugin::DrawDraggedHandle( const wxPoint
& pos
, cbDockPane
& pane
)
157 pane
.PaneToFrame( &fpos
.x
, &fpos
.y
);
160 int resizeHndSize
= pane
.mProps
.mResizeHandleSize
;
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.
167 wxScreenDC::StartDrawingOnTop(&mpLayout
->GetParentFrame());
169 mpLayout
->GetParentFrame().ClientToScreen( &ofsX
, &ofsY
);
171 int prevLF
= dc
.GetLogicalFunction();
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
177 wxBitmap
checker( (const char*)_gCheckerImg
, 8,8 );
179 wxBrush
checkerBrush( checker
);
181 dc
.SetPen( mpLayout
->mNullPen
);
182 dc
.SetBrush( checkerBrush
);
183 dc
.SetLogicalFunction( wxXOR
);
185 if ( mHandleIsVertical
)
187 int delta
= pos
.x
- mDragOrigin
.x
;
189 if ( !pane
.IsHorizontal() )
191 delta
= pos
.y
- mDragOrigin
.y
;
194 realHndOfs
= pane
.mBoundsInParent
.x
+ pane
.mLeftMargin
+ mHandleOfs
;
196 int newX
= realHndOfs
+ delta
;
198 if ( newX
+ resizeHndSize
> mHandleDragArea
.x
+ mHandleDragArea
.width
)
200 newX
= mHandleDragArea
.x
+ mHandleDragArea
.width
- 1;
202 if ( newX
< mHandleDragArea
.x
)
204 newX
= mHandleDragArea
.x
;
206 mDraggedDelta
= newX
- realHndOfs
;
208 dc
.DrawRectangle( newX
+ ofsX
, mHandleDragArea
.y
+ ofsY
,
210 mHandleDragArea
.height
+1 );
214 // otherwise, draw horizontal handle
216 int delta
= pos
.y
- mDragOrigin
.y
;
218 if ( !pane
.IsHorizontal() )
220 delta
= pos
.x
- mDragOrigin
.x
;
223 realHndOfs
= pane
.mBoundsInParent
.y
+ pane
.mTopMargin
+ mHandleOfs
;
225 int newY
= realHndOfs
+ delta
;
227 if ( newY
+ resizeHndSize
> mHandleDragArea
.y
+ mHandleDragArea
.height
)
229 newY
= mHandleDragArea
.y
+ mHandleDragArea
.height
- 1;
231 if ( newY
< mHandleDragArea
.y
)
233 newY
= mHandleDragArea
.y
;
235 mDraggedDelta
= newY
- realHndOfs
;
237 dc
.DrawRectangle( mHandleDragArea
.x
+ ofsX
, newY
+ ofsY
,
238 mHandleDragArea
.width
+ 1,
242 dc
.SetLogicalFunction( prevLF
);
244 // "End drawing on top (frees the window used for drawing
245 // over the screen)" --J.S.
246 wxScreenDC::EndDrawingOnTop();
249 void cbPaneDrawPlugin::OnMouseMove( cbMotionEvent
& event
)
251 if ( !mResizeStarted
)
253 // if nothing is started, do hit-tests
255 bool prevWasRowHandle
= mRowHandleHitted
;
257 mBarContentHitted
= FALSE
;
258 mBarHandleHitted
= FALSE
;
259 mRowHandleHitted
= FALSE
;
262 event
.mpPane
->HitTestPaneItems( event
.mPos
, // in pane's coordiantes
266 if ( testResult
!= CB_NO_ITEMS_HITTED
)
268 if ( testResult
== CB_BAR_CONTENT_HITTED
)
270 // restore cursor, if non of the handles were hit
271 if ( mResizeCursorOn
)
273 // remove resizing hints
275 mpLayout
->ReleaseEventsFromPane( event
.mpPane
);
276 mpLayout
->ReleaseEventsFromPlugin( this );
278 mResizeCursorOn
= FALSE
;
280 mBarContentHitted
= TRUE
;
282 mpLayout
->GetParentFrame().SetCursor( *mpLayout
->mpNormalCursor
);
285 // TBD:: fire something like "mouse-over-bar" event
287 event
.Skip(); // pass event to the next handler in the chain
291 wxCursor
* pCurs
= NULL
;
293 if ( testResult
== CB_UPPER_ROW_HANDLE_HITTED
||
294 testResult
== CB_LOWER_ROW_HANDLE_HITTED
)
296 if ( event
.mpPane
->IsHorizontal() )
298 pCurs
= mpLayout
->mpVertCursor
;
300 pCurs
= mpLayout
->mpHorizCursor
;
302 mRowHandleHitted
= TRUE
;
303 mIsUpperHandle
= ( testResult
== CB_UPPER_ROW_HANDLE_HITTED
);
307 // otherwise, if inter-bar handle was hitted
309 if ( event
.mpPane
->IsHorizontal() )
311 pCurs
= mpLayout
->mpHorizCursor
;
313 pCurs
= mpLayout
->mpVertCursor
;
315 mBarHandleHitted
= TRUE
;
316 mIsLeftHandle
= ( testResult
== CB_LEFT_BAR_HANDLE_HITTED
);
319 // avoid setting the same cursor twice
321 if ( !mResizeCursorOn
|| prevWasRowHandle
!= mRowHandleHitted
)
323 if ( !mResizeCursorOn
)
325 // caputre if not captured yet
326 mpLayout
->CaptureEventsForPane( event
.mpPane
);
327 mpLayout
->CaptureEventsForPlugin( this );
330 mpLayout
->GetParentFrame().SetCursor( *pCurs
);
333 mResizeCursorOn
= TRUE
;
335 // handled is being dragged now, thus event is "eaten" by this plugin
339 } // end of if (HitTestBarHandles())
341 // restore cursor, if non of the handles were hit
342 if ( mResizeCursorOn
)
344 mpLayout
->ReleaseEventsFromPane( event
.mpPane
);
345 mpLayout
->ReleaseEventsFromPlugin( this );
347 mpLayout
->GetParentFrame().SetCursor( *mpLayout
->mpNormalCursor
);
349 mResizeCursorOn
= FALSE
;
352 event
.Skip(); // pass event to the next plugin
355 // othewise series of actions, if something has already started
358 if ( mResizeStarted
)
360 // apply xor-mask twice
361 DrawDraggedHandle( mPrevPos
, *event
.mpPane
);
363 // draw handle in the new position
364 DrawDraggedHandle( event
.mPos
, *event
.mpPane
);
365 mPrevPos
= event
.mPos
;
367 // handled is dragged, thus event is "eaten" by this plugin
370 event
.Skip(); // pass event to the next plugin
373 void cbPaneDrawPlugin::OnLDblClick( cbLeftDClickEvent
& event
)
375 if ( !mResizeCursorOn
)
377 cbBarInfo
* pBarToFloat
;
379 if ( event
.mpPane
->HitTestPaneItems( event
.mPos
, // in pane's coordiantes
381 &pBarToFloat
) == CB_BAR_CONTENT_HITTED
387 mpLayout
->SetBarState( pBarToFloat
, wxCBAR_FLOATING
, TRUE
);
389 mpLayout
->RepositionFloatedBar( pBarToFloat
);
391 return; // event is "eaten" by this plugin
398 void cbPaneDrawPlugin::OnLButtonDown( cbLeftDownEvent
& event
)
400 wxASSERT( !mResizeStarted
);
402 if ( mResizeCursorOn
)
404 mResizeStarted
= TRUE
;
405 mDragOrigin
= event
.mPos
;
407 // setup constraints for the dragging handle
411 mHandleIsVertical
= FALSE
;
413 if ( mRowHandleHitted
)
415 event
.mpPane
->GetRowResizeRange( mpResizedRow
, &from
, &till
, mIsUpperHandle
);
417 // otherwise if bar handle was hitted
418 event
.mpPane
->GetBarResizeRange( mpDraggedBar
, &from
, &till
, mIsLeftHandle
);
420 if ( mRowHandleHitted
)
422 mHandleIsVertical
= ( event
.mpPane
->IsHorizontal() ) ? FALSE
: TRUE
;
424 mHandleDragArea
.x
= 0;
425 mHandleDragArea
.width
= event
.mpPane
->mPaneWidth
;
427 mHandleDragArea
.y
= from
;
428 mHandleDragArea
.height
= till
- from
;
430 if ( mIsUpperHandle
)
432 mHandleOfs
= mpResizedRow
->mRowY
;
434 mHandleOfs
= mpResizedRow
->mRowY
+
435 mpResizedRow
->mRowHeight
-
436 event
.mpPane
->mProps
.mResizeHandleSize
;
440 // otehrwise if bar handle dragged
442 cbRowInfo
& rowInfo
= *mpDraggedBar
->mpRow
;
443 wxRect
& bounds
= mpDraggedBar
->mBounds
;
445 mHandleIsVertical
= ( event
.mpPane
->IsHorizontal() ) ? TRUE
: FALSE
;
447 mHandleDragArea
.x
= from
;
448 mHandleDragArea
.width
= till
- from
;
451 mHandleDragArea
.y
= bounds
.y
;
452 mHandleDragArea
.height
= bounds
.height
;
454 // left-side-handle mBounds
457 mHandleOfs
= bounds
.x
;
459 mHandleOfs
= bounds
.x
+
460 bounds
.width
- event
.mpPane
->mProps
.mResizeHandleSize
;
464 event
.mpPane
->PaneToFrame( &mHandleDragArea
);
465 DrawDraggedHandle(mDragOrigin
, *event
.mpPane
);
467 mPrevPos
= mDragOrigin
;
470 // handled is dragged, thus event is "eaten" by this plugin
474 cbBarInfo
* pDraggedBar
;
476 if ( event
.mpPane
->HitTestPaneItems( event
.mPos
, // in pane's coordiantes
478 &pDraggedBar
) == CB_BAR_CONTENT_HITTED
481 int x
= event
.mPos
.x
,
484 event
.mpPane
->PaneToFrame( &x
, &y
);
486 cbStartBarDraggingEvent
dragEvt( pDraggedBar
, wxPoint(x
,y
), event
.mpPane
);
488 mpLayout
->FirePluginEvent( dragEvt
);
490 return; // event is "eaten" by this plugin
494 event
.Skip(); // pass event to the next plugin in the chain
497 void cbPaneDrawPlugin::OnLButtonUp( cbLeftUpEvent
& event
)
499 if ( mResizeStarted
)
501 DrawDraggedHandle( event
.mPos
, *event
.mpPane
);
503 mResizeStarted
= FALSE
;
504 mResizeCursorOn
= FALSE
;
506 mpLayout
->ReleaseEventsFromPane( event
.mpPane
);
507 mpLayout
->ReleaseEventsFromPlugin( this );
509 mpLayout
->GetParentFrame().SetCursor( *mpLayout
->mpNormalCursor
);
511 if ( mRowHandleHitted
)
513 event
.mpPane
->ResizeRow( mpResizedRow
,
519 event
.mpPane
->ResizeBar( mpDraggedBar
,
527 // handled dragging action was finished by this mouse-up,
528 // thus event is "eaten" by this plugin
533 event
.Skip(); // pass event to the next plugin
536 void cbPaneDrawPlugin::OnRButtonUp( cbRightUpEvent
& event
)
538 wxPoint fpos
= event
.mPos
;
539 event
.mpPane
->PaneToFrame( &fpos
.x
, &fpos
.y
);
541 cbBarInfo
* pDraggedBar
;
543 // user clicks inside the bar contnet, fire bar-customization event
545 if ( event
.mpPane
->HitTestPaneItems( event
.mPos
, // in pane's coordiantes
547 &pDraggedBar
) == CB_BAR_CONTENT_HITTED
550 cbCustomizeBarEvent
cbEvt( pDraggedBar
, fpos
, event
.mpPane
);
552 mpLayout
->FirePluginEvent( cbEvt
);
554 return; // event is "eaten" by this plugin
557 // otherwise fire whole-layout customization event
559 cbCustomizeLayoutEvent
csEvt( fpos
);
561 mpLayout
->FirePluginEvent( csEvt
);
563 // event is "eaten" by this plugin
566 void cbPaneDrawPlugin::OnSizeBarWindow( cbSizeBarWndEvent
& event
)
568 cbBarInfo
& bar
= *event
.mpBar
;
569 mpPane
= event
.mpPane
;
571 // it's possible that a bar does not have it's own window!
572 if ( !bar
.mpBarWnd
) return;
574 wxRect
& bounds
= event
.mBoundsInParent
;
577 if ( bounds
.height
!= 0 )
579 // size smaller than bounds, to leave space for shade lines
583 bar
.mpBarWnd
->wxWindow::SetSize( bounds
.x
+ 1 + bar
.mDimInfo
.mHorizGap
,
584 bounds
.y
+ 1 + bar
.mDimInfo
.mVertGap
,
585 bounds
.width
- 2 - bar
.mDimInfo
.mHorizGap
*2,
586 bounds
.height
- 2 - bar
.mDimInfo
.mVertGap
*2 ,
590 if ( !bar
.mpBarWnd
->IsShown() )
592 bar
.mpBarWnd
->Show( TRUE
);
595 // hide bar if not visible
596 bar
.mpBarWnd
->Show( FALSE
);
598 event
.Skip(); // pass event to the next plugin in the chain
601 void cbPaneDrawPlugin::OnDrawRowDecorations( cbDrawRowDecorEvent
& event
)
603 DrawPaneShadeForRow( event
.mpRow
, *event
.mpDc
);
605 event
.Skip(); // pass event to the next plugin
608 void cbPaneDrawPlugin::DrawUpperRowHandle( cbRowInfo
* pRow
, wxDC
& dc
)
610 wxRect
& bounds
= pRow
->mBoundsInParent
;
612 if ( mpPane
->IsHorizontal() )
614 if ( pRow
->mHasUpperHandle
)
616 mpPane
->DrawHorizHandle( dc
, bounds
.x
,
622 if ( pRow
->mHasUpperHandle
)
624 mpPane
->DrawVertHandle( dc
, bounds
.x
-1,
625 bounds
.y
, pRow
->mRowWidth
);
629 void cbPaneDrawPlugin::DrawLowerRowHandle( cbRowInfo
* pRow
, wxDC
& dc
)
631 wxRect
& bounds
= pRow
->mBoundsInParent
;
633 // check if iter-row handles present
635 if ( mpPane
->IsHorizontal() )
637 if ( pRow
->mHasLowerHandle
)
639 mpPane
->DrawHorizHandle( dc
, bounds
.x
, bounds
.y
+ bounds
.height
- mpPane
->mProps
.mResizeHandleSize
- 1,
644 if ( pRow
->mHasLowerHandle
)
646 mpPane
->DrawVertHandle( dc
, bounds
.x
+ bounds
.width
- mpPane
->mProps
.mResizeHandleSize
- 1,
647 bounds
.y
, pRow
->mRowWidth
);
651 void cbPaneDrawPlugin::OnDrawRowHandles( cbDrawRowHandlesEvent
& event
)
654 cbRowInfo
* pRow
= event
.mpRow
;
655 wxDC
& dc
= *event
.mpDc
;
656 mpPane
= event
.mpPane
;
658 // draw handles of surrounding rows first
660 if ( pRow
->mpPrev
&& pRow
->mpPrev
->mHasLowerHandle
)
662 DrawLowerRowHandle( pRow
->mpPrev
, dc
);
664 if ( pRow
->mpNext
&& pRow
->mpNext
->mHasUpperHandle
)
666 DrawUpperRowHandle( pRow
->mpNext
, dc
);
668 // draw handles of the given row
670 if ( pRow
->mHasUpperHandle
)
672 DrawUpperRowHandle( pRow
, dc
);
674 if ( pRow
->mHasLowerHandle
)
676 DrawLowerRowHandle( pRow
, dc
);
678 event
.Skip(); // pass event to the next plugin
681 void cbPaneDrawPlugin::OnDrawPaneBackground ( cbDrawPaneBkGroundEvent
& event
)
683 wxDC
& dc
= *event
.mpDc
;
684 mpPane
= event
.mpPane
;
686 // FOR NOW:: hard-coded
687 wxBrush
bkBrush( mpLayout
->mBorderPen
.GetColour(), wxSOLID
);
689 dc
.SetBrush( bkBrush
);
690 dc
.SetPen( mpLayout
->mNullPen
);
692 wxRect
& bounds
= mpPane
->mBoundsInParent
;
694 if ( mpPane
->mTopMargin
>= 1 )
696 dc
.DrawRectangle( bounds
.x
, bounds
.y
,
698 mpPane
->mTopMargin
+ 1);
701 if ( mpPane
->mBottomMargin
>= 1 )
703 dc
.DrawRectangle( bounds
.x
,
704 bounds
.y
+ bounds
.height
- mpPane
->mBottomMargin
,
706 mpPane
->mBottomMargin
+ 1);
709 if ( mpPane
->mLeftMargin
>= 1 )
711 dc
.DrawRectangle( bounds
.x
,
712 bounds
.y
+ mpPane
->mTopMargin
- 1,
713 mpPane
->mLeftMargin
+ 1,
714 bounds
.height
- mpPane
->mTopMargin
- mpPane
->mBottomMargin
+ 2);
717 if ( mpPane
->mRightMargin
>= 1 )
719 dc
.DrawRectangle( bounds
.x
+ bounds
.width
- mpPane
->mRightMargin
,
720 bounds
.y
+ mpPane
->mTopMargin
- 1,
721 mpPane
->mRightMargin
+ 1,
722 bounds
.height
- mpPane
->mTopMargin
- mpPane
->mBottomMargin
+ 2);
724 event
.Skip(); // pass event to the next plugin
727 void cbPaneDrawPlugin::OnDrawRowBackground ( cbDrawRowBkGroundEvent
& event
)
730 cbRowInfo
* pRow
= event
.mpRow
;
731 wxDC
& dc
= *event
.mpDc
;
732 mpPane
= event
.mpPane
;
735 wxRect rowBounds
= pRow
->mBoundsInParent
;
736 bool isHorizontal
= event
.mpPane
->IsHorizontal();
742 prevPos
= rowBounds
.x
;
743 // include one line obove and below the row
745 rowBounds
.height
+=2;
748 rowBounds
.width
+= 2;
752 prevPos
= rowBounds
.y
;
753 // include one line obove and below the row
755 rowBounds
.width
+= 2;
758 rowBounds
.height
+=2;
761 //#define TEST_BK_ERASING
763 #ifdef TEST_BK_ERASING
766 wxBrush
br0( wxColour(0,160,160), wxSOLID
);
768 dc
.SetPen ( mpLayout
->mNullPen
);
769 dc
.DrawRectangle( rowBounds
.x
, rowBounds
.y
,
771 rowBounds
.height
+ 1 );
774 wxBrush
bkBrush( mpLayout
->mGrayPen
.GetColour(), wxSOLID
);
776 dc
.SetPen ( mpLayout
->mNullPen
);
777 dc
.SetBrush( bkBrush
);
779 // fill background-recatangle of entire row area
780 dc
.DrawRectangle( rowBounds
.x
, rowBounds
.y
,
782 rowBounds
.height
+ 1 );
784 dc
.SetBrush( wxNullBrush
);
786 // draw "shaded-side-bars" for each bar
787 for( size_t i
= 0; i
!= pRow
->mBars
.Count(); ++i
)
789 wxRect
& bounds
= pRow
->mBars
[i
]->mBoundsInParent
;
793 DrawShade( 1, bounds
, FL_ALIGN_LEFT
, dc
);
794 DrawShade( 1, bounds
, FL_ALIGN_RIGHT
, dc
);
798 DrawShade( 1, bounds
, FL_ALIGN_TOP
, dc
);
799 DrawShade( 1, bounds
, FL_ALIGN_BOTTOM
, dc
);
803 // draw extra shades to simulate "glued-bricks" effect
805 // TBD:: reduce exessive drawing of shades, when the
806 // row handle is present, and shades will be overr-drawn anyway
808 DrawUpperRowShades( pRow
, dc
, 1 ); // outer shade
812 DrawLowerRowShades( pRow
->mpPrev
, dc
, 1 ); // outter shade
813 DrawLowerRowShades( pRow
->mpPrev
, dc
, 0 ); // inner shade
816 DrawLowerRowShades( pRow
, dc
, 1 );
820 DrawUpperRowShades( pRow
->mpNext
, dc
, 1 );
821 DrawUpperRowShades( pRow
->mpNext
, dc
, 0 );
824 event
.Skip(); // pass event to the next plugin
827 void cbPaneDrawPlugin::DrawUpperRowShades( cbRowInfo
* pRow
, wxDC
& dc
, int level
)
829 for( size_t i
= 0; i
!= pRow
->mBars
.Count(); ++i
)
831 wxRect
& bounds
= pRow
->mBars
[i
]->mBoundsInParent
;
833 if ( mpPane
->IsHorizontal() )
835 DrawShade( level
, bounds
, FL_ALIGN_TOP
, dc
);
838 dc
.SetPen( mpLayout
->mDarkPen
);
839 dc
.DrawPoint( bounds
.x
- 1, bounds
.y
);
840 dc
.SetPen( mpLayout
->mLightPen
);
841 dc
.DrawPoint( bounds
.x
+ bounds
.width
, bounds
.y
);
846 DrawShade( level
, bounds
, FL_ALIGN_LEFT
, dc
);
849 dc
.SetPen( mpLayout
->mDarkPen
);
850 dc
.DrawPoint( bounds
.x
, bounds
.y
-1 );
851 dc
.SetPen( mpLayout
->mLightPen
);
852 dc
.DrawPoint( bounds
.x
, bounds
.y
+ bounds
.height
);
858 void cbPaneDrawPlugin::DrawLowerRowShades( cbRowInfo
* pRow
, wxDC
& dc
, int level
)
860 for( size_t i
= 0; i
!= pRow
->mBars
.Count(); ++i
)
862 wxRect
& bounds
= pRow
->mBars
[i
]->mBoundsInParent
;
864 if ( mpPane
->IsHorizontal() )
866 DrawShade( level
, bounds
, FL_ALIGN_BOTTOM
, dc
);
869 dc
.SetPen( mpLayout
->mDarkPen
);
870 dc
.DrawPoint( bounds
.x
- 1, bounds
.y
+ bounds
.height
-1 );
871 dc
.SetPen( mpLayout
->mLightPen
);
872 dc
.DrawPoint( bounds
.x
+ bounds
.width
, bounds
.y
+ bounds
.height
-1 );
877 DrawShade( level
, bounds
, FL_ALIGN_RIGHT
, dc
);
880 dc
.SetPen( mpLayout
->mDarkPen
);
881 dc
.DrawPoint( bounds
.x
+ bounds
.width
- 1, bounds
.y
-1 );
882 dc
.SetPen( mpLayout
->mLightPen
);
883 dc
.DrawPoint( bounds
.x
+ bounds
.width
- 1, bounds
.y
+ bounds
.height
);
889 void cbPaneDrawPlugin::DrawBarInnerShadeRect( cbBarInfo
* pBar
, wxDC
& dc
)
891 wxRect
& bounds
= pBar
->mBoundsInParent
;
893 dc
.SetPen( mpLayout
->mDarkPen
);
895 dc
.DrawLine( bounds
.x
+ bounds
.width
- 1,
897 bounds
.x
+ bounds
.width
- 1,
898 bounds
.y
+ bounds
.height
);
900 dc
.DrawLine( bounds
.x
,
901 bounds
.y
+ bounds
.height
- 1,
902 bounds
.x
+ bounds
.width
,
903 bounds
.y
+ bounds
.height
-1 );
905 dc
.SetPen( mpLayout
->mLightPen
);
907 dc
.DrawLine( bounds
.x
,
909 bounds
.x
+ bounds
.width
- 1,
912 dc
.DrawLine( bounds
.x
,
915 bounds
.y
+ bounds
.height
- 1 );
918 void cbPaneDrawPlugin::DrawShade( int level
, wxRect
& rect
, int alignment
, wxDC
& dc
)
920 // simulates "guled-bricks" appearence of control bars
922 if ( ( alignment
== FL_ALIGN_TOP
&& level
== 1 ) ||
923 ( alignment
== FL_ALIGN_BOTTOM
&& level
== 0 ) ||
924 ( alignment
== FL_ALIGN_LEFT
&& level
== 1 ) ||
925 ( alignment
== FL_ALIGN_RIGHT
&& level
== 0 )
928 dc
.SetPen( mpLayout
->mDarkPen
);
930 dc
.SetPen( mpLayout
->mLightPen
);
932 if ( alignment
== FL_ALIGN_TOP
)
938 rect
.x
+ rect
.width
- 1,
941 dc
.DrawLine( rect
.x
- 1,
943 rect
.x
+ rect
.width
+ 0,
947 if ( alignment
== FL_ALIGN_BOTTOM
)
952 rect
.y
+ rect
.height
- 1,
954 rect
.y
+ rect
.height
- 1 );
956 dc
.DrawLine( rect
.x
- 1,
957 rect
.y
+ rect
.height
,
958 rect
.x
+ rect
.width
+ 1,
959 rect
.y
+ rect
.height
);
962 if ( alignment
== FL_ALIGN_LEFT
)
969 rect
.y
+ rect
.height
- 1 );
971 dc
.DrawLine( rect
.x
- 1,
974 rect
.y
+ rect
.height
);
977 if ( alignment
== FL_ALIGN_RIGHT
)
981 dc
.DrawLine( rect
.x
+ rect
.width
- 1,
983 rect
.x
+ rect
.width
- 1,
984 rect
.y
+ rect
.height
);
987 dc
.DrawLine( rect
.x
+ rect
.width
,
990 rect
.y
+ rect
.height
+ 1 );
995 void cbPaneDrawPlugin::DrawShade1( int level
, wxRect
& rect
, int alignment
, wxDC
& dc
)
997 // simulates "guled-bricks" appearence of control bars
999 if ( ( alignment
== FL_ALIGN_TOP
&& level
== 1 ) ||
1000 ( alignment
== FL_ALIGN_BOTTOM
&& level
== 0 ) ||
1001 ( alignment
== FL_ALIGN_LEFT
&& level
== 1 ) ||
1002 ( alignment
== FL_ALIGN_RIGHT
&& level
== 0 )
1005 dc
.SetPen( mpLayout
->mDarkPen
);
1007 dc
.SetPen( mpLayout
->mLightPen
);
1009 if ( alignment
== FL_ALIGN_TOP
)
1013 dc
.DrawLine( rect
.x
,
1015 rect
.x
+ rect
.width
,
1018 dc
.DrawLine( rect
.x
,
1020 rect
.x
+ rect
.width
,
1024 if ( alignment
== FL_ALIGN_BOTTOM
)
1028 dc
.DrawLine( rect
.x
,
1029 rect
.y
+ rect
.height
- 1,
1030 rect
.x
+ rect
.width
,
1031 rect
.y
+ rect
.height
- 1 );
1033 dc
.DrawLine( rect
.x
,
1034 rect
.y
+ rect
.height
,
1035 rect
.x
+ rect
.width
,
1036 rect
.y
+ rect
.height
);
1039 if ( alignment
== FL_ALIGN_LEFT
)
1043 dc
.DrawLine( rect
.x
,
1046 rect
.y
+ rect
.height
);
1048 dc
.DrawLine( rect
.x
- 1,
1051 rect
.y
+ rect
.height
);
1054 if ( alignment
== FL_ALIGN_RIGHT
)
1058 dc
.DrawLine( rect
.x
+ rect
.width
- 1,
1060 rect
.x
+ rect
.width
- 1,
1061 rect
.y
+ rect
.height
);
1064 dc
.DrawLine( rect
.x
+ rect
.width
,
1066 rect
.x
+ rect
.width
,
1067 rect
.y
+ rect
.height
);
1072 void cbPaneDrawPlugin::DrawPaneShade( wxDC
& dc
, int alignment
)
1074 if ( !mpPane
->mProps
.mShow3DPaneBorderOn
) return;
1076 wxRect bounds
= mpPane
->mBoundsInParent
;
1078 bounds
.x
+= mpPane
->mLeftMargin
;
1079 bounds
.y
+= mpPane
->mTopMargin
;
1080 bounds
.width
-= ( mpPane
->mLeftMargin
+ mpPane
->mRightMargin
);
1081 bounds
.height
-= ( mpPane
->mTopMargin
+ mpPane
->mBottomMargin
);
1083 DrawShade( 0, bounds
, alignment
, dc
);
1084 DrawShade( 1, bounds
, alignment
, dc
);
1087 void cbPaneDrawPlugin::DrawPaneShadeForRow( cbRowInfo
* pRow
, wxDC
& dc
)
1089 if ( !mpPane
->mProps
.mShow3DPaneBorderOn
) return;
1091 // do not draw decoration, if pane has "vainished"
1092 if ( mpPane
->mPaneWidth
< 0 ||
1093 mpPane
->mPaneHeight
< 0 )
1097 wxRect bounds
= pRow
->mBoundsInParent
;
1099 if ( mpPane
->mAlignment
== FL_ALIGN_TOP
||
1100 mpPane
->mAlignment
== FL_ALIGN_BOTTOM
)
1105 DrawShade1( 0, bounds
, FL_ALIGN_LEFT
, dc
);
1106 DrawShade1( 1, bounds
, FL_ALIGN_LEFT
, dc
);
1107 DrawShade1( 0, bounds
, FL_ALIGN_RIGHT
, dc
);
1108 DrawShade1( 1, bounds
, FL_ALIGN_RIGHT
, dc
);
1110 if ( !pRow
->mpNext
)
1111 DrawPaneShade( dc
, FL_ALIGN_BOTTOM
);
1113 if ( !pRow
->mpPrev
)
1114 DrawPaneShade( dc
, FL_ALIGN_TOP
);
1121 DrawShade1( 0, bounds
, FL_ALIGN_TOP
, dc
);
1122 DrawShade1( 1, bounds
, FL_ALIGN_TOP
, dc
);
1123 DrawShade1( 0, bounds
, FL_ALIGN_BOTTOM
, dc
);
1124 DrawShade1( 1, bounds
, FL_ALIGN_BOTTOM
, dc
);
1126 if ( !pRow
->mpNext
)
1127 DrawPaneShade( dc
, FL_ALIGN_RIGHT
);
1129 if ( !pRow
->mpPrev
)
1130 DrawPaneShade( dc
, FL_ALIGN_LEFT
);
1134 void cbPaneDrawPlugin::OnDrawPaneDecorations( cbDrawPaneDecorEvent
& event
)
1136 wxDC
& dc
= *event
.mpDc
;
1138 cbDockPane
* pPane
= event
.mpPane
;
1140 RowArrayT
& lst
= pPane
->GetRowList();
1142 // FIXME:: this is a workaround for some glitches
1146 cbRowInfo
* pLastRow
= lst
[ lst
.Count() - 1 ];
1148 pPane
->PaintRowBackground( pLastRow
, dc
);
1149 pPane
->PaintRowDecorations( pLastRow
, dc
);
1150 pPane
->PaintRowHandles( pLastRow
, dc
);
1153 if ( !pPane
->mProps
.mShow3DPaneBorderOn
) return;
1155 // do not draw decoration, if pane is completely hidden
1156 if ( event
.mpPane
->mPaneWidth
< 0 ||
1157 event
.mpPane
->mPaneHeight
< 0 )
1161 DrawPaneShade( dc
, FL_ALIGN_TOP
);
1162 DrawPaneShade( dc
, FL_ALIGN_BOTTOM
);
1163 DrawPaneShade( dc
, FL_ALIGN_LEFT
);
1164 DrawPaneShade( dc
, FL_ALIGN_RIGHT
);
1166 event
.Skip(); // pass event to the next plugin
1169 // bar decoration/sizing handlers
1171 void cbPaneDrawPlugin::OnDrawBarDecorations( cbDrawBarDecorEvent
& event
)
1173 cbBarInfo
* pBar
= event
.mpBar
;
1174 wxDC
& dc
= *event
.mpDc
;
1176 // draw brick borders
1178 wxRect
& rect
= event
.mBoundsInParent
;
1180 dc
.SetPen( mpLayout
->mLightPen
);
1183 dc
.DrawLine( rect
.x
, rect
.y
,
1184 rect
.x
+ rect
.width
-1, rect
.y
);
1187 dc
.DrawLine( rect
.x
, rect
.y
,
1188 rect
.x
, rect
.y
+ rect
.height
-1 );
1191 dc
.SetPen( mpLayout
->mDarkPen
);
1194 dc
.DrawLine( rect
.x
+ rect
.width
-1, rect
.y
,
1195 rect
.x
+ rect
.width
-1, rect
.y
+ rect
.height
-1 );
1198 dc
.DrawLine( rect
.x
, rect
.y
+ rect
.height
-1,
1199 rect
.x
+ rect
.width
, rect
.y
+ rect
.height
-1 );
1201 event
.Skip(); // pass event to the next plugin
1204 void cbPaneDrawPlugin::OnDrawBarHandles( cbDrawBarHandlesEvent
& event
)
1207 cbBarInfo
* pBar
= event
.mpBar
;
1208 wxDC
& dc
= *event
.mpDc
;
1209 mpPane
= event
.mpPane
;
1211 // draw handles around the bar if present
1213 if ( pBar
->mHasLeftHandle
||
1214 pBar
->mHasRightHandle
)
1216 wxRect
& bounds
= pBar
->mBoundsInParent
;
1218 if ( mpPane
->IsHorizontal() )
1220 if ( pBar
->mHasLeftHandle
)
1222 mpPane
->DrawVertHandle( dc
, bounds
.x
- mpPane
->mProps
.mResizeHandleSize
-1,
1223 bounds
.y
, bounds
.height
);
1225 if ( pBar
->mHasRightHandle
)
1227 mpPane
->DrawVertHandle( dc
,
1228 bounds
.x
+ bounds
.width
-1,
1229 bounds
.y
, bounds
.height
);
1233 if ( pBar
->mHasLeftHandle
)
1235 mpPane
->DrawHorizHandle( dc
, bounds
.x
,
1236 bounds
.y
- mpPane
->mProps
.mResizeHandleSize
- 1,
1239 if ( pBar
->mHasRightHandle
)
1241 mpPane
->DrawHorizHandle( dc
, bounds
.x
,
1242 bounds
.y
+ bounds
.height
- 1,
1247 event
.Skip(); // pass event to the next plugin
1250 void cbPaneDrawPlugin::OnStartDrawInArea( cbStartDrawInAreaEvent
& event
)
1253 wxASSERT( mpClntDc
== NULL
);
1255 // FOR NOW:: create/destroy client-dc upon each drawing
1256 mpClntDc
= new wxClientDC( &mpLayout
->GetParentFrame() );
1258 (*event
.mppDc
) = mpClntDc
;
1260 mpClntDc
->SetClippingRegion( event
.mArea
.x
, event
.mArea
.y
,
1261 event
.mArea
.width
, event
.mArea
.height
);
1264 void cbPaneDrawPlugin::OnFinishDrawInArea( cbFinishDrawInAreaEvent
& event
)
1267 wxASSERT( mpClntDc
);