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
This commit is contained in:
Vadim Zeitlin 2003-09-27 12:55:46 +00:00
parent 3dd514f167
commit fedec98126
5 changed files with 85 additions and 84 deletions

View File

@ -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; }

View File

@ -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

View File

@ -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__

73
include/wx/vidmode.h Normal file
View File

@ -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 <vadim@wxwindows.org>
// 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_

View File

@ -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() )
{