wxRibbonButtonBarButton: Added SetButtonIcon()
Added new function SetButtonIcon() which modifies button bitmaps of existing ribbon button bar buttons.
This commit is contained in:
@@ -139,6 +139,13 @@ public:
|
||||
virtual void EnableButton(int button_id, bool enable = true);
|
||||
virtual void ToggleButton(int button_id, bool checked);
|
||||
|
||||
virtual void SetButtonIcon(
|
||||
int button_id,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmap& bitmap_small = wxNullBitmap,
|
||||
const wxBitmap& bitmap_disabled = wxNullBitmap,
|
||||
const wxBitmap& bitmap_small_disabled = wxNullBitmap);
|
||||
|
||||
virtual wxRibbonButtonBarButtonBase *GetActiveItem() const;
|
||||
virtual wxRibbonButtonBarButtonBase *GetHoveredItem() const;
|
||||
|
||||
@@ -172,6 +179,11 @@ protected:
|
||||
void CommonInit(long style);
|
||||
void MakeLayouts();
|
||||
bool TryCollapseLayout(wxRibbonButtonBarLayout* original, size_t first_btn, size_t* last_button);
|
||||
void MakeBitmaps(wxRibbonButtonBarButtonBase* base,
|
||||
const wxBitmap& bitmap_large,
|
||||
const wxBitmap& bitmap_large_disabled,
|
||||
const wxBitmap& bitmap_small,
|
||||
const wxBitmap& bitmap_small_disabled);
|
||||
static wxBitmap MakeResizedBitmap(const wxBitmap& original, wxSize size);
|
||||
static wxBitmap MakeDisabledBitmap(const wxBitmap& original);
|
||||
void FetchButtonSizeInfo(wxRibbonButtonBarButtonBase* button,
|
||||
|
@@ -476,6 +476,33 @@ public:
|
||||
*/
|
||||
virtual void ToggleButton(int button_id, bool checked);
|
||||
|
||||
/**
|
||||
Changes the bitmap of an existing button.
|
||||
|
||||
@param button_id
|
||||
ID of the button to manipulate.
|
||||
@param bitmap
|
||||
Large bitmap of the new button. Must be the same size as all other
|
||||
large bitmaps used on the button bar.
|
||||
@param bitmap_small
|
||||
Small bitmap of the new button. If left as null, then a small
|
||||
bitmap will be automatically generated. Must be the same size as
|
||||
all other small bitmaps used on the button bar.
|
||||
@param bitmap_disabled
|
||||
Large bitmap of the new button when it is disabled. If left as
|
||||
null, then a bitmap will be automatically generated from @a bitmap.
|
||||
@param bitmap_small_disabled
|
||||
Small bitmap of the new button when it is disabled. If left as
|
||||
null, then a bitmap will be automatically generated from @a
|
||||
bitmap_small.
|
||||
*/
|
||||
virtual void SetButtonIcon(
|
||||
int button_id,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmap& bitmap_small = wxNullBitmap,
|
||||
const wxBitmap& bitmap_disabled = wxNullBitmap,
|
||||
const wxBitmap& bitmap_small_disabled = wxNullBitmap);
|
||||
|
||||
/**
|
||||
Returns the active item of the button bar or NULL if there is none.
|
||||
The active button is the one being clicked.
|
||||
|
@@ -323,38 +323,8 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
||||
wxRibbonButtonBarButtonBase* base = new wxRibbonButtonBarButtonBase;
|
||||
base->id = button_id;
|
||||
base->label = label;
|
||||
base->bitmap_large = bitmap;
|
||||
if(!base->bitmap_large.IsOk())
|
||||
{
|
||||
base->bitmap_large = MakeResizedBitmap(base->bitmap_small,
|
||||
m_bitmap_size_large);
|
||||
}
|
||||
else if(base->bitmap_large.GetScaledSize() != m_bitmap_size_large)
|
||||
{
|
||||
base->bitmap_large = MakeResizedBitmap(base->bitmap_large,
|
||||
m_bitmap_size_large);
|
||||
}
|
||||
base->bitmap_small = bitmap_small;
|
||||
if(!base->bitmap_small.IsOk())
|
||||
{
|
||||
base->bitmap_small = MakeResizedBitmap(base->bitmap_large,
|
||||
m_bitmap_size_small);
|
||||
}
|
||||
else if(base->bitmap_small.GetScaledSize() != m_bitmap_size_small)
|
||||
{
|
||||
base->bitmap_small = MakeResizedBitmap(base->bitmap_small,
|
||||
m_bitmap_size_small);
|
||||
}
|
||||
base->bitmap_large_disabled = bitmap_disabled;
|
||||
if(!base->bitmap_large_disabled.IsOk())
|
||||
{
|
||||
base->bitmap_large_disabled = MakeDisabledBitmap(base->bitmap_large);
|
||||
}
|
||||
base->bitmap_small_disabled = bitmap_small_disabled;
|
||||
if(!base->bitmap_small_disabled.IsOk())
|
||||
{
|
||||
base->bitmap_small_disabled = MakeDisabledBitmap(base->bitmap_small);
|
||||
}
|
||||
MakeBitmaps(base, bitmap, bitmap_disabled,
|
||||
bitmap_small, bitmap_small_disabled);
|
||||
base->kind = kind;
|
||||
base->help_string = help_string;
|
||||
base->state = 0;
|
||||
@@ -595,6 +565,21 @@ void wxRibbonButtonBar::ToggleButton(int button_id, bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void wxRibbonButtonBar::SetButtonIcon(
|
||||
int button_id,
|
||||
const wxBitmap& bitmap,
|
||||
const wxBitmap& bitmap_small,
|
||||
const wxBitmap& bitmap_disabled,
|
||||
const wxBitmap& bitmap_small_disabled)
|
||||
{
|
||||
wxRibbonButtonBarButtonBase* base = GetItemById(button_id);
|
||||
if(base == NULL)
|
||||
return;
|
||||
MakeBitmaps(base, bitmap, bitmap_small,
|
||||
bitmap_disabled, bitmap_small_disabled);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void wxRibbonButtonBar::SetArtProvider(wxRibbonArtProvider* art)
|
||||
{
|
||||
if(art == m_art)
|
||||
@@ -997,6 +982,46 @@ bool wxRibbonButtonBar::TryCollapseLayout(wxRibbonButtonBarLayout* original,
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxRibbonButtonBar::MakeBitmaps(wxRibbonButtonBarButtonBase* base,
|
||||
const wxBitmap& bitmap_large,
|
||||
const wxBitmap& bitmap_large_disabled,
|
||||
const wxBitmap& bitmap_small,
|
||||
const wxBitmap& bitmap_small_disabled)
|
||||
{
|
||||
base->bitmap_large = bitmap_large;
|
||||
if(!base->bitmap_large.IsOk())
|
||||
{
|
||||
base->bitmap_large = MakeResizedBitmap(base->bitmap_small,
|
||||
m_bitmap_size_large);
|
||||
}
|
||||
else if(base->bitmap_large.GetScaledSize() != m_bitmap_size_large)
|
||||
{
|
||||
base->bitmap_large = MakeResizedBitmap(base->bitmap_large,
|
||||
m_bitmap_size_large);
|
||||
}
|
||||
base->bitmap_small = bitmap_small;
|
||||
if(!base->bitmap_small.IsOk())
|
||||
{
|
||||
base->bitmap_small = MakeResizedBitmap(base->bitmap_large,
|
||||
m_bitmap_size_small);
|
||||
}
|
||||
else if(base->bitmap_small.GetScaledSize() != m_bitmap_size_small)
|
||||
{
|
||||
base->bitmap_small = MakeResizedBitmap(base->bitmap_small,
|
||||
m_bitmap_size_small);
|
||||
}
|
||||
base->bitmap_large_disabled = bitmap_large_disabled;
|
||||
if(!base->bitmap_large_disabled.IsOk())
|
||||
{
|
||||
base->bitmap_large_disabled = MakeDisabledBitmap(base->bitmap_large);
|
||||
}
|
||||
base->bitmap_small_disabled = bitmap_small_disabled;
|
||||
if(!base->bitmap_small_disabled.IsOk())
|
||||
{
|
||||
base->bitmap_small_disabled = MakeDisabledBitmap(base->bitmap_small);
|
||||
}
|
||||
}
|
||||
|
||||
void wxRibbonButtonBar::OnMouseMove(wxMouseEvent& evt)
|
||||
{
|
||||
wxPoint cursor(evt.GetPosition());
|
||||
|
Reference in New Issue
Block a user