cleanup - reformat
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36793 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -9,10 +9,6 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// headers & declarations
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#include "wx/app.h"
|
#include "wx/app.h"
|
||||||
@@ -20,23 +16,9 @@
|
|||||||
#include "wx/menuitem.h"
|
#include "wx/menuitem.h"
|
||||||
|
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
// ============================================================================
|
|
||||||
// implementation
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// dynamic classes implementation
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxMenuItem
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//
|
|
||||||
// ctor & dtor
|
|
||||||
// -----------
|
|
||||||
|
|
||||||
wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
||||||
int id,
|
int id,
|
||||||
@@ -50,10 +32,8 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu,
|
|||||||
|
|
||||||
// In other languages there is no difference in naming the Exit/Quit menu item between MacOS and Windows guidelines
|
// In other languages there is no difference in naming the Exit/Quit menu item between MacOS and Windows guidelines
|
||||||
// therefore these item must not be translated
|
// therefore these item must not be translated
|
||||||
if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") )
|
if ( wxStripMenuCodes(m_text).Upper() == wxT("EXIT") )
|
||||||
{
|
m_text = wxT("Quit\tCtrl+Q") ;
|
||||||
m_text =wxT("Quit\tCtrl+Q") ;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_radioGroup.start = -1;
|
m_radioGroup.start = -1;
|
||||||
m_isRadioGroupStart = false;
|
m_isRadioGroupStart = false;
|
||||||
@@ -79,7 +59,7 @@ void wxMenuItem::UpdateItemBitmap()
|
|||||||
|
|
||||||
MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
|
MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
|
||||||
MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
||||||
if( mhandle == NULL || index == 0)
|
if ( mhandle == NULL || index == 0)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( m_bitmap.Ok() )
|
if ( m_bitmap.Ok() )
|
||||||
@@ -102,7 +82,7 @@ void wxMenuItem::UpdateItemStatus()
|
|||||||
{
|
{
|
||||||
if ( !m_parentMenu )
|
if ( !m_parentMenu )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
if ( IsSeparator() )
|
if ( IsSeparator() )
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
@@ -150,7 +130,7 @@ void wxMenuItem::UpdateItemText()
|
|||||||
|
|
||||||
MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
|
MenuHandle mhandle = MAC_WXHMENU(m_parentMenu->GetHMenu()) ;
|
||||||
MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
MenuItemIndex index = m_parentMenu->MacGetIndexFromItem( this ) ;
|
||||||
if( mhandle == NULL || index == 0)
|
if (mhandle == NULL || index == 0)
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
UMASetMenuItemText( mhandle , index , wxStripMenuCodes(m_text) , wxFont::GetDefaultEncoding() ) ;
|
UMASetMenuItemText( mhandle , index , wxStripMenuCodes(m_text) , wxFont::GetDefaultEncoding() ) ;
|
||||||
@@ -264,7 +244,7 @@ void wxMenuItem::SetAsRadioGroupStart()
|
|||||||
void wxMenuItem::SetRadioGroupStart(int start)
|
void wxMenuItem::SetRadioGroupStart(int start)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( !m_isRadioGroupStart,
|
wxASSERT_MSG( !m_isRadioGroupStart,
|
||||||
_T("should only be called for the next radio items") );
|
wxT("should only be called for the next radio items") );
|
||||||
|
|
||||||
m_radioGroup.start = start;
|
m_radioGroup.start = start;
|
||||||
}
|
}
|
||||||
@@ -272,7 +252,7 @@ void wxMenuItem::SetRadioGroupStart(int start)
|
|||||||
void wxMenuItem::SetRadioGroupEnd(int end)
|
void wxMenuItem::SetRadioGroupEnd(int end)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( m_isRadioGroupStart,
|
wxASSERT_MSG( m_isRadioGroupStart,
|
||||||
_T("should only be called for the first radio item") );
|
wxT("should only be called for the first radio item") );
|
||||||
|
|
||||||
m_radioGroup.end = end;
|
m_radioGroup.end = end;
|
||||||
}
|
}
|
||||||
|
@@ -18,31 +18,28 @@
|
|||||||
#if wxUSE_RADIOBOX
|
#if wxUSE_RADIOBOX
|
||||||
|
|
||||||
#include "wx/arrstr.h"
|
#include "wx/arrstr.h"
|
||||||
|
|
||||||
#include "wx/radiobox.h"
|
#include "wx/radiobox.h"
|
||||||
#include "wx/radiobut.h"
|
#include "wx/radiobut.h"
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl)
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> wxRadioBox()
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Default constructor
|
|
||||||
BEGIN_EVENT_TABLE(wxRadioBox, wxControl)
|
BEGIN_EVENT_TABLE(wxRadioBox, wxControl)
|
||||||
EVT_RADIOBUTTON( wxID_ANY , wxRadioBox::OnRadioButton )
|
EVT_RADIOBUTTON( wxID_ANY , wxRadioBox::OnRadioButton )
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
void wxRadioBox::OnRadioButton( wxCommandEvent &outer )
|
void wxRadioBox::OnRadioButton( wxCommandEvent &outer )
|
||||||
{
|
{
|
||||||
if ( outer.IsChecked() )
|
if ( outer.IsChecked() )
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId);
|
wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId );
|
||||||
int i = GetSelection() ;
|
int i = GetSelection() ;
|
||||||
event.SetInt( i );
|
event.SetInt( i );
|
||||||
event.SetString( GetString( i ) );
|
event.SetString( GetString( i ) );
|
||||||
event.SetEventObject( this );
|
event.SetEventObject( this );
|
||||||
ProcessCommand(event);
|
ProcessCommand( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,63 +50,53 @@ wxRadioBox::wxRadioBox()
|
|||||||
m_radioButtonCycle = NULL;
|
m_radioButtonCycle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> wxRadioBox(wxWindow*, wxWindowID, const wxString&, const wxPoint&,
|
|
||||||
// const wxSize&, int, const wxString[], int, long,
|
|
||||||
// const wxValidator&, const wxString&)
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Contructor, creating and showing a radiobox
|
|
||||||
//
|
|
||||||
// inline defined
|
|
||||||
//
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> ~wxRadioBox
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Destructor, destroying the radiobox item
|
|
||||||
|
|
||||||
wxRadioBox::~wxRadioBox()
|
wxRadioBox::~wxRadioBox()
|
||||||
{
|
{
|
||||||
m_isBeingDeleted = true;
|
m_isBeingDeleted = true;
|
||||||
|
|
||||||
wxRadioButton *next,*current;
|
wxRadioButton *next, *current;
|
||||||
|
|
||||||
|
current = m_radioButtonCycle->NextInCycle();
|
||||||
|
if (current != NULL)
|
||||||
|
{
|
||||||
|
while (current != m_radioButtonCycle)
|
||||||
|
{
|
||||||
|
next = current->NextInCycle();
|
||||||
|
delete current;
|
||||||
|
|
||||||
|
current = next;
|
||||||
|
}
|
||||||
|
|
||||||
current=m_radioButtonCycle->NextInCycle();
|
|
||||||
next=current->NextInCycle();
|
|
||||||
while (current!=m_radioButtonCycle) {
|
|
||||||
delete current;
|
delete current;
|
||||||
current=next;
|
|
||||||
next=current->NextInCycle();
|
|
||||||
}
|
}
|
||||||
delete current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> Create
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Create the radiobox for two-step construction
|
// Create the radiobox for two-step construction
|
||||||
|
|
||||||
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
bool wxRadioBox::Create( wxWindow *parent,
|
||||||
const wxPoint& pos, const wxSize& size,
|
wxWindowID id, const wxString& label,
|
||||||
const wxArrayString& choices,
|
const wxPoint& pos, const wxSize& size,
|
||||||
int majorDim, long style,
|
const wxArrayString& choices,
|
||||||
const wxValidator& val, const wxString& name)
|
int majorDim, long style,
|
||||||
|
const wxValidator& val, const wxString& name )
|
||||||
{
|
{
|
||||||
wxCArrayString chs(choices);
|
wxCArrayString chs(choices);
|
||||||
|
|
||||||
return Create(parent, id, label, pos, size, chs.GetCount(),
|
return Create(
|
||||||
chs.GetStrings(), majorDim, style, val, name);
|
parent, id, label, pos, size, chs.GetCount(),
|
||||||
|
chs.GetStrings(), majorDim, style, val, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
bool wxRadioBox::Create( wxWindow *parent,
|
||||||
const wxPoint& pos, const wxSize& size,
|
wxWindowID id, const wxString& label,
|
||||||
int n, const wxString choices[],
|
const wxPoint& pos, const wxSize& size,
|
||||||
int majorDim, long style,
|
int n, const wxString choices[],
|
||||||
const wxValidator& val, const wxString& name)
|
int majorDim, long style,
|
||||||
|
const wxValidator& val, const wxString& name )
|
||||||
{
|
{
|
||||||
m_macIsUserPane = false ;
|
m_macIsUserPane = false ;
|
||||||
|
|
||||||
if ( !wxControl::Create(parent, id, pos, size, style, val, name) )
|
if ( !wxControl::Create( parent, id, pos, size, style, val, name ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
@@ -118,279 +105,250 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
|||||||
m_noRowsOrCols = majorDim;
|
m_noRowsOrCols = majorDim;
|
||||||
m_radioButtonCycle = NULL;
|
m_radioButtonCycle = NULL;
|
||||||
|
|
||||||
SetMajorDim(majorDim == 0 ? n : majorDim, style);
|
SetMajorDim( majorDim == 0 ? n : majorDim, style );
|
||||||
|
|
||||||
m_label = label ;
|
m_label = label ;
|
||||||
|
|
||||||
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
|
Rect bounds = wxMacGetBoundsForControl( this, pos, size );
|
||||||
if( bounds.right <= bounds.left )
|
if ( bounds.right <= bounds.left )
|
||||||
bounds.right = bounds.left + 100 ;
|
bounds.right = bounds.left + 100;
|
||||||
if ( bounds.bottom <= bounds.top )
|
if ( bounds.bottom <= bounds.top )
|
||||||
bounds.bottom = bounds.top + 100 ;
|
bounds.bottom = bounds.top + 100;
|
||||||
|
|
||||||
m_peer = new wxMacControl(this) ;
|
m_peer = new wxMacControl( this );
|
||||||
|
|
||||||
verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") ,
|
OSStatus err = CreateGroupBoxControl(
|
||||||
true /*primary*/ , m_peer->GetControlRefAddr() ) ) ;
|
MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
|
||||||
|
&bounds, CFSTR("") , true /*primary*/,
|
||||||
|
m_peer->GetControlRefAddr() );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
for (i = 0; i < n; i++)
|
for (i = 0; i < n; i++)
|
||||||
{
|
{
|
||||||
wxRadioButton *radBtn = new wxRadioButton
|
wxRadioButton *radBtn = new wxRadioButton(
|
||||||
(
|
this,
|
||||||
this,
|
wxID_ANY,
|
||||||
wxID_ANY,
|
wxStripMenuCodes(choices[i]),
|
||||||
wxStripMenuCodes(choices[i]),
|
wxPoint( 5, 20 * i + 10 ),
|
||||||
wxPoint(5,20*i+10),
|
wxDefaultSize,
|
||||||
wxDefaultSize,
|
i == 0 ? wxRB_GROUP : 0 );
|
||||||
i == 0 ? wxRB_GROUP : 0
|
|
||||||
);
|
|
||||||
if ( i == 0 )
|
if ( i == 0 )
|
||||||
m_radioButtonCycle = radBtn ;
|
m_radioButtonCycle = radBtn;
|
||||||
// m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle);
|
// m_radioButtonCycle = radBtn->AddInCycle( m_radioButtonCycle );
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSelection(0);
|
SetSelection( 0 );
|
||||||
MacPostControlCreate(pos,size) ;
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> Enable(bool)
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Enables or disables the entire radiobox
|
// Enables or disables the entire radiobox
|
||||||
|
//
|
||||||
bool wxRadioBox::Enable(bool enable)
|
bool wxRadioBox::Enable(bool enable)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
if (!wxControl::Enable(enable))
|
if (!wxControl::Enable( enable ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
current = m_radioButtonCycle;
|
current = m_radioButtonCycle;
|
||||||
for (i = 0; i < m_noItems; i++) {
|
for (i = 0; i < m_noItems; i++)
|
||||||
current->Enable(enable);
|
{
|
||||||
|
current->Enable( enable );
|
||||||
current = current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> Enable(int, bool)
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Enables or disables an given button
|
// Enables or disables an given button
|
||||||
|
//
|
||||||
bool wxRadioBox::Enable(int item, bool enable)
|
bool wxRadioBox::Enable(int item, bool enable)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
if (!IsValid(item))
|
if (!IsValid( item ))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
current = m_radioButtonCycle;
|
current = m_radioButtonCycle;
|
||||||
while (i != item) {
|
while (i != item)
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
current = current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
}
|
}
|
||||||
return current->Enable(enable);
|
|
||||||
|
return current->Enable( enable );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> GetLabel()
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Returns the radiobox label
|
// Returns the radiobox label
|
||||||
|
//
|
||||||
wxString wxRadioBox::GetLabel() const
|
wxString wxRadioBox::GetLabel() const
|
||||||
{
|
{
|
||||||
return wxControl::GetLabel();
|
return wxControl::GetLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> GetLabel(int)
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Returns the label for the given button
|
// Returns the label for the given button
|
||||||
|
//
|
||||||
wxString wxRadioBox::GetString(int item) const
|
wxString wxRadioBox::GetString(int item) const
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
if (!IsValid(item))
|
if (!IsValid( item ))
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
current = m_radioButtonCycle;
|
current = m_radioButtonCycle;
|
||||||
while (i != item) {
|
while (i != item)
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
current = current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
return current->GetLabel();
|
return current->GetLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> GetSelection
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Returns the zero-based position of the selected button
|
// Returns the zero-based position of the selected button
|
||||||
|
//
|
||||||
int wxRadioBox::GetSelection() const
|
int wxRadioBox::GetSelection() const
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
i=0;
|
i = 0;
|
||||||
current=m_radioButtonCycle;
|
current = m_radioButtonCycle;
|
||||||
while (!current->GetValue()) {
|
while (!current->GetValue())
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
current=current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> Number
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Returns the number of buttons in the radiobox
|
|
||||||
//
|
|
||||||
// inline defined
|
|
||||||
//
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> SetLabel(const wxString&)
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Sets the radiobox label
|
// Sets the radiobox label
|
||||||
|
//
|
||||||
void wxRadioBox::SetLabel(const wxString& label)
|
void wxRadioBox::SetLabel(const wxString& label)
|
||||||
{
|
{
|
||||||
return wxControl::SetLabel(label);
|
return wxControl::SetLabel( label );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> SetLabel(int, const wxString&)
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Sets the label of a given button
|
// Sets the label of a given button
|
||||||
|
//
|
||||||
void wxRadioBox::SetString(int item,const wxString& label)
|
void wxRadioBox::SetString(int item,const wxString& label)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
if (!IsValid(item))
|
if (!IsValid( item ))
|
||||||
return;
|
return;
|
||||||
i=0;
|
|
||||||
current=m_radioButtonCycle;
|
i = 0;
|
||||||
while (i!=item) {
|
current = m_radioButtonCycle;
|
||||||
|
while (i != item)
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
current=current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
}
|
}
|
||||||
return current->SetLabel(label);
|
|
||||||
|
return current->SetLabel( label );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> SetSelection
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Sets a button by passing the desired position. This does not cause
|
// Sets a button by passing the desired position. This does not cause
|
||||||
// wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted
|
// wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted
|
||||||
|
//
|
||||||
void wxRadioBox::SetSelection(int item)
|
void wxRadioBox::SetSelection(int item)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
if (!IsValid(item))
|
if (!IsValid( item ))
|
||||||
return;
|
return;
|
||||||
i=0;
|
|
||||||
current=m_radioButtonCycle;
|
|
||||||
while (i!=item) {
|
|
||||||
i++;
|
|
||||||
current=current->NextInCycle();
|
|
||||||
}
|
|
||||||
current->SetValue(true);
|
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
current = m_radioButtonCycle;
|
||||||
|
while (i != item)
|
||||||
|
{
|
||||||
|
i++;
|
||||||
|
current = current->NextInCycle();
|
||||||
|
}
|
||||||
|
|
||||||
|
current->SetValue( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> Show(bool)
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Shows or hides the entire radiobox
|
// Shows or hides the entire radiobox
|
||||||
|
//
|
||||||
bool wxRadioBox::Show(bool show)
|
bool wxRadioBox::Show(bool show)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
wxControl::Show(show);
|
current = m_radioButtonCycle;
|
||||||
|
for (i=0; i<m_noItems; i++)
|
||||||
current=m_radioButtonCycle;
|
|
||||||
for (i=0;i<m_noItems;i++)
|
|
||||||
{
|
{
|
||||||
current->Show(show);
|
current->Show( show );
|
||||||
current=current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxControl::Show( show );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> Show(int, bool)
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Shows or hides the given button
|
// Shows or hides the given button
|
||||||
|
//
|
||||||
bool wxRadioBox::Show(int item, bool show)
|
bool wxRadioBox::Show(int item, bool show)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
if (!IsValid(item))
|
if (!IsValid( item ))
|
||||||
return false;
|
return false;
|
||||||
i=0;
|
|
||||||
current=m_radioButtonCycle;
|
i = 0;
|
||||||
while (i!=item) {
|
current = m_radioButtonCycle;
|
||||||
|
while (i != item)
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
current=current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
}
|
}
|
||||||
return current->Show(show);
|
|
||||||
|
return current->Show( show );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> Command
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Simulates the effect of the user issuing a command to the item
|
// Simulates the effect of the user issuing a command to the item
|
||||||
|
//
|
||||||
void wxRadioBox::Command (wxCommandEvent & event)
|
void wxRadioBox::Command( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
SetSelection (event.GetInt());
|
SetSelection( event.GetInt() );
|
||||||
ProcessCommand (event);
|
ProcessCommand( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> SetFocus
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Sets the selected button to receive keyboard input
|
// Sets the selected button to receive keyboard input
|
||||||
|
//
|
||||||
void wxRadioBox::SetFocus()
|
void wxRadioBox::SetFocus()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wxRadioButton *current;
|
wxRadioButton *current;
|
||||||
|
|
||||||
i=0;
|
i = 0;
|
||||||
current=m_radioButtonCycle;
|
current = m_radioButtonCycle;
|
||||||
while (!current->GetValue()) {
|
while (!current->GetValue())
|
||||||
|
{
|
||||||
i++;
|
i++;
|
||||||
current=current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
current->SetFocus();
|
current->SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// <20> DoSetSize
|
|
||||||
//-------------------------------------------------------------------------------------
|
|
||||||
// Simulates the effect of the user issuing a command to the item
|
// Simulates the effect of the user issuing a command to the item
|
||||||
|
//
|
||||||
#define RADIO_SIZE 20
|
#define RADIO_SIZE 20
|
||||||
|
|
||||||
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
@@ -401,50 +359,58 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
// define the position
|
// define the position
|
||||||
|
|
||||||
int x_current, y_current;
|
int x_current, y_current;
|
||||||
int x_offset,y_offset;
|
int x_offset, y_offset;
|
||||||
int widthOld, heightOld;
|
int widthOld, heightOld;
|
||||||
GetSize(&widthOld, &heightOld);
|
|
||||||
|
GetSize( &widthOld, &heightOld );
|
||||||
|
GetPosition( &x_current, &y_current );
|
||||||
|
|
||||||
x_offset = x;
|
x_offset = x;
|
||||||
y_offset = y;
|
y_offset = y;
|
||||||
GetPosition(&x_current, &y_current);
|
if (!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||||
if ((x == wxDefaultCoord) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
|
||||||
x_offset = x_current;
|
|
||||||
if ((y == wxDefaultCoord)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
|
||||||
y_offset = y_current;
|
|
||||||
|
|
||||||
// define size
|
|
||||||
|
|
||||||
int charWidth,charHeight;
|
|
||||||
int maxWidth,maxHeight;
|
|
||||||
int eachWidth[128],eachHeight[128];
|
|
||||||
int totWidth,totHeight;
|
|
||||||
|
|
||||||
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight);
|
|
||||||
|
|
||||||
charWidth/=52;
|
|
||||||
|
|
||||||
maxWidth=-1;
|
|
||||||
maxHeight=-1;
|
|
||||||
for (i = 0 ; i < m_noItems; i++)
|
|
||||||
{
|
{
|
||||||
GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i]);
|
if (x == wxDefaultCoord)
|
||||||
eachWidth[i] = (int)(eachWidth[i] + RADIO_SIZE);
|
x_offset = x_current;
|
||||||
eachHeight[i] = (int)((3*eachHeight[i])/2);
|
if (y == wxDefaultCoord)
|
||||||
if (maxWidth<eachWidth[i]) maxWidth = eachWidth[i];
|
y_offset = y_current;
|
||||||
if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
totHeight = GetRowCount() * ( maxHeight ) ;
|
// define size
|
||||||
totWidth = GetColumnCount() * (maxWidth + charWidth) ;
|
int charWidth, charHeight;
|
||||||
|
int maxWidth, maxHeight;
|
||||||
|
int eachWidth[128], eachHeight[128];
|
||||||
|
int totWidth, totHeight;
|
||||||
|
|
||||||
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ;
|
GetTextExtent(
|
||||||
|
wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
|
||||||
|
&charWidth, &charHeight );
|
||||||
|
|
||||||
// only change our width/height if asked for
|
charWidth /= 52;
|
||||||
|
|
||||||
|
maxWidth = -1;
|
||||||
|
maxHeight = -1;
|
||||||
|
for (i = 0 ; i < m_noItems; i++)
|
||||||
|
{
|
||||||
|
GetTextExtent( GetString( i ), &eachWidth[i], &eachHeight[i] );
|
||||||
|
eachWidth[i] = (int)(eachWidth[i] + RADIO_SIZE);
|
||||||
|
eachHeight[i] = (int)((3 * eachHeight[i]) / 2);
|
||||||
|
|
||||||
|
if (maxWidth < eachWidth[i])
|
||||||
|
maxWidth = eachWidth[i];
|
||||||
|
if (maxHeight < eachHeight[i])
|
||||||
|
maxHeight = eachHeight[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
totHeight = GetRowCount() * maxHeight;
|
||||||
|
totWidth = GetColumnCount() * (maxWidth + charWidth);
|
||||||
|
|
||||||
|
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ;
|
||||||
|
|
||||||
|
// change the width / height only when specified
|
||||||
if ( width == wxDefaultCoord )
|
if ( width == wxDefaultCoord )
|
||||||
{
|
{
|
||||||
if ( sizeFlags & wxSIZE_AUTO_WIDTH )
|
if ( sizeFlags & wxSIZE_AUTO_WIDTH )
|
||||||
width = sz.x ;
|
width = sz.x;
|
||||||
else
|
else
|
||||||
width = widthOld;
|
width = widthOld;
|
||||||
}
|
}
|
||||||
@@ -452,28 +418,27 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
if ( height == wxDefaultCoord )
|
if ( height == wxDefaultCoord )
|
||||||
{
|
{
|
||||||
if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
|
if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
|
||||||
height = sz.y ;
|
height = sz.y;
|
||||||
else
|
else
|
||||||
height = heightOld;
|
height = heightOld;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxControl::DoSetSize(x_offset,y_offset,width,height,wxSIZE_AUTO);
|
wxControl::DoSetSize( x_offset, y_offset, width, height, wxSIZE_AUTO );
|
||||||
|
|
||||||
// arrange radiobuttons
|
|
||||||
|
|
||||||
int x_start,y_start;
|
|
||||||
|
|
||||||
|
// arrange radio buttons
|
||||||
|
int x_start, y_start;
|
||||||
|
|
||||||
x_start = 0;
|
x_start = 0;
|
||||||
y_start = 0 ;
|
y_start = 0;
|
||||||
|
|
||||||
x_offset = x_start;
|
x_offset = x_start;
|
||||||
y_offset = y_start;
|
y_offset = y_start;
|
||||||
|
|
||||||
current=m_radioButtonCycle;
|
current = m_radioButtonCycle;
|
||||||
for ( i = 0 ; i < m_noItems; i++)
|
for ( i = 0 ; i < m_noItems; i++)
|
||||||
{
|
{
|
||||||
if (i&&((i%GetMajorDim())==0)) // not to do for the zero button!
|
// not to do for the zero button!
|
||||||
|
if ((i > 0) && ((i % GetMajorDim()) == 0))
|
||||||
{
|
{
|
||||||
if (m_windowStyle & wxRA_SPECIFY_ROWS)
|
if (m_windowStyle & wxRA_SPECIFY_ROWS)
|
||||||
{
|
{
|
||||||
@@ -483,15 +448,15 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
x_offset = x_start;
|
x_offset = x_start;
|
||||||
y_offset += maxHeight ; /*+ charHeight/2;*/
|
y_offset += maxHeight ; //+ charHeight / 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
current->SetSize(x_offset,y_offset,eachWidth[i],eachHeight[i]);
|
current->SetSize( x_offset, y_offset, eachWidth[i], eachHeight[i]);
|
||||||
current=current->NextInCycle();
|
current = current->NextInCycle();
|
||||||
|
|
||||||
if (m_windowStyle & wxRA_SPECIFY_ROWS)
|
if (m_windowStyle & wxRA_SPECIFY_ROWS)
|
||||||
y_offset += maxHeight ; /*+ charHeight/2;*/
|
y_offset += maxHeight ; // + charHeight / 2
|
||||||
else
|
else
|
||||||
x_offset += maxWidth + charWidth;
|
x_offset += maxWidth + charWidth;
|
||||||
}
|
}
|
||||||
@@ -504,9 +469,10 @@ wxSize wxRadioBox::DoGetBestSize() const
|
|||||||
int eachWidth, eachHeight;
|
int eachWidth, eachHeight;
|
||||||
int totWidth, totHeight;
|
int totWidth, totHeight;
|
||||||
|
|
||||||
wxFont font = /*GetParent()->*/GetFont();
|
wxFont font = GetFont(); // GetParent()->GetFont()
|
||||||
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
|
GetTextExtent(
|
||||||
&charWidth, &charHeight, NULL, NULL, &font);
|
wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
|
||||||
|
&charWidth, &charHeight, NULL, NULL, &font );
|
||||||
|
|
||||||
charWidth /= 52;
|
charWidth /= 52;
|
||||||
|
|
||||||
@@ -515,27 +481,29 @@ wxSize wxRadioBox::DoGetBestSize() const
|
|||||||
|
|
||||||
for (int i = 0 ; i < m_noItems; i++)
|
for (int i = 0 ; i < m_noItems; i++)
|
||||||
{
|
{
|
||||||
GetTextExtent(GetString(i), &eachWidth, &eachHeight,NULL, NULL, &font);
|
GetTextExtent( GetString( i ), &eachWidth, &eachHeight, NULL, NULL, &font );
|
||||||
eachWidth = (int)(eachWidth + RADIO_SIZE) ;
|
eachWidth = (int)(eachWidth + RADIO_SIZE);
|
||||||
eachHeight = (int)((3 * eachHeight) / 2);
|
eachHeight = (int)((3 * eachHeight) / 2);
|
||||||
if (maxWidth < eachWidth) maxWidth = eachWidth;
|
if (maxWidth < eachWidth)
|
||||||
if (maxHeight < eachHeight) maxHeight = eachHeight;
|
maxWidth = eachWidth;
|
||||||
|
if (maxHeight < eachHeight)
|
||||||
|
maxHeight = eachHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
totHeight = GetRowCount() * (maxHeight ) ;
|
totHeight = GetRowCount() * maxHeight;
|
||||||
totWidth = GetColumnCount() * (maxWidth + charWidth) ;
|
totWidth = GetColumnCount() * (maxWidth + charWidth);
|
||||||
|
|
||||||
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ;
|
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) );
|
||||||
totWidth = sz.x ;
|
totWidth = sz.x;
|
||||||
totHeight = sz.y ;
|
totHeight = sz.y;
|
||||||
|
|
||||||
// handle radio box title as well
|
// handle radio box title as well
|
||||||
GetTextExtent(GetLabel(), &eachWidth, NULL);
|
GetTextExtent( GetLabel(), &eachWidth, NULL );
|
||||||
eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ;
|
eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth;
|
||||||
if (totWidth < eachWidth)
|
if (totWidth < eachWidth)
|
||||||
totWidth = eachWidth;
|
totWidth = eachWidth;
|
||||||
|
|
||||||
return wxSize(totWidth, totHeight);
|
return wxSize( totWidth, totHeight );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
// Name: radiobut.cpp
|
// Name: radiobut.cpp
|
||||||
// Purpose: wxRadioButton
|
// Purpose: wxRadioButton
|
||||||
// Author: AUTHOR
|
// Author: AUTHOR
|
||||||
// Modified by: JS Lair (99/11/15) adding the cyclic groupe notion for radiobox
|
// Modified by: JS Lair (99/11/15) adding the cyclic group notion for radiobox
|
||||||
// Created: ??/??/98
|
// Created: ??/??/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) AUTHOR
|
// Copyright: (c) AUTHOR
|
||||||
@@ -14,57 +14,64 @@
|
|||||||
#if wxUSE_RADIOBTN
|
#if wxUSE_RADIOBTN
|
||||||
|
|
||||||
#include "wx/radiobut.h"
|
#include "wx/radiobut.h"
|
||||||
|
#include "wx/mac/uma.h"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
|
||||||
|
|
||||||
#include "wx/mac/uma.h"
|
|
||||||
|
|
||||||
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
|
bool wxRadioButton::Create( wxWindow *parent,
|
||||||
const wxString& label,
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
const wxString& label,
|
||||||
const wxSize& size, long style,
|
const wxPoint& pos,
|
||||||
const wxValidator& validator,
|
const wxSize& size,
|
||||||
const wxString& name)
|
long style,
|
||||||
|
const wxValidator& validator,
|
||||||
|
const wxString& name )
|
||||||
{
|
{
|
||||||
m_macIsUserPane = false ;
|
m_macIsUserPane = false;
|
||||||
|
|
||||||
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
|
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_label = label ;
|
m_label = label;
|
||||||
|
|
||||||
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
|
Rect bounds = wxMacGetBoundsForControl( this, pos, size );
|
||||||
|
|
||||||
m_peer = new wxMacControl(this) ;
|
m_peer = new wxMacControl( this );
|
||||||
verify_noerr ( CreateRadioButtonControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , CFSTR("") ,
|
OSStatus err = CreateRadioButtonControl(
|
||||||
0 , false /* no autotoggle */ , m_peer->GetControlRefAddr() ) );
|
MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, CFSTR(""),
|
||||||
|
0, false /* no autotoggle */, m_peer->GetControlRefAddr() );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
MacPostControlCreate(pos,size) ;
|
m_cycle = this;
|
||||||
|
|
||||||
m_cycle = this ;
|
if (HasFlag( wxRB_GROUP ))
|
||||||
|
|
||||||
if (HasFlag(wxRB_GROUP))
|
|
||||||
{
|
{
|
||||||
AddInCycle( NULL ) ;
|
AddInCycle( NULL );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* search backward for last group start */
|
// search backward for last group start
|
||||||
wxRadioButton *chief = (wxRadioButton*) NULL;
|
wxRadioButton *chief = NULL;
|
||||||
wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast();
|
wxWindowList::compatibility_iterator node = parent->GetChildren().GetLast();
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
wxWindow *child = node->GetData();
|
wxWindow *child = node->GetData();
|
||||||
if (child->IsKindOf( CLASSINFO( wxRadioButton ) ) )
|
if (child->IsKindOf( CLASSINFO( wxRadioButton ) ))
|
||||||
{
|
{
|
||||||
chief = (wxRadioButton*) child;
|
chief = (wxRadioButton*)child;
|
||||||
if (child->HasFlag(wxRB_GROUP)) break;
|
if (child->HasFlag( wxRB_GROUP ))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node->GetPrevious();
|
node = node->GetPrevious();
|
||||||
}
|
}
|
||||||
AddInCycle( chief ) ;
|
|
||||||
|
AddInCycle( chief );
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,19 +83,19 @@ wxRadioButton::~wxRadioButton()
|
|||||||
void wxRadioButton::SetValue(bool val)
|
void wxRadioButton::SetValue(bool val)
|
||||||
{
|
{
|
||||||
wxRadioButton *cycle;
|
wxRadioButton *cycle;
|
||||||
if ( m_peer->GetValue() == val )
|
if (m_peer->GetValue() == val)
|
||||||
return ;
|
return;
|
||||||
|
|
||||||
m_peer->SetValue( val ) ;
|
m_peer->SetValue( val );
|
||||||
if (val)
|
if (val)
|
||||||
{
|
{
|
||||||
cycle=this->NextInCycle();
|
cycle = this->NextInCycle();
|
||||||
if (cycle!=NULL)
|
if (cycle != NULL)
|
||||||
{
|
{
|
||||||
while (cycle!=this)
|
while (cycle != this)
|
||||||
{
|
{
|
||||||
cycle->SetValue(false);
|
cycle->SetValue( false );
|
||||||
cycle=cycle->NextInCycle();
|
cycle = cycle->NextInCycle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,75 +103,76 @@ void wxRadioButton::SetValue(bool val)
|
|||||||
|
|
||||||
bool wxRadioButton::GetValue() const
|
bool wxRadioButton::GetValue() const
|
||||||
{
|
{
|
||||||
return m_peer->GetValue() ;
|
return m_peer->GetValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioButton::Command (wxCommandEvent & event)
|
void wxRadioButton::Command(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
SetValue ( (event.GetInt() != 0) );
|
SetValue( (event.GetInt() != 0) );
|
||||||
ProcessCommand (event);
|
ProcessCommand( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxInt32 wxRadioButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
|
wxInt32 wxRadioButton::MacControlHit( WXEVENTHANDLERREF WXUNUSED(handler), WXEVENTREF WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
// if already set -> no action
|
// if already set -> no action
|
||||||
if ( GetValue() )
|
if (GetValue())
|
||||||
return noErr;
|
return noErr;
|
||||||
|
|
||||||
wxRadioButton *cycle;
|
wxRadioButton *cycle;
|
||||||
cycle=this->NextInCycle();
|
cycle = this->NextInCycle();
|
||||||
if (cycle!=NULL) {
|
if (cycle != NULL)
|
||||||
while (cycle!=this) {
|
{
|
||||||
if ( cycle->GetValue() ) {
|
while (cycle != this)
|
||||||
cycle->SetValue(false);
|
{
|
||||||
}
|
if (cycle->GetValue())
|
||||||
cycle=cycle->NextInCycle();
|
cycle->SetValue( false );
|
||||||
|
|
||||||
|
cycle = cycle->NextInCycle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetValue(true) ;
|
SetValue( true );
|
||||||
|
|
||||||
wxCommandEvent event2(wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
|
wxCommandEvent event2( wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
|
||||||
event2.SetEventObject(this);
|
event2.SetEventObject( this );
|
||||||
event2.SetInt( true );
|
event2.SetInt( true );
|
||||||
ProcessCommand(event2);
|
ProcessCommand( event2 );
|
||||||
return noErr ;
|
|
||||||
|
return noErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
|
wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
|
||||||
{
|
{
|
||||||
wxRadioButton *next,*current;
|
wxRadioButton *next, *current;
|
||||||
|
|
||||||
if (cycle==NULL)
|
if (cycle == NULL)
|
||||||
{
|
{
|
||||||
m_cycle=this;
|
m_cycle = this;
|
||||||
return(this);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
current=cycle;
|
current = cycle;
|
||||||
while ((next=current->m_cycle)!=cycle)
|
while ((next = current->m_cycle) != cycle)
|
||||||
current=current->m_cycle;
|
current = current->m_cycle;
|
||||||
m_cycle=cycle;
|
|
||||||
current->m_cycle=this;
|
m_cycle = cycle;
|
||||||
return(cycle);
|
current->m_cycle = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return m_cycle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioButton::RemoveFromCycle()
|
void wxRadioButton::RemoveFromCycle()
|
||||||
{
|
{
|
||||||
if (m_cycle==NULL || m_cycle == this)
|
if ((m_cycle == NULL) || (m_cycle == this))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
else
|
// Find the previous one and make it point to the next one
|
||||||
{
|
wxRadioButton* prev = this;
|
||||||
// Find the previous one and make it point to the next one
|
while (prev->m_cycle != this)
|
||||||
wxRadioButton* prev = this;
|
prev = prev->m_cycle;
|
||||||
while (prev->m_cycle != this)
|
|
||||||
prev = prev->m_cycle;
|
prev->m_cycle = m_cycle;
|
||||||
prev->m_cycle = m_cycle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -16,29 +16,23 @@
|
|||||||
#include "wx/spinbutt.h"
|
#include "wx/spinbutt.h"
|
||||||
#include "wx/mac/uma.h"
|
#include "wx/mac/uma.h"
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// implementation
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxWin macros
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
|
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
|
||||||
|
|
||||||
|
|
||||||
wxSpinButton::wxSpinButton()
|
wxSpinButton::wxSpinButton()
|
||||||
: wxSpinButtonBase()
|
: wxSpinButtonBase()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
|
bool wxSpinButton::Create( wxWindow *parent,
|
||||||
long style, const wxString& name)
|
wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||||
|
long style, const wxString& name )
|
||||||
{
|
{
|
||||||
m_macIsUserPane = false ;
|
m_macIsUserPane = false;
|
||||||
|
|
||||||
if ( !wxSpinButtonBase::Create(parent, id, pos, size,
|
if ( !wxSpinButtonBase::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
|
||||||
style, wxDefaultValidator, name) )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_min = 0;
|
m_min = 0;
|
||||||
@@ -47,14 +41,16 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
|
|||||||
if (!parent)
|
if (!parent)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
|
Rect bounds = wxMacGetBoundsForControl( this , pos , size );
|
||||||
|
|
||||||
m_peer = new wxMacControl(this) ;
|
m_peer = new wxMacControl( this );
|
||||||
verify_noerr ( CreateLittleArrowsControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , 0 , m_min , m_max , 1 ,
|
OSStatus err = CreateLittleArrowsControl(
|
||||||
m_peer->GetControlRefAddr() ) );
|
MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, 0, m_min, m_max, 1,
|
||||||
|
m_peer->GetControlRefAddr() );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
m_peer->SetActionProc( GetwxMacLiveScrollbarActionProc() ) ;
|
m_peer->SetActionProc( GetwxMacLiveScrollbarActionProc() );
|
||||||
MacPostControlCreate(pos,size) ;
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -63,9 +59,6 @@ wxSpinButton::~wxSpinButton()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attributes
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
int wxSpinButton::GetMin() const
|
int wxSpinButton::GetMin() const
|
||||||
{
|
{
|
||||||
return m_min;
|
return m_min;
|
||||||
@@ -80,30 +73,31 @@ int wxSpinButton::GetValue() const
|
|||||||
{
|
{
|
||||||
int n = m_value;
|
int n = m_value;
|
||||||
|
|
||||||
if (n < m_min) n = m_min;
|
if (n < m_min)
|
||||||
if (n > m_max) n = m_max;
|
n = m_min;
|
||||||
|
else if (n > m_max)
|
||||||
|
n = m_max;
|
||||||
|
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinButton::SetValue(int val)
|
void wxSpinButton::SetValue(int val)
|
||||||
{
|
{
|
||||||
m_value = val ;
|
m_value = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinButton::SetRange(int minVal, int maxVal)
|
void wxSpinButton::SetRange(int minVal, int maxVal)
|
||||||
{
|
{
|
||||||
m_min = minVal;
|
m_min = minVal;
|
||||||
m_max = maxVal;
|
m_max = maxVal;
|
||||||
m_peer->SetMaximum( maxVal ) ;
|
m_peer->SetMaximum( maxVal );
|
||||||
m_peer->SetMinimum( minVal ) ;
|
m_peer->SetMinimum( minVal );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinButton::MacHandleValueChanged( int inc )
|
void wxSpinButton::MacHandleValueChanged( int inc )
|
||||||
{
|
{
|
||||||
|
|
||||||
wxEventType scrollEvent = wxEVT_NULL;
|
wxEventType scrollEvent = wxEVT_NULL;
|
||||||
int oldValue = m_value ;
|
int oldValue = m_value;
|
||||||
|
|
||||||
m_value = oldValue + inc;
|
m_value = oldValue + inc;
|
||||||
|
|
||||||
@@ -124,78 +118,83 @@ void wxSpinButton::MacHandleValueChanged( int inc )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( m_value - oldValue == -1 )
|
if ( m_value - oldValue == -1 )
|
||||||
scrollEvent = wxEVT_SCROLL_LINEDOWN ;
|
scrollEvent = wxEVT_SCROLL_LINEDOWN;
|
||||||
else if ( m_value - oldValue == 1 )
|
else if ( m_value - oldValue == 1 )
|
||||||
scrollEvent = wxEVT_SCROLL_LINEUP ;
|
scrollEvent = wxEVT_SCROLL_LINEUP;
|
||||||
else
|
else
|
||||||
scrollEvent = wxEVT_SCROLL_THUMBTRACK ;
|
scrollEvent = wxEVT_SCROLL_THUMBTRACK;
|
||||||
|
|
||||||
wxSpinEvent event(scrollEvent, m_windowId);
|
wxSpinEvent event( scrollEvent, m_windowId );
|
||||||
|
|
||||||
event.SetPosition(m_value);
|
event.SetPosition( m_value );
|
||||||
event.SetEventObject( this );
|
event.SetEventObject( this );
|
||||||
if ((GetEventHandler()->ProcessEvent( event )) &&
|
if ((GetEventHandler()->ProcessEvent( event )) && !event.IsAllowed())
|
||||||
!event.IsAllowed() )
|
m_value = oldValue;
|
||||||
{
|
|
||||||
m_value = oldValue ;
|
|
||||||
}
|
|
||||||
m_peer->SetValue( m_value ) ;
|
|
||||||
|
|
||||||
/* always send a thumbtrack event */
|
m_peer->SetValue( m_value );
|
||||||
|
|
||||||
|
// always send a thumbtrack event
|
||||||
if (scrollEvent != wxEVT_SCROLL_THUMBTRACK)
|
if (scrollEvent != wxEVT_SCROLL_THUMBTRACK)
|
||||||
{
|
{
|
||||||
scrollEvent = wxEVT_SCROLL_THUMBTRACK;
|
scrollEvent = wxEVT_SCROLL_THUMBTRACK;
|
||||||
wxSpinEvent event2( scrollEvent, GetId());
|
wxSpinEvent event2( scrollEvent, GetId() );
|
||||||
event2.SetPosition( m_value );
|
event2.SetPosition( m_value );
|
||||||
event2.SetEventObject( this );
|
event2.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent( event2 );
|
GetEventHandler()->ProcessEvent( event2 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool mouseStillDown )
|
void wxSpinButton::MacHandleControlClick( WXWidget control, wxInt16 controlpart, bool mouseStillDown )
|
||||||
{
|
{
|
||||||
int nScrollInc = 0;
|
int nScrollInc = 0;
|
||||||
|
|
||||||
switch( controlpart )
|
switch ( controlpart )
|
||||||
{
|
{
|
||||||
case kControlUpButtonPart :
|
case kControlUpButtonPart :
|
||||||
nScrollInc = 1;
|
nScrollInc = 1;
|
||||||
break ;
|
break;
|
||||||
|
|
||||||
case kControlDownButtonPart :
|
case kControlDownButtonPart :
|
||||||
nScrollInc = -1;
|
nScrollInc = -1;
|
||||||
break ;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
MacHandleValueChanged( nScrollInc ) ;
|
MacHandleValueChanged( nScrollInc ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxInt32 wxSpinButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF event )
|
wxInt32 wxSpinButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF event )
|
||||||
{
|
{
|
||||||
/*
|
#if 0
|
||||||
// these have been handled by the live action proc already
|
// these have been handled by the live action proc already
|
||||||
int nScrollInc = 0;
|
int nScrollInc = 0;
|
||||||
wxMacCarbonEvent cEvent( (EventRef) event ) ;
|
wxMacCarbonEvent cEvent( (EventRef)event );
|
||||||
|
|
||||||
switch( cEvent.GetParameter<ControlPartCode>(kEventParamControlPart,typeControlPartCode) )
|
switch ( cEvent.GetParameter<ControlPartCode>(kEventParamControlPart, typeControlPartCode) )
|
||||||
{
|
{
|
||||||
case kControlUpButtonPart :
|
case kControlUpButtonPart :
|
||||||
nScrollInc = 1;
|
nScrollInc = 1;
|
||||||
break ;
|
break;
|
||||||
|
|
||||||
case kControlDownButtonPart :
|
case kControlDownButtonPart :
|
||||||
nScrollInc = -1;
|
nScrollInc = -1;
|
||||||
break ;
|
break;
|
||||||
}
|
|
||||||
MacHandleValueChanged( nScrollInc ) ;
|
|
||||||
*/
|
|
||||||
return noErr ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
default :
|
||||||
// size calculation
|
break;
|
||||||
// ----------------------------------------------------------------------------
|
}
|
||||||
|
|
||||||
|
MacHandleValueChanged( nScrollInc ) ;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return noErr;
|
||||||
|
}
|
||||||
|
|
||||||
wxSize wxSpinButton::DoGetBestSize() const
|
wxSize wxSpinButton::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
return wxSize(16,24);
|
return wxSize( 16, 24 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_SPINBTN
|
#endif // wxUSE_SPINBTN
|
||||||
|
@@ -18,34 +18,33 @@
|
|||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
|
||||||
|
|
||||||
/*
|
|
||||||
* Static box
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
|
bool wxStaticBox::Create( wxWindow *parent,
|
||||||
const wxString& label,
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
const wxString& label,
|
||||||
const wxSize& size,
|
const wxPoint& pos,
|
||||||
long style,
|
const wxSize& size,
|
||||||
const wxString& name)
|
long style,
|
||||||
|
const wxString& name )
|
||||||
{
|
{
|
||||||
m_macIsUserPane = FALSE ;
|
m_macIsUserPane = false;
|
||||||
|
|
||||||
if ( !wxControl::Create(parent, id, pos, size,
|
if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
|
||||||
style, wxDefaultValidator, name) )
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_label = label ;
|
m_label = label;
|
||||||
|
|
||||||
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
|
Rect bounds = wxMacGetBoundsForControl( this, pos, size );
|
||||||
|
|
||||||
m_peer = new wxMacControl(this) ;
|
m_peer = new wxMacControl( this );
|
||||||
verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") ,
|
OSStatus err = CreateGroupBoxControl(
|
||||||
true /*primary*/ , m_peer->GetControlRefAddr() ) ) ;
|
MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, CFSTR(""),
|
||||||
|
true /*primary*/, m_peer->GetControlRefAddr() );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
MacPostControlCreate(pos,size) ;
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
|
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
|
||||||
@@ -55,11 +54,11 @@ void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
|
|||||||
|
|
||||||
if ( extraTop == -1 )
|
if ( extraTop == -1 )
|
||||||
{
|
{
|
||||||
// The minimal border used for the top. Later on the staticbox'
|
// The minimal border used for the top.
|
||||||
// font height is added to this.
|
// Later on, the staticbox's font height is added to this.
|
||||||
extraTop = 0;
|
extraTop = 0;
|
||||||
|
|
||||||
if ( UMAGetSystemVersion() >= 0x1030 /*Panther*/ )
|
if ( UMAGetSystemVersion() >= 0x1030 ) // Panther
|
||||||
{
|
{
|
||||||
// As indicated by the HIG, Panther needs an extra border of 11
|
// As indicated by the HIG, Panther needs an extra border of 11
|
||||||
// pixels (otherwise overlapping occurs at the top). The "other"
|
// pixels (otherwise overlapping occurs at the top). The "other"
|
||||||
@@ -67,7 +66,6 @@ void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
|
|||||||
extraTop = 11;
|
extraTop = 11;
|
||||||
other = 11;
|
other = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*borderTop = extraTop + GetCharHeight();
|
*borderTop = extraTop + GetCharHeight();
|
||||||
|
@@ -8,15 +8,6 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// declarations
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// headers
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
@@ -26,32 +17,25 @@
|
|||||||
#include "wx/statline.h"
|
#include "wx/statline.h"
|
||||||
#include "wx/statbox.h"
|
#include "wx/statbox.h"
|
||||||
|
|
||||||
// ============================================================================
|
|
||||||
// implementation
|
|
||||||
// ============================================================================
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl)
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// wxStaticLine
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
bool wxStaticLine::Create( wxWindow *parent,
|
bool wxStaticLine::Create( wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
const wxPoint &pos,
|
const wxPoint &pos,
|
||||||
const wxSize &size,
|
const wxSize &size,
|
||||||
long style,
|
long style,
|
||||||
const wxString &name)
|
const wxString &name )
|
||||||
{
|
{
|
||||||
if ( !CreateBase(parent, id, pos, size, style, wxDefaultValidator, name) )
|
if ( !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ) )
|
||||||
return FALSE;
|
return false;
|
||||||
|
|
||||||
// ok, this is ugly but it's better than nothing: use a thin static box to
|
// this is ugly but it's better than nothing:
|
||||||
// emulate static line
|
// use a thin static box to emulate static line
|
||||||
|
|
||||||
wxSize sizeReal = AdjustSize(size);
|
wxSize sizeReal = AdjustSize( size );
|
||||||
|
|
||||||
// m_statbox = new wxStaticBox(parent, id, wxT(""), pos, sizeReal, style, name);
|
// m_statbox = new wxStaticBox( parent, id, wxT(""), pos, sizeReal, style, name );
|
||||||
|
|
||||||
return TRUE;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -22,97 +22,114 @@
|
|||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/settings.h"
|
#include "wx/settings.h"
|
||||||
|
|
||||||
|
#include "wx/mac/uma.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
|
||||||
|
|
||||||
#include "wx/mac/uma.h"
|
|
||||||
|
|
||||||
bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
|
bool wxStaticText::Create( wxWindow *parent,
|
||||||
const wxString& label,
|
wxWindowID id,
|
||||||
const wxPoint& pos,
|
const wxString& label,
|
||||||
const wxSize& size,
|
const wxPoint& pos,
|
||||||
long style,
|
const wxSize& size,
|
||||||
const wxString& name)
|
long style,
|
||||||
|
const wxString& name )
|
||||||
{
|
{
|
||||||
m_macIsUserPane = FALSE ;
|
m_macIsUserPane = false;
|
||||||
|
|
||||||
m_label = wxStripMenuCodes(label) ;
|
|
||||||
|
|
||||||
if ( !wxControl::Create( parent, id, pos, size, style,
|
m_label = wxStripMenuCodes( label );
|
||||||
wxDefaultValidator , name ) )
|
|
||||||
{
|
if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
|
Rect bounds = wxMacGetBoundsForControl( this, pos, size );
|
||||||
wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
|
wxMacCFStringHolder str( m_label, m_font.GetEncoding() );
|
||||||
m_peer = new wxMacControl(this) ;
|
|
||||||
verify_noerr(CreateStaticTextControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, str ,
|
|
||||||
NULL , m_peer->GetControlRefAddr() ) ) ;
|
|
||||||
|
|
||||||
MacPostControlCreate(pos,size) ;
|
m_peer = new wxMacControl( this );
|
||||||
|
OSStatus err = CreateStaticTextControl(
|
||||||
|
MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
|
||||||
|
&bounds, str, NULL, m_peer->GetControlRefAddr() );
|
||||||
|
verify_noerr( err );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxStaticText::DoGetBestSize() const
|
wxSize wxStaticText::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
ControlFontStyleRec controlFont ;
|
ControlFontStyleRec controlFont;
|
||||||
verify_noerr( m_peer->GetData<ControlFontStyleRec>(kControlEntireControl , kControlFontStyleTag , &controlFont ) ) ;
|
OSStatus err = m_peer->GetData<ControlFontStyleRec>( kControlEntireControl, kControlFontStyleTag, &controlFont );
|
||||||
|
verify_noerr( err );
|
||||||
Point bounds ;
|
|
||||||
SInt16 baseline ;
|
Point bounds;
|
||||||
wxMacCFStringHolder str(m_label , m_font.GetEncoding() ) ;
|
SInt16 baseline;
|
||||||
|
wxMacCFStringHolder str( m_label, m_font.GetEncoding() );
|
||||||
|
|
||||||
if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
|
if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
|
||||||
verify_noerr( GetThemeTextDimensions( (m_label.Length() > 0 ? ((CFStringRef) str ) : CFSTR(" ") ) , m_font.MacGetThemeFontID() , kThemeStateActive , false , &bounds , &baseline ) ) ;
|
{
|
||||||
|
err = GetThemeTextDimensions(
|
||||||
|
(m_label.Length() > 0 ? (CFStringRef)str : CFSTR(" ")),
|
||||||
|
m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
|
||||||
|
verify_noerr( err );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxMacWindowStateSaver sv( this ) ;
|
wxMacWindowStateSaver sv( this );
|
||||||
::TextFont( m_font.MacGetFontNum() ) ;
|
::TextFont( m_font.MacGetFontNum() );
|
||||||
::TextSize( (short)( m_font.MacGetFontSize()) ) ;
|
::TextSize( (short)(m_font.MacGetFontSize()) );
|
||||||
::TextFace( m_font.MacGetFontStyle() ) ;
|
::TextFace( m_font.MacGetFontStyle() );
|
||||||
verify_noerr( GetThemeTextDimensions( (m_label.Length() > 0 ? ((CFStringRef) str ) : CFSTR(" ") ) , kThemeCurrentPortFont , kThemeStateActive , false , &bounds , &baseline ) ) ;
|
|
||||||
|
err = GetThemeTextDimensions(
|
||||||
|
(m_label.Length() > 0 ? (CFStringRef)str : CFSTR(" ")),
|
||||||
|
kThemeCurrentPortFont, kThemeStateActive, false, &bounds, &baseline );
|
||||||
|
verify_noerr( err );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( m_label.Length() == 0 )
|
if ( m_label.Length() == 0 )
|
||||||
bounds.h = 0 ;
|
bounds.h = 0 ;
|
||||||
|
|
||||||
bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize() ;
|
bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize();
|
||||||
bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize() ;
|
bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize();
|
||||||
return wxSize(bounds.h, bounds.v);
|
|
||||||
|
return wxSize( bounds.h, bounds.v );
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxStaticText::SetLabel(const wxString& st )
|
void wxStaticText::SetLabel( const wxString& st )
|
||||||
{
|
{
|
||||||
|
m_label = wxStripMenuCodes( st );
|
||||||
|
|
||||||
m_label = wxStripMenuCodes(st) ;
|
wxMacCFStringHolder str( m_label, m_font.GetEncoding() );
|
||||||
|
CFStringRef ref = str;
|
||||||
wxMacCFStringHolder str(m_label,m_font.GetEncoding() ) ;
|
OSStatus err = m_peer->SetData<CFStringRef>(kControlEntireControl, kControlStaticTextCFStringTag, ref );
|
||||||
CFStringRef ref = str ;
|
verify_noerr( err );
|
||||||
verify_noerr( m_peer->SetData<CFStringRef>(kControlEntireControl , kControlStaticTextCFStringTag, ref ) ) ;
|
|
||||||
|
|
||||||
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
|
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
|
||||||
{
|
{
|
||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
SetSize( GetBestSize() ) ;
|
SetSize( GetBestSize() );
|
||||||
}
|
}
|
||||||
Refresh() ;
|
|
||||||
|
Refresh();
|
||||||
|
|
||||||
// we shouldn't need forced updates
|
// we shouldn't need forced updates
|
||||||
// Update() ;
|
// Update() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxStaticText::SetFont(const wxFont& font)
|
bool wxStaticText::SetFont(const wxFont& font)
|
||||||
{
|
{
|
||||||
bool ret = wxControl::SetFont(font);
|
bool ret = wxControl::SetFont( font );
|
||||||
|
|
||||||
if ( ret )
|
if ( ret )
|
||||||
{
|
{
|
||||||
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
|
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
|
||||||
{
|
{
|
||||||
InvalidateBestSize();
|
InvalidateBestSize();
|
||||||
SetSize( GetBestSize() );
|
SetSize( GetBestSize() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -242,7 +242,8 @@ void UMASetMenuTitle( MenuRef menu , const wxString& title , wxFontEncoding enco
|
|||||||
|
|
||||||
void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title, wxFontEncoding encoding )
|
void UMASetMenuItemText( MenuRef menu, MenuItemIndex item, const wxString& title, wxFontEncoding encoding )
|
||||||
{
|
{
|
||||||
wxString str = title ; // we don't strip the accels here anynmore, must be done before
|
// we don't strip the accels here anymore, must be done before
|
||||||
|
wxString str = title ;
|
||||||
|
|
||||||
#if TARGET_CARBON
|
#if TARGET_CARBON
|
||||||
SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str , encoding) ) ;
|
SetMenuItemTextWithCFString( menu , item , wxMacCFStringHolder(str , encoding) ) ;
|
||||||
|
Reference in New Issue
Block a user