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