]>
Commit | Line | Data |
---|---|---|
2646f485 | 1 | /////////////////////////////////////////////////////////////////////////////// |
da80ae71 | 2 | // Name: src/mac/classic/statbar.cpp |
2646f485 SC |
3 | // Purpose: native implementation of wxStatusBar (optional) |
4 | // Author: Stefan Csomor | |
da80ae71 | 5 | // Modified by: |
2646f485 SC |
6 | // Created: 1998-01-01 |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Stefan Csomor | |
65571936 | 9 | // Licence: wxWindows licence |
2646f485 SC |
10 | /////////////////////////////////////////////////////////////////////////////// |
11 | ||
2646f485 SC |
12 | // ---------------------------------------------------------------------------- |
13 | // headers | |
14 | // ---------------------------------------------------------------------------- | |
15 | ||
16 | #include "wx/statusbr.h" | |
da80ae71 WS |
17 | |
18 | #ifndef WX_PRECOMP | |
19 | #include "wx/dc.h" | |
ed4b0fdc | 20 | #include "wx/dcclient.h" |
da80ae71 WS |
21 | #endif |
22 | ||
2646f485 SC |
23 | BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric) |
24 | EVT_PAINT(wxStatusBarMac::OnPaint) | |
25 | END_EVENT_TABLE() | |
26 | ||
27 | #ifdef __WXMAC__ | |
ed4b0fdc | 28 | #include "wx/mac/private.h" |
2646f485 SC |
29 | #endif |
30 | ||
31 | // ============================================================================ | |
32 | // implementation | |
33 | // ============================================================================ | |
34 | ||
35 | // ---------------------------------------------------------------------------- | |
36 | // wxStatusBarMac class | |
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, | |
49 | long style , | |
50 | const wxString& name) | |
51 | { | |
52 | return wxStatusBarGeneric::Create( parent , id , style , name ) ; | |
53 | } | |
54 | ||
55 | void wxStatusBarMac::DrawFieldText(wxDC& dc, int i) | |
56 | { | |
57 | int leftMargin = 2; | |
da80ae71 | 58 | |
2646f485 SC |
59 | wxRect rect; |
60 | GetFieldRect(i, rect); | |
da80ae71 | 61 | |
2646f485 SC |
62 | if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) |
63 | { | |
64 | dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ; | |
65 | } | |
da80ae71 | 66 | |
2646f485 | 67 | wxString text(GetStatusText(i)); |
da80ae71 | 68 | |
2646f485 | 69 | long x, y; |
da80ae71 | 70 | |
2646f485 | 71 | dc.GetTextExtent(text, &x, &y); |
da80ae71 | 72 | |
2646f485 SC |
73 | int xpos = rect.x + leftMargin + 1 ; |
74 | int ypos = 1 ; | |
da80ae71 | 75 | |
2646f485 | 76 | dc.SetClippingRegion(rect.x, 0, rect.width, m_height); |
da80ae71 | 77 | |
2646f485 | 78 | dc.DrawText(text, xpos, ypos); |
da80ae71 | 79 | |
2646f485 SC |
80 | dc.DestroyClippingRegion(); |
81 | } | |
82 | ||
83 | void wxStatusBarMac::DrawField(wxDC& dc, int i) | |
84 | { | |
85 | DrawFieldText(dc, i); | |
86 | } | |
87 | ||
88 | void wxStatusBarMac::SetStatusText(const wxString& text, int number) | |
89 | { | |
90 | wxCHECK_RET( (number >= 0) && (number < m_nFields), | |
91 | _T("invalid status bar field index") ); | |
da80ae71 | 92 | |
2646f485 SC |
93 | m_statusStrings[number] = text; |
94 | wxRect rect; | |
95 | GetFieldRect(number, rect); | |
96 | rect.y=0; | |
97 | rect.height = m_height ; | |
98 | Refresh( TRUE , &rect ) ; | |
99 | Update(); | |
100 | } | |
101 | ||
102 | void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) ) | |
103 | { | |
da80ae71 WS |
104 | wxPaintDC dc(this); |
105 | dc.Clear() ; | |
2646f485 SC |
106 | |
107 | int major,minor; | |
108 | wxGetOsVersion( &major, &minor ); | |
109 | ||
da80ae71 WS |
110 | if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) ) |
111 | { | |
112 | wxPen white( wxWHITE , 1 , wxSOLID ) ; | |
113 | if (major >= 10) | |
2646f485 SC |
114 | { |
115 | //Finder statusbar border color: (Project builder similar is 9B9B9B) | |
da80ae71 | 116 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); |
2646f485 SC |
117 | } |
118 | else | |
119 | { | |
120 | wxPen black( wxBLACK , 1 , wxSOLID ) ; | |
121 | dc.SetPen(black); | |
da80ae71 WS |
122 | } |
123 | dc.DrawLine(0, 0 , | |
124 | m_width , 0); | |
125 | dc.SetPen(white); | |
126 | dc.DrawLine(0, 1 , | |
127 | m_width , 1); | |
128 | } | |
129 | else | |
130 | { | |
131 | if (major >= 10) | |
2646f485 | 132 | //Finder statusbar border color: (Project builder similar is 9B9B9B) |
da80ae71 | 133 | dc.SetPen(wxPen(wxColour(0xB1,0xB1,0xB1),1,wxSOLID)); |
2646f485 SC |
134 | else |
135 | dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID)); | |
136 | ||
da80ae71 WS |
137 | dc.DrawLine(0, 0 , |
138 | m_width , 0); | |
139 | } | |
2646f485 | 140 | |
da80ae71 WS |
141 | int i; |
142 | if ( GetFont().Ok() ) | |
143 | dc.SetFont(GetFont()); | |
144 | dc.SetBackgroundMode(wxTRANSPARENT); | |
2646f485 | 145 | |
da80ae71 WS |
146 | for ( i = 0; i < m_nFields; i ++ ) |
147 | DrawField(dc, i); | |
2646f485 SC |
148 | } |
149 | ||
da80ae71 | 150 | void wxStatusBarMac::MacSuperEnabled( bool enabled ) |
2646f485 SC |
151 | { |
152 | Refresh(FALSE) ; | |
153 | wxWindow::MacSuperEnabled( enabled ) ; | |
154 | } |