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