]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.cpp | |
3 | // Purpose: wxWindow | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 04/01/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart and Markus Holzem | |
a3622daa | 9 | // Licence: wxWindows license |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "window.h" | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
09914df7 | 20 | #pragma hdrstop |
2bda0e17 KB |
21 | #endif |
22 | ||
23 | #ifndef WX_PRECOMP | |
3a19e16d VZ |
24 | #include "wx/setup.h" |
25 | #include "wx/menu.h" | |
26 | #include "wx/dc.h" | |
27 | #include "wx/dcclient.h" | |
28 | #include "wx/utils.h" | |
29 | #include "wx/app.h" | |
30 | #include "wx/panel.h" | |
31 | #include "wx/layout.h" | |
32 | #include "wx/dialog.h" | |
33 | #include "wx/frame.h" | |
34 | #include "wx/listbox.h" | |
35 | #include "wx/button.h" | |
36 | #include "wx/settings.h" | |
37 | #include "wx/msgdlg.h" | |
341c92a8 VZ |
38 | |
39 | #include <stdio.h> | |
2bda0e17 KB |
40 | #endif |
41 | ||
47d67540 | 42 | #if wxUSE_OWNER_DRAWN |
09914df7 | 43 | #include "wx/ownerdrw.h" |
2bda0e17 KB |
44 | #endif |
45 | ||
47d67540 | 46 | #if wxUSE_DRAG_AND_DROP |
09914df7 | 47 | #include "wx/msw/ole/droptgt.h" |
2bda0e17 KB |
48 | #endif |
49 | ||
50 | #include "wx/menuitem.h" | |
47cbd6da | 51 | #include "wx/log.h" |
750b78ba JS |
52 | |
53 | #if wxUSE_TOOLTIPS | |
3a19e16d | 54 | #include "wx/tooltip.h" |
750b78ba JS |
55 | #endif |
56 | ||
dbda9e86 JS |
57 | #include "wx/intl.h" |
58 | #include "wx/log.h" | |
3a19e16d | 59 | |
2bda0e17 KB |
60 | #include "wx/msw/private.h" |
61 | ||
62 | #include <string.h> | |
63 | ||
64 | #ifndef __GNUWIN32__ | |
3a19e16d VZ |
65 | #include <shellapi.h> |
66 | #include <mmsystem.h> | |
2bda0e17 KB |
67 | #endif |
68 | ||
69 | #ifdef __WIN32__ | |
3a19e16d | 70 | #include <windowsx.h> |
2bda0e17 KB |
71 | #endif |
72 | ||
acbd13a3 | 73 | #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) |
3a19e16d | 74 | #include <commctrl.h> |
acbd13a3 | 75 | #endif |
3a19e16d | 76 | |
57c208c5 | 77 | #ifndef __TWIN32__ |
3a19e16d VZ |
78 | #ifdef __GNUWIN32__ |
79 | #include <wx/msw/gnuwin32/extra.h> | |
80 | #endif | |
57c208c5 | 81 | #endif |
2bda0e17 | 82 | |
3a19e16d | 83 | // all these are defined in <windows.h> |
2bda0e17 KB |
84 | #ifdef GetCharWidth |
85 | #undef GetCharWidth | |
86 | #endif | |
87 | ||
88 | #ifdef FindWindow | |
89 | #undef FindWindow | |
90 | #endif | |
91 | ||
92 | #ifdef GetClassName | |
93 | #undef GetClassName | |
94 | #endif | |
95 | ||
96 | #ifdef GetClassInfo | |
97 | #undef GetClassInfo | |
98 | #endif | |
99 | ||
b2aef89b | 100 | #ifdef __WXDEBUG__ |
09914df7 | 101 | const char *wxGetMessageName(int message); |
ea57084d | 102 | #endif //__WXDEBUG__ |
47cbd6da | 103 | |
f54f3bff | 104 | #define WINDOW_MARGIN 3 // This defines sensitivity of Leave events |
2bda0e17 KB |
105 | |
106 | wxMenu *wxCurrentPopupMenu = NULL; | |
cde9f08e | 107 | extern wxList WXDLLEXPORT wxPendingDelete; |
2bda0e17 KB |
108 | |
109 | void wxRemoveHandleAssociation(wxWindow *win); | |
110 | void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win); | |
111 | wxWindow *wxFindWinFromHandle(WXHWND hWnd); | |
112 | ||
113 | #if !USE_SHARED_LIBRARY | |
3a19e16d | 114 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler) |
cf65ad8d | 115 | #endif |
2bda0e17 KB |
116 | |
117 | BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler) | |
cf65ad8d VZ |
118 | EVT_CHAR(wxWindow::OnChar) |
119 | EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground) | |
120 | EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) | |
121 | EVT_INIT_DIALOG(wxWindow::OnInitDialog) | |
122 | EVT_IDLE(wxWindow::OnIdle) | |
2bda0e17 KB |
123 | END_EVENT_TABLE() |
124 | ||
2bda0e17 | 125 | // Find an item given the MS Windows id |
debe6624 | 126 | wxWindow *wxWindow::FindItem(int id) const |
2bda0e17 | 127 | { |
c0ed460c JS |
128 | // if (!GetChildren()) |
129 | // return NULL; | |
130 | wxNode *current = GetChildren().First(); | |
2d0a075d JS |
131 | while (current) |
132 | { | |
133 | wxWindow *childWin = (wxWindow *)current->Data(); | |
2bda0e17 | 134 | |
2d0a075d JS |
135 | wxWindow *wnd = childWin->FindItem(id) ; |
136 | if (wnd) | |
137 | return wnd ; | |
2bda0e17 | 138 | |
2d0a075d JS |
139 | if (childWin->IsKindOf(CLASSINFO(wxControl))) |
140 | { | |
141 | wxControl *item = (wxControl *)childWin; | |
ce3ed50d | 142 | if (item->GetId() == id) |
2d0a075d JS |
143 | return item; |
144 | else | |
145 | { | |
146 | // In case it's a 'virtual' control (e.g. radiobox) | |
147 | if (item->GetSubcontrols().Member((wxObject *)id)) | |
148 | return item; | |
149 | } | |
150 | } | |
151 | current = current->Next(); | |
2bda0e17 | 152 | } |
2d0a075d | 153 | return NULL; |
2bda0e17 KB |
154 | } |
155 | ||
156 | // Find an item given the MS Windows handle | |
debe6624 | 157 | wxWindow *wxWindow::FindItemByHWND(WXHWND hWnd, bool controlOnly) const |
2bda0e17 | 158 | { |
c0ed460c JS |
159 | // if (!GetChildren()) |
160 | // return NULL; | |
161 | wxNode *current = GetChildren().First(); | |
2d0a075d | 162 | while (current) |
2bda0e17 | 163 | { |
2d0a075d JS |
164 | wxObject *obj = (wxObject *)current->Data() ; |
165 | // Do a recursive search. | |
166 | wxWindow *parent = (wxWindow *)obj ; | |
167 | wxWindow *wnd = parent->FindItemByHWND(hWnd) ; | |
168 | if (wnd) | |
169 | return wnd ; | |
170 | ||
171 | if ((!controlOnly) || obj->IsKindOf(CLASSINFO(wxControl))) | |
172 | { | |
173 | wxWindow *item = (wxWindow *)current->Data(); | |
174 | if ((HWND)(item->GetHWND()) == (HWND) hWnd) | |
175 | return item; | |
176 | else | |
177 | { | |
178 | if ( item->ContainsHWND(hWnd) ) | |
179 | return item; | |
180 | } | |
181 | } | |
182 | current = current->Next(); | |
2bda0e17 | 183 | } |
2d0a075d | 184 | return NULL; |
2bda0e17 KB |
185 | } |
186 | ||
187 | // Default command handler | |
debe6624 | 188 | bool wxWindow::MSWCommand(WXUINT WXUNUSED(param), WXWORD WXUNUSED(id)) |
2bda0e17 | 189 | { |
2d0a075d | 190 | return FALSE; |
2bda0e17 KB |
191 | } |
192 | ||
fd3f686c | 193 | bool wxWindow::MSWNotify(WXWPARAM WXUNUSED(wParam), |
3a19e16d | 194 | WXLPARAM lParam, |
fd3f686c | 195 | WXLPARAM* WXUNUSED(result)) |
2bda0e17 | 196 | { |
acbd13a3 | 197 | #ifdef __WIN95__ |
cb1a1dc9 | 198 | #if wxUSE_TOOLTIPS |
3a19e16d VZ |
199 | NMHDR* hdr = (NMHDR *)lParam; |
200 | if ( hdr->code == TTN_NEEDTEXT && m_tooltip ) | |
201 | { | |
202 | TOOLTIPTEXT *ttt = (TOOLTIPTEXT *)lParam; | |
203 | ttt->lpszText = (char *)m_tooltip->GetTip().c_str(); | |
204 | ||
205 | // processed | |
206 | return TRUE; | |
207 | } | |
cb1a1dc9 | 208 | #endif |
acbd13a3 | 209 | #endif |
3a19e16d | 210 | |
2d0a075d | 211 | return FALSE; |
2bda0e17 KB |
212 | } |
213 | ||
debe6624 | 214 | void wxWindow::PreDelete(WXHDC WXUNUSED(dc)) |
2bda0e17 KB |
215 | { |
216 | } | |
217 | ||
218 | WXHWND wxWindow::GetHWND(void) const | |
219 | { | |
2d0a075d | 220 | return (WXHWND) m_hWnd; |
2bda0e17 KB |
221 | } |
222 | ||
223 | void wxWindow::SetHWND(WXHWND hWnd) | |
224 | { | |
2d0a075d | 225 | m_hWnd = hWnd; |
2bda0e17 KB |
226 | } |
227 | ||
fd3f686c VZ |
228 | // ---------------------------------------------------------------------------- |
229 | // constructors and such | |
230 | // ---------------------------------------------------------------------------- | |
231 | ||
232 | void wxWindow::Init() | |
2bda0e17 | 233 | { |
634903fd VZ |
234 | m_isWindow = TRUE; |
235 | ||
2d0a075d JS |
236 | // Generic |
237 | m_windowId = 0; | |
238 | m_isShown = TRUE; | |
239 | m_windowStyle = 0; | |
240 | m_windowParent = NULL; | |
241 | m_windowEventHandler = this; | |
2d0a075d JS |
242 | m_children = new wxList; |
243 | m_doubleClickAllowed = 0 ; | |
244 | m_winCaptured = FALSE; | |
245 | m_constraints = NULL; | |
246 | m_constraintsInvolvedIn = NULL; | |
247 | m_windowSizer = NULL; | |
248 | m_sizerParent = NULL; | |
249 | m_autoLayout = FALSE; | |
250 | m_windowValidator = NULL; | |
251 | ||
252 | // MSW-specific | |
253 | m_hWnd = 0; | |
254 | m_winEnabled = TRUE; | |
fd3f686c VZ |
255 | m_caretWidth = m_caretHeight = 0; |
256 | m_caretEnabled = | |
2d0a075d JS |
257 | m_caretShown = FALSE; |
258 | m_inOnSize = FALSE; | |
fd3f686c VZ |
259 | m_minSizeX = |
260 | m_minSizeY = | |
261 | m_maxSizeX = | |
2d0a075d | 262 | m_maxSizeY = -1; |
fd3f686c | 263 | |
2d0a075d JS |
264 | m_isBeingDeleted = FALSE; |
265 | m_oldWndProc = 0; | |
2bda0e17 | 266 | #ifndef __WIN32__ |
2d0a075d | 267 | m_globalHandle = 0; |
2bda0e17 | 268 | #endif |
2d0a075d | 269 | m_useCtl3D = FALSE; |
fd3f686c | 270 | m_mouseInWindow = FALSE; |
2bda0e17 | 271 | |
fd3f686c | 272 | m_windowParent = NULL; |
2d0a075d | 273 | m_defaultItem = NULL; |
2bda0e17 | 274 | |
2d0a075d | 275 | wxSystemSettings settings; |
2bda0e17 | 276 | |
2d0a075d | 277 | m_backgroundColour = settings.GetSystemColour(wxSYS_COLOUR_3DFACE) ; |
2d0a075d | 278 | m_foregroundColour = *wxBLACK; |
2bda0e17 | 279 | |
2d0a075d JS |
280 | // wxWnd |
281 | m_lastMsg = 0; | |
282 | m_lastWParam = 0; | |
283 | m_lastLParam = 0; | |
2d0a075d | 284 | m_hMenu = 0; |
2bda0e17 | 285 | |
2d0a075d JS |
286 | m_xThumbSize = 0; |
287 | m_yThumbSize = 0; | |
288 | m_backgroundTransparent = FALSE; | |
2bda0e17 | 289 | |
2d0a075d JS |
290 | m_lastXPos = (float)-1.0; |
291 | m_lastYPos = (float)-1.0; | |
292 | m_lastEvent = -1; | |
293 | m_returnCode = 0; | |
2bda0e17 | 294 | |
47d67540 | 295 | #if wxUSE_DRAG_AND_DROP |
2d0a075d | 296 | m_pDropTarget = NULL; |
2bda0e17 | 297 | #endif |
3a19e16d | 298 | |
cb1a1dc9 | 299 | #if wxUSE_TOOLTIPS |
3a19e16d | 300 | m_tooltip = NULL; |
cb1a1dc9 | 301 | #endif |
2bda0e17 KB |
302 | } |
303 | ||
fd3f686c VZ |
304 | wxWindow::wxWindow() |
305 | { | |
306 | Init(); | |
307 | } | |
308 | ||
2bda0e17 | 309 | // Destructor |
fd3f686c | 310 | wxWindow::~wxWindow() |
2bda0e17 | 311 | { |
2d0a075d | 312 | m_isBeingDeleted = TRUE; |
2bda0e17 | 313 | |
3a19e16d VZ |
314 | // first of all, delete the things on which nothing else depends |
315 | ||
cb1a1dc9 | 316 | #if wxUSE_TOOLTIPS |
3a19e16d | 317 | wxDELETE(m_tooltip); |
cb1a1dc9 | 318 | #endif |
3a19e16d | 319 | |
2d0a075d JS |
320 | // JACS - if behaviour is odd, restore this |
321 | // to the start of ~wxWindow. Vadim has changed | |
322 | // it to nearer the end. Unsure of side-effects | |
323 | // e.g. when deleting associated global data. | |
324 | // Restore old Window proc, if required | |
325 | // UnsubclassWin(); | |
2bda0e17 | 326 | |
2d0a075d JS |
327 | // Have to delete constraints/sizer FIRST otherwise |
328 | // sizers may try to look at deleted windows as they | |
329 | // delete themselves. | |
47d67540 | 330 | #if wxUSE_CONSTRAINTS |
2d0a075d | 331 | DeleteRelatedConstraints(); |
3a19e16d | 332 | |
2d0a075d JS |
333 | if (m_constraints) |
334 | { | |
335 | // This removes any dangling pointers to this window | |
336 | // in other windows' constraintsInvolvedIn lists. | |
337 | UnsetConstraints(m_constraints); | |
338 | delete m_constraints; | |
339 | m_constraints = NULL; | |
340 | } | |
3a19e16d VZ |
341 | |
342 | wxDELETE(m_windowSizer); | |
343 | ||
2d0a075d JS |
344 | // If this is a child of a sizer, remove self from parent |
345 | if (m_sizerParent) | |
346 | m_sizerParent->RemoveChild((wxWindow *)this); | |
2bda0e17 | 347 | #endif |
c085e333 | 348 | |
2d0a075d JS |
349 | // wxWnd |
350 | MSWDetachWindowMenu(); | |
2bda0e17 | 351 | |
2d0a075d JS |
352 | if (m_windowParent) |
353 | m_windowParent->RemoveChild(this); | |
2bda0e17 | 354 | |
2d0a075d | 355 | DestroyChildren(); |
2bda0e17 | 356 | |
2d0a075d JS |
357 | if (m_hWnd) |
358 | ::DestroyWindow((HWND)m_hWnd); | |
195896c7 | 359 | |
2d0a075d JS |
360 | wxRemoveHandleAssociation(this); |
361 | m_hWnd = 0; | |
2bda0e17 | 362 | #ifndef __WIN32__ |
2d0a075d JS |
363 | if (m_globalHandle) |
364 | { | |
365 | GlobalFree((HGLOBAL) m_globalHandle); | |
366 | m_globalHandle = 0; | |
367 | } | |
2bda0e17 | 368 | #endif |
c085e333 | 369 | |
2d0a075d JS |
370 | delete m_children; |
371 | m_children = NULL; | |
2bda0e17 | 372 | |
2d0a075d JS |
373 | // Just in case the window has been Closed, but |
374 | // we're then deleting immediately: don't leave | |
375 | // dangling pointers. | |
376 | wxPendingDelete.DeleteObject(this); | |
2bda0e17 | 377 | |
2d0a075d JS |
378 | // Just in case we've loaded a top-level window via |
379 | // wxWindow::LoadNativeDialog but we weren't a dialog | |
380 | // class | |
381 | wxTopLevelWindows.DeleteObject(this); | |
2bda0e17 | 382 | |
2d0a075d JS |
383 | if ( m_windowValidator ) |
384 | delete m_windowValidator; | |
2bda0e17 | 385 | |
c085e333 | 386 | // Restore old Window proc, if required |
2d0a075d JS |
387 | // and remove hWnd <-> wxWindow association |
388 | UnsubclassWin(); | |
2bda0e17 KB |
389 | } |
390 | ||
391 | // Destroy the window (delayed, if a managed window) | |
fd3f686c | 392 | bool wxWindow::Destroy() |
2bda0e17 KB |
393 | { |
394 | delete this; | |
395 | return TRUE; | |
396 | } | |
397 | ||
398 | extern char wxCanvasClassName[]; | |
399 | ||
fd3f686c | 400 | // real construction (Init() must have been called before!) |
debe6624 | 401 | bool wxWindow::Create(wxWindow *parent, wxWindowID id, |
2d0a075d JS |
402 | const wxPoint& pos, |
403 | const wxSize& size, | |
404 | long style, | |
405 | const wxString& name) | |
406 | { | |
fd3f686c | 407 | wxCHECK_MSG( parent, FALSE, "can't create wxWindow without parent" ); |
2bda0e17 | 408 | |
fd3f686c | 409 | parent->AddChild(this); |
2bda0e17 | 410 | |
2d0a075d | 411 | SetName(name); |
2bda0e17 | 412 | |
2d0a075d JS |
413 | if ( id == -1 ) |
414 | m_windowId = (int)NewControlId(); | |
415 | else | |
416 | m_windowId = id; | |
2bda0e17 | 417 | |
2d0a075d JS |
418 | int x = pos.x; |
419 | int y = pos.y; | |
420 | int width = size.x; | |
421 | int height = size.y; | |
2bda0e17 | 422 | |
386af6a2 JS |
423 | // To be consistent with wxGTK |
424 | if (width == -1) | |
425 | width = 20; | |
426 | if (height == -1) | |
427 | height = 20; | |
428 | ||
2d0a075d | 429 | wxSystemSettings settings; |
2bda0e17 | 430 | |
2d0a075d | 431 | m_windowStyle = style; |
2bda0e17 | 432 | |
2d0a075d JS |
433 | DWORD msflags = 0; |
434 | if (style & wxBORDER) | |
435 | msflags |= WS_BORDER; | |
436 | if (style & wxTHICK_FRAME) | |
437 | msflags |= WS_THICKFRAME; | |
1c089c47 | 438 | |
2d0a075d JS |
439 | msflags |= WS_CHILD | WS_VISIBLE; |
440 | if (style & wxCLIP_CHILDREN) | |
441 | msflags |= WS_CLIPCHILDREN; | |
2bda0e17 | 442 | |
2d0a075d JS |
443 | bool want3D; |
444 | WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ; | |
2bda0e17 | 445 | |
2d0a075d JS |
446 | // Even with extended styles, need to combine with WS_BORDER |
447 | // for them to look right. | |
448 | if (want3D || (m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || | |
449 | (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER)) | |
450 | msflags |= WS_BORDER; | |
2bda0e17 | 451 | |
2d0a075d | 452 | MSWCreate(m_windowId, parent, wxCanvasClassName, this, NULL, |
fd3f686c | 453 | x, y, width, height, msflags, NULL, exStyle); |
2bda0e17 | 454 | |
2d0a075d | 455 | return TRUE; |
2bda0e17 KB |
456 | } |
457 | ||
fd3f686c | 458 | void wxWindow::SetFocus() |
2bda0e17 | 459 | { |
2d0a075d JS |
460 | HWND hWnd = (HWND) GetHWND(); |
461 | if (hWnd) | |
462 | ::SetFocus(hWnd); | |
2bda0e17 KB |
463 | } |
464 | ||
debe6624 | 465 | void wxWindow::Enable(bool enable) |
2bda0e17 | 466 | { |
2d0a075d JS |
467 | m_winEnabled = enable; |
468 | HWND hWnd = (HWND) GetHWND(); | |
469 | if (hWnd) | |
470 | ::EnableWindow(hWnd, (BOOL)enable); | |
2bda0e17 KB |
471 | } |
472 | ||
fd3f686c | 473 | void wxWindow::CaptureMouse() |
2bda0e17 | 474 | { |
2d0a075d JS |
475 | HWND hWnd = (HWND) GetHWND(); |
476 | if (hWnd && !m_winCaptured) | |
477 | { | |
478 | SetCapture(hWnd); | |
479 | m_winCaptured = TRUE; | |
480 | } | |
2bda0e17 KB |
481 | } |
482 | ||
fd3f686c | 483 | void wxWindow::ReleaseMouse() |
2bda0e17 | 484 | { |
2d0a075d JS |
485 | if (m_winCaptured) |
486 | { | |
487 | ReleaseCapture(); | |
488 | m_winCaptured = FALSE; | |
489 | } | |
2bda0e17 KB |
490 | } |
491 | ||
088a95f5 JS |
492 | void wxWindow::SetAcceleratorTable(const wxAcceleratorTable& accel) |
493 | { | |
494 | m_acceleratorTable = accel; | |
495 | } | |
496 | ||
497 | ||
2bda0e17 KB |
498 | // Push/pop event handler (i.e. allow a chain of event handlers |
499 | // be searched) | |
500 | void wxWindow::PushEventHandler(wxEvtHandler *handler) | |
501 | { | |
2d0a075d JS |
502 | handler->SetNextHandler(GetEventHandler()); |
503 | SetEventHandler(handler); | |
2bda0e17 KB |
504 | } |
505 | ||
506 | wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler) | |
507 | { | |
2d0a075d | 508 | if ( GetEventHandler() ) |
564b2609 | 509 | { |
2d0a075d JS |
510 | wxEvtHandler *handlerA = GetEventHandler(); |
511 | wxEvtHandler *handlerB = handlerA->GetNextHandler(); | |
512 | handlerA->SetNextHandler(NULL); | |
513 | SetEventHandler(handlerB); | |
514 | if ( deleteHandler ) | |
515 | { | |
516 | delete handlerA; | |
517 | return NULL; | |
518 | } | |
519 | else | |
520 | return handlerA; | |
564b2609 VZ |
521 | } |
522 | else | |
2d0a075d | 523 | return NULL; |
2bda0e17 KB |
524 | } |
525 | ||
47d67540 | 526 | #if wxUSE_DRAG_AND_DROP |
2bda0e17 KB |
527 | |
528 | void wxWindow::SetDropTarget(wxDropTarget *pDropTarget) | |
529 | { | |
2d0a075d JS |
530 | if ( m_pDropTarget != 0 ) { |
531 | m_pDropTarget->Revoke(m_hWnd); | |
532 | delete m_pDropTarget; | |
533 | } | |
195896c7 | 534 | |
2d0a075d JS |
535 | m_pDropTarget = pDropTarget; |
536 | if ( m_pDropTarget != 0 ) | |
537 | m_pDropTarget->Register(m_hWnd); | |
2bda0e17 KB |
538 | } |
539 | ||
3a19e16d VZ |
540 | #endif // wxUSE_DRAG_AND_DROP |
541 | ||
2bda0e17 KB |
542 | |
543 | //old style file-manager drag&drop support | |
544 | // I think we should retain the old-style | |
545 | // DragAcceptFiles in parallel with SetDropTarget. | |
546 | // JACS | |
debe6624 | 547 | void wxWindow::DragAcceptFiles(bool accept) |
2bda0e17 | 548 | { |
2d0a075d JS |
549 | HWND hWnd = (HWND) GetHWND(); |
550 | if (hWnd) | |
551 | ::DragAcceptFiles(hWnd, (BOOL)accept); | |
2bda0e17 KB |
552 | } |
553 | ||
3a19e16d VZ |
554 | // ---------------------------------------------------------------------------- |
555 | // tooltips | |
556 | // ---------------------------------------------------------------------------- | |
557 | ||
cb1a1dc9 VZ |
558 | #if wxUSE_TOOLTIPS |
559 | ||
3a19e16d VZ |
560 | void wxWindow::SetToolTip(const wxString &tip) |
561 | { | |
562 | SetToolTip(new wxToolTip(tip)); | |
563 | } | |
564 | ||
565 | void wxWindow::SetToolTip(wxToolTip *tooltip) | |
566 | { | |
567 | if ( m_tooltip ) | |
568 | delete m_tooltip; | |
569 | ||
570 | m_tooltip = tooltip; | |
571 | m_tooltip->SetWindow(this); | |
572 | } | |
573 | ||
cb1a1dc9 VZ |
574 | #endif // wxUSE_TOOLTIPS |
575 | ||
2bda0e17 KB |
576 | // Get total size |
577 | void wxWindow::GetSize(int *x, int *y) const | |
578 | { | |
2d0a075d JS |
579 | HWND hWnd = (HWND) GetHWND(); |
580 | RECT rect; | |
581 | GetWindowRect(hWnd, &rect); | |
582 | *x = rect.right - rect.left; | |
583 | *y = rect.bottom - rect.top; | |
2bda0e17 KB |
584 | } |
585 | ||
586 | void wxWindow::GetPosition(int *x, int *y) const | |
587 | { | |
2d0a075d JS |
588 | HWND hWnd = (HWND) GetHWND(); |
589 | HWND hParentWnd = 0; | |
590 | if (GetParent()) | |
591 | hParentWnd = (HWND) GetParent()->GetHWND(); | |
81d66cf3 | 592 | |
2d0a075d JS |
593 | RECT rect; |
594 | GetWindowRect(hWnd, &rect); | |
595 | ||
596 | // Since we now have the absolute screen coords, | |
597 | // if there's a parent we must subtract its top left corner | |
598 | POINT point; | |
599 | point.x = rect.left; | |
600 | point.y = rect.top; | |
601 | if (hParentWnd) | |
602 | { | |
603 | ::ScreenToClient(hParentWnd, &point); | |
604 | } | |
605 | ||
606 | // We may be faking the client origin. | |
607 | // So a window that's really at (0, 30) may appear | |
608 | // (to wxWin apps) to be at (0, 0). | |
609 | if (GetParent()) | |
610 | { | |
611 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
612 | point.x -= pt.x; | |
613 | point.y -= pt.y; | |
614 | } | |
615 | *x = point.x; | |
616 | *y = point.y; | |
2bda0e17 KB |
617 | } |
618 | ||
619 | void wxWindow::ScreenToClient(int *x, int *y) const | |
620 | { | |
2d0a075d JS |
621 | HWND hWnd = (HWND) GetHWND(); |
622 | POINT pt; | |
623 | pt.x = *x; | |
624 | pt.y = *y; | |
2d0a075d | 625 | |
87d1e11f | 626 | ::ScreenToClient(hWnd, &pt); |
0757d27c | 627 | |
2d0a075d JS |
628 | *x = pt.x; |
629 | *y = pt.y; | |
2bda0e17 KB |
630 | } |
631 | ||
632 | void wxWindow::ClientToScreen(int *x, int *y) const | |
633 | { | |
2d0a075d JS |
634 | HWND hWnd = (HWND) GetHWND(); |
635 | POINT pt; | |
636 | pt.x = *x; | |
637 | pt.y = *y; | |
638 | ||
2d0a075d | 639 | ::ClientToScreen(hWnd, &pt); |
2bda0e17 | 640 | |
2d0a075d JS |
641 | *x = pt.x; |
642 | *y = pt.y; | |
2bda0e17 KB |
643 | } |
644 | ||
645 | void wxWindow::SetCursor(const wxCursor& cursor) | |
646 | { | |
2d0a075d JS |
647 | m_windowCursor = cursor; |
648 | if (m_windowCursor.Ok()) | |
649 | { | |
650 | HWND hWnd = (HWND) GetHWND(); | |
2bda0e17 | 651 | |
2d0a075d JS |
652 | // Change the cursor NOW if we're within the correct window |
653 | POINT point; | |
654 | ::GetCursorPos(&point); | |
2bda0e17 | 655 | |
2d0a075d JS |
656 | RECT rect; |
657 | ::GetWindowRect(hWnd, &rect); | |
2bda0e17 | 658 | |
2d0a075d JS |
659 | if (::PtInRect(&rect, point) && !wxIsBusy()) |
660 | ::SetCursor((HCURSOR) m_windowCursor.GetHCURSOR()); | |
661 | } | |
2bda0e17 | 662 | |
2d0a075d JS |
663 | // This will cause big reentrancy problems if wxFlushEvents is implemented. |
664 | // wxFlushEvents(); | |
665 | // return old_cursor; | |
2bda0e17 KB |
666 | } |
667 | ||
668 | ||
669 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
2bda0e17 KB |
670 | void wxWindow::GetClientSize(int *x, int *y) const |
671 | { | |
2d0a075d JS |
672 | HWND hWnd = (HWND) GetHWND(); |
673 | RECT rect; | |
2de8030d | 674 | ::GetClientRect(hWnd, &rect); |
2d0a075d JS |
675 | *x = rect.right; |
676 | *y = rect.bottom; | |
2bda0e17 KB |
677 | } |
678 | ||
2de8030d | 679 | void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) |
2bda0e17 | 680 | { |
2d0a075d JS |
681 | int currentX, currentY; |
682 | GetPosition(¤tX, ¤tY); | |
72fd19a1 JS |
683 | int currentW,currentH; |
684 | GetSize(¤tW, ¤tH); | |
685 | ||
686 | if (x == currentX && y == currentY && width == currentW && height == currentH) | |
687 | return; | |
688 | ||
2d0a075d JS |
689 | int actualWidth = width; |
690 | int actualHeight = height; | |
691 | int actualX = x; | |
692 | int actualY = y; | |
693 | if (x == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
694 | actualX = currentX; | |
695 | if (y == -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) | |
696 | actualY = currentY; | |
697 | ||
698 | AdjustForParentClientOrigin(actualX, actualY, sizeFlags); | |
699 | ||
2d0a075d JS |
700 | if (width == -1) |
701 | actualWidth = currentW ; | |
702 | if (height == -1) | |
703 | actualHeight = currentH ; | |
81d66cf3 | 704 | |
2d0a075d JS |
705 | HWND hWnd = (HWND) GetHWND(); |
706 | if (hWnd) | |
707 | MoveWindow(hWnd, actualX, actualY, actualWidth, actualHeight, (BOOL)TRUE); | |
2bda0e17 KB |
708 | } |
709 | ||
2de8030d | 710 | void wxWindow::DoSetClientSize(int width, int height) |
2bda0e17 | 711 | { |
2d0a075d JS |
712 | wxWindow *parent = GetParent(); |
713 | HWND hWnd = (HWND) GetHWND(); | |
721b32e0 JS |
714 | HWND hParentWnd = (HWND) 0; |
715 | if (parent) | |
716 | hParentWnd = (HWND) parent->GetHWND(); | |
2bda0e17 | 717 | |
2d0a075d | 718 | RECT rect; |
2de8030d | 719 | ::GetClientRect(hWnd, &rect); |
2bda0e17 | 720 | |
2d0a075d JS |
721 | RECT rect2; |
722 | GetWindowRect(hWnd, &rect2); | |
2bda0e17 | 723 | |
2d0a075d JS |
724 | // Find the difference between the entire window (title bar and all) |
725 | // and the client area; add this to the new client size to move the | |
726 | // window | |
727 | int actual_width = rect2.right - rect2.left - rect.right + width; | |
728 | int actual_height = rect2.bottom - rect2.top - rect.bottom + height; | |
2bda0e17 | 729 | |
2d0a075d JS |
730 | // If there's a parent, must subtract the parent's top left corner |
731 | // since MoveWindow moves relative to the parent | |
2bda0e17 | 732 | |
2d0a075d JS |
733 | POINT point; |
734 | point.x = rect2.left; | |
735 | point.y = rect2.top; | |
736 | if (parent) | |
737 | { | |
738 | ::ScreenToClient(hParentWnd, &point); | |
739 | } | |
2bda0e17 | 740 | |
2d0a075d | 741 | MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)TRUE); |
debe6624 | 742 | |
2d0a075d JS |
743 | wxSizeEvent event(wxSize(width, height), m_windowId); |
744 | event.SetEventObject(this); | |
745 | GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
746 | } |
747 | ||
81d66cf3 JS |
748 | // For implementation purposes - sometimes decorations make the client area |
749 | // smaller | |
750 | wxPoint wxWindow::GetClientAreaOrigin() const | |
751 | { | |
752 | return wxPoint(0, 0); | |
753 | } | |
754 | ||
755 | // Makes an adjustment to the window position (for example, a frame that has | |
756 | // a toolbar that it manages itself). | |
757 | void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) | |
758 | { | |
759 | if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) | |
760 | { | |
761 | wxPoint pt(GetParent()->GetClientAreaOrigin()); | |
762 | x += pt.x; y += pt.y; | |
763 | } | |
764 | } | |
765 | ||
debe6624 | 766 | bool wxWindow::Show(bool show) |
2bda0e17 | 767 | { |
aed0ed3c | 768 | m_isShown = show; |
2d0a075d JS |
769 | HWND hWnd = (HWND) GetHWND(); |
770 | int cshow; | |
771 | if (show) | |
772 | cshow = SW_SHOW; | |
773 | else | |
774 | cshow = SW_HIDE; | |
aed0ed3c | 775 | ShowWindow(hWnd, cshow); |
2d0a075d JS |
776 | if (show) |
777 | { | |
778 | BringWindowToTop(hWnd); | |
779 | // Next line causes a crash on NT, apparently. | |
780 | // UpdateWindow(hWnd); // Should this be here or will it cause inefficiency? | |
781 | } | |
782 | return TRUE; | |
2bda0e17 KB |
783 | } |
784 | ||
785 | bool wxWindow::IsShown(void) const | |
786 | { | |
aed0ed3c JS |
787 | // Can't rely on IsWindowVisible, since it will return FALSE |
788 | // if the parent is not visible. | |
789 | return m_isShown; | |
790 | // int ret = ::IsWindowVisible((HWND) GetHWND()) ; | |
791 | // return (ret != 0); | |
2bda0e17 KB |
792 | } |
793 | ||
794 | int wxWindow::GetCharHeight(void) const | |
795 | { | |
2d0a075d JS |
796 | TEXTMETRIC lpTextMetric; |
797 | HWND hWnd = (HWND) GetHWND(); | |
798 | HDC dc = ::GetDC(hWnd); | |
2bda0e17 | 799 | |
2d0a075d JS |
800 | GetTextMetrics(dc, &lpTextMetric); |
801 | ::ReleaseDC(hWnd, dc); | |
2bda0e17 | 802 | |
2d0a075d | 803 | return lpTextMetric.tmHeight; |
2bda0e17 KB |
804 | } |
805 | ||
806 | int wxWindow::GetCharWidth(void) const | |
807 | { | |
2d0a075d JS |
808 | TEXTMETRIC lpTextMetric; |
809 | HWND hWnd = (HWND) GetHWND(); | |
810 | HDC dc = ::GetDC(hWnd); | |
2bda0e17 | 811 | |
2d0a075d JS |
812 | GetTextMetrics(dc, &lpTextMetric); |
813 | ::ReleaseDC(hWnd, dc); | |
2bda0e17 | 814 | |
2d0a075d | 815 | return lpTextMetric.tmAveCharWidth; |
2bda0e17 KB |
816 | } |
817 | ||
818 | void wxWindow::GetTextExtent(const wxString& string, int *x, int *y, | |
2d0a075d | 819 | int *descent, int *externalLeading, const wxFont *theFont, bool) const |
2bda0e17 | 820 | { |
2d0a075d JS |
821 | wxFont *fontToUse = (wxFont *)theFont; |
822 | if (!fontToUse) | |
823 | fontToUse = (wxFont *) & m_windowFont; | |
2bda0e17 | 824 | |
2d0a075d JS |
825 | HWND hWnd = (HWND) GetHWND(); |
826 | HDC dc = ::GetDC(hWnd); | |
2bda0e17 | 827 | |
c085e333 | 828 | HFONT fnt = 0; |
2d0a075d JS |
829 | HFONT was = 0; |
830 | if (fontToUse && fontToUse->Ok()) | |
831 | { | |
fd3f686c VZ |
832 | fnt = (HFONT)fontToUse->GetResourceHandle(); |
833 | if ( fnt ) | |
2d0a075d JS |
834 | was = (HFONT) SelectObject(dc,fnt) ; |
835 | } | |
2bda0e17 | 836 | |
2d0a075d JS |
837 | SIZE sizeRect; |
838 | TEXTMETRIC tm; | |
839 | GetTextExtentPoint(dc, (const char *)string, (int)string.Length(), &sizeRect); | |
840 | GetTextMetrics(dc, &tm); | |
2bda0e17 | 841 | |
c085e333 | 842 | if (fontToUse && fnt && was) |
2d0a075d | 843 | SelectObject(dc,was) ; |
2bda0e17 | 844 | |
2d0a075d | 845 | ReleaseDC(hWnd, dc); |
2bda0e17 | 846 | |
2d0a075d JS |
847 | *x = sizeRect.cx; |
848 | *y = sizeRect.cy; | |
849 | if (descent) *descent = tm.tmDescent; | |
850 | if (externalLeading) *externalLeading = tm.tmExternalLeading; | |
2bda0e17 | 851 | |
2d0a075d JS |
852 | // if (fontToUse) |
853 | // fontToUse->ReleaseResource(); | |
2bda0e17 KB |
854 | } |
855 | ||
16e93305 | 856 | void wxWindow::Refresh(bool eraseBack, const wxRect *rect) |
2bda0e17 | 857 | { |
2d0a075d JS |
858 | HWND hWnd = (HWND) GetHWND(); |
859 | if (hWnd) | |
2bda0e17 | 860 | { |
2d0a075d JS |
861 | if (rect) |
862 | { | |
863 | RECT mswRect; | |
864 | mswRect.left = rect->x; | |
865 | mswRect.top = rect->y; | |
866 | mswRect.right = rect->x + rect->width; | |
867 | mswRect.bottom = rect->y + rect->height; | |
868 | ||
869 | ::InvalidateRect(hWnd, &mswRect, eraseBack); | |
870 | } | |
871 | else | |
872 | ::InvalidateRect(hWnd, NULL, eraseBack); | |
2bda0e17 | 873 | } |
2bda0e17 KB |
874 | } |
875 | ||
a02eb1d2 VZ |
876 | bool wxWindow::ProcessEvent(wxEvent& event) |
877 | { | |
2d0a075d JS |
878 | // we save here the information about the last message because it might be |
879 | // overwritten if the event handler sends any messages to our window (case | |
880 | // in point: wxNotebook::OnSize) - and then if we call Default() later | |
881 | // (which is done quite often if the message is not processed) it will use | |
882 | // incorrect values for m_lastXXX variables | |
883 | WXUINT lastMsg = m_lastMsg; | |
884 | WXWPARAM lastWParam = m_lastWParam; | |
885 | WXLPARAM lastLParam = m_lastLParam; | |
a02eb1d2 | 886 | |
2d0a075d JS |
887 | // call the base version |
888 | bool bProcessed = wxEvtHandler::ProcessEvent(event); | |
a02eb1d2 | 889 | |
2d0a075d JS |
890 | // restore |
891 | m_lastMsg = lastMsg; | |
892 | m_lastWParam = lastWParam; | |
893 | m_lastLParam = lastLParam; | |
a02eb1d2 | 894 | |
2d0a075d | 895 | return bProcessed; |
a02eb1d2 VZ |
896 | } |
897 | ||
2bda0e17 KB |
898 | // Hook for new window just as it's being created, |
899 | // when the window isn't yet associated with the handle | |
900 | wxWindow *wxWndHook = NULL; | |
901 | ||
1c089c47 | 902 | // Main window proc |
2bda0e17 KB |
903 | LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
904 | { | |
2d0a075d | 905 | wxWindow *wnd = wxFindWinFromHandle((WXHWND) hWnd); |
2bda0e17 | 906 | |
2d0a075d JS |
907 | if (!wnd && wxWndHook) |
908 | { | |
909 | wxAssociateWinWithHandle(hWnd, wxWndHook); | |
910 | wnd = wxWndHook; | |
911 | wxWndHook = NULL; | |
912 | wnd->m_hWnd = (WXHWND) hWnd; | |
913 | } | |
ea57084d | 914 | |
341c92a8 | 915 | // Stop right here if we don't have a valid handle in our wxWindow object. |
2d0a075d | 916 | if (wnd && !wnd->m_hWnd) { |
2d0a075d JS |
917 | wnd->m_hWnd = (WXHWND) hWnd; |
918 | long res = wnd->MSWDefWindowProc(message, wParam, lParam ); | |
919 | wnd->m_hWnd = 0; | |
920 | return res; | |
921 | } | |
2bda0e17 | 922 | |
2d0a075d JS |
923 | if (wnd) { |
924 | wnd->m_lastMsg = message; | |
925 | wnd->m_lastWParam = wParam; | |
926 | wnd->m_lastLParam = lParam; | |
927 | } | |
928 | if (wnd) | |
929 | return wnd->MSWWindowProc(message, wParam, lParam); | |
930 | else | |
931 | return DefWindowProc( hWnd, message, wParam, lParam ); | |
2bda0e17 KB |
932 | } |
933 | ||
934 | // Should probably have a test for 'genuine' NT | |
935 | #if defined(__WIN32__) | |
09914df7 | 936 | #define DIMENSION_TYPE short |
2bda0e17 | 937 | #else |
09914df7 | 938 | #define DIMENSION_TYPE int |
2bda0e17 KB |
939 | #endif |
940 | ||
941 | // Main Windows 3 window proc | |
942 | long wxWindow::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) | |
943 | { | |
2d0a075d | 944 | wxASSERT( m_lastMsg == message && |
09914df7 | 945 | m_lastWParam == wParam && m_lastLParam == lParam ); |
5de76427 | 946 | |
2d0a075d | 947 | #ifdef __WXDEBUG__ |
a02eb1d2 | 948 | wxLogTrace(wxTraceMessages, "Processing %s(%lx, %lx)", |
3a19e16d | 949 | wxGetMessageName(message), wParam, lParam); |
ea57084d | 950 | #endif // __WXDEBUG__ |
c085e333 | 951 | |
2d0a075d | 952 | HWND hWnd = (HWND)m_hWnd; |
2bda0e17 | 953 | |
2d0a075d JS |
954 | switch (message) |
955 | { | |
956 | case WM_ACTIVATE: | |
2bda0e17 KB |
957 | { |
958 | #ifdef __WIN32__ | |
959 | WORD state = LOWORD(wParam); | |
960 | WORD minimized = HIWORD(wParam); | |
961 | HWND hwnd = (HWND)lParam; | |
962 | #else | |
963 | WORD state = (WORD)wParam; | |
964 | WORD minimized = LOWORD(lParam); | |
965 | HWND hwnd = (HWND)HIWORD(lParam); | |
966 | #endif | |
967 | MSWOnActivate(state, (minimized != 0), (WXHWND) hwnd); | |
968 | return 0; | |
969 | break; | |
970 | } | |
2d0a075d | 971 | case WM_SETFOCUS: |
2bda0e17 KB |
972 | { |
973 | HWND hwnd = (HWND)wParam; | |
2d0a075d | 974 | // return OnSetFocus(hwnd); |
2bda0e17 KB |
975 | |
976 | if (MSWOnSetFocus((WXHWND) hwnd)) | |
2d0a075d | 977 | return 0; |
2bda0e17 KB |
978 | else return MSWDefWindowProc(message, wParam, lParam ); |
979 | break; | |
980 | } | |
2d0a075d | 981 | case WM_KILLFOCUS: |
2bda0e17 KB |
982 | { |
983 | HWND hwnd = (HWND)lParam; | |
2d0a075d | 984 | // return OnKillFocus(hwnd); |
2bda0e17 | 985 | if (MSWOnKillFocus((WXHWND) hwnd)) |
2d0a075d | 986 | return 0; |
2bda0e17 | 987 | else |
2d0a075d | 988 | return MSWDefWindowProc(message, wParam, lParam ); |
2bda0e17 KB |
989 | break; |
990 | } | |
2d0a075d | 991 | case WM_CREATE: |
47cbd6da | 992 | { |
2d0a075d JS |
993 | MSWOnCreate((WXLPCREATESTRUCT) (LPCREATESTRUCT)lParam); |
994 | return 0; | |
995 | break; | |
47cbd6da | 996 | } |
2d0a075d | 997 | case WM_SHOWWINDOW: |
47cbd6da | 998 | { |
2d0a075d JS |
999 | MSWOnShow((wParam != 0), (int) lParam); |
1000 | break; | |
47cbd6da | 1001 | } |
2d0a075d | 1002 | case WM_PAINT: |
47cbd6da | 1003 | { |
2d0a075d JS |
1004 | if (MSWOnPaint()) |
1005 | return 0; | |
1006 | else return MSWDefWindowProc(message, wParam, lParam ); | |
1007 | break; | |
2bda0e17 | 1008 | } |
2d0a075d | 1009 | case WM_QUERYDRAGICON: |
47cbd6da | 1010 | { |
fd3f686c VZ |
1011 | HICON hIcon = (HICON)MSWOnQueryDragIcon(); |
1012 | if ( hIcon ) | |
2d0a075d | 1013 | return (long)hIcon; |
fd3f686c VZ |
1014 | else |
1015 | return MSWDefWindowProc(message, wParam, lParam ); | |
2d0a075d | 1016 | break; |
2bda0e17 | 1017 | } |
c085e333 | 1018 | |
2d0a075d | 1019 | case WM_SIZE: |
2bda0e17 | 1020 | { |
2d0a075d JS |
1021 | int width = LOWORD(lParam); |
1022 | int height = HIWORD(lParam); | |
1023 | MSWOnSize(width, height, wParam); | |
1024 | break; | |
2bda0e17 | 1025 | } |
c085e333 | 1026 | |
2d0a075d JS |
1027 | case WM_MOVE: |
1028 | { | |
568cb543 | 1029 | wxMoveEvent event(wxPoint(LOWORD(lParam), HIWORD(lParam)), |
2d0a075d | 1030 | m_windowId); |
568cb543 VZ |
1031 | event.SetEventObject(this); |
1032 | if ( !GetEventHandler()->ProcessEvent(event) ) | |
2d0a075d JS |
1033 | Default(); |
1034 | } | |
1035 | break; | |
568cb543 | 1036 | |
2d0a075d | 1037 | case WM_WINDOWPOSCHANGING: |
2bda0e17 | 1038 | { |
2d0a075d JS |
1039 | MSWOnWindowPosChanging((void *)lParam); |
1040 | break; | |
2bda0e17 | 1041 | } |
c085e333 | 1042 | |
2d0a075d | 1043 | case WM_RBUTTONDOWN: |
2bda0e17 KB |
1044 | { |
1045 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1046 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1047 | MSWOnRButtonDown(x, y, wParam); | |
1048 | break; | |
1049 | } | |
2d0a075d | 1050 | case WM_RBUTTONUP: |
2bda0e17 KB |
1051 | { |
1052 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1053 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1054 | MSWOnRButtonUp(x, y, wParam); | |
1055 | break; | |
1056 | } | |
2d0a075d | 1057 | case WM_RBUTTONDBLCLK: |
2bda0e17 KB |
1058 | { |
1059 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1060 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1061 | MSWOnRButtonDClick(x, y, wParam); | |
1062 | break; | |
1063 | } | |
2d0a075d | 1064 | case WM_MBUTTONDOWN: |
2bda0e17 KB |
1065 | { |
1066 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1067 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1068 | MSWOnMButtonDown(x, y, wParam); | |
1069 | break; | |
1070 | } | |
2d0a075d | 1071 | case WM_MBUTTONUP: |
2bda0e17 KB |
1072 | { |
1073 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1074 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1075 | MSWOnMButtonUp(x, y, wParam); | |
1076 | break; | |
1077 | } | |
2d0a075d | 1078 | case WM_MBUTTONDBLCLK: |
2bda0e17 KB |
1079 | { |
1080 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1081 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1082 | MSWOnMButtonDClick(x, y, wParam); | |
1083 | break; | |
1084 | } | |
2d0a075d | 1085 | case WM_LBUTTONDOWN: |
2bda0e17 KB |
1086 | { |
1087 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1088 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1089 | MSWOnLButtonDown(x, y, wParam); | |
1090 | break; | |
1091 | } | |
2d0a075d | 1092 | case WM_LBUTTONUP: |
2bda0e17 KB |
1093 | { |
1094 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1095 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1096 | MSWOnLButtonUp(x, y, wParam); | |
1097 | break; | |
1098 | } | |
2d0a075d | 1099 | case WM_LBUTTONDBLCLK: |
2bda0e17 KB |
1100 | { |
1101 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1102 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1103 | MSWOnLButtonDClick(x, y, wParam); | |
1104 | break; | |
1105 | } | |
2d0a075d | 1106 | case WM_MOUSEMOVE: |
2bda0e17 KB |
1107 | { |
1108 | int x = (DIMENSION_TYPE) LOWORD(lParam); | |
1109 | int y = (DIMENSION_TYPE) HIWORD(lParam); | |
1110 | MSWOnMouseMove(x, y, wParam); | |
1111 | break; | |
1112 | } | |
2d0a075d | 1113 | case MM_JOY1BUTTONDOWN: |
2bda0e17 KB |
1114 | { |
1115 | int x = LOWORD(lParam); | |
1116 | int y = HIWORD(lParam); | |
1117 | MSWOnJoyDown(wxJOYSTICK1, x, y, wParam); | |
1118 | break; | |
1119 | } | |
2d0a075d | 1120 | case MM_JOY2BUTTONDOWN: |
2bda0e17 KB |
1121 | { |
1122 | int x = LOWORD(lParam); | |
1123 | int y = HIWORD(lParam); | |
1124 | MSWOnJoyDown(wxJOYSTICK2, x, y, wParam); | |
1125 | break; | |
1126 | } | |
2d0a075d | 1127 | case MM_JOY1BUTTONUP: |
2bda0e17 KB |
1128 | { |
1129 | int x = LOWORD(lParam); | |
1130 | int y = HIWORD(lParam); | |
1131 | MSWOnJoyUp(wxJOYSTICK1, x, y, wParam); | |
1132 | break; | |
1133 | } | |
2d0a075d | 1134 | case MM_JOY2BUTTONUP: |
2bda0e17 KB |
1135 | { |
1136 | int x = LOWORD(lParam); | |
1137 | int y = HIWORD(lParam); | |
1138 | MSWOnJoyUp(wxJOYSTICK2, x, y, wParam); | |
1139 | break; | |
1140 | } | |
2d0a075d | 1141 | case MM_JOY1MOVE: |
2bda0e17 KB |
1142 | { |
1143 | int x = LOWORD(lParam); | |
1144 | int y = HIWORD(lParam); | |
1145 | MSWOnJoyMove(wxJOYSTICK1, x, y, wParam); | |
1146 | break; | |
1147 | } | |
2d0a075d | 1148 | case MM_JOY2MOVE: |
2bda0e17 KB |
1149 | { |
1150 | int x = LOWORD(lParam); | |
1151 | int y = HIWORD(lParam); | |
1152 | MSWOnJoyMove(wxJOYSTICK2, x, y, wParam); | |
1153 | break; | |
1154 | } | |
2d0a075d | 1155 | case MM_JOY1ZMOVE: |
2bda0e17 KB |
1156 | { |
1157 | int z = LOWORD(lParam); | |
1158 | MSWOnJoyZMove(wxJOYSTICK1, z, wParam); | |
1159 | break; | |
1160 | } | |
2d0a075d | 1161 | case MM_JOY2ZMOVE: |
2bda0e17 KB |
1162 | { |
1163 | int z = LOWORD(lParam); | |
1164 | MSWOnJoyZMove(wxJOYSTICK2, z, wParam); | |
1165 | break; | |
1166 | } | |
2d0a075d | 1167 | case WM_DESTROY: |
2bda0e17 | 1168 | { |
2d0a075d JS |
1169 | if (MSWOnDestroy()) |
1170 | return 0; | |
1171 | else return MSWDefWindowProc(message, wParam, lParam ); | |
1172 | break; | |
2bda0e17 | 1173 | } |
2d0a075d | 1174 | case WM_SYSCOMMAND: |
2bda0e17 KB |
1175 | { |
1176 | return MSWOnSysCommand(wParam, lParam); | |
1177 | break; | |
1178 | } | |
2d0a075d | 1179 | case WM_COMMAND: |
47cbd6da | 1180 | { |
2bda0e17 KB |
1181 | #ifdef __WIN32__ |
1182 | WORD id = LOWORD(wParam); | |
1183 | HWND hwnd = (HWND)lParam; | |
1184 | WORD cmd = HIWORD(wParam); | |
1185 | #else | |
1186 | WORD id = (WORD)wParam; | |
1187 | HWND hwnd = (HWND)LOWORD(lParam) ; | |
1188 | WORD cmd = HIWORD(lParam); | |
1189 | #endif | |
1190 | if (!MSWOnCommand(id, cmd, (WXHWND) hwnd)) | |
2d0a075d | 1191 | return MSWDefWindowProc(message, wParam, lParam ); |
2bda0e17 | 1192 | break; |
47cbd6da | 1193 | } |
2bda0e17 | 1194 | #if defined(__WIN95__) |
2d0a075d | 1195 | case WM_NOTIFY: |
47cbd6da | 1196 | { |
fd3f686c VZ |
1197 | // for some messages (TVN_ITEMEXPANDING for example), the return |
1198 | // value of WM_NOTIFY handler is important, so don't just return 0 | |
1199 | // if we processed the message | |
1200 | return MSWOnNotify(wParam, lParam); | |
2bda0e17 KB |
1201 | } |
1202 | #endif | |
2d0a075d | 1203 | case WM_MENUSELECT: |
2bda0e17 KB |
1204 | { |
1205 | #ifdef __WIN32__ | |
1206 | WORD flags = HIWORD(wParam); | |
1207 | HMENU sysmenu = (HMENU)lParam; | |
1208 | #else | |
1209 | WORD flags = LOWORD(lParam); | |
1210 | HMENU sysmenu = (HMENU)HIWORD(lParam); | |
1211 | #endif | |
1212 | MSWOnMenuHighlight((WORD)wParam, flags, (WXHMENU) sysmenu); | |
1213 | break; | |
1214 | } | |
2d0a075d | 1215 | case WM_INITMENUPOPUP: |
2bda0e17 KB |
1216 | { |
1217 | MSWOnInitMenuPopup((WXHMENU) (HMENU)wParam, (int)LOWORD(lParam), (HIWORD(lParam) != 0)); | |
1218 | break; | |
1219 | } | |
2d0a075d | 1220 | case WM_DRAWITEM: |
2bda0e17 | 1221 | { |
2d0a075d JS |
1222 | return MSWOnDrawItem((int)wParam, (WXDRAWITEMSTRUCT *)lParam); |
1223 | break; | |
2bda0e17 | 1224 | } |
2d0a075d | 1225 | case WM_MEASUREITEM: |
2bda0e17 | 1226 | { |
2d0a075d JS |
1227 | return MSWOnMeasureItem((int)wParam, (WXMEASUREITEMSTRUCT *)lParam); |
1228 | break; | |
2bda0e17 | 1229 | } |
c085e333 | 1230 | |
2d0a075d | 1231 | case WM_KEYDOWN: |
dbda9e86 JS |
1232 | // If this has been processed by an event handler, |
1233 | // return 0 now (we've handled it). | |
1234 | if (MSWOnKeyDown((WORD) wParam, lParam)) | |
1235 | { | |
1236 | return 0; | |
1237 | } | |
1238 | ||
1239 | // we consider these message "not interesting" to OnChar | |
2d0a075d | 1240 | if ( wParam == VK_SHIFT || wParam == VK_CONTROL ) |
dbda9e86 | 1241 | { |
2d0a075d | 1242 | return Default(); |
dbda9e86 | 1243 | } |
2d0a075d | 1244 | |
341c92a8 VZ |
1245 | // Avoid duplicate messages to OnChar for these special keys |
1246 | switch ( wParam ) | |
2d0a075d | 1247 | { |
341c92a8 VZ |
1248 | case VK_ESCAPE: |
1249 | case VK_SPACE: | |
1250 | case VK_RETURN: | |
1251 | case VK_BACK: | |
1252 | case VK_TAB: | |
1253 | case VK_LEFT: | |
1254 | case VK_RIGHT: | |
1255 | case VK_DOWN: | |
1256 | case VK_UP: | |
b23386b2 | 1257 | return Default(); |
839b865d VZ |
1258 | |
1259 | #ifdef VK_APPS | |
1260 | // special case of VK_APPS: treat it the same as right mouse click | |
1261 | // because both usually pop up a context menu | |
1262 | case VK_APPS: | |
1263 | { | |
1264 | // construct the key mask | |
1265 | WPARAM fwKeys = MK_RBUTTON; | |
1266 | if ( (::GetKeyState(VK_CONTROL) & 0x100) != 0 ) | |
1267 | fwKeys |= MK_CONTROL; | |
1268 | if ( (::GetKeyState(VK_SHIFT) & 0x100) != 0 ) | |
1269 | fwKeys |= MK_SHIFT; | |
1270 | ||
1271 | // simulate right mouse button click | |
1272 | DWORD dwPos = ::GetMessagePos(); | |
1273 | int x = GET_X_LPARAM(dwPos), | |
1274 | y = GET_Y_LPARAM(dwPos); | |
1275 | ||
1276 | ScreenToClient(&x, &y); | |
1277 | MSWOnRButtonDown(x, y, fwKeys); | |
1278 | } | |
b23386b2 | 1279 | break; |
839b865d VZ |
1280 | #endif // VK_APPS |
1281 | ||
341c92a8 | 1282 | default: |
dbda9e86 JS |
1283 | if (!MSWOnChar((WORD)wParam, lParam)) |
1284 | { | |
1285 | return Default(); | |
1286 | } | |
341c92a8 | 1287 | break; |
2d0a075d | 1288 | } |
341c92a8 | 1289 | |
2d0a075d | 1290 | break; |
839b865d | 1291 | |
4ce81a75 JS |
1292 | case WM_KEYUP: |
1293 | { | |
dbda9e86 JS |
1294 | if (!MSWOnKeyUp((WORD) wParam, lParam)) |
1295 | return Default(); | |
4ce81a75 JS |
1296 | break; |
1297 | } | |
2d0a075d JS |
1298 | case WM_CHAR: // Always an ASCII character |
1299 | { | |
dbda9e86 JS |
1300 | if (!MSWOnChar((WORD)wParam, lParam, TRUE)) |
1301 | return Default(); | |
47cbd6da | 1302 | break; |
2d0a075d | 1303 | } |
f54f3bff | 1304 | |
2d0a075d | 1305 | case WM_HSCROLL: |
2bda0e17 KB |
1306 | { |
1307 | #ifdef __WIN32__ | |
1308 | WORD code = LOWORD(wParam); | |
1309 | WORD pos = HIWORD(wParam); | |
1310 | HWND control = (HWND)lParam; | |
1311 | #else | |
1312 | WORD code = (WORD)wParam; | |
1313 | WORD pos = LOWORD(lParam); | |
1314 | HWND control = (HWND)HIWORD(lParam); | |
1315 | #endif | |
1316 | MSWOnHScroll(code, pos, (WXHWND) control); | |
1317 | break; | |
1318 | } | |
2d0a075d | 1319 | case WM_VSCROLL: |
2bda0e17 KB |
1320 | { |
1321 | #ifdef __WIN32__ | |
1322 | WORD code = LOWORD(wParam); | |
1323 | WORD pos = HIWORD(wParam); | |
1324 | HWND control = (HWND)lParam; | |
1325 | #else | |
1326 | WORD code = (WORD)wParam; | |
1327 | WORD pos = LOWORD(lParam); | |
1328 | HWND control = (HWND)HIWORD(lParam); | |
1329 | #endif | |
1330 | MSWOnVScroll(code, pos, (WXHWND) control); | |
1331 | break; | |
1332 | } | |
1333 | #ifdef __WIN32__ | |
2d0a075d | 1334 | case WM_CTLCOLORBTN: |
47cbd6da | 1335 | { |
2d0a075d JS |
1336 | int nCtlColor = CTLCOLOR_BTN; |
1337 | HWND control = (HWND)lParam; | |
1338 | HDC pDC = (HDC)wParam; | |
1339 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1340 | message, wParam, lParam); | |
1341 | break; | |
47cbd6da | 1342 | } |
2d0a075d | 1343 | case WM_CTLCOLORDLG: |
47cbd6da | 1344 | { |
2d0a075d JS |
1345 | int nCtlColor = CTLCOLOR_DLG; |
1346 | HWND control = (HWND)lParam; | |
1347 | HDC pDC = (HDC)wParam; | |
1348 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1349 | message, wParam, lParam);\ | |
1350 | break; | |
47cbd6da | 1351 | } |
2d0a075d | 1352 | case WM_CTLCOLORLISTBOX: |
47cbd6da | 1353 | { |
2d0a075d JS |
1354 | int nCtlColor = CTLCOLOR_LISTBOX; |
1355 | HWND control = (HWND)lParam; | |
1356 | HDC pDC = (HDC)wParam; | |
1357 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1358 | message, wParam, lParam); | |
1359 | break; | |
47cbd6da | 1360 | } |
2d0a075d | 1361 | case WM_CTLCOLORMSGBOX: |
47cbd6da | 1362 | { |
2d0a075d JS |
1363 | int nCtlColor = CTLCOLOR_MSGBOX; |
1364 | HWND control = (HWND)lParam; | |
1365 | HDC pDC = (HDC)wParam; | |
1366 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1367 | message, wParam, lParam); | |
1368 | break; | |
47cbd6da | 1369 | } |
2d0a075d | 1370 | case WM_CTLCOLORSCROLLBAR: |
47cbd6da | 1371 | { |
2d0a075d JS |
1372 | int nCtlColor = CTLCOLOR_SCROLLBAR; |
1373 | HWND control = (HWND)lParam; | |
1374 | HDC pDC = (HDC)wParam; | |
1375 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1376 | message, wParam, lParam); | |
1377 | break; | |
47cbd6da | 1378 | } |
2d0a075d | 1379 | case WM_CTLCOLORSTATIC: |
47cbd6da | 1380 | { |
2d0a075d JS |
1381 | int nCtlColor = CTLCOLOR_STATIC; |
1382 | HWND control = (HWND)lParam; | |
1383 | HDC pDC = (HDC)wParam; | |
1384 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1385 | message, wParam, lParam); | |
1386 | break; | |
47cbd6da | 1387 | } |
2d0a075d | 1388 | case WM_CTLCOLOREDIT: |
47cbd6da | 1389 | { |
2d0a075d JS |
1390 | int nCtlColor = CTLCOLOR_EDIT; |
1391 | HWND control = (HWND)lParam; | |
1392 | HDC pDC = (HDC)wParam; | |
1393 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1394 | message, wParam, lParam); | |
1395 | break; | |
47cbd6da | 1396 | } |
2bda0e17 | 1397 | #else |
2d0a075d | 1398 | case WM_CTLCOLOR: |
2bda0e17 | 1399 | { |
2d0a075d JS |
1400 | HWND control = (HWND)LOWORD(lParam); |
1401 | int nCtlColor = (int)HIWORD(lParam); | |
1402 | HDC pDC = (HDC)wParam; | |
1403 | return (DWORD)MSWOnCtlColor((WXHDC) pDC, (WXHWND) control, nCtlColor, | |
1404 | message, wParam, lParam); | |
1405 | break; | |
2bda0e17 KB |
1406 | } |
1407 | #endif | |
2d0a075d | 1408 | case WM_SYSCOLORCHANGE: |
2bda0e17 | 1409 | { |
2d0a075d JS |
1410 | // Return value of 0 means, we processed it. |
1411 | if (MSWOnColorChange((WXHWND) hWnd, message, wParam, lParam) == 0) | |
1412 | return 0; | |
1413 | else | |
1414 | return MSWDefWindowProc(message, wParam, lParam ); | |
1415 | break; | |
2bda0e17 | 1416 | } |
2d0a075d | 1417 | case WM_PALETTECHANGED: |
f7bd2698 JS |
1418 | { |
1419 | return MSWOnPaletteChanged((WXHWND) (HWND) wParam); | |
1420 | break; | |
1421 | } | |
2d0a075d | 1422 | case WM_QUERYNEWPALETTE: |
f7bd2698 JS |
1423 | { |
1424 | return MSWOnQueryNewPalette(); | |
1425 | break; | |
1426 | } | |
2d0a075d | 1427 | case WM_ERASEBKGND: |
2bda0e17 | 1428 | { |
2d0a075d JS |
1429 | // Prevents flicker when dragging |
1430 | if (IsIconic(hWnd)) return 1; | |
2bda0e17 | 1431 | |
2d0a075d JS |
1432 | if (!MSWOnEraseBkgnd((WXHDC) (HDC)wParam)) |
1433 | return 0; // Default(); MSWDefWindowProc(message, wParam, lParam ); | |
1434 | else return 1; | |
1435 | break; | |
2bda0e17 | 1436 | } |
2d0a075d | 1437 | case WM_MDIACTIVATE: |
2bda0e17 KB |
1438 | { |
1439 | #ifdef __WIN32__ | |
1440 | HWND hWndActivate = GET_WM_MDIACTIVATE_HWNDACTIVATE(wParam,lParam); | |
1441 | HWND hWndDeactivate = GET_WM_MDIACTIVATE_HWNDDEACT(wParam,lParam); | |
1442 | BOOL activate = GET_WM_MDIACTIVATE_FACTIVATE(hWnd,wParam,lParam); | |
1443 | return MSWOnMDIActivate((long) activate, (WXHWND) hWndActivate, (WXHWND) hWndDeactivate); | |
1444 | #else | |
1445 | return MSWOnMDIActivate((BOOL)wParam, (HWND)LOWORD(lParam), | |
2d0a075d | 1446 | (HWND)HIWORD(lParam)); |
2bda0e17 KB |
1447 | #endif |
1448 | } | |
2d0a075d | 1449 | case WM_DROPFILES: |
2bda0e17 KB |
1450 | { |
1451 | MSWOnDropFiles(wParam); | |
1452 | break; | |
47cbd6da | 1453 | } |
2d0a075d | 1454 | case WM_INITDIALOG: |
2bda0e17 KB |
1455 | { |
1456 | return 0; // MSWOnInitDialog((WXHWND)(HWND)wParam); | |
1457 | break; | |
47cbd6da | 1458 | } |
2d0a075d | 1459 | case WM_QUERYENDSESSION: |
2bda0e17 | 1460 | { |
47cbd6da | 1461 | // Same as WM_CLOSE, but inverted results. Thx Microsoft :-) |
2d0a075d | 1462 | // return MSWOnClose(); |
387a3b02 JS |
1463 | |
1464 | return MSWOnQueryEndSession(lParam); | |
1465 | break; | |
1466 | } | |
2d0a075d | 1467 | case WM_ENDSESSION: |
387a3b02 JS |
1468 | { |
1469 | // Same as WM_CLOSE, but inverted results. Thx Microsoft :-) | |
1470 | MSWOnEndSession((wParam != 0), lParam); | |
1471 | return 0L; | |
2bda0e17 KB |
1472 | break; |
1473 | } | |
2d0a075d | 1474 | case WM_CLOSE: |
2bda0e17 KB |
1475 | { |
1476 | if (MSWOnClose()) | |
2d0a075d | 1477 | return 0L; |
2bda0e17 | 1478 | else |
2d0a075d | 1479 | return 1L; |
2bda0e17 KB |
1480 | break; |
1481 | } | |
c085e333 | 1482 | |
2d0a075d | 1483 | case WM_GETMINMAXINFO: |
2bda0e17 | 1484 | { |
2d0a075d JS |
1485 | MINMAXINFO *info = (MINMAXINFO *)lParam; |
1486 | if (m_minSizeX != -1) | |
1487 | info->ptMinTrackSize.x = (int)m_minSizeX; | |
1488 | if (m_minSizeY != -1) | |
1489 | info->ptMinTrackSize.y = (int)m_minSizeY; | |
1490 | if (m_maxSizeX != -1) | |
1491 | info->ptMaxTrackSize.x = (int)m_maxSizeX; | |
1492 | if (m_maxSizeY != -1) | |
1493 | info->ptMaxTrackSize.y = (int)m_maxSizeY; | |
1494 | return MSWDefWindowProc(message, wParam, lParam ); | |
1495 | break; | |
2bda0e17 | 1496 | } |
c085e333 | 1497 | |
2d0a075d JS |
1498 | case WM_GETDLGCODE: |
1499 | return MSWGetDlgCode(); | |
2bda0e17 | 1500 | |
634903fd | 1501 | case WM_SETCURSOR: |
634903fd | 1502 | { |
1aff8b02 VZ |
1503 | // don't set cursor when the mouse is not in the client part |
1504 | short nHitTest = LOWORD(lParam); | |
1505 | if ( nHitTest == HTCLIENT || nHitTest == HTERROR ) | |
6bf57206 | 1506 | { |
1aff8b02 VZ |
1507 | HCURSOR hcursor = 0; |
1508 | if ( wxIsBusy() ) | |
1509 | { | |
1510 | extern HCURSOR gs_wxBusyCursor; // from msw\utils.cpp | |
6bf57206 | 1511 | |
1aff8b02 VZ |
1512 | hcursor = gs_wxBusyCursor; |
1513 | } | |
1aff8b02 VZ |
1514 | else |
1515 | { | |
f4621a09 VZ |
1516 | wxCursor *cursor = NULL; |
1517 | ||
1518 | if ( m_windowCursor.Ok() ) | |
1519 | { | |
1520 | cursor = &m_windowCursor; | |
1521 | } | |
1522 | else | |
1523 | { | |
1524 | extern wxCursor *g_globalCursor; // from msw\data.cpp | |
1525 | ||
1526 | if ( g_globalCursor && g_globalCursor->Ok() ) | |
1527 | cursor = g_globalCursor; | |
1528 | } | |
1529 | ||
1530 | if ( cursor ) | |
1531 | hcursor = (HCURSOR)cursor->GetHCURSOR(); | |
1aff8b02 | 1532 | } |
6bf57206 | 1533 | |
1aff8b02 VZ |
1534 | if ( hcursor ) |
1535 | { | |
1536 | ::SetCursor(hcursor); | |
634903fd | 1537 | |
1aff8b02 | 1538 | // returning TRUE stops the DefWindowProc() from further |
f4621a09 VZ |
1539 | // processing this message - exactly what we need because we've |
1540 | // just set the cursor. | |
1aff8b02 VZ |
1541 | return TRUE; |
1542 | } | |
6bf57206 | 1543 | } |
634903fd | 1544 | } |
6bf57206 | 1545 | |
1aff8b02 | 1546 | return MSWDefWindowProc(message, wParam, lParam ); |
634903fd | 1547 | |
2d0a075d JS |
1548 | default: |
1549 | return MSWDefWindowProc(message, wParam, lParam ); | |
2bda0e17 | 1550 | } |
341c92a8 | 1551 | |
2bda0e17 KB |
1552 | return 0; // Success: we processed this command. |
1553 | } | |
1554 | ||
1555 | // Dialog window proc | |
1556 | LONG APIENTRY _EXPORT | |
2d0a075d | 1557 | wxDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
2bda0e17 | 1558 | { |
2d0a075d | 1559 | return 0; |
2bda0e17 KB |
1560 | } |
1561 | ||
1562 | wxList *wxWinHandleList = NULL; | |
1563 | wxWindow *wxFindWinFromHandle(WXHWND hWnd) | |
1564 | { | |
2d0a075d JS |
1565 | wxNode *node = wxWinHandleList->Find((long)hWnd); |
1566 | if (!node) | |
1567 | return NULL; | |
1568 | return (wxWindow *)node->Data(); | |
2bda0e17 KB |
1569 | } |
1570 | ||
1571 | void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win) | |
1572 | { | |
2d0a075d JS |
1573 | // adding NULL hWnd is (first) surely a result of an error and |
1574 | // (secondly) breaks menu command processing | |
57c208c5 | 1575 | wxCHECK_RET( hWnd != (HWND) NULL, "attempt to add a NULL hWnd to window list" ); |
195896c7 | 1576 | |
2d0a075d JS |
1577 | if ( !wxWinHandleList->Find((long)hWnd) ) |
1578 | wxWinHandleList->Append((long)hWnd, win); | |
2bda0e17 KB |
1579 | } |
1580 | ||
1581 | void wxRemoveHandleAssociation(wxWindow *win) | |
1582 | { | |
2d0a075d | 1583 | wxWinHandleList->DeleteObject(win); |
2bda0e17 KB |
1584 | } |
1585 | ||
1586 | // Default destroyer - override if you destroy it in some other way | |
1587 | // (e.g. with MDI child windows) | |
fd3f686c | 1588 | void wxWindow::MSWDestroyWindow() |
2bda0e17 | 1589 | { |
2bda0e17 KB |
1590 | } |
1591 | ||
debe6624 | 1592 | void wxWindow::MSWCreate(int id, wxWindow *parent, const char *wclass, wxWindow *wx_win, const char *title, |
2d0a075d JS |
1593 | int x, int y, int width, int height, |
1594 | WXDWORD style, const char *dialog_template, WXDWORD extendedStyle) | |
1595 | { | |
1596 | bool is_dialog = (dialog_template != NULL); | |
1597 | int x1 = CW_USEDEFAULT; | |
1598 | int y1 = 0; | |
1599 | int width1 = CW_USEDEFAULT; | |
1600 | int height1 = 100; | |
1601 | ||
1602 | // Find parent's size, if it exists, to set up a possible default | |
1603 | // panel size the size of the parent window | |
1604 | RECT parent_rect; | |
1605 | if (parent) | |
1606 | { | |
1607 | // Was GetWindowRect: JACS 5/5/95 | |
1608 | ::GetClientRect((HWND) parent->GetHWND(), &parent_rect); | |
2bda0e17 | 1609 | |
2d0a075d JS |
1610 | width1 = parent_rect.right - parent_rect.left; |
1611 | height1 = parent_rect.bottom - parent_rect.top; | |
1612 | } | |
2bda0e17 | 1613 | |
2d0a075d JS |
1614 | if (x > -1) x1 = x; |
1615 | if (y > -1) y1 = y; | |
1616 | if (width > -1) width1 = width; | |
1617 | if (height > -1) height1 = height; | |
2bda0e17 | 1618 | |
2d0a075d JS |
1619 | HWND hParent = NULL; |
1620 | if (parent) | |
1621 | hParent = (HWND) parent->GetHWND(); | |
2bda0e17 | 1622 | |
2d0a075d | 1623 | wxWndHook = this; |
2bda0e17 | 1624 | |
2d0a075d JS |
1625 | if (is_dialog) |
1626 | { | |
1627 | // MakeProcInstance doesn't seem to be needed in C7. Is it needed for | |
1628 | // other compilers??? | |
1629 | // VZ: it's always needed for Win16 and never for Win32 | |
2bda0e17 | 1630 | #ifdef __WIN32__ |
2d0a075d JS |
1631 | m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent, |
1632 | (DLGPROC)wxDlgProc); | |
2bda0e17 | 1633 | #else |
f60d0f94 JS |
1634 | // N.B.: if we _don't_ use this form, |
1635 | // then with VC++ 1.5, it crashes horribly. | |
1636 | #if 1 | |
1637 | m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent, | |
1638 | (DLGPROC)wxDlgProc); | |
1639 | #else | |
1640 | // Crashes when we use this. | |
2d0a075d | 1641 | DLGPROC dlgproc = (DLGPROC)MakeProcInstance((DLGPROC)wxWndProc, wxGetInstance()); |
2bda0e17 | 1642 | |
2d0a075d JS |
1643 | m_hWnd = (WXHWND) ::CreateDialog(wxGetInstance(), dialog_template, hParent, |
1644 | (DLGPROC)dlgproc); | |
f60d0f94 | 1645 | #endif |
2bda0e17 | 1646 | #endif |
c085e333 | 1647 | |
2d0a075d JS |
1648 | if (m_hWnd == 0) |
1649 | MessageBox(NULL, "Can't find dummy dialog template!\nCheck resource include path for finding wx.rc.", | |
1650 | "wxWindows Error", MB_ICONEXCLAMATION | MB_OK); | |
1651 | else MoveWindow((HWND) m_hWnd, x1, y1, width1, height1, FALSE); | |
1652 | } | |
1653 | else | |
1654 | { | |
1655 | int controlId = 0; | |
1656 | if (style & WS_CHILD) | |
1657 | controlId = id; | |
1658 | if (!title) | |
1659 | title = ""; | |
1660 | ||
1661 | m_hWnd = (WXHWND)CreateWindowEx(extendedStyle, wclass, | |
1662 | title, | |
1663 | style, | |
1664 | x1, y1, | |
1665 | width1, height1, | |
1666 | hParent, (HMENU)controlId, wxGetInstance(), | |
1667 | NULL); | |
1668 | ||
1669 | if ( !m_hWnd ) { | |
1670 | wxLogError("Can't create window of class %s!\n" | |
1671 | "Possible Windows 3.x compatibility problem?", wclass); | |
1672 | } | |
2bda0e17 | 1673 | } |
a02eb1d2 | 1674 | |
2d0a075d JS |
1675 | wxWndHook = NULL; |
1676 | wxWinHandleList->Append((long)m_hWnd, this); | |
2bda0e17 KB |
1677 | } |
1678 | ||
1679 | void wxWindow::MSWOnCreate(WXLPCREATESTRUCT WXUNUSED(cs)) | |
1680 | { | |
1681 | } | |
1682 | ||
fd3f686c | 1683 | bool wxWindow::MSWOnClose() |
2bda0e17 | 1684 | { |
2d0a075d | 1685 | return FALSE; |
2bda0e17 KB |
1686 | } |
1687 | ||
3572173c JS |
1688 | // Some compilers don't define this |
1689 | #ifndef ENDSESSION_LOGOFF | |
1690 | #define ENDSESSION_LOGOFF 0x80000000 | |
1691 | #endif | |
1692 | ||
387a3b02 JS |
1693 | // Return TRUE to end session, FALSE to veto end session. |
1694 | bool wxWindow::MSWOnQueryEndSession(long logOff) | |
1695 | { | |
1696 | wxCloseEvent event(wxEVT_QUERY_END_SESSION, -1); | |
1697 | event.SetEventObject(wxTheApp); | |
1698 | event.SetCanVeto(TRUE); | |
1699 | event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) ); | |
1700 | if ((this == wxTheApp->GetTopWindow()) && // Only send once | |
2d0a075d | 1701 | wxTheApp->ProcessEvent(event) && event.GetVeto()) |
387a3b02 JS |
1702 | { |
1703 | return FALSE; // Veto! | |
1704 | } | |
1705 | else | |
1706 | { | |
1707 | return TRUE; // Don't veto | |
1708 | } | |
1709 | } | |
1710 | ||
1711 | bool wxWindow::MSWOnEndSession(bool endSession, long logOff) | |
1712 | { | |
1713 | wxCloseEvent event(wxEVT_END_SESSION, -1); | |
1714 | event.SetEventObject(wxTheApp); | |
1715 | event.SetCanVeto(FALSE); | |
1716 | event.SetLoggingOff( (logOff == ENDSESSION_LOGOFF) ); | |
1717 | if (endSession && // No need to send if the session isn't ending | |
1718 | (this == wxTheApp->GetTopWindow()) && // Only send once | |
2d0a075d | 1719 | wxTheApp->ProcessEvent(event)) |
387a3b02 JS |
1720 | { |
1721 | } | |
1722 | return TRUE; | |
1723 | } | |
1724 | ||
fd3f686c | 1725 | bool wxWindow::MSWOnDestroy() |
2bda0e17 | 1726 | { |
2d0a075d JS |
1727 | // delete our drop target if we've got one |
1728 | #if wxUSE_DRAG_AND_DROP | |
195896c7 | 1729 | if ( m_pDropTarget != NULL ) { |
2d0a075d | 1730 | m_pDropTarget->Revoke(m_hWnd); |
2bda0e17 | 1731 | |
2d0a075d JS |
1732 | delete m_pDropTarget; |
1733 | m_pDropTarget = NULL; | |
2bda0e17 | 1734 | } |
2d0a075d | 1735 | #endif |
c085e333 | 1736 | |
2d0a075d | 1737 | return TRUE; |
2bda0e17 KB |
1738 | } |
1739 | ||
1740 | // Deal with child commands from buttons etc. | |
1741 | ||
fd3f686c | 1742 | long wxWindow::MSWOnNotify(WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 KB |
1743 | { |
1744 | #if defined(__WIN95__) | |
1745 | // Find a child window to send the notification to, e.g. a toolbar. | |
1746 | // There's a problem here. NMHDR::hwndFrom doesn't give us the | |
1747 | // handle of the toolbar; it's probably the handle of the tooltip | |
1748 | // window (anyway, it's parent is also the toolbar's parent). | |
1749 | // So, since we don't know which hWnd or wxWindow originated the | |
1750 | // WM_NOTIFY, we'll need to go through all the children of this window | |
1751 | // trying out MSWNotify. | |
2d0a075d JS |
1752 | // This won't work now, though, because any number of controls |
1753 | // could respond to the same generic messages :-( | |
2bda0e17 | 1754 | |
2d0a075d JS |
1755 | /* This doesn't work for toolbars, but try for other controls first. |
1756 | */ | |
2bda0e17 KB |
1757 | NMHDR *hdr = (NMHDR *)lParam; |
1758 | HWND hWnd = (HWND)hdr->hwndFrom; | |
1759 | wxWindow *win = wxFindWinFromHandle((WXHWND) hWnd); | |
c085e333 | 1760 | |
fd3f686c VZ |
1761 | WXLPARAM result = 0; |
1762 | ||
2d0a075d | 1763 | if ( win ) |
fd3f686c | 1764 | { |
cf65ad8d VZ |
1765 | if ( win->MSWNotify(wParam, lParam, &result) ) |
1766 | return result; | |
fd3f686c | 1767 | } |
2d0a075d JS |
1768 | else |
1769 | { | |
564b2609 | 1770 | // Rely on MSWNotify to check whether the message |
2d0a075d | 1771 | // belongs to the window or not |
c0ed460c | 1772 | wxNode *node = GetChildren().First(); |
564b2609 VZ |
1773 | while (node) |
1774 | { | |
1775 | wxWindow *child = (wxWindow *)node->Data(); | |
fd3f686c | 1776 | if ( child->MSWNotify(wParam, lParam, &result) ) |
cf65ad8d | 1777 | return result; |
2d0a075d | 1778 | node = node->Next(); |
564b2609 | 1779 | } |
2bda0e17 | 1780 | |
cf65ad8d VZ |
1781 | // finally try this window too (catches toolbar case) |
1782 | if ( MSWNotify(wParam, lParam, &result) ) | |
1783 | return result; | |
1784 | } | |
fd3f686c | 1785 | #endif // Win95 |
c085e333 | 1786 | |
cf65ad8d | 1787 | // not processed |
71b8c213 | 1788 | return Default(); |
2bda0e17 KB |
1789 | } |
1790 | ||
debe6624 | 1791 | void wxWindow::MSWOnMenuHighlight(WXWORD WXUNUSED(item), WXWORD WXUNUSED(flags), WXHMENU WXUNUSED(sysmenu)) |
2bda0e17 | 1792 | { |
2bda0e17 KB |
1793 | } |
1794 | ||
debe6624 | 1795 | void wxWindow::MSWOnInitMenuPopup(WXHMENU menu, int pos, bool isSystem) |
2bda0e17 | 1796 | { |
2bda0e17 KB |
1797 | } |
1798 | ||
debe6624 | 1799 | bool wxWindow::MSWOnActivate(int state, bool WXUNUSED(minimized), WXHWND WXUNUSED(activate)) |
2bda0e17 | 1800 | { |
2d0a075d JS |
1801 | wxActivateEvent event(wxEVT_ACTIVATE, ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)), |
1802 | m_windowId); | |
1803 | event.SetEventObject(this); | |
1804 | GetEventHandler()->ProcessEvent(event); | |
1805 | return 0; | |
2bda0e17 KB |
1806 | } |
1807 | ||
debe6624 | 1808 | bool wxWindow::MSWOnSetFocus(WXHWND WXUNUSED(hwnd)) |
2bda0e17 | 1809 | { |
2bda0e17 KB |
1810 | // Deal with caret |
1811 | if (m_caretEnabled && (m_caretWidth > 0) && (m_caretHeight > 0)) | |
1812 | { | |
2d0a075d JS |
1813 | ::CreateCaret((HWND) GetHWND(), NULL, m_caretWidth, m_caretHeight); |
1814 | if (m_caretShown) | |
1815 | ::ShowCaret((HWND) GetHWND()); | |
2bda0e17 | 1816 | } |
c085e333 | 1817 | |
341c92a8 VZ |
1818 | // panel wants to track the window which was the last to have focus in it |
1819 | wxWindow *parent = GetParent(); | |
1820 | if ( parent && parent->IsKindOf(CLASSINFO(wxPanel)) ) | |
1821 | { | |
0492c5a0 | 1822 | ((wxPanel *)parent)->SetLastFocus(GetId()); |
341c92a8 VZ |
1823 | } |
1824 | ||
2d0a075d JS |
1825 | wxFocusEvent event(wxEVT_SET_FOCUS, m_windowId); |
1826 | event.SetEventObject(this); | |
1827 | if (!GetEventHandler()->ProcessEvent(event)) | |
1828 | Default(); | |
1829 | return TRUE; | |
2bda0e17 KB |
1830 | } |
1831 | ||
debe6624 | 1832 | bool wxWindow::MSWOnKillFocus(WXHWND WXUNUSED(hwnd)) |
2bda0e17 | 1833 | { |
2bda0e17 KB |
1834 | // Deal with caret |
1835 | if (m_caretEnabled) | |
1836 | { | |
2d0a075d | 1837 | ::DestroyCaret(); |
2bda0e17 | 1838 | } |
c085e333 | 1839 | |
2d0a075d JS |
1840 | wxFocusEvent event(wxEVT_KILL_FOCUS, m_windowId); |
1841 | event.SetEventObject(this); | |
1842 | if (!GetEventHandler()->ProcessEvent(event)) | |
1843 | Default(); | |
1844 | return TRUE; | |
2bda0e17 KB |
1845 | } |
1846 | ||
debe6624 | 1847 | void wxWindow::MSWOnDropFiles(WXWPARAM wParam) |
2bda0e17 | 1848 | { |
c085e333 | 1849 | |
2d0a075d JS |
1850 | HDROP hFilesInfo = (HDROP) wParam; |
1851 | POINT dropPoint; | |
1852 | DragQueryPoint(hFilesInfo, (LPPOINT) &dropPoint); | |
1853 | ||
1854 | // Get the total number of files dropped | |
1855 | WORD gwFilesDropped = (WORD)DragQueryFile ((HDROP)hFilesInfo, | |
1856 | (UINT)-1, | |
1857 | (LPSTR)0, | |
1858 | (UINT)0); | |
1859 | ||
1860 | wxString *files = new wxString[gwFilesDropped]; | |
1861 | int wIndex; | |
1862 | for (wIndex=0; wIndex < (int)gwFilesDropped; wIndex++) | |
1863 | { | |
1864 | DragQueryFile (hFilesInfo, wIndex, (LPSTR) wxBuffer, 1000); | |
1865 | files[wIndex] = wxBuffer; | |
1866 | } | |
1867 | DragFinish (hFilesInfo); | |
2bda0e17 | 1868 | |
2d0a075d JS |
1869 | wxDropFilesEvent event(wxEVT_DROP_FILES, gwFilesDropped, files); |
1870 | event.m_eventObject = this; | |
1871 | event.m_pos.x = dropPoint.x; event.m_pos.x = dropPoint.y; | |
2bda0e17 | 1872 | |
2d0a075d JS |
1873 | if (!GetEventHandler()->ProcessEvent(event)) |
1874 | Default(); | |
2bda0e17 | 1875 | |
2d0a075d | 1876 | delete[] files; |
2bda0e17 KB |
1877 | } |
1878 | ||
debe6624 | 1879 | bool wxWindow::MSWOnDrawItem(int id, WXDRAWITEMSTRUCT *itemStruct) |
2bda0e17 | 1880 | { |
47d67540 | 1881 | #if wxUSE_OWNER_DRAWN |
2bda0e17 | 1882 | if ( id == 0 ) { // is it a menu item? |
2d0a075d JS |
1883 | DRAWITEMSTRUCT *pDrawStruct = (DRAWITEMSTRUCT *)itemStruct; |
1884 | wxMenuItem *pMenuItem = (wxMenuItem *)(pDrawStruct->itemData); | |
1885 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); | |
1886 | ||
1887 | // prepare to call OnDrawItem() | |
1888 | wxDC dc; | |
1889 | dc.SetHDC((WXHDC)pDrawStruct->hDC, FALSE); | |
1890 | wxRect rect(pDrawStruct->rcItem.left, pDrawStruct->rcItem.top, | |
1891 | pDrawStruct->rcItem.right - pDrawStruct->rcItem.left, | |
1892 | pDrawStruct->rcItem.bottom - pDrawStruct->rcItem.top); | |
1893 | return pMenuItem->OnDrawItem( | |
1894 | dc, rect, | |
1895 | (wxOwnerDrawn::wxODAction)pDrawStruct->itemAction, | |
1896 | (wxOwnerDrawn::wxODStatus)pDrawStruct->itemState | |
1897 | ); | |
2bda0e17 KB |
1898 | } |
1899 | #endif // owner-drawn menus | |
c085e333 | 1900 | |
2d0a075d | 1901 | wxWindow *item = FindItem(id); |
47d67540 | 1902 | #if wxUSE_DYNAMIC_CLASSES |
2d0a075d JS |
1903 | if (item && item->IsKindOf(CLASSINFO(wxControl))) |
1904 | { | |
1905 | return ((wxControl *)item)->MSWOnDraw(itemStruct); | |
1906 | } | |
1907 | else | |
2bda0e17 | 1908 | #endif |
2d0a075d | 1909 | return FALSE; |
2bda0e17 KB |
1910 | } |
1911 | ||
debe6624 | 1912 | bool wxWindow::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) |
2bda0e17 | 1913 | { |
47d67540 | 1914 | #if wxUSE_OWNER_DRAWN |
2bda0e17 | 1915 | if ( id == 0 ) { // is it a menu item? |
2d0a075d JS |
1916 | MEASUREITEMSTRUCT *pMeasureStruct = (MEASUREITEMSTRUCT *)itemStruct; |
1917 | wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData); | |
1918 | wxCHECK( pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)), FALSE ); | |
2bda0e17 | 1919 | |
c085e333 | 1920 | return pMenuItem->OnMeasureItem(&pMeasureStruct->itemWidth, |
2d0a075d | 1921 | &pMeasureStruct->itemHeight); |
2bda0e17 KB |
1922 | } |
1923 | #endif // owner-drawn menus | |
c085e333 | 1924 | |
2d0a075d | 1925 | wxWindow *item = FindItem(id); |
47d67540 | 1926 | #if wxUSE_DYNAMIC_CLASSES |
2d0a075d JS |
1927 | if (item && item->IsKindOf(CLASSINFO(wxControl))) |
1928 | { | |
1929 | return ((wxControl *)item)->MSWOnMeasure(itemStruct); | |
1930 | } | |
1931 | else | |
2bda0e17 | 1932 | #endif |
2d0a075d | 1933 | return FALSE; |
2bda0e17 KB |
1934 | } |
1935 | ||
debe6624 | 1936 | WXHBRUSH wxWindow::MSWOnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
2d0a075d | 1937 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 | 1938 | { |
2d0a075d JS |
1939 | if (nCtlColor == CTLCOLOR_DLG) |
1940 | { | |
1941 | return OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); | |
1942 | } | |
2bda0e17 | 1943 | |
2d0a075d | 1944 | wxControl *item = (wxControl *)FindItemByHWND(pWnd, TRUE); |
2bda0e17 | 1945 | |
2d0a075d | 1946 | WXHBRUSH hBrush = 0; |
2bda0e17 | 1947 | |
2d0a075d JS |
1948 | if ( item ) |
1949 | hBrush = item->OnCtlColor(pDC, pWnd, nCtlColor, message, wParam, lParam); | |
2bda0e17 | 1950 | |
2d0a075d JS |
1951 | // I think that even for dialogs, we may need to call DefWindowProc (?) |
1952 | // Or maybe just rely on the usual default behaviour. | |
1953 | if ( !hBrush ) | |
1954 | hBrush = (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam); | |
2bda0e17 | 1955 | |
2d0a075d | 1956 | return hBrush ; |
2bda0e17 KB |
1957 | } |
1958 | ||
1959 | // Define for each class of dialog and control | |
debe6624 | 1960 | WXHBRUSH wxWindow::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, |
2d0a075d | 1961 | WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 KB |
1962 | { |
1963 | return (WXHBRUSH) MSWDefWindowProc(message, wParam, lParam); | |
1964 | } | |
1965 | ||
debe6624 | 1966 | bool wxWindow::MSWOnColorChange(WXHWND hWnd, WXUINT message, WXWPARAM wParam, WXLPARAM lParam) |
2bda0e17 | 1967 | { |
2d0a075d JS |
1968 | wxSysColourChangedEvent event; |
1969 | event.SetEventObject(this); | |
2bda0e17 | 1970 | |
2d0a075d JS |
1971 | // Check if app handles this. |
1972 | if (GetEventHandler()->ProcessEvent(event)) | |
1973 | return 0; | |
2bda0e17 | 1974 | |
2d0a075d JS |
1975 | // We didn't process it |
1976 | return 1; | |
2bda0e17 KB |
1977 | } |
1978 | ||
f7bd2698 JS |
1979 | long wxWindow::MSWOnPaletteChanged(WXHWND hWndPalChange) |
1980 | { | |
1981 | wxPaletteChangedEvent event(GetId()); | |
1982 | event.SetEventObject(this); | |
1983 | event.SetChangedWindow(wxFindWinFromHandle(hWndPalChange)); | |
1984 | GetEventHandler()->ProcessEvent(event); | |
1985 | return 0; | |
1986 | } | |
1987 | ||
1988 | long wxWindow::MSWOnQueryNewPalette() | |
1989 | { | |
1990 | wxQueryNewPaletteEvent event(GetId()); | |
1991 | event.SetEventObject(this); | |
1992 | if (!GetEventHandler()->ProcessEvent(event) || !event.GetPaletteRealized()) | |
1993 | { | |
1994 | return (long) FALSE; | |
1995 | } | |
1996 | else | |
1997 | return (long) TRUE; | |
1998 | } | |
1999 | ||
2bda0e17 KB |
2000 | // Responds to colour changes: passes event on to children. |
2001 | void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) | |
2002 | { | |
c0ed460c | 2003 | wxNode *node = GetChildren().First(); |
2bda0e17 KB |
2004 | while ( node ) |
2005 | { | |
2006 | // Only propagate to non-top-level windows | |
2007 | wxWindow *win = (wxWindow *)node->Data(); | |
2008 | if ( win->GetParent() ) | |
2009 | { | |
2010 | wxSysColourChangedEvent event2; | |
2011 | event.m_eventObject = win; | |
2012 | win->GetEventHandler()->ProcessEvent(event2); | |
2013 | } | |
c085e333 | 2014 | |
2bda0e17 KB |
2015 | node = node->Next(); |
2016 | } | |
2017 | } | |
2018 | ||
2019 | long wxWindow::MSWDefWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) | |
2020 | { | |
2d0a075d JS |
2021 | if ( m_oldWndProc ) |
2022 | return ::CallWindowProc(CASTWNDPROC m_oldWndProc, (HWND) GetHWND(), (UINT) nMsg, (WPARAM) wParam, (LPARAM) lParam); | |
2023 | else | |
2024 | return ::DefWindowProc((HWND) GetHWND(), nMsg, wParam, lParam); | |
2bda0e17 KB |
2025 | } |
2026 | ||
2027 | long wxWindow::Default() | |
2028 | { | |
46851318 JS |
2029 | // Ignore 'fake' events (perhaps generated as a result of a separate real event) |
2030 | if (m_lastMsg == 0) | |
1c089c47 | 2031 | return 0; |
c085e333 | 2032 | |
2d0a075d JS |
2033 | #ifdef __WXDEBUG__ |
2034 | wxLogTrace(wxTraceMessages, "Forwarding %s to DefWindowProc.", | |
2035 | wxGetMessageName(m_lastMsg)); | |
ea57084d | 2036 | #endif // __WXDEBUG__ |
c085e333 | 2037 | |
46851318 | 2038 | return this->MSWDefWindowProc(m_lastMsg, m_lastWParam, m_lastLParam); |
2bda0e17 KB |
2039 | } |
2040 | ||
2041 | bool wxWindow::MSWProcessMessage(WXMSG* pMsg) | |
2042 | { | |
2d0a075d JS |
2043 | if ( m_hWnd != 0 && (GetWindowStyleFlag() & wxTAB_TRAVERSAL) ) { |
2044 | // intercept dialog navigation keys | |
2045 | MSG *msg = (MSG *)pMsg; | |
2046 | bool bProcess = TRUE; | |
2047 | if ( msg->message != WM_KEYDOWN ) | |
2048 | bProcess = FALSE; | |
47cbd6da | 2049 | |
341c92a8 | 2050 | if ( bProcess && (HIWORD(msg->lParam) & KF_ALTDOWN) == KF_ALTDOWN ) |
2d0a075d | 2051 | bProcess = FALSE; |
47cbd6da | 2052 | |
341c92a8 VZ |
2053 | if ( bProcess ) |
2054 | { | |
2055 | bool bCtrlDown = (::GetKeyState(VK_CONTROL) & 0x100) != 0; | |
47cbd6da | 2056 | |
341c92a8 VZ |
2057 | // WM_GETDLGCODE: ask the control if it wants the key for itself, |
2058 | // don't process it if it's the case (except for Ctrl-Tab/Enter | |
2059 | // combinations which are always processed) | |
2060 | LONG lDlgCode = 0; | |
2061 | if ( !bCtrlDown ) | |
2062 | { | |
2063 | lDlgCode = ::SendMessage(msg->hwnd, WM_GETDLGCODE, 0, 0); | |
2064 | } | |
2065 | ||
2066 | bool bForward = TRUE, | |
2067 | bWindowChange = FALSE; | |
47cbd6da | 2068 | |
341c92a8 VZ |
2069 | switch ( msg->wParam ) |
2070 | { | |
fd3f686c | 2071 | case VK_TAB: |
3a19e16d | 2072 | if ( lDlgCode & DLGC_WANTTAB ) { |
fd3f686c | 2073 | bProcess = FALSE; |
3a19e16d VZ |
2074 | } |
2075 | else { | |
2076 | // Ctrl-Tab cycles thru notebook pages | |
2077 | bWindowChange = bCtrlDown; | |
fd3f686c | 2078 | bForward = !(::GetKeyState(VK_SHIFT) & 0x100); |
3a19e16d | 2079 | } |
fd3f686c | 2080 | break; |
47cbd6da | 2081 | |
fd3f686c VZ |
2082 | case VK_UP: |
2083 | case VK_LEFT: | |
2084 | if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) | |
2085 | bProcess = FALSE; | |
2086 | else | |
2087 | bForward = FALSE; | |
2088 | break; | |
47cbd6da | 2089 | |
fd3f686c VZ |
2090 | case VK_DOWN: |
2091 | case VK_RIGHT: | |
2092 | if ( (lDlgCode & DLGC_WANTARROWS) || bCtrlDown ) | |
2093 | bProcess = FALSE; | |
2094 | break; | |
47cbd6da | 2095 | |
3a19e16d | 2096 | case VK_RETURN: |
341c92a8 VZ |
2097 | { |
2098 | if ( lDlgCode & DLGC_WANTMESSAGE ) | |
5fb9fcfc VZ |
2099 | { |
2100 | // control wants to process Enter itself, don't | |
2101 | // call IsDialogMessage() which would interpret | |
2102 | // it | |
2103 | return FALSE; | |
2104 | } | |
750b78ba | 2105 | #ifndef __WIN16__ |
341c92a8 VZ |
2106 | wxButton *btnDefault = GetDefaultItem(); |
2107 | if ( btnDefault && !bCtrlDown ) | |
2108 | { | |
2109 | // if there is a default button, Enter should | |
2110 | // press it | |
2111 | (void)::SendMessage((HWND)btnDefault->GetHWND(), | |
2112 | BM_CLICK, 0, 0); | |
2113 | return TRUE; | |
2114 | } | |
2115 | // else: but if there is not it makes sense to make it | |
2116 | // work like a TAB - and that's what we do. | |
2117 | // Note that Ctrl-Enter always works this way. | |
750b78ba | 2118 | #endif |
3a19e16d | 2119 | } |
341c92a8 | 2120 | break; |
3a19e16d | 2121 | |
fd3f686c VZ |
2122 | default: |
2123 | bProcess = FALSE; | |
2d0a075d | 2124 | } |
47cbd6da | 2125 | |
341c92a8 VZ |
2126 | if ( bProcess ) |
2127 | { | |
2128 | wxNavigationKeyEvent event; | |
2129 | event.SetDirection(bForward); | |
2130 | event.SetWindowChange(bWindowChange); | |
2131 | event.SetEventObject(this); | |
47cbd6da | 2132 | |
341c92a8 VZ |
2133 | if ( GetEventHandler()->ProcessEvent(event) ) |
2134 | return TRUE; | |
2135 | } | |
2d0a075d | 2136 | } |
47cbd6da | 2137 | |
341c92a8 VZ |
2138 | if ( ::IsDialogMessage((HWND)GetHWND(), msg) ) |
2139 | return TRUE; | |
2d0a075d | 2140 | } |
3a19e16d | 2141 | #if wxUSE_TOOLTIPS |
341c92a8 VZ |
2142 | if ( m_tooltip ) |
2143 | { | |
3a19e16d VZ |
2144 | // relay mouse move events to the tooltip control |
2145 | MSG *msg = (MSG *)pMsg; | |
2146 | if ( msg->message == WM_MOUSEMOVE ) | |
2147 | m_tooltip->RelayEvent(pMsg); | |
2148 | } | |
2149 | #endif // wxUSE_TOOLTIPS | |
47cbd6da | 2150 | |
2d0a075d | 2151 | return FALSE; |
2bda0e17 KB |
2152 | } |
2153 | ||
088a95f5 | 2154 | bool wxWindow::MSWTranslateMessage(WXMSG* pMsg) |
57a7b7c1 | 2155 | { |
088a95f5 | 2156 | if (m_acceleratorTable.Ok() && |
2d0a075d | 2157 | ::TranslateAccelerator((HWND) GetHWND(), (HACCEL) m_acceleratorTable.GetHACCEL(), (MSG *)pMsg)) |
088a95f5 JS |
2158 | return TRUE; |
2159 | else | |
2160 | return FALSE; | |
57a7b7c1 JS |
2161 | } |
2162 | ||
debe6624 | 2163 | long wxWindow::MSWOnMDIActivate(long WXUNUSED(flag), WXHWND WXUNUSED(activate), WXHWND WXUNUSED(deactivate)) |
2bda0e17 | 2164 | { |
2d0a075d | 2165 | return 1; |
2bda0e17 KB |
2166 | } |
2167 | ||
fd3f686c | 2168 | void wxWindow::MSWDetachWindowMenu() |
2bda0e17 | 2169 | { |
2d0a075d | 2170 | if (m_hMenu) |
2bda0e17 | 2171 | { |
2d0a075d JS |
2172 | int N = GetMenuItemCount((HMENU) m_hMenu); |
2173 | int i; | |
2174 | for (i = 0; i < N; i++) | |
2175 | { | |
2176 | char buf[100]; | |
2177 | int chars = GetMenuString((HMENU) m_hMenu, i, buf, 100, MF_BYPOSITION); | |
2178 | if ((chars > 0) && (strcmp(buf, "&Window") == 0)) | |
2179 | { | |
2180 | RemoveMenu((HMENU) m_hMenu, i, MF_BYPOSITION); | |
2181 | break; | |
2182 | } | |
2183 | } | |
2bda0e17 | 2184 | } |
2bda0e17 KB |
2185 | } |
2186 | ||
fd3f686c | 2187 | bool wxWindow::MSWOnPaint() |
2bda0e17 | 2188 | { |
81d66cf3 | 2189 | #ifdef __WIN32__ |
2d0a075d JS |
2190 | HRGN hRegion = ::CreateRectRgn(0, 0, 0, 0); // Dummy call to get a handle |
2191 | ::GetUpdateRgn((HWND) GetHWND(), hRegion, FALSE); | |
81d66cf3 | 2192 | |
2d0a075d | 2193 | m_updateRegion = wxRegion((WXHRGN) hRegion); |
81d66cf3 | 2194 | #else |
2d0a075d JS |
2195 | RECT updateRect; |
2196 | ::GetUpdateRect((HWND) GetHWND(), & updateRect, FALSE); | |
81d66cf3 | 2197 | |
2d0a075d JS |
2198 | m_updateRegion = wxRegion(updateRect.left, updateRect.top, |
2199 | updateRect.right - updateRect.left, updateRect.bottom - updateRect.top); | |
81d66cf3 | 2200 | #endif |
c085e333 | 2201 | |
2d0a075d JS |
2202 | wxPaintEvent event(m_windowId); |
2203 | event.SetEventObject(this); | |
2204 | if (!GetEventHandler()->ProcessEvent(event)) | |
2205 | Default(); | |
2206 | return TRUE; | |
2bda0e17 KB |
2207 | } |
2208 | ||
debe6624 | 2209 | void wxWindow::MSWOnSize(int w, int h, WXUINT WXUNUSED(flag)) |
2bda0e17 | 2210 | { |
2d0a075d JS |
2211 | if (m_inOnSize) |
2212 | return; | |
2213 | ||
2d0a075d JS |
2214 | if (!m_hWnd) |
2215 | return; | |
2bda0e17 | 2216 | |
2d0a075d | 2217 | m_inOnSize = TRUE; |
2bda0e17 | 2218 | |
2d0a075d JS |
2219 | wxSizeEvent event(wxSize(w, h), m_windowId); |
2220 | event.SetEventObject(this); | |
2221 | if (!GetEventHandler()->ProcessEvent(event)) | |
2222 | Default(); | |
2bda0e17 | 2223 | |
2d0a075d | 2224 | m_inOnSize = FALSE; |
2bda0e17 KB |
2225 | } |
2226 | ||
2227 | void wxWindow::MSWOnWindowPosChanging(void *WXUNUSED(lpPos)) | |
2228 | { | |
2229 | Default(); | |
2230 | } | |
2231 | ||
2232 | // Deal with child commands from buttons etc. | |
34138703 | 2233 | bool wxWindow::MSWOnCommand(WXWORD id, WXWORD cmd, WXHWND control) |
2bda0e17 | 2234 | { |
2d0a075d JS |
2235 | if (wxCurrentPopupMenu) |
2236 | { | |
2237 | wxMenu *popupMenu = wxCurrentPopupMenu; | |
2238 | wxCurrentPopupMenu = NULL; | |
2239 | bool succ = popupMenu->MSWCommand(cmd, id); | |
2240 | return succ; | |
2241 | } | |
c085e333 | 2242 | |
2d0a075d JS |
2243 | wxWindow *item = FindItem(id); |
2244 | if (item) | |
2245 | { | |
2246 | bool value = item->MSWCommand(cmd, id); | |
2d0a075d JS |
2247 | return value; |
2248 | } | |
2249 | else | |
2250 | { | |
2251 | wxWindow *win = wxFindWinFromHandle(control); | |
2252 | if (win) | |
2253 | return win->MSWCommand(cmd, id); | |
2254 | } | |
2255 | return FALSE; | |
2bda0e17 KB |
2256 | } |
2257 | ||
2258 | long wxWindow::MSWOnSysCommand(WXWPARAM wParam, WXLPARAM lParam) | |
2259 | { | |
0492c5a0 | 2260 | switch (wParam & 0xFFFFFFF0) |
2bda0e17 | 2261 | { |
2d0a075d | 2262 | case SC_MAXIMIZE: |
2bda0e17 KB |
2263 | { |
2264 | wxMaximizeEvent event(m_windowId); | |
2265 | event.SetEventObject(this); | |
2266 | if (!GetEventHandler()->ProcessEvent(event)) | |
2267 | return Default(); | |
2268 | else | |
2269 | return 0; | |
2270 | break; | |
2271 | } | |
2d0a075d | 2272 | case SC_MINIMIZE: |
2bda0e17 KB |
2273 | { |
2274 | wxIconizeEvent event(m_windowId); | |
2275 | event.SetEventObject(this); | |
2276 | if (!GetEventHandler()->ProcessEvent(event)) | |
2277 | return Default(); | |
2278 | else | |
2279 | return 0; | |
2280 | break; | |
2281 | } | |
2d0a075d JS |
2282 | default: |
2283 | return Default(); | |
2bda0e17 KB |
2284 | } |
2285 | return 0; | |
2286 | } | |
2287 | ||
debe6624 | 2288 | void wxWindow::MSWOnLButtonDown(int x, int y, WXUINT flags) |
2bda0e17 | 2289 | { |
2d0a075d | 2290 | wxMouseEvent event(wxEVT_LEFT_DOWN); |
2bda0e17 | 2291 | |
2d0a075d JS |
2292 | event.m_x = x; event.m_y = y; |
2293 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2294 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2295 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2296 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2297 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2298 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2299 | event.m_eventObject = this; | |
2bda0e17 | 2300 | |
f5419957 | 2301 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DOWN; |
debe6624 | 2302 | |
2d0a075d JS |
2303 | if (!GetEventHandler()->ProcessEvent(event)) |
2304 | Default(); | |
2bda0e17 KB |
2305 | } |
2306 | ||
debe6624 | 2307 | void wxWindow::MSWOnLButtonUp(int x, int y, WXUINT flags) |
2bda0e17 | 2308 | { |
2d0a075d | 2309 | wxMouseEvent event(wxEVT_LEFT_UP); |
2bda0e17 | 2310 | |
2d0a075d JS |
2311 | event.m_x = x; event.m_y = y; |
2312 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2313 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2314 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2315 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2316 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2317 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2318 | event.m_eventObject = this; | |
2bda0e17 | 2319 | |
2d0a075d | 2320 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_UP; |
2bda0e17 | 2321 | |
2d0a075d JS |
2322 | if (!GetEventHandler()->ProcessEvent(event)) |
2323 | Default(); | |
2bda0e17 KB |
2324 | } |
2325 | ||
debe6624 | 2326 | void wxWindow::MSWOnLButtonDClick(int x, int y, WXUINT flags) |
2bda0e17 | 2327 | { |
2d0a075d | 2328 | wxMouseEvent event(wxEVT_LEFT_DCLICK); |
2bda0e17 | 2329 | |
2d0a075d JS |
2330 | event.m_x = x; event.m_y = y; |
2331 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2332 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2333 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2334 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2335 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2336 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2337 | event.m_eventObject = this; | |
2bda0e17 | 2338 | |
2d0a075d | 2339 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_LEFT_DCLICK; |
2bda0e17 | 2340 | |
2d0a075d JS |
2341 | if (!GetEventHandler()->ProcessEvent(event)) |
2342 | Default(); | |
2bda0e17 KB |
2343 | } |
2344 | ||
debe6624 | 2345 | void wxWindow::MSWOnMButtonDown(int x, int y, WXUINT flags) |
2bda0e17 | 2346 | { |
2d0a075d | 2347 | wxMouseEvent event(wxEVT_MIDDLE_DOWN); |
2bda0e17 | 2348 | |
2d0a075d JS |
2349 | event.m_x = x; event.m_y = y; |
2350 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2351 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2352 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2353 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2354 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2355 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2356 | event.m_eventObject = this; | |
2bda0e17 | 2357 | |
2d0a075d | 2358 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DOWN; |
debe6624 | 2359 | |
2d0a075d JS |
2360 | if (!GetEventHandler()->ProcessEvent(event)) |
2361 | Default(); | |
2bda0e17 KB |
2362 | } |
2363 | ||
debe6624 | 2364 | void wxWindow::MSWOnMButtonUp(int x, int y, WXUINT flags) |
2bda0e17 | 2365 | { |
2d0a075d | 2366 | wxMouseEvent event(wxEVT_MIDDLE_UP); |
2bda0e17 | 2367 | |
2d0a075d JS |
2368 | event.m_x = x; event.m_y = y; |
2369 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2370 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2371 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2372 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2373 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2374 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2375 | event.m_eventObject = this; | |
2bda0e17 | 2376 | |
2d0a075d | 2377 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_UP; |
debe6624 | 2378 | |
2d0a075d JS |
2379 | if (!GetEventHandler()->ProcessEvent(event)) |
2380 | Default(); | |
2bda0e17 KB |
2381 | } |
2382 | ||
debe6624 | 2383 | void wxWindow::MSWOnMButtonDClick(int x, int y, WXUINT flags) |
2bda0e17 | 2384 | { |
2d0a075d | 2385 | wxMouseEvent event(wxEVT_MIDDLE_DCLICK); |
2bda0e17 | 2386 | |
2d0a075d JS |
2387 | event.m_x = x; event.m_y = y; |
2388 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2389 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2390 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2391 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2392 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2393 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2394 | event.m_eventObject = this; | |
2bda0e17 | 2395 | |
2d0a075d | 2396 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_MIDDLE_DCLICK; |
debe6624 | 2397 | |
2d0a075d JS |
2398 | if (!GetEventHandler()->ProcessEvent(event)) |
2399 | Default(); | |
2bda0e17 KB |
2400 | } |
2401 | ||
debe6624 | 2402 | void wxWindow::MSWOnRButtonDown(int x, int y, WXUINT flags) |
2bda0e17 | 2403 | { |
2d0a075d | 2404 | wxMouseEvent event(wxEVT_RIGHT_DOWN); |
2bda0e17 | 2405 | |
2d0a075d JS |
2406 | event.m_x = x; event.m_y = y; |
2407 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2408 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2409 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2410 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2411 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2412 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2413 | event.m_eventObject = this; | |
2bda0e17 | 2414 | |
2d0a075d | 2415 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DOWN; |
debe6624 | 2416 | |
2d0a075d JS |
2417 | if (!GetEventHandler()->ProcessEvent(event)) |
2418 | Default(); | |
2bda0e17 KB |
2419 | } |
2420 | ||
debe6624 | 2421 | void wxWindow::MSWOnRButtonUp(int x, int y, WXUINT flags) |
2bda0e17 | 2422 | { |
2d0a075d | 2423 | wxMouseEvent event(wxEVT_RIGHT_UP); |
2bda0e17 | 2424 | |
2d0a075d JS |
2425 | event.m_x = x; event.m_y = y; |
2426 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2427 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2428 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2429 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2430 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2431 | event.m_eventObject = this; | |
2432 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2bda0e17 | 2433 | |
2d0a075d | 2434 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_UP; |
debe6624 | 2435 | |
2d0a075d JS |
2436 | if (!GetEventHandler()->ProcessEvent(event)) |
2437 | Default(); | |
2bda0e17 KB |
2438 | } |
2439 | ||
debe6624 | 2440 | void wxWindow::MSWOnRButtonDClick(int x, int y, WXUINT flags) |
2bda0e17 | 2441 | { |
2d0a075d | 2442 | wxMouseEvent event(wxEVT_RIGHT_DCLICK); |
2bda0e17 | 2443 | |
2d0a075d JS |
2444 | event.m_x = x; event.m_y = y; |
2445 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2446 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2447 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2448 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2449 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2450 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2451 | event.m_eventObject = this; | |
2bda0e17 | 2452 | |
2d0a075d | 2453 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; m_lastEvent = wxEVT_RIGHT_DCLICK; |
debe6624 | 2454 | |
2d0a075d JS |
2455 | if (!GetEventHandler()->ProcessEvent(event)) |
2456 | Default(); | |
2bda0e17 KB |
2457 | } |
2458 | ||
debe6624 | 2459 | void wxWindow::MSWOnMouseMove(int x, int y, WXUINT flags) |
2bda0e17 | 2460 | { |
2d0a075d | 2461 | // 'normal' move event... |
2bda0e17 | 2462 | |
2d0a075d JS |
2463 | if (!m_mouseInWindow) |
2464 | { | |
2465 | // Generate an ENTER event | |
2466 | m_mouseInWindow = TRUE; | |
2467 | MSWOnMouseEnter(x, y, flags); | |
2468 | } | |
2bda0e17 | 2469 | |
2d0a075d | 2470 | wxMouseEvent event(wxEVT_MOTION); |
debe6624 | 2471 | |
2d0a075d JS |
2472 | event.m_x = x; event.m_y = y; |
2473 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2474 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2475 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2476 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2477 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2478 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2479 | event.m_eventObject = this; | |
2480 | ||
2481 | // Window gets a click down message followed by a mouse move | |
2482 | // message even if position isn't changed! We want to discard | |
2483 | // the trailing move event if x and y are the same. | |
2484 | if ((m_lastEvent == wxEVT_RIGHT_DOWN || m_lastEvent == wxEVT_LEFT_DOWN || | |
2485 | m_lastEvent == wxEVT_MIDDLE_DOWN) && | |
2486 | (m_lastXPos == event.m_x && m_lastYPos == event.m_y)) | |
2487 | { | |
2488 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; | |
2489 | m_lastEvent = wxEVT_MOTION; | |
2490 | return; | |
2491 | } | |
2492 | ||
2493 | m_lastEvent = wxEVT_MOTION; | |
2494 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; | |
2495 | ||
2496 | if (!GetEventHandler()->ProcessEvent(event)) | |
2497 | Default(); | |
2bda0e17 | 2498 | } |
2bda0e17 | 2499 | |
debe6624 | 2500 | void wxWindow::MSWOnMouseEnter(int x, int y, WXUINT flags) |
2bda0e17 | 2501 | { |
2d0a075d | 2502 | wxMouseEvent event(wxEVT_ENTER_WINDOW); |
2bda0e17 | 2503 | |
2d0a075d JS |
2504 | event.m_x = x; event.m_y = y; |
2505 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2506 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2507 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2508 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2509 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2510 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2511 | event.m_eventObject = this; | |
2bda0e17 | 2512 | |
2d0a075d JS |
2513 | m_lastEvent = wxEVT_ENTER_WINDOW; |
2514 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; | |
2515 | // No message - ensure we don't try to call the default behaviour accidentally. | |
2516 | m_lastMsg = 0; | |
2517 | GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
2518 | } |
2519 | ||
debe6624 | 2520 | void wxWindow::MSWOnMouseLeave(int x, int y, WXUINT flags) |
2bda0e17 | 2521 | { |
2d0a075d | 2522 | wxMouseEvent event(wxEVT_LEAVE_WINDOW); |
2bda0e17 | 2523 | |
2d0a075d JS |
2524 | event.m_x = x; event.m_y = y; |
2525 | event.m_shiftDown = ((flags & MK_SHIFT) != 0); | |
2526 | event.m_controlDown = ((flags & MK_CONTROL) != 0); | |
2527 | event.m_leftDown = ((flags & MK_LBUTTON) != 0); | |
2528 | event.m_middleDown = ((flags & MK_MBUTTON) != 0); | |
2529 | event.m_rightDown = ((flags & MK_RBUTTON) != 0); | |
2530 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2531 | event.m_eventObject = this; | |
2bda0e17 | 2532 | |
2d0a075d JS |
2533 | m_lastEvent = wxEVT_LEAVE_WINDOW; |
2534 | m_lastXPos = event.m_x; m_lastYPos = event.m_y; | |
2535 | // No message - ensure we don't try to call the default behaviour accidentally. | |
2536 | m_lastMsg = 0; | |
2537 | GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
2538 | } |
2539 | ||
dbda9e86 | 2540 | bool wxWindow::MSWOnChar(WXWORD wParam, WXLPARAM lParam, bool isASCII) |
2bda0e17 | 2541 | { |
2d0a075d JS |
2542 | int id; |
2543 | bool tempControlDown = FALSE; | |
2544 | if (isASCII) | |
2bda0e17 | 2545 | { |
2d0a075d JS |
2546 | // If 1 -> 26, translate to CTRL plus a letter. |
2547 | id = wParam; | |
2548 | if ((id > 0) && (id < 27)) | |
2bda0e17 | 2549 | { |
2d0a075d JS |
2550 | switch (id) |
2551 | { | |
2552 | case 13: | |
2553 | { | |
2554 | id = WXK_RETURN; | |
2555 | break; | |
2556 | } | |
2557 | case 8: | |
2558 | { | |
2559 | id = WXK_BACK; | |
2560 | break; | |
2561 | } | |
2562 | case 9: | |
2563 | { | |
2564 | id = WXK_TAB; | |
2565 | break; | |
2566 | } | |
2567 | default: | |
2568 | { | |
2569 | tempControlDown = TRUE; | |
2570 | id = id + 96; | |
2571 | } | |
2572 | } | |
2bda0e17 | 2573 | } |
2bda0e17 | 2574 | } |
2d0a075d JS |
2575 | else if ((id = wxCharCodeMSWToWX(wParam)) == 0) { |
2576 | // it's ASCII and will be processed here only when called from | |
2577 | // WM_CHAR (i.e. when isASCII = TRUE) | |
2578 | id = -1; | |
2579 | } | |
2bda0e17 | 2580 | |
2d0a075d JS |
2581 | if (id != -1) |
2582 | { | |
2583 | wxKeyEvent event(wxEVT_CHAR); | |
2584 | event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE); | |
2585 | event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE); | |
2586 | if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN) | |
2587 | event.m_altDown = TRUE; | |
2588 | ||
2589 | event.m_eventObject = this; | |
2590 | event.m_keyCode = id; | |
2591 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2592 | ||
2593 | POINT pt ; | |
2594 | GetCursorPos(&pt) ; | |
2595 | RECT rect ; | |
2596 | GetWindowRect((HWND) GetHWND(),&rect) ; | |
2597 | pt.x -= rect.left ; | |
2598 | pt.y -= rect.top ; | |
2599 | ||
2600 | event.m_x = pt.x; event.m_y = pt.y; | |
2601 | ||
dbda9e86 JS |
2602 | if (GetEventHandler()->ProcessEvent(event)) |
2603 | return TRUE; | |
2604 | else | |
2605 | return FALSE; | |
2d0a075d | 2606 | } |
dbda9e86 JS |
2607 | else |
2608 | return FALSE; | |
2bda0e17 KB |
2609 | } |
2610 | ||
dbda9e86 | 2611 | bool wxWindow::MSWOnKeyDown(WXWORD wParam, WXLPARAM lParam, bool isASCII) |
4ce81a75 JS |
2612 | { |
2613 | int id; | |
2614 | ||
2615 | if ((id = wxCharCodeMSWToWX(wParam)) == 0) { | |
2616 | id = wParam; | |
2617 | } | |
2618 | ||
2619 | if (id != -1) | |
2620 | { | |
2621 | wxKeyEvent event(wxEVT_KEY_DOWN); | |
2622 | event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE); | |
2623 | event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE); | |
2624 | if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN) | |
2625 | event.m_altDown = TRUE; | |
2626 | ||
2627 | event.m_eventObject = this; | |
2628 | event.m_keyCode = id; | |
2629 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2630 | ||
2631 | POINT pt ; | |
2632 | GetCursorPos(&pt) ; | |
2633 | RECT rect ; | |
2634 | GetWindowRect((HWND) GetHWND(),&rect) ; | |
2635 | pt.x -= rect.left ; | |
2636 | pt.y -= rect.top ; | |
2637 | ||
2638 | event.m_x = pt.x; event.m_y = pt.y; | |
2639 | ||
dbda9e86 JS |
2640 | if (GetEventHandler()->ProcessEvent(event)) |
2641 | { | |
2642 | return TRUE; | |
2643 | } | |
2644 | else return FALSE; | |
2645 | } | |
2646 | else | |
2647 | { | |
2648 | return FALSE; | |
4ce81a75 JS |
2649 | } |
2650 | } | |
2651 | ||
dbda9e86 | 2652 | bool wxWindow::MSWOnKeyUp(WXWORD wParam, WXLPARAM lParam, bool isASCII) |
4ce81a75 JS |
2653 | { |
2654 | int id; | |
2655 | ||
2656 | if ((id = wxCharCodeMSWToWX(wParam)) == 0) { | |
2657 | id = wParam; | |
2658 | } | |
2659 | ||
2660 | if (id != -1) | |
2661 | { | |
2662 | wxKeyEvent event(wxEVT_KEY_UP); | |
2663 | event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE); | |
2664 | event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE); | |
2665 | if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN) | |
2666 | event.m_altDown = TRUE; | |
2667 | ||
2668 | event.m_eventObject = this; | |
2669 | event.m_keyCode = id; | |
2670 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
2671 | ||
2672 | POINT pt ; | |
2673 | GetCursorPos(&pt) ; | |
2674 | RECT rect ; | |
2675 | GetWindowRect((HWND) GetHWND(),&rect) ; | |
2676 | pt.x -= rect.left ; | |
2677 | pt.y -= rect.top ; | |
2678 | ||
2679 | event.m_x = pt.x; event.m_y = pt.y; | |
2680 | ||
dbda9e86 JS |
2681 | if (GetEventHandler()->ProcessEvent(event)) |
2682 | return TRUE; | |
2683 | else | |
2684 | return FALSE; | |
4ce81a75 | 2685 | } |
dbda9e86 JS |
2686 | else |
2687 | return FALSE; | |
4ce81a75 JS |
2688 | } |
2689 | ||
debe6624 | 2690 | void wxWindow::MSWOnJoyDown(int joystick, int x, int y, WXUINT flags) |
2bda0e17 KB |
2691 | { |
2692 | int buttons = 0; | |
2693 | int change = 0; | |
2694 | if (flags & JOY_BUTTON1CHG) | |
2695 | change = wxJOY_BUTTON1; | |
2696 | if (flags & JOY_BUTTON2CHG) | |
2697 | change = wxJOY_BUTTON2; | |
2698 | if (flags & JOY_BUTTON3CHG) | |
2699 | change = wxJOY_BUTTON3; | |
2700 | if (flags & JOY_BUTTON4CHG) | |
2701 | change = wxJOY_BUTTON4; | |
c085e333 | 2702 | |
2bda0e17 KB |
2703 | if (flags & JOY_BUTTON1) |
2704 | buttons |= wxJOY_BUTTON1; | |
2705 | if (flags & JOY_BUTTON2) | |
2706 | buttons |= wxJOY_BUTTON2; | |
2707 | if (flags & JOY_BUTTON3) | |
2708 | buttons |= wxJOY_BUTTON3; | |
2709 | if (flags & JOY_BUTTON4) | |
2710 | buttons |= wxJOY_BUTTON4; | |
c085e333 | 2711 | |
2bda0e17 KB |
2712 | wxJoystickEvent event(wxEVT_JOY_BUTTON_DOWN, buttons, joystick, change); |
2713 | event.SetPosition(wxPoint(x, y)); | |
2714 | event.SetEventObject(this); | |
c085e333 | 2715 | |
2bda0e17 KB |
2716 | GetEventHandler()->ProcessEvent(event); |
2717 | } | |
2718 | ||
debe6624 | 2719 | void wxWindow::MSWOnJoyUp(int joystick, int x, int y, WXUINT flags) |
2bda0e17 KB |
2720 | { |
2721 | int buttons = 0; | |
2722 | int change = 0; | |
2723 | if (flags & JOY_BUTTON1CHG) | |
2724 | change = wxJOY_BUTTON1; | |
2725 | if (flags & JOY_BUTTON2CHG) | |
2726 | change = wxJOY_BUTTON2; | |
2727 | if (flags & JOY_BUTTON3CHG) | |
2728 | change = wxJOY_BUTTON3; | |
2729 | if (flags & JOY_BUTTON4CHG) | |
2730 | change = wxJOY_BUTTON4; | |
c085e333 | 2731 | |
2bda0e17 KB |
2732 | if (flags & JOY_BUTTON1) |
2733 | buttons |= wxJOY_BUTTON1; | |
2734 | if (flags & JOY_BUTTON2) | |
2735 | buttons |= wxJOY_BUTTON2; | |
2736 | if (flags & JOY_BUTTON3) | |
2737 | buttons |= wxJOY_BUTTON3; | |
2738 | if (flags & JOY_BUTTON4) | |
2739 | buttons |= wxJOY_BUTTON4; | |
c085e333 | 2740 | |
2bda0e17 KB |
2741 | wxJoystickEvent event(wxEVT_JOY_BUTTON_UP, buttons, joystick, change); |
2742 | event.SetPosition(wxPoint(x, y)); | |
2743 | event.SetEventObject(this); | |
c085e333 | 2744 | |
2bda0e17 KB |
2745 | GetEventHandler()->ProcessEvent(event); |
2746 | } | |
2747 | ||
debe6624 | 2748 | void wxWindow::MSWOnJoyMove(int joystick, int x, int y, WXUINT flags) |
2bda0e17 KB |
2749 | { |
2750 | int buttons = 0; | |
2751 | if (flags & JOY_BUTTON1) | |
2752 | buttons |= wxJOY_BUTTON1; | |
2753 | if (flags & JOY_BUTTON2) | |
2754 | buttons |= wxJOY_BUTTON2; | |
2755 | if (flags & JOY_BUTTON3) | |
2756 | buttons |= wxJOY_BUTTON3; | |
2757 | if (flags & JOY_BUTTON4) | |
2758 | buttons |= wxJOY_BUTTON4; | |
c085e333 | 2759 | |
2bda0e17 KB |
2760 | wxJoystickEvent event(wxEVT_JOY_MOVE, buttons, joystick, 0); |
2761 | event.SetPosition(wxPoint(x, y)); | |
2762 | event.SetEventObject(this); | |
c085e333 | 2763 | |
2bda0e17 KB |
2764 | GetEventHandler()->ProcessEvent(event); |
2765 | } | |
2766 | ||
debe6624 | 2767 | void wxWindow::MSWOnJoyZMove(int joystick, int z, WXUINT flags) |
2bda0e17 KB |
2768 | { |
2769 | int buttons = 0; | |
2770 | if (flags & JOY_BUTTON1) | |
2771 | buttons |= wxJOY_BUTTON1; | |
2772 | if (flags & JOY_BUTTON2) | |
2773 | buttons |= wxJOY_BUTTON2; | |
2774 | if (flags & JOY_BUTTON3) | |
2775 | buttons |= wxJOY_BUTTON3; | |
2776 | if (flags & JOY_BUTTON4) | |
2777 | buttons |= wxJOY_BUTTON4; | |
c085e333 | 2778 | |
2bda0e17 KB |
2779 | wxJoystickEvent event(wxEVT_JOY_ZMOVE, buttons, joystick, 0); |
2780 | event.SetZPosition(z); | |
2781 | event.SetEventObject(this); | |
c085e333 | 2782 | |
2bda0e17 KB |
2783 | GetEventHandler()->ProcessEvent(event); |
2784 | } | |
2785 | ||
debe6624 | 2786 | void wxWindow::MSWOnVScroll(WXWORD wParam, WXWORD pos, WXHWND control) |
2bda0e17 | 2787 | { |
2d0a075d | 2788 | if (control) |
564b2609 | 2789 | { |
2d0a075d JS |
2790 | wxWindow *child = wxFindWinFromHandle(control); |
2791 | if ( child ) | |
2792 | child->MSWOnVScroll(wParam, pos, control); | |
2793 | return; | |
564b2609 | 2794 | } |
2bda0e17 | 2795 | |
564b2609 VZ |
2796 | wxScrollEvent event; |
2797 | event.SetPosition(pos); | |
2d0a075d | 2798 | event.SetOrientation(wxVERTICAL); |
564b2609 | 2799 | event.m_eventObject = this; |
2d0a075d | 2800 | |
564b2609 VZ |
2801 | switch ( wParam ) |
2802 | { | |
2d0a075d | 2803 | case SB_TOP: |
564b2609 VZ |
2804 | event.m_eventType = wxEVT_SCROLL_TOP; |
2805 | break; | |
2d0a075d JS |
2806 | |
2807 | case SB_BOTTOM: | |
564b2609 VZ |
2808 | event.m_eventType = wxEVT_SCROLL_BOTTOM; |
2809 | break; | |
2d0a075d JS |
2810 | |
2811 | case SB_LINEUP: | |
564b2609 VZ |
2812 | event.m_eventType = wxEVT_SCROLL_LINEUP; |
2813 | break; | |
2d0a075d JS |
2814 | |
2815 | case SB_LINEDOWN: | |
564b2609 VZ |
2816 | event.m_eventType = wxEVT_SCROLL_LINEDOWN; |
2817 | break; | |
2d0a075d JS |
2818 | |
2819 | case SB_PAGEUP: | |
564b2609 VZ |
2820 | event.m_eventType = wxEVT_SCROLL_PAGEUP; |
2821 | break; | |
2d0a075d JS |
2822 | |
2823 | case SB_PAGEDOWN: | |
564b2609 VZ |
2824 | event.m_eventType = wxEVT_SCROLL_PAGEDOWN; |
2825 | break; | |
2d0a075d JS |
2826 | |
2827 | case SB_THUMBTRACK: | |
2828 | case SB_THUMBPOSITION: | |
564b2609 VZ |
2829 | event.m_eventType = wxEVT_SCROLL_THUMBTRACK; |
2830 | break; | |
2d0a075d JS |
2831 | |
2832 | default: | |
564b2609 | 2833 | return; |
2d0a075d | 2834 | break; |
564b2609 | 2835 | } |
c085e333 | 2836 | |
2d0a075d JS |
2837 | if (!GetEventHandler()->ProcessEvent(event)) |
2838 | Default(); | |
2839 | } | |
2840 | ||
2841 | void wxWindow::MSWOnHScroll( WXWORD wParam, WXWORD pos, WXHWND control) | |
2842 | { | |
2843 | if (control) | |
2844 | { | |
2845 | wxWindow *child = wxFindWinFromHandle(control); | |
2846 | if ( child ) { | |
2847 | child->MSWOnHScroll(wParam, pos, control); | |
2848 | ||
2849 | return; | |
2850 | } | |
2851 | } | |
2852 | else { | |
2853 | wxScrollEvent event; | |
2854 | event.SetPosition(pos); | |
2855 | event.SetOrientation(wxHORIZONTAL); | |
2856 | event.m_eventObject = this; | |
2857 | ||
2858 | switch ( wParam ) | |
2859 | { | |
2860 | case SB_TOP: | |
2861 | event.m_eventType = wxEVT_SCROLL_TOP; | |
2862 | break; | |
2863 | ||
2864 | case SB_BOTTOM: | |
2865 | event.m_eventType = wxEVT_SCROLL_BOTTOM; | |
2866 | break; | |
2867 | ||
2868 | case SB_LINEUP: | |
2869 | event.m_eventType = wxEVT_SCROLL_LINEUP; | |
2870 | break; | |
2bda0e17 | 2871 | |
2d0a075d JS |
2872 | case SB_LINEDOWN: |
2873 | event.m_eventType = wxEVT_SCROLL_LINEDOWN; | |
2874 | break; | |
2875 | ||
2876 | case SB_PAGEUP: | |
2877 | event.m_eventType = wxEVT_SCROLL_PAGEUP; | |
2878 | break; | |
2879 | ||
2880 | case SB_PAGEDOWN: | |
2881 | event.m_eventType = wxEVT_SCROLL_PAGEDOWN; | |
2882 | break; | |
2883 | ||
2884 | case SB_THUMBTRACK: | |
2885 | case SB_THUMBPOSITION: | |
2886 | event.m_eventType = wxEVT_SCROLL_THUMBTRACK; | |
2887 | break; | |
2888 | ||
2889 | default: | |
2890 | return; | |
2891 | } | |
2bda0e17 | 2892 | |
2d0a075d JS |
2893 | if ( GetEventHandler()->ProcessEvent(event) ) |
2894 | return; | |
2895 | } | |
2896 | ||
2897 | // call the default WM_HSCROLL handler: it's non trivial in some common | |
2898 | // controls (up-down control for example) | |
2899 | Default(); | |
2bda0e17 KB |
2900 | } |
2901 | ||
2902 | void wxWindow::MSWOnShow(bool show, int status) | |
2903 | { | |
2d0a075d JS |
2904 | wxShowEvent event(GetId(), show); |
2905 | event.m_eventObject = this; | |
2906 | GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
2907 | } |
2908 | ||
2909 | bool wxWindow::MSWOnInitDialog(WXHWND WXUNUSED(hWndFocus)) | |
2910 | { | |
2d0a075d JS |
2911 | wxInitDialogEvent event(GetId()); |
2912 | event.m_eventObject = this; | |
2913 | GetEventHandler()->ProcessEvent(event); | |
2914 | return TRUE; | |
2bda0e17 KB |
2915 | } |
2916 | ||
fd3f686c | 2917 | void wxWindow::InitDialog() |
2bda0e17 | 2918 | { |
2d0a075d JS |
2919 | wxInitDialogEvent event(GetId()); |
2920 | event.SetEventObject( this ); | |
2921 | GetEventHandler()->ProcessEvent(event); | |
2bda0e17 KB |
2922 | } |
2923 | ||
2924 | // Default init dialog behaviour is to transfer data to window | |
2925 | void wxWindow::OnInitDialog(wxInitDialogEvent& event) | |
2926 | { | |
2d0a075d | 2927 | TransferDataToWindow(); |
2bda0e17 KB |
2928 | } |
2929 | ||
2930 | void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font) | |
2931 | { | |
2d0a075d JS |
2932 | TEXTMETRIC tm; |
2933 | HDC dc = ::GetDC((HWND) wnd); | |
2934 | HFONT fnt =0; | |
2935 | HFONT was = 0; | |
2936 | if (the_font) | |
2937 | { | |
2d0a075d JS |
2938 | // the_font->UseResource(); |
2939 | // the_font->RealizeResource(); | |
fd3f686c VZ |
2940 | fnt = (HFONT)the_font->GetResourceHandle(); |
2941 | if ( fnt ) | |
2d0a075d JS |
2942 | was = (HFONT) SelectObject(dc,fnt) ; |
2943 | } | |
2944 | GetTextMetrics(dc, &tm); | |
2945 | if (the_font && fnt && was) | |
2946 | { | |
2d0a075d JS |
2947 | SelectObject(dc,was) ; |
2948 | } | |
2949 | ReleaseDC((HWND)wnd, dc); | |
2950 | *x = tm.tmAveCharWidth; | |
2951 | *y = tm.tmHeight + tm.tmExternalLeading; | |
2bda0e17 | 2952 | |
2d0a075d JS |
2953 | // if (the_font) |
2954 | // the_font->ReleaseResource(); | |
2bda0e17 KB |
2955 | } |
2956 | ||
2957 | // Returns 0 if was a normal ASCII value, not a special key. This indicates that | |
2958 | // the key should be ignored by WM_KEYDOWN and processed by WM_CHAR instead. | |
2959 | int wxCharCodeMSWToWX(int keySym) | |
2960 | { | |
2d0a075d JS |
2961 | int id = 0; |
2962 | switch (keySym) | |
2963 | { | |
2964 | case VK_CANCEL: id = WXK_CANCEL; break; | |
2965 | case VK_BACK: id = WXK_BACK; break; | |
2966 | case VK_TAB: id = WXK_TAB; break; | |
564b2609 VZ |
2967 | case VK_CLEAR: id = WXK_CLEAR; break; |
2968 | case VK_RETURN: id = WXK_RETURN; break; | |
2969 | case VK_SHIFT: id = WXK_SHIFT; break; | |
2d0a075d | 2970 | case VK_CONTROL: id = WXK_CONTROL; break; |
564b2609 VZ |
2971 | case VK_MENU : id = WXK_MENU; break; |
2972 | case VK_PAUSE: id = WXK_PAUSE; break; | |
2973 | case VK_SPACE: id = WXK_SPACE; break; | |
2974 | case VK_ESCAPE: id = WXK_ESCAPE; break; | |
2975 | case VK_PRIOR: id = WXK_PRIOR; break; | |
2976 | case VK_NEXT : id = WXK_NEXT; break; | |
2977 | case VK_END: id = WXK_END; break; | |
2978 | case VK_HOME : id = WXK_HOME; break; | |
2979 | case VK_LEFT : id = WXK_LEFT; break; | |
2d0a075d | 2980 | case VK_UP: id = WXK_UP; break; |
564b2609 VZ |
2981 | case VK_RIGHT: id = WXK_RIGHT; break; |
2982 | case VK_DOWN : id = WXK_DOWN; break; | |
2983 | case VK_SELECT: id = WXK_SELECT; break; | |
2984 | case VK_PRINT: id = WXK_PRINT; break; | |
2d0a075d | 2985 | case VK_EXECUTE: id = WXK_EXECUTE; break; |
564b2609 VZ |
2986 | case VK_INSERT: id = WXK_INSERT; break; |
2987 | case VK_DELETE: id = WXK_DELETE; break; | |
2988 | case VK_HELP : id = WXK_HELP; break; | |
2d0a075d JS |
2989 | case VK_NUMPAD0: id = WXK_NUMPAD0; break; |
2990 | case VK_NUMPAD1: id = WXK_NUMPAD1; break; | |
2991 | case VK_NUMPAD2: id = WXK_NUMPAD2; break; | |
2992 | case VK_NUMPAD3: id = WXK_NUMPAD3; break; | |
2993 | case VK_NUMPAD4: id = WXK_NUMPAD4; break; | |
2994 | case VK_NUMPAD5: id = WXK_NUMPAD5; break; | |
2995 | case VK_NUMPAD6: id = WXK_NUMPAD6; break; | |
2996 | case VK_NUMPAD7: id = WXK_NUMPAD7; break; | |
2997 | case VK_NUMPAD8: id = WXK_NUMPAD8; break; | |
2998 | case VK_NUMPAD9: id = WXK_NUMPAD9; break; | |
2999 | case VK_MULTIPLY: id = WXK_MULTIPLY; break; | |
564b2609 | 3000 | case VK_ADD: id = WXK_ADD; break; |
2d0a075d JS |
3001 | case VK_SUBTRACT: id = WXK_SUBTRACT; break; |
3002 | case VK_DECIMAL: id = WXK_DECIMAL; break; | |
564b2609 | 3003 | case VK_DIVIDE: id = WXK_DIVIDE; break; |
2d0a075d JS |
3004 | case VK_F1: id = WXK_F1; break; |
3005 | case VK_F2: id = WXK_F2; break; | |
3006 | case VK_F3: id = WXK_F3; break; | |
3007 | case VK_F4: id = WXK_F4; break; | |
3008 | case VK_F5: id = WXK_F5; break; | |
3009 | case VK_F6: id = WXK_F6; break; | |
3010 | case VK_F7: id = WXK_F7; break; | |
3011 | case VK_F8: id = WXK_F8; break; | |
3012 | case VK_F9: id = WXK_F9; break; | |
564b2609 VZ |
3013 | case VK_F10: id = WXK_F10; break; |
3014 | case VK_F11: id = WXK_F11; break; | |
3015 | case VK_F12: id = WXK_F12; break; | |
3016 | case VK_F13: id = WXK_F13; break; | |
3017 | case VK_F14: id = WXK_F14; break; | |
3018 | case VK_F15: id = WXK_F15; break; | |
3019 | case VK_F16: id = WXK_F16; break; | |
3020 | case VK_F17: id = WXK_F17; break; | |
3021 | case VK_F18: id = WXK_F18; break; | |
3022 | case VK_F19: id = WXK_F19; break; | |
3023 | case VK_F20: id = WXK_F20; break; | |
3024 | case VK_F21: id = WXK_F21; break; | |
3025 | case VK_F22: id = WXK_F22; break; | |
3026 | case VK_F23: id = WXK_F23; break; | |
3027 | case VK_F24: id = WXK_F24; break; | |
2d0a075d | 3028 | case VK_NUMLOCK: id = WXK_NUMLOCK; break; |
564b2609 | 3029 | case VK_SCROLL: id = WXK_SCROLL; break; |
2bda0e17 | 3030 | default: |
2d0a075d JS |
3031 | { |
3032 | return 0; | |
3033 | } | |
2bda0e17 | 3034 | } |
2d0a075d | 3035 | return id; |
2bda0e17 KB |
3036 | } |
3037 | ||
3038 | int wxCharCodeWXToMSW(int id, bool *isVirtual) | |
3039 | { | |
2d0a075d JS |
3040 | *isVirtual = TRUE; |
3041 | int keySym = 0; | |
3042 | switch (id) | |
3043 | { | |
3044 | case WXK_CANCEL: keySym = VK_CANCEL; break; | |
564b2609 VZ |
3045 | case WXK_CLEAR: keySym = VK_CLEAR; break; |
3046 | case WXK_SHIFT: keySym = VK_SHIFT; break; | |
2d0a075d | 3047 | case WXK_CONTROL: keySym = VK_CONTROL; break; |
564b2609 VZ |
3048 | case WXK_MENU : keySym = VK_MENU; break; |
3049 | case WXK_PAUSE: keySym = VK_PAUSE; break; | |
3050 | case WXK_PRIOR: keySym = VK_PRIOR; break; | |
3051 | case WXK_NEXT : keySym = VK_NEXT; break; | |
3052 | case WXK_END: keySym = VK_END; break; | |
3053 | case WXK_HOME : keySym = VK_HOME; break; | |
3054 | case WXK_LEFT : keySym = VK_LEFT; break; | |
3055 | case WXK_UP: keySym = VK_UP; break; | |
3056 | case WXK_RIGHT: keySym = VK_RIGHT; break; | |
3057 | case WXK_DOWN : keySym = VK_DOWN; break; | |
2d0a075d | 3058 | case WXK_SELECT: keySym = VK_SELECT; break; |
564b2609 | 3059 | case WXK_PRINT: keySym = VK_PRINT; break; |
2d0a075d JS |
3060 | case WXK_EXECUTE: keySym = VK_EXECUTE; break; |
3061 | case WXK_INSERT: keySym = VK_INSERT; break; | |
3062 | case WXK_DELETE: keySym = VK_DELETE; break; | |
564b2609 | 3063 | case WXK_HELP : keySym = VK_HELP; break; |
2d0a075d JS |
3064 | case WXK_NUMPAD0: keySym = VK_NUMPAD0; break; |
3065 | case WXK_NUMPAD1: keySym = VK_NUMPAD1; break; | |
3066 | case WXK_NUMPAD2: keySym = VK_NUMPAD2; break; | |
3067 | case WXK_NUMPAD3: keySym = VK_NUMPAD3; break; | |
3068 | case WXK_NUMPAD4: keySym = VK_NUMPAD4; break; | |
3069 | case WXK_NUMPAD5: keySym = VK_NUMPAD5; break; | |
3070 | case WXK_NUMPAD6: keySym = VK_NUMPAD6; break; | |
3071 | case WXK_NUMPAD7: keySym = VK_NUMPAD7; break; | |
3072 | case WXK_NUMPAD8: keySym = VK_NUMPAD8; break; | |
3073 | case WXK_NUMPAD9: keySym = VK_NUMPAD9; break; | |
3074 | case WXK_MULTIPLY: keySym = VK_MULTIPLY; break; | |
564b2609 | 3075 | case WXK_ADD: keySym = VK_ADD; break; |
2d0a075d JS |
3076 | case WXK_SUBTRACT: keySym = VK_SUBTRACT; break; |
3077 | case WXK_DECIMAL: keySym = VK_DECIMAL; break; | |
3078 | case WXK_DIVIDE: keySym = VK_DIVIDE; break; | |
564b2609 VZ |
3079 | case WXK_F1: keySym = VK_F1; break; |
3080 | case WXK_F2: keySym = VK_F2; break; | |
3081 | case WXK_F3: keySym = VK_F3; break; | |
3082 | case WXK_F4: keySym = VK_F4; break; | |
3083 | case WXK_F5: keySym = VK_F5; break; | |
3084 | case WXK_F6: keySym = VK_F6; break; | |
3085 | case WXK_F7: keySym = VK_F7; break; | |
3086 | case WXK_F8: keySym = VK_F8; break; | |
3087 | case WXK_F9: keySym = VK_F9; break; | |
3088 | case WXK_F10: keySym = VK_F10; break; | |
3089 | case WXK_F11: keySym = VK_F11; break; | |
3090 | case WXK_F12: keySym = VK_F12; break; | |
3091 | case WXK_F13: keySym = VK_F13; break; | |
3092 | case WXK_F14: keySym = VK_F14; break; | |
3093 | case WXK_F15: keySym = VK_F15; break; | |
3094 | case WXK_F16: keySym = VK_F16; break; | |
3095 | case WXK_F17: keySym = VK_F17; break; | |
3096 | case WXK_F18: keySym = VK_F18; break; | |
3097 | case WXK_F19: keySym = VK_F19; break; | |
3098 | case WXK_F20: keySym = VK_F20; break; | |
3099 | case WXK_F21: keySym = VK_F21; break; | |
3100 | case WXK_F22: keySym = VK_F22; break; | |
3101 | case WXK_F23: keySym = VK_F23; break; | |
3102 | case WXK_F24: keySym = VK_F24; break; | |
2d0a075d JS |
3103 | case WXK_NUMLOCK: keySym = VK_NUMLOCK; break; |
3104 | case WXK_SCROLL: keySym = VK_SCROLL; break; | |
2bda0e17 | 3105 | default: |
2d0a075d JS |
3106 | { |
3107 | *isVirtual = FALSE; | |
3108 | keySym = id; | |
3109 | break; | |
3110 | } | |
2bda0e17 | 3111 | } |
2d0a075d | 3112 | return keySym; |
2bda0e17 KB |
3113 | } |
3114 | ||
3115 | // Caret manipulation | |
debe6624 | 3116 | void wxWindow::CreateCaret(int w, int h) |
2bda0e17 | 3117 | { |
2d0a075d JS |
3118 | m_caretWidth = w; |
3119 | m_caretHeight = h; | |
3120 | m_caretEnabled = TRUE; | |
2bda0e17 KB |
3121 | } |
3122 | ||
3123 | void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap)) | |
3124 | { | |
2d0a075d | 3125 | // Not implemented |
2bda0e17 KB |
3126 | } |
3127 | ||
debe6624 | 3128 | void wxWindow::ShowCaret(bool show) |
2bda0e17 | 3129 | { |
2d0a075d JS |
3130 | if (m_caretEnabled) |
3131 | { | |
3132 | if (show) | |
3133 | ::ShowCaret((HWND) GetHWND()); | |
3134 | else | |
3135 | ::HideCaret((HWND) GetHWND()); | |
3136 | m_caretShown = show; | |
3137 | } | |
2bda0e17 KB |
3138 | } |
3139 | ||
fd3f686c | 3140 | void wxWindow::DestroyCaret() |
2bda0e17 | 3141 | { |
2d0a075d | 3142 | m_caretEnabled = FALSE; |
2bda0e17 KB |
3143 | } |
3144 | ||
debe6624 | 3145 | void wxWindow::SetCaretPos(int x, int y) |
2bda0e17 | 3146 | { |
2d0a075d | 3147 | ::SetCaretPos(x, y); |
2bda0e17 KB |
3148 | } |
3149 | ||
3150 | void wxWindow::GetCaretPos(int *x, int *y) const | |
3151 | { | |
2d0a075d JS |
3152 | POINT point; |
3153 | ::GetCaretPos(&point); | |
3154 | *x = point.x; | |
3155 | *y = point.y; | |
2bda0e17 KB |
3156 | } |
3157 | ||
fd3f686c | 3158 | wxWindow *wxGetActiveWindow() |
2bda0e17 | 3159 | { |
2d0a075d JS |
3160 | HWND hWnd = GetActiveWindow(); |
3161 | if (hWnd != 0) | |
3162 | { | |
3163 | return wxFindWinFromHandle((WXHWND) hWnd); | |
3164 | } | |
3165 | return NULL; | |
2bda0e17 KB |
3166 | } |
3167 | ||
3168 | // Windows keyboard hook. Allows interception of e.g. F1, ESCAPE | |
3169 | // in active frames and dialogs, regardless of where the focus is. | |
3170 | static HHOOK wxTheKeyboardHook = 0; | |
3171 | static FARPROC wxTheKeyboardHookProc = 0; | |
3172 | int APIENTRY _EXPORT | |
2d0a075d | 3173 | wxKeyboardHook(int nCode, WORD wParam, DWORD lParam); |
2bda0e17 KB |
3174 | |
3175 | void wxSetKeyboardHook(bool doIt) | |
3176 | { | |
2d0a075d JS |
3177 | if (doIt) |
3178 | { | |
3179 | wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance()); | |
3180 | wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(), | |
57c208c5 | 3181 | #if defined(__WIN32__) && !defined(__TWIN32__) |
2d0a075d JS |
3182 | GetCurrentThreadId()); |
3183 | // (DWORD)GetCurrentProcess()); // This is another possibility. Which is right? | |
2bda0e17 | 3184 | #else |
2d0a075d | 3185 | GetCurrentTask()); |
2bda0e17 | 3186 | #endif |
2d0a075d JS |
3187 | } |
3188 | else | |
3189 | { | |
3190 | UnhookWindowsHookEx(wxTheKeyboardHook); | |
3191 | FreeProcInstance(wxTheKeyboardHookProc); | |
3192 | } | |
2bda0e17 KB |
3193 | } |
3194 | ||
3195 | int APIENTRY _EXPORT | |
2d0a075d | 3196 | wxKeyboardHook(int nCode, WORD wParam, DWORD lParam) |
2bda0e17 | 3197 | { |
2d0a075d JS |
3198 | DWORD hiWord = HIWORD(lParam); |
3199 | if (nCode != HC_NOREMOVE && ((hiWord & KF_UP) == 0)) | |
2bda0e17 | 3200 | { |
2d0a075d JS |
3201 | int id; |
3202 | if ((id = wxCharCodeMSWToWX(wParam)) != 0) | |
564b2609 | 3203 | { |
2d0a075d JS |
3204 | wxKeyEvent event(wxEVT_CHAR_HOOK); |
3205 | if ((HIWORD(lParam) & KF_ALTDOWN) == KF_ALTDOWN) | |
3206 | event.m_altDown = TRUE; | |
3207 | ||
3208 | event.m_eventObject = NULL; | |
3209 | event.m_keyCode = id; | |
3210 | /* begin Albert's fix for control and shift key 26.5 */ | |
3211 | event.m_shiftDown = (::GetKeyState(VK_SHIFT)&0x100?TRUE:FALSE); | |
3212 | event.m_controlDown = (::GetKeyState(VK_CONTROL)&0x100?TRUE:FALSE); | |
3213 | /* end Albert's fix for control and shift key 26.5 */ | |
3214 | event.SetTimestamp(wxApp::sm_lastMessageTime); | |
3215 | ||
3216 | wxWindow *win = wxGetActiveWindow(); | |
3217 | if (win) | |
3218 | { | |
3219 | if (win->GetEventHandler()->ProcessEvent(event)) | |
3220 | return 1; | |
3221 | } | |
3222 | else | |
3223 | { | |
3224 | if ( wxTheApp && wxTheApp->ProcessEvent(event) ) | |
3225 | return 1; | |
3226 | } | |
564b2609 | 3227 | } |
2bda0e17 | 3228 | } |
2d0a075d | 3229 | return (int)CallNextHookEx(wxTheKeyboardHook, nCode, wParam, lParam); |
2bda0e17 KB |
3230 | } |
3231 | ||
debe6624 | 3232 | void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int WXUNUSED(incW), int WXUNUSED(incH)) |
2bda0e17 | 3233 | { |
2d0a075d JS |
3234 | m_minSizeX = minW; |
3235 | m_minSizeY = minH; | |
3236 | m_maxSizeX = maxW; | |
3237 | m_maxSizeY = maxH; | |
2bda0e17 KB |
3238 | } |
3239 | ||
debe6624 | 3240 | void wxWindow::Centre(int direction) |
2bda0e17 | 3241 | { |
2d0a075d | 3242 | int x, y, width, height, panel_width, panel_height, new_x, new_y; |
2bda0e17 | 3243 | |
2d0a075d JS |
3244 | wxWindow *father = (wxWindow *)GetParent(); |
3245 | if (!father) | |
3246 | return; | |
2bda0e17 | 3247 | |
2d0a075d JS |
3248 | father->GetClientSize(&panel_width, &panel_height); |
3249 | GetSize(&width, &height); | |
3250 | GetPosition(&x, &y); | |
2bda0e17 | 3251 | |
2d0a075d JS |
3252 | new_x = -1; |
3253 | new_y = -1; | |
2bda0e17 | 3254 | |
2d0a075d JS |
3255 | if (direction & wxHORIZONTAL) |
3256 | new_x = (int)((panel_width - width)/2); | |
2bda0e17 | 3257 | |
2d0a075d JS |
3258 | if (direction & wxVERTICAL) |
3259 | new_y = (int)((panel_height - height)/2); | |
2bda0e17 | 3260 | |
2d0a075d | 3261 | SetSize(new_x, new_y, -1, -1); |
2bda0e17 KB |
3262 | |
3263 | } | |
3264 | ||
debe6624 | 3265 | void wxWindow::WarpPointer (int x_pos, int y_pos) |
2bda0e17 | 3266 | { |
5de76427 JS |
3267 | // Move the pointer to (x_pos,y_pos) coordinates. They are expressed in |
3268 | // pixel coordinates, relatives to the canvas -- So, we first need to | |
3269 | // substract origin of the window, then convert to screen position | |
c085e333 | 3270 | |
5de76427 JS |
3271 | int x = x_pos; int y = y_pos; |
3272 | RECT rect; | |
3273 | GetWindowRect ((HWND) GetHWND(), &rect); | |
c085e333 | 3274 | |
5de76427 JS |
3275 | x += rect.left; |
3276 | y += rect.top; | |
c085e333 | 3277 | |
5de76427 | 3278 | SetCursorPos (x, y); |
2bda0e17 KB |
3279 | } |
3280 | ||
3281 | void wxWindow::MSWDeviceToLogical (float *x, float *y) const | |
3282 | { | |
2bda0e17 KB |
3283 | } |
3284 | ||
debe6624 | 3285 | bool wxWindow::MSWOnEraseBkgnd (WXHDC pDC) |
2bda0e17 KB |
3286 | { |
3287 | wxDC dc ; | |
c085e333 | 3288 | |
564b2609 VZ |
3289 | dc.SetHDC(pDC); |
3290 | dc.SetWindow(this); | |
3291 | dc.BeginDrawing(); | |
c085e333 | 3292 | |
2bda0e17 KB |
3293 | wxEraseEvent event(m_windowId, &dc); |
3294 | event.m_eventObject = this; | |
3295 | if (!GetEventHandler()->ProcessEvent(event)) | |
3296 | { | |
564b2609 VZ |
3297 | dc.EndDrawing(); |
3298 | dc.SelectOldObjects(pDC); | |
2bda0e17 KB |
3299 | return FALSE; |
3300 | } | |
3301 | else | |
3302 | { | |
564b2609 VZ |
3303 | dc.EndDrawing(); |
3304 | dc.SelectOldObjects(pDC); | |
2bda0e17 | 3305 | } |
c085e333 | 3306 | |
2bda0e17 KB |
3307 | dc.SetHDC((WXHDC) NULL); |
3308 | return TRUE; | |
3309 | } | |
3310 | ||
3311 | void wxWindow::OnEraseBackground(wxEraseEvent& event) | |
3312 | { | |
ce3ed50d JS |
3313 | if (!GetHWND()) |
3314 | return; | |
3315 | ||
2d0a075d JS |
3316 | RECT rect; |
3317 | ::GetClientRect((HWND) GetHWND(), &rect); | |
2bda0e17 | 3318 | |
ce3ed50d JS |
3319 | COLORREF ref = PALETTERGB(m_backgroundColour.Red(), m_backgroundColour.Green(), m_backgroundColour.Blue()) ; |
3320 | HBRUSH hBrush = ::CreateSolidBrush(ref); | |
2d0a075d | 3321 | int mode = ::SetMapMode((HDC) event.GetDC()->GetHDC(), MM_TEXT); |
2bda0e17 | 3322 | |
2d0a075d JS |
3323 | // ::GetClipBox((HDC) event.GetDC()->GetHDC(), &rect); |
3324 | ::FillRect ((HDC) event.GetDC()->GetHDC(), &rect, hBrush); | |
3325 | ::DeleteObject(hBrush); | |
3326 | ::SetMapMode((HDC) event.GetDC()->GetHDC(), mode); | |
3327 | /* | |
3328 | // Less efficient version (and doesn't account for scrolling) | |
3329 | int w, h; | |
3330 | GetClientSize(& w, & h); | |
3331 | wxBrush *brush = wxTheBrushList->FindOrCreateBrush(& GetBackgroundColour(), wxSOLID); | |
3332 | event.GetDC()->SetBrush(brush); | |
3333 | event.GetDC()->SetPen(wxTRANSPARENT_PEN); | |
3334 | ||
3335 | event.GetDC()->DrawRectangle(0, 0, w+1, h+1); | |
3336 | */ | |
2bda0e17 KB |
3337 | } |
3338 | ||
3339 | #if WXWIN_COMPATIBILITY | |
debe6624 | 3340 | void wxWindow::SetScrollRange(int orient, int range, bool refresh) |
2bda0e17 KB |
3341 | { |
3342 | #if defined(__WIN95__) | |
c085e333 | 3343 | |
2d0a075d | 3344 | int range1 = range; |
2bda0e17 | 3345 | |
2d0a075d JS |
3346 | // Try to adjust the range to cope with page size > 1 |
3347 | // - a Windows API quirk | |
3348 | int pageSize = GetScrollPage(orient); | |
3349 | if ( pageSize > 1 && range > 0) | |
3350 | { | |
3351 | range1 += (pageSize - 1); | |
3352 | } | |
2bda0e17 | 3353 | |
2d0a075d JS |
3354 | SCROLLINFO info; |
3355 | int dir; | |
2bda0e17 | 3356 | |
2d0a075d JS |
3357 | if (orient == wxHORIZONTAL) { |
3358 | dir = SB_HORZ; | |
3359 | } else { | |
3360 | dir = SB_VERT; | |
3361 | } | |
2bda0e17 | 3362 | |
2d0a075d JS |
3363 | info.cbSize = sizeof(SCROLLINFO); |
3364 | info.nPage = pageSize; // Have to set this, or scrollbar goes awry | |
3365 | info.nMin = 0; | |
3366 | info.nMax = range1; | |
3367 | info.nPos = 0; | |
3368 | info.fMask = SIF_RANGE | SIF_PAGE; | |
2bda0e17 | 3369 | |
2d0a075d JS |
3370 | HWND hWnd = (HWND) GetHWND(); |
3371 | if (hWnd) | |
3372 | ::SetScrollInfo(hWnd, dir, &info, refresh); | |
2bda0e17 | 3373 | #else |
2d0a075d JS |
3374 | int wOrient ; |
3375 | if (orient == wxHORIZONTAL) | |
3376 | wOrient = SB_HORZ; | |
3377 | else | |
3378 | wOrient = SB_VERT; | |
3379 | ||
3380 | HWND hWnd = (HWND) GetHWND(); | |
3381 | if (hWnd) | |
3382 | ::SetScrollRange(hWnd, wOrient, 0, range, refresh); | |
2bda0e17 KB |
3383 | #endif |
3384 | } | |
3385 | ||
debe6624 | 3386 | void wxWindow::SetScrollPage(int orient, int page, bool refresh) |
2bda0e17 KB |
3387 | { |
3388 | #if defined(__WIN95__) | |
2d0a075d JS |
3389 | SCROLLINFO info; |
3390 | int dir; | |
3391 | ||
3392 | if (orient == wxHORIZONTAL) { | |
3393 | dir = SB_HORZ; | |
3394 | m_xThumbSize = page; | |
3395 | } else { | |
3396 | dir = SB_VERT; | |
3397 | m_yThumbSize = page; | |
3398 | } | |
2bda0e17 | 3399 | |
2d0a075d JS |
3400 | info.cbSize = sizeof(SCROLLINFO); |
3401 | info.nPage = page; | |
3402 | info.nMin = 0; | |
3403 | info.fMask = SIF_PAGE ; | |
2bda0e17 | 3404 | |
2d0a075d JS |
3405 | HWND hWnd = (HWND) GetHWND(); |
3406 | if (hWnd) | |
3407 | ::SetScrollInfo(hWnd, dir, &info, refresh); | |
2bda0e17 | 3408 | #else |
2d0a075d JS |
3409 | if (orient == wxHORIZONTAL) |
3410 | m_xThumbSize = page; | |
3411 | else | |
3412 | m_yThumbSize = page; | |
2bda0e17 KB |
3413 | #endif |
3414 | } | |
3415 | ||
debe6624 | 3416 | int wxWindow::OldGetScrollRange(int orient) const |
2bda0e17 | 3417 | { |
2d0a075d JS |
3418 | int wOrient ; |
3419 | if (orient == wxHORIZONTAL) | |
3420 | wOrient = SB_HORZ; | |
3421 | else | |
3422 | wOrient = SB_VERT; | |
2bda0e17 KB |
3423 | |
3424 | #if __WATCOMC__ && defined(__WINDOWS_386__) | |
2d0a075d | 3425 | short minPos, maxPos; |
2bda0e17 | 3426 | #else |
2d0a075d | 3427 | int minPos, maxPos; |
2bda0e17 | 3428 | #endif |
2d0a075d JS |
3429 | HWND hWnd = (HWND) GetHWND(); |
3430 | if (hWnd) | |
2bda0e17 | 3431 | { |
2d0a075d JS |
3432 | ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos); |
3433 | #if defined(__WIN95__) | |
3434 | // Try to adjust the range to cope with page size > 1 | |
3435 | // - a Windows API quirk | |
3436 | int pageSize = GetScrollPage(orient); | |
3437 | if ( pageSize > 1 ) | |
3438 | { | |
3439 | maxPos -= (pageSize - 1); | |
3440 | } | |
2bda0e17 | 3441 | #endif |
2d0a075d JS |
3442 | return maxPos; |
3443 | } | |
3444 | else | |
3445 | return 0; | |
2bda0e17 KB |
3446 | } |
3447 | ||
debe6624 | 3448 | int wxWindow::GetScrollPage(int orient) const |
2bda0e17 | 3449 | { |
2d0a075d JS |
3450 | if (orient == wxHORIZONTAL) |
3451 | return m_xThumbSize; | |
3452 | else | |
3453 | return m_yThumbSize; | |
2bda0e17 KB |
3454 | } |
3455 | #endif | |
3456 | ||
debe6624 | 3457 | int wxWindow::GetScrollPos(int orient) const |
2bda0e17 | 3458 | { |
2d0a075d JS |
3459 | int wOrient ; |
3460 | if (orient == wxHORIZONTAL) | |
3461 | wOrient = SB_HORZ; | |
3462 | else | |
3463 | wOrient = SB_VERT; | |
3464 | HWND hWnd = (HWND) GetHWND(); | |
3465 | if (hWnd) | |
3466 | { | |
3467 | return ::GetScrollPos(hWnd, wOrient); | |
3468 | } | |
3469 | else | |
3470 | return 0; | |
2bda0e17 KB |
3471 | } |
3472 | ||
3473 | // This now returns the whole range, not just the number | |
3474 | // of positions that we can scroll. | |
debe6624 | 3475 | int wxWindow::GetScrollRange(int orient) const |
2bda0e17 | 3476 | { |
2d0a075d JS |
3477 | int wOrient ; |
3478 | if (orient == wxHORIZONTAL) | |
3479 | wOrient = SB_HORZ; | |
3480 | else | |
3481 | wOrient = SB_VERT; | |
2bda0e17 KB |
3482 | |
3483 | #if __WATCOMC__ && defined(__WINDOWS_386__) | |
2d0a075d | 3484 | short minPos, maxPos; |
2bda0e17 | 3485 | #else |
2d0a075d | 3486 | int minPos, maxPos; |
2bda0e17 | 3487 | #endif |
2d0a075d JS |
3488 | HWND hWnd = (HWND) GetHWND(); |
3489 | if (hWnd) | |
2bda0e17 | 3490 | { |
2d0a075d JS |
3491 | ::GetScrollRange(hWnd, wOrient, &minPos, &maxPos); |
3492 | #if defined(__WIN95__) | |
3493 | // Try to adjust the range to cope with page size > 1 | |
3494 | // - a Windows API quirk | |
ca5e9f67 | 3495 | int pageSize = GetScrollThumb(orient); |
2d0a075d JS |
3496 | if ( pageSize > 1 ) |
3497 | { | |
3498 | maxPos -= (pageSize - 1); | |
3499 | } | |
3500 | // October 10th: new range concept. | |
3501 | maxPos += pageSize; | |
2bda0e17 | 3502 | #endif |
c085e333 | 3503 | |
2d0a075d JS |
3504 | return maxPos; |
3505 | } | |
3506 | else | |
3507 | return 0; | |
2bda0e17 KB |
3508 | } |
3509 | ||
debe6624 | 3510 | int wxWindow::GetScrollThumb(int orient) const |
2bda0e17 | 3511 | { |
2d0a075d JS |
3512 | if (orient == wxHORIZONTAL) |
3513 | return m_xThumbSize; | |
3514 | else | |
3515 | return m_yThumbSize; | |
2bda0e17 KB |
3516 | } |
3517 | ||
debe6624 | 3518 | void wxWindow::SetScrollPos(int orient, int pos, bool refresh) |
2bda0e17 KB |
3519 | { |
3520 | #if defined(__WIN95__) | |
2d0a075d JS |
3521 | SCROLLINFO info; |
3522 | int dir; | |
2bda0e17 | 3523 | |
2d0a075d JS |
3524 | if (orient == wxHORIZONTAL) { |
3525 | dir = SB_HORZ; | |
3526 | } else { | |
3527 | dir = SB_VERT; | |
3528 | } | |
2bda0e17 | 3529 | |
2d0a075d JS |
3530 | info.cbSize = sizeof(SCROLLINFO); |
3531 | info.nPage = 0; | |
3532 | info.nMin = 0; | |
3533 | info.nPos = pos; | |
3534 | info.fMask = SIF_POS ; | |
2bda0e17 | 3535 | |
2d0a075d JS |
3536 | HWND hWnd = (HWND) GetHWND(); |
3537 | if (hWnd) | |
3538 | ::SetScrollInfo(hWnd, dir, &info, refresh); | |
2bda0e17 | 3539 | #else |
2d0a075d JS |
3540 | int wOrient ; |
3541 | if (orient == wxHORIZONTAL) | |
3542 | wOrient = SB_HORZ; | |
3543 | else | |
3544 | wOrient = SB_VERT; | |
3545 | ||
3546 | HWND hWnd = (HWND) GetHWND(); | |
3547 | if (hWnd) | |
3548 | ::SetScrollPos(hWnd, wOrient, pos, refresh); | |
2bda0e17 KB |
3549 | #endif |
3550 | } | |
3551 | ||
3552 | // New function that will replace some of the above. | |
debe6624 | 3553 | void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, |
2d0a075d | 3554 | int range, bool refresh) |
2bda0e17 KB |
3555 | { |
3556 | /* | |
2d0a075d | 3557 | SetScrollPage(orient, thumbVisible, FALSE); |
2bda0e17 | 3558 | |
2d0a075d JS |
3559 | int oldRange = range - thumbVisible ; |
3560 | SetScrollRange(orient, oldRange, FALSE); | |
c085e333 | 3561 | |
2bda0e17 | 3562 | SetScrollPos(orient, pos, refresh); |
2d0a075d | 3563 | */ |
2bda0e17 | 3564 | #if defined(__WIN95__) |
2d0a075d | 3565 | int oldRange = range - thumbVisible ; |
2bda0e17 | 3566 | |
2d0a075d | 3567 | int range1 = oldRange; |
2bda0e17 | 3568 | |
2d0a075d JS |
3569 | // Try to adjust the range to cope with page size > 1 |
3570 | // - a Windows API quirk | |
3571 | int pageSize = thumbVisible; | |
3572 | if ( pageSize > 1 && range > 0) | |
3573 | { | |
3574 | range1 += (pageSize - 1); | |
3575 | } | |
2bda0e17 | 3576 | |
2d0a075d JS |
3577 | SCROLLINFO info; |
3578 | int dir; | |
2bda0e17 | 3579 | |
2d0a075d JS |
3580 | if (orient == wxHORIZONTAL) { |
3581 | dir = SB_HORZ; | |
3582 | } else { | |
3583 | dir = SB_VERT; | |
3584 | } | |
2bda0e17 | 3585 | |
2d0a075d JS |
3586 | info.cbSize = sizeof(SCROLLINFO); |
3587 | info.nPage = pageSize; // Have to set this, or scrollbar goes awry | |
3588 | info.nMin = 0; | |
3589 | info.nMax = range1; | |
3590 | info.nPos = pos; | |
3591 | info.fMask = SIF_RANGE | SIF_PAGE | SIF_POS; | |
2bda0e17 | 3592 | |
2d0a075d JS |
3593 | HWND hWnd = (HWND) GetHWND(); |
3594 | if (hWnd) | |
3595 | ::SetScrollInfo(hWnd, dir, &info, refresh); | |
2bda0e17 | 3596 | #else |
2d0a075d JS |
3597 | int wOrient ; |
3598 | if (orient == wxHORIZONTAL) | |
3599 | wOrient = SB_HORZ; | |
3600 | else | |
3601 | wOrient = SB_VERT; | |
3602 | ||
3603 | HWND hWnd = (HWND) GetHWND(); | |
3604 | if (hWnd) | |
3605 | { | |
3606 | ::SetScrollRange(hWnd, wOrient, 0, range, FALSE); | |
3607 | ::SetScrollPos(hWnd, wOrient, pos, refresh); | |
3608 | } | |
2bda0e17 | 3609 | #endif |
2d0a075d JS |
3610 | if (orient == wxHORIZONTAL) { |
3611 | m_xThumbSize = thumbVisible; | |
3612 | } else { | |
3613 | m_yThumbSize = thumbVisible; | |
3614 | } | |
2bda0e17 KB |
3615 | } |
3616 | ||
16e93305 | 3617 | void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) |
2bda0e17 | 3618 | { |
564b2609 VZ |
3619 | RECT rect2; |
3620 | if ( rect ) | |
3621 | { | |
3622 | rect2.left = rect->x; | |
3623 | rect2.top = rect->y; | |
3624 | rect2.right = rect->x + rect->width; | |
3625 | rect2.bottom = rect->y + rect->height; | |
3626 | } | |
c085e333 | 3627 | |
564b2609 VZ |
3628 | if ( rect ) |
3629 | ::ScrollWindow((HWND) GetHWND(), dx, dy, &rect2, NULL); | |
3630 | else | |
3631 | ::ScrollWindow((HWND) GetHWND(), dx, dy, NULL, NULL); | |
2bda0e17 KB |
3632 | } |
3633 | ||
2bda0e17 KB |
3634 | void wxWindow::SetFont(const wxFont& font) |
3635 | { | |
2d0a075d | 3636 | m_windowFont = font; |
2bda0e17 | 3637 | |
2d0a075d JS |
3638 | if (!m_windowFont.Ok()) |
3639 | return; | |
2bda0e17 | 3640 | |
2d0a075d JS |
3641 | HWND hWnd = (HWND) GetHWND(); |
3642 | if (hWnd != 0) | |
3643 | { | |
3644 | if (m_windowFont.GetResourceHandle()) | |
3645 | SendMessage(hWnd, WM_SETFONT, | |
3646 | (WPARAM)m_windowFont.GetResourceHandle(),TRUE); | |
3647 | } | |
2bda0e17 KB |
3648 | } |
3649 | ||
3650 | void wxWindow::SubclassWin(WXHWND hWnd) | |
3651 | { | |
2d0a075d | 3652 | wxASSERT_MSG( !m_oldWndProc, "subclassing window twice?" ); |
a02eb1d2 | 3653 | |
2d0a075d | 3654 | wxAssociateWinWithHandle((HWND)hWnd, this); |
2bda0e17 | 3655 | |
2d0a075d JS |
3656 | m_oldWndProc = (WXFARPROC) GetWindowLong((HWND) hWnd, GWL_WNDPROC); |
3657 | SetWindowLong((HWND) hWnd, GWL_WNDPROC, (LONG) wxWndProc); | |
2bda0e17 KB |
3658 | } |
3659 | ||
fd3f686c | 3660 | void wxWindow::UnsubclassWin() |
2bda0e17 | 3661 | { |
564b2609 | 3662 | wxRemoveHandleAssociation(this); |
c085e333 | 3663 | |
2d0a075d JS |
3664 | // Restore old Window proc |
3665 | if ((HWND) GetHWND()) | |
564b2609 | 3666 | { |
2d0a075d JS |
3667 | FARPROC farProc = (FARPROC) GetWindowLong((HWND) GetHWND(), GWL_WNDPROC); |
3668 | if ((m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc)) | |
3669 | { | |
3670 | SetWindowLong((HWND) GetHWND(), GWL_WNDPROC, (LONG) m_oldWndProc); | |
3671 | m_oldWndProc = 0; | |
3672 | } | |
564b2609 | 3673 | } |
2bda0e17 KB |
3674 | } |
3675 | ||
3676 | // Make a Windows extended style from the given wxWindows window style | |
3677 | WXDWORD wxWindow::MakeExtendedStyle(long style, bool eliminateBorders) | |
3678 | { | |
564b2609 VZ |
3679 | WXDWORD exStyle = 0; |
3680 | if ( style & wxTRANSPARENT_WINDOW ) | |
3681 | exStyle |= WS_EX_TRANSPARENT ; | |
c085e333 | 3682 | |
2d0a075d JS |
3683 | if ( !eliminateBorders ) |
3684 | { | |
3685 | if ( style & wxSUNKEN_BORDER ) | |
3686 | exStyle |= WS_EX_CLIENTEDGE ; | |
3687 | if ( style & wxDOUBLE_BORDER ) | |
3688 | exStyle |= WS_EX_DLGMODALFRAME ; | |
2bda0e17 | 3689 | #if defined(__WIN95__) |
2d0a075d JS |
3690 | if ( style & wxRAISED_BORDER ) |
3691 | exStyle |= WS_EX_WINDOWEDGE ; | |
3692 | if ( style & wxSTATIC_BORDER ) | |
3693 | exStyle |= WS_EX_STATICEDGE ; | |
2bda0e17 | 3694 | #endif |
2d0a075d JS |
3695 | } |
3696 | return exStyle; | |
2bda0e17 KB |
3697 | } |
3698 | ||
3699 | // Determines whether native 3D effects or CTL3D should be used, | |
3700 | // applying a default border style if required, and returning an extended | |
3701 | // style to pass to CreateWindowEx. | |
3702 | WXDWORD wxWindow::Determine3DEffects(WXDWORD defaultBorderStyle, bool *want3D) | |
3703 | { | |
2d0a075d JS |
3704 | // If matches certain criteria, then assume no 3D effects |
3705 | // unless specifically requested (dealt with in MakeExtendedStyle) | |
3706 | if ( !GetParent() || !IsKindOf(CLASSINFO(wxControl)) || (m_windowStyle & wxNO_BORDER) ) | |
3707 | { | |
3708 | *want3D = FALSE; | |
3709 | return MakeExtendedStyle(m_windowStyle, FALSE); | |
3710 | } | |
2bda0e17 | 3711 | |
2d0a075d JS |
3712 | // Determine whether we should be using 3D effects or not. |
3713 | bool nativeBorder = FALSE; // by default, we don't want a Win95 effect | |
2bda0e17 | 3714 | |
2d0a075d JS |
3715 | // 1) App can specify global 3D effects |
3716 | *want3D = wxTheApp->GetAuto3D(); | |
2bda0e17 | 3717 | |
2d0a075d JS |
3718 | // 2) If the parent is being drawn with user colours, or simple border specified, |
3719 | // switch effects off. TODO: replace wxUSER_COLOURS with wxNO_3D | |
3720 | if (GetParent() && (GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS) || (m_windowStyle & wxSIMPLE_BORDER)) | |
3721 | *want3D = FALSE; | |
2bda0e17 | 3722 | |
2d0a075d JS |
3723 | // 3) Control can override this global setting by defining |
3724 | // a border style, e.g. wxSUNKEN_BORDER | |
3725 | if (m_windowStyle & wxSUNKEN_BORDER ) | |
3726 | *want3D = TRUE; | |
2bda0e17 | 3727 | |
2d0a075d JS |
3728 | // 4) If it's a special border, CTL3D can't cope so we want a native border |
3729 | if ( (m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || | |
3730 | (m_windowStyle & wxSTATIC_BORDER) ) | |
3731 | { | |
3732 | *want3D = TRUE; | |
3733 | nativeBorder = TRUE; | |
3734 | } | |
2bda0e17 | 3735 | |
2d0a075d JS |
3736 | // 5) If this isn't a Win95 app, and we are using CTL3D, remove border |
3737 | // effects from extended style | |
1f112209 | 3738 | #if wxUSE_CTL3D |
2d0a075d JS |
3739 | if ( *want3D ) |
3740 | nativeBorder = FALSE; | |
2bda0e17 | 3741 | #endif |
c085e333 | 3742 | |
2d0a075d | 3743 | DWORD exStyle = MakeExtendedStyle(m_windowStyle, !nativeBorder); |
2bda0e17 | 3744 | |
2d0a075d JS |
3745 | // If we want 3D, but haven't specified a border here, |
3746 | // apply the default border style specified. | |
3747 | // TODO what about non-Win95 WIN32? Does it have borders? | |
1f112209 | 3748 | #if defined(__WIN95__) && !wxUSE_CTL3D |
2d0a075d | 3749 | if (defaultBorderStyle && (*want3D) && ! ((m_windowStyle & wxDOUBLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || |
2bda0e17 | 3750 | (m_windowStyle & wxSTATIC_BORDER) || (m_windowStyle & wxSIMPLE_BORDER) )) |
2d0a075d | 3751 | exStyle |= defaultBorderStyle; // WS_EX_CLIENTEDGE ; |
2bda0e17 | 3752 | #endif |
c085e333 | 3753 | |
2d0a075d | 3754 | return exStyle; |
2bda0e17 KB |
3755 | } |
3756 | ||
2bda0e17 KB |
3757 | void wxWindow::OnChar(wxKeyEvent& event) |
3758 | { | |
47cbd6da VZ |
3759 | bool isVirtual; |
3760 | int id = wxCharCodeWXToMSW((int)event.KeyCode(), &isVirtual); | |
c085e333 | 3761 | |
47cbd6da VZ |
3762 | if ( id == -1 ) |
3763 | id= m_lastWParam; | |
c085e333 | 3764 | |
dbda9e86 | 3765 | if ( !event.ControlDown() ) // Why this test? |
47cbd6da | 3766 | (void) MSWDefWindowProc(m_lastMsg, (WPARAM) id, m_lastLParam); |
2bda0e17 KB |
3767 | } |
3768 | ||
dbdb39b2 JS |
3769 | void wxWindow::OnKeyDown(wxKeyEvent& event) |
3770 | { | |
3771 | Default(); | |
3772 | } | |
3773 | ||
3774 | void wxWindow::OnKeyUp(wxKeyEvent& event) | |
3775 | { | |
3776 | Default(); | |
3777 | } | |
3778 | ||
3779 | void wxWindow::OnPaint(wxPaintEvent& event) | |
3780 | { | |
3781 | Default(); | |
3782 | } | |
3783 | ||
2bda0e17 KB |
3784 | bool wxWindow::IsEnabled(void) const |
3785 | { | |
564b2609 | 3786 | return (::IsWindowEnabled((HWND) GetHWND()) != 0); |
2bda0e17 KB |
3787 | } |
3788 | ||
3789 | // Dialog support: override these and call | |
3790 | // base class members to add functionality | |
3791 | // that can't be done using validators. | |
3792 | // NOTE: these functions assume that controls | |
3793 | // are direct children of this window, not grandchildren | |
3794 | // or other levels of descendant. | |
3795 | ||
3796 | // Transfer values to controls. If returns FALSE, | |
3797 | // it's an application error (pops up a dialog) | |
fd3f686c | 3798 | bool wxWindow::TransferDataToWindow() |
2bda0e17 | 3799 | { |
c0ed460c | 3800 | wxNode *node = GetChildren().First(); |
564b2609 VZ |
3801 | while ( node ) |
3802 | { | |
3803 | wxWindow *child = (wxWindow *)node->Data(); | |
3804 | if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ | |
2d0a075d | 3805 | !child->GetValidator()->TransferToWindow() ) |
564b2609 | 3806 | { |
341c92a8 | 3807 | wxLogError(_("Could not transfer data to window")); |
564b2609 VZ |
3808 | return FALSE; |
3809 | } | |
c085e333 | 3810 | |
564b2609 VZ |
3811 | node = node->Next(); |
3812 | } | |
3813 | return TRUE; | |
2bda0e17 KB |
3814 | } |
3815 | ||
3816 | // Transfer values from controls. If returns FALSE, | |
3817 | // validation failed: don't quit | |
fd3f686c | 3818 | bool wxWindow::TransferDataFromWindow() |
2bda0e17 | 3819 | { |
c0ed460c | 3820 | wxNode *node = GetChildren().First(); |
564b2609 VZ |
3821 | while ( node ) |
3822 | { | |
3823 | wxWindow *child = (wxWindow *)node->Data(); | |
3824 | if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->TransferFromWindow() ) | |
3825 | { | |
3826 | return FALSE; | |
3827 | } | |
c085e333 | 3828 | |
564b2609 VZ |
3829 | node = node->Next(); |
3830 | } | |
3831 | return TRUE; | |
2bda0e17 KB |
3832 | } |
3833 | ||
fd3f686c | 3834 | bool wxWindow::Validate() |
2bda0e17 | 3835 | { |
c0ed460c | 3836 | wxNode *node = GetChildren().First(); |
564b2609 VZ |
3837 | while ( node ) |
3838 | { | |
3839 | wxWindow *child = (wxWindow *)node->Data(); | |
3840 | if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) ) | |
3841 | { | |
3842 | return FALSE; | |
3843 | } | |
c085e333 | 3844 | |
564b2609 VZ |
3845 | node = node->Next(); |
3846 | } | |
3847 | return TRUE; | |
2bda0e17 KB |
3848 | } |
3849 | ||
3850 | // Get the window with the focus | |
fd3f686c | 3851 | wxWindow *wxWindow::FindFocus() |
2bda0e17 KB |
3852 | { |
3853 | HWND hWnd = ::GetFocus(); | |
3854 | if ( hWnd ) | |
3855 | { | |
3856 | return wxFindWinFromHandle((WXHWND) hWnd); | |
3857 | } | |
3858 | return NULL; | |
3859 | } | |
3860 | ||
3861 | void wxWindow::AddChild(wxWindow *child) | |
3862 | { | |
c0ed460c | 3863 | GetChildren().Append(child); |
2d0a075d | 3864 | child->m_windowParent = this; |
2bda0e17 KB |
3865 | } |
3866 | ||
3867 | void wxWindow::RemoveChild(wxWindow *child) | |
3868 | { | |
c0ed460c JS |
3869 | // if (GetChildren()) |
3870 | GetChildren().DeleteObject(child); | |
2d0a075d | 3871 | child->m_windowParent = NULL; |
2bda0e17 KB |
3872 | } |
3873 | ||
fd3f686c | 3874 | void wxWindow::DestroyChildren() |
2bda0e17 | 3875 | { |
2d0a075d | 3876 | wxNode *node; |
c0ed460c | 3877 | while ((node = GetChildren().First()) != (wxNode *)NULL) { |
2d0a075d JS |
3878 | wxWindow *child; |
3879 | if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) { | |
3880 | delete child; | |
c0ed460c | 3881 | if ( GetChildren().Member(child) ) |
2d0a075d JS |
3882 | delete node; |
3883 | } | |
3884 | } /* while */ | |
2bda0e17 KB |
3885 | } |
3886 | ||
debe6624 | 3887 | void wxWindow::MakeModal(bool modal) |
2bda0e17 | 3888 | { |
2d0a075d JS |
3889 | // Disable all other windows |
3890 | if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) | |
2bda0e17 | 3891 | { |
2d0a075d JS |
3892 | wxNode *node = wxTopLevelWindows.First(); |
3893 | while (node) | |
3894 | { | |
3895 | wxWindow *win = (wxWindow *)node->Data(); | |
3896 | if (win != this) | |
3897 | win->Enable(!modal); | |
2bda0e17 | 3898 | |
2d0a075d JS |
3899 | node = node->Next(); |
3900 | } | |
2bda0e17 | 3901 | } |
2bda0e17 KB |
3902 | } |
3903 | ||
3904 | // If nothing defined for this, try the parent. | |
3905 | // E.g. we may be a button loaded from a resource, with no callback function | |
3906 | // defined. | |
3907 | void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event) | |
3908 | { | |
2d0a075d JS |
3909 | if (GetEventHandler()->ProcessEvent(event) ) |
3910 | return; | |
3911 | if (m_windowParent) | |
3912 | m_windowParent->GetEventHandler()->OnCommand(win, event); | |
2bda0e17 KB |
3913 | } |
3914 | ||
3915 | void wxWindow::SetConstraints(wxLayoutConstraints *c) | |
3916 | { | |
2d0a075d JS |
3917 | if (m_constraints) |
3918 | { | |
3919 | UnsetConstraints(m_constraints); | |
3920 | delete m_constraints; | |
3921 | } | |
3922 | m_constraints = c; | |
3923 | if (m_constraints) | |
3924 | { | |
3925 | // Make sure other windows know they're part of a 'meaningful relationship' | |
3926 | if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this)) | |
3927 | m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3928 | if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this)) | |
3929 | m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3930 | if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this)) | |
3931 | m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3932 | if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this)) | |
3933 | m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3934 | if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this)) | |
3935 | m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3936 | if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this)) | |
3937 | m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3938 | if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this)) | |
3939 | m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3940 | if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this)) | |
3941 | m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this); | |
3942 | } | |
2bda0e17 KB |
3943 | } |
3944 | ||
3945 | // This removes any dangling pointers to this window | |
3946 | // in other windows' constraintsInvolvedIn lists. | |
3947 | void wxWindow::UnsetConstraints(wxLayoutConstraints *c) | |
3948 | { | |
2d0a075d JS |
3949 | if (c) |
3950 | { | |
3951 | if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this)) | |
3952 | c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3953 | if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this)) | |
3954 | c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3955 | if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this)) | |
3956 | c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3957 | if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this)) | |
3958 | c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3959 | if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this)) | |
3960 | c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3961 | if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this)) | |
3962 | c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3963 | if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this)) | |
3964 | c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3965 | if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this)) | |
3966 | c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this); | |
3967 | } | |
2bda0e17 KB |
3968 | } |
3969 | ||
3970 | // Back-pointer to other windows we're involved with, so if we delete | |
3971 | // this window, we must delete any constraints we're involved with. | |
3972 | void wxWindow::AddConstraintReference(wxWindow *otherWin) | |
3973 | { | |
2d0a075d JS |
3974 | if (!m_constraintsInvolvedIn) |
3975 | m_constraintsInvolvedIn = new wxList; | |
3976 | if (!m_constraintsInvolvedIn->Member(otherWin)) | |
3977 | m_constraintsInvolvedIn->Append(otherWin); | |
2bda0e17 KB |
3978 | } |
3979 | ||
3980 | // REMOVE back-pointer to other windows we're involved with. | |
3981 | void wxWindow::RemoveConstraintReference(wxWindow *otherWin) | |
3982 | { | |
2d0a075d JS |
3983 | if (m_constraintsInvolvedIn) |
3984 | m_constraintsInvolvedIn->DeleteObject(otherWin); | |
2bda0e17 KB |
3985 | } |
3986 | ||
3987 | // Reset any constraints that mention this window | |
fd3f686c | 3988 | void wxWindow::DeleteRelatedConstraints() |
2bda0e17 | 3989 | { |
2d0a075d | 3990 | if (m_constraintsInvolvedIn) |
2bda0e17 | 3991 | { |
2d0a075d JS |
3992 | wxNode *node = m_constraintsInvolvedIn->First(); |
3993 | while (node) | |
3994 | { | |
3995 | wxWindow *win = (wxWindow *)node->Data(); | |
3996 | wxNode *next = node->Next(); | |
3997 | wxLayoutConstraints *constr = win->GetConstraints(); | |
3998 | ||
3999 | // Reset any constraints involving this window | |
4000 | if (constr) | |
4001 | { | |
4002 | constr->left.ResetIfWin((wxWindow *)this); | |
4003 | constr->top.ResetIfWin((wxWindow *)this); | |
4004 | constr->right.ResetIfWin((wxWindow *)this); | |
4005 | constr->bottom.ResetIfWin((wxWindow *)this); | |
4006 | constr->width.ResetIfWin((wxWindow *)this); | |
4007 | constr->height.ResetIfWin((wxWindow *)this); | |
4008 | constr->centreX.ResetIfWin((wxWindow *)this); | |
4009 | constr->centreY.ResetIfWin((wxWindow *)this); | |
4010 | } | |
4011 | delete node; | |
4012 | node = next; | |
4013 | } | |
4014 | delete m_constraintsInvolvedIn; | |
4015 | m_constraintsInvolvedIn = NULL; | |
2bda0e17 | 4016 | } |
2bda0e17 KB |
4017 | } |
4018 | ||
4019 | void wxWindow::SetSizer(wxSizer *sizer) | |
4020 | { | |
2d0a075d JS |
4021 | m_windowSizer = sizer; |
4022 | if (sizer) | |
4023 | sizer->SetSizerParent((wxWindow *)this); | |
2bda0e17 KB |
4024 | } |
4025 | ||
4026 | /* | |
2d0a075d JS |
4027 | * New version |
4028 | */ | |
2bda0e17 | 4029 | |
fd3f686c | 4030 | bool wxWindow::Layout() |
2bda0e17 | 4031 | { |
2d0a075d JS |
4032 | if (GetConstraints()) |
4033 | { | |
4034 | int w, h; | |
4035 | GetClientSize(&w, &h); | |
4036 | GetConstraints()->width.SetValue(w); | |
4037 | GetConstraints()->height.SetValue(h); | |
4038 | } | |
4039 | ||
4040 | // If top level (one sizer), evaluate the sizer's constraints. | |
4041 | if (GetSizer()) | |
4042 | { | |
4043 | int noChanges; | |
4044 | GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated | |
4045 | GetSizer()->LayoutPhase1(&noChanges); | |
4046 | GetSizer()->LayoutPhase2(&noChanges); | |
4047 | GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes | |
4048 | return TRUE; | |
4049 | } | |
4050 | else | |
4051 | { | |
4052 | // Otherwise, evaluate child constraints | |
4053 | ResetConstraints(); // Mark all constraints as unevaluated | |
4054 | DoPhase(1); // Just one phase need if no sizers involved | |
4055 | DoPhase(2); | |
4056 | SetConstraintSizes(); // Recursively set the real window sizes | |
4057 | } | |
2bda0e17 | 4058 | return TRUE; |
2bda0e17 KB |
4059 | } |
4060 | ||
4061 | ||
4062 | // Do a phase of evaluating constraints: | |
4063 | // the default behaviour. wxSizers may do a similar | |
4064 | // thing, but also impose their own 'constraints' | |
4065 | // and order the evaluation differently. | |
4066 | bool wxWindow::LayoutPhase1(int *noChanges) | |
4067 | { | |
2d0a075d JS |
4068 | wxLayoutConstraints *constr = GetConstraints(); |
4069 | if (constr) | |
4070 | { | |
4071 | return constr->SatisfyConstraints((wxWindow *)this, noChanges); | |
4072 | } | |
4073 | else | |
4074 | return TRUE; | |
2bda0e17 KB |
4075 | } |
4076 | ||
4077 | bool wxWindow::LayoutPhase2(int *noChanges) | |
4078 | { | |
2d0a075d JS |
4079 | *noChanges = 0; |
4080 | ||
4081 | // Layout children | |
4082 | DoPhase(1); | |
4083 | DoPhase(2); | |
4084 | return TRUE; | |
2bda0e17 KB |
4085 | } |
4086 | ||
4087 | // Do a phase of evaluating child constraints | |
debe6624 | 4088 | bool wxWindow::DoPhase(int phase) |
2bda0e17 | 4089 | { |
2d0a075d JS |
4090 | int noIterations = 0; |
4091 | int maxIterations = 500; | |
4092 | int noChanges = 1; | |
4093 | int noFailures = 0; | |
4094 | wxList succeeded; | |
4095 | while ((noChanges > 0) && (noIterations < maxIterations)) | |
2bda0e17 | 4096 | { |
2d0a075d JS |
4097 | noChanges = 0; |
4098 | noFailures = 0; | |
c0ed460c | 4099 | wxNode *node = GetChildren().First(); |
2d0a075d | 4100 | while (node) |
2bda0e17 | 4101 | { |
2d0a075d JS |
4102 | wxWindow *child = (wxWindow *)node->Data(); |
4103 | if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog))) | |
2bda0e17 | 4104 | { |
2d0a075d JS |
4105 | wxLayoutConstraints *constr = child->GetConstraints(); |
4106 | if (constr) | |
4107 | { | |
4108 | if (succeeded.Member(child)) | |
4109 | { | |
4110 | } | |
4111 | else | |
4112 | { | |
4113 | int tempNoChanges = 0; | |
4114 | bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ; | |
4115 | noChanges += tempNoChanges; | |
4116 | if (success) | |
4117 | { | |
4118 | succeeded.Append(child); | |
4119 | } | |
4120 | } | |
4121 | } | |
2bda0e17 | 4122 | } |
2d0a075d | 4123 | node = node->Next(); |
2bda0e17 | 4124 | } |
2d0a075d | 4125 | noIterations ++; |
2bda0e17 | 4126 | } |
2d0a075d | 4127 | return TRUE; |
2bda0e17 KB |
4128 | } |
4129 | ||
fd3f686c | 4130 | void wxWindow::ResetConstraints() |
2bda0e17 | 4131 | { |
2d0a075d JS |
4132 | wxLayoutConstraints *constr = GetConstraints(); |
4133 | if (constr) | |
4134 | { | |
4135 | constr->left.SetDone(FALSE); | |
4136 | constr->top.SetDone(FALSE); | |
4137 | constr->right.SetDone(FALSE); | |
4138 | constr->bottom.SetDone(FALSE); | |
4139 | constr->width.SetDone(FALSE); | |
4140 | constr->height.SetDone(FALSE); | |
4141 | constr->centreX.SetDone(FALSE); | |
4142 | constr->centreY.SetDone(FALSE); | |
4143 | } | |
c0ed460c | 4144 | wxNode *node = GetChildren().First(); |
2d0a075d JS |
4145 | while (node) |
4146 | { | |
4147 | wxWindow *win = (wxWindow *)node->Data(); | |
4148 | if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) | |
4149 | win->ResetConstraints(); | |
4150 | node = node->Next(); | |
4151 | } | |
2bda0e17 KB |
4152 | } |
4153 | ||
4154 | // Need to distinguish between setting the 'fake' size for | |
4155 | // windows and sizers, and setting the real values. | |
debe6624 | 4156 | void wxWindow::SetConstraintSizes(bool recurse) |
2bda0e17 | 4157 | { |
2d0a075d JS |
4158 | wxLayoutConstraints *constr = GetConstraints(); |
4159 | if (constr && constr->left.GetDone() && constr->right.GetDone() && | |
4160 | constr->width.GetDone() && constr->height.GetDone()) | |
2bda0e17 | 4161 | { |
2d0a075d JS |
4162 | int x = constr->left.GetValue(); |
4163 | int y = constr->top.GetValue(); | |
4164 | int w = constr->width.GetValue(); | |
4165 | int h = constr->height.GetValue(); | |
4166 | ||
4167 | // If we don't want to resize this window, just move it... | |
4168 | if ((constr->width.GetRelationship() != wxAsIs) || | |
4169 | (constr->height.GetRelationship() != wxAsIs)) | |
4170 | { | |
4171 | // Calls Layout() recursively. AAAGH. How can we stop that. | |
4172 | // Simply take Layout() out of non-top level OnSizes. | |
4173 | SizerSetSize(x, y, w, h); | |
4174 | } | |
4175 | else | |
4176 | { | |
4177 | SizerMove(x, y); | |
4178 | } | |
2bda0e17 | 4179 | } |
2d0a075d | 4180 | else if (constr) |
2bda0e17 | 4181 | { |
2d0a075d | 4182 | char *windowClass = this->GetClassInfo()->GetClassName(); |
2bda0e17 | 4183 | |
2d0a075d JS |
4184 | wxString winName; |
4185 | if (GetName() == "") | |
4186 | winName = "unnamed"; | |
4187 | else | |
4188 | winName = GetName(); | |
341c92a8 VZ |
4189 | wxLogDebug("Constraint(s) not satisfied for window of type %s, name %s:", |
4190 | (const char *)windowClass, (const char *)winName); | |
2d0a075d | 4191 | if (!constr->left.GetDone()) |
341c92a8 | 4192 | wxLogDebug(" unsatisfied 'left' constraint."); |
2d0a075d | 4193 | if (!constr->right.GetDone()) |
341c92a8 | 4194 | wxLogDebug(" unsatisfied 'right' constraint."); |
2d0a075d | 4195 | if (!constr->width.GetDone()) |
341c92a8 | 4196 | wxLogDebug(" unsatisfied 'width' constraint."); |
2d0a075d | 4197 | if (!constr->height.GetDone()) |
341c92a8 VZ |
4198 | wxLogDebug(" unsatisfied 'height' constraint."); |
4199 | wxLogDebug("Please check constraints: try adding AsIs() constraints.\n"); | |
2d0a075d | 4200 | } |
2bda0e17 | 4201 | |
2d0a075d | 4202 | if (recurse) |
2bda0e17 | 4203 | { |
c0ed460c | 4204 | wxNode *node = GetChildren().First(); |
2d0a075d JS |
4205 | while (node) |
4206 | { | |
4207 | wxWindow *win = (wxWindow *)node->Data(); | |
4208 | if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog))) | |
4209 | win->SetConstraintSizes(); | |
4210 | node = node->Next(); | |
4211 | } | |
2bda0e17 | 4212 | } |
2bda0e17 KB |
4213 | } |
4214 | ||
4215 | // This assumes that all sizers are 'on' the same | |
4216 | // window, i.e. the parent of this window. | |
4217 | void wxWindow::TransformSizerToActual(int *x, int *y) const | |
4218 | { | |
2d0a075d JS |
4219 | if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) || |
4220 | m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) ) | |
4221 | return; | |
4222 | ||
4223 | int xp, yp; | |
4224 | m_sizerParent->GetPosition(&xp, &yp); | |
4225 | m_sizerParent->TransformSizerToActual(&xp, &yp); | |
4226 | *x += xp; | |
4227 | *y += yp; | |
2bda0e17 KB |
4228 | } |
4229 | ||
debe6624 | 4230 | void wxWindow::SizerSetSize(int x, int y, int w, int h) |
2bda0e17 | 4231 | { |
564b2609 VZ |
4232 | int xx = x; |
4233 | int yy = y; | |
2d0a075d JS |
4234 | TransformSizerToActual(&xx, &yy); |
4235 | SetSize(xx, yy, w, h); | |
2bda0e17 KB |
4236 | } |
4237 | ||
debe6624 | 4238 | void wxWindow::SizerMove(int x, int y) |
2bda0e17 | 4239 | { |
564b2609 VZ |
4240 | int xx = x; |
4241 | int yy = y; | |
2d0a075d JS |
4242 | TransformSizerToActual(&xx, &yy); |
4243 | Move(xx, yy); | |
2bda0e17 KB |
4244 | } |
4245 | ||
4246 | // Only set the size/position of the constraint (if any) | |
debe6624 | 4247 | void wxWindow::SetSizeConstraint(int x, int y, int w, int h) |
2bda0e17 | 4248 | { |
2d0a075d JS |
4249 | wxLayoutConstraints *constr = GetConstraints(); |
4250 | if (constr) | |
2bda0e17 | 4251 | { |
2d0a075d JS |
4252 | if (x != -1) |
4253 | { | |
4254 | constr->left.SetValue(x); | |
4255 | constr->left.SetDone(TRUE); | |
4256 | } | |
4257 | if (y != -1) | |
4258 | { | |
4259 | constr->top.SetValue(y); | |
4260 | constr->top.SetDone(TRUE); | |
4261 | } | |
4262 | if (w != -1) | |
4263 | { | |
4264 | constr->width.SetValue(w); | |
4265 | constr->width.SetDone(TRUE); | |
4266 | } | |
4267 | if (h != -1) | |
4268 | { | |
4269 | constr->height.SetValue(h); | |
4270 | constr->height.SetDone(TRUE); | |
4271 | } | |
2bda0e17 | 4272 | } |
2bda0e17 KB |
4273 | } |
4274 | ||
debe6624 | 4275 | void wxWindow::MoveConstraint(int x, int y) |
2bda0e17 | 4276 | { |
2d0a075d JS |
4277 | wxLayoutConstraints *constr = GetConstraints(); |
4278 | if (constr) | |
2bda0e17 | 4279 | { |
2d0a075d JS |
4280 | if (x != -1) |
4281 | { | |
4282 | constr->left.SetValue(x); | |
4283 | constr->left.SetDone(TRUE); | |
4284 | } | |
4285 | if (y != -1) | |
4286 | { | |
4287 | constr->top.SetValue(y); | |
4288 | constr->top.SetDone(TRUE); | |
4289 | } | |
2bda0e17 | 4290 | } |
2bda0e17 KB |
4291 | } |
4292 | ||
4293 | void wxWindow::GetSizeConstraint(int *w, int *h) const | |
4294 | { | |
2d0a075d JS |
4295 | wxLayoutConstraints *constr = GetConstraints(); |
4296 | if (constr) | |
4297 | { | |
4298 | *w = constr->width.GetValue(); | |
4299 | *h = constr->height.GetValue(); | |
4300 | } | |
4301 | else | |
4302 | GetSize(w, h); | |
2bda0e17 KB |
4303 | } |
4304 | ||
4305 | void wxWindow::GetClientSizeConstraint(int *w, int *h) const | |
4306 | { | |
2d0a075d JS |
4307 | wxLayoutConstraints *constr = GetConstraints(); |
4308 | if (constr) | |
4309 | { | |
4310 | *w = constr->width.GetValue(); | |
4311 | *h = constr->height.GetValue(); | |
4312 | } | |
4313 | else | |
4314 | GetClientSize(w, h); | |
2bda0e17 KB |
4315 | } |
4316 | ||
4317 | void wxWindow::GetPositionConstraint(int *x, int *y) const | |
4318 | { | |
2d0a075d JS |
4319 | wxLayoutConstraints *constr = GetConstraints(); |
4320 | if (constr) | |
4321 | { | |
4322 | *x = constr->left.GetValue(); | |
4323 | *y = constr->top.GetValue(); | |
4324 | } | |
4325 | else | |
4326 | GetPosition(x, y); | |
2bda0e17 KB |
4327 | } |
4328 | ||
debe6624 | 4329 | bool wxWindow::Close(bool force) |
2bda0e17 | 4330 | { |
2d0a075d JS |
4331 | wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId); |
4332 | event.SetEventObject(this); | |
e3065973 | 4333 | #if WXWIN_COMPATIBILITY |
2d0a075d | 4334 | event.SetForce(force); |
e3065973 | 4335 | #endif |
2d0a075d | 4336 | event.SetCanVeto(!force); |
2bda0e17 | 4337 | |
2d0a075d | 4338 | return (GetEventHandler()->ProcessEvent(event) && !event.GetVeto()); |
2bda0e17 KB |
4339 | } |
4340 | ||
debe6624 | 4341 | wxObject* wxWindow::GetChild(int number) const |
2bda0e17 | 4342 | { |
2d0a075d | 4343 | // Return a pointer to the Nth object in the Panel |
c0ed460c JS |
4344 | // if (!GetChildren()) |
4345 | // return(NULL) ; | |
4346 | wxNode *node = GetChildren().First(); | |
2d0a075d JS |
4347 | int n = number; |
4348 | while (node && n--) | |
4349 | node = node->Next() ; | |
4350 | if (node) | |
4351 | { | |
4352 | wxObject *obj = (wxObject *)node->Data(); | |
4353 | return(obj) ; | |
4354 | } | |
4355 | else | |
4356 | return NULL ; | |
2bda0e17 KB |
4357 | } |
4358 | ||
4359 | void wxWindow::OnDefaultAction(wxControl *initiatingItem) | |
4360 | { | |
debe6624 | 4361 | /* This is obsolete now; if we wish to intercept listbox double-clicks, |
2d0a075d JS |
4362 | * we explicitly intercept the wxEVT_COMMAND_LISTBOX_DOUBLECLICKED |
4363 | * event. | |
debe6624 JS |
4364 | |
4365 | if (initiatingItem->IsKindOf(CLASSINFO(wxListBox))) | |
2bda0e17 | 4366 | { |
2d0a075d JS |
4367 | wxListBox *lbox = (wxListBox *)initiatingItem; |
4368 | wxCommandEvent event(wxEVT_COMMAND_LEFT_DCLICK); | |
4369 | event.m_commandInt = -1; | |
4370 | if ((lbox->GetWindowStyleFlag() & wxLB_MULTIPLE) == 0) | |
2bda0e17 | 4371 | { |
2d0a075d JS |
4372 | event.m_commandString = copystring(lbox->GetStringSelection()); |
4373 | event.m_commandInt = lbox->GetSelection(); | |
4374 | event.m_clientData = lbox->wxListBox::GetClientData(event.m_commandInt); | |
2bda0e17 | 4375 | } |
2d0a075d | 4376 | event.m_eventObject = lbox; |
c085e333 | 4377 | |
2d0a075d | 4378 | lbox->ProcessCommand(event); |
c085e333 | 4379 | |
2d0a075d JS |
4380 | if (event.m_commandString) |
4381 | delete[] event.m_commandString; | |
4382 | return; | |
4383 | } | |
4384 | ||
4385 | wxButton *but = GetDefaultItem(); | |
4386 | if (but) | |
4387 | { | |
4388 | wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED); | |
4389 | event.SetEventObject(but); | |
4390 | but->Command(event); | |
4391 | } | |
4392 | */ | |
2bda0e17 KB |
4393 | } |
4394 | ||
fd3f686c | 4395 | void wxWindow::Clear() |
2bda0e17 | 4396 | { |
564b2609 | 4397 | wxClientDC dc(this); |
2bda0e17 KB |
4398 | wxBrush brush(GetBackgroundColour(), wxSOLID); |
4399 | dc.SetBackground(brush); | |
4400 | dc.Clear(); | |
4401 | } | |
4402 | ||
4403 | // Fits the panel around the items | |
fd3f686c | 4404 | void wxWindow::Fit() |
2bda0e17 | 4405 | { |
564b2609 VZ |
4406 | int maxX = 0; |
4407 | int maxY = 0; | |
c0ed460c | 4408 | wxNode *node = GetChildren().First(); |
564b2609 VZ |
4409 | while ( node ) |
4410 | { | |
4411 | wxWindow *win = (wxWindow *)node->Data(); | |
4412 | int wx, wy, ww, wh; | |
4413 | win->GetPosition(&wx, &wy); | |
4414 | win->GetSize(&ww, &wh); | |
4415 | if ( wx + ww > maxX ) | |
4416 | maxX = wx + ww; | |
4417 | if ( wy + wh > maxY ) | |
4418 | maxY = wy + wh; | |
c085e333 | 4419 | |
564b2609 VZ |
4420 | node = node->Next(); |
4421 | } | |
4422 | SetClientSize(maxX + 5, maxY + 5); | |
2bda0e17 KB |
4423 | } |
4424 | ||
4425 | void wxWindow::SetValidator(const wxValidator& validator) | |
4426 | { | |
564b2609 VZ |
4427 | if ( m_windowValidator ) |
4428 | delete m_windowValidator; | |
4429 | m_windowValidator = validator.Clone(); | |
c085e333 | 4430 | |
564b2609 VZ |
4431 | if ( m_windowValidator ) |
4432 | m_windowValidator->SetWindow(this) ; | |
2bda0e17 KB |
4433 | } |
4434 | ||
4435 | // Find a window by id or name | |
debe6624 | 4436 | wxWindow *wxWindow::FindWindow(long id) |
2bda0e17 | 4437 | { |
564b2609 VZ |
4438 | if ( GetId() == id) |
4439 | return this; | |
c085e333 | 4440 | |
c0ed460c | 4441 | wxNode *node = GetChildren().First(); |
564b2609 VZ |
4442 | while ( node ) |
4443 | { | |
4444 | wxWindow *child = (wxWindow *)node->Data(); | |
4445 | wxWindow *found = child->FindWindow(id); | |
4446 | if ( found ) | |
4447 | return found; | |
4448 | node = node->Next(); | |
4449 | } | |
4450 | return NULL; | |
2bda0e17 KB |
4451 | } |
4452 | ||
4453 | wxWindow *wxWindow::FindWindow(const wxString& name) | |
4454 | { | |
564b2609 VZ |
4455 | if ( GetName() == name) |
4456 | return this; | |
c085e333 | 4457 | |
c0ed460c | 4458 | wxNode *node = GetChildren().First(); |
564b2609 VZ |
4459 | while ( node ) |
4460 | { | |
4461 | wxWindow *child = (wxWindow *)node->Data(); | |
4462 | wxWindow *found = child->FindWindow(name); | |
4463 | if ( found ) | |
4464 | return found; | |
4465 | node = node->Next(); | |
4466 | } | |
4467 | return NULL; | |
2bda0e17 KB |
4468 | } |
4469 | ||
4470 | /* TODO | |
4471 | // Default input behaviour for a scrolling canvas should be to scroll | |
4472 | // according to the cursor keys pressed | |
4473 | void wxWindow::OnChar(wxKeyEvent& event) | |
4474 | { | |
2d0a075d JS |
4475 | int x_page = 0; |
4476 | int y_page = 0; | |
4477 | int start_x = 0; | |
4478 | int start_y = 0; | |
4479 | // Bugfix Begin | |
4480 | int v_width = 0; | |
4481 | int v_height = 0; | |
4482 | int y_pages = 0; | |
4483 | // Bugfix End | |
2bda0e17 KB |
4484 | |
4485 | GetScrollUnitsPerPage(&x_page, &y_page); | |
4486 | // Bugfix Begin | |
4487 | GetVirtualSize(&v_width,&v_height); | |
4488 | // Bugfix End | |
4489 | ViewStart(&start_x, &start_y); | |
4490 | // Bugfix begin | |
4491 | if (vert_units) | |
2d0a075d | 4492 | y_pages = (int)(v_height/vert_units) - y_page; |
c085e333 | 4493 | |
2d0a075d JS |
4494 | #ifdef __WXMSW__ |
4495 | int y = 0; | |
4496 | #else | |
4497 | int y = y_page-1; | |
4498 | #endif | |
4499 | // Bugfix End | |
4500 | switch (event.keyCode) | |
4501 | { | |
4502 | case WXK_PRIOR: | |
4503 | { | |
4504 | // BugFix Begin | |
4505 | if (y_page > 0) | |
4506 | { | |
4507 | if (start_y - y_page > 0) | |
4508 | Scroll(start_x, start_y - y_page); | |
4509 | else | |
4510 | Scroll(start_x, 0); | |
4511 | } | |
4512 | // Bugfix End | |
4513 | break; | |
4514 | } | |
4515 | case WXK_NEXT: | |
4516 | { | |
4517 | // Bugfix Begin | |
4518 | if ((y_page > 0) && (start_y <= y_pages-y-1)) | |
4519 | { | |
4520 | if (y_pages + y < start_y + y_page) | |
4521 | Scroll(start_x, y_pages + y); | |
4522 | else | |
4523 | Scroll(start_x, start_y + y_page); | |
4524 | } | |
4525 | // Bugfix End | |
4526 | break; | |
4527 | } | |
4528 | case WXK_UP: | |
4529 | { | |
4530 | if ((y_page > 0) && (start_y >= 1)) | |
4531 | Scroll(start_x, start_y - 1); | |
4532 | break; | |
4533 | } | |
4534 | case WXK_DOWN: | |
4535 | { | |
4536 | // Bugfix Begin | |
4537 | if ((y_page > 0) && (start_y <= y_pages-y-1)) | |
4538 | // Bugfix End | |
4539 | { | |
4540 | Scroll(start_x, start_y + 1); | |
4541 | } | |
4542 | break; | |
4543 | } | |
4544 | case WXK_LEFT: | |
4545 | { | |
4546 | if ((x_page > 0) && (start_x >= 1)) | |
4547 | Scroll(start_x - 1, start_y); | |
4548 | break; | |
4549 | } | |
4550 | case WXK_RIGHT: | |
4551 | { | |
4552 | if (x_page > 0) | |
4553 | Scroll(start_x + 1, start_y); | |
4554 | break; | |
4555 | } | |
4556 | case WXK_HOME: | |
4557 | { | |
4558 | Scroll(0, 0); | |
4559 | break; | |
4560 | } | |
4561 | // This is new | |
4562 | case WXK_END: | |
4563 | { | |
4564 | Scroll(start_x, y_pages+y); | |
4565 | break; | |
4566 | } | |
4567 | // end | |
4568 | } | |
4569 | } | |
2bda0e17 KB |
4570 | */ |
4571 | ||
4572 | // Setup background and foreground colours correctly | |
fd3f686c | 4573 | void wxWindow::SetupColours() |
2bda0e17 | 4574 | { |
564b2609 VZ |
4575 | if (GetParent()) |
4576 | SetBackgroundColour(GetParent()->GetBackgroundColour()); | |
2bda0e17 KB |
4577 | } |
4578 | ||
2bda0e17 KB |
4579 | void wxWindow::OnIdle(wxIdleEvent& event) |
4580 | { | |
43d811ea JS |
4581 | // Check if we need to send a LEAVE event |
4582 | if (m_mouseInWindow) | |
4583 | { | |
4584 | POINT pt; | |
4585 | ::GetCursorPos(&pt); | |
4586 | if (::WindowFromPoint(pt) != (HWND) GetHWND()) | |
4587 | { | |
4588 | // Generate a LEAVE event | |
4589 | m_mouseInWindow = FALSE; | |
c085e333 | 4590 | |
2d524929 | 4591 | int state = 0; |
567da5c6 JS |
4592 | if (::GetKeyState(VK_SHIFT) != 0) |
4593 | state |= MK_SHIFT; | |
4594 | if (::GetKeyState(VK_CONTROL) != 0) | |
4595 | state |= MK_CONTROL; | |
c085e333 | 4596 | |
567da5c6 JS |
4597 | // Unfortunately the mouse button and keyboard state may have changed |
4598 | // by the time the OnIdle function is called, so 'state' may be | |
4599 | // meaningless. | |
c085e333 | 4600 | |
567da5c6 | 4601 | MSWOnMouseLeave(pt.x, pt.y, state); |
43d811ea JS |
4602 | } |
4603 | } | |
564b2609 | 4604 | UpdateWindowUI(); |
2bda0e17 KB |
4605 | } |
4606 | ||
4607 | // Raise the window to the top of the Z order | |
fd3f686c | 4608 | void wxWindow::Raise() |
2bda0e17 KB |
4609 | { |
4610 | ::BringWindowToTop((HWND) GetHWND()); | |
4611 | } | |
4612 | ||
4613 | // Lower the window to the bottom of the Z order | |
fd3f686c | 4614 | void wxWindow::Lower() |
2bda0e17 KB |
4615 | { |
4616 | ::SetWindowPos((HWND) GetHWND(), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE); | |
4617 | } | |
4618 | ||
47cbd6da VZ |
4619 | long wxWindow::MSWGetDlgCode() |
4620 | { | |
2d0a075d JS |
4621 | // default: just forward to def window proc (the msg has no parameters) |
4622 | return MSWDefWindowProc(WM_GETDLGCODE, 0, 0); | |
47cbd6da VZ |
4623 | } |
4624 | ||
4625 | bool wxWindow::AcceptsFocus() const | |
4626 | { | |
3a19e16d | 4627 | // invisible and disabled controls don't need focus |
2d0a075d | 4628 | return IsShown() && IsEnabled(); |
47cbd6da VZ |
4629 | } |
4630 | ||
81d66cf3 JS |
4631 | // Update region access |
4632 | wxRegion wxWindow::GetUpdateRegion() const | |
4633 | { | |
4634 | return m_updateRegion; | |
4635 | } | |
4636 | ||
4637 | bool wxWindow::IsExposed(int x, int y, int w, int h) const | |
4638 | { | |
4639 | return (m_updateRegion.Contains(x, y, w, h) != wxOutRegion); | |
4640 | } | |
4641 | ||
4642 | bool wxWindow::IsExposed(const wxPoint& pt) const | |
4643 | { | |
4644 | return (m_updateRegion.Contains(pt) != wxOutRegion); | |
4645 | } | |
4646 | ||
4647 | bool wxWindow::IsExposed(const wxRect& rect) const | |
4648 | { | |
4649 | return (m_updateRegion.Contains(rect) != wxOutRegion); | |
4650 | } | |
4651 | ||
4fabb575 JS |
4652 | // Set this window to be the child of 'parent'. |
4653 | bool wxWindow::Reparent(wxWindow *parent) | |
4654 | { | |
4655 | if (parent == GetParent()) | |
4656 | return TRUE; | |
4657 | ||
4658 | // Unlink this window from the existing parent. | |
4659 | if (GetParent()) | |
4660 | { | |
4661 | GetParent()->RemoveChild(this); | |
4662 | } | |
4663 | else | |
4664 | wxTopLevelWindows.DeleteObject(this); | |
4665 | ||
4666 | HWND hWndParent = 0; | |
4667 | HWND hWndChild = (HWND) GetHWND(); | |
4668 | if (parent != (wxWindow*) NULL) | |
4669 | { | |
4670 | parent->AddChild(this); | |
4671 | hWndParent = (HWND) parent->GetHWND(); | |
4672 | } | |
4673 | else | |
4674 | wxTopLevelWindows.Append(this); | |
4675 | ||
4676 | ::SetParent(hWndChild, hWndParent); | |
4677 | ||
4678 | return TRUE; | |
4679 | } | |
4680 | ||
b2aef89b | 4681 | #ifdef __WXDEBUG__ |
f449ef69 | 4682 | const char *wxGetMessageName(int message) |
47cbd6da | 4683 | { |
2d0a075d | 4684 | switch ( message ) { |
47cbd6da VZ |
4685 | case 0x0000: return "WM_NULL"; |
4686 | case 0x0001: return "WM_CREATE"; | |
4687 | case 0x0002: return "WM_DESTROY"; | |
4688 | case 0x0003: return "WM_MOVE"; | |
4689 | case 0x0005: return "WM_SIZE"; | |
4690 | case 0x0006: return "WM_ACTIVATE"; | |
4691 | case 0x0007: return "WM_SETFOCUS"; | |
4692 | case 0x0008: return "WM_KILLFOCUS"; | |
4693 | case 0x000A: return "WM_ENABLE"; | |
4694 | case 0x000B: return "WM_SETREDRAW"; | |
4695 | case 0x000C: return "WM_SETTEXT"; | |
4696 | case 0x000D: return "WM_GETTEXT"; | |
4697 | case 0x000E: return "WM_GETTEXTLENGTH"; | |
4698 | case 0x000F: return "WM_PAINT"; | |
4699 | case 0x0010: return "WM_CLOSE"; | |
4700 | case 0x0011: return "WM_QUERYENDSESSION"; | |
4701 | case 0x0012: return "WM_QUIT"; | |
4702 | case 0x0013: return "WM_QUERYOPEN"; | |
4703 | case 0x0014: return "WM_ERASEBKGND"; | |
4704 | case 0x0015: return "WM_SYSCOLORCHANGE"; | |
4705 | case 0x0016: return "WM_ENDSESSION"; | |
4706 | case 0x0017: return "WM_SYSTEMERROR"; | |
4707 | case 0x0018: return "WM_SHOWWINDOW"; | |
4708 | case 0x0019: return "WM_CTLCOLOR"; | |
4709 | case 0x001A: return "WM_WININICHANGE"; | |
4710 | case 0x001B: return "WM_DEVMODECHANGE"; | |
4711 | case 0x001C: return "WM_ACTIVATEAPP"; | |
4712 | case 0x001D: return "WM_FONTCHANGE"; | |
4713 | case 0x001E: return "WM_TIMECHANGE"; | |
4714 | case 0x001F: return "WM_CANCELMODE"; | |
4715 | case 0x0020: return "WM_SETCURSOR"; | |
4716 | case 0x0021: return "WM_MOUSEACTIVATE"; | |
4717 | case 0x0022: return "WM_CHILDACTIVATE"; | |
4718 | case 0x0023: return "WM_QUEUESYNC"; | |
4719 | case 0x0024: return "WM_GETMINMAXINFO"; | |
4720 | case 0x0026: return "WM_PAINTICON"; | |
4721 | case 0x0027: return "WM_ICONERASEBKGND"; | |
4722 | case 0x0028: return "WM_NEXTDLGCTL"; | |
4723 | case 0x002A: return "WM_SPOOLERSTATUS"; | |
4724 | case 0x002B: return "WM_DRAWITEM"; | |
4725 | case 0x002C: return "WM_MEASUREITEM"; | |
4726 | case 0x002D: return "WM_DELETEITEM"; | |
4727 | case 0x002E: return "WM_VKEYTOITEM"; | |
4728 | case 0x002F: return "WM_CHARTOITEM"; | |
4729 | case 0x0030: return "WM_SETFONT"; | |
4730 | case 0x0031: return "WM_GETFONT"; | |
4731 | case 0x0037: return "WM_QUERYDRAGICON"; | |
4732 | case 0x0039: return "WM_COMPAREITEM"; | |
4733 | case 0x0041: return "WM_COMPACTING"; | |
4734 | case 0x0044: return "WM_COMMNOTIFY"; | |
4735 | case 0x0046: return "WM_WINDOWPOSCHANGING"; | |
4736 | case 0x0047: return "WM_WINDOWPOSCHANGED"; | |
4737 | case 0x0048: return "WM_POWER"; | |
c085e333 | 4738 | |
a02eb1d2 VZ |
4739 | #ifdef __WIN32__ |
4740 | case 0x004A: return "WM_COPYDATA"; | |
4741 | case 0x004B: return "WM_CANCELJOURNAL"; | |
4742 | case 0x004E: return "WM_NOTIFY"; | |
4743 | case 0x0050: return "WM_INPUTLANGCHANGEREQUEST"; | |
4744 | case 0x0051: return "WM_INPUTLANGCHANGE"; | |
4745 | case 0x0052: return "WM_TCARD"; | |
4746 | case 0x0053: return "WM_HELP"; | |
4747 | case 0x0054: return "WM_USERCHANGED"; | |
4748 | case 0x0055: return "WM_NOTIFYFORMAT"; | |
4749 | case 0x007B: return "WM_CONTEXTMENU"; | |
4750 | case 0x007C: return "WM_STYLECHANGING"; | |
4751 | case 0x007D: return "WM_STYLECHANGED"; | |
4752 | case 0x007E: return "WM_DISPLAYCHANGE"; | |
4753 | case 0x007F: return "WM_GETICON"; | |
4754 | case 0x0080: return "WM_SETICON"; | |
4755 | #endif //WIN32 | |
c085e333 | 4756 | |
47cbd6da VZ |
4757 | case 0x0081: return "WM_NCCREATE"; |
4758 | case 0x0082: return "WM_NCDESTROY"; | |
4759 | case 0x0083: return "WM_NCCALCSIZE"; | |
4760 | case 0x0084: return "WM_NCHITTEST"; | |
4761 | case 0x0085: return "WM_NCPAINT"; | |
4762 | case 0x0086: return "WM_NCACTIVATE"; | |
4763 | case 0x0087: return "WM_GETDLGCODE"; | |
4764 | case 0x00A0: return "WM_NCMOUSEMOVE"; | |
4765 | case 0x00A1: return "WM_NCLBUTTONDOWN"; | |
4766 | case 0x00A2: return "WM_NCLBUTTONUP"; | |
4767 | case 0x00A3: return "WM_NCLBUTTONDBLCLK"; | |
4768 | case 0x00A4: return "WM_NCRBUTTONDOWN"; | |
4769 | case 0x00A5: return "WM_NCRBUTTONUP"; | |
4770 | case 0x00A6: return "WM_NCRBUTTONDBLCLK"; | |
4771 | case 0x00A7: return "WM_NCMBUTTONDOWN"; | |
4772 | case 0x00A8: return "WM_NCMBUTTONUP"; | |
4773 | case 0x00A9: return "WM_NCMBUTTONDBLCLK"; | |
4774 | case 0x0100: return "WM_KEYDOWN"; | |
4775 | case 0x0101: return "WM_KEYUP"; | |
4776 | case 0x0102: return "WM_CHAR"; | |
4777 | case 0x0103: return "WM_DEADCHAR"; | |
4778 | case 0x0104: return "WM_SYSKEYDOWN"; | |
4779 | case 0x0105: return "WM_SYSKEYUP"; | |
4780 | case 0x0106: return "WM_SYSCHAR"; | |
4781 | case 0x0107: return "WM_SYSDEADCHAR"; | |
4782 | case 0x0108: return "WM_KEYLAST"; | |
c085e333 | 4783 | |
a02eb1d2 VZ |
4784 | #ifdef __WIN32__ |
4785 | case 0x010D: return "WM_IME_STARTCOMPOSITION"; | |
4786 | case 0x010E: return "WM_IME_ENDCOMPOSITION"; | |
4787 | case 0x010F: return "WM_IME_COMPOSITION"; | |
4788 | #endif //WIN32 | |
c085e333 | 4789 | |
47cbd6da VZ |
4790 | case 0x0110: return "WM_INITDIALOG"; |
4791 | case 0x0111: return "WM_COMMAND"; | |
4792 | case 0x0112: return "WM_SYSCOMMAND"; | |
4793 | case 0x0113: return "WM_TIMER"; | |
4794 | case 0x0114: return "WM_HSCROLL"; | |
4795 | case 0x0115: return "WM_VSCROLL"; | |
4796 | case 0x0116: return "WM_INITMENU"; | |
4797 | case 0x0117: return "WM_INITMENUPOPUP"; | |
4798 | case 0x011F: return "WM_MENUSELECT"; | |
4799 | case 0x0120: return "WM_MENUCHAR"; | |
4800 | case 0x0121: return "WM_ENTERIDLE"; | |
4801 | case 0x0200: return "WM_MOUSEMOVE"; | |
4802 | case 0x0201: return "WM_LBUTTONDOWN"; | |
4803 | case 0x0202: return "WM_LBUTTONUP"; | |
4804 | case 0x0203: return "WM_LBUTTONDBLCLK"; | |
4805 | case 0x0204: return "WM_RBUTTONDOWN"; | |
4806 | case 0x0205: return "WM_RBUTTONUP"; | |
4807 | case 0x0206: return "WM_RBUTTONDBLCLK"; | |
4808 | case 0x0207: return "WM_MBUTTONDOWN"; | |
4809 | case 0x0208: return "WM_MBUTTONUP"; | |
4810 | case 0x0209: return "WM_MBUTTONDBLCLK"; | |
4811 | case 0x0210: return "WM_PARENTNOTIFY"; | |
a02eb1d2 VZ |
4812 | case 0x0211: return "WM_ENTERMENULOOP"; |
4813 | case 0x0212: return "WM_EXITMENULOOP"; | |
c085e333 | 4814 | |
a02eb1d2 VZ |
4815 | #ifdef __WIN32__ |
4816 | case 0x0213: return "WM_NEXTMENU"; | |
4817 | case 0x0214: return "WM_SIZING"; | |
4818 | case 0x0215: return "WM_CAPTURECHANGED"; | |
4819 | case 0x0216: return "WM_MOVING"; | |
4820 | case 0x0218: return "WM_POWERBROADCAST"; | |
4821 | case 0x0219: return "WM_DEVICECHANGE"; | |
4822 | #endif //WIN32 | |
c085e333 | 4823 | |
47cbd6da VZ |
4824 | case 0x0220: return "WM_MDICREATE"; |
4825 | case 0x0221: return "WM_MDIDESTROY"; | |
4826 | case 0x0222: return "WM_MDIACTIVATE"; | |
4827 | case 0x0223: return "WM_MDIRESTORE"; | |
4828 | case 0x0224: return "WM_MDINEXT"; | |
4829 | case 0x0225: return "WM_MDIMAXIMIZE"; | |
4830 | case 0x0226: return "WM_MDITILE"; | |
4831 | case 0x0227: return "WM_MDICASCADE"; | |
4832 | case 0x0228: return "WM_MDIICONARRANGE"; | |
4833 | case 0x0229: return "WM_MDIGETACTIVE"; | |
4834 | case 0x0230: return "WM_MDISETMENU"; | |
4835 | case 0x0233: return "WM_DROPFILES"; | |
c085e333 | 4836 | |
a02eb1d2 VZ |
4837 | #ifdef __WIN32__ |
4838 | case 0x0281: return "WM_IME_SETCONTEXT"; | |
4839 | case 0x0282: return "WM_IME_NOTIFY"; | |
4840 | case 0x0283: return "WM_IME_CONTROL"; | |
4841 | case 0x0284: return "WM_IME_COMPOSITIONFULL"; | |
4842 | case 0x0285: return "WM_IME_SELECT"; | |
4843 | case 0x0286: return "WM_IME_CHAR"; | |
4844 | case 0x0290: return "WM_IME_KEYDOWN"; | |
4845 | case 0x0291: return "WM_IME_KEYUP"; | |
4846 | #endif //WIN32 | |
c085e333 | 4847 | |
47cbd6da VZ |
4848 | case 0x0300: return "WM_CUT"; |
4849 | case 0x0301: return "WM_COPY"; | |
4850 | case 0x0302: return "WM_PASTE"; | |
4851 | case 0x0303: return "WM_CLEAR"; | |
4852 | case 0x0304: return "WM_UNDO"; | |
4853 | case 0x0305: return "WM_RENDERFORMAT"; | |
4854 | case 0x0306: return "WM_RENDERALLFORMATS"; | |
4855 | case 0x0307: return "WM_DESTROYCLIPBOARD"; | |
4856 | case 0x0308: return "WM_DRAWCLIPBOARD"; | |
4857 | case 0x0309: return "WM_PAINTCLIPBOARD"; | |
4858 | case 0x030A: return "WM_VSCROLLCLIPBOARD"; | |
4859 | case 0x030B: return "WM_SIZECLIPBOARD"; | |
4860 | case 0x030C: return "WM_ASKCBFORMATNAME"; | |
4861 | case 0x030D: return "WM_CHANGECBCHAIN"; | |
4862 | case 0x030E: return "WM_HSCROLLCLIPBOARD"; | |
4863 | case 0x030F: return "WM_QUERYNEWPALETTE"; | |
4864 | case 0x0310: return "WM_PALETTEISCHANGING"; | |
4865 | case 0x0311: return "WM_PALETTECHANGED"; | |
c085e333 | 4866 | |
a02eb1d2 | 4867 | #ifdef __WIN32__ |
2d0a075d JS |
4868 | // common controls messages - although they're not strictly speaking |
4869 | // standard, it's nice to decode them nevertheless | |
a02eb1d2 | 4870 | |
2d0a075d | 4871 | // listview |
a02eb1d2 VZ |
4872 | case 0x1000 + 0: return "LVM_GETBKCOLOR"; |
4873 | case 0x1000 + 1: return "LVM_SETBKCOLOR"; | |
4874 | case 0x1000 + 2: return "LVM_GETIMAGELIST"; | |
4875 | case 0x1000 + 3: return "LVM_SETIMAGELIST"; | |
4876 | case 0x1000 + 4: return "LVM_GETITEMCOUNT"; | |
4877 | case 0x1000 + 5: return "LVM_GETITEMA"; | |
4878 | case 0x1000 + 75: return "LVM_GETITEMW"; | |
4879 | case 0x1000 + 6: return "LVM_SETITEMA"; | |
4880 | case 0x1000 + 76: return "LVM_SETITEMW"; | |
4881 | case 0x1000 + 7: return "LVM_INSERTITEMA"; | |
4882 | case 0x1000 + 77: return "LVM_INSERTITEMW"; | |
4883 | case 0x1000 + 8: return "LVM_DELETEITEM"; | |
4884 | case 0x1000 + 9: return "LVM_DELETEALLITEMS"; | |
4885 | case 0x1000 + 10: return "LVM_GETCALLBACKMASK"; | |
4886 | case 0x1000 + 11: return "LVM_SETCALLBACKMASK"; | |
4887 | case 0x1000 + 12: return "LVM_GETNEXTITEM"; | |
4888 | case 0x1000 + 13: return "LVM_FINDITEMA"; | |
4889 | case 0x1000 + 83: return "LVM_FINDITEMW"; | |
4890 | case 0x1000 + 14: return "LVM_GETITEMRECT"; | |
4891 | case 0x1000 + 15: return "LVM_SETITEMPOSITION"; | |
4892 | case 0x1000 + 16: return "LVM_GETITEMPOSITION"; | |
4893 | case 0x1000 + 17: return "LVM_GETSTRINGWIDTHA"; | |
4894 | case 0x1000 + 87: return "LVM_GETSTRINGWIDTHW"; | |
4895 | case 0x1000 + 18: return "LVM_HITTEST"; | |
4896 | case 0x1000 + 19: return "LVM_ENSUREVISIBLE"; | |
4897 | case 0x1000 + 20: return "LVM_SCROLL"; | |
4898 | case 0x1000 + 21: return "LVM_REDRAWITEMS"; | |
4899 | case 0x1000 + 22: return "LVM_ARRANGE"; | |
4900 | case 0x1000 + 23: return "LVM_EDITLABELA"; | |
4901 | case 0x1000 + 118: return "LVM_EDITLABELW"; | |
4902 | case 0x1000 + 24: return "LVM_GETEDITCONTROL"; | |
4903 | case 0x1000 + 25: return "LVM_GETCOLUMNA"; | |
4904 | case 0x1000 + 95: return "LVM_GETCOLUMNW"; | |
4905 | case 0x1000 + 26: return "LVM_SETCOLUMNA"; | |
4906 | case 0x1000 + 96: return "LVM_SETCOLUMNW"; | |
4907 | case 0x1000 + 27: return "LVM_INSERTCOLUMNA"; | |
4908 | case 0x1000 + 97: return "LVM_INSERTCOLUMNW"; | |
4909 | case 0x1000 + 28: return "LVM_DELETECOLUMN"; | |
4910 | case 0x1000 + 29: return "LVM_GETCOLUMNWIDTH"; | |
4911 | case 0x1000 + 30: return "LVM_SETCOLUMNWIDTH"; | |
4912 | case 0x1000 + 31: return "LVM_GETHEADER"; | |
4913 | case 0x1000 + 33: return "LVM_CREATEDRAGIMAGE"; | |
4914 | case 0x1000 + 34: return "LVM_GETVIEWRECT"; | |
4915 | case 0x1000 + 35: return "LVM_GETTEXTCOLOR"; | |
4916 | case 0x1000 + 36: return "LVM_SETTEXTCOLOR"; | |
4917 | case 0x1000 + 37: return "LVM_GETTEXTBKCOLOR"; | |
4918 | case 0x1000 + 38: return "LVM_SETTEXTBKCOLOR"; | |
4919 | case 0x1000 + 39: return "LVM_GETTOPINDEX"; | |
4920 | case 0x1000 + 40: return "LVM_GETCOUNTPERPAGE"; | |
4921 | case 0x1000 + 41: return "LVM_GETORIGIN"; | |
4922 | case 0x1000 + 42: return "LVM_UPDATE"; | |
4923 | case 0x1000 + 43: return "LVM_SETITEMSTATE"; | |
4924 | case 0x1000 + 44: return "LVM_GETITEMSTATE"; | |
4925 | case 0x1000 + 45: return "LVM_GETITEMTEXTA"; | |
4926 | case 0x1000 + 115: return "LVM_GETITEMTEXTW"; | |
4927 | case 0x1000 + 46: return "LVM_SETITEMTEXTA"; | |
4928 | case 0x1000 + 116: return "LVM_SETITEMTEXTW"; | |
4929 | case 0x1000 + 47: return "LVM_SETITEMCOUNT"; | |
4930 | case 0x1000 + 48: return "LVM_SORTITEMS"; | |
4931 | case 0x1000 + 49: return "LVM_SETITEMPOSITION32"; | |
4932 | case 0x1000 + 50: return "LVM_GETSELECTEDCOUNT"; | |
4933 | case 0x1000 + 51: return "LVM_GETITEMSPACING"; | |
4934 | case 0x1000 + 52: return "LVM_GETISEARCHSTRINGA"; | |
4935 | case 0x1000 + 117: return "LVM_GETISEARCHSTRINGW"; | |
4936 | case 0x1000 + 53: return "LVM_SETICONSPACING"; | |
4937 | case 0x1000 + 54: return "LVM_SETEXTENDEDLISTVIEWSTYLE"; | |
4938 | case 0x1000 + 55: return "LVM_GETEXTENDEDLISTVIEWSTYLE"; | |
4939 | case 0x1000 + 56: return "LVM_GETSUBITEMRECT"; | |
4940 | case 0x1000 + 57: return "LVM_SUBITEMHITTEST"; | |
4941 | case 0x1000 + 58: return "LVM_SETCOLUMNORDERARRAY"; | |
4942 | case 0x1000 + 59: return "LVM_GETCOLUMNORDERARRAY"; | |
4943 | case 0x1000 + 60: return "LVM_SETHOTITEM"; | |
4944 | case 0x1000 + 61: return "LVM_GETHOTITEM"; | |
4945 | case 0x1000 + 62: return "LVM_SETHOTCURSOR"; | |
4946 | case 0x1000 + 63: return "LVM_GETHOTCURSOR"; | |
4947 | case 0x1000 + 64: return "LVM_APPROXIMATEVIEWRECT"; | |
4948 | case 0x1000 + 65: return "LVM_SETWORKAREA"; | |
c085e333 | 4949 | |
2d0a075d | 4950 | // tree view |
a02eb1d2 VZ |
4951 | case 0x1100 + 0: return "TVM_INSERTITEMA"; |
4952 | case 0x1100 + 50: return "TVM_INSERTITEMW"; | |
4953 | case 0x1100 + 1: return "TVM_DELETEITEM"; | |
4954 | case 0x1100 + 2: return "TVM_EXPAND"; | |
4955 | case 0x1100 + 4: return "TVM_GETITEMRECT"; | |
4956 | case 0x1100 + 5: return "TVM_GETCOUNT"; | |
4957 | case 0x1100 + 6: return "TVM_GETINDENT"; | |
4958 | case 0x1100 + 7: return "TVM_SETINDENT"; | |
4959 | case 0x1100 + 8: return "TVM_GETIMAGELIST"; | |
4960 | case 0x1100 + 9: return "TVM_SETIMAGELIST"; | |
4961 | case 0x1100 + 10: return "TVM_GETNEXTITEM"; | |
4962 | case 0x1100 + 11: return "TVM_SELECTITEM"; | |
4963 | case 0x1100 + 12: return "TVM_GETITEMA"; | |
4964 | case 0x1100 + 62: return "TVM_GETITEMW"; | |
4965 | case 0x1100 + 13: return "TVM_SETITEMA"; | |
4966 | case 0x1100 + 63: return "TVM_SETITEMW"; | |
4967 | case 0x1100 + 14: return "TVM_EDITLABELA"; | |
4968 | case 0x1100 + 65: return "TVM_EDITLABELW"; | |
4969 | case 0x1100 + 15: return "TVM_GETEDITCONTROL"; | |
4970 | case 0x1100 + 16: return "TVM_GETVISIBLECOUNT"; | |
4971 | case 0x1100 + 17: return "TVM_HITTEST"; | |
4972 | case 0x1100 + 18: return "TVM_CREATEDRAGIMAGE"; | |
4973 | case 0x1100 + 19: return "TVM_SORTCHILDREN"; | |
4974 | case 0x1100 + 20: return "TVM_ENSUREVISIBLE"; | |
4975 | case 0x1100 + 21: return "TVM_SORTCHILDRENCB"; | |
4976 | case 0x1100 + 22: return "TVM_ENDEDITLABELNOW"; | |
4977 | case 0x1100 + 23: return "TVM_GETISEARCHSTRINGA"; | |
4978 | case 0x1100 + 64: return "TVM_GETISEARCHSTRINGW"; | |
4979 | case 0x1100 + 24: return "TVM_SETTOOLTIPS"; | |
4980 | case 0x1100 + 25: return "TVM_GETTOOLTIPS"; | |
c085e333 | 4981 | |
2d0a075d | 4982 | // header |
a02eb1d2 VZ |
4983 | case 0x1200 + 0: return "HDM_GETITEMCOUNT"; |
4984 | case 0x1200 + 1: return "HDM_INSERTITEMA"; | |
4985 | case 0x1200 + 10: return "HDM_INSERTITEMW"; | |
4986 | case 0x1200 + 2: return "HDM_DELETEITEM"; | |
4987 | case 0x1200 + 3: return "HDM_GETITEMA"; | |
4988 | case 0x1200 + 11: return "HDM_GETITEMW"; | |
4989 | case 0x1200 + 4: return "HDM_SETITEMA"; | |
4990 | case 0x1200 + 12: return "HDM_SETITEMW"; | |
4991 | case 0x1200 + 5: return "HDM_LAYOUT"; | |
4992 | case 0x1200 + 6: return "HDM_HITTEST"; | |
4993 | case 0x1200 + 7: return "HDM_GETITEMRECT"; | |
4994 | case 0x1200 + 8: return "HDM_SETIMAGELIST"; | |
4995 | case 0x1200 + 9: return "HDM_GETIMAGELIST"; | |
4996 | case 0x1200 + 15: return "HDM_ORDERTOINDEX"; | |
4997 | case 0x1200 + 16: return "HDM_CREATEDRAGIMAGE"; | |
4998 | case 0x1200 + 17: return "HDM_GETORDERARRAY"; | |
4999 | case 0x1200 + 18: return "HDM_SETORDERARRAY"; | |
5000 | case 0x1200 + 19: return "HDM_SETHOTDIVIDER"; | |
c085e333 | 5001 | |
2d0a075d | 5002 | // tab control |
a02eb1d2 VZ |
5003 | case 0x1300 + 2: return "TCM_GETIMAGELIST"; |
5004 | case 0x1300 + 3: return "TCM_SETIMAGELIST"; | |
5005 | case 0x1300 + 4: return "TCM_GETITEMCOUNT"; | |
5006 | case 0x1300 + 5: return "TCM_GETITEMA"; | |
5007 | case 0x1300 + 60: return "TCM_GETITEMW"; | |
5008 | case 0x1300 + 6: return "TCM_SETITEMA"; | |
5009 | case 0x1300 + 61: return "TCM_SETITEMW"; | |
5010 | case 0x1300 + 7: return "TCM_INSERTITEMA"; | |
5011 | case 0x1300 + 62: return "TCM_INSERTITEMW"; | |
5012 | case 0x1300 + 8: return "TCM_DELETEITEM"; | |
5013 | case 0x1300 + 9: return "TCM_DELETEALLITEMS"; | |
5014 | case 0x1300 + 10: return "TCM_GETITEMRECT"; | |
5015 | case 0x1300 + 11: return "TCM_GETCURSEL"; | |
5016 | case 0x1300 + 12: return "TCM_SETCURSEL"; | |
5017 | case 0x1300 + 13: return "TCM_HITTEST"; | |
5018 | case 0x1300 + 14: return "TCM_SETITEMEXTRA"; | |
5019 | case 0x1300 + 40: return "TCM_ADJUSTRECT"; | |
5020 | case 0x1300 + 41: return "TCM_SETITEMSIZE"; | |
5021 | case 0x1300 + 42: return "TCM_REMOVEIMAGE"; | |
5022 | case 0x1300 + 43: return "TCM_SETPADDING"; | |
5023 | case 0x1300 + 44: return "TCM_GETROWCOUNT"; | |
5024 | case 0x1300 + 45: return "TCM_GETTOOLTIPS"; | |
5025 | case 0x1300 + 46: return "TCM_SETTOOLTIPS"; | |
5026 | case 0x1300 + 47: return "TCM_GETCURFOCUS"; | |
5027 | case 0x1300 + 48: return "TCM_SETCURFOCUS"; | |
5028 | case 0x1300 + 49: return "TCM_SETMINTABWIDTH"; | |
5029 | case 0x1300 + 50: return "TCM_DESELECTALL"; | |
c085e333 | 5030 | |
2d0a075d | 5031 | // toolbar |
a02eb1d2 VZ |
5032 | case WM_USER+1: return "TB_ENABLEBUTTON"; |
5033 | case WM_USER+2: return "TB_CHECKBUTTON"; | |
5034 | case WM_USER+3: return "TB_PRESSBUTTON"; | |
5035 | case WM_USER+4: return "TB_HIDEBUTTON"; | |
5036 | case WM_USER+5: return "TB_INDETERMINATE"; | |
5037 | case WM_USER+9: return "TB_ISBUTTONENABLED"; | |
5038 | case WM_USER+10: return "TB_ISBUTTONCHECKED"; | |
5039 | case WM_USER+11: return "TB_ISBUTTONPRESSED"; | |
5040 | case WM_USER+12: return "TB_ISBUTTONHIDDEN"; | |
5041 | case WM_USER+13: return "TB_ISBUTTONINDETERMINATE"; | |
5042 | case WM_USER+17: return "TB_SETSTATE"; | |
5043 | case WM_USER+18: return "TB_GETSTATE"; | |
5044 | case WM_USER+19: return "TB_ADDBITMAP"; | |
5045 | case WM_USER+20: return "TB_ADDBUTTONS"; | |
5046 | case WM_USER+21: return "TB_INSERTBUTTON"; | |
5047 | case WM_USER+22: return "TB_DELETEBUTTON"; | |
5048 | case WM_USER+23: return "TB_GETBUTTON"; | |
5049 | case WM_USER+24: return "TB_BUTTONCOUNT"; | |
5050 | case WM_USER+25: return "TB_COMMANDTOINDEX"; | |
5051 | case WM_USER+26: return "TB_SAVERESTOREA"; | |
5052 | case WM_USER+76: return "TB_SAVERESTOREW"; | |
5053 | case WM_USER+27: return "TB_CUSTOMIZE"; | |
5054 | case WM_USER+28: return "TB_ADDSTRINGA"; | |
5055 | case WM_USER+77: return "TB_ADDSTRINGW"; | |
5056 | case WM_USER+29: return "TB_GETITEMRECT"; | |
5057 | case WM_USER+30: return "TB_BUTTONSTRUCTSIZE"; | |
5058 | case WM_USER+31: return "TB_SETBUTTONSIZE"; | |
5059 | case WM_USER+32: return "TB_SETBITMAPSIZE"; | |
5060 | case WM_USER+33: return "TB_AUTOSIZE"; | |
5061 | case WM_USER+35: return "TB_GETTOOLTIPS"; | |
5062 | case WM_USER+36: return "TB_SETTOOLTIPS"; | |
5063 | case WM_USER+37: return "TB_SETPARENT"; | |
5064 | case WM_USER+39: return "TB_SETROWS"; | |
5065 | case WM_USER+40: return "TB_GETROWS"; | |
5066 | case WM_USER+42: return "TB_SETCMDID"; | |
5067 | case WM_USER+43: return "TB_CHANGEBITMAP"; | |
5068 | case WM_USER+44: return "TB_GETBITMAP"; | |
5069 | case WM_USER+45: return "TB_GETBUTTONTEXTA"; | |
5070 | case WM_USER+75: return "TB_GETBUTTONTEXTW"; | |
5071 | case WM_USER+46: return "TB_REPLACEBITMAP"; | |
5072 | case WM_USER+47: return "TB_SETINDENT"; | |
5073 | case WM_USER+48: return "TB_SETIMAGELIST"; | |
5074 | case WM_USER+49: return "TB_GETIMAGELIST"; | |
5075 | case WM_USER+50: return "TB_LOADIMAGES"; | |
5076 | case WM_USER+51: return "TB_GETRECT"; | |
5077 | case WM_USER+52: return "TB_SETHOTIMAGELIST"; | |
5078 | case WM_USER+53: return "TB_GETHOTIMAGELIST"; | |
5079 | case WM_USER+54: return "TB_SETDISABLEDIMAGELIST"; | |
5080 | case WM_USER+55: return "TB_GETDISABLEDIMAGELIST"; | |
5081 | case WM_USER+56: return "TB_SETSTYLE"; | |
5082 | case WM_USER+57: return "TB_GETSTYLE"; | |
5083 | case WM_USER+58: return "TB_GETBUTTONSIZE"; | |
5084 | case WM_USER+59: return "TB_SETBUTTONWIDTH"; | |
5085 | case WM_USER+60: return "TB_SETMAXTEXTROWS"; | |
5086 | case WM_USER+61: return "TB_GETTEXTROWS"; | |
5087 | case WM_USER+41: return "TB_GETBITMAPFLAGS"; | |
c085e333 | 5088 | |
a02eb1d2 | 5089 | #endif //WIN32 |
c085e333 | 5090 | |
47cbd6da | 5091 | default: |
2d0a075d JS |
5092 | static char s_szBuf[128]; |
5093 | sprintf(s_szBuf, "<unknown message = %d>", message); | |
5094 | return s_szBuf; | |
47cbd6da VZ |
5095 | } |
5096 | } | |
ea57084d | 5097 | #endif //__WXDEBUG__ |