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