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