Change to the linux kernel coding style
[wmaker-crm.git] / WPrefs.app / KeyboardSettings.c
Commit [+]AuthorDateLineData
9d2e6ef9 scottc1998-09-29 22:36:29 +00001/* KeyboardSettings.c- keyboard options (equivalent to xset)
6830b057 dan2004-10-12 21:28:27 +00002 *
9af1c6c4 dan1998-10-21 14:43:47 +00003 * WPrefs - Window Maker Preferences Program
6830b057 dan2004-10-12 21:28:27 +00004 *
4153e2fd dan2003-01-16 23:30:45 +00005 * Copyright (c) 1998-2003 Alfredo K. Kojima
6830b057 dan2004-10-12 21:28:27 +00006 *
9d2e6ef9 scottc1998-09-29 22:36:29 +00007 * 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
18 * along with this program; if not, write to the Free Software
6830b057 dan2004-10-12 21:28:27 +000019 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
9d2e6ef9 scottc1998-09-29 22:36:29 +000020 * USA.
21 */
22
9d2e6ef9 scottc1998-09-29 22:36:29 +000023#include "WPrefs.h"
24
25typedef struct _Panel {
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020026 WMBox *box;
9d2e6ef9 scottc1998-09-29 22:36:29 +000027
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020028 char *sectionName;
d3f29988 kojima1999-04-25 01:49:46 +000029
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020030 char *description;
d3f29988 kojima1999-04-25 01:49:46 +000031
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020032 CallbackRec callbacks;
9d2e6ef9 scottc1998-09-29 22:36:29 +000033
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020034 WMWidget *parent;
9d2e6ef9 scottc1998-09-29 22:36:29 +000035
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020036 WMFrame *delaF;
37 WMButton *delaB[4];
38 WMLabel *dmsL;
39 WMTextField *dmsT;
6830b057 dan2004-10-12 21:28:27 +000040
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020041 WMFrame *rateF;
42 WMButton *rateB[4];
43 WMLabel *rmsL;
44 WMTextField *rmsT;
6830b057 dan2004-10-12 21:28:27 +000045
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020046 WMTextField *testT;
9d2e6ef9 scottc1998-09-29 22:36:29 +000047} _Panel;
48
9d2e6ef9 scottc1998-09-29 22:36:29 +000049#define ICON_FILE "keyboard"
50
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +020051static void createPanel(Panel * p)
9d2e6ef9 scottc1998-09-29 22:36:29 +000052{
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020053 _Panel *panel = (_Panel *) p;
54 WMScreen *scr = WMWidgetScreen(panel->parent);
55 int i;
56 WMColor *color;
57 WMFont *font;
9d2e6ef9 scottc1998-09-29 22:36:29 +000058
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020059 color = WMDarkGrayColor(scr);
60 font = WMSystemFontOfSize(scr, 10);
f91f2eb1 kojima2001-02-08 21:54:12 +000061
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020062 panel->box = WMCreateBox(panel->parent);
63 WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
6830b057 dan2004-10-12 21:28:27 +000064
9d2e6ef9 scottc1998-09-29 22:36:29 +000065 /**************** Initial Key Repeat ***************/
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +020066 panel->delaF = WMCreateFrame(panel->box);
67 WMResizeWidget(panel->delaF, 495, 60);
68 WMMoveWidget(panel->delaF, 15, 10);
69 WMSetFrameTitle(panel->delaF, _("Initial Key Repeat"));
70
71 for (i = 0; i < 4; i++) {
72 panel->delaB[i] = WMCreateButton(panel->delaF, WBTOnOff);
73 WMResizeWidget(panel->delaB[i], 60, 20);
74 WMMoveWidget(panel->delaB[i], 70 + i * 60, 25);
75 if (i > 0)
76 WMGroupButtons(panel->delaB[0], panel->delaB[i]);
77 switch (i) {
78 case 0:
79 WMSetButtonText(panel->delaB[i], "....a");
80 break;
81 case 1:
82 WMSetButtonText(panel->delaB[i], "...a");
83 break;
84 case 2:
85 WMSetButtonText(panel->delaB[i], "..a");
86 break;
87 case 3:
88 WMSetButtonText(panel->delaB[i], ".a");
89 break;
90 }
91 }
92 panel->dmsT = WMCreateTextField(panel->delaF);
93 WMResizeWidget(panel->dmsT, 50, 20);
94 WMMoveWidget(panel->dmsT, 345, 25);
95 /* WMSetTextFieldAlignment(panel->dmsT, WARight); */
96
97 panel->dmsL = WMCreateLabel(panel->delaF);
98 WMResizeWidget(panel->dmsL, 30, 16);
99 WMMoveWidget(panel->dmsL, 400, 30);
100 WMSetLabelTextColor(panel->dmsL, color);
101 WMSetLabelFont(panel->dmsL, font);
102 WMSetLabelText(panel->dmsL, "msec");
103
104 WMMapSubwidgets(panel->delaF);
6830b057 dan2004-10-12 21:28:27 +0000105
9d2e6ef9 scottc1998-09-29 22:36:29 +0000106 /**************** Key Repeat Rate ***************/
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200107 panel->rateF = WMCreateFrame(panel->box);
108 WMResizeWidget(panel->rateF, 495, 60);
109 WMMoveWidget(panel->rateF, 15, 95);
110 WMSetFrameTitle(panel->rateF, _("Key Repeat Rate"));
111
112 for (i = 0; i < 4; i++) {
113 panel->rateB[i] = WMCreateButton(panel->rateF, WBTOnOff);
114 WMResizeWidget(panel->rateB[i], 60, 20);
115 WMMoveWidget(panel->rateB[i], 70 + i * 60, 25);
116 if (i > 0)
117 WMGroupButtons(panel->rateB[0], panel->rateB[i]);
118 switch (i) {
119 case 0:
120 WMSetButtonText(panel->rateB[i], "a....a");
121 break;
122 case 1:
123 WMSetButtonText(panel->rateB[i], "a...a");
124 break;
125 case 2:
126 WMSetButtonText(panel->rateB[i], "a..a");
127 break;
128 case 3:
129 WMSetButtonText(panel->rateB[i], "a.a");
130 break;
131 }
132 }
133 panel->rmsT = WMCreateTextField(panel->rateF);
134 WMResizeWidget(panel->rmsT, 50, 20);
135 WMMoveWidget(panel->rmsT, 345, 25);
136 /* WMSetTextFieldAlignment(panel->rmsT, WARight); */
137
138 panel->rmsL = WMCreateLabel(panel->rateF);
139 WMResizeWidget(panel->rmsL, 30, 16);
140 WMMoveWidget(panel->rmsL, 400, 30);
141 WMSetLabelTextColor(panel->rmsL, color);
142 WMSetLabelFont(panel->rmsL, font);
143 WMSetLabelText(panel->rmsL, "msec");
144
145 WMMapSubwidgets(panel->rateF);
146
147 panel->testT = WMCreateTextField(panel->box);
148 WMResizeWidget(panel->testT, 480, 20);
149 WMMoveWidget(panel->testT, 20, 180);
150 WMSetTextFieldText(panel->testT, _("Type here to test"));
151
152 WMReleaseColor(color);
153 WMReleaseFont(font);
154
155 WMRealizeWidget(panel->box);
156 WMMapSubwidgets(panel->box);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000157}
158
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200159Panel *InitKeyboardSettings(WMScreen * scr, WMWidget * parent)
9d2e6ef9 scottc1998-09-29 22:36:29 +0000160{
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200161 _Panel *panel;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000162
688a56e8
CM
Carlos R. Mafra2009-08-20 00:59:40 +0200163 panel = wmalloc(sizeof(_Panel));
164 memset(panel, 0, sizeof(_Panel));
9d2e6ef9 scottc1998-09-29 22:36:29 +0000165
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200166 panel->sectionName = _("Keyboard Preferences");
9d2e6ef9 scottc1998-09-29 22:36:29 +0000167
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200168 panel->description = _("Not done");
d3f29988 kojima1999-04-25 01:49:46 +0000169
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200170 panel->parent = parent;
6830b057 dan2004-10-12 21:28:27 +0000171
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200172 panel->callbacks.createWidgets = createPanel;
6830b057 dan2004-10-12 21:28:27 +0000173
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200174 AddSection(panel, ICON_FILE);
9d2e6ef9 scottc1998-09-29 22:36:29 +0000175
688a56e8 Carlos R. Mafra2009-08-20 00:59:40 +0200176 return panel;
9d2e6ef9 scottc1998-09-29 22:36:29 +0000177}