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(__APPLE__)
18 #pragma interface "displaybase.h"
21 #include "wx/dynarray.h"
23 class WXDLLEXPORT wxWindow
;
25 // ----------------------------------------------------------------------------
26 // wxVideoMode: contains video mode parameters for a display
27 // ----------------------------------------------------------------------------
29 struct WXDLLEXPORT wxVideoMode
31 wxVideoMode(int width
= 0, int height
= 0, int depth
= 0, int freq
= 0)
41 // default copy ctor and assignment operator are ok
43 bool operator==(const wxVideoMode
& m
) const
45 return w
== m
.w
&& h
== m
.h
&& bpp
== m
.bpp
&& refresh
== m
.refresh
;
47 bool operator!=(const wxVideoMode
& mode
) const
49 return !operator==(mode
);
52 // returns true if this mode matches the other one in the sense that all
53 // non zero fields of the other mode have the same value in this one
54 // (except for refresh which is allowed to have a greater value)
55 bool Matches(const wxVideoMode
& other
) const
57 return (!other
.w
|| w
== other
.w
) &&
58 (!other
.h
|| h
== other
.h
) &&
59 (!other
.bpp
|| bpp
== other
.bpp
) &&
60 (!other
.refresh
|| refresh
>= other
.refresh
);
63 // the screen size in pixels (e.g. 640*480), 0 means unspecified
66 // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known
69 // refresh frequency in Hz, 0 means unspecified/unknown
73 WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode
, wxArrayVideoModes
);
75 // default, uninitialized, video mode object
76 WXDLLEXPORT_DATA(extern const wxVideoMode
) wxDefaultVideoMode
;
78 // ----------------------------------------------------------------------------
79 // wxDisplayBase: represents a display/monitor attached to the system
80 // ----------------------------------------------------------------------------
82 class WXDLLEXPORT wxDisplayBase
85 // initialize the object containing all information about the given
88 // the displays are numbered from 0 to GetCount() - 1, 0 is always the
89 // primary display and the only one which is always supported
90 wxDisplayBase(size_t index
= 0);
92 // return the number of available displays, valid parameters to
93 // wxDisplay ctor are from 0 up to this number
94 static size_t GetCount();
96 // find the display where the given point lies, return wxNOT_FOUND if
97 // it doesn't belong to any display
98 static int GetFromPoint(const wxPoint
& pt
);
100 // find the display where the given window lies, return wxNOT_FOUND if it
101 // is not shown at all
102 static int GetFromWindow(wxWindow
*window
);
105 // return true if the object was initialized successfully
106 virtual bool IsOk() const { return true; }
108 // get the display size
109 virtual wxRect
GetGeometry() const = 0;
112 virtual wxString
GetName() const = 0;
114 // display 0 is always the primary display
115 bool IsPrimary() const { return m_index
== 0; }
118 // enumerate all video modes supported by this display matching the given
119 // one (in the sense of wxVideoMode::Match())
121 // as any mode matches the default value of the argument and there is
122 // always at least one video mode supported by display, the returned array
123 // is only empty for the default value of the argument if this function is
124 // not supported at all on this platform
125 virtual wxArrayVideoModes
126 GetModes(const wxVideoMode
& mode
= wxDefaultVideoMode
) const = 0;
128 // get current video mode
129 virtual wxVideoMode
GetCurrentMode() const = 0;
131 // change current mode, return true if succeeded, false otherwise
133 // for the default value of the argument restores the video mode to default
134 virtual bool ChangeMode(const wxVideoMode
& mode
= wxDefaultVideoMode
) = 0;
136 // restore the default video mode (just a more readable synonym)
137 void ResetMode() { (void)ChangeMode(); }
139 // virtual dtor as for any base class
140 virtual ~wxDisplayBase() { }
143 // the index of this display (0 is always the primary one)
146 DECLARE_NO_COPY_CLASS(wxDisplayBase
)
150 #if defined(__WXMSW__)
151 #include "wx/msw/display.h"
152 #elif defined(__WXMOTIF__)
153 #include "wx/unix/displayx11.h"
154 #elif defined(__WXGTK__)
155 #include "wx/unix/displayx11.h"
156 #elif defined(__WXMAC__)
157 #include "wx/mac/display.h"
158 #elif defined(__WXPM__)
159 #include "wx/os2/display.h"
162 #endif // wxUSE_DISPLAY
164 #endif // _WX_DISPLAY_H_BASE_