home *** CD-ROM | disk | FTP | other *** search
/ Netrunner 2004 October / NETRUNNER0410.ISO / regular / ActivePerl-5.8.4.810-MSWin32-x86.msi / _7db40d5f2a1cba50c1dd84039e83fc74 < prev    next >
Encoding:
Text File  |  2004-06-01  |  15.1 KB  |  459 lines

  1.  
  2. /*    $Id: tixGrid.h,v 1.1.1.1 2000/05/17 11:08:42 idiscovery Exp $    */
  3.  
  4. /*
  5.  * tixGrid.h --
  6.  *
  7.  *    Defines main data structures for tixGrid
  8.  *
  9.  * Copyright (c) 1996, Expert Interface Technologies
  10.  *
  11.  * See the file "license.terms" for information on usage and redistribution
  12.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  *
  14.  */
  15.  
  16. #ifndef _TIX_GRID_H_
  17. #define _TIX_GRID_H_
  18. #include "tkVMacro.h"
  19.  
  20. #ifndef _TIX_GRID_DATA_H_
  21. #include "tixGrData.h"
  22. #endif
  23.  
  24. #define TIX_X 0
  25. #define TIX_Y 1
  26.  
  27.  
  28. #define TIX_S_MARGIN 0
  29. #define TIX_X_MARGIN 1
  30. #define TIX_Y_MARGIN 2
  31. #define TIX_MAIN     3
  32.  
  33. #define TIX_SITE_NONE -1
  34.  
  35. typedef struct TixGrEntry {
  36.     Tix_DItem * iPtr;
  37.     Tcl_HashEntry * entryPtr[2];    /* The index of this entry in the
  38.                      * row/col tables */
  39. } TixGrEntry;
  40.  
  41. /*----------------------------------------------------------------------
  42.  *             Render Block
  43.  *
  44.  * Before the Grid is rendered, information is filled into a pseudo 2D
  45.  * array of RenderBlockElem's:
  46.  *
  47.  *    (1) entries are placed in the appropriate (x,y) locations
  48.  *    (2) background and borders are formatted according
  49.  *    (3) highlights are formatted.
  50.  *
  51.  * The widget is redrawn using the render-block. This saves reformatting
  52.  * the next time the widget is exposed.
  53.  *----------------------------------------------------------------------
  54.  */
  55. typedef struct RenderBlockElem {
  56.     TixGrEntry * chPtr;        /* not allocated, don't need to free */
  57.     int borderW[2][2];
  58.     int index[2];
  59.  
  60.     unsigned int selected : 1;
  61.     unsigned int filled : 1;
  62. } RenderBlockElem;
  63.  
  64.  
  65. /* ElmDispSize --
  66.  *
  67.  *    This structure stores the size information of the visible
  68.  *    rows (RenderBlock.dispSize[0][...]) and columns
  69.  *    (RenderBlock.dispSize[1][...])
  70.  */
  71. typedef struct ElmDispSize {
  72.     int preBorder;
  73.     int size;
  74.     int postBorder;
  75.  
  76.     int total;        /* simple the sum of the above */
  77. } ElmDispSize;
  78.  
  79. typedef struct RenderBlock {
  80.     int size[2];        /* num of rows and cols in the render block */
  81.  
  82.     RenderBlockElem **elms;       /* An Malloc'ed pseudo 2D array (you can do
  83.                  * things like elms[0][0]), Used for the
  84.                  * main body of the Grid.
  85.                  */
  86.     ElmDispSize *dispSize[2];    /* (dispSizes[0][x], dispSizes[1][y])
  87.                  * will be the dimension of the element (x,y)
  88.                  * displayed on the screen (may be bigger
  89.                  * or smaller than its desired size). */
  90.     int visArea[2];        /* visible area (width times height) of
  91.                  * the visible cells on the screen */
  92. }  RenderBlock;
  93.  
  94. /*----------------------------------------------------------------------
  95.  *             RenderInfo
  96.  *
  97.  * This stores information for rendering from the RB into an X drawable.
  98.  *
  99.  *----------------------------------------------------------------------
  100.  */
  101. typedef struct RenderInfo {
  102.     Drawable drawable;
  103.     int origin[2];
  104.     int offset[2];
  105.     int size[2];        /* width and height of the area to draw
  106.                  * (number of pixels starting from the offset)
  107.                  * if offset = (2,2) and size = (5,5) we have
  108.                  * to draw the rectangle ((2,2), (6,6));
  109.                  */
  110.     struct {            /* the current valid grid area for the */
  111.     int x1, x2, y1, y2;    /* "format" command */
  112.     int whichArea;
  113.     } fmt;
  114. } RenderInfo;
  115.  
  116. typedef struct ExposedArea {
  117.     int x1, y1, x2, y2;
  118. } ExposedArea, Rect;
  119.  
  120. /*----------------------------------------------------------------------
  121.  *             ColorInfo
  122.  *
  123.  * These colors are used by the format commands. They must be saved
  124.  * or otherwise the colormap may be changed ..
  125.  *----------------------------------------------------------------------
  126.  */
  127. typedef struct ColorInfo {
  128.     struct ColorInfo * next;
  129.     int counter;
  130.     int type;            /* TK_CONFIG_BORDER or TK_CONFIG_COLOR */
  131.     long pixel;
  132.     Tk_3DBorder border;
  133.     XColor * color;
  134. } ColorInfo;
  135.  
  136. /*----------------------------------------------------------------------
  137.  *             SelectBlock
  138.  *
  139.  * These structures are arranged in a list and are used to determine
  140.  * where a cell is selected.
  141.  *----------------------------------------------------------------------
  142.  */
  143. #define TIX_GR_CLEAR        1
  144. #define TIX_GR_SET        2
  145. #define TIX_GR_TOGGLE        3
  146.  
  147. #define TIX_GR_MAX        0x7fffffff
  148.  
  149. #define TIX_GR_RESIZE        1
  150. #define TIX_GR_REDRAW        2
  151.  
  152.  
  153. typedef struct SelectBlock {
  154.     struct SelectBlock * next;
  155.     int range[2][2];        /* the top left and bottom right corners */
  156.     int type;            /* TIX_GR_CLEAR, TIX_GR_SET,
  157.                  * TIX_GR_TOGGLE
  158.                  *
  159.                  * If several SelectBlock covers the same
  160.                  * cell, the last block in the wPtr->selList
  161.                  * determines whether this cell is selected
  162.                  * or not */
  163. } SelectBlock;
  164.  
  165. /*----------------------------------------------------------------------
  166.  *             GrSortItem
  167.  *
  168.  * Used to sort the items in the grid
  169.  *----------------------------------------------------------------------
  170.  */
  171. typedef struct Tix_GrSortItem {
  172.     Tcl_Obj * data;            /* is usually a string, but
  173.                      * can be a pointer to an
  174.                      * arbitrary data in C API */
  175.     int index;                /* row or column */
  176. } Tix_GrSortItem;
  177.  
  178. /*----------------------------------------------------------------------
  179.  * Data structure for iterating the cells inside the grid.
  180.  *
  181.  *----------------------------------------------------------------------
  182.  */
  183.  
  184. typedef struct Tix_GrDataRowSearch {
  185.     struct TixGridRowCol * row;
  186.     Tcl_HashSearch hashSearch;
  187.     Tcl_HashEntry *hashPtr;
  188. } Tix_GrDataRowSearch;
  189.  
  190. typedef struct Tix_GrDataCellSearch {
  191.     char * data;
  192.     Tcl_HashSearch hashSearch;
  193.     Tcl_HashEntry *hashPtr;
  194. } Tix_GrDataCellSearch;
  195.  
  196. /*----------------------------------------------------------------------
  197.  *
  198.  *            Main data structure of the grid widget.
  199.  *
  200.  *----------------------------------------------------------------------
  201.  */
  202. typedef struct Tix_GridScrollInfo {
  203.     LangCallback *command;
  204.  
  205.     int max;        /* total size (width or height) of the widget*/
  206.     int offset;        /* The top/left side of the scrolled widget */
  207.     int unit;        /* How much should we scroll when the user */
  208.  
  209.     double window;    /* visible size, percentage of the total */
  210. }Tix_GridScrollInfo;
  211.  
  212.  
  213. typedef struct GridStruct {
  214.     Tix_DispData dispData;
  215.  
  216.     Tcl_Command widgetCmd;    /* Token for button's widget command. */
  217.  
  218.     /*
  219.      * Information used when displaying widget:
  220.      */
  221.     int reqSize[2];        /* For app programmer to request size */
  222.  
  223.     /*
  224.      * Information used when displaying widget:
  225.      */
  226.  
  227.     /* Border and general drawing */
  228.     int borderWidth;        /* Width of 3-D borders. */
  229.     int selBorderWidth;        /* Width of 3-D borders for selected items */
  230.     int relief;            /* Indicates whether window as a whole is
  231.                  * raised, sunken, or flat. */
  232.     Tk_3DBorder border;        /* Used for drawing the 3d border. */
  233.     Tk_3DBorder selectBorder;    /* Used for selected background. */
  234.     XColor *normalFg;        /* Normal foreground for text. */
  235.     XColor *normalBg;        /* Normal background for  text. */
  236.     XColor *selectFg;        /* Color for drawing selected text. */
  237.  
  238.     Tk_Uid state;        /* State can only be normal or disabled. */
  239.  
  240.        /* GC and stuff */
  241.     GC backgroundGC;        /* GC for drawing background. */
  242.     GC selectGC;        /* GC for drawing selected background. */
  243.     GC anchorGC;        /* GC for drawing dotted anchor highlight. */
  244.     TixFont font;        /* Default font used by the DItems. */
  245.  
  246.     /* Text drawing */
  247.     Cursor cursor;        /* Current cursor for window, or None. */
  248.  
  249.     /* For highlights */
  250.     int highlightWidth;        /* Width in pixels of highlight to draw
  251.                  * around widget when it has the focus.
  252.                  * <= 0 means don't draw a highlight. */
  253.     int bdPad;            /* = highlightWidth + borderWidth */
  254.     XColor *highlightColorPtr;    /* Color for drawing traversal highlight. */
  255.     GC highlightGC;        /* For drawing traversal highlight. */
  256.  
  257.     /*
  258.      * default pad and gap values
  259.      */
  260.     int padX, padY;
  261.  
  262.     Tk_Uid selectMode;        /* Selection style: single, browse, multiple,
  263.                  * or extended.  This value isn't used in C
  264.                  * code, but the Tcl bindings use it. */
  265.     Tk_Uid selectUnit;        /* Selection unit: cell, row or column.
  266.                  * This value isn't used in C
  267.                  * code, but the Tcl bindings use it. */
  268.  
  269.     /*
  270.      * The following three sites are used according to the -selectunit.
  271.      * if selectunit is: "cell", [0] and [1] are used; "row", only [0]
  272.      * is used; "column", only [1] is used
  273.      */
  274.     int anchor[2];        /* The current anchor unit */
  275.     int dropSite[2];        /* The current drop site */
  276.     int dragSite[2];        /* The current drop site */
  277.  
  278.     /*
  279.      * Callback commands.
  280.      */
  281.     LangCallback *command;        /* The command when user double-clicks */
  282.     LangCallback *browseCmd;        /* The command to call when the selection
  283.                  * changes. */
  284.     LangCallback *editNotifyCmd;    /* The command to call to determine whether
  285.                  * a cell is editable. */
  286.     LangCallback *editDoneCmd;        /* The command to call when an entry has
  287.                  * been edited by the user.*/
  288.     LangCallback *formatCmd;        /* The command to call when the Grid widget
  289.                  * needs to be reformatted (e.g, Exposure
  290.                  * events or when contents have been
  291.                  * changed). */
  292.     LangCallback *sizeCmd;        /* The command to call when the size of
  293.                  * the listbox changes. E.g., when the user
  294.                  * add/deletes elements. Useful for auto-
  295.                  * scrollbar geometry managers */
  296.  
  297.     /*
  298.      * Info for lay-out
  299.      */
  300.     char *takeFocus;        /* Value of -takefocus option;  not used in
  301.                  * the C code, but used by keyboard traversal
  302.                  * scripts.  Malloc'ed, but may be NULL. */
  303.  
  304.     int serial;            /* this number is incremented before each time
  305.                  * the widget is redisplayed */
  306.  
  307.     TixGridDataSet * dataSet;
  308.     RenderBlock * mainRB;    /* Malloc'ed */
  309.  
  310.     int hdrSize[2];        /* number of rows (height of x header, index
  311.                  * [0]) and columns (width of y header, index
  312.                  * [1]) */
  313.     int floatRange[2];        /* Are the num of columns and rows floated?
  314.                  * (if floated, you can scroll past the max
  315.                  * element).*/
  316.     int gridSize[2];        /* the size of the grid where there is data */
  317.     Tix_DItemInfo * diTypePtr;    /* Default item type */
  318.     ExposedArea expArea;
  319.  
  320.     RenderInfo * renderInfo;    /* only points to stuff in stack */
  321.     Tix_GridScrollInfo scrollInfo[2];
  322.     int fontSize[2];        /* size of the "0" char of the -font option
  323.                  */
  324.     TixGridSize defSize[2];
  325.     Tix_LinkList colorInfo;
  326.     Tix_LinkList selList;
  327.     Tix_LinkList mappedWindows;
  328.     int colorInfoCounter;
  329.  
  330.     unsigned int hasFocus  : 1;
  331.  
  332.     unsigned int idleEvent : 1;
  333.     unsigned int toResize  : 1;        /* idle event */
  334.     unsigned int toRedraw : 1;        /* idle event */
  335.  
  336.     unsigned int toResetRB  : 1; /* Do we need to reset the render block */
  337.     unsigned int toComputeSel  : 1;
  338.     unsigned int toRedrawHighlight : 1;
  339. } Grid;
  340.  
  341. typedef Grid   WidgetRecord;
  342. typedef Grid * WidgetPtr;
  343.  
  344. #define DEF_GRID_BG_COLOR        NORMAL_BG
  345. #define DEF_GRID_BG_MONO        WHITE
  346. #define DEF_GRID_BORDER_WIDTH        "2"
  347. #define DEF_GRID_BROWSE_COMMAND        ""
  348. #define DEF_GRID_COMMAND        ""
  349. #define DEF_GRID_CURSOR            ""
  350. #define DEF_GRID_DEFAULT_WIDTH        "40"
  351. #define DEF_GRID_DEFAULT_HEIGHT        "20"
  352. #define DEF_GRID_EDITDONE_COMMAND    ""
  353. #define DEF_GRID_EDITNOTIFY_COMMAND    ""
  354. #define DEF_GRID_FLOATING_ROWS        "0"
  355. #define DEF_GRID_FLOATING_COLS        "0"
  356. #define DEF_GRID_FONT            "Helvetica -12 bold"
  357. #define DEF_GRID_FG_COLOR        BLACK
  358. #define DEF_GRID_FG_MONO        BLACK
  359. #define DEF_GRID_FORMAT_COMMAND        ""
  360. #define DEF_GRID_HEIGHT            "10"
  361. #define DEF_GRID_HIGHLIGHT_COLOR    BLACK
  362. #define DEF_GRID_HIGHLIGHT_MONO        BLACK
  363. #define DEF_GRID_HIGHLIGHT_WIDTH    "2"
  364. #define DEF_GRID_LEFT_MARGIN        "1"
  365. #define DEF_GRID_ITEM_TYPE        "text"
  366. #define DEF_GRID_RELIEF            "sunken"
  367. #define DEF_GRID_PADX            "2"
  368. #define DEF_GRID_PADY            "2"
  369. #define DEF_GRID_SELECT_BG_COLOR    ACTIVE_BG
  370. #define DEF_GRID_SELECT_FG_COLOR    BLACK
  371. #define DEF_GRID_SELECT_BG_MONO        BLACK
  372. #define DEF_GRID_SELECT_FG_MONO        WHITE
  373. #define DEF_GRID_SELECT_MODE        "single"
  374. #define DEF_GRID_SELECT_UNIT        "row"
  375. #define DEF_GRID_SELECT_BORDERWIDTH    "1"
  376. #define DEF_GRID_STATE            "normal"
  377. #define DEF_GRID_SIZE_COMMAND        ""
  378. #define DEF_GRID_TAKE_FOCUS         "1"
  379. #define DEF_GRID_TOP_MARGIN        "1"
  380. #define DEF_GRID_WIDTH            "4"
  381. #define DEF_GRID_Y_SCROLL_COMMAND    ""
  382. #define DEF_GRID_X_SCROLL_COMMAND    ""
  383.  
  384. /*
  385.  * common functions
  386.  */
  387.  
  388. EXTERN void        Tix_GrAddChangedRect _ANSI_ARGS_((
  389.                 WidgetPtr wPtr, int changedRect[2][2],
  390.                 int isSite));
  391. EXTERN int        Tix_GrConfigSize _ANSI_ARGS_((Tcl_Interp *interp,
  392.                 WidgetPtr wPtr, int argc, Tcl_Obj *CONST *objv,
  393.                 TixGridSize *sizePtr, char * argcErrorMsg,
  394.                 int *changed_ret));
  395. EXTERN void        Tix_GrDoWhenIdle _ANSI_ARGS_((WidgetPtr wPtr,
  396.                 int type));
  397. EXTERN void        Tix_GrCancelDoWhenIdle _ANSI_ARGS_((WidgetPtr wPtr));
  398. EXTERN void        Tix_GrFreeElem _ANSI_ARGS_((TixGrEntry * chPtr));
  399. EXTERN void        Tix_GrFreeUnusedColors _ANSI_ARGS_((WidgetPtr wPtr,
  400.                 int freeAll));
  401. EXTERN void        Tix_GrScrollPage _ANSI_ARGS_((WidgetPtr wPtr,
  402.                 int count, int axis));
  403.  
  404. /*
  405.  * The dataset functions
  406.  */
  407.  
  408. EXTERN int        TixGridDataConfigRowColSize _ANSI_ARGS_((
  409.                 Tcl_Interp * interp, WidgetPtr wPtr,
  410.                 TixGridDataSet * dataSet, int which, int index,
  411.                 int argc, Tcl_Obj *CONST *objv, char * argcErrorMsg,
  412.                 int *changed_ret));
  413. EXTERN char *        TixGridDataCreateEntry _ANSI_ARGS_((
  414.                 TixGridDataSet * dataSet, int x, int y,
  415.                 char * defaultEntry));
  416. EXTERN int        TixGridDataDeleteEntry _ANSI_ARGS_((
  417.                 TixGridDataSet * dataSet, int x, int y));
  418. EXTERN void        TixGridDataDeleteRange _ANSI_ARGS_((WidgetPtr wPtr,
  419.                 TixGridDataSet * dataSet, int which,
  420.                 int from, int to));
  421. EXTERN void         TixGridDataDeleteSearchedEntry _ANSI_ARGS_((
  422.                 Tix_GrDataCellSearch * cellSearchPtr));
  423. EXTERN char *        TixGridDataFindEntry _ANSI_ARGS_((
  424.                 TixGridDataSet * dataSet, int x, int y));
  425. EXTERN int        TixGrDataFirstCell _ANSI_ARGS_((
  426.                 Tix_GrDataRowSearch * rowSearchPtr,
  427.                 Tix_GrDataCellSearch * cellSearchPtr));
  428. EXTERN int        TixGrDataFirstRow _ANSI_ARGS_((
  429.                 TixGridDataSet* dataSet,
  430.                 Tix_GrDataRowSearch * rowSearchPtr));
  431. EXTERN int        TixGridDataGetRowColSize _ANSI_ARGS_((
  432.                 WidgetPtr wPtr, TixGridDataSet * dataSet,
  433.                 int which, int index, TixGridSize * defSize,
  434.                 int *pad0, int * pad1));
  435. EXTERN void        TixGridDataGetGridSize _ANSI_ARGS_((
  436.                 TixGridDataSet * dataSet, int *width_ret,
  437.                 int *height_ret));
  438. EXTERN int        TixGridDataGetIndex _ANSI_ARGS_((
  439.                 Tcl_Interp * interp, WidgetPtr wPtr,
  440.                 Tcl_Obj * xStr, Tcl_Obj * yStr, int * xPtr, int * yPtr));
  441. EXTERN void         TixGridDataInsert _ANSI_ARGS_((
  442.                 TixGridDataSet * dataSet,
  443.                 int x, int y, ClientData data));
  444. EXTERN void        TixGridDataMoveRange _ANSI_ARGS_((WidgetPtr wPtr,
  445.                 TixGridDataSet * dataSet, int which,
  446.                 int from, int to, int by));
  447. EXTERN int        TixGrDataNextCell _ANSI_ARGS_((
  448.                 Tix_GrDataCellSearch * cellSearchPtr));
  449. EXTERN int        TixGrDataNextRow _ANSI_ARGS_((
  450.                 Tix_GrDataRowSearch * rowSearchPtr));
  451. EXTERN TixGridDataSet*    TixGridDataSetInit _ANSI_ARGS_((void));
  452. EXTERN void        TixGridDataSetFree _ANSI_ARGS_((
  453.                 TixGridDataSet* dataSet));
  454. EXTERN int        TixGridDataUpdateSort _ANSI_ARGS_((
  455.                 TixGridDataSet * dataSet, int axis,
  456.                 int start, int end, Tix_GrSortItem *items));
  457.  
  458. #endif /*_TIX_GRID_H_*/
  459.