]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/statbrma.cpp
Fix GetMsgCatalogSubdirs() to do as documentation says.
[wxWidgets.git] / src / osx / carbon / statbrma.cpp
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 // Margin between the field text and the field rect
27 #define wxFIELD_TEXT_MARGIN 2
28
29
30 BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
31 EVT_PAINT(wxStatusBarMac::OnPaint)
32 END_EVENT_TABLE()
33
34
35 wxStatusBarMac::wxStatusBarMac(wxWindow *parent,
36 wxWindowID id,
37 long style,
38 const wxString& name)
39 :
40 wxStatusBarGeneric()
41 {
42 SetParent( NULL );
43 Create( parent, id, style, name );
44 }
45
46 wxStatusBarMac::wxStatusBarMac()
47 :
48 wxStatusBarGeneric()
49 {
50 SetParent( NULL );
51 }
52
53 wxStatusBarMac::~wxStatusBarMac()
54 {
55 }
56
57 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
58 long style ,
59 const wxString& name)
60 {
61 if ( !wxStatusBarGeneric::Create( parent, id, style, name ) )
62 return false;
63
64 if ( parent->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
65 SetBackgroundStyle( wxBG_STYLE_TRANSPARENT );
66
67 // normal system font is too tall for fitting into the standard height
68 SetWindowVariant( wxWINDOW_VARIANT_SMALL );
69
70 return true;
71 }
72
73 void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int WXUNUSED(textHeight))
74 {
75 int w, h;
76 GetSize( &w , &h );
77
78 if ( !MacIsReallyHilited() )
79 dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) );
80
81 wxString text(GetStatusText( i ));
82
83 /*wxCoord x, y;
84 dc.GetTextExtent(text, &x, &y); -- seems unused (FM)*/
85
86 int xpos = rect.x + wxFIELD_TEXT_MARGIN + 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 dc.DrawText(text, xpos, ypos);
94 dc.DestroyClippingRegion();
95 }
96
97 void wxStatusBarMac::DrawField(wxDC& dc, int i, int textHeight)
98 {
99 wxRect rect;
100 GetFieldRect(i, rect);
101
102 DrawFieldText(dc, rect, i, textHeight);
103 }
104
105 void wxStatusBarMac::DoUpdateStatusText(int number)
106 {
107 wxRect rect;
108 GetFieldRect(number, rect);
109
110 int w, h;
111 GetSize( &w, &h );
112
113 rect.y = 0;
114 rect.height = h ;
115
116 Refresh( true, &rect );
117 // we should have to force the update here
118 // TODO Remove if no regressions occur
119 #if 0
120 Update();
121 #endif
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()->GetExtraStyle() & wxFRAME_EX_METAL )
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 if ( GetFont().IsOk() )
167 dc.SetFont(GetFont());
168 dc.SetBackgroundMode(wxTRANSPARENT);
169
170 // compute char height only once for all panes:
171 int textHeight = dc.GetCharHeight();
172
173 for ( size_t i = 0; i < m_panes.GetCount(); i ++ )
174 DrawField(dc, i, textHeight);
175 }
176
177 void wxStatusBarMac::MacHiliteChanged()
178 {
179 Refresh();
180 Update();
181 }
182
183 #endif // wxUSE_STATUSBAR
184