1 /* Apperance.c- color/texture for titlebar etc.
3 * WPrefs - Window Maker Preferences Program
5 * Copyright (c) 1999 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
;
69 /* for preview shit */
82 #define ICON_FILE "appearance"
84 #define TNEW_FILE "tnew"
85 #define TDEL_FILE "tdel"
86 #define TEDIT_FILE "tedit"
87 #define TEXTR_FILE "textr"
97 #define EVERYTHING 0xff
101 renderTexture(_Panel
*panel
, char *texture
, int width
, int height
,
109 updatePreviewBox(_Panel
*panel
, int elements
)
111 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
112 Display
*dpy
= WMScreenDisplay(scr
);
113 /* RContext *rc = WMScreenRContext(scr);*/
117 if (!panel
->preview
) {
118 panel
->preview
= XCreatePixmap(dpy
, WMWidgetXID(panel
->win
),
119 220-4, 185-4, WMScreenDepth(scr
));
124 if (elements
& FTITLE
) {
126 XFreePixmap(dpy
, panel
->ftitle
);
128 panel
->ftitle
= renderTexture(panel
, tmp
, 180, 20, True
);
132 /* have to repaint everything to make things simple, eliminating
140 pix
= WMCreatePixmapFromXPixmaps(scr
, panel
->preview
, None
,
141 220-4, 185-4, WMScreenDepth(scr
));
143 WMSetLabelImage(panel
->prevL
, pix
);
144 WMReleasePixmap(pix
);
151 getStrArrayForKey(char *key
)
155 v
= GetObjectForKey(key
);
159 return PLGetDescription(v
);
166 newTexture(WMButton
*bPtr
, void *data
)
168 _Panel
*panel
= (_Panel
*)data
;
175 changePage(WMWidget
*w
, void *data
)
177 _Panel
*panel
= (_Panel
*)data
;
180 section
= WMGetPopUpButtonSelectedItem(panel
->secP
);
182 WMSelectListItem(panel
->texLs
, section
);
188 selectTexture(WMWidget
*w
, void *data
)
190 _Panel
*panel
= (_Panel
*)data
;
193 section
= WMGetListSelectedItemRow(panel
->secP
);
199 fillTextureList(WMList
*lPtr
)
202 WMUserDefaults
*udb
= WMGetStandardUserDefaults();
204 textures
= WMGetUDObjectForKey(udb
, "Textures");
214 createPanel(Panel
*p
)
216 _Panel
*panel
= (_Panel
*)p
;
219 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
221 panel
->frame
= WMCreateFrame(panel
->win
);
222 WMResizeWidget(panel
->frame
, FRAME_WIDTH
, FRAME_HEIGHT
);
223 WMMoveWidget(panel
->frame
, FRAME_LEFT
, FRAME_TOP
);
226 panel
->prevB
= WMCreateCommandButton(panel
->frame
);
227 WMResizeWidget(panel
->prevB
, 260, 165);
228 WMMoveWidget(panel
->prevB
, 15, 10);
229 WMSetButtonImagePosition(panel
->prevB
, WIPImageOnly
);
231 panel
->secP
= WMCreatePopUpButton(panel
->frame
);
232 WMResizeWidget(panel
->secP
, 260, 20);
233 WMMoveWidget(panel
->secP
, 15, 180);
234 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
235 WMAddPopUpButtonItem(panel
->secP
, _("Titlebar of Focused Window"));
236 WMAddPopUpButtonItem(panel
->secP
, _("Titlebar of Unfocused Windows"));
237 WMAddPopUpButtonItem(panel
->secP
, _("Titlebar of Focused Window's Owner"));
238 WMAddPopUpButtonItem(panel
->secP
, _("Titlebar of Menus"));
239 WMAddPopUpButtonItem(panel
->secP
, _("Menu Items"));
240 WMAddPopUpButtonItem(panel
->secP
, _("Icon Background"));
241 WMAddPopUpButtonItem(panel
->secP
, _("Workspace Backgrounds"));
242 WMSetPopUpButtonAction(panel
->secP
, changePage
, panel
);
245 font
= WMBoldSystemFontOfSize(scr
, 12);
247 panel
->texL
= WMCreateLabel(panel
->frame
);
248 WMResizeWidget(panel
->texL
, 225, 18);
249 WMMoveWidget(panel
->texL
, 285, 10);
250 WMSetLabelFont(panel
->texL
, font
);
251 WMSetLabelText(panel
->texL
, _("Textures"));
252 WMSetLabelRelief(panel
->texL
, WRSunken
);
253 WMSetLabelTextAlignment(panel
->texL
, WACenter
);
254 color
= WMDarkGrayColor(scr
);
255 WMSetWidgetBackgroundColor(panel
->texL
, color
);
256 WMReleaseColor(color
);
257 color
= WMWhiteColor(scr
);
258 WMSetLabelTextColor(panel
->texL
, color
);
259 WMReleaseColor(color
);
263 panel
->texLs
= WMCreateList(panel
->frame
);
264 WMResizeWidget(panel
->texLs
, 225, 144);
265 WMMoveWidget(panel
->texLs
, 285, 30);
267 /* command buttons */
269 font
= WMSystemFontOfSize(scr
, 10);
272 panel
->newB
= WMCreateCommandButton(panel
->frame
);
273 WMResizeWidget(panel
->newB
, 56, 48);
274 WMMoveWidget(panel
->newB
, 285, 180);
275 WMSetButtonFont(panel
->newB
, font
);
276 WMSetButtonImagePosition(panel
->newB
, WIPAbove
);
277 WMSetButtonText(panel
->newB
, _("New"));
278 SetButtonAlphaImage(scr
, panel
->newB
, TNEW_FILE
);
280 panel
->ripB
= WMCreateCommandButton(panel
->frame
);
281 WMResizeWidget(panel
->ripB
, 56, 48);
282 WMMoveWidget(panel
->ripB
, 341, 180);
283 WMSetButtonFont(panel
->ripB
, font
);
284 WMSetButtonImagePosition(panel
->ripB
, WIPAbove
);
285 WMSetButtonText(panel
->ripB
, _("Extract..."));
286 SetButtonAlphaImage(scr
, panel
->ripB
, TEXTR_FILE
);
288 panel
->editB
= WMCreateCommandButton(panel
->frame
);
289 WMResizeWidget(panel
->editB
, 56, 48);
290 WMMoveWidget(panel
->editB
, 397, 180);
291 WMSetButtonFont(panel
->editB
, font
);
292 WMSetButtonImagePosition(panel
->editB
, WIPAbove
);
293 WMSetButtonText(panel
->editB
, _("Edit"));
294 SetButtonAlphaImage(scr
, panel
->editB
, TEDIT_FILE
);
295 WMSetButtonEnabled(panel
->editB
, False
);
297 panel
->delB
= WMCreateCommandButton(panel
->frame
);
298 WMResizeWidget(panel
->delB
, 56, 48);
299 WMMoveWidget(panel
->delB
, 453, 180);
300 WMSetButtonFont(panel
->delB
, font
);
301 WMSetButtonImagePosition(panel
->delB
, WIPAbove
);
302 WMSetButtonText(panel
->delB
, _("Delete"));
303 SetButtonAlphaImage(scr
, panel
->delB
, TDEL_FILE
);
304 WMSetButtonEnabled(panel
->delB
, False
);
310 WMRealizeWidget(panel
->frame
);
311 WMMapSubwidgets(panel
->frame
);
313 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
317 fillTextureList(panel
->texLs
);
322 setupTextureFor(WMList
*list
, char *key
, char *defValue
, char *title
)
328 prop
= GetObjectForKey(key
);
330 prop
= PLMakeString(defValue
);
332 tex
= PLGetDescription(prop
);
333 str
= wstrappend(title
, tex
);
335 item
= WMAddListItem(list
, str
);
337 item
->clientData
= prop
;
344 showData(_Panel
*panel
)
346 panel
->ftitleTex
= setupTextureFor(panel
->texLs
, "FTitleBack",
347 "(solid, black)", "[Focused]:");
348 panel
->ftitleIndex
= 0;
350 panel
->utitleTex
= setupTextureFor(panel
->texLs
, "UTitleBack",
351 "(solid, gray)", "[Unfocused]:");
352 panel
->utitleIndex
= 1;
354 panel
->ptitleTex
= setupTextureFor(panel
->texLs
, "PTitleBack",
355 "(solid, \"#616161\")",
356 "[Owner of Focused]:");
357 panel
->ptitleIndex
= 2;
359 panel
->mtitleTex
= setupTextureFor(panel
->texLs
, "MenuTitleBack",
360 "(solid, black)", "[Menu Title]:");
361 panel
->mtitleIndex
= 3;
363 panel
->menuTex
= setupTextureFor(panel
->texLs
, "MenuTextBack",
364 "(solid, gray)", "[Menu Item]:");
365 panel
->menuIndex
= 4;
367 panel
->iconTex
= setupTextureFor(panel
->texLs
, "IconBack",
368 "(solid, gray)", "[Icon]:");
369 panel
->iconIndex
= 5;
371 panel
->backTex
= setupTextureFor(panel
->texLs
, "WorkspaceBack",
372 "(solid, black)", "[Workspace]:");
373 panel
->backIndex
= 6;
379 InitAppearance(WMScreen
*scr
, WMWindow
*win
)
383 panel
= wmalloc(sizeof(_Panel
));
384 memset(panel
, 0, sizeof(_Panel
));
386 panel
->sectionName
= _("Appearance Preferences");
390 panel
->callbacks
.createWidgets
= createPanel
;
392 AddSection(panel
, ICON_FILE
);