1 /*
2  * KMFL Input Method for SCIM (Smart Common Input Method)
3  *
4  * Copyright (C) 2005 SIL International
5  * based on source from SCIM Copyright (c) 2004 James Su <suzhe@tsinghua.org.cn>
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20  *
21  */
22 
23 #if !defined (__XKBMAP_H)
24 #define __XKBMAP_H
25 #include <string>
26 #include <vector>
27 #include <X11/Xlib.h>
28 #include <X11/Xos.h>
29 #include <X11/XKBlib.h>
30 #include <X11/extensions/XKBfile.h>
31 #include <X11/extensions/XKBconfig.h>
32 #include <X11/extensions/XKBrules.h>
33 
34 
35 class Xkbmap
36 {
37 private:
38     Display *		dpy;
39 
40     enum svSources {
41 		FROM_SERVER	= 0,
42 		FROM_RULES	= 1,
43 		FROM_CMD_LINE	= 2,
44     };
45 
46     enum valueIndices {
47 		RULES_NDX	= 0,
48 		DISPLAY_NDX	= 1,
49 		LOCALE_NDX	= 2,
50 		MODEL_NDX	= 3,
51 		LAYOUT_NDX	= 4,
52 		VARIANT_NDX	= 5,
53 		KEYCODES_NDX	= 6,
54 		TYPES_NDX	= 7,
55 		COMPAT_NDX	= 8,
56 		SYMBOLS_NDX	= 9,
57 		GEOMETRY_NDX	= 10,
58 		KEYMAP_NDX	= 11,
59 		NUM_STRING_VALS	= 12,
60     };
61 	const std::string defaultlayout;
62 	const std::string unknownsymbols;
63     svSources svSrc[NUM_STRING_VALS];
64     char * svValue[NUM_STRING_VALS];
65 
66     XkbRF_VarDefsRec	rdefs;
67 
68     std::vector < std::string > options;
69     std::vector < std::string > inclPath;
70 
71 
72 	void clearValues(void);
73 	void trySetString(valueIndices which, const char *newVal, svSources src);
74 	Bool getDisplay(void);
75 	Bool getServerValues(void);
76 	void addStringToOptions(char *opt_str);
77 	char * stringFromOptions(char *orig);
78 	Bool applyRules(void);
79 	Bool checkName(char *name, const char* string);
80 	Bool applyComponentNames(void);
81 
82 public:
83     Xkbmap();
84     ~Xkbmap();
85 	std::string getCurrentLayout(void);
86 	void setLayout(const std::string & layout);
87 	std::string getCurrentSymbols(void);
88 	void setSymbols(const std::string & symbols);
89 };
90 #endif
91 /*
92 vi:ts=4:nowrap:ai:expandtab
93 */
94