3 * Fvwmbuttons, copyright 1996, Jarl Totland
5 * This module, and the entire GoodStuff program, and the concept for
6 * interfacing this module to the Window Manager, are all original work
9 * Copyright 1993, Robert Nation. No guarantees or warantees or anything
10 * are provided or implied in any way whatsoever. Use this program at your
11 * own risk. Permission to use this program for any purpose is given,
12 * as long as the copyright is kept intact.
16 /* This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2 of the License, or
19 * (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 * Derived from fvwm icon code
44 #include <X11/Xutil.h>
45 #include <X11/Xproto.h>
46 #include <X11/Xatom.h>
47 #include <X11/Intrinsic.h>
53 #include "libs/fvwmlib.h"
54 #include "libs/FShape.h"
55 #include "FvwmButtons.h"
56 #include "libs/PictureGraphics.h"
57 #include "libs/Colorset.h"
58 #include "libs/Rectangles.h"
63 * Combines icon shape masks after a resize
66 Bool
GetIconPosition(button_info
*b
,
67 FvwmPicture
*pic
, int *r_x
, int *r_y
, int *r_w
, int *r_h
)
72 int x
, y
, width
, height
;
74 int framew
, xpad
, ypad
;
77 Bool has_title
= (buttonTitle(b
) != NULL
? True
: False
);
79 buttonInfo(b
, &x
, &y
, &xpad
, &ypad
, &framew
);
81 Ffont
= buttonFont(b
);
88 width
= min(width
, BW
- 2 * (xpad
+ framew
));
90 if (has_title
== True
&& Ffont
&& !(buttonJustify(b
) & b_Horizontal
))
92 height
= min(height
, BH
- 2 * (ypad
+ framew
)
93 - Ffont
->ascent
- Ffont
->descent
);
97 height
= min(height
,BH
-2*(ypad
+framew
));
100 if (b
->flags
.b_Right
)
102 xoff
= BW
-framew
- xpad
-width
;
104 else if (b
->flags
.b_Left
)
106 xoff
= framew
+ xpad
;
110 if (buttonJustify(b
) & b_Horizontal
)
116 xoff
= (BW
- width
) >> 1;
118 if (xoff
< framew
+ xpad
)
120 xoff
= framew
+ xpad
;
124 if (has_title
== True
&& Ffont
&& !(buttonJustify(b
) & b_Horizontal
))
126 yoff
= (BH
- (height
+ Ffont
->height
)) >> 1;
130 yoff
= (BH
- height
) >> 1;
133 if (yoff
< framew
+ ypad
)
135 yoff
= framew
+ ypad
;
150 void DrawForegroundIcon(button_info
*b
, XEvent
*pev
)
156 FvwmRenderAttributes fra
;
157 FvwmPicture
*pic
= buttonIcon(b
);
159 if (!GetIconPosition(b
, pic
, &x
, &y
, &w
, &h
))
166 return; /* No need drawing to this */
176 if (!frect_get_intersection(
178 pev
->xexpose
.x
, pev
->xexpose
.y
,
179 pev
->xexpose
.width
, pev
->xexpose
.height
,
189 Dpy
, MyWindow
, clip
.x
, clip
.y
, clip
.width
, clip
.height
,
193 cset
= buttonColorset(b
);
194 fra
.mask
= FRAM_DEST_IS_A_WINDOW
;
197 fra
.mask
|= FRAM_HAVE_ICON_CSET
;
198 fra
.colorset
= &Colorset
[cset
];
201 PGraphicsRenderPicture(
202 Dpy
, MyWindow
, pic
, &fra
, MyWindow
,
203 NormalGC
, None
, None
,
204 clip
.x
- x
, clip
.y
- y
, clip
.width
, clip
.height
,
205 clip
.x
, clip
.y
, clip
.width
, clip
.height
, False
);