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