From fedec9812667b3f11c40d7d9be1e2e1c71ab41fa Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 27 Sep 2003 12:55:46 +0000 Subject: [PATCH] merged wxDisplayModeInfo and wxVideoMode in a single class, extracted it in a separate wx/vidmode.h header git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23959 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/app.h | 33 +++----------------- include/wx/display.h | 49 +---------------------------- include/wx/mgl/app.h | 6 ++-- include/wx/vidmode.h | 73 ++++++++++++++++++++++++++++++++++++++++++++ src/mgl/app.cpp | 8 ++--- 5 files changed, 85 insertions(+), 84 deletions(-) create mode 100644 include/wx/vidmode.h diff --git a/include/wx/app.h b/include/wx/app.h index eb507ed17d..7c2b61c4e3 100644 --- a/include/wx/app.h +++ b/include/wx/app.h @@ -21,6 +21,8 @@ #if wxUSE_GUI #include "wx/window.h" // for wxTopLevelWindows + + #include "wx/vidmode.h" #endif // wxUSE_GUI #include "wx/build.h" @@ -59,33 +61,6 @@ enum wxPRINT_POSTSCRIPT = 2 }; -// ---------------------------------------------------------------------------- -// support for framebuffer ports -// ---------------------------------------------------------------------------- - -#if wxUSE_GUI -// VS: Fullscreen/framebuffer application needs to choose display mode prior -// to wxWindows initialization. This class holds information about display -// mode. It is used by wxApp::Set/GetDisplayMode. -class WXDLLIMPEXP_CORE wxDisplayModeInfo -{ -public: - wxDisplayModeInfo() : m_ok(FALSE) {} - wxDisplayModeInfo(unsigned width, unsigned height, unsigned depth) - : m_width(width), m_height(height), m_depth(depth), m_ok(TRUE) {} - - unsigned GetWidth() const { return m_width; } - unsigned GetHeight() const { return m_height; } - unsigned GetDepth() const { return m_depth; } - bool IsOk() const { return m_ok; } - -private: - unsigned m_width, m_height, m_depth; - bool m_ok; -}; -#endif // wxUSE_GUI - - // ---------------------------------------------------------------------------- // wxAppConsole: wxApp for non-GUI applications // ---------------------------------------------------------------------------- @@ -482,11 +457,11 @@ public: // Get display mode that is used use. This is only used in framebuffer // wxWin ports (such as wxMGL). - virtual wxDisplayModeInfo GetDisplayMode() const { return wxDisplayModeInfo(); } + virtual wxVideoMode GetDisplayMode() const { return wxVideoMode(); } // Set display mode to use. This is only used in framebuffer wxWin // ports (such as wxMGL). This method should be called from // wxApp::OnInitGui - virtual bool SetDisplayMode(const wxDisplayModeInfo& WXUNUSED(info)) { return TRUE; } + virtual bool SetDisplayMode(const wxVideoMode& WXUNUSED(info)) { return TRUE; } // set use of best visual flag (see below) void SetUseBestVisual( bool flag ) { m_useBestVisual = flag; } diff --git a/include/wx/display.h b/include/wx/display.h index 11c4bd0117..835a233b23 100644 --- a/include/wx/display.h +++ b/include/wx/display.h @@ -19,60 +19,13 @@ #endif #include "wx/dynarray.h" +#include "wx/vidmode.h" class WXDLLEXPORT wxWindow; class WXDLLEXPORT wxPoint; class WXDLLEXPORT wxRect; class WXDLLEXPORT wxString; -// ---------------------------------------------------------------------------- -// wxVideoMode: contains video mode parameters for a display -// ---------------------------------------------------------------------------- - -struct WXDLLEXPORT wxVideoMode -{ - wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0) - { - w = width; - h = height; - - bpp = depth; - - refresh = freq; - } - - // default copy ctor and assignment operator are ok - - bool operator==(const wxVideoMode& m) const - { - return w == m.w && h == m.h && bpp == m.bpp && refresh == m.refresh; - } - bool operator!=(const wxVideoMode& mode) const - { - return !operator==(mode); - } - - // returns true if this mode matches the other one in the sense that all - // non zero fields of the other mode have the same value in this one - // (except for refresh which is allowed to have a greater value) - bool Matches(const wxVideoMode& other) const - { - return (!other.w || w == other.w) && - (!other.h || h == other.h) && - (!other.bpp || bpp == other.bpp) && - (!other.refresh || refresh >= other.refresh); - } - - // the screen size in pixels (e.g. 640*480), 0 means unspecified - int w, h; - - // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known - int bpp; - - // refresh frequency in Hz, 0 means unspecified/unknown - int refresh; -}; - WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes); // default, uninitialized, video mode object diff --git a/include/wx/mgl/app.h b/include/wx/mgl/app.h index fa98fc1e93..5cd952e867 100644 --- a/include/wx/mgl/app.h +++ b/include/wx/mgl/app.h @@ -51,14 +51,14 @@ public: virtual void WakeUpIdle(); virtual bool Yield(bool onlyIfNeeded = FALSE); - virtual wxDisplayModeInfo GetDisplayMode() const { return m_displayMode; } - virtual bool SetDisplayMode(const wxDisplayModeInfo& mode); + virtual wxVideoMode GetDisplayMode() const { return m_displayMode; } + virtual bool SetDisplayMode(const wxVideoMode& mode); private: DECLARE_DYNAMIC_CLASS(wxApp) DECLARE_EVENT_TABLE() - wxDisplayModeInfo m_displayMode; + wxVideoMode m_displayMode; }; #endif // __WX_APP_H__ diff --git a/include/wx/vidmode.h b/include/wx/vidmode.h new file mode 100644 index 0000000000..70853dc500 --- /dev/null +++ b/include/wx/vidmode.h @@ -0,0 +1,73 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: wx/vidmode.h +// Purpose: declares wxVideoMode class used by both wxDisplay and wxApp +// Author: Vadim Zeitlin +// Modified by: +// Created: 27.09.2003 (extracted from wx/display.h) +// RCS-ID: $Id$ +// Copyright: (c) 2003 Vadim Zeitlin +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#ifndef _WX_VMODE_H_ +#define _WX_VMODE_H_ + +// ---------------------------------------------------------------------------- +// wxVideoMode: a simple struct containing video mode parameters for a display +// ---------------------------------------------------------------------------- + +struct WXDLLEXPORT wxVideoMode +{ + wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0) + { + w = width; + h = height; + + bpp = depth; + + refresh = freq; + } + + // default copy ctor and assignment operator are ok + + bool operator==(const wxVideoMode& m) const + { + return w == m.w && h == m.h && bpp == m.bpp && refresh == m.refresh; + } + bool operator!=(const wxVideoMode& mode) const + { + return !operator==(mode); + } + + // returns true if this mode matches the other one in the sense that all + // non zero fields of the other mode have the same value in this one + // (except for refresh which is allowed to have a greater value) + bool Matches(const wxVideoMode& other) const + { + return (!other.w || w == other.w) && + (!other.h || h == other.h) && + (!other.bpp || bpp == other.bpp) && + (!other.refresh || refresh >= other.refresh); + } + + // trivial accessors + int GetWidth() const { return w; } + int GetHeight() const { return h; } + int GetDepth() const { return bpp; } + + // returns true if the object has been initialized + bool IsOk() const { return w && h; } + + + // the screen size in pixels (e.g. 640*480), 0 means unspecified + int w, h; + + // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known + int bpp; + + // refresh frequency in Hz, 0 means unspecified/unknown + int refresh; +}; + +#endif // _WX_VMODE_H_ + diff --git a/src/mgl/app.cpp b/src/mgl/app.cpp index dffb68253c..327356b8e7 100644 --- a/src/mgl/app.cpp +++ b/src/mgl/app.cpp @@ -147,7 +147,7 @@ static wxRootWindow *gs_rootWindow = NULL; // MGL initialization //----------------------------------------------------------------------------- -static bool wxCreateMGL_WM(const wxDisplayModeInfo& displayMode) +static bool wxCreateMGL_WM(const wxVideoMode& displayMode) { int mode; int refresh = MGL_DEFAULT_REFRESH; @@ -216,7 +216,7 @@ wxApp::~wxApp() { } -wxDisplayModeInfo wxGetDefaultDisplayMode() +wxVideoMode wxGetDefaultDisplayMode() { wxString mode; unsigned w, h, bpp; @@ -227,10 +227,10 @@ wxDisplayModeInfo wxGetDefaultDisplayMode() w = 640, h = 480, bpp = 16; } - return wxDisplayModeInfo(w, h, bpp); + return wxVideoMode(w, h, bpp); } -bool wxApp::SetDisplayMode(const wxDisplayModeInfo& mode) +bool wxApp::SetDisplayMode(const wxVideoMode& mode) { if ( !mode.IsOk() ) {