]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbrma.cpp
background drawing uncommented again
[wxWidgets.git] / src / mac / carbon / statbrma.cpp
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 #ifdef __GNUG__
13 #pragma implementation "statbrma.h"
14 #endif
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/statusbr.h"
21 #include "wx/dc.h"
22 #include "wx/dcclient.h"
23
24 BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
25 EVT_PAINT(wxStatusBarMac::OnPaint)
26 END_EVENT_TABLE()
27
28 #ifdef __WXMAC__
29 #include "wx/mac/private.h"
30 #endif
31
32 // ============================================================================
33 // implementation
34 // ============================================================================
35
36 // ----------------------------------------------------------------------------
37 // wxStatusBarMac class
38 // ----------------------------------------------------------------------------
39
40 wxStatusBarMac::wxStatusBarMac()
41 {
42 SetParent(NULL);
43 }
44
45 wxStatusBarMac::~wxStatusBarMac()
46 {
47 }
48
49 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
50 long style ,
51 const wxString& name)
52 {
53 if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
54 return FALSE ;
55
56 m_macBackgroundBrush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
57
58 return TRUE ;
59 }
60
61 void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
62 {
63 int leftMargin = 2;
64 int w, h ;
65 GetSize( &w , &h ) ;
66 wxRect rect;
67 GetFieldRect(i, rect);
68
69 if ( !IsWindowHilited( MAC_WXHWND( MacGetTopLevelWindowRef() ) ) )
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 ;
81 int ypos = 1 ;
82
83 dc.SetClippingRegion(rect.x, 0, rect.width, h);
84
85 dc.DrawText(text, xpos, ypos);
86
87 dc.DestroyClippingRegion();
88 }
89
90 void wxStatusBarMac::DrawField(wxDC& dc, int i)
91 {
92 DrawFieldText(dc, i);
93 }
94
95 void wxStatusBarMac::SetStatusText(const wxString& text, int number)
96 {
97 wxCHECK_RET( (number >= 0) && (number < m_nFields),
98 _T("invalid status bar field index") );
99
100 m_statusStrings[number] = text;
101 wxRect rect;
102 GetFieldRect(number, rect);
103 int w, h ;
104 GetSize( &w , &h ) ;
105 rect.y=0;
106 rect.height = h ;
107 Refresh( TRUE , &rect ) ;
108 Update();
109 }
110
111 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
112 {
113 wxPaintDC dc(this);
114 dc.Clear() ;
115
116 int major,minor;
117 wxGetOsVersion( &major, &minor );
118 int w, h ;
119 GetSize( &w , &h ) ;
120
121 if ( IsWindowHilited( MAC_WXHWND( MacGetTopLevelWindowRef() ) ) )
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 ,
135 w , 0);
136 dc.SetPen(white);
137 dc.DrawLine(0, 1 ,
138 w , 1);
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 ,
149 w , 0);
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);
159 }