]> git.saurik.com Git - wxWidgets.git/blob - include/wx/window.h
Added wxDllLoader::UnloadLibrary()
[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 void CentreOnParent(int direction = wxHORIZONTAL );
263 void CenterOnParent(int direction = wxHORIZONTAL ) { CentreOnParent(direction); }
264
265 // set window size to wrap around its children
266 virtual void Fit();
267
268 // set min/max size of the window
269 virtual void SetSizeHints( int minW, int minH,
270 int maxW = -1, int maxH = -1,
271 int incW = -1, int incH = -1 );
272
273 // window state
274 // ------------
275
276 // returns TRUE if window was shown/hidden, FALSE if the nothing was
277 // done (window was already shown/hidden)
278 virtual bool Show( bool show = TRUE );
279 bool Hide() { return Show(FALSE); }
280
281 // returns TRUE if window was enabled/disabled, FALSE if nothing done
282 virtual bool Enable( bool enable = TRUE );
283 bool Disable() { return Enable(FALSE); }
284
285 bool IsShown() const { return m_isShown; }
286 bool IsEnabled() const { return m_isEnabled; }
287
288 // get/set window style (setting style won't update the window and so
289 // is only useful for internal usage)
290 virtual void SetWindowStyleFlag( long style ) { m_windowStyle = style; }
291 virtual long GetWindowStyleFlag() const { return m_windowStyle; }
292
293 // just some (somewhat shorter) synonims
294 void SetWindowStyle( long style ) { SetWindowStyleFlag(style); }
295 long GetWindowStyle() const { return GetWindowStyleFlag(); }
296
297 bool HasFlag(int flag) const { return (m_windowStyle & flag) != 0; }
298
299 virtual bool IsRetained() const
300 { return (m_windowStyle & wxRETAINED) != 0; }
301
302 // make the window modal (all other windows unresponsive)
303 virtual void MakeModal(bool modal = TRUE);
304
305 // focus handling
306 // --------------
307
308 // set focus to this window
309 virtual void SetFocus() = 0;
310
311 // return the window which currently has the focus or NULL
312 static wxWindow *FindFocus() /* = 0: implement in derived classes */;
313
314 // can this window have focus?
315 virtual bool AcceptsFocus() const { return IsShown() && IsEnabled(); }
316
317 // parent/children relations
318 // -------------------------
319
320 // get the list of children
321 const wxWindowList& GetChildren() const { return m_children; }
322 wxWindowList& GetChildren() { return m_children; }
323
324 // get the parent or the parent of the parent
325 wxWindow *GetParent() const { return m_parent; }
326 inline wxWindow *GetGrandParent() const;
327
328 // is this window a top level one?
329 bool IsTopLevel() const;
330
331 // it doesn't really change parent, use ReParent() instead
332 void SetParent( wxWindowBase *parent ) { m_parent = (wxWindow *)parent; }
333 // change the real parent of this window, return TRUE if the parent
334 // was changed, FALSE otherwise (error or newParent == oldParent)
335 virtual bool Reparent( wxWindowBase *newParent );
336
337 // find window among the descendants of this one either by id or by
338 // name (return NULL if not found)
339 wxWindow *FindWindow( long id );
340 wxWindow *FindWindow( const wxString& name );
341
342 // implementation mostly
343 virtual void AddChild( wxWindowBase *child );
344 virtual void RemoveChild( wxWindowBase *child );
345
346 // event handler stuff
347 // -------------------
348
349 // get the current event handler
350 wxEvtHandler *GetEventHandler() const { return m_eventHandler; }
351
352 // replace the event handler (allows to completely subclass the
353 // window)
354 void SetEventHandler( wxEvtHandler *handler ) { m_eventHandler = handler; }
355
356 // push/pop event handler: allows to chain a custom event handler to
357 // alreasy existing ones
358 void PushEventHandler( wxEvtHandler *handler );
359 wxEvtHandler *PopEventHandler( bool deleteHandler = FALSE );
360
361 // validators and client data
362 // --------------------------
363
364 #if wxUSE_VALIDATORS
365 // a window may have an associated validator which is used to control
366 // user input
367 virtual void SetValidator( const wxValidator &validator );
368 virtual wxValidator *GetValidator() { return m_windowValidator; }
369 #endif // wxUSE_VALIDATORS
370
371 // each window may have associated client data: either a pointer to
372 // wxClientData object in which case it is managed by the window (i.e.
373 // it will delete the data when it's destroyed) or an untyped pointer
374 // which won't be deleted by the window
375 virtual void SetClientObject( wxClientData *data )
376 {
377 if ( m_clientObject )
378 delete m_clientObject;
379
380 m_clientObject = data;
381 }
382 virtual wxClientData *GetClientObject() const { return m_clientObject; }
383
384 virtual void SetClientData( void *data ) { m_clientData = data; }
385 virtual void *GetClientData() const { return m_clientData; }
386
387 // dialog oriented functions
388 // -------------------------
389
390 // validate the correctness of input, return TRUE if ok
391 virtual bool Validate();
392
393 // transfer data between internal and GUI representations
394 virtual bool TransferDataToWindow();
395 virtual bool TransferDataFromWindow();
396
397 virtual void InitDialog();
398
399 #if wxUSE_ACCEL
400 // accelerators
401 // ------------
402 virtual void SetAcceleratorTable( const wxAcceleratorTable& accel )
403 { m_acceleratorTable = accel; }
404 wxAcceleratorTable *GetAcceleratorTable()
405 { return &m_acceleratorTable; }
406 #endif // wxUSE_ACCEL
407
408 // dialog units translations
409 // -------------------------
410
411 wxPoint ConvertPixelsToDialog( const wxPoint& pt );
412 wxPoint ConvertDialogToPixels( const wxPoint& pt );
413 wxSize ConvertPixelsToDialog( const wxSize& sz )
414 {
415 wxPoint pt(ConvertPixelsToDialog(wxPoint(sz.x, sz.y)));
416
417 return wxSize(pt.x, pt.y);
418 }
419
420 wxSize ConvertDialogToPixels( const wxSize& sz )
421 {
422 wxPoint pt(ConvertDialogToPixels(wxPoint(sz.x, sz.y)));
423
424 return wxSize(pt.x, pt.y);
425 }
426
427 // mouse functions
428 // ---------------
429
430 // move the mouse to the specified position
431 virtual void WarpPointer(int x, int y) = 0;
432
433 // start or end mouse capture
434 virtual void CaptureMouse() = 0;
435 virtual void ReleaseMouse() = 0;
436
437 // painting the window
438 // -------------------
439
440 // mark the specified rectangle (or the whole window) as "dirty" so it
441 // will be repainted
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;
446
447 // adjust DC for drawing on this window
448 virtual void PrepareDC( wxDC & WXUNUSED(dc) ) { }
449
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; }
454
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;
459
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); }
464
465 // colours, fonts and cursors
466 // --------------------------
467
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 );
472
473 wxColour GetBackgroundColour() const { return m_backgroundColour; }
474 wxColour GetForegroundColour() const { return m_foregroundColour; }
475
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; }
481
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; }
487
488 #if wxUSE_CARET
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
494
495 // get the (average) character size for the current font
496 virtual int GetCharHeight() const = 0;
497 virtual int GetCharWidth() const = 0;
498
499 // get the width/height/... of the text using current or specified
500 // font
501 virtual void GetTextExtent(const wxString& string,
502 int *x, int *y,
503 int *descent = (int *) NULL,
504 int *externalLeading = (int *) NULL,
505 const wxFont *theFont = (const wxFont *) NULL)
506 const = 0;
507
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
514 {
515 int x = pt.x, y = pt.y;
516 DoClientToScreen(&x, &y);
517
518 return wxPoint(x, y);
519 }
520
521 wxPoint ScreenToClient(const wxPoint& pt) const
522 {
523 int x = pt.x, y = pt.y;
524 DoScreenToClient(&x, &y);
525
526 return wxPoint(x, y);
527 }
528
529 // misc
530 // ----
531
532 void UpdateWindowUI();
533
534 virtual bool PopupMenu( wxMenu *menu, int x, int y ) = 0;
535
536 // scrollbars
537 // ----------
538
539 // configure the window scrollbars
540 virtual void SetScrollbar( int orient,
541 int pos,
542 int thumbVisible,
543 int range,
544 bool refresh = TRUE ) = 0;
545 virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ) = 0;
546 virtual int GetScrollPos( int orient ) const = 0;
547 virtual int GetScrollThumb( int orient ) const = 0;
548 virtual int GetScrollRange( int orient ) const = 0;
549
550 // scroll window to the specified position
551 virtual void ScrollWindow( int dx, int dy,
552 const wxRect* rect = (wxRect *) NULL ) = 0;
553
554 // tooltips
555 // --------
556 #if wxUSE_TOOLTIPS
557 // the easiest way to set a tooltip for a window is to use this method
558 void SetToolTip( const wxString &tip );
559 // attach a tooltip to the window
560 void SetToolTip( wxToolTip *tip ) { DoSetToolTip(tip); }
561 // get the associated tooltip or NULL if none
562 wxToolTip* GetToolTip() const { return m_tooltip; }
563 #endif // wxUSE_TOOLTIPS
564
565 // drag and drop
566 // -------------
567 #if wxUSE_DRAG_AND_DROP
568 // set/retrieve the drop target associated with this window (may be
569 // NULL; it's owned by the window and will be deleted by it)
570 virtual void SetDropTarget( wxDropTarget *dropTarget ) = 0;
571 virtual wxDropTarget *GetDropTarget() const { return m_dropTarget; }
572 #endif // wxUSE_DRAG_AND_DROP
573
574 // constraints and sizers
575 // ----------------------
576 #if wxUSE_CONSTRAINTS
577 // set the constraints for this window or retrieve them (may be NULL)
578 void SetConstraints( wxLayoutConstraints *constraints );
579 wxLayoutConstraints *GetConstraints() const { return m_constraints; }
580
581 // when using constraints, it makes sense to update children positions
582 // automatically whenever the window is resized - this is done if
583 // autoLayout is on
584 void SetAutoLayout( bool autoLayout ) { m_autoLayout = autoLayout; }
585 bool GetAutoLayout() const { return m_autoLayout; }
586
587 // do layout the window and its children
588 virtual bool Layout();
589
590 // implementation only
591 void UnsetConstraints(wxLayoutConstraints *c);
592 wxWindowList *GetConstraintsInvolvedIn() const
593 { return m_constraintsInvolvedIn; }
594 void AddConstraintReference(wxWindowBase *otherWin);
595 void RemoveConstraintReference(wxWindowBase *otherWin);
596 void DeleteRelatedConstraints();
597 void ResetConstraints();
598
599 // these methods may be overriden for special layout algorithms
600 virtual void SetConstraintSizes(bool recurse = TRUE);
601 virtual bool LayoutPhase1(int *noChanges);
602 virtual bool LayoutPhase2(int *noChanges);
603 virtual bool DoPhase(int);
604
605 // these methods are virtual but normally won't be overridden
606 virtual void TransformSizerToActual(int *x, int *y) const ;
607 virtual void SetSizeConstraint(int x, int y, int w, int h);
608 virtual void MoveConstraint(int x, int y);
609 virtual void GetSizeConstraint(int *w, int *h) const ;
610 virtual void GetClientSizeConstraint(int *w, int *h) const ;
611 virtual void GetPositionConstraint(int *x, int *y) const ;
612
613 // sizers
614 // TODO: what are they and how do they work??
615 void SetSizer( wxSizer *sizer );
616 wxSizer *GetSizer() const { return m_windowSizer; }
617
618 void SetSizerParent( wxWindowBase *win ) { m_sizerParent = win; }
619 wxWindowBase *GetSizerParent() const { return m_sizerParent; }
620
621 virtual void SizerSetSize(int x, int y, int w, int h);
622 virtual void SizerMove(int x, int y);
623 #endif // wxUSE_CONSTRAINTS
624
625 // backward compatibility
626 // ----------------------
627 #if WXWIN_COMPATIBILITY
628 bool Enabled() const { return IsEnabled(); }
629
630 void SetButtonFont(const wxFont& font) { SetFont(font); }
631 void SetLabelFont(const wxFont& font) { SetFont(font); }
632 wxFont& GetLabelFont() { return GetFont(); };
633 wxFont& GetButtonFont() { return GetFont(); };
634 #endif // WXWIN_COMPATIBILITY
635
636 // implementation
637 // --------------
638
639 // event handlers
640 void OnSysColourChanged( wxSysColourChangedEvent& event );
641 void OnInitDialog( wxInitDialogEvent &event );
642
643 // get the haqndle of the window for the underlying window system: this
644 // is only used for wxWin itself or for user code which wants to call
645 // platform-specific APIs
646 virtual WXWidget GetHandle() const = 0;
647
648 protected:
649 // the window id - a number which uniquely identifies a window among
650 // its siblings unless it is -1
651 wxWindowID m_windowId;
652
653 // the parent window of this window (or NULL) and the list of the children
654 // of this window
655 wxWindow *m_parent;
656 wxWindowList m_children;
657
658 // the minimal allowed size for the window (no minimal size if variable(s)
659 // contain(s) -1)
660 int m_minWidth, m_minHeight, m_maxWidth, m_maxHeight;
661
662 // event handler for this window: usually is just 'this' but may be
663 // changed with SetEventHandler()
664 wxEvtHandler *m_eventHandler;
665
666 #if wxUSE_VALIDATORS
667 // associated validator or NULL if none
668 wxValidator *m_windowValidator;
669 #endif // wxUSE_VALIDATORS
670
671 #if wxUSE_DRAG_AND_DROP
672 wxDropTarget *m_dropTarget;
673 #endif // wxUSE_DRAG_AND_DROP
674
675 // visual window attributes
676 wxCursor m_cursor;
677 wxFont m_font;
678 wxColour m_backgroundColour, m_foregroundColour;
679
680 #if wxUSE_CARET
681 wxCaret *m_caret;
682 #endif // wxUSE_CARET
683
684 // the region which should be repainted in response to paint event
685 wxRegion m_updateRegion;
686
687 #if wxUSE_ACCEL
688 // the accelerator table for the window which translates key strokes into
689 // command events
690 wxAcceleratorTable m_acceleratorTable;
691 #endif // wxUSE_ACCEL
692
693 // user data associated with the window: either an object which will be
694 // deleted by the window when it's deleted or some raw pointer which we do
695 // nothing with
696 wxClientData *m_clientObject;
697 void *m_clientData;
698
699 // the tooltip for this window (may be NULL)
700 #if wxUSE_TOOLTIPS
701 wxToolTip *m_tooltip;
702 #endif // wxUSE_TOOLTIPS
703
704 // constraints and sizers
705 #if wxUSE_CONSTRAINTS
706 // the constraints for this window or NULL
707 wxLayoutConstraints *m_constraints;
708
709 // constraints this window is involved in
710 wxWindowList *m_constraintsInvolvedIn;
711
712 // top level and the parent sizers
713 // TODO what's this and how does it work?)
714 wxSizer *m_windowSizer;
715 wxWindowBase *m_sizerParent;
716
717 // Layout() window automatically when its size changes?
718 bool m_autoLayout:1;
719 #endif // wxUSE_CONSTRAINTS
720
721 // window state
722 bool m_isShown:1;
723 bool m_isEnabled:1;
724 bool m_isBeingDeleted:1;
725
726 // window attributes
727 long m_windowStyle;
728 wxString m_windowName;
729
730 protected:
731 // common part of all ctors: it is not virtual because it is called from
732 // ctor
733 void InitBase();
734
735 // get the default size for the new window if no explicit size given
736 // FIXME why 20 and not 30, 10 or ...?
737 static int WidthDefault(int w) { return w == -1 ? 20 : w; }
738 static int HeightDefault(int h) { return h == -1 ? 20 : h; }
739
740 // more pure virtual functions
741 // ---------------------------
742
743 // NB: we must have DoSomething() function when Something() is an overloaded
744 // method: indeed, we can't just have "virtual Something()" in case when
745 // the function is overloaded because then we'd have to make virtual all
746 // the variants (otherwise only the virtual function may be called on a
747 // pointer to derived class according to C++ rules) which is, in
748 // general, absolutely not needed. So instead we implement all
749 // overloaded Something()s in terms of DoSomething() which will be the
750 // only one to be virtual.
751
752 // coordinates translation
753 virtual void DoClientToScreen( int *x, int *y ) const = 0;
754 virtual void DoScreenToClient( int *x, int *y ) const = 0;
755
756 // retrieve the position/size of the window
757 virtual void DoGetPosition( int *x, int *y ) const = 0;
758 virtual void DoGetSize( int *width, int *height ) const = 0;
759 virtual void DoGetClientSize( int *width, int *height ) const = 0;
760
761 // this is the virtual function to be overriden in any derived class which
762 // wants to change how SetSize() or Move() works - it is called by all
763 // versions of these functions in the base class
764 virtual void DoSetSize(int x, int y,
765 int width, int height,
766 int sizeFlags = wxSIZE_AUTO) = 0;
767
768 // same as DoSetSize() for the client size
769 virtual void DoSetClientSize(int width, int height) = 0;
770
771 #if wxUSE_TOOLTIPS
772 virtual void DoSetToolTip( wxToolTip *tip );
773 #endif // wxUSE_TOOLTIPS
774
775 private:
776 // contains the last id generated by NewControlId
777 static int ms_lastControlId;
778
779 DECLARE_NO_COPY_CLASS(wxWindowBase);
780 DECLARE_EVENT_TABLE()
781 };
782
783 // ----------------------------------------------------------------------------
784 // now include the declaration of wxWindow class
785 // ----------------------------------------------------------------------------
786
787 #if defined(__WXMSW__)
788 #include "wx/msw/window.h"
789 #elif defined(__WXMOTIF__)
790 #include "wx/motif/window.h"
791 #elif defined(__WXGTK__)
792 #include "wx/gtk/window.h"
793 #elif defined(__WXQT__)
794 #include "wx/qt/window.h"
795 #elif defined(__WXMAC__)
796 #include "wx/mac/window.h"
797 #endif
798
799 // ----------------------------------------------------------------------------
800 // inline functions which couldn't be declared in the class body because of
801 // forward dependencies
802 // ----------------------------------------------------------------------------
803
804 inline wxWindow *wxWindowBase::GetGrandParent() const
805 {
806 return m_parent ? m_parent->GetParent() : (wxWindow *)NULL;
807 }
808
809 // ----------------------------------------------------------------------------
810 // global function
811 // ----------------------------------------------------------------------------
812
813 WXDLLEXPORT extern wxWindow* wxGetActiveWindow();
814 inline WXDLLEXPORT int NewControlId() { return wxWindowBase::NewControlId(); }
815
816 #endif
817 // _WX_WINDOW_H_BASE_