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