]> git.saurik.com Git - wxWidgets.git/blame - include/wx/msw/window.h
use wxTextEntry in wxTextValidator (modified patch 1821743)
[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
cc2b7472
VZ
16// ---------------------------------------------------------------------------
17// constants
18// ---------------------------------------------------------------------------
1e6d9499 19
cc2b7472
VZ
20// ---------------------------------------------------------------------------
21// wxWindow declaration for MSW
22// ---------------------------------------------------------------------------
b782f2e0 23
1e6feb95 24class WXDLLEXPORT wxWindowMSW : public wxWindowBase
1e6d9499 25{
8e44f3ca
JS
26 friend class wxSpinCtrl;
27 friend class wxSlider;
28 friend class wxRadioBox;
fa61fec5
MW
29#if defined __VISUALC__ && __VISUALC__ <= 1200
30 friend class wxWindowMSW;
31#endif
2bda0e17 32public:
6463b9f5 33 wxWindowMSW() { Init(); }
1e6feb95
VZ
34
35 wxWindowMSW(wxWindow *parent,
36 wxWindowID id,
37 const wxPoint& pos = wxDefaultPosition,
38 const wxSize& size = wxDefaultSize,
39 long style = 0,
6463b9f5
JS
40 const wxString& name = wxPanelNameStr)
41 {
42 Init();
43 Create(parent, id, pos, size, style, name);
44 }
2bda0e17 45
1e6feb95 46 virtual ~wxWindowMSW();
2bda0e17 47
cc2b7472
VZ
48 bool Create(wxWindow *parent,
49 wxWindowID id,
50 const wxPoint& pos = wxDefaultPosition,
51 const wxSize& size = wxDefaultSize,
52 long style = 0,
53 const wxString& name = wxPanelNameStr);
bfc6fde4 54
cc2b7472 55 // implement base class pure virtuals
faa49bfd
WS
56 virtual void SetLabel(const wxString& label);
57 virtual wxString GetLabel() const;
42e69d6b 58
bfc6fde4 59 virtual void Raise();
bfc6fde4
VZ
60 virtual void Lower();
61
27d2dbbc 62 virtual bool Show( bool show = true );
bfc6fde4 63
cc2b7472 64 virtual void SetFocus();
ddf9d04f 65 virtual void SetFocusFromKbd();
bfc6fde4 66
1e6feb95 67 virtual bool Reparent(wxWindowBase *newParent);
bfc6fde4 68
cc2b7472 69 virtual void WarpPointer(int x, int y);
bfc6fde4 70
27d2dbbc 71 virtual void Refresh( bool eraseBackground = true,
cc2b7472 72 const wxRect *rect = (const wxRect *) NULL );
1e6feb95 73 virtual void Update();
a0e449ff
VZ
74 virtual void Freeze();
75 virtual void Thaw();
d4a1433f 76 virtual bool IsFrozen() const { return m_frozenness > 0; }
bfc6fde4 77
7bd6bf45
VZ
78 virtual void SetWindowStyleFlag(long style);
79 virtual void SetExtraStyle(long exStyle);
cc2b7472
VZ
80 virtual bool SetCursor( const wxCursor &cursor );
81 virtual bool SetFont( const wxFont &font );
bfc6fde4 82
bfc6fde4
VZ
83 virtual int GetCharHeight() const;
84 virtual int GetCharWidth() const;
cc2b7472
VZ
85 virtual void GetTextExtent(const wxString& string,
86 int *x, int *y,
87 int *descent = (int *) NULL,
88 int *externalLeading = (int *) NULL,
89 const wxFont *theFont = (const wxFont *) NULL)
90 const;
91
cc2b7472 92 virtual void SetScrollbar( int orient, int pos, int thumbVisible,
27d2dbbc
WS
93 int range, bool refresh = true );
94 virtual void SetScrollPos( int orient, int pos, bool refresh = true );
cc2b7472
VZ
95 virtual int GetScrollPos( int orient ) const;
96 virtual int GetScrollThumb( int orient ) const;
97 virtual int GetScrollRange( int orient ) const;
98 virtual void ScrollWindow( int dx, int dy,
99 const wxRect* rect = (wxRect *) NULL );
2bda0e17 100
9cd6d737
VZ
101 virtual bool ScrollLines(int lines);
102 virtual bool ScrollPages(int pages);
b9b3393e 103
978af864
VZ
104 virtual void SetLayoutDirection(wxLayoutDirection dir);
105 virtual wxLayoutDirection GetLayoutDirection() const;
106 virtual wxCoord AdjustForLayoutDirection(wxCoord x,
107 wxCoord width,
108 wxCoord widthTotal) const;
109
47d67540 110#if wxUSE_DRAG_AND_DROP
cc2b7472
VZ
111 virtual void SetDropTarget( wxDropTarget *dropTarget );
112#endif // wxUSE_DRAG_AND_DROP
9f3362c4 113
bfc6fde4
VZ
114 // Accept files for dragging
115 virtual void DragAcceptFiles(bool accept);
2bda0e17 116
1e6feb95 117#ifndef __WXUNIVERSAL__
cc2b7472
VZ
118 // Native resource loading (implemented in src/msw/nativdlg.cpp)
119 // FIXME: should they really be all virtual?
bfc6fde4
VZ
120 virtual bool LoadNativeDialog(wxWindow* parent, wxWindowID& id);
121 virtual bool LoadNativeDialog(wxWindow* parent, const wxString& name);
42e69d6b
VZ
122 wxWindow* GetWindowChild1(wxWindowID id);
123 wxWindow* GetWindowChild(wxWindowID id);
1e6feb95 124#endif // __WXUNIVERSAL__
2bda0e17 125
540b6b09 126#if wxUSE_HOTKEY
5048c832 127 // install and deinstall a system wide hotkey
540b6b09 128 virtual bool RegisterHotKey(int hotkeyId, int modifiers, int keycode);
5048c832 129 virtual bool UnregisterHotKey(int hotkeyId);
540b6b09 130#endif // wxUSE_HOTKEY
5048c832 131
7d4f65e3
JS
132#ifdef __POCKETPC__
133 bool IsContextMenuEnabled() const { return m_contextMenuEnabled; }
134 void EnableContextMenu(bool enable = true) { m_contextMenuEnabled = enable; }
135#endif
136
ed4780ea
VZ
137 // window handle stuff
138 // -------------------
2bda0e17 139
d7c24517
VZ
140 WXHWND GetHWND() const { return m_hWnd; }
141 void SetHWND(WXHWND hWnd) { m_hWnd = hWnd; }
142 virtual WXWidget GetHandle() const { return GetHWND(); }
2bda0e17 143
ed4780ea
VZ
144 void AssociateHandle(WXWidget handle);
145 void DissociateHandle();
146
f7040b5f
VZ
147 // does this window have deferred position and/or size?
148 bool IsSizeDeferred() const;
149
5acec112
VZ
150 // these functions allow to register a global handler for the given Windows
151 // message: it will be called from MSWWindowProc() of any window which gets
152 // this event if it's not processed before (i.e. unlike a hook procedure it
153 // does not override the normal processing)
154 //
155 // notice that if you want to process a message for a given window only you
156 // should override its MSWWindowProc() instead
157
158 // type of the handler: it is called with the message parameters (except
159 // that the window object is passed instead of window handle) and should
160 // return true if it handled the message or false if it should be passed to
161 // DefWindowProc()
2035ad11 162 typedef bool (*MSWMessageHandler)(wxWindowMSW *win,
5acec112
VZ
163 WXUINT nMsg,
164 WXWPARAM wParam,
165 WXLPARAM lParam);
166
167 // install a handler, shouldn't be called more than one for the same message
168 static bool MSWRegisterMessageHandler(int msg, MSWMessageHandler handler);
169
170 // unregister a previously registered handler
171 static void MSWUnregisterMessageHandler(int msg, MSWMessageHandler handler);
172
ed4780ea
VZ
173
174 // implementation from now on
175 // ==========================
176
cc2b7472
VZ
177 // event handlers
178 // --------------
00c4e897 179
63da7df7 180 void OnPaint(wxPaintEvent& event);
8681b094 181 void OnEraseBackground(wxEraseEvent& event);
79099b80 182#ifdef __WXWINCE__
8681b094 183 void OnInitDialog(wxInitDialogEvent& event);
79099b80 184#endif
2bda0e17 185
2bda0e17 186public:
bfc6fde4
VZ
187 // Windows subclassing
188 void SubclassWin(WXHWND hWnd);
189 void UnsubclassWin();
bfc6fde4 190
a23fd0e1
VZ
191 WXFARPROC MSWGetOldWndProc() const { return m_oldWndProc; }
192 void MSWSetOldWndProc(WXFARPROC proc) { m_oldWndProc = proc; }
bfc6fde4 193
27d2dbbc 194 // return true if the window is of a standard (i.e. not wxWidgets') class
5a403e3f
VZ
195 //
196 // to understand why does it work, look at SubclassWin() code and comments
197 bool IsOfStandardClass() const { return m_oldWndProc != NULL; }
198
197dd9af 199 wxWindow *FindItem(long id) const;
27d2dbbc 200 wxWindow *FindItemByHWND(WXHWND hWnd, bool controlOnly = false) const;
bfc6fde4 201
27d2dbbc 202 // MSW only: true if this control is part of the main control
47b378bd 203 virtual bool ContainsHWND(WXHWND WXUNUSED(hWnd)) const { return false; }
bfc6fde4 204
c009bf3e
VZ
205#if wxUSE_TOOLTIPS
206 // MSW only: true if this window or any of its children have a tooltip
207 virtual bool HasToolTips() const { return GetToolTip() != NULL; }
208#endif // wxUSE_TOOLTIPS
209
77ffb593 210 // translate wxWidgets style flags for this control into the Windows style
b2d5a7ee
VZ
211 // and optional extended style for the corresponding native control
212 //
213 // this is the function that should be overridden in the derived classes,
214 // but you will mostly use MSWGetCreateWindowFlags() below
fe3d9123 215 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const ;
b2d5a7ee 216
77ffb593 217 // get the MSW window flags corresponding to wxWidgets ones
b2d5a7ee
VZ
218 //
219 // the functions returns the flags (WS_XXX) directly and puts the ext
220 // (WS_EX_XXX) flags into the provided pointer if not NULL
221 WXDWORD MSWGetCreateWindowFlags(WXDWORD *exflags = NULL) const
222 { return MSWGetStyle(GetWindowStyle(), exflags); }
223
7bd6bf45
VZ
224 // update the real underlying window style flags to correspond to the
225 // current wxWindow object style (safe to call even if window isn't fully
226 // created yet)
227 void MSWUpdateStyle(long flagsOld, long exflagsOld);
228
77ffb593 229 // translate wxWidgets coords into Windows ones suitable to be passed to
b225f659
VZ
230 // ::CreateWindow()
231 //
27d2dbbc 232 // returns true if non default coords are returned, false otherwise
b225f659
VZ
233 bool MSWGetCreateWindowCoords(const wxPoint& pos,
234 const wxSize& size,
235 int& x, int& y,
236 int& w, int& h) const;
237
9dfef5ac
VZ
238 // get the HWND to be used as parent of this window with CreateWindow()
239 virtual WXHWND MSWGetParent() const;
240
b225f659
VZ
241 // creates the window of specified Windows class with given style, extended
242 // style, title and geometry (default values
243 //
27d2dbbc 244 // returns true if the window has been created, false if creation failed
b225f659
VZ
245 bool MSWCreate(const wxChar *wclass,
246 const wxChar *title = NULL,
247 const wxPoint& pos = wxDefaultPosition,
248 const wxSize& size = wxDefaultSize,
249 WXDWORD style = 0,
a23fd0e1 250 WXDWORD exendedStyle = 0);
b225f659 251
42e69d6b 252 virtual bool MSWCommand(WXUINT param, WXWORD id);
bfc6fde4 253
1e6feb95 254#ifndef __WXUNIVERSAL__
bfc6fde4
VZ
255 // Create an appropriate wxWindow from a HWND
256 virtual wxWindow* CreateWindowFromHWND(wxWindow* parent, WXHWND hWnd);
257
258 // Make sure the window style reflects the HWND style (roughly)
259 virtual void AdoptAttributesFromHWND();
1e6feb95 260#endif // __WXUNIVERSAL__
bfc6fde4
VZ
261
262 // Setup background and foreground colours correctly
263 virtual void SetupColours();
264
42e69d6b
VZ
265 // ------------------------------------------------------------------------
266 // helpers for message handlers: these perform the same function as the
267 // message crackers from <windowsx.h> - they unpack WPARAM and LPARAM into
268 // the correct parameters
269 // ------------------------------------------------------------------------
270
271 void UnpackCommand(WXWPARAM wParam, WXLPARAM lParam,
272 WXWORD *id, WXHWND *hwnd, WXWORD *cmd);
273 void UnpackActivate(WXWPARAM wParam, WXLPARAM lParam,
274 WXWORD *state, WXWORD *minimized, WXHWND *hwnd);
275 void UnpackScroll(WXWPARAM wParam, WXLPARAM lParam,
276 WXWORD *code, WXWORD *pos, WXHWND *hwnd);
277 void UnpackCtlColor(WXWPARAM wParam, WXLPARAM lParam,
01c500af 278 WXHDC *hdc, WXHWND *hwnd);
42e69d6b
VZ
279 void UnpackMenuSelect(WXWPARAM wParam, WXLPARAM lParam,
280 WXWORD *item, WXWORD *flags, WXHMENU *hmenu);
281
a23fd0e1 282 // ------------------------------------------------------------------------
3cfcd50b 283 // internal handlers for MSW messages: all handlers return a boolean value:
27d2dbbc 284 // true means that the handler processed the event and false that it didn't
a23fd0e1 285 // ------------------------------------------------------------------------
bfc6fde4 286
42e69d6b
VZ
287 // there are several cases where we have virtual functions for Windows
288 // message processing: this is because these messages often require to be
289 // processed in a different manner in the derived classes. For all other
290 // messages, however, we do *not* have corresponding MSWOnXXX() function
291 // and if the derived class wants to process them, it should override
292 // MSWWindowProc() directly.
a23fd0e1 293
42e69d6b 294 // scroll event (both horizontal and vertical)
a23fd0e1
VZ
295 virtual bool MSWOnScroll(int orientation, WXWORD nSBCode,
296 WXWORD pos, WXHWND control);
297
42e69d6b 298 // child control notifications
a23fd0e1 299 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
a23fd0e1 300
42e69d6b
VZ
301 // owner-drawn controls need to process these messages
302 virtual bool MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *item);
303 virtual bool MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *item);
304
305 // the rest are not virtual
306 bool HandleCreate(WXLPCREATESTRUCT cs, bool *mayCreate);
307 bool HandleInitDialog(WXHWND hWndFocus);
308 bool HandleDestroy();
309
310 bool HandlePaint();
1a784dfc
VZ
311 bool HandlePrintClient(WXHDC hDC);
312 bool HandleEraseBkgnd(WXHDC hDC);
42e69d6b
VZ
313
314 bool HandleMinimize();
315 bool HandleMaximize();
316 bool HandleSize(int x, int y, WXUINT flag);
5706de1c 317 bool HandleSizing(wxRect& rect);
42e69d6b 318 bool HandleGetMinMaxInfo(void *mmInfo);
aa767a45
JS
319 bool HandleEnterSizeMove();
320 bool HandleExitSizeMove();
42e69d6b
VZ
321
322 bool HandleShow(bool show, int status);
323 bool HandleActivate(int flag, bool minimized, WXHWND activate);
324
325 bool HandleCommand(WXWORD id, WXWORD cmd, WXHWND control);
42e69d6b 326
48fa6bd3 327 bool HandleCtlColor(WXHBRUSH *hBrush, WXHDC hdc, WXHWND hWnd);
a23fd0e1 328
42e69d6b
VZ
329 bool HandlePaletteChanged(WXHWND hWndPalChange);
330 bool HandleQueryNewPalette();
331 bool HandleSysColorChange();
574c939e 332 bool HandleDisplayChange();
a5e84126 333 bool HandleCaptureChanged(WXHWND gainedCapture);
1272e71b 334 virtual bool HandleSettingChange(WXWPARAM wParam, WXLPARAM lParam);
a23fd0e1 335
42e69d6b
VZ
336 bool HandleQueryEndSession(long logOff, bool *mayEnd);
337 bool HandleEndSession(bool endSession, long logOff);
a23fd0e1 338
42e69d6b
VZ
339 bool HandleSetFocus(WXHWND wnd);
340 bool HandleKillFocus(WXHWND wnd);
bfc6fde4 341
42e69d6b 342 bool HandleDropFiles(WXWPARAM wParam);
bfc6fde4 343
42e69d6b
VZ
344 bool HandleMouseEvent(WXUINT msg, int x, int y, WXUINT flags);
345 bool HandleMouseMove(int x, int y, WXUINT flags);
d2c52078 346 bool HandleMouseWheel(WXWPARAM wParam, WXLPARAM lParam);
bfc6fde4 347
27d2dbbc 348 bool HandleChar(WXWPARAM wParam, WXLPARAM lParam, bool isASCII = false);
33ac7e6f
KB
349 bool HandleKeyDown(WXWPARAM wParam, WXLPARAM lParam);
350 bool HandleKeyUp(WXWPARAM wParam, WXLPARAM lParam);
5048c832
JS
351#if wxUSE_ACCEL
352 bool HandleHotKey(WXWPARAM wParam, WXLPARAM lParam);
353#endif
b74cce40
VZ
354#ifdef __WIN32__
355 int HandleMenuChar(int chAccel, WXLPARAM lParam);
356#endif
78c91815
VZ
357 // Create and process a clipboard event specified by type.
358 bool HandleClipboardEvent( WXUINT nMsg );
bfc6fde4 359
42e69d6b
VZ
360 bool HandleQueryDragIcon(WXHICON *hIcon);
361
362 bool HandleSetCursor(WXHWND hWnd, short nHitTest, int mouseMsg);
bfc6fde4 363
355debca
VZ
364 bool HandlePower(WXWPARAM wParam, WXLPARAM lParam, bool *vetoed);
365
366
bfc6fde4 367 // Window procedure
c140b7e7 368 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
bfc6fde4
VZ
369
370 // Calls an appropriate default window procedure
c140b7e7 371 virtual WXLRESULT MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
a37d422a
VZ
372
373 // message processing helpers
374
27d2dbbc 375 // return false if the message shouldn't be translated/preprocessed but
a37d422a
VZ
376 // dispatched normally
377 virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
378
27d2dbbc 379 // return true if the message was preprocessed and shouldn't be dispatched
bfc6fde4 380 virtual bool MSWProcessMessage(WXMSG* pMsg);
a37d422a 381
27d2dbbc 382 // return true if the message was translated and shouldn't be dispatched
bfc6fde4 383 virtual bool MSWTranslateMessage(WXMSG* pMsg);
a37d422a
VZ
384
385 // called when the window is about to be destroyed
bfc6fde4
VZ
386 virtual void MSWDestroyWindow();
387
01c500af 388
c5bd3c62
VZ
389 // this function should return the brush to paint the children controls
390 // background or 0 if this window doesn't impose any particular background
391 // on its children
392 //
c3732409
VZ
393 // the base class version returns a solid brush if we have a non default
394 // background colour or 0 otherwise
2bae4332 395 virtual WXHBRUSH MSWGetBgBrushForChild(WXHDC hDC, WXHWND hWnd);
c5bd3c62 396
c3732409
VZ
397 // return the background brush to use for painting the given window by
398 // quering the parent windows via their MSWGetBgBrushForChild() recursively
c5bd3c62 399 //
2bae4332 400 // hWndToPaint is normally NULL meaning this window itself, but it can also
c3732409
VZ
401 // be a child of this window which is used by the static box and could be
402 // potentially useful for other transparent controls
2bae4332 403 WXHBRUSH MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint = NULL);
c3732409
VZ
404
405 // gives the parent the possibility to draw its children background, e.g.
406 // this is used by wxNotebook to do it using DrawThemeBackground()
07c19327 407 //
c3732409
VZ
408 // return true if background was drawn, false otherwise
409 virtual bool MSWPrintChild(WXHDC WXUNUSED(hDC), wxWindow * WXUNUSED(child))
410 {
411 return false;
412 }
07c19327 413
ce0e1aac
JS
414 // some controls (e.g. wxListBox) need to set the return value themselves
415 //
416 // return true to let parent handle it if we don't, false otherwise
417 virtual bool MSWShouldPropagatePrintChild()
418 {
419 return true;
420 }
421
07c19327 422
bfc6fde4
VZ
423 // Responds to colour changes: passes event on to children.
424 void OnSysColourChanged(wxSysColourChangedEvent& event);
425
a23fd0e1
VZ
426 // initialize various fields of wxMouseEvent (common part of MSWOnMouseXXX)
427 void InitMouseEvent(wxMouseEvent& event, int x, int y, WXUINT flags);
bfc6fde4 428
1e6feb95
VZ
429 // check if mouse is in the window
430 bool IsMouseInWindow() const;
2e992e06
VZ
431
432 // check if a native double-buffering applies for this window
433 virtual bool IsDoubleBuffered() const;
1e6feb95 434
51e4e266
VZ
435 // synthesize a wxEVT_LEAVE_WINDOW event and set m_mouseInWindow to false
436 void GenerateMouseLeave();
437
e39af974
JS
438 // virtual function for implementing internal idle
439 // behaviour
c3732409 440 virtual void OnInternalIdle();
e39af974 441
2bda0e17 442protected:
3c75d8ba
PC
443 // this allows you to implement standard control borders without
444 // repeating the code in different classes that are not derived from
445 // wxControl
446 virtual wxBorder GetDefaultBorderForControl() const;
447
448 // choose the default border for this window
449 virtual wxBorder GetDefaultBorder() const;
6f02a879
VZ
450
451#if wxUSE_MENUS_NATIVE
452 virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
453#endif // wxUSE_MENUS_NATIVE
454
d7c24517
VZ
455 // the window handle
456 WXHWND m_hWnd;
457
cc2b7472 458 // the old window proc (we subclass all windows)
bfc6fde4 459 WXFARPROC m_oldWndProc;
2bda0e17 460
cc2b7472 461 // additional (MSW specific) flags
cc2b7472 462 bool m_mouseInWindow:1;
68304caf 463 bool m_lastKeydownProcessed:1;
bfc6fde4 464
cc2b7472 465 // the size of one page for scrolling
bfc6fde4
VZ
466 int m_xThumbSize;
467 int m_yThumbSize;
2bda0e17 468
cc2b7472 469 // implement the base class pure virtuals
dabc0cd5
VZ
470 virtual void DoClientToScreen( int *x, int *y ) const;
471 virtual void DoScreenToClient( int *x, int *y ) const;
cc2b7472
VZ
472 virtual void DoGetPosition( int *x, int *y ) const;
473 virtual void DoGetSize( int *width, int *height ) const;
474 virtual void DoGetClientSize( int *width, int *height ) const;
475 virtual void DoSetSize(int x, int y,
476 int width, int height,
477 int sizeFlags = wxSIZE_AUTO);
bfc6fde4 478 virtual void DoSetClientSize(int width, int height);
2bda0e17 479
94633ad9
VZ
480 virtual void DoCaptureMouse();
481 virtual void DoReleaseMouse();
68304caf 482
3c75d8ba
PC
483 virtual void DoEnable(bool enable);
484
7d86a2d4
VZ
485 // this simply moves/resizes the given HWND which is supposed to be our
486 // sibling (this is useful for controls which are composite at MSW level
487 // and for which DoMoveWindow() is not enough)
86e30911
VZ
488 //
489 // returns true if the window move was deferred, false if it was moved
490 // immediately (no error return)
491 bool DoMoveSibling(WXHWND hwnd, int x, int y, int width, int height);
7d86a2d4 492
b782f2e0
VZ
493 // move the window to the specified location and resize it: this is called
494 // from both DoSetSize() and DoSetClientSize() and would usually just call
495 // ::MoveWindow() except for composite controls which will want to arrange
496 // themselves inside the given rectangle
497 virtual void DoMoveWindow(int x, int y, int width, int height);
498
cc2b7472
VZ
499#if wxUSE_TOOLTIPS
500 virtual void DoSetToolTip( wxToolTip *tip );
bd9cd534
VZ
501
502 // process TTN_NEEDTEXT message properly (i.e. fixing the bugs in
503 // comctl32.dll in our code -- see the function body for more info)
504 bool HandleTooltipNotify(WXUINT code,
505 WXLPARAM lParam,
506 const wxString& ttip);
cc2b7472
VZ
507#endif // wxUSE_TOOLTIPS
508
b09bda68 509 // the helper functions used by HandleChar/KeyXXX methods
9c7df356
VZ
510 wxKeyEvent CreateKeyEvent(wxEventType evType, int id,
511 WXLPARAM lParam = 0, WXWPARAM wParam = 0) const;
b09bda68 512
3b72cd91
VZ
513
514 // default OnEraseBackground() implementation, return true if we did erase
c3732409
VZ
515 // the background, false otherwise (i.e. the system should erase it)
516 bool DoEraseBackground(WXHDC hDC);
3b72cd91 517
1ca78aa1 518 // generate WM_CHANGEUISTATE if it's needed for the OS we're running under
3ef092d6 519 //
1ca78aa1
JS
520 // action should be one of the UIS_XXX constants
521 // state should be one or more of the UISF_XXX constants
522 // if action == UIS_INITIALIZE then it doesn't seem to matter what we use
523 // for state as the system will decide for us what needs to be set
524 void MSWUpdateUIState(int action, int state = 0);
d7e0024b 525
fd3f686c
VZ
526private:
527 // common part of all ctors
528 void Init();
529
a23fd0e1
VZ
530 // the (non-virtual) handlers for the events
531 bool HandleMove(int x, int y);
5706de1c 532 bool HandleMoving(wxRect& rect);
a23fd0e1 533 bool HandleJoystickEvent(WXUINT msg, int x, int y, WXUINT flags);
a23fd0e1 534 bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
a23fd0e1 535
d7cbabe0 536
a1037371
VZ
537 // number of calls to Freeze() minus number of calls to Thaw()
538 unsigned int m_frozenness;
539
220f77b0 540 // current defer window position operation handle (may be NULL)
3b72cd91 541 WXHANDLE m_hDWP;
220f77b0 542
5637cc35 543protected:
67644c1d
RD
544 // When deferred positioning is done these hold the pending changes, and
545 // are used for the default values if another size/pos changes is done on
546 // this window before the group of deferred changes is completed.
547 wxPoint m_pendingPosition;
548 wxSize m_pendingSize;
220f77b0 549
5637cc35 550private:
7d4f65e3
JS
551#ifdef __POCKETPC__
552 bool m_contextMenuEnabled;
553#endif
554
e8e4fa12
GT
555 DECLARE_DYNAMIC_CLASS(wxWindowMSW)
556 DECLARE_NO_COPY_CLASS(wxWindowMSW)
fd3f686c 557 DECLARE_EVENT_TABLE()
2bda0e17
KB
558};
559
b0cb0158
VZ
560// ----------------------------------------------------------------------------
561// inline functions
562// ----------------------------------------------------------------------------
563
cc2b7472
VZ
564// ---------------------------------------------------------------------------
565// global functions
566// ---------------------------------------------------------------------------
2bda0e17 567
cc2b7472 568// kbd code translation
ff792344 569WXDLLEXPORT int wxCharCodeMSWToWX(int keySym, WXLPARAM lParam = 0);
d5c21b02 570WXDLLEXPORT WXWORD wxCharCodeWXToMSW(int id, bool *IsVirtual = NULL);
2bda0e17 571
b225f659
VZ
572// window creation helper class: before creating a new HWND, instantiate an
573// object of this class on stack - this allows to process the messages sent to
574// the window even before CreateWindow() returns
575class wxWindowCreationHook
576{
577public:
578 wxWindowCreationHook(wxWindowMSW *winBeingCreated);
579 ~wxWindowCreationHook();
580};
581
cbc8c6ee
VZ
582// ----------------------------------------------------------------------------
583// global objects
584// ----------------------------------------------------------------------------
585
586// notice that this hash must be defined after wxWindow declaration as it
587// needs to "see" its dtor and not just forward declaration
588#include "wx/hash.h"
589
590// pseudo-template HWND <-> wxWindow hash table
40ad3426 591WX_DECLARE_HASH(wxWindowMSW, wxWindowList, wxWinHashTable);
cbc8c6ee
VZ
592
593extern wxWinHashTable *wxWinHandleHash;
594
faa49bfd 595#endif // _WX_WINDOW_H_