1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: cbBarDragPlugin implementation
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "bardragpl.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
27 #include "wx/fl/bardragpl.h"
29 #define POS_UNDEFINED -32768
31 // helpers, FOR NOW:: static
33 static inline bool rect_hits_rect( const wxRect
& r1
, const wxRect
& r2
)
35 if ( ( r2
.x
>= r1
.x
&& r2
.x
<= r1
.x
+ r1
.width
) ||
36 ( r1
.x
>= r2
.x
&& r1
.x
<= r2
.x
+ r2
.width
) )
37 if ( ( r2
.y
>= r1
.y
&& r2
.y
<= r1
.y
+ r1
.height
) ||
38 ( r1
.y
>= r2
.y
&& r1
.y
<= r2
.y
+ r2
.height
) )
43 static inline bool rect_contains_point( const wxRect
& rect
, int x
, int y
)
45 return ( x
>= rect
.x
&&
47 x
< rect
.x
+ rect
.width
&&
48 y
< rect
.y
+ rect
.height
);
51 /***** Implementation for class cbBarDragPlugin *****/
53 IMPLEMENT_DYNAMIC_CLASS( cbBarDragPlugin
, cbPluginBase
)
55 BEGIN_EVENT_TABLE( cbBarDragPlugin
, cbPluginBase
)
57 //EVT_PL_LEFT_DOWN ( cbBarDragPlugin::OnLButtonDown )
58 EVT_PL_LEFT_UP ( cbBarDragPlugin::OnLButtonUp
)
59 EVT_PL_MOTION ( cbBarDragPlugin::OnMouseMove
)
60 EVT_PL_DRAW_HINT_RECT ( cbBarDragPlugin::OnDrawHintRect
)
61 EVT_PL_START_BAR_DRAGGING ( cbBarDragPlugin::OnStartBarDragging
)
62 EVT_PL_LEFT_DCLICK ( cbBarDragPlugin::OnLDblClick
)
66 cbBarDragPlugin::cbBarDragPlugin(void)
68 : mBarDragStarted ( false ),
72 mpDraggedBar ( NULL
),
73 mInClientHintBorder( 4 )
76 cbBarDragPlugin::cbBarDragPlugin( wxFrameLayout
* pPanel
, int paneMask
)
78 : cbPluginBase( pPanel
, paneMask
),
80 mBarDragStarted ( false ),
84 mpDraggedBar ( NULL
),
85 mInClientHintBorder( 4 )
88 cbBarDragPlugin::~cbBarDragPlugin()
93 // helper methods (protected)
95 // clips (top/bottom) or (right/left) edges against the frame's bounding rect.
97 void do_clip_edges( int len
, int& rectPos
, int& rectLen
)
107 if ( rectPos
> len
-1 )
113 if ( rectPos
+ rectLen
- 1 > len
)
114 rectLen
-= (rectPos
+ rectLen
) - len
+ 1;
117 void cbBarDragPlugin::ClipRectInFrame( wxRect
& rect
)
120 mpLayout
->GetParentFrame().GetClientSize( &w
, &h
);
122 do_clip_edges( w
, rect
.x
, rect
.width
);
123 do_clip_edges( h
, rect
.y
, rect
.height
);
126 void cbBarDragPlugin::ClipPosInFrame( wxPoint
& pos
)
129 mpLayout
->GetParentFrame().GetClientSize( &w
, &h
);
141 void cbBarDragPlugin::AdjustHintRect( wxPoint
& mousePos
)
143 mHintRect
.x
= mousePos
.x
- mMouseInRectX
;
144 mHintRect
.y
= mousePos
.y
- mMouseInRectY
;
147 cbDockPane
* cbBarDragPlugin::HitTestPanes( wxRect
& rect
)
149 //wxRect clipped = rect;
151 //ClipRectInFrame( clipped );
153 cbDockPane
** pPanes
= mpLayout
->GetPanesArray();
155 for( int i
= 0; i
!= MAX_PANES
; ++i
)
156 if ( rect_hits_rect( pPanes
[i
]->mBoundsInParent
, rect
) )
162 cbDockPane
* cbBarDragPlugin::HitTestPanes( wxPoint
& pos
)
164 wxPoint clipped
= pos
;
166 //ClipPosInFrame( pos );
168 cbDockPane
** pPanes
= mpLayout
->GetPanesArray();
170 for( int i
= 0; i
!= MAX_PANES
; ++i
)
171 if ( rect_contains_point( pPanes
[i
]->mBoundsInParent
, clipped
.x
, clipped
.y
) )
177 bool cbBarDragPlugin::HitsPane( cbDockPane
* pPane
, wxRect
& rect
)
179 return rect_hits_rect( pPane
->mBoundsInParent
, rect
);
182 int cbBarDragPlugin::GetDistanceToPane( cbDockPane
* pPane
, wxPoint
& mousePos
)
184 wxRect
& bounds
= pPane
->mBoundsInParent
;
186 switch( pPane
->mAlignment
)
188 case FL_ALIGN_TOP
: return mousePos
.y
- ( bounds
.y
+ bounds
.height
);
189 case FL_ALIGN_BOTTOM
: return bounds
.y
- mousePos
.y
;
190 case FL_ALIGN_LEFT
: return mousePos
.x
- ( bounds
.x
+ bounds
.width
);
191 case FL_ALIGN_RIGHT
: return bounds
.x
- mousePos
.x
;
192 default : return 0; // never reached
198 bool cbBarDragPlugin::IsInOtherPane( wxPoint
& mousePos
)
200 cbDockPane
* pPane
= HitTestPanes( mousePos
);
202 if ( pPane
&& pPane
!= mpCurPane
) return true;
206 bool cbBarDragPlugin::IsInClientArea( wxPoint
& mousePos
)
208 return ( HitTestPanes( mousePos
) == NULL
);
211 bool cbBarDragPlugin::IsInClientArea( wxRect
& rect
)
213 return ( HitTestPanes( rect
) == NULL
);
216 void cbBarDragPlugin::CalcOnScreenDims( wxRect
& rect
)
218 if ( !mpCurPane
|| mpDraggedBar
->IsFixed() ) return;
220 wxRect inPane
= rect
;
222 mpCurPane
->FrameToPane( &inPane
);
224 int rowNo
= mpCurPane
->GetRowAt( inPane
.y
, inPane
.y
+ inPane
.height
);
226 bool isMaximized
= ( rowNo
>= (int)mpCurPane
->GetRowList().Count() || rowNo
< 0 );
231 inPane
.width
= mpCurPane
->mPaneWidth
;
233 mpCurPane
->PaneToFrame( &inPane
);
241 static inline void check_upper_overrun( int& pos
, int width
, int mousePos
)
243 if ( mousePos
>= pos
+ width
)
244 pos
= mousePos
- width
/2;
247 static inline void check_lower_overrun( int& pos
, int width
, int mousePos
)
249 if ( mousePos
<= pos
)
250 pos
= mousePos
- width
/2;
253 void cbBarDragPlugin::StickToPane( cbDockPane
* pPane
, wxPoint
& mousePos
)
255 int wInPane
= GetBarWidthInPane ( pPane
);
256 int hInPane
= GetBarHeightInPane( pPane
);
258 // adjsut hint-rect horizontally (in pane's orientation)
260 if ( pPane
->IsHorizontal() )
262 mHintRect
.width
= wInPane
;
263 mHintRect
.height
= hInPane
;
267 mHintRect
.height
= wInPane
;
268 mHintRect
.width
= hInPane
;
271 // adjsut hint-rect vertically (in pane's orientation)
273 wxRect
& bounds
= pPane
->mBoundsInParent
;
275 // true, if hint enters the pane through it's lower edge
277 bool fromLowerEdge
= ( pPane
->IsHorizontal() )
278 ? mousePos
.y
> bounds
.y
279 : mousePos
.x
> bounds
.x
;
281 // NOTE:: about all the below min/max things: they are meant to ensure
282 // that the mouse pointer doesn't overrun (leave) the hint-rectangle
283 // when its dimensions are recalculated upon sticking it to the pane
285 if ( pPane
->IsHorizontal() && fromLowerEdge
)
287 int paneBottomEdgeY
= bounds
.y
+ bounds
.height
;
289 mHintRect
.y
= wxMin( paneBottomEdgeY
, mousePos
.y
);
291 check_lower_overrun( mHintRect
.y
, hInPane
, mousePos
.y
);
295 if ( pPane
->IsHorizontal() && !fromLowerEdge
)
297 int paneTopEdgeY
= bounds
.y
;
299 mHintRect
.y
= wxMax( paneTopEdgeY
- hInPane
, mousePos
.y
- hInPane
);
301 check_upper_overrun( mHintRect
.y
, hInPane
, mousePos
.y
);
304 if ( !pPane
->IsHorizontal() && fromLowerEdge
)
306 int paneRightEdgeX
= bounds
.x
+ bounds
.width
;
308 mHintRect
.x
= wxMin( paneRightEdgeX
, mousePos
.x
);
310 check_lower_overrun( mHintRect
.x
, hInPane
, mousePos
.x
);
313 if ( !pPane
->IsHorizontal() && !fromLowerEdge
)
315 int paneLeftEdgeX
= bounds
.x
;
317 mHintRect
.x
= wxMax( paneLeftEdgeX
- hInPane
, mousePos
.x
- hInPane
);
319 check_upper_overrun( mHintRect
.x
, hInPane
, mousePos
.x
);
322 mMouseInRectX
= mousePos
.x
- mHintRect
.x
;
323 mMouseInRectY
= mousePos
.y
- mHintRect
.y
;
325 mpCurPane
= pPane
; // memorize pane to which the hint is currently sticked
328 void cbBarDragPlugin::UnstickFromPane( cbDockPane
* pPane
, wxPoint
& mousePos
)
330 // unsticking causes rectangle to get the shape in which
331 // dragged control-bar would be when floated
333 int newWidth
= mpDraggedBar
->mDimInfo
.mSizes
[wxCBAR_FLOATING
].x
;
334 int newHeight
= mpDraggedBar
->mDimInfo
.mSizes
[wxCBAR_FLOATING
].y
;
336 wxRect
& flBounds
= mpDraggedBar
->mDimInfo
.mBounds
[wxCBAR_FLOATING
];
338 if ( flBounds
.width
!= -1 )
340 newWidth
= flBounds
.width
;
341 newHeight
= flBounds
.height
;
344 mHintRect
.width
= newWidth
;
345 mHintRect
.height
= newHeight
;
347 wxRect
& bounds
= pPane
->mBoundsInParent
;
349 // true, if hint leaves the pane through it's lower edge
351 bool fromLowerEdge
= ( pPane
->IsHorizontal() )
352 ? mousePos
.y
> bounds
.y
353 : mousePos
.x
> bounds
.x
;
355 // NOTE:: ...all the below min/max things - see comments about it in StickToPane(..)
357 if ( pPane
->IsHorizontal() && fromLowerEdge
)
359 // bool fromLowerEdge = mousePos.y > bounds.y;
361 mHintRect
.y
= wxMax( bounds
.y
+ bounds
.height
+ 1, mousePos
.y
- newHeight
);
363 check_upper_overrun( mHintRect
.y
, newHeight
, mousePos
.y
);
365 // this is how MFC's hint behaves:
367 if ( mMouseInRectX
> newWidth
)
368 mHintRect
.x
= mousePos
.x
- ( newWidth
/ 2 );
371 if ( pPane
->IsHorizontal() && !fromLowerEdge
)
373 mHintRect
.y
= wxMin( bounds
.y
- newHeight
- 1, mousePos
.y
);
377 if ( mMouseInRectX
> newWidth
)
378 mHintRect
.x
= mousePos
.x
- ( newWidth
/ 2 );
380 check_lower_overrun( mHintRect
.y
, newHeight
, mousePos
.y
);
383 if ( !pPane
->IsHorizontal() && fromLowerEdge
)
385 mHintRect
.x
= wxMax( bounds
.x
+ bounds
.width
, mousePos
.x
- newWidth
);
389 if ( mMouseInRectY
> newHeight
)
390 mHintRect
.y
= mousePos
.y
- ( newHeight
/ 2 );
392 check_upper_overrun( mHintRect
.x
, newWidth
, mousePos
.x
);
395 if ( !pPane
->IsHorizontal() && !fromLowerEdge
)
397 mHintRect
.x
= wxMin( bounds
.x
- newWidth
- 1, mousePos
.x
);
401 if ( mMouseInRectY
> newHeight
)
402 mHintRect
.y
= mousePos
.y
- ( newHeight
/ 2 );
404 check_lower_overrun( mHintRect
.x
, newWidth
, mousePos
.x
);
407 mMouseInRectX
= mousePos
.x
- mHintRect
.x
;
408 mMouseInRectY
= mousePos
.y
- mHintRect
.y
;
413 int cbBarDragPlugin::GetBarWidthInPane( cbDockPane
* pPane
)
415 if ( pPane
== mpSrcPane
)
416 return mBarWidthInSrcPane
;
418 // this is how MFC's bars behave:
420 if ( pPane
->IsHorizontal() )
421 return mpDraggedBar
->mDimInfo
.mSizes
[wxCBAR_DOCKED_HORIZONTALLY
].x
;
423 return mpDraggedBar
->mDimInfo
.mSizes
[wxCBAR_DOCKED_VERTICALLY
].x
;
426 int cbBarDragPlugin::GetBarHeightInPane( cbDockPane
* pPane
)
428 if ( pPane
->IsHorizontal() )
429 return mpDraggedBar
->mDimInfo
.mSizes
[wxCBAR_DOCKED_HORIZONTALLY
].y
;
431 return mpDraggedBar
->mDimInfo
.mSizes
[wxCBAR_DOCKED_VERTICALLY
].y
;
434 void cbBarDragPlugin::ShowHint( bool prevWasInClient
)
436 bool wasDocked
= false;
438 if ( mpSrcPane
->mProps
.mRealTimeUpdatesOn
== false )
440 // do heavy calculations first
442 wxRect actualRect
= mHintRect
; // will be adjusted depending on drag-settings
444 if ( mpSrcPane
->mProps
.mExactDockPredictionOn
&& mpCurPane
)
449 mpLayout
->RedockBar( mpDraggedBar
, mHintRect
, mpCurPane
, false );
451 wxASSERT( success
); // DBG::
453 actualRect
= mpDraggedBar
->mBounds
;
455 mpCurPane
->PaneToFrame( &actualRect
);
458 CalcOnScreenDims( actualRect
);
460 // release previous hint
462 if ( mPrevHintRect
.x
!= POS_UNDEFINED
)
464 // erase previous rectangle
466 cbDrawHintRectEvent
evt( mPrevHintRect
, prevWasInClient
, true, false );
468 mpLayout
->FirePluginEvent( evt
);
473 cbDrawHintRectEvent
evt( actualRect
, mpCurPane
== NULL
, false, false );
475 mpLayout
->FirePluginEvent( evt
);
477 mPrevHintRect
= actualRect
;
481 // otherwise, if real-time updates option is ON
483 if ( mpDraggedBar
->mState
!= wxCBAR_FLOATING
&& !mpCurPane
)
485 mpLayout
->SetBarState( mpDraggedBar
, wxCBAR_FLOATING
, true );
488 if ( mpDraggedBar
->mState
== wxCBAR_FLOATING
&& mpCurPane
)
490 mpLayout
->SetBarState( mpDraggedBar
, wxCBAR_DOCKED_HORIZONTALLY
, false );
497 mpLayout
->GetUpdatesManager().OnStartChanges();
501 mpDraggedBar
->mUMgrData
.SetDirty( true );
506 mpLayout
->RedockBar( mpDraggedBar
, mHintRect
, mpCurPane
, false );
508 wxASSERT( success
); // DBG ::
510 mpLayout
->GetUpdatesManager().OnFinishChanges();
511 mpLayout
->GetUpdatesManager().UpdateNow();
515 if ( mpLayout
->mFloatingOn
)
517 // move the top-most floated bar around as user drags the hint
519 mpDraggedBar
->mDimInfo
.mBounds
[ wxCBAR_FLOATING
] = mHintRect
;
521 mpLayout
->ApplyBarProperties( mpDraggedBar
);
527 /*** event handlers ***/
529 void cbBarDragPlugin::OnMouseMove( cbMotionEvent
& event
)
531 // calculate postion in frame's coordiantes
533 if ( !mBarDragStarted
)
535 event
.Skip(); // pass event to the next plugin
539 wxPoint mousePos
= event
.mPos
;
541 event
.mpPane
->PaneToFrame( &mousePos
.x
, &mousePos
.y
);
543 bool prevIsInClient
= ( mpCurPane
== 0 );
545 AdjustHintRect( mousePos
);
547 // if the hint-rect is not "tempted" to any pane yet
549 if ( mpCurPane
== NULL
)
551 cbDockPane
* pPane
= HitTestPanes( mHintRect
);
553 // enable sticking again, if we've left the pane completely
557 if ( mCanStick
&& pPane
&&
558 GetDistanceToPane( pPane
, mousePos
) < GetBarHeightInPane( pPane
) )
559 StickToPane( pPane
, mousePos
);
561 if ( pPane
&& HitTestPanes( mousePos
) == pPane
&& 0 ) // FOR NOW:: disabled
563 StickToPane( pPane
, mousePos
);
567 // otherwise, when rect is now sticked to some of the panes
568 // check if it should still remain in this pane
572 bool mouseInOther
= IsInOtherPane( mousePos
);
576 cbDockPane
* pPane
= HitTestPanes( mousePos
);
578 StickToPane( pPane
, mousePos
);
582 if ( IsInClientArea( mousePos
) )
584 cbDockPane
* pPane
= HitTestPanes( mHintRect
);
587 pPane
!= mpCurPane
&&
588 GetDistanceToPane( pPane
, mousePos
) < GetBarHeightInPane( pPane
) )
589 StickToPane( pPane
, mousePos
);
593 UnstickFromPane( mpCurPane
, mousePos
);
595 // FOR NOW:: disabled, would cause some mess
596 // mCanStick = false; // prevents from sticking to this
597 // pane again, flag is reset when hint-rect
598 // leaves the pane completely
601 if ( GetDistanceToPane( pPane
, mousePos
) > GetBarHeightInPane( pPane
) )
603 if ( !HitsPane( mpCurPane
, mHintRect
) )
605 UnstickFromPane( mpCurPane
, mousePos
);
607 // FOR NOW:: disabled, would cause some mess
608 // mCanStick = false; // prevents from sticking to this
609 // pane again, flag is reset when hint-rect
610 // leaves the pane completely
618 ShowHint( prevIsInClient
);
620 wxCursor
* pPrevCurs
= mpCurCursor
;
624 mpCurCursor
= mpLayout
->mpNormalCursor
;
628 // if floating is off, and we are in the client
629 // area, the cursor will be invalid, otherwise
630 // it will be the normal cursor
632 if (mpLayout
->mFloatingOn
)
634 mpCurCursor
= mpLayout
->mpNormalCursor
;
638 mpCurCursor
= mpLayout
->mpNECursor
;
642 if ( pPrevCurs
!= mpCurCursor
)
643 mpLayout
->GetParentFrame().SetCursor( *mpCurCursor
);
646 void cbBarDragPlugin::OnLButtonDown( cbLeftDownEvent
& event
)
648 if ( mBarDragStarted
)
650 wxMessageBox(wxT("DblClick!"));
656 void cbBarDragPlugin::OnLButtonUp( cbLeftUpEvent
& event
)
658 if ( mBarDragStarted
)
660 if ( mpSrcPane
->mProps
.mRealTimeUpdatesOn
== false )
662 // erase current rectangle, and finsih on-screen drawing session
664 cbDrawHintRectEvent
evt( mPrevHintRect
, mpCurPane
== NULL
, true, true );
666 mpLayout
->FirePluginEvent( evt
);
668 if ( mpCurPane
!= NULL
)
670 if ( mpSrcPane
->mProps
.mExactDockPredictionOn
)
672 mpLayout
->RedockBar( mpDraggedBar
, mHintRect
, mpCurPane
, false );
674 mpLayout
->GetUpdatesManager().OnFinishChanges();
675 mpLayout
->GetUpdatesManager().UpdateNow();
679 if (mpDraggedBar
->mState
== wxCBAR_FLOATING
)
681 mpLayout
->SetBarState( mpDraggedBar
, wxCBAR_DOCKED_HORIZONTALLY
, true);
684 mpLayout
->RedockBar( mpDraggedBar
, mHintRect
, mpCurPane
);
689 if (mpDraggedBar
->mState
!= wxCBAR_FLOATING
)
691 mpLayout
->SetBarState(mpDraggedBar
, wxCBAR_FLOATING
, true);
694 mpDraggedBar
->mDimInfo
.mBounds
[ wxCBAR_FLOATING
] = mHintRect
;
695 mpLayout
->ApplyBarProperties( mpDraggedBar
);
699 mHintRect
.width
= -1;
701 // In Windows, at least, the frame needs to have a null cursor
702 // else child windows (such as text windows) inherit the cursor
704 mpLayout
->GetParentFrame().SetCursor( wxNullCursor
);
706 mpLayout
->GetParentFrame().SetCursor( *mpLayout
->mpNormalCursor
);
709 mpLayout
->ReleaseEventsFromPane( event
.mpPane
);
710 mpLayout
->ReleaseEventsFromPlugin( this );
712 mBarDragStarted
= false;
714 if ( mBarWasFloating
&& mpDraggedBar
->mState
!= wxCBAR_FLOATING
)
716 // save bar's floating position before it was docked
718 mpDraggedBar
->mDimInfo
.mBounds
[ wxCBAR_FLOATING
] = mFloatedBarBounds
;
722 event
.Skip(); // pass event to the next plugin
725 void cbBarDragPlugin::OnLDblClick( cbLeftDClickEvent
& event
)
727 int avoidCompilerWarning
= 1;
728 if ( avoidCompilerWarning
)
730 cbBarInfo
* pHittedBar
;
733 if ( event
.mpPane
->HitTestPaneItems( event
.mPos
, // in pane's coordiantes
735 &pHittedBar
) == CB_BAR_CONTENT_HITTED
738 mpLayout
->SetBarState( pHittedBar
, wxCBAR_FLOATING
, true );
740 mpLayout
->RepositionFloatedBar( pHittedBar
);
742 return; // event is "eaten" by this plugin
745 mBarDragStarted
= false;
750 //wxMessageBox("Hi, dblclick arrived!");
753 void cbBarDragPlugin::OnStartBarDragging( cbStartBarDraggingEvent
& event
)
755 mpDraggedBar
= event
.mpBar
;
756 mpSrcPane
= event
.mpPane
;
758 mpLayout
->CaptureEventsForPane( event
.mpPane
);
759 mpLayout
->CaptureEventsForPlugin( this );
761 mpLayout
->GetParentFrame().SetCursor( *mpLayout
->mpNormalCursor
);
763 mBarDragStarted
= true;
765 wxRect inParent
= mpDraggedBar
->mBounds
;
767 mBarWasFloating
= mpDraggedBar
->mState
== wxCBAR_FLOATING
;
769 if ( mBarWasFloating
)
771 inParent
= mpDraggedBar
->mDimInfo
.mBounds
[ wxCBAR_FLOATING
];
772 mFloatedBarBounds
= inParent
;
775 event
.mpPane
->PaneToFrame( &inParent
);
777 mHintRect
.x
= POS_UNDEFINED
;
779 mHintRect
.width
= inParent
.width
;
780 mHintRect
.height
= inParent
.height
;
782 mMouseInRectX
= event
.mPos
.x
- inParent
.x
;
783 mMouseInRectY
= event
.mPos
.y
- inParent
.y
;
785 mpSrcPane
= event
.mpPane
;
787 if ( mpDraggedBar
->mState
== wxCBAR_FLOATING
)
791 mpCurPane
= event
.mpPane
;
793 mPrevHintRect
.x
= POS_UNDEFINED
;
795 mCanStick
= false; // we're not stuck into any pane now -
796 // there's nowhere to "stick-twice"
798 mBarWidthInSrcPane
= mpDraggedBar
->mDimInfo
.mSizes
[ mpDraggedBar
->mState
].x
;
800 if ( mpSrcPane
->mProps
.mRealTimeUpdatesOn
== false &&
801 mpSrcPane
->mProps
.mExactDockPredictionOn
)
802 mpLayout
->GetUpdatesManager().OnStartChanges(); // capture initial state of layout
804 // simulate the first mouse movement
806 int x
= event
.mPos
.x
, y
= event
.mPos
.y
;
807 mpSrcPane
->FrameToPane( &x
, &y
);
810 cbMotionEvent
motionEvt( pt
, event
.mpPane
);
811 this->OnMouseMove( motionEvt
);
813 return; // event is "eaten" by this plugin
816 /*** on-screen hint-tracking related methods ***/
818 void cbBarDragPlugin::OnDrawHintRect( cbDrawHintRectEvent
& event
)
820 if ( !mpScrDc
) StartTracking();
822 DoDrawHintRect( event
.mRect
, event
.mIsInClient
);
824 if ( event
.mLastTime
)
828 #define _IMG_A 0xAA // Note: modified from _A to _IMG_A, _A was already defined (cygwin)
829 #define _IMG_B 0x00 // Note: modified from _B to _IMG_A, _B was already defined (cygwin)
830 #define _IMG_C 0x55 // Note: modified from _C to _IMG_C, for consistency reasons.
831 #define _IMG_D 0x00 // Note: modified from _D to _IMG_D, for consistency reasons.
835 static const unsigned char _gCheckerImg
[16] = { _IMG_A
,_IMG_B
,_IMG_C
,_IMG_D
,
836 _IMG_A
,_IMG_B
,_IMG_C
,_IMG_D
,
837 _IMG_A
,_IMG_B
,_IMG_C
,_IMG_D
,
838 _IMG_A
,_IMG_B
,_IMG_C
,_IMG_D
841 void cbBarDragPlugin::StartTracking()
843 mpScrDc
= new wxScreenDC
;
845 wxScreenDC::StartDrawingOnTop(&mpLayout
->GetParentFrame());
848 void cbBarDragPlugin::DoDrawHintRect( wxRect
& rect
, bool isInClientRect
)
852 RectToScr( rect
, scrRect
);
854 int prevLF
= mpScrDc
->GetLogicalFunction();
856 mpScrDc
->SetLogicalFunction( wxINVERT
);
858 if ( isInClientRect
)
860 // BUG BUG BUG (wx):: somehow stippled brush works only
861 // when the bitmap created on stack, not
862 // as a member of the class
864 wxBitmap
checker( (const char*)_gCheckerImg
, 8,8 );
866 wxBrush
checkerBrush( checker
);
868 mpScrDc
->SetPen( mpLayout
->mNullPen
);
869 mpScrDc
->SetBrush( checkerBrush
);
871 int half
= mInClientHintBorder
/ 2;
873 mpScrDc
->DrawRectangle( scrRect
.x
- half
, scrRect
.y
- half
,
874 scrRect
.width
+ 2*half
, mInClientHintBorder
);
876 mpScrDc
->DrawRectangle( scrRect
.x
- half
, scrRect
.y
+ scrRect
.height
- half
,
877 scrRect
.width
+ 2*half
, mInClientHintBorder
);
879 mpScrDc
->DrawRectangle( scrRect
.x
- half
, scrRect
.y
+ half
- 1,
880 mInClientHintBorder
, scrRect
.height
- 2*half
+ 2);
882 mpScrDc
->DrawRectangle( scrRect
.x
+ scrRect
.width
- half
,
883 scrRect
.y
+ half
- 1,
884 mInClientHintBorder
, scrRect
.height
- 2*half
+ 2);
886 mpScrDc
->SetBrush( wxNullBrush
);
890 mpScrDc
->SetPen( mpLayout
->mBlackPen
);
892 mpScrDc
->DrawLine( scrRect
.x
, scrRect
.y
,
893 scrRect
.x
+ scrRect
.width
, scrRect
.y
);
895 mpScrDc
->DrawLine( scrRect
.x
, scrRect
.y
+ 1,
896 scrRect
.x
, scrRect
.y
+ scrRect
.height
);
898 mpScrDc
->DrawLine( scrRect
.x
+1, scrRect
.y
+ scrRect
.height
,
899 scrRect
.x
+ scrRect
.width
, scrRect
.y
+ scrRect
.height
);
901 mpScrDc
->DrawLine( scrRect
.x
+ scrRect
.width
, scrRect
.y
,
902 scrRect
.x
+ scrRect
.width
, scrRect
.y
+ scrRect
.height
+ 1);
905 mpScrDc
->SetLogicalFunction( prevLF
);
908 void cbBarDragPlugin::DrawHintRect ( wxRect
& rect
, bool isInClientRect
)
910 DoDrawHintRect( rect
, isInClientRect
);
913 void cbBarDragPlugin::EraseHintRect( wxRect
& rect
, bool isInClientRect
)
915 DoDrawHintRect( rect
, isInClientRect
);
918 void cbBarDragPlugin::FinishTracking()
920 wxScreenDC::EndDrawingOnTop();
927 void cbBarDragPlugin::RectToScr( wxRect
& frameRect
, wxRect
& scrRect
)
931 int x
= frameRect
.x
, y
= frameRect
.y
;
933 mpLayout
->GetParentFrame().ClientToScreen( &x
, &y
);