common implementation files
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55202 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
86
src/osx/bmpbuttn_osx.cpp
Normal file
86
src/osx/bmpbuttn_osx.cpp
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/osx/bmpbuttn_osx.cpp
|
||||||
|
// Purpose: wxBitmapButton
|
||||||
|
// Author: Stefan Csomor
|
||||||
|
// Modified by:
|
||||||
|
// Created: 1998-01-01
|
||||||
|
// RCS-ID: $Id: bmpbuttn.cpp 54820 2008-07-29 20:04:11Z SC $
|
||||||
|
// Copyright: (c) Stefan Csomor
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#if wxUSE_BMPBUTTON
|
||||||
|
|
||||||
|
#include "wx/bmpbuttn.h"
|
||||||
|
#include "wx/image.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/dcmemory.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
|
||||||
|
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxBitmapButton::Create( wxWindow *parent,
|
||||||
|
wxWindowID id, const wxBitmap& bitmap,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxValidator& validator,
|
||||||
|
const wxString& name )
|
||||||
|
{
|
||||||
|
m_macIsUserPane = false;
|
||||||
|
|
||||||
|
// since bitmapbuttonbase is subclass of button calling wxBitmapButtonBase::Create
|
||||||
|
// essentially creates an additional button
|
||||||
|
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ( style & wxBU_AUTODRAW )
|
||||||
|
{
|
||||||
|
m_marginX =
|
||||||
|
m_marginY = wxDEFAULT_BUTTON_MARGIN;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_marginX =
|
||||||
|
m_marginY = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_bmpNormal = bitmap;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateBitmapButton( this, parent, id, bitmap, pos, size, style, GetExtraStyle() );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBitmapButton::SetBitmapLabel( const wxBitmap& bitmap )
|
||||||
|
{
|
||||||
|
InvalidateBestSize();
|
||||||
|
|
||||||
|
m_peer->SetBitmap( bitmap );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize wxBitmapButton::DoGetBestSize() const
|
||||||
|
{
|
||||||
|
wxSize best;
|
||||||
|
|
||||||
|
best.x = 2 * m_marginX;
|
||||||
|
best.y = 2 * m_marginY;
|
||||||
|
if ( m_bmpNormal.Ok() )
|
||||||
|
{
|
||||||
|
best.x += m_bmpNormal.GetWidth();
|
||||||
|
best.y += m_bmpNormal.GetHeight();
|
||||||
|
}
|
||||||
|
|
||||||
|
return best;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
147
src/osx/button_osx.cpp
Normal file
147
src/osx/button_osx.cpp
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/osx/button_osx.cpp
|
||||||
|
// Purpose: wxButton
|
||||||
|
// Author: Stefan Csomor
|
||||||
|
// Modified by:
|
||||||
|
// Created: 1998-01-01
|
||||||
|
// RCS-ID: $Id: button.cpp 54845 2008-07-30 14:52:41Z SC $
|
||||||
|
// Copyright: (c) Stefan Csomor
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#include "wx/button.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/panel.h"
|
||||||
|
#include "wx/toplevel.h"
|
||||||
|
#include "wx/dcclient.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/stockitem.h"
|
||||||
|
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||||
|
|
||||||
|
bool wxButton::Create(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& lbl,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxValidator& validator,
|
||||||
|
const wxString& name)
|
||||||
|
{
|
||||||
|
wxString label(lbl);
|
||||||
|
if (label.empty() && wxIsStockID(id))
|
||||||
|
label = wxGetStockLabel(id);
|
||||||
|
|
||||||
|
m_macIsUserPane = false ;
|
||||||
|
|
||||||
|
if ( !wxButtonBase::Create(parent, id, pos, size, style, validator, name) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_labelOrig = m_label = label ;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateButton( this, parent, id, label, pos, size, style, GetExtraStyle() );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxWindow *wxButton::SetDefault()
|
||||||
|
{
|
||||||
|
wxWindow *btnOldDefault = wxButtonBase::SetDefault();
|
||||||
|
|
||||||
|
if ( btnOldDefault )
|
||||||
|
{
|
||||||
|
btnOldDefault->GetPeer()->SetDefaultButton( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
m_peer->SetDefaultButton( true );
|
||||||
|
|
||||||
|
return btnOldDefault;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxButton::Command (wxCommandEvent & event)
|
||||||
|
{
|
||||||
|
m_peer->PerformClick() ;
|
||||||
|
// ProcessCommand(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxButton::HandleClicked( double timestampsec )
|
||||||
|
{
|
||||||
|
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
ProcessCommand(event);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------
|
||||||
|
// wxDisclosureTriangle
|
||||||
|
//-------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxDisclosureTriangle::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 ;
|
||||||
|
|
||||||
|
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if wxOSX_USE_CARBON
|
||||||
|
Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ;
|
||||||
|
m_peer = new wxMacControl(this) ;
|
||||||
|
|
||||||
|
OSStatus err = CreateDisclosureTriangleControl(
|
||||||
|
MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds,
|
||||||
|
kControlDisclosureTrianglePointDefault,
|
||||||
|
wxCFStringRef( label ),
|
||||||
|
0, // closed
|
||||||
|
TRUE, // draw title
|
||||||
|
TRUE, // auto toggle back and forth
|
||||||
|
m_peer->GetControlRefAddr() );
|
||||||
|
|
||||||
|
verify_noerr( err );
|
||||||
|
#endif
|
||||||
|
wxASSERT_MSG( m_peer != NULL && m_peer->IsOk() , wxT("No valid Mac control") ) ;
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
// passing the text in the param doesn't seem to work, so lets do if again
|
||||||
|
SetLabel( label );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxDisclosureTriangle::SetOpen( bool open )
|
||||||
|
{
|
||||||
|
#if wxOSX_USE_CARBON
|
||||||
|
m_peer->SetValue( open ? 1 : 0 );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxDisclosureTriangle::IsOpen() const
|
||||||
|
{
|
||||||
|
#if wxOSX_USE_CARBON
|
||||||
|
return m_peer->GetValue() == 1;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxDisclosureTriangle::HandleClicked( double timestampsec )
|
||||||
|
{
|
||||||
|
// Just emit button event for now
|
||||||
|
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, m_windowId);
|
||||||
|
event.SetEventObject(this);
|
||||||
|
ProcessCommand(event);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize wxDisclosureTriangle::DoGetBestSize() const
|
||||||
|
{
|
||||||
|
return wxSize(16,16);
|
||||||
|
}
|
||||||
|
|
176
src/osx/checkbox_osx.cpp
Normal file
176
src/osx/checkbox_osx.cpp
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/mac/carbon/checkbox.cpp
|
||||||
|
// Purpose: wxCheckBox
|
||||||
|
// Author: Stefan Csomor
|
||||||
|
// Modified by:
|
||||||
|
// Created: 04/01/98
|
||||||
|
// RCS-ID: $Id: checkbox.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||||
|
// Copyright: (c) Stefan Csomor
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#if wxUSE_CHECKBOX
|
||||||
|
|
||||||
|
#include "wx/checkbox.h"
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
|
||||||
|
|
||||||
|
// Single check box item
|
||||||
|
bool wxCheckBox::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 ;
|
||||||
|
|
||||||
|
if ( !wxCheckBoxBase::Create(parent, id, pos, size, style, validator, name) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_labelOrig = m_label = label ;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateCheckBox( this, parent, id, label, pos, size, style, GetExtraStyle() ) ;
|
||||||
|
|
||||||
|
MacPostControlCreate(pos, size) ;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wxCheckBox::SetValue(bool val)
|
||||||
|
{
|
||||||
|
if (val)
|
||||||
|
Set3StateValue(wxCHK_CHECKED);
|
||||||
|
else
|
||||||
|
Set3StateValue(wxCHK_UNCHECKED);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxCheckBox::GetValue() const
|
||||||
|
{
|
||||||
|
return (DoGet3StateValue() != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxCheckBox::Command(wxCommandEvent & event)
|
||||||
|
{
|
||||||
|
int state = event.GetInt();
|
||||||
|
|
||||||
|
wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED)
|
||||||
|
|| (state == wxCHK_UNDETERMINED),
|
||||||
|
wxT("event.GetInt() returned an invalid checkbox state") );
|
||||||
|
|
||||||
|
Set3StateValue((wxCheckBoxState)state);
|
||||||
|
|
||||||
|
ProcessCommand(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCheckBoxState wxCheckBox::DoGet3StateValue() const
|
||||||
|
{
|
||||||
|
return (wxCheckBoxState)m_peer->GetValue() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxCheckBox::DoSet3StateValue(wxCheckBoxState val)
|
||||||
|
{
|
||||||
|
m_peer->SetValue( val ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxCheckBox::HandleClicked( double timestampsec )
|
||||||
|
{
|
||||||
|
wxCheckBoxState origState, newState;
|
||||||
|
|
||||||
|
newState = origState = Get3StateValue();
|
||||||
|
|
||||||
|
switch (origState)
|
||||||
|
{
|
||||||
|
case wxCHK_UNCHECKED:
|
||||||
|
newState = wxCHK_CHECKED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxCHK_CHECKED:
|
||||||
|
// If the style flag to allow the user setting the undetermined state is set,
|
||||||
|
// then set the state to undetermined; otherwise set state to unchecked.
|
||||||
|
newState = Is3rdStateAllowedForUser() ? wxCHK_UNDETERMINED : wxCHK_UNCHECKED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxCHK_UNDETERMINED:
|
||||||
|
newState = wxCHK_UNCHECKED;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newState != origState)
|
||||||
|
{
|
||||||
|
Set3StateValue( newState );
|
||||||
|
|
||||||
|
wxCommandEvent event( wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
|
||||||
|
event.SetInt( newState );
|
||||||
|
event.SetEventObject( this );
|
||||||
|
ProcessCommand( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bitmap checkbox
|
||||||
|
bool wxBitmapCheckBox::Create(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxBitmap *WXUNUSED(label),
|
||||||
|
const wxPoint& WXUNUSED(pos),
|
||||||
|
const wxSize& WXUNUSED(size),
|
||||||
|
long style,
|
||||||
|
const wxValidator& wxVALIDATOR_PARAM(validator),
|
||||||
|
const wxString& name)
|
||||||
|
{
|
||||||
|
SetName(name);
|
||||||
|
#if wxUSE_VALIDATORS
|
||||||
|
SetValidator(validator);
|
||||||
|
#endif
|
||||||
|
m_windowStyle = style;
|
||||||
|
|
||||||
|
if (parent)
|
||||||
|
parent->AddChild(this);
|
||||||
|
|
||||||
|
if ( id == -1 )
|
||||||
|
m_windowId = NewControlId();
|
||||||
|
else
|
||||||
|
m_windowId = id;
|
||||||
|
|
||||||
|
// TODO: Create the bitmap checkbox
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBitmapCheckBox::SetLabel(const wxBitmap *WXUNUSED(bitmap))
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
wxFAIL_MSG(wxT("wxBitmapCheckBox::SetLabel() not yet implemented"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBitmapCheckBox::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||||
|
{
|
||||||
|
wxControl::SetSize( x , y , width , height , sizeFlags ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBitmapCheckBox::SetValue(bool WXUNUSED(val))
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
wxFAIL_MSG(wxT("wxBitmapCheckBox::SetValue() not yet implemented"));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBitmapCheckBox::GetValue() const
|
||||||
|
{
|
||||||
|
// TODO
|
||||||
|
wxFAIL_MSG(wxT("wxBitmapCheckBox::GetValue() not yet implemented"));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
545
src/osx/notebook_osx.cpp
Normal file
545
src/osx/notebook_osx.cpp
Normal file
@@ -0,0 +1,545 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/osx/notebook_osx.cpp
|
||||||
|
// Purpose: implementation of wxNotebook
|
||||||
|
// Author: Stefan Csomor
|
||||||
|
// Modified by:
|
||||||
|
// Created: 1998-01-01
|
||||||
|
// RCS-ID: $Id: notebmac.cpp 55079 2008-08-13 14:56:42Z PC $
|
||||||
|
// Copyright: (c) Stefan Csomor
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#if wxUSE_NOTEBOOK
|
||||||
|
|
||||||
|
#include "wx/notebook.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/string.h"
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include "wx/app.h"
|
||||||
|
#include "wx/image.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/string.h"
|
||||||
|
#include "wx/imaglist.h"
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
|
|
||||||
|
// check that the page index is valid
|
||||||
|
#define IS_VALID_PAGE(nPage) ((nPage) < GetPageCount())
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
|
||||||
|
EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
|
||||||
|
|
||||||
|
EVT_SIZE(wxNotebook::OnSize)
|
||||||
|
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
|
||||||
|
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
|
||||||
|
|
||||||
|
|
||||||
|
// common part of all ctors
|
||||||
|
void wxNotebook::Init()
|
||||||
|
{
|
||||||
|
m_nSelection = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// default for dynamic class
|
||||||
|
wxNotebook::wxNotebook()
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
// the same arguments as for wxControl
|
||||||
|
wxNotebook::wxNotebook( wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxString& name )
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
|
Create( parent, id, pos, size, style, name );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxNotebook::Create( wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxString& name )
|
||||||
|
{
|
||||||
|
m_macIsUserPane = false ;
|
||||||
|
|
||||||
|
if (! (style & wxBK_ALIGN_MASK))
|
||||||
|
style |= wxBK_TOP;
|
||||||
|
|
||||||
|
if ( !wxNotebookBase::Create( parent, id, pos, size, style, name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateTabView(this,parent, id, pos, size, style, GetExtraStyle() );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// dtor
|
||||||
|
wxNotebook::~wxNotebook()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxNotebook accessors
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxNotebook::SetPadding(const wxSize& WXUNUSED(padding))
|
||||||
|
{
|
||||||
|
// unsupported by OS
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz))
|
||||||
|
{
|
||||||
|
// unsupported by OS
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxNotebook::SetPageSize(const wxSize& size)
|
||||||
|
{
|
||||||
|
SetSize( CalcSizeFromPage( size ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
|
||||||
|
{
|
||||||
|
return DoGetSizeFromClientSize( sizePage );
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxNotebook::DoSetSelection(size_t nPage, int flags)
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("DoSetSelection: invalid notebook page") );
|
||||||
|
|
||||||
|
if ( m_nSelection == wxNOT_FOUND || nPage != (size_t)m_nSelection )
|
||||||
|
{
|
||||||
|
if ( flags & SetSelection_SendEvent )
|
||||||
|
{
|
||||||
|
if ( !SendPageChangingEvent(nPage) )
|
||||||
|
{
|
||||||
|
// vetoed by program
|
||||||
|
return m_nSelection;
|
||||||
|
}
|
||||||
|
//else: program allows the page change
|
||||||
|
|
||||||
|
SendPageChangedEvent(m_nSelection, nPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
ChangePage(m_nSelection, nPage);
|
||||||
|
}
|
||||||
|
//else: no change
|
||||||
|
|
||||||
|
return m_nSelection;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("SetPageText: invalid notebook page") );
|
||||||
|
|
||||||
|
wxNotebookPage *page = m_pages[nPage];
|
||||||
|
page->SetLabel(wxStripMenuCodes(strText));
|
||||||
|
MacSetupTabs();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxNotebook::GetPageText(size_t nPage) const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("GetPageText: invalid notebook page") );
|
||||||
|
|
||||||
|
wxNotebookPage *page = m_pages[nPage];
|
||||||
|
|
||||||
|
return page->GetLabel();
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxNotebook::GetPageImage(size_t nPage) const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("GetPageImage: invalid notebook page") );
|
||||||
|
|
||||||
|
return m_images[nPage];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxNotebook::SetPageImage(size_t nPage, int nImage)
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( IS_VALID_PAGE(nPage), false,
|
||||||
|
wxT("SetPageImage: invalid notebook page") );
|
||||||
|
wxCHECK_MSG( m_imageList && nImage < m_imageList->GetImageCount(), false,
|
||||||
|
wxT("SetPageImage: invalid image index") );
|
||||||
|
|
||||||
|
if ( nImage != m_images[nPage] )
|
||||||
|
{
|
||||||
|
// if the item didn't have an icon before or, on the contrary, did have
|
||||||
|
// it but has lost it now, its size will change - but if the icon just
|
||||||
|
// changes, it won't
|
||||||
|
m_images[nPage] = nImage;
|
||||||
|
|
||||||
|
MacSetupTabs() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxNotebook operations
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// remove one page from the notebook, without deleting the window
|
||||||
|
wxNotebookPage* wxNotebook::DoRemovePage(size_t nPage)
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( IS_VALID_PAGE(nPage), NULL,
|
||||||
|
wxT("DoRemovePage: invalid notebook page") );
|
||||||
|
|
||||||
|
wxNotebookPage* page = m_pages[nPage] ;
|
||||||
|
m_pages.RemoveAt(nPage);
|
||||||
|
|
||||||
|
MacSetupTabs();
|
||||||
|
|
||||||
|
if (m_nSelection >= (int)GetPageCount())
|
||||||
|
m_nSelection = GetPageCount() - 1;
|
||||||
|
|
||||||
|
if (m_nSelection >= 0)
|
||||||
|
m_pages[m_nSelection]->Show(true);
|
||||||
|
|
||||||
|
InvalidateBestSize();
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove all pages
|
||||||
|
bool wxNotebook::DeleteAllPages()
|
||||||
|
{
|
||||||
|
WX_CLEAR_ARRAY(m_pages) ;
|
||||||
|
MacSetupTabs();
|
||||||
|
m_nSelection = -1 ;
|
||||||
|
InvalidateBestSize();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// same as AddPage() but does it at given position
|
||||||
|
bool wxNotebook::InsertPage(size_t nPage,
|
||||||
|
wxNotebookPage *pPage,
|
||||||
|
const wxString& strText,
|
||||||
|
bool bSelect,
|
||||||
|
int imageId )
|
||||||
|
{
|
||||||
|
if ( !wxNotebookBase::InsertPage( nPage, pPage, strText, bSelect, imageId ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
wxASSERT_MSG( pPage->GetParent() == this, wxT("notebook pages must have notebook as parent") );
|
||||||
|
|
||||||
|
// don't show pages by default (we'll need to adjust their size first)
|
||||||
|
pPage->Show( false ) ;
|
||||||
|
|
||||||
|
pPage->SetLabel( wxStripMenuCodes(strText) );
|
||||||
|
|
||||||
|
m_images.Insert( imageId, nPage );
|
||||||
|
|
||||||
|
MacSetupTabs();
|
||||||
|
|
||||||
|
wxRect rect = GetPageRect() ;
|
||||||
|
pPage->SetSize( rect );
|
||||||
|
if ( pPage->GetAutoLayout() )
|
||||||
|
pPage->Layout();
|
||||||
|
|
||||||
|
// now deal with the selection
|
||||||
|
// ---------------------------
|
||||||
|
|
||||||
|
// if the inserted page is before the selected one, we must update the
|
||||||
|
// index of the selected page
|
||||||
|
|
||||||
|
if ( int(nPage) <= m_nSelection )
|
||||||
|
{
|
||||||
|
m_nSelection++;
|
||||||
|
|
||||||
|
// while this still is the same page showing, we need to update the tabs
|
||||||
|
m_peer->SetValue( m_nSelection + 1 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// some page should be selected: either this one or the first one if there
|
||||||
|
// is still no selection
|
||||||
|
int selNew = -1;
|
||||||
|
if ( bSelect )
|
||||||
|
selNew = nPage;
|
||||||
|
else if ( m_nSelection == -1 )
|
||||||
|
selNew = 0;
|
||||||
|
|
||||||
|
if ( selNew != -1 )
|
||||||
|
SetSelection( selNew );
|
||||||
|
|
||||||
|
InvalidateBestSize();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxNotebook::HitTest(const wxPoint& pt, long * flags) const
|
||||||
|
{
|
||||||
|
int resultV = wxNOT_FOUND;
|
||||||
|
#if 0
|
||||||
|
const int countPages = GetPageCount();
|
||||||
|
|
||||||
|
// we have to convert from Client to Window relative coordinates
|
||||||
|
wxPoint adjustedPt = pt + GetClientAreaOrigin();
|
||||||
|
// and now to HIView native ones
|
||||||
|
adjustedPt.x -= MacGetLeftBorderSize() ;
|
||||||
|
adjustedPt.y -= MacGetTopBorderSize() ;
|
||||||
|
|
||||||
|
HIPoint hipoint= { adjustedPt.x , adjustedPt.y } ;
|
||||||
|
HIViewPartCode outPart = 0 ;
|
||||||
|
OSStatus err = HIViewGetPartHit( m_peer->GetControlRef(), &hipoint, &outPart );
|
||||||
|
|
||||||
|
int max = m_peer->GetMaximum() ;
|
||||||
|
if ( outPart == 0 && max > 0 )
|
||||||
|
{
|
||||||
|
// this is a hack, as unfortunately a hit on an already selected tab returns 0,
|
||||||
|
// so we have to go some extra miles to make sure we select something different
|
||||||
|
// and try again ..
|
||||||
|
int val = m_peer->GetValue() ;
|
||||||
|
int maxval = max ;
|
||||||
|
if ( max == 1 )
|
||||||
|
{
|
||||||
|
m_peer->SetMaximum( 2 ) ;
|
||||||
|
maxval = 2 ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( val == 1 )
|
||||||
|
m_peer->SetValue( maxval ) ;
|
||||||
|
else
|
||||||
|
m_peer->SetValue( 1 ) ;
|
||||||
|
|
||||||
|
err = HIViewGetPartHit( m_peer->GetControlRef(), &hipoint, &outPart );
|
||||||
|
|
||||||
|
m_peer->SetValue( val ) ;
|
||||||
|
if ( max == 1 )
|
||||||
|
m_peer->SetMaximum( 1 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( outPart >= 1 && outPart <= countPages )
|
||||||
|
resultV = outPart - 1 ;
|
||||||
|
|
||||||
|
if (flags != NULL)
|
||||||
|
{
|
||||||
|
*flags = 0;
|
||||||
|
|
||||||
|
// we cannot differentiate better
|
||||||
|
if (resultV >= 0)
|
||||||
|
*flags |= wxBK_HITTEST_ONLABEL;
|
||||||
|
else
|
||||||
|
*flags |= wxBK_HITTEST_NOWHERE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return resultV;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Added by Mark Newsam
|
||||||
|
// When a page is added or deleted to the notebook this function updates
|
||||||
|
// information held in the control so that it matches the order
|
||||||
|
// the user would expect.
|
||||||
|
//
|
||||||
|
void wxNotebook::MacSetupTabs()
|
||||||
|
{
|
||||||
|
m_peer->SetupTabs(*this);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRect wxNotebook::GetPageRect() const
|
||||||
|
{
|
||||||
|
wxSize size = GetClientSize() ;
|
||||||
|
|
||||||
|
return wxRect( 0 , 0 , size.x , size.y ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxNotebook callbacks
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// @@@ OnSize() is used for setting the font when it's called for the first
|
||||||
|
// time because doing it in ::Create() doesn't work (for unknown reasons)
|
||||||
|
void wxNotebook::OnSize(wxSizeEvent& event)
|
||||||
|
{
|
||||||
|
unsigned int nCount = m_pages.Count();
|
||||||
|
wxRect rect = GetPageRect() ;
|
||||||
|
|
||||||
|
for ( unsigned int nPage = 0; nPage < nCount; nPage++ )
|
||||||
|
{
|
||||||
|
wxNotebookPage *pPage = m_pages[nPage];
|
||||||
|
pPage->SetSize(rect);
|
||||||
|
if ( pPage->GetAutoLayout() )
|
||||||
|
pPage->Layout();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Processing continues to next OnSize
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxNotebook::OnSelChange(wxBookCtrlEvent& event)
|
||||||
|
{
|
||||||
|
// is it our tab control?
|
||||||
|
if ( event.GetEventObject() == this )
|
||||||
|
ChangePage(event.GetOldSelection(), event.GetSelection());
|
||||||
|
|
||||||
|
// we want to give others a chance to process this message as well
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxNotebook::OnSetFocus(wxFocusEvent& event)
|
||||||
|
{
|
||||||
|
// set focus to the currently selected page if any
|
||||||
|
if ( m_nSelection != -1 )
|
||||||
|
m_pages[m_nSelection]->SetFocus();
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event)
|
||||||
|
{
|
||||||
|
if ( event.IsWindowChange() )
|
||||||
|
{
|
||||||
|
// change pages
|
||||||
|
AdvanceSelection( event.GetDirection() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we get this event in 2 cases
|
||||||
|
//
|
||||||
|
// a) one of our pages might have generated it because the user TABbed
|
||||||
|
// out from it in which case we should propagate the event upwards and
|
||||||
|
// our parent will take care of setting the focus to prev/next sibling
|
||||||
|
//
|
||||||
|
// or
|
||||||
|
//
|
||||||
|
// b) the parent panel wants to give the focus to us so that we
|
||||||
|
// forward it to our selected page. We can't deal with this in
|
||||||
|
// OnSetFocus() because we don't know which direction the focus came
|
||||||
|
// from in this case and so can't choose between setting the focus to
|
||||||
|
// first or last panel child
|
||||||
|
wxWindow *parent = GetParent();
|
||||||
|
|
||||||
|
// the cast is here to fix a GCC ICE
|
||||||
|
if ( ((wxWindow*)event.GetEventObject()) == parent )
|
||||||
|
{
|
||||||
|
// no, it doesn't come from child, case (b): forward to a page
|
||||||
|
if ( m_nSelection != -1 )
|
||||||
|
{
|
||||||
|
// so that the page knows that the event comes from it's parent
|
||||||
|
// and is being propagated downwards
|
||||||
|
event.SetEventObject( this );
|
||||||
|
|
||||||
|
wxWindow *page = m_pages[m_nSelection];
|
||||||
|
if ( !page->HandleWindowEvent( event ) )
|
||||||
|
{
|
||||||
|
page->SetFocus();
|
||||||
|
}
|
||||||
|
//else: page manages focus inside it itself
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// we have no pages - still have to give focus to _something_
|
||||||
|
SetFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// it comes from our child, case (a), pass to the parent
|
||||||
|
if ( parent )
|
||||||
|
{
|
||||||
|
event.SetCurrentFocus( this );
|
||||||
|
parent->HandleWindowEvent( event );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxNotebook base class virtuals
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_CONSTRAINTS
|
||||||
|
|
||||||
|
// override these 2 functions to do nothing: everything is done in OnSize
|
||||||
|
|
||||||
|
void wxNotebook::SetConstraintSizes(bool WXUNUSED(recurse))
|
||||||
|
{
|
||||||
|
// don't set the sizes of the pages - their correct size is not yet known
|
||||||
|
wxControl::SetConstraintSizes( false );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxNotebook::DoPhase(int WXUNUSED(nPhase))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_CONSTRAINTS
|
||||||
|
|
||||||
|
void wxNotebook::Command(wxCommandEvent& WXUNUSED(event))
|
||||||
|
{
|
||||||
|
wxFAIL_MSG(wxT("wxNotebook::Command not implemented"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxNotebook helper functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// hide the currently active panel and show the new one
|
||||||
|
void wxNotebook::ChangePage(int nOldSel, int nSel)
|
||||||
|
{
|
||||||
|
if (nOldSel == nSel)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( nOldSel != -1 )
|
||||||
|
m_pages[nOldSel]->Show( false );
|
||||||
|
|
||||||
|
if ( nSel != -1 )
|
||||||
|
{
|
||||||
|
wxNotebookPage *pPage = m_pages[nSel];
|
||||||
|
pPage->Show( true );
|
||||||
|
pPage->SetFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_nSelection = nSel;
|
||||||
|
m_peer->SetValue( m_nSelection + 1 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxNotebook::HandleClicked( double timestampsec )
|
||||||
|
{
|
||||||
|
bool status = false ;
|
||||||
|
|
||||||
|
SInt32 newSel = m_peer->GetValue() - 1 ;
|
||||||
|
if ( newSel != m_nSelection )
|
||||||
|
{
|
||||||
|
wxBookCtrlEvent changing(
|
||||||
|
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId,
|
||||||
|
newSel , m_nSelection );
|
||||||
|
changing.SetEventObject( this );
|
||||||
|
HandleWindowEvent( changing );
|
||||||
|
|
||||||
|
if ( changing.IsAllowed() )
|
||||||
|
{
|
||||||
|
wxBookCtrlEvent event(
|
||||||
|
wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_windowId,
|
||||||
|
newSel, m_nSelection );
|
||||||
|
event.SetEventObject( this );
|
||||||
|
HandleWindowEvent( event );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_peer->SetValue( m_nSelection + 1 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
return status ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
172
src/osx/radiobut_osx.cpp
Normal file
172
src/osx/radiobut_osx.cpp
Normal file
@@ -0,0 +1,172 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: radiobut.cpp
|
||||||
|
// Purpose: wxRadioButton
|
||||||
|
// Author: AUTHOR
|
||||||
|
// Modified by: JS Lair (99/11/15) adding the cyclic group notion for radiobox
|
||||||
|
// Created: ??/??/98
|
||||||
|
// RCS-ID: $Id: radiobut.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||||
|
// Copyright: (c) AUTHOR
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#if wxUSE_RADIOBTN
|
||||||
|
|
||||||
|
#include "wx/radiobut.h"
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_labelOrig = m_label = label;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateRadioButton( this, parent, id, label, pos, size, style, GetExtraStyle() );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
|
m_cycle = this;
|
||||||
|
|
||||||
|
if (HasFlag( wxRB_GROUP ))
|
||||||
|
{
|
||||||
|
AddInCycle( NULL );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 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 ) ))
|
||||||
|
{
|
||||||
|
chief = (wxRadioButton*)child;
|
||||||
|
if (child->HasFlag( wxRB_GROUP ))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
node = node->GetPrevious();
|
||||||
|
}
|
||||||
|
|
||||||
|
AddInCycle( chief );
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRadioButton::~wxRadioButton()
|
||||||
|
{
|
||||||
|
RemoveFromCycle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxRadioButton::SetValue(bool val)
|
||||||
|
{
|
||||||
|
wxRadioButton *cycle;
|
||||||
|
if (m_peer->GetValue() == val)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_peer->SetValue( val );
|
||||||
|
if (val)
|
||||||
|
{
|
||||||
|
cycle = this->NextInCycle();
|
||||||
|
if (cycle != NULL)
|
||||||
|
{
|
||||||
|
while (cycle != this)
|
||||||
|
{
|
||||||
|
cycle->SetValue( false );
|
||||||
|
cycle = cycle->NextInCycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxRadioButton::GetValue() const
|
||||||
|
{
|
||||||
|
return m_peer->GetValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxRadioButton::Command(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
SetValue( (event.GetInt() != 0) );
|
||||||
|
ProcessCommand( event );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxRadioButton::HandleClicked( double timestampsec )
|
||||||
|
{
|
||||||
|
// if already set -> no action
|
||||||
|
if (GetValue())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
wxRadioButton *cycle;
|
||||||
|
cycle = this->NextInCycle();
|
||||||
|
if (cycle != NULL)
|
||||||
|
{
|
||||||
|
while (cycle != this)
|
||||||
|
{
|
||||||
|
if (cycle->GetValue())
|
||||||
|
cycle->SetValue( false );
|
||||||
|
|
||||||
|
cycle = cycle->NextInCycle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SetValue( true );
|
||||||
|
|
||||||
|
wxCommandEvent event2( wxEVT_COMMAND_RADIOBUTTON_SELECTED, m_windowId );
|
||||||
|
event2.SetEventObject( this );
|
||||||
|
event2.SetInt( true );
|
||||||
|
ProcessCommand( event2 );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRadioButton *wxRadioButton::AddInCycle(wxRadioButton *cycle)
|
||||||
|
{
|
||||||
|
wxRadioButton *current;
|
||||||
|
|
||||||
|
if (cycle == NULL)
|
||||||
|
{
|
||||||
|
m_cycle = this;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current = cycle;
|
||||||
|
while (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))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 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
|
69
src/osx/statbox_osx.cpp
Normal file
69
src/osx/statbox_osx.cpp
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/osx/statbox_osx.cpp
|
||||||
|
// Purpose: wxStaticBox
|
||||||
|
// Author: Stefan Csomor
|
||||||
|
// Modified by:
|
||||||
|
// Created: 1998-01-01
|
||||||
|
// RCS-ID: $Id: statbox.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||||
|
// Copyright: (c) Stefan Csomor
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#if wxUSE_STATBOX
|
||||||
|
|
||||||
|
#include "wx/statbox.h"
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
|
||||||
|
|
||||||
|
bool wxStaticBox::Create( wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxString& name )
|
||||||
|
{
|
||||||
|
m_macIsUserPane = false;
|
||||||
|
|
||||||
|
if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_labelOrig = m_label = label;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
|
||||||
|
{
|
||||||
|
static int extraTop = -1; // Uninitted
|
||||||
|
static int other = 5;
|
||||||
|
|
||||||
|
if ( extraTop == -1 )
|
||||||
|
{
|
||||||
|
// The minimal border used for the top.
|
||||||
|
// Later on, the staticbox's font height is added to this.
|
||||||
|
extraTop = 0;
|
||||||
|
|
||||||
|
// As indicated by the HIG, Panther needs an extra border of 11
|
||||||
|
// pixels (otherwise overlapping occurs at the top). The "other"
|
||||||
|
// border has to be 11.
|
||||||
|
extraTop = 11;
|
||||||
|
other = 11;
|
||||||
|
}
|
||||||
|
|
||||||
|
*borderTop = extraTop;
|
||||||
|
if ( !m_label.empty() )
|
||||||
|
*borderTop += GetCharHeight();
|
||||||
|
|
||||||
|
*borderOther = other;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_STATBOX
|
||||||
|
|
66
src/osx/statline_osx.cpp
Normal file
66
src/osx/statline_osx.cpp
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/mac/carbon/statlmac.cpp
|
||||||
|
// Purpose: a generic wxStaticLine class
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Created: 28.06.99
|
||||||
|
// Version: $Id: statlmac.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||||
|
// Copyright: (c) 1998 Vadim Zeitlin
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_STATLINE
|
||||||
|
|
||||||
|
#include "wx/statline.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/statbox.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/osx/private.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)
|
||||||
|
{
|
||||||
|
m_macIsUserPane = false ;
|
||||||
|
|
||||||
|
if ( !wxStaticLineBase::Create(parent, id, pos, size,
|
||||||
|
style, wxDefaultValidator, name) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateStaticLine( this, parent, id, pos, size, style, GetExtraStyle() );
|
||||||
|
|
||||||
|
MacPostControlCreate(pos,size) ;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //wxUSE_STATLINE
|
124
src/osx/stattext_osx.cpp
Normal file
124
src/osx/stattext_osx.cpp
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/mac/carbon/stattext.cpp
|
||||||
|
// Purpose: wxStaticText
|
||||||
|
// Author: Stefan Csomor
|
||||||
|
// Modified by:
|
||||||
|
// Created: 04/01/98
|
||||||
|
// RCS-ID: $Id: stattext.cpp 54845 2008-07-30 14:52:41Z SC $
|
||||||
|
// Copyright: (c) Stefan Csomor
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#if wxUSE_STATTEXT
|
||||||
|
|
||||||
|
#include "wx/stattext.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/app.h"
|
||||||
|
#include "wx/utils.h"
|
||||||
|
#include "wx/dc.h"
|
||||||
|
#include "wx/dcclient.h"
|
||||||
|
#include "wx/settings.h"
|
||||||
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
|
#include "wx/notebook.h"
|
||||||
|
#include "wx/tabctrl.h"
|
||||||
|
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
|
||||||
|
|
||||||
|
|
||||||
|
bool wxStaticText::Create( wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size,
|
||||||
|
long style,
|
||||||
|
const wxString& name )
|
||||||
|
{
|
||||||
|
m_macIsUserPane = false;
|
||||||
|
|
||||||
|
if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateStaticText( this, parent, id, label, pos, size, style, GetExtraStyle() );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
|
SetLabel(label);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxStaticText::SetLabel(const wxString& label)
|
||||||
|
{
|
||||||
|
m_labelOrig = label;
|
||||||
|
|
||||||
|
// middle/end ellipsization is handled by the OS:
|
||||||
|
if ( HasFlag(wxST_ELLIPSIZE_END) || HasFlag(wxST_ELLIPSIZE_MIDDLE) )
|
||||||
|
{
|
||||||
|
// remove markup
|
||||||
|
wxString str(label);
|
||||||
|
if (HasFlag(wxST_MARKUP))
|
||||||
|
str = RemoveMarkup(label);
|
||||||
|
|
||||||
|
// and leave ellipsization to the OS
|
||||||
|
DoSetLabel(str);
|
||||||
|
}
|
||||||
|
else // not supported natively
|
||||||
|
{
|
||||||
|
DoSetLabel(GetEllipsizedLabelWithoutMarkup());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) &&
|
||||||
|
!IsEllipsized() ) // don't resize if we adjust to current size
|
||||||
|
{
|
||||||
|
InvalidateBestSize();
|
||||||
|
SetSize( GetBestSize() );
|
||||||
|
}
|
||||||
|
|
||||||
|
Refresh();
|
||||||
|
|
||||||
|
// we shouldn't need forced updates
|
||||||
|
// Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxStaticText::SetFont(const wxFont& font)
|
||||||
|
{
|
||||||
|
bool ret = wxControl::SetFont( font );
|
||||||
|
|
||||||
|
if ( ret )
|
||||||
|
{
|
||||||
|
if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
|
||||||
|
{
|
||||||
|
InvalidateBestSize();
|
||||||
|
SetSize( GetBestSize() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxStaticText::DoSetLabel(const wxString& label)
|
||||||
|
{
|
||||||
|
m_labelOrig = label;
|
||||||
|
m_label = RemoveMnemonics(label);
|
||||||
|
m_peer->SetLabel(m_label , GetFont().GetEncoding() );
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxStaticText::DoGetLabel() const
|
||||||
|
{
|
||||||
|
return m_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
|
||||||
|
to allow correct dynamic ellipsizing of the label
|
||||||
|
*/
|
||||||
|
|
||||||
|
#endif //if wxUSE_STATTEXT
|
190
src/osx/tabctrl_osx.cpp
Normal file
190
src/osx/tabctrl_osx.cpp
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/osx/tabctrl_osx.cpp
|
||||||
|
// Purpose: wxTabCtrl
|
||||||
|
// Author: Stefan Csomor
|
||||||
|
// Modified by:
|
||||||
|
// Created: 1998-01-01
|
||||||
|
// RCS-ID: $Id: tabctrl.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||||
|
// Copyright: (c) Stefan Csomor
|
||||||
|
// Licence: wxWindows licence
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#if wxUSE_TAB_DIALOG
|
||||||
|
|
||||||
|
#include "wx/tabctrl.h"
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/control.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxTabCtrl, wxControl)
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxTabEvent, wxNotifyEvent)
|
||||||
|
|
||||||
|
// this control has been superseeded by the native wxNotebook implementation, but
|
||||||
|
// we leave the skeleton here, just in case it might become useful ...
|
||||||
|
|
||||||
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TAB_SEL_CHANGED)
|
||||||
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TAB_SEL_CHANGING)
|
||||||
|
|
||||||
|
|
||||||
|
BEGIN_EVENT_TABLE(wxTabCtrl, wxControl)
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
wxTabCtrl::wxTabCtrl()
|
||||||
|
{
|
||||||
|
m_macIsUserPane = false;
|
||||||
|
m_imageList = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTabCtrl::Create( wxWindow *parent,
|
||||||
|
wxWindowID id, const wxPoint& pos, const wxSize& size,
|
||||||
|
long style, const wxString& name )
|
||||||
|
{
|
||||||
|
m_macIsUserPane = false;
|
||||||
|
m_imageList = NULL;
|
||||||
|
|
||||||
|
if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateTabView( this, parent, id, pos, size, style, GetExtraStyle );
|
||||||
|
|
||||||
|
MacPostControlCreate( pos, size );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxTabCtrl::~wxTabCtrl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxTabCtrl::Command(wxCommandEvent& event)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTabCtrl::DeleteAllItems()
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTabCtrl::DeleteItem(int item)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxTabCtrl::GetSelection() const
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the tab with the current keyboard focus
|
||||||
|
//
|
||||||
|
int wxTabCtrl::GetCurFocus() const
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxImageList * wxTabCtrl::GetImageList() const
|
||||||
|
{
|
||||||
|
return m_imageList;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxTabCtrl::GetItemCount() const
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the rect corresponding to the tab
|
||||||
|
bool wxTabCtrl::GetItemRect(int item, wxRect& wxrect) const
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxTabCtrl::GetRowCount() const
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxTabCtrl::GetItemText(int item) const
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxTabCtrl::GetItemImage(int item) const
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* wxTabCtrl::GetItemData(int item) const
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxTabCtrl::HitTest(const wxPoint& pt, long& flags)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTabCtrl::InsertItem(int item, const wxString& text, int imageId, void* data)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxTabCtrl::SetSelection(int item)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxTabCtrl::SetImageList(wxImageList* imageList)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTabCtrl::SetItemText(int item, const wxString& text)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTabCtrl::SetItemImage(int item, int image)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTabCtrl::SetItemData(int item, void* data)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the size for a fixed-width tab control
|
||||||
|
void wxTabCtrl::SetItemSize(const wxSize& size)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the padding between tabs
|
||||||
|
void wxTabCtrl::SetPadding(const wxSize& padding)
|
||||||
|
{
|
||||||
|
// TODO:
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_TAB_DIALOG
|
162
src/osx/tglbtn_osx.cpp
Normal file
162
src/osx/tglbtn_osx.cpp
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/osx/tglbtn_osx.cpp
|
||||||
|
// Purpose: Definition of the wxToggleButton class, which implements a
|
||||||
|
// toggle button under wxMac.
|
||||||
|
// Author: Stefan Csomor
|
||||||
|
// Modified by:
|
||||||
|
// Created: 08.02.01
|
||||||
|
// RCS-ID: $Id: tglbtn.cpp 54129 2008-06-11 19:30:52Z SC $
|
||||||
|
// Copyright: (c) Stefan Csomor
|
||||||
|
// License: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declatations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#if wxUSE_TOGGLEBTN
|
||||||
|
|
||||||
|
#include "wx/tglbtn.h"
|
||||||
|
#include "wx/osx/private.h"
|
||||||
|
// Button
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
|
||||||
|
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxToggleButton
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxToggleButton::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 ;
|
||||||
|
|
||||||
|
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_labelOrig = m_label = label ;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateToggleButton( this, parent, id, label, pos, size, style, GetExtraStyle() ) ;
|
||||||
|
|
||||||
|
MacPostControlCreate(pos,size) ;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize wxToggleButton::DoGetBestSize() const
|
||||||
|
{
|
||||||
|
int wBtn = 70 ;
|
||||||
|
int hBtn = 20 ;
|
||||||
|
|
||||||
|
int lBtn = m_label.Length() * 8 + 12 ;
|
||||||
|
if (lBtn > wBtn)
|
||||||
|
wBtn = lBtn;
|
||||||
|
|
||||||
|
return wxSize ( wBtn , hBtn ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxToggleButton::SetValue(bool val)
|
||||||
|
{
|
||||||
|
m_peer->SetValue( val ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxToggleButton::GetValue() const
|
||||||
|
{
|
||||||
|
return m_peer->GetValue() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxToggleButton::Command(wxCommandEvent & event)
|
||||||
|
{
|
||||||
|
SetValue((event.GetInt() != 0));
|
||||||
|
ProcessCommand(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxToggleButton::HandleClicked( double timestampsec )
|
||||||
|
{
|
||||||
|
wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
|
||||||
|
event.SetInt(GetValue());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
ProcessCommand(event);
|
||||||
|
return true ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBitmapToggleButton
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxBitmapToggleButton, wxControl)
|
||||||
|
|
||||||
|
bool wxBitmapToggleButton::Create(wxWindow *parent, wxWindowID id,
|
||||||
|
const wxBitmap& label,
|
||||||
|
const wxPoint& pos,
|
||||||
|
const wxSize& size, long style,
|
||||||
|
const wxValidator& validator,
|
||||||
|
const wxString& name)
|
||||||
|
{
|
||||||
|
m_macIsUserPane = FALSE ;
|
||||||
|
|
||||||
|
m_bitmap = label;
|
||||||
|
|
||||||
|
if ( !wxControl::Create(parent, id, pos, size, style, validator, name) )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_peer = wxWidgetImpl::CreateBitmapToggleButton( this, parent, id, label, pos, size, style, GetExtraStyle() ) ;
|
||||||
|
|
||||||
|
MacPostControlCreate(pos,size) ;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxSize wxBitmapToggleButton::DoGetBestSize() const
|
||||||
|
{
|
||||||
|
if (!m_bitmap.IsOk())
|
||||||
|
return wxSize(20,20);
|
||||||
|
|
||||||
|
return wxSize ( m_bitmap.GetWidth()+6, m_bitmap.GetHeight()+6 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBitmapToggleButton::SetValue(bool val)
|
||||||
|
{
|
||||||
|
m_peer->SetValue( val ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBitmapToggleButton::GetValue() const
|
||||||
|
{
|
||||||
|
return m_peer->GetValue() ;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBitmapToggleButton::Command(wxCommandEvent & event)
|
||||||
|
{
|
||||||
|
SetValue((event.GetInt() != 0));
|
||||||
|
ProcessCommand(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBitmapToggleButton::HandleClicked( double timestampsec )
|
||||||
|
{
|
||||||
|
wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, m_windowId);
|
||||||
|
event.SetInt(GetValue());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
ProcessCommand(event);
|
||||||
|
return noErr ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_TOGGLEBTN
|
||||||
|
|
Reference in New Issue
Block a user