cleanup - reformat

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@36793 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
David Surovell
2006-01-09 00:46:43 +00:00
parent 2dc62891c4
commit 43524b1583
8 changed files with 450 additions and 495 deletions

View File

@@ -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,
@@ -51,9 +33,7 @@ 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") ;
}
m_radioGroup.start = -1;
m_isRadioGroupStart = false;
@@ -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;
}

View File

@@ -18,21 +18,18 @@
#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() )
@@ -53,21 +50,6 @@ 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;
@@ -75,21 +57,24 @@ wxRadioBox::~wxRadioBox()
wxRadioButton *next, *current;
current = m_radioButtonCycle->NextInCycle();
if (current != NULL)
{
while (current != m_radioButtonCycle)
{
next = current->NextInCycle();
while (current!=m_radioButtonCycle) {
delete current;
current = next;
next=current->NextInCycle();
}
delete current;
}
//-------------------------------------------------------------------------------------
// <20> Create
//-------------------------------------------------------------------------------------
delete current;
}
}
// Create the radiobox for two-step construction
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
bool wxRadioBox::Create( wxWindow *parent,
wxWindowID id, const wxString& label,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices,
int majorDim, long style,
@@ -97,11 +82,13 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
{
wxCArrayString chs(choices);
return Create(parent, id, label, pos, size, chs.GetCount(),
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,
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,
@@ -130,20 +117,22 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
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
(
wxRadioButton *radBtn = new wxRadioButton(
this,
wxID_ANY,
wxStripMenuCodes(choices[i]),
wxPoint( 5, 20 * i + 10 ),
wxDefaultSize,
i == 0 ? wxRB_GROUP : 0
);
i == 0 ? wxRB_GROUP : 0 );
if ( i == 0 )
m_radioButtonCycle = radBtn;
// m_radioButtonCycle = radBtn->AddInCycle( m_radioButtonCycle );
@@ -155,12 +144,8 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
return true;
}
//-------------------------------------------------------------------------------------
// <20> Enable(bool)
//-------------------------------------------------------------------------------------
// Enables or disables the entire radiobox
//
bool wxRadioBox::Enable(bool enable)
{
int i;
@@ -170,18 +155,17 @@ bool wxRadioBox::Enable(bool enable)
return false;
current = m_radioButtonCycle;
for (i = 0; i < m_noItems; i++) {
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;
@@ -192,28 +176,24 @@ bool wxRadioBox::Enable(int item, bool enable)
i = 0;
current = m_radioButtonCycle;
while (i != item) {
while (i != item)
{
i++;
current = current->NextInCycle();
}
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;
@@ -224,18 +204,17 @@ wxString wxRadioBox::GetString(int item) const
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;
@@ -243,7 +222,8 @@ int wxRadioBox::GetSelection() const
i = 0;
current = m_radioButtonCycle;
while (!current->GetValue()) {
while (!current->GetValue())
{
i++;
current = current->NextInCycle();
}
@@ -251,29 +231,15 @@ int wxRadioBox::GetSelection() const
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 );
}
//-------------------------------------------------------------------------------------
// <20> SetLabel(int, const wxString&)
//-------------------------------------------------------------------------------------
// Sets the label of a given button
//
void wxRadioBox::SetString(int item,const wxString& label)
{
int i;
@@ -281,21 +247,21 @@ void wxRadioBox::SetString(int item,const wxString& label)
if (!IsValid( item ))
return;
i = 0;
current = m_radioButtonCycle;
while (i!=item) {
while (i != item)
{
i++;
current = current->NextInCycle();
}
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;
@@ -303,42 +269,39 @@ void wxRadioBox::SetSelection(int item)
if (!IsValid( item ))
return;
i = 0;
current = m_radioButtonCycle;
while (i!=item) {
while (i != item)
{
i++;
current = current->NextInCycle();
}
current->SetValue(true);
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->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;
@@ -346,31 +309,28 @@ bool wxRadioBox::Show(int item, bool show)
if (!IsValid( item ))
return false;
i = 0;
current = m_radioButtonCycle;
while (i!=item) {
while (i != item)
{
i++;
current = current->NextInCycle();
}
return current->Show( show );
}
//-------------------------------------------------------------------------------------
// <20> Command
//-------------------------------------------------------------------------------------
// Simulates the effect of the user issuing a command to the item
//
void wxRadioBox::Command( wxCommandEvent& event )
{
SetSelection( event.GetInt() );
ProcessCommand( event );
}
//-------------------------------------------------------------------------------------
// <20> SetFocus
//-------------------------------------------------------------------------------------
// Sets the selected button to receive keyboard input
//
void wxRadioBox::SetFocus()
{
int i;
@@ -378,19 +338,17 @@ void wxRadioBox::SetFocus()
i = 0;
current = m_radioButtonCycle;
while (!current->GetValue()) {
while (!current->GetValue())
{
i++;
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)
@@ -403,24 +361,29 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
int x_current, y_current;
int x_offset, y_offset;
int widthOld, heightOld;
GetSize( &widthOld, &heightOld );
GetPosition( &x_current, &y_current );
x_offset = x;
y_offset = y;
GetPosition(&x_current, &y_current);
if ((x == wxDefaultCoord) && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
if (!(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
{
if (x == wxDefaultCoord)
x_offset = x_current;
if ((y == wxDefaultCoord)&& !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
if (y == wxDefaultCoord)
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);
GetTextExtent(
wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
&charWidth, &charHeight );
charWidth /= 52;
@@ -431,16 +394,19 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
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 (maxWidth < eachWidth[i])
maxWidth = eachWidth[i];
if (maxHeight < eachHeight[i])
maxHeight = eachHeight[i];
}
totHeight = GetRowCount() * ( maxHeight ) ;
totHeight = GetRowCount() * maxHeight;
totWidth = GetColumnCount() * (maxWidth + charWidth);
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) ) ;
// only change our width/height if asked for
// change the width / height only when specified
if ( width == wxDefaultCoord )
{
if ( sizeFlags & wxSIZE_AUTO_WIDTH )
@@ -460,10 +426,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
wxControl::DoSetSize( x_offset, y_offset, width, height, wxSIZE_AUTO );
// arrange radio buttons
int x_start, y_start;
x_start = 0;
y_start = 0;
@@ -473,7 +437,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
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,7 +448,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
else
{
x_offset = x_start;
y_offset += maxHeight ; /*+ charHeight/2;*/
y_offset += maxHeight ; //+ charHeight / 2
}
}
@@ -491,7 +456,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
current = current->NextInCycle();
if (m_windowStyle & wxRA_SPECIFY_ROWS)
y_offset += maxHeight ; /*+ charHeight/2;*/
y_offset += maxHeight ; // + charHeight / 2
else
x_offset += maxWidth + charWidth;
}
@@ -504,8 +469,9 @@ wxSize wxRadioBox::DoGetBestSize() const
int eachWidth, eachHeight;
int totWidth, totHeight;
wxFont font = /*GetParent()->*/GetFont();
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
wxFont font = GetFont(); // GetParent()->GetFont()
GetTextExtent(
wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
&charWidth, &charHeight, NULL, NULL, &font );
charWidth /= 52;
@@ -518,11 +484,13 @@ wxSize wxRadioBox::DoGetBestSize() const
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 ) ;
totHeight = GetRowCount() * maxHeight;
totWidth = GetColumnCount() * (maxWidth + charWidth);
wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth, totHeight ) );

View File

@@ -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,15 +14,17 @@
#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,
bool wxRadioButton::Create( wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size, long style,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name )
{
@@ -36,9 +38,10 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
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() ) );
OSStatus err = CreateRadioButtonControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, CFSTR(""),
0, false /* no autotoggle */, m_peer->GetControlRefAddr() );
verify_noerr( err );
MacPostControlCreate( pos, size );
@@ -50,8 +53,8 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
}
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)
{
@@ -59,12 +62,16 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
if (child->IsKindOf( CLASSINFO( wxRadioButton ) ))
{
chief = (wxRadioButton*)child;
if (child->HasFlag(wxRB_GROUP)) break;
if (child->HasFlag( wxRB_GROUP ))
break;
}
node = node->GetPrevious();
}
AddInCycle( chief );
}
return true;
}
@@ -113,11 +120,13 @@ wxInt32 wxRadioButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVE
wxRadioButton *cycle;
cycle = this->NextInCycle();
if (cycle!=NULL) {
while (cycle!=this) {
if ( cycle->GetValue() ) {
if (cycle != NULL)
{
while (cycle != this)
{
if (cycle->GetValue())
cycle->SetValue( false );
}
cycle = cycle->NextInCycle();
}
}
@@ -128,6 +137,7 @@ wxInt32 wxRadioButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVE
event2.SetEventObject( this );
event2.SetInt( true );
ProcessCommand( event2 );
return noErr;
}
@@ -138,33 +148,31 @@ wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
if (cycle == NULL)
{
m_cycle = this;
return(this);
}
else
{
current = cycle;
while ((next = current->m_cycle) != cycle)
current = current->m_cycle;
m_cycle = cycle;
current->m_cycle = this;
return(cycle);
}
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;
}
}
#endif

View File

@@ -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,
bool wxSpinButton::Create( wxWindow *parent,
wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name )
{
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;
@@ -50,8 +44,10 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
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() ) );
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 );
@@ -63,9 +59,6 @@ wxSpinButton::~wxSpinButton()
{
}
// Attributes
////////////////////////////////////////////////////////////////////////////
int wxSpinButton::GetMin() const
{
return m_min;
@@ -80,8 +73,10 @@ 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;
}
@@ -101,7 +96,6 @@ void wxSpinButton::SetRange(int minVal, int maxVal)
void wxSpinButton::MacHandleValueChanged( int inc )
{
wxEventType scrollEvent = wxEVT_NULL;
int oldValue = m_value;
@@ -134,14 +128,12 @@ void wxSpinButton::MacHandleValueChanged( int inc )
event.SetPosition( m_value );
event.SetEventObject( this );
if ((GetEventHandler()->ProcessEvent( event )) &&
!event.IsAllowed() )
{
if ((GetEventHandler()->ProcessEvent( event )) && !event.IsAllowed())
m_value = oldValue;
}
m_peer->SetValue( m_value );
/* always send a thumbtrack event */
// always send a thumbtrack event
if (scrollEvent != wxEVT_SCROLL_THUMBTRACK)
{
scrollEvent = wxEVT_SCROLL_THUMBTRACK;
@@ -161,16 +153,21 @@ void wxSpinButton::MacHandleControlClick( WXWidget control , wxInt16 controlpart
case kControlUpButtonPart :
nScrollInc = 1;
break;
case kControlDownButtonPart :
nScrollInc = -1;
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 );
@@ -180,18 +177,20 @@ wxInt32 wxSpinButton::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVEN
case kControlUpButtonPart :
nScrollInc = 1;
break;
case kControlDownButtonPart :
nScrollInc = -1;
break;
}
MacHandleValueChanged( nScrollInc ) ;
*/
return noErr ;
default :
break;
}
// ----------------------------------------------------------------------------
// size calculation
// ----------------------------------------------------------------------------
MacHandleValueChanged( nScrollInc ) ;
#endif
return noErr;
}
wxSize wxSpinButton::DoGetBestSize() const
{

View File

@@ -18,21 +18,18 @@
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
/*
* Static box
*/
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
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;
@@ -40,12 +37,14 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
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() ) ) ;
OSStatus err = CreateGroupBoxControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, CFSTR(""),
true /*primary*/, m_peer->GetControlRefAddr() );
verify_noerr( err );
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();

View File

@@ -8,15 +8,6 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
@@ -26,15 +17,8 @@
#include "wx/statline.h"
#include "wx/statbox.h"
// ============================================================================
// implementation
// ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl)
// ----------------------------------------------------------------------------
// wxStaticLine
// ----------------------------------------------------------------------------
bool wxStaticLine::Create( wxWindow *parent,
wxWindowID id,
@@ -44,14 +28,14 @@ bool wxStaticLine::Create( wxWindow *parent,
const wxString &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
// 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 );
// m_statbox = new wxStaticBox( parent, id, wxT(""), pos, sizeReal, style, name );
return TRUE;
return true;
}

View File

@@ -22,34 +22,36 @@
#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,
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_macIsUserPane = false;
m_label = wxStripMenuCodes( label );
if ( !wxControl::Create( parent, id, pos, size, style,
wxDefaultValidator , name ) )
{
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() ) ) ;
OSStatus err = CreateStaticTextControl(
MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
&bounds, str, NULL, m_peer->GetControlRefAddr() );
verify_noerr( err );
MacPostControlCreate( pos, size );
@@ -59,44 +61,59 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
wxSize wxStaticText::DoGetBestSize() const
{
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;
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 ) ) ;
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 );
}
void wxStaticText::SetLabel( const wxString& st )
{
m_label = wxStripMenuCodes( st );
wxMacCFStringHolder str( m_label, m_font.GetEncoding() );
CFStringRef ref = str;
verify_noerr( m_peer->SetData<CFStringRef>(kControlEntireControl , kControlStaticTextCFStringTag, ref ) ) ;
OSStatus err = m_peer->SetData<CFStringRef>(kControlEntireControl, kControlStaticTextCFStringTag, ref );
verify_noerr( err );
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
{
InvalidateBestSize();
SetSize( GetBestSize() );
}
Refresh();
// we shouldn't need forced updates
// Update() ;
}

View File

@@ -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) ) ;