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,
|
virtual bool AddPage(wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1)
|
int imageId = NO_IMAGE)
|
||||||
{
|
{
|
||||||
DoInvalidateBestSize();
|
DoInvalidateBestSize();
|
||||||
return InsertPage(GetPageCount(), page, text, bSelect, imageId);
|
return InsertPage(GetPageCount(), page, text, bSelect, imageId);
|
||||||
@@ -192,7 +192,7 @@ public:
|
|||||||
wxWindow *page,
|
wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1) = 0;
|
int imageId = NO_IMAGE) = 0;
|
||||||
|
|
||||||
// set the currently selected page, return the index of the previously
|
// set the currently selected page, return the index of the previously
|
||||||
// selected one (or wxNOT_FOUND on error)
|
// selected one (or wxNOT_FOUND on error)
|
||||||
|
@@ -68,7 +68,7 @@ public:
|
|||||||
wxWindow *page,
|
wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1);
|
int imageId = NO_IMAGE);
|
||||||
virtual int SetSelection(size_t n)
|
virtual int SetSelection(size_t n)
|
||||||
{ return DoSetSelection(n, SetSelection_SendEvent); }
|
{ return DoSetSelection(n, SetSelection_SendEvent); }
|
||||||
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
||||||
|
@@ -97,7 +97,7 @@ public:
|
|||||||
wxNotebookPage *win,
|
wxNotebookPage *win,
|
||||||
const wxString& strText,
|
const wxString& strText,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1 );
|
int imageId = NO_IMAGE );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
@@ -1262,20 +1262,20 @@ public:
|
|||||||
{ return GetStore()->IsContainer(item); }
|
{ return GetStore()->IsContainer(item); }
|
||||||
|
|
||||||
wxDataViewItem AppendItem( const wxDataViewItem& parent,
|
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,
|
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,
|
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,
|
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 );
|
wxClientData *data = NULL );
|
||||||
wxDataViewItem AppendContainer( const wxDataViewItem& parent,
|
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 );
|
wxClientData *data = NULL );
|
||||||
wxDataViewItem InsertContainer( const wxDataViewItem& parent, const wxDataViewItem& previous,
|
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 );
|
wxClientData *data = NULL );
|
||||||
|
|
||||||
wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
|
wxDataViewItem GetNthChild( const wxDataViewItem& parent, unsigned int pos ) const
|
||||||
|
@@ -107,7 +107,7 @@ public:
|
|||||||
wxNotebookPage *pPage,
|
wxNotebookPage *pPage,
|
||||||
const wxString& strText,
|
const wxString& strText,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
// ---------
|
// ---------
|
||||||
|
@@ -89,7 +89,7 @@ public:
|
|||||||
wxNotebookPage *win,
|
wxNotebookPage *win,
|
||||||
const wxString& strText,
|
const wxString& strText,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1 );
|
int imageId = NO_IMAGE );
|
||||||
|
|
||||||
// handler for tab navigation
|
// handler for tab navigation
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
@@ -89,7 +89,7 @@ public:
|
|||||||
wxNotebookPage *win,
|
wxNotebookPage *win,
|
||||||
const wxString& strText,
|
const wxString& strText,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1 );
|
int imageId = NO_IMAGE );
|
||||||
|
|
||||||
// handler for tab navigation
|
// handler for tab navigation
|
||||||
// --------------------------
|
// --------------------------
|
||||||
|
@@ -69,7 +69,7 @@ public:
|
|||||||
wxWindow *page,
|
wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1);
|
int imageId = NO_IMAGE);
|
||||||
virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
|
virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
|
||||||
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
||||||
virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
|
virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
|
||||||
|
@@ -96,7 +96,7 @@ public:
|
|||||||
wxNotebookPage *pPage,
|
wxNotebookPage *pPage,
|
||||||
const wxString& strText,
|
const wxString& strText,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
|
// Windows-only at present. Also, you must use the wxNB_FIXEDWIDTH
|
||||||
// style.
|
// style.
|
||||||
|
@@ -95,7 +95,7 @@ public:
|
|||||||
wxNotebookPage *pPage,
|
wxNotebookPage *pPage,
|
||||||
const wxString& strText,
|
const wxString& strText,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
// callbacks
|
// callbacks
|
||||||
// ---------
|
// ---------
|
||||||
|
@@ -127,7 +127,7 @@ public:
|
|||||||
wxNotebookPage *pPage,
|
wxNotebookPage *pPage,
|
||||||
const wxString& strText,
|
const wxString& strText,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ) ; }
|
void AddPageInfo( wxNotebookPageInfo* info ) { AddPage( info->GetPage() , info->GetText() , info->GetSelected() , info->GetImageId() ) ; }
|
||||||
const wxNotebookPageInfoList& GetPageInfos() const ;
|
const wxNotebookPageInfoList& GetPageInfos() const ;
|
||||||
|
@@ -78,7 +78,7 @@ public:
|
|||||||
wxWindow *page,
|
wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1);
|
int imageId = NO_IMAGE);
|
||||||
virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
|
virtual int SetSelection(size_t n) { return DoSetSelection(n, SetSelection_SendEvent); }
|
||||||
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
virtual int ChangeSelection(size_t n) { return DoSetSelection(n); }
|
||||||
virtual void SetImageList(wxImageList *imageList);
|
virtual void SetImageList(wxImageList *imageList);
|
||||||
|
@@ -74,27 +74,27 @@ public:
|
|||||||
wxWindow *page,
|
wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
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.
|
// Inserts a new sub-page to the end of children of the page at given pos.
|
||||||
virtual bool InsertSubPage(size_t pos,
|
virtual bool InsertSubPage(size_t pos,
|
||||||
wxWindow *page,
|
wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = wxNOT_FOUND);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
// Adds a new page at top level after all other pages.
|
// Adds a new page at top level after all other pages.
|
||||||
virtual bool AddPage(wxWindow *page,
|
virtual bool AddPage(wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = wxNOT_FOUND);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
// Adds a new child-page to the last top-level page inserted.
|
// Adds a new child-page to the last top-level page inserted.
|
||||||
// Useful when constructing 1 level tree structure.
|
// Useful when constructing 1 level tree structure.
|
||||||
virtual bool AddSubPage(wxWindow *page,
|
virtual bool AddSubPage(wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = wxNOT_FOUND);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
// Deletes the page and ALL its children. Could trigger page selection
|
// 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
|
// change in a case when selected page is removed. In that case its parent
|
||||||
@@ -169,16 +169,16 @@ private:
|
|||||||
wxWindow *page,
|
wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = wxNOT_FOUND);
|
int imageId = NO_IMAGE);
|
||||||
bool DoInsertSubPage(size_t pos,
|
bool DoInsertSubPage(size_t pos,
|
||||||
wxWindow *page,
|
wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = wxNOT_FOUND);
|
int imageId = NO_IMAGE);
|
||||||
bool DoAddSubPage(wxWindow *page,
|
bool DoAddSubPage(wxWindow *page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = wxNOT_FOUND);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
// Sets selection in the tree control and updates the page being shown.
|
// Sets selection in the tree control and updates the page being shown.
|
||||||
int DoSetSelection(size_t pos, int flags = 0);
|
int DoSetSelection(size_t pos, int flags = 0);
|
||||||
|
@@ -86,7 +86,7 @@ public:
|
|||||||
wxNotebookPage *pPage,
|
wxNotebookPage *pPage,
|
||||||
const wxString& strText,
|
const wxString& strText,
|
||||||
bool bSelect = false,
|
bool bSelect = false,
|
||||||
int imageId = -1);
|
int imageId = NO_IMAGE);
|
||||||
|
|
||||||
// style tests
|
// style tests
|
||||||
// -----------
|
// -----------
|
||||||
|
@@ -21,6 +21,11 @@
|
|||||||
class WXDLLIMPEXP_CORE wxWithImages
|
class WXDLLIMPEXP_CORE wxWithImages
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
NO_IMAGE = -1
|
||||||
|
};
|
||||||
|
|
||||||
wxWithImages()
|
wxWithImages()
|
||||||
{
|
{
|
||||||
m_imageList = NULL;
|
m_imageList = NULL;
|
||||||
@@ -55,13 +60,13 @@ protected:
|
|||||||
|
|
||||||
// Return the image with the given index from the image list.
|
// Return the image with the given index from the image list.
|
||||||
//
|
//
|
||||||
// If there is no image list or if index == -1 (which traditionally means
|
// If there is no image list or if index == NO_IMAGE, silently returns
|
||||||
// that no image should be used for the given item), silently returns
|
|
||||||
// wxNullIcon.
|
// wxNullIcon.
|
||||||
wxIcon GetImage(int iconIndex) const
|
wxIcon GetImage(int iconIndex) const
|
||||||
{
|
{
|
||||||
return m_imageList && iconIndex != -1 ? m_imageList->GetIcon(iconIndex)
|
return m_imageList && iconIndex != NO_IMAGE
|
||||||
: wxNullIcon;
|
? m_imageList->GetIcon(iconIndex)
|
||||||
|
: wxNullIcon;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -30,6 +30,12 @@
|
|||||||
class wxBookCtrlBase : public wxControl
|
class wxBookCtrlBase : public wxControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
/// Symbolic constant indicating that no image should be used.
|
||||||
|
NO_IMAGE = -1
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Default ctor.
|
Default ctor.
|
||||||
*/
|
*/
|
||||||
@@ -243,7 +249,7 @@ public:
|
|||||||
@see InsertPage()
|
@see InsertPage()
|
||||||
*/
|
*/
|
||||||
virtual bool AddPage(wxWindow* page, const wxString& text,
|
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.
|
Deletes all pages.
|
||||||
@@ -280,7 +286,7 @@ public:
|
|||||||
wxWindow* page,
|
wxWindow* page,
|
||||||
const wxString& text,
|
const wxString& text,
|
||||||
bool select = false,
|
bool select = false,
|
||||||
int imageId = wxNOT_FOUND) = 0;
|
int imageId = NO_IMAGE) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Deletes the specified page, without deleting the associated window.
|
Deletes the specified page, without deleting the associated window.
|
||||||
|
Reference in New Issue
Block a user