util.h revision 645f5050
1/*****************************************************************************/ 2/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/ 3/** Salt Lake City, Utah **/ 4/** Portions Copyright 1989 by the Massachusetts Institute of Technology **/ 5/** Cambridge, Massachusetts **/ 6/** **/ 7/** All Rights Reserved **/ 8/** **/ 9/** Permission to use, copy, modify, and distribute this software and **/ 10/** its documentation for any purpose and without fee is hereby **/ 11/** granted, provided that the above copyright notice appear in all **/ 12/** copies and that both that copyright notice and this permis- **/ 13/** sion notice appear in supporting documentation, and that the **/ 14/** names of Evans & Sutherland and M.I.T. not be used in advertising **/ 15/** in publicity pertaining to distribution of the software without **/ 16/** specific, written prior permission. **/ 17/** **/ 18/** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/ 19/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/ 20/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/ 21/** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/ 22/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/ 23/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/ 24/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/ 25/** OR PERFORMANCE OF THIS SOFTWARE. **/ 26/*****************************************************************************/ 27/* 28 * [ ctwm ] 29 * 30 * Copyright 1992 Claude Lecommandeur. 31 * 32 * Permission to use, copy, modify and distribute this software [ctwm] and 33 * its documentation for any purpose is hereby granted without fee, provided 34 * that the above copyright notice appear in all copies and that both that 35 * copyright notice and this permission notice appear in supporting documen- 36 * tation, and that the name of Claude Lecommandeur not be used in adverti- 37 * sing or publicity pertaining to distribution of the software without 38 * specific, written prior permission. Claude Lecommandeur make no represen- 39 * tations about the suitability of this software for any purpose. It is 40 * provided "as is" without express or implied warranty. 41 * 42 * Claude Lecommandeur DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 43 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO 44 * EVENT SHALL Claude Lecommandeur BE LIABLE FOR ANY SPECIAL, INDIRECT OR 45 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF 46 * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 47 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 48 * PERFORMANCE OF THIS SOFTWARE. 49 * 50 * Author: Claude Lecommandeur [ lecom@sic.epfl.ch ][ April 1992 ] 51 */ 52 53 54/*********************************************************************** 55 * 56 * $XConsortium: util.h,v 1.10 89/12/10 17:47:04 jim Exp $ 57 * 58 * utility routines header file 59 * 60 * 28-Oct-87 Thomas E. LaStrange File created 61 * 62 ***********************************************************************/ 63 64#include <X11/Intrinsic.h> 65#include <X11/Xproto.h> 66#include "types.h" 67 68#ifndef _UTIL_ 69#define _UTIL_ 70 71#if defined(VMS) || defined(ultrix) || defined(sequent) || defined(sony_news) || defined(riscix) 72# define strdup(s) ((char*) strcpy ((char*) malloc (strlen (s) + 1), s)) 73#endif 74 75/* 76 * Define some helper macros, because "The argument to toupper() must be 77 * EOF or representable as an unsigned char; otherwise, the behavior is 78 * undefined." In particular, an argument of type "char" is problematic 79 * (gcc: warning: array subscript has type 'char'). 80 */ 81#define Isascii(c) isascii((int)(unsigned char)(c)) 82#define Isdigit(c) isdigit((int)(unsigned char)(c)) 83#define Islower(c) islower((int)(unsigned char)(c)) 84#define Isupper(c) isupper((int)(unsigned char)(c)) 85#define Tolower(c) tolower((int)(unsigned char)(c)) 86#define Toupper(c) toupper((int)(unsigned char)(c)) 87 88extern void Zoom(Window wf, Window wt); 89extern void MoveOutline(Window root, 90 int x, int y, int width, int height, 91 int bw, int th); 92extern Pixmap GetBitmap(char *name); 93extern Pixmap FindBitmap(char *name, 94 unsigned int *widthp, unsigned int *heightp); 95extern void GetUnknownIcon(char *name); 96extern char *ExpandFilename(char *name); 97extern char *ExpandFilePath(char *path); 98extern char *ExpandPixmapPath (char *name); 99 100void MaskScreen (char *file); 101void UnmaskScreen (void); 102void StartAnimation (void); 103void StopAnimation (void); 104void SetAnimationSpeed (int speed); 105void ModifyAnimationSpeed (int incr); 106void Animate (void); 107void TryToAnimate (void); 108void InsertRGBColormap (Atom a, XStandardColormap *maps, int nmaps, 109 Bool replace); 110void RemoveRGBColormap (Atom a); 111void LocateStandardColormaps (void); 112void GetColor (int kind, Pixel *what, char *name); 113void GetShadeColors (ColorPair *cp); 114void GetFont(MyFont *font); 115void SetFocusVisualAttributes (TwmWindow *tmp_win, Bool focus); 116void SetFocus (TwmWindow *tmp_win, Time tim); 117Pixmap CreateMenuIcon(int height, unsigned int *widthp, unsigned int *heightp); 118Pixmap Create3DMenuIcon (unsigned int height, 119 unsigned int *widthp, unsigned int *heightp, 120 ColorPair cp); 121Pixmap Create3DIconManagerIcon (ColorPair cp); 122void Draw3DBorder (Window w, 123 int x, int y, int width, int height, int bw, 124 ColorPair cp, 125 int state, int fill, int forcebw); 126void Draw3DCorner (Window w, 127 int x, int y, int width, int height, int thick, int bw, 128 ColorPair cp, 129 int type); 130void PaintBorders (TwmWindow *tmp_win, Bool focus); 131void PaintAllDecoration (void); 132void PaintTitle (TwmWindow *tmp_win); 133void PaintIcon (TwmWindow *tmp_win); 134void PaintTitleButton (TwmWindow *tmp_win, TBWindow *tbw); 135void PaintTitleButtons (TwmWindow *tmp_win); 136void adoptWindow (void); 137void DebugTrace (char *file); 138void SetBorderCursor (TwmWindow *tmp_win, int x, int y); 139#if 0 /* These aren't implemented anywhere! */ 140void ChangeFocusGrab (); 141Cursor CalculateBorderCursor (); 142#endif 143 144extern int HotX, HotY; 145 146struct _Image { 147 Pixmap pixmap; 148 Pixmap mask; 149 int width; 150 int height; 151 struct _Image *next; 152}; 153 154extern Image *GetImage (char *name, ColorPair cp); 155 156extern unsigned char *GetWMPropertyString(Window w, Atom prop); 157extern void FreeWMPropertyString(char *prop); 158extern void ConstrainByBorders1 (int *left, int width, int *top, int height); 159extern void ConstrainByBorders (TwmWindow *twmwin, 160 int *left, int width, 161 int *top, int height); 162 163#endif /* _UTIL_ */ 164