1 /* KeyboardSettings.c- keyboard options (equivalent to xset)
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1998-2003 Alfredo K. Kojima
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program 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
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 */
21
22 #include "WPrefs.h"
23
24 typedef struct _Panel {
25 WMBox *box;
26
27 char *sectionName;
28
29 char *description;
30
31 CallbackRec callbacks;
32
33 WMWidget *parent;
34
35 WMFrame *delaF;
36 WMButton *delaB[4];
37 WMLabel *dmsL;
38 WMTextField *dmsT;
39
40 WMFrame *rateF;
41 WMButton *rateB[4];
42 WMLabel *rmsL;
43 WMTextField *rmsT;
44
45 WMTextField *testT;
46 } _Panel;
47
48 #define ICON_FILE "keyboard"
49
createPanel(Panel * p)50 static void createPanel(Panel * p)
51 {
52 _Panel *panel = (_Panel *) p;
53 WMScreen *scr = WMWidgetScreen(panel->parent);
54 int i;
55 WMColor *color;
56 WMFont *font;
57
58 color = WMDarkGrayColor(scr);
59 font = WMSystemFontOfSize(scr, 10);
60
61 panel->box = WMCreateBox(panel->parent);
62 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
63
64 /**************** Initial Key Repeat ***************/
65 panel->delaF = WMCreateFrame(panel->box);
66 WMResizeWidget(panel->delaF, 495, 60);
67 WMMoveWidget(panel->delaF, 15, 10);
68 WMSetFrameTitle(panel->delaF, _("Initial Key Repeat"));
69
70 for (i = 0; i < 4; i++) {
71 panel->delaB[i] = WMCreateButton(panel->delaF, WBTOnOff);
72 WMResizeWidget(panel->delaB[i], 60, 20);
73 WMMoveWidget(panel->delaB[i], 70 + i * 60, 25);
74 if (i > 0)
75 WMGroupButtons(panel->delaB[0], panel->delaB[i]);
76 switch (i) {
77 case 0:
78 WMSetButtonText(panel->delaB[i], "....a");
79 break;
80 case 1:
81 WMSetButtonText(panel->delaB[i], "...a");
82 break;
83 case 2:
84 WMSetButtonText(panel->delaB[i], "..a");
85 break;
86 case 3:
87 WMSetButtonText(panel->delaB[i], ".a");
88 break;
89 }
90 }
91 panel->dmsT = WMCreateTextField(panel->delaF);
92 WMResizeWidget(panel->dmsT, 50, 20);
93 WMMoveWidget(panel->dmsT, 345, 25);
94 /* WMSetTextFieldAlignment(panel->dmsT, WARight); */
95
96 panel->dmsL = WMCreateLabel(panel->delaF);
97 WMResizeWidget(panel->dmsL, 30, 16);
98 WMMoveWidget(panel->dmsL, 400, 30);
99 WMSetLabelTextColor(panel->dmsL, color);
100 WMSetLabelFont(panel->dmsL, font);
101 WMSetLabelText(panel->dmsL, "msec");
102
103 WMMapSubwidgets(panel->delaF);
104
105 /**************** Key Repeat Rate ***************/
106 panel->rateF = WMCreateFrame(panel->box);
107 WMResizeWidget(panel->rateF, 495, 60);
108 WMMoveWidget(panel->rateF, 15, 95);
109 WMSetFrameTitle(panel->rateF, _("Key Repeat Rate"));
110
111 for (i = 0; i < 4; i++) {
112 panel->rateB[i] = WMCreateButton(panel->rateF, WBTOnOff);
113 WMResizeWidget(panel->rateB[i], 60, 20);
114 WMMoveWidget(panel->rateB[i], 70 + i * 60, 25);
115 if (i > 0)
116 WMGroupButtons(panel->rateB[0], panel->rateB[i]);
117 switch (i) {
118 case 0:
119 WMSetButtonText(panel->rateB[i], "a....a");
120 break;
121 case 1:
122 WMSetButtonText(panel->rateB[i], "a...a");
123 break;
124 case 2:
125 WMSetButtonText(panel->rateB[i], "a..a");
126 break;
127 case 3:
128 WMSetButtonText(panel->rateB[i], "a.a");
129 break;
130 }
131 }
132 panel->rmsT = WMCreateTextField(panel->rateF);
133 WMResizeWidget(panel->rmsT, 50, 20);
134 WMMoveWidget(panel->rmsT, 345, 25);
135 /* WMSetTextFieldAlignment(panel->rmsT, WARight); */
136
137 panel->rmsL = WMCreateLabel(panel->rateF);
138 WMResizeWidget(panel->rmsL, 30, 16);
139 WMMoveWidget(panel->rmsL, 400, 30);
140 WMSetLabelTextColor(panel->rmsL, color);
141 WMSetLabelFont(panel->rmsL, font);
142 WMSetLabelText(panel->rmsL, "msec");
143
144 WMMapSubwidgets(panel->rateF);
145
146 panel->testT = WMCreateTextField(panel->box);
147 WMResizeWidget(panel->testT, 480, 20);
148 WMMoveWidget(panel->testT, 20, 180);
149 WMSetTextFieldText(panel->testT, _("Type here to test"));
150
151 WMReleaseColor(color);
152 WMReleaseFont(font);
153
154 WMRealizeWidget(panel->box);
155 WMMapSubwidgets(panel->box);
156 }
157
InitKeyboardSettings(WMWidget * parent)158 Panel *InitKeyboardSettings(WMWidget *parent)
159 {
160 _Panel *panel;
161
162 panel = wmalloc(sizeof(_Panel));
163
164 panel->sectionName = _("Keyboard Preferences");
165
166 panel->description = _("Not done");
167
168 panel->parent = parent;
169
170 panel->callbacks.createWidgets = createPanel;
171
172 AddSection(panel, ICON_FILE);
173
174 return panel;
175 }
176