]>
git.saurik.com Git - wxWidgets.git/blob - src/palmos/display.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/palmos/display.cpp
3 // Purpose: Palm OS Implementation of wxDisplay class
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
31 #include "wx/dynarray.h"
35 #include "wx/dynload.h"
37 #include "wx/display.h"
39 // ----------------------------------------------------------------------------
41 // ----------------------------------------------------------------------------
44 #define WINFUNC(x) _T(#x) L"W"
46 #define WINFUNC(x) #x "A"
49 // ----------------------------------------------------------------------------
51 // ----------------------------------------------------------------------------
56 // handle of this monitor used by MonitorXXX() functions, never NULL
59 // IDirectDraw object used to control this display, may be NULL
62 // DirectDraw GUID for this display, only valid when using DirectDraw
65 // the entire area of this monitor in virtual screen coordinates
68 // the display device name for this monitor, empty initially and retrieved
69 // on demand by DoGetName()
72 wxDisplayInfo() { m_hmon
= NULL
; m_pDD2
= NULL
; }
73 ~wxDisplayInfo() { if ( m_pDD2
) m_pDD2
->Release(); }
76 WX_DECLARE_OBJARRAY(wxDisplayInfo
, wxDisplayInfoArray
);
77 #include "wx/arrimpl.cpp"
78 WX_DEFINE_OBJARRAY(wxDisplayInfoArray
);
80 // this module is used to cleanup gs_displays array
81 class wxDisplayModule
: public wxModule
84 virtual bool OnInit() { return true; }
85 virtual void OnExit();
87 DECLARE_DYNAMIC_CLASS(wxDisplayModule
)
90 IMPLEMENT_DYNAMIC_CLASS(wxDisplayModule
, wxModule
)
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 // this is not really MT-unsafe as wxDisplay is only going to be used from the
97 // main thread, i.e. we consider that it's a GUI class and so don't protect it
98 static wxDisplayInfoArray
*gs_displays
= NULL
;
100 // ===========================================================================
102 // ===========================================================================
104 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
108 // initialize gs_displays using DirectX functions
109 static bool DoInitDirectX()
114 // initialize gs_displays using the standard Windows functions
115 static void DoInitStdWindows()
119 // this function must be called before accessing gs_displays array as it
120 // creates and initializes it
121 static void InitDisplays()
125 // convert a DEVMODE to our wxVideoMode
126 wxVideoMode
ConvertToVideoMode(const DEVMODE
& dm
)
128 return wxVideoMode(160,
134 // ----------------------------------------------------------------------------
136 // ----------------------------------------------------------------------------
138 void wxDisplayModule::OnExit()
142 // ---------------------------------------------------------------------------
144 // ---------------------------------------------------------------------------
147 void wxDisplay::UseDirectX(bool useDX
)
151 // helper of GetFromPoint() and GetFromWindow()
152 static int DisplayFromHMONITOR(HMONITOR hmon
)
158 size_t wxDisplayBase::GetCount()
164 int wxDisplayBase::GetFromPoint ( const wxPoint
& pt
)
170 int wxDisplayBase::GetFromWindow(wxWindow
*window
)
175 // ----------------------------------------------------------------------------
176 // wxDisplay ctor/dtor
177 // ----------------------------------------------------------------------------
179 wxDisplay::wxDisplay ( size_t n
)
180 : wxDisplayBase ( n
)
184 wxDisplay::~wxDisplay()
188 // ----------------------------------------------------------------------------
189 // wxDisplay simple accessors
190 // ----------------------------------------------------------------------------
192 bool wxDisplay::IsOk() const
197 wxRect
wxDisplay::GetGeometry() const
204 wxString
wxDisplay::GetName() const
211 wxString
wxDisplay::GetNameForEnumSettings() const
218 // ----------------------------------------------------------------------------
219 // video modes enumeration
220 // ----------------------------------------------------------------------------
223 wxDisplay::DoGetModesDirectX(const wxVideoMode
& WXUNUSED(modeMatch
)) const
225 wxArrayVideoModes modes
;
231 wxDisplay::DoGetModesWindows(const wxVideoMode
& modeMatch
) const
233 wxArrayVideoModes modes
;
238 wxArrayVideoModes
wxDisplay::GetModes(const wxVideoMode
& modeMatch
) const
240 return gs_useDirectX
? DoGetModesDirectX(modeMatch
)
241 : DoGetModesWindows(modeMatch
);
244 wxVideoMode
wxDisplay::GetCurrentMode() const
251 // ----------------------------------------------------------------------------
252 // video mode switching
253 // ----------------------------------------------------------------------------
255 bool wxDisplay::DoChangeModeDirectX(const wxVideoMode
& mode
)
260 bool wxDisplay::DoChangeModeWindows(const wxVideoMode
& mode
)
265 bool wxDisplay::ChangeMode(const wxVideoMode
& mode
)
267 return gs_useDirectX
? DoChangeModeDirectX(mode
)
268 : DoChangeModeWindows(mode
);
271 #endif // wxUSE_DISPLAY