~profzoom/ubuntu/quantal/wmaker/bug-1079925

« back to all changes in this revision

Viewing changes to WPrefs.app/Appearance.c

  • Committer: Bazaar Package Importer
  • Author(s): Marcelo E. Magallon
  • Date: 2004-11-10 14:05:30 UTC
  • Revision ID: james.westby@ubuntu.com-20041110140530-qpd66b5lm38x7apk
Tags: upstream-0.91.0
ImportĀ upstreamĀ versionĀ 0.91.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Apperance.c- color/texture for titlebar etc.
 
2
 *
 
3
 *  WPrefs - Window Maker Preferences Program
 
4
 *
 
5
 *  Copyright (c) 1999-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
 
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.
 
21
 */
 
22
 
 
23
 
 
24
#include "WPrefs.h"
 
25
 
 
26
#include <unistd.h>
 
27
#include <errno.h>
 
28
#include <ctype.h>
 
29
#include <time.h>
 
30
#include <sys/stat.h>
 
31
#include <sys/types.h>
 
32
#include <fcntl.h>
 
33
#include <unistd.h>
 
34
 
 
35
 
 
36
 
 
37
 
 
38
#include "TexturePanel.h"
 
39
 
 
40
typedef struct _Panel {
 
41
    WMBox *box;
 
42
    char *sectionName;
 
43
 
 
44
    char *description;
 
45
 
 
46
    CallbackRec callbacks;
 
47
 
 
48
    WMWidget *parent;
 
49
 
 
50
    WMLabel *prevL;
 
51
 
 
52
 
 
53
    WMTabView *tabv;
 
54
 
 
55
    /* texture list */
 
56
    WMFrame *texF;
 
57
    WMList *texLs;
 
58
 
 
59
    WMPopUpButton *secP;
 
60
 
 
61
    WMButton *newB;
 
62
    WMButton *editB;
 
63
    WMButton *ripB;
 
64
    WMButton *delB;
 
65
 
 
66
    /* text color */
 
67
    WMFrame *colF;
 
68
 
 
69
    WMPopUpButton *colP;
 
70
    WMColor *colors[14];
 
71
 
 
72
    WMColorWell *colW;
 
73
 
 
74
    WMColorWell *sampW[24];
 
75
 
 
76
    /* options */
 
77
    WMFrame *optF;
 
78
 
 
79
    WMFrame *mstyF;
 
80
    WMButton *mstyB[3];
 
81
 
 
82
    WMFrame *taliF;
 
83
    WMButton *taliB[3];
 
84
 
 
85
    /* root bg */
 
86
    WMFrame *bgF;
 
87
 
 
88
    WMLabel *bgprevL;
 
89
    WMButton *selbgB;
 
90
 
 
91
    WMPopUpButton *modeB[3];
 
92
 
 
93
    /* */
 
94
 
 
95
    int textureIndex[8];
 
96
 
 
97
    WMFont *smallFont;
 
98
    WMFont *normalFont;
 
99
    WMFont *boldFont;
 
100
 
 
101
    TexturePanel *texturePanel;
 
102
 
 
103
    WMPixmap *onLed;
 
104
    WMPixmap *offLed;
 
105
    WMPixmap *hand;
 
106
 
 
107
    int oldsection;
 
108
    int oldcsection;
 
109
 
 
110
    char oldTabItem;
 
111
 
 
112
    int menuStyle;
 
113
 
 
114
    int titleAlignment;
 
115
 
 
116
    Pixmap preview;
 
117
    Pixmap previewNoText;
 
118
 
 
119
    char *fprefix;
 
120
} _Panel;
 
121
 
 
122
 
 
123
typedef struct {
 
124
    char *title;
 
125
    char *texture;
 
126
    WMPropList *prop;
 
127
    Pixmap preview;
 
128
 
 
129
    char *path;
 
130
 
 
131
    char selectedFor;
 
132
    unsigned current:1;
 
133
    unsigned ispixmap:1;
 
134
} TextureListItem;
 
135
 
 
136
static void updateColorPreviewBox(_Panel *panel, int elements);
 
137
 
 
138
static void showData(_Panel *panel);
 
139
 
 
140
static void changePage(WMWidget *w, void *data);
 
141
 
 
142
static void changeColorPage(WMWidget *w, void *data);
 
143
 
 
144
static void OpenExtractPanelFor(_Panel *panel, char *path);
 
145
 
 
146
 
 
147
 
 
148
static void changedTabItem(struct WMTabViewDelegate *self, WMTabView *tabView,
 
149
                           WMTabViewItem *item);
 
150
 
 
151
 
 
152
 
 
153
static WMTabViewDelegate tabviewDelegate = {
 
154
    NULL,
 
155
    NULL, /* didChangeNumberOfItems */
 
156
    changedTabItem, /* didSelectItem */
 
157
    NULL, /* shouldSelectItem */
 
158
    NULL /* willSelectItem */
 
159
};
 
160
 
 
161
 
 
162
#define ICON_FILE       "appearance"
 
163
 
 
164
#define TNEW_FILE       "tnew"
 
165
#define TDEL_FILE       "tdel"
 
166
#define TEDIT_FILE      "tedit"
 
167
#define TEXTR_FILE      "textr"
 
168
 
 
169
#define MSTYLE1_FILE    "msty1"
 
170
#define MSTYLE2_FILE    "msty2"
 
171
#define MSTYLE3_FILE    "msty3"
 
172
 
 
173
 
 
174
/* XPM */
 
175
static char * blueled_xpm[] = {
 
176
    "8 8 17 1",
 
177
    "   c None",
 
178
    ".  c #020204",
 
179
    "+  c #16B6FC",
 
180
    "@  c #176AFC",
 
181
    "#  c #163AFC",
 
182
    "$  c #72D2FC",
 
183
    "%  c #224CF4",
 
184
    "&  c #76D6FC",
 
185
    "*  c #16AAFC",
 
186
    "=  c #CEE9FC",
 
187
    "-  c #229EFC",
 
188
    ";  c #164CFC",
 
189
    ">  c #FAFEFC",
 
190
    ",  c #2482FC",
 
191
    "'  c #1652FC",
 
192
    ")  c #1E76FC",
 
193
    "!  c #1A60FC",
 
194
    "  ....  ",
 
195
    " .=>-@. ",
 
196
    ".=>$@@'.",
 
197
    ".=$@!;;.",
 
198
    ".!@*+!#.",
 
199
    ".#'*+*,.",
 
200
    " .@)@,. ",
 
201
    "  ....  "};
 
202
 
 
203
 
 
204
/* XPM */
 
205
static char *blueled2_xpm[] = {
 
206
    /* width height num_colors chars_per_pixel */
 
207
    "     8     8       17            1",
 
208
    /* colors */
 
209
    ". c None",
 
210
    "# c #090909",
 
211
    "a c #4b63a4",
 
212
    "b c #011578",
 
213
    "c c #264194",
 
214
    "d c #04338c",
 
215
    "e c #989dac",
 
216
    "f c #011a7c",
 
217
    "g c #465c9c",
 
218
    "h c #03278a",
 
219
    "i c #6175ac",
 
220
    "j c #011e74",
 
221
    "k c #043a90",
 
222
    "l c #042f94",
 
223
    "m c #0933a4",
 
224
    "n c #022184",
 
225
    "o c #012998",
 
226
    /* pixels */
 
227
    "..####..",
 
228
    ".#aimn#.",
 
229
    "#aechnf#",
 
230
    "#gchnjf#",
 
231
    "#jndknb#",
 
232
    "#bjdddl#",
 
233
    ".#nono#.",
 
234
    "..####.."
 
235
};
 
236
 
 
237
 
 
238
/* XPM */
 
239
static char * hand_xpm[] = {
 
240
    "22 21 19 1",
 
241
    "       c None",
 
242
    ".      c #030305",
 
243
    "+      c #7F7F7E",
 
244
    "@      c #B5B5B6",
 
245
    "#      c #C5C5C6",
 
246
    "$      c #969697",
 
247
    "%      c #FDFDFB",
 
248
    "&      c #F2F2F4",
 
249
    "*      c #E5E5E4",
 
250
    "=      c #ECECEC",
 
251
    "-      c #DCDCDC",
 
252
    ";      c #D2D2D0",
 
253
    ">      c #101010",
 
254
    ",      c #767674",
 
255
    "'      c #676767",
 
256
    ")      c #535355",
 
257
    "!      c #323234",
 
258
    "~      c #3E3C56",
 
259
    "{      c #333147",
 
260
    "                      ",
 
261
    "       .....          ",
 
262
    "     ..+@##$.         ",
 
263
    "    .%%%&@..........  ",
 
264
    "   .%*%%&#%%%%%%%%%$. ",
 
265
    "  .*#%%%%%%%%%&&&&==. ",
 
266
    " .-%%%%%%%%%=*-;;;#$. ",
 
267
    " .-%%%%%%%%&..>.....  ",
 
268
    " >-%%%%%%%%%*#+.      ",
 
269
    " >-%%%%%%%%%*@,.      ",
 
270
    " >#%%%%%%%%%*@'.      ",
 
271
    " >$&&%%%%%%=...       ",
 
272
    " .+@@;=&%%&;$,>       ",
 
273
    "  .',$@####$+).       ",
 
274
    "   .!',+$++,'.        ",
 
275
    "     ..>>>>>.         ",
 
276
    "                      ",
 
277
    "     ~~{{{~~          ",
 
278
    "   {{{{{{{{{{{        ",
 
279
    "     ~~{{{~~          ",
 
280
    "                      "};
 
281
 
 
282
 
 
283
 
 
284
static char *sampleColors[] = {
 
285
    "black",
 
286
    "#292929",
 
287
    "#525252",
 
288
    "#848484",
 
289
    "#adadad",
 
290
    "#d6d6d6",
 
291
    "white",
 
292
    "#d6d68c",
 
293
    "#d6a57b",
 
294
    "#8cd68c",
 
295
    "#8cd6ce",
 
296
    "#d68c8c",
 
297
    "#8c9cd6",
 
298
    "#bd86d6",
 
299
    "#d68cbd",
 
300
    "#d64a4a",
 
301
    "#4a5ad6",
 
302
    "#4ad6ce",
 
303
    "#4ad65a",
 
304
    "#ced64a",
 
305
    "#d6844a",
 
306
    "#8ad631",
 
307
    "#ce29c6",
 
308
    "#ce2973",
 
309
    "black"
 
310
};
 
311
 
 
312
 
 
313
static char *textureOptions[] = {
 
314
    "FTitleBack", "(solid, black)", "[Focused]",
 
315
    "UTitleBack", "(solid, gray)", "[Unfocused]",
 
316
    "PTitleBack", "(solid, \"#616161\")", "[Owner of Focused]",
 
317
    "ResizebarBack", "(solid, gray)", "[Resizebar]",
 
318
    "MenuTitleBack", "(solid, black)", "[Menu Title]",
 
319
    "MenuTextBack", "(solid, gray)", "[Menu Item]",
 
320
    "IconBack", "(solid, gray)", "[Icon]"
 
321
};
 
322
 
 
323
 
 
324
#define RESIZEBAR_BEVEL -1
 
325
#define MENU_BEVEL      -2
 
326
 
 
327
#define TEXPREV_WIDTH   40
 
328
#define TEXPREV_HEIGHT  24
 
329
 
 
330
 
 
331
#define MSTYLE_NORMAL   0
 
332
#define MSTYLE_SINGLE   1
 
333
#define MSTYLE_FLAT     2
 
334
 
 
335
 
 
336
#define FTITLE_COL      (1<<0)
 
337
#define UTITLE_COL      (1<<1)
 
338
#define OTITLE_COL      (1<<2)
 
339
#define MTITLE_COL      (1<<3)
 
340
#define MITEM_COL       (1<<4)
 
341
#define MDISAB_COL      (1<<5)
 
342
#define MHIGH_COL       (1<<6)
 
343
#define MHIGHT_COL      (1<<7)
 
344
#define ICONT_COL       (1<<8)
 
345
#define ICONB_COL       (1<<9)
 
346
#define CLIP_COL        (1<<10)
 
347
#define CCLIP_COL       (1<<11)
 
348
 
 
349
 
 
350
static char *colorOptions[] = {
 
351
    "FTitleColor", "white",
 
352
    "UTitleColor", "black",
 
353
    "PTitleColor", "white",
 
354
    "MenuTitleColor", "white",
 
355
    "MenuTextColor", "black",
 
356
    "MenuDisabledColor", "#616161",
 
357
    "HighlightColor", "white",
 
358
    "HighlightTextColor", "black",
 
359
    "IconTitleColor", "white",
 
360
    "IconTitleBack", "black",
 
361
    "ClipTitleColor", "black",
 
362
    "CClipTitleColor", "#454045"
 
363
};
 
364
 
 
365
 
 
366
 
 
367
 
 
368
static WMRect previewPositions[] = {
 
369
#define PFOCUSED        0
 
370
    {{30,10},{190, 20}},
 
371
#define PUNFOCUSED      1
 
372
    {{30,40},{190,20}},
 
373
#define POWNER          2
 
374
    {{30,70},{190,20}},
 
375
#define PRESIZEBAR      3
 
376
    {{30,100},{190,9}},
 
377
#define PMTITLE         4
 
378
    {{30,120},{90,20}},
 
379
#define PMITEM          5
 
380
    {{30,140},{90,20*4}},
 
381
#define PICON           6
 
382
    {{155,130},{64,64}}
 
383
};
 
384
#define EVERYTHING      0xff
 
385
 
 
386
 
 
387
static WMRect previewColorPositions[] = {
 
388
    {{30,10},{190, 20}},
 
389
    {{30,40},{190,20}},
 
390
    {{30,70},{190,20}},
 
391
    {{30,120},{90,20}},
 
392
    {{30,140},{90,20}},
 
393
    {{30,160},{90,20}},
 
394
    {{30,180},{90,20}},
 
395
    {{30,200},{90,20}},
 
396
    {{155,130},{64,64}},
 
397
    {{155,130},{64,64}},
 
398
    {{155,130},{64,64}},
 
399
    {{155,130},{64,64}}
 
400
};
 
401
 
 
402
 
 
403
 
 
404
static void
 
405
str2rcolor(RContext *rc, char *name, RColor *color)
 
406
{
 
407
    XColor xcolor;
 
408
 
 
409
    XParseColor(rc->dpy, rc->cmap, name, &xcolor);
 
410
 
 
411
    color->alpha = 255;
 
412
    color->red = xcolor.red >> 8;
 
413
    color->green = xcolor.green >> 8;
 
414
    color->blue = xcolor.blue >> 8;
 
415
}
 
416
 
 
417
 
 
418
static void
 
419
dumpRImage(char *path, RImage *image)
 
420
{
 
421
    FILE *f;
 
422
    int channels = (image->format == RRGBAFormat ? 4 : 3);
 
423
 
 
424
    f = fopen(path, "wb");
 
425
    if (!f) {
 
426
        wsyserror(path);
 
427
        return;
 
428
    }
 
429
    fprintf(f, "%02x%02x%1x", image->width, image->height, channels);
 
430
 
 
431
    fwrite(image->data, 1, image->width * image->height * channels, f);
 
432
 
 
433
    if (fclose(f) < 0) {
 
434
        wsyserror(path);
 
435
    }
 
436
}
 
437
 
 
438
 
 
439
 
 
440
static int
 
441
isPixmap(WMPropList *prop)
 
442
{
 
443
    WMPropList *p;
 
444
    char *s;
 
445
 
 
446
    p = WMGetFromPLArray(prop, 0);
 
447
    s = WMGetFromPLString(p);
 
448
    if (strcasecmp(&s[1], "pixmap")==0)
 
449
        return 1;
 
450
    else
 
451
        return 0;
 
452
}
 
453
 
 
454
 
 
455
/**********************************************************************/
 
456
 
 
457
static void
 
458
drawResizebarBevel(RImage *img)
 
459
{
 
460
    RColor light;
 
461
    RColor dark;
 
462
    RColor black;
 
463
    int width = img->width;
 
464
    int height = img->height;
 
465
    int cwidth = 28;
 
466
 
 
467
    black.alpha = 255;
 
468
    black.red = black.green = black.blue = 0;
 
469
 
 
470
    light.alpha = 0;
 
471
    light.red = light.green = light.blue = 80;
 
472
 
 
473
    dark.alpha = 0;
 
474
    dark.red = dark.green = dark.blue = 40;
 
475
 
 
476
    ROperateLine(img, RSubtractOperation, 0, 0, width-1, 0, &dark);
 
477
    ROperateLine(img, RAddOperation, 0, 1, width-1, 1, &light);
 
478
 
 
479
    ROperateLine(img, RSubtractOperation, cwidth, 2, cwidth, height-1, &dark);
 
480
    ROperateLine(img, RAddOperation, cwidth+1, 2, cwidth+1, height-1, &light);
 
481
 
 
482
    ROperateLine(img, RSubtractOperation, width-cwidth-2, 2, width-cwidth-2,
 
483
                 height-1, &dark);
 
484
    ROperateLine(img, RAddOperation, width-cwidth-1, 2, width-cwidth-1,
 
485
                 height-1, &light);
 
486
 
 
487
    RDrawLine(img, 0, height-1, width-1, height-1, &black);
 
488
    RDrawLine(img, 0, 0, 0, height-1, &black);
 
489
    RDrawLine(img, width-1, 0, width-1, height-1, &black);
 
490
}
 
491
 
 
492
 
 
493
static void
 
494
drawMenuBevel(RImage *img)
 
495
{
 
496
    RColor light, dark, mid;
 
497
    int i;
 
498
    int iheight = img->height / 4;
 
499
 
 
500
    light.alpha = 0;
 
501
    light.red = light.green = light.blue = 80;
 
502
 
 
503
    dark.alpha = 255;
 
504
    dark.red = dark.green = dark.blue = 0;
 
505
 
 
506
    mid.alpha = 0;
 
507
    mid.red = mid.green = mid.blue = 40;
 
508
 
 
509
    for (i = 1; i < 4; i++) {
 
510
        ROperateLine(img, RSubtractOperation, 0, i*iheight-2,
 
511
                     img->width-1, i*iheight-2, &mid);
 
512
 
 
513
        RDrawLine(img, 0, i*iheight-1, img->width-1, i*iheight-1, &dark);
 
514
 
 
515
        ROperateLine(img, RAddOperation, 1, i*iheight,
 
516
                     img->width-2, i*iheight, &light);
 
517
    }
 
518
}
 
519
 
 
520
 
 
521
static Pixmap
 
522
renderTexture(WMScreen *scr, WMPropList *texture, int width, int height,
 
523
              char *path, int border)
 
524
{
 
525
    char *type;
 
526
    RImage *image = NULL;
 
527
    Pixmap pixmap;
 
528
    RContext *rc = WMScreenRContext(scr);
 
529
    char *str;
 
530
    RColor rcolor;
 
531
 
 
532
 
 
533
    type = WMGetFromPLString(WMGetFromPLArray(texture, 0));
 
534
 
 
535
    if (strcasecmp(type, "solid")==0) {
 
536
 
 
537
        str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
 
538
 
 
539
        str2rcolor(rc, str, &rcolor);
 
540
 
 
541
        image = RCreateImage(width, height, False);
 
542
        RClearImage(image, &rcolor);
 
543
    } else if (strcasecmp(type, "igradient")==0) {
 
544
        int t1, t2;
 
545
        RColor c1[2], c2[2];
 
546
 
 
547
        str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
 
548
        str2rcolor(rc, str, &c1[0]);
 
549
        str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
 
550
        str2rcolor(rc, str, &c1[1]);
 
551
        str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
 
552
        t1 = atoi(str);
 
553
 
 
554
        str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
 
555
        str2rcolor(rc, str, &c2[0]);
 
556
        str = WMGetFromPLString(WMGetFromPLArray(texture, 5));
 
557
        str2rcolor(rc, str, &c2[1]);
 
558
        str = WMGetFromPLString(WMGetFromPLArray(texture, 6));
 
559
        t2 = atoi(str);
 
560
 
 
561
        image = RRenderInterwovenGradient(width, height, c1, t1, c2, t2);
 
562
    } else if (strcasecmp(&type[1], "gradient")==0) {
 
563
        int style;
 
564
        RColor rcolor2;
 
565
 
 
566
        switch (toupper(type[0])) {
 
567
        case 'V':
 
568
            style = RVerticalGradient;
 
569
            break;
 
570
        case 'H':
 
571
            style = RHorizontalGradient;
 
572
            break;
 
573
        default:
 
574
        case 'D':
 
575
            style = RDiagonalGradient;
 
576
            break;
 
577
        }
 
578
 
 
579
        str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
 
580
        str2rcolor(rc, str, &rcolor);
 
581
        str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
 
582
        str2rcolor(rc, str, &rcolor2);
 
583
 
 
584
        image = RRenderGradient(width, height, &rcolor, &rcolor2, style);
 
585
    } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='T') {
 
586
        int style;
 
587
        RColor rcolor2;
 
588
        int i;
 
589
        RImage *grad, *timage;
 
590
        char *path;
 
591
 
 
592
        switch (toupper(type[1])) {
 
593
        case 'V':
 
594
            style = RVerticalGradient;
 
595
            break;
 
596
        case 'H':
 
597
            style = RHorizontalGradient;
 
598
            break;
 
599
        default:
 
600
        case 'D':
 
601
            style = RDiagonalGradient;
 
602
            break;
 
603
        }
 
604
 
 
605
        str = WMGetFromPLString(WMGetFromPLArray(texture, 3));
 
606
        str2rcolor(rc, str, &rcolor);
 
607
        str = WMGetFromPLString(WMGetFromPLArray(texture, 4));
 
608
        str2rcolor(rc, str, &rcolor2);
 
609
 
 
610
        str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
 
611
 
 
612
        if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL)
 
613
            timage = RLoadImage(rc, path, 0);
 
614
 
 
615
        if (!path || !timage) {
 
616
            wwarning("could not load file '%s': %s", path,
 
617
                     RMessageForError(RErrorCode));
 
618
        } else {
 
619
            grad = RRenderGradient(width, height, &rcolor, &rcolor2, style);
 
620
 
 
621
            image = RMakeTiledImage(timage, width, height);
 
622
            RReleaseImage(timage);
 
623
 
 
624
            i = atoi(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
 
625
 
 
626
            RCombineImagesWithOpaqueness(image, grad, i);
 
627
            RReleaseImage(grad);
 
628
        }
 
629
    } else if (strcasecmp(&type[2], "gradient")==0 && toupper(type[0])=='M') {
 
630
        int style;
 
631
        RColor **colors;
 
632
        int i, j;
 
633
 
 
634
        switch (toupper(type[1])) {
 
635
        case 'V':
 
636
            style = RVerticalGradient;
 
637
            break;
 
638
        case 'H':
 
639
            style = RHorizontalGradient;
 
640
            break;
 
641
        default:
 
642
        case 'D':
 
643
            style = RDiagonalGradient;
 
644
            break;
 
645
        }
 
646
 
 
647
        j = WMGetPropListItemCount(texture);
 
648
 
 
649
        if (j > 0) {
 
650
            colors = wmalloc(j * sizeof(RColor*));
 
651
 
 
652
            for (i = 2; i < j; i++) {
 
653
                str = WMGetFromPLString(WMGetFromPLArray(texture, i));
 
654
                colors[i-2] = wmalloc(sizeof(RColor));
 
655
                str2rcolor(rc, str, colors[i-2]);
 
656
            }
 
657
            colors[i-2] = NULL;
 
658
 
 
659
            image = RRenderMultiGradient(width, height, colors, style);
 
660
 
 
661
            for (i = 0; colors[i]!=NULL; i++)
 
662
                wfree(colors[i]);
 
663
            wfree(colors);
 
664
        }
 
665
    } else if (strcasecmp(&type[1], "pixmap")==0) {
 
666
        RImage *timage = NULL;
 
667
        char *path;
 
668
        RColor color;
 
669
 
 
670
        str = WMGetFromPLString(WMGetFromPLArray(texture, 1));
 
671
 
 
672
        if ((path=wfindfileinarray(GetObjectForKey("PixmapPath"), str))!=NULL)
 
673
            timage = RLoadImage(rc, path, 0);
 
674
 
 
675
        if (!path || !timage) {
 
676
            wwarning("could not load file '%s': %s", path ? path : str,
 
677
                     RMessageForError(RErrorCode));
 
678
        } else {
 
679
            str = WMGetFromPLString(WMGetFromPLArray(texture, 2));
 
680
            str2rcolor(rc, str, &color);
 
681
 
 
682
            switch (toupper(type[0])) {
 
683
            case 'T':
 
684
                image = RMakeTiledImage(timage, width, height);
 
685
                RReleaseImage(timage);
 
686
                timage = image;
 
687
                break;
 
688
            case 'C':
 
689
                image = RMakeCenteredImage(timage, width, height, &color);
 
690
                RReleaseImage(timage);
 
691
                timage = image;
 
692
                break;
 
693
            case 'S':
 
694
            case 'M':
 
695
                image = RScaleImage(timage, width, height);
 
696
                RReleaseImage(timage);
 
697
                timage = image;
 
698
                break;
 
699
            }
 
700
 
 
701
        }
 
702
        wfree(path);
 
703
    }
 
704
 
 
705
    if (!image)
 
706
        return None;
 
707
 
 
708
    if (path) {
 
709
        dumpRImage(path, image);
 
710
    }
 
711
 
 
712
    if (border < 0) {
 
713
        if (border == RESIZEBAR_BEVEL) {
 
714
            drawResizebarBevel(image);
 
715
        } else if (border == MENU_BEVEL) {
 
716
            drawMenuBevel(image);
 
717
            RBevelImage(image, RBEV_RAISED2);
 
718
        }
 
719
    } else if (border) {
 
720
        RBevelImage(image, border);
 
721
    }
 
722
 
 
723
    RConvertImage(rc, image, &pixmap);
 
724
    RReleaseImage(image);
 
725
 
 
726
    return pixmap;
 
727
}
 
728
 
 
729
 
 
730
static Pixmap
 
731
renderMenu(_Panel *panel, WMPropList *texture, int width, int iheight)
 
732
{
 
733
    WMScreen *scr = WMWidgetScreen(panel->parent);
 
734
    Display *dpy = WMScreenDisplay(scr);
 
735
    Pixmap pix, tmp;
 
736
    GC gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
 
737
    int i;
 
738
 
 
739
    switch (panel->menuStyle) {
 
740
    case MSTYLE_NORMAL:
 
741
        tmp = renderTexture(scr, texture, width, iheight, NULL, RBEV_RAISED2);
 
742
 
 
743
        pix = XCreatePixmap(dpy, tmp, width, iheight*4, WMScreenDepth(scr));
 
744
        for (i = 0; i < 4; i++) {
 
745
            XCopyArea(dpy, tmp, pix, gc, 0, 0, width, iheight, 0, iheight*i);
 
746
        }
 
747
        XFreePixmap(dpy, tmp);
 
748
        break;
 
749
    case MSTYLE_SINGLE:
 
750
        pix = renderTexture(scr, texture, width, iheight*4, NULL, MENU_BEVEL);
 
751
        break;
 
752
    case MSTYLE_FLAT:
 
753
        pix = renderTexture(scr, texture, width, iheight*4, NULL, RBEV_RAISED2);
 
754
        break;
 
755
    }
 
756
    XFreeGC(dpy, gc);
 
757
 
 
758
    return pix;
 
759
}
 
760
 
 
761
 
 
762
static void
 
763
renderPreview(_Panel *panel, GC gc, int part, int relief)
 
764
{
 
765
    WMListItem *item;
 
766
    TextureListItem *titem;
 
767
    Pixmap pix;
 
768
    WMScreen *scr = WMWidgetScreen(panel->box);
 
769
 
 
770
    item = WMGetListItem(panel->texLs, panel->textureIndex[part]);
 
771
    titem = (TextureListItem*)item->clientData;
 
772
 
 
773
    pix = renderTexture(scr, titem->prop,
 
774
                        previewPositions[part].size.width,
 
775
                        previewPositions[part].size.height,
 
776
                        NULL, relief);
 
777
 
 
778
    XCopyArea(WMScreenDisplay(scr), pix, panel->preview, gc, 0, 0,
 
779
              previewPositions[part].size.width,
 
780
              previewPositions[part].size.height,
 
781
              previewPositions[part].pos.x,
 
782
              previewPositions[part].pos.y);
 
783
 
 
784
    XCopyArea(WMScreenDisplay(scr), pix, panel->previewNoText, gc, 0, 0,
 
785
              previewPositions[part].size.width,
 
786
              previewPositions[part].size.height,
 
787
              previewPositions[part].pos.x,
 
788
              previewPositions[part].pos.y);
 
789
 
 
790
    XFreePixmap(WMScreenDisplay(scr), pix);
 
791
}
 
792
 
 
793
 
 
794
static void
 
795
updatePreviewBox(_Panel *panel, int elements)
 
796
{
 
797
    WMScreen *scr = WMWidgetScreen(panel->parent);
 
798
    Display *dpy = WMScreenDisplay(scr);
 
799
    Pixmap pix;
 
800
    GC gc;
 
801
    int colorUpdate = 0;
 
802
    WMColor *black = WMBlackColor(scr);
 
803
 
 
804
    gc = XCreateGC(dpy, WMWidgetXID(panel->parent), 0, NULL);
 
805
 
 
806
 
 
807
    if (panel->preview == None) {
 
808
        WMColor *color;
 
809
        WMPixmap *p;
 
810
 
 
811
        panel->previewNoText = XCreatePixmap(dpy, WMWidgetXID(panel->parent),
 
812
                                             240-4, 215-4, WMScreenDepth(scr));
 
813
 
 
814
        p = WMCreatePixmap(scr, 240-4, 215-4, WMScreenDepth(scr), False);
 
815
        panel->preview = WMGetPixmapXID(p);
 
816
        WMSetLabelImage(panel->prevL, p);
 
817
        WMReleasePixmap(p);
 
818
 
 
819
        color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
 
820
        XFillRectangle(dpy, panel->preview, WMColorGC(color),
 
821
                       0, 0, 240-4, 215-4);
 
822
        XFillRectangle(dpy, panel->previewNoText, WMColorGC(color),
 
823
                       0, 0, 240-4, 215-4);
 
824
        WMReleaseColor(color);
 
825
    }
 
826
 
 
827
 
 
828
    if (elements & (1<<PFOCUSED)) {
 
829
        renderPreview(panel, gc, PFOCUSED, RBEV_RAISED2);
 
830
        XDrawRectangle(dpy, panel->preview, WMColorGC(black),
 
831
                       previewPositions[PFOCUSED].pos.x-1,
 
832
                       previewPositions[PFOCUSED].pos.y-1,
 
833
                       previewPositions[PFOCUSED].size.width,
 
834
                       previewPositions[PFOCUSED].size.height);
 
835
        XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
 
836
                       previewPositions[PFOCUSED].pos.x-1,
 
837
                       previewPositions[PFOCUSED].pos.y-1,
 
838
                       previewPositions[PFOCUSED].size.width,
 
839
                       previewPositions[PFOCUSED].size.height);
 
840
        colorUpdate |= FTITLE_COL;
 
841
    }
 
842
    if (elements & (1<<PUNFOCUSED)) {
 
843
        renderPreview(panel, gc, PUNFOCUSED, RBEV_RAISED2);
 
844
        XDrawRectangle(dpy, panel->preview, WMColorGC(black),
 
845
                       previewPositions[PUNFOCUSED].pos.x-1,
 
846
                       previewPositions[PUNFOCUSED].pos.y-1,
 
847
                       previewPositions[PUNFOCUSED].size.width,
 
848
                       previewPositions[PUNFOCUSED].size.height);
 
849
        XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
 
850
                       previewPositions[PUNFOCUSED].pos.x-1,
 
851
                       previewPositions[PUNFOCUSED].pos.y-1,
 
852
                       previewPositions[PUNFOCUSED].size.width,
 
853
                       previewPositions[PUNFOCUSED].size.height);
 
854
        colorUpdate |= UTITLE_COL;
 
855
    }
 
856
    if (elements & (1<<POWNER)) {
 
857
        renderPreview(panel, gc, POWNER, RBEV_RAISED2);
 
858
        XDrawRectangle(dpy, panel->preview, WMColorGC(black),
 
859
                       previewPositions[POWNER].pos.x-1,
 
860
                       previewPositions[POWNER].pos.y-1,
 
861
                       previewPositions[POWNER].size.width,
 
862
                       previewPositions[POWNER].size.height);
 
863
        XDrawRectangle(dpy, panel->previewNoText, WMColorGC(black),
 
864
                       previewPositions[POWNER].pos.x-1,
 
865
                       previewPositions[POWNER].pos.y-1,
 
866
                       previewPositions[POWNER].size.width,
 
867
                       previewPositions[POWNER].size.height);
 
868
        colorUpdate |= OTITLE_COL;
 
869
    }
 
870
    if (elements & (1<<PRESIZEBAR)) {
 
871
        renderPreview(panel, gc, PRESIZEBAR, RESIZEBAR_BEVEL);
 
872
    }
 
873
    if (elements & (1<<PMTITLE)) {
 
874
        renderPreview(panel, gc, PMTITLE, RBEV_RAISED2);
 
875
        colorUpdate |= MTITLE_COL;
 
876
    }
 
877
    if (elements & (1<<PMITEM)) {
 
878
        WMListItem *item;
 
879
        TextureListItem *titem;
 
880
 
 
881
        item = WMGetListItem(panel->texLs, panel->textureIndex[5]);
 
882
        titem = (TextureListItem*)item->clientData;
 
883
 
 
884
        pix = renderMenu(panel, titem->prop,
 
885
                         previewPositions[PMITEM].size.width,
 
886
                         previewPositions[PMITEM].size.height/4);
 
887
 
 
888
        XCopyArea(dpy, pix, panel->preview, gc, 0, 0,
 
889
                  previewPositions[PMITEM].size.width,
 
890
                  previewPositions[PMITEM].size.height,
 
891
                  previewPositions[PMITEM].pos.x,
 
892
                  previewPositions[PMITEM].pos.y);
 
893
 
 
894
        XCopyArea(dpy, pix, panel->previewNoText, gc, 0, 0,
 
895
                  previewPositions[PMITEM].size.width,
 
896
                  previewPositions[PMITEM].size.height,
 
897
                  previewPositions[PMITEM].pos.x,
 
898
                  previewPositions[PMITEM].pos.y);
 
899
 
 
900
        XFreePixmap(dpy, pix);
 
901
 
 
902
        colorUpdate |= MITEM_COL|MDISAB_COL|MHIGH_COL|MHIGHT_COL;
 
903
    }
 
904
    if (elements & (1<<PMITEM|1<<PMTITLE)) {
 
905
        XDrawLine(dpy, panel->preview, gc, 29, 120, 29, 120+20*4+20);
 
906
        XDrawLine(dpy, panel->preview, gc, 29, 119, 119, 119);
 
907
 
 
908
        XDrawLine(dpy, panel->previewNoText, gc, 29, 120, 29, 120+20*4+20);
 
909
        XDrawLine(dpy, panel->previewNoText, gc, 29, 119, 119, 119);
 
910
    }
 
911
    if (elements & (1<<PICON)) {
 
912
        WMListItem *item;
 
913
        TextureListItem *titem;
 
914
 
 
915
        item = WMGetListItem(panel->texLs, panel->textureIndex[6]);
 
916
        titem = (TextureListItem*)item->clientData;
 
917
 
 
918
        renderPreview(panel, gc, PICON,
 
919
                      titem->ispixmap ? 0 : RBEV_RAISED3);
 
920
 
 
921
        colorUpdate |= ICONT_COL|ICONB_COL|CLIP_COL|CCLIP_COL;
 
922
    }
 
923
 
 
924
    if (colorUpdate)
 
925
        updateColorPreviewBox(panel, colorUpdate);
 
926
    else
 
927
        WMRedisplayWidget(panel->prevL);
 
928
 
 
929
    XFreeGC(dpy, gc);
 
930
    WMReleaseColor(black);
 
931
}
 
932
 
 
933
 
 
934
 
 
935
 
 
936
static void
 
937
cancelNewTexture(void *data)
 
938
{
 
939
    _Panel *panel = (_Panel*)data;
 
940
 
 
941
    HideTexturePanel(panel->texturePanel);
 
942
}
 
943
 
 
944
 
 
945
 
 
946
 
 
947
static char*
 
948
makeFileName(char *prefix)
 
949
{
 
950
    char *fname;
 
951
 
 
952
    fname = wstrdup(prefix);
 
953
 
 
954
    while (access(fname, F_OK)==0) {
 
955
        char buf[30];
 
956
 
 
957
        wfree(fname);
 
958
        sprintf(buf, "%08lx.cache", time(NULL));
 
959
        fname = wstrconcat(prefix, buf);
 
960
    }
 
961
 
 
962
    return fname;
 
963
}
 
964
 
 
965
 
 
966
 
 
967
 
 
968
static void
 
969
okNewTexture(void *data)
 
970
{
 
971
    _Panel *panel = (_Panel*)data;
 
972
    WMListItem *item;
 
973
    char *name;
 
974
    char *str;
 
975
    WMPropList *prop;
 
976
    TextureListItem *titem;
 
977
    WMScreen *scr = WMWidgetScreen(panel->parent);
 
978
 
 
979
    titem = wmalloc(sizeof(TextureListItem));
 
980
    memset(titem, 0, sizeof(TextureListItem));
 
981
 
 
982
    HideTexturePanel(panel->texturePanel);
 
983
 
 
984
    name = GetTexturePanelTextureName(panel->texturePanel);
 
985
 
 
986
    prop = GetTexturePanelTexture(panel->texturePanel);
 
987
 
 
988
    str = WMGetPropListDescription(prop, False);
 
989
 
 
990
    titem->title = name;
 
991
    titem->prop = prop;
 
992
    titem->texture = str;
 
993
    titem->selectedFor = 0;
 
994
 
 
995
    titem->ispixmap = isPixmap(prop);
 
996
 
 
997
    titem->path = makeFileName(panel->fprefix);
 
998
    titem->preview = renderTexture(scr, prop, TEXPREV_WIDTH, TEXPREV_HEIGHT,
 
999
                                   titem->path, 0);
 
1000
 
 
1001
    item = WMAddListItem(panel->texLs, "");
 
1002
    item->clientData = titem;
 
1003
 
 
1004
    WMSetListPosition(panel->texLs, WMGetListNumberOfRows(panel->texLs));
 
1005
}
 
1006
 
 
1007
 
 
1008
static void
 
1009
okEditTexture(void *data)
 
1010
{
 
1011
    _Panel *panel = (_Panel*)data;
 
1012
    WMListItem *item;
 
1013
    char *name;
 
1014
    char *str;
 
1015
    WMPropList *prop;
 
1016
    TextureListItem *titem;
 
1017
 
 
1018
    item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
 
1019
    titem = (TextureListItem*)item->clientData;
 
1020
 
 
1021
    HideTexturePanel(panel->texturePanel);
 
1022
 
 
1023
    if (titem->current) {
 
1024
        name = GetTexturePanelTextureName(panel->texturePanel);
 
1025
 
 
1026
        wfree(titem->title);
 
1027
        titem->title = name;
 
1028
    }
 
1029
 
 
1030
    prop = GetTexturePanelTexture(panel->texturePanel);
 
1031
 
 
1032
    str = WMGetPropListDescription(prop, False);
 
1033
 
 
1034
    WMReleasePropList(titem->prop);
 
1035
    titem->prop = prop;
 
1036
 
 
1037
    titem->ispixmap = isPixmap(prop);
 
1038
 
 
1039
    wfree(titem->texture);
 
1040
    titem->texture = str;
 
1041
 
 
1042
    XFreePixmap(WMScreenDisplay(WMWidgetScreen(panel->texLs)), titem->preview);
 
1043
    titem->preview = renderTexture(WMWidgetScreen(panel->texLs), titem->prop,
 
1044
                                   TEXPREV_WIDTH, TEXPREV_HEIGHT,
 
1045
                                   titem->path, 0);
 
1046
 
 
1047
    WMRedisplayWidget(panel->texLs);
 
1048
 
 
1049
    if (titem->selectedFor)
 
1050
        updatePreviewBox(panel, titem->selectedFor);
 
1051
 
 
1052
    changePage(panel->secP, panel);
 
1053
}
 
1054
 
 
1055
 
 
1056
 
 
1057
static void
 
1058
editTexture(WMWidget *w, void *data)
 
1059
{
 
1060
    _Panel *panel = (_Panel*)data;
 
1061
    WMListItem *item;
 
1062
    TextureListItem *titem;
 
1063
 
 
1064
    item = WMGetListItem(panel->texLs, WMGetListSelectedItemRow(panel->texLs));
 
1065
    titem = (TextureListItem*)item->clientData;
 
1066
 
 
1067
    SetTexturePanelPixmapPath(panel->texturePanel,
 
1068
                              GetObjectForKey("PixmapPath"));
 
1069
 
 
1070
    SetTexturePanelTexture(panel->texturePanel, titem->title, titem->prop);
 
1071
 
 
1072
    SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
 
1073
    SetTexturePanelOkAction(panel->texturePanel, okEditTexture, panel);
 
1074
 
 
1075
    ShowTexturePanel(panel->texturePanel);
 
1076
}
 
1077
 
 
1078
 
 
1079
 
 
1080
static void
 
1081
newTexture(WMWidget *w, void *data)
 
1082
{
 
1083
    _Panel *panel = (_Panel*)data;
 
1084
 
 
1085
    SetTexturePanelPixmapPath(panel->texturePanel,
 
1086
                              GetObjectForKey("PixmapPath"));
 
1087
 
 
1088
    SetTexturePanelTexture(panel->texturePanel, "New Texture", NULL);
 
1089
 
 
1090
    SetTexturePanelCancelAction(panel->texturePanel, cancelNewTexture, panel);
 
1091
 
 
1092
    SetTexturePanelOkAction(panel->texturePanel, okNewTexture, panel);
 
1093
 
 
1094
    ShowTexturePanel(panel->texturePanel);
 
1095
}
 
1096
 
 
1097
 
 
1098
 
 
1099
static void
 
1100
deleteTexture(WMWidget *w, void *data)
 
1101
{
 
1102
    _Panel *panel = (_Panel*)data;
 
1103
    WMListItem *item;
 
1104
    TextureListItem *titem;
 
1105
    int row;
 
1106
    int section;
 
1107
 
 
1108
    section = WMGetPopUpButtonSelectedItem(panel->secP);
 
1109
    row = WMGetListSelectedItemRow(panel->texLs);
 
1110
    item = WMGetListItem(panel->texLs, row);
 
1111
    titem = (TextureListItem*)item->clientData;
 
1112
 
 
1113
    if (titem->selectedFor & (1 << section)) {
 
1114
        TextureListItem *titem2;
 
1115
 
 
1116
        panel->textureIndex[section] = section;
 
1117
        item = WMGetListItem(panel->texLs, section);
 
1118
        titem2 = (TextureListItem*)item->clientData;
 
1119
        titem2->selectedFor |= 1 << section;
 
1120
    }
 
1121
 
 
1122
    wfree(titem->title);
 
1123
    wfree(titem->texture);
 
1124
    WMReleasePropList(titem->prop);
 
1125
    if (titem->path) {
 
1126
        if (remove(titem->path) < 0 && errno != ENOENT) {
 
1127
            wsyserror("could not remove file %s", titem->path);
 
1128
        }
 
1129
        wfree(titem->path);
 
1130
    }
 
1131
 
 
1132
    wfree(titem);
 
1133
 
 
1134
    WMRemoveListItem(panel->texLs, row);
 
1135
    WMSetButtonEnabled(panel->delB, False);
 
1136
}
 
1137
 
 
1138
 
 
1139
 
 
1140
 
 
1141
static void
 
1142
extractTexture(WMWidget *w, void *data)
 
1143
{
 
1144
    _Panel *panel = (_Panel*)data;
 
1145
    char *path;
 
1146
    WMOpenPanel *opanel;
 
1147
    WMScreen *scr = WMWidgetScreen(w);
 
1148
 
 
1149
    opanel = WMGetOpenPanel(scr);
 
1150
    WMSetFilePanelCanChooseDirectories(opanel, False);
 
1151
    WMSetFilePanelCanChooseFiles(opanel, True);
 
1152
 
 
1153
    if (WMRunModalFilePanelForDirectory(opanel, panel->parent, wgethomedir(),
 
1154
                                        _("Select File"), NULL)) {
 
1155
        path = WMGetFilePanelFileName(opanel);
 
1156
 
 
1157
        OpenExtractPanelFor(panel, path);
 
1158
 
 
1159
        wfree(path);
 
1160
    }
 
1161
}
 
1162
 
 
1163
 
 
1164
static void
 
1165
changePage(WMWidget *w, void *data)
 
1166
{
 
1167
    _Panel *panel = (_Panel*)data;
 
1168
    int section;
 
1169
    WMListItem *item;
 
1170
    TextureListItem *titem;
 
1171
    WMScreen *scr = WMWidgetScreen(panel->box);
 
1172
    RContext *rc = WMScreenRContext(scr);
 
1173
    static WMPoint positions[] = {
 
1174
        {5, 10},
 
1175
        {5, 40},
 
1176
        {5, 70},
 
1177
        {5, 100},
 
1178
        {5, 120},
 
1179
        {5, 160},
 
1180
        {130, 150}
 
1181
    };
 
1182
 
 
1183
    if (w) {
 
1184
        section = WMGetPopUpButtonSelectedItem(panel->secP);
 
1185
 
 
1186
        WMSelectListItem(panel->texLs, panel->textureIndex[section]);
 
1187
 
 
1188
        WMSetListPosition(panel->texLs, panel->textureIndex[section] - 2);
 
1189
 
 
1190
        item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
 
1191
 
 
1192
        titem = (TextureListItem*)item->clientData;
 
1193
    }
 
1194
    {
 
1195
        WMColor *color;
 
1196
 
 
1197
        color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
 
1198
        XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
 
1199
                       positions[panel->oldsection].x,
 
1200
                       positions[panel->oldsection].y, 22, 22);
 
1201
        WMReleaseColor(color);
 
1202
    }
 
1203
    if (w) {
 
1204
        panel->oldsection = section;
 
1205
        WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
 
1206
                     positions[section].y);
 
1207
    }
 
1208
    WMRedisplayWidget(panel->prevL);
 
1209
}
 
1210
 
 
1211
 
 
1212
 
 
1213
static void
 
1214
previewClick(XEvent *event, void *clientData)
 
1215
{
 
1216
    _Panel *panel = (_Panel*)clientData;
 
1217
    int i;
 
1218
 
 
1219
    switch (panel->oldTabItem) {
 
1220
    case 0:
 
1221
        for (i = 0; i < sizeof(previewPositions)/sizeof(WMRect); i++) {
 
1222
            if (event->xbutton.x >= previewPositions[i].pos.x
 
1223
                && event->xbutton.y >= previewPositions[i].pos.y
 
1224
                && event->xbutton.x < previewPositions[i].pos.x
 
1225
                + previewPositions[i].size.width
 
1226
                && event->xbutton.y < previewPositions[i].pos.y
 
1227
                + previewPositions[i].size.height) {
 
1228
 
 
1229
                WMSetPopUpButtonSelectedItem(panel->secP, i);
 
1230
                changePage(panel->secP, panel);
 
1231
                return;
 
1232
            }
 
1233
        }
 
1234
        break;
 
1235
    case 1:
 
1236
        for (i = 0; i < WMGetPopUpButtonNumberOfItems(panel->colP); i++) {
 
1237
            if (event->xbutton.x >= previewColorPositions[i].pos.x
 
1238
                && event->xbutton.y >= previewColorPositions[i].pos.y
 
1239
                && event->xbutton.x < previewColorPositions[i].pos.x
 
1240
                + previewColorPositions[i].size.width
 
1241
                && event->xbutton.y < previewColorPositions[i].pos.y
 
1242
                + previewColorPositions[i].size.height) {
 
1243
 
 
1244
                /* yuck kluge */
 
1245
                if (i == 7)
 
1246
                    i = 4;
 
1247
 
 
1248
                WMSetPopUpButtonSelectedItem(panel->colP, i);
 
1249
                changeColorPage(panel->colP, panel);
 
1250
                return;
 
1251
            }
 
1252
        }
 
1253
        break;
 
1254
    }
 
1255
}
 
1256
 
 
1257
 
 
1258
static void
 
1259
textureClick(WMWidget *w, void *data)
 
1260
{
 
1261
    _Panel *panel = (_Panel*)data;
 
1262
    int i;
 
1263
    WMListItem *item;
 
1264
    TextureListItem *titem;
 
1265
 
 
1266
    i = WMGetListSelectedItemRow(panel->texLs);
 
1267
 
 
1268
    item = WMGetListItem(panel->texLs, i);
 
1269
 
 
1270
    titem = (TextureListItem*)item->clientData;
 
1271
 
 
1272
    if (titem->current) {
 
1273
        WMSetButtonEnabled(panel->delB, False);
 
1274
    } else {
 
1275
        WMSetButtonEnabled(panel->delB, True);
 
1276
    }
 
1277
}
 
1278
 
 
1279
 
 
1280
 
 
1281
static void
 
1282
textureDoubleClick(WMWidget *w, void *data)
 
1283
{
 
1284
    _Panel *panel = (_Panel*)data;
 
1285
    int i, section;
 
1286
    WMListItem *item;
 
1287
    TextureListItem *titem;
 
1288
 
 
1289
    /* unselect old texture */
 
1290
    section = WMGetPopUpButtonSelectedItem(panel->secP);
 
1291
 
 
1292
    item = WMGetListItem(panel->texLs, panel->textureIndex[section]);
 
1293
    titem = (TextureListItem*)item->clientData;
 
1294
    titem->selectedFor &= ~(1 << section);
 
1295
 
 
1296
    /* select new texture */
 
1297
    i = WMGetListSelectedItemRow(panel->texLs);
 
1298
 
 
1299
    item = WMGetListItem(panel->texLs, i);
 
1300
 
 
1301
    titem = (TextureListItem*)item->clientData;
 
1302
 
 
1303
    titem->selectedFor |= 1<<section;
 
1304
 
 
1305
    panel->textureIndex[section] = i;
 
1306
 
 
1307
    WMRedisplayWidget(panel->texLs);
 
1308
 
 
1309
    updatePreviewBox(panel, 1<<section);
 
1310
}
 
1311
 
 
1312
 
 
1313
 
 
1314
static void
 
1315
paintListItem(WMList *lPtr, int index, Drawable d, char *text, int state,
 
1316
              WMRect *rect)
 
1317
{
 
1318
    _Panel *panel = (_Panel*)WMGetHangedData(lPtr);
 
1319
    WMScreen *scr = WMWidgetScreen(lPtr);
 
1320
    int width, height, x, y;
 
1321
    Display *dpy = WMScreenDisplay(scr);
 
1322
    WMColor *back = (state & WLDSSelected) ? WMWhiteColor(scr) : WMGrayColor(scr);
 
1323
    WMListItem *item;
 
1324
    WMColor *black = WMBlackColor(scr);
 
1325
    TextureListItem *titem;
 
1326
 
 
1327
    item = WMGetListItem(lPtr, index);
 
1328
    titem = (TextureListItem*)item->clientData;
 
1329
    if (!titem) {
 
1330
        WMReleaseColor(back);
 
1331
        WMReleaseColor(black);
 
1332
        return;
 
1333
    }
 
1334
 
 
1335
    width = rect->size.width;
 
1336
    height = rect->size.height;
 
1337
    x = rect->pos.x;
 
1338
    y = rect->pos.y;
 
1339
 
 
1340
    XFillRectangle(dpy, d, WMColorGC(back), x, y, width, height);
 
1341
 
 
1342
    if (titem->preview)
 
1343
        XCopyArea(dpy, titem->preview, d, WMColorGC(black), 0, 0,
 
1344
                  TEXPREV_WIDTH, TEXPREV_HEIGHT, x + 5, y + 5);
 
1345
 
 
1346
    if ((1 << WMGetPopUpButtonSelectedItem(panel->secP)) & titem->selectedFor)
 
1347
        WMDrawPixmap(panel->onLed, d, x + TEXPREV_WIDTH + 10, y + 6);
 
1348
    else if (titem->selectedFor)
 
1349
        WMDrawPixmap(panel->offLed, d, x + TEXPREV_WIDTH + 10, y + 6);
 
1350
 
 
1351
    WMDrawString(scr, d, black, panel->boldFont,
 
1352
                 x + TEXPREV_WIDTH + 22, y + 2, titem->title,
 
1353
                 strlen(titem->title));
 
1354
 
 
1355
    WMDrawString(scr, d, black, panel->smallFont,
 
1356
                 x + TEXPREV_WIDTH + 14, y + 18, titem->texture,
 
1357
                 strlen(titem->texture));
 
1358
 
 
1359
 
 
1360
    WMReleaseColor(back);
 
1361
    WMReleaseColor(black);
 
1362
}
 
1363
 
 
1364
 
 
1365
 
 
1366
static Pixmap
 
1367
loadRImage(WMScreen *scr, char *path)
 
1368
{
 
1369
    FILE *f;
 
1370
    RImage *image;
 
1371
    int w, h, d;
 
1372
    Pixmap pixmap;
 
1373
 
 
1374
    f = fopen(path, "rb");
 
1375
    if (!f)
 
1376
        return None;
 
1377
 
 
1378
    fscanf(f, "%02x%02x%1x", &w, &h, &d);
 
1379
 
 
1380
    image = RCreateImage(w, h, d == 4);
 
1381
    fread(image->data, 1, w*h*d, f);
 
1382
    fclose(f);
 
1383
 
 
1384
    RConvertImage(WMScreenRContext(scr), image, &pixmap);
 
1385
    RReleaseImage(image);
 
1386
 
 
1387
    return pixmap;
 
1388
}
 
1389
 
 
1390
 
 
1391
 
 
1392
static void
 
1393
fillTextureList(WMList *lPtr)
 
1394
{
 
1395
    WMPropList *textureList;
 
1396
    WMPropList *texture;
 
1397
    WMUserDefaults *udb = WMGetStandardUserDefaults();
 
1398
    TextureListItem *titem;
 
1399
    WMScreen *scr  = WMWidgetScreen(lPtr);
 
1400
    int i;
 
1401
 
 
1402
    textureList = WMGetUDObjectForKey(udb, "TextureList");
 
1403
    if (!textureList)
 
1404
        return;
 
1405
 
 
1406
    for (i = 0; i < WMGetPropListItemCount(textureList); i++) {
 
1407
        WMListItem *item;
 
1408
 
 
1409
        texture = WMGetFromPLArray(textureList, i);
 
1410
 
 
1411
        titem = wmalloc(sizeof(TextureListItem));
 
1412
        memset(titem, 0, sizeof(TextureListItem));
 
1413
 
 
1414
        titem->title = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 0)));
 
1415
        titem->prop = WMRetainPropList(WMGetFromPLArray(texture, 1));
 
1416
        titem->texture = WMGetPropListDescription(titem->prop, False);
 
1417
        titem->selectedFor = 0;
 
1418
        titem->path = wstrdup(WMGetFromPLString(WMGetFromPLArray(texture, 2)));
 
1419
 
 
1420
        titem->preview = loadRImage(scr, titem->path);
 
1421
        if (!titem->preview) {
 
1422
            titem->preview = renderTexture(scr, titem->prop, TEXPREV_WIDTH,
 
1423
                                           TEXPREV_HEIGHT, NULL, 0);
 
1424
        }
 
1425
        item = WMAddListItem(lPtr, "");
 
1426
        item->clientData = titem;
 
1427
    }
 
1428
}
 
1429
 
 
1430
 
 
1431
static void
 
1432
fillColorList(_Panel *panel)
 
1433
{
 
1434
    WMColor *color;
 
1435
    WMPropList *list;
 
1436
    WMUserDefaults *udb = WMGetStandardUserDefaults();
 
1437
    WMScreen *scr = WMWidgetScreen(panel->box);
 
1438
    int i;
 
1439
 
 
1440
    list = WMGetUDObjectForKey(udb, "ColorList");
 
1441
    if (!list) {
 
1442
        for (i = 0; i < 24; i++) {
 
1443
            color = WMCreateNamedColor(scr, sampleColors[i], False);
 
1444
            if (!color)
 
1445
                continue;
 
1446
            WMSetColorWellColor(panel->sampW[i], color);
 
1447
            WMReleaseColor(color);
 
1448
        }
 
1449
    } else {
 
1450
        WMPropList *c;
 
1451
 
 
1452
        for (i = 0; i < WMIN(24, WMGetPropListItemCount(list)); i++) {
 
1453
            c = WMGetFromPLArray(list, i);
 
1454
            if (!c || !WMIsPLString(c))
 
1455
                continue;
 
1456
            color = WMCreateNamedColor(scr, WMGetFromPLString(c), False);
 
1457
            if (!color)
 
1458
                continue;
 
1459
            WMSetColorWellColor(panel->sampW[i], color);
 
1460
            WMReleaseColor(color);
 
1461
        }
 
1462
    }
 
1463
}
 
1464
 
 
1465
 
 
1466
/*************************************************************************/
 
1467
 
 
1468
 
 
1469
static void
 
1470
changeColorPage(WMWidget *w, void *data)
 
1471
{
 
1472
    _Panel *panel = (_Panel*)data;
 
1473
    int section;
 
1474
    WMScreen *scr = WMWidgetScreen(panel->box);
 
1475
    RContext *rc = WMScreenRContext(scr);
 
1476
    static WMPoint positions[] = {
 
1477
        {5, 10},
 
1478
        {5, 40},
 
1479
        {5, 70},
 
1480
        {5, 120},
 
1481
        {5, 140},
 
1482
        {5, 160},
 
1483
        {5, 180},
 
1484
        {5, 180},
 
1485
        {130, 140},
 
1486
        {130, 140},
 
1487
        {130, 140},
 
1488
        {130, 140}
 
1489
    };
 
1490
 
 
1491
    if (panel->preview) {
 
1492
        WMColor *color;
 
1493
 
 
1494
        color = WMCreateRGBColor(scr, 0x5100, 0x5100, 0x7100, True);
 
1495
        XFillRectangle(rc->dpy, panel->preview, WMColorGC(color),
 
1496
                       positions[panel->oldcsection].x,
 
1497
                       positions[panel->oldcsection].y, 22, 22);
 
1498
        WMReleaseColor(color);
 
1499
    }
 
1500
    if (w) {
 
1501
        section = WMGetPopUpButtonSelectedItem(panel->colP);
 
1502
 
 
1503
        panel->oldcsection = section;
 
1504
        if (panel->preview)
 
1505
            WMDrawPixmap(panel->hand, panel->preview, positions[section].x,
 
1506
                         positions[section].y);
 
1507
 
 
1508
        section = WMGetPopUpButtonSelectedItem(panel->colP);
 
1509
 
 
1510
        WMSetColorWellColor(panel->colW, panel->colors[section]);
 
1511
    }
 
1512
    WMRedisplayWidget(panel->prevL);
 
1513
}
 
1514
 
 
1515
 
 
1516
static void
 
1517
paintText(WMScreen *scr, Drawable d, WMColor *color, WMFont *font,
 
1518
          int x, int y, int w, int h, WMAlignment align, char *text)
 
1519
{
 
1520
    int l = strlen(text);
 
1521
 
 
1522
    switch (align) {
 
1523
    case WALeft:
 
1524
        x += 5;
 
1525
        break;
 
1526
    case WARight:
 
1527
        x += w - 5 - WMWidthOfString(font, text, l);
 
1528
        break;
 
1529
    default:
 
1530
    case WACenter:
 
1531
        x += (w - WMWidthOfString(font, text, l))/2;
 
1532
        break;
 
1533
    }
 
1534
    WMDrawString(scr, d, color, font, x, y + (h - WMFontHeight(font))/2,
 
1535
                 text, l);
 
1536
}
 
1537
 
 
1538
 
 
1539
 
 
1540
static void
 
1541
updateColorPreviewBox(_Panel *panel, int elements)
 
1542
{
 
1543
    WMScreen *scr = WMWidgetScreen(panel->box);
 
1544
    Display *dpy = WMScreenDisplay(scr);
 
1545
    Pixmap d, pnot;
 
1546
    GC gc;
 
1547
 
 
1548
    d = panel->preview;
 
1549
    pnot = panel->previewNoText;
 
1550
    gc = WMColorGC(panel->colors[0]);
 
1551
 
 
1552
    if (elements & FTITLE_COL) {
 
1553
        XCopyArea(dpy, pnot, d, gc, 30, 10, 190, 20, 30, 10);
 
1554
        paintText(scr, d, panel->colors[0], panel->boldFont, 30, 10, 190, 20,
 
1555
                  panel->titleAlignment, _("Focused Window"));
 
1556
    }
 
1557
    if (elements & UTITLE_COL) {
 
1558
        XCopyArea(dpy, pnot, d, gc, 30, 40, 190, 20, 30, 40);
 
1559
        paintText(scr, d, panel->colors[1], panel->boldFont, 30, 40, 190, 20,
 
1560
                  panel->titleAlignment, _("Unfocused Window"));
 
1561
    }
 
1562
    if (elements & OTITLE_COL) {
 
1563
        XCopyArea(dpy, pnot, d, gc, 30, 70, 190, 20, 30, 70);
 
1564
        paintText(scr, d, panel->colors[2], panel->boldFont, 30, 70, 190, 20,
 
1565
                  panel->titleAlignment, _("Owner of Focused Window"));
 
1566
    }
 
1567
    if (elements & MTITLE_COL) {
 
1568
        XCopyArea(dpy, pnot, d, gc, 30, 120, 90, 20, 30, 120);
 
1569
        paintText(scr, d, panel->colors[3], panel->boldFont, 30, 120, 90, 20,
 
1570
                  WALeft, _("Menu Title"));
 
1571
    }
 
1572
    if (elements & MITEM_COL) {
 
1573
        XCopyArea(dpy, pnot, d, gc, 30, 140, 90, 20, 30, 140);
 
1574
        paintText(scr, d, panel->colors[4], panel->normalFont, 30, 140, 90, 20,
 
1575
                  WALeft, _("Normal Item"));
 
1576
        XCopyArea(dpy, pnot, d, gc, 30, 200, 90, 20, 30, 200);
 
1577
        paintText(scr, d, panel->colors[4], panel->normalFont, 30, 200, 90, 20,
 
1578
                  WALeft, _("Normal Item"));
 
1579
    }
 
1580
    if (elements & MDISAB_COL) {
 
1581
        XCopyArea(dpy, pnot, d, gc, 30, 160, 90, 20, 30, 160);
 
1582
        paintText(scr, d, panel->colors[5], panel->normalFont, 30, 160, 90, 20,
 
1583
                  WALeft, _("Disabled Item"));
 
1584
    }
 
1585
    if (elements & MHIGH_COL) {
 
1586
        XFillRectangle(WMScreenDisplay(scr), d, WMColorGC(panel->colors[6]),
 
1587
                       31, 181, 87, 17);
 
1588
        XFillRectangle(WMScreenDisplay(scr), pnot, WMColorGC(panel->colors[6]),
 
1589
                       31, 181, 87, 17);
 
1590
        elements |= MHIGHT_COL;
 
1591
    }
 
1592
    if (elements & MHIGHT_COL) {
 
1593
        XCopyArea(dpy, pnot, d, gc, 30, 180, 90, 20, 30, 180);
 
1594
        paintText(scr, d, panel->colors[7], panel->normalFont, 30, 180, 90, 20,
 
1595
                  WALeft, _("Highlighted"));
 
1596
    }
 
1597
    /*
 
1598
     if (elements & ICONT_COL) {
 
1599
     WRITE(_("Focused Window"), panel->colors[8], panel->boldFont,
 
1600
     155, 130, 64);
 
1601
     }
 
1602
     if (elements & ICONB_COL) {
 
1603
     WRITE(_("Focused Window"), panel->colors[9], panel->boldFont,
 
1604
     0, 0, 30);
 
1605
     }
 
1606
     if (elements & CLIP_COL) {
 
1607
     WRITE(_("Focused Window"), panel->colors[10], panel->boldFont,
 
1608
     0, 0, 30);
 
1609
     }
 
1610
     if (elements & CCLIP_COL) {
 
1611
     WRITE(_("Focused Window"), panel->colors[11], panel->boldFont,
 
1612
     0, 0, 30);
 
1613
     }
 
1614
     */
 
1615
    WMRedisplayWidget(panel->prevL);
 
1616
}
 
1617
 
 
1618
 
 
1619
static void
 
1620
colorWellObserver(void *self, WMNotification *n)
 
1621
{
 
1622
    _Panel *panel = (_Panel*)self;
 
1623
    int p;
 
1624
 
 
1625
    p = WMGetPopUpButtonSelectedItem(panel->colP);
 
1626
 
 
1627
    WMReleaseColor(panel->colors[p]);
 
1628
 
 
1629
    panel->colors[p] = WMRetainColor(WMGetColorWellColor(panel->colW));
 
1630
 
 
1631
    updateColorPreviewBox(panel, 1<<p);
 
1632
}
 
1633
 
 
1634
 
 
1635
static void
 
1636
changedTabItem(struct WMTabViewDelegate *self, WMTabView *tabView,
 
1637
               WMTabViewItem *item)
 
1638
{
 
1639
    _Panel *panel = self->data;
 
1640
    int i;
 
1641
 
 
1642
    i = WMGetTabViewItemIdentifier(item);
 
1643
    switch (i) {
 
1644
    case 0:
 
1645
        switch (panel->oldTabItem) {
 
1646
        case 1:
 
1647
            changeColorPage(NULL, panel);
 
1648
            break;
 
1649
        }
 
1650
        changePage(panel->secP, panel);
 
1651
        break;
 
1652
    case 1:
 
1653
        switch (panel->oldTabItem) {
 
1654
        case 0:
 
1655
            changePage(NULL, panel);
 
1656
            break;
 
1657
        }
 
1658
        changeColorPage(panel->colP, panel);
 
1659
        break;
 
1660
    case 3:
 
1661
        switch (panel->oldTabItem) {
 
1662
        case 0:
 
1663
            changePage(NULL, panel);
 
1664
            break;
 
1665
        case 1:
 
1666
            changeColorPage(NULL, panel);
 
1667
            break;
 
1668
        }
 
1669
        break;
 
1670
    }
 
1671
 
 
1672
    panel->oldTabItem = i;
 
1673
}
 
1674
 
 
1675
 
 
1676
/*************************************************************************/
 
1677
 
 
1678
static void
 
1679
menuStyleCallback(WMWidget *self, void *data)
 
1680
{
 
1681
    _Panel *panel = (_Panel*)data;
 
1682
 
 
1683
    if (self == panel->mstyB[0]) {
 
1684
        panel->menuStyle = MSTYLE_NORMAL;
 
1685
        updatePreviewBox(panel, 1<<PMITEM);
 
1686
 
 
1687
    } else if (self == panel->mstyB[1]) {
 
1688
        panel->menuStyle = MSTYLE_SINGLE;
 
1689
        updatePreviewBox(panel, 1<<PMITEM);
 
1690
 
 
1691
    } else if (self == panel->mstyB[2]) {
 
1692
        panel->menuStyle = MSTYLE_FLAT;
 
1693
        updatePreviewBox(panel, 1<<PMITEM);
 
1694
    }
 
1695
}
 
1696
 
 
1697
 
 
1698
static void
 
1699
titleAlignCallback(WMWidget *self, void *data)
 
1700
{
 
1701
    _Panel *panel = (_Panel*)data;
 
1702
 
 
1703
    if (self == panel->taliB[0]) {
 
1704
        panel->titleAlignment = WALeft;
 
1705
        updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
 
1706
 
 
1707
    } else if (self == panel->taliB[1]) {
 
1708
        panel->titleAlignment = WACenter;
 
1709
        updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
 
1710
 
 
1711
    } else if (self == panel->taliB[2]) {
 
1712
        panel->titleAlignment = WARight;
 
1713
        updatePreviewBox(panel, 1<<PFOCUSED|1<<PUNFOCUSED|1<<POWNER);
 
1714
    }
 
1715
}
 
1716
 
 
1717
 
 
1718
static void
 
1719
createPanel(Panel *p)
 
1720
{
 
1721
    _Panel *panel = (_Panel*)p;
 
1722
    WMFont *font;
 
1723
    WMScreen *scr = WMWidgetScreen(panel->parent);
 
1724
    WMTabViewItem *item;
 
1725
    int i;
 
1726
    char *tmp;
 
1727
    Bool ok = True;
 
1728
 
 
1729
    panel->fprefix = wstrconcat(wusergnusteppath(), "/.AppInfo");
 
1730
 
 
1731
    if (access(panel->fprefix, F_OK)!=0) {
 
1732
        if (mkdir(panel->fprefix, 0755) < 0) {
 
1733
            wsyserror(panel->fprefix);
 
1734
            ok = False;
 
1735
        }
 
1736
    }
 
1737
    if (ok) {
 
1738
        tmp = wstrconcat(panel->fprefix, "/WPrefs/");
 
1739
        wfree(panel->fprefix);
 
1740
        panel->fprefix = tmp;
 
1741
        if (access(panel->fprefix, F_OK)!=0) {
 
1742
            if (mkdir(panel->fprefix, 0755) < 0) {
 
1743
                wsyserror(panel->fprefix);
 
1744
            }
 
1745
        }
 
1746
    }
 
1747
 
 
1748
    panel->smallFont = WMSystemFontOfSize(scr, 10);
 
1749
    panel->normalFont = WMSystemFontOfSize(scr, 12);
 
1750
    panel->boldFont = WMBoldSystemFontOfSize(scr, 12);
 
1751
 
 
1752
    panel->onLed = WMCreatePixmapFromXPMData(scr, blueled_xpm);
 
1753
    panel->offLed = WMCreatePixmapFromXPMData(scr, blueled2_xpm);
 
1754
    panel->hand = WMCreatePixmapFromXPMData(scr, hand_xpm);
 
1755
 
 
1756
    panel->box = WMCreateBox(panel->parent);
 
1757
    WMSetViewExpandsToParent(WMWidgetView(panel->box), 2, 2, 2, 2);
 
1758
 
 
1759
    /* preview box */
 
1760
    panel->prevL = WMCreateLabel(panel->box);
 
1761
    WMResizeWidget(panel->prevL, 240, FRAME_HEIGHT - 20);
 
1762
    WMMoveWidget(panel->prevL, 15, 10);
 
1763
    WMSetLabelRelief(panel->prevL, WRSunken);
 
1764
    WMSetLabelImagePosition(panel->prevL, WIPImageOnly);
 
1765
 
 
1766
    WMCreateEventHandler(WMWidgetView(panel->prevL), ButtonPressMask,
 
1767
                         previewClick, panel);
 
1768
 
 
1769
 
 
1770
    /* tabview */
 
1771
 
 
1772
    tabviewDelegate.data = panel;
 
1773
 
 
1774
    panel->tabv = WMCreateTabView(panel->box);
 
1775
    WMResizeWidget(panel->tabv, 245, FRAME_HEIGHT - 20);
 
1776
    WMMoveWidget(panel->tabv, 265, 10);
 
1777
    WMSetTabViewDelegate(panel->tabv, &tabviewDelegate);
 
1778
 
 
1779
    /*** texture list ***/
 
1780
 
 
1781
    panel->texF = WMCreateFrame(panel->box);
 
1782
    WMSetFrameRelief(panel->texF, WRFlat);
 
1783
 
 
1784
    item = WMCreateTabViewItemWithIdentifier(0);
 
1785
    WMSetTabViewItemView(item, WMWidgetView(panel->texF));
 
1786
    WMSetTabViewItemLabel(item, _("Texture"));
 
1787
 
 
1788
    WMAddItemInTabView(panel->tabv, item);
 
1789
 
 
1790
 
 
1791
    panel->secP = WMCreatePopUpButton(panel->texF);
 
1792
    WMResizeWidget(panel->secP, 228, 20);
 
1793
    WMMoveWidget(panel->secP, 7, 7);
 
1794
    WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window"));
 
1795
    WMAddPopUpButtonItem(panel->secP, _("Titlebar of Unfocused Windows"));
 
1796
    WMAddPopUpButtonItem(panel->secP, _("Titlebar of Focused Window's Owner"));
 
1797
    WMAddPopUpButtonItem(panel->secP, _("Window Resizebar"));
 
1798
    WMAddPopUpButtonItem(panel->secP, _("Titlebar of Menus"));
 
1799
    WMAddPopUpButtonItem(panel->secP, _("Menu Items"));
 
1800
    WMAddPopUpButtonItem(panel->secP, _("Icon Background"));
 
1801
    /*    WMAddPopUpButtonItem(panel->secP, _("Workspace Backgrounds"));
 
1802
     */
 
1803
    WMSetPopUpButtonSelectedItem(panel->secP, 0);
 
1804
    WMSetPopUpButtonAction(panel->secP, changePage, panel);
 
1805
 
 
1806
    panel->texLs = WMCreateList(panel->texF);
 
1807
    WMResizeWidget(panel->texLs, 165, 155);
 
1808
    WMMoveWidget(panel->texLs, 70, 33);
 
1809
    WMSetListUserDrawItemHeight(panel->texLs, 35);
 
1810
    WMSetListUserDrawProc(panel->texLs, paintListItem);
 
1811
    WMHangData(panel->texLs, panel);
 
1812
    WMSetListAction(panel->texLs, textureClick, panel);
 
1813
    WMSetListDoubleAction(panel->texLs, textureDoubleClick, panel);
 
1814
 
 
1815
    WMSetBalloonTextForView(_("Double click in the texture you want to use\n"
 
1816
                              "for the selected item."),
 
1817
                            WMWidgetView(panel->texLs));
 
1818
 
 
1819
    /* command buttons */
 
1820
 
 
1821
    font = WMSystemFontOfSize(scr, 10);
 
1822
 
 
1823
 
 
1824
    panel->newB = WMCreateCommandButton(panel->texF);
 
1825
    WMResizeWidget(panel->newB, 57, 39);
 
1826
    WMMoveWidget(panel->newB, 7, 33);
 
1827
    WMSetButtonFont(panel->newB, font);
 
1828
    WMSetButtonImagePosition(panel->newB, WIPAbove);
 
1829
    WMSetButtonText(panel->newB, _("New"));
 
1830
    WMSetButtonAction(panel->newB, newTexture, panel);
 
1831
    SetButtonAlphaImage(scr, panel->newB, TNEW_FILE, NULL, NULL);
 
1832
 
 
1833
    WMSetBalloonTextForView(_("Create a new texture."),
 
1834
                            WMWidgetView(panel->newB));
 
1835
 
 
1836
    panel->ripB = WMCreateCommandButton(panel->texF);
 
1837
    WMResizeWidget(panel->ripB, 57, 39);
 
1838
    WMMoveWidget(panel->ripB, 7, 72);
 
1839
    WMSetButtonFont(panel->ripB, font);
 
1840
    WMSetButtonImagePosition(panel->ripB, WIPAbove);
 
1841
    WMSetButtonText(panel->ripB, _("Extract..."));
 
1842
    WMSetButtonAction(panel->ripB, extractTexture, panel);
 
1843
    SetButtonAlphaImage(scr, panel->ripB, TEXTR_FILE, NULL, NULL);
 
1844
 
 
1845
    WMSetBalloonTextForView(_("Extract texture(s) from a theme or a style file."),
 
1846
                            WMWidgetView(panel->ripB));
 
1847
 
 
1848
    WMSetButtonEnabled(panel->ripB, False);
 
1849
 
 
1850
    panel->editB = WMCreateCommandButton(panel->texF);
 
1851
    WMResizeWidget(panel->editB, 57, 39);
 
1852
    WMMoveWidget(panel->editB, 7, 111);
 
1853
    WMSetButtonFont(panel->editB, font);
 
1854
    WMSetButtonImagePosition(panel->editB, WIPAbove);
 
1855
    WMSetButtonText(panel->editB, _("Edit"));
 
1856
    SetButtonAlphaImage(scr, panel->editB, TEDIT_FILE, NULL, NULL);
 
1857
    WMSetButtonAction(panel->editB, editTexture, panel);
 
1858
    WMSetBalloonTextForView(_("Edit the highlighted texture."),
 
1859
                            WMWidgetView(panel->editB));
 
1860
 
 
1861
    panel->delB = WMCreateCommandButton(panel->texF);
 
1862
    WMResizeWidget(panel->delB, 57, 38);
 
1863
    WMMoveWidget(panel->delB, 7, 150);
 
1864
    WMSetButtonFont(panel->delB, font);
 
1865
    WMSetButtonImagePosition(panel->delB, WIPAbove);
 
1866
    WMSetButtonText(panel->delB, _("Delete"));
 
1867
    SetButtonAlphaImage(scr, panel->delB, TDEL_FILE, NULL, NULL);
 
1868
    WMSetButtonEnabled(panel->delB, False);
 
1869
    WMSetButtonAction(panel->delB, deleteTexture, panel);
 
1870
    WMSetBalloonTextForView(_("Delete the highlighted texture."),
 
1871
                            WMWidgetView(panel->delB));
 
1872
 
 
1873
    WMReleaseFont(font);
 
1874
 
 
1875
    WMMapSubwidgets(panel->texF);
 
1876
 
 
1877
    /*** colors ***/
 
1878
    panel->colF = WMCreateFrame(panel->box);
 
1879
    WMSetFrameRelief(panel->colF, WRFlat);
 
1880
 
 
1881
    item = WMCreateTabViewItemWithIdentifier(1);
 
1882
    WMSetTabViewItemView(item, WMWidgetView(panel->colF));
 
1883
    WMSetTabViewItemLabel(item, _("Color"));
 
1884
 
 
1885
    WMAddItemInTabView(panel->tabv, item);
 
1886
 
 
1887
    panel->colP = WMCreatePopUpButton(panel->colF);
 
1888
    WMResizeWidget(panel->colP, 228, 20);
 
1889
    WMMoveWidget(panel->colP, 7, 7);
 
1890
    WMAddPopUpButtonItem(panel->colP, _("Focused Window Title"));
 
1891
    WMAddPopUpButtonItem(panel->colP, _("Unfocused Window Title"));
 
1892
    WMAddPopUpButtonItem(panel->colP, _("Owner of Focused Window Title"));
 
1893
    WMAddPopUpButtonItem(panel->colP, _("Menu Title"));
 
1894
    WMAddPopUpButtonItem(panel->colP, _("Menu Item Text"));
 
1895
    WMAddPopUpButtonItem(panel->colP, _("Disabled Menu Item Text"));
 
1896
    WMAddPopUpButtonItem(panel->colP, _("Menu Highlight Color"));
 
1897
    WMAddPopUpButtonItem(panel->colP, _("Highlighted Menu Text Color"));
 
1898
    /*
 
1899
     WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title"));
 
1900
     WMAddPopUpButtonItem(panel->colP, _("Miniwindow Title Back"));
 
1901
     WMAddPopUpButtonItem(panel->colP, _("Clip Title"));
 
1902
     WMAddPopUpButtonItem(panel->colP, _("Collapsed Clip Title"));
 
1903
     */
 
1904
 
 
1905
    WMSetPopUpButtonSelectedItem(panel->colP, 0);
 
1906
 
 
1907
    WMSetPopUpButtonAction(panel->colP, changeColorPage, panel);
 
1908
 
 
1909
 
 
1910
    panel->colW = WMCreateColorWell(panel->colF);
 
1911
    WMResizeWidget(panel->colW, 65, 50);
 
1912
    WMMoveWidget(panel->colW, 30, 75);
 
1913
    WMAddNotificationObserver(colorWellObserver, panel,
 
1914
                              WMColorWellDidChangeNotification, panel->colW);
 
1915
 
 
1916
    for (i = 0; i < 4; i++) {
 
1917
        int j;
 
1918
        for (j = 0; j < 6; j++) {
 
1919
            panel->sampW[i+j*4] = WMCreateColorWell(panel->colF);
 
1920
            WMResizeWidget(panel->sampW[i+j*4], 22, 22);
 
1921
            WMMoveWidget(panel->sampW[i+j*4], 130 + i*22, 40 + j*22);
 
1922
            WSetColorWellBordered(panel->sampW[i+j*4], False);
 
1923
        }
 
1924
    }
 
1925
 
 
1926
    WMMapSubwidgets(panel->colF);
 
1927
 
 
1928
#ifdef unfinished
 
1929
    /*** root bg ***/
 
1930
 
 
1931
    panel->bgF = WMCreateFrame(panel->box);
 
1932
    WMSetFrameRelief(panel->bgF, WRFlat);
 
1933
 
 
1934
    item = WMCreateTabViewItemWithIdentifier(2);
 
1935
    WMSetTabViewItemView(item, WMWidgetView(panel->bgF));
 
1936
    WMSetTabViewItemLabel(item, _("Background"));
 
1937
 
 
1938
    WMAddItemInTabView(panel->tabv, item);
 
1939
 
 
1940
    panel->bgprevL = WMCreateLabel(panel->bgF);
 
1941
    WMResizeWidget(panel->bgprevL, 230, 155);
 
1942
    WMMoveWidget(panel->bgprevL, 5, 5);
 
1943
    WMSetLabelRelief(panel->bgprevL, WRSunken);
 
1944
 
 
1945
    panel->selbgB = WMCreateCommandButton(panel->bgF);
 
1946
    WMMoveWidget(panel->selbgB, 5, 165);
 
1947
    WMResizeWidget(panel->selbgB, 100, 24);
 
1948
    WMSetButtonText(panel->selbgB, _("Browse..."));
 
1949
 
 
1950
 
 
1951
 
 
1952
 
 
1953
    WMMapSubwidgets(panel->bgF);
 
1954
#endif /* unfinished */
 
1955
    /*** options ***/
 
1956
    panel->optF = WMCreateFrame(panel->box);
 
1957
    WMSetFrameRelief(panel->optF, WRFlat);
 
1958
 
 
1959
    item = WMCreateTabViewItemWithIdentifier(3);
 
1960
    WMSetTabViewItemView(item, WMWidgetView(panel->optF));
 
1961
    WMSetTabViewItemLabel(item, _("Options"));
 
1962
 
 
1963
    WMAddItemInTabView(panel->tabv, item);
 
1964
 
 
1965
    panel->mstyF = WMCreateFrame(panel->optF);
 
1966
    WMResizeWidget(panel->mstyF, 215, 85);
 
1967
    WMMoveWidget(panel->mstyF, 15, 10);
 
1968
    WMSetFrameTitle(panel->mstyF, _("Menu Style"));
 
1969
 
 
1970
    for (i = 0; i < 3; i++) {
 
1971
        WMPixmap *icon;
 
1972
        char *path;
 
1973
 
 
1974
        panel->mstyB[i] = WMCreateButton(panel->mstyF, WBTOnOff);
 
1975
        WMResizeWidget(panel->mstyB[i], 54, 54);
 
1976
        WMMoveWidget(panel->mstyB[i], 15 + i*65, 20);
 
1977
        WMSetButtonImagePosition(panel->mstyB[i], WIPImageOnly);
 
1978
        WMSetButtonAction(panel->mstyB[i], menuStyleCallback, panel);
 
1979
        switch (i) {
 
1980
        case 0:
 
1981
            path = LocateImage(MSTYLE1_FILE);
 
1982
            break;
 
1983
        case 1:
 
1984
            path = LocateImage(MSTYLE2_FILE);
 
1985
            break;
 
1986
        case 2:
 
1987
            path = LocateImage(MSTYLE3_FILE);
 
1988
            break;
 
1989
        }
 
1990
        if (path) {
 
1991
            icon = WMCreatePixmapFromFile(scr, path);
 
1992
            if (icon) {
 
1993
                WMSetButtonImage(panel->mstyB[i], icon);
 
1994
                WMReleasePixmap(icon);
 
1995
            } else {
 
1996
                wwarning(_("could not load icon file %s"), path);
 
1997
            }
 
1998
            wfree(path);
 
1999
        }
 
2000
    }
 
2001
    WMGroupButtons(panel->mstyB[0], panel->mstyB[1]);
 
2002
    WMGroupButtons(panel->mstyB[0], panel->mstyB[2]);
 
2003
 
 
2004
    WMMapSubwidgets(panel->mstyF);
 
2005
 
 
2006
 
 
2007
    panel->taliF = WMCreateFrame(panel->optF);
 
2008
    WMResizeWidget(panel->taliF, 110, 80);
 
2009
    WMMoveWidget(panel->taliF, 15, 100);
 
2010
    WMSetFrameTitle(panel->taliF, _("Title Alignment"));
 
2011
 
 
2012
    for (i = 0; i < 3; i++) {
 
2013
        panel->taliB[i] = WMCreateRadioButton(panel->taliF);
 
2014
        WMSetButtonAction(panel->taliB[i], titleAlignCallback, panel);
 
2015
        switch (i) {
 
2016
        case 0:
 
2017
            WMSetButtonText(panel->taliB[i], _("Left"));
 
2018
            break;
 
2019
        case 1:
 
2020
            WMSetButtonText(panel->taliB[i], _("Center"));
 
2021
            break;
 
2022
        case 2:
 
2023
            WMSetButtonText(panel->taliB[i], _("Right"));
 
2024
            break;
 
2025
        }
 
2026
        WMResizeWidget(panel->taliB[i], 90, 18);
 
2027
        WMMoveWidget(panel->taliB[i], 10, 15 + 20*i);
 
2028
    }
 
2029
    WMGroupButtons(panel->taliB[0], panel->taliB[1]);
 
2030
    WMGroupButtons(panel->taliB[0], panel->taliB[2]);
 
2031
 
 
2032
    WMMapSubwidgets(panel->taliF);
 
2033
 
 
2034
    WMMapSubwidgets(panel->optF);
 
2035
 
 
2036
    /**/
 
2037
 
 
2038
    WMRealizeWidget(panel->box);
 
2039
    WMMapSubwidgets(panel->box);
 
2040
 
 
2041
    WMSetPopUpButtonSelectedItem(panel->secP, 0);
 
2042
 
 
2043
    showData(panel);
 
2044
 
 
2045
    changePage(panel->secP, panel);
 
2046
 
 
2047
    fillTextureList(panel->texLs);
 
2048
 
 
2049
    fillColorList(panel);
 
2050
 
 
2051
    panel->texturePanel = CreateTexturePanel(panel->parent);
 
2052
}
 
2053
 
 
2054
 
 
2055
 
 
2056
static void
 
2057
setupTextureFor(WMList *list, char *key, char *defValue, char *title,
 
2058
                int index)
 
2059
{
 
2060
    WMListItem *item;
 
2061
    TextureListItem *titem;
 
2062
 
 
2063
    titem = wmalloc(sizeof(TextureListItem));
 
2064
    memset(titem, 0, sizeof(TextureListItem));
 
2065
 
 
2066
    titem->title = wstrdup(title);
 
2067
    titem->prop = GetObjectForKey(key);
 
2068
    if (!titem->prop || !WMIsPLArray(titem->prop)) {
 
2069
        /* Maybe also give a error message to stderr that the entry is bad? */
 
2070
        titem->prop = WMCreatePropListFromDescription(defValue);
 
2071
    } else {
 
2072
        WMRetainPropList(titem->prop);
 
2073
    }
 
2074
    titem->texture = WMGetPropListDescription((WMPropList*)titem->prop, False);
 
2075
    titem->current = 1;
 
2076
    titem->selectedFor = 1<<index;
 
2077
 
 
2078
    titem->ispixmap = isPixmap(titem->prop);
 
2079
 
 
2080
    titem->preview = renderTexture(WMWidgetScreen(list), titem->prop,
 
2081
                                   TEXPREV_WIDTH, TEXPREV_HEIGHT, NULL, 0);
 
2082
 
 
2083
    item = WMAddListItem(list, "");
 
2084
    item->clientData = titem;
 
2085
}
 
2086
 
 
2087
 
 
2088
 
 
2089
static void
 
2090
showData(_Panel *panel)
 
2091
{
 
2092
    int i;
 
2093
    char *str;
 
2094
 
 
2095
    str = GetStringForKey("MenuStyle");
 
2096
    if (str && strcasecmp(str, "flat")==0) {
 
2097
        panel->menuStyle = MSTYLE_FLAT;
 
2098
    } else if (str && strcasecmp(str, "singletexture")==0) {
 
2099
        panel->menuStyle = MSTYLE_SINGLE;
 
2100
    } else {
 
2101
        panel->menuStyle = MSTYLE_NORMAL;
 
2102
    }
 
2103
 
 
2104
    str = GetStringForKey("TitleJustify");
 
2105
    if (str && strcasecmp(str, "left")==0) {
 
2106
        panel->titleAlignment = WALeft;
 
2107
    } else if (str && strcasecmp(str, "right")==0) {
 
2108
        panel->titleAlignment = WARight;
 
2109
    } else {
 
2110
        panel->titleAlignment = WACenter;
 
2111
    }
 
2112
 
 
2113
    for (i = 0; i < sizeof(colorOptions)/(2*sizeof(char*)); i++) {
 
2114
        WMColor *color;
 
2115
 
 
2116
        str = GetStringForKey(colorOptions[i*2]);
 
2117
        if (!str)
 
2118
            str = colorOptions[i*2+1];
 
2119
 
 
2120
        if (!(color = WMCreateNamedColor(WMWidgetScreen(panel->box), str, False))) {
 
2121
            color = WMCreateNamedColor(WMWidgetScreen(panel->box), "#000000", False);
 
2122
        }
 
2123
 
 
2124
        panel->colors[i] = color;
 
2125
    }
 
2126
    changeColorPage(panel->colP, panel);
 
2127
 
 
2128
    for (i = 0; i < sizeof(textureOptions)/(3*sizeof(char*)); i++) {
 
2129
        setupTextureFor(panel->texLs, textureOptions[i*3],
 
2130
                        textureOptions[i*3+1], textureOptions[i*3+2], i);
 
2131
        panel->textureIndex[i] = i;
 
2132
    }
 
2133
    updatePreviewBox(panel, EVERYTHING);
 
2134
 
 
2135
    WMSetButtonSelected(panel->mstyB[panel->menuStyle], True);
 
2136
    WMSetButtonSelected(panel->taliB[panel->titleAlignment], True);
 
2137
}
 
2138
 
 
2139
 
 
2140
static void
 
2141
storeData(_Panel *panel)
 
2142
{
 
2143
    TextureListItem *titem;
 
2144
    WMListItem *item;
 
2145
    int i;
 
2146
 
 
2147
    for (i = 0; i < sizeof(textureOptions)/(sizeof(char*)*3); i++) {
 
2148
        item = WMGetListItem(panel->texLs, panel->textureIndex[i]);
 
2149
        titem = (TextureListItem*)item->clientData;
 
2150
        SetObjectForKey(titem->prop, textureOptions[i*3]);
 
2151
    }
 
2152
 
 
2153
    for (i = 0; i < 8; i++) {
 
2154
        char *str;
 
2155
 
 
2156
        str = WMGetColorRGBDescription(panel->colors[i]);
 
2157
 
 
2158
        if (str) {
 
2159
            SetStringForKey(str, colorOptions[i*2]);
 
2160
            wfree(str);
 
2161
        }
 
2162
    }
 
2163
 
 
2164
    switch (panel->menuStyle) {
 
2165
    case MSTYLE_SINGLE:
 
2166
        SetStringForKey("singletexture", "MenuStyle");
 
2167
        break;
 
2168
    case MSTYLE_FLAT:
 
2169
        SetStringForKey("flat", "MenuStyle");
 
2170
        break;
 
2171
    default:
 
2172
    case MSTYLE_NORMAL:
 
2173
        SetStringForKey("normal", "MenuStyle");
 
2174
        break;
 
2175
    }
 
2176
    switch (panel->titleAlignment) {
 
2177
    case WALeft:
 
2178
        SetStringForKey("left", "TitleJustify");
 
2179
        break;
 
2180
    case WARight:
 
2181
        SetStringForKey("right", "TitleJustify");
 
2182
        break;
 
2183
    default:
 
2184
    case WACenter:
 
2185
        SetStringForKey("center", "TitleJustify");
 
2186
        break;
 
2187
    }
 
2188
}
 
2189
 
 
2190
 
 
2191
static void
 
2192
prepareForClose(_Panel *panel)
 
2193
{
 
2194
    WMPropList *textureList;
 
2195
    WMPropList *texture;
 
2196
    TextureListItem *titem;
 
2197
    WMListItem *item;
 
2198
    WMUserDefaults *udb = WMGetStandardUserDefaults();
 
2199
    int i;
 
2200
 
 
2201
    textureList = WMCreatePLArray(NULL, NULL);
 
2202
 
 
2203
    /* store list of textures */
 
2204
    for (i = 7; i < WMGetListNumberOfRows(panel->texLs); i++) {
 
2205
        item = WMGetListItem(panel->texLs, i);
 
2206
        titem = (TextureListItem*)item->clientData;
 
2207
 
 
2208
        texture = WMCreatePLArray(WMCreatePLString(titem->title),
 
2209
                                  WMRetainPropList(titem->prop),
 
2210
                                  WMCreatePLString(titem->path),
 
2211
                                  NULL);
 
2212
 
 
2213
        WMAddToPLArray(textureList, texture);
 
2214
    }
 
2215
 
 
2216
    WMSetUDObjectForKey(udb, textureList, "TextureList");
 
2217
    WMReleasePropList(textureList);
 
2218
 
 
2219
    /* store list of colors */
 
2220
    textureList = WMCreatePLArray(NULL, NULL);
 
2221
    for (i = 0; i < 24; i++) {
 
2222
        WMColor *color;
 
2223
        char *str;
 
2224
 
 
2225
        color = WMGetColorWellColor(panel->sampW[i]);
 
2226
 
 
2227
        str = WMGetColorRGBDescription(color);
 
2228
        WMAddToPLArray(textureList, WMCreatePLString(str));
 
2229
        wfree(str);
 
2230
    }
 
2231
    WMSetUDObjectForKey(udb, textureList, "ColorList");
 
2232
    WMReleasePropList(textureList);
 
2233
 
 
2234
    WMSynchronizeUserDefaults(udb);
 
2235
}
 
2236
 
 
2237
 
 
2238
 
 
2239
Panel*
 
2240
InitAppearance(WMScreen *scr, WMWindow *win)
 
2241
{
 
2242
    _Panel *panel;
 
2243
 
 
2244
    panel = wmalloc(sizeof(_Panel));
 
2245
    memset(panel, 0, sizeof(_Panel));
 
2246
 
 
2247
    panel->sectionName = _("Appearance Preferences");
 
2248
 
 
2249
    panel->description = _("Background texture configuration for windows,\n"
 
2250
                           "menus and icons.");
 
2251
 
 
2252
    panel->parent = win;
 
2253
 
 
2254
    panel->callbacks.createWidgets = createPanel;
 
2255
    panel->callbacks.updateDomain = storeData;
 
2256
    panel->callbacks.prepareForClose = prepareForClose;
 
2257
 
 
2258
    AddSection(panel, ICON_FILE);
 
2259
 
 
2260
    return panel;
 
2261
}
 
2262
 
 
2263
 
 
2264
 
 
2265
/****************************************************************************/
 
2266
 
 
2267
 
 
2268
 
 
2269
typedef struct ExtractPanel {
 
2270
    WMWindow *win;
 
2271
 
 
2272
    WMLabel *label;
 
2273
    WMList *list;
 
2274
 
 
2275
    WMButton *closeB;
 
2276
    WMButton *extrB;
 
2277
} ExtractPanel;
 
2278
 
 
2279
 
 
2280
 
 
2281
static void
 
2282
OpenExtractPanelFor(_Panel *panel, char *path)
 
2283
{
 
2284
    ExtractPanel *epanel;
 
2285
    WMColor *color;
 
2286
    WMFont *font;
 
2287
    WMScreen *scr = WMWidgetScreen(panel->parent);
 
2288
 
 
2289
    epanel = wmalloc(sizeof(ExtractPanel));
 
2290
    epanel->win = WMCreatePanelWithStyleForWindow(panel->parent, "extract",
 
2291
                                                  WMTitledWindowMask
 
2292
                                                  |WMClosableWindowMask);
 
2293
    WMResizeWidget(epanel->win, 245, 250);
 
2294
    WMSetWindowTitle(epanel->win, _("Extract Texture"));
 
2295
 
 
2296
    epanel->label = WMCreateLabel(epanel->win);
 
2297
    WMResizeWidget(epanel->label, 225, 18);
 
2298
    WMMoveWidget(epanel->label, 10, 10);
 
2299
    WMSetLabelTextAlignment(epanel->label, WACenter);
 
2300
    WMSetLabelRelief(epanel->label, WRSunken);
 
2301
 
 
2302
    color = WMDarkGrayColor(scr);
 
2303
    WMSetWidgetBackgroundColor(epanel->label, color);
 
2304
    WMReleaseColor(color);
 
2305
 
 
2306
    color = WMWhiteColor(scr);
 
2307
    WMSetLabelTextColor(epanel->label, color);
 
2308
    WMReleaseColor(color);
 
2309
 
 
2310
    font = WMBoldSystemFontOfSize(scr, 12);
 
2311
    WMSetLabelFont(epanel->label, font);
 
2312
    WMReleaseFont(font);
 
2313
 
 
2314
    WMSetLabelText(epanel->label, _("Textures"));
 
2315
 
 
2316
    epanel->list = WMCreateList(epanel->win);
 
2317
    WMResizeWidget(epanel->list, 225, 165);
 
2318
    WMMoveWidget(epanel->list, 10, 30);
 
2319
 
 
2320
 
 
2321
 
 
2322
    epanel->closeB = WMCreateCommandButton(epanel->win);
 
2323
    WMResizeWidget(epanel->closeB, 74, 24);
 
2324
    WMMoveWidget(epanel->closeB, 165, 215);
 
2325
    WMSetButtonText(epanel->closeB, _("Close"));
 
2326
 
 
2327
    epanel->extrB = WMCreateCommandButton(epanel->win);
 
2328
    WMResizeWidget(epanel->extrB, 74, 24);
 
2329
    WMMoveWidget(epanel->extrB, 80, 215);
 
2330
    WMSetButtonText(epanel->extrB, _("Extract"));
 
2331
 
 
2332
    WMMapSubwidgets(epanel->win);
 
2333
 
 
2334
 
 
2335
    /* take textures from file */
 
2336
 
 
2337
 
 
2338
 
 
2339
    WMRealizeWidget(epanel->win);
 
2340
 
 
2341
    WMMapWidget(epanel->win);
 
2342
}
 
2343