1 /* TextureAndColor.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
;
49 /* for preview shit */
63 #define ICON_FILE "appearance"
73 #define EVERYTHING 0xff
77 renderTexture(_Panel
*panel
, char *texture
, int width
, int height
,
85 updatePreviewBox(_Panel
*panel
, int elements
)
87 WMScreen
*scr
= WMWidgetScreen(panel
->win
);
88 Display
*dpy
= WMScreenDisplay(scr
);
89 /* RContext *rc = WMScreenRContext(scr);*/
93 if (!panel
->preview
) {
94 panel
->preview
= XCreatePixmap(dpy
, WMWidgetXID(panel
->win
),
95 220-4, 185-4, WMScreenDepth(scr
));
100 if (elements
& FTITLE
) {
102 XFreePixmap(dpy
, panel
->ftitle
);
104 panel
->ftitle
= renderTexture(panel
, tmp
, 180, 20, True
);
108 /* have to repaint everything to make things simple, eliminating
116 pix
= WMCreatePixmapFromXPixmaps(scr
, panel
->preview
, None
,
117 220-4, 185-4, WMScreenDepth(scr
));
119 WMSetLabelImage(panel
->prevL
, pix
);
120 WMReleasePixmap(pix
);
127 getStrArrayForKey(char *key
)
131 v
= GetObjectForKey(key
);
135 return PLGetDescription(v
);
140 createPanel(Panel
*p
)
142 _Panel
*panel
= (_Panel
*)p
;
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
);
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);
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);
209 WMRealizeWidget(panel
->frame
);
210 WMMapSubwidgets(panel
->frame
);
212 WMSetPopUpButtonSelectedItem(panel
->secP
, 0);
221 InitAppearance(WMScreen
*scr
, WMWindow
*win
)
225 panel
= wmalloc(sizeof(_Panel
));
226 memset(panel
, 0, sizeof(_Panel
));
228 panel
->sectionName
= _("Appearance Preferences");
232 panel
->callbacks
.createWidgets
= createPanel
;
234 AddSection(panel
, ICON_FILE
);