2 * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
5 #ifndef KEYBOARD_LAYOUT_H
6 #define KEYBOARD_LAYOUT_H
12 #include <ObjectList.h>
26 uint32 alternate_code
[3];
27 uint32 alternate_modifier
[3];
31 // this is the width of the second row of a kEnterKeyShape key
40 typedef std::map
<BString
, BString
> VariableMap
;
42 class KeyboardLayout
{
50 Key
* KeyAt(int32 index
);
52 int32
CountIndicators();
53 Indicator
* IndicatorAt(int32 index
);
56 BSize
DefaultKeySize();
57 int32
IndexForModifier(int32 modifier
);
59 status_t
Load(const char* path
);
60 status_t
Load(entry_ref
& ref
);
63 bool IsDefault() const { return fIsDefault
; }
79 void _Error(const parse_state
& state
,
80 const char* reason
, ...);
81 void _AddAlternateKeyCode(Key
* key
, int32 modifier
,
83 bool _AddKey(const Key
& key
);
84 void _SkipCommentsAndSpace(parse_state
& state
,
86 void _Trim(BString
& string
, bool stripComments
);
87 bool _GetPair(const parse_state
& state
,
88 const char*& data
, BString
& name
,
90 bool _AddKeyCodes(const parse_state
& state
,
91 BPoint
& rowLeftTop
, Key
& key
, const char* data
,
93 bool _GetSize(const parse_state
& state
, const char* data
,
94 float& x
, float& y
, float* _secondRow
= NULL
);
95 bool _GetShape(const parse_state
& state
,
96 const char* data
, Key
& key
);
97 const char* _Delimiter(parse_mode mode
);
98 bool _GetTerm(const char*& data
, const char* delimiter
,
99 BString
& term
, bool closingBracketAllowed
);
100 bool _SubstituteVariables(BString
& term
,
101 VariableMap
& variables
, BString
& unknown
);
102 bool _ParseTerm(const parse_state
& state
,
103 const char*& data
, BString
& term
,
104 VariableMap
& variables
);
106 status_t
_InitFrom(const char* data
);
113 BSize fDefaultKeySize
;
114 int32 fAlternateIndex
[3];
115 BObjectList
<Indicator
> fIndicators
;
119 #endif // KEYBOARD_LAYOUT_H