00001 /* 00002 * Copyright 2003, 2004 Martin Fuchs 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this library; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 00019 00020 // 00021 // Explorer and Desktop clone 00022 // 00023 // traynotify.h 00024 // 00025 // Martin Fuchs, 22.08.2003 00026 // 00027 00028 00029 #define CLASSNAME_TRAYNOTIFY TEXT("TrayNotifyWnd") 00030 #define TITLE_TRAYNOTIFY TEXT("") 00031 00032 #define CLASSNAME_CLOCKWINDOW TEXT("TrayClockWClass") 00033 00034 #define NOTIFYAREA_WIDTH_DEF 100 00035 #define NOTIFYICON_DIST 20 00036 #define NOTIFYAREA_SPACE 10 00037 #define NOTIFYICON_SIZE 16 00038 #define NOTIFYICON_X 2 00039 #define NOTIFYICON_Y 3 00040 00041 #define ICON_AUTOHIDE_SECONDS 300 00042 00043 #define PM_GETMODULEPATH_CB (WM_APP+0x21) 00044 #define PM_GET_NOTIFYAREA (WM_APP+0x22) 00045 00046 00047 /// NotifyIconIndex is used for maintaining the order of notification icons. 00048 struct NotifyIconIndex 00049 { 00050 NotifyIconIndex(NOTIFYICONDATA* pnid); 00051 00052 // sort operator 00053 friend bool operator<(const NotifyIconIndex& a, const NotifyIconIndex& b) 00054 {return a._hWnd<b._hWnd || (a._hWnd==b._hWnd && a._uID<b._uID);} 00055 00056 HWND _hWnd; 00057 UINT _uID; 00058 00059 protected: 00060 NotifyIconIndex(); 00061 }; 00062 00063 00064 enum NOTIFYICONMODE { 00065 NIM_SHOW, NIM_HIDE, NIM_AUTO 00066 }; 00067 00068 extern String string_from_mode(NOTIFYICONMODE mode); 00069 00070 /// configuration for the display mode of a notification icon 00071 struct NotifyIconConfig 00072 { 00073 NotifyIconConfig() : _mode(NIM_AUTO) {} 00074 00075 void create_name(); 00076 bool match(const NotifyIconConfig& props) const; 00077 00078 // properties used to identify a notification icon 00079 String _tipText; 00080 String _windowTitle; // To look at the window title and at the window module path of the notify icon owner window 00081 String _modulePath; // to identify notification icons is an extension above XP's behaviour. 00082 // (XP seems to store icon image data in the registry instead.) 00083 NOTIFYICONMODE _mode; 00084 00085 String _name; /// unique name used to identify the entry in the configuration file 00086 }; 00087 00088 /// list of NotifyIconConfig structures 00089 typedef list<NotifyIconConfig> NotifyIconCfgList; 00090 00091 00092 /// structure for maintaining informations about one notification icon 00093 struct NotifyInfo : public NotifyIconIndex, public NotifyIconConfig 00094 { 00095 NotifyInfo(); 00096 00097 // sort operator 00098 friend bool operator<(const NotifyInfo& a, const NotifyInfo& b) 00099 {return a._idx < b._idx;} 00100 00101 bool modify(NOTIFYICONDATA* pnid); 00102 00103 int _idx; // display index 00104 HICON _hIcon; 00105 DWORD _dwState; 00106 UINT _uCallbackMessage; 00107 UINT _version; 00108 00109 DWORD _lastChange; // timer tick value of the last change 00110 }; 00111 00112 typedef map<NotifyIconIndex, NotifyInfo> NotifyIconMap; 00113 typedef set<NotifyInfo> NotifyIconSet; 00114 00115 00116 struct NotifyHook 00117 { 00118 NotifyHook(); 00119 ~NotifyHook(); 00120 00121 void GetModulePath(HWND hwnd, HWND hwndCallback); 00122 bool ModulePathCopyData(LPARAM lparam, HWND* phwnd, String& path); 00123 00124 protected: 00125 const UINT WM_GETMODULEPATH; 00126 }; 00127 00128 00129 /// tray notification area aka "tray" 00130 struct NotifyArea : public Window 00131 { 00132 typedef Window super; 00133 00134 NotifyArea(HWND hwnd); 00135 ~NotifyArea(); 00136 00137 static HWND Create(HWND hwndParent); 00138 00139 LRESULT ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pnid); 00140 00141 protected: 00142 WindowHandle _hwndClock; 00143 int _clock_width; 00144 00145 ToolTip _tooltip; 00146 NotifyHook _hook; 00147 00148 bool _show_hidden; 00149 bool _hide_inactive; 00150 bool _show_button; 00151 00152 LRESULT Init(LPCREATESTRUCT pcs); 00153 LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); 00154 int Command(int id, int code); 00155 int Notify(int id, NMHDR* pnmh); 00156 00157 void UpdateIcons(); 00158 void Paint(); 00159 void Refresh(bool do_refresh=false); 00160 void CancelModes(); 00161 00162 NotifyIconSet::iterator IconHitTest(const POINT& pos); 00163 bool DetermineHideState(NotifyInfo& entry); 00164 00165 void read_config(); 00166 void write_config(); 00167 00168 friend struct TrayNotifyDlg; 00169 00170 NotifyIconCfgList _cfg; 00171 00172 map<HWND, String> _window_modules; 00173 00174 NotifyIconMap _icon_map; 00175 NotifyIconSet _sorted_icons; 00176 int _next_idx; 00177 size_t _last_icon_count; 00178 00179 void show_clock(bool flag); 00180 }; 00181 00182 00183 struct NotifyIconDlgInfo : public NotifyIconConfig 00184 { 00185 typedef NotifyIconConfig super; 00186 00187 NotifyIconDlgInfo(const NotifyInfo& info) : super(info), _lastChange(info._lastChange) {} 00188 NotifyIconDlgInfo(const NotifyIconConfig& cfg) : super(cfg), _lastChange(0) {} 00189 NotifyIconDlgInfo() : _lastChange(0) {} 00190 00191 DWORD _lastChange; 00192 }; 00193 00194 typedef map<int, NotifyIconDlgInfo> NotifyIconDlgInfoMap; 00195 00196 00197 /// configuration dialog for notification icons 00198 struct TrayNotifyDlg : public ResizeController<Dialog> 00199 { 00200 typedef ResizeController<Dialog> super; 00201 00202 TrayNotifyDlg(HWND hwnd); 00203 ~TrayNotifyDlg(); 00204 00205 protected: 00206 HWND _tree_ctrl; 00207 HACCEL _haccel; 00208 HIMAGELIST _himl; 00209 NotifyArea* _pNotifyArea; 00210 NotifyIconDlgInfoMap _info; 00211 00212 typedef pair<NOTIFYICONMODE, DWORD> IconStatePair; 00213 typedef map<NotifyIconIndex, IconStatePair> IconStateMap; 00214 00215 NotifyIconCfgList _cfg_org; 00216 IconStateMap _icon_states_org; 00217 bool _show_hidden_org; 00218 00219 HTREEITEM _hitemCurrent; 00220 HTREEITEM _hitemCurrent_visible; 00221 HTREEITEM _hitemCurrent_hidden; 00222 HTREEITEM _hitemConfig; 00223 HTREEITEM _selectedItem; 00224 00225 virtual LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); 00226 virtual int Command(int id, int code); 00227 virtual int Notify(int id, NMHDR* pnmh); 00228 00229 void Refresh(); 00230 void InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyInfo&, HDC); 00231 void InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyIconDlgInfo&, HDC, HICON, NOTIFYICONMODE); 00232 void SetIconMode(NOTIFYICONMODE mode); 00233 void RefreshProperties(const NotifyIconDlgInfo& entry); 00234 }; 00235 00236 00237 /// window for displaying the time in the tray notification area 00238 struct ClockWindow : public Window 00239 { 00240 typedef Window super; 00241 00242 ClockWindow(HWND hwnd); 00243 00244 static HWND Create(HWND hwndParent); 00245 00246 void TimerTick(); 00247 00248 protected: 00249 LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam); 00250 int Notify(int id, NMHDR* pnmh); 00251 00252 bool FormatTime(); 00253 void Paint(); 00254 00255 TCHAR _time[16]; 00256 ToolTip _tooltip; 00257 };
ROS Explorer Source Code Documentation
generated on 02.01.2013 by ![]() |