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 //-----------------------------------------------------------------------------
86 //-----------------------------------------------------------------------------
92 virtual ~wxClientData() { }
95 //-----------------------------------------------------------------------------
97 //-----------------------------------------------------------------------------
99 class wxStringClientData
: public wxClientData
102 wxStringClientData() { }
103 wxStringClientData( wxString
&data
) { m_data
= data
; }
104 void SetData( wxString
&data
) { m_data
= data
; }
105 wxString
GetData() const { return m_data
; }
111 class WXDLLEXPORT wxWindow
: public wxEvtHandler
113 DECLARE_ABSTRACT_CLASS(wxWindow
)
116 friend class wxPaintDC
;
120 wxWindow(wxWindow
*parent
, wxWindowID id
,
121 const wxPoint
& pos
= wxDefaultPosition
,
122 const wxSize
& size
= wxDefaultSize
,
124 const wxString
& name
= wxPanelNameStr
)
127 Create(parent
, id
, pos
, size
, style
, name
);
132 bool Create(wxWindow
*parent
, wxWindowID id
,
133 const wxPoint
& pos
= wxDefaultPosition
,
134 const wxSize
& size
= wxDefaultSize
,
136 const wxString
& name
= wxPanelNameStr
);
138 // Fit the window around the items
141 // Show or hide the window
142 virtual bool Show(bool show
);
144 // Is the window shown?
145 virtual bool IsShown() const;
147 // Raise the window to the top of the Z order
148 virtual void Raise();
150 // Lower the window to the bottom of the Z order
151 virtual void Lower();
153 // Is the window enabled?
154 virtual bool IsEnabled() const;
157 inline bool Enabled() const { return IsEnabled(); }
159 // Dialog support: override these and call
160 // base class members to add functionality
161 // that can't be done using validators.
163 // Transfer values to controls. If returns FALSE,
164 // it's an application error (pops up a dialog)
165 virtual bool TransferDataToWindow();
167 // Transfer values from controls. If returns FALSE,
168 // transfer failed: don't quit
169 virtual bool TransferDataFromWindow();
171 // Validate controls. If returns FALSE,
172 // validation failed: don't quit
173 virtual bool Validate();
175 // Return code for dialogs
176 inline void SetReturnCode(int retCode
);
177 inline int GetReturnCode();
180 virtual void SetCursor(const wxCursor
& cursor
);
181 inline virtual wxCursor
& GetCursor() const { return (wxCursor
& ) m_windowCursor
; };
183 // Get the window with the focus
184 static wxWindow
*FindFocus();
186 // Get character size
187 virtual int GetCharHeight() const;
188 virtual int GetCharWidth() const;
190 // Get overall window size
191 virtual void GetSize(int *width
, int *height
) const;
192 wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
194 // Get window position, relative to parent (or screen if no parent)
195 virtual void GetPosition(int *x
, int *y
) const;
196 wxPoint
GetPosition() const
197 { int x
, y
; GetPosition(&x
, &y
); return wxPoint(x
, y
); }
199 // Get size and position
200 wxRect
GetRect() const
201 { int x
, y
, w
, h
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
203 // Get client (application-useable) size
204 virtual void GetClientSize(int *width
, int *height
) const;
205 wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
207 // Set overall size and position
208 // generic function, may be overriden in derived classes
209 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
211 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
212 { SetSize(rect
.x
, rect
.y
, rect
.width
, rect
.height
, sizeFlags
); }
215 void SetSize(int width
, int height
)
216 { SetSize(-1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
217 void SetSize(const wxSize
& size
)
218 { SetSize(-1, -1, size
.x
, size
.y
, wxSIZE_USE_EXISTING
); }
221 virtual void Move(int x
, int y
) { SetSize(x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
222 void Move(const wxPoint
& pt
) { SetSize(pt
.x
, pt
.y
, -1, -1, wxSIZE_USE_EXISTING
); }
225 virtual void SetClientSize(int width
, int height
);
226 void SetClientSize(const wxSize
& sz
) { SetClientSize(sz
.x
, sz
.y
); }
228 // Convert client to screen coordinates
229 virtual void ClientToScreen(int *x
, int *y
) const;
230 wxPoint
ClientToScreen(const wxPoint
& pt
) const
231 { int x
= pt
.x
; int y
= pt
.y
; ClientToScreen(& x
, & y
); return wxPoint(x
, y
); }
233 // Convert screen to client coordinates
234 virtual void ScreenToClient(int *x
, int *y
) const;
235 wxPoint
ScreenToClient(const wxPoint
& pt
) const
236 { int x
= pt
.x
; int y
= pt
.y
; ScreenToClient(& x
, & y
); return wxPoint(x
, y
); }
238 // Set the focus to this window
239 virtual void SetFocus();
241 // Capture/release mouse
242 virtual void CaptureMouse();
243 virtual void ReleaseMouse();
245 // Enable or disable the window
246 virtual void Enable(bool enable
);
248 #if wxUSE_DRAG_AND_DROP
249 // Associate a drop target with this window (if the window already had a drop
250 // target, it's deleted!) and return the current drop target (may be NULL).
251 void SetDropTarget(wxDropTarget
*pDropTarget
);
252 wxDropTarget
*GetDropTarget() const { return m_pDropTarget
; }
255 // Accept files for dragging
256 virtual void DragAcceptFiles(bool accept
);
258 // Update region access
259 virtual wxRegion
GetUpdateRegion() const;
260 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
261 virtual bool IsExposed(const wxPoint
& pt
) const;
262 virtual bool IsExposed(const wxRect
& rect
) const;
264 // Set/get the window title
265 virtual inline void SetTitle(const wxString
& WXUNUSED(title
)) {};
266 inline virtual wxString
GetTitle() const { return wxString(""); };
267 // Most windows have the concept of a label; for frames, this is the
268 // title; for items, this is the label or button text.
269 inline virtual wxString
GetLabel() const { return GetTitle(); }
271 // Set/get the window name (used for resource setting in X)
272 inline virtual wxString
GetName() const;
273 inline virtual void SetName(const wxString
& name
);
276 virtual void Centre(int direction
) ;
277 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
280 virtual bool PopupMenu(wxMenu
*menu
, int x
, int y
);
282 // Send the window a refresh event
283 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
285 #if WXWIN_COMPATIBILITY
286 // Set/get scroll attributes
287 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
288 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
289 virtual int OldGetScrollRange(int orient
) const;
290 virtual int GetScrollPage(int orient
) const;
293 // New functions that will replace the above.
294 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
295 int range
, bool refresh
= TRUE
);
297 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
298 virtual int GetScrollPos(int orient
) const;
299 virtual int GetScrollRange(int orient
) const;
300 virtual int GetScrollThumb(int orient
) const;
302 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
304 // Caret manipulation
305 virtual void CreateCaret(int w
, int h
);
306 virtual void CreateCaret(const wxBitmap
*bitmap
);
307 virtual void DestroyCaret();
308 virtual void ShowCaret(bool show
);
309 virtual void SetCaretPos(int x
, int y
);
310 virtual void GetCaretPos(int *x
, int *y
) const;
312 // Tell window how much it can be sized
313 virtual void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
315 // Set/get the window's identifier
316 inline int GetId() const;
317 inline void SetId(int id
);
319 // Make the window modal (all other windows unresponsive)
320 virtual void MakeModal(bool modal
);
322 // Get the private handle (platform-dependent)
323 inline void *GetHandle() const;
325 // Set/get the window's relatives
326 inline wxWindow
*GetParent() const;
327 inline void SetParent(wxWindow
*p
) ;
328 inline wxWindow
*GetGrandParent() const;
329 inline wxList
& GetChildren() const;
330 // Set this window to be the child of 'parent'.
331 // Returns FALSE it's not possible (some systems
333 virtual bool Reparent(wxWindow
*parent
);
335 // Set/get the window's font
336 virtual void SetFont(const wxFont
& f
);
337 inline virtual wxFont
& GetFont() const;
339 // Set/get the window's validator
340 void SetValidator(const wxValidator
& validator
);
341 inline wxValidator
*GetValidator() const;
343 // Set/get the window's style
344 inline void SetWindowStyleFlag(long flag
);
345 inline long GetWindowStyleFlag() const;
347 // Set/get double-clickability
348 // TODO: we probably wish to get rid of this, and
349 // always allow double clicks.
350 inline void SetDoubleClick(bool flag
);
351 inline bool GetDoubleClick() const;
352 inline void AllowDoubleClick(bool value
) { SetDoubleClick(value
); }
354 // Handle a control command
355 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
357 // Set/get event handler
358 inline void SetEventHandler(wxEvtHandler
*handler
);
359 inline wxEvtHandler
*GetEventHandler() const;
361 // Push/pop event handler (i.e. allow a chain of event handlers
363 void PushEventHandler(wxEvtHandler
*handler
) ;
364 wxEvtHandler
*PopEventHandler(bool deleteHandler
= FALSE
) ;
366 // Close the window by calling OnClose, posting a deletion
367 virtual bool Close(bool force
= FALSE
);
369 // Destroy the window (delayed, if a managed window)
370 virtual bool Destroy() ;
372 // Mode for telling default OnSize members to
373 // call Layout(), if not using Sizers, just top-down constraints
374 inline void SetAutoLayout(bool a
);
375 inline bool GetAutoLayout() const;
377 // Set/get constraints
378 inline wxLayoutConstraints
*GetConstraints() const;
379 void SetConstraints(wxLayoutConstraints
*c
);
381 // Set/get window background colour
382 inline virtual void SetBackgroundColour(const wxColour
& col
);
383 inline virtual wxColour
GetBackgroundColour() const;
385 // Set/get window foreground colour
386 inline virtual void SetForegroundColour(const wxColour
& col
);
387 inline virtual wxColour
GetForegroundColour() const;
389 // For backward compatibility
390 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
391 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
392 inline virtual wxFont
& GetLabelFont() const { return GetFont(); };
393 inline virtual wxFont
& GetButtonFont() const { return GetFont(); };
395 // Get the default button, if there is one
396 inline virtual wxButton
*GetDefaultItem() const;
397 inline virtual void SetDefaultItem(wxButton
*but
);
399 virtual void SetAcceleratorTable(const wxAcceleratorTable
& accel
);
400 inline virtual wxAcceleratorTable
& GetAcceleratorTable() const { return (wxAcceleratorTable
&) m_acceleratorTable
; }
402 // Override to define new behaviour for default action (e.g. double clicking
404 virtual void OnDefaultAction(wxControl
*initiatingItem
);
407 #if wxUSE_WX_RESOURCES
408 virtual bool LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
= NULL
);
409 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
= NULL
);
412 // Native resource loading
413 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
414 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
415 virtual wxWindow
* GetWindowChild1(wxWindowID
& id
);
416 virtual wxWindow
* GetWindowChild(wxWindowID
& id
);
418 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
420 int *externalLeading
= NULL
,
421 const wxFont
*theFont
= NULL
, bool use16
= FALSE
) const;
423 // Is the window retained?
424 inline bool IsRetained() const;
426 // Warp the pointer the given position
427 virtual void WarpPointer(int x_pos
, int y_pos
) ;
430 virtual void Clear();
432 // Find a window by id or name
433 virtual wxWindow
*FindWindow(long id
);
434 virtual wxWindow
*FindWindow(const wxString
& name
);
436 // Constraint operations
438 void SetSizer(wxSizer
*sizer
); // Adds sizer child to this window
439 inline wxSizer
*GetSizer() const ;
440 inline wxWindow
*GetSizerParent() const ;
441 inline void SetSizerParent(wxWindow
*win
);
443 // Do Update UI processing for controls
444 void UpdateWindowUI();
446 void OnEraseBackground(wxEraseEvent
& event
);
447 void OnChar(wxKeyEvent
& event
);
448 void OnPaint(wxPaintEvent
& event
);
449 void OnIdle(wxIdleEvent
& event
);
451 // Does this window want to accept keyboard focus?
452 virtual bool AcceptsFocus() const;
454 virtual void PrepareDC( wxDC
&dc
) {};
456 ////////////////////////////////////////////////////////////////////////
459 // For implementation purposes - sometimes decorations make the client area
461 virtual wxPoint
GetClientAreaOrigin() const;
463 // Makes an adjustment to the window position (for example, a frame that has
464 // a toolbar that it manages itself).
465 virtual void AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
);
467 // Windows subclassing
468 void SubclassWin(WXHWND hWnd
);
469 void UnsubclassWin();
470 virtual long Default();
471 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
473 // returns TRUE if the event was processed
474 virtual bool MSWNotify(WXWPARAM wParam
, WXLPARAM lParam
, WXLPARAM
*result
);
476 virtual wxWindow
*FindItem(int id
) const;
477 virtual wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const ;
478 virtual void PreDelete(WXHDC dc
); // Allows system cleanup
479 // TO DO: how many of these need to be virtual?
480 virtual WXHWND
GetHWND() const ;
481 virtual void SetHWND(WXHWND hWnd
);
483 // Make a Windows extended style from the given wxWindows window style
484 virtual WXDWORD
MakeExtendedStyle(long style
, bool eliminateBorders
= TRUE
);
485 // Determine whether 3D effects are wanted
486 virtual WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
);
488 virtual void AddChild(wxWindow
*child
); // Adds reference to the child object
489 virtual void RemoveChild(wxWindow
*child
); // Removes reference to child
490 // (but doesn't delete the child object)
491 virtual void DestroyChildren(); // Removes and destroys all children
493 inline bool IsBeingDeleted();
495 // MSW only: TRUE if this control is part of the main control
496 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
498 // Constraint implementation
499 void UnsetConstraints(wxLayoutConstraints
*c
);
500 inline wxList
*GetConstraintsInvolvedIn() const ;
501 // Back-pointer to other windows we're involved with, so if we delete
502 // this window, we must delete any constraints we're involved with.
503 void AddConstraintReference(wxWindow
*otherWin
);
504 void RemoveConstraintReference(wxWindow
*otherWin
);
505 void DeleteRelatedConstraints();
507 virtual void ResetConstraints();
508 virtual void SetConstraintSizes(bool recurse
= TRUE
);
509 virtual bool LayoutPhase1(int *noChanges
);
510 virtual bool LayoutPhase2(int *noChanges
);
511 virtual bool DoPhase(int);
512 // Transforms from sizer coordinate space to actual
513 // parent coordinate space
514 virtual void TransformSizerToActual(int *x
, int *y
) const ;
516 // Set size with transformation to actual coordinates if nec.
517 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
518 virtual void SizerMove(int x
, int y
);
520 // Only set/get the size/position of the constraint (if any)
521 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
522 virtual void MoveConstraint(int x
, int y
);
523 virtual void GetSizeConstraint(int *w
, int *h
) const ;
524 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
525 virtual void GetPositionConstraint(int *x
, int *y
) const ;
527 // Dialog units translations. Implemented in wincmn.cpp.
528 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
529 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
530 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
531 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
532 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
533 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
535 wxObject
*GetChild(int number
) const ;
537 void MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
538 int x
, int y
, int width
, int height
,
539 WXDWORD style
, const char *dialog_template
= NULL
,
540 WXDWORD exendedStyle
= 0);
542 // Actually defined in wx_canvs.cc since requires wxCanvas declaration
543 virtual void MSWDeviceToLogical(float *x
, float *y
) const ;
545 // Create an appropriate wxWindow from a HWND
546 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
548 // Make sure the window style reflects the HWND style (roughly)
549 virtual void AdoptAttributesFromHWND();
551 // Setup background and foreground colours correctly
552 virtual void SetupColours();
554 // Saves the last message information before calling base version
555 virtual bool ProcessEvent(wxEvent
& event
);
558 virtual void MSWOnCreate(WXLPCREATESTRUCT cs
);
559 virtual bool MSWOnPaint();
560 virtual WXHICON
MSWOnQueryDragIcon() { return 0; }
561 virtual void MSWOnSize(int x
, int y
, WXUINT flag
);
562 virtual void MSWOnWindowPosChanging(void *lpPos
);
563 virtual void MSWOnHScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
564 virtual void MSWOnVScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
565 virtual bool MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
566 virtual long MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
);
567 virtual long MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
);
568 virtual WXHBRUSH
MSWOnCtlColor(WXHDC dc
, WXHWND pWnd
, WXUINT nCtlColor
,
569 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
570 virtual bool MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
571 virtual long MSWOnPaletteChanged(WXHWND hWndPalChange
);
572 virtual long MSWOnQueryNewPalette();
573 virtual bool MSWOnEraseBkgnd(WXHDC pDC
);
574 virtual void MSWOnMenuHighlight(WXWORD item
, WXWORD flags
, WXHMENU sysmenu
);
575 virtual void MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
);
576 virtual bool MSWOnClose();
577 // Return TRUE to end session, FALSE to veto end session.
578 virtual bool MSWOnQueryEndSession(long logOff
);
579 virtual bool MSWOnEndSession(bool endSession
, long logOff
);
580 virtual bool MSWOnDestroy();
581 virtual bool MSWOnSetFocus(WXHWND wnd
);
582 virtual bool MSWOnKillFocus(WXHWND wnd
);
583 virtual void MSWOnDropFiles(WXWPARAM wParam
);
584 virtual bool MSWOnInitDialog(WXHWND hWndFocus
);
585 virtual void MSWOnShow(bool show
, int status
);
587 // TODO: rationalise these functions into 1 or 2 which take the
588 // event type as argument.
589 virtual void MSWOnLButtonDown(int x
, int y
, WXUINT flags
);
590 virtual void MSWOnLButtonUp(int x
, int y
, WXUINT flags
);
591 virtual void MSWOnLButtonDClick(int x
, int y
, WXUINT flags
);
593 virtual void MSWOnMButtonDown(int x
, int y
, WXUINT flags
);
594 virtual void MSWOnMButtonUp(int x
, int y
, WXUINT flags
);
595 virtual void MSWOnMButtonDClick(int x
, int y
, WXUINT flags
);
597 virtual void MSWOnRButtonDown(int x
, int y
, WXUINT flags
);
598 virtual void MSWOnRButtonUp(int x
, int y
, WXUINT flags
);
599 virtual void MSWOnRButtonDClick(int x
, int y
, WXUINT flags
);
601 virtual void MSWOnMouseMove(int x
, int y
, WXUINT flags
);
602 virtual void MSWOnMouseEnter(int x
, int y
, WXUINT flags
);
603 virtual void MSWOnMouseLeave(int x
, int y
, WXUINT flags
);
605 virtual void MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
607 virtual bool MSWOnActivate(int flag
, bool minimized
, WXHWND activate
);
608 virtual long MSWOnMDIActivate(long flag
, WXHWND activate
, WXHWND deactivate
);
610 virtual bool MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*item
);
611 virtual bool MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*item
);
613 virtual void MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
);
614 virtual void MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
);
615 virtual void MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
);
616 virtual void MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
);
618 virtual long MSWGetDlgCode();
621 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
623 // Calls an appropriate default window procedure
624 virtual long MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
625 virtual bool MSWProcessMessage(WXMSG
* pMsg
);
626 virtual bool MSWTranslateMessage(WXMSG
* pMsg
);
627 virtual void MSWDestroyWindow();
629 // Detach "Window" menu from menu bar so it doesn't get deleted
630 void MSWDetachWindowMenu();
632 inline WXFARPROC
MSWGetOldWndProc() const;
633 inline void MSWSetOldWndProc(WXFARPROC proc
);
635 // Define for each class of dialog and control
636 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
637 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
639 inline void SetShowing(bool show
);
640 inline bool IsUserEnabled() const;
641 inline bool GetUseCtl3D() const ;
642 inline bool GetTransparentBackground() const ;
644 // Responds to colour changes: passes event on to children.
645 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
647 // Transfers data to any child controls
648 void OnInitDialog(wxInitDialogEvent
& event
);
650 // Sends an OnInitDialog event, which in turns transfers data to
651 // to the window via validators.
652 virtual void InitDialog();
654 ////////////////////////////////////////////////////////////////////////
657 wxAcceleratorTable m_acceleratorTable
;
659 long m_windowStyle
; // Store the window's style
660 wxEvtHandler
* m_windowEventHandler
; // Usually is 'this'
661 wxLayoutConstraints
* m_constraints
; // Constraints for this window
662 wxList
* m_constraintsInvolvedIn
; // List of constraints we're involved in
663 wxSizer
* m_windowSizer
; // Window's top-level sizer (if any)
664 wxWindow
* m_sizerParent
; // Window's parent sizer (if any)
665 bool m_autoLayout
; // Whether to call Layout() in OnSize
666 wxWindow
* m_windowParent
; // Each window always knows its parent
667 wxValidator
* m_windowValidator
;
668 // Old window proc, for subclassed controls
669 WXFARPROC m_oldWndProc
;
670 bool m_useCtl3D
; // Using CTL3D for this control
672 bool m_inOnSize
; // Protection against OnSize reentry
674 // Pointer to global memory, for EDIT controls that need
675 // special treatment to reduce USER area consumption.
676 WXHGLOBAL m_globalHandle
;
690 wxFont m_windowFont
; // Window's font
692 bool m_doubleClickAllowed
;
693 wxCursor m_windowCursor
; // Window's cursor
695 wxString m_windowName
; // Window name
697 #if wxUSE_EXTENDED_STATICS
698 wxList m_staticItems
;
701 wxButton
* m_defaultItem
;
702 wxColour m_backgroundColour
;
703 wxColour m_foregroundColour
;
704 bool m_backgroundTransparent
;
713 bool m_mouseInWindow
;
715 #if wxUSE_DRAG_AND_DROP
716 wxDropTarget
*m_pDropTarget
; // the current drop target or NULL
717 #endif //USE_DRAG_AND_DROP
720 WXHWND m_hWnd
; // MS Windows window handle
722 WXWPARAM m_lastWParam
;
723 WXLPARAM m_lastLParam
;
725 wxRegion m_updateRegion
;
727 wxRect m_updateRect; // Bounding box for screen damage area
729 WXHRGN m_updateRgn; // NT allows access to the rectangle list
733 // WXHANDLE m_acceleratorTable;
734 WXHMENU m_hMenu
; // Menu, if any
735 wxList
* m_children
; // Window's children
737 bool m_isBeingDeleted
; // Fudge because can't access parent
738 // when being deleted
741 // common part of all ctors
744 DECLARE_EVENT_TABLE()
747 ////////////////////////////////////////////////////////////////////////
750 inline void *wxWindow::GetHandle() const { return (void *)GetHWND(); }
751 inline int wxWindow::GetId() const { return m_windowId
; }
752 inline void wxWindow::SetId(int id
) { m_windowId
= id
; }
753 inline wxWindow
*wxWindow::GetParent() const { return m_windowParent
; }
754 inline void wxWindow::SetParent(wxWindow
*p
) { m_windowParent
= p
; }
755 inline wxWindow
*wxWindow::GetGrandParent() const { return (m_windowParent
? m_windowParent
->m_windowParent
: NULL
); }
756 inline wxList
& wxWindow::GetChildren() const { return (wxList
&) *m_children
; }
757 inline wxFont
& wxWindow::GetFont() const { return (wxFont
&) m_windowFont
; }
758 inline wxString
wxWindow::GetName() const { return m_windowName
; }
759 inline void wxWindow::SetName(const wxString
& name
) { m_windowName
= name
; }
760 inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle
; }
761 inline void wxWindow::SetWindowStyleFlag(long flag
) { m_windowStyle
= flag
; }
762 inline void wxWindow::SetDoubleClick(bool flag
) { m_doubleClickAllowed
= flag
; }
763 inline bool wxWindow::GetDoubleClick() const { return m_doubleClickAllowed
; }
764 inline void wxWindow::SetEventHandler(wxEvtHandler
*handler
) { m_windowEventHandler
= handler
; }
765 inline wxEvtHandler
*wxWindow::GetEventHandler() const { return m_windowEventHandler
; }
766 inline void wxWindow::SetAutoLayout(bool a
) { m_autoLayout
= a
; }
767 inline bool wxWindow::GetAutoLayout() const { return m_autoLayout
; }
768 inline wxLayoutConstraints
*wxWindow::GetConstraints() const { return m_constraints
; }
769 inline void wxWindow::SetBackgroundColour(const wxColour
& col
) { m_backgroundColour
= col
; };
770 inline wxColour
wxWindow::GetBackgroundColour() const { return m_backgroundColour
; };
771 inline void wxWindow::SetForegroundColour(const wxColour
& col
) { m_foregroundColour
= col
; };
772 inline wxColour
wxWindow::GetForegroundColour() const { return m_foregroundColour
; };
774 inline wxButton
*wxWindow::GetDefaultItem() const { return m_defaultItem
; }
775 inline void wxWindow::SetDefaultItem(wxButton
*but
) { m_defaultItem
= but
; }
776 inline bool wxWindow::IsRetained() const { return ((m_windowStyle
& wxRETAINED
) == wxRETAINED
); }
778 inline void wxWindow::SetShowing(bool show
) { m_isShown
= show
; }
779 inline wxList
*wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn
; }
780 inline wxSizer
*wxWindow::GetSizer() const { return m_windowSizer
; }
781 inline wxWindow
*wxWindow::GetSizerParent() const { return m_sizerParent
; }
782 inline void wxWindow::SetSizerParent(wxWindow
*win
) { m_sizerParent
= win
; }
783 inline WXFARPROC
wxWindow::MSWGetOldWndProc() const { return m_oldWndProc
; }
784 inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
785 inline wxValidator
*wxWindow::GetValidator() const { return m_windowValidator
; }
786 inline bool wxWindow::IsUserEnabled() const { return m_winEnabled
; }
787 inline bool wxWindow::GetUseCtl3D() const { return m_useCtl3D
; }
788 inline bool wxWindow::GetTransparentBackground() const { return m_backgroundTransparent
; }
789 inline void wxWindow::SetReturnCode(int retCode
) { m_returnCode
= retCode
; }
790 inline int wxWindow::GetReturnCode() { return m_returnCode
; }
791 inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted
; }
793 // Window specific (so far)
794 WXDLLEXPORT wxWindow
* wxGetActiveWindow();
796 WXDLLEXPORT_DATA(extern wxList
) wxTopLevelWindows
;
798 WXDLLEXPORT
int wxCharCodeMSWToWX(int keySym
);
799 WXDLLEXPORT
int wxCharCodeWXToMSW(int id
, bool *IsVirtual
);
801 // Allocates control ids
802 WXDLLEXPORT
int NewControlId();