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