]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/window.h
Refactor wxWindow::MSWHandleMessage() out from MSWWindowProc().
[wxWidgets.git] / include / wx / msw / window.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/window.h
3 // Purpose: wxWindowMSW class
4 // Author: Julian Smart
5 // Modified by: Vadim Zeitlin on 13.05.99: complete refont of message handling,
6 // elimination of Default(), ...
7 // Created: 01/02/97
8 // RCS-ID: $Id$
9 // Copyright: (c) Julian Smart
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
12
13 #ifndef _WX_WINDOW_H_
14 #define _WX_WINDOW_H_
15
16 #include "wx/settings.h" // solely for wxSystemColour
17
18 // if this is set to 1, we use deferred window sizing to reduce flicker when
19 // resizing complicated window hierarchies, but this can in theory result in
20 // different behaviour than the old code so we keep the possibility to use it
21 // by setting this to 0 (in the future this should be removed completely)
22 #ifdef __WXWINCE__
23 #define wxUSE_DEFERRED_SIZING 0
24 #else
25 #define wxUSE_DEFERRED_SIZING 1
26 #endif
27
28 // ---------------------------------------------------------------------------
29 // wxWindow declaration for MSW
30 // ---------------------------------------------------------------------------
31
32 class WXDLLIMPEXP_CORE wxWindowMSW : public wxWindowBase
33 {
34 friend class wxSpinCtrl;
35 friend class wxSlider;
36 friend class wxRadioBox;
37 #if defined __VISUALC__ && __VISUALC__ <= 1200
38 friend class wxWindowMSW;
39 #endif
40 public:
41 wxWindowMSW() { Init(); }
42
43 wxWindowMSW(wxWindow *parent,
44 wxWindowID id,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = 0,
48 const wxString& name = wxPanelNameStr)
49 {
50 Init();
51 Create(parent, id, pos, size, style, name);
52 }
53
54 virtual ~wxWindowMSW();
55
56 bool Create(wxWindow *parent,
57 wxWindowID id,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 long style = 0,
61 const wxString& name = wxPanelNameStr);
62
63 // implement base class pure virtuals
64 virtual void SetLabel(const wxString& label);
65 virtual wxString GetLabel() const;
66
67 virtual void Raise();
68 virtual void Lower();
69
70 virtual bool Show(bool show = true);
71 virtual bool ShowWithEffect(wxShowEffect effect,
72 unsigned timeout = 0)
73 {
74 return MSWShowWithEffect(true, effect, timeout);
75 }
76 virtual bool HideWithEffect(wxShowEffect effect,
77 unsigned timeout = 0)
78 {
79 return MSWShowWithEffect(false, effect, timeout);
80 }
81
82 virtual void SetFocus();
83 virtual void SetFocusFromKbd();
84
85 virtual bool Reparent(wxWindowBase *newParent);
86
87 virtual void WarpPointer(int x, int y);
88
89 virtual void Refresh( bool eraseBackground = true,
90 const wxRect *rect = (const wxRect *) NULL );
91 virtual void Update();
92
93 virtual void SetWindowStyleFlag(long style);
94 virtual void SetExtraStyle(long exStyle);
95 virtual bool SetCursor( const wxCursor &cursor );
96 virtual bool SetFont( const wxFont &font );
97
98 virtual int GetCharHeight() const;
99 virtual int GetCharWidth() const;
100
101 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
102 int range, bool refresh = true );
103 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
104 virtual int GetScrollPos( int orient ) const;
105 virtual int GetScrollThumb( int orient ) const;
106 virtual int GetScrollRange( int orient ) const;
107 virtual void ScrollWindow( int dx, int dy,
108 const wxRect* rect = NULL );
109
110 virtual bool ScrollLines(int lines);
111 virtual bool ScrollPages(int pages);
112
113 virtual void SetLayoutDirection(wxLayoutDirection dir);
114 virtual wxLayoutDirection GetLayoutDirection() const;
115 virtual wxCoord AdjustForLayoutDirection(wxCoord x,
116 wxCoord width,
117 wxCoord widthTotal) const;
118
119 #if wxUSE_DRAG_AND_DROP
120 virtual void SetDropTarget( wxDropTarget *dropTarget );
121 #endif // wxUSE_DRAG_AND_DROP
122
123 // Accept files for dragging
124 virtual void DragAcceptFiles(bool accept);
125
126 #ifndef __WXUNIVERSAL__
127 // Native resource loading (implemented in src/msw/nativdlg.cpp)
128 // FIXME: should they really be all virtual?
129 virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
130 virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
131 wxWindow* GetWindowChild1(wxWindowID id);
132 wxWindow* GetWindowChild(wxWindowID id);
133 #endif // __WXUNIVERSAL__
134
135 #if wxUSE_HOTKEY
136 // install and deinstall a system wide hotkey
137 virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode);
138 virtual bool UnregisterHotKey(int hotkeyId);
139 #endif // wxUSE_HOTKEY
140
141 #ifdef __POCKETPC__
142 bool IsContextMenuEnabled() const { return m_contextMenuEnabled; }
143 void EnableContextMenu(bool enable = true) { m_contextMenuEnabled = enable; }
144 #endif
145
146 // window handle stuff
147 // -------------------
148
149 WXHWND GetHWND() const { return m_hWnd; }
150 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
151 virtual WXWidget GetHandle() const { return GetHWND(); }
152
153 void AssociateHandle(WXWidget handle);
154 void DissociateHandle();
155
156 // does this window have deferred position and/or size?
157 bool IsSizeDeferred() const;
158
159 // these functions allow to register a global handler for the given Windows
160 // message: it will be called from MSWWindowProc() of any window which gets
161 // this event if it's not processed before (i.e. unlike a hook procedure it
162 // does not override the normal processing)
163 //
164 // notice that if you want to process a message for a given window only you
165 // should override its MSWWindowProc() instead
166
167 // type of the handler: it is called with the message parameters (except
168 // that the window object is passed instead of window handle) and should
169 // return true if it handled the message or false if it should be passed to
170 // DefWindowProc()
171 typedef bool (*MSWMessageHandler)(wxWindowMSW *win,
172 WXUINT nMsg,
173 WXWPARAM wParam,
174 WXLPARAM lParam);
175
176 // install a handler, shouldn't be called more than one for the same message
177 static bool MSWRegisterMessageHandler(int msg, MSWMessageHandler handler);
178
179 // unregister a previously registered handler
180 static void MSWUnregisterMessageHandler(int msg, MSWMessageHandler handler);
181
182
183 // implementation from now on
184 // ==========================
185
186 // event handlers
187 // --------------
188
189 void OnPaint(wxPaintEvent& event);
190 #ifdef __WXWINCE__
191 void OnInitDialog(wxInitDialogEvent& event);
192 #endif
193
194 public:
195 // Windows subclassing
196 void SubclassWin(WXHWND hWnd);
197 void UnsubclassWin();
198
199 WXFARPROC MSWGetOldWndProc() const { return m_oldWndProc; }
200 void MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
201
202 // return true if the window is of a standard (i.e. not wxWidgets') class
203 //
204 // to understand why does it work, look at SubclassWin() code and comments
205 bool IsOfStandardClass() const { return m_oldWndProc != NULL; }
206
207 wxWindow *FindItem(long id) const;
208 wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const;
209
210 // MSW only: true if this control is part of the main control
211 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return false; }
212
213 #if wxUSE_TOOLTIPS
214 // MSW only: true if this window or any of its children have a tooltip
215 virtual bool HasToolTips() const { return GetToolTip() != NULL; }
216 #endif // wxUSE_TOOLTIPS
217
218 // translate wxWidgets style flags for this control into the Windows style
219 // and optional extended style for the corresponding native control
220 //
221 // this is the function that should be overridden in the derived classes,
222 // but you will mostly use MSWGetCreateWindowFlags() below
223 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const ;
224
225 // get the MSW window flags corresponding to wxWidgets ones
226 //
227 // the functions returns the flags (WS_XXX) directly and puts the ext
228 // (WS_EX_XXX) flags into the provided pointer if not NULL
229 WXDWORD MSWGetCreateWindowFlags(WXDWORD *exflags = NULL) const
230 { return MSWGetStyle(GetWindowStyle(), exflags); }
231
232 // update the real underlying window style flags to correspond to the
233 // current wxWindow object style (safe to call even if window isn't fully
234 // created yet)
235 void MSWUpdateStyle(long flagsOld, long exflagsOld);
236
237 // get the HWND to be used as parent of this window with CreateWindow()
238 virtual WXHWND MSWGetParent() const;
239
240 // get the Win32 window class name used by all wxWindow objects by default
241 static const wxChar *MSWGetRegisteredClassName();
242
243 // creates the window of specified Windows class with given style, extended
244 // style, title and geometry (default values
245 //
246 // returns true if the window has been created, false if creation failed
247 bool MSWCreate(const wxChar *wclass,
248 const wxChar *title = NULL,
249 const wxPoint& pos = wxDefaultPosition,
250 const wxSize& size = wxDefaultSize,
251 WXDWORD style = 0,
252 WXDWORD exendedStyle = 0);
253
254 virtual bool MSWCommand(WXUINT param, WXWORD id);
255
256 #ifndef __WXUNIVERSAL__
257 // Create an appropriate wxWindow from a HWND
258 virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
259
260 // Make sure the window style reflects the HWND style (roughly)
261 virtual void AdoptAttributesFromHWND();
262 #endif // __WXUNIVERSAL__
263
264 // Setup background and foreground colours correctly
265 virtual void SetupColours();
266
267 // ------------------------------------------------------------------------
268 // helpers for message handlers: these perform the same function as the
269 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
270 // the correct parameters
271 // ------------------------------------------------------------------------
272
273 void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
274 WXWORD *id, WXHWND *hwnd, WXWORD *cmd);
275 void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
276 WXWORD *state, WXWORD *minimized, WXHWND *hwnd);
277 void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
278 WXWORD *code, WXWORD *pos, WXHWND *hwnd);
279 void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
280 WXHDC *hdc, WXHWND *hwnd);
281 void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
282 WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
283
284 // ------------------------------------------------------------------------
285 // internal handlers for MSW messages: all handlers return a boolean value:
286 // true means that the handler processed the event and false that it didn't
287 // ------------------------------------------------------------------------
288
289 // there are several cases where we have virtual functions for Windows
290 // message processing: this is because these messages often require to be
291 // processed in a different manner in the derived classes. For all other
292 // messages, however, we do *not* have corresponding MSWOnXXX() function
293 // and if the derived class wants to process them, it should override
294 // MSWWindowProc() directly.
295
296 // scroll event (both horizontal and vertical)
297 virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
298 WXWORD pos, WXHWND control);
299
300 // child control notifications
301 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
302
303 // owner-drawn controls need to process these messages
304 virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item);
305 virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item);
306
307 // the rest are not virtual
308 bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate);
309 bool HandleInitDialog(WXHWND hWndFocus);
310 bool HandleDestroy();
311
312 bool HandlePaint();
313 bool HandlePrintClient(WXHDC hDC);
314 bool HandleEraseBkgnd(WXHDC hDC);
315
316 bool HandleMinimize();
317 bool HandleMaximize();
318 bool HandleSize(int x, int y, WXUINT flag);
319 bool HandleSizing(wxRect& rect);
320 bool HandleGetMinMaxInfo(void *mmInfo);
321 bool HandleEnterSizeMove();
322 bool HandleExitSizeMove();
323
324 bool HandleShow(bool show, int status);
325 bool HandleActivate(int flag, bool minimized, WXHWND activate);
326
327 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
328
329 bool HandleCtlColor(WXHBRUSH *hBrush, WXHDC hdc, WXHWND hWnd);
330
331 bool HandlePaletteChanged(WXHWND hWndPalChange);
332 bool HandleQueryNewPalette();
333 bool HandleSysColorChange();
334 bool HandleDisplayChange();
335 bool HandleCaptureChanged(WXHWND gainedCapture);
336 virtual bool HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam);
337
338 bool HandleQueryEndSession(long logOff, bool *mayEnd);
339 bool HandleEndSession(bool endSession, long logOff);
340
341 bool HandleSetFocus(WXHWND wnd);
342 bool HandleKillFocus(WXHWND wnd);
343
344 bool HandleDropFiles(WXWPARAM wParam);
345
346 bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags);
347 bool HandleMouseMove(int x, int y, WXUINT flags);
348 bool HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam);
349
350 bool HandleChar(WXWPARAM wParam, WXLPARAM lParam);
351 bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam);
352 bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam);
353 #if wxUSE_ACCEL
354 bool HandleHotKey(WXWPARAM wParam, WXLPARAM lParam);
355 #endif
356 #ifdef __WIN32__
357 int HandleMenuChar(int chAccel, WXLPARAM lParam);
358 #endif
359 // Create and process a clipboard event specified by type.
360 bool HandleClipboardEvent( WXUINT nMsg );
361
362 bool HandleQueryDragIcon(WXHICON *hIcon);
363
364 bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg);
365
366 bool HandlePower(WXWPARAM wParam, WXLPARAM lParam, bool *vetoed);
367
368
369 // The main body of common window proc for all wxWindow objects. It tries
370 // to handle the given message and returns true if it was handled (the
371 // appropriate return value is then put in result, which must be non-NULL)
372 // or false if it wasn't.
373 //
374 // This function should be overridden in any new code instead of
375 // MSWWindowProc() even if currently most of the code overrides
376 // MSWWindowProc() as it had been written before this function was added.
377 virtual bool MSWHandleMessage(WXLRESULT *result,
378 WXUINT message,
379 WXWPARAM wParam,
380 WXLPARAM lParam);
381
382 // Common Window procedure for all wxWindow objects: forwards to
383 // MSWHandleMessage() and MSWDefWindowProc() if the message wasn't handled.
384 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
385
386 // Calls an appropriate default window procedure
387 virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
388
389 // message processing helpers
390
391 // return false if the message shouldn't be translated/preprocessed but
392 // dispatched normally
393 virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
394
395 // return true if the message was preprocessed and shouldn't be dispatched
396 virtual bool MSWProcessMessage(WXMSG* pMsg);
397
398 // return true if the message was translated and shouldn't be dispatched
399 virtual bool MSWTranslateMessage(WXMSG* pMsg);
400
401 // called when the window is about to be destroyed
402 virtual void MSWDestroyWindow();
403
404
405 // Functions dealing with painting the window background. The derived
406 // classes should normally only need to reimplement MSWGetBgBrush() if they
407 // need to use a non-solid brush for erasing their background. This
408 // function is called by MSWGetBgBrushForChild() which only exists for the
409 // weird wxToolBar case and MSWGetBgBrushForChild() itself is used by
410 // MSWGetBgBrush() to actually find the right brush to use.
411
412 // The brush returned from here must remain valid at least until the next
413 // event loop iteration. Returning 0, as is done by default, indicates
414 // there is no custom background brush.
415 virtual WXHBRUSH MSWGetCustomBgBrush() { return 0; }
416
417 // this function should return the brush to paint the children controls
418 // background or 0 if this window doesn't impose any particular background
419 // on its children
420 //
421 // the hDC parameter is the DC background will be drawn on, it can be used
422 // to call SetBrushOrgEx() on it if the returned brush is a bitmap one
423 //
424 // child parameter is never NULL, it can be this window itself or one of
425 // its (grand)children
426 //
427 // the base class version returns a solid brush if we have a non default
428 // background colour or 0 otherwise
429 virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, wxWindowMSW *child);
430
431 // return the background brush to use for painting the given window by
432 // querying the parent windows via MSWGetBgBrushForChild() recursively
433 WXHBRUSH MSWGetBgBrush(WXHDC hDC);
434
435 enum MSWThemeColour
436 {
437 ThemeColourText = 0,
438 ThemeColourBackground,
439 ThemeColourBorder
440 };
441
442 // returns a specific theme colour, or if that is not possible then
443 // wxSystemSettings::GetColour(fallback)
444 wxColour MSWGetThemeColour(const wchar_t *themeName,
445 int themePart,
446 int themeState,
447 MSWThemeColour themeColour,
448 wxSystemColour fallback) const;
449
450 // gives the parent the possibility to draw its children background, e.g.
451 // this is used by wxNotebook to do it using DrawThemeBackground()
452 //
453 // return true if background was drawn, false otherwise
454 virtual bool MSWPrintChild(WXHDC WXUNUSED(hDC), wxWindow * WXUNUSED(child))
455 {
456 return false;
457 }
458
459 // some controls (e.g. wxListBox) need to set the return value themselves
460 //
461 // return true to let parent handle it if we don't, false otherwise
462 virtual bool MSWShouldPropagatePrintChild()
463 {
464 return true;
465 }
466
467 // This should be overridden to return true for the controls which have
468 // themed background that should through their children. Currently only
469 // wxNotebook uses this.
470 virtual bool MSWHasInheritableBackground() const { return false; }
471
472 #if !defined(__WXWINCE__) && !defined(__WXUNIVERSAL__)
473 #define wxHAS_MSW_BACKGROUND_ERASE_HOOK
474 #endif
475
476 #ifdef wxHAS_MSW_BACKGROUND_ERASE_HOOK
477 // allows the child to hook into its parent WM_ERASEBKGND processing: call
478 // MSWSetEraseBgHook() with a non-NULL window to make parent call
479 // MSWEraseBgHook() on this window (don't forget to reset it to NULL
480 // afterwards)
481 //
482 // this hack is used by wxToolBar, see comments there
483 void MSWSetEraseBgHook(wxWindow *child);
484
485 // return true if WM_ERASEBKGND is currently hooked
486 bool MSWHasEraseBgHook() const;
487
488 // called when the window on which MSWSetEraseBgHook() had been called
489 // receives WM_ERASEBKGND
490 virtual bool MSWEraseBgHook(WXHDC WXUNUSED(hDC)) { return false; }
491 #endif // wxHAS_MSW_BACKGROUND_ERASE_HOOK
492
493 // common part of Show/HideWithEffect()
494 bool MSWShowWithEffect(bool show,
495 wxShowEffect effect,
496 unsigned timeout);
497
498 // Responds to colour changes: passes event on to children.
499 void OnSysColourChanged(wxSysColourChangedEvent& event);
500
501 // initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX)
502 void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags);
503
504 // check if mouse is in the window
505 bool IsMouseInWindow() const;
506
507 // check if a native double-buffering applies for this window
508 virtual bool IsDoubleBuffered() const;
509
510 void SetDoubleBuffered(bool on);
511
512 // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false
513 void GenerateMouseLeave();
514
515 // virtual function for implementing internal idle
516 // behaviour
517 virtual void OnInternalIdle();
518
519 protected:
520 // this allows you to implement standard control borders without
521 // repeating the code in different classes that are not derived from
522 // wxControl
523 virtual wxBorder GetDefaultBorderForControl() const;
524
525 // choose the default border for this window
526 virtual wxBorder GetDefaultBorder() const;
527
528 // Translate wxBORDER_THEME (and other border styles if necessary to the value
529 // that makes most sense for this Windows environment
530 virtual wxBorder TranslateBorder(wxBorder border) const;
531
532 #if wxUSE_MENUS_NATIVE
533 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
534 #endif // wxUSE_MENUS_NATIVE
535
536 // the window handle
537 WXHWND m_hWnd;
538
539 // the old window proc (we subclass all windows)
540 WXFARPROC m_oldWndProc;
541
542 // additional (MSW specific) flags
543 bool m_mouseInWindow:1;
544 bool m_lastKeydownProcessed:1;
545
546 // the size of one page for scrolling
547 int m_xThumbSize;
548 int m_yThumbSize;
549
550 // implement the base class pure virtuals
551 virtual void DoGetTextExtent(const wxString& string,
552 int *x, int *y,
553 int *descent = NULL,
554 int *externalLeading = NULL,
555 const wxFont *font = NULL) const;
556 virtual void DoClientToScreen( int *x, int *y ) const;
557 virtual void DoScreenToClient( int *x, int *y ) const;
558 virtual void DoGetPosition( int *x, int *y ) const;
559 virtual void DoGetSize( int *width, int *height ) const;
560 virtual void DoGetClientSize( int *width, int *height ) const;
561 virtual void DoSetSize(int x, int y,
562 int width, int height,
563 int sizeFlags = wxSIZE_AUTO);
564 virtual void DoSetClientSize(int width, int height);
565
566 virtual wxSize DoGetBorderSize() const;
567
568 virtual void DoCaptureMouse();
569 virtual void DoReleaseMouse();
570
571 virtual void DoEnable(bool enable);
572
573 virtual void DoFreeze();
574 virtual void DoThaw();
575
576 // this simply moves/resizes the given HWND which is supposed to be our
577 // sibling (this is useful for controls which are composite at MSW level
578 // and for which DoMoveWindow() is not enough)
579 //
580 // returns true if the window move was deferred, false if it was moved
581 // immediately (no error return)
582 bool DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height);
583
584 // move the window to the specified location and resize it: this is called
585 // from both DoSetSize() and DoSetClientSize() and would usually just call
586 // ::MoveWindow() except for composite controls which will want to arrange
587 // themselves inside the given rectangle
588 virtual void DoMoveWindow(int x, int y, int width, int height);
589
590 #if wxUSE_TOOLTIPS
591 virtual void DoSetToolTip( wxToolTip *tip );
592
593 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
594 // comctl32.dll in our code -- see the function body for more info)
595 bool HandleTooltipNotify(WXUINT code,
596 WXLPARAM lParam,
597 const wxString& ttip);
598 #endif // wxUSE_TOOLTIPS
599
600 // This is used by CreateKeyEvent() and also for wxEVT_CHAR[_HOOK] event
601 // creation. Notice that this method doesn't initialize wxKeyEvent
602 // m_keyCode and m_uniChar fields.
603 void InitAnyKeyEvent(wxKeyEvent& event,
604 WXWPARAM wParam,
605 WXLPARAM lParam) const;
606
607 // Helper functions used by HandleKeyXXX() methods and some derived
608 // classes, wParam and lParam have the same meaning as in WM_KEY{DOWN,UP}.
609 //
610 // NB: evType here must be wxEVT_KEY_{DOWN,UP} as wParam here contains the
611 // virtual key code, not character!
612 wxKeyEvent CreateKeyEvent(wxEventType evType,
613 WXWPARAM wParam,
614 WXLPARAM lParam = 0) const;
615
616 // Another helper for creating wxKeyEvent for wxEVT_CHAR and related types.
617 //
618 // The wParam and lParam here must come from WM_CHAR event parameters, i.e.
619 // wParam must be a character and not a virtual code.
620 wxKeyEvent CreateCharEvent(wxEventType evType,
621 WXWPARAM wParam,
622 WXLPARAM lParam) const;
623
624
625 // default OnEraseBackground() implementation, return true if we did erase
626 // the background, false otherwise (i.e. the system should erase it)
627 bool DoEraseBackground(WXHDC hDC);
628
629 // generate WM_CHANGEUISTATE if it's needed for the OS we're running under
630 //
631 // action should be one of the UIS_XXX constants
632 // state should be one or more of the UISF_XXX constants
633 // if action == UIS_INITIALIZE then it doesn't seem to matter what we use
634 // for state as the system will decide for us what needs to be set
635 void MSWUpdateUIState(int action, int state = 0);
636
637 // translate wxWidgets coords into Windows ones suitable to be passed to
638 // ::CreateWindow(), called from MSWCreate()
639 virtual void MSWGetCreateWindowCoords(const wxPoint& pos,
640 const wxSize& size,
641 int& x, int& y,
642 int& w, int& h) const;
643
644 bool MSWEnableHWND(WXHWND hWnd, bool enable);
645
646 private:
647 // common part of all ctors
648 void Init();
649
650 // the (non-virtual) handlers for the events
651 bool HandleMove(int x, int y);
652 bool HandleMoving(wxRect& rect);
653 bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
654 bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
655
656 #if wxUSE_DEFERRED_SIZING
657 protected:
658 // this function is called after the window was resized to its new size
659 virtual void MSWEndDeferWindowPos()
660 {
661 m_pendingPosition = wxDefaultPosition;
662 m_pendingSize = wxDefaultSize;
663 }
664
665 // current defer window position operation handle (may be NULL)
666 WXHANDLE m_hDWP;
667
668 // When deferred positioning is done these hold the pending changes, and
669 // are used for the default values if another size/pos changes is done on
670 // this window before the group of deferred changes is completed.
671 wxPoint m_pendingPosition;
672 wxSize m_pendingSize;
673 #endif // wxUSE_DEFERRED_SIZING
674
675 private:
676 #ifdef __POCKETPC__
677 bool m_contextMenuEnabled;
678 #endif
679
680 DECLARE_DYNAMIC_CLASS(wxWindowMSW)
681 wxDECLARE_NO_COPY_CLASS(wxWindowMSW);
682 DECLARE_EVENT_TABLE()
683 };
684
685 // window creation helper class: before creating a new HWND, instantiate an
686 // object of this class on stack - this allows to process the messages sent to
687 // the window even before CreateWindow() returns
688 class wxWindowCreationHook
689 {
690 public:
691 wxWindowCreationHook(wxWindowMSW *winBeingCreated);
692 ~wxWindowCreationHook();
693 };
694
695 #endif // _WX_WINDOW_H_