X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..2a31049201e9c1ff9f515eb9d144ae392f4b4e5a:/src/msw/statbr95.cpp diff --git a/src/msw/statbr95.cpp b/src/msw/statbr95.cpp index 581d1db266..8a0063d0b1 100644 --- a/src/msw/statbr95.cpp +++ b/src/msw/statbr95.cpp @@ -9,13 +9,9 @@ // Licence: wxWindows license /////////////////////////////////////////////////////////////////////////////// -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- +#ifdef __GNUG__ +#pragma implementation "statbr95.h" +#endif // for compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" @@ -31,28 +27,26 @@ #include "wx/dcclient.h" #endif -#include "wx/log.h" +#ifdef __WIN95__ +#include "wx/log.h" #include "wx/generic/statusbr.h" #include "wx/msw/statbr95.h" -#include -#include +#include "wx/msw/private.h" +#include -#ifndef __GNUWIN32__ -#include +#if !defined(__GNUWIN32__) || defined(__TWIN32__) || defined(wxUSE_NORLANDER_HEADERS) +#include #endif -#if USE_NATIVE_STATUSBAR +#if wxUSE_NATIVE_STATUSBAR -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxStatusBar95, wxStatusBar); BEGIN_EVENT_TABLE(wxStatusBar95, wxStatusBar) - EVT_PAINT(wxWindow::OnPaint) EVT_SIZE(wxStatusBar95::OnSize) END_EVENT_TABLE() -#endif //USE_SHARED_LIBRARY // ---------------------------------------------------------------------------- @@ -61,9 +55,9 @@ // windowsx.h and commctrl.h don't define those, so we do it here #define StatusBar_SetParts(h, n, w) SendMessage(h, SB_SETPARTS, (WPARAM)n, (LPARAM)w) -#define StatusBar_SetText(h, n, t) SendMessage(h, SB_SETTEXT, (WPARAM)n, (LPARAM)(LPCSTR)t) +#define StatusBar_SetText(h, n, t) SendMessage(h, SB_SETTEXT, (WPARAM)n, (LPARAM)(LPCTSTR)t) #define StatusBar_GetTextLen(h, n) LOWORD(SendMessage(h, SB_GETTEXTLENGTH, (WPARAM)n, 0)) -#define StatusBar_GetText(h, n, s) LOWORD(SendMessage(h, SB_GETTEXT, (WPARAM)n, (LPARAM)(LPSTR)s)) +#define StatusBar_GetText(h, n, s) LOWORD(SendMessage(h, SB_GETTEXT, (WPARAM)n, (LPARAM)(LPTSTR)s)) #define hwnd ((HWND)m_hWnd) @@ -91,18 +85,21 @@ bool wxStatusBar95::Create(wxWindow *parent, wxWindowID id, long style) { SetParent(parent); - m_windowId = id == -1 ? NewControlId() : id; + if (id == -1) + m_windowId = NewControlId(); + else + m_windowId = id; DWORD wstyle = WS_CHILD | WS_VISIBLE; - if ( style & wxSB_SIZEGRIP ) + if ( style & wxST_SIZEGRIP ) wstyle |= SBARS_SIZEGRIP; m_hWnd = (WXHWND)CreateStatusWindow(wstyle, - "", + wxT(""), (HWND)parent->GetHWND(), m_windowId); if ( m_hWnd == 0 ) { - wxLogSysError("can't create status bar window"); + wxLogSysError(wxT("can't create status bar window")); return FALSE; } @@ -112,7 +109,7 @@ bool wxStatusBar95::Create(wxWindow *parent, wxWindowID id, long style) return TRUE; } -void wxStatusBar95::CopyFieldsWidth(const int *widths) +void wxStatusBar95::CopyFieldsWidth(const int widths[]) { if (widths && !m_statusWidths) m_statusWidths = new int[m_nFields]; @@ -127,7 +124,7 @@ void wxStatusBar95::CopyFieldsWidth(const int *widths) } } -void wxStatusBar95::SetFieldsCount(int nFields, const int *widths) +void wxStatusBar95::SetFieldsCount(int nFields, const int widths[]) { wxASSERT( (nFields > 0) && (nFields < 255) ); @@ -137,7 +134,7 @@ void wxStatusBar95::SetFieldsCount(int nFields, const int *widths) SetFieldsWidth(); } -void wxStatusBar95::SetStatusWidths(int n, const int *widths) +void wxStatusBar95::SetStatusWidths(int n, const int widths[]) { // @@ I don't understand what this function is for... wxASSERT( n == m_nFields ); @@ -148,6 +145,9 @@ void wxStatusBar95::SetStatusWidths(int n, const int *widths) void wxStatusBar95::SetFieldsWidth() { + if ( !m_nFields ) + return; + int *pWidths = new int[m_nFields]; int nWindowWidth, y; @@ -157,7 +157,7 @@ void wxStatusBar95::SetFieldsWidth() // default: all fields have the same width int nWidth = nWindowWidth / m_nFields; for ( int i = 0; i < m_nFields; i++ ) - pWidths[i] = (i + 1) * nWindowWidth; + pWidths[i] = (i + 1) * nWidth; } else { // -1 doesn't mean the same thing for wxWindows and Win32, recalc @@ -192,26 +192,30 @@ void wxStatusBar95::SetFieldsWidth() } if ( !StatusBar_SetParts(hwnd, m_nFields, pWidths) ) { - wxLogDebug("StatusBar_SetParts failed."); + wxLogLastError(wxT("StatusBar_SetParts")); } delete [] pWidths; } -void wxStatusBar95::SetStatusText(const wxString& strText, const int nField) +void wxStatusBar95::SetStatusText(const wxString& strText, int nField) { if ( !StatusBar_SetText(hwnd, nField, strText) ) { - wxLogDebug("StatusBar_SetText failed"); + wxLogLastError(wxT("StatusBar_SetText")); } } wxString wxStatusBar95::GetStatusText(int nField) const { - wxASSERT( (nField > 0) && (nField < m_nFields) ); - - wxString str; - StatusBar_GetText(hwnd, nField, - str.GetWriteBuf(StatusBar_GetTextLen(hwnd, nField))); + wxASSERT( (nField > -1) && (nField < m_nFields) ); + + wxString str(wxT("")); + int len = StatusBar_GetTextLen(hwnd, nField); + if (len > 0) + { + StatusBar_GetText(hwnd, nField, str.GetWriteBuf(len)); + str.UngetWriteBuf(); + } return str; } @@ -224,4 +228,9 @@ void wxStatusBar95::OnSize(wxSizeEvent& event) SetFieldsWidth(); } -#endif //USE_NATIVE_STATUSBAR \ No newline at end of file +#endif // wxUSE_NATIVE_STATUSBAR + +#else + #error "wxStatusBar95 is only available under Windows 95 and later." +#endif // __WIN95__ +