]>
git.saurik.com Git - wxWidgets.git/blob - src/osx/carbon/statbrma.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/carbon/statbarma.cpp
3 // Purpose: native implementation of wxStatusBar (optional)
4 // Author: Stefan Csomor
8 // Copyright: (c) 1998 Stefan Csomor
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/statusbr.h"
20 #include "wx/dcclient.h"
21 #include "wx/toplevel.h"
24 #include "wx/osx/private.h"
26 // Margin between the field text and the field rect
27 #define wxFIELD_TEXT_MARGIN 2
30 BEGIN_EVENT_TABLE(wxStatusBarMac
, wxStatusBarGeneric
)
31 EVT_PAINT(wxStatusBarMac::OnPaint
)
35 wxStatusBarMac::wxStatusBarMac(wxWindow
*parent
,
43 Create( parent
, id
, style
, name
);
46 wxStatusBarMac::wxStatusBarMac()
53 wxStatusBarMac::~wxStatusBarMac()
57 bool wxStatusBarMac::Create(wxWindow
*parent
, wxWindowID id
,
61 if ( !wxStatusBarGeneric::Create( parent
, id
, style
, name
) )
64 if ( parent
->MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL
)
65 SetBackgroundStyle( wxBG_STYLE_TRANSPARENT
);
67 // normal system font is too tall for fitting into the standard height
68 SetWindowVariant( wxWINDOW_VARIANT_SMALL
);
73 void wxStatusBarMac::DrawFieldText(wxDC
& dc
, const wxRect
& rect
, int i
, int WXUNUSED(textHeight
))
78 if ( !MacIsReallyHilited() )
79 dc
.SetTextForeground( wxColour( 0x80, 0x80, 0x80 ) );
81 wxString
text(GetStatusText( i
));
84 dc.GetTextExtent(text, &x, &y); -- seems unused (FM)*/
86 int xpos
= rect
.x
+ wxFIELD_TEXT_MARGIN
+ 1;
89 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL
)
92 dc
.SetClippingRegion(rect
.x
, 0, rect
.width
, h
);
93 dc
.DrawText(text
, xpos
, ypos
);
94 dc
.DestroyClippingRegion();
97 void wxStatusBarMac::DrawField(wxDC
& dc
, int i
, int textHeight
)
100 GetFieldRect(i
, rect
);
102 DrawFieldText(dc
, rect
, i
, textHeight
);
105 void wxStatusBarMac::SetStatusText(const wxString
& text
, int number
)
107 // NOTE: seems this function is identic to wxStatusBarGeneric::SetStatusText;
108 // probably can be removed without problems (FM)
110 wxCHECK_RET( (number
>= 0) && ((size_t)number
< m_panes
.GetCount()),
111 wxT("invalid status bar field index") );
113 if ( GetStatusText(number
) == text
)
116 wxStatusBarGeneric::SetStatusText(text
, number
);
119 GetFieldRect(number
, rect
);
127 Refresh( true, &rect
);
131 void wxStatusBarMac::OnPaint(wxPaintEvent
& WXUNUSED(event
))
137 wxGetOsVersion( &major
, &minor
);
141 if ( MacIsReallyHilited() )
143 wxPen
white( *wxWHITE
, 1 , wxSOLID
);
146 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
147 if ( MacGetTopLevelWindow()->GetExtraStyle() & wxFRAME_EX_METAL
)
148 dc
.SetPen(wxPen(wxColour(0x40, 0x40, 0x40), 1, wxSOLID
));
150 dc
.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID
));
154 wxPen
black( *wxBLACK
, 1 , wxSOLID
);
158 dc
.DrawLine(0, 0, w
, 0);
160 dc
.DrawLine(0, 1, w
, 1);
165 // Finder statusbar border color: (Project Builder similar is 9B9B9B)
166 dc
.SetPen(wxPen(wxColour(0xB1, 0xB1, 0xB1), 1, wxSOLID
));
168 dc
.SetPen(wxPen(wxColour(0x80, 0x80, 0x80), 1, wxSOLID
));
170 dc
.DrawLine(0, 0, w
, 0);
173 if ( GetFont().IsOk() )
174 dc
.SetFont(GetFont());
175 dc
.SetBackgroundMode(wxTRANSPARENT
);
177 // compute char height only once for all panes:
178 int textHeight
= dc
.GetCharHeight();
180 for ( size_t i
= 0; i
< m_panes
.GetCount(); i
++ )
181 DrawField(dc
, i
, textHeight
);
184 void wxStatusBarMac::MacHiliteChanged()
190 #endif // wxUSE_STATUSBAR