-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwxFreeSplitter.h
More file actions
255 lines (202 loc) · 7.41 KB
/
Copy pathwxFreeSplitter.h
File metadata and controls
255 lines (202 loc) · 7.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
/***************************************************************
* Name: wxFreeSplitter.h
* Purpose: wxFreeSplitter class interface
* Author: Sergey Dvoryantsev
* Created: 2019-09-19
* Copyright: (c) Sergey Dvoryantsev
* License:
**************************************************************/
#ifndef WXFREESPLITTER_H
#define WXFREESPLITTER_H
class WXDLLIMPEXP_FWD_CORE wxFreeSplitter;
//#define TEST_COLOR
// ----------------------------------------------------------------------------
// defines
// ----------------------------------------------------------------------------
enum wxTrackerStyle
{
wxST_NONE,
wxST_LINE,
wxST_PATTERN,
wxST_UPDATE
};
enum wxSplitterStyle
{
wxSS_AUTO,
wxSS_PATTERN, // pattern: no any frame lines (default)
wxSS_PATTERN_TR, // pattern + transparent background
wxSS_BEVEL, // beveled: simple flat bevel
wxSS_BEVEL_TR, // beveled + transparent background
wsSS_FRAME_3DRAISED, // frame: raised 3D frame
wsSS_FRAME_3DSUNKEN, // frame: sunked 3D frame
};
enum wxSplitSide
{
wxRS_NO, // no split side: used when splitter not set completly
wxRS_TOP,
wxRS_LEFT,
wxRS_RIGHT,
wxRS_BOTTOM
};
// ----------------------------------------------------------------------------
// wxFreeSplitter
// ----------------------------------------------------------------------------
class wxFreeSizerItem;
class /*WXDLLIMPEXP_CORE*/ wxFreeSplitter : public wxNavigationEnabled<wxWindow>
{
public:
// default constants
const int def_splitPanelSize = 3; // minimum splitter panel size
const int def_trackLineSize = 3; // minimum tracker size
const wxTrackerStyle def_trackerStyle = wxST_PATTERN;
const wxSplitterStyle def_splitterStyle = wxSS_AUTO;
public:
wxFreeSplitter();
wxFreeSplitter(wxFreeSizerItem * owner_, wxSplitSide side_);
virtual
~wxFreeSplitter();
void AssignOwner(wxFreeSizerItem * owner_, wxSplitSide side_ = wxRS_NO);
bool IsVisible();
bool Show();
void Hide();
void ArrangeByOwner();
//(**
void OnChangeResizeSide();
void OnChangeOwnerPosition();
//
//
wxPoint m_curPosition; // current window position
wxSize m_curSize;
inline wxPoint GetCurPosition() { return m_curPosition; };
inline wxSize GetCurSize() { return m_curSize; };
//void UpdateOwnerPosition(int dx_, int dy_);
void UpdateOwnerPosition(int dx_, int dy_);
//**)
private:
// inits
void Init();
// owner
public:
inline bool IsOwned();
inline wxFreeSizerItem * GetOwner();
protected:
// getters
inline wxWindow * GetOwnerWindow();
inline wxWindow * GetParentWindow();
// setters
void SetOwner(wxFreeSizerItem * owner_, wxSplitSide side_ = wxRS_NO);
void SetPosition(const wxPoint & pos_);
void SetSize(const wxSize & sz_);
// dotters
bool doArrangeByOwner();
// calcs
wxPoint CalcPosByOwner();
wxPoint CorrPosByOwnerAngle( const wxPoint & ownpos_ );
wxSize CalcSizeByOwner();
int CalcConstraintDrag_X( int dx_ );
int CalcConstraintDrag_Y( int dy_ );
// draws
void DrawSplitter( wxDC & dc );
public:
void SetTrackerStyle( wxTrackerStyle st_ ); // SetTrackerStyle
void SetSplitterStyle( wxSplitterStyle st_ );
void SetSplitPanelSize( int sz_ );
void SetSplitTrackerSize( int sz_ );
//void SetVisible(bool v_);
public:
// check is splitter dragged
bool IsDragging() { return m_Dragging; };
inline wxSplitterStyle GetSplitterStyle() { return m_splitterStyle; };
protected:
void AllocateLineDC();
void DrawSplitTracker(int x_, int y_);
// do drawing tracker
void doDrawTrackerLine( const wxPoint & pos_, const wxSize & size_ );
void doDrawTrackerPattern( const wxPoint & pos_, const wxSize & size_ );
// do drawing tracker Microsoft Windows API
void doDrawTrackerLineMSW( const wxPoint & pos_, const wxSize & size_ );
void doDrawTrackerPatternMSW( const wxPoint & pos_, const wxSize & size_ );
// do drawing splitter
void doDrawSplitter_Pattern( wxDC & dc_, wxRect & rect_, bool tr_ = false ); // wxSS_PATTERNxx
void doDrawSplitter_Bevel( wxDC & dc_, wxRect & rect_, bool tr_ = false ); // wxSS_BEVEL
void doDrawSplitter_Frame_3DRaised( wxDC & dc_, wxRect & rect_ );
void doDrawSplitter_Frame_3DSunken( wxDC & dc_, wxRect & rect_ );
void doDrawRoundedRectangle( wxDC & dc_, wxRect & rect_, wxPen & penrc_, wxPen & penbg_ );
// on need owner change
void doUpdateOwnerPosition( int dx_, int dy_ );
// resize cursor depended from splitter orientation ( V or H )
void doSelectResizeCursor();
// do dragging
void doBeginDrag(); // { m_Dragging = true; wxWindow::Hide(); };
void doEndDrag(); // { m_Dragging = false; wxWindow::Show(); };
bool IsSplitVertical() { return (m_splitSide == wxRS_NO) || (m_splitSide == wxRS_LEFT) || (m_splitSide == wxRS_RIGHT); };
bool IsSplitHorizontal() { return (m_splitSide == wxRS_TOP) || (m_splitSide == wxRS_BOTTOM); };
// getters
inline int GetSplitPanelSize() { return m_splitPanelSize; };
inline int GetTrackLineSize() { return m_trackLineSize; };
inline wxSplitSide GetSplitSide() { return m_splitSide; };
// constraint
wxSize AdjustSize( const wxSize & sz_ );
wxBitmap CreatePatternBitmap( wxColor bgc_, wxColor fgc_ );
wxSplitterStyle GetAutoSplitterStyle();
private:
// private members
wxFreeSizerItem * m_owner;
wxSplitSide m_splitSide;
// current splitter and tracker sizes
// VSplit: width, HSplit: height
int m_splitPanelSize;
int m_trackLineSize;
// drag tracker
bool m_Dragging;
wxPoint m_dragMouseStart;
wxPoint m_dragPosStart;
wxPoint m_dragPosCurrent;
bool m_trackerVisible = false;
bool m_lastStateVisible = false;
// splitter and tracker style
wxTrackerStyle m_trackerStyle; // tracker line style
wxSplitterStyle m_splitterStyle; // splitter frame style
// resize cursors
wxCursor m_cursorResizeV;
wxCursor m_cursorResizeH;
// tracker pattern
wxBitmap m_trackerPattern;
private:
// ???
double GetScalingFactor();
#ifdef TEST_COLOR
// test
void Test_ColoredSplitters();
#endif
protected:
// Event handlers
// paints the border and sash
void OnPaint( wxPaintEvent& event );
// handles mouse events
void OnMouseEvent( wxMouseEvent& ev );
// aborts dragging mode
void OnMouseCaptureLost( wxMouseCaptureLostEvent& event ) { };
// adjusts the panes
void OnSize( wxSizeEvent& event ) { };
#if defined(__WXMSW__) || defined(__WXMAC__)
// set cursor events
void OnSetCursor( wxSetCursorEvent& event );
#endif // wxMSW
// callbacks executed when we detect that the mouse has entered
// or left the splitter band
virtual void OnEnterSplitter();
virtual void OnLeaveSplitter();
protected:
// paint resources
wxPen m_penBtnHLG;
wxPen m_penBtnSHD;
wxPen m_penDarkGrey;
wxPen m_penLightGrey;
wxPen m_penHighLight;
private:
wxDECLARE_DYNAMIC_CLASS( wxFreeSplitter );
wxDECLARE_EVENT_TABLE();
wxDECLARE_NO_COPY_CLASS( wxFreeSplitter );
};
#endif // WXFREESPLITTER_H