db318f2be5ef4e6c94824602957de2d609e2f452
[reactos.git] / subsys / system / explorer / taskbar / traynotify.h
1 /*
2  * Copyright 2003 Martin Fuchs
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20  //
21  // Explorer and Desktop clone
22  //
23  // traynotify.h
24  //
25  // Martin Fuchs, 22.08.2003
26  //
27
28
29 #define CLASSNAME_TRAYNOTIFY    _T("TrayNotifyWnd")
30 #define TITLE_TRAYNOTIFY                _T("")
31
32 #define CLASSNAME_CLOCKWINDOW   _T("TrayClockWClass")
33
34 #define NOTIFYAREA_WIDTH                244
35 #define CLOCKWINDOW_WIDTH               32
36
37
38 struct NotifyIconIndex
39 {
40         NotifyIconIndex(NOTIFYICONDATA* pnid);
41
42          // sort operator
43         friend bool operator<(const NotifyIconIndex& a, const NotifyIconIndex& b)
44                 {return a._hWnd<b._hWnd || (a._hWnd==b._hWnd && a._uID<b._uID);}
45
46         HWND    _hWnd;
47         UINT    _uID;
48
49 protected:
50         NotifyIconIndex();
51 };
52
53 struct NotifyInfo : public NotifyIconIndex
54 {
55         NotifyInfo();
56
57          // sort operator
58         friend bool operator<(const NotifyInfo& a, const NotifyInfo& b)
59                 {return a._idx < b._idx;}
60
61         NotifyInfo& operator=(NOTIFYICONDATA* pnid);
62
63         int             _idx;   // display index
64         HICON   _hIcon;
65         DWORD   _dwState;
66         UINT    _uCallbackMessage;
67 };
68
69 typedef map<NotifyIconIndex, NotifyInfo> NotifyIconMap;
70 typedef set<NotifyInfo> NotifyIconSet;
71
72
73  /// tray notification area aka "tray"
74 struct NotifyArea : public Window
75 {
76         typedef Window super;
77
78         NotifyArea(HWND hwnd);
79         ~NotifyArea();
80
81         static HWND Create(HWND hwndParent);
82
83         LRESULT ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pnid);
84
85 protected:
86         NotifyIconMap _icon_map;
87         NotifyIconSet _sorted_icons;
88         int             _next_idx;
89
90         WindowHandle _hwndClock;
91
92         LRESULT Init(LPCREATESTRUCT pcs);
93         LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
94
95         void    Refresh();
96         void    Paint();
97         void    TimerTick();
98         void    CancelModes();
99
100         NotifyIconSet::iterator IconHitTest(const POINT& pos);
101 };
102
103
104  /// window for displaying the time in the tray notification area
105 struct ClockWindow : public Window
106 {
107         typedef Window super;
108
109         ClockWindow(HWND hwnd);
110
111         static HWND Create(HWND hwndParent);
112
113         void    TimerTick();
114
115 protected:
116         LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
117         int             Notify(int id, NMHDR* pnmh);
118
119         bool    FormatTime();
120         void    Paint();
121
122         TCHAR   _time[16];
123         ToolTip _tooltip;
124 };