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 );
280 int GetMinWidth() const { return m_minWidth
; }
281 int GetMinHeight() const { return m_minHeight
; }
282 int GetMaxWidth() const { return m_maxWidth
; }
283 int GetMaxHeight() const { return m_maxHeight
; }
288 // returns TRUE if window was shown/hidden, FALSE if the nothing was
289 // done (window was already shown/hidden)
290 virtual bool Show( bool show
= TRUE
);
291 bool Hide() { return Show(FALSE
); }
293 // returns TRUE if window was enabled/disabled, FALSE if nothing done
294 virtual bool Enable( bool enable
= TRUE
);
295 bool Disable() { return Enable(FALSE
); }
297 bool IsShown() const { return m_isShown
; }
298 bool IsEnabled() const { return m_isEnabled
; }
300 // get/set window style (setting style won't update the window and so
301 // is only useful for internal usage)
302 virtual void SetWindowStyleFlag( long style
) { m_windowStyle
= style
; }
303 virtual long GetWindowStyleFlag() const { return m_windowStyle
; }
305 // just some (somewhat shorter) synonims
306 void SetWindowStyle( long style
) { SetWindowStyleFlag(style
); }
307 long GetWindowStyle() const { return GetWindowStyleFlag(); }
309 bool HasFlag(int flag
) const { return (m_windowStyle
& flag
) != 0; }
311 virtual bool IsRetained() const
312 { return (m_windowStyle
& wxRETAINED
) != 0; }
314 // make the window modal (all other windows unresponsive)
315 virtual void MakeModal(bool modal
= TRUE
);
320 // set focus to this window
321 virtual void SetFocus() = 0;
323 // return the window which currently has the focus or NULL
324 static wxWindow
*FindFocus() /* = 0: implement in derived classes */;
326 // can this window have focus?
327 virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
329 // parent/children relations
330 // -------------------------
332 // get the list of children
333 const wxWindowList
& GetChildren() const { return m_children
; }
334 wxWindowList
& GetChildren() { return m_children
; }
336 // get the parent or the parent of the parent
337 wxWindow
*GetParent() const { return m_parent
; }
338 inline wxWindow
*GetGrandParent() const;
340 // is this window a top level one?
341 bool IsTopLevel() const;
343 // it doesn't really change parent, use ReParent() instead
344 void SetParent( wxWindowBase
*parent
) { m_parent
= (wxWindow
*)parent
; }
345 // change the real parent of this window, return TRUE if the parent
346 // was changed, FALSE otherwise (error or newParent == oldParent)
347 virtual bool Reparent( wxWindowBase
*newParent
);
349 // find window among the descendants of this one either by id or by
350 // name (return NULL if not found)
351 wxWindow
*FindWindow( long id
);
352 wxWindow
*FindWindow( const wxString
& name
);
354 // implementation mostly
355 virtual void AddChild( wxWindowBase
*child
);
356 virtual void RemoveChild( wxWindowBase
*child
);
358 // event handler stuff
359 // -------------------
361 // get the current event handler
362 wxEvtHandler
*GetEventHandler() const { return m_eventHandler
; }
364 // replace the event handler (allows to completely subclass the
366 void SetEventHandler( wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
368 // push/pop event handler: allows to chain a custom event handler to
369 // alreasy existing ones
370 void PushEventHandler( wxEvtHandler
*handler
);
371 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
373 // validators and client data
374 // --------------------------
377 // a window may have an associated validator which is used to control
379 virtual void SetValidator( const wxValidator
&validator
);
380 virtual wxValidator
*GetValidator() { return m_windowValidator
; }
381 #endif // wxUSE_VALIDATORS
383 // each window may have associated client data: either a pointer to
384 // wxClientData object in which case it is managed by the window (i.e.
385 // it will delete the data when it's destroyed) or an untyped pointer
386 // which won't be deleted by the window - but not both of them
387 void SetClientObject( wxClientData
*data
) { DoSetClientObject(data
); }
388 wxClientData
*GetClientObject() const { return DoGetClientObject(); }
390 void SetClientData( void *data
) { DoSetClientData(data
); }
391 void *GetClientData() const { return DoGetClientData(); }
393 // dialog oriented functions
394 // -------------------------
396 // validate the correctness of input, return TRUE if ok
397 virtual bool Validate();
399 // transfer data between internal and GUI representations
400 virtual bool TransferDataToWindow();
401 virtual bool TransferDataFromWindow();
403 virtual void InitDialog();
408 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
)
409 { m_acceleratorTable
= accel
; }
410 wxAcceleratorTable
*GetAcceleratorTable()
411 { return &m_acceleratorTable
; }
412 #endif // wxUSE_ACCEL
414 // dialog units translations
415 // -------------------------
417 wxPoint
ConvertPixelsToDialog( const wxPoint
& pt
);
418 wxPoint
ConvertDialogToPixels( const wxPoint
& pt
);
419 wxSize
ConvertPixelsToDialog( const wxSize
& sz
)
421 wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
)));
423 return wxSize(pt
.x
, pt
.y
);
426 wxSize
ConvertDialogToPixels( const wxSize
& sz
)
428 wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
)));
430 return wxSize(pt
.x
, pt
.y
);
436 // move the mouse to the specified position
437 virtual void WarpPointer(int x
, int y
) = 0;
439 // start or end mouse capture
440 virtual void CaptureMouse() = 0;
441 virtual void ReleaseMouse() = 0;
443 // painting the window
444 // -------------------
446 // mark the specified rectangle (or the whole window) as "dirty" so it
448 virtual void Refresh( bool eraseBackground
= TRUE
,
449 const wxRect
*rect
= (const wxRect
*) NULL
) = 0;
450 // clear the window entirely
451 virtual void Clear() = 0;
453 // adjust DC for drawing on this window
454 virtual void PrepareDC( wxDC
& WXUNUSED(dc
) ) { }
456 // the update region of the window contains the areas which must be
457 // repainted by the program
458 const wxRegion
& GetUpdateRegion() const { return m_updateRegion
; }
459 wxRegion
& GetUpdateRegion() { return m_updateRegion
; }
461 // these functions verify whether the given point/rectangle belongs to
462 // (or at least intersects with) the update region
463 bool IsExposed( int x
, int y
) const;
464 bool IsExposed( int x
, int y
, int w
, int h
) const;
466 bool IsExposed( const wxPoint
& pt
) const
467 { return IsExposed(pt
.x
, pt
.y
); }
468 bool IsExposed( const wxRect
& rect
) const
469 { return IsExposed(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
471 // colours, fonts and cursors
472 // --------------------------
474 // set/retrieve the window colours (system defaults are used by
475 // default): Set functions return TRUE if colour was changed
476 virtual bool SetBackgroundColour( const wxColour
&colour
);
477 virtual bool SetForegroundColour( const wxColour
&colour
);
479 wxColour
GetBackgroundColour() const { return m_backgroundColour
; }
480 wxColour
GetForegroundColour() const { return m_foregroundColour
; }
482 // set/retrieve the cursor for this window (SetCursor() returns TRUE
483 // if the cursor was really changed)
484 virtual bool SetCursor( const wxCursor
&cursor
);
485 const wxCursor
& GetCursor() const { return m_cursor
; }
486 wxCursor
& GetCursor() { return m_cursor
; }
488 // set/retrieve the font for the window (SetFont() returns TRUE if the
489 // font really changed)
490 virtual bool SetFont( const wxFont
&font
) = 0;
491 const wxFont
& GetFont() const { return m_font
; }
492 wxFont
& GetFont() { return m_font
; }
495 // associate a caret with the window
496 void SetCaret(wxCaret
*caret
);
497 // get the current caret (may be NULL)
498 wxCaret
*GetCaret() const { return m_caret
; }
499 #endif // wxUSE_CARET
501 // get the (average) character size for the current font
502 virtual int GetCharHeight() const = 0;
503 virtual int GetCharWidth() const = 0;
505 // get the width/height/... of the text using current or specified
507 virtual void GetTextExtent(const wxString
& string
,
509 int *descent
= (int *) NULL
,
510 int *externalLeading
= (int *) NULL
,
511 const wxFont
*theFont
= (const wxFont
*) NULL
)
514 // translate to/from screen/client coordinates (pointers may be NULL)
515 void ClientToScreen( int *x
, int *y
) const
516 { DoClientToScreen(x
, y
); }
517 void ScreenToClient( int *x
, int *y
) const
518 { DoScreenToClient(x
, y
); }
519 wxPoint
ClientToScreen(const wxPoint
& pt
) const
521 int x
= pt
.x
, y
= pt
.y
;
522 DoClientToScreen(&x
, &y
);
524 return wxPoint(x
, y
);
527 wxPoint
ScreenToClient(const wxPoint
& pt
) const
529 int x
= pt
.x
, y
= pt
.y
;
530 DoScreenToClient(&x
, &y
);
532 return wxPoint(x
, y
);
538 void UpdateWindowUI();
540 bool PopupMenu( wxMenu
*menu
, const wxPoint
& pos
)
541 { return DoPopupMenu(menu
, pos
.x
, pos
.y
); }
542 bool PopupMenu( wxMenu
*menu
, int x
, int y
)
543 { return DoPopupMenu(menu
, x
, y
); }
548 // configure the window scrollbars
549 virtual void SetScrollbar( int orient
,
553 bool refresh
= TRUE
) = 0;
554 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
) = 0;
555 virtual int GetScrollPos( int orient
) const = 0;
556 virtual int GetScrollThumb( int orient
) const = 0;
557 virtual int GetScrollRange( int orient
) const = 0;
559 // scroll window to the specified position
560 virtual void ScrollWindow( int dx
, int dy
,
561 const wxRect
* rect
= (wxRect
*) NULL
) = 0;
566 // the easiest way to set a tooltip for a window is to use this method
567 void SetToolTip( const wxString
&tip
);
568 // attach a tooltip to the window
569 void SetToolTip( wxToolTip
*tip
) { DoSetToolTip(tip
); }
570 // get the associated tooltip or NULL if none
571 wxToolTip
* GetToolTip() const { return m_tooltip
; }
572 #endif // wxUSE_TOOLTIPS
576 #if wxUSE_DRAG_AND_DROP
577 // set/retrieve the drop target associated with this window (may be
578 // NULL; it's owned by the window and will be deleted by it)
579 virtual void SetDropTarget( wxDropTarget
*dropTarget
) = 0;
580 virtual wxDropTarget
*GetDropTarget() const { return m_dropTarget
; }
581 #endif // wxUSE_DRAG_AND_DROP
583 // constraints and sizers
584 // ----------------------
585 #if wxUSE_CONSTRAINTS
586 // set the constraints for this window or retrieve them (may be NULL)
587 void SetConstraints( wxLayoutConstraints
*constraints
);
588 wxLayoutConstraints
*GetConstraints() const { return m_constraints
; }
590 // when using constraints, it makes sense to update children positions
591 // automatically whenever the window is resized - this is done if
593 void SetAutoLayout( bool autoLayout
) { m_autoLayout
= autoLayout
; }
594 bool GetAutoLayout() const { return m_autoLayout
; }
596 // do layout the window and its children
597 virtual bool Layout();
599 // implementation only
600 void UnsetConstraints(wxLayoutConstraints
*c
);
601 wxWindowList
*GetConstraintsInvolvedIn() const
602 { return m_constraintsInvolvedIn
; }
603 void AddConstraintReference(wxWindowBase
*otherWin
);
604 void RemoveConstraintReference(wxWindowBase
*otherWin
);
605 void DeleteRelatedConstraints();
606 void ResetConstraints();
608 // these methods may be overriden for special layout algorithms
609 virtual void SetConstraintSizes(bool recurse
= TRUE
);
610 virtual bool LayoutPhase1(int *noChanges
);
611 virtual bool LayoutPhase2(int *noChanges
);
612 virtual bool DoPhase(int);
614 // these methods are virtual but normally won't be overridden
615 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
616 virtual void MoveConstraint(int x
, int y
);
617 virtual void GetSizeConstraint(int *w
, int *h
) const ;
618 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
619 virtual void GetPositionConstraint(int *x
, int *y
) const ;
622 // TODO: what are they and how do they work??
623 void SetSizer( wxSizer
*sizer
);
624 wxSizer
*GetSizer() const { return m_windowSizer
; }
625 #endif // wxUSE_CONSTRAINTS
627 // backward compatibility
628 // ----------------------
629 #if WXWIN_COMPATIBILITY
630 bool Enabled() const { return IsEnabled(); }
632 void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
633 void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
634 wxFont
& GetLabelFont() { return GetFont(); };
635 wxFont
& GetButtonFont() { return GetFont(); };
636 #endif // WXWIN_COMPATIBILITY
642 void OnSysColourChanged( wxSysColourChangedEvent
& event
);
643 void OnInitDialog( wxInitDialogEvent
&event
);
645 // get the haqndle of the window for the underlying window system: this
646 // is only used for wxWin itself or for user code which wants to call
647 // platform-specific APIs
648 virtual WXWidget
GetHandle() const = 0;
651 // the window id - a number which uniquely identifies a window among
652 // its siblings unless it is -1
653 wxWindowID m_windowId
;
655 // the parent window of this window (or NULL) and the list of the children
658 wxWindowList m_children
;
660 // the minimal allowed size for the window (no minimal size if variable(s)
662 int m_minWidth
, m_minHeight
, m_maxWidth
, m_maxHeight
;
664 // event handler for this window: usually is just 'this' but may be
665 // changed with SetEventHandler()
666 wxEvtHandler
*m_eventHandler
;
669 // associated validator or NULL if none
670 wxValidator
*m_windowValidator
;
671 #endif // wxUSE_VALIDATORS
673 #if wxUSE_DRAG_AND_DROP
674 wxDropTarget
*m_dropTarget
;
675 #endif // wxUSE_DRAG_AND_DROP
677 // visual window attributes
680 wxColour m_backgroundColour
, m_foregroundColour
;
684 #endif // wxUSE_CARET
686 // the region which should be repainted in response to paint event
687 wxRegion m_updateRegion
;
690 // the accelerator table for the window which translates key strokes into
692 wxAcceleratorTable m_acceleratorTable
;
693 #endif // wxUSE_ACCEL
695 // user data associated with the window: either an object which will be
696 // deleted by the window when it's deleted or some raw pointer which we do
697 // nothing with - only one type of data can be used with the given window
698 // (i.e. you cannot set the void data and then associate the window with
699 // wxClientData or vice versa)
702 wxClientData
*m_clientObject
;
706 // the tooltip for this window (may be NULL)
708 wxToolTip
*m_tooltip
;
709 #endif // wxUSE_TOOLTIPS
711 // constraints and sizers
712 #if wxUSE_CONSTRAINTS
713 // the constraints for this window or NULL
714 wxLayoutConstraints
*m_constraints
;
716 // constraints this window is involved in
717 wxWindowList
*m_constraintsInvolvedIn
;
719 // top level and the parent sizers
720 // TODO what's this and how does it work?)
721 wxSizer
*m_windowSizer
;
722 wxWindowBase
*m_sizerParent
;
724 // Layout() window automatically when its size changes?
726 #endif // wxUSE_CONSTRAINTS
731 bool m_isBeingDeleted
:1;
735 wxString m_windowName
;
738 // common part of all ctors: it is not virtual because it is called from
742 // get the default size for the new window if no explicit size given
743 // FIXME why 20 and not 30, 10 or ...?
744 static int WidthDefault(int w
) { return w
== -1 ? 20 : w
; }
745 static int HeightDefault(int h
) { return h
== -1 ? 20 : h
; }
747 // more pure virtual functions
748 // ---------------------------
750 // NB: we must have DoSomething() function when Something() is an overloaded
751 // method: indeed, we can't just have "virtual Something()" in case when
752 // the function is overloaded because then we'd have to make virtual all
753 // the variants (otherwise only the virtual function may be called on a
754 // pointer to derived class according to C++ rules) which is, in
755 // general, absolutely not needed. So instead we implement all
756 // overloaded Something()s in terms of DoSomething() which will be the
757 // only one to be virtual.
759 // coordinates translation
760 virtual void DoClientToScreen( int *x
, int *y
) const = 0;
761 virtual void DoScreenToClient( int *x
, int *y
) const = 0;
763 // retrieve the position/size of the window
764 virtual void DoGetPosition( int *x
, int *y
) const = 0;
765 virtual void DoGetSize( int *width
, int *height
) const = 0;
766 virtual void DoGetClientSize( int *width
, int *height
) const = 0;
768 // this is the virtual function to be overriden in any derived class which
769 // wants to change how SetSize() or Move() works - it is called by all
770 // versions of these functions in the base class
771 virtual void DoSetSize(int x
, int y
,
772 int width
, int height
,
773 int sizeFlags
= wxSIZE_AUTO
) = 0;
775 // same as DoSetSize() for the client size
776 virtual void DoSetClientSize(int width
, int height
) = 0;
779 virtual void DoSetToolTip( wxToolTip
*tip
);
780 #endif // wxUSE_TOOLTIPS
782 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
) = 0;
784 // client data accessors
785 virtual void DoSetClientObject( wxClientData
*data
);
786 virtual wxClientData
*DoGetClientObject() const;
788 virtual void DoSetClientData( void *data
);
789 virtual void *DoGetClientData() const;
791 // what kind of data do we have?
792 enum wxClientDataType
794 ClientData_None
, // we don't know yet because we don't have it at all
795 ClientData_Object
, // our client data is typed and we own it
796 ClientData_Void
// client data is untyped and we don't own it
800 // contains the last id generated by NewControlId
801 static int ms_lastControlId
;
803 DECLARE_NO_COPY_CLASS(wxWindowBase
);
804 DECLARE_EVENT_TABLE()
807 // ----------------------------------------------------------------------------
808 // now include the declaration of wxWindow class
809 // ----------------------------------------------------------------------------
811 #if defined(__WXMSW__)
812 #include "wx/msw/window.h"
813 #elif defined(__WXMOTIF__)
814 #include "wx/motif/window.h"
815 #elif defined(__WXGTK__)
816 #include "wx/gtk/window.h"
817 #elif defined(__WXQT__)
818 #include "wx/qt/window.h"
819 #elif defined(__WXMAC__)
820 #include "wx/mac/window.h"
821 #elif defined(__WXPM__)
822 #include "wx/os2/window.h"
825 // ----------------------------------------------------------------------------
826 // inline functions which couldn't be declared in the class body because of
827 // forward dependencies
828 // ----------------------------------------------------------------------------
830 inline wxWindow
*wxWindowBase::GetGrandParent() const
832 return m_parent
? m_parent
->GetParent() : (wxWindow
*)NULL
;
835 // ----------------------------------------------------------------------------
837 // ----------------------------------------------------------------------------
839 WXDLLEXPORT
extern wxWindow
* wxGetActiveWindow();
840 inline WXDLLEXPORT
int NewControlId() { return wxWindowBase::NewControlId(); }
843 // _WX_WINDOW_H_BASE_