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 #include "wx/validate.h" // defines wxDefaultValidator
34 #endif // wxUSE_VALIDATORS
40 // ----------------------------------------------------------------------------
41 // forward declarations
42 // ----------------------------------------------------------------------------
44 class WXDLLEXPORT wxCaret
;
45 class WXDLLEXPORT wxClientData
;
46 class WXDLLEXPORT wxControl
;
47 class WXDLLEXPORT wxCursor
;
48 class WXDLLEXPORT wxDC
;
49 class WXDLLEXPORT wxDropTarget
;
50 class WXDLLEXPORT wxItemResource
;
51 class WXDLLEXPORT wxLayoutConstraints
;
52 class WXDLLEXPORT wxResourceTable
;
53 class WXDLLEXPORT wxSizer
;
54 class WXDLLEXPORT wxToolTip
;
55 class WXDLLEXPORT wxWindowBase
;
56 class WXDLLEXPORT wxWindow
;
58 // ----------------------------------------------------------------------------
59 // (pseudo)template list classes
60 // ----------------------------------------------------------------------------
62 WX_DECLARE_LIST_3(wxWindow
, wxWindowBase
, wxWindowList
, wxWindowListNode
);
64 // ----------------------------------------------------------------------------
66 // ----------------------------------------------------------------------------
68 WXDLLEXPORT_DATA(extern wxWindowList
) wxTopLevelWindows
;
70 // ----------------------------------------------------------------------------
71 // helper classes used by [SG]etClientObject/Data
73 // TODO move into a separate header?
74 // ----------------------------------------------------------------------------
80 virtual ~wxClientData() { }
83 class wxStringClientData
: public wxClientData
86 wxStringClientData() { }
87 wxStringClientData( const wxString
&data
) : m_data(data
) { }
88 void SetData( const wxString
&data
) { m_data
= data
; }
89 const wxString
& GetData() const { return m_data
; }
95 // ----------------------------------------------------------------------------
96 // wxWindowBase is the base class for all GUI controls/widgets, this is the public
97 // interface of this class.
99 // Event handler: windows have themselves as their event handlers by default,
100 // but their event handlers could be set to another object entirely. This
101 // separation can reduce the amount of derivation required, and allow
102 // alteration of a window's functionality (e.g. by a resource editor that
103 // temporarily switches event handlers).
104 // ----------------------------------------------------------------------------
106 class WXDLLEXPORT wxWindowBase
: public wxEvtHandler
108 DECLARE_ABSTRACT_CLASS(wxWindowBase
);
111 // creating the window
112 // -------------------
115 wxWindowBase() { InitBase(); }
117 // pseudo ctor (can't be virtual, called from ctor)
118 bool CreateBase(wxWindowBase
*parent
,
120 const wxPoint
& pos
= wxDefaultPosition
,
121 const wxSize
& size
= wxDefaultSize
,
124 const wxValidator
& validator
= wxDefaultValidator
,
125 #endif // wxUSE_VALIDATORS
126 const wxString
& name
= wxPanelNameStr
);
128 virtual ~wxWindowBase();
130 #if wxUSE_WX_RESOURCES
131 // these functions are implemented in resource.cpp and resourc2.cpp
132 virtual bool LoadFromResource(wxWindow
*parent
,
133 const wxString
& resourceName
,
134 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
135 virtual wxControl
*CreateItem(const wxItemResource
* childResource
,
136 const wxItemResource
* parentResource
,
137 const wxResourceTable
*table
= (const wxResourceTable
*) NULL
);
138 #endif // wxUSE_WX_RESOURCES
140 // deleting the window
141 // -------------------
143 // ask the window to close itself, return TRUE if the event handler
144 // honoured our request
145 bool Close( bool force
= FALSE
);
147 // the following functions delete the C++ objects (the window itself
148 // or its children) as well as the GUI windows and normally should
149 // never be used directly
151 // delete window unconditionally (dangerous!), returns TRUE if ok
152 virtual bool Destroy();
153 // delete all children of this window, returns TRUE if ok
154 bool DestroyChildren();
156 // is the window being deleted?
157 bool IsBeingDeleted() const { return m_isBeingDeleted
; }
162 // the title (or label, see below) of the window: the text which the
164 virtual void SetTitle( const wxString
& WXUNUSED(title
) ) { }
165 virtual wxString
GetTitle() const { return ""; }
167 // label is just the same as the title (but for, e.g., buttons it
168 // makes more sense to speak about labels)
169 virtual void SetLabel(const wxString
& label
) { SetTitle(label
); }
170 virtual wxString
GetLabel() const { return GetTitle(); }
172 // the window name is used for ressource setting in X, it is not the
173 // same as the window title/label
174 virtual void SetName( const wxString
&name
) { m_windowName
= name
; }
175 virtual wxString
GetName() const { return m_windowName
; }
177 // window id uniquely identifies the window among its siblings unless
178 // it is -1 which means "don't care"
179 void SetId( wxWindowID id
) { m_windowId
= id
; }
180 wxWindowID
GetId() const { return m_windowId
; }
182 // generate a control id for the controls which were not given one by
184 static int NewControlId() { return --ms_lastControlId
; }
185 // get the id of the control following the one with the given
186 // (autogenerated) id
187 static int NextControlId(int id
) { return id
- 1; }
188 // get the id of the control preceding the one with the given
189 // (autogenerated) id
190 static int PrevControlId(int id
) { return id
+ 1; }
195 // set the window size and/or position
196 void SetSize( int x
, int y
, int width
, int height
,
197 int sizeFlags
= wxSIZE_AUTO
)
198 { DoSetSize(x
, y
, width
, height
, sizeFlags
); }
200 void SetSize( int width
, int height
)
201 { DoSetSize( -1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
203 void SetSize( const wxSize
& size
)
204 { SetSize( size
.x
, size
.y
); }
206 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
207 { DoSetSize(rect
.x
, rect
.y
, rect
.width
, rect
.height
, sizeFlags
); }
209 void Move( int x
, int y
)
210 { DoSetSize( x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
212 void Move(const wxPoint
& pt
)
213 { Move(pt
.x
, pt
.y
); }
216 virtual void Raise() = 0;
217 virtual void Lower() = 0;
219 // client size is the size of area available for subwindows
220 void SetClientSize( int width
, int height
)
221 { DoSetClientSize(width
, height
); }
223 void SetClientSize( const wxSize
& size
)
224 { DoSetClientSize(size
.x
, size
.y
); }
226 void SetClientSize(const wxRect
& rect
)
227 { SetClientSize( rect
.width
, rect
.height
); }
229 // get the window position and/or size (pointers may be NULL)
230 void GetPosition( int *x
, int *y
) const { DoGetPosition(x
, y
); }
231 wxPoint
GetPosition() const
234 DoGetPosition(&w
, &h
);
236 return wxPoint(w
, h
);
239 void GetSize( int *w
, int *h
) const { DoGetSize(w
, h
); }
240 wxSize
GetSize() const
247 wxRect
GetRect() const
250 GetPosition(& x
, & y
);
253 return wxRect(x
, y
, w
, h
);
256 void GetClientSize( int *w
, int *h
) const { DoGetClientSize(w
, h
); }
257 wxSize
GetClientSize() const
260 DoGetClientSize(& w
, & h
);
265 // centre with respect to the the parent window
266 void Centre( int direction
= wxBOTH
);
267 void Center( int direction
= wxBOTH
) { Centre(direction
); }
268 void CentreOnParent( int dir
= wxBOTH
) { Centre(dir
| wxCENTER_FRAME
); }
269 void CenterOnParent( int dir
= wxBOTH
) { Centre(dir
| wxCENTER_FRAME
); }
271 // set window size to wrap around its children
274 // set min/max size of the window
275 virtual void SetSizeHints( int minW
, int minH
,
276 int maxW
= -1, int maxH
= -1,
277 int incW
= -1, int incH
= -1 );
282 // returns TRUE if window was shown/hidden, FALSE if the nothing was
283 // done (window was already shown/hidden)
284 virtual bool Show( bool show
= TRUE
);
285 bool Hide() { return Show(FALSE
); }
287 // returns TRUE if window was enabled/disabled, FALSE if nothing done
288 virtual bool Enable( bool enable
= TRUE
);
289 bool Disable() { return Enable(FALSE
); }
291 bool IsShown() const { return m_isShown
; }
292 bool IsEnabled() const { return m_isEnabled
; }
294 // get/set window style (setting style won't update the window and so
295 // is only useful for internal usage)
296 virtual void SetWindowStyleFlag( long style
) { m_windowStyle
= style
; }
297 virtual long GetWindowStyleFlag() const { return m_windowStyle
; }
299 // just some (somewhat shorter) synonims
300 void SetWindowStyle( long style
) { SetWindowStyleFlag(style
); }
301 long GetWindowStyle() const { return GetWindowStyleFlag(); }
303 bool HasFlag(int flag
) const { return (m_windowStyle
& flag
) != 0; }
305 virtual bool IsRetained() const
306 { return (m_windowStyle
& wxRETAINED
) != 0; }
308 // make the window modal (all other windows unresponsive)
309 virtual void MakeModal(bool modal
= TRUE
);
314 // set focus to this window
315 virtual void SetFocus() = 0;
317 // return the window which currently has the focus or NULL
318 static wxWindow
*FindFocus() /* = 0: implement in derived classes */;
320 // can this window have focus?
321 virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
323 // parent/children relations
324 // -------------------------
326 // get the list of children
327 const wxWindowList
& GetChildren() const { return m_children
; }
328 wxWindowList
& GetChildren() { return m_children
; }
330 // get the parent or the parent of the parent
331 wxWindow
*GetParent() const { return m_parent
; }
332 inline wxWindow
*GetGrandParent() const;
334 // is this window a top level one?
335 bool IsTopLevel() const;
337 // it doesn't really change parent, use ReParent() instead
338 void SetParent( wxWindowBase
*parent
) { m_parent
= (wxWindow
*)parent
; }
339 // change the real parent of this window, return TRUE if the parent
340 // was changed, FALSE otherwise (error or newParent == oldParent)
341 virtual bool Reparent( wxWindowBase
*newParent
);
343 // find window among the descendants of this one either by id or by
344 // name (return NULL if not found)
345 wxWindow
*FindWindow( long id
);
346 wxWindow
*FindWindow( const wxString
& name
);
348 // implementation mostly
349 virtual void AddChild( wxWindowBase
*child
);
350 virtual void RemoveChild( wxWindowBase
*child
);
352 // event handler stuff
353 // -------------------
355 // get the current event handler
356 wxEvtHandler
*GetEventHandler() const { return m_eventHandler
; }
358 // replace the event handler (allows to completely subclass the
360 void SetEventHandler( wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
362 // push/pop event handler: allows to chain a custom event handler to
363 // alreasy existing ones
364 void PushEventHandler( wxEvtHandler
*handler
);
365 wxEvtHandler
*PopEventHandler( bool deleteHandler
= FALSE
);
367 // validators and client data
368 // --------------------------
371 // a window may have an associated validator which is used to control
373 virtual void SetValidator( const wxValidator
&validator
);
374 virtual wxValidator
*GetValidator() { return m_windowValidator
; }
375 #endif // wxUSE_VALIDATORS
377 // each window may have associated client data: either a pointer to
378 // wxClientData object in which case it is managed by the window (i.e.
379 // it will delete the data when it's destroyed) or an untyped pointer
380 // which won't be deleted by the window - but not both of them
381 void SetClientObject( wxClientData
*data
) { DoSetClientObject(data
); }
382 wxClientData
*GetClientObject() const { return DoGetClientObject(); }
384 void SetClientData( void *data
) { DoSetClientData(data
); }
385 void *GetClientData() const { return DoGetClientData(); }
387 // dialog oriented functions
388 // -------------------------
390 // validate the correctness of input, return TRUE if ok
391 virtual bool Validate();
393 // transfer data between internal and GUI representations
394 virtual bool TransferDataToWindow();
395 virtual bool TransferDataFromWindow();
397 virtual void InitDialog();
402 virtual void SetAcceleratorTable( const wxAcceleratorTable
& accel
)
403 { m_acceleratorTable
= accel
; }
404 wxAcceleratorTable
*GetAcceleratorTable()
405 { return &m_acceleratorTable
; }
406 #endif // wxUSE_ACCEL
408 // dialog units translations
409 // -------------------------
411 wxPoint
ConvertPixelsToDialog( const wxPoint
& pt
);
412 wxPoint
ConvertDialogToPixels( const wxPoint
& pt
);
413 wxSize
ConvertPixelsToDialog( const wxSize
& sz
)
415 wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
)));
417 return wxSize(pt
.x
, pt
.y
);
420 wxSize
ConvertDialogToPixels( const wxSize
& sz
)
422 wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
)));
424 return wxSize(pt
.x
, pt
.y
);
430 // move the mouse to the specified position
431 virtual void WarpPointer(int x
, int y
) = 0;
433 // start or end mouse capture
434 virtual void CaptureMouse() = 0;
435 virtual void ReleaseMouse() = 0;
437 // painting the window
438 // -------------------
440 // mark the specified rectangle (or the whole window) as "dirty" so it
442 virtual void Refresh( bool eraseBackground
= TRUE
,
443 const wxRect
*rect
= (const wxRect
*) NULL
) = 0;
444 // clear the window entirely
445 virtual void Clear() = 0;
447 // adjust DC for drawing on this window
448 virtual void PrepareDC( wxDC
& WXUNUSED(dc
) ) { }
450 // the update region of the window contains the areas which must be
451 // repainted by the program
452 const wxRegion
& GetUpdateRegion() const { return m_updateRegion
; }
453 wxRegion
& GetUpdateRegion() { return m_updateRegion
; }
455 // these functions verify whether the given point/rectangle belongs to
456 // (or at least intersects with) the update region
457 bool IsExposed( int x
, int y
) const;
458 bool IsExposed( int x
, int y
, int w
, int h
) const;
460 bool IsExposed( const wxPoint
& pt
) const
461 { return IsExposed(pt
.x
, pt
.y
); }
462 bool IsExposed( const wxRect
& rect
) const
463 { return IsExposed(rect
.x
, rect
.y
, rect
.width
, rect
.height
); }
465 // colours, fonts and cursors
466 // --------------------------
468 // set/retrieve the window colours (system defaults are used by
469 // default): Set functions return TRUE if colour was changed
470 virtual bool SetBackgroundColour( const wxColour
&colour
);
471 virtual bool SetForegroundColour( const wxColour
&colour
);
473 wxColour
GetBackgroundColour() const { return m_backgroundColour
; }
474 wxColour
GetForegroundColour() const { return m_foregroundColour
; }
476 // set/retrieve the cursor for this window (SetCursor() returns TRUE
477 // if the cursor was really changed)
478 virtual bool SetCursor( const wxCursor
&cursor
);
479 const wxCursor
& GetCursor() const { return m_cursor
; }
480 wxCursor
& GetCursor() { return m_cursor
; }
482 // set/retrieve the font for the window (SetFont() returns TRUE if the
483 // font really changed)
484 virtual bool SetFont( const wxFont
&font
) = 0;
485 const wxFont
& GetFont() const { return m_font
; }
486 wxFont
& GetFont() { return m_font
; }
489 // associate a caret with the window
490 void SetCaret(wxCaret
*caret
);
491 // get the current caret (may be NULL)
492 wxCaret
*GetCaret() const { return m_caret
; }
493 #endif // wxUSE_CARET
495 // get the (average) character size for the current font
496 virtual int GetCharHeight() const = 0;
497 virtual int GetCharWidth() const = 0;
499 // get the width/height/... of the text using current or specified
501 virtual void GetTextExtent(const wxString
& string
,
503 int *descent
= (int *) NULL
,
504 int *externalLeading
= (int *) NULL
,
505 const wxFont
*theFont
= (const wxFont
*) NULL
)
508 // translate to/from screen/client coordinates (pointers may be NULL)
509 void ClientToScreen( int *x
, int *y
) const
510 { DoClientToScreen(x
, y
); }
511 void ScreenToClient( int *x
, int *y
) const
512 { DoScreenToClient(x
, y
); }
513 wxPoint
ClientToScreen(const wxPoint
& pt
) const
515 int x
= pt
.x
, y
= pt
.y
;
516 DoClientToScreen(&x
, &y
);
518 return wxPoint(x
, y
);
521 wxPoint
ScreenToClient(const wxPoint
& pt
) const
523 int x
= pt
.x
, y
= pt
.y
;
524 DoScreenToClient(&x
, &y
);
526 return wxPoint(x
, y
);
532 void UpdateWindowUI();
534 bool PopupMenu( wxMenu
*menu
, const wxPoint
& pos
)
535 { return DoPopupMenu(menu
, pos
.x
, pos
.y
); }
536 bool PopupMenu( wxMenu
*menu
, int x
, int y
)
537 { return DoPopupMenu(menu
, x
, y
); }
542 // configure the window scrollbars
543 virtual void SetScrollbar( int orient
,
547 bool refresh
= TRUE
) = 0;
548 virtual void SetScrollPos( int orient
, int pos
, bool refresh
= TRUE
) = 0;
549 virtual int GetScrollPos( int orient
) const = 0;
550 virtual int GetScrollThumb( int orient
) const = 0;
551 virtual int GetScrollRange( int orient
) const = 0;
553 // scroll window to the specified position
554 virtual void ScrollWindow( int dx
, int dy
,
555 const wxRect
* rect
= (wxRect
*) NULL
) = 0;
560 // the easiest way to set a tooltip for a window is to use this method
561 void SetToolTip( const wxString
&tip
);
562 // attach a tooltip to the window
563 void SetToolTip( wxToolTip
*tip
) { DoSetToolTip(tip
); }
564 // get the associated tooltip or NULL if none
565 wxToolTip
* GetToolTip() const { return m_tooltip
; }
566 #endif // wxUSE_TOOLTIPS
570 #if wxUSE_DRAG_AND_DROP
571 // set/retrieve the drop target associated with this window (may be
572 // NULL; it's owned by the window and will be deleted by it)
573 virtual void SetDropTarget( wxDropTarget
*dropTarget
) = 0;
574 virtual wxDropTarget
*GetDropTarget() const { return m_dropTarget
; }
575 #endif // wxUSE_DRAG_AND_DROP
577 // constraints and sizers
578 // ----------------------
579 #if wxUSE_CONSTRAINTS
580 // set the constraints for this window or retrieve them (may be NULL)
581 void SetConstraints( wxLayoutConstraints
*constraints
);
582 wxLayoutConstraints
*GetConstraints() const { return m_constraints
; }
584 // when using constraints, it makes sense to update children positions
585 // automatically whenever the window is resized - this is done if
587 void SetAutoLayout( bool autoLayout
) { m_autoLayout
= autoLayout
; }
588 bool GetAutoLayout() const { return m_autoLayout
; }
590 // do layout the window and its children
591 virtual bool Layout();
593 // implementation only
594 void UnsetConstraints(wxLayoutConstraints
*c
);
595 wxWindowList
*GetConstraintsInvolvedIn() const
596 { return m_constraintsInvolvedIn
; }
597 void AddConstraintReference(wxWindowBase
*otherWin
);
598 void RemoveConstraintReference(wxWindowBase
*otherWin
);
599 void DeleteRelatedConstraints();
600 void ResetConstraints();
602 // these methods may be overriden for special layout algorithms
603 virtual void SetConstraintSizes(bool recurse
= TRUE
);
604 virtual bool LayoutPhase1(int *noChanges
);
605 virtual bool LayoutPhase2(int *noChanges
);
606 virtual bool DoPhase(int);
608 // these methods are virtual but normally won't be overridden
609 virtual void TransformSizerToActual(int *x
, int *y
) const ;
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
; }
621 void SetSizerParent( wxWindowBase
*win
) { m_sizerParent
= win
; }
622 wxWindowBase
*GetSizerParent() const { return m_sizerParent
; }
624 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
625 virtual void SizerMove(int x
, int y
);
626 #endif // wxUSE_CONSTRAINTS
628 // backward compatibility
629 // ----------------------
630 #if WXWIN_COMPATIBILITY
631 bool Enabled() const { return IsEnabled(); }
633 void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
634 void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
635 wxFont
& GetLabelFont() { return GetFont(); };
636 wxFont
& GetButtonFont() { return GetFont(); };
637 #endif // WXWIN_COMPATIBILITY
643 void OnSysColourChanged( wxSysColourChangedEvent
& event
);
644 void OnInitDialog( wxInitDialogEvent
&event
);
646 // get the haqndle of the window for the underlying window system: this
647 // is only used for wxWin itself or for user code which wants to call
648 // platform-specific APIs
649 virtual WXWidget
GetHandle() const = 0;
652 // the window id - a number which uniquely identifies a window among
653 // its siblings unless it is -1
654 wxWindowID m_windowId
;
656 // the parent window of this window (or NULL) and the list of the children
659 wxWindowList m_children
;
661 // the minimal allowed size for the window (no minimal size if variable(s)
663 int m_minWidth
, m_minHeight
, m_maxWidth
, m_maxHeight
;
665 // event handler for this window: usually is just 'this' but may be
666 // changed with SetEventHandler()
667 wxEvtHandler
*m_eventHandler
;
670 // associated validator or NULL if none
671 wxValidator
*m_windowValidator
;
672 #endif // wxUSE_VALIDATORS
674 #if wxUSE_DRAG_AND_DROP
675 wxDropTarget
*m_dropTarget
;
676 #endif // wxUSE_DRAG_AND_DROP
678 // visual window attributes
681 wxColour m_backgroundColour
, m_foregroundColour
;
685 #endif // wxUSE_CARET
687 // the region which should be repainted in response to paint event
688 wxRegion m_updateRegion
;
691 // the accelerator table for the window which translates key strokes into
693 wxAcceleratorTable m_acceleratorTable
;
694 #endif // wxUSE_ACCEL
696 // user data associated with the window: either an object which will be
697 // deleted by the window when it's deleted or some raw pointer which we do
698 // nothing with - only one type of data can be used with the given window
699 // (i.e. you cannot set the void data and then associate the window with
700 // wxClientData or vice versa)
703 wxClientData
*m_clientObject
;
707 // the tooltip for this window (may be NULL)
709 wxToolTip
*m_tooltip
;
710 #endif // wxUSE_TOOLTIPS
712 // constraints and sizers
713 #if wxUSE_CONSTRAINTS
714 // the constraints for this window or NULL
715 wxLayoutConstraints
*m_constraints
;
717 // constraints this window is involved in
718 wxWindowList
*m_constraintsInvolvedIn
;
720 // top level and the parent sizers
721 // TODO what's this and how does it work?)
722 wxSizer
*m_windowSizer
;
723 wxWindowBase
*m_sizerParent
;
725 // Layout() window automatically when its size changes?
727 #endif // wxUSE_CONSTRAINTS
732 bool m_isBeingDeleted
:1;
736 wxString m_windowName
;
739 // common part of all ctors: it is not virtual because it is called from
743 // get the default size for the new window if no explicit size given
744 // FIXME why 20 and not 30, 10 or ...?
745 static int WidthDefault(int w
) { return w
== -1 ? 20 : w
; }
746 static int HeightDefault(int h
) { return h
== -1 ? 20 : h
; }
748 // more pure virtual functions
749 // ---------------------------
751 // NB: we must have DoSomething() function when Something() is an overloaded
752 // method: indeed, we can't just have "virtual Something()" in case when
753 // the function is overloaded because then we'd have to make virtual all
754 // the variants (otherwise only the virtual function may be called on a
755 // pointer to derived class according to C++ rules) which is, in
756 // general, absolutely not needed. So instead we implement all
757 // overloaded Something()s in terms of DoSomething() which will be the
758 // only one to be virtual.
760 // coordinates translation
761 virtual void DoClientToScreen( int *x
, int *y
) const = 0;
762 virtual void DoScreenToClient( int *x
, int *y
) const = 0;
764 // retrieve the position/size of the window
765 virtual void DoGetPosition( int *x
, int *y
) const = 0;
766 virtual void DoGetSize( int *width
, int *height
) const = 0;
767 virtual void DoGetClientSize( int *width
, int *height
) const = 0;
769 // this is the virtual function to be overriden in any derived class which
770 // wants to change how SetSize() or Move() works - it is called by all
771 // versions of these functions in the base class
772 virtual void DoSetSize(int x
, int y
,
773 int width
, int height
,
774 int sizeFlags
= wxSIZE_AUTO
) = 0;
776 // same as DoSetSize() for the client size
777 virtual void DoSetClientSize(int width
, int height
) = 0;
780 virtual void DoSetToolTip( wxToolTip
*tip
);
781 #endif // wxUSE_TOOLTIPS
783 virtual bool DoPopupMenu( wxMenu
*menu
, int x
, int y
) = 0;
785 // client data accessors
786 virtual void DoSetClientObject( wxClientData
*data
);
787 virtual wxClientData
*DoGetClientObject() const;
789 virtual void DoSetClientData( void *data
);
790 virtual void *DoGetClientData() const;
792 // what kind of data do we have?
793 enum wxClientDataType
795 ClientData_None
, // we don't know yet because we don't have it at all
796 ClientData_Object
, // our client data is typed and we own it
797 ClientData_Void
// client data is untyped and we don't own it
801 // contains the last id generated by NewControlId
802 static int ms_lastControlId
;
804 DECLARE_NO_COPY_CLASS(wxWindowBase
);
805 DECLARE_EVENT_TABLE()
808 // ----------------------------------------------------------------------------
809 // now include the declaration of wxWindow class
810 // ----------------------------------------------------------------------------
812 #if defined(__WXMSW__)
813 #include "wx/msw/window.h"
814 #elif defined(__WXMOTIF__)
815 #include "wx/motif/window.h"
816 #elif defined(__WXGTK__)
817 #include "wx/gtk/window.h"
818 #elif defined(__WXQT__)
819 #include "wx/qt/window.h"
820 #elif defined(__WXMAC__)
821 #include "wx/mac/window.h"
822 #elif defined(__WXPM__)
823 #include "wx/os2/window.h"
826 // ----------------------------------------------------------------------------
827 // inline functions which couldn't be declared in the class body because of
828 // forward dependencies
829 // ----------------------------------------------------------------------------
831 inline wxWindow
*wxWindowBase::GetGrandParent() const
833 return m_parent
? m_parent
->GetParent() : (wxWindow
*)NULL
;
836 // ----------------------------------------------------------------------------
838 // ----------------------------------------------------------------------------
840 WXDLLEXPORT
extern wxWindow
* wxGetActiveWindow();
841 inline WXDLLEXPORT
int NewControlId() { return wxWindowBase::NewControlId(); }
844 // _WX_WINDOW_H_BASE_