source: tags/ms_r18q1/AWT/AWT_hotkeys.cxx

Last change on this file was 13044, checked in by westram, 10 years ago
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1//  ==================================================================== //
2//                                                                       //
3//    File      : AWT_hotkeys.cxx                                        //
4//    Purpose   :                                                        //
5//                                                                       //
6//                                                                       //
7//  Coded by Ralf Westram (coder@reallysoft.de) in August 2001           //
8//  Copyright Department of Microbiology (Technical University Munich)   //
9//                                                                       //
10//  Visit our web site at: http://www.arb-home.de/                       //
11//                                                                       //
12//                                                                       //
13//  ==================================================================== //
14
15#include "awt_hotkeys.hxx"
16#include <cctype>
17
18
19using namespace std;
20
21const char* awt_hotkeys::artificial_hotkey() {
22    if (artificial <= '9') {
23        current[0] = artificial++;
24    }
25    else {
26        int i;
27        for (i = 25; i >= 0; --i) {
28            if (!used[i]) {
29                current[0] = 'a'+i;
30                used[i]    = true;
31                break;
32            }
33            if (!USED[i]) {
34                current[0] = 'A'+i;
35                USED[i]    = true;
36                break;
37            }
38        }
39
40        if (i == 26) current[0] = 0;
41    }
42
43    return current;
44}
45
46const char* awt_hotkeys::hotkey(const string& label) {
47    if (label.length()) {
48        for (string::const_iterator ch = label.begin(); ch != label.end(); ++ch) {
49            if (islower(*ch)) {
50                if (!used[*ch-'a']) {
51                    used[*ch-'a'] = true;
52                    current[0] = *ch;
53                    return current;
54                }
55            }
56            else if (isupper(*ch)) {
57                if (!USED[*ch-'A']) {
58                    USED[*ch-'A'] = true;
59                    current[0]    = *ch;
60                    return current;
61                }
62            }
63        }
64    }
65    return artificial_hotkey();
66}
67
68
69
70
Note: See TracBrowser for help on using the repository browser.