]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/osx/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/osx/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()->GetExtraStyle() & wxFRAME_EX_METAL ) | |
62 | SetBackgroundStyle( wxBG_STYLE_TRANSPARENT ); | |
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 | wxCoord x, y; | |
83 | dc.GetTextExtent(text, &x, &y); | |
84 | ||
85 | int leftMargin = 2; | |
86 | int xpos = rect.x + leftMargin + 1; | |
87 | int ypos = 1; | |
88 | ||
89 | if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL ) | |
90 | ypos++; | |
91 | ||
92 | dc.SetClippingRegion(rect.x, 0, rect.width, h); | |
93 | ||
94 | dc.DrawText(text, xpos, ypos); | |
95 | ||
96 | dc.DestroyClippingRegion(); | |
97 | } | |
98 | ||
99 | void wxStatusBarMac::DrawField(wxDC& dc, int i) | |
100 | { | |
101 | DrawFieldText(dc, i); | |
102 | } | |
103 | ||
104 | void wxStatusBarMac::SetStatusText(const wxString& text, int number) | |
105 | { | |
106 | wxCHECK_RET( (number >= 0) && ((size_t)number < m_panes.GetCount()), | |
107 | wxT("invalid status bar field index") ); | |
108 | ||
109 | if ( m_statusStrings[number] == text ) | |
110 | return ; | |
111 | ||
112 | m_statusStrings[number] = text; | |
113 | wxRect rect; | |
114 | GetFieldRect(number, rect); | |
115 | int w, h; | |
116 | GetSize( &w, &h ); | |
117 | rect.y = 0; | |
118 | rect.height = h ; | |
119 | Refresh( true, &rect ); | |
120 | Update(); | |
121 | } | |
122 | ||
123 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event)) | |
124 | { | |
125 | wxPaintDC dc(this); | |
126 | dc.Clear(); | |
127 | ||
128 | int major, minor; | |
129 | wxGetOsVersion( &major, &minor ); | |
130 | int w, h; | |
131 | GetSize( &w, &h ); | |
132 | ||
133 | if ( MacIsReallyHilited() ) | |
134 | { | |
135 | wxPen white( *wxWHITE , 1 , wxSOLID ); | |
136 | if (major >= 10) | |
137 | { | |
138 | // Finder statusbar border color: (Project Builder similar is 9B9B9B) | |
139 | if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL ) | |
140 | dc.SetPen(wxPen(wxColour(0x40, 0x40, 0x40), 1, wxSOLID)); | |
141 | else | |
142 | dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID)); | |
143 | } | |
144 | else | |
145 | { | |
146 | wxPen black( *wxBLACK , 1 , wxSOLID ); | |
147 | dc.SetPen(black); | |
148 | } | |
149 | ||
150 | dc.DrawLine(0, 0, w, 0); | |
151 | dc.SetPen(white); | |
152 | dc.DrawLine(0, 1, w, 1); | |
153 | } | |
154 | else | |
155 | { | |
156 | if (major >= 10) | |
157 | // Finder statusbar border color: (Project Builder similar is 9B9B9B) | |
158 | dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID)); | |
159 | else | |
160 | dc.SetPen(wxPen(wxColour(0x80, 0x80, 0x80), 1, wxSOLID)); | |
161 | ||
162 | dc.DrawLine(0, 0, w, 0); | |
163 | } | |
164 | ||
165 | if ( GetFont().Ok() ) | |
166 | dc.SetFont(GetFont()); | |
167 | dc.SetBackgroundMode(wxTRANSPARENT); | |
168 | ||
169 | for ( size_t i = 0; i < m_panes.GetCount(); i ++ ) | |
170 | DrawField(dc, i); | |
171 | } | |
172 | ||
173 | void wxStatusBarMac::MacHiliteChanged() | |
174 | { | |
175 | Refresh(); | |
176 | Update(); | |
177 | } | |
178 | ||
179 | #endif // wxUSE_STATUSBAR | |
180 |