1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxWindow class
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
16 #pragma interface "window.h"
19 #include "wx/gdicmn.h"
21 #include "wx/cursor.h"
24 #include "wx/validate.h"
26 #include "wx/string.h"
28 #include "wx/region.h"
34 * Base class for frame, panel, canvas, panel items, dialog box.
39 * Event handler: windows have themselves as their event handlers
40 * by default, but their event handlers could be set to another
41 * object entirely. This separation can reduce the amount of
42 * derivation required, and allow alteration of a window's functionality
43 * (e.g. by a resource editor that temporarily switches event handlers).
46 class WXDLLEXPORT wxWindow
;
47 class WXDLLEXPORT wxEvent
;
48 class WXDLLEXPORT wxCommandEvent
;
49 class WXDLLEXPORT wxKeyEvent
;
50 class WXDLLEXPORT wxControl
;
51 class WXDLLEXPORT wxCursor
;
52 class WXDLLEXPORT wxColourMap
;
53 class WXDLLEXPORT wxFont
;
54 class WXDLLEXPORT wxMenu
;
55 class WXDLLEXPORT wxRectangle
;
56 class WXDLLEXPORT wxBitmap
;
57 class WXDLLEXPORT wxSizer
;
58 class WXDLLEXPORT wxList
;
59 class WXDLLEXPORT wxLayoutConstraints
;
60 class WXDLLEXPORT wxMouseEvent
;
61 class WXDLLEXPORT wxButton
;
62 class WXDLLEXPORT wxColour
;
63 class WXDLLEXPORT wxBrush
;
64 class WXDLLEXPORT wxPen
;
65 class WXDLLEXPORT wxIcon
;
66 class WXDLLEXPORT wxDC
;
67 class WXDLLEXPORT wxValidator
;
74 class WXDLLEXPORT wxResourceTable
;
75 class WXDLLEXPORT wxItemResource
;
78 WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr
;
80 WXDLLEXPORT_DATA(extern const wxSize
) wxDefaultSize
;
81 WXDLLEXPORT_DATA(extern const wxPoint
) wxDefaultPosition
;
83 class WXDLLEXPORT wxWindow
: public wxEvtHandler
85 DECLARE_ABSTRACT_CLASS(wxWindow
)
87 friend class wxUpdateIterator
;
89 friend class wxPaintDC
;
93 inline wxWindow(wxWindow
*parent
, wxWindowID id
,
94 const wxPoint
& pos
= wxDefaultPosition
,
95 const wxSize
& size
= wxDefaultSize
,
97 const wxString
& name
= wxPanelNameStr
)
99 m_children
= new wxList
;
100 Create(parent
, id
, pos
, size
, style
, name
);
103 virtual ~wxWindow(void);
105 bool Create(wxWindow
*parent
, wxWindowID id
,
106 const wxPoint
& pos
= wxDefaultPosition
,
107 const wxSize
& size
= wxDefaultSize
,
109 const wxString
& name
= wxPanelNameStr
);
111 // Fit the window around the items
112 virtual void Fit(void);
114 // Show or hide the window
115 virtual bool Show(bool show
);
117 // Is the window shown?
118 virtual bool IsShown(void) const;
120 // Raise the window to the top of the Z order
121 virtual void Raise(void);
123 // Lower the window to the bottom of the Z order
124 virtual void Lower(void);
126 // Is the window enabled?
127 virtual bool IsEnabled(void) const;
130 inline bool Enabled(void) const { return IsEnabled(); }
132 // Dialog support: override these and call
133 // base class members to add functionality
134 // that can't be done using validators.
136 // Transfer values to controls. If returns FALSE,
137 // it's an application error (pops up a dialog)
138 virtual bool TransferDataToWindow(void);
140 // Transfer values from controls. If returns FALSE,
141 // transfer failed: don't quit
142 virtual bool TransferDataFromWindow(void);
144 // Validate controls. If returns FALSE,
145 // validation failed: don't quit
146 virtual bool Validate(void);
148 // Return code for dialogs
149 inline void SetReturnCode(int retCode
);
150 inline int GetReturnCode(void);
153 virtual void SetCursor(const wxCursor
& cursor
);
154 inline virtual wxCursor
*GetCursor(void) const { return (wxCursor
*)& m_windowCursor
; };
156 // Get the window with the focus
157 static wxWindow
*FindFocus(void);
159 // Get character size
160 virtual int GetCharHeight(void) const;
161 virtual int GetCharWidth(void) const;
163 // Get overall window size
164 virtual void GetSize(int *width
, int *height
) const;
166 // Get window position, relative to parent (or screen if no parent)
167 virtual void GetPosition(int *x
, int *y
) const;
169 // Get client (application-useable) size
170 virtual void GetClientSize(int *width
, int *height
) const;
172 // Set overall size and position
173 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
174 inline virtual void SetSize(int width
, int height
) { SetSize(-1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
175 inline virtual void Move(int x
, int y
) { SetSize(x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
178 virtual void SetClientSize(int width
, int size
);
180 // Convert client to screen coordinates
181 virtual void ClientToScreen(int *x
, int *y
) const;
183 // Convert screen to client coordinates
184 virtual void ScreenToClient(int *x
, int *y
) const;
186 // Set the focus to this window
187 virtual void SetFocus(void);
189 // Capture/release mouse
190 virtual void CaptureMouse(void);
191 virtual void ReleaseMouse(void);
193 // Enable or disable the window
194 virtual void Enable(bool enable
);
196 #if USE_DRAG_AND_DROP
197 // Associate a drop target with this window (if the window already had a drop
198 // target, it's deleted!) and return the current drop target (may be NULL).
199 void SetDropTarget(wxDropTarget
*pDropTarget
);
200 wxDropTarget
*GetDropTarget() const { return m_pDropTarget
; }
203 // Accept files for dragging
204 virtual void DragAcceptFiles(bool accept
);
206 // Update region access
207 virtual wxRegion
GetUpdateRegion() const;
208 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
209 virtual bool IsExposed(const wxPoint
& pt
) const;
210 virtual bool IsExposed(const wxRect
& rect
) const;
212 // Set/get the window title
213 virtual inline void SetTitle(const wxString
& WXUNUSED(title
)) {};
214 inline virtual wxString
GetTitle(void) const { return wxString(""); };
215 // Most windows have the concept of a label; for frames, this is the
216 // title; for items, this is the label or button text.
217 inline virtual wxString
GetLabel(void) const { return GetTitle(); }
219 // Set/get the window name (used for resource setting in X)
220 inline virtual wxString
GetName(void) const;
221 inline virtual void SetName(const wxString
& name
);
224 virtual void Centre(int direction
) ;
225 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
228 virtual bool PopupMenu(wxMenu
*menu
, int x
, int y
);
230 // Send the window a refresh event
231 virtual void Refresh(bool eraseBack
= TRUE
, const wxRectangle
*rect
= NULL
);
233 #if WXWIN_COMPATIBILITY
234 // Set/get scroll attributes
235 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
236 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
237 virtual int OldGetScrollRange(int orient
) const;
238 virtual int GetScrollPage(int orient
) const;
241 // New functions that will replace the above.
242 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
243 int range
, bool refresh
= TRUE
);
245 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
246 virtual int GetScrollPos(int orient
) const;
247 virtual int GetScrollRange(int orient
) const;
248 virtual int GetScrollThumb(int orient
) const;
250 virtual void ScrollWindow(int dx
, int dy
, const wxRectangle
*rect
= NULL
);
252 // Caret manipulation
253 virtual void CreateCaret(int w
, int h
);
254 virtual void CreateCaret(const wxBitmap
*bitmap
);
255 virtual void DestroyCaret(void);
256 virtual void ShowCaret(bool show
);
257 virtual void SetCaretPos(int x
, int y
);
258 virtual void GetCaretPos(int *x
, int *y
) const;
260 // Tell window how much it can be sized
261 virtual void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
263 // Set/get the window's identifier
264 inline int GetId() const;
265 inline void SetId(int id
);
267 // Make the window modal (all other windows unresponsive)
268 virtual void MakeModal(bool modal
);
270 // Get the private handle (platform-dependent)
271 inline void *GetHandle(void) const;
273 // Set/get the window's relatives
274 inline wxWindow
*GetParent(void) const;
275 inline void SetParent(wxWindow
*p
) ;
276 inline wxWindow
*GetGrandParent(void) const;
277 inline wxList
*GetChildren() const;
279 // Set/get the window's font
280 virtual void SetFont(const wxFont
& f
);
281 inline virtual wxFont
*GetFont(void) const;
283 // Set/get the window's validator
284 void SetValidator(const wxValidator
& validator
);
285 inline wxValidator
*GetValidator(void) const;
287 // Set/get the window's style
288 inline void SetWindowStyleFlag(long flag
);
289 inline long GetWindowStyleFlag(void) const;
291 // Set/get double-clickability
292 // TODO: we probably wish to get rid of this, and
293 // always allow double clicks.
294 inline void SetDoubleClick(bool flag
);
295 inline bool GetDoubleClick(void) const;
296 inline void AllowDoubleClick(bool value
) { SetDoubleClick(value
); }
298 // Old way to handle a control command
299 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
301 // Set/get event handler
302 inline void SetEventHandler(wxEvtHandler
*handler
);
303 inline wxEvtHandler
*GetEventHandler(void) const;
305 // Push/pop event handler (i.e. allow a chain of event handlers
307 void PushEventHandler(wxEvtHandler
*handler
) ;
308 wxEvtHandler
*PopEventHandler(bool deleteHandler
= FALSE
) ;
310 // Close the window by calling OnClose, posting a deletion
311 virtual bool Close(bool force
= FALSE
);
313 // Destroy the window (delayed, if a managed window)
314 virtual bool Destroy(void) ;
316 // Mode for telling default OnSize members to
317 // call Layout(), if not using Sizers, just top-down constraints
318 inline void SetAutoLayout(bool a
);
319 inline bool GetAutoLayout(void) const;
321 // Set/get constraints
322 inline wxLayoutConstraints
*GetConstraints(void) const;
323 void SetConstraints(wxLayoutConstraints
*c
);
325 // Set/get window background colour
326 inline virtual void SetBackgroundColour(const wxColour
& col
);
327 inline virtual wxColour
GetBackgroundColour(void) const;
329 // Set/get window foreground colour
330 inline virtual void SetForegroundColour(const wxColour
& col
);
331 inline virtual wxColour
GetForegroundColour(void) const;
333 // TODO: are these really necessary???
334 // Set/get window default background colour (for children to inherit)
335 inline virtual void SetDefaultBackgroundColour(const wxColour
& col
);
336 inline virtual wxColour
GetDefaultBackgroundColour(void) const;
338 // Set/get window default foreground colour (for children to inherit)
339 inline virtual void SetDefaultForegroundColour(const wxColour
& col
);
340 inline virtual wxColour
GetDefaultForegroundColour(void) const;
342 // For backward compatibility
343 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
344 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
345 inline virtual wxFont
*GetLabelFont(void) const { return GetFont(); };
346 inline virtual wxFont
*GetButtonFont(void) const { return GetFont(); };
348 // Get the default button, if there is one
349 inline virtual wxButton
*GetDefaultItem(void) const;
350 inline virtual void SetDefaultItem(wxButton
*but
);
352 // Override to define new behaviour for default action (e.g. double clicking
354 virtual void OnDefaultAction(wxControl
*initiatingItem
);
358 virtual bool LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
= NULL
);
359 virtual wxControl
*CreateItem(const wxItemResource
*childResource
, const wxResourceTable
*table
= NULL
);
362 // Native resource loading
363 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
364 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
365 virtual wxWindow
* GetWindowChild1(wxWindowID
& id
);
366 virtual wxWindow
* GetWindowChild(wxWindowID
& id
);
368 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
370 int *externalLeading
= NULL
,
371 const wxFont
*theFont
= NULL
, bool use16
= FALSE
) const;
373 // Is the window retained?
374 inline bool IsRetained(void) const;
376 // Warp the pointer the given position
377 virtual void WarpPointer(int x_pos
, int y_pos
) ;
380 virtual void Clear(void);
382 // Find a window by id or name
383 virtual wxWindow
*FindWindow(long id
);
384 virtual wxWindow
*FindWindow(const wxString
& name
);
386 // Constraint operations
388 void SetSizer(wxSizer
*sizer
); // Adds sizer child to this window
389 inline wxSizer
*GetSizer(void) const ;
390 inline wxWindow
*GetSizerParent(void) const ;
391 inline void SetSizerParent(wxWindow
*win
);
393 // Do Update UI processing for controls
394 void UpdateWindowUI(void);
396 void OnEraseBackground(wxEraseEvent
& event
);
397 void OnChar(wxKeyEvent
& event
);
398 void OnPaint(wxPaintEvent
& event
);
399 void OnIdle(wxIdleEvent
& event
);
401 // Does this window want to accept keyboard focus?
402 virtual bool AcceptsFocus() const;
405 ////////////////////////////////////////////////////////////////////////
408 // For implementation purposes - sometimes decorations make the client area
410 virtual wxPoint
GetClientAreaOrigin() const;
412 // Makes an adjustment to the window position (for example, a frame that has
413 // a toolbar that it manages itself).
414 virtual void AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
);
416 // Windows subclassing
417 void SubclassWin(WXHWND hWnd
);
418 void UnsubclassWin(void);
419 virtual long Default(void);
420 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
421 virtual bool MSWNotify(WXWPARAM wParam
, WXLPARAM lParam
);
422 virtual wxWindow
*FindItem(int id
) const;
423 virtual wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const ;
424 virtual void PreDelete(WXHDC dc
); // Allows system cleanup
425 // TO DO: how many of these need to be virtual?
426 virtual WXHWND
GetHWND(void) const ;
427 virtual void SetHWND(WXHWND hWnd
);
429 // Make a Windows extended style from the given wxWindows window style
430 virtual WXDWORD
MakeExtendedStyle(long style
, bool eliminateBorders
= TRUE
);
431 // Determine whether 3D effects are wanted
432 virtual WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
);
434 virtual void AddChild(wxWindow
*child
); // Adds reference to the child object
435 virtual void RemoveChild(wxWindow
*child
); // Removes reference to child
436 // (but doesn't delete the child object)
437 virtual void DestroyChildren(void); // Removes and destroys all children
439 inline bool IsBeingDeleted(void);
441 // MSW only: TRUE if this control is part of the main control
442 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
444 // Constraint implementation
445 void UnsetConstraints(wxLayoutConstraints
*c
);
446 inline wxList
*GetConstraintsInvolvedIn(void) const ;
447 // Back-pointer to other windows we're involved with, so if we delete
448 // this window, we must delete any constraints we're involved with.
449 void AddConstraintReference(wxWindow
*otherWin
);
450 void RemoveConstraintReference(wxWindow
*otherWin
);
451 void DeleteRelatedConstraints(void);
453 virtual void ResetConstraints(void);
454 virtual void SetConstraintSizes(bool recurse
= TRUE
);
455 virtual bool LayoutPhase1(int *noChanges
);
456 virtual bool LayoutPhase2(int *noChanges
);
457 virtual bool DoPhase(int);
458 // Transforms from sizer coordinate space to actual
459 // parent coordinate space
460 virtual void TransformSizerToActual(int *x
, int *y
) const ;
462 // Set size with transformation to actual coordinates if nec.
463 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
464 virtual void SizerMove(int x
, int y
);
466 // Only set/get the size/position of the constraint (if any)
467 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
468 virtual void MoveConstraint(int x
, int y
);
469 virtual void GetSizeConstraint(int *w
, int *h
) const ;
470 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
471 virtual void GetPositionConstraint(int *x
, int *y
) const ;
473 wxObject
*GetChild(int number
) const ;
475 void MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
476 int x
, int y
, int width
, int height
,
477 WXDWORD style
, const char *dialog_template
= NULL
,
478 WXDWORD exendedStyle
= 0);
480 // Actually defined in wx_canvs.cc since requires wxCanvas declaration
481 virtual void MSWDeviceToLogical(float *x
, float *y
) const ;
483 // Create an appropriate wxWindow from a HWND
484 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
486 // Make sure the window style reflects the HWND style (roughly)
487 virtual void AdoptAttributesFromHWND(void);
489 // Setup background and foreground colours correctly
490 virtual void SetupColours(void);
493 virtual void MSWOnCreate(WXLPCREATESTRUCT cs
);
494 virtual bool MSWOnPaint(void);
495 virtual WXHICON
MSWOnQueryDragIcon(void) { return 0; }
496 virtual void MSWOnSize(int x
, int y
, WXUINT flag
);
497 virtual void MSWOnWindowPosChanging(void *lpPos
);
498 virtual void MSWOnHScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
499 virtual void MSWOnVScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
500 virtual bool MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
501 virtual long MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
);
502 virtual bool MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
);
503 virtual WXHBRUSH
MSWOnCtlColor(WXHDC dc
, WXHWND pWnd
, WXUINT nCtlColor
,
504 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
505 virtual bool MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
506 virtual long MSWOnPaletteChanged(WXHWND hWndPalChange
);
507 virtual long MSWOnQueryNewPalette();
508 virtual bool MSWOnEraseBkgnd(WXHDC pDC
);
509 virtual void MSWOnMenuHighlight(WXWORD item
, WXWORD flags
, WXHMENU sysmenu
);
510 virtual void MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
);
511 virtual bool MSWOnClose(void);
512 virtual bool MSWOnDestroy(void);
513 virtual bool MSWOnSetFocus(WXHWND wnd
);
514 virtual bool MSWOnKillFocus(WXHWND wnd
);
515 virtual void MSWOnDropFiles(WXWPARAM wParam
);
516 virtual bool MSWOnInitDialog(WXHWND hWndFocus
);
517 virtual void MSWOnShow(bool show
, int status
);
519 // TODO: rationalise these functions into 1 or 2 which take the
520 // event type as argument.
521 virtual void MSWOnLButtonDown(int x
, int y
, WXUINT flags
);
522 virtual void MSWOnLButtonUp(int x
, int y
, WXUINT flags
);
523 virtual void MSWOnLButtonDClick(int x
, int y
, WXUINT flags
);
525 virtual void MSWOnMButtonDown(int x
, int y
, WXUINT flags
);
526 virtual void MSWOnMButtonUp(int x
, int y
, WXUINT flags
);
527 virtual void MSWOnMButtonDClick(int x
, int y
, WXUINT flags
);
529 virtual void MSWOnRButtonDown(int x
, int y
, WXUINT flags
);
530 virtual void MSWOnRButtonUp(int x
, int y
, WXUINT flags
);
531 virtual void MSWOnRButtonDClick(int x
, int y
, WXUINT flags
);
533 virtual void MSWOnMouseMove(int x
, int y
, WXUINT flags
);
534 virtual void MSWOnMouseEnter(int x
, int y
, WXUINT flags
);
535 virtual void MSWOnMouseLeave(int x
, int y
, WXUINT flags
);
537 virtual void MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
539 virtual bool MSWOnActivate(int flag
, bool minimized
, WXHWND activate
);
540 virtual long MSWOnMDIActivate(long flag
, WXHWND activate
, WXHWND deactivate
);
542 virtual bool MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*item
);
543 virtual bool MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*item
);
545 virtual void MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
);
546 virtual void MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
);
547 virtual void MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
);
548 virtual void MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
);
550 virtual long MSWGetDlgCode();
553 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
555 // Calls an appropriate default window procedure
556 virtual long MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
557 virtual bool MSWProcessMessage(WXMSG
* pMsg
);
558 virtual void MSWDestroyWindow(void);
560 // Detach "Window" menu from menu bar so it doesn't get deleted
561 void MSWDetachWindowMenu(void);
563 inline WXFARPROC
MSWGetOldWndProc() const;
564 inline void MSWSetOldWndProc(WXFARPROC proc
);
566 // Define for each class of dialog and control
567 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
568 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
570 inline void SetShowing(bool show
);
571 inline bool IsUserEnabled(void) const;
572 inline bool GetUseCtl3D(void) const ;
573 inline bool GetTransparentBackground(void) const ;
575 // Responds to colour changes: passes event on to children.
576 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
578 // Transfers data to any child controls
579 void OnInitDialog(wxInitDialogEvent
& event
);
581 // Sends an OnInitDialog event, which in turns transfers data to
582 // to the window via validators.
583 virtual void InitDialog(void);
585 ////////////////////////////////////////////////////////////////////////
589 long m_windowStyle
; // Store the window's style
590 wxEvtHandler
* m_windowEventHandler
; // Usually is 'this'
591 wxLayoutConstraints
* m_constraints
; // Constraints for this window
592 wxList
* m_constraintsInvolvedIn
; // List of constraints we're involved in
593 wxSizer
* m_windowSizer
; // Window's top-level sizer (if any)
594 wxWindow
* m_sizerParent
; // Window's parent sizer (if any)
595 bool m_autoLayout
; // Whether to call Layout() in OnSize
596 wxWindow
* m_windowParent
; // Each window always knows its parent
597 wxValidator
* m_windowValidator
;
598 // Old window proc, for subclassed controls
599 WXFARPROC m_oldWndProc
;
600 bool m_useCtl3D
; // Using CTL3D for this control
602 bool m_inOnSize
; // Protection against OnSize reentry
604 // Pointer to global memory, for EDIT controls that need
605 // special treatment to reduce USER area consumption.
606 WXHGLOBAL m_globalHandle
;
620 wxFont m_windowFont
; // Window's font
622 bool m_doubleClickAllowed
;
623 wxCursor m_windowCursor
; // Window's cursor
625 wxString m_windowName
; // Window name
627 #if USE_EXTENDED_STATICS
628 wxList m_staticItems
;
631 wxButton
* m_defaultItem
;
633 wxColour m_backgroundColour
;
634 wxColour m_defaultBackgroundColour
;
636 wxColour m_foregroundColour
;
637 wxColour m_defaultForegroundColour
;
639 bool m_backgroundTransparent
;
648 bool m_mouseInWindow
;
650 #if USE_DRAG_AND_DROP
651 wxDropTarget
*m_pDropTarget
; // the current drop target or NULL
652 #endif //USE_DRAG_AND_DROP
655 WXHWND m_hWnd
; // MS Windows window handle
657 WXWPARAM m_lastWParam
;
658 WXLPARAM m_lastLParam
;
660 wxRegion m_updateRegion
;
662 wxRectangle m_updateRect; // Bounding box for screen damage area
664 WXHRGN m_updateRgn; // NT allows access to the rectangle list
668 WXHANDLE m_acceleratorTable
;
669 WXHMENU m_hMenu
; // Menu, if any
670 wxList
* m_children
; // Window's children
672 bool m_isBeingDeleted
; // Fudge because can't access parent
673 // when being deleted
675 DECLARE_EVENT_TABLE()
678 ////////////////////////////////////////////////////////////////////////
681 inline void *wxWindow::GetHandle(void) const { return (void *)GetHWND(); }
682 inline int wxWindow::GetId() const { return m_windowId
; }
683 inline void wxWindow::SetId(int id
) { m_windowId
= id
; }
684 inline wxWindow
*wxWindow::GetParent(void) const { return m_windowParent
; }
685 inline void wxWindow::SetParent(wxWindow
*p
) { m_windowParent
= p
; }
686 inline wxWindow
*wxWindow::GetGrandParent(void) const { return (m_windowParent
? m_windowParent
->m_windowParent
: NULL
); }
687 inline wxList
*wxWindow::GetChildren() const { return m_children
; }
688 inline wxFont
*wxWindow::GetFont(void) const { return (wxFont
*) & m_windowFont
; }
689 inline wxString
wxWindow::GetName(void) const { return m_windowName
; }
690 inline void wxWindow::SetName(const wxString
& name
) { m_windowName
= name
; }
691 inline long wxWindow::GetWindowStyleFlag(void) const { return m_windowStyle
; }
692 inline void wxWindow::SetWindowStyleFlag(long flag
) { m_windowStyle
= flag
; }
693 inline void wxWindow::SetDoubleClick(bool flag
) { m_doubleClickAllowed
= flag
; }
694 inline bool wxWindow::GetDoubleClick(void) const { return m_doubleClickAllowed
; }
695 inline void wxWindow::SetEventHandler(wxEvtHandler
*handler
) { m_windowEventHandler
= handler
; }
696 inline wxEvtHandler
*wxWindow::GetEventHandler(void) const { return m_windowEventHandler
; }
697 inline void wxWindow::SetAutoLayout(bool a
) { m_autoLayout
= a
; }
698 inline bool wxWindow::GetAutoLayout(void) const { return m_autoLayout
; }
699 inline wxLayoutConstraints
*wxWindow::GetConstraints(void) const { return m_constraints
; }
700 inline void wxWindow::SetBackgroundColour(const wxColour
& col
) { m_backgroundColour
= col
; };
701 inline wxColour
wxWindow::GetBackgroundColour(void) const { return m_backgroundColour
; };
702 inline void wxWindow::SetForegroundColour(const wxColour
& col
) { m_foregroundColour
= col
; };
703 inline wxColour
wxWindow::GetForegroundColour(void) const { return m_foregroundColour
; };
704 inline void wxWindow::SetDefaultForegroundColour(const wxColour
& col
) { m_defaultForegroundColour
= col
; };
705 inline wxColour
wxWindow::GetDefaultForegroundColour(void) const { return m_defaultForegroundColour
; };
706 inline void wxWindow::SetDefaultBackgroundColour(const wxColour
& col
) { m_defaultBackgroundColour
= col
; };
707 inline wxColour
wxWindow::GetDefaultBackgroundColour(void) const { return m_defaultBackgroundColour
; };
709 inline wxButton
*wxWindow::GetDefaultItem(void) const { return m_defaultItem
; }
710 inline void wxWindow::SetDefaultItem(wxButton
*but
) { m_defaultItem
= but
; }
711 inline bool wxWindow::IsRetained(void) const { return ((m_windowStyle
& wxRETAINED
) == wxRETAINED
); }
713 inline void wxWindow::SetShowing(bool show
) { m_isShown
= show
; }
714 inline wxList
*wxWindow::GetConstraintsInvolvedIn(void) const { return m_constraintsInvolvedIn
; }
715 inline wxSizer
*wxWindow::GetSizer(void) const { return m_windowSizer
; }
716 inline wxWindow
*wxWindow::GetSizerParent(void) const { return m_sizerParent
; }
717 inline void wxWindow::SetSizerParent(wxWindow
*win
) { m_sizerParent
= win
; }
718 inline WXFARPROC
wxWindow::MSWGetOldWndProc() const { return m_oldWndProc
; }
719 inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
720 inline wxValidator
*wxWindow::GetValidator(void) const { return m_windowValidator
; }
721 inline bool wxWindow::IsUserEnabled(void) const { return m_winEnabled
; }
722 inline bool wxWindow::GetUseCtl3D(void) const { return m_useCtl3D
; }
723 inline bool wxWindow::GetTransparentBackground(void) const { return m_backgroundTransparent
; }
724 inline void wxWindow::SetReturnCode(int retCode
) { m_returnCode
= retCode
; }
725 inline int wxWindow::GetReturnCode(void) { return m_returnCode
; }
726 inline bool wxWindow::IsBeingDeleted(void) { return m_isBeingDeleted
; }
728 // Window specific (so far)
729 wxWindow
* WXDLLEXPORT
wxGetActiveWindow(void);
733 // Allows iteration through damaged rectangles in OnPaint
734 class WXDLLEXPORT wxUpdateIterator
736 int rects
; // How many rects in Update region
737 int current
; // Current rectangle index
738 void *rp
; // current rectangle
740 WXRGNDATA
*rlist
; // Storage for regiondata
744 wxUpdateIterator(wxWindow
* wnd
);
745 ~wxUpdateIterator(void);
748 wxUpdateIterator
* operator ++(int);
749 void GetRect(wxRectangle
*rect
);
757 WXDLLEXPORT_DATA(extern wxList
) wxTopLevelWindows
;
759 int WXDLLEXPORT
wxCharCodeMSWToWX(int keySym
);
760 int WXDLLEXPORT
wxCharCodeWXToMSW(int id
, bool *IsVirtual
);
762 // Allocates control ids
763 int WXDLLEXPORT
NewControlId(void);