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/toplevel.h"
|
||||
#include "wx/tglbtn.h"
|
||||
|
||||
#include "wx/osx/private.h"
|
||||
|
||||
@@ -82,20 +83,14 @@
|
||||
- (NSControlSize)controlSize;
|
||||
@end
|
||||
|
||||
namespace
|
||||
wxButtonCocoaImpl::wxButtonCocoaImpl(wxWindowMac *wxpeer, wxNSButton *v)
|
||||
: wxWidgetCocoaImpl(wxpeer, v)
|
||||
{
|
||||
|
||||
class wxButtonCocoaImpl : public wxWidgetCocoaImpl, public wxButtonImpl
|
||||
{
|
||||
public:
|
||||
wxButtonCocoaImpl(wxWindowMac *wxpeer, wxNSButton *v)
|
||||
: wxWidgetCocoaImpl(wxpeer, v)
|
||||
{
|
||||
SetNeedsFrame(false);
|
||||
}
|
||||
}
|
||||
|
||||
virtual void SetBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
void wxButtonCocoaImpl::SetBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
// switch bezel style for plain pushbuttons
|
||||
if ( bitmap.IsOk() )
|
||||
{
|
||||
@@ -108,11 +103,11 @@ public:
|
||||
}
|
||||
|
||||
wxWidgetCocoaImpl::SetBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
#if wxUSE_MARKUP
|
||||
virtual void SetLabelMarkup(const wxString& markup)
|
||||
{
|
||||
void wxButtonCocoaImpl::SetLabelMarkup(const wxString& markup)
|
||||
{
|
||||
wxMarkupToAttrString toAttr(GetWXPeer(), markup);
|
||||
NSMutableAttributedString *attrString = toAttr.GetNSAttributedString();
|
||||
|
||||
@@ -126,18 +121,25 @@ public:
|
||||
[paragraphStyle release];
|
||||
|
||||
[GetNSButton() setAttributedTitle:attrString];
|
||||
}
|
||||
}
|
||||
#endif // wxUSE_MARKUP
|
||||
|
||||
void SetPressedBitmap( const wxBitmap& bitmap )
|
||||
{
|
||||
void wxButtonCocoaImpl::SetPressedBitmap( const wxBitmap& bitmap )
|
||||
{
|
||||
NSButton* button = GetNSButton();
|
||||
[button setAlternateImage: bitmap.GetNSImage()];
|
||||
if ( GetWXPeer()->IsKindOf(wxCLASSINFO(wxToggleButton)) )
|
||||
{
|
||||
[button setButtonType:NSToggleButton];
|
||||
}
|
||||
else
|
||||
{
|
||||
[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;
|
||||
NSControlSize size = NSRegularControlSize;
|
||||
if ( [m_osxView respondsToSelector:@selector(controlSize)] )
|
||||
@@ -170,10 +172,10 @@ public:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SetAcceleratorFromLabel(const wxString& label)
|
||||
{
|
||||
void wxButtonCocoaImpl::SetAcceleratorFromLabel(const wxString& label)
|
||||
{
|
||||
const int accelPos = wxControl::FindAccelIndex(label);
|
||||
if ( accelPos != wxNOT_FOUND )
|
||||
{
|
||||
@@ -187,19 +189,14 @@ public:
|
||||
{
|
||||
[GetNSButton() setKeyEquivalent:@""];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
NSButton *GetNSButton() const
|
||||
{
|
||||
NSButton *wxButtonCocoaImpl::GetNSButton() const
|
||||
{
|
||||
wxASSERT( [m_osxView isKindOfClass:[NSButton class]] );
|
||||
|
||||
return static_cast<NSButton *>(m_osxView);
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
}
|
||||
|
||||
// Set the keyboard accelerator key from the label (e.g. "Click &Me")
|
||||
void wxButton::OSXSetAcceleratorFromLabel(const wxString& label)
|
||||
|
Reference in New Issue
Block a user