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
)
100 Create(parent
, id
, pos
, size
, style
, name
);
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
114 // Show or hide the window
115 virtual bool Show(bool show
);
117 // Is the window shown?
118 virtual bool IsShown() const;
120 // Raise the window to the top of the Z order
121 virtual void Raise();
123 // Lower the window to the bottom of the Z order
124 virtual void Lower();
126 // Is the window enabled?
127 virtual bool IsEnabled() const;
130 inline bool Enabled() 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();
140 // Transfer values from controls. If returns FALSE,
141 // transfer failed: don't quit
142 virtual bool TransferDataFromWindow();
144 // Validate controls. If returns FALSE,
145 // validation failed: don't quit
146 virtual bool Validate();
148 // Return code for dialogs
149 inline void SetReturnCode(int retCode
);
150 inline int GetReturnCode();
153 virtual void SetCursor(const wxCursor
& cursor
);
154 inline virtual wxCursor
& GetCursor() const { return (wxCursor
& ) m_windowCursor
; };
156 // Get the window with the focus
157 static wxWindow
*FindFocus();
159 // Get character size
160 virtual int GetCharHeight() const;
161 virtual int GetCharWidth() const;
163 // Get overall window size
164 virtual void GetSize(int *width
, int *height
) const;
165 wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
167 // Get window position, relative to parent (or screen if no parent)
168 virtual void GetPosition(int *x
, int *y
) const;
169 wxPoint
GetPosition() const
170 { int x
, y
; GetPosition(&x
, &y
); return wxPoint(x
, y
); }
172 // Get size and position
173 wxRect
GetRect() const
174 { int x
, y
, w
, h
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
176 // Get client (application-useable) size
177 virtual void GetClientSize(int *width
, int *height
) const;
178 wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
180 // Set overall size and position
181 // generic function, may be overriden in derived classes
182 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
184 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
185 { SetSize(rect
.x
, rect
.y
, rect
.width
, rect
.height
, sizeFlags
); }
188 void SetSize(int width
, int height
)
189 { SetSize(-1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
190 void SetSize(const wxSize
& size
)
191 { SetSize(-1, -1, size
.x
, size
.y
, wxSIZE_USE_EXISTING
); }
194 virtual void Move(int x
, int y
) { SetSize(x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
195 void Move(const wxPoint
& pt
) { SetSize(pt
.x
, pt
.y
, -1, -1, wxSIZE_USE_EXISTING
); }
198 virtual void SetClientSize(int width
, int height
);
199 void SetClientSize(const wxSize
& sz
) { SetClientSize(sz
.x
, sz
.y
); }
201 // Convert client to screen coordinates
202 virtual void ClientToScreen(int *x
, int *y
) const;
203 wxPoint
ClientToScreen(const wxPoint
& pt
) const
204 { int x
= pt
.x
; int y
= pt
.y
; ClientToScreen(& x
, & y
); return wxPoint(x
, y
); }
206 // Convert screen to client coordinates
207 virtual void ScreenToClient(int *x
, int *y
) const;
208 wxPoint
ScreenToClient(const wxPoint
& pt
) const
209 { int x
= pt
.x
; int y
= pt
.y
; ScreenToClient(& x
, & y
); return wxPoint(x
, y
); }
211 // Set the focus to this window
212 virtual void SetFocus();
214 // Capture/release mouse
215 virtual void CaptureMouse();
216 virtual void ReleaseMouse();
218 // Enable or disable the window
219 virtual void Enable(bool enable
);
221 #if wxUSE_DRAG_AND_DROP
222 // Associate a drop target with this window (if the window already had a drop
223 // target, it's deleted!) and return the current drop target (may be NULL).
224 void SetDropTarget(wxDropTarget
*pDropTarget
);
225 wxDropTarget
*GetDropTarget() const { return m_pDropTarget
; }
228 // Accept files for dragging
229 virtual void DragAcceptFiles(bool accept
);
231 // Update region access
232 virtual wxRegion
GetUpdateRegion() const;
233 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
234 virtual bool IsExposed(const wxPoint
& pt
) const;
235 virtual bool IsExposed(const wxRect
& rect
) const;
237 // Set/get the window title
238 virtual inline void SetTitle(const wxString
& WXUNUSED(title
)) {};
239 inline virtual wxString
GetTitle() const { return wxString(""); };
240 // Most windows have the concept of a label; for frames, this is the
241 // title; for items, this is the label or button text.
242 inline virtual wxString
GetLabel() const { return GetTitle(); }
244 // Set/get the window name (used for resource setting in X)
245 inline virtual wxString
GetName() const;
246 inline virtual void SetName(const wxString
& name
);
249 virtual void Centre(int direction
) ;
250 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
253 virtual bool PopupMenu(wxMenu
*menu
, int x
, int y
);
255 // Send the window a refresh event
256 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
258 #if WXWIN_COMPATIBILITY
259 // Set/get scroll attributes
260 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
261 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
262 virtual int OldGetScrollRange(int orient
) const;
263 virtual int GetScrollPage(int orient
) const;
266 // New functions that will replace the above.
267 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
268 int range
, bool refresh
= TRUE
);
270 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
271 virtual int GetScrollPos(int orient
) const;
272 virtual int GetScrollRange(int orient
) const;
273 virtual int GetScrollThumb(int orient
) const;
275 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
277 // Caret manipulation
278 virtual void CreateCaret(int w
, int h
);
279 virtual void CreateCaret(const wxBitmap
*bitmap
);
280 virtual void DestroyCaret();
281 virtual void ShowCaret(bool show
);
282 virtual void SetCaretPos(int x
, int y
);
283 virtual void GetCaretPos(int *x
, int *y
) const;
285 // Tell window how much it can be sized
286 virtual void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
288 // Set/get the window's identifier
289 inline int GetId() const;
290 inline void SetId(int id
);
292 // Make the window modal (all other windows unresponsive)
293 virtual void MakeModal(bool modal
);
295 // Get the private handle (platform-dependent)
296 inline void *GetHandle() const;
298 // Set/get the window's relatives
299 inline wxWindow
*GetParent() const;
300 inline void SetParent(wxWindow
*p
) ;
301 inline wxWindow
*GetGrandParent() const;
302 inline wxList
& GetChildren() const;
303 // Set this window to be the child of 'parent'.
304 // Returns FALSE it's not possible (some systems
306 virtual bool Reparent(wxWindow
*parent
);
308 // Set/get the window's font
309 virtual void SetFont(const wxFont
& f
);
310 inline virtual wxFont
& GetFont() const;
312 // Set/get the window's validator
313 void SetValidator(const wxValidator
& validator
);
314 inline wxValidator
*GetValidator() const;
316 // Set/get the window's style
317 inline void SetWindowStyleFlag(long flag
);
318 inline long GetWindowStyleFlag() const;
320 // Set/get double-clickability
321 // TODO: we probably wish to get rid of this, and
322 // always allow double clicks.
323 inline void SetDoubleClick(bool flag
);
324 inline bool GetDoubleClick() const;
325 inline void AllowDoubleClick(bool value
) { SetDoubleClick(value
); }
327 // Handle a control command
328 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
330 // Set/get event handler
331 inline void SetEventHandler(wxEvtHandler
*handler
);
332 inline wxEvtHandler
*GetEventHandler() const;
334 // Push/pop event handler (i.e. allow a chain of event handlers
336 void PushEventHandler(wxEvtHandler
*handler
) ;
337 wxEvtHandler
*PopEventHandler(bool deleteHandler
= FALSE
) ;
339 // Close the window by calling OnClose, posting a deletion
340 virtual bool Close(bool force
= FALSE
);
342 // Destroy the window (delayed, if a managed window)
343 virtual bool Destroy() ;
345 // Mode for telling default OnSize members to
346 // call Layout(), if not using Sizers, just top-down constraints
347 inline void SetAutoLayout(bool a
);
348 inline bool GetAutoLayout() const;
350 // Set/get constraints
351 inline wxLayoutConstraints
*GetConstraints() const;
352 void SetConstraints(wxLayoutConstraints
*c
);
354 // Set/get window background colour
355 inline virtual void SetBackgroundColour(const wxColour
& col
);
356 inline virtual wxColour
GetBackgroundColour() const;
358 // Set/get window foreground colour
359 inline virtual void SetForegroundColour(const wxColour
& col
);
360 inline virtual wxColour
GetForegroundColour() const;
362 // For backward compatibility
363 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
364 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
365 inline virtual wxFont
& GetLabelFont() const { return GetFont(); };
366 inline virtual wxFont
& GetButtonFont() const { return GetFont(); };
368 // Get the default button, if there is one
369 inline virtual wxButton
*GetDefaultItem() const;
370 inline virtual void SetDefaultItem(wxButton
*but
);
372 virtual void SetAcceleratorTable(const wxAcceleratorTable
& accel
);
373 inline virtual wxAcceleratorTable
& GetAcceleratorTable() const { return (wxAcceleratorTable
&) m_acceleratorTable
; }
375 // Override to define new behaviour for default action (e.g. double clicking
377 virtual void OnDefaultAction(wxControl
*initiatingItem
);
380 #if wxUSE_WX_RESOURCES
381 virtual bool LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
= NULL
);
382 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
= NULL
);
385 // Native resource loading
386 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
387 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
388 virtual wxWindow
* GetWindowChild1(wxWindowID
& id
);
389 virtual wxWindow
* GetWindowChild(wxWindowID
& id
);
391 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
393 int *externalLeading
= NULL
,
394 const wxFont
*theFont
= NULL
, bool use16
= FALSE
) const;
396 // Is the window retained?
397 inline bool IsRetained() const;
399 // Warp the pointer the given position
400 virtual void WarpPointer(int x_pos
, int y_pos
) ;
403 virtual void Clear();
405 // Find a window by id or name
406 virtual wxWindow
*FindWindow(long id
);
407 virtual wxWindow
*FindWindow(const wxString
& name
);
409 // Constraint operations
411 void SetSizer(wxSizer
*sizer
); // Adds sizer child to this window
412 inline wxSizer
*GetSizer() const ;
413 inline wxWindow
*GetSizerParent() const ;
414 inline void SetSizerParent(wxWindow
*win
);
416 // Do Update UI processing for controls
417 void UpdateWindowUI();
419 void OnEraseBackground(wxEraseEvent
& event
);
420 void OnChar(wxKeyEvent
& event
);
421 void OnPaint(wxPaintEvent
& event
);
422 void OnIdle(wxIdleEvent
& event
);
424 // Does this window want to accept keyboard focus?
425 virtual bool AcceptsFocus() const;
427 virtual void PrepareDC( wxDC
&dc
) {};
429 ////////////////////////////////////////////////////////////////////////
432 // For implementation purposes - sometimes decorations make the client area
434 virtual wxPoint
GetClientAreaOrigin() const;
436 // Makes an adjustment to the window position (for example, a frame that has
437 // a toolbar that it manages itself).
438 virtual void AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
);
440 // Windows subclassing
441 void SubclassWin(WXHWND hWnd
);
442 void UnsubclassWin();
443 virtual long Default();
444 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
446 // returns TRUE if the event was processed
447 virtual bool MSWNotify(WXWPARAM wParam
, WXLPARAM lParam
, WXLPARAM
*result
);
449 virtual wxWindow
*FindItem(int id
) const;
450 virtual wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const ;
451 virtual void PreDelete(WXHDC dc
); // Allows system cleanup
452 // TO DO: how many of these need to be virtual?
453 virtual WXHWND
GetHWND() const ;
454 virtual void SetHWND(WXHWND hWnd
);
456 // Make a Windows extended style from the given wxWindows window style
457 virtual WXDWORD
MakeExtendedStyle(long style
, bool eliminateBorders
= TRUE
);
458 // Determine whether 3D effects are wanted
459 virtual WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
);
461 virtual void AddChild(wxWindow
*child
); // Adds reference to the child object
462 virtual void RemoveChild(wxWindow
*child
); // Removes reference to child
463 // (but doesn't delete the child object)
464 virtual void DestroyChildren(); // Removes and destroys all children
466 inline bool IsBeingDeleted();
468 // MSW only: TRUE if this control is part of the main control
469 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
471 // Constraint implementation
472 void UnsetConstraints(wxLayoutConstraints
*c
);
473 inline wxList
*GetConstraintsInvolvedIn() const ;
474 // Back-pointer to other windows we're involved with, so if we delete
475 // this window, we must delete any constraints we're involved with.
476 void AddConstraintReference(wxWindow
*otherWin
);
477 void RemoveConstraintReference(wxWindow
*otherWin
);
478 void DeleteRelatedConstraints();
480 virtual void ResetConstraints();
481 virtual void SetConstraintSizes(bool recurse
= TRUE
);
482 virtual bool LayoutPhase1(int *noChanges
);
483 virtual bool LayoutPhase2(int *noChanges
);
484 virtual bool DoPhase(int);
485 // Transforms from sizer coordinate space to actual
486 // parent coordinate space
487 virtual void TransformSizerToActual(int *x
, int *y
) const ;
489 // Set size with transformation to actual coordinates if nec.
490 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
491 virtual void SizerMove(int x
, int y
);
493 // Only set/get the size/position of the constraint (if any)
494 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
495 virtual void MoveConstraint(int x
, int y
);
496 virtual void GetSizeConstraint(int *w
, int *h
) const ;
497 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
498 virtual void GetPositionConstraint(int *x
, int *y
) const ;
500 // Dialog units translations. Implemented in wincmn.cpp.
501 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
502 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
503 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
504 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
505 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
506 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
508 wxObject
*GetChild(int number
) const ;
510 void MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
511 int x
, int y
, int width
, int height
,
512 WXDWORD style
, const char *dialog_template
= NULL
,
513 WXDWORD exendedStyle
= 0);
515 // Actually defined in wx_canvs.cc since requires wxCanvas declaration
516 virtual void MSWDeviceToLogical(float *x
, float *y
) const ;
518 // Create an appropriate wxWindow from a HWND
519 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
521 // Make sure the window style reflects the HWND style (roughly)
522 virtual void AdoptAttributesFromHWND();
524 // Setup background and foreground colours correctly
525 virtual void SetupColours();
527 // Saves the last message information before calling base version
528 virtual bool ProcessEvent(wxEvent
& event
);
531 virtual void MSWOnCreate(WXLPCREATESTRUCT cs
);
532 virtual bool MSWOnPaint();
533 virtual WXHICON
MSWOnQueryDragIcon() { return 0; }
534 virtual void MSWOnSize(int x
, int y
, WXUINT flag
);
535 virtual void MSWOnWindowPosChanging(void *lpPos
);
536 virtual void MSWOnHScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
537 virtual void MSWOnVScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
538 virtual bool MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
539 virtual long MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
);
540 virtual long MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
);
541 virtual WXHBRUSH
MSWOnCtlColor(WXHDC dc
, WXHWND pWnd
, WXUINT nCtlColor
,
542 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
543 virtual bool MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
544 virtual long MSWOnPaletteChanged(WXHWND hWndPalChange
);
545 virtual long MSWOnQueryNewPalette();
546 virtual bool MSWOnEraseBkgnd(WXHDC pDC
);
547 virtual void MSWOnMenuHighlight(WXWORD item
, WXWORD flags
, WXHMENU sysmenu
);
548 virtual void MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
);
549 virtual bool MSWOnClose();
550 // Return TRUE to end session, FALSE to veto end session.
551 virtual bool MSWOnQueryEndSession(long logOff
);
552 virtual bool MSWOnEndSession(bool endSession
, long logOff
);
553 virtual bool MSWOnDestroy();
554 virtual bool MSWOnSetFocus(WXHWND wnd
);
555 virtual bool MSWOnKillFocus(WXHWND wnd
);
556 virtual void MSWOnDropFiles(WXWPARAM wParam
);
557 virtual bool MSWOnInitDialog(WXHWND hWndFocus
);
558 virtual void MSWOnShow(bool show
, int status
);
560 // TODO: rationalise these functions into 1 or 2 which take the
561 // event type as argument.
562 virtual void MSWOnLButtonDown(int x
, int y
, WXUINT flags
);
563 virtual void MSWOnLButtonUp(int x
, int y
, WXUINT flags
);
564 virtual void MSWOnLButtonDClick(int x
, int y
, WXUINT flags
);
566 virtual void MSWOnMButtonDown(int x
, int y
, WXUINT flags
);
567 virtual void MSWOnMButtonUp(int x
, int y
, WXUINT flags
);
568 virtual void MSWOnMButtonDClick(int x
, int y
, WXUINT flags
);
570 virtual void MSWOnRButtonDown(int x
, int y
, WXUINT flags
);
571 virtual void MSWOnRButtonUp(int x
, int y
, WXUINT flags
);
572 virtual void MSWOnRButtonDClick(int x
, int y
, WXUINT flags
);
574 virtual void MSWOnMouseMove(int x
, int y
, WXUINT flags
);
575 virtual void MSWOnMouseEnter(int x
, int y
, WXUINT flags
);
576 virtual void MSWOnMouseLeave(int x
, int y
, WXUINT flags
);
578 virtual void MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
580 virtual bool MSWOnActivate(int flag
, bool minimized
, WXHWND activate
);
581 virtual long MSWOnMDIActivate(long flag
, WXHWND activate
, WXHWND deactivate
);
583 virtual bool MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*item
);
584 virtual bool MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*item
);
586 virtual void MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
);
587 virtual void MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
);
588 virtual void MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
);
589 virtual void MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
);
591 virtual long MSWGetDlgCode();
594 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
596 // Calls an appropriate default window procedure
597 virtual long MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
598 virtual bool MSWProcessMessage(WXMSG
* pMsg
);
599 virtual bool MSWTranslateMessage(WXMSG
* pMsg
);
600 virtual void MSWDestroyWindow();
602 // Detach "Window" menu from menu bar so it doesn't get deleted
603 void MSWDetachWindowMenu();
605 inline WXFARPROC
MSWGetOldWndProc() const;
606 inline void MSWSetOldWndProc(WXFARPROC proc
);
608 // Define for each class of dialog and control
609 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
610 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
612 inline void SetShowing(bool show
);
613 inline bool IsUserEnabled() const;
614 inline bool GetUseCtl3D() const ;
615 inline bool GetTransparentBackground() const ;
617 // Responds to colour changes: passes event on to children.
618 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
620 // Transfers data to any child controls
621 void OnInitDialog(wxInitDialogEvent
& event
);
623 // Sends an OnInitDialog event, which in turns transfers data to
624 // to the window via validators.
625 virtual void InitDialog();
627 ////////////////////////////////////////////////////////////////////////
630 wxAcceleratorTable m_acceleratorTable
;
632 long m_windowStyle
; // Store the window's style
633 wxEvtHandler
* m_windowEventHandler
; // Usually is 'this'
634 wxLayoutConstraints
* m_constraints
; // Constraints for this window
635 wxList
* m_constraintsInvolvedIn
; // List of constraints we're involved in
636 wxSizer
* m_windowSizer
; // Window's top-level sizer (if any)
637 wxWindow
* m_sizerParent
; // Window's parent sizer (if any)
638 bool m_autoLayout
; // Whether to call Layout() in OnSize
639 wxWindow
* m_windowParent
; // Each window always knows its parent
640 wxValidator
* m_windowValidator
;
641 // Old window proc, for subclassed controls
642 WXFARPROC m_oldWndProc
;
643 bool m_useCtl3D
; // Using CTL3D for this control
645 bool m_inOnSize
; // Protection against OnSize reentry
647 // Pointer to global memory, for EDIT controls that need
648 // special treatment to reduce USER area consumption.
649 WXHGLOBAL m_globalHandle
;
663 wxFont m_windowFont
; // Window's font
665 bool m_doubleClickAllowed
;
666 wxCursor m_windowCursor
; // Window's cursor
668 wxString m_windowName
; // Window name
670 #if wxUSE_EXTENDED_STATICS
671 wxList m_staticItems
;
674 wxButton
* m_defaultItem
;
675 wxColour m_backgroundColour
;
676 wxColour m_foregroundColour
;
677 bool m_backgroundTransparent
;
686 bool m_mouseInWindow
;
688 #if wxUSE_DRAG_AND_DROP
689 wxDropTarget
*m_pDropTarget
; // the current drop target or NULL
690 #endif //USE_DRAG_AND_DROP
693 WXHWND m_hWnd
; // MS Windows window handle
695 WXWPARAM m_lastWParam
;
696 WXLPARAM m_lastLParam
;
698 wxRegion m_updateRegion
;
700 wxRect m_updateRect; // Bounding box for screen damage area
702 WXHRGN m_updateRgn; // NT allows access to the rectangle list
706 // WXHANDLE m_acceleratorTable;
707 WXHMENU m_hMenu
; // Menu, if any
708 wxList
* m_children
; // Window's children
710 bool m_isBeingDeleted
; // Fudge because can't access parent
711 // when being deleted
714 // common part of all ctors
717 DECLARE_EVENT_TABLE()
720 ////////////////////////////////////////////////////////////////////////
723 inline void *wxWindow::GetHandle() const { return (void *)GetHWND(); }
724 inline int wxWindow::GetId() const { return m_windowId
; }
725 inline void wxWindow::SetId(int id
) { m_windowId
= id
; }
726 inline wxWindow
*wxWindow::GetParent() const { return m_windowParent
; }
727 inline void wxWindow::SetParent(wxWindow
*p
) { m_windowParent
= p
; }
728 inline wxWindow
*wxWindow::GetGrandParent() const { return (m_windowParent
? m_windowParent
->m_windowParent
: NULL
); }
729 inline wxList
& wxWindow::GetChildren() const { return (wxList
&) *m_children
; }
730 inline wxFont
& wxWindow::GetFont() const { return (wxFont
&) m_windowFont
; }
731 inline wxString
wxWindow::GetName() const { return m_windowName
; }
732 inline void wxWindow::SetName(const wxString
& name
) { m_windowName
= name
; }
733 inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle
; }
734 inline void wxWindow::SetWindowStyleFlag(long flag
) { m_windowStyle
= flag
; }
735 inline void wxWindow::SetDoubleClick(bool flag
) { m_doubleClickAllowed
= flag
; }
736 inline bool wxWindow::GetDoubleClick() const { return m_doubleClickAllowed
; }
737 inline void wxWindow::SetEventHandler(wxEvtHandler
*handler
) { m_windowEventHandler
= handler
; }
738 inline wxEvtHandler
*wxWindow::GetEventHandler() const { return m_windowEventHandler
; }
739 inline void wxWindow::SetAutoLayout(bool a
) { m_autoLayout
= a
; }
740 inline bool wxWindow::GetAutoLayout() const { return m_autoLayout
; }
741 inline wxLayoutConstraints
*wxWindow::GetConstraints() const { return m_constraints
; }
742 inline void wxWindow::SetBackgroundColour(const wxColour
& col
) { m_backgroundColour
= col
; };
743 inline wxColour
wxWindow::GetBackgroundColour() const { return m_backgroundColour
; };
744 inline void wxWindow::SetForegroundColour(const wxColour
& col
) { m_foregroundColour
= col
; };
745 inline wxColour
wxWindow::GetForegroundColour() const { return m_foregroundColour
; };
747 inline wxButton
*wxWindow::GetDefaultItem() const { return m_defaultItem
; }
748 inline void wxWindow::SetDefaultItem(wxButton
*but
) { m_defaultItem
= but
; }
749 inline bool wxWindow::IsRetained() const { return ((m_windowStyle
& wxRETAINED
) == wxRETAINED
); }
751 inline void wxWindow::SetShowing(bool show
) { m_isShown
= show
; }
752 inline wxList
*wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn
; }
753 inline wxSizer
*wxWindow::GetSizer() const { return m_windowSizer
; }
754 inline wxWindow
*wxWindow::GetSizerParent() const { return m_sizerParent
; }
755 inline void wxWindow::SetSizerParent(wxWindow
*win
) { m_sizerParent
= win
; }
756 inline WXFARPROC
wxWindow::MSWGetOldWndProc() const { return m_oldWndProc
; }
757 inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
758 inline wxValidator
*wxWindow::GetValidator() const { return m_windowValidator
; }
759 inline bool wxWindow::IsUserEnabled() const { return m_winEnabled
; }
760 inline bool wxWindow::GetUseCtl3D() const { return m_useCtl3D
; }
761 inline bool wxWindow::GetTransparentBackground() const { return m_backgroundTransparent
; }
762 inline void wxWindow::SetReturnCode(int retCode
) { m_returnCode
= retCode
; }
763 inline int wxWindow::GetReturnCode() { return m_returnCode
; }
764 inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted
; }
766 // Window specific (so far)
767 WXDLLEXPORT wxWindow
* wxGetActiveWindow();
769 WXDLLEXPORT_DATA(extern wxList
) wxTopLevelWindows
;
771 WXDLLEXPORT
int wxCharCodeMSWToWX(int keySym
);
772 WXDLLEXPORT
int wxCharCodeWXToMSW(int id
, bool *IsVirtual
);
774 // Allocates control ids
775 WXDLLEXPORT
int NewControlId();