1 /* TextureAndColor.c- color/texture for titlebar etc.
3 * WPrefs - WindowMaker Preferences Program
5 * Copyright (c) 1998 Alfredo K. Kojima
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,
26 typedef struct _Panel
{
30 CallbackRec callbacks
;
113 #define ICON_FILE "appearance"
116 #define FTITLE (1<<0)
117 #define UTITLE (1<<1)
118 #define OTITLE (1<<2)
121 #define MTITLE (1<<5)
123 #define EVERYTHING 0xff
127 updatePreviewBox(_Panel
*panel
, int elements
)
135 changePage(WMWidget
*self
, void *data
)
138 _Panel
*panel
= (_Panel
*)data
;
140 i
= WMGetPopUpButtonSelectedItem(self
);
143 WMMapWidget(panel
->focF
);
144 WMMapWidget(panel
->unfF
);
145 WMMapWidget(panel
->ownF
);
147 WMMapWidget(panel
->backF
);
148 WMMapWidget(panel
->textF
);
150 WMMapWidget(panel
->unsF
);
151 WMMapWidget(panel
->selF
);
153 WMMapWidget(panel
->workF
);
154 WMMapWidget(panel
->clipF
);
156 WMMapWidget(panel
->iconF
);
160 WMUnmapWidget(panel
->focF
);
161 WMUnmapWidget(panel
->unfF
);
162 WMUnmapWidget(panel
->ownF
);
165 WMUnmapWidget(panel
->backF
);
166 WMUnmapWidget(panel
->textF
);
169 WMUnmapWidget(panel
->unsF
);
170 WMUnmapWidget(panel
->selF
);
173 WMUnmapWidget(panel
->workF
);
174 WMUnmapWidget(panel
->clipF
);
177 WMUnmapWidget(panel
->iconF
);
183 getStrArrayForKey(char *key
)
187 v
= GetObjectForKey(key
);
191 return PLGetDescription(v
);
196 showData(_Panel
*panel
)
199 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
202 str
= GetStringForKey("FTitleColor");
205 color
= WMCreateNamedColor(scr
, str
, True
);
206 WMSetColorWellColor(panel
->focC
, color
);
207 WMReleaseColor(color
);
209 str
= GetStringForKey("PTitleColor");
212 color
= WMCreateNamedColor(scr
, str
, True
);
213 WMSetColorWellColor(panel
->ownC
, color
);
214 WMReleaseColor(color
);
216 str
= GetStringForKey("UTitleColor");
219 color
= WMCreateNamedColor(scr
, str
, True
);
220 WMSetColorWellColor(panel
->unfC
, color
);
221 WMReleaseColor(color
);
224 str
= getStrArrayForKey("FTitleBack");
226 str
= wstrdup("(solid, black)");
227 WMSetTextFieldText(panel
->focT
, str
);
230 str
= getStrArrayForKey("PTitleBack");
232 str
= wstrdup("(solid, gray40)");
233 WMSetTextFieldText(panel
->ownT
, str
);
236 str
= getStrArrayForKey("UTitleBack");
238 str
= wstrdup("(solid, grey66)");
239 WMSetTextFieldText(panel
->unfT
, str
);
244 str
= GetStringForKey("MenuTitleColor");
247 color
= WMCreateNamedColor(scr
, str
, True
);
248 WMSetColorWellColor(panel
->textC
, color
);
249 WMReleaseColor(color
);
251 str
= getStrArrayForKey("MenuTitleBack");
253 str
= wstrdup("(solid, black)");
254 WMSetTextFieldText(panel
->backT
, str
);
259 str
= getStrArrayForKey("MenuTextBack");
261 str
= wstrdup("gray66");
262 WMSetTextFieldText(panel
->unsT
, str
);
265 str
= GetStringForKey("MenuTextColor");
268 color
= WMCreateNamedColor(scr
, str
, True
);
269 WMSetColorWellColor(panel
->unsnC
, color
);
270 WMReleaseColor(color
);
272 str
= GetStringForKey("MenuDisabledColor");
275 color
= WMCreateNamedColor(scr
, str
, True
);
276 WMSetColorWellColor(panel
->unsdC
, color
);
277 WMReleaseColor(color
);
279 str
= GetStringForKey("HighlightTextColor");
282 color
= WMCreateNamedColor(scr
, str
, True
);
283 WMSetColorWellColor(panel
->seltC
, color
);
284 WMReleaseColor(color
);
286 str
= GetStringForKey("HighlightColor");
289 color
= WMCreateNamedColor(scr
, str
, True
);
290 WMSetColorWellColor(panel
->selbC
, color
);
291 WMReleaseColor(color
);
295 str
= getStrArrayForKey("WorkspaceBack");
296 WMSetTextFieldText(panel
->workT
, str
);
301 str
= GetStringForKey("ClipTitleColor");
304 color
= WMCreateNamedColor(scr
, str
, True
);
305 WMSetColorWellColor(panel
->clipnC
, color
);
306 WMReleaseColor(color
);
308 str
= GetStringForKey("CClipTitleColor");
311 color
= WMCreateNamedColor(scr
, str
, True
);
312 WMSetColorWellColor(panel
->clipcC
, color
);
313 WMReleaseColor(color
);
317 str
= getStrArrayForKey("IconBack");
319 str
= wstrdup("(solid, gray66)");
320 WMSetTextFieldText(panel
->iconT
, str
);
326 createPanel(Panel
*p
)
328 _Panel
*panel
= (_Panel
*)p
;
330 panel
->frame
= WMCreateFrame(panel
->win
);
331 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
332 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
334 panel
->secP
= WMCreatePopUpButton(panel
->frame
);
335 WMResizeWidget(panel
->secP
, 220, 20);
336 WMMoveWidget(panel
->secP
, 15, 10);
337 WMSetPopUpButtonAction(panel
->secP
, changePage
, panel
);
339 WMAddPopUpButtonItem(panel
->secP
, _("Window Title Bar"));
340 WMAddPopUpButtonItem(panel
->secP
, _("Menu Title Bar"));
341 WMAddPopUpButtonItem(panel
->secP
, _("Menu Items"));
342 WMAddPopUpButtonItem(panel
->secP
, _("Workspace/Clip"));
343 WMAddPopUpButtonItem(panel
->secP
, _("Icons"));
345 panel
->prevL
= WMCreateLabel(panel
->frame
);
346 WMResizeWidget(panel
->prevL
, 220, 185);
347 WMMoveWidget(panel
->prevL
, 15, 40);
348 WMSetLabelRelief(panel
->prevL
, WRSunken
);
350 /* window titlebar */
351 panel
->focF
= WMCreateFrame(panel
->frame
);
352 WMResizeWidget(panel
->focF
, 265, 70);
353 WMMoveWidget(panel
->focF
, 245, 5);
354 WMSetFrameTitle(panel
->focF
, _("Focused Window"));
356 panel
->focC
= WMCreateColorWell(panel
->focF
);
357 WMResizeWidget(panel
->focC
, 60, 35);
358 WMMoveWidget(panel
->focC
, 15, 15);
360 panel
->focT
= WMCreateTextField(panel
->focF
);
361 WMResizeWidget(panel
->focT
, 116, 20);
362 WMMoveWidget(panel
->focT
, 85, 25);
364 panel
->foc2L
= WMCreateLabel(panel
->focF
);
365 WMResizeWidget(panel
->foc2L
, 165, 16);
366 WMMoveWidget(panel
->foc2L
, 90, 50);
367 WMSetLabelText(panel
->foc2L
, _("Texture"));
368 WMSetLabelTextAlignment(panel
->foc2L
, WACenter
);
370 panel
->focL
= WMCreateLabel(panel
->focF
);
371 WMResizeWidget(panel
->focL
, 100, 16);
372 WMMoveWidget(panel
->focL
, 15, 50);
373 WMSetLabelText(panel
->focL
, _("Text Color"));
375 panel
->focB
= WMCreateCommandButton(panel
->focF
);
376 WMResizeWidget(panel
->focB
, 48, 22);
377 WMMoveWidget(panel
->focB
, 205, 24);
378 WMSetButtonText(panel
->focB
, _("Set..."));
380 WMMapSubwidgets(panel
->focF
);
382 panel
->unfF
= WMCreateFrame(panel
->frame
);
383 WMResizeWidget(panel
->unfF
, 265, 70);
384 WMMoveWidget(panel
->unfF
, 245, 80);
385 WMSetFrameTitle(panel
->unfF
, _("Unfocused Window"));
387 panel
->unfC
= WMCreateColorWell(panel
->unfF
);
388 WMResizeWidget(panel
->unfC
, 60, 35);
389 WMMoveWidget(panel
->unfC
, 15, 15);
391 panel
->unfT
= WMCreateTextField(panel
->unfF
);
392 WMResizeWidget(panel
->unfT
, 116, 20);
393 WMMoveWidget(panel
->unfT
, 85, 25);
395 panel
->unf2L
= WMCreateLabel(panel
->unfF
);
396 WMResizeWidget(panel
->unf2L
, 165, 16);
397 WMMoveWidget(panel
->unf2L
, 90, 50);
398 WMSetLabelText(panel
->unf2L
, _("Texture"));
399 WMSetLabelTextAlignment(panel
->unf2L
, WACenter
);
401 panel
->unfL
= WMCreateLabel(panel
->unfF
);
402 WMResizeWidget(panel
->unfL
, 100, 16);
403 WMMoveWidget(panel
->unfL
, 15, 50);
404 WMSetLabelText(panel
->unfL
, _("Text Color"));
406 panel
->unfB
= WMCreateCommandButton(panel
->unfF
);
407 WMResizeWidget(panel
->unfB
, 48, 22);
408 WMMoveWidget(panel
->unfB
, 205, 24);
409 WMSetButtonText(panel
->unfB
, _("Set..."));
411 WMMapSubwidgets(panel
->unfF
);
413 panel
->ownF
= WMCreateFrame(panel
->frame
);
414 WMResizeWidget(panel
->ownF
, 265, 70);
415 WMMoveWidget(panel
->ownF
, 245, 155);
416 WMSetFrameTitle(panel
->ownF
, _("Owner of Focused Window"));
418 panel
->ownC
= WMCreateColorWell(panel
->ownF
);
419 WMResizeWidget(panel
->ownC
, 60, 35);
420 WMMoveWidget(panel
->ownC
, 15, 15);
422 panel
->ownT
= WMCreateTextField(panel
->ownF
);
423 WMResizeWidget(panel
->ownT
, 116, 20);
424 WMMoveWidget(panel
->ownT
, 85, 25);
426 panel
->own2L
= WMCreateLabel(panel
->ownF
);
427 WMResizeWidget(panel
->own2L
, 165, 16);
428 WMMoveWidget(panel
->own2L
, 90, 50);
429 WMSetLabelText(panel
->own2L
, _("Texture"));
430 WMSetLabelTextAlignment(panel
->own2L
, WACenter
);
432 panel
->ownL
= WMCreateLabel(panel
->ownF
);
433 WMResizeWidget(panel
->ownL
, 100, 16);
434 WMMoveWidget(panel
->ownL
, 15, 50);
435 WMSetLabelText(panel
->ownL
, _("Text Color"));
437 panel
->ownB
= WMCreateCommandButton(panel
->ownF
);
438 WMResizeWidget(panel
->ownB
, 48, 22);
439 WMMoveWidget(panel
->ownB
, 205, 24);
440 WMSetButtonText(panel
->ownB
, _("Set..."));
442 WMMapSubwidgets(panel
->ownF
);
444 /***************** Menu Item *****************/
446 panel
->unsF
= WMCreateFrame(panel
->frame
);
447 WMResizeWidget(panel
->unsF
, 260, 140);
448 WMMoveWidget(panel
->unsF
, 250, 5);
449 WMSetFrameTitle(panel
->unsF
, _("Unselected Items"));
451 panel
->unsT
= WMCreateTextField(panel
->unsF
);
452 WMResizeWidget(panel
->unsT
, 175, 20);
453 WMMoveWidget(panel
->unsT
, 15, 25);
455 panel
->unsL
= WMCreateLabel(panel
->unsF
);
456 WMResizeWidget(panel
->unsL
, 175, 16);
457 WMMoveWidget(panel
->unsL
, 15, 50);
458 WMSetLabelTextAlignment(panel
->unsL
, WACenter
);
459 WMSetLabelText(panel
->unsL
, _("Background"));
461 panel
->unsB
= WMCreateCommandButton(panel
->unsF
);
462 WMResizeWidget(panel
->unsB
, 48, 22);
463 WMMoveWidget(panel
->unsB
, 200, 24);
464 WMSetButtonText(panel
->unsB
, _("Set..."));
466 panel
->unsnC
= WMCreateColorWell(panel
->unsF
);
467 WMResizeWidget(panel
->unsnC
, 60, 40);
468 WMMoveWidget(panel
->unsnC
, 40, 75);
470 panel
->unsnL
= WMCreateLabel(panel
->unsF
);
471 WMResizeWidget(panel
->unsnL
, 120, 16);
472 WMMoveWidget(panel
->unsnL
, 10, 117);
473 WMSetLabelTextAlignment(panel
->unsnL
, WACenter
);
474 WMSetLabelText(panel
->unsnL
, _("Normal Text"));
476 panel
->unsdC
= WMCreateColorWell(panel
->unsF
);
477 WMResizeWidget(panel
->unsdC
, 60, 40);
478 WMMoveWidget(panel
->unsdC
, 160, 75);
480 panel
->unsdL
= WMCreateLabel(panel
->unsF
);
481 WMResizeWidget(panel
->unsdL
, 120, 16);
482 WMMoveWidget(panel
->unsdL
, 130, 117);
483 WMSetLabelTextAlignment(panel
->unsdL
, WACenter
);
484 WMSetLabelText(panel
->unsdL
, _("Disabled Text"));
486 WMMapSubwidgets(panel
->unsF
);
490 panel
->selF
= WMCreateFrame(panel
->frame
);
491 WMResizeWidget(panel
->selF
, 260, 75);
492 WMMoveWidget(panel
->selF
, 250, 150);
493 WMSetFrameTitle(panel
->selF
, _("Selected Items"));
495 panel
->seltC
= WMCreateColorWell(panel
->selF
);
496 WMResizeWidget(panel
->seltC
, 60, 36);
497 WMMoveWidget(panel
->seltC
, 40, 20);
499 panel
->seltL
= WMCreateLabel(panel
->selF
);
500 WMResizeWidget(panel
->seltL
, 120, 16);
501 WMMoveWidget(panel
->seltL
, 10, 56);
502 WMSetLabelTextAlignment(panel
->seltL
, WACenter
);
503 WMSetLabelText(panel
->seltL
, _("Text"));
505 panel
->selbC
= WMCreateColorWell(panel
->selF
);
506 WMResizeWidget(panel
->selbC
, 60, 36);
507 WMMoveWidget(panel
->selbC
, 160, 20);
509 panel
->selbL
= WMCreateLabel(panel
->selF
);
510 WMResizeWidget(panel
->selbL
, 120, 16);
511 WMMoveWidget(panel
->selbL
, 130, 56);
512 WMSetLabelTextAlignment(panel
->selbL
, WACenter
);
513 WMSetLabelText(panel
->selbL
, _("Background"));
515 WMMapSubwidgets(panel
->selF
);
517 /***************** Menu Title *****************/
518 panel
->backF
= WMCreateFrame(panel
->frame
);
519 WMResizeWidget(panel
->backF
, 260, 110);
520 WMMoveWidget(panel
->backF
, 250, 35);
521 WMSetFrameTitle(panel
->backF
, _("Menu Title Background"));
523 panel
->backT
= WMCreateTextField(panel
->backF
);
524 WMResizeWidget(panel
->backT
, 210, 20);
525 WMMoveWidget(panel
->backT
, 25, 35);
527 panel
->backB
= WMCreateCommandButton(panel
->backF
);
528 WMResizeWidget(panel
->backB
, 50, 24);
529 WMMoveWidget(panel
->backB
, 185, 60);
530 WMSetButtonText(panel
->backB
, _("Set..."));
532 WMMapSubwidgets(panel
->backF
);
536 panel
->textF
= WMCreateFrame(panel
->frame
);
537 WMResizeWidget(panel
->textF
, 260, 75);
538 WMMoveWidget(panel
->textF
, 250, 150);
539 WMSetFrameTitle(panel
->textF
, _("Menu Title Text"));
541 panel
->textC
= WMCreateColorWell(panel
->textF
);
542 WMResizeWidget(panel
->textC
, 60, 40);
543 WMMoveWidget(panel
->textC
, 100, 20);
545 WMMapSubwidgets(panel
->textF
);
547 /***************** Workspace ****************/
548 panel
->workF
= WMCreateFrame(panel
->frame
);
549 WMResizeWidget(panel
->workF
, 260, 90);
550 WMMoveWidget(panel
->workF
, 250, 35);
551 WMSetFrameTitle(panel
->workF
, _("Workspace Background"));
553 panel
->workT
= WMCreateTextField(panel
->workF
);
554 WMResizeWidget(panel
->workT
, 220, 20);
555 WMMoveWidget(panel
->workT
, 20, 25);
557 panel
->workB
= WMCreateCommandButton(panel
->workF
);
558 WMResizeWidget(panel
->workB
, 70, 24);
559 WMMoveWidget(panel
->workB
, 170, 55);
560 WMSetButtonText(panel
->workB
, _("Change"));
563 panel
->clipF
= WMCreateFrame(panel
->frame
);
564 WMResizeWidget(panel
->clipF
, 260, 90);
565 WMMoveWidget(panel
->clipF
, 250, 135);
566 WMSetFrameTitle(panel
->clipF
, _("Clip Title Text"));
568 panel
->clipnC
= WMCreateColorWell(panel
->clipF
);
569 WMResizeWidget(panel
->clipnC
, 60, 40);
570 WMMoveWidget(panel
->clipnC
, 40, 25);
572 panel
->clipnL
= WMCreateLabel(panel
->clipF
);
573 WMResizeWidget(panel
->clipnL
, 120, 16);
574 WMMoveWidget(panel
->clipnL
, 10, 70);
575 WMSetLabelTextAlignment(panel
->clipnL
, WACenter
);
576 WMSetLabelText(panel
->clipnL
, _("Normal"));
578 panel
->clipcC
= WMCreateColorWell(panel
->clipF
);
579 WMResizeWidget(panel
->clipcC
, 60, 40);
580 WMMoveWidget(panel
->clipcC
, 160, 25);
582 panel
->clipcL
= WMCreateLabel(panel
->clipF
);
583 WMResizeWidget(panel
->clipcL
, 120, 16);
584 WMMoveWidget(panel
->clipcL
, 130, 70);
585 WMSetLabelTextAlignment(panel
->clipcL
, WACenter
);
586 WMSetLabelText(panel
->clipcL
, _("Collapsed"));
588 WMMapSubwidgets(panel
->clipF
);
592 WMMapSubwidgets(panel
->workF
);
594 /***************** Icon *****************/
595 panel
->iconF
= WMCreateFrame(panel
->frame
);
596 WMResizeWidget(panel
->iconF
, 260, 190);
597 WMMoveWidget(panel
->iconF
, 250, 35);
598 WMSetFrameTitle(panel
->iconF
, _("Icon Background"));
600 panel
->iconT
= WMCreateTextField(panel
->iconF
);
601 WMResizeWidget(panel
->iconT
, 220, 20);
602 WMMoveWidget(panel
->iconT
, 20, 80);
604 panel
->iconB
= WMCreateCommandButton(panel
->iconF
);
605 WMResizeWidget(panel
->iconB
, 50, 24);
606 WMMoveWidget(panel
->iconB
, 190, 105);
607 WMSetButtonText(panel
->iconB
, _("Set..."));
609 WMMapSubwidgets(panel
->iconF
);
612 WMRealizeWidget(panel
->frame
);
613 WMMapSubwidgets(panel
->frame
);
615 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
616 changePage(panel
->secP
, panel
);
625 InitTextureAndColor(WMScreen
*scr
, WMWindow
*win
)
629 panel
= wmalloc(sizeof(_Panel
));
630 memset(panel
, 0, sizeof(_Panel
));
632 panel
->sectionName
= _("Texture and Color Preferences");
636 panel
->callbacks
.createWidgets
= createPanel
;
638 AddSection(panel
, ICON_FILE
);