]>
Commit | Line | Data |
---|---|---|
f03fc89f | 1 | /////////////////////////////////////////////////////////////////////////////// |
23895080 | 2 | // Name: wx/window.h |
789295bf | 3 | // Purpose: wxWindowBase class - the interface of wxWindow |
f03fc89f | 4 | // Author: Vadim Zeitlin |
566d84a7 | 5 | // Modified by: Ron Lee |
f03fc89f VZ |
6 | // Created: 01/02/97 |
7 | // RCS-ID: $Id$ | |
99d80019 | 8 | // Copyright: (c) Vadim Zeitlin |
65571936 | 9 | // Licence: wxWindows licence |
f03fc89f VZ |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
34138703 JS |
12 | #ifndef _WX_WINDOW_H_BASE_ |
13 | #define _WX_WINDOW_H_BASE_ | |
c801d85f | 14 | |
12028905 | 15 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
58654ed0 VZ |
16 | #pragma interface "windowbase.h" |
17 | #endif | |
18 | ||
f03fc89f VZ |
19 | // ---------------------------------------------------------------------------- |
20 | // headers which we must include here | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
23 | #include "wx/event.h" // the base class | |
24 | ||
25 | #include "wx/list.h" // defines wxWindowList | |
26 | ||
27 | #include "wx/cursor.h" // we have member variables of these classes | |
28 | #include "wx/font.h" // so we can't do without them | |
29 | #include "wx/colour.h" | |
30 | #include "wx/region.h" | |
5e4ff78a | 31 | #include "wx/utils.h" |
88ac883a | 32 | |
674ac8b9 | 33 | #include "wx/validate.h" // for wxDefaultValidator (always include it) |
8d99be5f | 34 | |
574c939e | 35 | #if wxUSE_PALETTE |
d577d610 | 36 | #include "wx/palette.h" |
574c939e KB |
37 | #endif // wxUSE_PALETTE |
38 | ||
88ac883a VZ |
39 | #if wxUSE_ACCEL |
40 | #include "wx/accel.h" | |
41 | #endif // wxUSE_ACCEL | |
f03fc89f | 42 | |
45a959a3 JS |
43 | #if wxUSE_ACCESSIBILITY |
44 | #include "wx/access.h" | |
45 | #endif | |
46 | ||
6522713c VZ |
47 | // when building wxUniv/Foo we don't want the code for native menu use to be |
48 | // compiled in - it should only be used when building real wxFoo | |
49 | #ifdef __WXUNIVERSAL__ | |
50 | #define wxUSE_MENUS_NATIVE 0 | |
22dd3847 | 51 | #else // !__WXUNIVERSAL__ |
6522713c | 52 | #define wxUSE_MENUS_NATIVE wxUSE_MENUS |
22dd3847 | 53 | #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__ |
6522713c | 54 | |
f03fc89f VZ |
55 | // ---------------------------------------------------------------------------- |
56 | // forward declarations | |
57 | // ---------------------------------------------------------------------------- | |
58 | ||
789295bf | 59 | class WXDLLEXPORT wxCaret; |
f03fc89f VZ |
60 | class WXDLLEXPORT wxControl; |
61 | class WXDLLEXPORT wxCursor; | |
eb082a08 | 62 | class WXDLLEXPORT wxDC; |
f03fc89f VZ |
63 | class WXDLLEXPORT wxDropTarget; |
64 | class WXDLLEXPORT wxItemResource; | |
65 | class WXDLLEXPORT wxLayoutConstraints; | |
66 | class WXDLLEXPORT wxResourceTable; | |
67 | class WXDLLEXPORT wxSizer; | |
68 | class WXDLLEXPORT wxToolTip; | |
f03fc89f VZ |
69 | class WXDLLEXPORT wxWindowBase; |
70 | class WXDLLEXPORT wxWindow; | |
71 | ||
45a959a3 JS |
72 | #if wxUSE_ACCESSIBILITY |
73 | class WXDLLEXPORT wxAccessible; | |
74 | #endif | |
75 | ||
da78f3b1 RD |
76 | class WXDLLEXPORT wxWindowExtraData; |
77 | ||
1b69c815 VZ |
78 | // ---------------------------------------------------------------------------- |
79 | // helper stuff used by wxWindow | |
80 | // ---------------------------------------------------------------------------- | |
81 | ||
82 | // struct containing all the visual attributes of a control | |
83 | struct WXDLLEXPORT wxVisualAttributes | |
84 | { | |
85 | // the font used for control label/text inside it | |
86 | wxFont font; | |
87 | ||
88 | // the foreground colour | |
89 | wxColour colFg; | |
90 | ||
91 | // the background colour, may be wxNullColour if the controls background | |
92 | // colour is not solid | |
93 | wxColour colBg; | |
94 | }; | |
95 | ||
96 | // different window variants, on platforms like eg mac uses different | |
97 | // rendering sizes | |
400a9e41 | 98 | enum wxWindowVariant |
1b69c815 VZ |
99 | { |
100 | wxWINDOW_VARIANT_NORMAL, // Normal size | |
101 | wxWINDOW_VARIANT_SMALL, // Smaller size (about 25 % smaller than normal) | |
102 | wxWINDOW_VARIANT_MINI, // Mini size (about 33 % smaller than normal) | |
103 | wxWINDOW_VARIANT_LARGE, // Large size (about 25 % larger than normal) | |
104 | wxWINDOW_VARIANT_MAX | |
105 | }; | |
106 | ||
ff9f7a12 SC |
107 | #if wxUSE_SYSTEM_OPTIONS |
108 | #define wxWINDOW_DEFAULT_VARIANT wxT("window-default-variant") | |
109 | #endif | |
110 | ||
f03fc89f VZ |
111 | // ---------------------------------------------------------------------------- |
112 | // (pseudo)template list classes | |
113 | // ---------------------------------------------------------------------------- | |
114 | ||
f6bcfd97 | 115 | WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode, class WXDLLEXPORT); |
f03fc89f VZ |
116 | |
117 | // ---------------------------------------------------------------------------- | |
118 | // global variables | |
119 | // ---------------------------------------------------------------------------- | |
120 | ||
16cba29d | 121 | extern WXDLLEXPORT_DATA(wxWindowList) wxTopLevelWindows; |
f03fc89f | 122 | |
f03fc89f VZ |
123 | // ---------------------------------------------------------------------------- |
124 | // wxWindowBase is the base class for all GUI controls/widgets, this is the public | |
125 | // interface of this class. | |
126 | // | |
127 | // Event handler: windows have themselves as their event handlers by default, | |
128 | // but their event handlers could be set to another object entirely. This | |
129 | // separation can reduce the amount of derivation required, and allow | |
130 | // alteration of a window's functionality (e.g. by a resource editor that | |
131 | // temporarily switches event handlers). | |
132 | // ---------------------------------------------------------------------------- | |
133 | ||
134 | class WXDLLEXPORT wxWindowBase : public wxEvtHandler | |
135 | { | |
f03fc89f VZ |
136 | public: |
137 | // creating the window | |
138 | // ------------------- | |
139 | ||
06f6df7d VZ |
140 | // default ctor, initializes everything which can be initialized before |
141 | // Create() | |
6463b9f5 | 142 | wxWindowBase() ; |
f03fc89f VZ |
143 | |
144 | // pseudo ctor (can't be virtual, called from ctor) | |
145 | bool CreateBase(wxWindowBase *parent, | |
d9e2e4c2 | 146 | wxWindowID winid, |
f03fc89f VZ |
147 | const wxPoint& pos = wxDefaultPosition, |
148 | const wxSize& size = wxDefaultSize, | |
149 | long style = 0, | |
8d99be5f | 150 | const wxValidator& validator = wxDefaultValidator, |
f03fc89f VZ |
151 | const wxString& name = wxPanelNameStr); |
152 | ||
153 | virtual ~wxWindowBase(); | |
154 | ||
f03fc89f VZ |
155 | // deleting the window |
156 | // ------------------- | |
157 | ||
d4864e97 | 158 | // ask the window to close itself, return true if the event handler |
f03fc89f | 159 | // honoured our request |
d4864e97 | 160 | bool Close( bool force = false ); |
f03fc89f VZ |
161 | |
162 | // the following functions delete the C++ objects (the window itself | |
163 | // or its children) as well as the GUI windows and normally should | |
164 | // never be used directly | |
165 | ||
d4864e97 | 166 | // delete window unconditionally (dangerous!), returns true if ok |
f03fc89f | 167 | virtual bool Destroy(); |
d4864e97 | 168 | // delete all children of this window, returns true if ok |
f03fc89f VZ |
169 | bool DestroyChildren(); |
170 | ||
171 | // is the window being deleted? | |
172 | bool IsBeingDeleted() const { return m_isBeingDeleted; } | |
173 | ||
174 | // window attributes | |
175 | // ----------------- | |
176 | ||
77ffb593 | 177 | // NB: in future versions of wxWidgets Set/GetTitle() will only work |
456bc6d9 VZ |
178 | // with the top level windows (such as dialogs and frames) and |
179 | // Set/GetLabel() only with the other ones (i.e. all controls). | |
180 | ||
f03fc89f VZ |
181 | // the title (or label, see below) of the window: the text which the |
182 | // window shows | |
fe6b43a3 VS |
183 | virtual void SetTitle( const wxString& WXUNUSED(title) ) {} |
184 | virtual wxString GetTitle() const { return wxEmptyString; } | |
f03fc89f VZ |
185 | |
186 | // label is just the same as the title (but for, e.g., buttons it | |
187 | // makes more sense to speak about labels) | |
eba0e4d4 RR |
188 | virtual void SetLabel(const wxString& label) { SetTitle(label); } |
189 | virtual wxString GetLabel() const { return GetTitle(); } | |
f03fc89f VZ |
190 | |
191 | // the window name is used for ressource setting in X, it is not the | |
192 | // same as the window title/label | |
193 | virtual void SetName( const wxString &name ) { m_windowName = name; } | |
194 | virtual wxString GetName() const { return m_windowName; } | |
195 | ||
69d90995 SC |
196 | // sets the window variant, calls internally DoSetVariant if variant has changed |
197 | void SetWindowVariant( wxWindowVariant variant ) ; | |
198 | wxWindowVariant GetWindowVariant() const { return m_windowVariant ; } | |
400a9e41 | 199 | |
69d90995 | 200 | |
f03fc89f | 201 | // window id uniquely identifies the window among its siblings unless |
a0d9c6cb | 202 | // it is wxID_ANY which means "don't care" |
d9e2e4c2 | 203 | void SetId( wxWindowID winid ) { m_windowId = winid; } |
f03fc89f VZ |
204 | wxWindowID GetId() const { return m_windowId; } |
205 | ||
206 | // generate a control id for the controls which were not given one by | |
207 | // user | |
69418a8e | 208 | static int NewControlId() { return --ms_lastControlId; } |
c539ab55 VZ |
209 | // get the id of the control following the one with the given |
210 | // (autogenerated) id | |
d9e2e4c2 | 211 | static int NextControlId(int winid) { return winid - 1; } |
c539ab55 VZ |
212 | // get the id of the control preceding the one with the given |
213 | // (autogenerated) id | |
d9e2e4c2 | 214 | static int PrevControlId(int winid) { return winid + 1; } |
f03fc89f VZ |
215 | |
216 | // moving/resizing | |
217 | // --------------- | |
218 | ||
219 | // set the window size and/or position | |
220 | void SetSize( int x, int y, int width, int height, | |
221 | int sizeFlags = wxSIZE_AUTO ) | |
222 | { DoSetSize(x, y, width, height, sizeFlags); } | |
223 | ||
224 | void SetSize( int width, int height ) | |
a0d9c6cb | 225 | { DoSetSize( wxDefaultCoord, wxDefaultCoord, width, height, wxSIZE_USE_EXISTING ); } |
f03fc89f VZ |
226 | |
227 | void SetSize( const wxSize& size ) | |
228 | { SetSize( size.x, size.y); } | |
229 | ||
230 | void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO) | |
231 | { DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); } | |
232 | ||
1e6feb95 | 233 | void Move(int x, int y, int flags = wxSIZE_USE_EXISTING) |
a0d9c6cb | 234 | { DoSetSize(x, y, wxDefaultCoord, wxDefaultCoord, flags); } |
f03fc89f | 235 | |
1e6feb95 VZ |
236 | void Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING) |
237 | { Move(pt.x, pt.y, flags); } | |
f03fc89f VZ |
238 | |
239 | // Z-order | |
240 | virtual void Raise() = 0; | |
241 | virtual void Lower() = 0; | |
242 | ||
243 | // client size is the size of area available for subwindows | |
244 | void SetClientSize( int width, int height ) | |
245 | { DoSetClientSize(width, height); } | |
246 | ||
247 | void SetClientSize( const wxSize& size ) | |
248 | { DoSetClientSize(size.x, size.y); } | |
249 | ||
250 | void SetClientSize(const wxRect& rect) | |
251 | { SetClientSize( rect.width, rect.height ); } | |
252 | ||
253 | // get the window position and/or size (pointers may be NULL) | |
254 | void GetPosition( int *x, int *y ) const { DoGetPosition(x, y); } | |
255 | wxPoint GetPosition() const | |
256 | { | |
257 | int w, h; | |
258 | DoGetPosition(&w, &h); | |
259 | ||
260 | return wxPoint(w, h); | |
261 | } | |
262 | ||
311a173b | 263 | void SetPosition( const wxPoint& pt ) { Move( pt ) ; } |
38759b67 | 264 | |
f03fc89f VZ |
265 | void GetSize( int *w, int *h ) const { DoGetSize(w, h); } |
266 | wxSize GetSize() const | |
267 | { | |
268 | int w, h; | |
269 | DoGetSize(& w, & h); | |
270 | return wxSize(w, h); | |
271 | } | |
272 | ||
273 | wxRect GetRect() const | |
274 | { | |
275 | int x, y, w, h; | |
276 | GetPosition(& x, & y); | |
277 | GetSize(& w, & h); | |
278 | ||
279 | return wxRect(x, y, w, h); | |
280 | } | |
281 | ||
282 | void GetClientSize( int *w, int *h ) const { DoGetClientSize(w, h); } | |
283 | wxSize GetClientSize() const | |
284 | { | |
285 | int w, h; | |
286 | DoGetClientSize(& w, & h); | |
287 | ||
288 | return wxSize(w, h); | |
289 | } | |
290 | ||
1e6feb95 VZ |
291 | // get the origin of the client area of the window relative to the |
292 | // window top left corner (the client area may be shifted because of | |
293 | // the borders, scrollbars, other decorations...) | |
294 | virtual wxPoint GetClientAreaOrigin() const; | |
295 | ||
296 | // get the client rectangle in window (i.e. client) coordinates | |
297 | wxRect GetClientRect() const | |
298 | { | |
299 | return wxRect(GetClientAreaOrigin(), GetClientSize()); | |
300 | } | |
301 | ||
f68586e5 | 302 | // get the size best suited for the window (in fact, minimal |
9f884528 RD |
303 | // acceptable size using which it will still look "nice" in |
304 | // most situations) | |
305 | wxSize GetBestSize() const | |
306 | { | |
307 | if (m_bestSizeCache.IsFullySpecified()) | |
308 | return m_bestSizeCache; | |
309 | return DoGetBestSize(); | |
310 | } | |
f68586e5 VZ |
311 | void GetBestSize(int *w, int *h) const |
312 | { | |
9f884528 | 313 | wxSize s = GetBestSize(); |
f68586e5 VZ |
314 | if ( w ) |
315 | *w = s.x; | |
316 | if ( h ) | |
317 | *h = s.y; | |
318 | } | |
319 | ||
9f884528 RD |
320 | // reset the cached best size value so it will be recalculated the |
321 | // next time it is needed. | |
992b2ec4 | 322 | void InvalidateBestSize(); |
9f884528 RD |
323 | void CacheBestSize(const wxSize& size) const |
324 | { wxConstCast(this, wxWindowBase)->m_bestSizeCache = size; } | |
a0d9c6cb | 325 | |
2b5f62a0 VZ |
326 | // There are times (and windows) where 'Best' size and 'Min' size |
327 | // are vastly out of sync. This should be remedied somehow, but in | |
328 | // the meantime, this method will return the larger of BestSize | |
329 | // (the window's smallest legible size), and any user specified | |
330 | // MinSize hint. | |
331 | wxSize GetAdjustedBestSize() const | |
332 | { | |
9f884528 | 333 | wxSize s( GetBestSize() ); |
2b5f62a0 VZ |
334 | return wxSize( wxMax( s.x, GetMinWidth() ), wxMax( s.y, GetMinHeight() ) ); |
335 | } | |
336 | ||
9f884528 RD |
337 | // This function will merge the window's best size into the window's |
338 | // minimum size, giving priority to the min size components, and | |
339 | // returns the results. | |
340 | wxSize GetBestFittingSize() const; | |
a0d9c6cb | 341 | |
9f884528 RD |
342 | // A 'Smart' SetSize that will fill in default size values with 'best' |
343 | // size. Sets the minsize to what was passed in. | |
344 | void SetBestFittingSize(const wxSize& size=wxDefaultSize); | |
345 | ||
2b5f62a0 | 346 | // the generic centre function - centers the window on parent by` |
7eb4e9cc VZ |
347 | // default or on screen if it doesn't have parent or |
348 | // wxCENTER_ON_SCREEN flag is given | |
c39eda94 VZ |
349 | void Centre( int direction = wxBOTH ); |
350 | void Center( int direction = wxBOTH ) { Centre(direction); } | |
7eb4e9cc VZ |
351 | |
352 | // centre on screen (only works for top level windows) | |
353 | void CentreOnScreen(int dir = wxBOTH) { Centre(dir | wxCENTER_ON_SCREEN); } | |
354 | void CenterOnScreen(int dir = wxBOTH) { CentreOnScreen(dir); } | |
355 | ||
356 | // centre with respect to the the parent window | |
357 | void CentreOnParent(int dir = wxBOTH) { Centre(dir | wxCENTER_FRAME); } | |
358 | void CenterOnParent(int dir = wxBOTH) { CentreOnParent(dir); } | |
f03fc89f VZ |
359 | |
360 | // set window size to wrap around its children | |
361 | virtual void Fit(); | |
362 | ||
2b5f62a0 VZ |
363 | // set virtual size to satisfy children |
364 | virtual void FitInside(); | |
365 | ||
f03fc89f VZ |
366 | // set min/max size of the window |
367 | virtual void SetSizeHints( int minW, int minH, | |
a0d9c6cb | 368 | int maxW = wxDefaultCoord, int maxH = wxDefaultCoord, |
571f6981 VS |
369 | int incW = wxDefaultCoord, int incH = wxDefaultCoord ) |
370 | { | |
371 | DoSetSizeHints(minW, minH, maxW, maxH, incW, incH); | |
372 | } | |
6fb99eb3 | 373 | |
1ec25e8f RD |
374 | void SetSizeHints( const wxSize& minSize, |
375 | const wxSize& maxSize=wxDefaultSize, | |
376 | const wxSize& incSize=wxDefaultSize) | |
377 | { | |
571f6981 VS |
378 | DoSetSizeHints(minSize.x, minSize.y, |
379 | maxSize.x, maxSize.y, | |
380 | incSize.x, incSize.y); | |
1ec25e8f | 381 | } |
6fb99eb3 | 382 | |
571f6981 VS |
383 | virtual void DoSetSizeHints(int minW, int minH, |
384 | int maxW = wxDefaultCoord, int maxH = wxDefaultCoord, | |
385 | int incW = wxDefaultCoord, int incH = wxDefaultCoord ); | |
f03fc89f | 386 | |
566d84a7 | 387 | virtual void SetVirtualSizeHints( int minW, int minH, |
a0d9c6cb | 388 | int maxW = wxDefaultCoord, int maxH = wxDefaultCoord ); |
1ec25e8f RD |
389 | void SetVirtualSizeHints( const wxSize& minSize, |
390 | const wxSize& maxSize=wxDefaultSize) | |
391 | { | |
392 | SetVirtualSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y); | |
393 | } | |
566d84a7 | 394 | |
e7dda1ff VS |
395 | virtual int GetMinWidth() const { return m_minWidth; } |
396 | virtual int GetMinHeight() const { return m_minHeight; } | |
738f9e5a RR |
397 | int GetMaxWidth() const { return m_maxWidth; } |
398 | int GetMaxHeight() const { return m_maxHeight; } | |
57c4d796 | 399 | |
34c3ffca RL |
400 | // Override this method to control the values given to Sizers etc. |
401 | virtual wxSize GetMaxSize() const { return wxSize( m_maxWidth, m_maxHeight ); } | |
1ec25e8f | 402 | virtual wxSize GetMinSize() const { return wxSize( m_minWidth, m_minHeight ); } |
400a9e41 | 403 | |
49f1dc5e RD |
404 | void SetMinSize(const wxSize& minSize) { SetSizeHints(minSize); } |
405 | void SetMaxSize(const wxSize& maxSize) { SetSizeHints(GetMinSize(), maxSize); } | |
a0d9c6cb | 406 | |
566d84a7 RL |
407 | // Methods for accessing the virtual size of a window. For most |
408 | // windows this is just the client area of the window, but for | |
409 | // some like scrolled windows it is more or less independent of | |
410 | // the screen window size. You may override the DoXXXVirtual | |
411 | // methods below for classes where that is is the case. | |
412 | ||
413 | void SetVirtualSize( const wxSize &size ) { DoSetVirtualSize( size.x, size.y ); } | |
414 | void SetVirtualSize( int x, int y ) { DoSetVirtualSize( x, y ); } | |
415 | ||
416 | wxSize GetVirtualSize() const { return DoGetVirtualSize(); } | |
417 | void GetVirtualSize( int *x, int *y ) const | |
418 | { | |
419 | wxSize s( DoGetVirtualSize() ); | |
420 | ||
421 | if( x ) | |
422 | *x = s.GetWidth(); | |
423 | if( y ) | |
424 | *y = s.GetHeight(); | |
425 | } | |
426 | ||
427 | // Override these methods for windows that have a virtual size | |
428 | // independent of their client size. eg. the virtual area of a | |
e5ecf1fc | 429 | // wxScrolledWindow. |
566d84a7 RL |
430 | |
431 | virtual void DoSetVirtualSize( int x, int y ); | |
85b38e0b | 432 | virtual wxSize DoGetVirtualSize() const; |
e5ecf1fc | 433 | |
2b5f62a0 VZ |
434 | // Return the largest of ClientSize and BestSize (as determined |
435 | // by a sizer, interior children, or other means) | |
436 | ||
437 | virtual wxSize GetBestVirtualSize() const | |
438 | { | |
439 | wxSize client( GetClientSize() ); | |
440 | wxSize best( GetBestSize() ); | |
441 | ||
442 | return wxSize( wxMax( client.x, best.x ), wxMax( client.y, best.y ) ); | |
443 | } | |
444 | ||
f03fc89f VZ |
445 | // window state |
446 | // ------------ | |
447 | ||
d4864e97 | 448 | // returns true if window was shown/hidden, false if the nothing was |
f03fc89f | 449 | // done (window was already shown/hidden) |
d4864e97 VZ |
450 | virtual bool Show( bool show = true ); |
451 | bool Hide() { return Show(false); } | |
f03fc89f | 452 | |
d4864e97 VZ |
453 | // returns true if window was enabled/disabled, false if nothing done |
454 | virtual bool Enable( bool enable = true ); | |
455 | bool Disable() { return Enable(false); } | |
f03fc89f | 456 | |
b08cd3bf | 457 | virtual bool IsShown() const { return m_isShown; } |
db101bd3 | 458 | virtual bool IsEnabled() const { return m_isEnabled; } |
f03fc89f VZ |
459 | |
460 | // get/set window style (setting style won't update the window and so | |
461 | // is only useful for internal usage) | |
462 | virtual void SetWindowStyleFlag( long style ) { m_windowStyle = style; } | |
463 | virtual long GetWindowStyleFlag() const { return m_windowStyle; } | |
464 | ||
465 | // just some (somewhat shorter) synonims | |
466 | void SetWindowStyle( long style ) { SetWindowStyleFlag(style); } | |
467 | long GetWindowStyle() const { return GetWindowStyleFlag(); } | |
468 | ||
469 | bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; } | |
d80cd92a | 470 | virtual bool IsRetained() const { return HasFlag(wxRETAINED); } |
f03fc89f | 471 | |
d80cd92a VZ |
472 | // extra style: the less often used style bits which can't be set with |
473 | // SetWindowStyleFlag() | |
b2d5a7ee | 474 | virtual void SetExtraStyle(long exStyle) { m_exStyle = exStyle; } |
d80cd92a | 475 | long GetExtraStyle() const { return m_exStyle; } |
f03fc89f VZ |
476 | |
477 | // make the window modal (all other windows unresponsive) | |
d4864e97 | 478 | virtual void MakeModal(bool modal = true); |
f03fc89f | 479 | |
b8e7b673 VZ |
480 | |
481 | // (primitive) theming support | |
482 | // --------------------------- | |
483 | ||
a2d93e73 JS |
484 | virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; } |
485 | virtual bool GetThemeEnabled() const { return m_themeEnabled; } | |
486 | ||
d4864e97 | 487 | |
456bc6d9 VZ |
488 | // focus and keyboard handling |
489 | // --------------------------- | |
f03fc89f VZ |
490 | |
491 | // set focus to this window | |
492 | virtual void SetFocus() = 0; | |
493 | ||
d577d610 VZ |
494 | // set focus to this window as the result of a keyboard action |
495 | virtual void SetFocusFromKbd() { SetFocus(); } | |
496 | ||
f03fc89f | 497 | // return the window which currently has the focus or NULL |
0fe02759 | 498 | static wxWindow *FindFocus(); |
6fb99eb3 | 499 | |
0fe02759 | 500 | static wxWindow *DoFindFocus() /* = 0: implement in derived classes */; |
f03fc89f VZ |
501 | |
502 | // can this window have focus? | |
503 | virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); } | |
504 | ||
1e6feb95 VZ |
505 | // can this window be given focus by keyboard navigation? if not, the |
506 | // only way to give it focus (provided it accepts it at all) is to | |
507 | // click it | |
508 | virtual bool AcceptsFocusFromKeyboard() const { return AcceptsFocus(); } | |
509 | ||
456bc6d9 VZ |
510 | // NB: these methods really don't belong here but with the current |
511 | // class hierarchy there is no other place for them :-( | |
512 | ||
513 | // get the default child of this parent, i.e. the one which is | |
514 | // activated by pressing <Enter> | |
515 | virtual wxWindow *GetDefaultItem() const { return NULL; } | |
516 | ||
517 | // set this child as default, return the old default | |
518 | virtual wxWindow *SetDefaultItem(wxWindow * WXUNUSED(child)) | |
519 | { return NULL; } | |
520 | ||
036da5e3 VZ |
521 | // set this child as temporary default |
522 | virtual void SetTmpDefaultItem(wxWindow * WXUNUSED(win)) { } | |
523 | ||
a24de76b | 524 | // navigates in the specified direction by sending a wxNavigationKeyEvent |
eedc82f4 | 525 | virtual bool Navigate(int flags = wxNavigationKeyEvent::IsForward); |
5f6cfda7 | 526 | |
a24de76b VZ |
527 | // move this window just before/after the specified one in tab order |
528 | // (the other window must be our sibling!) | |
529 | void MoveBeforeInTabOrder(wxWindow *win) | |
530 | { DoMoveInTabOrder(win, MoveBefore); } | |
531 | void MoveAfterInTabOrder(wxWindow *win) | |
532 | { DoMoveInTabOrder(win, MoveAfter); } | |
533 | ||
534 | ||
f03fc89f VZ |
535 | // parent/children relations |
536 | // ------------------------- | |
537 | ||
538 | // get the list of children | |
539 | const wxWindowList& GetChildren() const { return m_children; } | |
540 | wxWindowList& GetChildren() { return m_children; } | |
541 | ||
1978421a SC |
542 | // needed just for extended runtime |
543 | const wxWindowList& GetWindowChildren() const { return GetChildren() ; } | |
544 | ||
f03fc89f VZ |
545 | // get the parent or the parent of the parent |
546 | wxWindow *GetParent() const { return m_parent; } | |
547 | inline wxWindow *GetGrandParent() const; | |
548 | ||
549 | // is this window a top level one? | |
8487f887 | 550 | virtual bool IsTopLevel() const; |
f03fc89f | 551 | |
87b6002d | 552 | // it doesn't really change parent, use Reparent() instead |
f03fc89f | 553 | void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; } |
d4864e97 VZ |
554 | // change the real parent of this window, return true if the parent |
555 | // was changed, false otherwise (error or newParent == oldParent) | |
f03fc89f VZ |
556 | virtual bool Reparent( wxWindowBase *newParent ); |
557 | ||
146ba0fe VZ |
558 | // implementation mostly |
559 | virtual void AddChild( wxWindowBase *child ); | |
560 | virtual void RemoveChild( wxWindowBase *child ); | |
561 | ||
562 | // looking for windows | |
563 | // ------------------- | |
564 | ||
f03fc89f VZ |
565 | // find window among the descendants of this one either by id or by |
566 | // name (return NULL if not found) | |
6b73af79 VZ |
567 | wxWindow *FindWindow(long winid) const; |
568 | wxWindow *FindWindow(const wxString& name) const; | |
f03fc89f | 569 | |
146ba0fe | 570 | // Find a window among any window (all return NULL if not found) |
d9e2e4c2 | 571 | static wxWindow *FindWindowById( long winid, const wxWindow *parent = NULL ); |
146ba0fe VZ |
572 | static wxWindow *FindWindowByName( const wxString& name, |
573 | const wxWindow *parent = NULL ); | |
574 | static wxWindow *FindWindowByLabel( const wxString& label, | |
575 | const wxWindow *parent = NULL ); | |
f03fc89f VZ |
576 | |
577 | // event handler stuff | |
578 | // ------------------- | |
579 | ||
580 | // get the current event handler | |
581 | wxEvtHandler *GetEventHandler() const { return m_eventHandler; } | |
582 | ||
583 | // replace the event handler (allows to completely subclass the | |
584 | // window) | |
585 | void SetEventHandler( wxEvtHandler *handler ) { m_eventHandler = handler; } | |
586 | ||
587 | // push/pop event handler: allows to chain a custom event handler to | |
588 | // alreasy existing ones | |
589 | void PushEventHandler( wxEvtHandler *handler ); | |
d4864e97 | 590 | wxEvtHandler *PopEventHandler( bool deleteHandler = false ); |
f03fc89f | 591 | |
2e36d5cf | 592 | // find the given handler in the event handler chain and remove (but |
d4864e97 VZ |
593 | // not delete) it from the event handler chain, return true if it was |
594 | // found and false otherwise (this also results in an assert failure so | |
2e36d5cf VZ |
595 | // this function should only be called when the handler is supposed to |
596 | // be there) | |
597 | bool RemoveEventHandler(wxEvtHandler *handler); | |
598 | ||
1e6feb95 VZ |
599 | // validators |
600 | // ---------- | |
f03fc89f | 601 | |
88ac883a | 602 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
603 | // a window may have an associated validator which is used to control |
604 | // user input | |
605 | virtual void SetValidator( const wxValidator &validator ); | |
606 | virtual wxValidator *GetValidator() { return m_windowValidator; } | |
88ac883a | 607 | #endif // wxUSE_VALIDATORS |
f03fc89f | 608 | |
f03fc89f VZ |
609 | |
610 | // dialog oriented functions | |
611 | // ------------------------- | |
612 | ||
d4864e97 | 613 | // validate the correctness of input, return true if ok |
f03fc89f VZ |
614 | virtual bool Validate(); |
615 | ||
616 | // transfer data between internal and GUI representations | |
617 | virtual bool TransferDataToWindow(); | |
618 | virtual bool TransferDataFromWindow(); | |
619 | ||
620 | virtual void InitDialog(); | |
621 | ||
88ac883a | 622 | #if wxUSE_ACCEL |
f03fc89f VZ |
623 | // accelerators |
624 | // ------------ | |
625 | virtual void SetAcceleratorTable( const wxAcceleratorTable& accel ) | |
626 | { m_acceleratorTable = accel; } | |
627 | wxAcceleratorTable *GetAcceleratorTable() | |
628 | { return &m_acceleratorTable; } | |
5048c832 | 629 | |
540b6b09 VZ |
630 | #endif // wxUSE_ACCEL |
631 | ||
632 | #if wxUSE_HOTKEY | |
633 | // hot keys (system wide accelerators) | |
634 | // ----------------------------------- | |
635 | ||
636 | virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode); | |
5048c832 | 637 | virtual bool UnregisterHotKey(int hotkeyId); |
540b6b09 | 638 | #endif // wxUSE_HOTKEY |
5048c832 | 639 | |
f03fc89f VZ |
640 | |
641 | // dialog units translations | |
642 | // ------------------------- | |
643 | ||
644 | wxPoint ConvertPixelsToDialog( const wxPoint& pt ); | |
645 | wxPoint ConvertDialogToPixels( const wxPoint& pt ); | |
646 | wxSize ConvertPixelsToDialog( const wxSize& sz ) | |
647 | { | |
648 | wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y))); | |
649 | ||
650 | return wxSize(pt.x, pt.y); | |
651 | } | |
652 | ||
653 | wxSize ConvertDialogToPixels( const wxSize& sz ) | |
654 | { | |
655 | wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y))); | |
656 | ||
657 | return wxSize(pt.x, pt.y); | |
658 | } | |
659 | ||
660 | // mouse functions | |
661 | // --------------- | |
662 | ||
663 | // move the mouse to the specified position | |
664 | virtual void WarpPointer(int x, int y) = 0; | |
665 | ||
94633ad9 VZ |
666 | // start or end mouse capture, these functions maintain the stack of |
667 | // windows having captured the mouse and after calling ReleaseMouse() | |
668 | // the mouse is not released but returns to the window which had had | |
669 | // captured it previously (if any) | |
670 | void CaptureMouse(); | |
671 | void ReleaseMouse(); | |
f03fc89f | 672 | |
1e6feb95 VZ |
673 | // get the window which currently captures the mouse or NULL |
674 | static wxWindow *GetCapture(); | |
675 | ||
676 | // does this window have the capture? | |
677 | virtual bool HasCapture() const | |
678 | { return (wxWindow *)this == GetCapture(); } | |
679 | ||
f03fc89f VZ |
680 | // painting the window |
681 | // ------------------- | |
682 | ||
683 | // mark the specified rectangle (or the whole window) as "dirty" so it | |
684 | // will be repainted | |
d4864e97 | 685 | virtual void Refresh( bool eraseBackground = true, |
f03fc89f | 686 | const wxRect *rect = (const wxRect *) NULL ) = 0; |
1e6feb95 VZ |
687 | |
688 | // a less awkward wrapper for Refresh | |
8cfa09bd VZ |
689 | void RefreshRect(const wxRect& rect, bool eraseBackground = true) |
690 | { | |
691 | Refresh(eraseBackground, &rect); | |
692 | } | |
1e6feb95 VZ |
693 | |
694 | // repaint all invalid areas of the window immediately | |
695 | virtual void Update() { } | |
696 | ||
5da0803c VZ |
697 | // clear the window background |
698 | virtual void ClearBackground(); | |
f03fc89f | 699 | |
0cc7251e VZ |
700 | // freeze the window: don't redraw it until it is thawed |
701 | virtual void Freeze() { } | |
702 | ||
703 | // thaw the window: redraw it after it had been frozen | |
704 | virtual void Thaw() { } | |
705 | ||
f03fc89f | 706 | // adjust DC for drawing on this window |
f6147cfc | 707 | virtual void PrepareDC( wxDC & WXUNUSED(dc) ) { } |
f03fc89f VZ |
708 | |
709 | // the update region of the window contains the areas which must be | |
710 | // repainted by the program | |
711 | const wxRegion& GetUpdateRegion() const { return m_updateRegion; } | |
712 | wxRegion& GetUpdateRegion() { return m_updateRegion; } | |
713 | ||
1e6feb95 VZ |
714 | // get the update rectangleregion bounding box in client coords |
715 | wxRect GetUpdateClientRect() const; | |
716 | ||
f03fc89f VZ |
717 | // these functions verify whether the given point/rectangle belongs to |
718 | // (or at least intersects with) the update region | |
719 | bool IsExposed( int x, int y ) const; | |
720 | bool IsExposed( int x, int y, int w, int h ) const; | |
721 | ||
722 | bool IsExposed( const wxPoint& pt ) const | |
723 | { return IsExposed(pt.x, pt.y); } | |
724 | bool IsExposed( const wxRect& rect ) const | |
725 | { return IsExposed(rect.x, rect.y, rect.width, rect.height); } | |
726 | ||
727 | // colours, fonts and cursors | |
728 | // -------------------------- | |
729 | ||
1b69c815 VZ |
730 | // get the default attributes for the controls of this class: we |
731 | // provide a virtual function which can be used to query the default | |
732 | // attributes of an existing control and a static function which can | |
733 | // be used even when no existing object of the given class is | |
734 | // available, but which won't return any styles specific to this | |
735 | // particular control, of course (e.g. "Ok" button might have | |
736 | // different -- bold for example -- font) | |
737 | virtual wxVisualAttributes GetDefaultAttributes() const | |
738 | { | |
739 | return GetClassDefaultAttributes(GetWindowVariant()); | |
740 | } | |
741 | ||
742 | static wxVisualAttributes | |
743 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
744 | ||
f03fc89f | 745 | // set/retrieve the window colours (system defaults are used by |
b8e7b673 | 746 | // default): SetXXX() functions return true if colour was changed, |
f8ff87ed VS |
747 | // SetDefaultXXX() reset the "m_inheritXXX" flag after setting the |
748 | // value to prevent it from being inherited by our children | |
b8e7b673 | 749 | virtual bool SetBackgroundColour(const wxColour& colour); |
fa47d7a7 | 750 | void SetOwnBackgroundColour(const wxColour& colour) |
b8e7b673 VZ |
751 | { |
752 | if ( SetBackgroundColour(colour) ) | |
f8ff87ed | 753 | m_inheritBgCol = false; |
b8e7b673 | 754 | } |
1b69c815 | 755 | wxColour GetBackgroundColour() const; |
e5ecf1fc WS |
756 | bool InheritsBackgroundColour() const |
757 | { | |
758 | return m_inheritBgCol; | |
759 | } | |
760 | bool UseBgCol() const | |
761 | { | |
762 | return m_hasBgCol; | |
763 | } | |
b8e7b673 VZ |
764 | |
765 | virtual bool SetForegroundColour(const wxColour& colour); | |
fa47d7a7 | 766 | void SetOwnForegroundColour(const wxColour& colour) |
b8e7b673 VZ |
767 | { |
768 | if ( SetForegroundColour(colour) ) | |
f8ff87ed | 769 | m_inheritFgCol = false; |
b8e7b673 | 770 | } |
1b69c815 | 771 | wxColour GetForegroundColour() const; |
f03fc89f | 772 | |
50c53860 JS |
773 | // Set/get the background style. |
774 | // Pass one of wxBG_STYLE_SYSTEM, wxBG_STYLE_COLOUR, wxBG_STYLE_CUSTOM | |
775 | virtual bool SetBackgroundStyle(wxBackgroundStyle style) { m_backgroundStyle = style; return true; } | |
776 | virtual wxBackgroundStyle GetBackgroundStyle() const { return m_backgroundStyle; } | |
777 | ||
7c7a653b VZ |
778 | // returns true if the control has "transparent" areas such as a |
779 | // wxStaticText and wxCheckBox and the background should be adapted | |
780 | // from a parent window | |
781 | virtual bool HasTransparentBackground() { return false; } | |
782 | ||
b8e7b673 VZ |
783 | // set/retrieve the font for the window (SetFont() returns true if the |
784 | // font really changed) | |
785 | virtual bool SetFont(const wxFont& font) = 0; | |
fa47d7a7 | 786 | void SetOwnFont(const wxFont& font) |
b8e7b673 VZ |
787 | { |
788 | if ( SetFont(font) ) | |
f8ff87ed | 789 | m_inheritFont = false; |
b8e7b673 | 790 | } |
29094af0 | 791 | wxFont GetFont() const; |
b8e7b673 | 792 | |
d4864e97 | 793 | // set/retrieve the cursor for this window (SetCursor() returns true |
f03fc89f VZ |
794 | // if the cursor was really changed) |
795 | virtual bool SetCursor( const wxCursor &cursor ); | |
796 | const wxCursor& GetCursor() const { return m_cursor; } | |
f03fc89f | 797 | |
789295bf VZ |
798 | #if wxUSE_CARET |
799 | // associate a caret with the window | |
800 | void SetCaret(wxCaret *caret); | |
801 | // get the current caret (may be NULL) | |
802 | wxCaret *GetCaret() const { return m_caret; } | |
803 | #endif // wxUSE_CARET | |
804 | ||
f03fc89f VZ |
805 | // get the (average) character size for the current font |
806 | virtual int GetCharHeight() const = 0; | |
807 | virtual int GetCharWidth() const = 0; | |
808 | ||
809 | // get the width/height/... of the text using current or specified | |
810 | // font | |
811 | virtual void GetTextExtent(const wxString& string, | |
812 | int *x, int *y, | |
813 | int *descent = (int *) NULL, | |
814 | int *externalLeading = (int *) NULL, | |
815 | const wxFont *theFont = (const wxFont *) NULL) | |
816 | const = 0; | |
817 | ||
1e6feb95 VZ |
818 | // client <-> screen coords |
819 | // ------------------------ | |
820 | ||
f03fc89f | 821 | // translate to/from screen/client coordinates (pointers may be NULL) |
dabc0cd5 VZ |
822 | void ClientToScreen( int *x, int *y ) const |
823 | { DoClientToScreen(x, y); } | |
824 | void ScreenToClient( int *x, int *y ) const | |
825 | { DoScreenToClient(x, y); } | |
1e6feb95 VZ |
826 | |
827 | // wxPoint interface to do the same thing | |
dabc0cd5 VZ |
828 | wxPoint ClientToScreen(const wxPoint& pt) const |
829 | { | |
830 | int x = pt.x, y = pt.y; | |
831 | DoClientToScreen(&x, &y); | |
832 | ||
833 | return wxPoint(x, y); | |
834 | } | |
835 | ||
836 | wxPoint ScreenToClient(const wxPoint& pt) const | |
837 | { | |
838 | int x = pt.x, y = pt.y; | |
839 | DoScreenToClient(&x, &y); | |
840 | ||
841 | return wxPoint(x, y); | |
842 | } | |
f03fc89f | 843 | |
1e6feb95 VZ |
844 | // test where the given (in client coords) point lies |
845 | wxHitTest HitTest(wxCoord x, wxCoord y) const | |
846 | { return DoHitTest(x, y); } | |
847 | ||
848 | wxHitTest HitTest(const wxPoint& pt) const | |
849 | { return DoHitTest(pt.x, pt.y); } | |
850 | ||
f03fc89f VZ |
851 | // misc |
852 | // ---- | |
853 | ||
aede4ebb VZ |
854 | // get the window border style from the given flags: this is different from |
855 | // simply doing flags & wxBORDER_MASK because it uses GetDefaultBorder() to | |
856 | // translate wxBORDER_DEFAULT to something reasonable | |
857 | wxBorder GetBorder(long flags) const; | |
858 | ||
859 | // get border for the flags of this window | |
860 | wxBorder GetBorder() const { return GetBorder(GetWindowStyleFlag()); } | |
1e6feb95 | 861 | |
d4864e97 | 862 | // send wxUpdateUIEvents to this window, and children if recurse is true |
e39af974 JS |
863 | virtual void UpdateWindowUI(long flags = wxUPDATE_UI_NONE); |
864 | ||
865 | // do the window-specific processing after processing the update event | |
866 | virtual void DoUpdateWindowUI(wxUpdateUIEvent& event) ; | |
f03fc89f | 867 | |
1e6feb95 | 868 | #if wxUSE_MENUS |
45b8a256 | 869 | bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition) |
a1665b22 | 870 | { return DoPopupMenu(menu, pos.x, pos.y); } |
971562cb | 871 | bool PopupMenu(wxMenu *menu, int x, int y) |
a1665b22 | 872 | { return DoPopupMenu(menu, x, y); } |
1e6feb95 | 873 | #endif // wxUSE_MENUS |
f03fc89f VZ |
874 | |
875 | // scrollbars | |
876 | // ---------- | |
877 | ||
1e6feb95 VZ |
878 | // does the window have the scrollbar for this orientation? |
879 | bool HasScrollbar(int orient) const | |
880 | { | |
881 | return (m_windowStyle & | |
882 | (orient == wxHORIZONTAL ? wxHSCROLL : wxVSCROLL)) != 0; | |
883 | } | |
884 | ||
f03fc89f VZ |
885 | // configure the window scrollbars |
886 | virtual void SetScrollbar( int orient, | |
887 | int pos, | |
1e6feb95 | 888 | int thumbvisible, |
f03fc89f | 889 | int range, |
d4864e97 VZ |
890 | bool refresh = true ) = 0; |
891 | virtual void SetScrollPos( int orient, int pos, bool refresh = true ) = 0; | |
f03fc89f VZ |
892 | virtual int GetScrollPos( int orient ) const = 0; |
893 | virtual int GetScrollThumb( int orient ) const = 0; | |
894 | virtual int GetScrollRange( int orient ) const = 0; | |
895 | ||
896 | // scroll window to the specified position | |
897 | virtual void ScrollWindow( int dx, int dy, | |
898 | const wxRect* rect = (wxRect *) NULL ) = 0; | |
899 | ||
b9b3393e | 900 | // scrolls window by line/page: note that not all controls support this |
9cd6d737 | 901 | // |
d4864e97 VZ |
902 | // return true if the position changed, false otherwise |
903 | virtual bool ScrollLines(int WXUNUSED(lines)) { return false; } | |
904 | virtual bool ScrollPages(int WXUNUSED(pages)) { return false; } | |
9cd6d737 VZ |
905 | |
906 | // convenient wrappers for ScrollLines/Pages | |
907 | bool LineUp() { return ScrollLines(-1); } | |
908 | bool LineDown() { return ScrollLines(1); } | |
909 | bool PageUp() { return ScrollPages(-1); } | |
910 | bool PageDown() { return ScrollPages(1); } | |
b9b3393e | 911 | |
bd83cb56 VZ |
912 | // context-sensitive help |
913 | // ---------------------- | |
914 | ||
915 | // these are the convenience functions wrapping wxHelpProvider methods | |
916 | ||
917 | #if wxUSE_HELP | |
918 | // associate this help text with this window | |
919 | void SetHelpText(const wxString& text); | |
920 | // associate this help text with all windows with the same id as this | |
921 | // one | |
922 | void SetHelpTextForId(const wxString& text); | |
923 | // get the help string associated with this window (may be empty) | |
924 | wxString GetHelpText() const; | |
925 | #endif // wxUSE_HELP | |
926 | ||
f03fc89f VZ |
927 | // tooltips |
928 | // -------- | |
bd83cb56 | 929 | |
f03fc89f VZ |
930 | #if wxUSE_TOOLTIPS |
931 | // the easiest way to set a tooltip for a window is to use this method | |
932 | void SetToolTip( const wxString &tip ); | |
933 | // attach a tooltip to the window | |
934 | void SetToolTip( wxToolTip *tip ) { DoSetToolTip(tip); } | |
935 | // get the associated tooltip or NULL if none | |
936 | wxToolTip* GetToolTip() const { return m_tooltip; } | |
311a173b | 937 | wxString GetToolTipText() const ; |
7649d8fc JS |
938 | #else |
939 | // make it much easier to compile apps in an environment | |
940 | // that doesn't support tooltips, such as PocketPC | |
941 | inline void SetToolTip( const wxString & WXUNUSED(tip) ) {} | |
f03fc89f VZ |
942 | #endif // wxUSE_TOOLTIPS |
943 | ||
944 | // drag and drop | |
945 | // ------------- | |
946 | #if wxUSE_DRAG_AND_DROP | |
947 | // set/retrieve the drop target associated with this window (may be | |
948 | // NULL; it's owned by the window and will be deleted by it) | |
949 | virtual void SetDropTarget( wxDropTarget *dropTarget ) = 0; | |
950 | virtual wxDropTarget *GetDropTarget() const { return m_dropTarget; } | |
951 | #endif // wxUSE_DRAG_AND_DROP | |
952 | ||
953 | // constraints and sizers | |
954 | // ---------------------- | |
955 | #if wxUSE_CONSTRAINTS | |
956 | // set the constraints for this window or retrieve them (may be NULL) | |
957 | void SetConstraints( wxLayoutConstraints *constraints ); | |
958 | wxLayoutConstraints *GetConstraints() const { return m_constraints; } | |
959 | ||
f03fc89f VZ |
960 | // implementation only |
961 | void UnsetConstraints(wxLayoutConstraints *c); | |
962 | wxWindowList *GetConstraintsInvolvedIn() const | |
963 | { return m_constraintsInvolvedIn; } | |
964 | void AddConstraintReference(wxWindowBase *otherWin); | |
965 | void RemoveConstraintReference(wxWindowBase *otherWin); | |
966 | void DeleteRelatedConstraints(); | |
967 | void ResetConstraints(); | |
968 | ||
969 | // these methods may be overriden for special layout algorithms | |
d4864e97 | 970 | virtual void SetConstraintSizes(bool recurse = true); |
f03fc89f VZ |
971 | virtual bool LayoutPhase1(int *noChanges); |
972 | virtual bool LayoutPhase2(int *noChanges); | |
4b7f2165 | 973 | virtual bool DoPhase(int phase); |
f03fc89f VZ |
974 | |
975 | // these methods are virtual but normally won't be overridden | |
f03fc89f VZ |
976 | virtual void SetSizeConstraint(int x, int y, int w, int h); |
977 | virtual void MoveConstraint(int x, int y); | |
978 | virtual void GetSizeConstraint(int *w, int *h) const ; | |
979 | virtual void GetClientSizeConstraint(int *w, int *h) const ; | |
980 | virtual void GetPositionConstraint(int *x, int *y) const ; | |
981 | ||
461e93f9 JS |
982 | #endif // wxUSE_CONSTRAINTS |
983 | ||
984 | // when using constraints or sizers, it makes sense to update | |
985 | // children positions automatically whenever the window is resized | |
986 | // - this is done if autoLayout is on | |
987 | void SetAutoLayout( bool autoLayout ) { m_autoLayout = autoLayout; } | |
988 | bool GetAutoLayout() const { return m_autoLayout; } | |
989 | ||
990 | // lay out the window and its children | |
991 | virtual bool Layout(); | |
992 | ||
f03fc89f | 993 | // sizers |
d4864e97 VZ |
994 | void SetSizer(wxSizer *sizer, bool deleteOld = true ); |
995 | void SetSizerAndFit( wxSizer *sizer, bool deleteOld = true ); | |
566d84a7 | 996 | |
f03fc89f | 997 | wxSizer *GetSizer() const { return m_windowSizer; } |
be90c029 RD |
998 | |
999 | // Track if this window is a member of a sizer | |
1ebfafde | 1000 | void SetContainingSizer(wxSizer* sizer); |
be90c029 RD |
1001 | wxSizer *GetContainingSizer() const { return m_containingSizer; } |
1002 | ||
45a959a3 JS |
1003 | // accessibility |
1004 | // ---------------------- | |
1005 | #if wxUSE_ACCESSIBILITY | |
1006 | // Override to create a specific accessible object. | |
1007 | virtual wxAccessible* CreateAccessible(); | |
1008 | ||
1009 | // Sets the accessible object. | |
1010 | void SetAccessible(wxAccessible* accessible) ; | |
1011 | ||
1012 | // Returns the accessible object. | |
1013 | wxAccessible* GetAccessible() { return m_accessible; }; | |
1014 | ||
1015 | // Returns the accessible object, creating if necessary. | |
1016 | wxAccessible* GetOrCreateAccessible() ; | |
1017 | #endif | |
1018 | ||
f03fc89f VZ |
1019 | // implementation |
1020 | // -------------- | |
1021 | ||
1022 | // event handlers | |
1023 | void OnSysColourChanged( wxSysColourChangedEvent& event ); | |
1024 | void OnInitDialog( wxInitDialogEvent &event ); | |
72fc5caf | 1025 | void OnMiddleClick( wxMouseEvent& event ); |
bd83cb56 VZ |
1026 | #if wxUSE_HELP |
1027 | void OnHelp(wxHelpEvent& event); | |
1028 | #endif // wxUSE_HELP | |
f03fc89f | 1029 | |
e39af974 JS |
1030 | // virtual function for implementing internal idle |
1031 | // behaviour | |
1032 | virtual void OnInternalIdle() {} | |
1033 | ||
1034 | // call internal idle recursively | |
5109ae5d | 1035 | // void ProcessInternalIdle() ; |
e39af974 JS |
1036 | |
1037 | // get the handle of the window for the underlying window system: this | |
d7c24517 VZ |
1038 | // is only used for wxWin itself or for user code which wants to call |
1039 | // platform-specific APIs | |
d22699b5 | 1040 | virtual WXWidget GetHandle() const = 0; |
ed4780ea VZ |
1041 | // associate the window with a new native handle |
1042 | virtual void AssociateHandle(WXWidget WXUNUSED(handle)) { } | |
1043 | // dissociate the current native handle from the window | |
1044 | virtual void DissociateHandle() { } | |
cc2b7472 | 1045 | |
574c939e KB |
1046 | #if wxUSE_PALETTE |
1047 | // Store the palette used by DCs in wxWindow so that the dcs can share | |
1048 | // a palette. And we can respond to palette messages. | |
1049 | wxPalette GetPalette() const { return m_palette; } | |
b95edd47 | 1050 | |
574c939e KB |
1051 | // When palette is changed tell the DC to set the system palette to the |
1052 | // new one. | |
b95edd47 VZ |
1053 | void SetPalette(const wxPalette& pal); |
1054 | ||
1055 | // return true if we have a specific palette | |
1056 | bool HasCustomPalette() const { return m_hasCustomPalette; } | |
1057 | ||
1058 | // return the first parent window with a custom palette or NULL | |
1059 | wxWindow *GetAncestorWithCustomPalette() const; | |
574c939e KB |
1060 | #endif // wxUSE_PALETTE |
1061 | ||
b8e7b673 VZ |
1062 | // inherit the parents visual attributes if they had been explicitly set |
1063 | // by the user (i.e. we don't inherit default attributes) and if we don't | |
1064 | // have our own explicitly set | |
1065 | virtual void InheritAttributes(); | |
1066 | ||
1067 | // returns false from here if this window doesn't want to inherit the | |
1068 | // parents colours even if InheritAttributes() would normally do it | |
1069 | // | |
1070 | // this just provides a simple way to customize InheritAttributes() | |
1071 | // behaviour in the most common case | |
1072 | virtual bool ShouldInheritColours() const { return false; } | |
1073 | ||
45a2f949 JS |
1074 | // Reserved for future use |
1075 | virtual void ReservedWindowFunc1() {} | |
1076 | virtual void ReservedWindowFunc2() {} | |
1077 | virtual void ReservedWindowFunc3() {} | |
1078 | virtual void ReservedWindowFunc4() {} | |
1079 | virtual void ReservedWindowFunc5() {} | |
1080 | virtual void ReservedWindowFunc6() {} | |
1081 | virtual void ReservedWindowFunc7() {} | |
1082 | virtual void ReservedWindowFunc8() {} | |
1083 | virtual void ReservedWindowFunc9() {} | |
1084 | ||
245c5d2e RD |
1085 | protected: |
1086 | // event handling specific to wxWindow | |
1087 | virtual bool TryValidator(wxEvent& event); | |
1088 | virtual bool TryParent(wxEvent& event); | |
1089 | ||
a24de76b VZ |
1090 | // common part of MoveBefore/AfterInTabOrder() |
1091 | enum MoveKind | |
1092 | { | |
1093 | MoveBefore, // insert before the given window | |
1094 | MoveAfter // insert after the given window | |
1095 | }; | |
1096 | virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move); | |
4caf847c | 1097 | |
ec5bb70d VZ |
1098 | #if wxUSE_CONSTRAINTS |
1099 | // satisfy the constraints for the windows but don't set the window sizes | |
1100 | void SatisfyConstraints(); | |
1101 | #endif // wxUSE_CONSTRAINTS | |
566d84a7 | 1102 | |
7de59551 RD |
1103 | // Send the wxWindowDestroyEvent |
1104 | void SendDestroyEvent(); | |
1105 | ||
0fe02759 VS |
1106 | // returns the main window of composite control; this is the window |
1107 | // that FindFocus returns if the focus is in one of composite control's | |
1108 | // windows | |
6fb99eb3 | 1109 | virtual wxWindow *GetMainWindowOfCompositeControl() |
0fe02759 VS |
1110 | { return (wxWindow*)this; } |
1111 | ||
7af6f327 | 1112 | // the window id - a number which uniquely identifies a window among |
a0d9c6cb | 1113 | // its siblings unless it is wxID_ANY |
f03fc89f | 1114 | wxWindowID m_windowId; |
456bc6d9 | 1115 | |
f03fc89f VZ |
1116 | // the parent window of this window (or NULL) and the list of the children |
1117 | // of this window | |
1118 | wxWindow *m_parent; | |
1119 | wxWindowList m_children; | |
1120 | ||
1121 | // the minimal allowed size for the window (no minimal size if variable(s) | |
a0d9c6cb | 1122 | // contain(s) wxDefaultCoord) |
ec5bb70d VZ |
1123 | int m_minWidth, |
1124 | m_minHeight, | |
1125 | m_maxWidth, | |
1126 | m_maxHeight; | |
f03fc89f VZ |
1127 | |
1128 | // event handler for this window: usually is just 'this' but may be | |
1129 | // changed with SetEventHandler() | |
1130 | wxEvtHandler *m_eventHandler; | |
1131 | ||
88ac883a | 1132 | #if wxUSE_VALIDATORS |
f03fc89f VZ |
1133 | // associated validator or NULL if none |
1134 | wxValidator *m_windowValidator; | |
88ac883a | 1135 | #endif // wxUSE_VALIDATORS |
f03fc89f VZ |
1136 | |
1137 | #if wxUSE_DRAG_AND_DROP | |
1138 | wxDropTarget *m_dropTarget; | |
1139 | #endif // wxUSE_DRAG_AND_DROP | |
1140 | ||
1141 | // visual window attributes | |
1142 | wxCursor m_cursor; | |
1b69c815 VZ |
1143 | wxFont m_font; // see m_hasFont |
1144 | wxColour m_backgroundColour, // m_hasBgCol | |
1145 | m_foregroundColour; // m_hasFgCol | |
f03fc89f | 1146 | |
789295bf VZ |
1147 | #if wxUSE_CARET |
1148 | wxCaret *m_caret; | |
1149 | #endif // wxUSE_CARET | |
1150 | ||
f03fc89f VZ |
1151 | // the region which should be repainted in response to paint event |
1152 | wxRegion m_updateRegion; | |
1153 | ||
88ac883a | 1154 | #if wxUSE_ACCEL |
f03fc89f VZ |
1155 | // the accelerator table for the window which translates key strokes into |
1156 | // command events | |
1157 | wxAcceleratorTable m_acceleratorTable; | |
88ac883a | 1158 | #endif // wxUSE_ACCEL |
f03fc89f | 1159 | |
f03fc89f VZ |
1160 | // the tooltip for this window (may be NULL) |
1161 | #if wxUSE_TOOLTIPS | |
1162 | wxToolTip *m_tooltip; | |
1163 | #endif // wxUSE_TOOLTIPS | |
1164 | ||
1165 | // constraints and sizers | |
1166 | #if wxUSE_CONSTRAINTS | |
1167 | // the constraints for this window or NULL | |
1168 | wxLayoutConstraints *m_constraints; | |
1169 | ||
1170 | // constraints this window is involved in | |
1171 | wxWindowList *m_constraintsInvolvedIn; | |
461e93f9 | 1172 | #endif // wxUSE_CONSTRAINTS |
f03fc89f | 1173 | |
be90c029 | 1174 | // this window's sizer |
f03fc89f | 1175 | wxSizer *m_windowSizer; |
be90c029 RD |
1176 | |
1177 | // The sizer this window is a member of, if any | |
1178 | wxSizer *m_containingSizer; | |
f03fc89f VZ |
1179 | |
1180 | // Layout() window automatically when its size changes? | |
1181 | bool m_autoLayout:1; | |
f03fc89f VZ |
1182 | |
1183 | // window state | |
1184 | bool m_isShown:1; | |
1185 | bool m_isEnabled:1; | |
1186 | bool m_isBeingDeleted:1; | |
1187 | ||
23895080 VZ |
1188 | // was the window colours/font explicitly changed by user? |
1189 | bool m_hasBgCol:1; | |
1190 | bool m_hasFgCol:1; | |
1191 | bool m_hasFont:1; | |
a0d9c6cb | 1192 | |
f8ff87ed VS |
1193 | // and should it be inherited by children? |
1194 | bool m_inheritBgCol:1; | |
1195 | bool m_inheritFgCol:1; | |
1196 | bool m_inheritFont:1; | |
23895080 | 1197 | |
f03fc89f | 1198 | // window attributes |
d80cd92a VZ |
1199 | long m_windowStyle, |
1200 | m_exStyle; | |
f03fc89f | 1201 | wxString m_windowName; |
a2d93e73 | 1202 | bool m_themeEnabled; |
50c53860 | 1203 | wxBackgroundStyle m_backgroundStyle; |
071e5fd9 | 1204 | #if wxUSE_PALETTE |
574c939e | 1205 | wxPalette m_palette; |
b95edd47 VZ |
1206 | bool m_hasCustomPalette; |
1207 | #endif // wxUSE_PALETTE | |
574c939e | 1208 | |
45a959a3 JS |
1209 | #if wxUSE_ACCESSIBILITY |
1210 | wxAccessible* m_accessible; | |
1211 | #endif | |
2654f7e4 | 1212 | |
566d84a7 RL |
1213 | // Virtual size (scrolling) |
1214 | wxSize m_virtualSize; | |
1215 | ||
1216 | int m_minVirtualWidth; // VirtualSizeHints | |
1217 | int m_minVirtualHeight; | |
1218 | int m_maxVirtualWidth; | |
1219 | int m_maxVirtualHeight; | |
400a9e41 | 1220 | |
69d90995 | 1221 | wxWindowVariant m_windowVariant ; |
45e0dc94 | 1222 | |
1e6feb95 VZ |
1223 | // override this to change the default (i.e. used when no style is |
1224 | // specified) border for the window class | |
1225 | virtual wxBorder GetDefaultBorder() const; | |
1226 | ||
5c2be659 RD |
1227 | // Get the default size for the new window if no explicit size given. TLWs |
1228 | // have their own default size so this is just for non top-level windows. | |
a0d9c6cb WS |
1229 | static int WidthDefault(int w) { return w == wxDefaultCoord ? 20 : w; } |
1230 | static int HeightDefault(int h) { return h == wxDefaultCoord ? 20 : h; } | |
f03fc89f | 1231 | |
9f884528 RD |
1232 | |
1233 | // Used to save the results of DoGetBestSize so it doesn't need to be | |
1234 | // recalculated each time the value is needed. | |
1235 | wxSize m_bestSizeCache; | |
1236 | ||
fe161a26 RD |
1237 | // keep the old name for compatibility, at least until all the internal |
1238 | // usages of it are changed to SetBestFittingSize | |
1239 | void SetBestSize(const wxSize& size) { SetBestFittingSize(size); } | |
a0d9c6cb | 1240 | |
d3b5db4b | 1241 | // set the initial window size if none is given (i.e. at least one of the |
cab1a605 | 1242 | // components of the size passed to ctor/Create() is wxDefaultCoord) |
d3b5db4b RD |
1243 | // |
1244 | // normally just calls SetBestSize() for controls, but can be overridden | |
1245 | // not to do it for the controls which have to do some additional | |
1246 | // initialization (e.g. add strings to list box) before their best size | |
1247 | // can be accurately calculated | |
1248 | virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) {} | |
1249 | ||
a0d9c6cb | 1250 | |
d3b5db4b | 1251 | |
f03fc89f VZ |
1252 | // more pure virtual functions |
1253 | // --------------------------- | |
1254 | ||
1255 | // NB: we must have DoSomething() function when Something() is an overloaded | |
1256 | // method: indeed, we can't just have "virtual Something()" in case when | |
1257 | // the function is overloaded because then we'd have to make virtual all | |
1258 | // the variants (otherwise only the virtual function may be called on a | |
1259 | // pointer to derived class according to C++ rules) which is, in | |
1260 | // general, absolutely not needed. So instead we implement all | |
1261 | // overloaded Something()s in terms of DoSomething() which will be the | |
1262 | // only one to be virtual. | |
1263 | ||
dabc0cd5 VZ |
1264 | // coordinates translation |
1265 | virtual void DoClientToScreen( int *x, int *y ) const = 0; | |
1266 | virtual void DoScreenToClient( int *x, int *y ) const = 0; | |
1267 | ||
1e6feb95 VZ |
1268 | virtual wxHitTest DoHitTest(wxCoord x, wxCoord y) const; |
1269 | ||
94633ad9 | 1270 | // capture/release the mouse, used by Capture/ReleaseMouse() |
a83e1475 VZ |
1271 | virtual void DoCaptureMouse() = 0; |
1272 | virtual void DoReleaseMouse() = 0; | |
be90c029 | 1273 | |
f03fc89f VZ |
1274 | // retrieve the position/size of the window |
1275 | virtual void DoGetPosition( int *x, int *y ) const = 0; | |
1276 | virtual void DoGetSize( int *width, int *height ) const = 0; | |
1277 | virtual void DoGetClientSize( int *width, int *height ) const = 0; | |
1278 | ||
f68586e5 VZ |
1279 | // get the size which best suits the window: for a control, it would be |
1280 | // the minimal size which doesn't truncate the control, for a panel - the | |
1281 | // same size as it would have after a call to Fit() | |
1282 | virtual wxSize DoGetBestSize() const; | |
1283 | ||
f03fc89f VZ |
1284 | // this is the virtual function to be overriden in any derived class which |
1285 | // wants to change how SetSize() or Move() works - it is called by all | |
1286 | // versions of these functions in the base class | |
1287 | virtual void DoSetSize(int x, int y, | |
1288 | int width, int height, | |
1289 | int sizeFlags = wxSIZE_AUTO) = 0; | |
1290 | ||
1291 | // same as DoSetSize() for the client size | |
1292 | virtual void DoSetClientSize(int width, int height) = 0; | |
1293 | ||
9d9b7755 VZ |
1294 | // move the window to the specified location and resize it: this is called |
1295 | // from both DoSetSize() and DoSetClientSize() and would usually just | |
1296 | // reposition this window except for composite controls which will want to | |
1297 | // arrange themselves inside the given rectangle | |
1298 | virtual void DoMoveWindow(int x, int y, int width, int height) = 0; | |
1299 | ||
f03fc89f VZ |
1300 | #if wxUSE_TOOLTIPS |
1301 | virtual void DoSetToolTip( wxToolTip *tip ); | |
1302 | #endif // wxUSE_TOOLTIPS | |
1303 | ||
1e6feb95 | 1304 | #if wxUSE_MENUS |
971562cb | 1305 | virtual bool DoPopupMenu(wxMenu *menu, int x, int y) = 0; |
1e6feb95 | 1306 | #endif // wxUSE_MENUS |
a1665b22 | 1307 | |
716e96df VZ |
1308 | // Makes an adjustment to the window position to make it relative to the |
1309 | // parents client area, e.g. if the parent is a frame with a toolbar, its | |
1310 | // (0, 0) is just below the toolbar | |
1311 | virtual void AdjustForParentClientOrigin(int& x, int& y, | |
1312 | int sizeFlags = 0) const; | |
8d99be5f | 1313 | |
69d90995 SC |
1314 | // implements the window variants |
1315 | virtual void DoSetWindowVariant( wxWindowVariant variant ) ; | |
45e0dc94 | 1316 | |
da78f3b1 RD |
1317 | // Was a reserved pointer in 2.6.0, now used to hold extra data members |
1318 | // without breaking compatibility. | |
1319 | wxWindowExtraData* m_extraData; | |
45a2f949 | 1320 | |
f03fc89f VZ |
1321 | private: |
1322 | // contains the last id generated by NewControlId | |
1323 | static int ms_lastControlId; | |
1324 | ||
a83e1475 VZ |
1325 | // the stack of windows which have captured the mouse |
1326 | static struct WXDLLEXPORT wxWindowNext *ms_winCaptureNext; | |
1327 | ||
1e6feb95 VZ |
1328 | DECLARE_ABSTRACT_CLASS(wxWindowBase) |
1329 | DECLARE_NO_COPY_CLASS(wxWindowBase) | |
f03fc89f VZ |
1330 | DECLARE_EVENT_TABLE() |
1331 | }; | |
1332 | ||
1333 | // ---------------------------------------------------------------------------- | |
1334 | // now include the declaration of wxWindow class | |
1335 | // ---------------------------------------------------------------------------- | |
1336 | ||
1e6feb95 | 1337 | // include the declaration of the platform-specific class |
4055ed82 | 1338 | #if defined(__WXPALMOS__) |
ffecfa5a JS |
1339 | #ifdef __WXUNIVERSAL__ |
1340 | #define wxWindowNative wxWindowPalm | |
1341 | #else // !wxUniv | |
1342 | #define wxWindowPalm wxWindow | |
1343 | #endif // wxUniv/!wxUniv | |
1344 | #include "wx/palmos/window.h" | |
1345 | #elif defined(__WXMSW__) | |
a5b3669d VZ |
1346 | #ifdef __WXUNIVERSAL__ |
1347 | #define wxWindowNative wxWindowMSW | |
1348 | #else // !wxUniv | |
1e6feb95 | 1349 | #define wxWindowMSW wxWindow |
a5b3669d | 1350 | #endif // wxUniv/!wxUniv |
f03fc89f | 1351 | #include "wx/msw/window.h" |
2049ba38 | 1352 | #elif defined(__WXMOTIF__) |
f03fc89f | 1353 | #include "wx/motif/window.h" |
2049ba38 | 1354 | #elif defined(__WXGTK__) |
a5b3669d VZ |
1355 | #ifdef __WXUNIVERSAL__ |
1356 | #define wxWindowNative wxWindowGTK | |
1357 | #else // !wxUniv | |
1e6feb95 | 1358 | #define wxWindowGTK wxWindow |
1e6feb95 | 1359 | #endif // wxUniv |
f03fc89f | 1360 | #include "wx/gtk/window.h" |
83df96d6 JS |
1361 | #elif defined(__WXX11__) |
1362 | #ifdef __WXUNIVERSAL__ | |
1363 | #define wxWindowNative wxWindowX11 | |
1364 | #else // !wxUniv | |
1365 | #define wxWindowX11 wxWindow | |
83df96d6 JS |
1366 | #endif // wxUniv |
1367 | #include "wx/x11/window.h" | |
711c76db | 1368 | #elif defined(__WXMGL__) |
386c7058 VS |
1369 | #ifdef __WXUNIVERSAL__ |
1370 | #define wxWindowNative wxWindowMGL | |
1371 | #else // !wxUniv | |
1372 | #define wxWindowMGL wxWindow | |
386c7058 VS |
1373 | #endif // wxUniv |
1374 | #include "wx/mgl/window.h" | |
34138703 | 1375 | #elif defined(__WXMAC__) |
e766c8a9 SC |
1376 | #ifdef __WXUNIVERSAL__ |
1377 | #define wxWindowNative wxWindowMac | |
1378 | #else // !wxUniv | |
1379 | #define wxWindowMac wxWindow | |
e766c8a9 | 1380 | #endif // wxUniv |
f03fc89f | 1381 | #include "wx/mac/window.h" |
e64df9bc DE |
1382 | #elif defined(__WXCOCOA__) |
1383 | #ifdef __WXUNIVERSAL__ | |
1384 | #define wxWindowNative wxWindowCocoa | |
1385 | #else // !wxUniv | |
1386 | #define wxWindowCocoa wxWindow | |
e64df9bc DE |
1387 | #endif // wxUniv |
1388 | #include "wx/cocoa/window.h" | |
1777b9bb | 1389 | #elif defined(__WXPM__) |
210a651b DW |
1390 | #ifdef __WXUNIVERSAL__ |
1391 | #define wxWindowNative wxWindowOS2 | |
1392 | #else // !wxUniv | |
1393 | #define wxWindowOS2 wxWindow | |
210a651b | 1394 | #endif // wxUniv/!wxUniv |
1777b9bb | 1395 | #include "wx/os2/window.h" |
c801d85f KB |
1396 | #endif |
1397 | ||
1e6feb95 VZ |
1398 | // for wxUniversal, we now derive the real wxWindow from wxWindow<platform>, |
1399 | // for the native ports we already have defined it above | |
1400 | #if defined(__WXUNIVERSAL__) | |
a5b3669d VZ |
1401 | #ifndef wxWindowNative |
1402 | #error "wxWindowNative must be defined above!" | |
1403 | #endif | |
1404 | ||
1e6feb95 VZ |
1405 | #include "wx/univ/window.h" |
1406 | #endif // wxUniv | |
1407 | ||
f03fc89f VZ |
1408 | // ---------------------------------------------------------------------------- |
1409 | // inline functions which couldn't be declared in the class body because of | |
1410 | // forward dependencies | |
1411 | // ---------------------------------------------------------------------------- | |
1412 | ||
bacd69f9 | 1413 | inline wxWindow *wxWindowBase::GetGrandParent() const |
f03fc89f VZ |
1414 | { |
1415 | return m_parent ? m_parent->GetParent() : (wxWindow *)NULL; | |
1416 | } | |
1417 | ||
1418 | // ---------------------------------------------------------------------------- | |
3723b7b1 | 1419 | // global functions |
f03fc89f VZ |
1420 | // ---------------------------------------------------------------------------- |
1421 | ||
3723b7b1 JS |
1422 | // Find the wxWindow at the current mouse position, also returning the mouse |
1423 | // position. | |
16cba29d | 1424 | extern WXDLLEXPORT wxWindow* wxFindWindowAtPointer(wxPoint& pt); |
3723b7b1 JS |
1425 | |
1426 | // Get the current mouse position. | |
16cba29d | 1427 | extern WXDLLEXPORT wxPoint wxGetMousePosition(); |
3723b7b1 | 1428 | |
1e6feb95 | 1429 | // get the currently active window of this application or NULL |
16cba29d | 1430 | extern WXDLLEXPORT wxWindow *wxGetActiveWindow(); |
1e6feb95 | 1431 | |
33b494d6 VZ |
1432 | // get the (first) top level parent window |
1433 | WXDLLEXPORT wxWindow* wxGetTopLevelParent(wxWindow *win); | |
1434 | ||
f68586e5 | 1435 | // deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId() |
6d56eb5c | 1436 | inline int NewControlId() { return wxWindowBase::NewControlId(); } |
f03fc89f | 1437 | |
45a959a3 JS |
1438 | #if wxUSE_ACCESSIBILITY |
1439 | // ---------------------------------------------------------------------------- | |
1440 | // accessible object for windows | |
1441 | // ---------------------------------------------------------------------------- | |
1442 | ||
1443 | class WXDLLEXPORT wxWindowAccessible: public wxAccessible | |
1444 | { | |
1445 | public: | |
f81387bd | 1446 | wxWindowAccessible(wxWindow* win): wxAccessible(win) { if (win) win->SetAccessible(this); } |
6fb99eb3 | 1447 | virtual ~wxWindowAccessible() {} |
45a959a3 JS |
1448 | |
1449 | // Overridables | |
1450 | ||
1451 | // Can return either a child object, or an integer | |
1452 | // representing the child element, starting from 1. | |
1453 | virtual wxAccStatus HitTest(const wxPoint& pt, int* childId, wxAccessible** childObject); | |
1454 | ||
1455 | // Returns the rectangle for this object (id = 0) or a child element (id > 0). | |
1456 | virtual wxAccStatus GetLocation(wxRect& rect, int elementId); | |
1457 | ||
1458 | // Navigates from fromId to toId/toObject. | |
1459 | virtual wxAccStatus Navigate(wxNavDir navDir, int fromId, | |
1460 | int* toId, wxAccessible** toObject); | |
1461 | ||
1462 | // Gets the name of the specified object. | |
1463 | virtual wxAccStatus GetName(int childId, wxString* name); | |
1464 | ||
1465 | // Gets the number of children. | |
a37e4a07 | 1466 | virtual wxAccStatus GetChildCount(int* childCount); |
45a959a3 JS |
1467 | |
1468 | // Gets the specified child (starting from 1). | |
1469 | // If *child is NULL and return value is wxACC_OK, | |
1470 | // this means that the child is a simple element and | |
1471 | // not an accessible object. | |
1472 | virtual wxAccStatus GetChild(int childId, wxAccessible** child); | |
1473 | ||
1474 | // Gets the parent, or NULL. | |
1475 | virtual wxAccStatus GetParent(wxAccessible** parent); | |
1476 | ||
1477 | // Performs the default action. childId is 0 (the action for this object) | |
1478 | // or > 0 (the action for a child). | |
1479 | // Return wxACC_NOT_SUPPORTED if there is no default action for this | |
1480 | // window (e.g. an edit control). | |
1481 | virtual wxAccStatus DoDefaultAction(int childId); | |
1482 | ||
1483 | // Gets the default action for this object (0) or > 0 (the action for a child). | |
1484 | // Return wxACC_OK even if there is no action. actionName is the action, or the empty | |
1485 | // string if there is no action. | |
1486 | // The retrieved string describes the action that is performed on an object, | |
1487 | // not what the object does as a result. For example, a toolbar button that prints | |
1488 | // a document has a default action of "Press" rather than "Prints the current document." | |
1489 | virtual wxAccStatus GetDefaultAction(int childId, wxString* actionName); | |
1490 | ||
1491 | // Returns the description for this object or a child. | |
1492 | virtual wxAccStatus GetDescription(int childId, wxString* description); | |
1493 | ||
1494 | // Returns help text for this object or a child, similar to tooltip text. | |
1495 | virtual wxAccStatus GetHelpText(int childId, wxString* helpText); | |
1496 | ||
1497 | // Returns the keyboard shortcut for this object or child. | |
1498 | // Return e.g. ALT+K | |
1499 | virtual wxAccStatus GetKeyboardShortcut(int childId, wxString* shortcut); | |
1500 | ||
1501 | // Returns a role constant. | |
1502 | virtual wxAccStatus GetRole(int childId, wxAccRole* role); | |
1503 | ||
1504 | // Returns a state constant. | |
1505 | virtual wxAccStatus GetState(int childId, long* state); | |
1506 | ||
1507 | // Returns a localized string representing the value for the object | |
1508 | // or child. | |
1509 | virtual wxAccStatus GetValue(int childId, wxString* strValue); | |
1510 | ||
1511 | // Selects the object or child. | |
1512 | virtual wxAccStatus Select(int childId, wxAccSelectionFlags selectFlags); | |
1513 | ||
1514 | // Gets the window with the keyboard focus. | |
1515 | // If childId is 0 and child is NULL, no object in | |
1516 | // this subhierarchy has the focus. | |
1517 | // If this object has the focus, child should be 'this'. | |
1518 | virtual wxAccStatus GetFocus(int* childId, wxAccessible** child); | |
1519 | ||
1520 | // Gets a variant representing the selected children | |
1521 | // of this object. | |
1522 | // Acceptable values: | |
d4864e97 | 1523 | // - a null variant (IsNull() returns true) |
45a959a3 JS |
1524 | // - a list variant (GetType() == wxT("list") |
1525 | // - an integer representing the selected child element, | |
1526 | // or 0 if this object is selected (GetType() == wxT("long") | |
1527 | // - a "void*" pointer to a wxAccessible child object | |
1528 | virtual wxAccStatus GetSelections(wxVariant* selections); | |
1529 | }; | |
1530 | ||
1531 | #endif // wxUSE_ACCESSIBILITY | |
1532 | ||
1533 | ||
c801d85f | 1534 | #endif |
34138703 | 1535 | // _WX_WINDOW_H_BASE_ |
34c3ffca | 1536 |