]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/mac/carbon/statbarma.cpp | |
3 | // Purpose: native implementation of wxStatusBar (optional) | |
4 | // Author: Stefan Csomor | |
5 | // Modified by: | |
6 | // Created: 1998-01-01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Stefan Csomor | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #if wxUSE_STATUSBAR | |
15 | ||
16 | #include "wx/statusbr.h" | |
17 | ||
18 | #ifndef WX_PRECOMP | |
19 | #include "wx/dc.h" | |
20 | #include "wx/dcclient.h" | |
21 | #include "wx/toplevel.h" | |
22 | #endif | |
23 | ||
24 | #include "wx/mac/private.h" | |
25 | ||
26 | ||
27 | BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) | |
28 | EVT_PAINT(wxStatusBarMac::OnPaint) | |
29 | END_EVENT_TABLE() | |
30 | ||
31 | ||
32 | wxStatusBarMac::wxStatusBarMac(wxWindow *parent, | |
33 | wxWindowID id, | |
34 | long style, | |
35 | const wxString& name) | |
36 | : | |
37 | wxStatusBarGeneric() | |
38 | { | |
39 | SetParent( NULL ); | |
40 | Create( parent, id, style, name ); | |
41 | } | |
42 | ||
43 | wxStatusBarMac::wxStatusBarMac() | |
44 | : | |
45 | wxStatusBarGeneric() | |
46 | { | |
47 | SetParent( NULL ); | |
48 | } | |
49 | ||
50 | wxStatusBarMac::~wxStatusBarMac() | |
51 | { | |
52 | } | |
53 | ||
54 | bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, | |
55 | long style , | |
56 | const wxString& name) | |
57 | { | |
58 | if ( !wxStatusBarGeneric::Create( parent, id, style, name ) ) | |
59 | return false; | |
60 | ||
61 | if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() ) | |
62 | MacSetBackgroundBrush( wxNullBrush ); | |
63 | ||
64 | // normal system font is too tall for fitting into the standard height | |
65 | SetWindowVariant( wxWINDOW_VARIANT_SMALL ); | |
66 | ||
67 | return true; | |
68 | } | |
69 | ||
70 | void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) | |
71 | { | |
72 | int w, h; | |
73 | GetSize( &w , &h ); | |
74 | wxRect rect; | |
75 | GetFieldRect( i, rect ); | |
76 | ||
77 | if ( !MacIsReallyHilited() ) | |
78 | dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) ); | |
79 | ||
80 | wxString text(GetStatusText( i )); | |
81 | ||
82 | long x, y; | |
83 | ||
84 | dc.GetTextExtent(text, &x, &y); | |
85 | ||
86 | int leftMargin = 2; | |
87 | int xpos = rect.x + leftMargin + 1; | |
88 | int ypos = 1; | |
89 | ||
90 | if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) | |
91 | ypos++; | |
92 | ||
93 | dc.SetClippingRegion(rect.x, 0, rect.width, h); | |
94 | ||
95 | dc.DrawText(text, xpos, ypos); | |
96 | ||
97 | dc.DestroyClippingRegion(); | |
98 | } | |
99 | ||
100 | void wxStatusBarMac::DrawField(wxDC& dc, int i) | |
101 | { | |
102 | DrawFieldText(dc, i); | |
103 | } | |
104 | ||
105 | void wxStatusBarMac::SetStatusText(const wxString& text, int number) | |
106 | { | |
107 | wxCHECK_RET( (number >= 0) && (number < m_nFields), | |
108 | wxT("invalid status bar field index") ); | |
109 | ||
110 | if ( m_statusStrings[number] == text ) | |
111 | return ; | |
112 | ||
113 | m_statusStrings[number] = text; | |
114 | wxRect rect; | |
115 | GetFieldRect(number, rect); | |
116 | int w, h; | |
117 | GetSize( &w, &h ); | |
118 | rect.y = 0; | |
119 | rect.height = h ; | |
120 | Refresh( true, &rect ); | |
121 | Update(); | |
122 | } | |
123 | ||
124 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
125 | { | |
126 | wxPaintDC dc(this); | |
127 | dc.Clear(); | |
128 | ||
129 | int major, minor; | |
130 | wxGetOsVersion( &major, &minor ); | |
131 | int w, h; | |
132 | GetSize( &w, &h ); | |
133 | ||
134 | if ( MacIsReallyHilited() ) | |
135 | { | |
136 | wxPen white( *wxWHITE , 1 , wxSOLID ); | |
137 | if (major >= 10) | |
138 | { | |
139 | // Finder statusbar border color: (Project Builder similar is 9B9B9B) | |
140 | if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) | |
141 | dc.SetPen(wxPen(wxColour(0x40, 0x40, 0x40), 1, wxSOLID)); | |
142 | else | |
143 | dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID)); | |
144 | } | |
145 | else | |
146 | { | |
147 | wxPen black( *wxBLACK , 1 , wxSOLID ); | |
148 | dc.SetPen(black); | |
149 | } | |
150 | ||
151 | dc.DrawLine(0, 0, w, 0); | |
152 | dc.SetPen(white); | |
153 | dc.DrawLine(0, 1, w, 1); | |
154 | } | |
155 | else | |
156 | { | |
157 | if (major >= 10) | |
158 | // Finder statusbar border color: (Project Builder similar is 9B9B9B) | |
159 | dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID)); | |
160 | else | |
161 | dc.SetPen(wxPen(wxColour(0x80, 0x80, 0x80), 1, wxSOLID)); | |
162 | ||
163 | dc.DrawLine(0, 0, w, 0); | |
164 | } | |
165 | ||
166 | int i; | |
167 | if ( GetFont().Ok() ) | |
168 | dc.SetFont(GetFont()); | |
169 | dc.SetBackgroundMode(wxTRANSPARENT); | |
170 | ||
171 | for ( i = 0; i < m_nFields; i ++ ) | |
172 | DrawField(dc, i); | |
173 | } | |
174 | ||
175 | void wxStatusBarMac::MacHiliteChanged() | |
176 | { | |
177 | Refresh(); | |
178 | Update(); | |
179 | } | |
180 | ||
181 | #endif // wxUSE_STATUSBAR | |
182 |