From dd06fa3aa80fe2e3053d2c0868e6ac5491098349 Mon Sep 17 00:00:00 2001 From: Bryan Petty Date: Wed, 10 Sep 2014 14:52:55 +0000 Subject: [PATCH] Add new api for appending a separator to the thumbnail toolbar. Actually, when calling AppendSeparator we are appending a disable ThumbBarButton without background, which can simulate the behavior of appending a separator. Author: Chaobin Zhang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77610 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/taskbarbutton.h | 1 + include/wx/taskbarbutton.h | 1 + interface/wx/taskbarbutton.h | 19 ++++++++++++++----- samples/taskbarbutton/taskbarbutton.cpp | 3 +-- src/msw/taskbarbutton.cpp | 21 +++++++++++++++++++-- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/include/wx/msw/taskbarbutton.h b/include/wx/msw/taskbarbutton.h index ded1092eec..5d84ee57d6 100644 --- a/include/wx/msw/taskbarbutton.h +++ b/include/wx/msw/taskbarbutton.h @@ -35,6 +35,7 @@ public: virtual bool InsertThumbBarButton(size_t pos, wxThumbBarButton *button) wxOVERRIDE; virtual bool AppendThumbBarButton(wxThumbBarButton *button) wxOVERRIDE; + virtual bool AppendSeparatorInThumbBar() wxOVERRIDE; virtual wxThumbBarButton* RemoveThumbBarButton( wxThumbBarButton *button) wxOVERRIDE; virtual wxThumbBarButton* RemoveThumbBarButton(int id) wxOVERRIDE; diff --git a/include/wx/taskbarbutton.h b/include/wx/taskbarbutton.h index 5436e41488..ca140ea34e 100644 --- a/include/wx/taskbarbutton.h +++ b/include/wx/taskbarbutton.h @@ -116,6 +116,7 @@ public: virtual void SetThumbnailContents(const wxWindow *child) = 0; virtual bool InsertThumbBarButton(size_t pos, wxThumbBarButton *button) = 0; virtual bool AppendThumbBarButton(wxThumbBarButton *button) = 0; + virtual bool AppendSeparatorInThumbBar() = 0; virtual wxThumbBarButton* RemoveThumbBarButton(wxThumbBarButton *button) = 0; virtual wxThumbBarButton* RemoveThumbBarButton(int id) = 0; diff --git a/interface/wx/taskbarbutton.h b/interface/wx/taskbarbutton.h index b44bbe089f..0c1f98b002 100644 --- a/interface/wx/taskbarbutton.h +++ b/interface/wx/taskbarbutton.h @@ -279,21 +279,30 @@ public: Inserts the given button before the position pos to the taskbar thumbnail toolbar. - @note The number of buttons is limited to 7. + @note The number of buttons and separators is limited to 7. - @see AppendThumbBarButton() + @see AppendThumbBarButton(), AppendSeparatorInThumbBar() */ virtual bool InsertThumbBarButton(size_t pos, wxThumbBarButton *button); /** - Adds a button to the taskbar thumbnail toolbar. + Appends a button to the taskbar thumbnail toolbar. - @note The number of buttons is limited to 7. + @note The number of buttons and separators is limited to 7. - @see InsertThumbBarButton() + @see InsertThumbBarButton(), AppendSeparatorInThumbBar() */ virtual bool AppendThumbBarButton(wxThumbBarButton *button); + /** + Appends a separator to the taskbar thumbnail toolbar. + + @note The number of buttons and separators is limited to 7. + + @see AppendThumbBarButton(), InsertThumbBarButton() + */ + virtual bool AppendSeparatorInThumbBar(); + /** Removes the thumbnail toolbar button from the taskbar button but doesn't delete the associated c++ object. diff --git a/samples/taskbarbutton/taskbarbutton.cpp b/samples/taskbarbutton/taskbarbutton.cpp index 54387438ea..20687de633 100644 --- a/samples/taskbarbutton/taskbarbutton.cpp +++ b/samples/taskbarbutton/taskbarbutton.cpp @@ -346,13 +346,12 @@ void MyFrame::OnSetOrRestoreThumbnailClip(wxCommandEvent& event) MSWGetTaskBarButton()->SetThumbnailClip(rect); } - void MyFrame::OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event)) { if ( m_thumbBarButtons.size() >= 7 ) return; - wxThumbBarButton* button = + wxThumbBarButton *button = new wxThumbBarButton(m_thumbBarButtons.size() + ThumbnailToolbarBtn_0 , CreateRandomIcon()); MSWGetTaskBarButton()->AppendThumbBarButton(button); diff --git a/src/msw/taskbarbutton.cpp b/src/msw/taskbarbutton.cpp index c05751a2b8..eaed7f7205 100644 --- a/src/msw/taskbarbutton.cpp +++ b/src/msw/taskbarbutton.cpp @@ -253,18 +253,35 @@ void wxTaskBarButtonImpl::SetThumbnailContents(const wxWindow *child) bool wxTaskBarButtonImpl::AppendThumbBarButton(wxThumbBarButton *button) { wxASSERT_MSG( m_thumbBarButtons.size() < MAX_BUTTON_COUNT, - "Number of thumb buttons is limited to 7" ); + "Number of ThumbBarButtons and separators is limited to 7" ); button->SetParent(this); m_thumbBarButtons.push_back(button); return InitOrUpdateThumbBarButtons(); } +bool wxTaskBarButtonImpl::AppendSeparatorInThumbBar() +{ + wxASSERT_MSG( m_thumbBarButtons.size() < MAX_BUTTON_COUNT, + "Number of ThumbBarButtons and separators is limited to 7" ); + + // Append a disable ThumbBarButton without background can simulate the + // behavior of appending a separator. + wxThumbBarButton *separator = new wxThumbBarButton(wxID_ANY, + wxNullIcon, + wxEmptyString, + false, + false, + false); + m_thumbBarButtons.push_back(separator); + return InitOrUpdateThumbBarButtons(); +} + bool wxTaskBarButtonImpl::InsertThumbBarButton(size_t pos, wxThumbBarButton *button) { wxASSERT_MSG( m_thumbBarButtons.size() < MAX_BUTTON_COUNT, - "Number of thumb buttons is limited to 7" ); + "Number of ThumbBarButtons and separators is limited to 7" ); wxASSERT_MSG( pos <= m_thumbBarButtons.size(), "Invalid index when inserting the button" );