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"
34 #include "wx/validate.h" // defines wxDefaultValidator
35 #endif // wxUSE_VALIDATORS
41 // ----------------------------------------------------------------------------
42 // forward declarations
43 // ----------------------------------------------------------------------------
45 class WXDLLEXPORT wxCaret
;
46 class WXDLLEXPORT wxClientData
;
47 class WXDLLEXPORT wxControl
;
48 class WXDLLEXPORT wxCursor
;
49 class WXDLLEXPORT wxDC
;
50 class WXDLLEXPORT wxDropTarget
;
51 class WXDLLEXPORT wxItemResource
;
52 class WXDLLEXPORT wxLayoutConstraints
;
53 class WXDLLEXPORT wxResourceTable
;
54 class WXDLLEXPORT wxSizer
;
55 class WXDLLEXPORT wxToolTip
;
56 class WXDLLEXPORT wxWindowBase
;
57 class WXDLLEXPORT wxWindow
;
59 // ----------------------------------------------------------------------------
60 // (pseudo)template list classes
61 // ----------------------------------------------------------------------------
63 WX_DECLARE_LIST_3(wxWindow
, wxWindowBase
, wxWindowList
, wxWindowListNode
);
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 WXDLLEXPORT_DATA(extern wxWindowList
) wxTopLevelWindows
;
71 // ----------------------------------------------------------------------------
72 // helper classes used by [SG]etClientObject/Data
74 // TODO move into a separate header?
75 // ----------------------------------------------------------------------------
81 virtual ~wxClientData() { }
84 class wxStringClientData
: public wxClientData
87 wxStringClientData() { }
88 wxStringClientData( const wxString
&data
) : m_data(data
) { }
89 void SetData( const wxString
&data
) { m_data
= data
; }
90 const wxString
& GetData() const { return m_data
; }
96 // ----------------------------------------------------------------------------
97 // wxWindowBase is the base class for all GUI controls/widgets, this is the public
98 // interface of this class.
100 // Event handler: windows have themselves as their event handlers by default,
101 // but their event handlers could be set to another object entirely. This
102 // separation can reduce the amount of derivation required, and allow
103 // alteration of a window's functionality (e.g. by a resource editor that
104 // temporarily switches event handlers).
105 // ----------------------------------------------------------------------------
107 class WXDLLEXPORT wxWindowBase
: public wxEvtHandler
109 DECLARE_ABSTRACT_CLASS(wxWindowBase
);
112 // creating the window
113 // -------------------
116 wxWindowBase() { InitBase(); }
118 // pseudo ctor (can't be virtual, called from ctor)
119 bool CreateBase(wxWindowBase
*parent
,
121 const wxPoint
& pos
= wxDefaultPosition
,
122 const wxSize
& size
= wxDefaultSize
,
125 const wxValidator
& validator
= wxDefaultValidator
,
126 #endif // wxUSE_VALIDATORS
127 const wxString
& name
= wxPanelNameStr
);
129 virtual ~wxWindowBase();
131 #if wxUSE_WX_RESOURCES
132 // these functions are implemented in resource.cpp and resourc2.cpp
133 virtual bool LoadFromResource(wxWindow
*parent
,
134 const wxString
& resourceName
,
135 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
136 virtual wxControl
*CreateItem(const wxItemResource
* childResource
,
137 const wxItemResource
* parentResource
,
138 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
139 #endif // wxUSE_WX_RESOURCES
141 // deleting the window
142 // -------------------
144 // ask the window to close itself, return TRUE if the event handler
145 // honoured our request
146 bool Close( bool force
= FALSE
);
148 // the following functions delete the C++ objects (the window itself
149 // or its children) as well as the GUI windows and normally should
150 // never be used directly
152 // delete window unconditionally (dangerous!), returns TRUE if ok
153 virtual bool Destroy();
154 // delete all children of this window, returns TRUE if ok
155 bool DestroyChildren();
157 // is the window being deleted?
158 bool IsBeingDeleted() const { return m_isBeingDeleted
; }
163 // the title (or label, see below) of the window: the text which the
165 virtual void SetTitle( const wxString
& WXUNUSED(title
) ) { }
166 virtual wxString
GetTitle() const { return ""; }
168 // label is just the same as the title (but for, e.g., buttons it
169 // makes more sense to speak about labels)
170 virtual void SetLabel(const wxString
& label
) { SetTitle(label
); }
171 virtual wxString
GetLabel() const { return GetTitle(); }
173 // the window name is used for ressource setting in X, it is not the
174 // same as the window title/label
175 virtual void SetName( const wxString
&name
) { m_windowName
= name
; }
176 virtual wxString
GetName() const { return m_windowName
; }
178 // window id uniquely identifies the window among its siblings unless
179 // it is -1 which means "don't care"
180 void SetId( wxWindowID id
) { m_windowId
= id
; }
181 wxWindowID
GetId() const { return m_windowId
; }
183 // generate a control id for the controls which were not given one by
185 static int NewControlId() { return --ms_lastControlId
; }
186 // get the id of the control following the one with the given
187 // (autogenerated) id
188 static int NextControlId(int id
) { return id
- 1; }
189 // get the id of the control preceding the one with the given
190 // (autogenerated) id
191 static int PrevControlId(int id
) { return id
+ 1; }
196 // set the window size and/or position
197 void SetSize( int x
, int y
, int width
, int height
,
198 int sizeFlags
= wxSIZE_AUTO
)
199 { DoSetSize(x
, y
, width
, height
, sizeFlags
); }
201 void SetSize( int width
, int height
)
202 { DoSetSize( -1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
204 void SetSize( const wxSize
& size
)
205 { SetSize( size
.x
, size
.y
); }
207 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
208 { DoSetSize(rect
.x
, rect
.y
, rect
.width
, rect
.height
, sizeFlags
); }
210 void Move( int x
, int y
)
211 { DoSetSize( x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
213 void Move(const wxPoint
& pt
)
214 { Move(pt
.x
, pt
.y
); }
217 virtual void Raise() = 0;
218 virtual void Lower() = 0;
220 // client size is the size of area available for subwindows
221 void SetClientSize( int width
, int height
)
222 { DoSetClientSize(width
, height
); }
224 void SetClientSize( const wxSize
& size
)
225 { DoSetClientSize(size
.x
, size
.y
); }
227 void SetClientSize(const wxRect
& rect
)
228 { SetClientSize( rect
.width
, rect
.height
); }
230 // get the window position and/or size (pointers may be NULL)
231 void GetPosition( int *x
, int *y
) const { DoGetPosition(x
, y
); }
232 wxPoint
GetPosition() const
235 DoGetPosition(&w
, &h
);
237 return wxPoint(w
, h
);
240 void GetSize( int *w
, int *h
) const { DoGetSize(w
, h
); }
241 wxSize
GetSize() const
248 wxRect
GetRect() const
251 GetPosition(& x
, & y
);
254 return wxRect(x
, y
, w
, h
);
257 void GetClientSize( int *w
, int *h
) const { DoGetClientSize(w
, h
); }
258 wxSize
GetClientSize() const
261 DoGetClientSize(& w
, & h
);
266 // centre with respect to the the parent window
267 void Centre( int direction
= wxBOTH
);
268 void Center( int direction
= wxBOTH
) { Centre(direction
); }
269 void CentreOnParent( int dir
= wxBOTH
) { Centre(dir
| wxCENTER_FRAME
); }
270 void CenterOnParent( int dir
= wxBOTH
) { Centre(dir
| wxCENTER_FRAME
); }
272 // set window size to wrap around its children
275 // set min/max size of the window
276 virtual void SetSizeHints( int minW
, int minH
,
277 int maxW
= -1, int maxH
= -1,
278 int incW
= -1, int incH
= -1 );
283 // returns TRUE if window was shown/hidden, FALSE if the nothing was
284 // done (window was already shown/hidden)
285 virtual bool Show( bool show
= TRUE
);
286 bool Hide() { return Show(FALSE
); }
288 // returns TRUE if window was enabled/disabled, FALSE if nothing done
289 virtual bool Enable( bool enable
= TRUE
);
290 bool Disable() { return Enable(FALSE
); }
292 bool IsShown() const { return m_isShown
; }
293 bool IsEnabled() const { return m_isEnabled
; }
295 // get/set window style (setting style won't update the window and so
296 // is only useful for internal usage)
297 virtual void SetWindowStyleFlag( long style
) { m_windowStyle
= style
; }
298 virtual long GetWindowStyleFlag() const { return m_windowStyle
; }
300 // just some (somewhat shorter) synonims
301 void SetWindowStyle( long style
) { SetWindowStyleFlag(style
); }
302 long GetWindowStyle() const { return GetWindowStyleFlag(); }
304 bool HasFlag(int flag
) const { return (m_windowStyle
& flag
) != 0; }
306 virtual bool IsRetained() const
307 { return (m_windowStyle
& wxRETAINED
) != 0; }
309 // make the window modal (all other windows unresponsive)
310 virtual void MakeModal(bool modal
= TRUE
);
315 // set focus to this window
316 virtual void SetFocus() = 0;
318 // return the window which currently has the focus or NULL
319 static wxWindow
*FindFocus() /* = 0: implement in derived classes */;
321 // can this window have focus?
322 virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
324 // parent/children relations
325 // -------------------------
327 // get the list of children
328 const wxWindowList
& GetChildren() const { return m_children
; }
329 wxWindowList
& GetChildren() { return m_children
; }
331 // get the parent or the parent of the parent
332 wxWindow
*GetParent() const { return m_parent
; }
333 inline wxWindow
*GetGrandParent() const;
335 // is this window a top level one?
336 bool IsTopLevel() const;
338 // it doesn't really change parent, use ReParent() instead
339 void SetParent( wxWindowBase
*parent
) { m_parent
= (wxWindow
*)parent
; }
340 // change the real parent of this window, return TRUE if the parent
341 // was changed, FALSE otherwise (error or newParent == oldParent)
342 virtual bool Reparent( wxWindowBase
*newParent
);
344 // find window among the descendants of this one either by id or by
345 // name (return NULL if not found)
346 wxWindow
*FindWindow( long id
);
347 wxWindow
*FindWindow( const wxString
& name
);
349 // implementation mostly
350 virtual void AddChild( wxWindowBase
*child
);
351 virtual void RemoveChild( wxWindowBase
*child
);
353 // event handler stuff
354 // -------------------
356 // get the current event handler
357 wxEvtHandler
*GetEventHandler() const { return m_eventHandler
; }
359 // replace the event handler (allows to completely subclass the
361 void SetEventHandler( wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
363 // push/pop event handler: allows to chain a custom event handler to
364 // alreasy existing ones
365 void PushEventHandler( wxEvtHandler
*handler
);
366 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
368 // validators and client data
369 // --------------------------
372 // a window may have an associated validator which is used to control
374 virtual void SetValidator( const wxValidator
&validator
);
375 virtual wxValidator
*GetValidator() { return m_windowValidator
; }
376 #endif // wxUSE_VALIDATORS
378 // each window may have associated client data: either a pointer to
379 // wxClientData object in which case it is managed by the window (i.e.
380 // it will delete the data when it's destroyed) or an untyped pointer
381 // which won't be deleted by the window - but not both of them
382 void SetClientObject( wxClientData
*data
) { DoSetClientObject(data
); }
383 wxClientData
*GetClientObject() const { return DoGetClientObject(); }
385 void SetClientData( void *data
) { DoSetClientData(data
); }
386 void *GetClientData() const { return DoGetClientData(); }
388 // dialog oriented functions
389 // -------------------------
391 // validate the correctness of input, return TRUE if ok
392 virtual bool Validate();
394 // transfer data between internal and GUI representations
395 virtual bool TransferDataToWindow();
396 virtual bool TransferDataFromWindow();
398 virtual void InitDialog();
403 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
)
404 { m_acceleratorTable
= accel
; }
405 wxAcceleratorTable
*GetAcceleratorTable()
406 { return &m_acceleratorTable
; }
407 #endif // wxUSE_ACCEL
409 // dialog units translations
410 // -------------------------
412 wxPoint
ConvertPixelsToDialog( const wxPoint
& pt
);
413 wxPoint
ConvertDialogToPixels( const wxPoint
& pt
);
414 wxSize
ConvertPixelsToDialog( const wxSize
& sz
)
416 wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
)));
418 return wxSize(pt
.x
, pt
.y
);
421 wxSize
ConvertDialogToPixels( const wxSize
& sz
)
423 wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
)));
425 return wxSize(pt
.x
, pt
.y
);
431 // move the mouse to the specified position
432 virtual void WarpPointer(int x
, int y
) = 0;
434 // start or end mouse capture
435 virtual void CaptureMouse() = 0;
436 virtual void ReleaseMouse() = 0;
438 // painting the window
439 // -------------------
441 // mark the specified rectangle (or the whole window) as "dirty" so it
443 virtual void Refresh( bool eraseBackground
= TRUE
,
444 const wxRect
*rect
= (const wxRect
*) NULL
) = 0;
445 // clear the window entirely
446 virtual void Clear() = 0;
448 // adjust DC for drawing on this window
449 virtual void PrepareDC( wxDC
& WXUNUSED(dc
) ) { }
451 // the update region of the window contains the areas which must be
452 // repainted by the program
453 const wxRegion
& GetUpdateRegion() const { return m_updateRegion
; }
454 wxRegion
& GetUpdateRegion() { return m_updateRegion
; }
456 // these functions verify whether the given point/rectangle belongs to
457 // (or at least intersects with) the update region
458 bool IsExposed( int x
, int y
) const;
459 bool IsExposed( int x
, int y
, int w
, int h
) const;
461 bool IsExposed( const wxPoint
& pt
) const
462 { return IsExposed(pt
.x
, pt
.y
); }
463 bool IsExposed( const wxRect
& rect
) const
464 { return IsExposed(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
466 // colours, fonts and cursors
467 // --------------------------
469 // set/retrieve the window colours (system defaults are used by
470 // default): Set functions return TRUE if colour was changed
471 virtual bool SetBackgroundColour( const wxColour
&colour
);
472 virtual bool SetForegroundColour( const wxColour
&colour
);
474 wxColour
GetBackgroundColour() const { return m_backgroundColour
; }
475 wxColour
GetForegroundColour() const { return m_foregroundColour
; }
477 // set/retrieve the cursor for this window (SetCursor() returns TRUE
478 // if the cursor was really changed)
479 virtual bool SetCursor( const wxCursor
&cursor
);
480 const wxCursor
& GetCursor() const { return m_cursor
; }
481 wxCursor
& GetCursor() { return m_cursor
; }
483 // set/retrieve the font for the window (SetFont() returns TRUE if the
484 // font really changed)
485 virtual bool SetFont( const wxFont
&font
) = 0;
486 const wxFont
& GetFont() const { return m_font
; }
487 wxFont
& GetFont() { return m_font
; }
490 // associate a caret with the window
491 void SetCaret(wxCaret
*caret
);
492 // get the current caret (may be NULL)
493 wxCaret
*GetCaret() const { return m_caret
; }
494 #endif // wxUSE_CARET
496 // get the (average) character size for the current font
497 virtual int GetCharHeight() const = 0;
498 virtual int GetCharWidth() const = 0;
500 // get the width/height/... of the text using current or specified
502 virtual void GetTextExtent(const wxString
& string
,
504 int *descent
= (int *) NULL
,
505 int *externalLeading
= (int *) NULL
,
506 const wxFont
*theFont
= (const wxFont
*) NULL
)
509 // translate to/from screen/client coordinates (pointers may be NULL)
510 void ClientToScreen( int *x
, int *y
) const
511 { DoClientToScreen(x
, y
); }
512 void ScreenToClient( int *x
, int *y
) const
513 { DoScreenToClient(x
, y
); }
514 wxPoint
ClientToScreen(const wxPoint
& pt
) const
516 int x
= pt
.x
, y
= pt
.y
;
517 DoClientToScreen(&x
, &y
);
519 return wxPoint(x
, y
);
522 wxPoint
ScreenToClient(const wxPoint
& pt
) const
524 int x
= pt
.x
, y
= pt
.y
;
525 DoScreenToClient(&x
, &y
);
527 return wxPoint(x
, y
);
533 void UpdateWindowUI();
535 bool PopupMenu( wxMenu
*menu
, const wxPoint
& pos
)
536 { return DoPopupMenu(menu
, pos
.x
, pos
.y
); }
537 bool PopupMenu( wxMenu
*menu
, int x
, int y
)
538 { return DoPopupMenu(menu
, x
, y
); }
543 // configure the window scrollbars
544 virtual void SetScrollbar( int orient
,
548 bool refresh
= TRUE
) = 0;
549 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
) = 0;
550 virtual int GetScrollPos( int orient
) const = 0;
551 virtual int GetScrollThumb( int orient
) const = 0;
552 virtual int GetScrollRange( int orient
) const = 0;
554 // scroll window to the specified position
555 virtual void ScrollWindow( int dx
, int dy
,
556 const wxRect
* rect
= (wxRect
*) NULL
) = 0;
561 // the easiest way to set a tooltip for a window is to use this method
562 void SetToolTip( const wxString
&tip
);
563 // attach a tooltip to the window
564 void SetToolTip( wxToolTip
*tip
) { DoSetToolTip(tip
); }
565 // get the associated tooltip or NULL if none
566 wxToolTip
* GetToolTip() const { return m_tooltip
; }
567 #endif // wxUSE_TOOLTIPS
571 #if wxUSE_DRAG_AND_DROP
572 // set/retrieve the drop target associated with this window (may be
573 // NULL; it's owned by the window and will be deleted by it)
574 virtual void SetDropTarget( wxDropTarget
*dropTarget
) = 0;
575 virtual wxDropTarget
*GetDropTarget() const { return m_dropTarget
; }
576 #endif // wxUSE_DRAG_AND_DROP
578 // constraints and sizers
579 // ----------------------
580 #if wxUSE_CONSTRAINTS
581 // set the constraints for this window or retrieve them (may be NULL)
582 void SetConstraints( wxLayoutConstraints
*constraints
);
583 wxLayoutConstraints
*GetConstraints() const { return m_constraints
; }
585 // when using constraints, it makes sense to update children positions
586 // automatically whenever the window is resized - this is done if
588 void SetAutoLayout( bool autoLayout
) { m_autoLayout
= autoLayout
; }
589 bool GetAutoLayout() const { return m_autoLayout
; }
591 // do layout the window and its children
592 virtual bool Layout();
594 // implementation only
595 void UnsetConstraints(wxLayoutConstraints
*c
);
596 wxWindowList
*GetConstraintsInvolvedIn() const
597 { return m_constraintsInvolvedIn
; }
598 void AddConstraintReference(wxWindowBase
*otherWin
);
599 void RemoveConstraintReference(wxWindowBase
*otherWin
);
600 void DeleteRelatedConstraints();
601 void ResetConstraints();
603 // these methods may be overriden for special layout algorithms
604 virtual void SetConstraintSizes(bool recurse
= TRUE
);
605 virtual bool LayoutPhase1(int *noChanges
);
606 virtual bool LayoutPhase2(int *noChanges
);
607 virtual bool DoPhase(int);
609 // these methods are virtual but normally won't be overridden
610 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
611 virtual void MoveConstraint(int x
, int y
);
612 virtual void GetSizeConstraint(int *w
, int *h
) const ;
613 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
614 virtual void GetPositionConstraint(int *x
, int *y
) const ;
617 // TODO: what are they and how do they work??
618 void SetSizer( wxSizer
*sizer
);
619 wxSizer
*GetSizer() const { return m_windowSizer
; }
620 #endif // wxUSE_CONSTRAINTS
622 // backward compatibility
623 // ----------------------
624 #if WXWIN_COMPATIBILITY
625 bool Enabled() const { return IsEnabled(); }
627 void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
628 void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
629 wxFont
& GetLabelFont() { return GetFont(); };
630 wxFont
& GetButtonFont() { return GetFont(); };
631 #endif // WXWIN_COMPATIBILITY
637 void OnSysColourChanged( wxSysColourChangedEvent
& event
);
638 void OnInitDialog( wxInitDialogEvent
&event
);
640 // get the haqndle of the window for the underlying window system: this
641 // is only used for wxWin itself or for user code which wants to call
642 // platform-specific APIs
643 virtual WXWidget
GetHandle() const = 0;
646 // the window id - a number which uniquely identifies a window among
647 // its siblings unless it is -1
648 wxWindowID m_windowId
;
650 // the parent window of this window (or NULL) and the list of the children
653 wxWindowList m_children
;
655 // the minimal allowed size for the window (no minimal size if variable(s)
657 int m_minWidth
, m_minHeight
, m_maxWidth
, m_maxHeight
;
659 // event handler for this window: usually is just 'this' but may be
660 // changed with SetEventHandler()
661 wxEvtHandler
*m_eventHandler
;
664 // associated validator or NULL if none
665 wxValidator
*m_windowValidator
;
666 #endif // wxUSE_VALIDATORS
668 #if wxUSE_DRAG_AND_DROP
669 wxDropTarget
*m_dropTarget
;
670 #endif // wxUSE_DRAG_AND_DROP
672 // visual window attributes
675 wxColour m_backgroundColour
, m_foregroundColour
;
679 #endif // wxUSE_CARET
681 // the region which should be repainted in response to paint event
682 wxRegion m_updateRegion
;
685 // the accelerator table for the window which translates key strokes into
687 wxAcceleratorTable m_acceleratorTable
;
688 #endif // wxUSE_ACCEL
690 // user data associated with the window: either an object which will be
691 // deleted by the window when it's deleted or some raw pointer which we do
692 // nothing with - only one type of data can be used with the given window
693 // (i.e. you cannot set the void data and then associate the window with
694 // wxClientData or vice versa)
697 wxClientData
*m_clientObject
;
701 // the tooltip for this window (may be NULL)
703 wxToolTip
*m_tooltip
;
704 #endif // wxUSE_TOOLTIPS
706 // constraints and sizers
707 #if wxUSE_CONSTRAINTS
708 // the constraints for this window or NULL
709 wxLayoutConstraints
*m_constraints
;
711 // constraints this window is involved in
712 wxWindowList
*m_constraintsInvolvedIn
;
714 // top level and the parent sizers
715 // TODO what's this and how does it work?)
716 wxSizer
*m_windowSizer
;
717 wxWindowBase
*m_sizerParent
;
719 // Layout() window automatically when its size changes?
721 #endif // wxUSE_CONSTRAINTS
726 bool m_isBeingDeleted
:1;
730 wxString m_windowName
;
733 // common part of all ctors: it is not virtual because it is called from
737 // get the default size for the new window if no explicit size given
738 // FIXME why 20 and not 30, 10 or ...?
739 static int WidthDefault(int w
) { return w
== -1 ? 20 : w
; }
740 static int HeightDefault(int h
) { return h
== -1 ? 20 : h
; }
742 // more pure virtual functions
743 // ---------------------------
745 // NB: we must have DoSomething() function when Something() is an overloaded
746 // method: indeed, we can't just have "virtual Something()" in case when
747 // the function is overloaded because then we'd have to make virtual all
748 // the variants (otherwise only the virtual function may be called on a
749 // pointer to derived class according to C++ rules) which is, in
750 // general, absolutely not needed. So instead we implement all
751 // overloaded Something()s in terms of DoSomething() which will be the
752 // only one to be virtual.
754 // coordinates translation
755 virtual void DoClientToScreen( int *x
, int *y
) const = 0;
756 virtual void DoScreenToClient( int *x
, int *y
) const = 0;
758 // retrieve the position/size of the window
759 virtual void DoGetPosition( int *x
, int *y
) const = 0;
760 virtual void DoGetSize( int *width
, int *height
) const = 0;
761 virtual void DoGetClientSize( int *width
, int *height
) const = 0;
763 // this is the virtual function to be overriden in any derived class which
764 // wants to change how SetSize() or Move() works - it is called by all
765 // versions of these functions in the base class
766 virtual void DoSetSize(int x
, int y
,
767 int width
, int height
,
768 int sizeFlags
= wxSIZE_AUTO
) = 0;
770 // same as DoSetSize() for the client size
771 virtual void DoSetClientSize(int width
, int height
) = 0;
774 virtual void DoSetToolTip( wxToolTip
*tip
);
775 #endif // wxUSE_TOOLTIPS
777 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
) = 0;
779 // client data accessors
780 virtual void DoSetClientObject( wxClientData
*data
);
781 virtual wxClientData
*DoGetClientObject() const;
783 virtual void DoSetClientData( void *data
);
784 virtual void *DoGetClientData() const;
786 // what kind of data do we have?
787 enum wxClientDataType
789 ClientData_None
, // we don't know yet because we don't have it at all
790 ClientData_Object
, // our client data is typed and we own it
791 ClientData_Void
// client data is untyped and we don't own it
795 // contains the last id generated by NewControlId
796 static int ms_lastControlId
;
798 DECLARE_NO_COPY_CLASS(wxWindowBase
);
799 DECLARE_EVENT_TABLE()
802 // ----------------------------------------------------------------------------
803 // now include the declaration of wxWindow class
804 // ----------------------------------------------------------------------------
806 #if defined(__WXMSW__)
807 #include "wx/msw/window.h"
808 #elif defined(__WXMOTIF__)
809 #include "wx/motif/window.h"
810 #elif defined(__WXGTK__)
811 #include "wx/gtk/window.h"
812 #elif defined(__WXQT__)
813 #include "wx/qt/window.h"
814 #elif defined(__WXMAC__)
815 #include "wx/mac/window.h"
816 #elif defined(__WXPM__)
817 #include "wx/os2/window.h"
820 // ----------------------------------------------------------------------------
821 // inline functions which couldn't be declared in the class body because of
822 // forward dependencies
823 // ----------------------------------------------------------------------------
825 inline wxWindow
*wxWindowBase::GetGrandParent() const
827 return m_parent
? m_parent
->GetParent() : (wxWindow
*)NULL
;
830 // ----------------------------------------------------------------------------
832 // ----------------------------------------------------------------------------
834 WXDLLEXPORT
extern wxWindow
* wxGetActiveWindow();
835 inline WXDLLEXPORT
int NewControlId() { return wxWindowBase::NewControlId(); }
838 // _WX_WINDOW_H_BASE_