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