Add wxTreeCtrl::GetStateImageCount() and HasStateImages()
Add these functions for consistency with SetStateImages() and to avoid using GetStateImageList() in the treectrl sample, which can now use GetStateImageCount() instead.
This commit is contained in:
parent
a5449a94a1
commit
f9a22962e0
3 changed files with 34 additions and 1 deletions
|
|
@ -62,6 +62,11 @@ public:
|
|||
// (for example, checked/unchecked).
|
||||
virtual void SetStateImages(const wxVector<wxBitmapBundle>& images) = 0;
|
||||
|
||||
// Simple accessors similar to the inherited from wxWithImages
|
||||
// HasImages() and GetImageCount() for normal images.
|
||||
bool HasStateImages() const { return m_imagesState.HasImages(); }
|
||||
int GetStateImageCount() const { return m_imagesState.GetImageCount(); }
|
||||
|
||||
// These functions parallel {Set,Get,Assign}ImageList() methods
|
||||
// inherited from wxWithImages, but correspond to SetStateImages().
|
||||
// As with the other functions using wxImageList, they still work but
|
||||
|
|
|
|||
|
|
@ -699,12 +699,38 @@ public:
|
|||
*/
|
||||
virtual size_t GetSelections(wxArrayTreeItemIds& selection) const;
|
||||
|
||||
/**
|
||||
Returns the number of state images used by the control.
|
||||
|
||||
Returns the number of images passed to the last call to
|
||||
SetStateImages() or 0 if it had been never called.
|
||||
|
||||
@see HasImages()
|
||||
|
||||
@since 3.3.0
|
||||
*/
|
||||
int GetStateImageCount() const;
|
||||
|
||||
/**
|
||||
Returns the state image list (from which application-defined state
|
||||
images are taken).
|
||||
|
||||
@see HasStateImages(), GetStateImageCount()
|
||||
*/
|
||||
wxImageList* GetStateImageList() const;
|
||||
|
||||
/**
|
||||
Returns true if the control uses any state images.
|
||||
|
||||
This is equivalent to comparing GetStateImageCount() return value with
|
||||
0 but more clear.
|
||||
|
||||
@see SetStateImages(), GetStateImageCount()
|
||||
|
||||
@since 3.3.0
|
||||
*/
|
||||
bool HasStateImages() const;
|
||||
|
||||
/**
|
||||
Calculates which (if any) item is under the given @a point, returning
|
||||
the tree item id at this point plus extra information @a flags. @a flags
|
||||
|
|
@ -994,6 +1020,8 @@ public:
|
|||
resolutions for each state. If the vector is empty, no state images are
|
||||
shown.
|
||||
|
||||
@see HasStateImages(), GetStateImageCount()
|
||||
|
||||
@since 3.3.0
|
||||
*/
|
||||
virtual void SetStateImages(const wxVector<wxBitmapBundle>& images);
|
||||
|
|
|
|||
|
|
@ -1288,7 +1288,7 @@ void MyTreeCtrl::DoToggleState(const wxTreeItemId& item)
|
|||
|
||||
srand (time(nullptr));
|
||||
do {
|
||||
nState = rand() % GetStateImageList()->GetImageCount();
|
||||
nState = rand() % GetStateImageCount();
|
||||
} while (nState == state);
|
||||
|
||||
SetItemState(item, nState);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue