1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxDisplay class
4 // Author: Royce Mitchell III
5 // Modified by: Vadim Zeitlin (resolution changes, display modes, ...)
8 // Copyright: (c) 2002-2003 wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_DISPLAY_H_BASE_
13 #define _WX_DISPLAY_H_BASE_
17 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "displaybase.h"
21 #include "wx/dynarray.h"
23 class WXDLLEXPORT wxWindow
;
24 class WXDLLEXPORT wxPoint
;
25 class WXDLLEXPORT wxRect
;
26 class WXDLLEXPORT wxString
;
28 // ----------------------------------------------------------------------------
29 // wxVideoMode: contains video mode parameters for a display
30 // ----------------------------------------------------------------------------
32 struct WXDLLEXPORT wxVideoMode
34 wxVideoMode(int width
= 0, int height
= 0, int depth
= 0, int freq
= 0)
44 // default copy ctor and assignment operator are ok
46 bool operator==(const wxVideoMode
& m
) const
48 return w
== m
.w
&& h
== m
.h
&& bpp
== m
.bpp
&& refresh
== m
.refresh
;
50 bool operator!=(const wxVideoMode
& mode
) const
52 return !operator==(mode
);
55 // returns true if this mode matches the other one in the sense that all
56 // non zero fields of the other mode have the same value in this one
57 // (except for refresh which is allowed to have a greater value)
58 bool Matches(const wxVideoMode
& other
) const
60 return (!other
.w
|| w
== other
.w
) &&
61 (!other
.h
|| h
== other
.h
) &&
62 (!other
.bpp
|| bpp
== other
.bpp
) &&
63 (!other
.refresh
|| refresh
>= other
.refresh
);
66 // the screen size in pixels (e.g. 640*480), 0 means unspecified
69 // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known
72 // refresh frequency in Hz, 0 means unspecified/unknown
76 WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode
, wxArrayVideoModes
);
78 // default, uninitialized, video mode object
79 WXDLLEXPORT_DATA(extern const wxVideoMode
) wxDefaultVideoMode
;
81 // ----------------------------------------------------------------------------
82 // wxDisplayBase: represents a display/monitor attached to the system
83 // ----------------------------------------------------------------------------
85 class WXDLLEXPORT wxDisplayBase
88 // initialize the object containing all information about the given
91 // the displays are numbered from 0 to GetCount() - 1, 0 is always the
92 // primary display and the only one which is always supported
93 wxDisplayBase(size_t index
= 0);
95 // return the number of available displays, valid parameters to
96 // wxDisplay ctor are from 0 up to this number
97 static size_t GetCount();
99 // find the display where the given point lies, return wxNOT_FOUND if
100 // it doesn't belong to any display
101 static int GetFromPoint(const wxPoint
& pt
);
103 // find the display where the given window lies, return wxNOT_FOUND if it
104 // is not shown at all
105 static int GetFromWindow(wxWindow
*window
);
108 // return true if the object was initialized successfully
109 virtual bool IsOk() const { return true; }
111 // get the display size
112 virtual wxRect
GetGeometry() const = 0;
115 virtual wxString
GetName() const = 0;
117 // display 0 is always the primary display
118 bool IsPrimary() const { return m_index
== 0; }
121 // enumerate all video modes supported by this display matching the given
122 // one (in the sense of wxVideoMode::Match())
124 // as any mode matches the default value of the argument and there is
125 // always at least one video mode supported by display, the returned array
126 // is only empty for the default value of the argument if this function is
127 // not supported at all on this platform
128 virtual wxArrayVideoModes
129 GetModes(const wxVideoMode
& mode
= wxDefaultVideoMode
) const = 0;
131 // get current video mode
132 virtual wxVideoMode
GetCurrentMode() const = 0;
134 // change current mode, return true if succeeded, false otherwise
136 // for the default value of the argument restores the video mode to default
137 virtual bool ChangeMode(const wxVideoMode
& mode
= wxDefaultVideoMode
) = 0;
139 // restore the default video mode (just a more readable synonym)
140 void ResetMode() { (void)ChangeMode(); }
142 // virtual dtor as for any base class
143 virtual ~wxDisplayBase() { }
146 // the index of this display (0 is always the primary one)
149 DECLARE_NO_COPY_CLASS(wxDisplayBase
)
153 #if defined(__WXMSW__)
154 #include "wx/msw/display.h"
155 #elif defined(__WXMOTIF__)
156 #include "wx/unix/displayx11.h"
157 #elif defined(__WXGTK__)
158 #include "wx/unix/displayx11.h"
159 #elif defined(__WXMAC__)
160 #include "wx/mac/display.h"
161 #elif defined(__WXPM__)
162 #include "wx/os2/display.h"
165 #endif // wxUSE_DISPLAY
167 #endif // _WX_DISPLAY_H_BASE_