Expose APIs that can update the behavior of wxThumbBarButton.
- void Enable(bool enable = true); void Disable(); - void EnableDismissOnClick(bool enable = true); void DisableDimissOnClick(); - void SetHasBackground(bool has = true); - void Show(bool shown = true); void Hide(); - void EnableInteractive(bool interactive = true); void DisableInteractive(); Author: Chaobin Zhang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77608 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -41,6 +41,8 @@ public:
|
||||
|
||||
private:
|
||||
friend class wxFrame;
|
||||
friend class wxThumbBarButton;
|
||||
|
||||
wxTaskBarButtonImpl(WXWidget parent);
|
||||
|
||||
bool InitOrUpdateThumbBarButtons();
|
||||
|
@@ -19,6 +19,8 @@
|
||||
// wxTaskBarButton: define wxTaskBarButton interface.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxTaskBarButton;
|
||||
|
||||
/**
|
||||
State of the task bar button.
|
||||
*/
|
||||
@@ -33,7 +35,7 @@ enum WXDLLIMPEXP_CORE wxTaskBarButtonState
|
||||
|
||||
class WXDLLIMPEXP_CORE wxThumbBarButton : public wxObject {
|
||||
public:
|
||||
wxThumbBarButton() { }
|
||||
wxThumbBarButton() : m_taskBarButtonParent(NULL) { }
|
||||
wxThumbBarButton(int id,
|
||||
const wxIcon& icon,
|
||||
const wxString& tooltip = wxString(),
|
||||
@@ -56,13 +58,32 @@ public:
|
||||
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; }
|
||||
void Enable(bool enable = true);
|
||||
void Disable() { Enable(false); }
|
||||
|
||||
bool IsDismissOnClick() const { return m_dismissOnClick; }
|
||||
void EnableDismissOnClick(bool enable = true);
|
||||
void DisableDimissOnClick() { EnableDismissOnClick(false); }
|
||||
|
||||
bool HasBackground() const { return m_hasBackground; }
|
||||
void SetHasBackground(bool has = true);
|
||||
|
||||
bool IsShown() const { return m_shown; }
|
||||
void Show(bool shown = true);
|
||||
void Hide() { Show(false); }
|
||||
|
||||
bool IsInteractive() const { return m_interactive; }
|
||||
void EnableInteractive(bool interactive = true);
|
||||
void DisableInteractive() { EnableInteractive(false); }
|
||||
|
||||
void SetParent(wxTaskBarButton *parent) { m_taskBarButtonParent = parent; }
|
||||
wxTaskBarButton* GetParent() const { return m_taskBarButtonParent; }
|
||||
|
||||
private:
|
||||
bool UpdateParentTaskBarButton();
|
||||
|
||||
int m_id;
|
||||
wxIcon m_icon;
|
||||
wxString m_tooltip;
|
||||
@@ -71,6 +92,7 @@ private:
|
||||
bool m_hasBackground;
|
||||
bool m_shown;
|
||||
bool m_interactive;
|
||||
wxTaskBarButton *m_taskBarButtonParent;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxThumbBarButton)
|
||||
};
|
||||
|
@@ -69,7 +69,8 @@ wxThumbBarButton::wxThumbBarButton(int id,
|
||||
m_dismissOnClick(dismissOnClick),
|
||||
m_hasBackground(hasBackground),
|
||||
m_shown(shown),
|
||||
m_interactive(interactive)
|
||||
m_interactive(interactive),
|
||||
m_taskBarButtonParent(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -93,6 +94,60 @@ bool wxThumbBarButton::Create(int id,
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxThumbBarButton::Enable(bool enable)
|
||||
{
|
||||
if ( m_enable != enable )
|
||||
{
|
||||
m_enable = enable;
|
||||
UpdateParentTaskBarButton();
|
||||
}
|
||||
}
|
||||
|
||||
void wxThumbBarButton::SetHasBackground(bool has)
|
||||
{
|
||||
if ( m_hasBackground != has )
|
||||
{
|
||||
m_hasBackground = has;
|
||||
UpdateParentTaskBarButton();
|
||||
}
|
||||
}
|
||||
|
||||
void wxThumbBarButton::EnableDismissOnClick(bool enable)
|
||||
{
|
||||
if ( m_dismissOnClick != enable )
|
||||
{
|
||||
m_dismissOnClick = enable;
|
||||
UpdateParentTaskBarButton();
|
||||
}
|
||||
}
|
||||
|
||||
void wxThumbBarButton::Show(bool shown)
|
||||
{
|
||||
if ( m_shown != shown )
|
||||
{
|
||||
m_shown = shown;
|
||||
UpdateParentTaskBarButton();
|
||||
}
|
||||
}
|
||||
|
||||
void wxThumbBarButton::EnableInteractive(bool interactive)
|
||||
{
|
||||
if ( m_interactive != interactive )
|
||||
{
|
||||
m_interactive = interactive;
|
||||
UpdateParentTaskBarButton();
|
||||
}
|
||||
}
|
||||
|
||||
bool wxThumbBarButton::UpdateParentTaskBarButton()
|
||||
{
|
||||
if ( !m_taskBarButtonParent )
|
||||
return false;
|
||||
|
||||
return static_cast<wxTaskBarButtonImpl*>(
|
||||
m_taskBarButtonParent)->InitOrUpdateThumbBarButtons();
|
||||
}
|
||||
|
||||
wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent)
|
||||
: m_hwnd(parent),
|
||||
m_taskbarList(NULL),
|
||||
@@ -200,6 +255,7 @@ bool wxTaskBarButtonImpl::AppendThumbBarButton(wxThumbBarButton *button)
|
||||
wxASSERT_MSG( m_thumbBarButtons.size() < MAX_BUTTON_COUNT,
|
||||
"Number of thumb buttons is limited to 7" );
|
||||
|
||||
button->SetParent(this);
|
||||
m_thumbBarButtons.push_back(button);
|
||||
return InitOrUpdateThumbBarButtons();
|
||||
}
|
||||
@@ -212,11 +268,13 @@ bool wxTaskBarButtonImpl::InsertThumbBarButton(size_t pos,
|
||||
wxASSERT_MSG( pos <= m_thumbBarButtons.size(),
|
||||
"Invalid index when inserting the button" );
|
||||
|
||||
button->SetParent(this);
|
||||
m_thumbBarButtons.insert(m_thumbBarButtons.begin() + pos, button);
|
||||
return InitOrUpdateThumbBarButtons();
|
||||
}
|
||||
|
||||
wxThumbBarButton* wxTaskBarButtonImpl::RemoveThumbBarButton(wxThumbBarButton *button)
|
||||
wxThumbBarButton* wxTaskBarButtonImpl::RemoveThumbBarButton(
|
||||
wxThumbBarButton *button)
|
||||
{
|
||||
for ( wxThumbBarButtons::iterator iter = m_thumbBarButtons.begin();
|
||||
iter != m_thumbBarButtons.end();
|
||||
@@ -225,6 +283,7 @@ wxThumbBarButton* wxTaskBarButtonImpl::RemoveThumbBarButton(wxThumbBarButton *bu
|
||||
if ( button == *iter )
|
||||
{
|
||||
m_thumbBarButtons.erase(iter);
|
||||
button->SetParent(NULL);
|
||||
InitOrUpdateThumbBarButtons();
|
||||
return *iter;
|
||||
}
|
||||
@@ -242,6 +301,7 @@ wxThumbBarButton* wxTaskBarButtonImpl::RemoveThumbBarButton(int id)
|
||||
if ( id == (*iter)->GetID() )
|
||||
{
|
||||
m_thumbBarButtons.erase(iter);
|
||||
(*iter)->SetParent(NULL);
|
||||
InitOrUpdateThumbBarButtons();
|
||||
return *iter;
|
||||
}
|
||||
|
Reference in New Issue
Block a user