root/branches/stable_5.0/AWT/AWT_hotkeys.cxx

Revision 5675, 2.6 KB (checked in by westram, 3 years ago)
  • removed automatic timestamps (the best they were good for, were vc-conflicts)
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
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 <ctype.h>
17
18
19using namespace std;
20
21//  -----------------------------------------------------
22//      const char* awt_hotkeys::artifical_hotkey()
23//  -----------------------------------------------------
24const char* awt_hotkeys::artifical_hotkey()  {
25    if (artifical <= '9') {
26        current[0] = artifical++;
27    }
28    else {
29        int i;
30        for (i = 25; i >= 0; --i) {
31            if (!used[i]) {
32                current[0] = 'a'+i;
33                used[i]    = true;
34                break;
35            }
36            if (!USED[i]) {
37                current[0] = 'A'+i;
38                USED[i]    = true;
39                break;
40            }
41        }
42
43        if (i == 26) current[0] = 0;
44    }
45
46    return current;
47}
48
49//  -----------------------------------------------------------------------
50//      const char* awt_hotkeys::hotkey_internal(const string& label)
51//  -----------------------------------------------------------------------
52const char* awt_hotkeys::hotkey(const string& label)  {
53    if (label.length()) {
54        for (string::const_iterator ch = label.begin(); ch != label.end(); ++ch) {
55            if (islower(*ch)) {
56                if (!used[*ch-'a']) {
57                    used[*ch-'a'] = true;
58                    current[0] = *ch;
59                    return current;
60                }
61            }
62            else if (isupper(*ch)) {
63                if (!USED[*ch-'A']) {
64                    USED[*ch-'A'] = true;
65                    current[0]    = *ch;
66                    return current;
67                }
68            }
69        }
70    }
71    return artifical_hotkey();
72}
73
74
75
Note: See TracBrowser for help on using the browser.