// (based on GTK & MSW implementations)
// RCS-ID: $Id$
// Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
-// Licence: wxWindows license
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ===========================================================================
// headers
// ---------------------------------------------------------------------------
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "window.h"
#endif
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/panel.h"
- #include "wx/caret.h"
#endif
#if wxUSE_DRAG_AND_DROP
#include "wx/mgl/private.h"
#include "wx/intl.h"
#include "wx/dcscreen.h"
+#include "wx/caret.h"
#include <mgraph.hpp>
IMPLEMENT_ABSTRACT_CLASS(wxWindowMGL, wxWindowBase)
BEGIN_EVENT_TABLE(wxWindowMGL, wxWindowBase)
- EVT_IDLE(wxWindowMGL::OnIdle)
END_EVENT_TABLE()
// ===========================================================================
// constructors and such
// ----------------------------------------------------------------------------
-extern wxDisplayModeInfo wxGetDefaultDisplayMode();
+extern wxVideoMode wxGetDefaultDisplayMode();
void wxWindowMGL::Init()
{
wxLogFatalError(_("Cannot initialize display."));
}
- // generic:
- InitBase();
-
// mgl specific:
m_wnd = NULL;
m_isShown = TRUE;
- m_isBeingDeleted = FALSE;
- m_isEnabled = TRUE;
m_frozen = FALSE;
m_paintMGLDC = NULL;
m_eraseBackground = -1;
if ( gs_windowUnderMouse == this )
gs_windowUnderMouse = NULL;
- // VS: destroy children first and _then_ detach *this from its parent.
- // If we'd do it the other way around, children wouldn't be able
- // find their parent frame (see above).
DestroyChildren();
- if ( m_parent )
- m_parent->RemoveChild(this);
-
if ( m_wnd )
MGL_wmDestroyWindow(m_wnd);
}
long mgl_style = 0;
window_t *wnd_parent = parent ? parent->GetHandle() : NULL;
- if ( !(style & wxNO_FULL_REPAINT_ON_RESIZE) )
+ if ( style & wxFULL_REPAINT_ON_RESIZE )
{
mgl_style |= MGL_WM_FULL_REPAINT_ON_RESIZE;
}
// this wxWindowBase function is implemented here (in platform-specific file)
// because it is static and so couldn't be made virtual
// ----------------------------------------------------------------------------
-wxWindow *wxWindowBase::FindFocus()
+wxWindow *wxWindowBase::DoFindFocus()
{
return (wxWindow*)gs_focusedWindow;
}
EVT_setMousePos(x, y);
}
-#if WXWIN_COMPATIBILITY
-// If nothing defined for this, try the parent.
-// E.g. we may be a button loaded from a resource, with no callback function
-// defined.
-void wxWindowMGL::OnCommand(wxWindow& win, wxCommandEvent& event)
-{
- if ( GetEventHandler()->ProcessEvent(event) )
- return;
- if ( m_parent )
- m_parent->GetEventHandler()->OnCommand(win, event);
-}
-#endif // WXWIN_COMPATIBILITY_2
-
-#if WXWIN_COMPATIBILITY
-wxObject* wxWindowMGL::GetChild(int number) const
-{
- // Return a pointer to the Nth object in the Panel
- wxNode *node = GetChildren().First();
- int n = number;
- while (node && n--)
- node = node->Next();
- if ( node )
- {
- wxObject *obj = (wxObject *)node->Data();
- return(obj);
- }
- else
- return NULL;
-}
-#endif // WXWIN_COMPATIBILITY
-
// Set this window to be the child of 'parent'.
bool wxWindowMGL::Reparent(wxWindowBase *parent)
{
void wxWindowMGL::DoMoveWindow(int x, int y, int width, int height)
{
- MGL_wmSetWindowPosition(GetHandle(), x, y, width, height);
+ wxRect rcClient(GetClientRect());
+
+ MGL_wmSetWindowPosition(m_wnd, x, y, width, height);
+
+ // When the origin or a window stays fixed but the height or width
+ // changes, invalidate the old and new non-client areas
+ if ( !HasFlag(wxFULL_REPAINT_ON_RESIZE) &&
+ m_wnd->x == x && m_wnd->y == y &&
+ rcClient.Intersect(GetClientRect()) != wxRect(0, 0, width, height) )
+ {
+ wxRegion rgn(0, 0, width, height);
+ rgn.Subtract(rcClient);
+
+ // This should work I think, but doesn't seem to:
+ //MGL_wmInvalidateWindowRegion(m_wnd, rgn.GetMGLRegion().rgnPointer());
+
+ // Use MGL_wmInvalidateWindowRect instead:
+ for (wxRegionIterator it(rgn); it; it++)
+ {
+ rect_t rc;
+ rc.left = it.GetX();
+ rc.top = it.GetY();
+ rc.right = rc.left + it.GetW();
+ rc.bottom = rc.top + it.GetH();
+ MGL_wmInvalidateWindowRect(m_wnd, &rc);
+ }
+ }
}
// set the size of the window: if the dimensions are positive, just use them,
dc.GetTextExtent(string, x, y, descent, externalLeading, (wxFont*)theFont);
}
-#if wxUSE_CARET && WXWIN_COMPATIBILITY
-// ---------------------------------------------------------------------------
-// Caret manipulation
-// ---------------------------------------------------------------------------
-
-void wxWindowMGL::CreateCaret(int w, int h)
-{
- SetCaret(new wxCaret(this, w, h));
-}
-
-void wxWindowMGL::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
-{
- wxFAIL_MSG("not implemented");
-}
-
-void wxWindowMGL::ShowCaret(bool show)
-{
- wxCHECK_RET( m_caret, "no caret to show" );
-
- m_caret->Show(show);
-}
-
-void wxWindowMGL::DestroyCaret()
-{
- SetCaret(NULL);
-}
-
-void wxWindowMGL::SetCaretPos(int x, int y)
-{
- wxCHECK_RET( m_caret, "no caret to move" );
-
- m_caret->Move(x, y);
-}
-
-void wxWindowMGL::GetCaretPos(int *x, int *y) const
-{
- wxCHECK_RET( m_caret, "no caret to get position of" );
-
- m_caret->GetPosition(x, y);
-}
-#endif // wxUSE_CARET
-
// ---------------------------------------------------------------------------
// painting
// idle events processing
// ---------------------------------------------------------------------------
-void wxWindowMGL::OnIdle(wxIdleEvent& WXUNUSED(event))
+void wxWindowMGL::OnInternalIdle()
{
- UpdateWindowUI();
+ if (wxUpdateUIEvent::CanUpdate(this))
+ UpdateWindowUI(wxUPDATE_UI_FROMIDLE);
}