1 // TimeBar.h --- Time bar
2 //
3 // Copyright (C) 2004, 2005, 2006, 2007 Raymond Penners <raymond@dotsphinx.com>
4 // All rights reserved.
5 //
6 // This program is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 //
19 
20 #ifndef TIMEBAR_H
21 #define TIMEBAR_H
22 
23 #include <windows.h>
24 #include <time.h>
25 
26 #include "ITimeBar.hh"
27 #include "Applet.hh"
28 
29 class CDeskBand;
30 class PaintHelper;
31 
32 class TimeBar
33 {
34 public:
35   TimeBar(HWND hwnd, HINSTANCE hinst, CDeskBand *deskband);
36   ~TimeBar();
37 
38   void set_progress(int value, int max_value);
39   void set_secondary_progress(int value, int max_value);
40 
41   void set_text(const char *text);
42 
43   void update();
44   void set_bar_color(ITimeBar::ColorId color);
45   void set_secondary_bar_color(ITimeBar::ColorId color);
46 
47   void get_size(int &width, int &height);
get_handle()48   HWND get_handle() const { return hwnd; };
49 
50 private:
51   CDeskBand *deskband;
52   HWND hwnd;
53   int width, height;
54   int bar_max_value;
55   int bar_value;
56   int secondary_bar_max_value;
57   int secondary_bar_value;
58   ITimeBar::ColorId secondary_bar_color;
59   ITimeBar::ColorId bar_color;
60   char bar_text[APPLET_BAR_TEXT_MAX_LENGTH];
61   PaintHelper *paint_helper;
62 
63   static HFONT bar_font;
64   static HBRUSH bar_colors[ITimeBar::COLOR_ID_SIZEOF];
65   static void init(HINSTANCE hinst);
66   static LRESULT CALLBACK wnd_proc(HWND hWnd, UINT uMessage, WPARAM wParam,
67                                    LPARAM lParam);
68   void compute_size(int &width, int &height);
69   LRESULT on_paint();
70   void time_to_string(time_t time, char *buf, int len);
71 };
72 
73 
74 struct NONCLIENTMETRICS_PRE_VISTA_STRUCT
75 {
76     UINT    cbSize;
77     int     iBorderWidth;
78     int     iScrollWidth;
79     int     iScrollHeight;
80     int     iCaptionWidth;
81     int     iCaptionHeight;
82     LOGFONT lfCaptionFont;
83     int     iSmCaptionWidth;
84     int     iSmCaptionHeight;
85     LOGFONT lfSmCaptionFont;
86     int     iMenuWidth;
87     int     iMenuHeight;
88     LOGFONT lfMenuFont;
89     LOGFONT lfStatusFont;
90     LOGFONT lfMessageFont;
91 	/*
92 	This is a pre-vista structure for compatibility across platforms.
93 	Normally, when Vista is the target build (WINVER 0x0600),
94 	NONCLIENTMETRICS structs contain an ifdef WINVER >= 0x0600:
95 	int     iPaddedBorderWidth;
96 	*/
97 };
98 
99 #endif // TIMEBAR_H
100 
101