Update for 0.51.0
[wmaker-crm.git] / WPrefs.app / Appearance.c
blob40d6ed32d8b9d0757cff367d19b0d166e3a12b00
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;
83 #if 0
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);
137 #endif
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);
164 /* texture list */
165 boldFont = WMBoldSystemFontOfSize(scr, 12);
167 panel->texL = WMCreateLabel(panel->frame);
168 WMResizeWidget(panel->texL, 225, 18);
169 WMMoveWidget(panel->texL, 285, 10);
170 WMSetLabelFont(panel->texL, boldFont);
171 WMSetLabelText(panel->texL, _("Textures"));
172 WMSetLabelRelief(panel->texL, WRSunken);
173 WMSetLabelTextAlignment(panel->texL, WACenter);
174 color = WMDarkGrayColor(scr);
175 WMSetWidgetBackgroundColor(panel->texL, color);
176 WMReleaseColor(color);
177 color = WMWhiteColor(scr);
178 WMSetLabelTextColor(panel->texL, color);
179 WMReleaseColor(color);
181 WMReleaseFont(boldFont);
184 panel->texLs = WMCreateList(panel->frame);
185 WMResizeWidget(panel->texLs, 225, 144);
186 WMMoveWidget(panel->texLs, 285, 30);
188 panel->cmdP = WMCreatePopUpButton(panel->frame);
189 WMResizeWidget(panel->cmdP, 225, 20);
190 WMMoveWidget(panel->cmdP, 285, 180);
191 WMSetPopUpButtonPullsDown(panel->cmdP, True);
192 WMSetPopUpButtonText(panel->cmdP, _("Texture Commands"));
193 WMAddPopUpButtonItem(panel->cmdP, _("Create New"));
194 WMAddPopUpButtonItem(panel->cmdP, _("Add From Text Field"));
195 WMAddPopUpButtonItem(panel->cmdP, _("Remove Selected"));
196 WMAddPopUpButtonItem(panel->cmdP, _("Extract From File"));
198 panel->editB = WMCreateCommandButton(panel->frame);
199 WMResizeWidget(panel->editB, 64, 20);
200 WMMoveWidget(panel->editB, 260, 207);
201 WMSetButtonText(panel->editB, _("Browse..."));
203 panel->texT = WMCreateTextField(panel->frame);
204 WMResizeWidget(panel->texT, 176, 20);
205 WMMoveWidget(panel->texT, 330, 207);
207 /**/
209 WMRealizeWidget(panel->frame);
210 WMMapSubwidgets(panel->frame);
212 WMSetPopUpButtonSelectedItem(panel->secP, 0);
220 Panel*
221 InitAppearance(WMScreen *scr, WMWindow *win)
223 _Panel *panel;
225 panel = wmalloc(sizeof(_Panel));
226 memset(panel, 0, sizeof(_Panel));
228 panel->sectionName = _("Appearance Preferences");
230 panel->win = win;
232 panel->callbacks.createWidgets = createPanel;
234 AddSection(panel, ICON_FILE);
236 return panel;