]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/statbrma.cpp
Make wxTaskBarIcon's ctor have the same API on all platforms even though setting...
[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 Update();
118 }
119
120 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event))
121 {
122 wxPaintDC dc(this);
123 dc.Clear();
124
125 int major, minor;
126 wxGetOsVersion( &major, &minor );
127 int w, h;
128 GetSize( &w, &h );
129
130 if ( MacIsReallyHilited() )
131 {
132 wxPen white( *wxWHITE , 1 , wxSOLID );
133 if (major >= 10)
134 {
135 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
136 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
137 dc.SetPen(wxPen(wxColour(0x40, 0x40, 0x40), 1, wxSOLID));
138 else
139 dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID));
140 }
141 else
142 {
143 wxPen black( *wxBLACK , 1 , wxSOLID );
144 dc.SetPen(black);
145 }
146
147 dc.DrawLine(0, 0, w, 0);
148 dc.SetPen(white);
149 dc.DrawLine(0, 1, w, 1);
150 }
151 else
152 {
153 if (major >= 10)
154 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
155 dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID));
156 else
157 dc.SetPen(wxPen(wxColour(0x80, 0x80, 0x80), 1, wxSOLID));
158
159 dc.DrawLine(0, 0, w, 0);
160 }
161
162 if ( GetFont().IsOk() )
163 dc.SetFont(GetFont());
164 dc.SetBackgroundMode(wxTRANSPARENT);
165
166 // compute char height only once for all panes:
167 int textHeight = dc.GetCharHeight();
168
169 for ( size_t i = 0; i < m_panes.GetCount(); i ++ )
170 DrawField(dc, i, textHeight);
171 }
172
173 void wxStatusBarMac::MacHiliteChanged()
174 {
175 Refresh();
176 Update();
177 }
178
179 #endif // wxUSE_STATUSBAR
180