]>
Commit | Line | Data |
---|---|---|
ee6b1d97 SC |
1 | /////////////////////////////////////////////////////////////////////////////// |
2 | // Name: statbar.cpp | |
3 | // Purpose: native implementation of wxStatusBar (optional) | |
a31a5f85 | 4 | // Author: Stefan Csomor |
ee6b1d97 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
ee6b1d97 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) 1998 Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
ee6b1d97 SC |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
3d1a4878 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
b142515e | 13 | #pragma implementation "statbrma.h" |
ee6b1d97 SC |
14 | #endif |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
3d1a4878 SC |
20 | #include "wx/wxprec.h" |
21 | ||
03e11df5 GD |
22 | #include "wx/statusbr.h" |
23 | #include "wx/dc.h" | |
24 | #include "wx/dcclient.h" | |
ee6b1d97 | 25 | |
ee6b1d97 | 26 | BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) |
e40298d5 | 27 | EVT_PAINT(wxStatusBarMac::OnPaint) |
ee6b1d97 | 28 | END_EVENT_TABLE() |
ee6b1d97 | 29 | |
76a5e5d2 SC |
30 | #ifdef __WXMAC__ |
31 | #include "wx/mac/private.h" | |
3a72b6a4 | 32 | #include "wx/toplevel.h" |
76a5e5d2 SC |
33 | #endif |
34 | ||
ee6b1d97 SC |
35 | // ============================================================================ |
36 | // implementation | |
37 | // ============================================================================ | |
38 | ||
39 | // ---------------------------------------------------------------------------- | |
03e11df5 | 40 | // wxStatusBarMac class |
ee6b1d97 SC |
41 | // ---------------------------------------------------------------------------- |
42 | ||
43 | wxStatusBarMac::wxStatusBarMac() | |
44 | { | |
45 | SetParent(NULL); | |
46 | } | |
47 | ||
48 | wxStatusBarMac::~wxStatusBarMac() | |
49 | { | |
50 | } | |
51 | ||
52 | bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id, | |
e40298d5 JS |
53 | long style , |
54 | const wxString& name) | |
ee6b1d97 | 55 | { |
facd6764 SC |
56 | if( !wxStatusBarGeneric::Create( parent , id , style , name ) ) |
57 | return FALSE ; | |
58 | ||
0966d1fe SC |
59 | if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() ) |
60 | MacSetBackgroundBrush( wxNullBrush ) ; | |
facd6764 | 61 | |
70aaa701 SC |
62 | // normal system font is too tall for fitting into the standard height |
63 | SetWindowVariant( wxWINDOW_VARIANT_SMALL ) ; | |
64 | ||
facd6764 | 65 | return TRUE ; |
ee6b1d97 SC |
66 | } |
67 | ||
68 | void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) | |
69 | { | |
e40298d5 | 70 | int leftMargin = 2; |
facd6764 SC |
71 | int w, h ; |
72 | GetSize( &w , &h ) ; | |
e40298d5 JS |
73 | wxRect rect; |
74 | GetFieldRect(i, rect); | |
75 | ||
8ab50549 | 76 | if ( !MacIsReallyHilited() ) |
e40298d5 JS |
77 | { |
78 | dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; | |
79 | } | |
80 | ||
81 | wxString text(GetStatusText(i)); | |
82 | ||
83 | long x, y; | |
84 | ||
85 | dc.GetTextExtent(text, &x, &y); | |
86 | ||
87 | int xpos = rect.x + leftMargin + 1 ; | |
8ab50549 | 88 | int ypos = 1 ; |
e40298d5 | 89 | |
8ab50549 SC |
90 | if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) |
91 | ypos++ ; | |
92 | ||
facd6764 | 93 | dc.SetClippingRegion(rect.x, 0, rect.width, h); |
e40298d5 JS |
94 | |
95 | dc.DrawText(text, xpos, ypos); | |
96 | ||
97 | dc.DestroyClippingRegion(); | |
ee6b1d97 SC |
98 | } |
99 | ||
100 | void wxStatusBarMac::DrawField(wxDC& dc, int i) | |
101 | { | |
102 | DrawFieldText(dc, i); | |
103 | } | |
104 | ||
8dba8632 SC |
105 | void wxStatusBarMac::SetStatusText(const wxString& text, int number) |
106 | { | |
107 | wxCHECK_RET( (number >= 0) && (number < m_nFields), | |
e40298d5 JS |
108 | _T("invalid status bar field index") ); |
109 | ||
8dba8632 SC |
110 | m_statusStrings[number] = text; |
111 | wxRect rect; | |
112 | GetFieldRect(number, rect); | |
facd6764 SC |
113 | int w, h ; |
114 | GetSize( &w , &h ) ; | |
6dbc7fb4 | 115 | rect.y=0; |
facd6764 | 116 | rect.height = h ; |
8dba8632 | 117 | Refresh( TRUE , &rect ) ; |
852b1185 | 118 | Update(); |
8dba8632 SC |
119 | } |
120 | ||
ee6b1d97 SC |
121 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) |
122 | { | |
11d1adbf SC |
123 | wxPaintDC dc(this); |
124 | dc.Clear() ; | |
125 | ||
126 | int major,minor; | |
127 | wxGetOsVersion( &major, &minor ); | |
facd6764 SC |
128 | int w, h ; |
129 | GetSize( &w , &h ) ; | |
11d1adbf | 130 | |
8ab50549 | 131 | if ( MacIsReallyHilited() ) |
11d1adbf SC |
132 | { |
133 | wxPen white( wxWHITE , 1 , wxSOLID ) ; | |
0966d1fe | 134 | if (major >= 10 ) |
11d1adbf SC |
135 | { |
136 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
0966d1fe SC |
137 | if ( MacGetTopLevelWindow()->MacGetMetalAppearance() ) |
138 | dc.SetPen(wxPen(wxColour(0x40,40,40) ,1,wxSOLID)) ; | |
139 | else | |
140 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
11d1adbf SC |
141 | } |
142 | else | |
143 | { | |
144 | wxPen black( wxBLACK , 1 , wxSOLID ) ; | |
145 | dc.SetPen(black); | |
146 | } | |
147 | dc.DrawLine(0, 0 , | |
facd6764 | 148 | w , 0); |
11d1adbf SC |
149 | dc.SetPen(white); |
150 | dc.DrawLine(0, 1 , | |
facd6764 | 151 | w , 1); |
11d1adbf SC |
152 | } |
153 | else | |
154 | { | |
155 | if (major >= 10) | |
156 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
157 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); | |
158 | else | |
159 | dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); | |
160 | ||
161 | dc.DrawLine(0, 0 , | |
facd6764 | 162 | w , 0); |
11d1adbf SC |
163 | } |
164 | ||
165 | int i; | |
166 | if ( GetFont().Ok() ) | |
167 | dc.SetFont(GetFont()); | |
168 | dc.SetBackgroundMode(wxTRANSPARENT); | |
169 | ||
170 | for ( i = 0; i < m_nFields; i ++ ) | |
171 | DrawField(dc, i); | |
03e11df5 | 172 | } |
8ab50549 SC |
173 | |
174 | void wxStatusBarMac::MacHiliteChanged() | |
175 | { | |
176 | Refresh() ; | |
177 | Update() ; | |
178 | } |