Debian Codegraph @

Frameworks/OpenVanilla/Headers/OpenVanilla.h

raw symbols SCIP
1 // OpenVanilla.h: The Framework
2 //
3 // Copyright (c) 2004-2008 The OpenVanilla Project (http://openvanilla.org)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions
8 // are met:
9 //
10 // 1. Redistributions of source code must retain the above copyright
11 // notice, this list of conditions and the following disclaimer.
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 // 3. Neither the name of OpenVanilla nor the names of its contributors
16 // may be used to endorse or promote products derived from this software
17 // without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30
31 #ifndef __OpenVanilla_h
32 #define __OpenVanilla_h
33
34 #define OV_VERSION (0x00080000) // version 0.8.0 (00_08_00_00)
35
36
37 class OVBase {
38 public:
39 virtual ~OVBase() {}
40 };
41
42 class OVKeyCode : public OVBase {
43 public:
44
45 virtual int code() = 0;
46 virtual bool isShift() = 0;
47 virtual bool isCapslock() = 0;
48
49 virtual bool isCtrl() = 0;
50 virtual bool isAlt() = 0;
51 virtual bool isOpt() { return isAlt(); }
52 virtual bool isCommand() { return isAlt(); }
53 virtual bool isNum() = 0;
54 virtual bool isFunctionKey()
55 {
56 return isCtrl() || isAlt() || isOpt() || isCommand() || isNum();
57 }
58 };
59
60 class OVBuffer : public OVBase {
61 public:
62 virtual OVBuffer* clear() = 0;
63 virtual OVBuffer* append(const char *s) = 0;
64 virtual OVBuffer* send() = 0;
65 virtual OVBuffer* update() = 0;
66 virtual OVBuffer* update(int cursorPos, int markFrom = -1, int markTo = -1) = 0;
67 virtual bool isEmpty() = 0;
68 };
69
70 class OVCandidate : public OVBase {
71 public:
72
73 virtual OVCandidate* clear() = 0;
74 virtual OVCandidate* append(const char *s) = 0;
75 virtual OVCandidate* hide() = 0;
76 virtual OVCandidate* show() = 0;
77 virtual OVCandidate* update() = 0;
78 virtual bool onScreen() = 0;
79 };
80
81 class OVDictionary : public OVBase {
82 public:
83
84 virtual bool keyExist(const char *key) = 0;
85 virtual int getInteger(const char *key) = 0;
86 virtual int setInteger(const char *key, int value) = 0;
87 virtual const char *getString(const char *key) = 0;
88 virtual const char *setString(const char *key, const char *value) = 0;
89 virtual int getIntegerWithDefault(const char *key, int value)
90 {
91 if (!keyExist(key)) setInteger(key, value); return getInteger(key);
92 }
93
94 virtual const char *getStringWithDefault(const char *key, const char *value)
95 {
96 if (!keyExist(key)) setString(key, value); return getString(key);
97 }
98 };
99
100 class OVService : public OVBase {
101 public:
102
103 virtual void beep() = 0;
104 virtual void notify(const char *msg) = 0;
105 virtual const char *locale() = 0 ;
106 virtual const char *userSpacePath(const char *modid) = 0;
107 virtual const char *pathSeparator() = 0;
108 // limited support for encoding conversion
109 virtual const char *toUTF8(const char *encoding, const char *src) = 0;
110 virtual const char *fromUTF8(const char *encoding, const char *src) = 0;
111 virtual const char *UTF16ToUTF8(unsigned short *src, int len) = 0;
112 virtual int UTF8ToUTF16(const char *src, unsigned short **rcvr) = 0;
113 };
114
115 class OVInputMethodContext : public OVBase {
116 public:
117
118 virtual void start(OVBuffer*, OVCandidate*, OVService*) {}
119 virtual void clear() {}
120 virtual void end() {}
121 virtual int keyEvent(OVKeyCode*, OVBuffer*, OVCandidate*, OVService*) = 0;
122 };
123
124 class OVModule : public OVBase {
125 public:
126 virtual const char *moduleType() = 0;
127 virtual const char *identifier() = 0;
128 virtual const char *localizedName(const char *locale) { return identifier(); }
129 virtual int initialize(OVDictionary* moduleCfg, OVService* srv, const char *modulePath) { return 1; }
130 virtual void update(OVDictionary* moduleCfg, OVService* srv) {}
131 };
132
133 class OVInputMethod : public OVModule
134 {
135 public:
136 virtual OVInputMethodContext* newContext() = 0;
137 virtual const char *moduleType() { return "OVInputMethod"; }
138 };
139
140 class OVOutputFilter : public OVModule
141 {
142 public:
143 virtual const char *process(const char *source, OVService* srv) = 0;
144 virtual const char *moduleType() { return "OVOutputFilter"; }
145 };
146
147 enum
148 {
149 ovkEsc =27, ovkSpace = 32, ovkReturn = 13,
150 ovkDelete = 127, ovkBackspace = 8,
151 ovkUp = 30, ovkDown = 31, ovkLeft = 28, ovkRight = 29,
152 ovkHome = 1, ovkEnd = 4, ovkPageUp = 11, ovkPageDown = 12,
153 ovkTab = 9
154 };
155 #endif