Fix and enhance support for client data in wxRibbonButtonBar.
Add the possibility to retrieve the client data associated with a button and not only set it (which wasn't very useful on its own). Also allow having both typed (owned) and untyped (not owned) client data, as in the other wxWidgets controls. To avoid confusion between two different kinds of data, remove "client_data" argument from the functions adding buttons and provide separate methods with distinct names for setting and getting client data. Closes #14630. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72529 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
7f08b8283b
commit
652aa9360f
@ -548,6 +548,9 @@ All (GUI):
|
||||
- Add expand/collapse button to wxRibbonBar (rakeshthp).
|
||||
- Fix item data access in wxDataViewListCtrl (Kry).
|
||||
- Fix problem with floating maximized AUI panes (Laurent Poujoulat).
|
||||
- Add owned client data support to wxRibbonButtonBar. Notice that the client
|
||||
data now must be set using the SetItemClient{Data,Object}() methods and not
|
||||
when inserting the button (Laurent Poujoulat).
|
||||
- Add wxBitmapButton::NewCloseButton().
|
||||
- Add wxTextEntry::SelectNone() (troelsk).
|
||||
- Restore the original wxGrid col/row size when unhiding it (Michael Richards).
|
||||
|
@ -81,8 +81,7 @@ public:
|
||||
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);
|
||||
const wxString& help_string = wxEmptyString);
|
||||
|
||||
virtual wxRibbonButtonBarButtonBase* InsertButton(
|
||||
size_t pos,
|
||||
@ -122,8 +121,12 @@ public:
|
||||
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);
|
||||
const wxString& help_string = wxEmptyString);
|
||||
|
||||
void SetItemClientObject(wxRibbonButtonBarButtonBase* item, wxClientData* data);
|
||||
wxClientData* GetItemClientObject(const wxRibbonButtonBarButtonBase* item) const;
|
||||
void SetItemClientData(wxRibbonButtonBarButtonBase* item, void* data);
|
||||
void* GetItemClientData(const wxRibbonButtonBarButtonBase* item) const;
|
||||
|
||||
virtual size_t GetButtonCount() const;
|
||||
virtual wxRibbonButtonBarButtonBase *GetItem(size_t n) const;
|
||||
|
@ -231,8 +231,6 @@ public:
|
||||
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.
|
||||
@ -249,8 +247,7 @@ public:
|
||||
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);
|
||||
const wxString& help_string = wxEmptyString);
|
||||
|
||||
/**
|
||||
Inserts a button to the button bar (simple version) at the given position.
|
||||
@ -345,8 +342,6 @@ public:
|
||||
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.
|
||||
@ -367,8 +362,7 @@ public:
|
||||
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);
|
||||
const wxString& help_string = wxEmptyString);
|
||||
|
||||
/**
|
||||
Returns the number of buttons in this button bar.
|
||||
@ -377,6 +371,37 @@ public:
|
||||
*/
|
||||
virtual size_t GetButtonCount() const;
|
||||
|
||||
/**
|
||||
Set the client object associated with a button. The button bar
|
||||
owns the given object and takes care of its deletion.
|
||||
Please, note that you cannot use both client object and client data.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
void SetItemClientObject(wxRibbonButtonBarButtonBase* item, wxClientData* data);
|
||||
|
||||
/**
|
||||
Get the client object associated with a button.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
wxClientData* GetItemClientObject(const wxRibbonButtonBarButtonBase* item) const;
|
||||
|
||||
/**
|
||||
Set the client data associated with a button.
|
||||
Please, note that you cannot use both client object and client data.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
void SetItemClientData(wxRibbonButtonBarButtonBase* item, void* data);
|
||||
|
||||
/**
|
||||
Get the client data associated with a button.
|
||||
|
||||
@since 2.9.5
|
||||
*/
|
||||
void* GetItemClientData(const wxRibbonButtonBarButtonBase* item) const;
|
||||
|
||||
/**
|
||||
Returns the N-th button of the bar.
|
||||
|
||||
|
@ -117,7 +117,7 @@ public:
|
||||
wxBitmap bitmap_small;
|
||||
wxBitmap bitmap_small_disabled;
|
||||
wxRibbonButtonBarButtonSizeInfo sizes[3];
|
||||
wxObject* client_data;
|
||||
wxClientDataContainer client_data;
|
||||
int id;
|
||||
wxRibbonButtonKind kind;
|
||||
long state;
|
||||
@ -278,12 +278,10 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::AddButton(
|
||||
const wxBitmap& bitmap_disabled,
|
||||
const wxBitmap& bitmap_small_disabled,
|
||||
wxRibbonButtonKind kind,
|
||||
const wxString& help_string,
|
||||
wxObject* client_data)
|
||||
const wxString& help_string)
|
||||
{
|
||||
return InsertButton(GetButtonCount(), button_id, label, bitmap,
|
||||
bitmap_small, bitmap_disabled,bitmap_small_disabled, kind, help_string,
|
||||
client_data);
|
||||
bitmap_small, bitmap_disabled,bitmap_small_disabled, kind, help_string);
|
||||
}
|
||||
|
||||
wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
||||
@ -295,8 +293,7 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
||||
const wxBitmap& bitmap_disabled,
|
||||
const wxBitmap& bitmap_small_disabled,
|
||||
wxRibbonButtonKind kind,
|
||||
const wxString& help_string,
|
||||
wxObject* client_data)
|
||||
const wxString& help_string)
|
||||
{
|
||||
wxASSERT(bitmap.IsOk() || bitmap_small.IsOk());
|
||||
if(m_buttons.IsEmpty())
|
||||
@ -358,7 +355,6 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
||||
}
|
||||
base->kind = kind;
|
||||
base->help_string = help_string;
|
||||
base->client_data = client_data;
|
||||
base->state = 0;
|
||||
|
||||
wxClientDC temp_dc(this);
|
||||
@ -371,6 +367,42 @@ wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
||||
return base;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
wxRibbonButtonBar::SetItemClientObject(wxRibbonButtonBarButtonBase* item,
|
||||
wxClientData* data)
|
||||
{
|
||||
wxCHECK_RET( item, "Can't associate client object with an invalid item" );
|
||||
|
||||
item->client_data.SetClientObject(data);
|
||||
}
|
||||
|
||||
wxClientData*
|
||||
wxRibbonButtonBar::GetItemClientObject(const wxRibbonButtonBarButtonBase* item) const
|
||||
{
|
||||
wxCHECK_MSG( item, NULL, "Can't get client object for an invalid item" );
|
||||
|
||||
return item->client_data.GetClientObject();
|
||||
}
|
||||
|
||||
void
|
||||
wxRibbonButtonBar::SetItemClientData(wxRibbonButtonBarButtonBase* item,
|
||||
void* data)
|
||||
{
|
||||
wxCHECK_RET( item, "Can't associate client data with an invalid item" );
|
||||
|
||||
item->client_data.SetClientData(data);
|
||||
}
|
||||
|
||||
void*
|
||||
wxRibbonButtonBar::GetItemClientData(const wxRibbonButtonBarButtonBase* item) const
|
||||
{
|
||||
wxCHECK_MSG( item, NULL, "Can't get client data for an invalid item" );
|
||||
|
||||
return item->client_data.GetClientData();
|
||||
}
|
||||
|
||||
|
||||
wxRibbonButtonBarButtonBase* wxRibbonButtonBar::InsertButton(
|
||||
size_t pos,
|
||||
int button_id,
|
||||
|
Loading…
Reference in New Issue
Block a user