]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/window.cpp
added a cast to wxDecodeSurrogate() to fix wxMSW cross-compilation
[wxWidgets.git] / src / mgl / window.cpp
CommitLineData
32b8ec41 1/////////////////////////////////////////////////////////////////////////////
a4bbc9f7
VS
2// Name: src/mgl/window.cpp
3// Purpose: wxWindow
4// Author: Vaclav Slavik
5// (based on GTK & MSW implementations)
6// RCS-ID: $Id$
eea93267 7// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
65571936 8// Licence: wxWindows licence
32b8ec41
VZ
9/////////////////////////////////////////////////////////////////////////////
10
a4bbc9f7
VS
11// ===========================================================================
12// declarations
13// ===========================================================================
14
15// ---------------------------------------------------------------------------
16// headers
17// ---------------------------------------------------------------------------
32b8ec41 18
a4bbc9f7
VS
19// For compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#ifndef WX_PRECOMP
27 #include "wx/window.h"
d53fc7c9 28 #include "wx/msgdlg.h"
a4bbc9f7 29 #include "wx/accel.h"
a4bbc9f7
VS
30 #include "wx/dc.h"
31 #include "wx/dcclient.h"
32 #include "wx/utils.h"
33 #include "wx/app.h"
34 #include "wx/panel.h"
a4bbc9f7
VS
35#endif
36
37#if wxUSE_DRAG_AND_DROP
38 #include "wx/dnd.h"
39#endif
40
41#include "wx/log.h"
42#include "wx/sysopt.h"
43#include "wx/mgl/private.h"
44#include "wx/intl.h"
45#include "wx/dcscreen.h"
90eb13e6 46#include "wx/caret.h"
a4bbc9f7
VS
47
48#include <mgraph.hpp>
49
50#if wxUSE_TOOLTIPS
51 #include "wx/tooltip.h"
52#endif
53
54// ---------------------------------------------------------------------------
55// global variables
56// ---------------------------------------------------------------------------
57
58// MGL window manager and associated DC.
59winmng_t *g_winMng = NULL;
60MGLDevCtx *g_displayDC = NULL;
61
7de59551 62// the window that has keyboard focus:
7cdbf02c 63static wxWindowMGL *gs_focusedWindow = NULL;
7de59551 64// the window that is about to be focused after currently focused
eea93267
VS
65// one looses focus:
66static wxWindow *gs_toBeFocusedWindow = NULL;
7bdc1879 67// the window that is currently under mouse cursor:
7cdbf02c
VS
68static wxWindowMGL *gs_windowUnderMouse = NULL;
69// the window that has mouse capture
70static wxWindowMGL *gs_mouseCapture = NULL;
71// the frame that is currently active (i.e. its child has focus). It is
72// used to generate wxActivateEvents
73static wxWindowMGL *gs_activeFrame = NULL;
a4bbc9f7
VS
74
75// ---------------------------------------------------------------------------
76// constants
77// ---------------------------------------------------------------------------
78
7de59551 79// Custom identifiers used to distinguish between various event handlers
a4bbc9f7
VS
80// and capture handlers passed to MGL_wm
81enum
82{
83 wxMGL_CAPTURE_MOUSE = 1,
84 wxMGL_CAPTURE_KEYB = 2
85};
86
87
88// ---------------------------------------------------------------------------
89// private functions
90// ---------------------------------------------------------------------------
91
7cdbf02c
VS
92// Returns toplevel grandparent of given window:
93static wxWindowMGL* wxGetTopLevelParent(wxWindowMGL *win)
94{
95 wxWindowMGL *p = win;
96 while (p && !p->IsTopLevel())
97 p = p->GetParent();
98 return p;
99}
100
d53fc7c9 101// An easy way to capture screenshots:
2d1efe3f 102static void wxCaptureScreenshot(bool activeWindowOnly)
e6daf008 103{
d53fc7c9
VS
104#ifdef __DOS__
105 #define SCREENSHOT_FILENAME _T("sshot%03i.png")
106#else
107 #define SCREENSHOT_FILENAME _T("screenshot-%03i.png")
108#endif
e6daf008 109 static int screenshot_num = 0;
d53fc7c9 110 wxString screenshot;
7de59551
RD
111
112 do
d53fc7c9
VS
113 {
114 screenshot.Printf(SCREENSHOT_FILENAME, screenshot_num++);
115 } while ( wxFileExists(screenshot) && screenshot_num < 1000 );
7de59551 116
2d1efe3f
VS
117 wxRect r(0, 0, g_displayDC->sizex(), g_displayDC->sizey());
118
119 if ( activeWindowOnly && gs_activeFrame )
120 {
121 r.Intersect(gs_activeFrame->GetRect());
122 }
7de59551
RD
123
124 g_displayDC->savePNGFromDC(screenshot.mb_str(),
06534aa1 125 r.x, r. y, r.x+r.width, r.y+r.height);
7de59551 126
2b5f62a0
VZ
127 wxMessageBox(wxString::Format(_T("Screenshot captured: %s"),
128 screenshot.c_str()));
e6daf008 129}
e6daf008 130
7bdc1879
VS
131// ---------------------------------------------------------------------------
132// MGL_WM hooks:
133// ---------------------------------------------------------------------------
134
b43a9886 135static void MGLAPI wxWindowPainter(window_t *wnd, MGLDC *dc)
7bdc1879
VS
136{
137 wxWindowMGL *w = (wxWindow*) wnd->userData;
7de59551 138
544c782d 139 if ( w && !(w->GetWindowStyle() & wxTRANSPARENT_WINDOW) )
7bdc1879
VS
140 {
141 MGLDevCtx ctx(dc);
142 w->HandlePaint(&ctx);
143 }
ef344ff8
VS
144}
145
b43a9886 146static ibool MGLAPI wxWindowMouseHandler(window_t *wnd, event_t *e)
ef344ff8
VS
147{
148 wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);
d76048f5 149 wxPoint orig(win->GetClientAreaOrigin());
985520bc 150 wxPoint where;
7de59551
RD
151
152 MGL_wmCoordGlobalToLocal(win->GetHandle(),
985520bc
VS
153 e->where_x, e->where_y, &where.x, &where.y);
154
0a89ac9c
VS
155 for (wxWindowMGL *w = win; w; w = w->GetParent())
156 {
7de59551 157 if ( !w->IsEnabled() )
0a89ac9c
VS
158 return FALSE;
159 if ( w->IsTopLevel() )
160 break;
161 }
7de59551 162
ef344ff8
VS
163 wxEventType type = wxEVT_NULL;
164 wxMouseEvent event;
165 event.SetEventObject(win);
166 event.SetTimestamp(e->when);
d76048f5
VS
167 event.m_x = where.x - orig.x;
168 event.m_y = where.y - orig.y;
318ac890
MW
169 event.m_shiftDown = ( e->modifiers & EVT_SHIFTKEY ) != 0;
170 event.m_controlDown = ( e->modifiers & EVT_CTRLSTATE ) != 0;
171 event.m_altDown = ( e->modifiers & EVT_LEFTALT ) != 0;
172 event.m_metaDown = ( e->modifiers & EVT_RIGHTALT ) != 0;
173 event.m_leftDown = ( e->modifiers & EVT_LEFTBUT ) != 0;
174 event.m_middleDown = ( e->modifiers & EVT_MIDDLEBUT ) != 0;
175 event.m_rightDown = ( e->modifiers & EVT_RIGHTBUT ) != 0;
7de59551 176
ef344ff8
VS
177 switch (e->what)
178 {
179 case EVT_MOUSEDOWN:
8f5e92db
VS
180 // Change focus if the user clicks outside focused window:
181 if ( win->AcceptsFocus() && wxWindow::FindFocus() != win )
182 win->SetFocus();
183
8f5e92db
VS
184 if ( e->message & EVT_DBLCLICK )
185 {
8f5e92db
VS
186 if ( e->message & EVT_LEFTBMASK )
187 type = wxEVT_LEFT_DCLICK;
188 else if ( e->message & EVT_MIDDLEBMASK )
189 type = wxEVT_MIDDLE_DCLICK;
190 else if ( e->message & EVT_RIGHTBMASK )
191 type = wxEVT_RIGHT_DCLICK;
192 }
ea98f686
VS
193 else
194 {
195 if ( e->message & EVT_LEFTBMASK )
196 type = wxEVT_LEFT_DOWN;
197 else if ( e->message & EVT_MIDDLEBMASK )
198 type = wxEVT_MIDDLE_DOWN;
199 else if ( e->message & EVT_RIGHTBMASK )
200 type = wxEVT_RIGHT_DOWN;
201 }
a679e129 202
ef344ff8
VS
203 break;
204
205 case EVT_MOUSEUP:
206 if ( e->message & EVT_LEFTBMASK )
207 type = wxEVT_LEFT_UP;
208 else if ( e->message & EVT_MIDDLEBMASK )
209 type = wxEVT_MIDDLE_UP;
210 else if ( e->message & EVT_RIGHTBMASK )
211 type = wxEVT_RIGHT_UP;
212 break;
213
214 case EVT_MOUSEMOVE:
7cdbf02c
VS
215 if ( !gs_mouseCapture )
216 {
217 if ( win != gs_windowUnderMouse )
218 {
219 if ( gs_windowUnderMouse )
220 {
221 wxMouseEvent event2(event);
7de59551
RD
222 MGL_wmCoordGlobalToLocal(gs_windowUnderMouse->GetHandle(),
223 e->where_x, e->where_y,
7cdbf02c
VS
224 &event2.m_x, &event2.m_y);
225
d76048f5
VS
226 wxPoint orig(gs_windowUnderMouse->GetClientAreaOrigin());
227 event2.m_x -= orig.x;
228 event2.m_y -= orig.y;
229
7cdbf02c
VS
230 event2.SetEventObject(gs_windowUnderMouse);
231 event2.SetEventType(wxEVT_LEAVE_WINDOW);
232 gs_windowUnderMouse->GetEventHandler()->ProcessEvent(event2);
233 }
234
235 wxMouseEvent event3(event);
236 event3.SetEventType(wxEVT_ENTER_WINDOW);
237 win->GetEventHandler()->ProcessEvent(event3);
238
239 gs_windowUnderMouse = win;
240 }
241 }
242 else // gs_mouseCapture
ef344ff8 243 {
7de59551 244 bool inside = (where.x >= 0 &&
7cdbf02c
VS
245 where.y >= 0 &&
246 where.x < win->GetSize().x &&
247 where.y < win->GetSize().y);
248 if ( (inside && gs_windowUnderMouse != win) ||
249 (!inside && gs_windowUnderMouse == win) )
ef344ff8 250 {
7de59551 251 wxMouseEvent evt(inside ?
7cdbf02c
VS
252 wxEVT_ENTER_WINDOW : wxEVT_LEAVE_WINDOW);
253 evt.SetEventObject(win);
254 win->GetEventHandler()->ProcessEvent(evt);
255 gs_windowUnderMouse = inside ? win : NULL;
ef344ff8 256 }
ef344ff8 257 }
7de59551 258
ef344ff8
VS
259 type = wxEVT_MOTION;
260 break;
261
262 default:
263 break;
264 }
7de59551 265
ef344ff8
VS
266 if ( type == wxEVT_NULL )
267 {
268 return FALSE;
269 }
270 else
271 {
272 event.SetEventType(type);
273 return win->GetEventHandler()->ProcessEvent(event);
274 }
275}
276
a679e129 277static long wxScanToKeyCode(event_t *event, bool translate)
ef344ff8 278{
84c88a17
VS
279 // VS: make it __WXDEBUG__-only, since we have lots of wxLogTrace calls
280 // here and the arguments would be stored in non-debug executable even
281 // though wxLogTrace would be no-op...
282 #ifdef __WXDEBUG__
283 #define KEY(mgl_key,wx_key) \
284 case mgl_key: \
285 wxLogTrace(_T("keyevents"), \
286 _T("key " #mgl_key ", mapped to " #wx_key)); \
287 key = wx_key; \
288 break;
289 #else
290 #define KEY(mgl_key,wx_key) \
7de59551 291 case mgl_key: key = wx_key; break;
84c88a17 292 #endif
2b260bc3
VS
293
294 long key = 0;
7de59551 295
a679e129 296 if ( translate )
2b260bc3 297 {
a679e129
VS
298 switch ( EVT_scanCode(event->message) )
299 {
300 KEY (KB_padMinus, WXK_NUMPAD_SUBTRACT)
301 KEY (KB_padPlus, WXK_NUMPAD_ADD)
302 KEY (KB_padTimes, WXK_NUMPAD_MULTIPLY)
303 KEY (KB_padDivide, WXK_NUMPAD_DIVIDE)
304 KEY (KB_padCenter, WXK_NUMPAD_SEPARATOR) // ?
305 KEY (KB_padLeft, WXK_NUMPAD_LEFT)
306 KEY (KB_padRight, WXK_NUMPAD_RIGHT)
307 KEY (KB_padUp, WXK_NUMPAD_UP)
308 KEY (KB_padDown, WXK_NUMPAD_DOWN)
309 KEY (KB_padInsert, WXK_NUMPAD_INSERT)
310 KEY (KB_padDelete, WXK_NUMPAD_DELETE)
311 KEY (KB_padHome, WXK_NUMPAD_HOME)
312 KEY (KB_padEnd, WXK_NUMPAD_END)
313 KEY (KB_padPageUp, WXK_NUMPAD_PAGEUP)
a679e129 314 KEY (KB_padPageDown, WXK_NUMPAD_PAGEDOWN)
a679e129
VS
315 KEY (KB_1, '1')
316 KEY (KB_2, '2')
317 KEY (KB_3, '3')
318 KEY (KB_4, '4')
319 KEY (KB_5, '5')
320 KEY (KB_6, '6')
321 KEY (KB_7, '7')
322 KEY (KB_8, '8')
323 KEY (KB_9, '9')
324 KEY (KB_0, '0')
325 KEY (KB_minus, WXK_SUBTRACT)
326 KEY (KB_equals, WXK_ADD)
327 KEY (KB_backSlash, '\\')
328 KEY (KB_Q, 'Q')
329 KEY (KB_W, 'W')
330 KEY (KB_E, 'E')
331 KEY (KB_R, 'R')
332 KEY (KB_T, 'T')
333 KEY (KB_Y, 'Y')
334 KEY (KB_U, 'U')
335 KEY (KB_I, 'I')
336 KEY (KB_O, 'O')
337 KEY (KB_P, 'P')
338 KEY (KB_leftSquareBrace,'[')
339 KEY (KB_rightSquareBrace,']')
340 KEY (KB_A, 'A')
341 KEY (KB_S, 'S')
342 KEY (KB_D, 'D')
343 KEY (KB_F, 'F')
344 KEY (KB_G, 'G')
345 KEY (KB_H, 'H')
346 KEY (KB_J, 'J')
347 KEY (KB_K, 'K')
348 KEY (KB_L, 'L')
349 KEY (KB_semicolon, ';')
350 KEY (KB_apostrophe, '\'')
351 KEY (KB_Z, 'Z')
352 KEY (KB_X, 'X')
353 KEY (KB_C, 'C')
354 KEY (KB_V, 'V')
355 KEY (KB_B, 'B')
356 KEY (KB_N, 'N')
357 KEY (KB_M, 'M')
358 KEY (KB_comma, ',')
359 KEY (KB_period, '.')
360 KEY (KB_divide, WXK_DIVIDE)
361 KEY (KB_space, WXK_SPACE)
362 KEY (KB_tilde, '~')
363
364 default: break;
365 }
366 }
7de59551 367
a679e129
VS
368 if ( key == 0 )
369 {
370 switch ( EVT_scanCode(event->message) )
371 {
372 KEY (KB_padEnter, WXK_NUMPAD_ENTER)
373 KEY (KB_F1, WXK_F1)
374 KEY (KB_F2, WXK_F2)
375 KEY (KB_F3, WXK_F3)
376 KEY (KB_F4, WXK_F4)
377 KEY (KB_F5, WXK_F5)
378 KEY (KB_F6, WXK_F6)
379 KEY (KB_F7, WXK_F7)
380 KEY (KB_F8, WXK_F8)
381 KEY (KB_F9, WXK_F9)
382 KEY (KB_F10, WXK_F10)
383 KEY (KB_F11, WXK_F11)
384 KEY (KB_F12, WXK_F12)
385 KEY (KB_left, WXK_LEFT)
386 KEY (KB_right, WXK_RIGHT)
387 KEY (KB_up, WXK_UP)
388 KEY (KB_down, WXK_DOWN)
389 KEY (KB_insert, WXK_INSERT)
390 KEY (KB_delete, WXK_DELETE)
391 KEY (KB_home, WXK_HOME)
392 KEY (KB_end, WXK_END)
393 KEY (KB_pageUp, WXK_PAGEUP)
394 KEY (KB_pageDown, WXK_PAGEDOWN)
395 KEY (KB_capsLock, WXK_CAPITAL)
396 KEY (KB_numLock, WXK_NUMLOCK)
397 KEY (KB_scrollLock, WXK_SCROLL)
398 KEY (KB_leftShift, WXK_SHIFT)
399 KEY (KB_rightShift, WXK_SHIFT)
400 KEY (KB_leftCtrl, WXK_CONTROL)
401 KEY (KB_rightCtrl, WXK_CONTROL)
402 KEY (KB_leftAlt, WXK_ALT)
403 KEY (KB_rightAlt, WXK_ALT)
404 KEY (KB_leftWindows, WXK_START)
405 KEY (KB_rightWindows, WXK_START)
406 KEY (KB_menu, WXK_MENU)
407 KEY (KB_sysReq, WXK_SNAPSHOT)
408 KEY (KB_esc, WXK_ESCAPE)
409 KEY (KB_backspace, WXK_BACK)
410 KEY (KB_tab, WXK_TAB)
7de59551 411 KEY (KB_enter, WXK_RETURN)
a679e129 412
7de59551
RD
413 default:
414 key = EVT_asciiCode(event->message);
a679e129
VS
415 break;
416 }
2b260bc3
VS
417 }
418
544c782d
VS
419 #undef KEY
420
2b260bc3 421 return key;
ef344ff8
VS
422}
423
d53fc7c9
VS
424static bool wxHandleSpecialKeys(wxKeyEvent& event)
425{
426 // Add an easy way to capture screenshots:
427 if ( event.m_keyCode == WXK_SNAPSHOT
428 #ifdef __WXDEBUG__ // FIXME_MGL - remove when KB_sysReq works in MGL!
7de59551
RD
429 || (event.m_keyCode == WXK_F1 &&
430 event.m_shiftDown && event.m_controlDown)
d53fc7c9 431 #endif
197b1626 432 )
d53fc7c9 433 {
2d1efe3f 434 wxCaptureScreenshot(event.m_altDown/*only active wnd?*/);
127eab18 435 return true;
d53fc7c9 436 }
7de59551 437
127eab18 438 return false;
d53fc7c9
VS
439}
440
b43a9886 441static ibool MGLAPI wxWindowKeybHandler(window_t *wnd, event_t *e)
2b260bc3 442{
2b260bc3 443 wxWindowMGL *win = (wxWindowMGL*)MGL_wmGetWindowUserData(wnd);
a200c35e
VS
444
445 if ( !win->IsEnabled() ) return FALSE;
446
985520bc 447 wxPoint where;
7de59551 448 MGL_wmCoordGlobalToLocal(win->GetHandle(),
985520bc 449 e->where_x, e->where_y, &where.x, &where.y);
7de59551 450
2b260bc3
VS
451 wxKeyEvent event;
452 event.SetEventObject(win);
453 event.SetTimestamp(e->when);
127eab18 454 event.m_keyCode = wxScanToKeyCode(e, true);
2b260bc3
VS
455 event.m_scanCode = 0; // not used by wx at all
456 event.m_x = where.x;
457 event.m_y = where.y;
318ac890
MW
458 event.m_shiftDown = ( e->modifiers & EVT_SHIFTKEY ) != 0;
459 event.m_controlDown = ( e->modifiers & EVT_CTRLSTATE ) != 0;
460 event.m_altDown = ( e->modifiers & EVT_LEFTALT ) != 0;
461 event.m_metaDown = ( e->modifiers & EVT_RIGHTALT ) != 0;
2b260bc3
VS
462
463 if ( e->what == EVT_KEYUP )
464 {
465 event.SetEventType(wxEVT_KEY_UP);
466 return win->GetEventHandler()->ProcessEvent(event);
467 }
468 else
469 {
470 bool ret;
471 wxKeyEvent event2;
472
473 event.SetEventType(wxEVT_KEY_DOWN);
474 event2 = event;
7de59551 475
2b260bc3
VS
476 ret = win->GetEventHandler()->ProcessEvent(event);
477
84c88a17
VS
478 // wxMSW doesn't send char events with Alt pressed
479 // Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x
d53fc7c9 480 // will only be sent if it is not in an accelerator table:
127eab18 481 event2.m_keyCode = wxScanToKeyCode(e, false);
2b260bc3
VS
482 if ( !ret && event2.m_keyCode != 0 )
483 {
484 event2.SetEventType(wxEVT_CHAR);
485 ret = win->GetEventHandler()->ProcessEvent(event2);
486 }
7de59551 487
84c88a17 488 // Synthetize navigation key event, but do it only if the TAB key
d53fc7c9 489 // wasn't handled yet:
84c88a17
VS
490 if ( !ret && event.m_keyCode == WXK_TAB &&
491 win->GetParent() && win->GetParent()->HasFlag(wxTAB_TRAVERSAL) )
492 {
493 wxNavigationKeyEvent navEvent;
494 navEvent.SetEventObject(win->GetParent());
495 // Shift-TAB goes in reverse direction:
496 navEvent.SetDirection(!event.m_shiftDown);
497 // Ctrl-TAB changes the (parent) window, i.e. switch notebook page:
498 navEvent.SetWindowChange(event.m_controlDown);
499 navEvent.SetCurrentFocus(wxStaticCast(win, wxWindow));
500 ret = win->GetParent()->GetEventHandler()->ProcessEvent(navEvent);
501 }
7de59551
RD
502
503 // Finally, process special meaning keys that are usually
d53fc7c9
VS
504 // a responsibility of OS or window manager:
505 if ( !ret )
506 ret = wxHandleSpecialKeys(event);
7de59551 507
2b260bc3
VS
508 return ret;
509 }
7bdc1879 510}
a4bbc9f7
VS
511
512// ---------------------------------------------------------------------------
513// event tables
514// ---------------------------------------------------------------------------
515
ef344ff8 516// in wxUniv this class is abstract because it doesn't have DoPopupMenu()
a4bbc9f7
VS
517IMPLEMENT_ABSTRACT_CLASS(wxWindowMGL, wxWindowBase)
518
519BEGIN_EVENT_TABLE(wxWindowMGL, wxWindowBase)
a4bbc9f7
VS
520END_EVENT_TABLE()
521
522// ===========================================================================
523// implementation
524// ===========================================================================
525
526// ----------------------------------------------------------------------------
527// constructors and such
528// ----------------------------------------------------------------------------
529
1c53456f 530extern wxVideoMode wxGetDefaultDisplayMode();
a3e76614 531
a4bbc9f7
VS
532void wxWindowMGL::Init()
533{
1f43b5c9
VS
534 // First of all, make sure window manager is up and running. If it is
535 // not the case, initialize it in default display mode
536 if ( !g_winMng )
7b9f73d2
VS
537 {
538 if ( !wxTheApp->SetDisplayMode(wxGetDefaultDisplayMode()) )
a1f7eb20 539 wxLogFatalError(_("Cannot initialize display."));
7b9f73d2 540 }
1f43b5c9 541
a4bbc9f7 542 // mgl specific:
a4bbc9f7 543 m_wnd = NULL;
127eab18
WS
544 m_isShown = true;
545 m_frozen = false;
a4bbc9f7 546 m_paintMGLDC = NULL;
2b260bc3 547 m_eraseBackground = -1;
a4bbc9f7
VS
548}
549
550// Destructor
551wxWindowMGL::~wxWindowMGL()
552{
7de59551
RD
553 SendDestroyEvent();
554
127eab18 555 m_isBeingDeleted = true;
a4bbc9f7 556
7cdbf02c
VS
557 if ( gs_mouseCapture == this )
558 ReleaseMouse();
d46330c5 559
7cdbf02c 560 if (gs_activeFrame == this)
d46330c5 561 {
66858adf
VS
562 gs_activeFrame = NULL;
563 // activate next frame in Z-order:
564 if ( m_wnd->prev )
565 {
566 wxWindowMGL *win = (wxWindowMGL*)m_wnd->prev->userData;
567 win->SetFocus();
568 }
569 else if ( m_wnd->next )
570 {
571 wxWindowMGL *win = (wxWindowMGL*)m_wnd->next->userData;
572 win->SetFocus();
d46330c5 573 }
d46330c5 574 }
7de59551 575
7cdbf02c 576 if ( gs_focusedWindow == this )
7bdc1879 577 KillFocus();
d46330c5 578
7cdbf02c
VS
579 if ( gs_windowUnderMouse == this )
580 gs_windowUnderMouse = NULL;
a4bbc9f7 581
a4bbc9f7
VS
582 DestroyChildren();
583
a4bbc9f7
VS
584 if ( m_wnd )
585 MGL_wmDestroyWindow(m_wnd);
586}
587
588// real construction (Init() must have been called before!)
589bool wxWindowMGL::Create(wxWindow *parent,
590 wxWindowID id,
591 const wxPoint& pos,
592 const wxSize& size,
593 long style,
594 const wxString& name)
595{
a4bbc9f7 596 if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
127eab18 597 return false;
a4bbc9f7 598
544c782d 599 if ( parent )
7bdc1879 600 parent->AddChild(this);
a4bbc9f7 601
ef344ff8
VS
602 int x, y, w, h;
603 x = pos.x, y = pos.y;
604 if ( x == -1 )
605 x = 0; // FIXME_MGL, something better, see GTK+
606 if ( y == -1 )
607 y = 0; // FIXME_MGL, something better, see GTK+
82186005 608 AdjustForParentClientOrigin(x, y, 0);
ef344ff8
VS
609 w = WidthDefault(size.x);
610 h = HeightDefault(size.y);
7de59551 611
72fa862b 612 long mgl_style = 0;
7cdbf02c 613 window_t *wnd_parent = parent ? parent->GetHandle() : NULL;
544c782d 614
e441e1f4 615 if ( style & wxFULL_REPAINT_ON_RESIZE )
544c782d 616 {
72fa862b 617 mgl_style |= MGL_WM_FULL_REPAINT_ON_RESIZE;
544c782d 618 }
72fa862b 619 if ( style & wxSTAY_ON_TOP )
544c782d 620 {
72fa862b 621 mgl_style |= MGL_WM_ALWAYS_ON_TOP;
544c782d
VS
622 }
623 if ( style & wxPOPUP_WINDOW )
624 {
7cdbf02c 625 mgl_style |= MGL_WM_ALWAYS_ON_TOP;
544c782d 626 // it is created hidden as other top level windows
127eab18 627 m_isShown = false;
7cdbf02c 628 wnd_parent = NULL;
544c782d 629 }
ef344ff8 630
58061670
VS
631 window_t *wnd = MGL_wmCreateWindow(g_winMng, wnd_parent, x, y, w, h);
632
633 MGL_wmSetWindowFlags(wnd, mgl_style);
634 MGL_wmShowWindow(wnd, m_isShown);
7de59551 635
58061670
VS
636 SetMGLwindow_t(wnd);
637
127eab18 638 return true;
58061670
VS
639}
640
641void wxWindowMGL::SetMGLwindow_t(struct window_t *wnd)
642{
643 if ( m_wnd )
644 MGL_wmDestroyWindow(m_wnd);
645
646 m_wnd = wnd;
647 if ( !m_wnd ) return;
7de59551 648
127eab18 649 m_isShown = (bool)m_wnd->visible;
ef344ff8 650
a4bbc9f7
VS
651 MGL_wmSetWindowUserData(m_wnd, (void*) this);
652 MGL_wmSetWindowPainter(m_wnd, wxWindowPainter);
ef344ff8
VS
653 MGL_wmPushWindowEventHandler(m_wnd, wxWindowMouseHandler, EVT_MOUSEEVT, 0);
654 MGL_wmPushWindowEventHandler(m_wnd, wxWindowKeybHandler, EVT_KEYEVT, 0);
58061670
VS
655
656 if ( m_cursor.Ok() )
657 MGL_wmSetWindowCursor(m_wnd, *m_cursor.GetMGLCursor());
658 else
659 MGL_wmSetWindowCursor(m_wnd, *wxSTANDARD_CURSOR->GetMGLCursor());
a4bbc9f7
VS
660}
661
662// ---------------------------------------------------------------------------
663// basic operations
664// ---------------------------------------------------------------------------
665
666void wxWindowMGL::SetFocus()
667{
a46935cb
VS
668 if ( gs_focusedWindow == this ) return;
669
eea93267
VS
670 wxWindowMGL *oldFocusedWindow = gs_focusedWindow;
671
7cdbf02c 672 if ( gs_focusedWindow )
eea93267
VS
673 {
674 gs_toBeFocusedWindow = (wxWindow*)this;
7cdbf02c 675 gs_focusedWindow->KillFocus();
eea93267
VS
676 gs_toBeFocusedWindow = NULL;
677 }
7de59551 678
7cdbf02c 679 gs_focusedWindow = this;
7de59551 680
2b260bc3 681 MGL_wmCaptureEvents(GetHandle(), EVT_KEYEVT, wxMGL_CAPTURE_KEYB);
a4bbc9f7 682
7cdbf02c 683 wxWindowMGL *active = wxGetTopLevelParent(this);
61bd618f 684 if ( !(m_windowStyle & wxPOPUP_WINDOW) && active != gs_activeFrame )
a4bbc9f7 685 {
7cdbf02c
VS
686 if ( gs_activeFrame )
687 {
127eab18 688 wxActivateEvent event(wxEVT_ACTIVATE, false, gs_activeFrame->GetId());
7cdbf02c
VS
689 event.SetEventObject(gs_activeFrame);
690 gs_activeFrame->GetEventHandler()->ProcessEvent(event);
691 }
692
693 gs_activeFrame = active;
127eab18 694 wxActivateEvent event(wxEVT_ACTIVATE, true, gs_activeFrame->GetId());
7cdbf02c
VS
695 event.SetEventObject(gs_activeFrame);
696 gs_activeFrame->GetEventHandler()->ProcessEvent(event);
a4bbc9f7 697 }
7de59551 698
a4bbc9f7
VS
699 wxFocusEvent event(wxEVT_SET_FOCUS, GetId());
700 event.SetEventObject(this);
eea93267 701 event.SetWindow((wxWindow*)oldFocusedWindow);
a46935cb 702 GetEventHandler()->ProcessEvent(event);
869dabf8
VS
703
704#if wxUSE_CARET
705 // caret needs to be informed about focus change
706 wxCaret *caret = GetCaret();
707 if ( caret )
708 caret->OnSetFocus();
709#endif // wxUSE_CARET
a4bbc9f7 710}
32b8ec41 711
a4bbc9f7 712void wxWindowMGL::KillFocus()
32b8ec41 713{
7cdbf02c
VS
714 if ( gs_focusedWindow != this ) return;
715 gs_focusedWindow = NULL;
a4bbc9f7 716
7bdc1879 717 if ( m_isBeingDeleted ) return;
7de59551 718
a4bbc9f7
VS
719 MGL_wmUncaptureEvents(GetHandle(), wxMGL_CAPTURE_KEYB);
720
721#if wxUSE_CARET
722 // caret needs to be informed about focus change
723 wxCaret *caret = GetCaret();
7bdc1879 724 if ( caret )
a4bbc9f7
VS
725 caret->OnKillFocus();
726#endif // wxUSE_CARET
727
a4bbc9f7
VS
728 wxFocusEvent event(wxEVT_KILL_FOCUS, GetId());
729 event.SetEventObject(this);
eea93267 730 event.SetWindow(gs_toBeFocusedWindow);
a46935cb 731 GetEventHandler()->ProcessEvent(event);
32b8ec41
VZ
732}
733
a4bbc9f7
VS
734// ----------------------------------------------------------------------------
735// this wxWindowBase function is implemented here (in platform-specific file)
736// because it is static and so couldn't be made virtual
737// ----------------------------------------------------------------------------
0fe02759 738wxWindow *wxWindowBase::DoFindFocus()
32b8ec41 739{
7cdbf02c 740 return (wxWindow*)gs_focusedWindow;
a4bbc9f7
VS
741}
742
743bool wxWindowMGL::Show(bool show)
744{
745 if ( !wxWindowBase::Show(show) )
127eab18 746 return false;
a4bbc9f7
VS
747
748 MGL_wmShowWindow(m_wnd, show);
7de59551 749
ead60ec5
VS
750 if (!show && gs_activeFrame == this)
751 {
66858adf
VS
752 // activate next frame in Z-order:
753 if ( m_wnd->prev )
754 {
755 wxWindowMGL *win = (wxWindowMGL*)m_wnd->prev->userData;
756 win->SetFocus();
757 }
758 else if ( m_wnd->next )
759 {
760 wxWindowMGL *win = (wxWindowMGL*)m_wnd->next->userData;
761 win->SetFocus();
762 }
763 else
764 {
765 gs_activeFrame = NULL;
ead60ec5
VS
766 }
767 }
768
127eab18 769 return true;
a4bbc9f7
VS
770}
771
772// Raise the window to the top of the Z order
773void wxWindowMGL::Raise()
774{
775 MGL_wmRaiseWindow(m_wnd);
776}
777
778// Lower the window to the bottom of the Z order
779void wxWindowMGL::Lower()
780{
781 MGL_wmLowerWindow(m_wnd);
782}
783
4116c221 784void wxWindowMGL::DoCaptureMouse()
a4bbc9f7 785{
7cdbf02c
VS
786 if ( gs_mouseCapture )
787 MGL_wmUncaptureEvents(gs_mouseCapture->m_wnd, wxMGL_CAPTURE_MOUSE);
788
789 gs_mouseCapture = this;
a4bbc9f7
VS
790 MGL_wmCaptureEvents(m_wnd, EVT_MOUSEEVT, wxMGL_CAPTURE_MOUSE);
791}
792
4116c221 793void wxWindowMGL::DoReleaseMouse()
a4bbc9f7 794{
63fd5f0b 795 wxASSERT_MSG( gs_mouseCapture == this, wxT("attempt to release mouse, but this window hasn't captured it") );
7de59551 796
a4bbc9f7 797 MGL_wmUncaptureEvents(m_wnd, wxMGL_CAPTURE_MOUSE);
7cdbf02c 798 gs_mouseCapture = NULL;
a4bbc9f7
VS
799}
800
801/* static */ wxWindow *wxWindowBase::GetCapture()
802{
7cdbf02c 803 return (wxWindow*)gs_mouseCapture;
a4bbc9f7
VS
804}
805
806bool wxWindowMGL::SetCursor(const wxCursor& cursor)
807{
808 if ( !wxWindowBase::SetCursor(cursor) )
809 {
810 // no change
127eab18 811 return false;
a4bbc9f7
VS
812 }
813
814 if ( m_cursor.Ok() )
815 MGL_wmSetWindowCursor(m_wnd, *m_cursor.GetMGLCursor());
ef344ff8
VS
816 else
817 MGL_wmSetWindowCursor(m_wnd, *wxSTANDARD_CURSOR->GetMGLCursor());
a4bbc9f7 818
127eab18 819 return true;
a4bbc9f7
VS
820}
821
822void wxWindowMGL::WarpPointer(int x, int y)
823{
8014db41
VS
824 int w, h;
825 wxDisplaySize(&w, &h);
826
a4bbc9f7 827 ClientToScreen(&x, &y);
8014db41
VS
828 if ( x < 0 )
829 x = 0;
830 if ( y < 0 )
831 y = 0;
832 if ( x >= w )
833 x = w-1;
834 if ( y >= h )
835 y = h-1;
7de59551 836
a4bbc9f7
VS
837 EVT_setMousePos(x, y);
838}
839
a4bbc9f7
VS
840// Set this window to be the child of 'parent'.
841bool wxWindowMGL::Reparent(wxWindowBase *parent)
842{
843 if ( !wxWindowBase::Reparent(parent) )
127eab18 844 return false;
a4bbc9f7
VS
845
846 MGL_wmReparentWindow(m_wnd, parent->GetHandle());
847
127eab18 848 return true;
a4bbc9f7
VS
849}
850
851
852// ---------------------------------------------------------------------------
853// drag and drop
854// ---------------------------------------------------------------------------
855
856#if wxUSE_DRAG_AND_DROP
857
858void wxWindowMGL::SetDropTarget(wxDropTarget *pDropTarget)
859{
860 if ( m_dropTarget != 0 ) {
861 m_dropTarget->Revoke(m_hWnd);
862 delete m_dropTarget;
863 }
864
865 m_dropTarget = pDropTarget;
866 if ( m_dropTarget != 0 )
867 m_dropTarget->Register(m_hWnd);
868}
869// FIXME_MGL
870#endif // wxUSE_DRAG_AND_DROP
871
872// old style file-manager drag&drop support: we retain the old-style
873// DragAcceptFiles in parallel with SetDropTarget.
127eab18 874void wxWindowMGL::DragAcceptFiles(bool WXUNUSED(accept))
a4bbc9f7
VS
875{
876#if 0 // FIXME_MGL
877 HWND hWnd = GetHwnd();
878 if ( hWnd )
879 ::DragAcceptFiles(hWnd, (BOOL)accept);
880#endif
881}
882
883// ---------------------------------------------------------------------------
884// moving and resizing
885// ---------------------------------------------------------------------------
886
887// Get total size
888void wxWindowMGL::DoGetSize(int *x, int *y) const
889{
ea98f686 890 wxASSERT_MSG( m_wnd, wxT("invalid window") );
7de59551 891
a4bbc9f7
VS
892 if (x) *x = m_wnd->width;
893 if (y) *y = m_wnd->height;
894}
895
896void wxWindowMGL::DoGetPosition(int *x, int *y) const
897{
ea98f686
VS
898 wxASSERT_MSG( m_wnd, wxT("invalid window") );
899
900 int pX = 0, pY = 0;
7de59551 901 AdjustForParentClientOrigin(pX, pY, 0);
e41dcea5 902
ea98f686
VS
903 if (x) *x = m_wnd->x - pX;
904 if (y) *y = m_wnd->y - pY;
a4bbc9f7
VS
905}
906
907void wxWindowMGL::DoScreenToClient(int *x, int *y) const
908{
909 int ax, ay;
985520bc 910 MGL_wmCoordGlobalToLocal(m_wnd, 0, 0, &ax, &ay);
a4bbc9f7 911 if (x)
985520bc 912 (*x) += ax;
a4bbc9f7 913 if (y)
985520bc 914 (*y) += ay;
a4bbc9f7
VS
915}
916
917void wxWindowMGL::DoClientToScreen(int *x, int *y) const
918{
919 int ax, ay;
985520bc 920 MGL_wmCoordLocalToGlobal(m_wnd, 0, 0, &ax, &ay);
a4bbc9f7 921 if (x)
985520bc 922 (*x) += ax;
a4bbc9f7 923 if (y)
985520bc 924 (*y) += ay;
a4bbc9f7
VS
925}
926
927// Get size *available for subwindows* i.e. excluding menu bar etc.
928void wxWindowMGL::DoGetClientSize(int *x, int *y) const
929{
930 DoGetSize(x, y);
931}
932
933void wxWindowMGL::DoMoveWindow(int x, int y, int width, int height)
934{
1cdab5d1
MW
935 wxRect rcClient(GetClientRect());
936
937 MGL_wmSetWindowPosition(m_wnd, x, y, width, height);
938
939 // When the origin or a window stays fixed but the height or width
940 // changes, invalidate the old and new non-client areas
941 if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) &&
942 m_wnd->x == x && m_wnd->y == y &&
943 rcClient.Intersect(GetClientRect()) != wxRect(0, 0, width, height) )
944 {
945 wxRegion rgn(0, 0, width, height);
946 rgn.Subtract(rcClient);
947
948 // This should work I think, but doesn't seem to:
949 //MGL_wmInvalidateWindowRegion(m_wnd, rgn.GetMGLRegion().rgnPointer());
950
951 // Use MGL_wmInvalidateWindowRect instead:
952 for (wxRegionIterator it(rgn); it; it++)
953 {
954 rect_t rc;
955 rc.left = it.GetX();
956 rc.top = it.GetY();
957 rc.right = rc.left + it.GetW();
958 rc.bottom = rc.top + it.GetH();
959 MGL_wmInvalidateWindowRect(m_wnd, &rc);
960 }
961 }
a4bbc9f7
VS
962}
963
964// set the size of the window: if the dimensions are positive, just use them,
965// but if any of them is equal to -1, it means that we must find the value for
966// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in
967// which case -1 is a valid value for x and y)
968//
969// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate
970// the width/height to best suit our contents, otherwise we reuse the current
971// width/height
972void wxWindowMGL::DoSetSize(int x, int y, int width, int height, int sizeFlags)
973{
974 // get the current size and position...
975 int currentX, currentY;
976 GetPosition(&currentX, &currentY);
977 int currentW,currentH;
978 GetSize(&currentW, &currentH);
979
980 // ... and don't do anything (avoiding flicker) if it's already ok
981 if ( x == currentX && y == currentY &&
982 width == currentW && height == currentH )
983 {
984 return;
985 }
986
987 if ( x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
988 x = currentX;
989 if ( y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )
990 y = currentY;
991
a4bbc9f7 992 AdjustForParentClientOrigin(x, y, sizeFlags);
a4bbc9f7
VS
993
994 wxSize size(-1, -1);
995 if ( width == -1 )
996 {
997 if ( sizeFlags & wxSIZE_AUTO_WIDTH )
998 {
999 size = DoGetBestSize();
1000 width = size.x;
1001 }
1002 else
1003 {
1004 // just take the current one
1005 width = currentW;
1006 }
1007 }
7de59551 1008
a4bbc9f7
VS
1009 if ( height == -1 )
1010 {
1011 if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
1012 {
1013 if ( size.x == -1 )
1014 {
1015 size = DoGetBestSize();
1016 }
1017 //else: already called DoGetBestSize() above
1018
1019 height = size.y;
1020 }
1021 else
1022 {
1023 // just take the current one
1024 height = currentH;
1025 }
1026 }
7de59551 1027
6feddea3 1028 int maxWidth = GetMaxWidth(),
7de59551 1029 minWidth = GetMinWidth(),
6feddea3
VS
1030 maxHeight = GetMaxHeight(),
1031 minHeight = GetMinHeight();
7de59551 1032
6feddea3
VS
1033 if ( minWidth != -1 && width < minWidth ) width = minWidth;
1034 if ( maxWidth != -1 && width > maxWidth ) width = maxWidth;
1035 if ( minHeight != -1 && height < minHeight ) height = minHeight;
1036 if ( maxHeight != -1 && height > maxHeight ) height = maxHeight;
a4bbc9f7 1037
7de59551 1038 if ( m_wnd->x != x || m_wnd->y != y ||
88f2a771
VS
1039 (int)m_wnd->width != width || (int)m_wnd->height != height )
1040 {
1041 DoMoveWindow(x, y, width, height);
a4bbc9f7 1042
127eab18
WS
1043 wxSize newSize(width, height);
1044 wxSizeEvent event(newSize, GetId());
88f2a771
VS
1045 event.SetEventObject(this);
1046 GetEventHandler()->ProcessEvent(event);
1047 }
a4bbc9f7
VS
1048}
1049
1050void wxWindowMGL::DoSetClientSize(int width, int height)
1051{
1052 SetSize(width, height);
1053}
1054
1055// ---------------------------------------------------------------------------
1056// text metrics
1057// ---------------------------------------------------------------------------
1058
1059int wxWindowMGL::GetCharHeight() const
1060{
1061 wxScreenDC dc;
1062 dc.SetFont(m_font);
1063 return dc.GetCharHeight();
1064}
1065
1066int wxWindowMGL::GetCharWidth() const
1067{
1068 wxScreenDC dc;
1069 dc.SetFont(m_font);
1070 return dc.GetCharWidth();
1071}
1072
1073void wxWindowMGL::GetTextExtent(const wxString& string,
1074 int *x, int *y,
1075 int *descent, int *externalLeading,
1076 const wxFont *theFont) const
1077{
1078 wxScreenDC dc;
1079 if (!theFont)
1080 theFont = &m_font;
1081 dc.GetTextExtent(string, x, y, descent, externalLeading, (wxFont*)theFont);
1082}
1083
a4bbc9f7 1084
a4bbc9f7
VS
1085// ---------------------------------------------------------------------------
1086// painting
1087// ---------------------------------------------------------------------------
1088
1089void wxWindowMGL::Clear()
1090{
1091 wxClientDC dc((wxWindow *)this);
1092 wxBrush brush(GetBackgroundColour(), wxSOLID);
1093 dc.SetBackground(brush);
1094 dc.Clear();
1095}
1096
61bd618f 1097#include "wx/menu.h"
2b260bc3 1098void wxWindowMGL::Refresh(bool eraseBack, const wxRect *rect)
a4bbc9f7 1099{
2b260bc3
VS
1100 if ( m_eraseBackground == -1 )
1101 m_eraseBackground = eraseBack;
1102 else
1103 m_eraseBackground |= eraseBack;
7de59551 1104
a4bbc9f7
VS
1105 if ( rect )
1106 {
1107 rect_t r;
1108 r.left = rect->GetLeft(), r.right = rect->GetRight();
1109 r.top = rect->GetTop(), r.bottom = rect->GetBottom();
1110 MGL_wmInvalidateWindowRect(GetHandle(), &r);
1111 }
1112 else
1113 MGL_wmInvalidateWindow(GetHandle());
1114}
1115
1116void wxWindowMGL::Update()
1117{
a4bbc9f7
VS
1118 if ( !m_frozen )
1119 MGL_wmUpdateDC(g_winMng);
1120}
1121
1122void wxWindowMGL::Freeze()
1123{
127eab18
WS
1124 m_frozen = true;
1125 m_refreshAfterThaw = false;
a4bbc9f7
VS
1126}
1127
1128void wxWindowMGL::Thaw()
1129{
127eab18 1130 m_frozen = false;
a4bbc9f7
VS
1131 if ( m_refreshAfterThaw )
1132 Refresh();
1133}
1134
a4bbc9f7
VS
1135void wxWindowMGL::HandlePaint(MGLDevCtx *dc)
1136{
1137 if ( m_frozen )
1138 {
7de59551 1139 // Don't paint anything if the window is frozen.
127eab18 1140 m_refreshAfterThaw = true;
a4bbc9f7
VS
1141 return;
1142 }
7de59551
RD
1143
1144#ifdef __WXDEBUG__
82186005
VS
1145 // FIXME_MGL -- debugging stuff, to be removed!
1146 static int debugPaintEvents = -1;
1147 if ( debugPaintEvents == -1 )
1148 debugPaintEvents = wxGetEnv(wxT("WXMGL_DEBUG_PAINT_EVENTS"), NULL);
1149 if ( debugPaintEvents )
1150 {
1151 dc->setColorRGB(255,0,255);
1152 dc->fillRect(-1000,-1000,2000,2000);
1153 wxUsleep(50);
1154 }
b8c0528d
VS
1155#endif
1156
fd495ab3
VS
1157 MGLRegion clip;
1158 dc->getClipRegion(clip);
1159 m_updateRegion = wxRegion(clip);
a4bbc9f7
VS
1160 m_paintMGLDC = dc;
1161
a679e129
VS
1162#if wxUSE_CARET
1163 // must hide caret temporarily, otherwise we'd get rendering artifacts
1164 wxCaret *caret = GetCaret();
1165 if ( caret )
1166 caret->Hide();
1167#endif // wxUSE_CARET
1168
2b260bc3 1169 if ( m_eraseBackground != 0 )
7bdc1879 1170 {
2b260bc3
VS
1171 wxWindowDC dc((wxWindow*)this);
1172 wxEraseEvent eventEr(m_windowId, &dc);
1173 eventEr.SetEventObject(this);
1174 GetEventHandler()->ProcessEvent(eventEr);
7bdc1879 1175 }
2b260bc3 1176 m_eraseBackground = -1;
a4bbc9f7
VS
1177
1178 wxNcPaintEvent eventNc(GetId());
1179 eventNc.SetEventObject(this);
1180 GetEventHandler()->ProcessEvent(eventNc);
7de59551 1181
a4bbc9f7
VS
1182 wxPaintEvent eventPt(GetId());
1183 eventPt.SetEventObject(this);
1184 GetEventHandler()->ProcessEvent(eventPt);
a4bbc9f7 1185
a679e129
VS
1186#if wxUSE_CARET
1187 if ( caret )
1188 caret->Show();
1189#endif // wxUSE_CARET
1190
7bdc1879 1191 m_paintMGLDC = NULL;
fd495ab3 1192 m_updateRegion.Clear();
a4bbc9f7
VS
1193}
1194
1195
1196// Find the wxWindow at the current mouse position, returning the mouse
1197// position.
1198wxWindow* wxFindWindowAtPointer(wxPoint& pt)
1199{
1200 return wxFindWindowAtPoint(pt = wxGetMousePosition());
1201}
1202
1203wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
1204{
1205 window_t *wnd = MGL_wmGetWindowAtPosition(g_winMng, pt.x, pt.y);
1206 return (wxWindow*)wnd->userData;
32b8ec41 1207}
d53fc7c9
VS
1208
1209
1210// ---------------------------------------------------------------------------
1211// idle events processing
1212// ---------------------------------------------------------------------------
1213
e39af974 1214void wxWindowMGL::OnInternalIdle()
d53fc7c9 1215{
e39af974
JS
1216 if (wxUpdateUIEvent::CanUpdate(this))
1217 UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
d53fc7c9 1218}