]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/statbrma.cpp
new file added
[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 25
0cd15959
FM
26// Margin between the field text and the field rect
27#define wxFIELD_TEXT_MARGIN 2
28
489468fe
SC
29
30BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
31 EVT_PAINT(wxStatusBarMac::OnPaint)
32END_EVENT_TABLE()
33
34
35wxStatusBarMac::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
46wxStatusBarMac::wxStatusBarMac()
47 :
48 wxStatusBarGeneric()
49{
50 SetParent( NULL );
51}
52
53wxStatusBarMac::~wxStatusBarMac()
54{
55}
56
57bool 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
b2680ced 64 if ( parent->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
489468fe
SC
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
de0d2095 73void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int WXUNUSED(textHeight))
489468fe
SC
74{
75 int w, h;
76 GetSize( &w , &h );
489468fe
SC
77
78 if ( !MacIsReallyHilited() )
79 dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) );
80
81 wxString text(GetStatusText( i ));
82
0cd15959
FM
83 /*wxCoord x, y;
84 dc.GetTextExtent(text, &x, &y); -- seems unused (FM)*/
489468fe 85
0cd15959 86 int xpos = rect.x + wxFIELD_TEXT_MARGIN + 1;
489468fe
SC
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);
489468fe 93 dc.DrawText(text, xpos, ypos);
489468fe
SC
94 dc.DestroyClippingRegion();
95}
96
0cd15959 97void wxStatusBarMac::DrawField(wxDC& dc, int i, int textHeight)
489468fe 98{
0cd15959
FM
99 wxRect rect;
100 GetFieldRect(i, rect);
101
102 DrawFieldText(dc, rect, i, textHeight);
489468fe
SC
103}
104
6cf68971 105void wxStatusBarMac::DoUpdateStatusText(int number)
489468fe 106{
489468fe
SC
107 wxRect rect;
108 GetFieldRect(number, rect);
0cd15959 109
489468fe
SC
110 int w, h;
111 GetSize( &w, &h );
0cd15959 112
489468fe
SC
113 rect.y = 0;
114 rect.height = h ;
0cd15959 115
489468fe
SC
116 Refresh( true, &rect );
117 Update();
118}
119
120void 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)
b2680ced 136 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
489468fe
SC
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
0cd15959 162 if ( GetFont().IsOk() )
489468fe
SC
163 dc.SetFont(GetFont());
164 dc.SetBackgroundMode(wxTRANSPARENT);
165
0cd15959
FM
166 // compute char height only once for all panes:
167 int textHeight = dc.GetCharHeight();
168
7b6fefbe 169 for ( size_t i = 0; i < m_panes.GetCount(); i ++ )
0cd15959 170 DrawField(dc, i, textHeight);
489468fe
SC
171}
172
173void wxStatusBarMac::MacHiliteChanged()
174{
175 Refresh();
176 Update();
177}
178
179#endif // wxUSE_STATUSBAR
180