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