X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0e320a79f187558effb04d92020b470372bbe456..6b55490abdb56cd66acf9d965981c4bb4b5f2abb:/src/os2/radiobut.cpp diff --git a/src/os2/radiobut.cpp b/src/os2/radiobut.cpp index 65baab38b6..d0b290c997 100644 --- a/src/os2/radiobut.cpp +++ b/src/os2/radiobut.cpp @@ -1,45 +1,127 @@ ///////////////////////////////////////////////////////////////////////////// // Name: radiobut.cpp // Purpose: wxRadioButton -// Author: AUTHOR +// Author: David Webster // Modified by: -// Created: ??/??/98 +// Created: 10/12/99 // RCS-ID: $Id$ -// Copyright: (c) AUTHOR -// Licence: wxWindows licence +// Copyright: (c) David Webster +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "radiobut.h" +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + +#ifdef __BORLANDC__ +#pragma hdrstop #endif +#ifndef WX_PRECOMP +#include +#include "wx/setup.h" #include "wx/radiobut.h" +#include "wx/brush.h" +#endif + +#include "wx/os2/private.h" -#if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) -#endif + +bool wxRadioButton::OS2Command(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 wxString& label, const wxPoint& pos, const wxSize& size, long style, +#if wxUSE_VALIDATORS const wxValidator& validator, +#endif const wxString& name) { SetName(name); +#if wxUSE_VALIDATORS SetValidator(validator); +#endif if (parent) parent->AddChild(this); + 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; + int width = size.x; + int height = size.y; m_windowStyle = style ; - // TODO create radiobutton - return FALSE; +// TODO create radiobutton +/* + long groupStyle = 0; + if (m_windowStyle & wxRB_GROUP) + groupStyle = WS_GROUP; + +// long msStyle = groupStyle | RADIO_FLAGS; + long msStyle = groupStyle | BS_AUTORADIOBUTTON | WS_CHILD | WS_VISIBLE ; + + bool want3D; + WXDWORD exStyle = Determine3DEffects(0, &want3D) ; + + m_hWnd = (WXHWND) CreateWindowEx(exStyle, RADIO_CLASS, (const wxChar *)label, + msStyle,0,0,0,0, + (HWND) parent->GetHWND(), (HMENU)m_windowId, wxGetInstance(), NULL); + + wxCHECK_MSG( m_hWnd, FALSE, wxT("Failed to create radiobutton") ); + + + SetFont(parent->GetFont()); + + // Subclass again for purposes of dialog editing mode + SubclassWin((WXHWND)m_hWnd); + +// SetValue(value); +*/ + + // start GRW fix + if (label != wxT("")) + { + 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) + { + height = (int)(label_height); + if (height < RADIO_SIZE) + height = RADIO_SIZE; + } + } + else + { + if (width < 0) + width = RADIO_SIZE; + if (height < 0) + height = RADIO_SIZE; + } + // end GRW fix + + SetSize(x, y, width, height); + return FALSE; } void wxRadioButton::SetLabel(const wxString& label) @@ -65,4 +147,77 @@ void wxRadioButton::Command (wxCommandEvent & event) ProcessCommand (event); } +// Not implemented +#if 0 + +bool wxBitmapRadioButton::Create(wxWindow *parent, wxWindowID id, + const wxBitmap *bitmap, + const wxPoint& pos, + const wxSize& size, long style, +#if wxUSE_VALIDATORS + const wxValidator& validator, +#endif + const wxString& name) +{ + SetName(name); +#if wxUSE_VALIDATORS + SetValidator(validator); +#endif + + if (parent) parent->AddChild(this); + SetBackgroundColour(parent->GetBackgroundColour()); + SetForegroundColour(parent->GetForegroundColour()); + + if ( id == -1 ) + m_windowId = (int)NewControlId(); + else + m_windowId = id; + + int x = pos.x; + int y = pos.y; + int width = size.x; + int height = size.y; + m_windowStyle = style ; + + long groupStyle = 0; + if (m_windowStyle & wxRB_GROUP) + groupStyle = WS_GROUP; + +// TODO: +/* +// long msStyle = groupStyle | RADIO_FLAGS; +// long msStyle = groupStyle | BS_RADIOBUTTON | WS_CHILD | WS_VISIBLE ; + + 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 ); + +*/ + // Subclass again for purposes of dialog editing mode + SubclassWin(GetHWND()); + + SetSize(x, y, width, height); + + return TRUE; +} + +void wxBitmapRadioButton::SetLabel(const wxBitmap *bitmap) +{ +} + +void wxBitmapRadioButton::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 +bool wxBitmapRadioButton::GetValue(void) const +{ +// return (bool)SendMessage((HWND) GetHWND(), BM_GETCHECK, 0, 0L); + return FALSE; +} +#endif \ No newline at end of file