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;
164 virtual wxSize
GetSize() const { int w
, h
; GetSize(& w
, & h
); return wxSize(w
, h
); }
165 virtual wxRect
GetRect() const { int w
, h
; int x
, y
; GetPosition(& x
, & y
); GetSize(& w
, & h
); return wxRect(x
, y
, w
, h
); }
167 // Get window position, relative to parent (or screen if no parent)
168 virtual void GetPosition(int *x
, int *y
) const;
169 virtual wxPoint
GetPosition() const { int x
, y
; GetPosition(&x
, &y
); return wxPoint(x
, y
); }
171 // Get client (application-useable) size
172 virtual void GetClientSize(int *width
, int *height
) const;
173 virtual wxSize
GetClientSize() const { int w
, h
; GetClientSize(& w
, & h
); return wxSize(w
, h
); }
175 // Set overall size and position
176 virtual void SetSize(int x
, int y
, int width
, int height
, int sizeFlags
= wxSIZE_AUTO
);
177 virtual void SetSize(int width
, int height
) { SetSize(-1, -1, width
, height
, wxSIZE_USE_EXISTING
); }
178 virtual void SetSize(const wxRect
& rect
, int sizeFlags
= wxSIZE_AUTO
)
179 { SetSize(rect
.x
, rect
.y
, rect
.width
, rect
.height
, sizeFlags
); }
180 virtual void SetSize(const wxSize
& size
) { SetSize(-1, -1, size
.x
, size
.y
, wxSIZE_USE_EXISTING
); }
182 virtual void Move(int x
, int y
) { SetSize(x
, y
, -1, -1, wxSIZE_USE_EXISTING
); }
183 virtual void Move(const wxPoint
& pt
) { SetSize(pt
.x
, pt
.y
, -1, -1, wxSIZE_USE_EXISTING
); }
186 virtual void SetClientSize(int width
, int height
);
187 virtual void SetClientSize(const wxSize
& sz
) { SetClientSize(sz
.x
, sz
.y
); }
189 // Convert client to screen coordinates
190 virtual void ClientToScreen(int *x
, int *y
) const;
191 virtual wxPoint
ClientToScreen(const wxPoint
& pt
) const
192 { int x
= pt
.x
; int y
= pt
.y
; ClientToScreen(& x
, & y
); return wxPoint(x
, y
); }
194 // Convert screen to client coordinates
195 virtual void ScreenToClient(int *x
, int *y
) const;
196 virtual wxPoint
ScreenToClient(const wxPoint
& pt
) const
197 { int x
= pt
.x
; int y
= pt
.y
; ScreenToClient(& x
, & y
); return wxPoint(x
, y
); }
199 // Set the focus to this window
200 virtual void SetFocus();
202 // Capture/release mouse
203 virtual void CaptureMouse();
204 virtual void ReleaseMouse();
206 // Enable or disable the window
207 virtual void Enable(bool enable
);
209 #if wxUSE_DRAG_AND_DROP
210 // Associate a drop target with this window (if the window already had a drop
211 // target, it's deleted!) and return the current drop target (may be NULL).
212 void SetDropTarget(wxDropTarget
*pDropTarget
);
213 wxDropTarget
*GetDropTarget() const { return m_pDropTarget
; }
216 // Accept files for dragging
217 virtual void DragAcceptFiles(bool accept
);
219 // Update region access
220 virtual wxRegion
GetUpdateRegion() const;
221 virtual bool IsExposed(int x
, int y
, int w
, int h
) const;
222 virtual bool IsExposed(const wxPoint
& pt
) const;
223 virtual bool IsExposed(const wxRect
& rect
) const;
225 // Set/get the window title
226 virtual inline void SetTitle(const wxString
& WXUNUSED(title
)) {};
227 inline virtual wxString
GetTitle() const { return wxString(""); };
228 // Most windows have the concept of a label; for frames, this is the
229 // title; for items, this is the label or button text.
230 inline virtual wxString
GetLabel() const { return GetTitle(); }
232 // Set/get the window name (used for resource setting in X)
233 inline virtual wxString
GetName() const;
234 inline virtual void SetName(const wxString
& name
);
237 virtual void Centre(int direction
) ;
238 inline void Center(int direction
= wxHORIZONTAL
) { Centre(direction
); }
241 virtual bool PopupMenu(wxMenu
*menu
, int x
, int y
);
243 // Send the window a refresh event
244 virtual void Refresh(bool eraseBack
= TRUE
, const wxRect
*rect
= NULL
);
246 #if WXWIN_COMPATIBILITY
247 // Set/get scroll attributes
248 virtual void SetScrollRange(int orient
, int range
, bool refresh
= TRUE
);
249 virtual void SetScrollPage(int orient
, int page
, bool refresh
= TRUE
);
250 virtual int OldGetScrollRange(int orient
) const;
251 virtual int GetScrollPage(int orient
) const;
254 // New functions that will replace the above.
255 virtual void SetScrollbar(int orient
, int pos
, int thumbVisible
,
256 int range
, bool refresh
= TRUE
);
258 virtual void SetScrollPos(int orient
, int pos
, bool refresh
= TRUE
);
259 virtual int GetScrollPos(int orient
) const;
260 virtual int GetScrollRange(int orient
) const;
261 virtual int GetScrollThumb(int orient
) const;
263 virtual void ScrollWindow(int dx
, int dy
, const wxRect
*rect
= NULL
);
265 // Caret manipulation
266 virtual void CreateCaret(int w
, int h
);
267 virtual void CreateCaret(const wxBitmap
*bitmap
);
268 virtual void DestroyCaret();
269 virtual void ShowCaret(bool show
);
270 virtual void SetCaretPos(int x
, int y
);
271 virtual void GetCaretPos(int *x
, int *y
) const;
273 // Tell window how much it can be sized
274 virtual void SetSizeHints(int minW
= -1, int minH
= -1, int maxW
= -1, int maxH
= -1, int incW
= -1, int incH
= -1);
276 // Set/get the window's identifier
277 inline int GetId() const;
278 inline void SetId(int id
);
280 // Make the window modal (all other windows unresponsive)
281 virtual void MakeModal(bool modal
);
283 // Get the private handle (platform-dependent)
284 inline void *GetHandle() const;
286 // Set/get the window's relatives
287 inline wxWindow
*GetParent() const;
288 inline void SetParent(wxWindow
*p
) ;
289 inline wxWindow
*GetGrandParent() const;
290 inline wxList
*GetChildren() const;
291 // Set this window to be the child of 'parent'.
292 // Returns FALSE it's not possible (some systems
294 virtual bool Reparent(wxWindow
*parent
);
296 // Set/get the window's font
297 virtual void SetFont(const wxFont
& f
);
298 inline virtual wxFont
*GetFont() const;
300 // Set/get the window's validator
301 void SetValidator(const wxValidator
& validator
);
302 inline wxValidator
*GetValidator() const;
304 // Set/get the window's style
305 inline void SetWindowStyleFlag(long flag
);
306 inline long GetWindowStyleFlag() const;
308 // Set/get double-clickability
309 // TODO: we probably wish to get rid of this, and
310 // always allow double clicks.
311 inline void SetDoubleClick(bool flag
);
312 inline bool GetDoubleClick() const;
313 inline void AllowDoubleClick(bool value
) { SetDoubleClick(value
); }
315 // Handle a control command
316 virtual void OnCommand(wxWindow
& win
, wxCommandEvent
& event
);
318 // Set/get event handler
319 inline void SetEventHandler(wxEvtHandler
*handler
);
320 inline wxEvtHandler
*GetEventHandler() const;
322 // Push/pop event handler (i.e. allow a chain of event handlers
324 void PushEventHandler(wxEvtHandler
*handler
) ;
325 wxEvtHandler
*PopEventHandler(bool deleteHandler
= FALSE
) ;
327 // Close the window by calling OnClose, posting a deletion
328 virtual bool Close(bool force
= FALSE
);
330 // Destroy the window (delayed, if a managed window)
331 virtual bool Destroy() ;
333 // Mode for telling default OnSize members to
334 // call Layout(), if not using Sizers, just top-down constraints
335 inline void SetAutoLayout(bool a
);
336 inline bool GetAutoLayout() const;
338 // Set/get constraints
339 inline wxLayoutConstraints
*GetConstraints() const;
340 void SetConstraints(wxLayoutConstraints
*c
);
342 // Set/get window background colour
343 inline virtual void SetBackgroundColour(const wxColour
& col
);
344 inline virtual wxColour
GetBackgroundColour() const;
346 // Set/get window foreground colour
347 inline virtual void SetForegroundColour(const wxColour
& col
);
348 inline virtual wxColour
GetForegroundColour() const;
350 // For backward compatibility
351 inline virtual void SetButtonFont(const wxFont
& font
) { SetFont(font
); }
352 inline virtual void SetLabelFont(const wxFont
& font
) { SetFont(font
); }
353 inline virtual wxFont
*GetLabelFont() const { return GetFont(); };
354 inline virtual wxFont
*GetButtonFont() const { return GetFont(); };
356 // Get the default button, if there is one
357 inline virtual wxButton
*GetDefaultItem() const;
358 inline virtual void SetDefaultItem(wxButton
*but
);
360 virtual void SetAcceleratorTable(const wxAcceleratorTable
& accel
);
361 inline virtual wxAcceleratorTable
& GetAcceleratorTable() const { return (wxAcceleratorTable
&) m_acceleratorTable
; }
363 // Override to define new behaviour for default action (e.g. double clicking
365 virtual void OnDefaultAction(wxControl
*initiatingItem
);
368 #if wxUSE_WX_RESOURCES
369 virtual bool LoadFromResource(wxWindow
*parent
, const wxString
& resourceName
, const wxResourceTable
*table
= NULL
);
370 virtual wxControl
*CreateItem(const wxItemResource
* childResource
, const wxItemResource
* parentResource
, const wxResourceTable
*table
= NULL
);
373 // Native resource loading
374 virtual bool LoadNativeDialog(wxWindow
* parent
, wxWindowID
& id
);
375 virtual bool LoadNativeDialog(wxWindow
* parent
, const wxString
& name
);
376 virtual wxWindow
* GetWindowChild1(wxWindowID
& id
);
377 virtual wxWindow
* GetWindowChild(wxWindowID
& id
);
379 virtual void GetTextExtent(const wxString
& string
, int *x
, int *y
,
381 int *externalLeading
= NULL
,
382 const wxFont
*theFont
= NULL
, bool use16
= FALSE
) const;
384 // Is the window retained?
385 inline bool IsRetained() const;
387 // Warp the pointer the given position
388 virtual void WarpPointer(int x_pos
, int y_pos
) ;
391 virtual void Clear();
393 // Find a window by id or name
394 virtual wxWindow
*FindWindow(long id
);
395 virtual wxWindow
*FindWindow(const wxString
& name
);
397 // Constraint operations
399 void SetSizer(wxSizer
*sizer
); // Adds sizer child to this window
400 inline wxSizer
*GetSizer() const ;
401 inline wxWindow
*GetSizerParent() const ;
402 inline void SetSizerParent(wxWindow
*win
);
404 // Do Update UI processing for controls
405 void UpdateWindowUI();
407 void OnEraseBackground(wxEraseEvent
& event
);
408 void OnChar(wxKeyEvent
& event
);
409 void OnPaint(wxPaintEvent
& event
);
410 void OnIdle(wxIdleEvent
& event
);
412 // Does this window want to accept keyboard focus?
413 virtual bool AcceptsFocus() const;
415 virtual void PrepareDC( wxDC
&dc
) {};
417 ////////////////////////////////////////////////////////////////////////
420 // For implementation purposes - sometimes decorations make the client area
422 virtual wxPoint
GetClientAreaOrigin() const;
424 // Makes an adjustment to the window position (for example, a frame that has
425 // a toolbar that it manages itself).
426 virtual void AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
);
428 // Windows subclassing
429 void SubclassWin(WXHWND hWnd
);
430 void UnsubclassWin();
431 virtual long Default();
432 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
434 // returns TRUE if the event was processed
435 virtual bool MSWNotify(WXWPARAM wParam
, WXLPARAM lParam
, WXLPARAM
*result
);
437 virtual wxWindow
*FindItem(int id
) const;
438 virtual wxWindow
*FindItemByHWND(WXHWND hWnd
, bool controlOnly
= FALSE
) const ;
439 virtual void PreDelete(WXHDC dc
); // Allows system cleanup
440 // TO DO: how many of these need to be virtual?
441 virtual WXHWND
GetHWND() const ;
442 virtual void SetHWND(WXHWND hWnd
);
444 // Make a Windows extended style from the given wxWindows window style
445 virtual WXDWORD
MakeExtendedStyle(long style
, bool eliminateBorders
= TRUE
);
446 // Determine whether 3D effects are wanted
447 virtual WXDWORD
Determine3DEffects(WXDWORD defaultBorderStyle
, bool *want3D
);
449 virtual void AddChild(wxWindow
*child
); // Adds reference to the child object
450 virtual void RemoveChild(wxWindow
*child
); // Removes reference to child
451 // (but doesn't delete the child object)
452 virtual void DestroyChildren(); // Removes and destroys all children
454 inline bool IsBeingDeleted();
456 // MSW only: TRUE if this control is part of the main control
457 virtual bool ContainsHWND(WXHWND
WXUNUSED(hWnd
)) const { return FALSE
; };
459 // Constraint implementation
460 void UnsetConstraints(wxLayoutConstraints
*c
);
461 inline wxList
*GetConstraintsInvolvedIn() const ;
462 // Back-pointer to other windows we're involved with, so if we delete
463 // this window, we must delete any constraints we're involved with.
464 void AddConstraintReference(wxWindow
*otherWin
);
465 void RemoveConstraintReference(wxWindow
*otherWin
);
466 void DeleteRelatedConstraints();
468 virtual void ResetConstraints();
469 virtual void SetConstraintSizes(bool recurse
= TRUE
);
470 virtual bool LayoutPhase1(int *noChanges
);
471 virtual bool LayoutPhase2(int *noChanges
);
472 virtual bool DoPhase(int);
473 // Transforms from sizer coordinate space to actual
474 // parent coordinate space
475 virtual void TransformSizerToActual(int *x
, int *y
) const ;
477 // Set size with transformation to actual coordinates if nec.
478 virtual void SizerSetSize(int x
, int y
, int w
, int h
);
479 virtual void SizerMove(int x
, int y
);
481 // Only set/get the size/position of the constraint (if any)
482 virtual void SetSizeConstraint(int x
, int y
, int w
, int h
);
483 virtual void MoveConstraint(int x
, int y
);
484 virtual void GetSizeConstraint(int *w
, int *h
) const ;
485 virtual void GetClientSizeConstraint(int *w
, int *h
) const ;
486 virtual void GetPositionConstraint(int *x
, int *y
) const ;
488 // Dialog units translations. Implemented in wincmn.cpp.
489 wxPoint
ConvertPixelsToDialog(const wxPoint
& pt
) ;
490 wxPoint
ConvertDialogToPixels(const wxPoint
& pt
) ;
491 inline wxSize
ConvertPixelsToDialog(const wxSize
& sz
)
492 { wxPoint
pt(ConvertPixelsToDialog(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
493 inline wxSize
ConvertDialogToPixels(const wxSize
& sz
)
494 { wxPoint
pt(ConvertDialogToPixels(wxPoint(sz
.x
, sz
.y
))); return wxSize(pt
.x
, pt
.y
); }
496 wxObject
*GetChild(int number
) const ;
498 void MSWCreate(int id
, wxWindow
*parent
, const char *wclass
, wxWindow
*wx_win
, const char *title
,
499 int x
, int y
, int width
, int height
,
500 WXDWORD style
, const char *dialog_template
= NULL
,
501 WXDWORD exendedStyle
= 0);
503 // Actually defined in wx_canvs.cc since requires wxCanvas declaration
504 virtual void MSWDeviceToLogical(float *x
, float *y
) const ;
506 // Create an appropriate wxWindow from a HWND
507 virtual wxWindow
* CreateWindowFromHWND(wxWindow
* parent
, WXHWND hWnd
);
509 // Make sure the window style reflects the HWND style (roughly)
510 virtual void AdoptAttributesFromHWND();
512 // Setup background and foreground colours correctly
513 virtual void SetupColours();
515 // Saves the last message information before calling base version
516 virtual bool ProcessEvent(wxEvent
& event
);
519 virtual void MSWOnCreate(WXLPCREATESTRUCT cs
);
520 virtual bool MSWOnPaint();
521 virtual WXHICON
MSWOnQueryDragIcon() { return 0; }
522 virtual void MSWOnSize(int x
, int y
, WXUINT flag
);
523 virtual void MSWOnWindowPosChanging(void *lpPos
);
524 virtual void MSWOnHScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
525 virtual void MSWOnVScroll(WXWORD nSBCode
, WXWORD pos
, WXHWND control
);
526 virtual bool MSWOnCommand(WXWORD id
, WXWORD cmd
, WXHWND control
);
527 virtual long MSWOnSysCommand(WXWPARAM wParam
, WXLPARAM lParam
);
528 virtual long MSWOnNotify(WXWPARAM wParam
, WXLPARAM lParam
);
529 virtual WXHBRUSH
MSWOnCtlColor(WXHDC dc
, WXHWND pWnd
, WXUINT nCtlColor
,
530 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
531 virtual bool MSWOnColorChange(WXHWND hWnd
, WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
532 virtual long MSWOnPaletteChanged(WXHWND hWndPalChange
);
533 virtual long MSWOnQueryNewPalette();
534 virtual bool MSWOnEraseBkgnd(WXHDC pDC
);
535 virtual void MSWOnMenuHighlight(WXWORD item
, WXWORD flags
, WXHMENU sysmenu
);
536 virtual void MSWOnInitMenuPopup(WXHMENU menu
, int pos
, bool isSystem
);
537 virtual bool MSWOnClose();
538 // Return TRUE to end session, FALSE to veto end session.
539 virtual bool MSWOnQueryEndSession(long logOff
);
540 virtual bool MSWOnEndSession(bool endSession
, long logOff
);
541 virtual bool MSWOnDestroy();
542 virtual bool MSWOnSetFocus(WXHWND wnd
);
543 virtual bool MSWOnKillFocus(WXHWND wnd
);
544 virtual void MSWOnDropFiles(WXWPARAM wParam
);
545 virtual bool MSWOnInitDialog(WXHWND hWndFocus
);
546 virtual void MSWOnShow(bool show
, int status
);
548 // TODO: rationalise these functions into 1 or 2 which take the
549 // event type as argument.
550 virtual void MSWOnLButtonDown(int x
, int y
, WXUINT flags
);
551 virtual void MSWOnLButtonUp(int x
, int y
, WXUINT flags
);
552 virtual void MSWOnLButtonDClick(int x
, int y
, WXUINT flags
);
554 virtual void MSWOnMButtonDown(int x
, int y
, WXUINT flags
);
555 virtual void MSWOnMButtonUp(int x
, int y
, WXUINT flags
);
556 virtual void MSWOnMButtonDClick(int x
, int y
, WXUINT flags
);
558 virtual void MSWOnRButtonDown(int x
, int y
, WXUINT flags
);
559 virtual void MSWOnRButtonUp(int x
, int y
, WXUINT flags
);
560 virtual void MSWOnRButtonDClick(int x
, int y
, WXUINT flags
);
562 virtual void MSWOnMouseMove(int x
, int y
, WXUINT flags
);
563 virtual void MSWOnMouseEnter(int x
, int y
, WXUINT flags
);
564 virtual void MSWOnMouseLeave(int x
, int y
, WXUINT flags
);
566 virtual void MSWOnChar(WXWORD wParam
, WXLPARAM lParam
, bool isASCII
= FALSE
);
568 virtual bool MSWOnActivate(int flag
, bool minimized
, WXHWND activate
);
569 virtual long MSWOnMDIActivate(long flag
, WXHWND activate
, WXHWND deactivate
);
571 virtual bool MSWOnDrawItem(int id
, WXDRAWITEMSTRUCT
*item
);
572 virtual bool MSWOnMeasureItem(int id
, WXMEASUREITEMSTRUCT
*item
);
574 virtual void MSWOnJoyDown(int joystick
, int x
, int y
, WXUINT flags
);
575 virtual void MSWOnJoyUp(int joystick
, int x
, int y
, WXUINT flags
);
576 virtual void MSWOnJoyMove(int joystick
, int x
, int y
, WXUINT flags
);
577 virtual void MSWOnJoyZMove(int joystick
, int z
, WXUINT flags
);
579 virtual long MSWGetDlgCode();
582 virtual long MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
584 // Calls an appropriate default window procedure
585 virtual long MSWDefWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
586 virtual bool MSWProcessMessage(WXMSG
* pMsg
);
587 virtual bool MSWTranslateMessage(WXMSG
* pMsg
);
588 virtual void MSWDestroyWindow();
590 // Detach "Window" menu from menu bar so it doesn't get deleted
591 void MSWDetachWindowMenu();
593 inline WXFARPROC
MSWGetOldWndProc() const;
594 inline void MSWSetOldWndProc(WXFARPROC proc
);
596 // Define for each class of dialog and control
597 virtual WXHBRUSH
OnCtlColor(WXHDC pDC
, WXHWND pWnd
, WXUINT nCtlColor
,
598 WXUINT message
, WXWPARAM wParam
, WXLPARAM lParam
);
600 inline void SetShowing(bool show
);
601 inline bool IsUserEnabled() const;
602 inline bool GetUseCtl3D() const ;
603 inline bool GetTransparentBackground() const ;
605 // Responds to colour changes: passes event on to children.
606 void OnSysColourChanged(wxSysColourChangedEvent
& event
);
608 // Transfers data to any child controls
609 void OnInitDialog(wxInitDialogEvent
& event
);
611 // Sends an OnInitDialog event, which in turns transfers data to
612 // to the window via validators.
613 virtual void InitDialog();
615 ////////////////////////////////////////////////////////////////////////
618 wxAcceleratorTable m_acceleratorTable
;
620 long m_windowStyle
; // Store the window's style
621 wxEvtHandler
* m_windowEventHandler
; // Usually is 'this'
622 wxLayoutConstraints
* m_constraints
; // Constraints for this window
623 wxList
* m_constraintsInvolvedIn
; // List of constraints we're involved in
624 wxSizer
* m_windowSizer
; // Window's top-level sizer (if any)
625 wxWindow
* m_sizerParent
; // Window's parent sizer (if any)
626 bool m_autoLayout
; // Whether to call Layout() in OnSize
627 wxWindow
* m_windowParent
; // Each window always knows its parent
628 wxValidator
* m_windowValidator
;
629 // Old window proc, for subclassed controls
630 WXFARPROC m_oldWndProc
;
631 bool m_useCtl3D
; // Using CTL3D for this control
633 bool m_inOnSize
; // Protection against OnSize reentry
635 // Pointer to global memory, for EDIT controls that need
636 // special treatment to reduce USER area consumption.
637 WXHGLOBAL m_globalHandle
;
651 wxFont m_windowFont
; // Window's font
653 bool m_doubleClickAllowed
;
654 wxCursor m_windowCursor
; // Window's cursor
656 wxString m_windowName
; // Window name
658 #if wxUSE_EXTENDED_STATICS
659 wxList m_staticItems
;
662 wxButton
* m_defaultItem
;
663 wxColour m_backgroundColour
;
664 wxColour m_foregroundColour
;
665 bool m_backgroundTransparent
;
674 bool m_mouseInWindow
;
676 #if wxUSE_DRAG_AND_DROP
677 wxDropTarget
*m_pDropTarget
; // the current drop target or NULL
678 #endif //USE_DRAG_AND_DROP
681 WXHWND m_hWnd
; // MS Windows window handle
683 WXWPARAM m_lastWParam
;
684 WXLPARAM m_lastLParam
;
686 wxRegion m_updateRegion
;
688 wxRect m_updateRect; // Bounding box for screen damage area
690 WXHRGN m_updateRgn; // NT allows access to the rectangle list
694 // WXHANDLE m_acceleratorTable;
695 WXHMENU m_hMenu
; // Menu, if any
696 wxList
* m_children
; // Window's children
698 bool m_isBeingDeleted
; // Fudge because can't access parent
699 // when being deleted
702 // common part of all ctors
705 DECLARE_EVENT_TABLE()
708 ////////////////////////////////////////////////////////////////////////
711 inline void *wxWindow::GetHandle() const { return (void *)GetHWND(); }
712 inline int wxWindow::GetId() const { return m_windowId
; }
713 inline void wxWindow::SetId(int id
) { m_windowId
= id
; }
714 inline wxWindow
*wxWindow::GetParent() const { return m_windowParent
; }
715 inline void wxWindow::SetParent(wxWindow
*p
) { m_windowParent
= p
; }
716 inline wxWindow
*wxWindow::GetGrandParent() const { return (m_windowParent
? m_windowParent
->m_windowParent
: NULL
); }
717 inline wxList
*wxWindow::GetChildren() const { return m_children
; }
718 inline wxFont
*wxWindow::GetFont() const { return (wxFont
*) & m_windowFont
; }
719 inline wxString
wxWindow::GetName() const { return m_windowName
; }
720 inline void wxWindow::SetName(const wxString
& name
) { m_windowName
= name
; }
721 inline long wxWindow::GetWindowStyleFlag() const { return m_windowStyle
; }
722 inline void wxWindow::SetWindowStyleFlag(long flag
) { m_windowStyle
= flag
; }
723 inline void wxWindow::SetDoubleClick(bool flag
) { m_doubleClickAllowed
= flag
; }
724 inline bool wxWindow::GetDoubleClick() const { return m_doubleClickAllowed
; }
725 inline void wxWindow::SetEventHandler(wxEvtHandler
*handler
) { m_windowEventHandler
= handler
; }
726 inline wxEvtHandler
*wxWindow::GetEventHandler() const { return m_windowEventHandler
; }
727 inline void wxWindow::SetAutoLayout(bool a
) { m_autoLayout
= a
; }
728 inline bool wxWindow::GetAutoLayout() const { return m_autoLayout
; }
729 inline wxLayoutConstraints
*wxWindow::GetConstraints() const { return m_constraints
; }
730 inline void wxWindow::SetBackgroundColour(const wxColour
& col
) { m_backgroundColour
= col
; };
731 inline wxColour
wxWindow::GetBackgroundColour() const { return m_backgroundColour
; };
732 inline void wxWindow::SetForegroundColour(const wxColour
& col
) { m_foregroundColour
= col
; };
733 inline wxColour
wxWindow::GetForegroundColour() const { return m_foregroundColour
; };
735 inline wxButton
*wxWindow::GetDefaultItem() const { return m_defaultItem
; }
736 inline void wxWindow::SetDefaultItem(wxButton
*but
) { m_defaultItem
= but
; }
737 inline bool wxWindow::IsRetained() const { return ((m_windowStyle
& wxRETAINED
) == wxRETAINED
); }
739 inline void wxWindow::SetShowing(bool show
) { m_isShown
= show
; }
740 inline wxList
*wxWindow::GetConstraintsInvolvedIn() const { return m_constraintsInvolvedIn
; }
741 inline wxSizer
*wxWindow::GetSizer() const { return m_windowSizer
; }
742 inline wxWindow
*wxWindow::GetSizerParent() const { return m_sizerParent
; }
743 inline void wxWindow::SetSizerParent(wxWindow
*win
) { m_sizerParent
= win
; }
744 inline WXFARPROC
wxWindow::MSWGetOldWndProc() const { return m_oldWndProc
; }
745 inline void wxWindow::MSWSetOldWndProc(WXFARPROC proc
) { m_oldWndProc
= proc
; }
746 inline wxValidator
*wxWindow::GetValidator() const { return m_windowValidator
; }
747 inline bool wxWindow::IsUserEnabled() const { return m_winEnabled
; }
748 inline bool wxWindow::GetUseCtl3D() const { return m_useCtl3D
; }
749 inline bool wxWindow::GetTransparentBackground() const { return m_backgroundTransparent
; }
750 inline void wxWindow::SetReturnCode(int retCode
) { m_returnCode
= retCode
; }
751 inline int wxWindow::GetReturnCode() { return m_returnCode
; }
752 inline bool wxWindow::IsBeingDeleted() { return m_isBeingDeleted
; }
754 // Window specific (so far)
755 WXDLLEXPORT wxWindow
* wxGetActiveWindow();
757 WXDLLEXPORT_DATA(extern wxList
) wxTopLevelWindows
;
759 WXDLLEXPORT
int wxCharCodeMSWToWX(int keySym
);
760 WXDLLEXPORT
int wxCharCodeWXToMSW(int id
, bool *IsVirtual
);
762 // Allocates control ids
763 WXDLLEXPORT
int NewControlId();