]> git.saurik.com Git - wxWidgets.git/blob - include/wx/window.h
Updated for Mahogany.
[wxWidgets.git] / include / wx / window.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: window.h
3 // Purpose: wxWindowBase class - the interface of wxWindowBase
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_WINDOW_H_BASE_
13 #define _WX_WINDOW_H_BASE_
14
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"
27 #include "wx/accel.h"
28
29 // ----------------------------------------------------------------------------
30 // forward declarations
31 // ----------------------------------------------------------------------------
32
33 class WXDLLEXPORT wxClientData;
34 class WXDLLEXPORT wxControl;
35 class WXDLLEXPORT wxCursor;
36 class WXDLLEXPORT wxDc;
37 class WXDLLEXPORT wxDropTarget;
38 class WXDLLEXPORT wxItemResource;
39 class WXDLLEXPORT wxLayoutConstraints;
40 class WXDLLEXPORT wxResourceTable;
41 class WXDLLEXPORT wxSizer;
42 class WXDLLEXPORT wxToolTip;
43 class WXDLLEXPORT wxValidator;
44 class WXDLLEXPORT wxWindowBase;
45 class WXDLLEXPORT wxWindow;
46
47 // ----------------------------------------------------------------------------
48 // (pseudo)template list classes
49 // ----------------------------------------------------------------------------
50
51 WX_DECLARE_LIST_3(wxWindow, wxWindowBase, wxWindowList, wxWindowListNode);
52
53 // ----------------------------------------------------------------------------
54 // global variables
55 // ----------------------------------------------------------------------------
56
57 WXDLLEXPORT_DATA(extern wxWindowList) wxTopLevelWindows;
58
59 // ----------------------------------------------------------------------------
60 // helper classes used by [SG]etClientObject/Data
61 //
62 // TODO move into a separate header?
63 // ----------------------------------------------------------------------------
64
65 class wxClientData
66 {
67 public:
68 wxClientData() { }
69 virtual ~wxClientData() { }
70 };
71
72 class wxStringClientData : public wxClientData
73 {
74 public:
75 wxStringClientData() { }
76 wxStringClientData( const wxString &data ) : m_data(data) { }
77 void SetData( const wxString &data ) { m_data = data; }
78 const wxString& GetData() const { return m_data; }
79
80 private:
81 wxString m_data;
82 };
83
84 // ----------------------------------------------------------------------------
85 // wxWindowBase is the base class for all GUI controls/widgets, this is the public
86 // interface of this class.
87 //
88 // Event handler: windows have themselves as their event handlers by default,
89 // but their event handlers could be set to another object entirely. This
90 // separation can reduce the amount of derivation required, and allow
91 // alteration of a window's functionality (e.g. by a resource editor that
92 // temporarily switches event handlers).
93 // ----------------------------------------------------------------------------
94
95 class WXDLLEXPORT wxWindowBase : public wxEvtHandler
96 {
97 DECLARE_ABSTRACT_CLASS(wxWindowBase);
98
99 public:
100 // creating the window
101 // -------------------
102
103 // default ctor
104 wxWindowBase() { InitBase(); }
105
106 // pseudo ctor (can't be virtual, called from ctor)
107 bool CreateBase(wxWindowBase *parent,
108 wxWindowID id,
109 const wxPoint& pos = wxDefaultPosition,
110 const wxSize& size = wxDefaultSize,
111 long style = 0,
112 const wxString& name = wxPanelNameStr);
113
114 virtual ~wxWindowBase();
115
116 #if wxUSE_WX_RESOURCES
117 // these functions are implemented in resource.cpp and resourc2.cpp
118 virtual bool LoadFromResource(wxWindow *parent,
119 const wxString& resourceName,
120 const wxResourceTable *table = (const wxResourceTable *) NULL);
121 virtual wxControl *CreateItem(const wxItemResource* childResource,
122 const wxItemResource* parentResource,
123 const wxResourceTable *table = (const wxResourceTable *) NULL);
124 #endif // wxUSE_WX_RESOURCES
125
126 // deleting the window
127 // -------------------
128
129 // ask the window to close itself, return TRUE if the event handler
130 // honoured our request
131 bool Close( bool force = FALSE );
132
133 // the following functions delete the C++ objects (the window itself
134 // or its children) as well as the GUI windows and normally should
135 // never be used directly
136
137 // delete window unconditionally (dangerous!), returns TRUE if ok
138 virtual bool Destroy();
139 // delete all children of this window, returns TRUE if ok
140 bool DestroyChildren();
141
142 // is the window being deleted?
143 bool IsBeingDeleted() const { return m_isBeingDeleted; }
144
145 // window attributes
146 // -----------------
147
148 // the title (or label, see below) of the window: the text which the
149 // window shows
150 virtual void SetTitle( const wxString & WXUNUSED(title) ) { }
151 virtual wxString GetTitle() const { return ""; }
152
153 // label is just the same as the title (but for, e.g., buttons it
154 // makes more sense to speak about labels)
155 wxString GetLabel() const { return GetTitle(); }
156
157 // the window name is used for ressource setting in X, it is not the
158 // same as the window title/label
159 virtual void SetName( const wxString &name ) { m_windowName = name; }
160 virtual wxString GetName() const { return m_windowName; }
161
162 // window id uniquely identifies the window among its siblings unless
163 // it is -1 which means "don't care"
164 void SetId( wxWindowID id ) { m_windowId = id; }
165 wxWindowID GetId() const { return m_windowId; }
166
167 // generate a control id for the controls which were not given one by
168 // user
169 static int NewControlId() { return ++ms_lastControlId; }
170
171 // moving/resizing
172 // ---------------
173
174 // set the window size and/or position
175 void SetSize( int x, int y, int width, int height,
176 int sizeFlags = wxSIZE_AUTO )
177 { DoSetSize(x, y, width, height, sizeFlags); }
178
179 void SetSize( int width, int height )
180 { DoSetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); }
181
182 void SetSize( const wxSize& size )
183 { SetSize( size.x, size.y); }
184
185 void SetSize(const wxRect& rect, int sizeFlags = wxSIZE_AUTO)
186 { DoSetSize(rect.x, rect.y, rect.width, rect.height, sizeFlags); }
187
188 void Move( int x, int y )
189 { DoSetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); }
190
191 void Move(const wxPoint& pt)
192 { Move(pt.x, pt.y); }
193
194 // Z-order
195 virtual void Raise() = 0;
196 virtual void Lower() = 0;
197
198 // client size is the size of area available for subwindows
199 void SetClientSize( int width, int height )
200 { DoSetClientSize(width, height); }
201
202 void SetClientSize( const wxSize& size )
203 { DoSetClientSize(size.x, size.y); }
204
205 void SetClientSize(const wxRect& rect)
206 { SetClientSize( rect.width, rect.height ); }
207
208 // get the window position and/or size (pointers may be NULL)
209 void GetPosition( int *x, int *y ) const { DoGetPosition(x, y); }
210 wxPoint GetPosition() const
211 {
212 int w, h;
213 DoGetPosition(&w, &h);
214
215 return wxPoint(w, h);
216 }
217
218 void GetSize( int *w, int *h ) const { DoGetSize(w, h); }
219 wxSize GetSize() const
220 {
221 int w, h;
222 DoGetSize(& w, & h);
223 return wxSize(w, h);
224 }
225
226 wxRect GetRect() const
227 {
228 int x, y, w, h;
229 GetPosition(& x, & y);
230 GetSize(& w, & h);
231
232 return wxRect(x, y, w, h);
233 }
234
235 void GetClientSize( int *w, int *h ) const { DoGetClientSize(w, h); }
236 wxSize GetClientSize() const
237 {
238 int w, h;
239 DoGetClientSize(& w, & h);
240
241 return wxSize(w, h);
242 }
243
244 // centre with respect to the the parent window
245 void Centre( int direction = wxHORIZONTAL );
246 void Center( int direction = wxHORIZONTAL ) { Centre(direction); }
247
248 // set window size to wrap around its children
249 virtual void Fit();
250
251 // set min/max size of the window
252 virtual void SetSizeHints( int minW, int minH,
253 int maxW = -1, int maxH = -1,
254 int incW = -1, int incH = -1 );
255
256 // window state
257 // ------------
258
259 // returns TRUE if window was shown/hidden, FALSE if the nothing was
260 // done (window was already shown/hidden)
261 virtual bool Show( bool show = TRUE );
262 bool Hide() { return Show(FALSE); }
263
264 // returns TRUE if window was enabled/disabled, FALSE if nothing done
265 virtual bool Enable( bool enable = TRUE );
266 bool Disable() { return Enable(FALSE); }
267
268 bool IsShown() const { return m_isShown; }
269 bool IsEnabled() const { return m_isEnabled; }
270
271 // get/set window style (setting style won't update the window and so
272 // is only useful for internal usage)
273 virtual void SetWindowStyleFlag( long style ) { m_windowStyle = style; }
274 virtual long GetWindowStyleFlag() const { return m_windowStyle; }
275
276 // just some (somewhat shorter) synonims
277 void SetWindowStyle( long style ) { SetWindowStyleFlag(style); }
278 long GetWindowStyle() const { return GetWindowStyleFlag(); }
279
280 bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
281
282 virtual bool IsRetained() const
283 { return (m_windowStyle & wxRETAINED) != 0; }
284
285 // make the window modal (all other windows unresponsive)
286 virtual void MakeModal(bool modal = TRUE);
287
288 // focus handling
289 // --------------
290
291 // set focus to this window
292 virtual void SetFocus() = 0;
293
294 // return the window which currently has the focus or NULL
295 static wxWindow *FindFocus() /* = 0: implement in derived classes */;
296
297 // can this window have focus?
298 virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
299
300 // parent/children relations
301 // -------------------------
302
303 // get the list of children
304 const wxWindowList& GetChildren() const { return m_children; }
305 wxWindowList& GetChildren() { return m_children; }
306
307 // get the parent or the parent of the parent
308 wxWindow *GetParent() const { return m_parent; }
309 inline wxWindow *GetGrandParent() const;
310
311 // is this window a top level one?
312 bool IsTopLevel() const { return m_parent != 0; }
313
314 // it doesn't really change parent, use ReParent() instead
315 void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; }
316 // change the real parent of this window, return TRUE if the parent
317 // was changed, FALSE otherwise (error or newParent == oldParent)
318 virtual bool Reparent( wxWindowBase *newParent );
319
320 // find window among the descendants of this one either by id or by
321 // name (return NULL if not found)
322 wxWindow *FindWindow( long id );
323 wxWindow *FindWindow( const wxString& name );
324
325 // implementation mostly
326 virtual void AddChild( wxWindowBase *child );
327 virtual void RemoveChild( wxWindowBase *child );
328
329 // event handler stuff
330 // -------------------
331
332 // get the current event handler
333 wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
334
335 // replace the event handler (allows to completely subclass the
336 // window)
337 void SetEventHandler( wxEvtHandler *handler ) { m_eventHandler = handler; }
338
339 // push/pop event handler: allows to chain a custom event handler to
340 // alreasy existing ones
341 void PushEventHandler( wxEvtHandler *handler );
342 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
343
344 // validators and client data
345 // --------------------------
346
347 // a window may have an associated validator which is used to control
348 // user input
349 virtual void SetValidator( const wxValidator &validator );
350 virtual wxValidator *GetValidator() { return m_windowValidator; }
351
352 // each window may have associated client data: either a pointer to
353 // wxClientData object in which case it is managed by the window (i.e.
354 // it will delete the data when it's destroyed) or an untyped pointer
355 // which won't be deleted by the window
356 virtual void SetClientObject( wxClientData *data )
357 {
358 if ( m_clientObject )
359 delete m_clientObject;
360
361 m_clientObject = data;
362 }
363 virtual wxClientData *GetClientObject() const { return m_clientObject; }
364
365 virtual void SetClientData( void *data ) { m_clientData = data; }
366 virtual void *GetClientData() const { return m_clientData; }
367
368 // dialog oriented functions
369 // -------------------------
370
371 // validate the correctness of input, return TRUE if ok
372 virtual bool Validate();
373
374 // transfer data between internal and GUI representations
375 virtual bool TransferDataToWindow();
376 virtual bool TransferDataFromWindow();
377
378 virtual void InitDialog();
379
380 // accelerators
381 // ------------
382 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel )
383 { m_acceleratorTable = accel; }
384 wxAcceleratorTable *GetAcceleratorTable()
385 { return &m_acceleratorTable; }
386
387 // dialog units translations
388 // -------------------------
389
390 wxPoint ConvertPixelsToDialog( const wxPoint& pt );
391 wxPoint ConvertDialogToPixels( const wxPoint& pt );
392 wxSize ConvertPixelsToDialog( const wxSize& sz )
393 {
394 wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y)));
395
396 return wxSize(pt.x, pt.y);
397 }
398
399 wxSize ConvertDialogToPixels( const wxSize& sz )
400 {
401 wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y)));
402
403 return wxSize(pt.x, pt.y);
404 }
405
406 // mouse functions
407 // ---------------
408
409 // move the mouse to the specified position
410 virtual void WarpPointer(int x, int y) = 0;
411
412 // start or end mouse capture
413 virtual void CaptureMouse() = 0;
414 virtual void ReleaseMouse() = 0;
415
416 // painting the window
417 // -------------------
418
419 // mark the specified rectangle (or the whole window) as "dirty" so it
420 // will be repainted
421 virtual void Refresh( bool eraseBackground = TRUE,
422 const wxRect *rect = (const wxRect *) NULL ) = 0;
423 // clear the window entirely
424 virtual void Clear() = 0;
425
426 // adjust DC for drawing on this window
427 virtual void PrepareDC( wxDC &dc ) { }
428
429 // the update region of the window contains the areas which must be
430 // repainted by the program
431 const wxRegion& GetUpdateRegion() const { return m_updateRegion; }
432 wxRegion& GetUpdateRegion() { return m_updateRegion; }
433
434 // these functions verify whether the given point/rectangle belongs to
435 // (or at least intersects with) the update region
436 bool IsExposed( int x, int y ) const;
437 bool IsExposed( int x, int y, int w, int h ) const;
438
439 bool IsExposed( const wxPoint& pt ) const
440 { return IsExposed(pt.x, pt.y); }
441 bool IsExposed( const wxRect& rect ) const
442 { return IsExposed(rect.x, rect.y, rect.width, rect.height); }
443
444 // colours, fonts and cursors
445 // --------------------------
446
447 // set/retrieve the window colours (system defaults are used by
448 // default): Set functions return TRUE if colour was changed
449 virtual bool SetBackgroundColour( const wxColour &colour );
450 virtual bool SetForegroundColour( const wxColour &colour );
451
452 wxColour GetBackgroundColour() const { return m_backgroundColour; }
453 wxColour GetForegroundColour() const { return m_foregroundColour; }
454
455 // set/retrieve the cursor for this window (SetCursor() returns TRUE
456 // if the cursor was really changed)
457 virtual bool SetCursor( const wxCursor &cursor );
458 const wxCursor& GetCursor() const { return m_cursor; }
459 wxCursor& GetCursor() { return m_cursor; }
460
461 // set/retrieve the font for the window (SetFont() returns TRUE if the
462 // font really changed)
463 virtual bool SetFont( const wxFont &font ) = 0;
464 const wxFont& GetFont() const { return m_font; }
465 wxFont& GetFont() { return m_font; }
466
467 // get the (average) character size for the current font
468 virtual int GetCharHeight() const = 0;
469 virtual int GetCharWidth() const = 0;
470
471 // get the width/height/... of the text using current or specified
472 // font
473 virtual void GetTextExtent(const wxString& string,
474 int *x, int *y,
475 int *descent = (int *) NULL,
476 int *externalLeading = (int *) NULL,
477 const wxFont *theFont = (const wxFont *) NULL)
478 const = 0;
479
480 // translate to/from screen/client coordinates (pointers may be NULL)
481 virtual void ClientToScreen( int *x, int *y ) const = 0;
482 virtual void ScreenToClient( int *x, int *y ) const = 0;
483
484 // misc
485 // ----
486
487 void UpdateWindowUI();
488
489 virtual bool PopupMenu( wxMenu *menu, int x, int y ) = 0;
490
491 // scrollbars
492 // ----------
493
494 // configure the window scrollbars
495 virtual void SetScrollbar( int orient,
496 int pos,
497 int thumbVisible,
498 int range,
499 bool refresh = TRUE ) = 0;
500 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ) = 0;
501 virtual int GetScrollPos( int orient ) const = 0;
502 virtual int GetScrollThumb( int orient ) const = 0;
503 virtual int GetScrollRange( int orient ) const = 0;
504
505 // scroll window to the specified position
506 virtual void ScrollWindow( int dx, int dy,
507 const wxRect* rect = (wxRect *) NULL ) = 0;
508
509 // tooltips
510 // --------
511 #if wxUSE_TOOLTIPS
512 // the easiest way to set a tooltip for a window is to use this method
513 void SetToolTip( const wxString &tip );
514 // attach a tooltip to the window
515 void SetToolTip( wxToolTip *tip ) { DoSetToolTip(tip); }
516 // get the associated tooltip or NULL if none
517 wxToolTip* GetToolTip() const { return m_tooltip; }
518 #endif // wxUSE_TOOLTIPS
519
520 // drag and drop
521 // -------------
522 #if wxUSE_DRAG_AND_DROP
523 // set/retrieve the drop target associated with this window (may be
524 // NULL; it's owned by the window and will be deleted by it)
525 virtual void SetDropTarget( wxDropTarget *dropTarget ) = 0;
526 virtual wxDropTarget *GetDropTarget() const { return m_dropTarget; }
527 #endif // wxUSE_DRAG_AND_DROP
528
529 // constraints and sizers
530 // ----------------------
531 #if wxUSE_CONSTRAINTS
532 // set the constraints for this window or retrieve them (may be NULL)
533 void SetConstraints( wxLayoutConstraints *constraints );
534 wxLayoutConstraints *GetConstraints() const { return m_constraints; }
535
536 // when using constraints, it makes sense to update children positions
537 // automatically whenever the window is resized - this is done if
538 // autoLayout is on
539 void SetAutoLayout( bool autoLayout ) { m_autoLayout = autoLayout; }
540 bool GetAutoLayout() const { return m_autoLayout; }
541
542 // do layout the window and its children
543 virtual bool Layout();
544
545 // implementation only
546 void UnsetConstraints(wxLayoutConstraints *c);
547 wxWindowList *GetConstraintsInvolvedIn() const
548 { return m_constraintsInvolvedIn; }
549 void AddConstraintReference(wxWindowBase *otherWin);
550 void RemoveConstraintReference(wxWindowBase *otherWin);
551 void DeleteRelatedConstraints();
552 void ResetConstraints();
553
554 // these methods may be overriden for special layout algorithms
555 virtual void SetConstraintSizes(bool recurse = TRUE);
556 virtual bool LayoutPhase1(int *noChanges);
557 virtual bool LayoutPhase2(int *noChanges);
558 virtual bool DoPhase(int);
559
560 // these methods are virtual but normally won't be overridden
561 virtual void TransformSizerToActual(int *x, int *y) const ;
562 virtual void SetSizeConstraint(int x, int y, int w, int h);
563 virtual void MoveConstraint(int x, int y);
564 virtual void GetSizeConstraint(int *w, int *h) const ;
565 virtual void GetClientSizeConstraint(int *w, int *h) const ;
566 virtual void GetPositionConstraint(int *x, int *y) const ;
567
568 // sizers
569 // TODO: what are they and how do they work??
570 void SetSizer( wxSizer *sizer );
571 wxSizer *GetSizer() const { return m_windowSizer; }
572
573 void SetSizerParent( wxWindowBase *win ) { m_sizerParent = win; }
574 wxWindowBase *GetSizerParent() const { return m_sizerParent; }
575
576 virtual void SizerSetSize(int x, int y, int w, int h);
577 virtual void SizerMove(int x, int y);
578 #endif // wxUSE_CONSTRAINTS
579
580 // backward compatibility
581 // ----------------------
582 #if WXWIN_COMPATIBILITY
583 bool Enabled() const { return IsEnabled(); }
584
585 void SetButtonFont(const wxFont& font) { SetFont(font); }
586 void SetLabelFont(const wxFont& font) { SetFont(font); }
587 wxFont& GetLabelFont() { return GetFont(); };
588 wxFont& GetButtonFont() { return GetFont(); };
589 #endif // WXWIN_COMPATIBILITY
590
591 // implementation
592 // --------------
593
594 // event handlers
595 void OnSysColourChanged( wxSysColourChangedEvent& event );
596 void OnInitDialog( wxInitDialogEvent &event );
597
598 // accessors
599 WXWidget GetHandle() const { return m_widget; }
600
601 protected:
602 // the window handle (for the underlying windowing system) and the window
603 // id - a number which uniquely identifies a window among its siblings
604 // unless it is -1
605 union
606 {
607 // we have 2 common names for this member, one for MSW and the other
608 // for the rest of the world
609 WXWidget m_widget;
610 WXWidget m_hWnd;
611 };
612
613 wxWindowID m_windowId;
614
615 // the parent window of this window (or NULL) and the list of the children
616 // of this window
617 wxWindow *m_parent;
618 wxWindowList m_children;
619
620 // the minimal allowed size for the window (no minimal size if variable(s)
621 // contain(s) -1)
622 int m_minWidth, m_minHeight, m_maxWidth, m_maxHeight;
623
624 // event handler for this window: usually is just 'this' but may be
625 // changed with SetEventHandler()
626 wxEvtHandler *m_eventHandler;
627
628 // associated validator or NULL if none
629 wxValidator *m_windowValidator;
630
631 #if wxUSE_DRAG_AND_DROP
632 wxDropTarget *m_dropTarget;
633 #endif // wxUSE_DRAG_AND_DROP
634
635 // visual window attributes
636 wxCursor m_cursor;
637 wxFont m_font;
638 wxColour m_backgroundColour, m_foregroundColour;
639
640 // the region which should be repainted in response to paint event
641 wxRegion m_updateRegion;
642
643 // the accelerator table for the window which translates key strokes into
644 // command events
645 wxAcceleratorTable m_acceleratorTable;
646
647 // user data associated with the window: either an object which will be
648 // deleted by the window when it's deleted or some raw pointer which we do
649 // nothing with
650 wxClientData *m_clientObject;
651 void *m_clientData;
652
653 // the tooltip for this window (may be NULL)
654 #if wxUSE_TOOLTIPS
655 wxToolTip *m_tooltip;
656 #endif // wxUSE_TOOLTIPS
657
658 // constraints and sizers
659 #if wxUSE_CONSTRAINTS
660 // the constraints for this window or NULL
661 wxLayoutConstraints *m_constraints;
662
663 // constraints this window is involved in
664 wxWindowList *m_constraintsInvolvedIn;
665
666 // top level and the parent sizers
667 // TODO what's this and how does it work?)
668 wxSizer *m_windowSizer;
669 wxWindowBase *m_sizerParent;
670
671 // Layout() window automatically when its size changes?
672 bool m_autoLayout:1;
673 #endif // wxUSE_CONSTRAINTS
674
675 // window state
676 bool m_isShown:1;
677 bool m_isEnabled:1;
678 bool m_isBeingDeleted:1;
679
680 // window attributes
681 long m_windowStyle;
682 wxString m_windowName;
683
684 protected:
685 // common part of all ctors: it is not virtual because it is called from
686 // ctor
687 void InitBase();
688
689 // get the default size for the new window if no explicit size given
690 // FIXME why 20 and not 30, 10 or ...?
691 static int WidthDefault(int w) { return w == -1 ? 20 : w; }
692 static int HeightDefault(int h) { return h == -1 ? 20 : h; }
693
694 // more pure virtual functions
695 // ---------------------------
696
697 // NB: we must have DoSomething() function when Something() is an overloaded
698 // method: indeed, we can't just have "virtual Something()" in case when
699 // the function is overloaded because then we'd have to make virtual all
700 // the variants (otherwise only the virtual function may be called on a
701 // pointer to derived class according to C++ rules) which is, in
702 // general, absolutely not needed. So instead we implement all
703 // overloaded Something()s in terms of DoSomething() which will be the
704 // only one to be virtual.
705
706 // retrieve the position/size of the window
707 virtual void DoGetPosition( int *x, int *y ) const = 0;
708 virtual void DoGetSize( int *width, int *height ) const = 0;
709 virtual void DoGetClientSize( int *width, int *height ) const = 0;
710
711 // this is the virtual function to be overriden in any derived class which
712 // wants to change how SetSize() or Move() works - it is called by all
713 // versions of these functions in the base class
714 virtual void DoSetSize(int x, int y,
715 int width, int height,
716 int sizeFlags = wxSIZE_AUTO) = 0;
717
718 // same as DoSetSize() for the client size
719 virtual void DoSetClientSize(int width, int height) = 0;
720
721 #if wxUSE_TOOLTIPS
722 virtual void DoSetToolTip( wxToolTip *tip );
723 #endif // wxUSE_TOOLTIPS
724
725 private:
726 // contains the last id generated by NewControlId
727 static int ms_lastControlId;
728
729 DECLARE_EVENT_TABLE()
730 };
731
732 // ----------------------------------------------------------------------------
733 // now include the declaration of wxWindow class
734 // ----------------------------------------------------------------------------
735
736 #if defined(__WXMSW__)
737 #include "wx/msw/window.h"
738 #elif defined(__WXMOTIF__)
739 #include "wx/motif/window.h"
740 #elif defined(__WXGTK__)
741 #include "wx/gtk/window.h"
742 #elif defined(__WXQT__)
743 #include "wx/qt/window.h"
744 #elif defined(__WXMAC__)
745 #include "wx/mac/window.h"
746 #endif
747
748 // ----------------------------------------------------------------------------
749 // inline functions which couldn't be declared in the class body because of
750 // forward dependencies
751 // ----------------------------------------------------------------------------
752
753 wxWindow *wxWindowBase::GetGrandParent() const
754 {
755 return m_parent ? m_parent->GetParent() : (wxWindow *)NULL;
756 }
757
758 // ----------------------------------------------------------------------------
759 // global function
760 // ----------------------------------------------------------------------------
761
762 extern wxWindow* WXDLLEXPORT wxGetActiveWindow();
763 inline int WXDLLEXPORT NewControlId() { return wxWindowBase::NewControlId(); }
764
765 #endif
766 // _WX_WINDOW_H_BASE_