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