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"
36 * Base class for frame, panel, canvas, panel items, dialog box.
41 * Event handler: windows have themselves as their event handlers
42 * by default, but their event handlers could be set to another
43 * object entirely. This separation can reduce the amount of
44 * derivation required, and allow alteration of a window's functionality
45 * (e.g. by a resource editor that temporarily switches event handlers).
48 class WXDLLEXPORT wxWindow
;
49 class WXDLLEXPORT wxEvent
;
50 class WXDLLEXPORT wxCommandEvent
;
51 class WXDLLEXPORT wxKeyEvent
;
52 class WXDLLEXPORT wxControl
;
53 class WXDLLEXPORT wxCursor
;
54 class WXDLLEXPORT wxColourMap
;
55 class WXDLLEXPORT wxFont
;
56 class WXDLLEXPORT wxMenu
;
57 class WXDLLEXPORT wxRect
;
58 class WXDLLEXPORT wxBitmap
;
59 class WXDLLEXPORT wxSizer
;
60 class WXDLLEXPORT wxList
;
61 class WXDLLEXPORT wxLayoutConstraints
;
62 class WXDLLEXPORT wxMouseEvent
;
63 class WXDLLEXPORT wxButton
;
64 class WXDLLEXPORT wxColour
;
65 class WXDLLEXPORT wxBrush
;
66 class WXDLLEXPORT wxPen
;
67 class WXDLLEXPORT wxIcon
;
68 class WXDLLEXPORT wxDC
;
69 class WXDLLEXPORT wxValidator
;
70 class WXDLLEXPORT wxToolTip
;
72 #if wxUSE_DRAG_AND_DROP
73 class WXDLLEXPORT wxDropTarget
;
76 #if wxUSE_WX_RESOURCES
77 class WXDLLEXPORT wxResourceTable
;
78 class WXDLLEXPORT wxItemResource
;
81 WXDLLEXPORT_DATA(extern const char*) wxPanelNameStr
;
83 WXDLLEXPORT_DATA(extern const wxSize
) wxDefaultSize
;
84 WXDLLEXPORT_DATA(extern const wxPoint
) wxDefaultPosition
;
86 //-----------------------------------------------------------------------------
88 //-----------------------------------------------------------------------------
94 virtual ~wxClientData() { }
97 //-----------------------------------------------------------------------------
99 //-----------------------------------------------------------------------------
101 class wxStringClientData
: public wxClientData
104 wxStringClientData() { }
105 wxStringClientData( wxString
&data
) { m_data
= data
; }
106 void SetData( wxString
&data
) { m_data
= data
; }
107 wxString
GetData() const { return m_data
; }
113 // Clash with Windows headers
122 class WXDLLEXPORT wxWindow
: public wxEvtHandler
124 DECLARE_ABSTRACT_CLASS(wxWindow
)
127 friend class wxPaintDC
;
131 wxWindow(wxWindow
*parent
, wxWindowID id
,
132 const wxPoint
& pos
= wxDefaultPosition
,
133 const wxSize
& size
= wxDefaultSize
,
135 const wxString
& name
= wxPanelNameStr
)
138 Create(parent
, id
, pos
, size
, style
, name
);
143 bool Create(wxWindow
*parent
, wxWindowID id
,
144 const wxPoint
& pos
= wxDefaultPosition
,
145 const wxSize
& size
= wxDefaultSize
,
147 const wxString
& name
= wxPanelNameStr
);
149 // Fit the window around the items
152 // Show or hide the window
153 virtual bool Show(bool show
);
155 // Is the window shown?
156 virtual bool IsShown() const;
158 // Raise the window to the top of the Z order
159 virtual void Raise();
161 // Lower the window to the bottom of the Z order
162 virtual void Lower();
164 // Is the window enabled?
165 virtual bool IsEnabled() const;
168 inline bool Enabled() const { return IsEnabled(); }
170 // Dialog support: override these and call
171 // base class members to add functionality
172 // that can't be done using validators.
174 // Transfer values to controls. If returns FALSE,
175 // it's an application error (pops up a dialog)
176 virtual bool TransferDataToWindow();
178 // Transfer values from controls. If returns FALSE,
179 // transfer failed: don't quit
180 virtual bool TransferDataFromWindow();
182 // Validate controls. If returns FALSE,
183 // validation failed: don't quit
184 virtual bool Validate();
186 // Return code for dialogs
187 inline void SetReturnCode(int retCode
);
188 inline int GetReturnCode();
191 virtual void SetCursor(const wxCursor
& cursor
);
192 inline virtual wxCursor
& GetCursor() const { return (wxCursor
& ) m_windowCursor
; };
194 // Get the window with the focus
195 static wxWindow
*FindFocus();
197 // Get character size
198 virtual int GetCharHeight() const;
199 virtual int GetCharWidth() const;
201 // Get overall window size
202 virtual void GetSize(int *width
, int *height
) const;
203 wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
205 // Get window position, relative to parent (or screen if no parent)
206 virtual void GetPosition(int *x
, int *y
) const;
207 wxPoint
GetPosition() const
208 { int x
, y
; GetPosition(&x
, &y
); return wxPoint(x
, y
); }
210 // Get size and position
211 wxRect
GetRect() const
212 { int x
, y
, w
, h
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
214 // Get client (application-useable) size
215 virtual void GetClientSize(int *width
, int *height
) const;
216 wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
218 // Set overall size and position
219 // generic function, may be overriden in derived classes
220 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
222 void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
223 { SetSize(rect
.x
, rect
.y
, rect
.width
, rect
.height
, sizeFlags
); }
226 void SetSize(int width
, int height
)
227 { SetSize(-1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
228 void SetSize(const wxSize
& size
)
229 { SetSize(-1, -1, size
.x
, size
.y
, wxSIZE_USE_EXISTING
); }
232 virtual void Move(int x
, int y
) { SetSize(x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
233 void Move(const wxPoint
& pt
) { SetSize(pt
.x
, pt
.y
, -1, -1, wxSIZE_USE_EXISTING
); }
236 virtual void SetClientSize(int width
, int height
);
237 void SetClientSize(const wxSize
& sz
) { SetClientSize(sz
.x
, sz
.y
); }
239 // Convert client to screen coordinates
240 virtual void ClientToScreen(int *x
, int *y
) const;
241 wxPoint
ClientToScreen(const wxPoint
& pt
) const
242 { int x
= pt
.x
; int y
= pt
.y
; ClientToScreen(& x
, & y
); return wxPoint(x
, y
); }
244 // Convert screen to client coordinates
245 virtual void ScreenToClient(int *x
, int *y
) const;
246 wxPoint
ScreenToClient(const wxPoint
& pt
) const
247 { int x
= pt
.x
; int y
= pt
.y
; ScreenToClient(& x
, & y
); return wxPoint(x
, y
); }
249 // Set the focus to this window
250 virtual void SetFocus();
252 // Capture/release mouse
253 virtual void CaptureMouse();
254 virtual void ReleaseMouse();
256 // Enable or disable the window
257 virtual void Enable(bool enable
);
259 #if wxUSE_DRAG_AND_DROP
260 // Associate a drop target with this window (if the window already had a drop
261 // target, it's deleted!) and return the current drop target (may be NULL).
262 void SetDropTarget(wxDropTarget
*pDropTarget
);
263 wxDropTarget
*GetDropTarget() const { return m_pDropTarget
; }
268 // create a tooltip with this text
269 void SetToolTip(const wxString
&tip
);
270 // pointer may be NULL to remove the tooltip
271 void SetToolTip(wxToolTip
*tooltip
);
272 // get the current tooltip (may return NULL if none)
273 wxToolTip
* GetToolTip() const { return m_tooltip
; }
274 #endif // wxUSE_TOOLTIPS
276 // Accept files for dragging
277 virtual void DragAcceptFiles(bool accept
);
279 // Update region access
280 virtual wxRegion
GetUpdateRegion() const;
281 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
282 virtual bool IsExposed(const wxPoint
& pt
) const;
283 virtual bool IsExposed(const wxRect
& rect
) const;
285 // Set/get the window title
286 virtual inline void SetTitle(const wxString
& WXUNUSED(title
)) {};
287 inline virtual wxString
GetTitle() const { return wxString(""); };
288 // Most windows have the concept of a label; for frames, this is the
289 // title; for items, this is the label or button text.
290 inline virtual wxString
GetLabel() const { return GetTitle(); }
292 // Set/get the window name (used for resource setting in X)
293 inline virtual wxString
GetName() const;
294 inline virtual void SetName(const wxString
& name
);
297 virtual void Centre(int direction
) ;
298 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
301 virtual bool PopupMenu(wxMenu
*menu
, int x
, int y
);
303 // Send the window a refresh event
304 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
306 #if WXWIN_COMPATIBILITY
307 // Set/get scroll attributes
308 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
309 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
310 virtual int OldGetScrollRange(int orient
) const;
311 virtual int GetScrollPage(int orient
) const;
314 // New functions that will replace the above.
315 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
316 int range
, bool refresh
= TRUE
);
318 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
319 virtual int GetScrollPos(int orient
) const;
320 virtual int GetScrollRange(int orient
) const;
321 virtual int GetScrollThumb(int orient
) const;
323 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
325 // Caret manipulation
326 virtual void CreateCaret(int w
, int h
);
327 virtual void CreateCaret(const wxBitmap
*bitmap
);
328 virtual void DestroyCaret();
329 virtual void ShowCaret(bool show
);
330 virtual void SetCaretPos(int x
, int y
);
331 virtual void GetCaretPos(int *x
, int *y
) const;
333 // Tell window how much it can be sized
334 virtual void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
336 // Set/get the window's identifier
337 inline int GetId() const;
338 inline void SetId(int id
);
340 // Make the window modal (all other windows unresponsive)
341 virtual void MakeModal(bool modal
);
343 // Get the private handle (platform-dependent)
344 inline void *GetHandle() const;
346 // Set/get the window's relatives
347 inline wxWindow
*GetParent() const;
348 inline void SetParent(wxWindow
*p
) ;
349 inline wxWindow
*GetGrandParent() const;
350 inline wxList
& GetChildren() const;
351 // Set this window to be the child of 'parent'.
352 // Returns FALSE it's not possible (some systems
354 virtual bool Reparent(wxWindow
*parent
);
356 // Set/get the window's font
357 virtual void SetFont(const wxFont
& f
);
358 inline virtual wxFont
& GetFont() const;
360 // Set/get the window's validator
361 void SetValidator(const wxValidator
& validator
);
362 inline wxValidator
*GetValidator() const;
364 // Set/get the window's style
365 inline void SetWindowStyleFlag(long flag
);
366 inline long GetWindowStyleFlag() const;
368 // Set/get double-clickability
369 // TODO: we probably wish to get rid of this, and
370 // always allow double clicks.
371 inline void SetDoubleClick(bool flag
);
372 inline bool GetDoubleClick() const;
373 inline void AllowDoubleClick(bool value
) { SetDoubleClick(value
); }
375 // Handle a control command
376 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
378 // Set/get event handler
379 inline void SetEventHandler(wxEvtHandler
*handler
);
380 inline wxEvtHandler
*GetEventHandler() const;
382 // Push/pop event handler (i.e. allow a chain of event handlers
384 void PushEventHandler(wxEvtHandler
*handler
) ;
385 wxEvtHandler
*PopEventHandler(bool deleteHandler
= FALSE
) ;
387 // Close the window by calling OnClose, posting a deletion
388 virtual bool Close(bool force
= FALSE
);
390 // Destroy the window (delayed, if a managed window)
391 virtual bool Destroy() ;
393 // Mode for telling default OnSize members to
394 // call Layout(), if not using Sizers, just top-down constraints
395 inline void SetAutoLayout(bool a
);
396 inline bool GetAutoLayout() const;
398 // Set/get constraints
399 inline wxLayoutConstraints
*GetConstraints() const;
400 void SetConstraints(wxLayoutConstraints
*c
);
402 // Set/get window background colour
403 inline virtual void SetBackgroundColour(const wxColour
& col
);
404 inline virtual wxColour
GetBackgroundColour() const;
406 // Set/get window foreground colour
407 inline virtual void SetForegroundColour(const wxColour
& col
);
408 inline virtual wxColour
GetForegroundColour() const;
410 // For backward compatibility
411 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
412 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
413 inline virtual wxFont
& GetLabelFont() const { return GetFont(); };
414 inline virtual wxFont
& GetButtonFont() const { return GetFont(); };
416 // Get the default button, if there is one
417 inline virtual wxButton
*GetDefaultItem() const;
418 inline virtual void SetDefaultItem(wxButton
*but
);
420 virtual void SetAcceleratorTable(const wxAcceleratorTable
& accel
);
421 inline virtual wxAcceleratorTable
& GetAcceleratorTable() const { return (wxAcceleratorTable
&) m_acceleratorTable
; }
423 // Override to define new behaviour for default action (e.g. double clicking
425 virtual void OnDefaultAction(wxControl
*initiatingItem
);
428 #if wxUSE_WX_RESOURCES
429 virtual bool LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
= NULL
);
430 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
= NULL
);
433 // Native resource loading
434 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
435 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
436 virtual wxWindow
* GetWindowChild1(wxWindowID
& id
);
437 virtual wxWindow
* GetWindowChild(wxWindowID
& id
);
439 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
441 int *externalLeading
= NULL
,
442 const wxFont
*theFont
= NULL
, bool use16
= FALSE
) const;
444 // Is the window retained?
445 inline bool IsRetained() const;
447 // Warp the pointer the given position
448 virtual void WarpPointer(int x_pos
, int y_pos
) ;
451 virtual void Clear();
453 // Find a window by id or name
454 virtual wxWindow
*FindWindow(long id
);
455 virtual wxWindow
*FindWindow(const wxString
& name
);
457 // Constraint operations
459 void SetSizer(wxSizer
*sizer
); // Adds sizer child to this window
460 inline wxSizer
*GetSizer() const ;
461 inline wxWindow
*GetSizerParent() const ;
462 inline void SetSizerParent(wxWindow
*win
);
464 // Do Update UI processing for controls
465 void UpdateWindowUI();
467 void OnEraseBackground(wxEraseEvent
& event
);
468 void OnChar(wxKeyEvent
& event
);
469 void OnIdle(wxIdleEvent
& event
);
471 // Does this window want to accept keyboard focus?
472 virtual bool AcceptsFocus() const;
474 virtual void PrepareDC( wxDC
& WXUNUSED(dc
) ) {};
476 ////////////////////////////////////////////////////////////////////////
479 // For implementation purposes - sometimes decorations make the client area
481 virtual wxPoint
GetClientAreaOrigin() const;
483 // Makes an adjustment to the window position (for example, a frame that has
484 // a toolbar that it manages itself).
485 virtual void AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
);
487 // Windows subclassing
488 void SubclassWin(WXHWND hWnd
);
489 void UnsubclassWin();
490 virtual long Default();
491 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
493 // returns TRUE if the event was processed
494 virtual bool MSWNotify(WXWPARAM wParam
, WXLPARAM lParam
, WXLPARAM
*result
);
496 virtual wxWindow
*FindItem(int id
) const;
497 virtual wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const ;
498 virtual void PreDelete(WXHDC dc
); // Allows system cleanup
499 // TO DO: how many of these need to be virtual?
500 virtual WXHWND
GetHWND() const ;
501 virtual void SetHWND(WXHWND hWnd
);
503 // Make a Windows extended style from the given wxWindows window style
504 virtual WXDWORD
MakeExtendedStyle(long style
, bool eliminateBorders
= TRUE
);
505 // Determine whether 3D effects are wanted
506 virtual WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
);
508 virtual void AddChild(wxWindow
*child
); // Adds reference to the child object
509 virtual void RemoveChild(wxWindow
*child
); // Removes reference to child
510 // (but doesn't delete the child object)
511 virtual void DestroyChildren(); // Removes and destroys all children
513 inline bool IsBeingDeleted();
515 // MSW only: TRUE if this control is part of the main control
516 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
518 // Constraint implementation
519 void UnsetConstraints(wxLayoutConstraints
*c
);
520 inline wxList
*GetConstraintsInvolvedIn() const ;
521 // Back-pointer to other windows we're involved with, so if we delete
522 // this window, we must delete any constraints we're involved with.
523 void AddConstraintReference(wxWindow
*otherWin
);
524 void RemoveConstraintReference(wxWindow
*otherWin
);
525 void DeleteRelatedConstraints();
527 virtual void ResetConstraints();
528 virtual void SetConstraintSizes(bool recurse
= TRUE
);
529 virtual bool LayoutPhase1(int *noChanges
);
530 virtual bool LayoutPhase2(int *noChanges
);
531 virtual bool DoPhase(int);
532 // Transforms from sizer coordinate space to actual
533 // parent coordinate space
534 virtual void TransformSizerToActual(int *x
, int *y
) const ;
536 // Set size with transformation to actual coordinates if nec.
537 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
538 virtual void SizerMove(int x
, int y
);
540 // Only set/get the size/position of the constraint (if any)
541 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
542 virtual void MoveConstraint(int x
, int y
);
543 virtual void GetSizeConstraint(int *w
, int *h
) const ;
544 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
545 virtual void GetPositionConstraint(int *x
, int *y
) const ;
547 // Dialog units translations. Implemented in wincmn.cpp.
548 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
549 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
550 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
551 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
552 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
553 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
555 wxObject
*GetChild(int number
) const ;
557 void MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
558 int x
, int y
, int width
, int height
,
559 WXDWORD style
, const char *dialog_template
= NULL
,
560 WXDWORD exendedStyle
= 0);
562 // Actually defined in wx_canvs.cc since requires wxCanvas declaration
563 virtual void MSWDeviceToLogical(float *x
, float *y
) const ;
565 // Create an appropriate wxWindow from a HWND
566 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
568 // Make sure the window style reflects the HWND style (roughly)
569 virtual void AdoptAttributesFromHWND();
571 // Setup background and foreground colours correctly
572 virtual void SetupColours();
574 // Saves the last message information before calling base version
575 virtual bool ProcessEvent(wxEvent
& event
);
578 virtual void MSWOnCreate(WXLPCREATESTRUCT cs
);
579 virtual bool MSWOnPaint();
580 virtual WXHICON
MSWOnQueryDragIcon() { return 0; }
581 virtual void MSWOnSize(int x
, int y
, WXUINT flag
);
582 virtual void MSWOnWindowPosChanging(void *lpPos
);
583 virtual void MSWOnHScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
584 virtual void MSWOnVScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
585 virtual bool MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
586 virtual long MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
);
587 virtual long MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
);
588 virtual WXHBRUSH
MSWOnCtlColor(WXHDC dc
, WXHWND pWnd
, WXUINT nCtlColor
,
589 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
590 virtual bool MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
591 virtual long MSWOnPaletteChanged(WXHWND hWndPalChange
);
592 virtual long MSWOnQueryNewPalette();
593 virtual bool MSWOnEraseBkgnd(WXHDC pDC
);
594 virtual void MSWOnMenuHighlight(WXWORD item
, WXWORD flags
, WXHMENU sysmenu
);
595 virtual void MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
);
596 virtual bool MSWOnClose();
597 // Return TRUE to end session, FALSE to veto end session.
598 virtual bool MSWOnQueryEndSession(long logOff
);
599 virtual bool MSWOnEndSession(bool endSession
, long logOff
);
600 virtual bool MSWOnDestroy();
601 virtual bool MSWOnSetFocus(WXHWND wnd
);
602 virtual bool MSWOnKillFocus(WXHWND wnd
);
603 virtual void MSWOnDropFiles(WXWPARAM wParam
);
604 virtual bool MSWOnInitDialog(WXHWND hWndFocus
);
605 virtual void MSWOnShow(bool show
, int status
);
607 // TODO: rationalise these functions into 1 or 2 which take the
608 // event type as argument.
609 virtual void MSWOnLButtonDown(int x
, int y
, WXUINT flags
);
610 virtual void MSWOnLButtonUp(int x
, int y
, WXUINT flags
);
611 virtual void MSWOnLButtonDClick(int x
, int y
, WXUINT flags
);
613 virtual void MSWOnMButtonDown(int x
, int y
, WXUINT flags
);
614 virtual void MSWOnMButtonUp(int x
, int y
, WXUINT flags
);
615 virtual void MSWOnMButtonDClick(int x
, int y
, WXUINT flags
);
617 virtual void MSWOnRButtonDown(int x
, int y
, WXUINT flags
);
618 virtual void MSWOnRButtonUp(int x
, int y
, WXUINT flags
);
619 virtual void MSWOnRButtonDClick(int x
, int y
, WXUINT flags
);
621 virtual void MSWOnMouseMove(int x
, int y
, WXUINT flags
);
622 virtual void MSWOnMouseEnter(int x
, int y
, WXUINT flags
);
623 virtual void MSWOnMouseLeave(int x
, int y
, WXUINT flags
);
625 // These return TRUE if an event handler was found, FALSE otherwise (not processed)
626 virtual bool MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
627 virtual bool MSWOnKeyDown(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
628 virtual bool MSWOnKeyUp(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
630 virtual bool MSWOnActivate(int flag
, bool minimized
, WXHWND activate
);
631 virtual long MSWOnMDIActivate(long flag
, WXHWND activate
, WXHWND deactivate
);
633 virtual bool MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*item
);
634 virtual bool MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*item
);
636 virtual void MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
);
637 virtual void MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
);
638 virtual void MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
);
639 virtual void MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
);
641 virtual long MSWGetDlgCode();
644 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
646 // Calls an appropriate default window procedure
647 virtual long MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
648 virtual bool MSWProcessMessage(WXMSG
* pMsg
);
649 virtual bool MSWTranslateMessage(WXMSG
* pMsg
);
650 virtual void MSWDestroyWindow();
652 // Detach "Window" menu from menu bar so it doesn't get deleted
653 void MSWDetachWindowMenu();
655 inline WXFARPROC
MSWGetOldWndProc() const;
656 inline void MSWSetOldWndProc(WXFARPROC proc
);
658 // Define for each class of dialog and control
659 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
660 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
662 inline void SetShowing(bool show
);
663 inline bool IsUserEnabled() const;
664 inline bool GetUseCtl3D() const ;
665 inline bool GetTransparentBackground() const ;
667 // Responds to colour changes: passes event on to children.
668 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
670 // Transfers data to any child controls
671 void OnInitDialog(wxInitDialogEvent
& event
);
673 // Sends an OnInitDialog event, which in turns transfers data to
674 // to the window via validators.
675 virtual void InitDialog();
677 ////////////////////////////////////////////////////////////////////////
680 wxAcceleratorTable m_acceleratorTable
;
682 long m_windowStyle
; // Store the window's style
683 wxEvtHandler
* m_windowEventHandler
; // Usually is 'this'
684 wxLayoutConstraints
* m_constraints
; // Constraints for this window
685 wxList
* m_constraintsInvolvedIn
; // List of constraints we're involved in
686 wxSizer
* m_windowSizer
; // Window's top-level sizer (if any)
687 wxWindow
* m_sizerParent
; // Window's parent sizer (if any)
688 bool m_autoLayout
; // Whether to call Layout() in OnSize
689 wxWindow
* m_windowParent
; // Each window always knows its parent
690 wxValidator
* m_windowValidator
;
691 // Old window proc, for subclassed controls
692 WXFARPROC m_oldWndProc
;
693 bool m_useCtl3D
; // Using CTL3D for this control
695 bool m_inOnSize
; // Protection against OnSize reentry
697 // Pointer to global memory, for EDIT controls that need
698 // special treatment to reduce USER area consumption.
699 WXHGLOBAL m_globalHandle
;
713 wxFont m_windowFont
; // Window's font
715 bool m_doubleClickAllowed
;
716 wxCursor m_windowCursor
; // Window's cursor
718 wxString m_windowName
; // Window name
720 #if wxUSE_EXTENDED_STATICS
721 wxList m_staticItems
;
724 wxButton
* m_defaultItem
;
725 wxColour m_backgroundColour
;
726 wxColour m_foregroundColour
;
727 bool m_backgroundTransparent
;
736 bool m_mouseInWindow
;
738 #if wxUSE_DRAG_AND_DROP
739 wxDropTarget
*m_pDropTarget
; // the current drop target or NULL
740 #endif //USE_DRAG_AND_DROP
743 WXHWND m_hWnd
; // MS Windows window handle
745 WXWPARAM m_lastWParam
;
746 WXLPARAM m_lastLParam
;
748 wxRegion m_updateRegion
;
750 wxRect m_updateRect; // Bounding box for screen damage area
752 WXHRGN m_updateRgn; // NT allows access to the rectangle list
756 // WXHANDLE m_acceleratorTable;
757 WXHMENU m_hMenu
; // Menu, if any
758 wxList
* m_children
; // Window's children
760 bool m_isBeingDeleted
; // Fudge because can't access parent
761 // when being deleted
764 // common part of all ctors
767 // the associated tooltip (may be NULL if none)
769 wxToolTip
*m_tooltip
;
772 DECLARE_EVENT_TABLE()
775 ////////////////////////////////////////////////////////////////////////
778 inline void *wxWindow::GetHandle() const { return (void *)GetHWND(); }
779 inline int wxWindow::GetId() const { return m_windowId
; }
780 inline void wxWindow::SetId(int id
) { m_windowId
= id
; }
781 inline wxWindow
*wxWindow::GetParent() const { return m_windowParent
; }
782 inline void wxWindow::SetParent(wxWindow
*p
) { m_windowParent
= p
; }
783 inline wxWindow
*wxWindow::GetGrandParent() const { return (m_windowParent
? m_windowParent
->m_windowParent
: (wxWindow
*) NULL
); }
784 inline wxList
& wxWindow::GetChildren() const { return (wxList
&) *m_children
; }
785 inline wxFont
& wxWindow::GetFont() const { return (wxFont
&) m_windowFont
; }
786 inline wxString
wxWindow::GetName() const { return m_windowName
; }
787 inline void wxWindow::SetName(const wxString
& name
) { m_windowName
= name
; }
788 inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle
; }
789 inline void wxWindow::SetWindowStyleFlag(long flag
) { m_windowStyle
= flag
; }
790 inline void wxWindow::SetDoubleClick(bool flag
) { m_doubleClickAllowed
= flag
; }
791 inline bool wxWindow::GetDoubleClick() const { return m_doubleClickAllowed
; }
792 inline void wxWindow::SetEventHandler(wxEvtHandler
*handler
) { m_windowEventHandler
= handler
; }
793 inline wxEvtHandler
*wxWindow::GetEventHandler() const { return m_windowEventHandler
; }
794 inline void wxWindow::SetAutoLayout(bool a
) { m_autoLayout
= a
; }
795 inline bool wxWindow::GetAutoLayout() const { return m_autoLayout
; }
796 inline wxLayoutConstraints
*wxWindow::GetConstraints() const { return m_constraints
; }
797 inline void wxWindow::SetBackgroundColour(const wxColour
& col
) { m_backgroundColour
= col
; };
798 inline wxColour
wxWindow::GetBackgroundColour() const { return m_backgroundColour
; };
799 inline void wxWindow::SetForegroundColour(const wxColour
& col
) { m_foregroundColour
= col
; };
800 inline wxColour
wxWindow::GetForegroundColour() const { return m_foregroundColour
; };
802 inline wxButton
*wxWindow::GetDefaultItem() const { return m_defaultItem
; }
803 inline void wxWindow::SetDefaultItem(wxButton
*but
) { m_defaultItem
= but
; }
804 inline bool wxWindow::IsRetained() const { return ((m_windowStyle
& wxRETAINED
) == wxRETAINED
); }
806 inline void wxWindow::SetShowing(bool show
) { m_isShown
= show
; }
807 inline wxList
*wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn
; }
808 inline wxSizer
*wxWindow::GetSizer() const { return m_windowSizer
; }
809 inline wxWindow
*wxWindow::GetSizerParent() const { return m_sizerParent
; }
810 inline void wxWindow::SetSizerParent(wxWindow
*win
) { m_sizerParent
= win
; }
811 inline WXFARPROC
wxWindow::MSWGetOldWndProc() const { return m_oldWndProc
; }
812 inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
813 inline wxValidator
*wxWindow::GetValidator() const { return m_windowValidator
; }
814 inline bool wxWindow::IsUserEnabled() const { return m_winEnabled
; }
815 inline bool wxWindow::GetUseCtl3D() const { return m_useCtl3D
; }
816 inline bool wxWindow::GetTransparentBackground() const { return m_backgroundTransparent
; }
817 inline void wxWindow::SetReturnCode(int retCode
) { m_returnCode
= retCode
; }
818 inline int wxWindow::GetReturnCode() { return m_returnCode
; }
819 inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted
; }
821 // Window specific (so far)
822 WXDLLEXPORT wxWindow
* wxGetActiveWindow();
824 WXDLLEXPORT_DATA(extern wxList
) wxTopLevelWindows
;
826 WXDLLEXPORT
int wxCharCodeMSWToWX(int keySym
);
827 WXDLLEXPORT
int wxCharCodeWXToMSW(int id
, bool *IsVirtual
);
829 // Allocates control ids
830 WXDLLEXPORT
int NewControlId();