1 // Applet.h --- Applet
2 //
3 // Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 Rob Caelers & Raymond Penners
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 APPLET_H
21 #define APPLET_H
22 
23 #include "ICore.hh"
24 using namespace workrave;
25 
26 #define APPLET_WINDOW_CLASS_NAME "WorkraveApplet"
27 #define APPLET_BAR_TEXT_MAX_LENGTH 16
28 
29 #define APPLET_MESSAGE_HEARTBEAT 0
30 #define APPLET_MESSAGE_MENU 1
31 
32 
33 /*!!!!!!!!!!!!!!!!!!!
34 On Windows x64, the installed Applet will be 64-bit.
35 
36 Therefore Workrave (32-bit) could be passing structures to a
37 64-bit applet. And so we must ensure that all members of any
38 passed structure have types that are the same size on both
39 32 and 64 bit Windows.
40 
41 All structures declared in this file are used by both
42 Workrave (x86) and the applet (x86 & x64).
43 */
44 
45 
46 struct AppletHeartbeatData
47 {
48   volatile bool enabled;
49   short slots[BREAK_ID_SIZEOF];
50 
51   char bar_text[BREAK_ID_SIZEOF][APPLET_BAR_TEXT_MAX_LENGTH];
52 
53   short bar_secondary_color[BREAK_ID_SIZEOF];
54   int bar_secondary_val[BREAK_ID_SIZEOF];
55   int bar_secondary_max[BREAK_ID_SIZEOF];
56 
57   short bar_primary_color[BREAK_ID_SIZEOF];
58   int bar_primary_val[BREAK_ID_SIZEOF];
59   int bar_primary_max[BREAK_ID_SIZEOF];
60 };
61 
62 #define APPLET_MAX_MENU_ITEMS 16
63 #define APPLET_MENU_TEXT_MAX_LENGTH 48
64 
65 #define APPLET_MENU_FLAG_TOGGLE 1
66 #define APPLET_MENU_FLAG_SELECTED 2
67 #define APPLET_MENU_FLAG_POPUP 4
68 
69 struct AppletMenuItemData
70 {
71   char text[APPLET_MENU_TEXT_MAX_LENGTH]; // mbs
72   int flags;
73   short command;
74 };
75 
76 struct AppletMenuData
77 {
78   short num_items;
79 
80   /*
81   MSDN notes:
82   Handles have 32 significant bits on 64-bit Windows
83   .
84   We must ensure that our types are the same size
85   on both 64 and 32 bit systems (see x64 comment).
86 
87   We will pass the command_window HWND as a LONG:
88   */
89   LONG command_window;
90 
91   AppletMenuItemData items[APPLET_MAX_MENU_ITEMS];
92 };
93 
94 
95 #endif /* APPLET_H */
96