compilation fix for Mac (patch 813378)
[wxWidgets.git] / include / wx / display.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/display.h
3 // Purpose: wxDisplay class
4 // Author: Royce Mitchell III
5 // Modified by: Vadim Zeitlin (resolution changes, display modes, ...)
6 // Created: 06/21/02
7 // RCS-ID: $Id$
8 // Copyright: (c) 2002-2003 wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_DISPLAY_H_BASE_
13 #define _WX_DISPLAY_H_BASE_
14
15 #if wxUSE_DISPLAY
16
17 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
18 #pragma interface "displaybase.h"
19 #endif
20
21 #include "wx/dynarray.h"
22
23 class WXDLLEXPORT wxWindow;
24 class WXDLLEXPORT wxPoint;
25 class WXDLLEXPORT wxRect;
26 class WXDLLEXPORT wxString;
27
28 // ----------------------------------------------------------------------------
29 // wxVideoMode: contains video mode parameters for a display
30 // ----------------------------------------------------------------------------
31
32 struct WXDLLEXPORT wxVideoMode
33 {
34 wxVideoMode(int width = 0, int height = 0, int depth = 0, int freq = 0)
35 {
36 w = width;
37 h = height;
38
39 bpp = depth;
40
41 refresh = freq;
42 }
43
44 // default copy ctor and assignment operator are ok
45
46 bool operator==(const wxVideoMode& m) const
47 {
48 return w == m.w && h == m.h && bpp == m.bpp && refresh == m.refresh;
49 }
50 bool operator!=(const wxVideoMode& mode) const
51 {
52 return !operator==(mode);
53 }
54
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
59 {
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);
64 }
65
66 // the screen size in pixels (e.g. 640*480), 0 means unspecified
67 int w, h;
68
69 // bits per pixel (e.g. 32), 1 is monochrome and 0 means unspecified/known
70 int bpp;
71
72 // refresh frequency in Hz, 0 means unspecified/unknown
73 int refresh;
74 };
75
76 WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes);
77
78 // default, uninitialized, video mode object
79 WXDLLEXPORT_DATA(extern const wxVideoMode) wxDefaultVideoMode;
80
81 // ----------------------------------------------------------------------------
82 // wxDisplayBase: represents a display/monitor attached to the system
83 // ----------------------------------------------------------------------------
84
85 class WXDLLEXPORT wxDisplayBase
86 {
87 public:
88 // initialize the object containing all information about the given
89 // display
90 //
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);
94
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();
98
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);
102
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);
106
107
108 // return true if the object was initialized successfully
109 virtual bool IsOk() const { return true; }
110
111 // get the display size
112 virtual wxRect GetGeometry() const = 0;
113
114 // name may be empty
115 virtual wxString GetName() const = 0;
116
117 // display 0 is always the primary display
118 bool IsPrimary() const { return m_index == 0; }
119
120
121 // enumerate all video modes supported by this display matching the given
122 // one (in the sense of wxVideoMode::Match())
123 //
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;
130
131 // get current video mode
132 virtual wxVideoMode GetCurrentMode() const = 0;
133
134 // change current mode, return true if succeeded, false otherwise
135 //
136 // for the default value of the argument restores the video mode to default
137 virtual bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode) = 0;
138
139 // restore the default video mode (just a more readable synonym)
140 void ResetMode() { (void)ChangeMode(); }
141
142 // virtual dtor as for any base class
143 virtual ~wxDisplayBase() { }
144
145 protected:
146 // the index of this display (0 is always the primary one)
147 size_t m_index;
148
149 DECLARE_NO_COPY_CLASS(wxDisplayBase)
150 };
151
152
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"
163 #endif
164
165 #endif // wxUSE_DISPLAY
166
167 #endif // _WX_DISPLAY_H_BASE_