Aquila  2.0 prealpha
Cognitive Robotics Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
win7progressBar.h
Go to the documentation of this file.
1 //##############################################################################################################################################################################################################//
2 //Aquila - An Open-Source GPU-Accelerated Toolkit for Cognitive and Neuro-Robotics Research //
3 // //
4 //Copyright (c) <2012>, <Martin Peniak - www.martinpeniak.com> //
5 //All rights reserved. //
6 // //
7 //Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: //
8 // //
9 // - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. //
10 // - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. //
11 // //
12 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR //
13 //A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT //
14 //LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR //
15 //TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. //
16 // //
17 //The views and conclusions contained in the software and documentation are those of the authors and should not be interpreted //
18 //as representing official policies,either expressed or implied, of the FreeBSD Project. //
19 //##############################################################################################################################################################################################################//
20 //Acknowledgement: This class is based on EcWin7 library by Emanuele Colombo
21 
22 #ifndef WIN7_PROGRESS_BAR_H
23 #define WIN7_PROGRESS_BAR_H
24 
25 #include <QObject>
26 
27 #if defined _WIN64 || defined _WIN32
28 #include <Windows.h>
29 #endif
30 
31 #ifdef NTDDI_WIN7
32 #include <QtGui>
33 #include <InitGuid.h>
34 #include <vector>
35 
36 using namespace std;
37 
38 #define CMIC_MASK_ASYNCOK SEE_MASK_ASYNCOK
39 
40 //structs types and enums definitions for Windows 7 taskbar
41 typedef enum THUMBBUTTONMASK
42 {
43  THB_BITMAP = 0x1,
44  THB_ICON = 0x2,
45  THB_TOOLTIP = 0x4,
46  THB_FLAGS = 0x8
47 } THUMBBUTTONMASK;
48 
49 typedef enum THUMBBUTTONFLAGS
50 {
51  THBF_ENABLED = 0,
52  THBF_DISABLED = 0x1,
53  THBF_DISMISSONCLICK = 0x2,
54  THBF_NOBACKGROUND = 0x4,
55  THBF_HIDDEN = 0x8,
56  THBF_NONINTERACTIVE = 0x10
57 } THUMBBUTTONFLAGS;
58 
59 typedef struct THUMBBUTTON
60 {
61  THUMBBUTTONMASK dwMask;
62  UINT iId;
63  UINT iBitmap;
64  HICON hIcon;
65  WCHAR szTip[260];
66  THUMBBUTTONFLAGS dwFlags;
67 } THUMBBUTTON;
68 typedef struct THUMBBUTTON *LPTHUMBBUTTON;
69 
70 typedef enum TBPFLAG
71 {
72  TBPF_NOPROGRESS = 0,
73  TBPF_INDETERMINATE = 0x1,
74  TBPF_NORMAL = 0x2,
75  TBPF_ERROR = 0x4,
76  TBPF_PAUSED = 0x8
77 } TBPFLAG;
78 
79 typedef IUnknown *HIMAGELIST;
80 
81 //taskbar interface
82 DECLARE_INTERFACE_(ITaskbarList3,IUnknown)
83 {
84  //IUnknown
85  STDMETHOD(QueryInterface) (THIS_ REFIID riid,void **ppv) PURE;
86  STDMETHOD_(ULONG,AddRef) (THIS) PURE;
87  STDMETHOD_(ULONG,Release) (THIS) PURE;
88 
89  //ITaskbarList
90  STDMETHOD(HrInit) (THIS) PURE;
91  STDMETHOD(AddTab) (THIS_ HWND hwnd) PURE;
92  STDMETHOD(DeleteTab) (THIS_ HWND hwnd) PURE;
93  STDMETHOD(ActivateTab) (THIS_ HWND hwnd) PURE;
94  STDMETHOD(SetActiveAlt) (THIS_ HWND hwnd) PURE;
95  STDMETHOD (MarkFullscreenWindow) (THIS_ HWND hwnd, int fFullscreen) PURE;
96 
97  //ITaskbarList3
98  STDMETHOD (SetProgressValue) (THIS_ HWND hwnd, ULONGLONG ullCompleted, ULONGLONG ullTotal) PURE;
99  STDMETHOD (SetProgressState) (THIS_ HWND hwnd, TBPFLAG tbpFlags) PURE;
100  STDMETHOD (RegisterTab) (THIS_ HWND hwndTab,HWND hwndMDI) PURE;
101  STDMETHOD (UnregisterTab) (THIS_ HWND hwndTab) PURE;
102  STDMETHOD (SetTabOrder) (THIS_ HWND hwndTab, HWND hwndInsertBefore) PURE;
103  STDMETHOD (SetTabActive) (THIS_ HWND hwndTab, HWND hwndMDI, DWORD dwReserved) PURE;
104  STDMETHOD (ThumbBarAddButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE;
105  STDMETHOD (ThumbBarUpdateButtons) (THIS_ HWND hwnd, UINT cButtons, LPTHUMBBUTTON pButton) PURE;
106  STDMETHOD (ThumbBarSetImageList) (THIS_ HWND hwnd, HIMAGELIST himl) PURE;
107 
108  //STDMETHOD (SetOverlayIcon) (THIS_ HWND hwnd, HICON hIcon, LPCWSTR pszDescription) PURE;
109  STDMETHOD (SetThumbnailTooltip) (THIS_ HWND hwnd, LPCWSTR pszTip) PURE;
110  STDMETHOD (SetThumbnailClip) (THIS_ HWND hwnd, RECT *prcClip) PURE;
111 };
112 typedef ITaskbarList3 *LPITaskbarList3;
113 #endif
114 
116 class Win7ProgressBar: public QObject
117 {
118  Q_OBJECT
119 public:
120  Win7ProgressBar();
121 #ifdef NTDDI_WIN7
122 
123  //progress indicator handling
124  enum ToolBarProgressState
125  {
126  NoProgress = 0,
127  Indeterminate = 1,
128  Normal = 2,
129  Error = 4,
130  Paused = 8
131  };
132 
133  void init(WId wid);
134  void setProgressValue(int value, int max);
135  void setProgressState(ToolBarProgressState state);
136  void setClientProgress(int id, int progress);
137  void removeClient(int id);
138  void showOverallProgress();
139  bool winEvent(MSG * message, long * result);
140  int addClient();
141 
142 private:
143  int clients;
144  WId mWindowId;
145  UINT mTaskbarMessageId;
146  ITaskbarList3 *mTaskbar;
147  vector<int> clientProgress;
148 #endif
149 };
150 
151 #endif//WIN7_PROGRESS_BAR_H