unussed param warning suppressed
[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 & WXUNUSED(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 // get the haqndle of the window for the underlying window system: this
599 // is only used for wxWin itself or for user code which wants to call
600 // platform-specific APIs
601 virtual WXWidget GetHandle() const = 0;
602
603 protected:
604 // the window id - a number which uniquely identifies a window among
605 // its siblings unless it is -1
606 wxWindowID m_windowId;
607
608 // the parent window of this window (or NULL) and the list of the children
609 // of this window
610 wxWindow *m_parent;
611 wxWindowList m_children;
612
613 // the minimal allowed size for the window (no minimal size if variable(s)
614 // contain(s) -1)
615 int m_minWidth, m_minHeight, m_maxWidth, m_maxHeight;
616
617 // event handler for this window: usually is just 'this' but may be
618 // changed with SetEventHandler()
619 wxEvtHandler *m_eventHandler;
620
621 // associated validator or NULL if none
622 wxValidator *m_windowValidator;
623
624 #if wxUSE_DRAG_AND_DROP
625 wxDropTarget *m_dropTarget;
626 #endif // wxUSE_DRAG_AND_DROP
627
628 // visual window attributes
629 wxCursor m_cursor;
630 wxFont m_font;
631 wxColour m_backgroundColour, m_foregroundColour;
632
633 // the region which should be repainted in response to paint event
634 wxRegion m_updateRegion;
635
636 // the accelerator table for the window which translates key strokes into
637 // command events
638 wxAcceleratorTable m_acceleratorTable;
639
640 // user data associated with the window: either an object which will be
641 // deleted by the window when it's deleted or some raw pointer which we do
642 // nothing with
643 wxClientData *m_clientObject;
644 void *m_clientData;
645
646 // the tooltip for this window (may be NULL)
647 #if wxUSE_TOOLTIPS
648 wxToolTip *m_tooltip;
649 #endif // wxUSE_TOOLTIPS
650
651 // constraints and sizers
652 #if wxUSE_CONSTRAINTS
653 // the constraints for this window or NULL
654 wxLayoutConstraints *m_constraints;
655
656 // constraints this window is involved in
657 wxWindowList *m_constraintsInvolvedIn;
658
659 // top level and the parent sizers
660 // TODO what's this and how does it work?)
661 wxSizer *m_windowSizer;
662 wxWindowBase *m_sizerParent;
663
664 // Layout() window automatically when its size changes?
665 bool m_autoLayout:1;
666 #endif // wxUSE_CONSTRAINTS
667
668 // window state
669 bool m_isShown:1;
670 bool m_isEnabled:1;
671 bool m_isBeingDeleted:1;
672
673 // window attributes
674 long m_windowStyle;
675 wxString m_windowName;
676
677 protected:
678 // common part of all ctors: it is not virtual because it is called from
679 // ctor
680 void InitBase();
681
682 // get the default size for the new window if no explicit size given
683 // FIXME why 20 and not 30, 10 or ...?
684 static int WidthDefault(int w) { return w == -1 ? 20 : w; }
685 static int HeightDefault(int h) { return h == -1 ? 20 : h; }
686
687 // more pure virtual functions
688 // ---------------------------
689
690 // NB: we must have DoSomething() function when Something() is an overloaded
691 // method: indeed, we can't just have "virtual Something()" in case when
692 // the function is overloaded because then we'd have to make virtual all
693 // the variants (otherwise only the virtual function may be called on a
694 // pointer to derived class according to C++ rules) which is, in
695 // general, absolutely not needed. So instead we implement all
696 // overloaded Something()s in terms of DoSomething() which will be the
697 // only one to be virtual.
698
699 // retrieve the position/size of the window
700 virtual void DoGetPosition( int *x, int *y ) const = 0;
701 virtual void DoGetSize( int *width, int *height ) const = 0;
702 virtual void DoGetClientSize( int *width, int *height ) const = 0;
703
704 // this is the virtual function to be overriden in any derived class which
705 // wants to change how SetSize() or Move() works - it is called by all
706 // versions of these functions in the base class
707 virtual void DoSetSize(int x, int y,
708 int width, int height,
709 int sizeFlags = wxSIZE_AUTO) = 0;
710
711 // same as DoSetSize() for the client size
712 virtual void DoSetClientSize(int width, int height) = 0;
713
714 #if wxUSE_TOOLTIPS
715 virtual void DoSetToolTip( wxToolTip *tip );
716 #endif // wxUSE_TOOLTIPS
717
718 private:
719 // contains the last id generated by NewControlId
720 static int ms_lastControlId;
721
722 DECLARE_EVENT_TABLE()
723 };
724
725 // ----------------------------------------------------------------------------
726 // now include the declaration of wxWindow class
727 // ----------------------------------------------------------------------------
728
729 #if defined(__WXMSW__)
730 #include "wx/msw/window.h"
731 #elif defined(__WXMOTIF__)
732 #include "wx/motif/window.h"
733 #elif defined(__WXGTK__)
734 #include "wx/gtk/window.h"
735 #elif defined(__WXQT__)
736 #include "wx/qt/window.h"
737 #elif defined(__WXMAC__)
738 #include "wx/mac/window.h"
739 #endif
740
741 // ----------------------------------------------------------------------------
742 // inline functions which couldn't be declared in the class body because of
743 // forward dependencies
744 // ----------------------------------------------------------------------------
745
746 inline wxWindow *wxWindowBase::GetGrandParent() const
747 {
748 return m_parent ? m_parent->GetParent() : (wxWindow *)NULL;
749 }
750
751 // ----------------------------------------------------------------------------
752 // global function
753 // ----------------------------------------------------------------------------
754
755 extern wxWindow* WXDLLEXPORT wxGetActiveWindow();
756 inline int WXDLLEXPORT NewControlId() { return wxWindowBase::NewControlId(); }
757
758 #endif
759 // _WX_WINDOW_H_BASE_