]>
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 // ---------------------------------------------------------------------------- 
  20 #include "wx/mac/statusbr.h" 
  22 IMPLEMENT_DYNAMIC_CLASS(wxStatusBarXX
, wxStatusBar
); 
  24 BEGIN_EVENT_TABLE(wxStatusBarXX
, wxStatusBar
) 
  25     EVT_SIZE(wxStatusBarXX::OnSize
) 
  29 // ============================================================================ 
  31 // ============================================================================ 
  33 // ---------------------------------------------------------------------------- 
  34 // wxStatusBarXX class 
  35 // ---------------------------------------------------------------------------- 
  37 wxStatusBarXX::wxStatusBarXX() 
  42 wxStatusBarXX::wxStatusBarXX(wxWindow 
*parent
, wxWindowID id
, long style
) 
  44     Create(parent
, id
, style
); 
  47 bool wxStatusBarXX::Create(wxWindow 
*parent
, wxWindowID id
, long style
) 
  52         m_windowId 
= NewControlId(); 
  56     // TODO: create status bar 
  60 void wxStatusBarXX::SetFieldsCount(int nFields
, const int widths
[]) 
  62   wxASSERT( (nFields 
> 0) && (nFields 
< 255) ); 
  66   CopyFieldsWidth(widths
); 
  70 void wxStatusBarXX::SetStatusWidths(int n
, const int widths
[]) 
  72   wxASSERT( n 
== m_nFields 
); 
  74   CopyFieldsWidth(widths
); 
  78 void wxStatusBarXX::CopyFieldsWidth(const int widths
[]) 
  80   if (widths 
&& !m_statusWidths
) 
  81     m_statusWidths 
= new int[m_nFields
]; 
  83   if ( widths 
!= NULL 
) { 
  84     for ( int i 
= 0; i 
< m_nFields
; i
++ ) 
  85       m_statusWidths
[i
] = widths
[i
]; 
  88     delete [] m_statusWidths
; 
  89     m_statusWidths 
= NULL
; 
  93 void wxStatusBarXX::SetFieldsWidth() 
  95   int *pWidths 
= new int[m_nFields
]; 
  98   GetClientSize(&nWindowWidth
, &y
); 
 100   if ( m_statusWidths 
== NULL 
) { 
 101     // default: all fields have the same width 
 102     int nWidth 
= nWindowWidth 
/ m_nFields
; 
 103     for ( int i 
= 0; i 
< m_nFields
; i
++ ) 
 104       pWidths
[i
] = (i 
+ 1) * nWidth
; 
 107     // -1 doesn't mean the same thing for wxWindows and Win32, recalc 
 111     for ( i 
= 0; i 
< m_nFields
; i
++ ) { 
 112       if ( m_statusWidths
[i
] == -1 ) 
 115         nTotalWidth 
+= m_statusWidths
[i
]; 
 118     if ( nVarCount 
== 0 ) { 
 119       // wrong! at least one field must be of variable width 
 125     int nVarWidth 
= (nWindowWidth 
- nTotalWidth
) / nVarCount
; 
 129     for ( i 
= 0; i 
< m_nFields
; i
++ ) { 
 130       if ( m_statusWidths
[i
] == -1 ) 
 131         nCurPos 
+= nVarWidth
; 
 133         nCurPos 
+= m_statusWidths
[i
]; 
 134       pWidths
[i
] = nCurPos
; 
 143 void wxStatusBarXX::SetStatusText(const wxString
& strText
, int nField
) 
 148 wxString 
wxStatusBarXX::GetStatusText(int nField
) const 
 150     wxASSERT( (nField 
> -1) && (nField 
< m_nFields
) ); 
 156 void wxStatusBarXX::OnSize(wxSizeEvent
& event
) 
 158     // adjust fields widths to the new size