From: Václav Slavík Date: Sun, 4 Nov 2001 00:00:36 +0000 (+0000) Subject: implemented display mode setting X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/634f6a1f0a5e863305bf1152e287fdf486433eee?ds=sidebyside implemented display mode setting git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/mgl/app.h b/include/wx/mgl/app.h index 526328c674..529e61da5b 100644 --- a/include/wx/mgl/app.h +++ b/include/wx/mgl/app.h @@ -24,7 +24,6 @@ class WXDLLEXPORT wxApp; class WXDLLEXPORT wxLog; class WXDLLEXPORT wxEventLoop; -class WXDLLEXPORT wxDesktopWindow; //----------------------------------------------------------------------------- // wxApp @@ -64,11 +63,15 @@ public: virtual bool Yield(bool onlyIfNeeded = FALSE); + virtual wxDisplayModeInfo GetDisplayMode() const { return m_displayMode; } + virtual bool SetDisplayMode(const wxDisplayModeInfo& mode); + private: DECLARE_DYNAMIC_CLASS(wxApp) DECLARE_EVENT_TABLE() wxEventLoop *m_mainLoop; + wxDisplayModeInfo m_displayMode; }; int WXDLLEXPORT wxEntry(int argc, char *argv[]); diff --git a/src/mgl/app.cpp b/src/mgl/app.cpp index 39d708ed0b..164860cf2a 100644 --- a/src/mgl/app.cpp +++ b/src/mgl/app.cpp @@ -155,10 +155,9 @@ static wxRootWindow *gs_rootWindow = NULL; // MGL initialization //----------------------------------------------------------------------------- -static bool wxCreateMGL_WM() +static bool wxCreateMGL_WM(const wxDisplayModeInfo& displayMode) { int mode; - int width = 640, height = 480, depth = 16; int refresh = MGL_DEFAULT_REFRESH; #if wxUSE_SYSTEM_OPTIONS @@ -166,10 +165,15 @@ static bool wxCreateMGL_WM() refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh")); #endif - mode = MGL_findMode(width, height, depth); + mode = MGL_findMode(displayMode.GetScreenSize().x, + displayMode.GetScreenSize().y, + displayMode.GetDepth()); if ( mode == -1 ) { - wxLogWarning(_("Mode %ix%i-%i not available, falling back to default mode."), width, height, depth); + wxLogWarning(_("Mode %ix%i-%i not available, falling back to default mode."), + displayMode.GetScreenSize().x, + displayMode.GetScreenSize().y, + displayMode.GetDepth()); mode = 0; // always available } g_displayDC = new MGLDisplayDC(mode, 1, refresh); @@ -214,15 +218,33 @@ END_EVENT_TABLE() wxApp::wxApp() : m_mainLoop(NULL) { + m_displayMode = wxDisplayModeInfo(wxSize(640, 480), 16); } wxApp::~wxApp() { } +bool wxApp::SetDisplayMode(const wxDisplayModeInfo& mode) +{ + if ( !mode.IsOk() ) + { + return FALSE; + } + if ( g_displayDC != NULL ) + { + // FIXME_MGL -- we currently don't allow to switch video mode + // at runtime. This can hopefully be changed... + wxFAIL_MSG(wxT("Can't change display mode after intialization!")); + return FALSE; + } + m_displayMode = mode; + return TRUE; +} + bool wxApp::OnInitGui() { - if ( !wxCreateMGL_WM() ) + if ( !wxCreateMGL_WM(m_displayMode) ) return FALSE; // This has to be done *after* wxCreateMGL_WM() because it initializes diff --git a/src/mgl/window.cpp b/src/mgl/window.cpp index 08ad332bce..6b6c5df6e5 100644 --- a/src/mgl/window.cpp +++ b/src/mgl/window.cpp @@ -127,8 +127,6 @@ static void wxWindowPainter(window_t *wnd, MGLDC *dc) MGLDevCtx ctx(dc); w->HandlePaint(&ctx); } - // FIXME_MGL -- root window should be a regular window so that - // enter/leave and activate/deactivate events work correctly } static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)