X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a536e411022b21280532c9daadc806a437fbb4c6..931d6a47c32a5b4c283243cb553ce71ee2b535d5:/include/wx/display.h diff --git a/include/wx/display.h b/include/wx/display.h index e62be18768..4678672138 100644 --- a/include/wx/display.h +++ b/include/wx/display.h @@ -1,81 +1,127 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: display.h +// Name: wx/display.h // Purpose: wxDisplay class -// Author: Royce Mitchell III -// Modified by: +// Author: Royce Mitchell III, Vadim Zeitlin // Created: 06/21/02 -// RCS-ID: $Id$ -// Copyright: (c) wxWindows team +// Copyright: (c) 2002-2006 wxWidgets team // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DISPLAY_H_BASE_ #define _WX_DISPLAY_H_BASE_ +// 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 + #if wxUSE_DISPLAY + #include "wx/dynarray.h" + #include "wx/vidmode.h" + + WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes); + + // default, uninitialized, video mode object + extern WXDLLIMPEXP_DATA_CORE(const wxVideoMode) wxDefaultVideoMode; +#endif // wxUSE_DISPLAY -#ifdef __GNUG__ - #pragma interface "display.h" -#endif +class WXDLLIMPEXP_FWD_CORE wxWindow; +class WXDLLIMPEXP_FWD_CORE wxPoint; +class WXDLLIMPEXP_FWD_CORE wxRect; +class WXDLLIMPEXP_FWD_BASE wxString; -class wxPoint; -class wxRect; -class wxString; +class WXDLLIMPEXP_FWD_CORE wxDisplayFactory; +class WXDLLIMPEXP_FWD_CORE wxDisplayImpl; -class WXDLLEXPORT wxDisplayBase +// ---------------------------------------------------------------------------- +// wxDisplay: represents a display/monitor attached to the system +// ---------------------------------------------------------------------------- + +class WXDLLIMPEXP_CORE wxDisplay { public: // initialize the object containing all information about the given // display - wxDisplayBase ( size_t index = 0 ) : m_index ( index ) - { - wxASSERT_MSG(m_index < wxDisplayBase::GetCount(), wxT("An invalid index was passed to wxDisplay")); - } + // + // the displays are numbered from 0 to GetCount() - 1, 0 is always the + // primary display and the only one which is always supported + wxDisplay(unsigned n = 0); + + // dtor is not virtual as this is a concrete class not meant to be derived + // from + ~wxDisplay(); - // accessors // return the number of available displays, valid parameters to // wxDisplay ctor are from 0 up to this number - static size_t GetCount(); + static unsigned GetCount(); - // find the display where the given point lies, return -1 if + // find the display where the given point lies, return wxNOT_FOUND if // it doesn't belong to any display - static int GetFromPoint ( const wxPoint& pt ); + static int GetFromPoint(const wxPoint& pt); + + // find the display where the given window lies, return wxNOT_FOUND if it + // is not shown at all + static int GetFromWindow(const wxWindow *window); + - virtual wxRect GetGeometry() const = 0; - virtual int GetDepth() const = 0; - bool IsColour() const { return GetDepth() != 1; } + // return true if the object was initialized successfully + bool IsOk() const { return m_impl != NULL; } - // some people never learn to spell ;-) - bool IsColor() const { return IsColour(); } + // get the full display size + wxRect GetGeometry() const; + + // get the client area of the display, i.e. without taskbars and such + wxRect GetClientArea() const; // name may be empty - virtual wxString GetName() const = 0; + wxString GetName() const; - // let display 0 always be the primary display - bool IsPrimary() { return m_index == 0; } + // display 0 is usually the primary display + bool IsPrimary() const; - virtual ~wxDisplayBase() {} +#if wxUSE_DISPLAY + // enumerate all video modes supported by this display matching the given + // one (in the sense of wxVideoMode::Match()) + // + // as any mode matches the default value of the argument and there is + // 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 + wxArrayVideoModes + GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const; + + // get current video mode + 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 + bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode); + + // restore the default video mode (just a more readable synonym) + void ResetMode() { (void)ChangeMode(); } +#endif // wxUSE_DISPLAY -protected: - size_t m_index; // which display did we select when creating this file? +private: + // returns the factory used to implement our static methods and create new + // displays + static wxDisplayFactory& Factory(); - DECLARE_NO_COPY_CLASS(wxDisplayBase); -}; + // 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(); -#if defined(__WXMSW__) - #include "wx/msw/display.h" -#elif defined(__WXMOTIF__) - #include "wx/motif/display.h" -#elif defined(__WXGTK__) - #include "wx/gtk/display.h" -#elif defined(__WXMAC__) - #include "wx/mac/display.h" -#elif defined(__WXPM__) - #include "wx/os2/display.h" -#endif -#endif // wxUSE_DISPLAY + // the real implementation + wxDisplayImpl *m_impl; + + + wxDECLARE_NO_COPY_CLASS(wxDisplay); +}; #endif // _WX_DISPLAY_H_BASE_