]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/display.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Mac implementation of wxDisplay class
4 // Author: Brian Victor
5 // Modified by: Royce Mitchell III
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "display.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/dynarray.h"
30 #include <Carbon/Carbon.h>
33 #include <Quickdraw.h>
36 #include "wx/display.h"
37 #include "wx/gdicmn.h"
38 #include "wx/string.h"
40 // ----------------------------------------------------------------------------
42 // ----------------------------------------------------------------------------
44 class wxDisplayMacPriv
50 size_t wxDisplayBase::GetCount()
54 hndl
= DMGetFirstScreenDevice(true);
58 hndl
= DMGetNextScreenDevice(hndl
, true);
63 int wxDisplayBase::GetFromPoint(const wxPoint
&p
)
67 hndl
= DMGetFirstScreenDevice(true);
70 Rect screenrect
= (*hndl
)->gdRect
;
71 if (p
.x
>= screenrect
.left
&&
72 p
.x
<= screenrect
.right
&&
73 p
.y
>= screenrect
.top
&&
74 p
.y
<= screenrect
.bottom
)
79 hndl
= DMGetNextScreenDevice(hndl
, true);
84 wxDisplay::wxDisplay(size_t index
) : wxDisplayBase ( index
),
85 m_priv ( new wxDisplayMacPriv() )
88 hndl
= DMGetFirstScreenDevice(true);
89 m_priv
->m_hndl
= NULL
;
94 m_priv
->m_hndl
= hndl
;
97 hndl
= DMGetNextScreenDevice(hndl
, true);
101 wxRect
wxDisplay::GetGeometry() const
103 if (!(m_priv
)) return wxRect(0, 0, 0, 0);
104 if (!(m_priv
->m_hndl
)) return wxRect(0, 0, 0, 0);
105 Rect screenrect
= (*(m_priv
->m_hndl
))->gdRect
;
106 return wxRect( screenrect
.left
, screenrect
.top
,
107 screenrect
.right
- screenrect
.left
, screenrect
.bottom
- screenrect
.top
);
110 int wxDisplay::GetDepth() const
112 if (!(m_priv
)) return 0;
113 if (!(m_priv
->m_hndl
)) return 0;
115 // This cryptic looking code is based on Apple's sample code:
116 // http://developer.apple.com/samplecode/Sample_Code/Graphics_2D/GDevVideo/Gen.cp.htm
117 return ((*(*(m_priv
->m_hndl
))->gdPMap
)->pixelSize
) & 0x0000FFFF;
120 wxString
wxDisplay::GetName() const
122 // Macs don't name their displays...
126 wxDisplay::~wxDisplay()
135 #endif // wxUSE_DISPLAY