Restructure how we look for Read files slightly.
[fvwm.git] / modules / FvwmScript / Widgets / VDipstick.c
blobfd3a1dc7f0e427d338256961772973b78419568c
1 /* -*-c-*- */
2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 #include "config.h"
19 #include "libs/fvwmlib.h"
20 #include "libs/ColorUtils.h"
21 #include "libs/Graphics.h"
22 #include "Tools.h"
25 * Fonction pour VDipstick
26 * Création d'une jauge verticale
27 * plusieurs options
29 void InitVDipstick(struct XObj *xobj)
31 unsigned long mask;
32 XSetWindowAttributes Attr;
34 /* Enregistrement des couleurs et de la police */
35 if (xobj->colorset >= 0) {
36 xobj->TabColor[fore] = Colorset[xobj->colorset].fg;
37 xobj->TabColor[back] = Colorset[xobj->colorset].bg;
38 xobj->TabColor[hili] = Colorset[xobj->colorset].hilite;
39 xobj->TabColor[shad] = Colorset[xobj->colorset].shadow;
40 } else {
41 xobj->TabColor[fore] = GetColor(xobj->forecolor);
42 xobj->TabColor[back] = GetColor(xobj->backcolor);
43 xobj->TabColor[hili] = GetColor(xobj->hilicolor);
44 xobj->TabColor[shad] = GetColor(xobj->shadcolor);
47 /* Minimum size */
48 if (xobj->width<11)
49 xobj->width=11;
50 if (xobj->height<30)
51 xobj->height=30;
53 mask=0;
54 Attr.background_pixel=x11base->TabColor[back];
55 mask|=CWBackPixel;
56 xobj->win=XCreateWindow(dpy,*xobj->ParentWin,
57 xobj->x,xobj->y,xobj->width,xobj->height,0,
58 CopyFromParent,InputOutput,CopyFromParent,
59 mask,&Attr);
60 xobj->gc=fvwmlib_XCreateGC(dpy,xobj->win,0,NULL);
61 if (xobj->colorset >= 0)
62 SetWindowBackground(dpy, xobj->win, xobj->width, xobj->height,
63 &Colorset[xobj->colorset], Pdepth,
64 xobj->gc, True);
65 XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]);
66 XSetLineAttributes(dpy,xobj->gc,1,LineSolid,CapRound,JoinMiter);
68 if (xobj->value2>xobj->value3)
69 xobj->value3=xobj->value2+50;
70 if (xobj->value<xobj->value2)
71 xobj->value=xobj->value2;
72 if (xobj->value>xobj->value3)
73 xobj->value=xobj->value3;
74 XSelectInput(dpy, xobj->win, ExposureMask);
77 void DestroyVDipstick(struct XObj *xobj)
79 XFreeGC(dpy,xobj->gc);
80 XDestroyWindow(dpy,xobj->win);
83 void DrawVDipstick(struct XObj *xobj, XEvent *evp)
85 int i;
87 i=(xobj->height-4)*
88 (xobj->value-xobj->value2)/(xobj->value3-xobj->value2);
90 DrawReliefRect(0,0,xobj->width,xobj->height,xobj,shad,hili);
91 if (i!=0)
93 DrawReliefRect(
94 2,xobj->height-i-2,xobj->width-4,i,xobj,hili,shad);
95 XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]);
96 XFillRectangle(
97 dpy,xobj->win,xobj->gc,4,xobj->height-i,xobj->width-8,
98 i-4);
103 void EvtMouseVDipstick(struct XObj *xobj,XButtonEvent *EvtButton)
107 void EvtKeyVDipstick(struct XObj *xobj,XKeyEvent *EvtKey)
111 void ProcessMsgVDipstick(
112 struct XObj *xobj,unsigned long type,unsigned long *body)