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

Annotation of /trunk/Src/wptHotkey.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 69 - (hide annotations)
Sat Nov 5 12:28:12 2005 UTC (19 years, 3 months ago) by twoaday
File size: 3371 byte(s)
More minor fixes...

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    
27     #include "wptHotkey.h"
28     #include "wptGPG.h"
29     #include "wptRegistry.h"
30     #include "wptErrors.h"
31     #include "wptNLS.h"
32     #include "wptTypes.h"
33    
34     static int err_hotkey = 0;
35    
36     const char *
37     hotkeys_strerror (void)
38     {
39     switch (err_hotkey) {
40     case 0: return NULL;
41     case 1: return _("Clipboard Encrypt (ALT+CTRL+E)");
42     case 2: return _("Clipboard Decrypt/Verify (ALT+CTRL+D)");
43     case 3: return _("Clipboard Sign (ALT+CTRL+S)");
44     case 4: return _("Clipboard Sign Encrypt (ALT+CTRL+B)");
45     case 5: return _("Current Window Encrypt (ALT+SHIFT+E)");
46     case 6: return _("Current Window Decrypt/Verify (ALT+SHIFT+D)");
47     case 7: return _("Current Window Sign (ALT+SHIFT+S)");
48     case 8: return _("Current Window Sign Encrypt (ALT+SHIFT+B");
49     default: return _("Unknown Hotkey");
50     }
51     return NULL;
52     }
53    
54    
55     int
56     hotkeys_register (HWND wnd)
57     {
58     int j = 0, rc = 0;
59    
60     err_hotkey = 0; /* reset */
61     for (j=0; wpt_hotkeys[j].id != 0; j++) {
62     if (wpt_hotkeys[j].enabled) {
63     rc = hotkey_register_single (wnd, &wpt_hotkeys[j]);
64     if (rc) {
65     err_hotkey = j+1;
66     break;
67     }
68     }
69     }
70    
71     return rc;
72     } /* hotkeys_register */
73    
74    
75     int
76     hotkeys_unregister (HWND wnd)
77     {
78     int j = 0, rc = 0;
79    
80     for (j=0; wpt_hotkeys[j].id != 0; j++) {
81     if (wpt_hotkeys[j].enabled) {
82     rc = hotkey_unregister_single (wnd, &wpt_hotkeys[j]);
83     if (rc)
84     break;
85     }
86     }
87    
88     return rc;
89     } /* hotkeys_unregister */
90    
91    
92     int
93     hotkey_register_single (HWND wnd, hotkey_t hk)
94     {
95 twoaday 69 int keymod=0;
96     int rc;
97 werner 36
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