/[winpt]/trunk/Src/wptHotkey.cpp
ViewVC logotype

Annotation of /trunk/Src/wptHotkey.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 36 - (hide annotations)
Thu Oct 27 15:25:13 2005 UTC (19 years, 4 months ago) by werner
File size: 3382 byte(s)
First set of changes to use autotools for building.
1 werner 36 /* wptHotkey.cpp - Systemwide hotkeys
2     * Copyright (C) 2001, 2002, 2003 Timo Schulz
3     *
4     * This file is part of WinPT.
5     *
6     * WinPT is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU General Public License
8     * as published by the Free Software Foundation; either version 2
9     * of the License, or (at your option) any later version.
10     *
11     * WinPT 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 GNU
14     * General Public License for more details.
15     *
16     * You should have received a copy of the GNU General Public License
17     * along with WinPT; if not, write to the Free Software Foundation,
18     * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     */
20    
21     #ifdef HAVE_CONFIG_H
22     #include <config.h>
23     #endif
24    
25     #include <windows.h>
26     #include <windows.h>
27    
28     #include "wptHotkey.h"
29     #include "wptGPG.h"
30     #include "wptRegistry.h"
31     #include "wptErrors.h"
32     #include "wptNLS.h"
33     #include "wptTypes.h"
34    
35     static int err_hotkey = 0;
36    
37     const char *
38     hotkeys_strerror (void)
39     {
40     switch (err_hotkey) {
41     case 0: return NULL;
42     case 1: return _("Clipboard Encrypt (ALT+CTRL+E)");
43     case 2: return _("Clipboard Decrypt/Verify (ALT+CTRL+D)");
44     case 3: return _("Clipboard Sign (ALT+CTRL+S)");
45     case 4: return _("Clipboard Sign Encrypt (ALT+CTRL+B)");
46     case 5: return _("Current Window Encrypt (ALT+SHIFT+E)");
47     case 6: return _("Current Window Decrypt/Verify (ALT+SHIFT+D)");
48     case 7: return _("Current Window Sign (ALT+SHIFT+S)");
49     case 8: return _("Current Window Sign Encrypt (ALT+SHIFT+B");
50     default: return _("Unknown Hotkey");
51     }
52     return NULL;
53     }
54    
55    
56     int
57     hotkeys_register (HWND wnd)
58     {
59     int j = 0, rc = 0;
60    
61     err_hotkey = 0; /* reset */
62     for (j=0; wpt_hotkeys[j].id != 0; j++) {
63     if (wpt_hotkeys[j].enabled) {
64     rc = hotkey_register_single (wnd, &wpt_hotkeys[j]);
65     if (rc) {
66     err_hotkey = j+1;
67     break;
68     }
69     }
70     }
71    
72     return rc;
73     } /* hotkeys_register */
74    
75    
76     int
77     hotkeys_unregister (HWND wnd)
78     {
79     int j = 0, rc = 0;
80    
81     for (j=0; wpt_hotkeys[j].id != 0; j++) {
82     if (wpt_hotkeys[j].enabled) {
83     rc = hotkey_unregister_single (wnd, &wpt_hotkeys[j]);
84     if (rc)
85     break;
86     }
87     }
88    
89     return rc;
90     } /* hotkeys_unregister */
91    
92    
93     int
94     hotkey_register_single (HWND wnd, hotkey_t hk)
95     {
96     int rc, keymod;
97    
98     if (!hk->enabled)
99     return 0;
100    
101     if (hk->alt_ctrl)
102     keymod = MOD_CONTROL | MOD_ALT;
103     else if (hk->alt_shift)
104     keymod = MOD_ALT | MOD_SHIFT;
105    
106     rc = RegisterHotKey (wnd, hk->id, keymod, hk->key);
107     if (!rc)
108     return WPTERR_HOTKEY;
109     return 0;
110     } /* hotkey_register_single */
111    
112     int
113     hotkey_unregister_single (HWND wnd, hotkey_t hk)
114     {
115     int rc = UnregisterHotKey (wnd, hk->id);
116     return rc==0? WPTERR_HOTKEY: 0;
117     } /* hotkey_unregister_single */
118    
119    
120     void
121     hotkeys_modify (void)
122     {
123     int i;
124    
125     for (i = 0; wpt_hotkeys[i].id; i++) {
126     if( reg_hotkeys[i].enabled ) {
127     wpt_hotkeys[i].key = reg_hotkeys[i].key[0];
128     wpt_hotkeys[i].enabled = 1;
129     }
130     }
131     } /* hotkeys_modify */
132    
133    
134     void
135     hotkey_disable (reg_hotkey_t rhk)
136     {
137     strcpy (rhk->key, " ");
138     rhk->enabled = 0;
139     } /* hotkey_disable */
140    
141    
142     void
143     hotkey_enable (reg_hotkey_t rhk, const char * key)
144     {
145     if (strlen (key) > 2)
146     BUG (0);
147     strcpy (rhk->key, key);
148     rhk->enabled = 1;
149     } /* hotkey_enable */

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26