]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/statbrma.cpp
Set missing Language: headers in PO files.
[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
489468fe
SC
7// Copyright: (c) 1998 Stefan Csomor
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11#include "wx/wxprec.h"
12
13#if wxUSE_STATUSBAR
14
15#include "wx/statusbr.h"
16
17#ifndef WX_PRECOMP
18 #include "wx/dc.h"
19 #include "wx/dcclient.h"
20 #include "wx/toplevel.h"
21#endif
22
1f0c8f31 23#include "wx/osx/private.h"
489468fe 24
0cd15959
FM
25// Margin between the field text and the field rect
26#define wxFIELD_TEXT_MARGIN 2
27
489468fe
SC
28
29BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
30 EVT_PAINT(wxStatusBarMac::OnPaint)
31END_EVENT_TABLE()
32
33
34wxStatusBarMac::wxStatusBarMac(wxWindow *parent,
35 wxWindowID id,
36 long style,
37 const wxString& name)
38 :
39 wxStatusBarGeneric()
40{
41 SetParent( NULL );
42 Create( parent, id, style, name );
43}
44
45wxStatusBarMac::wxStatusBarMac()
46 :
47 wxStatusBarGeneric()
48{
49 SetParent( NULL );
50}
51
52wxStatusBarMac::~wxStatusBarMac()
53{
54}
55
56bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
57 long style ,
58 const wxString& name)
59{
60 if ( !wxStatusBarGeneric::Create( parent, id, style, name ) )
61 return false;
62
b2680ced 63 if ( parent->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
489468fe
SC
64 SetBackgroundStyle( wxBG_STYLE_TRANSPARENT );
65
66 // normal system font is too tall for fitting into the standard height
67 SetWindowVariant( wxWINDOW_VARIANT_SMALL );
68
69 return true;
70}
71
de0d2095 72void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int WXUNUSED(textHeight))
489468fe
SC
73{
74 int w, h;
75 GetSize( &w , &h );
489468fe
SC
76
77 if ( !MacIsReallyHilited() )
78 dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) );
79
80 wxString text(GetStatusText( i ));
81
0cd15959
FM
82 /*wxCoord x, y;
83 dc.GetTextExtent(text, &x, &y); -- seems unused (FM)*/
489468fe 84
0cd15959 85 int xpos = rect.x + wxFIELD_TEXT_MARGIN + 1;
489468fe
SC
86 int ypos = 1;
87
b2680ced 88 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
489468fe
SC
89 ypos++;
90
91 dc.SetClippingRegion(rect.x, 0, rect.width, h);
489468fe 92 dc.DrawText(text, xpos, ypos);
489468fe
SC
93 dc.DestroyClippingRegion();
94}
95
0cd15959 96void wxStatusBarMac::DrawField(wxDC& dc, int i, int textHeight)
489468fe 97{
0cd15959
FM
98 wxRect rect;
99 GetFieldRect(i, rect);
100
101 DrawFieldText(dc, rect, i, textHeight);
489468fe
SC
102}
103
6cf68971 104void wxStatusBarMac::DoUpdateStatusText(int number)
489468fe 105{
489468fe
SC
106 wxRect rect;
107 GetFieldRect(number, rect);
0cd15959 108
489468fe
SC
109 int w, h;
110 GetSize( &w, &h );
0cd15959 111
489468fe
SC
112 rect.y = 0;
113 rect.height = h ;
0cd15959 114
489468fe 115 Refresh( true, &rect );
5856534c
SC
116 // we should have to force the update here
117 // TODO Remove if no regressions occur
118#if 0
489468fe 119 Update();
5856534c 120#endif
489468fe
SC
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
0cd15959 165 if ( GetFont().IsOk() )
489468fe
SC
166 dc.SetFont(GetFont());
167 dc.SetBackgroundMode(wxTRANSPARENT);
168
0cd15959
FM
169 // compute char height only once for all panes:
170 int textHeight = dc.GetCharHeight();
171
7b6fefbe 172 for ( size_t i = 0; i < m_panes.GetCount(); i ++ )
0cd15959 173 DrawField(dc, i, textHeight);
489468fe
SC
174}
175
176void wxStatusBarMac::MacHiliteChanged()
177{
178 Refresh();
179 Update();
180}
181
182#endif // wxUSE_STATUSBAR
183