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