Work around the limitation of windows API when setting thumbnail toolbar buttons.

- New API: InsertThumbBarButton, AppendThumbBarButton, RemoveThumbBarButton.
- Though MSDN said that "Buttons cannot be added or deleted later, so this must
  be the full defined set. Buttons also cannot be reordered.", we can work
  around it by: when first time adding button, initialize all of the possible
  seven buttons and hide them, except the button adding. In the next time adding
  button, just show it, which can make it looks like it is added on the fly.

Author: Chaobin Zhang

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77602 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2014-09-10 14:51:29 +00:00
parent a7145e561d
commit 1580848eeb
5 changed files with 186 additions and 47 deletions

View File

@@ -13,6 +13,8 @@
#if wxUSE_TASKBARBUTTON
#include "wx/defs.h"
// ----------------------------------------------------------------------------
// wxTaskBarButton: define wxTaskBarButton interface.
// ----------------------------------------------------------------------------
@@ -33,18 +35,33 @@ class WXDLLIMPEXP_ADV wxThumbBarButton {
public:
wxThumbBarButton(int id,
const wxIcon& icon,
const wxString& tooltip = wxString());
const wxString& tooltip = wxString(),
bool enable = true,
bool dismissOnClick = false,
bool hasBackground = true,
bool shown = true,
bool interactive = true);
virtual ~wxThumbBarButton() {}
int GetID() const { return m_id; }
const wxIcon& GetIcon() const { return m_icon; }
const wxString& GetTooltip() const { return m_tooltip; }
bool IsEnable() const { return m_enable; }
bool IsDismissOnClick() const { return m_dismissOnClick; }
bool HasBackground() const { return m_hasBackground; }
bool IsShown() const { return m_shown; }
bool IsInteractive() const { return m_interactive; }
private:
int m_id;
wxIcon m_icon;
wxString m_tooltip;
bool m_enable;
bool m_dismissOnClick;
bool m_hasBackground;
bool m_shown;
bool m_interactive;
};
class WXDLLIMPEXP_ADV wxTaskBarButton
@@ -65,16 +82,10 @@ public:
const wxString& description = wxString()) = 0;
virtual void SetThumbnailClip(const wxRect& rect) = 0;
virtual void SetThumbnailContents(const wxWindow *child) = 0;
/**
Adds a thumbnail toolbar button to the thumbnail image of a window in
the taskbar button flyout. Note that a wxTaskbarButton can only have no
more than seven wxThumbBarButtons, and ShowThumbnailToolbar should be
called to show them, then these buttons cannot be added or removed until
the window is re-created.
*/
virtual bool AddThumbBarButton(wxThumbBarButton *button) = 0;
virtual void ShowThumbnailToolbar() = 0;
virtual bool InsertThumbBarButton(size_t pos, wxThumbBarButton *button) = 0;
virtual bool AppendThumbBarButton(wxThumbBarButton *button) = 0;
virtual bool RemoveThumbBarButton(wxThumbBarButton *button) = 0;
virtual bool RemoveThumbBarButton(int id) = 0;
private:
wxDECLARE_NO_COPY_CLASS(wxTaskBarButton);