1 /* TextureAndColor.c- color/texture for titlebar etc.
3 * WPrefs - Window Maker 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 #include "TexturePanel.h"
28 typedef struct _Panel
{
32 CallbackRec callbacks
;
115 #define ICON_FILE "appearance"
118 #define FTITLE (1<<0)
119 #define UTITLE (1<<1)
120 #define OTITLE (1<<2)
123 #define MTITLE (1<<5)
125 #define EVERYTHING 0xff
129 renderTexture(_Panel
*panel
, char *texture
, int width
, int height
,
137 updatePreviewBox(_Panel
*panel
, int elements
)
139 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
140 Display
*dpy
= WMScreenDisplay(scr
);
141 /* RContext *rc = WMScreenRContext(scr);*/
145 if (!panel
->preview
) {
146 panel
->preview
= XCreatePixmap(dpy
, WMWidgetXID(panel
->win
),
147 220-4, 185-4, WMScreenDepth(scr
));
152 if (elements
& FTITLE
) {
154 XFreePixmap(dpy
, panel
->ftitle
);
156 tmp
= WMGetTextFieldText(panel
->focT
);
157 panel
->ftitle
= renderTexture(panel
, tmp
, 180, 20, True
);
161 /* have to repaint everything to make things simple, eliminating
169 pix
= WMCreatePixmapFromXPixmaps(scr
, panel
->preview
, None
,
170 220-4, 185-4, WMScreenDepth(scr
));
172 WMSetLabelImage(panel
->prevL
, pix
);
173 WMReleasePixmap(pix
);
180 changePage(WMWidget
*self
, void *data
)
183 _Panel
*panel
= (_Panel
*)data
;
185 i
= WMGetPopUpButtonSelectedItem(self
);
188 WMMapWidget(panel
->focF
);
189 WMMapWidget(panel
->unfF
);
190 WMMapWidget(panel
->ownF
);
192 WMMapWidget(panel
->backF
);
193 WMMapWidget(panel
->textF
);
195 WMMapWidget(panel
->unsF
);
196 WMMapWidget(panel
->selF
);
198 WMMapWidget(panel
->workF
);
199 WMMapWidget(panel
->clipF
);
201 WMMapWidget(panel
->iconF
);
205 WMUnmapWidget(panel
->focF
);
206 WMUnmapWidget(panel
->unfF
);
207 WMUnmapWidget(panel
->ownF
);
210 WMUnmapWidget(panel
->backF
);
211 WMUnmapWidget(panel
->textF
);
214 WMUnmapWidget(panel
->unsF
);
215 WMUnmapWidget(panel
->selF
);
218 WMUnmapWidget(panel
->workF
);
219 WMUnmapWidget(panel
->clipF
);
222 WMUnmapWidget(panel
->iconF
);
228 getStrArrayForKey(char *key
)
232 v
= GetObjectForKey(key
);
236 return PLGetDescription(v
);
241 showData(_Panel
*panel
)
244 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
247 str
= GetStringForKey("FTitleColor");
250 color
= WMCreateNamedColor(scr
, str
, True
);
251 WMSetColorWellColor(panel
->focC
, color
);
252 WMReleaseColor(color
);
254 str
= GetStringForKey("PTitleColor");
257 color
= WMCreateNamedColor(scr
, str
, True
);
258 WMSetColorWellColor(panel
->ownC
, color
);
259 WMReleaseColor(color
);
261 str
= GetStringForKey("UTitleColor");
264 color
= WMCreateNamedColor(scr
, str
, True
);
265 WMSetColorWellColor(panel
->unfC
, color
);
266 WMReleaseColor(color
);
269 str
= getStrArrayForKey("FTitleBack");
271 str
= wstrdup("(solid, black)");
272 WMSetTextFieldText(panel
->focT
, str
);
275 str
= getStrArrayForKey("PTitleBack");
277 str
= wstrdup("(solid, gray40)");
278 WMSetTextFieldText(panel
->ownT
, str
);
281 str
= getStrArrayForKey("UTitleBack");
283 str
= wstrdup("(solid, grey66)");
284 WMSetTextFieldText(panel
->unfT
, str
);
289 str
= GetStringForKey("MenuTitleColor");
292 color
= WMCreateNamedColor(scr
, str
, True
);
293 WMSetColorWellColor(panel
->textC
, color
);
294 WMReleaseColor(color
);
296 str
= getStrArrayForKey("MenuTitleBack");
298 str
= wstrdup("(solid, black)");
299 WMSetTextFieldText(panel
->backT
, str
);
304 str
= getStrArrayForKey("MenuTextBack");
306 str
= wstrdup("gray66");
307 WMSetTextFieldText(panel
->unsT
, str
);
310 str
= GetStringForKey("MenuTextColor");
313 color
= WMCreateNamedColor(scr
, str
, True
);
314 WMSetColorWellColor(panel
->unsnC
, color
);
315 WMReleaseColor(color
);
317 str
= GetStringForKey("MenuDisabledColor");
320 color
= WMCreateNamedColor(scr
, str
, True
);
321 WMSetColorWellColor(panel
->unsdC
, color
);
322 WMReleaseColor(color
);
324 str
= GetStringForKey("HighlightTextColor");
327 color
= WMCreateNamedColor(scr
, str
, True
);
328 WMSetColorWellColor(panel
->seltC
, color
);
329 WMReleaseColor(color
);
331 str
= GetStringForKey("HighlightColor");
334 color
= WMCreateNamedColor(scr
, str
, True
);
335 WMSetColorWellColor(panel
->selbC
, color
);
336 WMReleaseColor(color
);
340 str
= getStrArrayForKey("WorkspaceBack");
341 WMSetTextFieldText(panel
->workT
, str
);
346 str
= GetStringForKey("ClipTitleColor");
349 color
= WMCreateNamedColor(scr
, str
, True
);
350 WMSetColorWellColor(panel
->clipnC
, color
);
351 WMReleaseColor(color
);
353 str
= GetStringForKey("CClipTitleColor");
356 color
= WMCreateNamedColor(scr
, str
, True
);
357 WMSetColorWellColor(panel
->clipcC
, color
);
358 WMReleaseColor(color
);
362 str
= getStrArrayForKey("IconBack");
364 str
= wstrdup("(solid, gray66)");
365 WMSetTextFieldText(panel
->iconT
, str
);
371 createPanel(Panel
*p
)
373 _Panel
*panel
= (_Panel
*)p
;
375 panel
->frame
= WMCreateFrame(panel
->win
);
376 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
377 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
379 panel
->secP
= WMCreatePopUpButton(panel
->frame
);
380 WMResizeWidget(panel
->secP
, 220, 20);
381 WMMoveWidget(panel
->secP
, 15, 10);
382 WMSetPopUpButtonAction(panel
->secP
, changePage
, panel
);
384 WMAddPopUpButtonItem(panel
->secP
, _("Window Title Bar"));
385 WMAddPopUpButtonItem(panel
->secP
, _("Menu Title Bar"));
386 WMAddPopUpButtonItem(panel
->secP
, _("Menu Items"));
387 WMAddPopUpButtonItem(panel
->secP
, _("Workspace/Clip"));
388 WMAddPopUpButtonItem(panel
->secP
, _("Icons"));
390 panel
->prevL
= WMCreateLabel(panel
->frame
);
391 WMResizeWidget(panel
->prevL
, 220, 185);
392 WMMoveWidget(panel
->prevL
, 15, 40);
393 WMSetLabelRelief(panel
->prevL
, WRSunken
);
395 /* window titlebar */
396 panel
->focF
= WMCreateFrame(panel
->frame
);
397 WMResizeWidget(panel
->focF
, 265, 70);
398 WMMoveWidget(panel
->focF
, 245, 5);
399 WMSetFrameTitle(panel
->focF
, _("Focused Window"));
401 panel
->focC
= WMCreateColorWell(panel
->focF
);
402 WMResizeWidget(panel
->focC
, 60, 35);
403 WMMoveWidget(panel
->focC
, 15, 15);
405 panel
->focT
= WMCreateTextField(panel
->focF
);
406 WMResizeWidget(panel
->focT
, 116, 20);
407 WMMoveWidget(panel
->focT
, 85, 25);
409 panel
->foc2L
= WMCreateLabel(panel
->focF
);
410 WMResizeWidget(panel
->foc2L
, 165, 16);
411 WMMoveWidget(panel
->foc2L
, 90, 50);
412 WMSetLabelText(panel
->foc2L
, _("Texture"));
413 WMSetLabelTextAlignment(panel
->foc2L
, WACenter
);
415 panel
->focL
= WMCreateLabel(panel
->focF
);
416 WMResizeWidget(panel
->focL
, 100, 16);
417 WMMoveWidget(panel
->focL
, 15, 50);
418 WMSetLabelText(panel
->focL
, _("Text Color"));
420 panel
->focB
= WMCreateCommandButton(panel
->focF
);
421 WMResizeWidget(panel
->focB
, 48, 22);
422 WMMoveWidget(panel
->focB
, 205, 24);
423 WMSetButtonText(panel
->focB
, _("Set..."));
425 WMMapSubwidgets(panel
->focF
);
427 panel
->unfF
= WMCreateFrame(panel
->frame
);
428 WMResizeWidget(panel
->unfF
, 265, 70);
429 WMMoveWidget(panel
->unfF
, 245, 80);
430 WMSetFrameTitle(panel
->unfF
, _("Unfocused Window"));
432 panel
->unfC
= WMCreateColorWell(panel
->unfF
);
433 WMResizeWidget(panel
->unfC
, 60, 35);
434 WMMoveWidget(panel
->unfC
, 15, 15);
436 panel
->unfT
= WMCreateTextField(panel
->unfF
);
437 WMResizeWidget(panel
->unfT
, 116, 20);
438 WMMoveWidget(panel
->unfT
, 85, 25);
440 panel
->unf2L
= WMCreateLabel(panel
->unfF
);
441 WMResizeWidget(panel
->unf2L
, 165, 16);
442 WMMoveWidget(panel
->unf2L
, 90, 50);
443 WMSetLabelText(panel
->unf2L
, _("Texture"));
444 WMSetLabelTextAlignment(panel
->unf2L
, WACenter
);
446 panel
->unfL
= WMCreateLabel(panel
->unfF
);
447 WMResizeWidget(panel
->unfL
, 100, 16);
448 WMMoveWidget(panel
->unfL
, 15, 50);
449 WMSetLabelText(panel
->unfL
, _("Text Color"));
451 panel
->unfB
= WMCreateCommandButton(panel
->unfF
);
452 WMResizeWidget(panel
->unfB
, 48, 22);
453 WMMoveWidget(panel
->unfB
, 205, 24);
454 WMSetButtonText(panel
->unfB
, _("Set..."));
456 WMMapSubwidgets(panel
->unfF
);
458 panel
->ownF
= WMCreateFrame(panel
->frame
);
459 WMResizeWidget(panel
->ownF
, 265, 70);
460 WMMoveWidget(panel
->ownF
, 245, 155);
461 WMSetFrameTitle(panel
->ownF
, _("Owner of Focused Window"));
463 panel
->ownC
= WMCreateColorWell(panel
->ownF
);
464 WMResizeWidget(panel
->ownC
, 60, 35);
465 WMMoveWidget(panel
->ownC
, 15, 15);
467 panel
->ownT
= WMCreateTextField(panel
->ownF
);
468 WMResizeWidget(panel
->ownT
, 116, 20);
469 WMMoveWidget(panel
->ownT
, 85, 25);
471 panel
->own2L
= WMCreateLabel(panel
->ownF
);
472 WMResizeWidget(panel
->own2L
, 165, 16);
473 WMMoveWidget(panel
->own2L
, 90, 50);
474 WMSetLabelText(panel
->own2L
, _("Texture"));
475 WMSetLabelTextAlignment(panel
->own2L
, WACenter
);
477 panel
->ownL
= WMCreateLabel(panel
->ownF
);
478 WMResizeWidget(panel
->ownL
, 100, 16);
479 WMMoveWidget(panel
->ownL
, 15, 50);
480 WMSetLabelText(panel
->ownL
, _("Text Color"));
482 panel
->ownB
= WMCreateCommandButton(panel
->ownF
);
483 WMResizeWidget(panel
->ownB
, 48, 22);
484 WMMoveWidget(panel
->ownB
, 205, 24);
485 WMSetButtonText(panel
->ownB
, _("Set..."));
487 WMMapSubwidgets(panel
->ownF
);
489 /***************** Menu Item *****************/
491 panel
->unsF
= WMCreateFrame(panel
->frame
);
492 WMResizeWidget(panel
->unsF
, 260, 140);
493 WMMoveWidget(panel
->unsF
, 250, 5);
494 WMSetFrameTitle(panel
->unsF
, _("Unselected Items"));
496 panel
->unsT
= WMCreateTextField(panel
->unsF
);
497 WMResizeWidget(panel
->unsT
, 175, 20);
498 WMMoveWidget(panel
->unsT
, 15, 25);
500 panel
->unsL
= WMCreateLabel(panel
->unsF
);
501 WMResizeWidget(panel
->unsL
, 175, 16);
502 WMMoveWidget(panel
->unsL
, 15, 50);
503 WMSetLabelTextAlignment(panel
->unsL
, WACenter
);
504 WMSetLabelText(panel
->unsL
, _("Background"));
506 panel
->unsB
= WMCreateCommandButton(panel
->unsF
);
507 WMResizeWidget(panel
->unsB
, 48, 22);
508 WMMoveWidget(panel
->unsB
, 200, 24);
509 WMSetButtonText(panel
->unsB
, _("Set..."));
511 panel
->unsnC
= WMCreateColorWell(panel
->unsF
);
512 WMResizeWidget(panel
->unsnC
, 60, 40);
513 WMMoveWidget(panel
->unsnC
, 40, 75);
515 panel
->unsnL
= WMCreateLabel(panel
->unsF
);
516 WMResizeWidget(panel
->unsnL
, 120, 16);
517 WMMoveWidget(panel
->unsnL
, 10, 117);
518 WMSetLabelTextAlignment(panel
->unsnL
, WACenter
);
519 WMSetLabelText(panel
->unsnL
, _("Normal Text"));
521 panel
->unsdC
= WMCreateColorWell(panel
->unsF
);
522 WMResizeWidget(panel
->unsdC
, 60, 40);
523 WMMoveWidget(panel
->unsdC
, 160, 75);
525 panel
->unsdL
= WMCreateLabel(panel
->unsF
);
526 WMResizeWidget(panel
->unsdL
, 120, 16);
527 WMMoveWidget(panel
->unsdL
, 130, 117);
528 WMSetLabelTextAlignment(panel
->unsdL
, WACenter
);
529 WMSetLabelText(panel
->unsdL
, _("Disabled Text"));
531 WMMapSubwidgets(panel
->unsF
);
535 panel
->selF
= WMCreateFrame(panel
->frame
);
536 WMResizeWidget(panel
->selF
, 260, 75);
537 WMMoveWidget(panel
->selF
, 250, 150);
538 WMSetFrameTitle(panel
->selF
, _("Selected Items"));
540 panel
->seltC
= WMCreateColorWell(panel
->selF
);
541 WMResizeWidget(panel
->seltC
, 60, 36);
542 WMMoveWidget(panel
->seltC
, 40, 20);
544 panel
->seltL
= WMCreateLabel(panel
->selF
);
545 WMResizeWidget(panel
->seltL
, 120, 16);
546 WMMoveWidget(panel
->seltL
, 10, 56);
547 WMSetLabelTextAlignment(panel
->seltL
, WACenter
);
548 WMSetLabelText(panel
->seltL
, _("Text"));
550 panel
->selbC
= WMCreateColorWell(panel
->selF
);
551 WMResizeWidget(panel
->selbC
, 60, 36);
552 WMMoveWidget(panel
->selbC
, 160, 20);
554 panel
->selbL
= WMCreateLabel(panel
->selF
);
555 WMResizeWidget(panel
->selbL
, 120, 16);
556 WMMoveWidget(panel
->selbL
, 130, 56);
557 WMSetLabelTextAlignment(panel
->selbL
, WACenter
);
558 WMSetLabelText(panel
->selbL
, _("Background"));
560 WMMapSubwidgets(panel
->selF
);
562 /***************** Menu Title *****************/
563 panel
->backF
= WMCreateFrame(panel
->frame
);
564 WMResizeWidget(panel
->backF
, 260, 110);
565 WMMoveWidget(panel
->backF
, 250, 35);
566 WMSetFrameTitle(panel
->backF
, _("Menu Title Background"));
568 panel
->backT
= WMCreateTextField(panel
->backF
);
569 WMResizeWidget(panel
->backT
, 210, 20);
570 WMMoveWidget(panel
->backT
, 25, 35);
572 panel
->backB
= WMCreateCommandButton(panel
->backF
);
573 WMResizeWidget(panel
->backB
, 50, 24);
574 WMMoveWidget(panel
->backB
, 185, 60);
575 WMSetButtonText(panel
->backB
, _("Set..."));
577 WMMapSubwidgets(panel
->backF
);
581 panel
->textF
= WMCreateFrame(panel
->frame
);
582 WMResizeWidget(panel
->textF
, 260, 75);
583 WMMoveWidget(panel
->textF
, 250, 150);
584 WMSetFrameTitle(panel
->textF
, _("Menu Title Text"));
586 panel
->textC
= WMCreateColorWell(panel
->textF
);
587 WMResizeWidget(panel
->textC
, 60, 40);
588 WMMoveWidget(panel
->textC
, 100, 20);
590 WMMapSubwidgets(panel
->textF
);
592 /***************** Workspace ****************/
593 panel
->workF
= WMCreateFrame(panel
->frame
);
594 WMResizeWidget(panel
->workF
, 260, 90);
595 WMMoveWidget(panel
->workF
, 250, 35);
596 WMSetFrameTitle(panel
->workF
, _("Workspace Background"));
598 panel
->workT
= WMCreateTextField(panel
->workF
);
599 WMResizeWidget(panel
->workT
, 220, 20);
600 WMMoveWidget(panel
->workT
, 20, 25);
602 panel
->workB
= WMCreateCommandButton(panel
->workF
);
603 WMResizeWidget(panel
->workB
, 70, 24);
604 WMMoveWidget(panel
->workB
, 170, 55);
605 WMSetButtonText(panel
->workB
, _("Change"));
608 panel
->clipF
= WMCreateFrame(panel
->frame
);
609 WMResizeWidget(panel
->clipF
, 260, 90);
610 WMMoveWidget(panel
->clipF
, 250, 135);
611 WMSetFrameTitle(panel
->clipF
, _("Clip Title Text"));
613 panel
->clipnC
= WMCreateColorWell(panel
->clipF
);
614 WMResizeWidget(panel
->clipnC
, 60, 40);
615 WMMoveWidget(panel
->clipnC
, 40, 25);
617 panel
->clipnL
= WMCreateLabel(panel
->clipF
);
618 WMResizeWidget(panel
->clipnL
, 120, 16);
619 WMMoveWidget(panel
->clipnL
, 10, 70);
620 WMSetLabelTextAlignment(panel
->clipnL
, WACenter
);
621 WMSetLabelText(panel
->clipnL
, _("Normal"));
623 panel
->clipcC
= WMCreateColorWell(panel
->clipF
);
624 WMResizeWidget(panel
->clipcC
, 60, 40);
625 WMMoveWidget(panel
->clipcC
, 160, 25);
627 panel
->clipcL
= WMCreateLabel(panel
->clipF
);
628 WMResizeWidget(panel
->clipcL
, 120, 16);
629 WMMoveWidget(panel
->clipcL
, 130, 70);
630 WMSetLabelTextAlignment(panel
->clipcL
, WACenter
);
631 WMSetLabelText(panel
->clipcL
, _("Collapsed"));
633 WMMapSubwidgets(panel
->clipF
);
637 WMMapSubwidgets(panel
->workF
);
639 /***************** Icon *****************/
640 panel
->iconF
= WMCreateFrame(panel
->frame
);
641 WMResizeWidget(panel
->iconF
, 260, 190);
642 WMMoveWidget(panel
->iconF
, 250, 35);
643 WMSetFrameTitle(panel
->iconF
, _("Icon Background"));
645 panel
->iconT
= WMCreateTextField(panel
->iconF
);
646 WMResizeWidget(panel
->iconT
, 220, 20);
647 WMMoveWidget(panel
->iconT
, 20, 80);
649 panel
->iconB
= WMCreateCommandButton(panel
->iconF
);
650 WMResizeWidget(panel
->iconB
, 50, 24);
651 WMMoveWidget(panel
->iconB
, 190, 105);
652 WMSetButtonText(panel
->iconB
, _("Set..."));
654 WMMapSubwidgets(panel
->iconF
);
657 WMRealizeWidget(panel
->frame
);
658 WMMapSubwidgets(panel
->frame
);
660 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
661 changePage(panel
->secP
, panel
);
670 InitTextureAndColor(WMScreen
*scr
, WMWindow
*win
)
674 panel
= wmalloc(sizeof(_Panel
));
675 memset(panel
, 0, sizeof(_Panel
));
677 panel
->sectionName
= _("Texture and Color Preferences");
681 panel
->callbacks
.createWidgets
= createPanel
;
683 AddSection(panel
, ICON_FILE
);