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