X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2bda0e173844e8e0f8acf4e8ad8b5c26e5c6fe5d..d311155fa2c85587286ea271bd5c9546faf9aa90:/src/msw/radiobut.cpp diff --git a/src/msw/radiobut.cpp b/src/msw/radiobut.cpp index f3a4b655d8..eb067a09a3 100644 --- a/src/msw/radiobut.cpp +++ b/src/msw/radiobut.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -24,6 +24,7 @@ #include #include "wx/setup.h" #include "wx/radiobut.h" +#include "wx/brush.h" #endif #include "wx/msw/private.h" @@ -33,10 +34,22 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) // IMPLEMENT_DYNAMIC_CLASS(wxBitmapRadioButton, wxRadioButton) #endif -bool wxRadioButton::Create(wxWindow *parent, const wxWindowID id, - const wxString& label, +bool wxRadioButton::MSWCommand(WXUINT param, WXWORD id) +{ + if (param == BN_CLICKED) + { + wxCommandEvent event(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId); + event.SetEventObject( this ); + ProcessCommand(event); + return TRUE; + } + else return FALSE; +} + +bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, + const wxString& label, const wxPoint& pos, - const wxSize& size, const long style, + const wxSize& size, long style, const wxValidator& validator, const wxString& name) { @@ -45,13 +58,13 @@ bool wxRadioButton::Create(wxWindow *parent, const wxWindowID id, if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetBackgroundColour(parent->GetBackgroundColour()); + SetForegroundColour(parent->GetForegroundColour()); if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; int x = pos.x; int y = pos.y; @@ -65,29 +78,33 @@ bool wxRadioButton::Create(wxWindow *parent, const wxWindowID id, groupStyle = WS_GROUP; // long msStyle = groupStyle | RADIO_FLAGS; - long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ; + long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ; bool want3D; WXDWORD exStyle = Determine3DEffects(0, &want3D) ; // Even with extended styles, need to combine with WS_BORDER // for them to look right. - if (want3D && ((m_windowStyle & wxSIMPLE_BORDER) || (m_windowStyle & wxRAISED_BORDER) || - (m_windowStyle & wxSUNKEN_BORDER) || (m_windowStyle & wxDOUBLE_BORDER))) +/* + if ( want3D || wxStyleHasBorder(m_windowStyle) ) msStyle |= WS_BORDER; +*/ m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const char *)label, msStyle,0,0,0,0, (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); + + wxCHECK_MSG( m_hWnd, FALSE, "Failed to create radiobutton" ); + #if CTL3D if (want3D) { Ctl3dSubclassCtl((HWND) m_hWnd); - m_useCtl3D = TRUE; + m_useCtl3D = TRUE; } #endif - SetFont(* parent->GetFont()); + SetFont(parent->GetFont()); // Subclass again for purposes of dialog editing mode SubclassWin((WXHWND)m_hWnd); @@ -97,8 +114,8 @@ bool wxRadioButton::Create(wxWindow *parent, const wxWindowID id, // start GRW fix if (label != "") { - float label_width, label_height; - GetTextExtent(label, &label_width, &label_height, NULL, NULL, GetFont()); + int label_width, label_height; + GetTextExtent(label, &label_width, &label_height, NULL, NULL, & this->GetFont()); if (width < 0) width = (int)(label_width + RADIO_SIZE); if (height<0) @@ -128,20 +145,20 @@ void wxRadioButton::SetLabel(const wxString& label) SetWindowText((HWND) GetHWND(), (const char *)label); } -void wxRadioButton::SetValue(const bool value) +void wxRadioButton::SetValue(bool value) { // Following necessary for Win32s, because Win32s translate BM_SETCHECK SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L); } -// Get single selection, for single choice list items +// Get single selection bool wxRadioButton::GetValue(void) const { - return (SendMessage((HWND) GetHWND(), BM_SETCHECK, 0, 0L) != 0); + return (SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L) != 0); } -WXHBRUSH wxRadioButton::OnCtlColor(const WXHDC pDC, const WXHWND pWnd, const WXUINT nCtlColor, - WXUINT message, WXWPARAM wParam, WXLPARAM lParam) +WXHBRUSH wxRadioButton::OnCtlColor(WXHDC pDC, WXHWND pWnd, WXUINT nCtlColor, + WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { #if CTL3D if ( m_useCtl3D ) @@ -176,10 +193,10 @@ void wxRadioButton::Command (wxCommandEvent & event) // Not implemented #if 0 -bool wxBitmapRadioButton::Create(wxWindow *parent, const wxWindowID id, - const wxBitmap *bitmap, +bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id, + const wxBitmap *bitmap, const wxPoint& pos, - const wxSize& size, const long style, + const wxSize& size, long style, const wxValidator& validator, const wxString& name) { @@ -187,13 +204,13 @@ bool wxBitmapRadioButton::Create(wxWindow *parent, const wxWindowID id, SetValidator(validator); if (parent) parent->AddChild(this); - SetBackgroundColour(parent->GetDefaultBackgroundColour()); - SetForegroundColour(parent->GetDefaultForegroundColour()); + SetBackgroundColour(parent->GetBackgroundColour()); + SetForegroundColour(parent->GetForegroundColour()); if ( id == -1 ) - m_windowId = (int)NewControlId(); + m_windowId = (int)NewControlId(); else - m_windowId = id; + m_windowId = id; int x = pos.x; int y = pos.y; @@ -211,11 +228,14 @@ bool wxBitmapRadioButton::Create(wxWindow *parent, const wxWindowID id, m_hWnd = (WXHWND) CreateWindowEx(MakeExtendedStyle(m_windowStyle), RADIO_CLASS, "toggle", msStyle,0,0,0,0, (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); + + wxCHECK_MSG( m_hWnd, "Failed to create radio button", FALSE ); + #if CTL3D if (!(GetParent()->GetWindowStyleFlag() & wxUSER_COLOURS)) { Ctl3dSubclassCtl((HWND) GetHWND()); - m_useCtl3D = TRUE; + m_useCtl3D = TRUE; } #endif @@ -231,7 +251,7 @@ void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap) { } -void wxBitmapRadioButton::SetValue(const bool value) +void wxBitmapRadioButton::SetValue(bool value) { // Following necessary for Win32s, because Win32s translate BM_SETCHECK SendMessage((HWND) GetHWND(), BM_SETCHECK, (WPARAM)value, 0L);