#ifndef _WX_MENUBTN_H_
#define _WX_MENUBTN_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "menubtn.h"
#endif
class wxMenu;
class wxBitmap;
class wxCustomButton;
enum wxCustomButton_Style
{
wxCUSTBUT_LEFT = 0x0001,
wxCUSTBUT_RIGHT = 0x0002,
wxCUSTBUT_TOP = 0x0004,
wxCUSTBUT_BOTTOM = 0x0008,
wxCUSTBUT_NOTOGGLE = 0x0100,
wxCUSTBUT_BUTTON = 0x0200,
wxCUSTBUT_TOGGLE = 0x0400,
wxCUSTBUT_BUT_DCLICK_TOG = 0x0800,
wxCUSTBUT_TOG_DCLICK_BUT = 0x1000,
wxCUSTBUT_FLAT = 0x2000
};
class WXDLLEXPORT wxCustomButton : public wxControl
{
public:
wxCustomButton() : wxControl() {
Init();
}
wxCustomButton(wxWindow* parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCUSTBUT_TOGGLE,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxCustomButton"))
: wxControl()
{
Init();
Create(parent,id,label,wxNullBitmap,pos,size,style,val,name);
}
wxCustomButton(wxWindow *parent, wxWindowID id,
const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCUSTBUT_TOGGLE,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxCustomButton"))
: wxControl()
{
Init();
Create(parent,id,wxEmptyString,bitmap,pos,size,style,val,name);
}
wxCustomButton(wxWindow *parent, wxWindowID id,
const wxString& label, const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxCUSTBUT_TOGGLE|wxCUSTBUT_BOTTOM,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxCustomButton"))
: wxControl()
{
Init();
Create(parent,id,label,bitmap,pos,size,style,val,name);
}
virtual ~wxCustomButton();
bool Create(wxWindow* parent,
wxWindowID id,
const wxString& label,
const wxBitmap &bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxCustomButton"));
bool GetValue() const {
return m_down%2 != 0;
}
void SetValue( bool depressed );
long GetButtonStyle() const {
return m_button_style;
}
bool SetButtonStyle( long style );
void SetLabel( const wxString &label );
void SetBitmapLabel(const wxBitmap& bitmap);
void SetBitmapSelected(const wxBitmap& sel) {
m_bmpSelected = sel;
CalcLayout(TRUE);
};
void SetBitmapFocus(const wxBitmap& focus) {
m_bmpFocus = focus;
CalcLayout(TRUE);
};
void SetBitmapDisabled(const wxBitmap& disabled) {
m_bmpDisabled = disabled;
CalcLayout(TRUE);
};
void SetLabel(const wxBitmap& bitmap) {
SetBitmapLabel(bitmap);
}
const wxBitmap& GetBitmapLabel() const {
return m_bmpLabel;
}
const wxBitmap& GetBitmapSelected() const {
return m_bmpSelected;
}
const wxBitmap& GetBitmapFocus() const {
return m_bmpFocus;
}
const wxBitmap& GetBitmapDisabled() const {
return m_bmpDisabled;
}
wxBitmap CreateBitmapDisabled(const wxBitmap &bitmap) const;
void SetMargins(const wxSize &margin, bool fit = FALSE);
void SetLabelMargin(const wxSize &margin, bool fit = FALSE);
wxSize GetLabelMargin() const {
return m_labelMargin;
}
void SetBitmapMargin(const wxSize &margin, bool fit = FALSE);
wxSize GetBitmapMargin() const {
return m_bitmapMargin;
}
void SetFocused(bool focused) {
m_focused = focused;
Refresh(FALSE);
}
bool GetFocused() const {
return m_focused;
}
protected:
void OnPaint(wxPaintEvent &event);
void Redraw();
virtual void Paint( wxDC &dc );
virtual wxSize DoGetBestSize() const;
virtual void SendEvent();
void OnMouseEvents(wxMouseEvent &event);
void OnSize( wxSizeEvent &event );
virtual void CalcLayout(bool refresh);
long m_down;
bool m_focused;
long m_button_style;
wxBitmap m_bmpLabel,
m_bmpSelected,
m_bmpFocus,
m_bmpDisabled;
wxSize m_labelMargin,
m_bitmapMargin;
wxPoint m_bitmapPos,
m_labelPos;
wxTimer *m_timer;
wxEventType m_eventType;
private:
void Init();
DECLARE_DYNAMIC_CLASS(wxCustomButton)
DECLARE_EVENT_TABLE()
};
#define wxMENUBUTTON_DROP_WIDTH 10
#define wxMENUBUTTON_DROP_HEIGHT 22
enum wxMenuButton_Styles
{
wxMENUBUT_FLAT = wxCUSTBUT_FLAT
};
class wxMenuButton : public wxControl
{
public:
wxMenuButton() : wxControl() {
Init();
}
wxMenuButton( wxWindow* parent, wxWindowID id,
const wxBitmap &bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxMenuButton"))
: wxControl()
{
Init();
Create(parent,id,wxEmptyString,bitmap,pos,size,style,val,name);
}
virtual ~wxMenuButton();
bool Create( wxWindow* parent,
wxWindowID id,
const wxString &label,
const wxBitmap &bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxT("wxMenuButton"));
int GetSelection() const;
void AssignMenu(wxMenu *menu, bool static_menu = FALSE);
wxMenu *GetMenu() const {
return m_menu;
}
wxCustomButton *GetLabelButton() const {
return m_labelButton;
}
wxCustomButton *GetDropDownButton() const {
return m_dropdownButton;
}
void SetToolTip(const wxString &tip);
void SetToolTip(wxToolTip *tip);
protected:
void OnButton(wxCommandEvent &event);
virtual void DoSetSize(int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual wxSize DoGetBestSize();
#ifdef __WXMSW__
void OnMenu( wxCommandEvent &event );
#endif
wxCustomButton *m_labelButton;
wxCustomButton *m_dropdownButton;
wxMenu *m_menu;
bool m_menu_static;
long m_style;
private:
void Init();
DECLARE_DYNAMIC_CLASS(wxMenuButton)
DECLARE_EVENT_TABLE()
};
BEGIN_DECLARE_EVENT_TYPES()
DECLARE_LOCAL_EVENT_TYPE( wxEVT_MENUBUTTON_OPEN, 0 )
END_DECLARE_EVENT_TYPES()
#define EVT_MENUBUTTON_OPEN(id, fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_MENUBUTTON_OPEN, id, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxCommandEventFunction) (wxNotifyEventFunction) & fn, (wxObject *) NULL ),
#endif