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