home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Editores / Perl5 / perl / lib / site / Tk / pTk / tkCanvas.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-10  |  9.8 KB  |  261 lines

  1. /*
  2.  * tkCanvas.h --
  3.  *
  4.  *    Declarations shared among all the files that implement
  5.  *    canvas widgets.
  6.  *
  7.  * Copyright (c) 1991-1994 The Regents of the University of California.
  8.  * Copyright (c) 1994-1995 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * SCCS: @(#) tkCanvas.h 1.41 96/02/15 18:51:28
  14.  */
  15.  
  16. #ifndef _TKCANVAS
  17. #define _TKCANVAS
  18.  
  19. #ifndef _TK
  20. #include "tk.h"
  21. #endif
  22.  
  23. #ifndef _TKCANVASES
  24. #include "tkCanvases.h"
  25. #endif
  26.  
  27. /*
  28.  * The record below describes a canvas widget.  It is made available
  29.  * to the item procedures so they can access certain shared fields such
  30.  * as the overall displacement and scale factor for the canvas.
  31.  */
  32.  
  33. typedef struct TkCanvas {
  34.     Tk_Window tkwin;        /* Window that embodies the canvas.  NULL
  35.                  * means that the window has been destroyed
  36.                  * but the data structures haven't yet been
  37.                  * cleaned up.*/
  38.     Display *display;        /* Display containing widget;  needed, among
  39.                  * other things, to release resources after
  40.                  * tkwin has already gone away. */
  41.     Tcl_Interp *interp;        /* Interpreter associated with canvas. */
  42.     Tcl_Command widgetCmd;    /* Token for canvas's widget command. */
  43.     Tk_Item *firstItemPtr;    /* First in list of all items in canvas,
  44.                  * or NULL if canvas empty. */
  45.     Tk_Item *lastItemPtr;    /* Last in list of all items in canvas,
  46.                  * or NULL if canvas empty. */
  47.  
  48.     /*
  49.      * Information used when displaying widget:
  50.      */
  51.  
  52.     int borderWidth;        /* Width of 3-D border around window. */
  53.     Tk_3DBorder bgBorder;    /* Used for canvas background. */
  54.     int relief;            /* Indicates whether window as a whole is
  55.                  * raised, sunken, or flat. */
  56.     int highlightWidth;        /* Width in pixels of highlight to draw
  57.                  * around widget when it has the focus.
  58.                  * <= 0 means don't draw a highlight. */
  59.     XColor *highlightBgColorPtr;
  60.                 /* Color for drawing traversal highlight
  61.                  * area when highlight is off. */
  62.     XColor *highlightColorPtr;    /* Color for drawing traversal highlight. */
  63.     int inset;            /* Total width of all borders, including
  64.                  * traversal highlight and 3-D border.
  65.                  * Indicates how much interior stuff must
  66.                  * be offset from outside edges to leave
  67.                  * room for borders. */
  68.     GC pixmapGC;        /* Used to copy bits from a pixmap to the
  69.                  * screen and also to clear the pixmap. */
  70.     int width, height;        /* Dimensions to request for canvas window,
  71.                  * specified in pixels. */
  72.     int redrawX1, redrawY1;    /* Upper left corner of area to redraw,
  73.                  * in pixel coordinates.  Border pixels
  74.                  * are included.  Only valid if
  75.                  * REDRAW_PENDING flag is set. */
  76.     int redrawX2, redrawY2;    /* Lower right corner of area to redraw,
  77.                  * in integer canvas coordinates.  Border
  78.                  * pixels will *not* be redrawn. */
  79.     int confine;        /* Non-zero means constrain view to keep
  80.                  * as much of canvas visible as possible. */
  81.  
  82.     /*
  83.      * Information used to manage the selection and insertion cursor:
  84.      */
  85.  
  86.     Tk_CanvasTextInfo textInfo; /* Contains lots of fields;  see tk.h for
  87.                  * details.  This structure is shared with
  88.                  * the code that implements individual items. */
  89.     int insertOnTime;        /* Number of milliseconds cursor should spend
  90.                  * in "on" state for each blink. */
  91.     int insertOffTime;        /* Number of milliseconds cursor should spend
  92.                  * in "off" state for each blink. */
  93.     Tcl_TimerToken insertBlinkHandler;
  94.                 /* Timer handler used to blink cursor on and
  95.                  * off. */
  96.  
  97.     /*
  98.      * Transformation applied to canvas as a whole:  to compute screen
  99.      * coordinates (X,Y) from canvas coordinates (x,y), do the following:
  100.      *
  101.      * X = x - xOrigin;
  102.      * Y = y - yOrigin;
  103.      */
  104.  
  105.     int xOrigin, yOrigin;    /* Canvas coordinates corresponding to
  106.                  * upper-left corner of window, given in
  107.                  * canvas pixel units. */
  108.     int drawableXOrigin, drawableYOrigin;
  109.                 /* During redisplay, these fields give the
  110.                  * canvas coordinates corresponding to
  111.                  * the upper-left corner of the drawable
  112.                  * where items are actually being drawn
  113.                  * (typically a pixmap smaller than the
  114.                  * whole window). */
  115.  
  116.     /*
  117.      * Information used for event bindings associated with items.
  118.      */
  119.  
  120.     Tk_BindingTable bindingTable;
  121.                 /* Table of all bindings currently defined
  122.                  * for this canvas.  NULL means that no
  123.                  * bindings exist, so the table hasn't been
  124.                  * created.  Each "object" used for this
  125.                  * table is either a Tk_Uid for a tag or
  126.                  * the address of an item named by id. */
  127.     Tk_Item *currentItemPtr;    /* The item currently containing the mouse
  128.                  * pointer, or NULL if none. */
  129.     Tk_Item *newCurrentPtr;    /* The item that is about to become the
  130.                  * current one, or NULL.  This field is
  131.                  * used to detect deletions  of the new
  132.                  * current item pointer that occur during
  133.                  * Leave processing of the previous current
  134.                  * item.  */
  135.     double closeEnough;        /* The mouse is assumed to be inside an
  136.                  * item if it is this close to it. */
  137.     XEvent pickEvent;        /* The event upon which the current choice
  138.                  * of currentItem is based.  Must be saved
  139.                  * so that if the currentItem is deleted,
  140.                  * can pick another. */
  141.     int state;            /* Last known modifier state.  Used to
  142.                  * defer picking a new current object
  143.                  * while buttons are down. */
  144.  
  145.     /*
  146.      * Information used for managing scrollbars:
  147.      */
  148.  
  149.     LangCallback *xScrollCmd;    /* Command prefix for communicating with
  150.                  * horizontal scrollbar.  NULL means no
  151.                  * horizontal scrollbar.  Malloc'ed*/
  152.     LangCallback *yScrollCmd;    /* Command prefix for communicating with
  153.                  * vertical scrollbar.  NULL means no
  154.                  * vertical scrollbar.  Malloc'ed*/
  155.     int scrollX1, scrollY1, scrollX2, scrollY2;
  156.                 /* These four coordinates define the region
  157.                  * that is the 100% area for scrolling (i.e.
  158.                  * these numbers determine the size and
  159.                  * location of the sliders on scrollbars).
  160.                  * Units are pixels in canvas coords. */
  161.     Arg regionArg;        /* The option string from which scrollX1
  162.                  * etc. are derived.  Malloc'ed. */
  163.     int xScrollIncrement;    /* If >0, defines a grid for horizontal
  164.                  * scrolling.  This is the size of the "unit",
  165.                  * and the left edge of the screen will always
  166.                  * lie on an even unit boundary. */
  167.     int yScrollIncrement;    /* If >0, defines a grid for horizontal
  168.                  * scrolling.  This is the size of the "unit",
  169.                  * and the left edge of the screen will always
  170.                  * lie on an even unit boundary. */
  171.  
  172.     /*
  173.      * Information used for scanning:
  174.      */
  175.  
  176.     int scanX;            /* X-position at which scan started (e.g.
  177.                  * button was pressed here). */
  178.     int scanXOrigin;        /* Value of xOrigin field when scan started. */
  179.     int scanY;            /* Y-position at which scan started (e.g.
  180.                  * button was pressed here). */
  181.     int scanYOrigin;        /* Value of yOrigin field when scan started. */
  182.  
  183.     /*
  184.      * Information used to speed up searches by remembering the last item
  185.      * created or found with an item id search.
  186.      */
  187.  
  188.     Tk_Item *hotPtr;        /* Pointer to "hot" item (one that's been
  189.                  * recently used.  NULL means there's no
  190.                  * hot item. */
  191.     Tk_Item *hotPrevPtr;    /* Pointer to predecessor to hotPtr (NULL
  192.                  * means item is first in list).  This is
  193.                  * only a hint and may not really be hotPtr's
  194.                  * predecessor. */
  195.  
  196.     /*
  197.      * Miscellaneous information:
  198.      */
  199.  
  200.     Tk_Cursor cursor;        /* Current cursor for window, or None. */
  201.     char *takeFocus;        /* Value of -takefocus option;  not used in
  202.                  * the C code, but used by keyboard traversal
  203.                  * scripts.  Malloc'ed, but may be NULL. */
  204.     double pixelsPerMM;        /* Scale factor between MM and pixels;
  205.                  * used when converting coordinates. */
  206.     int flags;            /* Various flags;  see below for
  207.                  * definitions. */
  208.     int nextId;            /* Number to use as id for next item
  209.                  * created in widget. */
  210.     struct TkPostscriptInfo *psInfoPtr;
  211.                 /* Pointer to information used for generating
  212.                  * Postscript for the canvas.  NULL means
  213.                  * no Postscript is currently being
  214.                  * generated. */
  215. } TkCanvas;
  216.  
  217. /*
  218.  * Flag bits for canvases:
  219.  *
  220.  * REDRAW_PENDING -        1 means a DoWhenIdle handler has already
  221.  *                been created to redraw some or all of the
  222.  *                canvas.
  223.  * REDRAW_BORDERS -         1 means that the borders need to be redrawn
  224.  *                during the next redisplay operation.
  225.  * REPICK_NEEDED -        1 means DisplayCanvas should pick a new
  226.  *                current item before redrawing the canvas.
  227.  * GOT_FOCUS -            1 means the focus is currently in this
  228.  *                widget, so should draw the insertion cursor
  229.  *                and traversal highlight.
  230.  * CURSOR_ON -            1 means the insertion cursor is in the "on"
  231.  *                phase of its blink cycle.  0 means either
  232.  *                we don't have the focus or the cursor is in
  233.  *                the "off" phase of its cycle.
  234.  * UPDATE_SCROLLBARS -        1 means the scrollbars should get updated
  235.  *                as part of the next display operation.
  236.  * LEFT_GRABBED_ITEM -        1 means that the mouse left the current
  237.  *                item while a grab was in effect, so we
  238.  *                didn't change canvasPtr->currentItemPtr.
  239.  * REPICK_IN_PROGRESS -        1 means PickCurrentItem is currently
  240.  *                executing.  If it should be called recursively,
  241.  *                it should simply return immediately.
  242.  */
  243.  
  244. #define REDRAW_PENDING        1
  245. #define REDRAW_BORDERS        2
  246. #define REPICK_NEEDED        4
  247. #define GOT_FOCUS        8
  248. #define CURSOR_ON        0x10
  249. #define UPDATE_SCROLLBARS    0x20
  250. #define LEFT_GRABBED_ITEM    0x40
  251. #define REPICK_IN_PROGRESS    0x100
  252.  
  253. /*
  254.  * Canvas-related procedures that are shared among Tk modules but not
  255.  * exported to the outside world:
  256.  */
  257.  
  258. extern int        TkCanvPostscriptCmd _ANSI_ARGS_((TkCanvas *canvasPtr,
  259.                 Tcl_Interp *interp, int argc, Arg *args));
  260. #endif /* _TKCANVAS */
  261.