wxDisplay cleanup/rewrite:
[wxWidgets.git] / include / wx / display.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/display.h
3 // Purpose: wxDisplay class
4 // Author: Royce Mitchell III, Vadim Zeitlin
5 // Created: 06/21/02
6 // RCS-ID: $Id$
7 // Copyright: (c) 2002-2006 wxWidgets team
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_DISPLAY_H_BASE_
12 #define _WX_DISPLAY_H_BASE_
13
14 // NB: no #if wxUSE_DISPLAY here, the display geometry part of this class (but
15 // not the video mode stuff) is always available but if wxUSE_DISPLAY == 0
16 // it becomes just a trivial wrapper around the old wxDisplayXXX() functions
17
18 #if wxUSE_DISPLAY
19 #include "wx/dynarray.h"
20 #include "wx/vidmode.h"
21
22 WX_DECLARE_EXPORTED_OBJARRAY(wxVideoMode, wxArrayVideoModes);
23
24 // default, uninitialized, video mode object
25 extern WXDLLEXPORT_DATA(const wxVideoMode) wxDefaultVideoMode;
26 #endif // wxUSE_DISPLAY
27
28 class WXDLLEXPORT wxWindow;
29 class WXDLLEXPORT wxPoint;
30 class WXDLLEXPORT wxRect;
31 class WXDLLEXPORT wxString;
32
33 class WXDLLEXPORT wxDisplayFactory;
34 class WXDLLEXPORT wxDisplayImpl;
35
36 // ----------------------------------------------------------------------------
37 // wxDisplay: represents a display/monitor attached to the system
38 // ----------------------------------------------------------------------------
39
40 class WXDLLEXPORT wxDisplay
41 {
42 public:
43 // initialize the object containing all information about the given
44 // display
45 //
46 // the displays are numbered from 0 to GetCount() - 1, 0 is always the
47 // primary display and the only one which is always supported
48 wxDisplay(size_t n = 0);
49
50 // dtor is not virtual as this is a concrete class not meant to be derived
51 // from
52 ~wxDisplay();
53
54
55 // return the number of available displays, valid parameters to
56 // wxDisplay ctor are from 0 up to this number
57 static size_t GetCount();
58
59 // find the display where the given point lies, return wxNOT_FOUND if
60 // it doesn't belong to any display
61 static int GetFromPoint(const wxPoint& pt);
62
63 // find the display where the given window lies, return wxNOT_FOUND if it
64 // is not shown at all
65 static int GetFromWindow(wxWindow *window);
66
67
68 // return true if the object was initialized successfully
69 bool IsOk() const { return m_impl != NULL; }
70
71 // get the display size
72 wxRect GetGeometry() const;
73
74 // name may be empty
75 wxString GetName() const;
76
77 // display 0 is usually the primary display
78 bool IsPrimary() const;
79
80
81 #if wxUSE_DISPLAY
82 // enumerate all video modes supported by this display matching the given
83 // one (in the sense of wxVideoMode::Match())
84 //
85 // as any mode matches the default value of the argument and there is
86 // always at least one video mode supported by display, the returned array
87 // is only empty for the default value of the argument if this function is
88 // not supported at all on this platform
89 wxArrayVideoModes
90 GetModes(const wxVideoMode& mode = wxDefaultVideoMode) const;
91
92 // get current video mode
93 wxVideoMode GetCurrentMode() const;
94
95 // change current mode, return true if succeeded, false otherwise
96 //
97 // for the default value of the argument restores the video mode to default
98 bool ChangeMode(const wxVideoMode& mode = wxDefaultVideoMode);
99
100 // restore the default video mode (just a more readable synonym)
101 void ResetMode() { (void)ChangeMode(); }
102 #endif // wxUSE_DISPLAY
103
104 private:
105 // returns the factory used to implement our static methods and create new
106 // displays
107 static wxDisplayFactory& Factory();
108
109 // creates the factory object, called by Factory() when it is called for
110 // the first time and should return a pointer allocated with new (the
111 // caller will delete it)
112 //
113 // this method must be implemented in platform-specific code if
114 // wxUSE_DISPLAY == 1 (if it is 0 we provide the stub in common code)
115 static wxDisplayFactory *CreateFactory();
116
117
118 // the real implementation
119 wxDisplayImpl *m_impl;
120
121
122 DECLARE_NO_COPY_CLASS(wxDisplay)
123 };
124
125 #endif // _WX_DISPLAY_H_BASE_