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