1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindowBase class - the interface of wxWindow
4 // Author: Vadim Zeitlin
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_WINDOW_H_BASE_
13 #define _WX_WINDOW_H_BASE_
16 #pragma interface "windowbase.h"
19 // ----------------------------------------------------------------------------
20 // headers which we must include here
21 // ----------------------------------------------------------------------------
23 #include "wx/event.h" // the base class
25 #include "wx/list.h" // defines wxWindowList
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"
33 // ----------------------------------------------------------------------------
34 // forward declarations
35 // ----------------------------------------------------------------------------
37 class WXDLLEXPORT wxCaret
;
38 class WXDLLEXPORT wxClientData
;
39 class WXDLLEXPORT wxControl
;
40 class WXDLLEXPORT wxCursor
;
41 class WXDLLEXPORT wxDC
;
42 class WXDLLEXPORT wxDropTarget
;
43 class WXDLLEXPORT wxItemResource
;
44 class WXDLLEXPORT wxLayoutConstraints
;
45 class WXDLLEXPORT wxResourceTable
;
46 class WXDLLEXPORT wxSizer
;
47 class WXDLLEXPORT wxToolTip
;
48 class WXDLLEXPORT wxValidator
;
49 class WXDLLEXPORT wxWindowBase
;
50 class WXDLLEXPORT wxWindow
;
52 // ----------------------------------------------------------------------------
53 // (pseudo)template list classes
54 // ----------------------------------------------------------------------------
56 WX_DECLARE_LIST_3(wxWindow
, wxWindowBase
, wxWindowList
, wxWindowListNode
);
58 // ----------------------------------------------------------------------------
60 // ----------------------------------------------------------------------------
62 WXDLLEXPORT_DATA(extern wxWindowList
) wxTopLevelWindows
;
64 // ----------------------------------------------------------------------------
65 // helper classes used by [SG]etClientObject/Data
67 // TODO move into a separate header?
68 // ----------------------------------------------------------------------------
74 virtual ~wxClientData() { }
77 class wxStringClientData
: public wxClientData
80 wxStringClientData() { }
81 wxStringClientData( const wxString
&data
) : m_data(data
) { }
82 void SetData( const wxString
&data
) { m_data
= data
; }
83 const wxString
& GetData() const { return m_data
; }
89 // ----------------------------------------------------------------------------
90 // wxWindowBase is the base class for all GUI controls/widgets, this is the public
91 // interface of this class.
93 // Event handler: windows have themselves as their event handlers by default,
94 // but their event handlers could be set to another object entirely. This
95 // separation can reduce the amount of derivation required, and allow
96 // alteration of a window's functionality (e.g. by a resource editor that
97 // temporarily switches event handlers).
98 // ----------------------------------------------------------------------------
100 class WXDLLEXPORT wxWindowBase
: public wxEvtHandler
102 DECLARE_ABSTRACT_CLASS(wxWindowBase
);
105 // creating the window
106 // -------------------
109 wxWindowBase() { InitBase(); }
111 // pseudo ctor (can't be virtual, called from ctor)
112 bool CreateBase(wxWindowBase
*parent
,
114 const wxPoint
& pos
= wxDefaultPosition
,
115 const wxSize
& size
= wxDefaultSize
,
117 const wxString
& name
= wxPanelNameStr
);
119 virtual ~wxWindowBase();
121 #if wxUSE_WX_RESOURCES
122 // these functions are implemented in resource.cpp and resourc2.cpp
123 virtual bool LoadFromResource(wxWindow
*parent
,
124 const wxString
& resourceName
,
125 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
126 virtual wxControl
*CreateItem(const wxItemResource
* childResource
,
127 const wxItemResource
* parentResource
,
128 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
129 #endif // wxUSE_WX_RESOURCES
131 // deleting the window
132 // -------------------
134 // ask the window to close itself, return TRUE if the event handler
135 // honoured our request
136 bool Close( bool force
= FALSE
);
138 // the following functions delete the C++ objects (the window itself
139 // or its children) as well as the GUI windows and normally should
140 // never be used directly
142 // delete window unconditionally (dangerous!), returns TRUE if ok
143 virtual bool Destroy();
144 // delete all children of this window, returns TRUE if ok
145 bool DestroyChildren();
147 // is the window being deleted?
148 bool IsBeingDeleted() const { return m_isBeingDeleted
; }
153 // the title (or label, see below) of the window: the text which the
155 virtual void SetTitle( const wxString
& WXUNUSED(title
) ) { }
156 virtual wxString
GetTitle() const { return ""; }
158 // label is just the same as the title (but for, e.g., buttons it
159 // makes more sense to speak about labels)
160 virtual void SetLabel(const wxString
& label
) { SetTitle(label
); }
161 virtual wxString
GetLabel() const { return GetTitle(); }
163 // the window name is used for ressource setting in X, it is not the
164 // same as the window title/label
165 virtual void SetName( const wxString
&name
) { m_windowName
= name
; }
166 virtual wxString
GetName() const { return m_windowName
; }
168 // window id uniquely identifies the window among its siblings unless
169 // it is -1 which means "don't care"
170 void SetId( wxWindowID id
) { m_windowId
= id
; }
171 wxWindowID
GetId() const { return m_windowId
; }
173 // generate a control id for the controls which were not given one by
175 static int NewControlId() { return --ms_lastControlId
; }
176 // get the id of the control following the one with the given
177 // (autogenerated) id
178 static int NextControlId(int id
) { return id
- 1; }
179 // get the id of the control preceding the one with the given
180 // (autogenerated) id
181 static int PrevControlId(int id
) { return id
+ 1; }
186 // set the window size and/or position
187 void SetSize( int x
, int y
, int width
, int height
,
188 int sizeFlags
= wxSIZE_AUTO
)
189 { DoSetSize(x
, y
, width
, height
, sizeFlags
); }
191 void SetSize( int width
, int height
)
192 { DoSetSize( -1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
194 void SetSize( const wxSize
& size
)
195 { SetSize( size
.x
, size
.y
); }
197 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
198 { DoSetSize(rect
.x
, rect
.y
, rect
.width
, rect
.height
, sizeFlags
); }
200 void Move( int x
, int y
)
201 { DoSetSize( x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
203 void Move(const wxPoint
& pt
)
204 { Move(pt
.x
, pt
.y
); }
207 virtual void Raise() = 0;
208 virtual void Lower() = 0;
210 // client size is the size of area available for subwindows
211 void SetClientSize( int width
, int height
)
212 { DoSetClientSize(width
, height
); }
214 void SetClientSize( const wxSize
& size
)
215 { DoSetClientSize(size
.x
, size
.y
); }
217 void SetClientSize(const wxRect
& rect
)
218 { SetClientSize( rect
.width
, rect
.height
); }
220 // get the window position and/or size (pointers may be NULL)
221 void GetPosition( int *x
, int *y
) const { DoGetPosition(x
, y
); }
222 wxPoint
GetPosition() const
225 DoGetPosition(&w
, &h
);
227 return wxPoint(w
, h
);
230 void GetSize( int *w
, int *h
) const { DoGetSize(w
, h
); }
231 wxSize
GetSize() const
238 wxRect
GetRect() const
241 GetPosition(& x
, & y
);
244 return wxRect(x
, y
, w
, h
);
247 void GetClientSize( int *w
, int *h
) const { DoGetClientSize(w
, h
); }
248 wxSize
GetClientSize() const
251 DoGetClientSize(& w
, & h
);
256 // centre with respect to the the parent window
257 void Centre( int direction
= wxHORIZONTAL
);
258 void Center( int direction
= wxHORIZONTAL
) { Centre(direction
); }
260 // set window size to wrap around its children
263 // set min/max size of the window
264 virtual void SetSizeHints( int minW
, int minH
,
265 int maxW
= -1, int maxH
= -1,
266 int incW
= -1, int incH
= -1 );
271 // returns TRUE if window was shown/hidden, FALSE if the nothing was
272 // done (window was already shown/hidden)
273 virtual bool Show( bool show
= TRUE
);
274 bool Hide() { return Show(FALSE
); }
276 // returns TRUE if window was enabled/disabled, FALSE if nothing done
277 virtual bool Enable( bool enable
= TRUE
);
278 bool Disable() { return Enable(FALSE
); }
280 bool IsShown() const { return m_isShown
; }
281 bool IsEnabled() const { return m_isEnabled
; }
283 // get/set window style (setting style won't update the window and so
284 // is only useful for internal usage)
285 virtual void SetWindowStyleFlag( long style
) { m_windowStyle
= style
; }
286 virtual long GetWindowStyleFlag() const { return m_windowStyle
; }
288 // just some (somewhat shorter) synonims
289 void SetWindowStyle( long style
) { SetWindowStyleFlag(style
); }
290 long GetWindowStyle() const { return GetWindowStyleFlag(); }
292 bool HasFlag(int flag
) const { return (m_windowStyle
& flag
) != 0; }
294 virtual bool IsRetained() const
295 { return (m_windowStyle
& wxRETAINED
) != 0; }
297 // make the window modal (all other windows unresponsive)
298 virtual void MakeModal(bool modal
= TRUE
);
303 // set focus to this window
304 virtual void SetFocus() = 0;
306 // return the window which currently has the focus or NULL
307 static wxWindow
*FindFocus() /* = 0: implement in derived classes */;
309 // can this window have focus?
310 virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
312 // parent/children relations
313 // -------------------------
315 // get the list of children
316 const wxWindowList
& GetChildren() const { return m_children
; }
317 wxWindowList
& GetChildren() { return m_children
; }
319 // get the parent or the parent of the parent
320 wxWindow
*GetParent() const { return m_parent
; }
321 inline wxWindow
*GetGrandParent() const;
323 // is this window a top level one?
324 bool IsTopLevel() const { return m_parent
!= 0; }
326 // it doesn't really change parent, use ReParent() instead
327 void SetParent( wxWindowBase
*parent
) { m_parent
= (wxWindow
*)parent
; }
328 // change the real parent of this window, return TRUE if the parent
329 // was changed, FALSE otherwise (error or newParent == oldParent)
330 virtual bool Reparent( wxWindowBase
*newParent
);
332 // find window among the descendants of this one either by id or by
333 // name (return NULL if not found)
334 wxWindow
*FindWindow( long id
);
335 wxWindow
*FindWindow( const wxString
& name
);
337 // implementation mostly
338 virtual void AddChild( wxWindowBase
*child
);
339 virtual void RemoveChild( wxWindowBase
*child
);
341 // event handler stuff
342 // -------------------
344 // get the current event handler
345 wxEvtHandler
*GetEventHandler() const { return m_eventHandler
; }
347 // replace the event handler (allows to completely subclass the
349 void SetEventHandler( wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
351 // push/pop event handler: allows to chain a custom event handler to
352 // alreasy existing ones
353 void PushEventHandler( wxEvtHandler
*handler
);
354 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
356 // validators and client data
357 // --------------------------
359 // a window may have an associated validator which is used to control
361 virtual void SetValidator( const wxValidator
&validator
);
362 virtual wxValidator
*GetValidator() { return m_windowValidator
; }
364 // each window may have associated client data: either a pointer to
365 // wxClientData object in which case it is managed by the window (i.e.
366 // it will delete the data when it's destroyed) or an untyped pointer
367 // which won't be deleted by the window
368 virtual void SetClientObject( wxClientData
*data
)
370 if ( m_clientObject
)
371 delete m_clientObject
;
373 m_clientObject
= data
;
375 virtual wxClientData
*GetClientObject() const { return m_clientObject
; }
377 virtual void SetClientData( void *data
) { m_clientData
= data
; }
378 virtual void *GetClientData() const { return m_clientData
; }
380 // dialog oriented functions
381 // -------------------------
383 // validate the correctness of input, return TRUE if ok
384 virtual bool Validate();
386 // transfer data between internal and GUI representations
387 virtual bool TransferDataToWindow();
388 virtual bool TransferDataFromWindow();
390 virtual void InitDialog();
394 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
)
395 { m_acceleratorTable
= accel
; }
396 wxAcceleratorTable
*GetAcceleratorTable()
397 { return &m_acceleratorTable
; }
399 // dialog units translations
400 // -------------------------
402 wxPoint
ConvertPixelsToDialog( const wxPoint
& pt
);
403 wxPoint
ConvertDialogToPixels( const wxPoint
& pt
);
404 wxSize
ConvertPixelsToDialog( const wxSize
& sz
)
406 wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
)));
408 return wxSize(pt
.x
, pt
.y
);
411 wxSize
ConvertDialogToPixels( const wxSize
& sz
)
413 wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
)));
415 return wxSize(pt
.x
, pt
.y
);
421 // move the mouse to the specified position
422 virtual void WarpPointer(int x
, int y
) = 0;
424 // start or end mouse capture
425 virtual void CaptureMouse() = 0;
426 virtual void ReleaseMouse() = 0;
428 // painting the window
429 // -------------------
431 // mark the specified rectangle (or the whole window) as "dirty" so it
433 virtual void Refresh( bool eraseBackground
= TRUE
,
434 const wxRect
*rect
= (const wxRect
*) NULL
) = 0;
435 // clear the window entirely
436 virtual void Clear() = 0;
438 // adjust DC for drawing on this window
439 virtual void PrepareDC( wxDC
& WXUNUSED(dc
) ) { }
441 // the update region of the window contains the areas which must be
442 // repainted by the program
443 const wxRegion
& GetUpdateRegion() const { return m_updateRegion
; }
444 wxRegion
& GetUpdateRegion() { return m_updateRegion
; }
446 // these functions verify whether the given point/rectangle belongs to
447 // (or at least intersects with) the update region
448 bool IsExposed( int x
, int y
) const;
449 bool IsExposed( int x
, int y
, int w
, int h
) const;
451 bool IsExposed( const wxPoint
& pt
) const
452 { return IsExposed(pt
.x
, pt
.y
); }
453 bool IsExposed( const wxRect
& rect
) const
454 { return IsExposed(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
456 // colours, fonts and cursors
457 // --------------------------
459 // set/retrieve the window colours (system defaults are used by
460 // default): Set functions return TRUE if colour was changed
461 virtual bool SetBackgroundColour( const wxColour
&colour
);
462 virtual bool SetForegroundColour( const wxColour
&colour
);
464 wxColour
GetBackgroundColour() const { return m_backgroundColour
; }
465 wxColour
GetForegroundColour() const { return m_foregroundColour
; }
467 // set/retrieve the cursor for this window (SetCursor() returns TRUE
468 // if the cursor was really changed)
469 virtual bool SetCursor( const wxCursor
&cursor
);
470 const wxCursor
& GetCursor() const { return m_cursor
; }
471 wxCursor
& GetCursor() { return m_cursor
; }
473 // set/retrieve the font for the window (SetFont() returns TRUE if the
474 // font really changed)
475 virtual bool SetFont( const wxFont
&font
) = 0;
476 const wxFont
& GetFont() const { return m_font
; }
477 wxFont
& GetFont() { return m_font
; }
480 // associate a caret with the window
481 void SetCaret(wxCaret
*caret
);
482 // get the current caret (may be NULL)
483 wxCaret
*GetCaret() const { return m_caret
; }
484 #endif // wxUSE_CARET
486 // get the (average) character size for the current font
487 virtual int GetCharHeight() const = 0;
488 virtual int GetCharWidth() const = 0;
490 // get the width/height/... of the text using current or specified
492 virtual void GetTextExtent(const wxString
& string
,
494 int *descent
= (int *) NULL
,
495 int *externalLeading
= (int *) NULL
,
496 const wxFont
*theFont
= (const wxFont
*) NULL
)
499 // translate to/from screen/client coordinates (pointers may be NULL)
500 void ClientToScreen( int *x
, int *y
) const
501 { DoClientToScreen(x
, y
); }
502 void ScreenToClient( int *x
, int *y
) const
503 { DoScreenToClient(x
, y
); }
504 wxPoint
ClientToScreen(const wxPoint
& pt
) const
506 int x
= pt
.x
, y
= pt
.y
;
507 DoClientToScreen(&x
, &y
);
509 return wxPoint(x
, y
);
512 wxPoint
ScreenToClient(const wxPoint
& pt
) const
514 int x
= pt
.x
, y
= pt
.y
;
515 DoScreenToClient(&x
, &y
);
517 return wxPoint(x
, y
);
523 void UpdateWindowUI();
525 virtual bool PopupMenu( wxMenu
*menu
, int x
, int y
) = 0;
530 // configure the window scrollbars
531 virtual void SetScrollbar( int orient
,
535 bool refresh
= TRUE
) = 0;
536 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
) = 0;
537 virtual int GetScrollPos( int orient
) const = 0;
538 virtual int GetScrollThumb( int orient
) const = 0;
539 virtual int GetScrollRange( int orient
) const = 0;
541 // scroll window to the specified position
542 virtual void ScrollWindow( int dx
, int dy
,
543 const wxRect
* rect
= (wxRect
*) NULL
) = 0;
548 // the easiest way to set a tooltip for a window is to use this method
549 void SetToolTip( const wxString
&tip
);
550 // attach a tooltip to the window
551 void SetToolTip( wxToolTip
*tip
) { DoSetToolTip(tip
); }
552 // get the associated tooltip or NULL if none
553 wxToolTip
* GetToolTip() const { return m_tooltip
; }
554 #endif // wxUSE_TOOLTIPS
558 #if wxUSE_DRAG_AND_DROP
559 // set/retrieve the drop target associated with this window (may be
560 // NULL; it's owned by the window and will be deleted by it)
561 virtual void SetDropTarget( wxDropTarget
*dropTarget
) = 0;
562 virtual wxDropTarget
*GetDropTarget() const { return m_dropTarget
; }
563 #endif // wxUSE_DRAG_AND_DROP
565 // constraints and sizers
566 // ----------------------
567 #if wxUSE_CONSTRAINTS
568 // set the constraints for this window or retrieve them (may be NULL)
569 void SetConstraints( wxLayoutConstraints
*constraints
);
570 wxLayoutConstraints
*GetConstraints() const { return m_constraints
; }
572 // when using constraints, it makes sense to update children positions
573 // automatically whenever the window is resized - this is done if
575 void SetAutoLayout( bool autoLayout
) { m_autoLayout
= autoLayout
; }
576 bool GetAutoLayout() const { return m_autoLayout
; }
578 // do layout the window and its children
579 virtual bool Layout();
581 // implementation only
582 void UnsetConstraints(wxLayoutConstraints
*c
);
583 wxWindowList
*GetConstraintsInvolvedIn() const
584 { return m_constraintsInvolvedIn
; }
585 void AddConstraintReference(wxWindowBase
*otherWin
);
586 void RemoveConstraintReference(wxWindowBase
*otherWin
);
587 void DeleteRelatedConstraints();
588 void ResetConstraints();
590 // these methods may be overriden for special layout algorithms
591 virtual void SetConstraintSizes(bool recurse
= TRUE
);
592 virtual bool LayoutPhase1(int *noChanges
);
593 virtual bool LayoutPhase2(int *noChanges
);
594 virtual bool DoPhase(int);
596 // these methods are virtual but normally won't be overridden
597 virtual void TransformSizerToActual(int *x
, int *y
) const ;
598 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
599 virtual void MoveConstraint(int x
, int y
);
600 virtual void GetSizeConstraint(int *w
, int *h
) const ;
601 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
602 virtual void GetPositionConstraint(int *x
, int *y
) const ;
605 // TODO: what are they and how do they work??
606 void SetSizer( wxSizer
*sizer
);
607 wxSizer
*GetSizer() const { return m_windowSizer
; }
609 void SetSizerParent( wxWindowBase
*win
) { m_sizerParent
= win
; }
610 wxWindowBase
*GetSizerParent() const { return m_sizerParent
; }
612 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
613 virtual void SizerMove(int x
, int y
);
614 #endif // wxUSE_CONSTRAINTS
616 // backward compatibility
617 // ----------------------
618 #if WXWIN_COMPATIBILITY
619 bool Enabled() const { return IsEnabled(); }
621 void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
622 void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
623 wxFont
& GetLabelFont() { return GetFont(); };
624 wxFont
& GetButtonFont() { return GetFont(); };
625 #endif // WXWIN_COMPATIBILITY
631 void OnSysColourChanged( wxSysColourChangedEvent
& event
);
632 void OnInitDialog( wxInitDialogEvent
&event
);
634 // get the haqndle of the window for the underlying window system: this
635 // is only used for wxWin itself or for user code which wants to call
636 // platform-specific APIs
637 virtual WXWidget
GetHandle() const = 0;
640 // the window id - a number which uniquely identifies a window among
641 // its siblings unless it is -1
642 wxWindowID m_windowId
;
644 // the parent window of this window (or NULL) and the list of the children
647 wxWindowList m_children
;
649 // the minimal allowed size for the window (no minimal size if variable(s)
651 int m_minWidth
, m_minHeight
, m_maxWidth
, m_maxHeight
;
653 // event handler for this window: usually is just 'this' but may be
654 // changed with SetEventHandler()
655 wxEvtHandler
*m_eventHandler
;
657 // associated validator or NULL if none
658 wxValidator
*m_windowValidator
;
660 #if wxUSE_DRAG_AND_DROP
661 wxDropTarget
*m_dropTarget
;
662 #endif // wxUSE_DRAG_AND_DROP
664 // visual window attributes
667 wxColour m_backgroundColour
, m_foregroundColour
;
671 #endif // wxUSE_CARET
673 // the region which should be repainted in response to paint event
674 wxRegion m_updateRegion
;
676 // the accelerator table for the window which translates key strokes into
678 wxAcceleratorTable m_acceleratorTable
;
680 // user data associated with the window: either an object which will be
681 // deleted by the window when it's deleted or some raw pointer which we do
683 wxClientData
*m_clientObject
;
686 // the tooltip for this window (may be NULL)
688 wxToolTip
*m_tooltip
;
689 #endif // wxUSE_TOOLTIPS
691 // constraints and sizers
692 #if wxUSE_CONSTRAINTS
693 // the constraints for this window or NULL
694 wxLayoutConstraints
*m_constraints
;
696 // constraints this window is involved in
697 wxWindowList
*m_constraintsInvolvedIn
;
699 // top level and the parent sizers
700 // TODO what's this and how does it work?)
701 wxSizer
*m_windowSizer
;
702 wxWindowBase
*m_sizerParent
;
704 // Layout() window automatically when its size changes?
706 #endif // wxUSE_CONSTRAINTS
711 bool m_isBeingDeleted
:1;
715 wxString m_windowName
;
718 // common part of all ctors: it is not virtual because it is called from
722 // get the default size for the new window if no explicit size given
723 // FIXME why 20 and not 30, 10 or ...?
724 static int WidthDefault(int w
) { return w
== -1 ? 20 : w
; }
725 static int HeightDefault(int h
) { return h
== -1 ? 20 : h
; }
727 // more pure virtual functions
728 // ---------------------------
730 // NB: we must have DoSomething() function when Something() is an overloaded
731 // method: indeed, we can't just have "virtual Something()" in case when
732 // the function is overloaded because then we'd have to make virtual all
733 // the variants (otherwise only the virtual function may be called on a
734 // pointer to derived class according to C++ rules) which is, in
735 // general, absolutely not needed. So instead we implement all
736 // overloaded Something()s in terms of DoSomething() which will be the
737 // only one to be virtual.
739 // coordinates translation
740 virtual void DoClientToScreen( int *x
, int *y
) const = 0;
741 virtual void DoScreenToClient( int *x
, int *y
) const = 0;
743 // retrieve the position/size of the window
744 virtual void DoGetPosition( int *x
, int *y
) const = 0;
745 virtual void DoGetSize( int *width
, int *height
) const = 0;
746 virtual void DoGetClientSize( int *width
, int *height
) const = 0;
748 // this is the virtual function to be overriden in any derived class which
749 // wants to change how SetSize() or Move() works - it is called by all
750 // versions of these functions in the base class
751 virtual void DoSetSize(int x
, int y
,
752 int width
, int height
,
753 int sizeFlags
= wxSIZE_AUTO
) = 0;
755 // same as DoSetSize() for the client size
756 virtual void DoSetClientSize(int width
, int height
) = 0;
759 virtual void DoSetToolTip( wxToolTip
*tip
);
760 #endif // wxUSE_TOOLTIPS
763 // contains the last id generated by NewControlId
764 static int ms_lastControlId
;
766 DECLARE_NO_COPY_CLASS(wxWindowBase
);
767 DECLARE_EVENT_TABLE()
770 // ----------------------------------------------------------------------------
771 // now include the declaration of wxWindow class
772 // ----------------------------------------------------------------------------
774 #if defined(__WXMSW__)
775 #include "wx/msw/window.h"
776 #elif defined(__WXMOTIF__)
777 #include "wx/motif/window.h"
778 #elif defined(__WXGTK__)
779 #include "wx/gtk/window.h"
780 #elif defined(__WXQT__)
781 #include "wx/qt/window.h"
782 #elif defined(__WXMAC__)
783 #include "wx/mac/window.h"
786 // ----------------------------------------------------------------------------
787 // inline functions which couldn't be declared in the class body because of
788 // forward dependencies
789 // ----------------------------------------------------------------------------
791 inline wxWindow
*wxWindowBase::GetGrandParent() const
793 return m_parent
? m_parent
->GetParent() : (wxWindow
*)NULL
;
796 // ----------------------------------------------------------------------------
798 // ----------------------------------------------------------------------------
800 WXDLLEXPORT
extern wxWindow
* wxGetActiveWindow();
801 inline WXDLLEXPORT
int NewControlId() { return wxWindowBase::NewControlId(); }
804 // _WX_WINDOW_H_BASE_