]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/statusbr.cpp
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: native implementation of wxStatusBar (optional)
8 // Copyright: (c) 1998 AUTHOR
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "statusbr.h"
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #include "wx/statusbr.h"
23 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarMac
, wxStatusBar
);
25 BEGIN_EVENT_TABLE(wxStatusBarMac
, wxStatusBar
)
26 EVT_SIZE(wxStatusBarMac::OnSize
)
30 // ============================================================================
32 // ============================================================================
34 // ----------------------------------------------------------------------------
35 // wxStatusBarMac class
36 // ----------------------------------------------------------------------------
38 wxStatusBarMac::wxStatusBarMac()
43 bool wxStatusBarMac::Create(wxWindow
*parent
, wxWindowID id
, long style
, const wxString
& name
= wxPanelNameStr
)
48 m_windowId
= NewControlId();
52 // TODO: create status bar
56 void wxStatusBarMac::SetFieldsCount(int nFields
, const int widths
[])
58 wxASSERT( (nFields
> 0) && (nFields
< 255) );
62 CopyFieldsWidth(widths
);
66 void wxStatusBarMac::SetStatusWidths(int n
, const int widths
[])
68 wxASSERT( n
== m_nFields
);
70 CopyFieldsWidth(widths
);
74 void wxStatusBarMac::CopyFieldsWidth(const int widths
[])
76 if (widths
&& !m_statusWidths
)
77 m_statusWidths
= new int[m_nFields
];
79 if ( widths
!= NULL
) {
80 for ( int i
= 0; i
< m_nFields
; i
++ )
81 m_statusWidths
[i
] = widths
[i
];
84 delete [] m_statusWidths
;
85 m_statusWidths
= NULL
;
89 void wxStatusBarMac::SetFieldsWidth()
91 int *pWidths
= new int[m_nFields
];
94 GetClientSize(&nWindowWidth
, &y
);
96 if ( m_statusWidths
== NULL
) {
97 // default: all fields have the same width
98 int nWidth
= nWindowWidth
/ m_nFields
;
99 for ( int i
= 0; i
< m_nFields
; i
++ )
100 pWidths
[i
] = (i
+ 1) * nWidth
;
103 // -1 doesn't mean the same thing for wxWindows and Win32, recalc
107 for ( i
= 0; i
< m_nFields
; i
++ ) {
108 if ( m_statusWidths
[i
] == -1 )
111 nTotalWidth
+= m_statusWidths
[i
];
114 if ( nVarCount
== 0 ) {
115 // wrong! at least one field must be of variable width
121 int nVarWidth
= (nWindowWidth
- nTotalWidth
) / nVarCount
;
125 for ( i
= 0; i
< m_nFields
; i
++ ) {
126 if ( m_statusWidths
[i
] == -1 )
127 nCurPos
+= nVarWidth
;
129 nCurPos
+= m_statusWidths
[i
];
130 pWidths
[i
] = nCurPos
;
139 void wxStatusBarMac::SetStatusText(const wxString
& strText
, int nField
)
144 wxString
wxStatusBarMac::GetStatusText(int nField
) const
146 wxASSERT( (nField
> -1) && (nField
< m_nFields
) );
152 void wxStatusBarMac::OnSize(wxSizeEvent
& event
)
154 // adjust fields widths to the new size