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"
29 #include "wx/msw/accel.h"
35 * Base class for frame, panel, canvas, panel items, dialog box.
40 * Event handler: windows have themselves as their event handlers
41 * by default, but their event handlers could be set to another
42 * object entirely. This separation can reduce the amount of
43 * derivation required, and allow alteration of a window's functionality
44 * (e.g. by a resource editor that temporarily switches event handlers).
47 class WXDLLEXPORT wxWindow
;
48 class WXDLLEXPORT wxEvent
;
49 class WXDLLEXPORT wxCommandEvent
;
50 class WXDLLEXPORT wxKeyEvent
;
51 class WXDLLEXPORT wxControl
;
52 class WXDLLEXPORT wxCursor
;
53 class WXDLLEXPORT wxColourMap
;
54 class WXDLLEXPORT wxFont
;
55 class WXDLLEXPORT wxMenu
;
56 class WXDLLEXPORT wxRect
;
57 class WXDLLEXPORT wxBitmap
;
58 class WXDLLEXPORT wxSizer
;
59 class WXDLLEXPORT wxList
;
60 class WXDLLEXPORT wxLayoutConstraints
;
61 class WXDLLEXPORT wxMouseEvent
;
62 class WXDLLEXPORT wxButton
;
63 class WXDLLEXPORT wxColour
;
64 class WXDLLEXPORT wxBrush
;
65 class WXDLLEXPORT wxPen
;
66 class WXDLLEXPORT wxIcon
;
67 class WXDLLEXPORT wxDC
;
68 class WXDLLEXPORT wxValidator
;
70 #if wxUSE_DRAG_AND_DROP
71 class WXDLLEXPORT wxDropTarget
;
74 #if wxUSE_WX_RESOURCES
75 class WXDLLEXPORT wxResourceTable
;
76 class WXDLLEXPORT wxItemResource
;
79 WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr
;
81 WXDLLEXPORT_DATA(extern const wxSize
) wxDefaultSize
;
82 WXDLLEXPORT_DATA(extern const wxPoint
) wxDefaultPosition
;
84 class WXDLLEXPORT wxWindow
: public wxEvtHandler
86 DECLARE_ABSTRACT_CLASS(wxWindow
)
89 friend class wxPaintDC
;
93 wxWindow(wxWindow
*parent
, wxWindowID id
,
94 const wxPoint
& pos
= wxDefaultPosition
,
95 const wxSize
& size
= wxDefaultSize
,
97 const wxString
& name
= wxPanelNameStr
)
99 Create(parent
, id
, pos
, size
, style
, name
);
104 bool Create(wxWindow
*parent
, wxWindowID id
,
105 const wxPoint
& pos
= wxDefaultPosition
,
106 const wxSize
& size
= wxDefaultSize
,
108 const wxString
& name
= wxPanelNameStr
);
110 // Fit the window around the items
113 // Show or hide the window
114 virtual bool Show(bool show
);
116 // Is the window shown?
117 virtual bool IsShown() const;
119 // Raise the window to the top of the Z order
120 virtual void Raise();
122 // Lower the window to the bottom of the Z order
123 virtual void Lower();
125 // Is the window enabled?
126 virtual bool IsEnabled() const;
129 inline bool Enabled() const { return IsEnabled(); }
131 // Dialog support: override these and call
132 // base class members to add functionality
133 // that can't be done using validators.
135 // Transfer values to controls. If returns FALSE,
136 // it's an application error (pops up a dialog)
137 virtual bool TransferDataToWindow();
139 // Transfer values from controls. If returns FALSE,
140 // transfer failed: don't quit
141 virtual bool TransferDataFromWindow();
143 // Validate controls. If returns FALSE,
144 // validation failed: don't quit
145 virtual bool Validate();
147 // Return code for dialogs
148 inline void SetReturnCode(int retCode
);
149 inline int GetReturnCode();
152 virtual void SetCursor(const wxCursor
& cursor
);
153 inline virtual wxCursor
*GetCursor() const { return (wxCursor
*)& m_windowCursor
; };
155 // Get the window with the focus
156 static wxWindow
*FindFocus();
158 // Get character size
159 virtual int GetCharHeight() const;
160 virtual int GetCharWidth() const;
162 // Get overall window size
163 virtual void GetSize(int *width
, int *height
) const;
165 // Get window position, relative to parent (or screen if no parent)
166 virtual void GetPosition(int *x
, int *y
) const;
168 // Get client (application-useable) size
169 virtual void GetClientSize(int *width
, int *height
) const;
171 // Set overall size and position
172 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
173 inline virtual void SetSize(int width
, int height
) { SetSize(-1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
174 inline virtual void Move(int x
, int y
) { SetSize(x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
177 virtual void SetClientSize(int width
, int size
);
179 // Convert client to screen coordinates
180 virtual void ClientToScreen(int *x
, int *y
) const;
182 // Convert screen to client coordinates
183 virtual void ScreenToClient(int *x
, int *y
) const;
185 // Set the focus to this window
186 virtual void SetFocus();
188 // Capture/release mouse
189 virtual void CaptureMouse();
190 virtual void ReleaseMouse();
192 // Enable or disable the window
193 virtual void Enable(bool enable
);
195 #if wxUSE_DRAG_AND_DROP
196 // Associate a drop target with this window (if the window already had a drop
197 // target, it's deleted!) and return the current drop target (may be NULL).
198 void SetDropTarget(wxDropTarget
*pDropTarget
);
199 wxDropTarget
*GetDropTarget() const { return m_pDropTarget
; }
202 // Accept files for dragging
203 virtual void DragAcceptFiles(bool accept
);
205 // Update region access
206 virtual wxRegion
GetUpdateRegion() const;
207 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
208 virtual bool IsExposed(const wxPoint
& pt
) const;
209 virtual bool IsExposed(const wxRect
& rect
) const;
211 // Set/get the window title
212 virtual inline void SetTitle(const wxString
& WXUNUSED(title
)) {};
213 inline virtual wxString
GetTitle() const { return wxString(""); };
214 // Most windows have the concept of a label; for frames, this is the
215 // title; for items, this is the label or button text.
216 inline virtual wxString
GetLabel() const { return GetTitle(); }
218 // Set/get the window name (used for resource setting in X)
219 inline virtual wxString
GetName() const;
220 inline virtual void SetName(const wxString
& name
);
223 virtual void Centre(int direction
) ;
224 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
227 virtual bool PopupMenu(wxMenu
*menu
, int x
, int y
);
229 // Send the window a refresh event
230 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
232 #if WXWIN_COMPATIBILITY
233 // Set/get scroll attributes
234 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
235 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
236 virtual int OldGetScrollRange(int orient
) const;
237 virtual int GetScrollPage(int orient
) const;
240 // New functions that will replace the above.
241 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
242 int range
, bool refresh
= TRUE
);
244 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
245 virtual int GetScrollPos(int orient
) const;
246 virtual int GetScrollRange(int orient
) const;
247 virtual int GetScrollThumb(int orient
) const;
249 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
251 // Caret manipulation
252 virtual void CreateCaret(int w
, int h
);
253 virtual void CreateCaret(const wxBitmap
*bitmap
);
254 virtual void DestroyCaret();
255 virtual void ShowCaret(bool show
);
256 virtual void SetCaretPos(int x
, int y
);
257 virtual void GetCaretPos(int *x
, int *y
) const;
259 // Tell window how much it can be sized
260 virtual void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
262 // Set/get the window's identifier
263 inline int GetId() const;
264 inline void SetId(int id
);
266 // Make the window modal (all other windows unresponsive)
267 virtual void MakeModal(bool modal
);
269 // Get the private handle (platform-dependent)
270 inline void *GetHandle() const;
272 // Set/get the window's relatives
273 inline wxWindow
*GetParent() const;
274 inline void SetParent(wxWindow
*p
) ;
275 inline wxWindow
*GetGrandParent() const;
276 inline wxList
*GetChildren() const;
278 // Set/get the window's font
279 virtual void SetFont(const wxFont
& f
);
280 inline virtual wxFont
*GetFont() const;
282 // Set/get the window's validator
283 void SetValidator(const wxValidator
& validator
);
284 inline wxValidator
*GetValidator() const;
286 // Set/get the window's style
287 inline void SetWindowStyleFlag(long flag
);
288 inline long GetWindowStyleFlag() const;
290 // Set/get double-clickability
291 // TODO: we probably wish to get rid of this, and
292 // always allow double clicks.
293 inline void SetDoubleClick(bool flag
);
294 inline bool GetDoubleClick() const;
295 inline void AllowDoubleClick(bool value
) { SetDoubleClick(value
); }
297 // Handle a control command
298 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
300 // Set/get event handler
301 inline void SetEventHandler(wxEvtHandler
*handler
);
302 inline wxEvtHandler
*GetEventHandler() const;
304 // Push/pop event handler (i.e. allow a chain of event handlers
306 void PushEventHandler(wxEvtHandler
*handler
) ;
307 wxEvtHandler
*PopEventHandler(bool deleteHandler
= FALSE
) ;
309 // Close the window by calling OnClose, posting a deletion
310 virtual bool Close(bool force
= FALSE
);
312 // Destroy the window (delayed, if a managed window)
313 virtual bool Destroy() ;
315 // Mode for telling default OnSize members to
316 // call Layout(), if not using Sizers, just top-down constraints
317 inline void SetAutoLayout(bool a
);
318 inline bool GetAutoLayout() const;
320 // Set/get constraints
321 inline wxLayoutConstraints
*GetConstraints() const;
322 void SetConstraints(wxLayoutConstraints
*c
);
324 // Set/get window background colour
325 inline virtual void SetBackgroundColour(const wxColour
& col
);
326 inline virtual wxColour
GetBackgroundColour() const;
328 // Set/get window foreground colour
329 inline virtual void SetForegroundColour(const wxColour
& col
);
330 inline virtual wxColour
GetForegroundColour() const;
332 // For backward compatibility
333 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
334 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
335 inline virtual wxFont
*GetLabelFont() const { return GetFont(); };
336 inline virtual wxFont
*GetButtonFont() const { return GetFont(); };
338 // Get the default button, if there is one
339 inline virtual wxButton
*GetDefaultItem() const;
340 inline virtual void SetDefaultItem(wxButton
*but
);
342 virtual void SetAcceleratorTable(const wxAcceleratorTable
& accel
);
343 inline virtual wxAcceleratorTable
& GetAcceleratorTable() const { return (wxAcceleratorTable
&) m_acceleratorTable
; }
345 // Override to define new behaviour for default action (e.g. double clicking
347 virtual void OnDefaultAction(wxControl
*initiatingItem
);
350 #if wxUSE_WX_RESOURCES
351 virtual bool LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
= NULL
);
352 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
= NULL
);
355 // Native resource loading
356 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
357 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
358 virtual wxWindow
* GetWindowChild1(wxWindowID
& id
);
359 virtual wxWindow
* GetWindowChild(wxWindowID
& id
);
361 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
363 int *externalLeading
= NULL
,
364 const wxFont
*theFont
= NULL
, bool use16
= FALSE
) const;
366 // Is the window retained?
367 inline bool IsRetained() const;
369 // Warp the pointer the given position
370 virtual void WarpPointer(int x_pos
, int y_pos
) ;
373 virtual void Clear();
375 // Find a window by id or name
376 virtual wxWindow
*FindWindow(long id
);
377 virtual wxWindow
*FindWindow(const wxString
& name
);
379 // Constraint operations
381 void SetSizer(wxSizer
*sizer
); // Adds sizer child to this window
382 inline wxSizer
*GetSizer() const ;
383 inline wxWindow
*GetSizerParent() const ;
384 inline void SetSizerParent(wxWindow
*win
);
386 // Do Update UI processing for controls
387 void UpdateWindowUI();
389 void OnEraseBackground(wxEraseEvent
& event
);
390 void OnChar(wxKeyEvent
& event
);
391 void OnPaint(wxPaintEvent
& event
);
392 void OnIdle(wxIdleEvent
& event
);
394 // Does this window want to accept keyboard focus?
395 virtual bool AcceptsFocus() const;
397 virtual void PrepareDC( wxDC
&dc
) {};
399 ////////////////////////////////////////////////////////////////////////
402 // For implementation purposes - sometimes decorations make the client area
404 virtual wxPoint
GetClientAreaOrigin() const;
406 // Makes an adjustment to the window position (for example, a frame that has
407 // a toolbar that it manages itself).
408 virtual void AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
);
410 // Windows subclassing
411 void SubclassWin(WXHWND hWnd
);
412 void UnsubclassWin();
413 virtual long Default();
414 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
416 // returns TRUE if the event was processed
417 virtual bool MSWNotify(WXWPARAM wParam
, WXLPARAM lParam
, WXLPARAM
*result
);
419 virtual wxWindow
*FindItem(int id
) const;
420 virtual wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const ;
421 virtual void PreDelete(WXHDC dc
); // Allows system cleanup
422 // TO DO: how many of these need to be virtual?
423 virtual WXHWND
GetHWND() const ;
424 virtual void SetHWND(WXHWND hWnd
);
426 // Make a Windows extended style from the given wxWindows window style
427 virtual WXDWORD
MakeExtendedStyle(long style
, bool eliminateBorders
= TRUE
);
428 // Determine whether 3D effects are wanted
429 virtual WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
);
431 virtual void AddChild(wxWindow
*child
); // Adds reference to the child object
432 virtual void RemoveChild(wxWindow
*child
); // Removes reference to child
433 // (but doesn't delete the child object)
434 virtual void DestroyChildren(); // Removes and destroys all children
436 inline bool IsBeingDeleted();
438 // MSW only: TRUE if this control is part of the main control
439 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
441 // Constraint implementation
442 void UnsetConstraints(wxLayoutConstraints
*c
);
443 inline wxList
*GetConstraintsInvolvedIn() const ;
444 // Back-pointer to other windows we're involved with, so if we delete
445 // this window, we must delete any constraints we're involved with.
446 void AddConstraintReference(wxWindow
*otherWin
);
447 void RemoveConstraintReference(wxWindow
*otherWin
);
448 void DeleteRelatedConstraints();
450 virtual void ResetConstraints();
451 virtual void SetConstraintSizes(bool recurse
= TRUE
);
452 virtual bool LayoutPhase1(int *noChanges
);
453 virtual bool LayoutPhase2(int *noChanges
);
454 virtual bool DoPhase(int);
455 // Transforms from sizer coordinate space to actual
456 // parent coordinate space
457 virtual void TransformSizerToActual(int *x
, int *y
) const ;
459 // Set size with transformation to actual coordinates if nec.
460 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
461 virtual void SizerMove(int x
, int y
);
463 // Only set/get the size/position of the constraint (if any)
464 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
465 virtual void MoveConstraint(int x
, int y
);
466 virtual void GetSizeConstraint(int *w
, int *h
) const ;
467 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
468 virtual void GetPositionConstraint(int *x
, int *y
) const ;
470 // Dialog units translations. Implemented in wincmn.cpp.
471 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
472 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
473 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
474 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
475 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
476 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
478 wxObject
*GetChild(int number
) const ;
480 void MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
481 int x
, int y
, int width
, int height
,
482 WXDWORD style
, const char *dialog_template
= NULL
,
483 WXDWORD exendedStyle
= 0);
485 // Actually defined in wx_canvs.cc since requires wxCanvas declaration
486 virtual void MSWDeviceToLogical(float *x
, float *y
) const ;
488 // Create an appropriate wxWindow from a HWND
489 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
491 // Make sure the window style reflects the HWND style (roughly)
492 virtual void AdoptAttributesFromHWND();
494 // Setup background and foreground colours correctly
495 virtual void SetupColours();
497 // Saves the last message information before calling base version
498 virtual bool ProcessEvent(wxEvent
& event
);
501 virtual void MSWOnCreate(WXLPCREATESTRUCT cs
);
502 virtual bool MSWOnPaint();
503 virtual WXHICON
MSWOnQueryDragIcon() { return 0; }
504 virtual void MSWOnSize(int x
, int y
, WXUINT flag
);
505 virtual void MSWOnWindowPosChanging(void *lpPos
);
506 virtual void MSWOnHScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
507 virtual void MSWOnVScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
508 virtual bool MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
509 virtual long MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
);
510 virtual long MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
);
511 virtual WXHBRUSH
MSWOnCtlColor(WXHDC dc
, WXHWND pWnd
, WXUINT nCtlColor
,
512 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
513 virtual bool MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
514 virtual long MSWOnPaletteChanged(WXHWND hWndPalChange
);
515 virtual long MSWOnQueryNewPalette();
516 virtual bool MSWOnEraseBkgnd(WXHDC pDC
);
517 virtual void MSWOnMenuHighlight(WXWORD item
, WXWORD flags
, WXHMENU sysmenu
);
518 virtual void MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
);
519 virtual bool MSWOnClose();
520 // Return TRUE to end session, FALSE to veto end session.
521 virtual bool MSWOnQueryEndSession(long logOff
);
522 virtual bool MSWOnEndSession(bool endSession
, long logOff
);
523 virtual bool MSWOnDestroy();
524 virtual bool MSWOnSetFocus(WXHWND wnd
);
525 virtual bool MSWOnKillFocus(WXHWND wnd
);
526 virtual void MSWOnDropFiles(WXWPARAM wParam
);
527 virtual bool MSWOnInitDialog(WXHWND hWndFocus
);
528 virtual void MSWOnShow(bool show
, int status
);
530 // TODO: rationalise these functions into 1 or 2 which take the
531 // event type as argument.
532 virtual void MSWOnLButtonDown(int x
, int y
, WXUINT flags
);
533 virtual void MSWOnLButtonUp(int x
, int y
, WXUINT flags
);
534 virtual void MSWOnLButtonDClick(int x
, int y
, WXUINT flags
);
536 virtual void MSWOnMButtonDown(int x
, int y
, WXUINT flags
);
537 virtual void MSWOnMButtonUp(int x
, int y
, WXUINT flags
);
538 virtual void MSWOnMButtonDClick(int x
, int y
, WXUINT flags
);
540 virtual void MSWOnRButtonDown(int x
, int y
, WXUINT flags
);
541 virtual void MSWOnRButtonUp(int x
, int y
, WXUINT flags
);
542 virtual void MSWOnRButtonDClick(int x
, int y
, WXUINT flags
);
544 virtual void MSWOnMouseMove(int x
, int y
, WXUINT flags
);
545 virtual void MSWOnMouseEnter(int x
, int y
, WXUINT flags
);
546 virtual void MSWOnMouseLeave(int x
, int y
, WXUINT flags
);
548 virtual void MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
550 virtual bool MSWOnActivate(int flag
, bool minimized
, WXHWND activate
);
551 virtual long MSWOnMDIActivate(long flag
, WXHWND activate
, WXHWND deactivate
);
553 virtual bool MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*item
);
554 virtual bool MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*item
);
556 virtual void MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
);
557 virtual void MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
);
558 virtual void MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
);
559 virtual void MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
);
561 virtual long MSWGetDlgCode();
564 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
566 // Calls an appropriate default window procedure
567 virtual long MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
568 virtual bool MSWProcessMessage(WXMSG
* pMsg
);
569 virtual bool MSWTranslateMessage(WXMSG
* pMsg
);
570 virtual void MSWDestroyWindow();
572 // Detach "Window" menu from menu bar so it doesn't get deleted
573 void MSWDetachWindowMenu();
575 inline WXFARPROC
MSWGetOldWndProc() const;
576 inline void MSWSetOldWndProc(WXFARPROC proc
);
578 // Define for each class of dialog and control
579 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
580 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
582 inline void SetShowing(bool show
);
583 inline bool IsUserEnabled() const;
584 inline bool GetUseCtl3D() const ;
585 inline bool GetTransparentBackground() const ;
587 // Responds to colour changes: passes event on to children.
588 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
590 // Transfers data to any child controls
591 void OnInitDialog(wxInitDialogEvent
& event
);
593 // Sends an OnInitDialog event, which in turns transfers data to
594 // to the window via validators.
595 virtual void InitDialog();
597 ////////////////////////////////////////////////////////////////////////
600 wxAcceleratorTable m_acceleratorTable
;
602 long m_windowStyle
; // Store the window's style
603 wxEvtHandler
* m_windowEventHandler
; // Usually is 'this'
604 wxLayoutConstraints
* m_constraints
; // Constraints for this window
605 wxList
* m_constraintsInvolvedIn
; // List of constraints we're involved in
606 wxSizer
* m_windowSizer
; // Window's top-level sizer (if any)
607 wxWindow
* m_sizerParent
; // Window's parent sizer (if any)
608 bool m_autoLayout
; // Whether to call Layout() in OnSize
609 wxWindow
* m_windowParent
; // Each window always knows its parent
610 wxValidator
* m_windowValidator
;
611 // Old window proc, for subclassed controls
612 WXFARPROC m_oldWndProc
;
613 bool m_useCtl3D
; // Using CTL3D for this control
615 bool m_inOnSize
; // Protection against OnSize reentry
617 // Pointer to global memory, for EDIT controls that need
618 // special treatment to reduce USER area consumption.
619 WXHGLOBAL m_globalHandle
;
633 wxFont m_windowFont
; // Window's font
635 bool m_doubleClickAllowed
;
636 wxCursor m_windowCursor
; // Window's cursor
638 wxString m_windowName
; // Window name
640 #if wxUSE_EXTENDED_STATICS
641 wxList m_staticItems
;
644 wxButton
* m_defaultItem
;
645 wxColour m_backgroundColour
;
646 wxColour m_foregroundColour
;
647 bool m_backgroundTransparent
;
656 bool m_mouseInWindow
;
658 #if wxUSE_DRAG_AND_DROP
659 wxDropTarget
*m_pDropTarget
; // the current drop target or NULL
660 #endif //USE_DRAG_AND_DROP
663 WXHWND m_hWnd
; // MS Windows window handle
665 WXWPARAM m_lastWParam
;
666 WXLPARAM m_lastLParam
;
668 wxRegion m_updateRegion
;
670 wxRect m_updateRect; // Bounding box for screen damage area
672 WXHRGN m_updateRgn; // NT allows access to the rectangle list
676 // WXHANDLE m_acceleratorTable;
677 WXHMENU m_hMenu
; // Menu, if any
678 wxList
* m_children
; // Window's children
680 bool m_isBeingDeleted
; // Fudge because can't access parent
681 // when being deleted
684 // common part of all ctors
687 DECLARE_EVENT_TABLE()
690 ////////////////////////////////////////////////////////////////////////
693 inline void *wxWindow::GetHandle() const { return (void *)GetHWND(); }
694 inline int wxWindow::GetId() const { return m_windowId
; }
695 inline void wxWindow::SetId(int id
) { m_windowId
= id
; }
696 inline wxWindow
*wxWindow::GetParent() const { return m_windowParent
; }
697 inline void wxWindow::SetParent(wxWindow
*p
) { m_windowParent
= p
; }
698 inline wxWindow
*wxWindow::GetGrandParent() const { return (m_windowParent
? m_windowParent
->m_windowParent
: NULL
); }
699 inline wxList
*wxWindow::GetChildren() const { return m_children
; }
700 inline wxFont
*wxWindow::GetFont() const { return (wxFont
*) & m_windowFont
; }
701 inline wxString
wxWindow::GetName() const { return m_windowName
; }
702 inline void wxWindow::SetName(const wxString
& name
) { m_windowName
= name
; }
703 inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle
; }
704 inline void wxWindow::SetWindowStyleFlag(long flag
) { m_windowStyle
= flag
; }
705 inline void wxWindow::SetDoubleClick(bool flag
) { m_doubleClickAllowed
= flag
; }
706 inline bool wxWindow::GetDoubleClick() const { return m_doubleClickAllowed
; }
707 inline void wxWindow::SetEventHandler(wxEvtHandler
*handler
) { m_windowEventHandler
= handler
; }
708 inline wxEvtHandler
*wxWindow::GetEventHandler() const { return m_windowEventHandler
; }
709 inline void wxWindow::SetAutoLayout(bool a
) { m_autoLayout
= a
; }
710 inline bool wxWindow::GetAutoLayout() const { return m_autoLayout
; }
711 inline wxLayoutConstraints
*wxWindow::GetConstraints() const { return m_constraints
; }
712 inline void wxWindow::SetBackgroundColour(const wxColour
& col
) { m_backgroundColour
= col
; };
713 inline wxColour
wxWindow::GetBackgroundColour() const { return m_backgroundColour
; };
714 inline void wxWindow::SetForegroundColour(const wxColour
& col
) { m_foregroundColour
= col
; };
715 inline wxColour
wxWindow::GetForegroundColour() const { return m_foregroundColour
; };
717 inline wxButton
*wxWindow::GetDefaultItem() const { return m_defaultItem
; }
718 inline void wxWindow::SetDefaultItem(wxButton
*but
) { m_defaultItem
= but
; }
719 inline bool wxWindow::IsRetained() const { return ((m_windowStyle
& wxRETAINED
) == wxRETAINED
); }
721 inline void wxWindow::SetShowing(bool show
) { m_isShown
= show
; }
722 inline wxList
*wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn
; }
723 inline wxSizer
*wxWindow::GetSizer() const { return m_windowSizer
; }
724 inline wxWindow
*wxWindow::GetSizerParent() const { return m_sizerParent
; }
725 inline void wxWindow::SetSizerParent(wxWindow
*win
) { m_sizerParent
= win
; }
726 inline WXFARPROC
wxWindow::MSWGetOldWndProc() const { return m_oldWndProc
; }
727 inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
728 inline wxValidator
*wxWindow::GetValidator() const { return m_windowValidator
; }
729 inline bool wxWindow::IsUserEnabled() const { return m_winEnabled
; }
730 inline bool wxWindow::GetUseCtl3D() const { return m_useCtl3D
; }
731 inline bool wxWindow::GetTransparentBackground() const { return m_backgroundTransparent
; }
732 inline void wxWindow::SetReturnCode(int retCode
) { m_returnCode
= retCode
; }
733 inline int wxWindow::GetReturnCode() { return m_returnCode
; }
734 inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted
; }
736 // Window specific (so far)
737 WXDLLEXPORT wxWindow
* wxGetActiveWindow();
739 WXDLLEXPORT_DATA(extern wxList
) wxTopLevelWindows
;
741 WXDLLEXPORT
int wxCharCodeMSWToWX(int keySym
);
742 WXDLLEXPORT
int wxCharCodeWXToMSW(int id
, bool *IsVirtual
);
744 // Allocates control ids
745 WXDLLEXPORT
int NewControlId();