1 /* dockapp.h - support functions for a WindowMaker docked application 2 * 3 * Copyright (C) 2000-2002 Casey Harkins (charkins@pobox.com) 4 * 5 * DESCRIPTION: 6 * This small library of functions should simplify the creation of 7 * WindowMaker docked applications. First the user must make a call to 8 * create_dockapp. Then calls to set_paint_func and set_mouse_func to 9 * set the appropriate callback functions. Finally calling run_dockapp 10 * enters the event loop which calls the appropriate callbacks. The 11 * callbacks receive parameters which will be useful in handling those 12 * events. If more information is needed, the get_XXXXXX calls provide 13 * some additional information. The clear_window and request_paint 14 * functions may also be called from the callbacks to clear the draw 15 * window or request that the paint callback be called. 16 * 17 * For information or for updates to these libraries check: 18 * http://www.pobox.com/~charkins/dockapp.html 19 * 20 * This is free software; you can redistribute it and/or 21 * modify it under the terms of the GNU General Public 22 * License as published by the Free Software Foundation; either 23 * version 2 of the License, or (at your option) any later version. 24 * 25 * This software is distributed in the hope that it will be useful, 26 * but WITHOUT ANY WARRANTY; without even the implied warranty of 27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 28 * General Public License for more details. 29 * 30 * You should have received a copy of the GNU General Public 31 * License along with this software; if not, write to the Free 32 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 33 */ 34 #ifndef __DOCKAPP_H__ 35 #define __DOCKAPP_H__ 36 37 #include "../config.h" 38 #include <X11/Xlib.h> 39 #include <X11/Xutil.h> 40 #include <X11/extensions/shape.h> 41 #include <X11/xpm.h> 42 #include <stdio.h> 43 #include <stdlib.h> 44 #include <unistd.h> 45 #include <string.h> 46 47 48 /* time to wait till the next XPending */ 49 #define _DELAY_TIME 100000 50 51 /* MOUSE MACROS */ 52 #define MOUSE_PRESSED 1 53 #define MOUSE_RELEASED 0 54 55 /* tooltip structure */ 56 typedef struct _Tooltip_ { 57 Window win; 58 GC gc; 59 char **text; 60 int lines; 61 XFontStruct *font; 62 } Tooltip; 63 64 65 /* dockapp_create 66 * PARAMETERS: 67 * char * appname : name of application to be registered with X 68 * char * geometry : X geometry string to use when creating the window 69 * char **interface : the XPM to use for the background and shape mask 70 * int withdrawn : if withdrawn is > 0 then the app is drawn in 71 * withdrawn state (WindowMaker DockApps) 72 * if withdrawn is zero then it is drawn as a 73 * normal window 74 * int argc : number of command line parameters 75 * char **argv : array of command line parameters 76 * RETURN: 77 * int : returns non-zero on success 78 */ 79 int dockapp_create(char *appname, char *geometry, char **interface, 80 int withdrawn, int argc, char **argv); 81 82 /* dockapp_run 83 * PARAMETERS: 84 * none 85 * RETURN: 86 * int : returns non-zero on success 87 */ 88 int dockapp_run(); 89 90 /* dockapp_redraw - requests that the paint function be called 91 * PARAMETERS: 92 * none 93 * RETURN: 94 * none 95 */ 96 void dockapp_redraw(); 97 98 /* dockapp_clear - clears the draw window 99 * PARAMETERS: 100 * none 101 * RETURN: 102 * none 103 */ 104 void dockapp_clear(); 105 106 /* dockapp_set_paint 107 * PARAMETERS: 108 * void (*func)(Display *dsp, Drawable drw, GC g) : pointer to paint 109 * function 110 * RETURN: 111 * int : returns non-zero on success 112 */ 113 int dockapp_set_paint( void (*func)(Display *dsp, Drawable drw, GC g)); 114 115 /* dockapp_set_mouse 116 * PARAMETERS: 117 * void (*func)(int x, int y, int b, int s) : pointer to mouse function 118 * RETURN: 119 * int : returns non-zero on success 120 */ 121 int dockapp_set_mouse( void (*func)(int x, int y, int b, int s)); 122 123 /* dockapp_init_display 124 * 125 * RETURN: status. <0 on error, 0 when OK 126 */ 127 int dockapp_init_display(void); 128 129 /* dockapp_get_display 130 * RETURN: 131 * Display * : returns display 132 */ 133 Display* dockapp_get_display(); 134 135 /* dockapp_get_screen 136 * RETURN: 137 * int : returns screen 138 */ 139 int dockapp_get_screen(); 140 141 /* dockapp_black_pixel 142 * RETURN: 143 * unsigned long : black pixel value 144 */ 145 unsigned long dockapp_black_pixel(); 146 147 /* dockapp_white_pixel 148 * RETURN: 149 * unsigned long : white pixel value 150 */ 151 unsigned long dockapp_white_pixel(); 152 153 /* dockapp_to_screen_coords 154 * PARAMETERS: 155 * int x : x coordinate relative to origin of draw_window 156 * int y : y coordinate relative to origin of draw_window 157 * int *x_return : returned x coordinate relative to root window 158 * int *y_return : returned y coordinate relative to root window 159 * RETURN: 160 * int : returns non-zero on success 161 */ 162 int dockapp_to_screen_coords(int x, int y, int *x_return, int *y_return); 163 164 /* dockapp_set_background_color 165 * PARAMETERS: 166 * char *: background color name 167 * 168 */ 169 void dockapp_set_background_color(char *color); 170 171 /* dockapp_set_background_pixel 172 * PARAMETERS: 173 * unsigned long pixel : background color 174 * 175 */ 176 void dockapp_set_background_pixel(unsigned long pixel); 177 178 /* dockapp_set_background_pixmap_data 179 * PARAMETERS: 180 * char **data : background pixmap 181 * 182 */ 183 void dockapp_set_background_pixmap_data(char **data); 184 185 /* dockapp_set_background_pixmap_file 186 * PARAMETERS: 187 * char *data : absolute path to background pixmap 188 * 189 */ 190 void dockapp_set_background_pixmap_file(char *file); 191 192 193 /* dockapp_set_background_pixmap 194 * PARAMETERS: 195 * Pixmap pixmap : background pixmap 196 * 197 */ 198 void dockapp_set_background_pixmap(Pixmap pixmap); 199 200 #ifdef USE_TOOLTIPS 201 202 /* dockapp_set_tooltip_foreground 203 * PARAMETERS: 204 * char *: tooltip foreground color name 205 * 206 */ 207 void dockapp_set_tooltip_foreground(char *color); 208 209 /* dockapp_set_tooltip_background 210 * PARAMETERS: 211 * char *: tooltip background color name 212 * 213 */ 214 void dockapp_set_tooltip_background(char *color); 215 216 /* dockapp_set_tooltip 217 * PARAMETERS: 218 * char * (*func) (int x, int y): pointer to tooltip callback function 219 * RETURN: 220 * int : returns non-zero on success 221 */ 222 int dockapp_set_tooltip(char * (*func) (int x, int y)); 223 224 225 /* dockapp_show_tooltip 226 * PARAMETERS: 227 * int x : x coordinate of "tip" of the tooltip 228 * int y : y coordinate of "tip" of the tooltip 229 * char *string : the string to be displayed in the tooltip 230 * 231 * RETURN: 232 * int : non-zero on success 233 */ 234 int dockapp_show_tooltip(int x, int y, char *string); 235 236 237 /* dockapp_hide_tooltip 238 * RETURN: 239 * int : <0 if there is no tooltip to hide 240 * >0 on successful hiding of tooltip 241 * =0 error 242 */ 243 int dockapp_hide_tooltip(); 244 245 246 /* dockapp_update_tooltip 247 */ 248 void dockapp_update_tooltip(); 249 250 /* dockapp_update_tooltip 251 */ 252 void dockapp_process_tooltip(); 253 254 /* dockapp_tooltip_location 255 */ 256 void dockapp_tooltip_location(XSizeHints *sizehints); 257 #endif 258 259 #endif /* not __DOCKAPP_H__ */ 260