const wxString& name = wxButtonNameStr);
protected:
+ void OnEnterWindow( wxMouseEvent& event);
+ void OnLeaveWindow( wxMouseEvent& event);
+
virtual wxSize DoGetBestSize() const;
virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
DECLARE_DYNAMIC_CLASS(wxBitmapButton)
+ DECLARE_EVENT_TABLE()
};
#endif // _WX_OSX_BMPBUTTN_H_
@interface wxNSButton : NSButton
{
+ NSTrackingRectTag rectTag;
}
@end
virtual void CheckSpelling(bool WXUNUSED(check)) { }
};
+//
+// common interface bitmapbuttons
+//
+
+class wxBitmapButtonImpl
+{
+ public :
+ wxBitmapButtonImpl(){}
+ virtual ~wxBitmapButtonImpl(){}
+
+ virtual void SetPressedBitmap( const wxBitmap& bitmap ) = 0;
+} ;
+
//
// common interface for search controls
//
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
+BEGIN_EVENT_TABLE(wxBitmapButton, wxButton)
+ EVT_ENTER_WINDOW(wxBitmapButton::OnEnterWindow)
+ EVT_LEAVE_WINDOW(wxBitmapButton::OnLeaveWindow)
+END_EVENT_TABLE()
+
#include "wx/osx/private.h"
//---------------------------------------------------------------------------
{
m_peer->SetBitmap( bitmap );
}
+ else if ( which == State_Pressed )
+ {
+ wxBitmapButtonImpl* bi = dynamic_cast<wxBitmapButtonImpl*> (m_peer);
+ if ( bi )
+ bi->SetPressedBitmap(bitmap);
+ }
}
wxSize wxBitmapButton::DoGetBestSize() const
return best;
}
+void wxBitmapButton::OnEnterWindow( wxMouseEvent& WXUNUSED(event))
+{
+ if ( DoGetBitmap( State_Current ).IsOk() )
+ m_peer->SetBitmap( DoGetBitmap( State_Current ) );
+}
+
+void wxBitmapButton::OnLeaveWindow( wxMouseEvent& WXUNUSED(event))
+{
+ if ( DoGetBitmap( State_Current ).IsOk() )
+ m_peer->SetBitmap( DoGetBitmap( State_Normal ) );
+}
+
#endif // wxUSE_BMPBUTTON
// define a derived class to override SetBitmap() and also to provide
// InitButtonContentInfo() helper used by CreateBitmapButton()
-class wxMacBitmapButton : public wxMacControl
+class wxMacBitmapButton : public wxMacControl, public wxBitmapButtonImpl
{
public:
wxMacBitmapButton(wxWindowMac* peer, const wxBitmap& bitmap, int style)
m_isIcon ? kControlContentIconRef : 0);
}
+ void SetPressedBitmap( const wxBitmap& WXUNUSED(bitmap) )
+ {
+ // not implemented under Carbon
+ }
+
private:
// helper function: returns true if the given bitmap is of one of standard
// sizes supported by OS X icons
#include "wx/osx/private.h"
+class wxBitmapButtonCocoaImpl : public wxWidgetCocoaImpl, public wxBitmapButtonImpl
+{
+ public :
+ wxBitmapButtonCocoaImpl( wxWindowMac* peer , WXWidget w) : wxWidgetCocoaImpl(peer,w)
+ {
+ }
+
+ void SetPressedBitmap( const wxBitmap& bitmap )
+ {
+ wxNSButton* button = (wxNSButton*) m_osxView;
+ [button setAlternateImage: bitmap.GetNSImage()];
+ [button setButtonType:NSMomentaryChangeButton];
+ }
+} ;
+
wxWidgetImplType* wxWidgetImpl::CreateBitmapButton( wxWindowMac* wxpeer,
wxWindowMac* WXUNUSED(parent),
wxWindowID WXUNUSED(id),
[v setImage:bitmap.GetNSImage() ];
[v setButtonType:NSMomentaryPushInButton];
- wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
+ wxWidgetCocoaImpl* c = new wxBitmapButtonCocoaImpl( wxpeer, v );
return c;
}
}
}
+- (void) setTrackingTag: (NSTrackingRectTag)tag
+{
+ rectTag = tag;
+}
+
+- (NSTrackingRectTag) trackingTag
+{
+ return rectTag;
+}
+
@end
namespace
if ( [m_osxView respondsToSelector:@selector(setImage:)] )
{
[m_osxView setImage:bitmap.GetNSImage()];
+ [m_osxView setNeedsDisplay:YES];
}
}