aboutsummaryrefslogtreecommitdiff
path: root/src/ScreenResources.cc
blob: 3d153e62c896ab7ee9f8db1617a11e54b4ac202d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
// holds screen resource handling

#include "Screen.hh"
#include <string>
using namespace std;

template <>
void FbTk::Resource<BScreen::PlacementPolicy>::setDefaultValue() {
    *(*this) = BScreen::ROWSMARTPLACEMENT;
}

template <>
void FbTk::Resource<BScreen::PlacementPolicy>::setFromString(const char *str) {
    if (strcasecmp("RowSmartPlacement", str) == 0)
        *(*this) = BScreen::ROWSMARTPLACEMENT;
    else if (strcasecmp("ColSmartPlacement", str) == 0)
        *(*this) = BScreen::COLSMARTPLACEMENT;
    else if (strcasecmp("UnderMousePlacement", str) == 0)
        *(*this) = BScreen::UNDERMOUSEPLACEMENT;
    else if (strcasecmp("CascadePlacement", str) == 0)
        *(*this) = BScreen::CASCADEPLACEMENT;
    else
        setDefaultValue();
    
}

template <>
string FbTk::Resource<BScreen::PlacementPolicy>::getString() {
    switch (*(*this)) {
    case BScreen::ROWSMARTPLACEMENT:
        return "RowSmartPlacement";
    case BScreen::COLSMARTPLACEMENT:
        return "ColSmartPlacement";
    case BScreen::UNDERMOUSEPLACEMENT:
        return "UnderMousePlacement";
    case BScreen::CASCADEPLACEMENT:
        return "CascadePlacement";
    }

    return "RowSmartPlacement";
}

template <>
void FbTk::Resource<BScreen::RowDirection>::setDefaultValue() {
    *(*this) = BScreen::LEFTRIGHT;
}

template <>
void FbTk::Resource<BScreen::RowDirection>::setFromString(const char *str) {
    if (strcasecmp("LeftToRight", str) == 0)
        *(*this) = BScreen::LEFTRIGHT;
    else if (strcasecmp("RightToLeft", str) == 0)
        *(*this) = BScreen::RIGHTLEFT;
    else
        setDefaultValue();
    
}

template <>
string FbTk::Resource<BScreen::RowDirection>::getString() {
    switch (*(*this)) {
    case BScreen::LEFTRIGHT:
        return "LeftToRight";
    case BScreen::RIGHTLEFT:
        return "RightToLeft";
    }

    return "LeftToRight";
}


template <>
void FbTk::Resource<BScreen::ColumnDirection>::setDefaultValue() {
    *(*this) = BScreen::TOPBOTTOM;
}

template <>
void FbTk::Resource<BScreen::ColumnDirection>::setFromString(const char *str) {
    if (strcasecmp("TopToBottom", str) == 0)
        *(*this) = BScreen::TOPBOTTOM;
    else if (strcasecmp("BottomToTop", str) == 0)
        *(*this) = BScreen::BOTTOMTOP;
    else
        setDefaultValue();
    
}

template <>
string FbTk::Resource<BScreen::ColumnDirection>::getString() {
    switch (*(*this)) {
    case BScreen::TOPBOTTOM:
        return "TopToBottom";
    case BScreen::BOTTOMTOP:
        return "BottomToTop";
    }

    return "TopToBottom";
}

template <>
void FbTk::Resource<FbTk::MenuTheme::MenuMode>::setDefaultValue() {
    *(*this) = FbTk::MenuTheme::DELAY_OPEN;
}

template <>
string FbTk::Resource<FbTk::MenuTheme::MenuMode>::getString() {
    switch (*(*this)) {
    case FbTk::MenuTheme::DELAY_OPEN:
        return string("Delay");
    case FbTk::MenuTheme::CLICK_OPEN:
        return string("Click");
    }
    return string("Delay");
}

template <>
void FbTk::Resource<FbTk::MenuTheme::MenuMode>::setFromString(const char *str) {
    if (strcasecmp(str, "Delay") == 0)
        *(*this) = FbTk::MenuTheme::DELAY_OPEN;
    else if (strcasecmp(str, "Click") == 0)
        *(*this) = FbTk::MenuTheme::CLICK_OPEN;
    else
        setDefaultValue();
}

template<>
std::string FbTk::Resource<BScreen::ResizeModel>::
getString() {
    switch (m_value) {
    case BScreen::QUADRANTRESIZE:
        return std::string("Quadrant");
    case BScreen::BOTTOMRESIZE:
        return std::string("Bottom");
    };

    return std::string("Default");
}

template<>
void FbTk::Resource<BScreen::ResizeModel>::
setFromString(char const *strval) {
    if (strcasecmp(strval, "Bottom") == 0) {
        m_value = BScreen::BOTTOMRESIZE;
    } else if (strcasecmp(strval, "Quadrant") == 0) {
        m_value = BScreen::QUADRANTRESIZE;
    } else 
        m_value = BScreen::DEFAULTRESIZE;
}

template<>
std::string FbTk::Resource<BScreen::FocusModel>::
getString() {
    switch (m_value) {
    case BScreen::SLOPPYFOCUS:
        return string("SloppyFocus");
    case BScreen::SEMISLOPPYFOCUS:
        return string("SemiSloppyFocus");
    case BScreen::CLICKTOFOCUS:
        return string("ClickToFocus");
    }
    // default string
    return string("ClickToFocus");
}

template<>
void FbTk::Resource<BScreen::FocusModel>::
setFromString(char const *strval) {
    // auto raise options here for backwards read compatibility
    // they are not supported for saving purposes. Nor does the "AutoRaise" 
    // part actually do anything
    if (strcasecmp(strval, "SloppyFocus") == 0 
        || strcasecmp(strval, "AutoRaiseSloppyFocus") == 0) 
        m_value = BScreen::SLOPPYFOCUS;
    else if (strcasecmp(strval, "SemiSloppyFocus") == 0
        || strcasecmp(strval, "AutoRaiseSemiSloppyFocus") == 0) 
        m_value = BScreen::SEMISLOPPYFOCUS;
    else if (strcasecmp(strval, "ClickToFocus") == 0) 
        m_value = BScreen::CLICKTOFOCUS;
    else
        setDefaultValue();
}

template<>
std::string FbTk::Resource<BScreen::FollowModel>::
getString() {
    switch (m_value) {
    case BScreen::FOLLOW_ACTIVE_WINDOW:
        return std::string("Follow");
        break;
    case BScreen::FETCH_ACTIVE_WINDOW:
        return std::string("Current");
        break;
    };

    return std::string("Ignore");
}

template<>
void FbTk::Resource<BScreen::FollowModel>::
setFromString(char const *strval) {
    if (strcasecmp(strval, "Follow") == 0)
        m_value = BScreen::FOLLOW_ACTIVE_WINDOW;
    else if (strcasecmp(strval, "Current") == 0 || 
             strcasecmp(strval, "CurrentWorkspace") == 0 ||
             strcasecmp(strval, "Fetch") == 0)
        m_value = BScreen::FETCH_ACTIVE_WINDOW;
    else
        setDefaultValue();
}

template<>
void FbTk::Resource<FbTk::GContext::LineStyle>::setDefaultValue() {
    *(*this) = FbTk::GContext::LINESOLID;
}

template<>
std::string FbTk::Resource<FbTk::GContext::LineStyle>::getString() {
    switch(m_value) {
    case FbTk::GContext::LINESOLID:
        return "LineSolid";
        break;
    case FbTk::GContext::LINEONOFFDASH:
        return "LineOnOffDash";
        break;
    case FbTk::GContext::LINEDOUBLEDASH:
        return "LineDoubleDash";
        break;
    };
    return "LineSolid";
}

template<>
void FbTk::Resource<FbTk::GContext::LineStyle>
::setFromString(char const *strval) { 

    if (strcasecmp(strval, "LineSolid") == 0 )
        m_value = FbTk::GContext::LINESOLID;
    else if (strcasecmp(strval, "LineOnOffDash") == 0 )
        m_value = FbTk::GContext::LINEONOFFDASH;
    else if (strcasecmp(strval, "LineDoubleDash") == 0) 
        m_value = FbTk::GContext::LINEDOUBLEDASH;
    else
        setDefaultValue();
}

template<>
void FbTk::Resource<FbTk::GContext::JoinStyle>::setDefaultValue() {
    *(*this) = FbTk::GContext::JOINMITER;
}

template<>
std::string FbTk::Resource<FbTk::GContext::JoinStyle>::getString() {
    switch(m_value) {
    case FbTk::GContext::JOINMITER:
        return "JoinMiter";
        break;
    case FbTk::GContext::JOINBEVEL:
        return "JoinBevel";
        break;
    case FbTk::GContext::JOINROUND:
        return "JoinRound";
        break;
    };
    return "JoinMiter";
}

template<>
void FbTk::Resource<FbTk::GContext::JoinStyle>
::setFromString(char const *strval) { 

    if (strcasecmp(strval, "JoinRound") == 0 )
        m_value = FbTk::GContext::JOINROUND;
    else if (strcasecmp(strval, "JoinMiter") == 0 )
        m_value = FbTk::GContext::JOINMITER;
    else if (strcasecmp(strval, "JoinBevel") == 0) 
        m_value = FbTk::GContext::JOINBEVEL;
    else
        setDefaultValue();
}

template<>
void FbTk::Resource<FbTk::GContext::CapStyle>::setDefaultValue() {
    *(*this) = FbTk::GContext::CAPNOTLAST;
}

template<>
std::string FbTk::Resource<FbTk::GContext::CapStyle>::getString() {
    switch(m_value) {
    case FbTk::GContext::CAPNOTLAST:
        return "CapNotLast";
        break;
    case FbTk::GContext::CAPBUTT:
        return "CapButt";
        break;
    case FbTk::GContext::CAPROUND:
        return "CapRound";
        break;
    case FbTk::GContext::CAPPROJECTING:
        return "CapProjecting";
        break;
    };
    return "CapNotLast";
}

template<>
void FbTk::Resource<FbTk::GContext::CapStyle>
::setFromString(char const *strval) { 

    if (strcasecmp(strval, "CapNotLast") == 0 )
        m_value = FbTk::GContext::CAPNOTLAST;
    else if (strcasecmp(strval, "CapProjecting") == 0 )
        m_value = FbTk::GContext::CAPPROJECTING;
    else if (strcasecmp(strval, "CapRound") == 0) 
        m_value = FbTk::GContext::CAPROUND;
    else if (strcasecmp(strval, "CapButt" ) == 0)
        m_value = FbTk::GContext::CAPBUTT;
    else
        setDefaultValue();
}