1 /* 2 * windows.h -- 3 * 4 * Interface definitions for Magic's window manager. This 5 * package manages a set of overlapping windows. 6 * 7 * ********************************************************************* 8 * * Copyright (C) 1985, 1990 Regents of the University of California. * 9 * * Permission to use, copy, modify, and distribute this * 10 * * software and its documentation for any purpose and without * 11 * * fee is hereby granted, provided that the above copyright * 12 * * notice appear in all copies. The University of California * 13 * * makes no representations about the suitability of this * 14 * * software for any purpose. It is provided "as is" without * 15 * * express or implied warranty. Export of this software outside * 16 * * of the United States of America may require an export license. * 17 * ********************************************************************* 18 * 19 * rcsid $Header$ 20 * 21 */ 22 23 #ifndef _WINDOWS_H 24 #define _WINDOWS_H 25 26 #include "utils/magic.h" 27 #include "utils/geometry.h" 28 29 /* SUBPIXELBITS represents a fixed-point shift for representing the */ 30 /* scale factor between the screen and the layout. It is only */ 31 /* necessary that the screen resolution * SUBPIXEL does not overflow */ 32 /* type (int). The original value of 12 has become too small for */ 33 /* large chips on nanometer grids, so it has been upped to 16. */ 34 35 #define SUBPIXELBITS 16 36 #define SUBPIXEL (1 << SUBPIXELBITS) 37 #define HSUBPIXEL (1 << (SUBPIXELBITS - 1)) 38 39 typedef ClientData WindClient; /* A unique ID of a client of the 40 * window package. The value 'NULL' is 41 * indicates an invalid value. 42 */ 43 44 /* 45 * The following structure describes a window. Windows are overlapping 46 * rectangles. Each window contains a 'surface', whose contents are maintained 47 * by a client of the window package. The client is responsible for redrawing 48 * the surface when requested. The window package maintains the transform 49 * from surface coordinates to screen coordinates and also controls which 50 * portion of the surface is currently visable in the window. See the 51 * comments in windMain.c and above the proc 'WindAddClient' for more info. 52 * 53 * To see an example of a simple window client, look at the colormap window 54 * located in 'cmwind/CMWmain.c'. A more complex window is the layout window, 55 * located in 'dbwind/DBWprocs.c'. 56 * 57 * The following key letters in parens after a field indicate who should 58 * read & write it: 59 * 60 * P - Private (window package use only). 61 * R - Read-only (clients should not modify this, but may read it). 62 * W - Writable by client at any time. 63 * C - Writable by the client only during window creation time (in the 64 * create proc passed to WindAddClient) and readable at all times. 65 * L - Writable by the client at creation time and when the window is 66 * loaded with a new surface. 67 * G - Private to the graphics module. 68 * 69 * The comments below often mention a procedure that sets a given field. This 70 * is the normal procedure used to set the field, but there may be other seldom 71 * used procs in the window package that set the field. 72 */ 73 typedef struct WIND_S1 { 74 struct WIND_S1 *w_nextWindow; /* A doubly-linked list (P) */ 75 struct WIND_S1 *w_prevWindow; /* A doubly-linked list (P) */ 76 ClientData w_clientData; /* Used by the client an any manner (W) */ 77 WindClient w_client; /* The client of this window (R) */ 78 char *w_caption; /* The caption at the top of the window. (R) 79 * Set via WindCaption(). 80 */ 81 ClientData w_surfaceID; /* A unique ID for this surface, other than 82 * NULL. (R) 83 * Set via WindLoad(). 84 */ 85 Rect w_allArea; /* The entire area of the window in the screen 86 * coordinates for the window, including the 87 * border and obscured areas. (R) 88 * 89 * If we are using Magic's window package, 90 * then this field is equal to w_frameArea 91 * since all windows share the same coordinate 92 * system. In SunWindows, the lower-left 93 * corner of this area is at (0, 0) because 94 * each Sun window has it's own coordinate 95 * system with the origin in the lower left 96 * corner. 97 * 98 * This field is recomputed by WindReframe(). 99 */ 100 Rect w_frameArea; /* The location of the window on the screen (C) 101 * If a window's create proc modifies this, it 102 * needs to set w_allArea and w_screenArea by 103 * calling WindSetWindowAreas(). 104 * 105 * Also, see comments for w_allArea. 106 * 107 * This field is initialized to a reasonable 108 * value at window creation time, but the 109 * 'reposition' proc passed to WindAddClient 110 * has a way of overriding it. 111 */ 112 Rect w_screenArea; /* The area of the window in the screen 113 * coordinates of the window -- not including 114 * the border but including obscured areas. (R) 115 * 116 * This field is recomputed by WindReframe(). 117 */ 118 Rect w_surfaceArea; /* An area in surface coordinates that 119 * is large enough to contain everything 120 * displayed in w_screenArea plus at least 121 * one pixel of border on all sides. (R) 122 * This field, and w_origin and w_scale below, 123 * are modified by procedures that move and 124 * scroll windows, e.g. WindMove and WindScroll. 125 */ 126 Point w_origin; /* This screen point, in 1/SUBPIXEL pixels, 127 * corresponds to w_surfaceArea.r_ll. 128 * Used to transform between surface and screen 129 * coordinates. (R) 130 */ 131 int w_scale; /* Defines how many 1/SUBPIXEL of a pixel 132 * correspond to 1 world unit. Used to 133 * transform between surface and screen 134 * coordinates. (R) 135 */ 136 LinkedRect *w_clipAgainst; /* A linked list of areas which obscure 137 * portions of this window. (R) 138 * Normally clients just pass this down to the 139 * graphics package. 140 * Changed via WindOver(), WindUnder(), and 141 * WindFullScreen(). 142 */ 143 Point w_stippleOrigin; /* A point that serves as the origin (in screen 144 * coordinates) of stipple patterns within 145 * this window. (R) 146 * This field is maintained for the benifit of 147 * device drivers, but is often unused. 148 */ 149 int w_flags; /* A collection of flag bits: 150 * 151 * WIND_SCROLLABLE (C) 152 * WIND_SCROLLBARS (C) 153 * WIND_CAPTION (C) 154 * WIND_BORDER (C) 155 * WIND_COMMANDS (C) 156 * WIND_FULLSCREEN (P) 157 * WIND_OFFSCREEN (P) 158 * WIND_ISICONIC (P) 159 * WIND_REDRAWICON (P) 160 * WIND_OBSCURED (G) 161 * 162 * Note: It is an error for a client to set 163 * WIND_SCROLLBARS but not WIND_SCROLLABLE. 164 * If WIND_SCROLLABLE is set, then the client 165 * must fill in the pointer w_bbox; 166 */ 167 Rect w_oldArea; /* If the window has been blown up to full- 168 * screen size, this records its old area so 169 * it can be shrunk back later. (P) 170 */ 171 int w_oldDepth; /* If the window is full-screen, this records 172 * its old depth on the list of windows, so 173 * it can be put back where it came from. (P) 174 */ 175 Rect *w_bbox; /* A pointer to the bounding box of the stuff 176 * in this window. Used for WindView() and for 177 * scroll bars. (L) 178 * This MUST be set if WIND_SCROLLABLE is set. 179 */ 180 int w_wid; /* The window ID for this window. Windows are 181 * assigned small non-negative integers for 182 * easy reference. (R) 183 * Set at window creation time. 184 */ 185 ClientData w_grdata; /* Data private to the graphics package. (G) 186 * Generally references an X11 or Tk window. 187 */ 188 ClientData w_grdata2; /* Data private to the graphics packsge. (G) 189 * Used to contain per-window information 190 * other than the window itself, since 191 * various parts of the code have w_grdata 192 * hard-coded to the window pointer. 193 */ 194 ClientData w_backingStore; /* Specific data private to the graphics 195 * package. Used to save and restore the 196 * image under the cursor for fast redraw. 197 */ 198 char *w_iconname; /* Short name for the icon. */ 199 ClientData w_redrawAreas; /* List of areas that need to be redrawn. (P) 200 * Set by WindAreaChanged(), cleared by 201 * WindUpdate(). Initialized by 202 * WindSeparateRedisplay(). 203 */ 204 } MagWindow; 205 206 207 /* Window flags, for w->w_flags */ 208 #define WIND_FULLSCREEN 0x001 /* Set if the window has been blown up to 209 * full-screen size. 210 */ 211 #define WIND_OFFSCREEN 0x002 /* Set if the window is to be rendered off- 212 * screen (i.e., onto a pixmap) 213 */ 214 #define WIND_COMMANDS 0x004 /* Set if the window accepts the standard 215 * set of window commands 216 */ 217 #define WIND_SCROLLABLE 0x008 /* Set if the window can scroll & zoom. */ 218 #define WIND_SCROLLBARS 0x010 /* Set if the window has scroll bars. */ 219 #define WIND_CAPTION 0x020 /* Set if the window displays its own caption. */ 220 #define WIND_BORDER 0x040 /* Set if the window should display a border 221 * (includes scrollbars and caption area) 222 */ 223 #define WIND_ISICONIC 0x080 /* Set if the window is closed down to an 224 * icon (on Suns only) 225 */ 226 #define WIND_REDRAWICON 0x100 /* The icon needs to be redrawn. */ 227 #define WIND_OBSCURED 0x200 /* The window is partially or fully obscured */ 228 229 230 /* Special values for Window IDs. Some procedures that expect a Window ID will 231 * also accept one of these flags instead. 232 */ 233 #define WIND_UNKNOWN_WINDOW -2 /* We should pick one by looking at 234 * the location of the point. 235 */ 236 #define WIND_NO_WINDOW -3 /* Use NULL for the window */ 237 238 /* utility procs & special stuff */ 239 extern MagWindow *WindCreate(); 240 extern WindClient WindGetClient(); 241 extern WindClient WindNextClient(); 242 extern WindClient WindAddClient(); 243 extern void WindInit(); 244 extern void WindUpdate(); 245 extern void WindDrawBorder(); 246 extern void WindOutToIn(); 247 extern void WindInToOut(); 248 extern void WindSetWindowAreas(); 249 extern void windFixSurfaceArea(); 250 extern int WindExecute(); 251 extern void WindAddCommand(); 252 extern int WindReplaceCommand(); 253 extern char **WindGetCommandTable(); 254 extern int windCheckOnlyWindow(MagWindow **, WindClient); 255 256 257 /* searching procs */ 258 extern int WindSearch(); 259 extern MagWindow *WindSearchWid(); 260 extern MagWindow *WindSearchData(); 261 262 263 /* procs for moving the surface inside of a window (changing the view) */ 264 extern void WindZoom(); 265 extern void WindMove(); 266 extern void WindView(); 267 extern void WindScroll(); 268 269 270 /* procs for moving the window itself */ 271 extern void WindOver(); 272 extern void WindUnder(); 273 extern void WindReframe(); 274 extern void WindFullScreen(); 275 276 277 /* procs to transform into and out of screen coordinates */ 278 279 extern void WindScreenToSurface(); 280 extern void WindSurfaceToScreen(); 281 extern void WindPointToSurface(); 282 extern void WindPointToScreen(); 283 extern void WindSurfaceToScreenNoClip(); 284 285 /* procs to change things or inform the window manager about changes */ 286 extern void WindCaption(); 287 extern void WindAreaChanged(); 288 extern void WindIconChanged(); 289 extern bool WindLoad(); 290 extern void WindSeparateRedisplay(); 291 292 /* handler for window buttons in the scrollbar/zoom (non-wrapper) frame */ 293 extern bool WindButtonInFrame(); 294 295 /* interface variables */ 296 extern int WindDefaultFlags; /* Mask of properties applied to new windows */ 297 extern int WindNewButtons; /* A mask of the buttons that are down now. */ 298 extern int WindOldButtons; /* The buttons that were down on the previous 299 * command. 300 */ 301 extern Point WindCommandPoint; /* The point for the current command. */ 302 extern bool WindAnotherUpdatePlease; /* Set by a client during redisplay if it 303 * discovers that more stuff needs to be 304 * displayed, and wants the window package 305 * to do another WindUpdate(). Used by 306 * dbwind in dbwhlRedrawFunc() when it suddenly 307 * discovers that drawing feedback areas 308 * requires that all the mask geometry be 309 * redrawn. 310 */ 311 312 /* Macro to set the maximum number of windows */ 313 #define WIND_MAX_WINDOWS(x) (windMaxWindows = MIN(windMaxWindows, (x))) 314 extern int windMaxWindows; /* Use above macro, never increase this! */ 315 316 /* The type of windows that we will implement. This variable must be set by 317 * the graphics package before WindInit() is called. 318 */ 319 extern int WindPackageType; 320 #define WIND_MAGIC_WINDOWS 0 321 #define WIND_X_WINDOWS 1 322 323 /* Scroll bar width. 324 * May be set by the graphics package before WindInit() is called. 325 * If the width is XX, the window package tries to load glyphs from 326 * the file 'windowsXX.glyphs' located in $CAD_ROOT/magic/sys. This file 327 * contains the arrow for the scroll bars, and those icons should be of 328 * this width. 329 */ 330 extern int WindScrollBarWidth; 331 332 /* Global identifier for the window client structure */ 333 extern WindClient windClientID; 334 335 #endif /* _WINDOWS_H */ 336