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