home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / X / mit / clients / bitmap / BitmapP.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-01  |  5.3 KB  |  187 lines

  1. /*
  2.  * $XConsortium: BitmapP.h,v 1.11 91/02/01 16:39:28 dmatic Exp $
  3.  *
  4.  * Copyright 1989 Massachusetts Institute of Technology
  5.  *
  6.  * Permission to use, copy, modify, distribute, and sell this software and its
  7.  * documentation for any purpose is hereby granted without fee, provided that
  8.  * the above copyright notice appear in all copies and that both that
  9.  * copyright notice and this permission notice appear in supporting
  10.  * documentation, and that the name of M.I.T. not be used in advertising or
  11.  * publicity pertaining to distribution of the software without specific,
  12.  * written prior permission.  M.I.T. makes no representations about the
  13.  * suitability of this software for any purpose.  It is provided "as is"
  14.  * without express or implied warranty.
  15.  *
  16.  * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
  17.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
  18.  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  19.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
  20.  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
  21.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  22.  *
  23.  * Author:  Davor Matic, MIT X Consortium
  24.  */
  25.  
  26.  
  27.  
  28. #ifndef _BitmapP_h
  29. #define _BitmapP_h
  30.  
  31. #include "Bitmap.h"
  32. #include <X11/Xaw/SimpleP.h>
  33.  
  34. typedef struct {
  35.     Atom           *targets;
  36.     Cardinal        num_targets;
  37.     BWRequestRec   *requests;
  38.     Cardinal        num_requests;
  39.     BWRequestRec   *request[100];
  40.   
  41. } BitmapClassPart;
  42.  
  43. /* Full class record declaration */
  44. typedef struct _BitmapClassRec {
  45.   CoreClassPart          core_class;
  46.   SimpleClassPart        simple_class;
  47.   BitmapClassPart        bitmap_class;
  48. } BitmapClassRec;
  49.  
  50. extern BitmapClassRec bitmapClassRec;
  51.  
  52. /**********/
  53. struct _BWRequestRec {
  54.   char       *name;
  55.   int         status_size;
  56.   void      (*engage)();
  57.   caddr_t     engage_client_data;
  58.   void      (*terminate)();
  59.   caddr_t     terminate_client_data;
  60.   void      (*remove)();
  61.   caddr_t     remove_client_data;
  62. } ;
  63.  
  64. typedef struct {
  65.   Position from_x, from_y,
  66.            to_x, to_y;
  67. } BWArea;
  68.  
  69. typedef struct {
  70.     BWRequestRec *request;
  71.     caddr_t       status;
  72.     Boolean       trap;
  73.     caddr_t       call_data;
  74. } BWRequestStack;
  75.  
  76. typedef struct {
  77.     XImage   *image, *buffer;
  78.     XPoint    hot;
  79.     Position  at_x, at_y;
  80.     Boolean   fold;
  81.     Boolean   grid;
  82.     Boolean   changed;
  83. } BWZoom;
  84.  
  85. typedef struct {
  86.     Boolean   own;
  87.     Boolean   limbo;
  88. } BWSelection;
  89.  
  90. /* New fields for the Bitmap widget record */
  91. typedef struct {
  92.   /* resources */
  93.   Pixel            foreground_pixel;
  94.   Pixel            highlight_pixel;
  95.   Pixel            frame_pixel;
  96.   Pixmap           stipple;
  97.   Boolean          stippled;
  98.   Boolean          proportional;
  99.   Boolean          grid;
  100.   Dimension        grid_tolerance;
  101.   Pixmap           dashes;
  102.   Boolean          dashed;
  103.   Boolean          axes;
  104.   Boolean          resize;
  105.   Dimension        margin, squareW, squareH, width, height;
  106.   XPoint           hot;
  107.   int              button_function[5];
  108.   String           filename, basename;
  109.   /* private state */
  110.   String           size;
  111.   Position         horizOffset, vertOffset;
  112.   void           (*notify)();
  113.   BWRequestStack  *request_stack;
  114.   Cardinal         cardinal, current;
  115.   /*Boolean          trapping;*/
  116.   XImage          *image, *buffer, *storage;
  117.   XPoint           buffer_hot;
  118.   BWArea           mark, buffer_mark;
  119.   GC               drawing_gc;
  120.   GC               highlighting_gc;
  121.   GC               frame_gc;
  122.   GC               axes_gc;
  123.   Boolean          changed;
  124.   Boolean          fold;
  125.   Boolean          zooming;
  126.   BWZoom           zoom;
  127.   caddr_t         *value;
  128.   char             status[80];
  129.   BWSelection      selection;
  130.   Boolean          stipple_change_expose_event;
  131. } BitmapPart;
  132.  
  133. /* Full instance record declaration */
  134. typedef struct _BitmapRec {
  135.   CorePart      core;
  136.   SimplePart    simple;
  137.   BitmapPart    bitmap;
  138. } BitmapRec;
  139.  
  140. /* Private functions */
  141.  
  142. #define Length(width, height)\
  143.         (((int)(width) + 7) / 8 * (height))
  144.  
  145. #define InBitmapX(BW, x)\
  146.     (Position)(min((Position)((Dimension)(max(BW->bitmap.horizOffset,x)  -\
  147.                    BW->bitmap.horizOffset) /\
  148.                    BW->bitmap.squareW), BW->bitmap.width - 1))
  149.     
  150. #define InBitmapY(BW, y)\
  151.     (Position)(min((Position)((Dimension)(max(BW->bitmap.vertOffset, y)  -\
  152.                    BW->bitmap.vertOffset) /\
  153.                    BW->bitmap.squareH), BW->bitmap.height - 1))
  154.     
  155. #define InWindowX(BW, x)\
  156.     (Position) (BW->bitmap.horizOffset + ((x) * BW->bitmap.squareW))
  157.  
  158. #define InWindowY(BW, y)\
  159.     (Position) (BW->bitmap.vertOffset + ((y) * BW->bitmap.squareH))
  160.      
  161. #define GetPixmap(BW, image)\
  162.     XCreateBitmapFromData(XtDisplay(BW), XtWindow(BW),\
  163.               image->data, image->width, image->height)
  164.  
  165.  
  166. #define QuerySet(x, y) (((x) != NotSet) && ((y) != NotSet))
  167.  
  168. #define bit int
  169.  
  170. #define QueryZero(x, y) (((x) == 0) || ((y) == 0))
  171.  
  172. #define Swap(x, y) {Position t; t = x; x = y; y = t;}
  173.  
  174. #define QuerySwap(x, y) if(x > y) Swap(x, y)
  175.  
  176. #define QueryInBitmap(BW, x, y)\
  177.   (((x) >= 0) && ((x) < BW->bitmap.image->width) &&\
  178.    ((y) >= 0) && ((y) < BW->bitmap.image->height))
  179.  
  180. #define Value(BW, button)   (BW->bitmap.button_function[button - 1])
  181.  
  182. #define CreateCleanData(length) XtCalloc(length, sizeof(char))
  183. XImage *CreateBitmapImage();
  184. void DestroyBitmapImage();
  185.  
  186. #endif /* _BitmapP_h */
  187.