Code update for Window Maker version 0.50.0
[wmaker-crm.git] / WPrefs.app / Appearance.c
blob13a310d7f86d207ff5c63e64b0030d1099586d0a
1 /* TextureAndColor.c- color/texture for titlebar etc.
2 *
3 * WPrefs - Window Maker Preferences Program
4 *
5 * Copyright (c) 1999 Alfredo K. Kojima
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 * USA.
24 #include "WPrefs.h"
26 #include "TexturePanel.h"
28 typedef struct _Panel {
29 WMFrame *frame;
30 char *sectionName;
32 CallbackRec callbacks;
34 WMWindow *win;
36 WMLabel *prevL;
38 WMPopUpButton *secP;
40 /* texture list */
41 WMLabel *texL;
42 WMList *texLs;
44 WMPopUpButton *cmdP;
45 WMTextField *texT;
47 WMButton *editB;
49 /* for preview shit */
50 Pixmap preview;
51 Pixmap ftitle;
52 Pixmap utitle;
53 Pixmap otitle;
54 Pixmap icon;
55 Pixmap back;
56 Pixmap mtitle;
57 Pixmap mitem;
58 } _Panel;
63 #define ICON_FILE "appearance"
66 #define FTITLE (1<<0)
67 #define UTITLE (1<<1)
68 #define OTITLE (1<<2)
69 #define ICON (1<<3)
70 #define BACK (1<<4)
71 #define MTITLE (1<<5)
72 #define MITEM (1<<6)
73 #define EVERYTHING 0xff
76 static Pixmap
77 renderTexture(_Panel *panel, char *texture, int width, int height,
78 Bool bordered)
80 return None;
84 static void
85 updatePreviewBox(_Panel *panel, int elements)
87 WMScreen *scr = WMWidgetScreen(panel->win);
88 Display *dpy = WMScreenDisplay(scr);
89 /* RContext *rc = WMScreenRContext(scr);*/
90 int refresh = 0;
91 char *tmp;
93 if (!panel->preview) {
94 panel->preview = XCreatePixmap(dpy, WMWidgetXID(panel->win),
95 220-4, 185-4, WMScreenDepth(scr));
97 refresh = -1;
100 if (elements & FTITLE) {
101 if (panel->ftitle)
102 XFreePixmap(dpy, panel->ftitle);
104 panel->ftitle = renderTexture(panel, tmp, 180, 20, True);
105 free(tmp);
108 /* have to repaint everything to make things simple, eliminating
109 * clipping stuff */
110 if (refresh) {
114 if (refresh<0) {
115 WMPixmap *pix;
116 pix = WMCreatePixmapFromXPixmaps(scr, panel->preview, None,
117 220-4, 185-4, WMScreenDepth(scr));
119 WMSetLabelImage(panel->prevL, pix);
120 WMReleasePixmap(pix);
126 static char*
127 getStrArrayForKey(char *key)
129 proplist_t v;
131 v = GetObjectForKey(key);
132 if (!v)
133 return NULL;
135 return PLGetDescription(v);
139 static void
140 createPanel(Panel *p)
142 _Panel *panel = (_Panel*)p;
143 WMColor *color;
144 WMFont *boldFont;
145 WMScreen *scr = WMWidgetScreen(panel->win);
147 panel->frame = WMCreateFrame(panel->win);
148 WMResizeWidget(panel->frame, FRAME_WIDTH, FRAME_HEIGHT);
149 WMMoveWidget(panel->frame, FRAME_LEFT, FRAME_TOP);
151 /* preview box */
152 panel->prevL = WMCreateLabel(panel->frame);
153 WMResizeWidget(panel->prevL, 260, 190);
154 WMMoveWidget(panel->prevL, 10, 10);
155 WMSetLabelRelief(panel->prevL, WRSunken);
157 panel->secP = WMCreatePopUpButton(panel->frame);
158 WMResizeWidget(panel->secP, 242, 20);
159 WMMoveWidget(panel->secP, 10, 207);
160 // WMSetPopUpButtonAction(panel->secP, changePage, panel);
163 /* texture list */
164 boldFont = WMBoldSystemFontOfSize(scr, 12);
166 panel->texL = WMCreateLabel(panel->frame);
167 WMResizeWidget(panel->texL, 225, 18);
168 WMMoveWidget(panel->texL, 285, 10);
169 WMSetLabelFont(panel->texL, boldFont);
170 WMSetLabelText(panel->texL, _("Textures"));
171 WMSetLabelRelief(panel->texL, WRSunken);
172 WMSetLabelTextAlignment(panel->texL, WACenter);
173 color = WMDarkGrayColor(scr);
174 WMSetWidgetBackgroundColor(panel->texL, color);
175 WMReleaseColor(color);
176 color = WMWhiteColor(scr);
177 WMSetLabelTextColor(panel->texL, color);
178 WMReleaseColor(color);
180 WMReleaseFont(boldFont);
183 panel->texLs = WMCreateList(panel->frame);
184 WMResizeWidget(panel->texLs, 225, 144);
185 WMMoveWidget(panel->texLs, 285, 30);
187 panel->cmdP = WMCreatePopUpButton(panel->frame);
188 WMResizeWidget(panel->cmdP, 225, 20);
189 WMMoveWidget(panel->cmdP, 285, 180);
190 WMSetPopUpButtonPullsDown(panel->cmdP, True);
191 WMSetPopUpButtonText(panel->cmdP, _("Texture Commands"));
192 WMAddPopUpButtonItem(panel->cmdP, _("Create New"));
193 WMAddPopUpButtonItem(panel->cmdP, _("Add From Text Field"));
194 WMAddPopUpButtonItem(panel->cmdP, _("Remove Selected"));
195 WMAddPopUpButtonItem(panel->cmdP, _("Extract From File"));
197 panel->editB = WMCreateCommandButton(panel->frame);
198 WMResizeWidget(panel->editB, 64, 20);
199 WMMoveWidget(panel->editB, 260, 207);
200 WMSetButtonText(panel->editB, _("Browse..."));
202 panel->texT = WMCreateTextField(panel->frame);
203 WMResizeWidget(panel->texT, 176, 20);
204 WMMoveWidget(panel->texT, 330, 207);
206 /**/
208 WMRealizeWidget(panel->frame);
209 WMMapSubwidgets(panel->frame);
211 WMSetPopUpButtonSelectedItem(panel->secP, 0);
219 Panel*
220 InitAppearance(WMScreen *scr, WMWindow *win)
222 _Panel *panel;
224 panel = wmalloc(sizeof(_Panel));
225 memset(panel, 0, sizeof(_Panel));
227 panel->sectionName = _("Appearance Preferences");
229 panel->win = win;
231 panel->callbacks.createWidgets = createPanel;
233 AddSection(panel, ICON_FILE);
235 return panel;