]>
git.saurik.com Git - wxWidgets.git/blob - src/stubs/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 // ----------------------------------------------------------------------------
20 #include "wx/stubs/statusbr.h"
22 #if !USE_SHARED_LIBRARY
23 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX
, wxStatusBar
);
25 BEGIN_EVENT_TABLE(wxStatusBarXX
, wxStatusBar
)
26 EVT_SIZE(wxStatusBarXX::OnSize
)
28 #endif //USE_SHARED_LIBRARY
31 // ============================================================================
33 // ============================================================================
35 // ----------------------------------------------------------------------------
36 // wxStatusBarXX class
37 // ----------------------------------------------------------------------------
39 wxStatusBarXX::wxStatusBarXX()
44 wxStatusBarXX::wxStatusBarXX(wxWindow
*parent
, wxWindowID id
, long style
)
46 Create(parent
, id
, style
);
49 bool wxStatusBarXX::Create(wxWindow
*parent
, wxWindowID id
, long style
)
54 m_windowId
= NewControlId();
58 // TODO: create status bar
62 void wxStatusBarXX::CopyFieldsWidth(const int widths
[])
64 if (widths
&& !m_statusWidths
)
65 m_statusWidths
= new int[m_nFields
];
67 if ( widths
!= NULL
) {
68 for ( int i
= 0; i
< m_nFields
; i
++ )
69 m_statusWidths
[i
] = widths
[i
];
72 delete [] m_statusWidths
;
73 m_statusWidths
= NULL
;
77 void wxStatusBarXX::SetFieldsCount(int nFields
, const int widths
[])
79 wxASSERT( (nFields
> 0) && (nFields
< 255) );
83 CopyFieldsWidth(widths
);
87 void wxStatusBarXX::SetStatusWidths(int n
, const int widths
[])
89 wxASSERT( n
== m_nFields
);
91 CopyFieldsWidth(widths
);
95 void wxStatusBarXX::SetFieldsWidth()
97 int *pWidths
= new int[m_nFields
];
100 GetClientSize(&nWindowWidth
, &y
);
102 if ( m_statusWidths
== NULL
) {
103 // default: all fields have the same width
104 int nWidth
= nWindowWidth
/ m_nFields
;
105 for ( int i
= 0; i
< m_nFields
; i
++ )
106 pWidths
[i
] = (i
+ 1) * nWidth
;
109 // -1 doesn't mean the same thing for wxWindows and Win32, recalc
113 for ( i
= 0; i
< m_nFields
; i
++ ) {
114 if ( m_statusWidths
[i
] == -1 )
117 nTotalWidth
+= m_statusWidths
[i
];
120 if ( nVarCount
== 0 ) {
121 // wrong! at least one field must be of variable width
127 int nVarWidth
= (nWindowWidth
- nTotalWidth
) / nVarCount
;
131 for ( i
= 0; i
< m_nFields
; i
++ ) {
132 if ( m_statusWidths
[i
] == -1 )
133 nCurPos
+= nVarWidth
;
135 nCurPos
+= m_statusWidths
[i
];
136 pWidths
[i
] = nCurPos
;
145 void wxStatusBarXX::SetStatusText(const wxString
& strText
, int nField
)
150 wxString
wxStatusBarXX::GetStatusText(int nField
) const
152 wxASSERT( (nField
> -1) && (nField
< m_nFields
) );
158 void wxStatusBarXX::OnSize(wxSizeEvent
& event
)
160 // adjust fields widths to the new size