From 1871b9facb9435e636f1ce355fd31a0594438d01 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Aug 2011 14:08:49 +0000 Subject: [PATCH] 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 --- include/wx/bookctrl.h | 4 ++-- include/wx/choicebk.h | 2 +- include/wx/cocoa/notebook.h | 2 +- include/wx/dataview.h | 12 ++++++------ include/wx/generic/notebook.h | 2 +- include/wx/gtk/notebook.h | 2 +- include/wx/gtk1/notebook.h | 2 +- include/wx/listbook.h | 2 +- include/wx/msw/notebook.h | 2 +- include/wx/osx/notebook.h | 2 +- include/wx/palmos/notebook.h | 2 +- include/wx/toolbook.h | 2 +- include/wx/treebook.h | 14 +++++++------- include/wx/univ/notebook.h | 2 +- include/wx/withimages.h | 13 +++++++++---- interface/wx/bookctrl.h | 10 ++++++++-- 16 files changed, 43 insertions(+), 32 deletions(-) diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h index bc2b89d8b3..e42d904871 100644 --- a/include/wx/bookctrl.h +++ b/include/wx/bookctrl.h @@ -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) diff --git a/include/wx/choicebk.h b/include/wx/choicebk.h index 5dbbecc104..0539b353dd 100644 --- a/include/wx/choicebk.h +++ b/include/wx/choicebk.h @@ -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); } diff --git a/include/wx/cocoa/notebook.h b/include/wx/cocoa/notebook.h index 6cc8161ff0..e158a18fdd 100644 --- a/include/wx/cocoa/notebook.h +++ b/include/wx/cocoa/notebook.h @@ -97,7 +97,7 @@ public: wxNotebookPage *win, const wxString& strText, bool bSelect = false, - int imageId = -1 ); + int imageId = NO_IMAGE ); protected: }; diff --git a/include/wx/dataview.h b/include/wx/dataview.h index ff6e3b31e3..96af042c9d 100644 --- a/include/wx/dataview.h +++ b/include/wx/dataview.h @@ -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 diff --git a/include/wx/generic/notebook.h b/include/wx/generic/notebook.h index 32deb7564d..1bd34877be 100644 --- a/include/wx/generic/notebook.h +++ b/include/wx/generic/notebook.h @@ -107,7 +107,7 @@ public: wxNotebookPage *pPage, const wxString& strText, bool bSelect = false, - int imageId = -1); + int imageId = NO_IMAGE); // callbacks // --------- diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h index bad2b59524..aeb5399ea2 100644 --- a/include/wx/gtk/notebook.h +++ b/include/wx/gtk/notebook.h @@ -89,7 +89,7 @@ public: wxNotebookPage *win, const wxString& strText, bool bSelect = false, - int imageId = -1 ); + int imageId = NO_IMAGE ); // handler for tab navigation // -------------------------- diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h index 78c7ce5125..5be3df0b5b 100644 --- a/include/wx/gtk1/notebook.h +++ b/include/wx/gtk1/notebook.h @@ -89,7 +89,7 @@ public: wxNotebookPage *win, const wxString& strText, bool bSelect = false, - int imageId = -1 ); + int imageId = NO_IMAGE ); // handler for tab navigation // -------------------------- diff --git a/include/wx/listbook.h b/include/wx/listbook.h index 052b463024..48140dc0bb 100644 --- a/include/wx/listbook.h +++ b/include/wx/listbook.h @@ -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; diff --git a/include/wx/msw/notebook.h b/include/wx/msw/notebook.h index 70993e4d61..bb8ca64cc2 100644 --- a/include/wx/msw/notebook.h +++ b/include/wx/msw/notebook.h @@ -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. diff --git a/include/wx/osx/notebook.h b/include/wx/osx/notebook.h index 3447388f95..1affba34a9 100644 --- a/include/wx/osx/notebook.h +++ b/include/wx/osx/notebook.h @@ -95,7 +95,7 @@ public: wxNotebookPage *pPage, const wxString& strText, bool bSelect = false, - int imageId = -1); + int imageId = NO_IMAGE); // callbacks // --------- diff --git a/include/wx/palmos/notebook.h b/include/wx/palmos/notebook.h index 5e85e4259d..3c603a8169 100644 --- a/include/wx/palmos/notebook.h +++ b/include/wx/palmos/notebook.h @@ -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 ; diff --git a/include/wx/toolbook.h b/include/wx/toolbook.h index d39df2e99f..bfe6211e8f 100644 --- a/include/wx/toolbook.h +++ b/include/wx/toolbook.h @@ -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); diff --git a/include/wx/treebook.h b/include/wx/treebook.h index 86aa0acabc..30bc563e0d 100644 --- a/include/wx/treebook.h +++ b/include/wx/treebook.h @@ -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); diff --git a/include/wx/univ/notebook.h b/include/wx/univ/notebook.h index 7fa65423be..cf982afe6c 100644 --- a/include/wx/univ/notebook.h +++ b/include/wx/univ/notebook.h @@ -86,7 +86,7 @@ public: wxNotebookPage *pPage, const wxString& strText, bool bSelect = false, - int imageId = -1); + int imageId = NO_IMAGE); // style tests // ----------- diff --git a/include/wx/withimages.h b/include/wx/withimages.h index 6ca0c902e9..e36380dfd2 100644 --- a/include/wx/withimages.h +++ b/include/wx/withimages.h @@ -21,6 +21,11 @@ class WXDLLIMPEXP_CORE wxWithImages { public: + enum + { + NO_IMAGE = -1 + }; + wxWithImages() { m_imageList = NULL; @@ -55,13 +60,13 @@ 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) - : wxNullIcon; + return m_imageList && iconIndex != NO_IMAGE + ? m_imageList->GetIcon(iconIndex) + : wxNullIcon; } private: diff --git a/interface/wx/bookctrl.h b/interface/wx/bookctrl.h index 450cd6d4eb..06092c4eaf 100644 --- a/interface/wx/bookctrl.h +++ b/interface/wx/bookctrl.h @@ -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. -- 2.45.2