]> git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/statbrma.cpp
Don't use DDEExec registry key in wxMSW wxExecute() if it's empty.
[wxWidgets.git] / src / osx / carbon / statbrma.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/statbarma.cpp
3 // Purpose: native implementation of wxStatusBar (optional)
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // Copyright: (c) 1998 Stefan Csomor
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #if wxUSE_STATUSBAR
14
15 #include "wx/statusbr.h"
16
17 #ifndef WX_PRECOMP
18 #include "wx/dc.h"
19 #include "wx/dcclient.h"
20 #include "wx/toplevel.h"
21 #endif
22
23 #include "wx/osx/private.h"
24
25 // Margin between the field text and the field rect
26 #define wxFIELD_TEXT_MARGIN 2
27
28
29 BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
30 EVT_PAINT(wxStatusBarMac::OnPaint)
31 END_EVENT_TABLE()
32
33
34 wxStatusBarMac::wxStatusBarMac(wxWindow *parent,
35 wxWindowID id,
36 long style,
37 const wxString& name)
38 :
39 wxStatusBarGeneric()
40 {
41 SetParent( NULL );
42 Create( parent, id, style, name );
43 }
44
45 wxStatusBarMac::wxStatusBarMac()
46 :
47 wxStatusBarGeneric()
48 {
49 SetParent( NULL );
50 }
51
52 wxStatusBarMac::~wxStatusBarMac()
53 {
54 }
55
56 bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
57 long style ,
58 const wxString& name)
59 {
60 if ( !wxStatusBarGeneric::Create( parent, id, style, name ) )
61 return false;
62
63 if ( parent->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
64 SetBackgroundStyle( wxBG_STYLE_TRANSPARENT );
65
66 // normal system font is too tall for fitting into the standard height
67 SetWindowVariant( wxWINDOW_VARIANT_SMALL );
68
69 return true;
70 }
71
72 void wxStatusBarMac::DrawFieldText(wxDC& dc, const wxRect& rect, int i, int WXUNUSED(textHeight))
73 {
74 int w, h;
75 GetSize( &w , &h );
76
77 if ( !MacIsReallyHilited() )
78 dc.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) );
79
80 wxString text(GetStatusText( i ));
81
82 /*wxCoord x, y;
83 dc.GetTextExtent(text, &x, &y); -- seems unused (FM)*/
84
85 int xpos = rect.x + wxFIELD_TEXT_MARGIN + 1;
86 int ypos = 1;
87
88 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
89 ypos++;
90
91 dc.SetClippingRegion(rect.x, 0, rect.width, h);
92 dc.DrawText(text, xpos, ypos);
93 dc.DestroyClippingRegion();
94 }
95
96 void wxStatusBarMac::DrawField(wxDC& dc, int i, int textHeight)
97 {
98 wxRect rect;
99 GetFieldRect(i, rect);
100
101 DrawFieldText(dc, rect, i, textHeight);
102 }
103
104 void wxStatusBarMac::DoUpdateStatusText(int number)
105 {
106 wxRect rect;
107 GetFieldRect(number, rect);
108
109 int w, h;
110 GetSize( &w, &h );
111
112 rect.y = 0;
113 rect.height = h ;
114
115 Refresh( true, &rect );
116 // we should have to force the update here
117 // TODO Remove if no regressions occur
118 #if 0
119 Update();
120 #endif
121 }
122
123 void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event))
124 {
125 wxPaintDC dc(this);
126 dc.Clear();
127
128 int major, minor;
129 wxGetOsVersion( &major, &minor );
130 int w, h;
131 GetSize( &w, &h );
132
133 if ( MacIsReallyHilited() )
134 {
135 wxPen white( *wxWHITE , 1 , wxSOLID );
136 if (major >= 10)
137 {
138 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
139 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL )
140 dc.SetPen(wxPen(wxColour(0x40, 0x40, 0x40), 1, wxSOLID));
141 else
142 dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID));
143 }
144 else
145 {
146 wxPen black( *wxBLACK , 1 , wxSOLID );
147 dc.SetPen(black);
148 }
149
150 dc.DrawLine(0, 0, w, 0);
151 dc.SetPen(white);
152 dc.DrawLine(0, 1, w, 1);
153 }
154 else
155 {
156 if (major >= 10)
157 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
158 dc.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID));
159 else
160 dc.SetPen(wxPen(wxColour(0x80, 0x80, 0x80), 1, wxSOLID));
161
162 dc.DrawLine(0, 0, w, 0);
163 }
164
165 if ( GetFont().IsOk() )
166 dc.SetFont(GetFont());
167 dc.SetBackgroundMode(wxTRANSPARENT);
168
169 // compute char height only once for all panes:
170 int textHeight = dc.GetCharHeight();
171
172 for ( size_t i = 0; i < m_panes.GetCount(); i ++ )
173 DrawField(dc, i, textHeight);
174 }
175
176 void wxStatusBarMac::MacHiliteChanged()
177 {
178 Refresh();
179 Update();
180 }
181
182 #endif // wxUSE_STATUSBAR
183