]>
Commit | Line | Data |
---|---|---|
0f1bf77d VS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/toplevel.h | |
3 | // Purpose: Top level window, abstraction of wxFrame and wxDialog | |
4 | // Author: Vaclav Slavik | |
5 | // Id: $Id$ | |
52750c2e | 6 | // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com) |
0f1bf77d VS |
7 | // Licence: wxWindows licence |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | ||
11 | #ifndef __WX_UNIV_TOPLEVEL_H__ | |
12 | #define __WX_UNIV_TOPLEVEL_H__ | |
13 | ||
14 | #ifdef __GNUG__ | |
15 | #pragma interface "univtoplevel.h" | |
16 | #endif | |
17 | ||
24a23c35 | 18 | #include "wx/univ/inpcons.h" |
ea1b0d6c | 19 | #include "wx/univ/inphand.h" |
24a23c35 VS |
20 | |
21 | // ---------------------------------------------------------------------------- | |
22 | // constants | |
23 | // ---------------------------------------------------------------------------- | |
24 | ||
25 | // frame decorations type flags used in wxRenderer and wxColourScheme | |
26 | enum | |
27 | { | |
ea1b0d6c | 28 | wxTOPLEVEL_ACTIVE = 0x00000001, |
24a23c35 VS |
29 | wxTOPLEVEL_MAXIMIZED = 0x00000002, |
30 | wxTOPLEVEL_TITLEBAR = 0x00000004, | |
bff995bf | 31 | wxTOPLEVEL_ICON = 0x00000008, |
813edf09 VS |
32 | wxTOPLEVEL_RESIZEABLE = 0x00000010, |
33 | wxTOPLEVEL_BORDER = 0x00000020, | |
34 | wxTOPLEVEL_BUTTON_CLOSE = 0x01000000, | |
35 | wxTOPLEVEL_BUTTON_MAXIMIZE = 0x02000000, | |
36 | wxTOPLEVEL_BUTTON_ICONIZE = 0x04000000, | |
37 | wxTOPLEVEL_BUTTON_RESTORE = 0x08000000, | |
71e03035 | 38 | wxTOPLEVEL_BUTTON_HELP = 0x10000000, |
24a23c35 | 39 | }; |
0f1bf77d | 40 | |
ea1b0d6c VS |
41 | // frame hit test return values: |
42 | enum | |
43 | { | |
813edf09 VS |
44 | wxHT_TOPLEVEL_NOWHERE = 0x00000000, |
45 | wxHT_TOPLEVEL_CLIENT_AREA = 0x00000001, | |
46 | wxHT_TOPLEVEL_ICON = 0x00000002, | |
47 | wxHT_TOPLEVEL_TITLEBAR = 0x00000004, | |
48 | ||
49 | wxHT_TOPLEVEL_BORDER_N = 0x00000010, | |
50 | wxHT_TOPLEVEL_BORDER_S = 0x00000020, | |
51 | wxHT_TOPLEVEL_BORDER_E = 0x00000040, | |
52 | wxHT_TOPLEVEL_BORDER_W = 0x00000080, | |
813edf09 VS |
53 | wxHT_TOPLEVEL_BORDER_NE = wxHT_TOPLEVEL_BORDER_N | wxHT_TOPLEVEL_BORDER_E, |
54 | wxHT_TOPLEVEL_BORDER_SE = wxHT_TOPLEVEL_BORDER_S | wxHT_TOPLEVEL_BORDER_E, | |
55 | wxHT_TOPLEVEL_BORDER_NW = wxHT_TOPLEVEL_BORDER_N | wxHT_TOPLEVEL_BORDER_W, | |
56 | wxHT_TOPLEVEL_BORDER_SW = wxHT_TOPLEVEL_BORDER_S | wxHT_TOPLEVEL_BORDER_W, | |
bff995bf | 57 | wxHT_TOPLEVEL_ANY_BORDER = 0x000000F0, |
813edf09 VS |
58 | |
59 | wxHT_TOPLEVEL_BUTTON_CLOSE = /*0x01000000*/ wxTOPLEVEL_BUTTON_CLOSE, | |
60 | wxHT_TOPLEVEL_BUTTON_MAXIMIZE = /*0x02000000*/ wxTOPLEVEL_BUTTON_MAXIMIZE, | |
61 | wxHT_TOPLEVEL_BUTTON_ICONIZE = /*0x04000000*/ wxTOPLEVEL_BUTTON_ICONIZE, | |
62 | wxHT_TOPLEVEL_BUTTON_RESTORE = /*0x08000000*/ wxTOPLEVEL_BUTTON_RESTORE, | |
63 | wxHT_TOPLEVEL_BUTTON_HELP = /*0x10000000*/ wxTOPLEVEL_BUTTON_HELP, | |
64 | wxHT_TOPLEVEL_ANY_BUTTON = 0x1F000000 | |
ea1b0d6c VS |
65 | }; |
66 | ||
ed72fbf7 VS |
67 | // Flags for interactive frame manipulation functions (only in wxUniversal): |
68 | enum | |
69 | { | |
70 | wxINTERACTIVE_MOVE = 0x00000001, | |
71 | wxINTERACTIVE_RESIZE = 0x00000002, | |
72 | wxINTERACTIVE_RESIZE_S = 0x00000010, | |
73 | wxINTERACTIVE_RESIZE_N = 0x00000020, | |
74 | wxINTERACTIVE_RESIZE_W = 0x00000040, | |
75 | wxINTERACTIVE_RESIZE_E = 0x00000080, | |
76 | wxINTERACTIVE_WAIT_FOR_INPUT = 0x10000000 | |
77 | }; | |
78 | ||
ea1b0d6c VS |
79 | // ---------------------------------------------------------------------------- |
80 | // the actions supported by this control | |
81 | // ---------------------------------------------------------------------------- | |
82 | ||
813edf09 VS |
83 | #define wxACTION_TOPLEVEL_ACTIVATE _T("activate") // (de)activate the frame |
84 | #define wxACTION_TOPLEVEL_BUTTON_PRESS _T("pressbtn") // press titlebar btn | |
85 | #define wxACTION_TOPLEVEL_BUTTON_RELEASE _T("releasebtn") // press titlebar btn | |
86 | #define wxACTION_TOPLEVEL_BUTTON_CLICK _T("clickbtn") // press titlebar btn | |
87 | #define wxACTION_TOPLEVEL_MOVE _T("move") // move the frame | |
88 | #define wxACTION_TOPLEVEL_RESIZE _T("resize") // resize the frame | |
ea1b0d6c | 89 | |
0f1bf77d VS |
90 | //----------------------------------------------------------------------------- |
91 | // wxTopLevelWindow | |
92 | //----------------------------------------------------------------------------- | |
93 | ||
ea1b0d6c VS |
94 | class WXDLLEXPORT wxTopLevelWindow : public wxTopLevelWindowNative, |
95 | public wxInputConsumer | |
0f1bf77d VS |
96 | { |
97 | public: | |
98 | // construction | |
99 | wxTopLevelWindow() { Init(); } | |
100 | wxTopLevelWindow(wxWindow *parent, | |
101 | wxWindowID id, | |
102 | const wxString& title, | |
103 | const wxPoint& pos = wxDefaultPosition, | |
104 | const wxSize& size = wxDefaultSize, | |
105 | long style = wxDEFAULT_FRAME_STYLE, | |
106 | const wxString& name = wxFrameNameStr) | |
107 | { | |
108 | Init(); | |
109 | ||
110 | Create(parent, id, title, pos, size, style, name); | |
111 | } | |
112 | ||
113 | bool Create(wxWindow *parent, | |
114 | wxWindowID id, | |
115 | const wxString& title, | |
116 | const wxPoint& pos = wxDefaultPosition, | |
117 | const wxSize& size = wxDefaultSize, | |
118 | long style = wxDEFAULT_FRAME_STYLE, | |
119 | const wxString& name = wxFrameNameStr); | |
120 | ||
121 | // implement base class pure virtuals | |
122 | virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); | |
24a23c35 VS |
123 | virtual wxPoint GetClientAreaOrigin() const; |
124 | virtual void DoGetClientSize(int *width, int *height) const; | |
125 | virtual void DoSetClientSize(int width, int height); | |
126 | virtual void SetIcon(const wxIcon& icon); | |
0f1bf77d VS |
127 | |
128 | // implementation from now on | |
129 | // -------------------------- | |
71e03035 | 130 | |
813edf09 VS |
131 | // tests for frame's part at given point |
132 | long HitTest(const wxPoint& pt) const; | |
0f1bf77d | 133 | |
ea1b0d6c VS |
134 | virtual bool PerformAction(const wxControlAction& action, |
135 | long numArg = -1, | |
136 | const wxString& strArg = wxEmptyString); | |
71e03035 | 137 | |
ed72fbf7 VS |
138 | // move/resize the frame interactively, i.e. let the user do it |
139 | virtual void InteractiveMove(int flags = wxINTERACTIVE_MOVE); | |
140 | ||
e7dda1ff VS |
141 | virtual int GetMinWidth() const; |
142 | virtual int GetMinHeight() const; | |
143 | ||
71e03035 | 144 | protected: |
813edf09 VS |
145 | // handle titlebar button click event |
146 | virtual void ClickTitleBarButton(long button); | |
ea1b0d6c | 147 | |
813edf09 | 148 | virtual wxWindow *GetInputWindow() const { return (wxWindow*)this; } |
24a23c35 VS |
149 | |
150 | // return wxTOPLEVEL_xxx combination based on current state of the frame | |
151 | long GetDecorationsStyle() const; | |
813edf09 VS |
152 | |
153 | // common part of all ctors | |
154 | void Init(); | |
71e03035 | 155 | |
813edf09 | 156 | void RefreshTitleBar(); |
24a23c35 VS |
157 | void OnNcPaint(wxPaintEvent& event); |
158 | ||
159 | // TRUE if wxTLW should render decorations (aka titlebar) itself | |
160 | static int ms_drawDecorations; | |
90da9c3f VS |
161 | // TRUE if wxTLW can be iconized |
162 | static int ms_canIconize; | |
24a23c35 VS |
163 | // true for currently active frame |
164 | bool m_isActive:1; | |
165 | // version of icon for titlebar (16x16) | |
166 | wxIcon m_titlebarIcon; | |
ea1b0d6c VS |
167 | // saved window style in fullscreen mdoe |
168 | long m_fsSavedStyle; | |
813edf09 VS |
169 | // currently pressed titlebar button |
170 | long m_pressedButton; | |
ea1b0d6c VS |
171 | |
172 | DECLARE_DYNAMIC_CLASS(wxTopLevelWindow) | |
173 | DECLARE_EVENT_TABLE() | |
174 | WX_DECLARE_INPUT_CONSUMER() | |
175 | }; | |
176 | ||
177 | // ---------------------------------------------------------------------------- | |
178 | // wxStdFrameInputHandler: handles focus, resizing and titlebar buttons clicks | |
179 | // ---------------------------------------------------------------------------- | |
180 | ||
181 | class WXDLLEXPORT wxStdFrameInputHandler : public wxStdInputHandler | |
182 | { | |
183 | public: | |
184 | wxStdFrameInputHandler(wxInputHandler *inphand); | |
185 | ||
186 | virtual bool HandleMouse(wxInputConsumer *consumer, | |
187 | const wxMouseEvent& event); | |
188 | virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event); | |
189 | virtual bool HandleActivation(wxInputConsumer *consumer, bool activated); | |
813edf09 VS |
190 | |
191 | private: | |
192 | // the window (button) which has capture or NULL and the last hittest result | |
193 | wxTopLevelWindow *m_winCapture; | |
194 | long m_winHitTest; | |
195 | long m_winPressed; | |
bff995bf VS |
196 | bool m_borderCursorOn; |
197 | wxCursor m_origCursor; | |
0f1bf77d VS |
198 | }; |
199 | ||
200 | #endif // __WX_UNIV_TOPLEVEL_H__ |