2014-09-10 10:49:33 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: taskbarbutton.cpp
|
2014-09-10 10:50:08 -04:00
|
|
|
// Purpose: wxTaskBarButton sample
|
2014-09-10 10:49:33 -04:00
|
|
|
// Author: Chaobin Zhang <zhchbin@gmail.com>
|
|
|
|
// Created: 2014-04-30
|
|
|
|
// Copyright: (c) 2014 wxWidgets development team
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
2014-09-10 10:53:17 -04:00
|
|
|
#include "wx/progdlg.h"
|
2014-09-10 10:49:33 -04:00
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
2018-08-17 13:54:52 -04:00
|
|
|
#include "wx/stdpaths.h"
|
2014-09-10 10:49:33 -04:00
|
|
|
#include "wx/taskbarbutton.h"
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ProgressValueSlider = wxID_HIGHEST,
|
2014-09-10 10:49:44 -04:00
|
|
|
VisibilityRadio,
|
2014-09-10 10:49:55 -04:00
|
|
|
ThumbnailTooltipSetBtn,
|
|
|
|
ProgressStateChoice,
|
|
|
|
SetOverlayIconBtn,
|
|
|
|
ClearOverlayIconBtn,
|
|
|
|
SetThumbnailClipBtn,
|
|
|
|
RestoreThumbnailClipBtn,
|
2014-09-10 10:50:08 -04:00
|
|
|
AddThumbBarButtonBtn,
|
2014-09-10 10:51:29 -04:00
|
|
|
RemoveThumbBarButtonBtn,
|
2014-09-10 10:50:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ThumbnailToolbarBtn_0 = wxID_HIGHEST + 100,
|
|
|
|
ThumbnailToolbarBtn_1,
|
|
|
|
ThumbnailToolbarBtn_2,
|
|
|
|
ThumbnailToolbarBtn_3,
|
|
|
|
ThumbnailToolbarBtn_4,
|
|
|
|
ThumbnailToolbarBtn_5,
|
|
|
|
ThumbnailToolbarBtn_6
|
2014-09-10 10:49:33 -04:00
|
|
|
};
|
|
|
|
|
2014-09-10 10:49:55 -04:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
wxBitmap CreateBitmap(const wxColour& colour, int w, int h)
|
|
|
|
{
|
|
|
|
wxMemoryDC dc;
|
|
|
|
wxBitmap bmp(w, h);
|
|
|
|
dc.SelectObject(bmp);
|
|
|
|
|
|
|
|
// Draw transparent background
|
|
|
|
wxColour magic(255, 0, 255);
|
|
|
|
wxBrush magicBrush(magic);
|
|
|
|
dc.SetBrush(magicBrush);
|
|
|
|
dc.SetPen(*wxTRANSPARENT_PEN);
|
|
|
|
dc.DrawRectangle(0, 0, w, h);
|
|
|
|
|
|
|
|
// Draw image content
|
|
|
|
dc.SetBrush(wxBrush(colour));
|
|
|
|
dc.DrawCircle(h / 2, h / 2 + 1, h / 2);
|
|
|
|
dc.SelectObject(wxNullBitmap);
|
|
|
|
|
|
|
|
// Finalize transparency with a mask
|
|
|
|
wxMask *mask = new wxMask(bmp, magic);
|
|
|
|
bmp.SetMask(mask);
|
|
|
|
return bmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxIcon CreateRandomIcon()
|
|
|
|
{
|
|
|
|
static int counter = 0;
|
|
|
|
static const wxColour* colours[] =
|
|
|
|
{
|
|
|
|
wxBLACK,
|
|
|
|
wxWHITE,
|
|
|
|
wxRED,
|
|
|
|
wxBLUE,
|
|
|
|
wxGREEN,
|
|
|
|
wxCYAN,
|
|
|
|
wxLIGHT_GREY
|
|
|
|
};
|
|
|
|
|
|
|
|
wxIcon icon;
|
|
|
|
icon.CopyFromBitmap(CreateBitmap(*(colours[counter]), 16, 16));
|
2014-09-10 10:51:51 -04:00
|
|
|
counter += 1;
|
|
|
|
counter = counter % WXSIZEOF(colours);
|
2014-09-10 10:49:55 -04:00
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
2014-09-10 10:49:33 -04:00
|
|
|
class MyApp : public wxApp
|
|
|
|
{
|
|
|
|
public:
|
2018-03-06 17:12:19 -05:00
|
|
|
virtual bool OnInit() wxOVERRIDE;
|
2014-09-10 10:49:33 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
class MyFrame : public wxFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MyFrame(const wxString& title);
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxDECLARE_EVENT_TABLE();
|
|
|
|
|
|
|
|
void OnSetProgressValue(wxScrollEvent& WXUNUSED(event));
|
2014-09-10 10:49:44 -04:00
|
|
|
void OnVisibilityChange(wxCommandEvent& WXUNUSED(event));
|
2014-09-10 10:49:55 -04:00
|
|
|
void OnSetThumbnailTooltipBtn(wxCommandEvent& WXUNUSED(event));
|
|
|
|
void OnChoice(wxCommandEvent& event);
|
|
|
|
void OnSetOverlayIcon(wxCommandEvent& WXUNUSED(event));
|
|
|
|
void OnClearOverlayIcon(wxCommandEvent& WXUNUSED(event));
|
|
|
|
void OnSetOrRestoreThumbnailClip(wxCommandEvent& event);
|
2014-09-10 10:50:08 -04:00
|
|
|
void OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
2014-09-10 10:51:29 -04:00
|
|
|
void OnRemoveThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
2014-09-10 10:50:08 -04:00
|
|
|
void OnThumbnailToolbarBtnClicked(wxCommandEvent& event);
|
2014-09-10 10:49:33 -04:00
|
|
|
|
|
|
|
wxSlider *m_slider;
|
2014-09-10 10:49:44 -04:00
|
|
|
wxRadioBox *m_visibilityRadioBox;
|
2014-09-10 10:49:55 -04:00
|
|
|
wxTextCtrl *m_textCtrl;
|
|
|
|
wxChoice *m_stateChoice;
|
2014-09-10 10:51:29 -04:00
|
|
|
|
|
|
|
typedef wxVector<wxThumbBarButton*> wxThumbBarButtons;
|
|
|
|
wxThumbBarButtons m_thumbBarButtons;
|
2014-09-10 10:49:33 -04:00
|
|
|
};
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxIMPLEMENT_APP(MyApp);
|
2014-09-10 10:49:33 -04:00
|
|
|
|
|
|
|
bool MyApp::OnInit()
|
|
|
|
{
|
|
|
|
if ( !wxApp::OnInit() )
|
|
|
|
return false;
|
2014-09-10 10:54:51 -04:00
|
|
|
|
2014-09-10 10:54:40 -04:00
|
|
|
wxTaskBarJumpList jumpList;
|
|
|
|
wxTaskBarJumpListItem *item1 = new wxTaskBarJumpListItem(
|
2014-09-10 10:55:21 -04:00
|
|
|
NULL,
|
2014-09-10 10:54:40 -04:00
|
|
|
wxTASKBAR_JUMP_LIST_TASK,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Task 1",
|
2014-09-10 10:53:57 -04:00
|
|
|
wxStandardPaths::Get().GetExecutablePath(),
|
|
|
|
wxEmptyString,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Test Task",
|
2014-09-10 10:53:57 -04:00
|
|
|
wxStandardPaths::Get().GetExecutablePath(),
|
|
|
|
0);
|
2014-09-10 10:54:40 -04:00
|
|
|
wxTaskBarJumpListItem *item2 = new wxTaskBarJumpListItem(
|
2014-09-10 10:55:21 -04:00
|
|
|
NULL,
|
2014-09-10 10:54:40 -04:00
|
|
|
wxTASKBAR_JUMP_LIST_TASK,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Task 2",
|
2014-09-10 10:53:57 -04:00
|
|
|
wxStandardPaths::Get().GetExecutablePath(),
|
|
|
|
wxEmptyString,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Test Task",
|
2014-09-10 10:53:57 -04:00
|
|
|
wxStandardPaths::Get().GetExecutablePath(),
|
|
|
|
0);
|
2014-09-10 10:54:40 -04:00
|
|
|
jumpList.GetTasks().Append(item1);
|
|
|
|
jumpList.GetTasks().Append(
|
2014-09-10 10:55:21 -04:00
|
|
|
new wxTaskBarJumpListItem(NULL, wxTASKBAR_JUMP_LIST_SEPARATOR));
|
2014-09-10 10:54:40 -04:00
|
|
|
jumpList.GetTasks().Append(item2);
|
2014-09-10 10:53:57 -04:00
|
|
|
jumpList.ShowRecentCategory();
|
|
|
|
jumpList.ShowFrequentCategory();
|
2014-09-10 10:54:08 -04:00
|
|
|
|
2014-09-10 10:55:21 -04:00
|
|
|
wxTaskBarJumpListCategory* customCategory =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxTaskBarJumpListCategory(&jumpList, "Custom");
|
2014-09-10 10:54:40 -04:00
|
|
|
wxTaskBarJumpListItem* item3 = new wxTaskBarJumpListItem(
|
2014-09-10 10:55:21 -04:00
|
|
|
customCategory,
|
2017-06-21 14:48:08 -04:00
|
|
|
wxTASKBAR_JUMP_LIST_DESTINATION,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Help",
|
2014-09-10 10:54:08 -04:00
|
|
|
wxStandardPaths::Get().GetExecutablePath(),
|
2018-09-22 19:15:08 -04:00
|
|
|
"--help",
|
|
|
|
"wxTaskBarButton help.",
|
2014-09-10 10:54:08 -04:00
|
|
|
wxStandardPaths::Get().GetExecutablePath(),
|
|
|
|
0);
|
|
|
|
customCategory->Append(item3);
|
2014-09-10 10:54:51 -04:00
|
|
|
jumpList.AddCustomCategory(customCategory);
|
2014-09-10 10:54:08 -04:00
|
|
|
|
2014-09-10 10:54:40 -04:00
|
|
|
const wxTaskBarJumpListCategory& frequentCategory =
|
|
|
|
jumpList.GetFrequentCategory();
|
|
|
|
const wxTaskBarJumpListItems& frequentItems = frequentCategory.GetItems();
|
2014-09-10 10:53:57 -04:00
|
|
|
for ( size_t i = 0; i < frequentItems.size(); ++i )
|
|
|
|
{
|
|
|
|
wxLogMessage(frequentItems[i]->GetFilePath());
|
|
|
|
}
|
2014-09-10 10:54:40 -04:00
|
|
|
|
|
|
|
const wxTaskBarJumpListCategory& recentCategory =
|
|
|
|
jumpList.GetRecentCategory();
|
|
|
|
const wxTaskBarJumpListItems& recentItems = recentCategory.GetItems();
|
2014-09-10 10:53:57 -04:00
|
|
|
for ( size_t i = 0; i < recentItems.size(); ++i )
|
|
|
|
{
|
|
|
|
wxLogMessage(recentItems[i]->GetFilePath());
|
|
|
|
}
|
2014-09-10 10:49:33 -04:00
|
|
|
|
2014-09-10 10:50:08 -04:00
|
|
|
MyFrame *frame = new MyFrame("wxTaskBarButton App");
|
2014-09-14 19:58:14 -04:00
|
|
|
if ( !frame->MSWGetTaskBarButton() )
|
|
|
|
{
|
|
|
|
wxLogError("Task bar button API is not available on this system, sorry.");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-09-10 10:49:33 -04:00
|
|
|
frame->Show(true);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MyFrame::MyFrame(const wxString& title)
|
|
|
|
: wxFrame(NULL, wxID_ANY, title)
|
|
|
|
{
|
|
|
|
wxPanel *panel = new wxPanel(this);
|
|
|
|
wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
wxFlexGridSizer *gs = new wxFlexGridSizer(4, 2, 10, 10);
|
|
|
|
|
|
|
|
// SetProgressValue section.
|
|
|
|
wxStaticBoxSizer *spvSizer =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxStaticBoxSizer(wxVERTICAL, panel, "SetProgressValue");
|
2014-09-10 10:49:33 -04:00
|
|
|
int flags = wxSL_MIN_MAX_LABELS | wxSL_VALUE_LABEL | wxSL_AUTOTICKS;
|
|
|
|
m_slider = new wxSlider(spvSizer->GetStaticBox(), ProgressValueSlider,
|
|
|
|
0, 0, 100,
|
|
|
|
wxDefaultPosition, wxSize(250, -1),
|
|
|
|
flags);
|
|
|
|
m_slider->SetTickFreq(10);
|
|
|
|
spvSizer->Add(m_slider);
|
|
|
|
|
2014-09-10 10:49:44 -04:00
|
|
|
// Show/Hide in Taskbar section.
|
|
|
|
const wxString labels[] =
|
|
|
|
{
|
|
|
|
"&Show in Taskbar",
|
|
|
|
"&Hide in Taskbar"
|
|
|
|
};
|
|
|
|
m_visibilityRadioBox = new wxRadioBox(panel, VisibilityRadio, "Visibility:",
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
WXSIZEOF(labels), labels,
|
|
|
|
1, wxRA_SPECIFY_ROWS);
|
2014-09-10 10:49:55 -04:00
|
|
|
// SetThumbnailTooltip section.
|
|
|
|
wxStaticBoxSizer *sttSizer =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxStaticBoxSizer(wxVERTICAL, panel, "SetThumbnailTooltip");
|
2014-09-10 10:49:55 -04:00
|
|
|
m_textCtrl = new wxTextCtrl(panel, wxID_ANY);
|
2018-09-22 19:15:08 -04:00
|
|
|
wxButton *btn = new wxButton(panel, ThumbnailTooltipSetBtn, "Set");
|
2014-09-10 10:49:55 -04:00
|
|
|
sttSizer->Add(m_textCtrl, 1, wxEXPAND | wxALL, 2);
|
|
|
|
sttSizer->Add(btn, 1, wxEXPAND | wxALL, 2);
|
|
|
|
|
|
|
|
// SetProgressState section.
|
|
|
|
wxStaticBoxSizer *spsSizer =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxStaticBoxSizer(wxVERTICAL, panel, "SetProgressState");
|
2014-09-10 10:49:55 -04:00
|
|
|
const wxString choices[] =
|
|
|
|
{
|
|
|
|
"wxNoProgress",
|
|
|
|
"wxIndeterminate",
|
|
|
|
"wxNormal",
|
|
|
|
"wxError",
|
|
|
|
"wxPaused"
|
|
|
|
};
|
|
|
|
m_stateChoice = new wxChoice(panel, ProgressStateChoice,
|
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
WXSIZEOF(choices), choices);
|
|
|
|
spsSizer->Add(m_stateChoice, 0, wxALL | wxGROW, 5);
|
|
|
|
|
|
|
|
// SetOverlayIcon section.
|
|
|
|
wxStaticBoxSizer *soiSizer =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxStaticBoxSizer(wxVERTICAL, panel, "SetOverlayIcon");
|
2014-09-10 10:49:55 -04:00
|
|
|
wxButton *setOverlayIconBtn =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxButton(panel, SetOverlayIconBtn, "Set Overlay Icon");
|
2014-09-10 10:49:55 -04:00
|
|
|
wxButton *clearOverlayIconBtn =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxButton(panel, ClearOverlayIconBtn, "Clear Overlay Icon");
|
2014-09-10 10:49:55 -04:00
|
|
|
soiSizer->Add(setOverlayIconBtn, 1, wxEXPAND | wxALL, 2);
|
|
|
|
soiSizer->Add(clearOverlayIconBtn, 1, wxEXPAND | wxALL, 2);
|
|
|
|
|
|
|
|
// SetThumbnailClip section.
|
|
|
|
wxStaticBoxSizer *stcSizer =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxStaticBoxSizer(wxVERTICAL, panel, "SetThumbnailClip");
|
2014-09-10 10:49:55 -04:00
|
|
|
wxButton *setThumbnailClipBtn =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxButton(panel, SetThumbnailClipBtn, "Set Thumbnail Clip");
|
2014-09-10 10:49:55 -04:00
|
|
|
wxButton *restoreThumbnailClipBtn =
|
|
|
|
new wxButton(panel, RestoreThumbnailClipBtn,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Restore Thumbnail Clip");
|
2014-09-10 10:49:55 -04:00
|
|
|
stcSizer->Add(setThumbnailClipBtn, 1, wxEXPAND | wxALL, 2);
|
|
|
|
stcSizer->Add(restoreThumbnailClipBtn, 1, wxEXPAND | wxALL, 2);
|
2014-09-10 10:49:44 -04:00
|
|
|
|
2014-09-10 10:50:08 -04:00
|
|
|
// Thumbnail Toolbar Buttons section.
|
|
|
|
wxStaticBoxSizer *ttbSizer =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxStaticBoxSizer(wxVERTICAL, panel, "ThumbBar Buttons");
|
2014-09-10 10:50:08 -04:00
|
|
|
wxButton *addThumbBarButtonBtn =
|
2018-09-22 19:15:08 -04:00
|
|
|
new wxButton(panel, AddThumbBarButtonBtn, "Add ThumbBar Button");
|
2014-09-10 10:50:08 -04:00
|
|
|
wxButton *showThumbnailToolbarBtn =
|
2014-09-10 10:51:29 -04:00
|
|
|
new wxButton(panel, RemoveThumbBarButtonBtn,
|
2018-09-22 19:15:08 -04:00
|
|
|
"Remove Last ThumbBar Button");
|
2014-09-10 10:50:08 -04:00
|
|
|
ttbSizer->Add(addThumbBarButtonBtn, 1, wxEXPAND | wxALL, 2);
|
|
|
|
ttbSizer->Add(showThumbnailToolbarBtn, 1, wxEXPAND | wxALL, 2);
|
|
|
|
|
2014-09-10 10:49:33 -04:00
|
|
|
gs->Add(spvSizer, 0, wxEXPAND);
|
2014-09-10 10:49:44 -04:00
|
|
|
gs->Add(m_visibilityRadioBox, 0, wxEXPAND);
|
2014-09-10 10:49:55 -04:00
|
|
|
gs->Add(sttSizer, 0, wxEXPAND);
|
|
|
|
gs->Add(spsSizer, 0, wxEXPAND);
|
|
|
|
gs->Add(soiSizer, 0, wxEXPAND);
|
|
|
|
gs->Add(stcSizer, 0, wxEXPAND);
|
2014-09-10 10:50:08 -04:00
|
|
|
gs->Add(ttbSizer, 0, wxEXPAND);
|
2014-09-10 10:49:33 -04:00
|
|
|
|
|
|
|
wxStaticText *text = new wxStaticText(
|
2018-09-22 19:15:08 -04:00
|
|
|
panel, wxID_ANY, "Welcome to wxTaskBarButton sample");
|
2014-09-10 10:49:33 -04:00
|
|
|
mainSizer->Add(text, 0, wxALIGN_CENTRE_HORIZONTAL);
|
|
|
|
mainSizer->Add(gs);
|
|
|
|
|
|
|
|
panel->SetSizer(mainSizer);
|
|
|
|
|
|
|
|
SetIcon(wxICON(sample));
|
|
|
|
SetSize(537, 420);
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
|
|
|
wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
2014-09-14 19:58:12 -04:00
|
|
|
EVT_COMMAND_SCROLL(ProgressValueSlider, MyFrame::OnSetProgressValue)
|
2014-09-10 10:49:44 -04:00
|
|
|
EVT_RADIOBOX(VisibilityRadio, MyFrame::OnVisibilityChange)
|
2014-09-10 10:49:55 -04:00
|
|
|
EVT_BUTTON(ThumbnailTooltipSetBtn, MyFrame::OnSetThumbnailTooltipBtn)
|
|
|
|
EVT_CHOICE(ProgressStateChoice, MyFrame::OnChoice)
|
|
|
|
EVT_BUTTON(SetOverlayIconBtn, MyFrame::OnSetOverlayIcon)
|
|
|
|
EVT_BUTTON(ClearOverlayIconBtn, MyFrame::OnClearOverlayIcon)
|
|
|
|
EVT_BUTTON(SetThumbnailClipBtn, MyFrame::OnSetOrRestoreThumbnailClip)
|
|
|
|
EVT_BUTTON(RestoreThumbnailClipBtn, MyFrame::OnSetOrRestoreThumbnailClip)
|
2014-09-10 10:50:08 -04:00
|
|
|
EVT_BUTTON(AddThumbBarButtonBtn, MyFrame::OnAddThubmBarButton)
|
2014-09-10 10:51:29 -04:00
|
|
|
EVT_BUTTON(RemoveThumbBarButtonBtn, MyFrame::OnRemoveThubmBarButton)
|
2014-09-10 10:50:08 -04:00
|
|
|
EVT_BUTTON(ThumbnailToolbarBtn_0, MyFrame::OnThumbnailToolbarBtnClicked)
|
|
|
|
EVT_BUTTON(ThumbnailToolbarBtn_1, MyFrame::OnThumbnailToolbarBtnClicked)
|
|
|
|
EVT_BUTTON(ThumbnailToolbarBtn_2, MyFrame::OnThumbnailToolbarBtnClicked)
|
|
|
|
EVT_BUTTON(ThumbnailToolbarBtn_3, MyFrame::OnThumbnailToolbarBtnClicked)
|
|
|
|
EVT_BUTTON(ThumbnailToolbarBtn_4, MyFrame::OnThumbnailToolbarBtnClicked)
|
|
|
|
EVT_BUTTON(ThumbnailToolbarBtn_5, MyFrame::OnThumbnailToolbarBtnClicked)
|
|
|
|
EVT_BUTTON(ThumbnailToolbarBtn_6, MyFrame::OnThumbnailToolbarBtnClicked)
|
2014-09-10 10:49:33 -04:00
|
|
|
wxEND_EVENT_TABLE()
|
|
|
|
|
|
|
|
void MyFrame::OnSetProgressValue(wxScrollEvent& WXUNUSED(event))
|
|
|
|
{
|
2014-09-10 10:51:09 -04:00
|
|
|
static bool s_hasRangeSet = false;
|
|
|
|
if ( !s_hasRangeSet )
|
|
|
|
{
|
|
|
|
MSWGetTaskBarButton()->SetProgressRange(100);
|
|
|
|
s_hasRangeSet = true;
|
|
|
|
}
|
|
|
|
|
2014-09-10 10:49:33 -04:00
|
|
|
MSWGetTaskBarButton()->SetProgressValue(m_slider->GetValue());
|
|
|
|
}
|
2014-09-10 10:49:44 -04:00
|
|
|
|
|
|
|
void MyFrame::OnVisibilityChange(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
if ( m_visibilityRadioBox->GetSelection() == 0 )
|
2014-09-10 10:49:55 -04:00
|
|
|
MSWGetTaskBarButton()->Show();
|
2014-09-10 10:49:44 -04:00
|
|
|
else
|
2014-09-10 10:49:55 -04:00
|
|
|
MSWGetTaskBarButton()->Hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSetThumbnailTooltipBtn(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
MSWGetTaskBarButton()->SetThumbnailTooltip(m_textCtrl->GetLineText(0));
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnChoice(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
int sel = event.GetSelection();
|
|
|
|
wxTaskBarButtonState state;
|
|
|
|
switch(sel)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
state = wxTASKBAR_BUTTON_NO_PROGRESS;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
state = wxTASKBAR_BUTTON_INDETERMINATE;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
state = wxTASKBAR_BUTTON_NORMAL;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
state = wxTASKBAR_BUTTON_ERROR;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
state = wxTASKBAR_BUTTON_PAUSED;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
state = wxTASKBAR_BUTTON_NO_PROGRESS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-09-10 10:51:29 -04:00
|
|
|
MSWGetTaskBarButton()->SetProgressValue(m_slider->GetValue());
|
2014-09-10 10:49:55 -04:00
|
|
|
MSWGetTaskBarButton()->SetProgressState(state);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSetOverlayIcon(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
MSWGetTaskBarButton()->SetOverlayIcon(CreateRandomIcon());
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnClearOverlayIcon(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
MSWGetTaskBarButton()->SetOverlayIcon(wxNullIcon);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnSetOrRestoreThumbnailClip(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
wxRect rect;
|
|
|
|
if ( event.GetId() == SetThumbnailClipBtn )
|
|
|
|
{
|
|
|
|
static const int CLIP_LENGTH = 100;
|
|
|
|
int height, width;
|
|
|
|
GetClientSize(&width, &height);
|
|
|
|
rect.SetX((width - CLIP_LENGTH) / 2);
|
|
|
|
rect.SetY((height - CLIP_LENGTH) / 2);
|
|
|
|
rect.SetHeight(CLIP_LENGTH);
|
|
|
|
rect.SetWidth(CLIP_LENGTH);
|
|
|
|
}
|
|
|
|
|
|
|
|
MSWGetTaskBarButton()->SetThumbnailClip(rect);
|
2014-09-10 10:49:44 -04:00
|
|
|
}
|
2014-09-10 10:50:08 -04:00
|
|
|
|
|
|
|
void MyFrame::OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2014-09-10 10:51:29 -04:00
|
|
|
if ( m_thumbBarButtons.size() >= 7 )
|
2014-09-10 10:50:08 -04:00
|
|
|
return;
|
|
|
|
|
2014-09-10 10:52:55 -04:00
|
|
|
wxThumbBarButton *button =
|
2014-09-10 10:51:29 -04:00
|
|
|
new wxThumbBarButton(m_thumbBarButtons.size() + ThumbnailToolbarBtn_0 ,
|
|
|
|
CreateRandomIcon());
|
|
|
|
MSWGetTaskBarButton()->AppendThumbBarButton(button);
|
|
|
|
m_thumbBarButtons.push_back(button);
|
2014-09-10 10:50:08 -04:00
|
|
|
}
|
|
|
|
|
2014-09-10 10:51:29 -04:00
|
|
|
void MyFrame::OnRemoveThubmBarButton(wxCommandEvent& WXUNUSED(event))
|
2014-09-10 10:50:08 -04:00
|
|
|
{
|
2014-09-10 10:51:29 -04:00
|
|
|
if ( m_thumbBarButtons.empty() )
|
|
|
|
return;
|
|
|
|
|
|
|
|
wxThumbBarButton* button = m_thumbBarButtons.back();
|
|
|
|
m_thumbBarButtons.pop_back();
|
2018-04-07 16:01:18 -04:00
|
|
|
delete MSWGetTaskBarButton()->RemoveThumbBarButton(button);
|
2014-09-10 10:50:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void MyFrame::OnThumbnailToolbarBtnClicked(wxCommandEvent& event)
|
|
|
|
{
|
|
|
|
wxLogMessage("Thumbnail Toolbar Button %d is clicked.", event.GetId());
|
|
|
|
}
|