]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/statbrma.cpp
fixes for file drops in unicode
[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 #include "wx/toplevel.h"
31 #endif
32
33 // ============================================================================
34 // implementation
35 // ============================================================================
36
37 // ----------------------------------------------------------------------------
38 // wxStatusBarMac class
39 // ----------------------------------------------------------------------------
40
41 wxStatusBarMac::wxStatusBarMac()
42 {
43 SetParent(NULL);
44 }
45
46 wxStatusBarMac::~wxStatusBarMac()
47 {
48 }
49
50 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
51 long style ,
52 const wxString& name)
53 {
54 if( !wxStatusBarGeneric::Create( parent , id , style , name ) )
55 return FALSE ;
56
57 if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
58 MacSetBackgroundBrush( wxNullBrush ) ;
59
60 return TRUE ;
61 }
62
63 void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
64 {
65 int leftMargin = 2;
66 int w, h ;
67 GetSize( &w , &h ) ;
68 wxRect rect;
69 GetFieldRect(i, rect);
70
71 if ( !MacIsReallyHilited() )
72 {
73 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
74 }
75
76 wxString text(GetStatusText(i));
77
78 long x, y;
79
80 dc.GetTextExtent(text, &x, &y);
81
82 int xpos = rect.x + leftMargin + 1 ;
83 int ypos = 1 ;
84
85 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
86 ypos++ ;
87
88 dc.SetClippingRegion(rect.x, 0, rect.width, h);
89
90 dc.DrawText(text, xpos, ypos);
91
92 dc.DestroyClippingRegion();
93 }
94
95 void wxStatusBarMac::DrawField(wxDC& dc, int i)
96 {
97 DrawFieldText(dc, i);
98 }
99
100 void wxStatusBarMac::SetStatusText(const wxString& text, int number)
101 {
102 wxCHECK_RET( (number >= 0) && (number < m_nFields),
103 _T("invalid status bar field index") );
104
105 m_statusStrings[number] = text;
106 wxRect rect;
107 GetFieldRect(number, rect);
108 int w, h ;
109 GetSize( &w , &h ) ;
110 rect.y=0;
111 rect.height = h ;
112 Refresh( TRUE , &rect ) ;
113 Update();
114 }
115
116 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
117 {
118 wxPaintDC dc(this);
119 dc.Clear() ;
120
121 int major,minor;
122 wxGetOsVersion( &major, &minor );
123 int w, h ;
124 GetSize( &w , &h ) ;
125
126 if ( MacIsReallyHilited() )
127 {
128 wxPen white( wxWHITE , 1 , wxSOLID ) ;
129 if (major >= 10 )
130 {
131 //Finder statusbar border color: (Project builder similar is 9B9B9B)
132 if ( MacGetTopLevelWindow()->MacGetMetalAppearance() )
133 dc.SetPen(wxPen(wxColour(0x40,40,40) ,1,wxSOLID)) ;
134 else
135 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
136 }
137 else
138 {
139 wxPen black( wxBLACK , 1 , wxSOLID ) ;
140 dc.SetPen(black);
141 }
142 dc.DrawLine(0, 0 ,
143 w , 0);
144 dc.SetPen(white);
145 dc.DrawLine(0, 1 ,
146 w , 1);
147 }
148 else
149 {
150 if (major >= 10)
151 //Finder statusbar border color: (Project builder similar is 9B9B9B)
152 dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID));
153 else
154 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
155
156 dc.DrawLine(0, 0 ,
157 w , 0);
158 }
159
160 int i;
161 if ( GetFont().Ok() )
162 dc.SetFont(GetFont());
163 dc.SetBackgroundMode(wxTRANSPARENT);
164
165 for ( i = 0; i < m_nFields; i ++ )
166 DrawField(dc, i);
167 }
168
169 void wxStatusBarMac::MacHiliteChanged()
170 {
171 Refresh() ;
172 Update() ;
173 }