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