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