00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef CARCHTASKBARWINDOWS_H
00016 #define CARCHTASKBARWINDOWS_H
00017
00018 #define WIN32_LEAN_AND_MEAN
00019
00020 #include "IArchTaskBar.h"
00021 #include "IArchMultithread.h"
00022 #include "stdmap.h"
00023 #include "stdvector.h"
00024 #include <windows.h>
00025
00026 #define ARCH_TASKBAR CArchTaskBarWindows
00027
00029 class CArchTaskBarWindows : public IArchTaskBar {
00030 public:
00031 CArchTaskBarWindows(void*);
00032 virtual ~CArchTaskBarWindows();
00033
00035
00040 static void addDialog(HWND);
00041
00043
00046 static void removeDialog(HWND);
00047
00048
00049 virtual void addReceiver(IArchTaskBarReceiver*);
00050 virtual void removeReceiver(IArchTaskBarReceiver*);
00051 virtual void updateReceiver(IArchTaskBarReceiver*);
00052
00053 private:
00054 class CReceiverInfo {
00055 public:
00056 UINT m_id;
00057 };
00058
00059 typedef std::map<IArchTaskBarReceiver*, CReceiverInfo> CReceiverToInfoMap;
00060 typedef std::map<UINT, CReceiverToInfoMap::iterator> CIDToReceiverMap;
00061 typedef std::vector<UINT> CIDStack;
00062 typedef std::map<HWND, bool> CDialogs;
00063
00064 UINT getNextID();
00065 void recycleID(UINT);
00066
00067 void addIcon(UINT);
00068 void removeIcon(UINT);
00069 void updateIcon(UINT);
00070 void addAllIcons();
00071 void removeAllIcons();
00072 void modifyIconNoLock(CReceiverToInfoMap::const_iterator,
00073 DWORD taskBarMessage);
00074 void removeIconNoLock(UINT id);
00075 void handleIconMessage(IArchTaskBarReceiver*, LPARAM);
00076
00077 bool processDialogs(MSG*);
00078 LRESULT wndProc(HWND, UINT, WPARAM, LPARAM);
00079 static LRESULT CALLBACK
00080 staticWndProc(HWND, UINT, WPARAM, LPARAM);
00081 void threadMainLoop();
00082 static void* threadEntry(void*);
00083
00084 private:
00085 static CArchTaskBarWindows* s_instance;
00086 static HINSTANCE s_appInstance;
00087
00088
00089 CArchMutex m_mutex;
00090 CArchCond m_condVar;
00091 bool m_ready;
00092 int m_result;
00093 CArchThread m_thread;
00094
00095
00096 HWND m_hwnd;
00097 UINT m_taskBarRestart;
00098
00099
00100 CReceiverToInfoMap m_receivers;
00101 CIDToReceiverMap m_idTable;
00102 CIDStack m_oldIDs;
00103 UINT m_nextID;
00104
00105
00106 CDialogs m_dialogs;
00107 CDialogs m_addedDialogs;
00108 };
00109
00110 #endif