]> git.saurik.com Git - wxWidgets.git/blob - include/wx/window.h
added wxEvtHandler::Disconnect(evtType, ...) overload
[wxWidgets.git] / include / wx / window.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/window.h
3 // Purpose: wxWindowBase class - the interface of wxWindow
4 // Author: Vadim Zeitlin
5 // Modified by: Ron Lee
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_BASE_
13 #define _WX_WINDOW_H_BASE_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "windowbase.h"
17 #endif
18
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"
31 #include "wx/utils.h"
32
33 #include "wx/validate.h" // for wxDefaultValidator (always include it)
34
35 #if wxUSE_PALETTE
36 #include "wx/palette.h"
37 #endif // wxUSE_PALETTE
38
39 #if wxUSE_ACCEL
40 #include "wx/accel.h"
41 #endif // wxUSE_ACCEL
42
43 #if wxUSE_ACCESSIBILITY
44 #include "wx/access.h"
45 #endif
46
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
51 #else // !__WXUNIVERSAL__
52 #define wxUSE_MENUS_NATIVE wxUSE_MENUS
53 #endif // __WXUNIVERSAL__/!__WXUNIVERSAL__
54
55 // ----------------------------------------------------------------------------
56 // forward declarations
57 // ----------------------------------------------------------------------------
58
59 class WXDLLEXPORT wxCaret;
60 class WXDLLEXPORT wxControl;
61 class WXDLLEXPORT wxCursor;
62 class WXDLLEXPORT wxDC;
63 class WXDLLEXPORT wxDropTarget;
64 class WXDLLEXPORT wxItemResource;
65 class WXDLLEXPORT wxLayoutConstraints;
66 class WXDLLEXPORT wxResourceTable;
67 class WXDLLEXPORT wxSizer;
68 class WXDLLEXPORT wxToolTip;
69 class WXDLLEXPORT wxWindowBase;
70 class WXDLLEXPORT wxWindow;
71
72 #if wxUSE_ACCESSIBILITY
73 class WXDLLEXPORT wxAccessible;
74 #endif
75
76 class WXDLLEXPORT wxWindowExtraData;
77
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
98 enum wxWindowVariant
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
107 #if wxUSE_SYSTEM_OPTIONS
108 #define wxWINDOW_DEFAULT_VARIANT wxT("window-default-variant")
109 #endif
110
111 // ----------------------------------------------------------------------------
112 // (pseudo)template list classes
113 // ----------------------------------------------------------------------------
114
115 WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode, class WXDLLEXPORT);
116
117 // ----------------------------------------------------------------------------
118 // global variables
119 // ----------------------------------------------------------------------------
120
121 extern WXDLLEXPORT_DATA(wxWindowList) wxTopLevelWindows;
122
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 {
136 public:
137 // creating the window
138 // -------------------
139
140 // default ctor, initializes everything which can be initialized before
141 // Create()
142 wxWindowBase() ;
143
144 // pseudo ctor (can't be virtual, called from ctor)
145 bool CreateBase(wxWindowBase *parent,
146 wxWindowID winid,
147 const wxPoint& pos = wxDefaultPosition,
148 const wxSize& size = wxDefaultSize,
149 long style = 0,
150 const wxValidator& validator = wxDefaultValidator,
151 const wxString& name = wxPanelNameStr);
152
153 virtual ~wxWindowBase();
154
155 // deleting the window
156 // -------------------
157
158 // ask the window to close itself, return true if the event handler
159 // honoured our request
160 bool Close( bool force = false );
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
166 // delete window unconditionally (dangerous!), returns true if ok
167 virtual bool Destroy();
168 // delete all children of this window, returns true if ok
169 bool DestroyChildren();
170
171 // is the window being deleted?
172 bool IsBeingDeleted() const { return m_isBeingDeleted; }
173
174 // window attributes
175 // -----------------
176
177 // NB: in future versions of wxWidgets Set/GetTitle() will only work
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
181 // the title (or label, see below) of the window: the text which the
182 // window shows
183 virtual void SetTitle( const wxString& WXUNUSED(title) ) {}
184 virtual wxString GetTitle() const { return wxEmptyString; }
185
186 // label is just the same as the title (but for, e.g., buttons it
187 // makes more sense to speak about labels)
188 virtual void SetLabel(const wxString& label) { SetTitle(label); }
189 virtual wxString GetLabel() const { return GetTitle(); }
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
196 // sets the window variant, calls internally DoSetVariant if variant has changed
197 void SetWindowVariant( wxWindowVariant variant ) ;
198 wxWindowVariant GetWindowVariant() const { return m_windowVariant ; }
199
200
201 // window id uniquely identifies the window among its siblings unless
202 // it is wxID_ANY which means "don't care"
203 void SetId( wxWindowID winid ) { m_windowId = winid; }
204 wxWindowID GetId() const { return m_windowId; }
205
206 // generate a control id for the controls which were not given one by
207 // user
208 static int NewControlId() { return --ms_lastControlId; }
209 // get the id of the control following the one with the given
210 // (autogenerated) id
211 static int NextControlId(int winid) { return winid - 1; }
212 // get the id of the control preceding the one with the given
213 // (autogenerated) id
214 static int PrevControlId(int winid) { return winid + 1; }
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 )
225 { DoSetSize( wxDefaultCoord, wxDefaultCoord, width, height, wxSIZE_USE_EXISTING ); }
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
233 void Move(int x, int y, int flags = wxSIZE_USE_EXISTING)
234 { DoSetSize(x, y, wxDefaultCoord, wxDefaultCoord, flags); }
235
236 void Move(const wxPoint& pt, int flags = wxSIZE_USE_EXISTING)
237 { Move(pt.x, pt.y, flags); }
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
263 void SetPosition( const wxPoint& pt ) { Move( pt ) ; }
264
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
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
302 // get the size best suited for the window (in fact, minimal
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 }
311 void GetBestSize(int *w, int *h) const
312 {
313 wxSize s = GetBestSize();
314 if ( w )
315 *w = s.x;
316 if ( h )
317 *h = s.y;
318 }
319
320 // reset the cached best size value so it will be recalculated the
321 // next time it is needed.
322 void InvalidateBestSize();
323 void CacheBestSize(const wxSize& size) const
324 { wxConstCast(this, wxWindowBase)->m_bestSizeCache = size; }
325
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 {
333 wxSize s( GetBestSize() );
334 return wxSize( wxMax( s.x, GetMinWidth() ), wxMax( s.y, GetMinHeight() ) );
335 }
336
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;
341
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
346 // the generic centre function - centers the window on parent by`
347 // default or on screen if it doesn't have parent or
348 // wxCENTER_ON_SCREEN flag is given
349 void Centre( int direction = wxBOTH );
350 void Center( int direction = wxBOTH ) { Centre(direction); }
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); }
359
360 // set window size to wrap around its children
361 virtual void Fit();
362
363 // set virtual size to satisfy children
364 virtual void FitInside();
365
366 // set min/max size of the window
367 virtual void SetSizeHints( int minW, int minH,
368 int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
369 int incW = wxDefaultCoord, int incH = wxDefaultCoord )
370 {
371 DoSetSizeHints(minW, minH, maxW, maxH, incW, incH);
372 }
373
374 void SetSizeHints( const wxSize& minSize,
375 const wxSize& maxSize=wxDefaultSize,
376 const wxSize& incSize=wxDefaultSize)
377 {
378 DoSetSizeHints(minSize.x, minSize.y,
379 maxSize.x, maxSize.y,
380 incSize.x, incSize.y);
381 }
382
383 virtual void DoSetSizeHints(int minW, int minH,
384 int maxW = wxDefaultCoord, int maxH = wxDefaultCoord,
385 int incW = wxDefaultCoord, int incH = wxDefaultCoord );
386
387 virtual void SetVirtualSizeHints( int minW, int minH,
388 int maxW = wxDefaultCoord, int maxH = wxDefaultCoord );
389 void SetVirtualSizeHints( const wxSize& minSize,
390 const wxSize& maxSize=wxDefaultSize)
391 {
392 SetVirtualSizeHints(minSize.x, minSize.y, maxSize.x, maxSize.y);
393 }
394
395 virtual int GetMinWidth() const { return m_minWidth; }
396 virtual int GetMinHeight() const { return m_minHeight; }
397 int GetMaxWidth() const { return m_maxWidth; }
398 int GetMaxHeight() const { return m_maxHeight; }
399
400 // Override this method to control the values given to Sizers etc.
401 virtual wxSize GetMaxSize() const { return wxSize( m_maxWidth, m_maxHeight ); }
402 virtual wxSize GetMinSize() const { return wxSize( m_minWidth, m_minHeight ); }
403
404 void SetMinSize(const wxSize& minSize) { SetSizeHints(minSize); }
405 void SetMaxSize(const wxSize& maxSize) { SetSizeHints(GetMinSize(), maxSize); }
406
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
429 // wxScrolledWindow.
430
431 virtual void DoSetVirtualSize( int x, int y );
432 virtual wxSize DoGetVirtualSize() const;
433
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
445 // window state
446 // ------------
447
448 // returns true if window was shown/hidden, false if the nothing was
449 // done (window was already shown/hidden)
450 virtual bool Show( bool show = true );
451 bool Hide() { return Show(false); }
452
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); }
456
457 virtual bool IsShown() const { return m_isShown; }
458 virtual bool IsEnabled() const { return m_isEnabled; }
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; }
470 virtual bool IsRetained() const { return HasFlag(wxRETAINED); }
471
472 // extra style: the less often used style bits which can't be set with
473 // SetWindowStyleFlag()
474 virtual void SetExtraStyle(long exStyle) { m_exStyle = exStyle; }
475 long GetExtraStyle() const { return m_exStyle; }
476
477 // make the window modal (all other windows unresponsive)
478 virtual void MakeModal(bool modal = true);
479
480
481 // (primitive) theming support
482 // ---------------------------
483
484 virtual void SetThemeEnabled(bool enableTheme) { m_themeEnabled = enableTheme; }
485 virtual bool GetThemeEnabled() const { return m_themeEnabled; }
486
487
488 // focus and keyboard handling
489 // ---------------------------
490
491 // set focus to this window
492 virtual void SetFocus() = 0;
493
494 // set focus to this window as the result of a keyboard action
495 virtual void SetFocusFromKbd() { SetFocus(); }
496
497 // return the window which currently has the focus or NULL
498 static wxWindow *FindFocus();
499
500 static wxWindow *DoFindFocus() /* = 0: implement in derived classes */;
501
502 // can this window have focus?
503 virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
504
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
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
521 // set this child as temporary default
522 virtual void SetTmpDefaultItem(wxWindow * WXUNUSED(win)) { }
523
524 // navigates in the specified direction by sending a wxNavigationKeyEvent
525 virtual bool Navigate(int flags = wxNavigationKeyEvent::IsForward);
526
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
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
542 // needed just for extended runtime
543 const wxWindowList& GetWindowChildren() const { return GetChildren() ; }
544
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?
550 virtual bool IsTopLevel() const;
551
552 // it doesn't really change parent, use Reparent() instead
553 void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; }
554 // change the real parent of this window, return true if the parent
555 // was changed, false otherwise (error or newParent == oldParent)
556 virtual bool Reparent( wxWindowBase *newParent );
557
558 // implementation mostly
559 virtual void AddChild( wxWindowBase *child );
560 virtual void RemoveChild( wxWindowBase *child );
561
562 // looking for windows
563 // -------------------
564
565 // find window among the descendants of this one either by id or by
566 // name (return NULL if not found)
567 wxWindow *FindWindow(long winid) const;
568 wxWindow *FindWindow(const wxString& name) const;
569
570 // Find a window among any window (all return NULL if not found)
571 static wxWindow *FindWindowById( long winid, const wxWindow *parent = NULL );
572 static wxWindow *FindWindowByName( const wxString& name,
573 const wxWindow *parent = NULL );
574 static wxWindow *FindWindowByLabel( const wxString& label,
575 const wxWindow *parent = NULL );
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 );
590 wxEvtHandler *PopEventHandler( bool deleteHandler = false );
591
592 // find the given handler in the event handler chain and remove (but
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
595 // this function should only be called when the handler is supposed to
596 // be there)
597 bool RemoveEventHandler(wxEvtHandler *handler);
598
599 // validators
600 // ----------
601
602 #if wxUSE_VALIDATORS
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; }
607 #endif // wxUSE_VALIDATORS
608
609
610 // dialog oriented functions
611 // -------------------------
612
613 // validate the correctness of input, return true if ok
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
622 #if wxUSE_ACCEL
623 // accelerators
624 // ------------
625 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel )
626 { m_acceleratorTable = accel; }
627 wxAcceleratorTable *GetAcceleratorTable()
628 { return &m_acceleratorTable; }
629
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);
637 virtual bool UnregisterHotKey(int hotkeyId);
638 #endif // wxUSE_HOTKEY
639
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
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();
672
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
680 // painting the window
681 // -------------------
682
683 // mark the specified rectangle (or the whole window) as "dirty" so it
684 // will be repainted
685 virtual void Refresh( bool eraseBackground = true,
686 const wxRect *rect = (const wxRect *) NULL ) = 0;
687
688 // a less awkward wrapper for Refresh
689 void RefreshRect(const wxRect& rect, bool eraseBackground = true)
690 {
691 Refresh(eraseBackground, &rect);
692 }
693
694 // repaint all invalid areas of the window immediately
695 virtual void Update() { }
696
697 // clear the window background
698 virtual void ClearBackground();
699
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
706 // adjust DC for drawing on this window
707 virtual void PrepareDC( wxDC & WXUNUSED(dc) ) { }
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
714 // get the update rectangleregion bounding box in client coords
715 wxRect GetUpdateClientRect() const;
716
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
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
745 // set/retrieve the window colours (system defaults are used by
746 // default): SetXXX() functions return true if colour was changed,
747 // SetDefaultXXX() reset the "m_inheritXXX" flag after setting the
748 // value to prevent it from being inherited by our children
749 virtual bool SetBackgroundColour(const wxColour& colour);
750 void SetOwnBackgroundColour(const wxColour& colour)
751 {
752 if ( SetBackgroundColour(colour) )
753 m_inheritBgCol = false;
754 }
755 wxColour GetBackgroundColour() const;
756 bool InheritsBackgroundColour() const
757 {
758 return m_inheritBgCol;
759 }
760 bool UseBgCol() const
761 {
762 return m_hasBgCol;
763 }
764
765 virtual bool SetForegroundColour(const wxColour& colour);
766 void SetOwnForegroundColour(const wxColour& colour)
767 {
768 if ( SetForegroundColour(colour) )
769 m_inheritFgCol = false;
770 }
771 wxColour GetForegroundColour() const;
772
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
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
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;
786 void SetOwnFont(const wxFont& font)
787 {
788 if ( SetFont(font) )
789 m_inheritFont = false;
790 }
791 wxFont GetFont() const;
792
793 // set/retrieve the cursor for this window (SetCursor() returns true
794 // if the cursor was really changed)
795 virtual bool SetCursor( const wxCursor &cursor );
796 const wxCursor& GetCursor() const { return m_cursor; }
797
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
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
818 // client <-> screen coords
819 // ------------------------
820
821 // translate to/from screen/client coordinates (pointers may be NULL)
822 void ClientToScreen( int *x, int *y ) const
823 { DoClientToScreen(x, y); }
824 void ScreenToClient( int *x, int *y ) const
825 { DoScreenToClient(x, y); }
826
827 // wxPoint interface to do the same thing
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 }
843
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
851 // misc
852 // ----
853
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()); }
861
862 // send wxUpdateUIEvents to this window, and children if recurse is true
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) ;
867
868 #if wxUSE_MENUS
869 bool PopupMenu(wxMenu *menu, const wxPoint& pos = wxDefaultPosition)
870 { return DoPopupMenu(menu, pos.x, pos.y); }
871 bool PopupMenu(wxMenu *menu, int x, int y)
872 { return DoPopupMenu(menu, x, y); }
873 #endif // wxUSE_MENUS
874
875 // scrollbars
876 // ----------
877
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
885 // configure the window scrollbars
886 virtual void SetScrollbar( int orient,
887 int pos,
888 int thumbvisible,
889 int range,
890 bool refresh = true ) = 0;
891 virtual void SetScrollPos( int orient, int pos, bool refresh = true ) = 0;
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
900 // scrolls window by line/page: note that not all controls support this
901 //
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; }
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); }
911
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
927 // tooltips
928 // --------
929
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; }
937 wxString GetToolTipText() const ;
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) ) {}
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
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
970 virtual void SetConstraintSizes(bool recurse = true);
971 virtual bool LayoutPhase1(int *noChanges);
972 virtual bool LayoutPhase2(int *noChanges);
973 virtual bool DoPhase(int phase);
974
975 // these methods are virtual but normally won't be overridden
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
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
993 // sizers
994 void SetSizer(wxSizer *sizer, bool deleteOld = true );
995 void SetSizerAndFit( wxSizer *sizer, bool deleteOld = true );
996
997 wxSizer *GetSizer() const { return m_windowSizer; }
998
999 // Track if this window is a member of a sizer
1000 void SetContainingSizer(wxSizer* sizer);
1001 wxSizer *GetContainingSizer() const { return m_containingSizer; }
1002
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
1019 // implementation
1020 // --------------
1021
1022 // event handlers
1023 void OnSysColourChanged( wxSysColourChangedEvent& event );
1024 void OnInitDialog( wxInitDialogEvent &event );
1025 void OnMiddleClick( wxMouseEvent& event );
1026 #if wxUSE_HELP
1027 void OnHelp(wxHelpEvent& event);
1028 #endif // wxUSE_HELP
1029
1030 // virtual function for implementing internal idle
1031 // behaviour
1032 virtual void OnInternalIdle() {}
1033
1034 // call internal idle recursively
1035 // void ProcessInternalIdle() ;
1036
1037 // get the handle of the window for the underlying window system: this
1038 // is only used for wxWin itself or for user code which wants to call
1039 // platform-specific APIs
1040 virtual WXWidget GetHandle() const = 0;
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() { }
1045
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; }
1050
1051 // When palette is changed tell the DC to set the system palette to the
1052 // new one.
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;
1060 #endif // wxUSE_PALETTE
1061
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
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
1085 protected:
1086 // event handling specific to wxWindow
1087 virtual bool TryValidator(wxEvent& event);
1088 virtual bool TryParent(wxEvent& event);
1089
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);
1097
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
1102
1103 // Send the wxWindowDestroyEvent
1104 void SendDestroyEvent();
1105
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
1109 virtual wxWindow *GetMainWindowOfCompositeControl()
1110 { return (wxWindow*)this; }
1111
1112 // the window id - a number which uniquely identifies a window among
1113 // its siblings unless it is wxID_ANY
1114 wxWindowID m_windowId;
1115
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)
1122 // contain(s) wxDefaultCoord)
1123 int m_minWidth,
1124 m_minHeight,
1125 m_maxWidth,
1126 m_maxHeight;
1127
1128 // event handler for this window: usually is just 'this' but may be
1129 // changed with SetEventHandler()
1130 wxEvtHandler *m_eventHandler;
1131
1132 #if wxUSE_VALIDATORS
1133 // associated validator or NULL if none
1134 wxValidator *m_windowValidator;
1135 #endif // wxUSE_VALIDATORS
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;
1143 wxFont m_font; // see m_hasFont
1144 wxColour m_backgroundColour, // m_hasBgCol
1145 m_foregroundColour; // m_hasFgCol
1146
1147 #if wxUSE_CARET
1148 wxCaret *m_caret;
1149 #endif // wxUSE_CARET
1150
1151 // the region which should be repainted in response to paint event
1152 wxRegion m_updateRegion;
1153
1154 #if wxUSE_ACCEL
1155 // the accelerator table for the window which translates key strokes into
1156 // command events
1157 wxAcceleratorTable m_acceleratorTable;
1158 #endif // wxUSE_ACCEL
1159
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;
1172 #endif // wxUSE_CONSTRAINTS
1173
1174 // this window's sizer
1175 wxSizer *m_windowSizer;
1176
1177 // The sizer this window is a member of, if any
1178 wxSizer *m_containingSizer;
1179
1180 // Layout() window automatically when its size changes?
1181 bool m_autoLayout:1;
1182
1183 // window state
1184 bool m_isShown:1;
1185 bool m_isEnabled:1;
1186 bool m_isBeingDeleted:1;
1187
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;
1192
1193 // and should it be inherited by children?
1194 bool m_inheritBgCol:1;
1195 bool m_inheritFgCol:1;
1196 bool m_inheritFont:1;
1197
1198 // window attributes
1199 long m_windowStyle,
1200 m_exStyle;
1201 wxString m_windowName;
1202 bool m_themeEnabled;
1203 wxBackgroundStyle m_backgroundStyle;
1204 #if wxUSE_PALETTE
1205 wxPalette m_palette;
1206 bool m_hasCustomPalette;
1207 #endif // wxUSE_PALETTE
1208
1209 #if wxUSE_ACCESSIBILITY
1210 wxAccessible* m_accessible;
1211 #endif
1212
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;
1220
1221 wxWindowVariant m_windowVariant ;
1222
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
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.
1229 static int WidthDefault(int w) { return w == wxDefaultCoord ? 20 : w; }
1230 static int HeightDefault(int h) { return h == wxDefaultCoord ? 20 : h; }
1231
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
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); }
1240
1241 // set the initial window size if none is given (i.e. at least one of the
1242 // components of the size passed to ctor/Create() is wxDefaultCoord)
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
1250
1251
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
1264 // coordinates translation
1265 virtual void DoClientToScreen( int *x, int *y ) const = 0;
1266 virtual void DoScreenToClient( int *x, int *y ) const = 0;
1267
1268 virtual wxHitTest DoHitTest(wxCoord x, wxCoord y) const;
1269
1270 // capture/release the mouse, used by Capture/ReleaseMouse()
1271 virtual void DoCaptureMouse() = 0;
1272 virtual void DoReleaseMouse() = 0;
1273
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
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
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
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
1300 #if wxUSE_TOOLTIPS
1301 virtual void DoSetToolTip( wxToolTip *tip );
1302 #endif // wxUSE_TOOLTIPS
1303
1304 #if wxUSE_MENUS
1305 virtual bool DoPopupMenu(wxMenu *menu, int x, int y) = 0;
1306 #endif // wxUSE_MENUS
1307
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;
1313
1314 // implements the window variants
1315 virtual void DoSetWindowVariant( wxWindowVariant variant ) ;
1316
1317 // Was a reserved pointer in 2.6.0, now used to hold extra data members
1318 // without breaking compatibility.
1319 wxWindowExtraData* m_extraData;
1320
1321 private:
1322 // contains the last id generated by NewControlId
1323 static int ms_lastControlId;
1324
1325 // the stack of windows which have captured the mouse
1326 static struct WXDLLEXPORT wxWindowNext *ms_winCaptureNext;
1327
1328 DECLARE_ABSTRACT_CLASS(wxWindowBase)
1329 DECLARE_NO_COPY_CLASS(wxWindowBase)
1330 DECLARE_EVENT_TABLE()
1331 };
1332
1333 // ----------------------------------------------------------------------------
1334 // now include the declaration of wxWindow class
1335 // ----------------------------------------------------------------------------
1336
1337 // include the declaration of the platform-specific class
1338 #if defined(__WXPALMOS__)
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__)
1346 #ifdef __WXUNIVERSAL__
1347 #define wxWindowNative wxWindowMSW
1348 #else // !wxUniv
1349 #define wxWindowMSW wxWindow
1350 #endif // wxUniv/!wxUniv
1351 #include "wx/msw/window.h"
1352 #elif defined(__WXMOTIF__)
1353 #include "wx/motif/window.h"
1354 #elif defined(__WXGTK__)
1355 #ifdef __WXUNIVERSAL__
1356 #define wxWindowNative wxWindowGTK
1357 #else // !wxUniv
1358 #define wxWindowGTK wxWindow
1359 #endif // wxUniv
1360 #include "wx/gtk/window.h"
1361 #elif defined(__WXX11__)
1362 #ifdef __WXUNIVERSAL__
1363 #define wxWindowNative wxWindowX11
1364 #else // !wxUniv
1365 #define wxWindowX11 wxWindow
1366 #endif // wxUniv
1367 #include "wx/x11/window.h"
1368 #elif defined(__WXMGL__)
1369 #ifdef __WXUNIVERSAL__
1370 #define wxWindowNative wxWindowMGL
1371 #else // !wxUniv
1372 #define wxWindowMGL wxWindow
1373 #endif // wxUniv
1374 #include "wx/mgl/window.h"
1375 #elif defined(__WXMAC__)
1376 #ifdef __WXUNIVERSAL__
1377 #define wxWindowNative wxWindowMac
1378 #else // !wxUniv
1379 #define wxWindowMac wxWindow
1380 #endif // wxUniv
1381 #include "wx/mac/window.h"
1382 #elif defined(__WXCOCOA__)
1383 #ifdef __WXUNIVERSAL__
1384 #define wxWindowNative wxWindowCocoa
1385 #else // !wxUniv
1386 #define wxWindowCocoa wxWindow
1387 #endif // wxUniv
1388 #include "wx/cocoa/window.h"
1389 #elif defined(__WXPM__)
1390 #ifdef __WXUNIVERSAL__
1391 #define wxWindowNative wxWindowOS2
1392 #else // !wxUniv
1393 #define wxWindowOS2 wxWindow
1394 #endif // wxUniv/!wxUniv
1395 #include "wx/os2/window.h"
1396 #endif
1397
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__)
1401 #ifndef wxWindowNative
1402 #error "wxWindowNative must be defined above!"
1403 #endif
1404
1405 #include "wx/univ/window.h"
1406 #endif // wxUniv
1407
1408 // ----------------------------------------------------------------------------
1409 // inline functions which couldn't be declared in the class body because of
1410 // forward dependencies
1411 // ----------------------------------------------------------------------------
1412
1413 inline wxWindow *wxWindowBase::GetGrandParent() const
1414 {
1415 return m_parent ? m_parent->GetParent() : (wxWindow *)NULL;
1416 }
1417
1418 // ----------------------------------------------------------------------------
1419 // global functions
1420 // ----------------------------------------------------------------------------
1421
1422 // Find the wxWindow at the current mouse position, also returning the mouse
1423 // position.
1424 extern WXDLLEXPORT wxWindow* wxFindWindowAtPointer(wxPoint& pt);
1425
1426 // Get the current mouse position.
1427 extern WXDLLEXPORT wxPoint wxGetMousePosition();
1428
1429 // get the currently active window of this application or NULL
1430 extern WXDLLEXPORT wxWindow *wxGetActiveWindow();
1431
1432 // get the (first) top level parent window
1433 WXDLLEXPORT wxWindow* wxGetTopLevelParent(wxWindow *win);
1434
1435 // deprecated (doesn't start with 'wx' prefix), use wxWindow::NewControlId()
1436 inline int NewControlId() { return wxWindowBase::NewControlId(); }
1437
1438 #if wxUSE_ACCESSIBILITY
1439 // ----------------------------------------------------------------------------
1440 // accessible object for windows
1441 // ----------------------------------------------------------------------------
1442
1443 class WXDLLEXPORT wxWindowAccessible: public wxAccessible
1444 {
1445 public:
1446 wxWindowAccessible(wxWindow* win): wxAccessible(win) { if (win) win->SetAccessible(this); }
1447 virtual ~wxWindowAccessible() {}
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.
1466 virtual wxAccStatus GetChildCount(int* childCount);
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:
1523 // - a null variant (IsNull() returns true)
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
1534 #endif
1535 // _WX_WINDOW_H_BASE_
1536