exposing common used button impl class
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72861 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "wx/button.h"
|
#include "wx/button.h"
|
||||||
#include "wx/toplevel.h"
|
#include "wx/toplevel.h"
|
||||||
|
#include "wx/tglbtn.h"
|
||||||
|
|
||||||
#include "wx/osx/private.h"
|
#include "wx/osx/private.h"
|
||||||
|
|
||||||
@@ -82,19 +83,13 @@
|
|||||||
- (NSControlSize)controlSize;
|
- (NSControlSize)controlSize;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
namespace
|
wxButtonCocoaImpl::wxButtonCocoaImpl(wxWindowMac *wxpeer, wxNSButton *v)
|
||||||
{
|
|
||||||
|
|
||||||
class wxButtonCocoaImpl : public wxWidgetCocoaImpl, public wxButtonImpl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxButtonCocoaImpl(wxWindowMac *wxpeer, wxNSButton *v)
|
|
||||||
: wxWidgetCocoaImpl(wxpeer, v)
|
: wxWidgetCocoaImpl(wxpeer, v)
|
||||||
{
|
{
|
||||||
SetNeedsFrame(false);
|
SetNeedsFrame(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void SetBitmap(const wxBitmap& bitmap)
|
void wxButtonCocoaImpl::SetBitmap(const wxBitmap& bitmap)
|
||||||
{
|
{
|
||||||
// switch bezel style for plain pushbuttons
|
// switch bezel style for plain pushbuttons
|
||||||
if ( bitmap.IsOk() )
|
if ( bitmap.IsOk() )
|
||||||
@@ -111,7 +106,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if wxUSE_MARKUP
|
#if wxUSE_MARKUP
|
||||||
virtual void SetLabelMarkup(const wxString& markup)
|
void wxButtonCocoaImpl::SetLabelMarkup(const wxString& markup)
|
||||||
{
|
{
|
||||||
wxMarkupToAttrString toAttr(GetWXPeer(), markup);
|
wxMarkupToAttrString toAttr(GetWXPeer(), markup);
|
||||||
NSMutableAttributedString *attrString = toAttr.GetNSAttributedString();
|
NSMutableAttributedString *attrString = toAttr.GetNSAttributedString();
|
||||||
@@ -129,14 +124,21 @@ public:
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_MARKUP
|
#endif // wxUSE_MARKUP
|
||||||
|
|
||||||
void SetPressedBitmap( const wxBitmap& bitmap )
|
void wxButtonCocoaImpl::SetPressedBitmap( const wxBitmap& bitmap )
|
||||||
{
|
{
|
||||||
NSButton* button = GetNSButton();
|
NSButton* button = GetNSButton();
|
||||||
[button setAlternateImage: bitmap.GetNSImage()];
|
[button setAlternateImage: bitmap.GetNSImage()];
|
||||||
|
if ( GetWXPeer()->IsKindOf(wxCLASSINFO(wxToggleButton)) )
|
||||||
|
{
|
||||||
|
[button setButtonType:NSToggleButton];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
[button setButtonType:NSMomentaryChangeButton];
|
[button setButtonType:NSMomentaryChangeButton];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
|
void wxButtonCocoaImpl::GetLayoutInset(int &left , int &top , int &right, int &bottom) const
|
||||||
{
|
{
|
||||||
left = top = right = bottom = 0;
|
left = top = right = bottom = 0;
|
||||||
NSControlSize size = NSRegularControlSize;
|
NSControlSize size = NSRegularControlSize;
|
||||||
@@ -172,7 +174,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAcceleratorFromLabel(const wxString& label)
|
void wxButtonCocoaImpl::SetAcceleratorFromLabel(const wxString& label)
|
||||||
{
|
{
|
||||||
const int accelPos = wxControl::FindAccelIndex(label);
|
const int accelPos = wxControl::FindAccelIndex(label);
|
||||||
if ( accelPos != wxNOT_FOUND )
|
if ( accelPos != wxNOT_FOUND )
|
||||||
@@ -189,17 +191,12 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NSButton *wxButtonCocoaImpl::GetNSButton() const
|
||||||
private:
|
|
||||||
NSButton *GetNSButton() const
|
|
||||||
{
|
{
|
||||||
wxASSERT( [m_osxView isKindOfClass:[NSButton class]] );
|
wxASSERT( [m_osxView isKindOfClass:[NSButton class]] );
|
||||||
|
|
||||||
return static_cast<NSButton *>(m_osxView);
|
return static_cast<NSButton *>(m_osxView);
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
} // anonymous namespace
|
|
||||||
|
|
||||||
// Set the keyboard accelerator key from the label (e.g. "Click &Me")
|
// Set the keyboard accelerator key from the label (e.g. "Click &Me")
|
||||||
void wxButton::OSXSetAcceleratorFromLabel(const wxString& label)
|
void wxButton::OSXSetAcceleratorFromLabel(const wxString& label)
|
||||||
|
Reference in New Issue
Block a user