- Show resize gripper on resizeable dialogs (Kolya Kosenko)
- Implement support for display enumeration under WinCE (Vince Harron)
- Use different Win32 class names in different wx instances (Thomas Hauk)
+- Support multiline labels for wxCheckBox.
wxX11:
virtual bool GetValue() const;
// override some base class virtuals
+ virtual void SetLabel(const wxString& label);
+
virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual void Command(wxCommandEvent& event);
virtual bool SetForegroundColour(const wxColour& colour);
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: msw/private/button.h
+// Purpose: helper functions used with native BUTTON control
+// Author: Vadim Zeitlin
+// Created: 2008-06-07
+// RCS-ID: $Id$
+// Copyright: (c) 2008 Vadim Zeitlin <vadim@wxwidgets.org>
+// Licence: wxWindows licence
+///////////////////////////////////////////////////////////////////////////////
+
+#ifndef _WX_MSW_PRIVATE_BUTTON_H_
+#define _WX_MSW_PRIVATE_BUTTON_H_
+
+namespace wxMSWButton
+{
+
+// returns BS_MULTILINE if the label contains new lines or 0 otherwise
+inline int GetMultilineStyle(const wxString& label)
+{
+ return label.find(_T('\n')) == wxString::npos ? 0 : BS_MULTILINE;
+}
+
+// update the style of the specified HWND to include or exclude BS_MULTILINE
+// depending on whether the label contains the new lines
+inline void UpdateMultilineStyle(HWND hwnd, const wxString& label)
+{
+ // update BS_MULTILINE style depending on the new label (resetting it
+ // doesn't seem to do anything very useful but it shouldn't hurt and we do
+ // have to set it whenever the label becomes multi line as otherwise it
+ // wouldn't be shown correctly as we don't use BS_MULTILINE when creating
+ // the control unless it already has new lines in its label)
+ long styleOld = ::GetWindowLong(hwnd, GWL_STYLE),
+ styleNew;
+ if ( label.find(_T('\n')) != wxString::npos )
+ styleNew = styleOld | BS_MULTILINE;
+ else
+ styleNew = styleOld & ~BS_MULTILINE;
+
+ if ( styleNew != styleOld )
+ ::SetWindowLong(hwnd, GWL_STYLE, styleNew);
+}
+
+} // namespace wxMSWButton
+
+#endif // _WX_MSW_PRIVATE_BUTTON_H_
+
#endif
#include "wx/stockitem.h"
-#include "wx/tokenzr.h"
#include "wx/msw/private.h"
+#include "wx/msw/private/button.h"
#if wxUSE_UXTHEME
#include "wx/msw/uxtheme.h"
//
// NB: we do it here and not in MSWGetStyle() because we need the label
// value and the label is not set yet when MSWGetStyle() is called
- if ( label.find(_T('\n')) != wxString::npos )
- {
- msStyle |= BS_MULTILINE;
- }
+ msStyle |= wxMSWButton::GetMultilineStyle(label);
return MSWCreateControl(_T("BUTTON"), msStyle, pos, size, label, exstyle);
}
void wxButton::SetLabel(const wxString& label)
{
- // update BS_MULTILINE style depending on the new label (resetting it
- // doesn't seem to do anything very useful but it shouldn't hurt and we do
- // have to set it whenever the label becomes multi line as otherwise it
- // wouldn't be shown correctly)
- long styleOld = ::GetWindowLong(GetHwnd(), GWL_STYLE),
- styleNew;
- if ( label.find(_T('\n')) != wxString::npos )
- styleNew = styleOld | BS_MULTILINE;
- else
- styleNew = styleOld & ~BS_MULTILINE;
-
- if ( styleNew != styleOld )
- ::SetWindowLong(GetHwnd(), GWL_STYLE, styleNew);
+ wxMSWButton::UpdateMultilineStyle(GetHwnd(), label);
wxButtonBase::SetLabel(label);
}
#endif
#include "wx/msw/dc.h" // for wxDCTemp
-#include "wx/msw/uxtheme.h"
#include "wx/renderer.h"
+#include "wx/msw/uxtheme.h"
+#include "wx/msw/private/button.h"
// ----------------------------------------------------------------------------
// constants
msStyle |= BS_LEFTTEXT | BS_RIGHT;
}
+ msStyle |= wxMSWButton::GetMultilineStyle(label);
+
return MSWCreateControl(wxT("BUTTON"), msStyle, pos, size, label, 0);
}
int wCheckbox, hCheckbox;
if ( !str.empty() )
{
- GetTextExtent(GetLabelText(str), &wCheckbox, &hCheckbox);
+ wxClientDC dc(wx_const_cast(wxCheckBox *, this));
+ dc.SetFont(GetFont());
+ dc.GetMultiLineTextExtent(GetLabelText(str), &wCheckbox, &hCheckbox);
wCheckbox += s_checkSize + GetCharWidth();
if ( hCheckbox < s_checkSize )
// wxCheckBox operations
// ----------------------------------------------------------------------------
+void wxCheckBox::SetLabel(const wxString& label)
+{
+ wxMSWButton::UpdateMultilineStyle(GetHwnd(), label);
+
+ wxCheckBoxBase::SetLabel(label);
+}
+
void wxCheckBox::SetValue(bool val)
{
Set3StateValue(val ? wxCHK_CHECKED : wxCHK_UNCHECKED);