]> git.saurik.com Git - wxWidgets.git/blob - utils/framelayout/src/bardragpl.h
don't crash when invalid colour is set as fg/bg colour
[wxWidgets.git] / utils / framelayout / src / bardragpl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: No names yet.
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
5 // Modified by:
6 // Created: 23/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __BARDRAGPL_G__
13 #define __BARDRAGPL_G__
14
15 #include "controlbar.h"
16 #include "toolwnd.h"
17
18 class cbBarDragPlugin : public cbPluginBase
19 {
20 DECLARE_DYNAMIC_CLASS( cbBarDragPlugin )
21 protected:
22
23 // plugin is active only in bar-dragging state
24 bool mBarDragStarted;
25 bool mCanStick; // flag used to prevent "bouncing" of hint-rectangle
26 wxScreenDC* mpScrDc; // created while tracking hint-rect
27 wxCursor* mpCurCursor;
28
29 // rectnagle shows the position/dimensions of the bar,
30 // if it would be docked now
31
32 wxRect mPrevHintRect;
33 wxRect mHintRect;
34
35
36 int mMouseInRectX;
37 int mMouseInRectY;
38
39 cbDockPane* mpSrcPane; // pane, from which the bar was originally taken
40 int mBarWidthInSrcPane;
41
42 cbDockPane* mpCurPane;
43
44 cbBarInfo* mpDraggedBar; // bar, which is being dragged
45 bool mBarWasFloating;
46 wxRect mFloatedBarBounds;
47
48 public: /*** public properties ***/
49
50 int mInClientHintBorder; // when hint-rect moves within client window area,
51 // the thicker rectangle is drawn using hatched brush,
52 // the default border width for this rectangle is 8 pix.
53
54 protected:
55
56
57 void AdjustHintRect( wxPoint& mousePos );
58
59 void ClipRectInFrame( wxRect& rect );
60 void ClipPosInFrame( wxPoint& pos );
61
62 cbDockPane* HitTestPanes( wxRect& rect );
63 cbDockPane* HitTestPanes( wxPoint& pos );
64 bool HitsPane( cbDockPane* pPane, wxRect& rect );
65
66 void CalcOnScreenDims( wxRect& rect );
67
68 int GetDistanceToPane( cbDockPane* pPane, wxPoint& mousePos );
69
70 bool IsInOtherPane ( wxPoint& mousePos );
71 bool IsInClientArea( wxPoint& mousePos );
72 bool IsInClientArea( wxRect& rect );
73
74 void StickToPane( cbDockPane* pPane, wxPoint& mousePos );
75 void UnstickFromPane( cbDockPane* pPane, wxPoint& mousePos );
76
77 int GetBarWidthInPane( cbDockPane* pPane );
78 int GetBarHeightInPane( cbDockPane* pPane );
79
80 // on-screen hint-tracking related methods
81
82 void StartTracking();
83
84 void DrawHintRect ( wxRect& rect, bool isInClientRect);
85 void EraseHintRect( wxRect& rect, bool isInClientRect);
86
87 void FinishTracking();
88
89 void DoDrawHintRect( wxRect& rect, bool isInClientRect);
90
91 void RectToScr( wxRect& frameRect, wxRect& scrRect );
92
93 void ShowHint( bool prevWasInClient );
94
95 public:
96 cbBarDragPlugin(void);
97
98 cbBarDragPlugin( wxFrameLayout* pPanel, int paneMask = wxALL_PANES );
99
100 virtual ~cbBarDragPlugin();
101
102 // handlers for plugin events
103
104 void OnMouseMove( cbMotionEvent& event );
105 void OnLButtonUp( cbLeftUpEvent& event );
106 void OnLButtonDown( cbLeftDownEvent& event );
107 void OnLDblClick( cbLeftDClickEvent& event );
108
109 // handles event, which oriniates from itself
110 void OnDrawHintRect( cbDrawHintRectEvent& event );
111
112 void OnStartBarDragging( cbStartBarDraggingEvent& event );
113
114 DECLARE_EVENT_TABLE()
115 };
116
117 #endif