forked from arthurzam/dukto-qt5
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathecwin7.h
139 lines (121 loc) · 4.27 KB
/
ecwin7.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* EcWin7 - Support library for integrating Windows 7 taskbar features
* into any Qt application
* Copyright (C) 2010 Emanuele Colombo
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef ECWIN7_H
#define ECWIN7_H
#include <QtGlobal>
// Windows only data definitions
#ifdef Q_OS_WIN
#include <windows.h>
#include <initguid.h>
#define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK
// Structs types and enums definitions for Windows 7 taskbar
typedef enum THUMBBUTTONMASK
{
THB_BITMAP = 0x1,
THB_ICON = 0x2,
THB_TOOLTIP = 0x4,
THB_FLAGS = 0x8
} THUMBBUTTONMASK;
typedef enum THUMBBUTTONFLAGS
{
THBF_ENABLED = 0,
THBF_DISABLED = 0x1,
THBF_DISMISSONCLICK = 0x2,
THBF_NOBACKGROUND = 0x4,
THBF_HIDDEN = 0x8,
THBF_NONINTERACTIVE = 0x10
} THUMBBUTTONFLAGS;
typedef struct THUMBBUTTON
{
THUMBBUTTONMASK dwMask;
UINT iId;
UINT iBitmap;
HICON hIcon;
WCHAR szTip[260];
THUMBBUTTONFLAGS dwFlags;
} THUMBBUTTON;
typedef struct THUMBBUTTON *LPTHUMBBUTTON;
typedef enum TBPFLAG
{
TBPF_NOPROGRESS = 0,
TBPF_INDETERMINATE = 0x1,
TBPF_NORMAL = 0x2,
TBPF_ERROR = 0x4,
TBPF_PAUSED = 0x8
} TBPFLAG;
typedef IUnknown *HIMAGELIST;
// Taskbar interface
DECLARE_INTERFACE_(ITaskbarList3,IUnknown)
{
// IUnknown
STDMETHOD(QueryInterface) (THIS_ REFIID riid,void **ppv) PURE;
STDMETHOD_(ULONG,AddRef) (THIS) PURE;
STDMETHOD_(ULONG,Release) (THIS) PURE;
// ITaskbarList
STDMETHOD(HrInit) (THIS) PURE;
STDMETHOD(AddTab) (THIS_ HWND hwnd) PURE;
STDMETHOD(DeleteTab) (THIS_ HWND hwnd) PURE;
STDMETHOD(ActivateTab) (THIS_ HWND hwnd) PURE;
STDMETHOD(SetActiveAlt) (THIS_ HWND hwnd) PURE;
STDMETHOD (MarkFullscreenWindow) (THIS_ HWND hwnd, int fFullscreen) PURE;
// ITaskbarList3
STDMETHOD (SetProgressValue) (THIS_ HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) PURE;
STDMETHOD (SetProgressState) (THIS_ HWND hwnd, TBPFLAG tbpFlags) PURE;
STDMETHOD (RegisterTab) (THIS_ HWND hwndTab,HWND hwndMDI) PURE;
STDMETHOD (UnregisterTab) (THIS_ HWND hwndTab) PURE;
STDMETHOD (SetTabOrder) (THIS_ HWND hwndTab, HWND hwndInsertBefore) PURE;
STDMETHOD (SetTabActive) (THIS_ HWND hwndTab, HWND hwndMDI, DWORD dwReserved) PURE;
STDMETHOD (ThumbBarAddButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE;
STDMETHOD (ThumbBarUpdateButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE;
STDMETHOD (ThumbBarSetImageList) (THIS_ HWND hwnd, HIMAGELIST himl) PURE;
STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE;
STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE;
STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE;
};
typedef ITaskbarList3 *LPITaskbarList3;
// Windows only data d#endifefinitions - END
// ********************************************************************
// EcWin7 class - Windows 7 taskbar handling for Qt and MinGW
#include <QWindow>
class EcWin7
{
public:
// Progress indicator handling
enum ToolBarProgressState {
NoProgress = 0,
Indeterminate = 1,
Normal = 2,
Error = 4,
Paused = 8
};
// Initialization methods
explicit EcWin7(QWindow *window);
bool winEvent(MSG * message, long * result);
// Overlay icon handling
void setOverlayIcon(const QString &iconName, const QString &description);
void setProgressValue(int value, int max);
void setProgressState(ToolBarProgressState state);
private:
HWND mWindowId;
UINT mTaskbarMessageId;
ITaskbarList3 *mTaskbar = nullptr;
HICON mOverlayIcon = nullptr;
};
#endif
#endif // ECWIN7_H