Initial update from my source tree. For 0.52.0
[wmaker-crm.git] / WPrefs.app / KeyboardSettings.c
blob324764d3a5e6451d0afff233046a5044822094bb
1 /* KeyboardSettings.c- keyboard options (equivalent to xset)
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1998 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.
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.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
24 #include "WPrefs.h"
26 typedef struct _Panel {
27 WMFrame *frame;
29 char *sectionName;
31 CallbackRec callbacks;
33 WMWindow *win;
35 WMFrame *delaF;
36 WMButton *delaB[4];
37 WMLabel *dmsL;
38 WMTextField *dmsT;
40 WMFrame *rateF;
41 WMButton *rateB[4];
42 WMLabel *rmsL;
43 WMTextField *rmsT;
45 WMTextField *testT;
46 } _Panel;
49 #define ICON_FILE "keyboard"
52 static void
53 createPanel(Panel *p)
55 _Panel *panel = (_Panel*)p;
56 WMScreen *scr = WMWidgetScreen(panel->win);
57 int i;
58 WMColor *color;
59 WMFont *font;
61 color = WMDarkGrayColor(scr);
62 font = WMSystemFontOfSize(scr, 10);
64 panel->frame = WMCreateFrame(panel->win);
65 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
66 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
68 /**************** Initial Key Repeat ***************/
69 panel->delaF = WMCreateFrame(panel->frame);
70 WMResizeWidget(panel->delaF, 495, 60);
71 WMMoveWidget(panel->delaF, 15, 10);
72 WMSetFrameTitle(panel->delaF, _("Initial Key Repeat"));
74 for (i = 0; i < 4; i++) {
75 panel->delaB[i] = WMCreateButton(panel->delaF, WBTOnOff);
76 WMResizeWidget(panel->delaB[i], 60, 20);
77 WMMoveWidget(panel->delaB[i], 70+i*60, 25);
78 if (i>0)
79 WMGroupButtons(panel->delaB[0], panel->delaB[i]);
80 switch (i) {
81 case 0:
82 WMSetButtonText(panel->delaB[i], "....a");
83 break;
84 case 1:
85 WMSetButtonText(panel->delaB[i], "...a");
86 break;
87 case 2:
88 WMSetButtonText(panel->delaB[i], "..a");
89 break;
90 case 3:
91 WMSetButtonText(panel->delaB[i], ".a");
92 break;
95 panel->dmsT = WMCreateTextField(panel->delaF);
96 WMResizeWidget(panel->dmsT, 50, 20);
97 WMMoveWidget(panel->dmsT, 345, 25);
98 /* WMSetTextFieldAlignment(panel->dmsT, WARight);*/
100 panel->dmsL = WMCreateLabel(panel->delaF);
101 WMResizeWidget(panel->dmsL, 30, 16);
102 WMMoveWidget(panel->dmsL, 400, 30);
103 WMSetLabelTextColor(panel->dmsL, color);
104 WMSetLabelFont(panel->dmsL, font);
105 WMSetLabelText(panel->dmsL, "msec");
107 WMMapSubwidgets(panel->delaF);
109 /**************** Key Repeat Rate ***************/
110 panel->rateF = WMCreateFrame(panel->frame);
111 WMResizeWidget(panel->rateF, 495, 60);
112 WMMoveWidget(panel->rateF, 15, 95);
113 WMSetFrameTitle(panel->rateF, _("Key Repeat Rate"));
115 for (i = 0; i < 4; i++) {
116 panel->rateB[i] = WMCreateButton(panel->rateF, WBTOnOff);
117 WMResizeWidget(panel->rateB[i], 60, 20);
118 WMMoveWidget(panel->rateB[i], 70+i*60, 25);
119 if (i>0)
120 WMGroupButtons(panel->rateB[0], panel->rateB[i]);
121 switch (i) {
122 case 0:
123 WMSetButtonText(panel->rateB[i], "a....a");
124 break;
125 case 1:
126 WMSetButtonText(panel->rateB[i], "a...a");
127 break;
128 case 2:
129 WMSetButtonText(panel->rateB[i], "a..a");
130 break;
131 case 3:
132 WMSetButtonText(panel->rateB[i], "a.a");
133 break;
136 panel->rmsT = WMCreateTextField(panel->rateF);
137 WMResizeWidget(panel->rmsT, 50, 20);
138 WMMoveWidget(panel->rmsT, 345, 25);
139 /* WMSetTextFieldAlignment(panel->rmsT, WARight);*/
141 panel->rmsL = WMCreateLabel(panel->rateF);
142 WMResizeWidget(panel->rmsL, 30, 16);
143 WMMoveWidget(panel->rmsL, 400, 30);
144 WMSetLabelTextColor(panel->rmsL, color);
145 WMSetLabelFont(panel->rmsL, font);
146 WMSetLabelText(panel->rmsL, "msec");
148 WMMapSubwidgets(panel->rateF);
150 panel->testT = WMCreateTextField(panel->frame);
151 WMResizeWidget(panel->testT, 480, 20);
152 WMMoveWidget(panel->testT, 20, 180);
153 WMSetTextFieldText(panel->testT, _("Type here to test"));
155 WMReleaseColor(color);
156 WMReleaseFont(font);
158 WMRealizeWidget(panel->frame);
159 WMMapSubwidgets(panel->frame);
164 Panel*
165 InitKeyboardSettings(WMScreen *scr, WMWindow *win)
167 _Panel *panel;
169 panel = wmalloc(sizeof(_Panel));
170 memset(panel, 0, sizeof(_Panel));
172 panel->sectionName = _("Keyboard Preferences");
174 panel->win = win;
176 panel->callbacks.createWidgets = createPanel;
178 AddSection(panel, ICON_FILE);
180 return panel;