Add wxRibbonButtonBar::InsertXXXButton() methods.
Allow inserting buttons into the ribbon bar and not only appending them. Closes #13811. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70181 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -462,6 +462,7 @@ All (GUI):
|
|||||||
- Show ribbon tools help strings in tooltips (John Roberts).
|
- Show ribbon tools help strings in tooltips (John Roberts).
|
||||||
- Improve row/column selection modes in wxGrid (joostn).
|
- Improve row/column selection modes in wxGrid (joostn).
|
||||||
- Allow using wxEVT_UPDATE_UI with wxRibbonButtonBar (Emilien Kia).
|
- Allow using wxEVT_UPDATE_UI with wxRibbonButtonBar (Emilien Kia).
|
||||||
|
- Add wxRibbonButtonBar::InsertXXXButton() methods (Emilien Kia).
|
||||||
|
|
||||||
GTK:
|
GTK:
|
||||||
|
|
||||||
|
@@ -84,6 +84,49 @@ public:
|
|||||||
const wxString& help_string = wxEmptyString,
|
const wxString& help_string = wxEmptyString,
|
||||||
wxObject* client_data = NULL);
|
wxObject* client_data = NULL);
|
||||||
|
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string,
|
||||||
|
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL);
|
||||||
|
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertDropdownButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string = wxEmptyString);
|
||||||
|
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertHybridButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string = wxEmptyString);
|
||||||
|
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertToggleButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string = wxEmptyString);
|
||||||
|
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxBitmap& bitmap_small = wxNullBitmap,
|
||||||
|
const wxBitmap& bitmap_disabled = wxNullBitmap,
|
||||||
|
const wxBitmap& bitmap_small_disabled = wxNullBitmap,
|
||||||
|
wxRibbonButtonKind kind = wxRIBBON_BUTTON_NORMAL,
|
||||||
|
const wxString& help_string = wxEmptyString,
|
||||||
|
wxObject* client_data = NULL);
|
||||||
|
|
||||||
|
virtual size_t GetButtonCount() const;
|
||||||
|
|
||||||
virtual bool Realize();
|
virtual bool Realize();
|
||||||
virtual void ClearButtons();
|
virtual void ClearButtons();
|
||||||
virtual bool DeleteButton(int button_id);
|
virtual bool DeleteButton(int button_id);
|
||||||
|
@@ -252,6 +252,131 @@ public:
|
|||||||
const wxString& help_string = wxEmptyString,
|
const wxString& help_string = wxEmptyString,
|
||||||
wxObject* client_data = NULL);
|
wxObject* client_data = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Inserts a button to the button bar (simple version) at the given position.
|
||||||
|
|
||||||
|
@see AddButton()
|
||||||
|
|
||||||
|
@since 2.9.4
|
||||||
|
*/
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string,
|
||||||
|
wxRibbonButtonBarButtonKind kind = wxRIBBON_BUTTONBAR_BUTTON_NORMAL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Inserts a dropdown button to the button bar (simple version) at the
|
||||||
|
given position.
|
||||||
|
|
||||||
|
@see InsertButton()
|
||||||
|
@see AddDropdownButton()
|
||||||
|
@see AddButton()
|
||||||
|
|
||||||
|
@since 2.9.4
|
||||||
|
*/
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertDropdownButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string = wxEmptyString);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Inserts a hybrid button to the button bar (simple version) at the given
|
||||||
|
position.
|
||||||
|
|
||||||
|
@see InsertButton()
|
||||||
|
@see AddHybridButton()
|
||||||
|
@see AddButton()
|
||||||
|
|
||||||
|
@since 2.9.4
|
||||||
|
*/
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertHybridButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string = wxEmptyString);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Inserts a toggle button to the button bar (simple version) at the given
|
||||||
|
position.
|
||||||
|
|
||||||
|
@see InsertButton()
|
||||||
|
@see AddToggleButton()
|
||||||
|
@see AddButton()
|
||||||
|
|
||||||
|
@since 2.9.4
|
||||||
|
*/
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertToggleButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string = wxEmptyString);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Insert a button to the button bar at the given position.
|
||||||
|
|
||||||
|
@param pos
|
||||||
|
Position of the new button in the button bar.
|
||||||
|
@param button_id
|
||||||
|
ID of the new button (used for event callbacks).
|
||||||
|
@param label
|
||||||
|
Label of the new button.
|
||||||
|
@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.
|
||||||
|
@param kind
|
||||||
|
The kind of button to add.
|
||||||
|
@param help_string
|
||||||
|
The UI help string to associate with the new button.
|
||||||
|
@param client_data
|
||||||
|
Client data to associate with the new button.
|
||||||
|
|
||||||
|
@return An opaque pointer which can be used only with other button bar
|
||||||
|
methods.
|
||||||
|
|
||||||
|
@see InsertDropdownButton()
|
||||||
|
@see InsertHybridButton()
|
||||||
|
@see InsertToggleButton()
|
||||||
|
@see AddButton()
|
||||||
|
|
||||||
|
@since 2.9.4
|
||||||
|
*/
|
||||||
|
virtual wxRibbonButtonBarButtonBase* InsertButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxBitmap& bitmap_small = wxNullBitmap,
|
||||||
|
const wxBitmap& bitmap_disabled = wxNullBitmap,
|
||||||
|
const wxBitmap& bitmap_small_disabled = wxNullBitmap,
|
||||||
|
wxRibbonButtonBarButtonKind kind = wxRIBBON_BUTTONBAR_BUTTON_NORMAL,
|
||||||
|
const wxString& help_string = wxEmptyString,
|
||||||
|
wxObject* client_data = NULL);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Returns the number of buttons in this button bar.
|
||||||
|
|
||||||
|
@since 2.9.4
|
||||||
|
*/
|
||||||
|
virtual size_t GetButtonCount() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calculate button layouts and positions.
|
Calculate button layouts and positions.
|
||||||
|
|
||||||
|
@@ -279,6 +279,23 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::AddButton(
|
|||||||
wxRibbonButtonKind kind,
|
wxRibbonButtonKind kind,
|
||||||
const wxString& help_string,
|
const wxString& help_string,
|
||||||
wxObject* client_data)
|
wxObject* client_data)
|
||||||
|
{
|
||||||
|
return InsertButton(GetButtonCount(), button_id, label, bitmap,
|
||||||
|
bitmap_small, bitmap_disabled,bitmap_small_disabled, kind, help_string,
|
||||||
|
client_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxBitmap& bitmap_small,
|
||||||
|
const wxBitmap& bitmap_disabled,
|
||||||
|
const wxBitmap& bitmap_small_disabled,
|
||||||
|
wxRibbonButtonKind kind,
|
||||||
|
const wxString& help_string,
|
||||||
|
wxObject* client_data)
|
||||||
{
|
{
|
||||||
wxASSERT(bitmap.IsOk() || bitmap_small.IsOk());
|
wxASSERT(bitmap.IsOk() || bitmap_small.IsOk());
|
||||||
if(m_buttons.IsEmpty())
|
if(m_buttons.IsEmpty())
|
||||||
@@ -348,12 +365,56 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::AddButton(
|
|||||||
FetchButtonSizeInfo(base, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM, temp_dc);
|
FetchButtonSizeInfo(base, wxRIBBON_BUTTONBAR_BUTTON_MEDIUM, temp_dc);
|
||||||
FetchButtonSizeInfo(base, wxRIBBON_BUTTONBAR_BUTTON_LARGE, temp_dc);
|
FetchButtonSizeInfo(base, wxRIBBON_BUTTONBAR_BUTTON_LARGE, temp_dc);
|
||||||
|
|
||||||
// TODO
|
m_buttons.Insert(base, pos);
|
||||||
m_buttons.Add(base);
|
|
||||||
m_layouts_valid = false;
|
m_layouts_valid = false;
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string,
|
||||||
|
wxRibbonButtonKind kind)
|
||||||
|
{
|
||||||
|
return InsertButton(pos, button_id, label, bitmap, wxNullBitmap,
|
||||||
|
wxNullBitmap, wxNullBitmap, kind, help_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertDropdownButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string)
|
||||||
|
{
|
||||||
|
return InsertButton(pos, button_id, label, bitmap, help_string,
|
||||||
|
wxRIBBON_BUTTON_DROPDOWN);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertToggleButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string)
|
||||||
|
{
|
||||||
|
return InsertButton(pos, button_id, label, bitmap, help_string,
|
||||||
|
wxRIBBON_BUTTON_TOGGLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertHybridButton(
|
||||||
|
size_t pos,
|
||||||
|
int button_id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxBitmap& bitmap,
|
||||||
|
const wxString& help_string)
|
||||||
|
{
|
||||||
|
return InsertButton(pos, button_id, label, bitmap, help_string,
|
||||||
|
wxRIBBON_BUTTON_HYBRID);
|
||||||
|
}
|
||||||
|
|
||||||
void wxRibbonButtonBar::FetchButtonSizeInfo(wxRibbonButtonBarButtonBase* button,
|
void wxRibbonButtonBar::FetchButtonSizeInfo(wxRibbonButtonBarButtonBase* button,
|
||||||
wxRibbonButtonBarButtonState size, wxDC& dc)
|
wxRibbonButtonBarButtonState size, wxDC& dc)
|
||||||
{
|
{
|
||||||
@@ -382,6 +443,11 @@ wxBitmap wxRibbonButtonBar::MakeDisabledBitmap(const wxBitmap& original)
|
|||||||
return wxBitmap(img.ConvertToGreyscale());
|
return wxBitmap(img.ConvertToGreyscale());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t wxRibbonButtonBar::GetButtonCount() const
|
||||||
|
{
|
||||||
|
return m_buttons.GetCount();
|
||||||
|
}
|
||||||
|
|
||||||
bool wxRibbonButtonBar::Realize()
|
bool wxRibbonButtonBar::Realize()
|
||||||
{
|
{
|
||||||
if(!m_layouts_valid)
|
if(!m_layouts_valid)
|
||||||
|
Reference in New Issue
Block a user