libdockapp: Remove trailing whitespace.
Doug Torrance authored 9 years ago
Carlos R. Mafra committed 9 years ago
0 | 0 | # $Id: Imakefile,v 1.4 2002/10/16 07:19:18 dalroi Exp $ |
1 | 1 | |
2 | 2 | STD_INCLUDES = $(INC_PATH) -I/usr/local/include -I. |
3 | DEPLIBS = $(DEPXLIB) | |
3 | DEPLIBS = $(DEPXLIB) | |
4 | 4 | |
5 | 5 | LOCAL_LIBRARIES = $(LIB_PATH) -L/usr/local/lib -L/usr/X11R6/lib \ |
6 | 6 | -L../../src/.libs \ |
11 | 11 | These icons were originally made for Mosaic for X and have been |
12 | 12 | included in the NCSA httpd and Apache server distributions in the |
13 | 13 | past. They are in the public domain and may be freely included in any |
14 | application. The originals were done by Kevin Hughes | |
14 | application. The originals were done by Kevin Hughes | |
15 | 15 | (kevinh@kevcom.com). |
16 | 16 | |
17 | 17 | Many thanks to Andy Polyakov for tuning the icon colors and adding a |
0 | 0 | /* $Id: basic.c,v 1.10 2003/02/10 12:35:03 dalroi Exp $ |
1 | 1 | * |
2 | 2 | * Copyright (c) 2002 Alban G. Hertroys |
3 | * | |
3 | * | |
4 | 4 | * Basic example of libDockapp usage |
5 | 5 | * |
6 | 6 | * This dockapp will draw a rectangle with a |
178 | 178 | x = 1; |
179 | 179 | dx = -dx + var; |
180 | 180 | } |
181 | ||
181 | ||
182 | 182 | if (y < 1) { |
183 | 183 | y = 1; |
184 | 184 | dy = -dy + var; |
188 | 188 | x = 46 - ballPix->geometry.width; |
189 | 189 | dx = -dx + var; |
190 | 190 | } |
191 | ||
191 | ||
192 | 192 | if (y + ballPix->geometry.height > 46) { |
193 | 193 | y = 46 - ballPix->geometry.height; |
194 | 194 | dy = -dy + var; |
0 | 0 | # $Id: Imakefile,v 1.1 2002/10/16 07:19:18 dalroi Exp $ |
1 | 1 | |
2 | 2 | STD_INCLUDES = $(INC_PATH) -I/usr/local/include -I. |
3 | DEPLIBS = $(DEPXLIB) | |
3 | DEPLIBS = $(DEPXLIB) | |
4 | 4 | |
5 | 5 | LOCAL_LIBRARIES = $(LIB_PATH) -L/usr/local/lib -L/usr/X11R6/lib \ |
6 | 6 | -L../../src/.libs \ |
32 | 32 | GC black; /* background color, idem */ |
33 | 33 | GC lightGray; /* Some GC's we'll have to define for colors */ |
34 | 34 | GC darkGray; |
35 | GC slider; /* draw-color when not highlighted, | |
35 | GC slider; /* draw-color when not highlighted, | |
36 | 36 | * dark-color when highlighted |
37 | 37 | */ |
38 | 38 | GC sliderLight; /* draw-color when highlighted */ |
124 | 124 | /* define what to do if an event occurs in a rectangle */ |
125 | 125 | DAActionRect *buttonPressRects, *buttonReleaseRects, |
126 | 126 | *mouseMoveRects, *mouseEnterRects, *mouseLeaveRects; |
127 | ||
127 | ||
128 | 128 | buttonPressRects = malloc(3 * sizeof(DAActionRect)); |
129 | 129 | buttonPressRects[0] = setRectAction(btn, btnDown); |
130 | 130 | buttonPressRects[1] = setRectAction(square, squareDown); |
143 | 143 | mouseLeaveRects = malloc(2 * sizeof(DAActionRect)); |
144 | 144 | mouseLeaveRects[0] = setRectAction(btn, btnLeave); |
145 | 145 | mouseLeaveRects[1] = setRectAction(slider, sliderLeave); |
146 | ||
146 | ||
147 | 147 | |
148 | 148 | /* XXX: make action rectangles available outside main() |
149 | 149 | * ...libDockapp should be able to do this... (reminder) |
207 | 207 | */ |
208 | 208 | pointer = XCreateFontCursor(DADisplay, XC_based_arrow_up); |
209 | 209 | XDefineCursor(DADisplay, DAWindow, pointer); |
210 | ||
210 | ||
211 | 211 | /* a square with an image that changes when clicked (A button). */ |
212 | 212 | createBtn(btn); |
213 | 213 | |
257 | 257 | |
258 | 258 | /* don't send expose events */ |
259 | 259 | gcv.graphics_exposures = False; |
260 | ||
260 | ||
261 | 261 | /* GC for white color */ |
262 | 262 | gcv.foreground = WhitePixel(DADisplay, DefaultScreen(DADisplay)); |
263 | 263 | colors->white = XCreateGC(DADisplay, d, |
271 | 271 | #endif |
272 | 272 | colors->black = XCreateGC(DADisplay, d, |
273 | 273 | GCForeground|GCGraphicsExposures, &gcv); |
274 | ||
274 | ||
275 | 275 | /* GC for light borders */ |
276 | 276 | gcv.foreground = DAGetColor("lightGray"); |
277 | 277 | colors->lightGray = XCreateGC(DADisplay, d, |
328 | 328 | r += adjustment; |
329 | 329 | g += adjustment; |
330 | 330 | b += adjustment; |
331 | ||
331 | ||
332 | 332 | if (r > 0xff) r = 0xff; |
333 | 333 | if (g > 0xff) g = 0xff; |
334 | 334 | if (b > 0xff) b = 0xff; |
336 | 336 | if (r < 0) r = 0; |
337 | 337 | if (g < 0) g = 0; |
338 | 338 | if (b < 0) b = 0; |
339 | ||
339 | ||
340 | 340 | return ((unsigned short)r << 16) + |
341 | 341 | ((unsigned short)g << 8) + |
342 | 342 | (unsigned short)b; |
448 | 448 | |
449 | 449 | if (data) { |
450 | 450 | int *tmp = (int*)data; |
451 | ||
451 | ||
452 | 452 | button = *tmp; |
453 | 453 | } else |
454 | 454 | button = 0; |
489 | 489 | sliderPos = (float)(rect.height - y)/(float)rect.height; |
490 | 490 | if (sliderPos > 1.0) sliderPos = 1.0; |
491 | 491 | if (sliderPos < 0.0) sliderPos = 0.0; |
492 | ||
492 | ||
493 | 493 | drawSlider(rect); |
494 | 494 | } |
495 | 495 | |
555 | 555 | DASetPixmap(pixmap); |
556 | 556 | } |
557 | 557 | |
558 | ||
558 | ||
559 | 559 | void |
560 | 560 | createSquare(DARect rect) |
561 | 561 | { |
0 | 0 | fontdir = @FONTDIR@ |
1 | 1 | dist_font_DATA = luxel-ascii-06x09.pcf.gz \ |
2 | seg7-ascii-05x07.pcf.gz | |
2 | seg7-ascii-05x07.pcf.gz | |
3 | 3 | |
4 | 4 | install-data-hook: |
5 | 5 | @rm -f $(DESTDIR)$(fontdir)/font.dir |
29 | 29 | DASetCallbacks(DACallbacks *callbacks) |
30 | 30 | { |
31 | 31 | long mask = 0; |
32 | ||
32 | ||
33 | 33 | _daContext->callbacks = *callbacks; |
34 | 34 | |
35 | 35 | if (callbacks->destroy) |
44 | 44 | mask |= EnterWindowMask; |
45 | 45 | if (callbacks->leave) |
46 | 46 | mask |= LeaveWindowMask; |
47 | ||
47 | ||
48 | 48 | XSelectInput(DADisplay, DAWindow, mask); |
49 | 49 | XFlush(DADisplay); |
50 | 50 | } |
30 | 30 | DAGetColor(char *colorName) |
31 | 31 | { |
32 | 32 | XColor color; |
33 | ||
33 | ||
34 | 34 | if (!XParseColor(DADisplay, |
35 | 35 | DefaultColormap(DADisplay, DefaultScreen(DADisplay)), |
36 | 36 | colorName, &color)) |
37 | 37 | DAError("could not parse color %s", colorName); |
38 | ||
38 | ||
39 | 39 | if (!XAllocColor(DADisplay, DefaultColormap(DADisplay, DefaultScreen(DADisplay)), &color)) { |
40 | 40 | DAWarning("could not allocate color %s. Using black instead", colorName); |
41 | 41 | return BlackPixel(DADisplay, DefaultScreen(DADisplay)); |
42 | 42 | } |
43 | ||
43 | ||
44 | 44 | return color.pixel; |
45 | 45 | } |
46 | 46 |
101 | 101 | default: |
102 | 102 | return False; |
103 | 103 | } |
104 | ||
104 | ||
105 | 105 | return True; |
106 | 106 | } |
107 | 107 | |
136 | 136 | { |
137 | 137 | struct timeval timeout; |
138 | 138 | fd_set rset; |
139 | ||
139 | ||
140 | 140 | XSync(DADisplay, False); |
141 | 141 | if (XPending(DADisplay)) { |
142 | 142 | XNextEvent(DADisplay, event); |
143 | 143 | return True; |
144 | 144 | } |
145 | ||
145 | ||
146 | 146 | timeout.tv_sec = milliseconds / 1000; |
147 | 147 | timeout.tv_usec = (milliseconds % 1000) * 1000; |
148 | ||
148 | ||
149 | 149 | FD_ZERO(&rset); |
150 | 150 | FD_SET(ConnectionNumber(DADisplay), &rset); |
151 | ||
151 | ||
152 | 152 | if (select(ConnectionNumber(DADisplay)+1, &rset, NULL, NULL, &timeout) > 0) { |
153 | 153 | XNextEvent(DADisplay, event); |
154 | 154 | return True; |
155 | 155 | } |
156 | ||
156 | ||
157 | 157 | return False; |
158 | 158 | } |
159 | 159 |
69 | 69 | |
70 | 70 | /* Get the nearest allowed icon size if the WM specifies such */ |
71 | 71 | iconSizes = XAllocIconSize(); |
72 | if (XGetIconSizes(DADisplay, DefaultRootWindow(DADisplay), | |
72 | if (XGetIconSizes(DADisplay, DefaultRootWindow(DADisplay), | |
73 | 73 | &iconSizes, &nrSizes)) { |
74 | 74 | int i; |
75 | 75 | int da = -1; |
79 | 79 | for (i = 0; i < nrSizes; i++) { |
80 | 80 | int w1, h1, w, h; |
81 | 81 | |
82 | if ((max_w < iconSizes[i].max_width) || | |
82 | if ((max_w < iconSizes[i].max_width) || | |
83 | 83 | (max_h < iconSizes[i].max_height)) { |
84 | 84 | max_w = iconSizes[i].max_width; |
85 | 85 | max_h = iconSizes[i].max_height; |
86 | 86 | } |
87 | ||
88 | if ((min_w > iconSizes[i].min_width) || | |
89 | (min_h > iconSizes[i].min_height) || | |
87 | ||
88 | if ((min_w > iconSizes[i].min_width) || | |
89 | (min_h > iconSizes[i].min_height) || | |
90 | 90 | (min_w == -1)) { |
91 | 91 | min_w = iconSizes[i].min_width; |
92 | 92 | min_h = iconSizes[i].min_height; |
93 | 93 | } |
94 | ||
94 | ||
95 | 95 | if ((width > iconSizes[i].max_width) || |
96 | 96 | (width < iconSizes[i].min_width) || |
97 | 97 | (height > iconSizes[i].max_height) || |
98 | 98 | (height < iconSizes[i].min_height)) |
99 | 99 | continue; |
100 | ||
100 | ||
101 | 101 | w1 = (iconSizes[i].max_width - width ) % iconSizes[i].width_inc; |
102 | 102 | h1 = (iconSizes[i].max_height - height) % iconSizes[i].height_inc; |
103 | 103 | w = MIN(w1, iconSizes[i].width_inc - w1); |
180 | 180 | /* Set WMProtocols */ |
181 | 181 | WM_DELETE_WINDOW = XInternAtom(DADisplay, "WM_DELETE_WINDOW", True); |
182 | 182 | XSetWMProtocols(DADisplay, DALeader, &WM_DELETE_WINDOW, 1); |
183 | ||
183 | ||
184 | 184 | /* Set Command to start the app so it can be docked properly */ |
185 | 185 | XSetCommand(DADisplay, DALeader, argv, argc); |
186 | 186 |
117 | 117 | unsigned short *width, unsigned short *height) |
118 | 118 | { |
119 | 119 | XpmAttributes xpmAttr; |
120 | ||
120 | ||
121 | 121 | xpmAttr.valuemask = XpmCloseness; |
122 | 122 | xpmAttr.closeness = 40000; |
123 | ||
124 | ||
123 | ||
124 | ||
125 | 125 | if (source == daXpmSourceData |
126 | 126 | && (XpmCreatePixmapFromData( |
127 | 127 | DADisplay, DAWindow, data, pixmap, mask, &xpmAttr) != 0)) |
134 | 134 | |
135 | 135 | *width = xpmAttr.width; |
136 | 136 | *height = xpmAttr.height; |
137 | ||
137 | ||
138 | 138 | return True; |
139 | 139 | } |
140 | 140 |
16 | 16 | * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
17 | 17 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
18 | 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
19 | * | |
19 | * | |
20 | 20 | * $Id: dashaped.c,v 1.11 2008/05/01 09:49:06 dalroi Exp $ |
21 | 21 | */ |
22 | 22 | |
56 | 56 | dasp->shape = DAMakeShape(); |
57 | 57 | dasp->geometry.width = _daContext->width; |
58 | 58 | dasp->geometry.height = _daContext->height; |
59 | ||
59 | ||
60 | 60 | setGCs(dasp); |
61 | 61 | DASPClear(dasp); |
62 | 62 | |
176 | 176 | |
177 | 177 | if (dasp == NULL) |
178 | 178 | return NULL; |
179 | ||
179 | ||
180 | 180 | memset(dasp, 0, sizeof(DAShapedPixmap)); |
181 | 181 | |
182 | 182 | if (source == daShapeSourceData) |
188 | 188 | |
189 | 189 | if (!success) |
190 | 190 | return NULL; |
191 | ||
191 | ||
192 | 192 | setGCs(dasp); |
193 | 193 | |
194 | 194 | return dasp; |
16 | 16 | * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN |
17 | 17 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
18 | 18 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
19 | * | |
19 | * | |
20 | 20 | * $Id: dockapp.h,v 1.18 2005/07/16 11:49:10 dalroi Exp $ |
21 | 21 | */ |
22 | 22 | |
48 | 48 | |
49 | 49 | /* !!! DEPRECATED !!! |
50 | 50 | * This feature may be removed in the future. Use DAEventCallbacks instead. |
51 | * | |
51 | * | |
52 | 52 | * the callbacks for events related to the dockapp window your program wants |
53 | 53 | * to handle |
54 | 54 | */ |
74 | 74 | char *shortForm; /* short form for option, like -w */ |
75 | 75 | char *longForm; /* long form for option, like --withdrawn */ |
76 | 76 | char *description; /* description for the option */ |
77 | ||
77 | ||
78 | 78 | short type; /* type of argument */ |
79 | 79 | Bool used; /* if the argument was passed on the cmd-line */ |
80 | ||
80 | ||
81 | 81 | /* the following are only set if the "used" field is True */ |
82 | 82 | union { |
83 | 83 | void *ptr; /* a ptr for the value that was passed */ |