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