]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/statbrpm.cpp
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: native implementation of wxStatusBar (optional)
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
18 #include "wx/settings.h"
19 #include "wx/dcclient.h"
23 #include "wx/generic/statusbr.h"
24 #include "wx/os2/statusbr.h"
26 #include "wx/os2/private.h"
28 #if !USE_SHARED_LIBRARY
29 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarPM
, wxStatusBar
);
31 BEGIN_EVENT_TABLE(wxStatusBarPM
, wxStatusBar
)
32 EVT_SIZE(wxStatusBarPM::OnSize
)
34 #endif //USE_SHARED_LIBRARY
37 // ============================================================================
39 // ============================================================================
41 // ----------------------------------------------------------------------------
42 // wxStatusBarPM class
43 // ----------------------------------------------------------------------------
45 wxStatusBarPM::wxStatusBarPM()
52 wxStatusBarPM::wxStatusBarPM(wxWindow
*parent
, wxWindowID id
, long style
)
54 Create(parent
, id
, style
);
57 bool wxStatusBarPM::Create(wxWindow
*parent
, wxWindowID id
, long style
)
62 m_windowId
= NewControlId();
66 // TODO: create status bar
70 void wxStatusBarPM::CopyFieldsWidth(const int widths
[])
72 if (widths
&& !m_statusWidths
)
73 m_statusWidths
= new int[m_nFields
];
75 if ( widths
!= NULL
) {
76 for ( int i
= 0; i
< m_nFields
; i
++ )
77 m_statusWidths
[i
] = widths
[i
];
80 delete [] m_statusWidths
;
81 m_statusWidths
= NULL
;
85 void wxStatusBarPM::SetFieldsCount(int nFields
, const int widths
[])
87 wxASSERT( (nFields
> 0) && (nFields
< 255) );
91 CopyFieldsWidth(widths
);
95 void wxStatusBarPM::SetStatusWidths(int n
, const int widths
[])
97 wxASSERT( n
== m_nFields
);
99 CopyFieldsWidth(widths
);
103 void wxStatusBarPM::SetFieldsWidth()
105 int *pWidths
= new int[m_nFields
];
108 GetClientSize(&nWindowWidth
, &y
);
110 if ( m_statusWidths
== NULL
) {
111 // default: all fields have the same width
112 int nWidth
= nWindowWidth
/ m_nFields
;
113 for ( int i
= 0; i
< m_nFields
; i
++ )
114 pWidths
[i
] = (i
+ 1) * nWidth
;
117 // -1 doesn't mean the same thing for wxWindows and Win32, recalc
121 for ( i
= 0; i
< m_nFields
; i
++ ) {
122 if ( m_statusWidths
[i
] == -1 )
125 nTotalWidth
+= m_statusWidths
[i
];
128 if ( nVarCount
== 0 ) {
129 // wrong! at least one field must be of variable width
135 int nVarWidth
= (nWindowWidth
- nTotalWidth
) / nVarCount
;
139 for ( i
= 0; i
< m_nFields
; i
++ ) {
140 if ( m_statusWidths
[i
] == -1 )
141 nCurPos
+= nVarWidth
;
143 nCurPos
+= m_statusWidths
[i
];
144 pWidths
[i
] = nCurPos
;
153 void wxStatusBarPM::SetStatusText(const wxString
& strText
, int nField
)
158 wxString
wxStatusBarPM::GetStatusText(int nField
) const
160 wxASSERT( (nField
> -1) && (nField
< m_nFields
) );
166 void wxStatusBarPM::OnSize(wxSizeEvent
& event
)
168 // adjust fields widths to the new size