implemented display mode setting
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@12299 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -24,7 +24,6 @@
|
|||||||
class WXDLLEXPORT wxApp;
|
class WXDLLEXPORT wxApp;
|
||||||
class WXDLLEXPORT wxLog;
|
class WXDLLEXPORT wxLog;
|
||||||
class WXDLLEXPORT wxEventLoop;
|
class WXDLLEXPORT wxEventLoop;
|
||||||
class WXDLLEXPORT wxDesktopWindow;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxApp
|
// wxApp
|
||||||
@@ -64,11 +63,15 @@ public:
|
|||||||
|
|
||||||
virtual bool Yield(bool onlyIfNeeded = FALSE);
|
virtual bool Yield(bool onlyIfNeeded = FALSE);
|
||||||
|
|
||||||
|
virtual wxDisplayModeInfo GetDisplayMode() const { return m_displayMode; }
|
||||||
|
virtual bool SetDisplayMode(const wxDisplayModeInfo& mode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxApp)
|
DECLARE_DYNAMIC_CLASS(wxApp)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
wxEventLoop *m_mainLoop;
|
wxEventLoop *m_mainLoop;
|
||||||
|
wxDisplayModeInfo m_displayMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
int WXDLLEXPORT wxEntry(int argc, char *argv[]);
|
int WXDLLEXPORT wxEntry(int argc, char *argv[]);
|
||||||
|
@@ -155,10 +155,9 @@ static wxRootWindow *gs_rootWindow = NULL;
|
|||||||
// MGL initialization
|
// MGL initialization
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
static bool wxCreateMGL_WM()
|
static bool wxCreateMGL_WM(const wxDisplayModeInfo& displayMode)
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
int width = 640, height = 480, depth = 16;
|
|
||||||
int refresh = MGL_DEFAULT_REFRESH;
|
int refresh = MGL_DEFAULT_REFRESH;
|
||||||
|
|
||||||
#if wxUSE_SYSTEM_OPTIONS
|
#if wxUSE_SYSTEM_OPTIONS
|
||||||
@@ -166,10 +165,15 @@ static bool wxCreateMGL_WM()
|
|||||||
refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh"));
|
refresh = wxSystemOptions::GetOptionInt(wxT("mgl.screen-refresh"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mode = MGL_findMode(width, height, depth);
|
mode = MGL_findMode(displayMode.GetScreenSize().x,
|
||||||
|
displayMode.GetScreenSize().y,
|
||||||
|
displayMode.GetDepth());
|
||||||
if ( mode == -1 )
|
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
|
mode = 0; // always available
|
||||||
}
|
}
|
||||||
g_displayDC = new MGLDisplayDC(mode, 1, refresh);
|
g_displayDC = new MGLDisplayDC(mode, 1, refresh);
|
||||||
@@ -214,15 +218,33 @@ END_EVENT_TABLE()
|
|||||||
|
|
||||||
wxApp::wxApp() : m_mainLoop(NULL)
|
wxApp::wxApp() : m_mainLoop(NULL)
|
||||||
{
|
{
|
||||||
|
m_displayMode = wxDisplayModeInfo(wxSize(640, 480), 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxApp::~wxApp()
|
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()
|
bool wxApp::OnInitGui()
|
||||||
{
|
{
|
||||||
if ( !wxCreateMGL_WM() )
|
if ( !wxCreateMGL_WM(m_displayMode) )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// This has to be done *after* wxCreateMGL_WM() because it initializes
|
// This has to be done *after* wxCreateMGL_WM() because it initializes
|
||||||
|
@@ -127,8 +127,6 @@ static void wxWindowPainter(window_t *wnd, MGLDC *dc)
|
|||||||
MGLDevCtx ctx(dc);
|
MGLDevCtx ctx(dc);
|
||||||
w->HandlePaint(&ctx);
|
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)
|
static ibool wxWindowMouseHandler(window_t *wnd, event_t *e)
|
||||||
|
Reference in New Issue
Block a user