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