X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1395ff56f4a8dd0fa400abc0faecc281c304caf7..9806a0e71eb2190827e93cd463e9682a3b939eee:/src/mac/radiobox.cpp diff --git a/src/mac/radiobox.cpp b/src/mac/radiobox.cpp index d00911c8fd..905618716f 100644 --- a/src/mac/radiobox.cpp +++ b/src/mac/radiobox.cpp @@ -18,7 +18,8 @@ #endif #include "wx/radiobox.h" -#include +#include "wx/radiobut.h" +#include "wx/mac/uma.h" #if !USE_SHARED_LIBRARY IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) @@ -31,6 +32,22 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) // ¥ wxRadioBox() //------------------------------------------------------------------------------------- // Default constructor +BEGIN_EVENT_TABLE(wxRadioBox, wxControl) +EVT_RADIOBUTTON( -1 , wxRadioBox::OnRadioButton ) +END_EVENT_TABLE() + +void wxRadioBox::OnRadioButton( wxCommandEvent &outer ) +{ + if ( outer.IsChecked() ) + { + wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId); + int i = GetSelection() ; + event.SetInt( i ); + event.SetString( GetString( i ) ); + event.SetEventObject( this ); + ProcessCommand(event); + } +} wxRadioBox::wxRadioBox() { @@ -95,17 +112,20 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, Rect bounds ; Str255 title ; - MacPreControlCreate( parent , id , label , pos , size ,style, *((wxValidator*)NULL) , name , &bounds , title ) ; + MacPreControlCreate( parent , id , label , pos , size ,style, val , name , &bounds , title ) ; - m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , true , 0 , 0 , 1, + m_macControl = UMANewControl( parent->GetMacRootWindow() , &bounds , title , false , 0 , 0 , 1, kControlGroupBoxTextTitleProc , (long) this ) ; MacPostControlCreate() ; for (i = 0; i < n; i++) { - wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(),choices[i],wxPoint(5,20*i+10)); - m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); + wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(),choices[i],wxPoint(5,20*i+10), + wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ; + if ( i == 0 ) + m_radioButtonCycle = radBtn ; +// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } SetSelection(0); @@ -123,18 +143,20 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, //------------------------------------------------------------------------------------- // Enables or disables the entire radiobox -void wxRadioBox::Enable(bool enable) +bool wxRadioBox::Enable(bool enable) { int i; wxRadioButton *current; - wxControl::Enable(enable); + if (!wxControl::Enable(enable)) + return (false); current=m_radioButtonCycle; for (i=0;iEnable(enable); current=current->NextInCycle(); } + return (true); } //------------------------------------------------------------------------------------- @@ -155,7 +177,6 @@ void wxRadioBox::Enable(int item, bool enable) i++; current=current->NextInCycle(); } - return current->Enable(enable); } @@ -419,7 +440,7 @@ void wxRadioBox::SetFocus() //------------------------------------------------------------------------------------- // Simulates the effect of the user issuing a command to the item -#define RADIO_SIZE 20 +#define RADIO_SIZE 40 void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { @@ -430,13 +451,15 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) int x_current, y_current; int x_offset,y_offset; + int widthOld, heightOld; + GetSize(&widthOld, &heightOld); x_offset = x; y_offset = y; GetPosition(&x_current, &y_current); - if ((x == -1) || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + if ((x == -1) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) x_offset = x_current; - if ((y == -1) || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) + if ((y == -1)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) y_offset = y_current; // define size @@ -464,7 +487,24 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) totHeight = GetNumVer() * (maxHeight + charHeight/2) + charHeight*3/2; totWidth = GetNumHor() * (maxWidth + charWidth) + charWidth; - wxControl::DoSetSize(x_offset,y_offset,totWidth,totHeight); + // only change our width/height if asked for + if ( width == -1 ) + { + if ( sizeFlags & wxSIZE_AUTO_WIDTH ) + width = totWidth ; + else + width = widthOld; + } + + if ( height == -1 ) + { + if ( sizeFlags & wxSIZE_AUTO_HEIGHT ) + height = totHeight ; + else + height = heightOld; + } + + wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO); // arrange radiobuttons @@ -472,7 +512,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) x_start = charWidth; - y_start = charHeight*3/2; + y_start = 15 ; x_offset = x_start; y_offset = y_start; @@ -489,7 +529,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) else { x_offset = x_start; - y_offset += maxHeight + charHeight/2; + y_offset += maxHeight ; /*+ charHeight/2;*/ } } @@ -497,7 +537,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) current=current->NextInCycle(); if (m_windowStyle & wxRA_SPECIFY_ROWS) - y_offset += maxHeight + charHeight/2; + y_offset += maxHeight ; /*+ charHeight/2;*/ else x_offset += maxWidth + charWidth; }