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