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