]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/display.cpp
unicode fixes, enabling notebook images again
[wxWidgets.git] / src / mac / carbon / display.cpp
CommitLineData
a536e411
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: display.cpp
3// Purpose: Mac implementation of wxDisplay class
4// Author: Brian Victor
5// Modified by: Royce Mitchell III
6// Created: 06/21/02
7// RCS-ID: $Id$
8// Copyright: (c) wxWindows team
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13 #pragma implementation "display.h"
14#endif
15
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
19#ifdef __BORLANDC__
20 #pragma hdrstop
21#endif
22
23#if wxUSE_DISPLAY
24
25#ifndef WX_PRECOMP
26 #include "wx/dynarray.h"
27#endif
28
29#ifdef __DARWIN__
30 #include <Carbon/Carbon.h>
31#else
32 #include <Displays.h>
33 #include <Quickdraw.h>
34#endif
35
36#include "wx/display.h"
37#include "wx/gdicmn.h"
38#include "wx/string.h"
39
40// ----------------------------------------------------------------------------
41// private classes
42// ----------------------------------------------------------------------------
43
44class wxDisplayMacPriv
45{
46public:
e40298d5 47 GDHandle m_hndl;
a536e411
JS
48};
49
50size_t wxDisplayBase::GetCount()
51{
52 GDHandle hndl;
53 size_t num = 0;
54 hndl = DMGetFirstScreenDevice(true);
55 while(hndl)
56 {
57 num++;
58 hndl = DMGetNextScreenDevice(hndl, true);
59 }
60 return num;
61}
62
63int wxDisplayBase::GetFromPoint(const wxPoint &p)
64{
65 GDHandle hndl;
66 size_t num = 0;
67 hndl = DMGetFirstScreenDevice(true);
68 while(hndl)
69 {
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)
75 {
76 return num;
77 }
78 num++;
79 hndl = DMGetNextScreenDevice(hndl, true);
80 }
81 return -1;
82}
83
84wxDisplay::wxDisplay(size_t index) : wxDisplayBase ( index ),
85 m_priv ( new wxDisplayMacPriv() )
86{
87 GDHandle hndl;
88 hndl = DMGetFirstScreenDevice(true);
89 m_priv->m_hndl = NULL;
90 while(hndl)
91 {
92 if (index == 0)
93 {
94 m_priv->m_hndl = hndl;
95 }
96 index--;
97 hndl = DMGetNextScreenDevice(hndl, true);
98 }
99}
100
101wxRect wxDisplay::GetGeometry() const
102{
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);
108}
109
110int wxDisplay::GetDepth() const
111{
112 if (!(m_priv)) return 0;
113 if (!(m_priv->m_hndl)) return 0;
114
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;
118}
119
120wxString wxDisplay::GetName() const
121{
122 // Macs don't name their displays...
123 return wxT("");
124}
125
126wxDisplay::~wxDisplay()
127{
128 if ( m_priv )
129 {
130 delete m_priv;
131 m_priv = 0;
132 }
133}
134
135#endif // wxUSE_DISPLAY