cleanup in wxMGL code

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12223 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-10-30 23:30:51 +00:00
parent 253293c103
commit 580616706f
9 changed files with 113 additions and 346 deletions

View File

@@ -33,6 +33,7 @@
#include "wx/fontutil.h"
#include "wx/univ/theme.h"
#include "wx/univ/renderer.h"
#include "wx/univ/colschem.h"
#include "wx/mgl/private.h"
#define MGL_DEBUG
@@ -127,6 +128,79 @@ void wxWakeUpIdle()
#endif
}
//-----------------------------------------------------------------------------
// Root window
//-----------------------------------------------------------------------------
class wxRootWindow : public wxWindow
{
public:
wxRootWindow() : wxWindow(NULL, -1)
{
SetMGLwindow_t(MGL_wmGetRootWindow(g_winMng));
SetBackgroundColour(wxTHEME_COLOUR(DESKTOP));
}
~wxRootWindow()
{
// we don't want to delete MGL_WM's rootWnd
m_wnd = NULL;
}
virtual bool AcceptsFocus() { return FALSE; }
};
static wxRootWindow *gs_rootWindow = NULL;
//-----------------------------------------------------------------------------
// MGL initialization
//-----------------------------------------------------------------------------
static bool wxCreateMGL_WM()
{
int mode;
int width = 640, height = 480, depth = 16;
int refresh = MGL_DEFAULT_REFRESH;
#if wxUSE_SYSTEM_OPTIONS
if ( wxSystemOptions::HasOption(wxT("mgl.screen-refresh") )
refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh"));
#endif
mode = MGL_findMode(width, height, depth);
if ( mode == -1 )
{
wxLogWarning(_("Mode %ix%i-%i not available, falling back to default mode."), width, height, depth);
mode = 0; // always available
}
g_displayDC = new MGLDisplayDC(mode, 1, refresh);
if ( !g_displayDC->isValid() )
{
delete g_displayDC;
g_displayDC = NULL;
return FALSE;
}
g_winMng = MGL_wmCreate(g_displayDC->getDC());
if (!g_winMng)
return FALSE;
return TRUE;
}
static void wxDestroyMGL_WM()
{
if ( g_winMng )
{
MGL_wmDestroy(g_winMng);
g_winMng = NULL;
}
if ( g_displayDC )
{
delete g_displayDC;
g_displayDC = NULL;
}
}
//-----------------------------------------------------------------------------
// wxApp
//-----------------------------------------------------------------------------
@@ -155,6 +229,9 @@ bool wxApp::OnInitGui()
// wxUniv's themes
if ( !wxAppBase::OnInitGui() )
return FALSE;
// ...and this has to be done after wxUniv themes were initialized
gs_rootWindow = new wxRootWindow;
#ifdef MGL_DEBUG
// That damn MGL redirects stdin and stdout to physical console
@@ -335,6 +412,8 @@ wxIcon wxApp::GetStdIcon(int which) const
void wxApp::CleanUp()
{
delete gs_rootWindow;
#if wxUSE_LOG
// flush the logged messages if any
wxLog *log = wxLog::GetActiveTarget();