derive wxBitmapButton from wxBitmapButtonBase
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15293 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
33188aa47a
commit
d460ed4071
@ -22,47 +22,32 @@ WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
|
||||
|
||||
#define wxDEFAULT_BUTTON_MARGIN 4
|
||||
|
||||
class WXDLLEXPORT wxBitmapButton: public wxButton
|
||||
class WXDLLEXPORT wxBitmapButton: public wxBitmapButtonBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmapButton)
|
||||
public:
|
||||
inline wxBitmapButton() { m_marginX = wxDEFAULT_BUTTON_MARGIN; m_marginY = wxDEFAULT_BUTTON_MARGIN; }
|
||||
inline wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxButtonNameStr)
|
||||
{
|
||||
Create(parent, id, bitmap, pos, size, style, validator, name);
|
||||
}
|
||||
DECLARE_DYNAMIC_CLASS(wxBitmapButton)
|
||||
|
||||
bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxButtonNameStr);
|
||||
public:
|
||||
wxBitmapButton()
|
||||
{
|
||||
SetMargins(wxDEFAULT_BUTTON_MARGIN, wxDEFAULT_BUTTON_MARGIN);
|
||||
}
|
||||
|
||||
wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxButtonNameStr)
|
||||
{
|
||||
Create(parent, id, bitmap, pos, size, style, validator, name);
|
||||
}
|
||||
|
||||
virtual void SetLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
SetBitmapLabel(bitmap);
|
||||
}
|
||||
bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
|
||||
const wxValidator& validator = wxDefaultValidator,
|
||||
const wxString& name = wxButtonNameStr);
|
||||
|
||||
virtual void SetLabel( const wxString &name ) {}
|
||||
|
||||
virtual void SetBitmapLabel(const wxBitmap& bitmap);
|
||||
|
||||
inline wxBitmap& GetBitmapLabel() const { return (wxBitmap&) m_buttonBitmap; }
|
||||
inline wxBitmap& GetBitmapSelected() const { return (wxBitmap&) m_buttonBitmapSelected; }
|
||||
inline wxBitmap& GetBitmapFocus() const { return (wxBitmap&) m_buttonBitmapFocus; }
|
||||
inline wxBitmap& GetBitmapDisabled() const { return (wxBitmap&) m_buttonBitmapDisabled; }
|
||||
|
||||
inline void SetBitmapSelected(const wxBitmap& sel) { m_buttonBitmapSelected = sel; };
|
||||
inline void SetBitmapFocus(const wxBitmap& focus) { m_buttonBitmapFocus = focus; };
|
||||
inline void SetBitmapDisabled(const wxBitmap& disabled) { m_buttonBitmapDisabled = disabled; };
|
||||
|
||||
inline void SetMargins(int x, int y) { m_marginX = x; m_marginY = y; }
|
||||
inline int GetMarginX() { return m_marginX; }
|
||||
inline int GetMarginY() { return m_marginY; }
|
||||
virtual void SetBitmapLabel(const wxBitmap& bitmap);
|
||||
|
||||
/*
|
||||
// TODO: Implementation
|
||||
@ -71,14 +56,6 @@ class WXDLLEXPORT wxBitmapButton: public wxButton
|
||||
virtual void DrawButtonFocus( WXHDC dc, int left, int top, int right, int bottom, bool sel );
|
||||
virtual void DrawButtonDisable( WXHDC dc, int left, int top, int right, int bottom, bool with_marg );
|
||||
*/
|
||||
|
||||
protected:
|
||||
wxBitmap m_buttonBitmap;
|
||||
wxBitmap m_buttonBitmapSelected;
|
||||
wxBitmap m_buttonBitmapFocus;
|
||||
wxBitmap m_buttonBitmapDisabled;
|
||||
int m_marginX;
|
||||
int m_marginY;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -29,13 +29,13 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_buttonBitmap = bitmap;
|
||||
m_bmpNormal = bitmap;
|
||||
|
||||
m_marginX = 0;
|
||||
m_marginY = 0;
|
||||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
// int x = pos.x;
|
||||
// int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
|
||||
@ -52,8 +52,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_buttonBitmap = bitmap;
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||
m_bmpNormal = bitmap;
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
|
||||
|
||||
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
@ -64,7 +64,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
||||
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
|
||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||
if ( info.contentType != kControlNoContent )
|
||||
{
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
@ -76,13 +76,13 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
m_buttonBitmap = bitmap;
|
||||
m_bmpNormal = bitmap;
|
||||
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
|
||||
if ( info.contentType != kControlNoContent )
|
||||
{
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||
if ( info.contentType != kControlNoContent )
|
||||
{
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,13 +29,13 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_buttonBitmap = bitmap;
|
||||
m_bmpNormal = bitmap;
|
||||
|
||||
m_marginX = 0;
|
||||
m_marginY = 0;
|
||||
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
// int x = pos.x;
|
||||
// int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
|
||||
@ -52,8 +52,8 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
Rect bounds ;
|
||||
Str255 title ;
|
||||
m_buttonBitmap = bitmap;
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_buttonBitmap.GetRefData()) ;
|
||||
m_bmpNormal = bitmap;
|
||||
wxBitmapRefData * bmap = (wxBitmapRefData*) ( m_bmpNormal.GetRefData()) ;
|
||||
|
||||
MacPreControlCreate( parent , id , "" , pos , wxSize( width , height ) ,style, validator , name , &bounds , title ) ;
|
||||
|
||||
@ -64,7 +64,7 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
wxASSERT_MSG( (ControlHandle) m_macControl != NULL , "No valid mac control" ) ;
|
||||
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
|
||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||
if ( info.contentType != kControlNoContent )
|
||||
{
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
@ -76,13 +76,13 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
|
||||
|
||||
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
m_buttonBitmap = bitmap;
|
||||
m_bmpNormal = bitmap;
|
||||
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_buttonBitmap ) ;
|
||||
if ( info.contentType != kControlNoContent )
|
||||
{
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
ControlButtonContentInfo info ;
|
||||
wxMacCreateBitmapButton( &info , m_bmpNormal ) ;
|
||||
if ( info.contentType != kControlNoContent )
|
||||
{
|
||||
::SetControlData( (ControlHandle) m_macControl , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user