Fix CursorMove command to correctly honour EdgeScroll settings.
[fvwm.git] / modules / FvwmScript / Widgets / Rectangle.c
blob534fb285b70e08d1ee3623ad3034c45c8f4ad0cd
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 Rectangle
27 void InitRectangle(struct XObj *xobj)
29 unsigned long mask;
30 XSetWindowAttributes Attr;
32 /* Enregistrement des couleurs et de la police */
33 if (xobj->colorset >= 0) {
34 xobj->TabColor[fore] = Colorset[xobj->colorset].fg;
35 xobj->TabColor[back] = Colorset[xobj->colorset].bg;
36 xobj->TabColor[hili] = Colorset[xobj->colorset].hilite;
37 xobj->TabColor[shad] = Colorset[xobj->colorset].shadow;
38 } else {
39 xobj->TabColor[fore] = GetColor(xobj->forecolor);
40 xobj->TabColor[back] = GetColor(xobj->backcolor);
41 xobj->TabColor[hili] = GetColor(xobj->hilicolor);
42 xobj->TabColor[shad] = GetColor(xobj->shadcolor);
45 xobj->gc=fvwmlib_XCreateGC(dpy,*xobj->ParentWin,0,NULL);
46 XSetForeground(dpy,xobj->gc,xobj->TabColor[fore]);
47 XSetBackground(dpy,xobj->gc,xobj->TabColor[back]);
48 XSetLineAttributes(dpy,xobj->gc,1,LineSolid,CapRound,JoinMiter);
50 mask=0;
51 xobj->win=XCreateWindow(dpy,*xobj->ParentWin,
52 -1000,-1000,xobj->width,xobj->height,0,
53 CopyFromParent,InputOutput,CopyFromParent,
54 mask,&Attr);
57 void DestroyRectangle(struct XObj *xobj)
59 XFreeGC(dpy,xobj->gc);
60 XDestroyWindow(dpy,xobj->win);
63 void DrawRectangle(struct XObj *xobj, XEvent *evp)
65 XSegment segm[4];
67 segm[0].x1=xobj->x;
68 segm[0].y1=xobj->y;
69 segm[0].x2=xobj->width+xobj->x-1;
70 segm[0].y2=xobj->y;
72 segm[1].x1=xobj->x;
73 segm[1].y1=xobj->y;
74 segm[1].x2=xobj->x;
75 segm[1].y2=xobj->height+xobj->y-1;
77 segm[2].x1=2+xobj->x;
78 segm[2].y1=xobj->height-2+xobj->y;
79 segm[2].x2=xobj->width-2+xobj->x;
80 segm[2].y2=xobj->height-2+xobj->y;
82 segm[3].x1=xobj->width-2+xobj->x;
83 segm[3].y1=2+xobj->y;
84 segm[3].x2=xobj->width-2+xobj->x;
85 segm[3].y2=xobj->height-2+xobj->y;
87 XSetForeground(dpy,xobj->gc,xobj->TabColor[shad]);
88 XDrawSegments(dpy,*xobj->ParentWin,xobj->gc,segm,4);
91 segm[0].x1=1+xobj->x;
92 segm[0].y1=1+xobj->y;
93 segm[0].x2=xobj->width-1+xobj->x;
94 segm[0].y2=1+xobj->y;
96 segm[1].x1=1+xobj->x;
97 segm[1].y1=1+xobj->y;
98 segm[1].x2=1+xobj->x;
99 segm[1].y2=xobj->height-1+xobj->y;
101 segm[2].x1=1+xobj->x;
102 segm[2].y1=xobj->height-1+xobj->y;
103 segm[2].x2=xobj->width-1+xobj->x;
104 segm[2].y2=xobj->height-1+xobj->y;
106 segm[3].x1=xobj->width-1+xobj->x;
107 segm[3].y1=1+xobj->y;
108 segm[3].x2=xobj->width-1+xobj->x;
109 segm[3].y2=xobj->height-1+xobj->y;
111 XSetForeground(dpy,xobj->gc,xobj->TabColor[hili]);
112 XDrawSegments(dpy,*xobj->ParentWin,xobj->gc,segm,4);
116 void EvtMouseRectangle(struct XObj *xobj,XButtonEvent *EvtButton)
120 void EvtKeyRectangle(struct XObj *xobj,XKeyEvent *EvtKey)
124 void ProcessMsgRectangle(
125 struct XObj *xobj,unsigned long type,unsigned long *body)