]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/statbrma.cpp
removed Win16 code (patch 905241), last version with remains of Win16 support tagged...
[wxWidgets.git] / src / mac / carbon / statbrma.cpp
CommitLineData
ee6b1d97
SC
1///////////////////////////////////////////////////////////////////////////////
2// Name: statbar.cpp
3// Purpose: native implementation of wxStatusBar (optional)
a31a5f85 4// Author: Stefan Csomor
ee6b1d97 5// Modified by:
a31a5f85 6// Created: 1998-01-01
ee6b1d97 7// RCS-ID: $Id$
a31a5f85 8// Copyright: (c) 1998 Stefan Csomor
ee6b1d97
SC
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
b142515e 13#pragma implementation "statbrma.h"
ee6b1d97
SC
14#endif
15
16// ----------------------------------------------------------------------------
17// headers
18// ----------------------------------------------------------------------------
19
03e11df5
GD
20#include "wx/statusbr.h"
21#include "wx/dc.h"
22#include "wx/dcclient.h"
ee6b1d97 23
ee6b1d97 24BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
e40298d5 25 EVT_PAINT(wxStatusBarMac::OnPaint)
ee6b1d97 26END_EVENT_TABLE()
ee6b1d97 27
76a5e5d2
SC
28#ifdef __WXMAC__
29#include "wx/mac/private.h"
30#endif
31
ee6b1d97
SC
32// ============================================================================
33// implementation
34// ============================================================================
35
36// ----------------------------------------------------------------------------
03e11df5 37// wxStatusBarMac class
ee6b1d97
SC
38// ----------------------------------------------------------------------------
39
40wxStatusBarMac::wxStatusBarMac()
41{
42 SetParent(NULL);
43}
44
45wxStatusBarMac::~wxStatusBarMac()
46{
47}
48
49bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
e40298d5
JS
50 long style ,
51 const wxString& name)
ee6b1d97 52{
facd6764
SC
53 if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
54 return FALSE ;
55
56 m_macBackgroundBrush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
57
58 return TRUE ;
ee6b1d97
SC
59}
60
61void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
62{
e40298d5 63 int leftMargin = 2;
facd6764
SC
64 int w, h ;
65 GetSize( &w , &h ) ;
e40298d5
JS
66 wxRect rect;
67 GetFieldRect(i, rect);
68
facd6764 69 if ( !IsWindowHilited( MAC_WXHWND( MacGetTopLevelWindowRef() ) ) )
e40298d5
JS
70 {
71 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
72 }
73
74 wxString text(GetStatusText(i));
75
76 long x, y;
77
78 dc.GetTextExtent(text, &x, &y);
79
80 int xpos = rect.x + leftMargin + 1 ;
852b1185 81 int ypos = 1 ;
e40298d5 82
facd6764 83 dc.SetClippingRegion(rect.x, 0, rect.width, h);
e40298d5
JS
84
85 dc.DrawText(text, xpos, ypos);
86
87 dc.DestroyClippingRegion();
ee6b1d97
SC
88}
89
90void wxStatusBarMac::DrawField(wxDC& dc, int i)
91{
92 DrawFieldText(dc, i);
93}
94
8dba8632
SC
95void wxStatusBarMac::SetStatusText(const wxString& text, int number)
96{
97 wxCHECK_RET( (number >= 0) && (number < m_nFields),
e40298d5
JS
98 _T("invalid status bar field index") );
99
8dba8632
SC
100 m_statusStrings[number] = text;
101 wxRect rect;
102 GetFieldRect(number, rect);
facd6764
SC
103 int w, h ;
104 GetSize( &w , &h ) ;
6dbc7fb4 105 rect.y=0;
facd6764 106 rect.height = h ;
8dba8632 107 Refresh( TRUE , &rect ) ;
852b1185 108 Update();
8dba8632
SC
109}
110
ee6b1d97
SC
111void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
112{
11d1adbf
SC
113 wxPaintDC dc(this);
114 dc.Clear() ;
115
116 int major,minor;
117 wxGetOsVersion( &major, &minor );
facd6764
SC
118 int w, h ;
119 GetSize( &w , &h ) ;
11d1adbf 120
facd6764 121 if ( IsWindowHilited( MAC_WXHWND( MacGetTopLevelWindowRef() ) ) )
11d1adbf
SC
122 {
123 wxPen white( wxWHITE , 1 , wxSOLID ) ;
124 if (major >= 10)
125 {
126 //Finder statusbar border color: (Project builder similar is 9B9B9B)
127 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
128 }
129 else
130 {
131 wxPen black( wxBLACK , 1 , wxSOLID ) ;
132 dc.SetPen(black);
133 }
134 dc.DrawLine(0, 0 ,
facd6764 135 w , 0);
11d1adbf
SC
136 dc.SetPen(white);
137 dc.DrawLine(0, 1 ,
facd6764 138 w , 1);
11d1adbf
SC
139 }
140 else
141 {
142 if (major >= 10)
143 //Finder statusbar border color: (Project builder similar is 9B9B9B)
144 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
145 else
146 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
147
148 dc.DrawLine(0, 0 ,
facd6764 149 w , 0);
11d1adbf
SC
150 }
151
152 int i;
153 if ( GetFont().Ok() )
154 dc.SetFont(GetFont());
155 dc.SetBackgroundMode(wxTRANSPARENT);
156
157 for ( i = 0; i < m_nFields; i ++ )
158 DrawField(dc, i);
03e11df5 159}