]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/mac/carbon/statbrma.cpp
fix Borland bug http://news.gmane.org/find-root.php?message_id=%3c43A0B07F.8010204...
[wxWidgets.git] / src / mac / carbon / statbrma.cpp
... / ...
CommitLineData
1///////////////////////////////////////////////////////////////////////////////
2// Name: statbar.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// ----------------------------------------------------------------------------
13// headers
14// ----------------------------------------------------------------------------
15
16#include "wx/wxprec.h"
17
18#include "wx/statusbr.h"
19#include "wx/dc.h"
20#include "wx/dcclient.h"
21
22BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
23 EVT_PAINT(wxStatusBarMac::OnPaint)
24END_EVENT_TABLE()
25
26#ifdef __WXMAC__
27#include "wx/mac/private.h"
28#include "wx/toplevel.h"
29#endif
30
31// ============================================================================
32// implementation
33// ============================================================================
34
35// ----------------------------------------------------------------------------
36// wxStatusBarMac class
37// ----------------------------------------------------------------------------
38
39wxStatusBarMac::wxStatusBarMac()
40{
41 SetParent(NULL);
42}
43
44wxStatusBarMac::~wxStatusBarMac()
45{
46}
47
48bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
49 long style ,
50 const wxString& name)
51{
52 if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
53 return FALSE ;
54
55 if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
56 MacSetBackgroundBrush( wxNullBrush ) ;
57
58 // normal system font is too tall for fitting into the standard height
59 SetWindowVariant( wxWINDOW_VARIANT_SMALL ) ;
60
61 return TRUE ;
62}
63
64void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
65{
66 int leftMargin = 2;
67 int w, h ;
68 GetSize( &w , &h ) ;
69 wxRect rect;
70 GetFieldRect(i, rect);
71
72 if ( !MacIsReallyHilited() )
73 {
74 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
75 }
76
77 wxString text(GetStatusText(i));
78
79 long x, y;
80
81 dc.GetTextExtent(text, &x, &y);
82
83 int xpos = rect.x + leftMargin + 1 ;
84 int ypos = 1 ;
85
86 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
87 ypos++ ;
88
89 dc.SetClippingRegion(rect.x, 0, rect.width, h);
90
91 dc.DrawText(text, xpos, ypos);
92
93 dc.DestroyClippingRegion();
94}
95
96void wxStatusBarMac::DrawField(wxDC& dc, int i)
97{
98 DrawFieldText(dc, i);
99}
100
101void wxStatusBarMac::SetStatusText(const wxString& text, int number)
102{
103 wxCHECK_RET( (number >= 0) && (number < m_nFields),
104 _T("invalid status bar field index") );
105
106 if ( m_statusStrings[number] == text )
107 return ;
108
109 m_statusStrings[number] = text;
110 wxRect rect;
111 GetFieldRect(number, rect);
112 int w, h ;
113 GetSize( &w , &h ) ;
114 rect.y=0;
115 rect.height = h ;
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)
136 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
137 dc.SetPen(wxPen(wxColour(0x40,40,40) ,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 dc.DrawLine(0, 0 ,
147 w , 0);
148 dc.SetPen(white);
149 dc.DrawLine(0, 1 ,
150 w , 1);
151 }
152 else
153 {
154 if (major >= 10)
155 //Finder statusbar border color: (Project builder similar is 9B9B9B)
156 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
157 else
158 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
159
160 dc.DrawLine(0, 0 ,
161 w , 0);
162 }
163
164 int i;
165 if ( GetFont().Ok() )
166 dc.SetFont(GetFont());
167 dc.SetBackgroundMode(wxTRANSPARENT);
168
169 for ( i = 0; i < m_nFields; i ++ )
170 DrawField(dc, i);
171}
172
173void wxStatusBarMac::MacHiliteChanged()
174{
175 Refresh() ;
176 Update() ;
177}