]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/statbrma.cpp
10.4 support for osx-cocoa
[wxWidgets.git] / src / osx / carbon / statbrma.cpp
CommitLineData
489468fe 1///////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/carbon/statbarma.cpp
489468fe
SC
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
1f0c8f31 24#include "wx/osx/private.h"
489468fe
SC
25
26
27BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
28 EVT_PAINT(wxStatusBarMac::OnPaint)
29END_EVENT_TABLE()
30
31
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
43wxStatusBarMac::wxStatusBarMac()
44 :
45 wxStatusBarGeneric()
46{
47 SetParent( NULL );
48}
49
50wxStatusBarMac::~wxStatusBarMac()
51{
52}
53
54bool 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
b2680ced 61 if ( parent->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
489468fe
SC
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
70void 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
b2680ced 89 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
489468fe
SC
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
99void wxStatusBarMac::DrawField(wxDC& dc, int i)
100{
101 DrawFieldText(dc, i);
102}
103
104void wxStatusBarMac::SetStatusText(const wxString& text, int number)
105{
106 wxCHECK_RET( (number >= 0) && (number < m_nFields),
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
123void 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)
b2680ced 139 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
489468fe
SC
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 int i;
166 if ( GetFont().Ok() )
167 dc.SetFont(GetFont());
168 dc.SetBackgroundMode(wxTRANSPARENT);
169
170 for ( i = 0; i < m_nFields; i ++ )
171 DrawField(dc, i);
172}
173
174void wxStatusBarMac::MacHiliteChanged()
175{
176 Refresh();
177 Update();
178}
179
180#endif // wxUSE_STATUSBAR
181