-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwxResizeCtrl.h
87 lines (74 loc) · 3.82 KB
/
wxResizeCtrl.h
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
/***************************************************************
* Widgets: wxResizeCtrl
* Name: wxResizeCtrl.h
* Purpose: Draw a sizing border around the child wxWindow, and allow the user to resize it
* Author: Seb ([email protected])
* Created: 2010-04-17
* Copyright: Seb ()
* License: GPL 3.0
**************************************************************/
#ifndef RESIZECONTROL_H
#define RESIZECONTROL_H
#include <wx/window.h>
#include <wx/colour.h>
/** \brief this simple class is a resizeable and moveable control: it has a child window
* that the user can resize or move using the mouse.
*
*/
class wxResizeCtrl : public wxWindow
{
public:
//constructors
wxResizeCtrl(void); ///< \brief default constructor. call Create() after the constructor
wxResizeCtrl(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_SIMPLE,
const wxString& name = wxPanelNameStr
); ///< \brief constructor
wxResizeCtrl(wxWindow *parent,
wxWindowID id,
wxWindow *child,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_SIMPLE,
const wxString& name = wxPanelNameStr
); ///< \brief constructor - call SetChild()
~wxResizeCtrl(void); ///< \brief destructor
//initializations methods
void Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxBORDER_SIMPLE,
const wxString& name = wxPanelNameStr
); ///< \brief create the window itself
void SetChild(wxWindow *Child); ///< \brief set the child window
wxWindow* GetChild(void); ///< \brief get the child window
void SetMargin(int iNewMargin); ///< \brief set the size of the resizing border, in pixel
int GetMargin(void); ///< \brief get the size of the resizing border, in pixel
void SetColour(wxColour cColour); ///< \brief set the colour of the resizing border
wxColour GetColour(void); ///< \brief get the colour of the resizing border
protected:
//Event handlers
void OnMouseMove(wxMouseEvent& event); ///< \brief Mouse events handler
void OnLeftDown(wxMouseEvent& event); ///< \brief Mouse left button down event
void OnLeftUp(wxMouseEvent& event); ///< \brief Mouse left button up event
void OnSize(wxSizeEvent& event); ///< \brief Size event
void OnPaint(wxPaintEvent& event); ///< \brief Paint event
void OnCaptureLost(wxMouseCaptureLostEvent& event); ///< \brief mouse capture lost event
private:
void SetChildSize(wxSize s); ///< \brief compute the new size and pos of the child, and resize / move it
wxWindow *child; ///< \brief the child window. Can be anything, including a wxPanel
int iMargin; ///< \brief the size of the resizing border border
wxColour cBoxColour; ///< \brief the colour of the resizing blocks
bool bResizeTop; ///< \brief true if resizing the top border
bool bResizeLeft; ///< \brief true if resizing the left border
bool bResizeBottom; ///< \brief true if resizing the bottom border
bool bResizeRight; ///< \brief true if resizing the right border
bool bMoving; ///< \brief true if moving the window
int x;
int y;
};
#endif