No changes, just use symbolic NO_IMAGE constant instead of -1 or wxNOT_FOUND.
Existing declarations used -1 in several places to indicate the absence of the image which wasn't especially clear and was also inconsistent with other places that used wxNOT_FOUND which didn't make much sense in this context. Add a new symbolic constant NO_IMAGE in wxWithImages and use it in the classes deriving from it. This still doesn't help with wx{Tree,List}Ctrl but improves clarity for the other classes. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68810 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -181,7 +181,7 @@ public:
|
||||
virtual bool AddPage(wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = -1)
|
||||
int imageId = NO_IMAGE)
|
||||
{
|
||||
DoInvalidateBestSize();
|
||||
return InsertPage(GetPageCount(), page, text, bSelect, imageId);
|
||||
@@ -192,7 +192,7 @@ public:
|
||||
wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = -1) = 0;
|
||||
int imageId = NO_IMAGE) = 0;
|
||||
|
||||
// set the currently selected page, return the index of the previously
|
||||
// selected one (or wxNOT_FOUND on error)
|
||||
|
@@ -68,7 +68,7 @@ public:
|
||||
wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = -1);
|
||||
int imageId = NO_IMAGE);
|
||||
virtual int SetSelection(size_t n)
|
||||
{ return DoSetSelection(n, SetSelection_SendEvent); }
|
||||
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
||||
|
@@ -97,7 +97,7 @@ public:
|
||||
wxNotebookPage *win,
|
||||
const wxString& strText,
|
||||
bool bSelect = false,
|
||||
int imageId = -1 );
|
||||
int imageId = NO_IMAGE );
|
||||
|
||||
protected:
|
||||
};
|
||||
|
@@ -1262,20 +1262,20 @@ public:
|
||||
{ return GetStore()->IsContainer(item); }
|
||||
|
||||
wxDataViewItem AppendItem( const wxDataViewItem& parent,
|
||||
const wxString &text, int icon = -1, wxClientData *data = NULL );
|
||||
const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL );
|
||||
wxDataViewItem PrependItem( const wxDataViewItem& parent,
|
||||
const wxString &text, int icon = -1, wxClientData *data = NULL );
|
||||
const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL );
|
||||
wxDataViewItem InsertItem( const wxDataViewItem& parent, const wxDataViewItem& previous,
|
||||
const wxString &text, int icon = -1, wxClientData *data = NULL );
|
||||
const wxString &text, int icon = NO_IMAGE, wxClientData *data = NULL );
|
||||
|
||||
wxDataViewItem PrependContainer( const wxDataViewItem& parent,
|
||||
const wxString &text, int icon = -1, int expanded = -1,
|
||||
const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE,
|
||||
wxClientData *data = NULL );
|
||||
wxDataViewItem AppendContainer( const wxDataViewItem& parent,
|
||||
const wxString &text, int icon = -1, int expanded = -1,
|
||||
const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE,
|
||||
wxClientData *data = NULL );
|
||||
wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
|
||||
const wxString &text, int icon = -1, int expanded = -1,
|
||||
const wxString &text, int icon = NO_IMAGE, int expanded = NO_IMAGE,
|
||||
wxClientData *data = NULL );
|
||||
|
||||
wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
|
||||
|
@@ -107,7 +107,7 @@ public:
|
||||
wxNotebookPage *pPage,
|
||||
const wxString& strText,
|
||||
bool bSelect = false,
|
||||
int imageId = -1);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// callbacks
|
||||
// ---------
|
||||
|
@@ -89,7 +89,7 @@ public:
|
||||
wxNotebookPage *win,
|
||||
const wxString& strText,
|
||||
bool bSelect = false,
|
||||
int imageId = -1 );
|
||||
int imageId = NO_IMAGE );
|
||||
|
||||
// handler for tab navigation
|
||||
// --------------------------
|
||||
|
@@ -89,7 +89,7 @@ public:
|
||||
wxNotebookPage *win,
|
||||
const wxString& strText,
|
||||
bool bSelect = false,
|
||||
int imageId = -1 );
|
||||
int imageId = NO_IMAGE );
|
||||
|
||||
// handler for tab navigation
|
||||
// --------------------------
|
||||
|
@@ -69,7 +69,7 @@ public:
|
||||
wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = -1);
|
||||
int imageId = NO_IMAGE);
|
||||
virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
|
||||
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
||||
virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
|
||||
|
@@ -96,7 +96,7 @@ public:
|
||||
wxNotebookPage *pPage,
|
||||
const wxString& strText,
|
||||
bool bSelect = false,
|
||||
int imageId = -1);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
|
||||
// style.
|
||||
|
@@ -95,7 +95,7 @@ public:
|
||||
wxNotebookPage *pPage,
|
||||
const wxString& strText,
|
||||
bool bSelect = false,
|
||||
int imageId = -1);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// callbacks
|
||||
// ---------
|
||||
|
@@ -127,7 +127,7 @@ public:
|
||||
wxNotebookPage *pPage,
|
||||
const wxString& strText,
|
||||
bool bSelect = false,
|
||||
int imageId = -1);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ) ; }
|
||||
const wxNotebookPageInfoList& GetPageInfos() const ;
|
||||
|
@@ -78,7 +78,7 @@ public:
|
||||
wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = -1);
|
||||
int imageId = NO_IMAGE);
|
||||
virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
|
||||
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
||||
virtual void SetImageList(wxImageList *imageList);
|
||||
|
@@ -74,27 +74,27 @@ public:
|
||||
wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = wxNOT_FOUND);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// Inserts a new sub-page to the end of children of the page at given pos.
|
||||
virtual bool InsertSubPage(size_t pos,
|
||||
wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = wxNOT_FOUND);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// Adds a new page at top level after all other pages.
|
||||
virtual bool AddPage(wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = wxNOT_FOUND);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// Adds a new child-page to the last top-level page inserted.
|
||||
// Useful when constructing 1 level tree structure.
|
||||
virtual bool AddSubPage(wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = wxNOT_FOUND);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// Deletes the page and ALL its children. Could trigger page selection
|
||||
// change in a case when selected page is removed. In that case its parent
|
||||
@@ -169,16 +169,16 @@ private:
|
||||
wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = wxNOT_FOUND);
|
||||
int imageId = NO_IMAGE);
|
||||
bool DoInsertSubPage(size_t pos,
|
||||
wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = wxNOT_FOUND);
|
||||
int imageId = NO_IMAGE);
|
||||
bool DoAddSubPage(wxWindow *page,
|
||||
const wxString& text,
|
||||
bool bSelect = false,
|
||||
int imageId = wxNOT_FOUND);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// Sets selection in the tree control and updates the page being shown.
|
||||
int DoSetSelection(size_t pos, int flags = 0);
|
||||
|
@@ -86,7 +86,7 @@ public:
|
||||
wxNotebookPage *pPage,
|
||||
const wxString& strText,
|
||||
bool bSelect = false,
|
||||
int imageId = -1);
|
||||
int imageId = NO_IMAGE);
|
||||
|
||||
// style tests
|
||||
// -----------
|
||||
|
@@ -21,6 +21,11 @@
|
||||
class WXDLLIMPEXP_CORE wxWithImages
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
NO_IMAGE = -1
|
||||
};
|
||||
|
||||
wxWithImages()
|
||||
{
|
||||
m_imageList = NULL;
|
||||
@@ -55,12 +60,12 @@ protected:
|
||||
|
||||
// Return the image with the given index from the image list.
|
||||
//
|
||||
// If there is no image list or if index == -1 (which traditionally means
|
||||
// that no image should be used for the given item), silently returns
|
||||
// If there is no image list or if index == NO_IMAGE, silently returns
|
||||
// wxNullIcon.
|
||||
wxIcon GetImage(int iconIndex) const
|
||||
{
|
||||
return m_imageList && iconIndex != -1 ? m_imageList->GetIcon(iconIndex)
|
||||
return m_imageList && iconIndex != NO_IMAGE
|
||||
? m_imageList->GetIcon(iconIndex)
|
||||
: wxNullIcon;
|
||||
}
|
||||
|
||||
|
@@ -30,6 +30,12 @@
|
||||
class wxBookCtrlBase : public wxControl
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
/// Symbolic constant indicating that no image should be used.
|
||||
NO_IMAGE = -1
|
||||
};
|
||||
|
||||
/**
|
||||
Default ctor.
|
||||
*/
|
||||
@@ -243,7 +249,7 @@ public:
|
||||
@see InsertPage()
|
||||
*/
|
||||
virtual bool AddPage(wxWindow* page, const wxString& text,
|
||||
bool select = false, int imageId = wxNOT_FOUND);
|
||||
bool select = false, int imageId = NO_IMAGE);
|
||||
|
||||
/**
|
||||
Deletes all pages.
|
||||
@@ -280,7 +286,7 @@ public:
|
||||
wxWindow* page,
|
||||
const wxString& text,
|
||||
bool select = false,
|
||||
int imageId = wxNOT_FOUND) = 0;
|
||||
int imageId = NO_IMAGE) = 0;
|
||||
|
||||
/**
|
||||
Deletes the specified page, without deleting the associated window.
|
||||
|
Reference in New Issue
Block a user