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