]> git.saurik.com Git - wxWidgets.git/blame - src/mac/statbrma.cpp
carbon modal state
[wxWidgets.git] / src / mac / statbrma.cpp
CommitLineData
ee6b1d97
SC
1///////////////////////////////////////////////////////////////////////////////
2// Name: statbar.cpp
3// Purpose: native implementation of wxStatusBar (optional)
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) 1998 AUTHOR
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
SC
24BEGIN_EVENT_TABLE(wxStatusBarMac, wxStatusBarGeneric)
25 EVT_PAINT(wxStatusBarMac::OnPaint)
26END_EVENT_TABLE()
ee6b1d97 27
76a5e5d2
SC
28#ifdef __WXMAC__
29#include "wx/mac/private.h"
30#endif
31
ee6b1d97
SC
32// ============================================================================
33// implementation
34// ============================================================================
35
36// ----------------------------------------------------------------------------
03e11df5 37// wxStatusBarMac class
ee6b1d97
SC
38// ----------------------------------------------------------------------------
39
40wxStatusBarMac::wxStatusBarMac()
41{
42 SetParent(NULL);
43}
44
45wxStatusBarMac::~wxStatusBarMac()
46{
47}
48
49bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
50 long style ,
51 const wxString& name)
52{
53 return wxStatusBarGeneric::Create( parent , id , style , name ) ;
54}
55
56void wxStatusBarMac::DrawFieldText(wxDC& dc, int i)
57{
58 int leftMargin = 2;
59
60 wxRect rect;
61 GetFieldRect(i, rect);
1c469f7f 62
76a5e5d2 63 if ( !IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
1c469f7f
SC
64 {
65 dc.SetTextForeground( wxColour( 0x80 , 0x80 , 0x80 ) ) ;
66 }
ee6b1d97
SC
67
68 wxString text(GetStatusText(i));
69
70 long x, y;
71
72 dc.GetTextExtent(text, &x, &y);
73
74 int xpos = rect.x + leftMargin + 1 ;
75 int ypos = 2 ;
76
77 dc.SetClippingRegion(rect.x, 0, rect.width, m_height);
78
79 dc.DrawText(text, xpos, ypos);
80
81 dc.DestroyClippingRegion();
82}
83
84void wxStatusBarMac::DrawField(wxDC& dc, int i)
85{
86 DrawFieldText(dc, i);
87}
88
8dba8632
SC
89void wxStatusBarMac::SetStatusText(const wxString& text, int number)
90{
91 wxCHECK_RET( (number >= 0) && (number < m_nFields),
92 _T("invalid status bar field index") );
93
94 m_statusStrings[number] = text;
95 wxRect rect;
96 GetFieldRect(number, rect);
97 Refresh( TRUE , &rect ) ;
98 /*
99 // TODO make clear work again also when using themes
100 wxClientDC dc(this);
101 dc.SetBackground( wxBrush(GetBackgroundColour(), wxSOLID) );
102 dc.SetClippingRegion( rect.x+1, rect.y+1, rect.width-1, rect.height-1 );
103 dc.Clear();
104 dc.DestroyClippingRegion();
105 DrawFieldText( dc, number );
106 */
107
108}
109
ee6b1d97
SC
110void wxStatusBarMac::OnPaint(wxPaintEvent& WXUNUSED(event) )
111{
112 wxPaintDC dc(this);
1c469f7f 113
76a5e5d2 114 if ( IsWindowHilited( MAC_WXHWND( MacGetRootWindow() ) ) )
1c469f7f
SC
115 {
116 wxPen black( wxBLACK , 1 , wxSOLID ) ;
ee6b1d97
SC
117 wxPen white( wxWHITE , 1 , wxSOLID ) ;
118
119 dc.SetPen(black);
120 dc.DrawLine(0, 0 ,
121 m_width , 0);
122 dc.SetPen(white);
123 dc.DrawLine(0, 1 ,
124 m_width , 1);
1c469f7f
SC
125 }
126 else
127 {
128 dc.SetPen(wxPen(wxColour(0x80,0x80,0x80),1,wxSOLID));
129 dc.DrawLine(0, 0 ,
130 m_width , 0);
131 }
ee6b1d97
SC
132
133 int i;
134 if ( GetFont().Ok() )
135 dc.SetFont(GetFont());
136 dc.SetBackgroundMode(wxTRANSPARENT);
137
138 for ( i = 0; i < m_nFields; i ++ )
139 DrawField(dc, i);
140
141# ifdef __WXMSW__
142 dc.SetFont(wxNullFont);
143# endif // MSW
03e11df5 144}
1c469f7f
SC
145
146void wxStatusBarMac::MacSuperEnabled( bool enabled )
147{
148 Refresh(FALSE) ;
149 wxWindow::MacSuperEnabled( enabled ) ;
d84afea9 150}