wxDisplay cleanup/rewrite:

- wxDisplay is now a concrete class and uses a pImpl-based design
- got rid of four duplicate but subtly different versions of trivial
  single display-only wxDisplay implementation (but 2 versions of Mac
  Classic and Mac CoreGraphics implementations each still remain...)
- assorted code simplifications and memory leaks fixes


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38127 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-03-16 04:23:07 +00:00
parent 8072477d51
commit ef1717a963
23 changed files with 1739 additions and 2073 deletions

View File

@@ -1,37 +1,43 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/display.h
// Purpose: wxDisplay class
// Author: Royce Mitchell III
// Modified by: Vadim Zeitlin (resolution changes, display modes, ...)
// Author: Royce Mitchell III, Vadim Zeitlin
// Created: 06/21/02
// RCS-ID: $Id$
// Copyright: (c) 2002-2003 wxWidgets team
// Copyright: (c) 2002-2006 wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DISPLAY_H_BASE_
#define _WX_DISPLAY_H_BASE_
#if wxUSE_DISPLAY
// NB: no #if wxUSE_DISPLAY here, the display geometry part of this class (but
// not the video mode stuff) is always available but if wxUSE_DISPLAY == 0
// it becomes just a trivial wrapper around the old wxDisplayXXX() functions
#include "wx/dynarray.h"
#include "wx/vidmode.h"
#if wxUSE_DISPLAY
#include "wx/dynarray.h"
#include "wx/vidmode.h"
WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes);
// default, uninitialized, video mode object
extern WXDLLEXPORT_DATA(const wxVideoMode) wxDefaultVideoMode;
#endif // wxUSE_DISPLAY
class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxPoint;
class WXDLLEXPORT wxRect;
class WXDLLEXPORT wxString;
WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes);
// default, uninitialized, video mode object
extern WXDLLEXPORT_DATA(const wxVideoMode) wxDefaultVideoMode;
class WXDLLEXPORT wxDisplayFactory;
class WXDLLEXPORT wxDisplayImpl;
// ----------------------------------------------------------------------------
// wxDisplayBase: represents a display/monitor attached to the system
// wxDisplay: represents a display/monitor attached to the system
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxDisplayBase
class WXDLLEXPORT wxDisplay
{
public:
// initialize the object containing all information about the given
@@ -39,7 +45,12 @@ public:
//
// the displays are numbered from 0 to GetCount() - 1, 0 is always the
// primary display and the only one which is always supported
wxDisplayBase(size_t index = 0);
wxDisplay(size_t n = 0);
// dtor is not virtual as this is a concrete class not meant to be derived
// from
~wxDisplay();
// return the number of available displays, valid parameters to
// wxDisplay ctor are from 0 up to this number
@@ -55,18 +66,19 @@ public:
// return true if the object was initialized successfully
virtual bool IsOk() const { return true; }
bool IsOk() const { return m_impl != NULL; }
// get the display size
virtual wxRect GetGeometry() const = 0;
wxRect GetGeometry() const;
// name may be empty
virtual wxString GetName() const = 0;
wxString GetName() const;
// display 0 is usually the primary display
virtual bool IsPrimary() const { return m_index == 0; }
bool IsPrimary() const;
#if wxUSE_DISPLAY
// enumerate all video modes supported by this display matching the given
// one (in the sense of wxVideoMode::Match())
//
@@ -74,49 +86,40 @@ public:
// always at least one video mode supported by display, the returned array
// is only empty for the default value of the argument if this function is
// not supported at all on this platform
virtual wxArrayVideoModes
GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const = 0;
wxArrayVideoModes
GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const;
// get current video mode
virtual wxVideoMode GetCurrentMode() const = 0;
wxVideoMode GetCurrentMode() const;
// change current mode, return true if succeeded, false otherwise
//
// for the default value of the argument restores the video mode to default
virtual bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode) = 0;
bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode);
// restore the default video mode (just a more readable synonym)
void ResetMode() { (void)ChangeMode(); }
// virtual dtor as for any base class
virtual ~wxDisplayBase() { }
protected:
// the index of this display (0 is always the primary one)
size_t m_index;
DECLARE_NO_COPY_CLASS(wxDisplayBase)
};
#if defined(__WXMSW__)
#include "wx/msw/display.h"
#elif defined(__WXMOTIF__)
#include "wx/unix/displayx11.h"
#elif defined(__WXGTK__)
#include "wx/unix/displayx11.h"
#elif defined(__WXX11__)
#include "wx/unix/displayx11.h"
#elif defined(__WXCOCOA__)
#include "wx/cocoa/display.h"
#elif defined(__WXMAC__)
#include "wx/mac/display.h"
#elif defined(__WXPM__)
#include "wx/os2/display.h"
#elif defined(__WXMGL__)
#include "wx/mgl/display.h"
#endif
#endif // wxUSE_DISPLAY
private:
// returns the factory used to implement our static methods and create new
// displays
static wxDisplayFactory& Factory();
// creates the factory object, called by Factory() when it is called for
// the first time and should return a pointer allocated with new (the
// caller will delete it)
//
// this method must be implemented in platform-specific code if
// wxUSE_DISPLAY == 1 (if it is 0 we provide the stub in common code)
static wxDisplayFactory *CreateFactory();
// the real implementation
wxDisplayImpl *m_impl;
DECLARE_NO_COPY_CLASS(wxDisplay)
};
#endif // _WX_DISPLAY_H_BASE_