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