home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Interfaces / CIncludes / UGridView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-25  |  30.8 KB  |  699 lines  |  [TEXT/MPS ]

  1. /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/
  2. /* UGridView.p */
  3. /* Copyright © 1987-1990 by Apple Computer Inc. All rights reserved. */
  4. #ifndef  __UGridView__
  5. #define __UGridView__  0
  6. #endif
  7. #if  ! __UGridView__
  8. #define __UGridView__  1
  9.  
  10.         /* • Auto-Include the requirements for this unit's interface. */
  11. #ifndef  __UMacApp__
  12. #include "UMacApp.h"
  13. #endif
  14.  
  15.             /* Booleans for Adornment */
  16. const short kAdorn                = true;
  17. const short kDontAdorn            = false;
  18.  
  19.             /* Booleans for SetSelection */
  20. const short kExtend                = true;
  21. const short kDontExtend            = false;
  22.  
  23. const short kHighlight            = true;
  24. const short kDontHighlight        = false;
  25.  
  26. const short kSelect                = true;
  27. const short kDeSelect            = false;
  28.  
  29. typedef Point GridCell;                                    /* A cell is a QuickDraw point */
  30.  
  31. typedef enum {badChoice, inCell, inRow, inColumn, inVertex} GridViewPart;
  32.  
  33. /*--------------------------------------------------------------------------------------
  34.    ------------*/
  35.  
  36. struct RunArrayChunk {
  37.     short count;                                        /* Number of consecutive items with this
  38.                                                          value */
  39.     short value;                                        /* The value represented by this chunk */
  40. };
  41.  
  42. typedef RunArrayChunk ChunkArray[100001];
  43. typedef ChunkArray *ChunkArrayPtr;                        /* Preferred */
  44. typedef ChunkArrayPtr *ChunkArrayHandle;                /* Preferred */
  45. typedef ChunkArrayPtr PChunkArray;                        /* Left in for compatibility (2.0) */
  46. typedef ChunkArrayHandle HChunkArray;                    /* Left in for compatibility (2.0) */
  47.  
  48. class TRunArray : public TObject {
  49.   public:            /* The run array class is used to maintain
  50.                                                          the column widths and row heights. Entries
  51.                                                          in the array are values for a given item,
  52.  
  53.                                                          where the items are indexed from one.
  54.                                                          fNoOfItems indicates the number of items
  55.                                                          (and values) in the array. The values are
  56.                                                          maintained in "chunks" which lump together
  57.                                                          consecutive items with the same value. A
  58.                                                          variable length array, fChunks,
  59.     is used to
  60.                                                          store the chunks. It is indexed from zero.
  61.                                                          */
  62.     short fLastItem;                                    /* cache the last item found */
  63.     short fLastChunk;                                    /* cache the last chunk found */
  64.  
  65.     long fLastTotal;                                    /* cache the last total calculated */
  66.     short fLastIndex;                                    /* cache the last index used */
  67.     short fNoOfItems;
  68.        /* Number of items (values) in this run-array
  69.                                                          */
  70.     long fTotal;                                        /* The sum of the values in the run array */
  71.     short fNoOfChunks;                                    /* Number of chunks in the run array */
  72.     ChunkArrayHandle fChunks;                            /* A handle to the chunks themselves. */
  73.  
  74.     virtual pascal void IRunArray(void);
  75.                 /* Initializes a run array to have zero items. */
  76.  
  77.     virtual pascal void Free(void);
  78.                 /* Frees the fChunks field which is a handle to the chunks, before calling inherited
  79.                 Free. */
  80.  
  81.     virtual pascal void InsertItems(short firstItem, short noOfItems, short value);
  82.  
  83.         /* Inserts the indicated items into the run array, all of which have the given value.
  84.                 */
  85.  
  86.     virtual pascal void DeleteItems(short firstItem, short noOfItems);
  87.                 /* Deletes the indicated items from the run array.*/
  88.  
  89.     virtual pascal Boolean FindChunk(short item, short *chunk, short *indexInChunk, long *theTotal);
  90.  
  91.         /* Returns information about a given item in the run array. chunk indicates the chunk
  92.                 in which the item is located, where zero is the first chunk in the run array.
  93.                 indexInChunk is the location of the item withinin the chunk. Note that the chunk
  94.                 indexes are one-based--the first item in the chunk is index 1. theTotal is the sum
  95.                 of values up to, but not including, the chunk in which the given item is located.
  96.                 FindChunk returns false if the given item is outside the range of items in the
  97.                 run-array (i.e. item < 1 or item > fNoOfItems), or the given item is not
  98.                 represented in a chunk (i.e. a bug).
  99.                 Example: Item   Value   Chunk   indexInChunk    theTotal
  100.                             1       05      0           1           000
  101.                             2       05      0           2           000
  102.                             3       20      1           1           010
  103.                             4       35      2           1           030
  104.                             5       35      2           2           030
  105.                             6       10      3           1           100
  106.                 */
  107.  
  108.     virtual pascal short FindItem(long theTotal);
  109.                 /* Returns the item number for which the sum of the values exceeds theTotal, or zero
  110.                 if theTotal is outside the sum of values represented by the run array.*/
  111.  
  112.     virtual pascal short GetValue(short item);
  113.                 /* Returns the value for the given item. */
  114.  
  115.     virtual pascal long SumValues(short firstItem, short noOfItems);
  116.                 /* Returns the sum of the values over the given items. */
  117.  
  118.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  119.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  120.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  121.                 fields. */
  122.  
  123. };
  124.  
  125. /*--------------------------------------------------------------------------------------
  126.    ------------*/
  127.  
  128. struct GridViewTemplate {
  129.     short numOfRows;
  130.     short numOfCols;
  131.     short rowHeight;
  132.     short colWidth;
  133.     short rowInset;
  134.     short colInset;
  135.     unsigned adornRows : 1;
  136.     unsigned adornCols : 1;
  137.     unsigned singleSelection : 1;
  138.     unsigned filler : 13;
  139. };
  140. typedef GridViewTemplate *GridViewTemplatePtr;
  141.  
  142. struct TextGridViewTemplate {
  143.     Style itsFontFace;
  144.     short itsFontSize;
  145.     RGBColor itsFontColor;
  146.     Str255 itsFontName;                                    /* a variable length P-String */
  147. };
  148. typedef TextGridViewTemplate *TextGridViewTemplatePtr;
  149.  
  150. class TGridView : public TView {
  151.   public:                /* TGridView forms the base class for a
  152.                                                          building block that allows the creation of
  153.                                                          views that can contain and manage cells,
  154.  
  155.                                                          similar to a spreadsheet. */
  156.     short fNumOfRows;                                    /* number of rows */
  157.     short fNumOfCols;                                    /* number of columns */
  158.     TRunArray *fColWidths;                                /* bag containing col widths */
  159.     TRunArray *fRowHeights;                                /* bag containing row heights */
  160.     Boolean fAdornRows;                                    /* Draw adornment for rows? */
  161.     Boolean fAdornCols;                                    /* Draw adornment for columns? */
  162.     short fRowInset;                                    /* Number of pixels between cell rows */
  163.     short fColInset;                                    /* Number of pixels between cell cols */
  164.     Boolean fSingleSelection;                            /* only one cell selected at a time? */
  165.     RgnHandle fSelections;                                /* Region of currently selected cells */
  166.     RgnHandle fHLRegion;                                /* Region of cells to be highlighted. This
  167.                                                          will be different from fSelections while
  168.                                                          selection with the mouse is taking place.
  169.                                                          */
  170.     RgnHandle fTempSelections;                            /* Used by SetSelectionRect */
  171.  
  172.     virtual pascal void IGridView(TDocument *itsDocument, TView *itsSuperView, VPoint *itsLocation, 
  173.        VPoint *itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short numOfRows, 
  174.        short numOfCols, short rowHeight, short colWidth, Boolean adornRows, Boolean adornCols, short
  175.         rowInset, short colInset, Boolean singleSelection);
  176.        /* single cell selection? */
  177.  
  178.  
  179.        /* Initialize the gridview. If numOfRows or numOfCols is non-zero then the gridview is
  180.                 initialized to the specified size using rowHeight and colWidth if the sizedeterminer
  181.                 is sizeVariable. If either adorn is kDontAdorn, then that adorn will not
  182.     be called. */
  183.  
  184.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  185.                 /* Initialize the view template. */
  186.  
  187.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  188.                 /* Write this object out as a view resource. */
  189.  
  190.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  191.                 /* Set up the type and signature of this object and call WRes. */
  192.  
  193.     virtual pascal void Free(void);
  194.                 /* Free the TGridView object */
  195.  
  196.                 /*  Methods to OVERRIDE    */
  197.  
  198.                 /*  Inherited Methods  (OVERRIDE)    */
  199.  
  200.     virtual pascal void CalcMinSize(VPoint *minSize);
  201.                 /* Sets the extent of the view. */
  202.  
  203.     virtual pascal void DoHighlightSelection(HLState fromHL, HLState toHL);
  204.                 /* Do highlighting */
  205.  
  206.     virtual pascal TCommand *DoMouseCommand(Point *theMouse, EventInfo *info, Point *hysteresis);
  207.                 /* Handle mouse commands */
  208.  
  209.     virtual pascal void Draw(Rect *area);
  210.                 /* Calls DrawRangeOfCells and AdornRow/Col as appropriate. */
  211.  
  212.                 /*  UGridView Methods to OVERRIDE    */
  213.  
  214.     virtual pascal void AdornCol(short aCol, Rect *area);
  215.                 /* If fAdornCol is TRUE, this method is called to draw the column adornments. */
  216.  
  217.     virtual pascal void AdornRow(short aRow, Rect *area);
  218.                 /* If fAdornRow is TRUE, this method is called to draw the row  adornments. */
  219.  
  220.     virtual pascal Boolean CanSelectCell(Point aCell);
  221.  
  222.         /* This method checks to see if a cell can be seleced. By default, this method always
  223.                 returns TRUE. */
  224.  
  225.     virtual pascal void HighlightCells(RgnHandle theCells, HLState fromHL, HLState toHL);
  226.                 /* Highlights the cells in theCells according to the given highlight state. */
  227.  
  228.     virtual pascal void DrawRangeOfCells(Point startCell, Point stopCell, Rect *aQDRect);
  229.                 /* This method calls DrawCell for each cell in need of re-drawing. */
  230.  
  231.     virtual pascal void DrawCell(Point aCell, Rect *aQDRect);
  232.                 /* This method draws each individual cell.  IT MUST BE OVERRIDDEN! */
  233.  
  234.                 /*  General UGridView Methods     */
  235.  
  236.     virtual pascal void AllCellsDo(pascal void (*DoToCell)(Point aCell, void *DoToCell_StaticLink), 
  237.        void *DoToCell_StaticLink);
  238.                 /* For every cell in the view perform "DoToCell". */
  239.  
  240.     virtual pascal void CellToVRect(Point aCell, VRect *aRect);
  241.  
  242.       /* Get the rectangle bounding a given cell. This includes the row and column insets. */
  243.  
  244.     virtual pascal void ColToVRect(short aCol, short numOfCols, VRect *aRect);
  245.  
  246.        /* Get the rectangle bounding the given columns. This includes the cells in the row or
  247.                 column and the row or column insets. */
  248.  
  249.     virtual pascal void RowToVRect(short aRow, short numOfRows, VRect *aRect);
  250.                 /* Get the rectangle bounding the given rows. This includes the cells in the row or
  251.                 column and the row or column insets. */
  252.  
  253.     virtual pascal void CellsToPixels(RgnHandle theCells, RgnHandle thePixels);
  254.                 /* Returns in thePixels a region that contains all of the cells in theCells. */
  255.  
  256.     virtual pascal void DelColAt(short aCol, short numOfCols);
  257.                 /* Delete the specified columns, starting at 'aCol' with the number to be deleted
  258.                 'numOfCols'.This causes a redraw of only the necessary cells. */
  259.  
  260.     virtual pascal void DelRowAt(short aRow, short numOfRows);
  261.                 /* Delete the specified rows, starting at 'aRow' with the number of to be deleted
  262.                 'numOfRows'.This causes a redraw of only the necessary cells. */
  263.  
  264.     virtual pascal void DelColFirst(short numOfCols);
  265.  
  266.        /* Delete the specified number of columns from the beginning of the list.This causes a
  267.                 redraw of only the necessary cells. */
  268.  
  269.     virtual pascal void DelRowFirst(short numOfRows);
  270.                 /* Delete the specified number of rows from the beginning of the list.This causes a
  271.                 redraw of only the necessary cells. */
  272.  
  273.     virtual pascal void DelColLast(short numOfCols);
  274.  
  275.        /* Delete the specified number of columns from the last cell of the list.This causes a
  276.                 redraw of only the necessary cells. */
  277.  
  278.     virtual pascal void DelRowLast(short numOfRows);
  279.                 /* Delete the specified number of rows from the last cell of the list.This causes a
  280.                 redraw of only the necessary cells. */
  281.  
  282.     virtual pascal void EachCellDo(Point startCell, Point stopCell, pascal void (*DoToCell)(Point 
  283.        aCell, void *DoToCell_StaticLink), void *DoToCell_StaticLink);
  284.                 /* For each cell in the rectangle defined by startCell and stopCell perform
  285.                 "DoToCell". */
  286.  
  287.     virtual pascal void EachSelectedCellDo(pascal void (*DoToCell)(Point aCell, void *
  288.        DoToCell_StaticLink), void *DoToCell_StaticLink);
  289.                 /* For each cell in the selected region perform "DoToCell". */
  290.  
  291.     virtual pascal void EachInRgn(RgnHandle aRgn, pascal void (*DoToCell)(Point aCell, void *
  292.        DoToCell_StaticLink), void *DoToCell_StaticLink);
  293.                 /* For each cell in the specified region perform "DoToCell". */
  294.  
  295.     virtual pascal Point FirstSelectedCell(void);
  296.                 /* Returns the top left cell in the selection range, if any */
  297.  
  298.     virtual pascal short GetColWidth(short aCol);
  299.                 /* Return the width  for the specified  column. */
  300.  
  301.     virtual pascal short GetRowHeight(short aRow);
  302.                 /* Return the height for the specified row . */
  303.  
  304.     virtual pascal GridViewPart IdentifyPoint(Point theQDPoint, short *aRow, short *aCol);
  305.                 /* Return the GridViewPart (inCell, inColumn, inRow, inVertex)
  306.                 in which the specified point lies. The "vertex" is the area
  307.                 where a row and column meet. */
  308.  
  309.     virtual pascal void InsColBefore(short aCol, short numOfCols, short aWidth);
  310.  
  311.         /* Insert the specified columns before the column given.The widths of the columns are
  312.                 all set to the specified aWidth. */
  313.  
  314.     virtual pascal void InsRowBefore(short aRow, short numOfRows, short aHeight);
  315.  
  316.         /* Insert the specified rows before the row given.The heights of the rows are all set
  317.                 to the specified aHeight. */
  318.  
  319.     virtual pascal void InsColFirst(short numOfCols, short aWidth);
  320.                 /* Insert the specified number of columns at the beginning of the list.The widths of
  321.                 the columns are all set to the specified aWidth. */
  322.  
  323.     virtual pascal void InsRowFirst(short numOfRows, short aHeight);
  324.  
  325.        /* Insert the specified number of rows at the beginning of the list.The heights of the
  326.                 rows are all set to the specified aHeight. */
  327.  
  328.     virtual pascal void InsColLast(short numOfCols, short aWidth);
  329.                 /* Insert the specified number columns at the end of the list.The widths of the
  330.                 columns are all set to the specified aWidth. */
  331.  
  332.     virtual pascal void InsRowLast(short numOfRows, short aHeight);
  333.  
  334.         /* Insert the specified number of rows at the end of the list.The heights of the rows
  335.                 are all set to the specified aHeight. */
  336.  
  337.     virtual pascal void InvalidateCell(Point aCell);
  338.                 /* Cause a cell to be marked invalid (in need of re-drawing). */
  339.  
  340.     virtual pascal void InvalidateSelection(void);
  341.                 /* Cause the rectangle bounding the selections to be marked
  342.                 invalid (in need of re-drawing). */
  343.  
  344.     virtual pascal Boolean IsCellSelected(Point aCell);
  345.                 /* Check if the specified cell is currently selected. */
  346.  
  347.     virtual pascal Point LastSelectedCell(void);
  348.                 /* Returns the bottom right cell in the selection range, if any */
  349.  
  350.     virtual pascal void ScrollSelectionIntoView(Boolean redraw);
  351.                 /* Scroll the specified rectangle into view. */
  352.  
  353.     virtual pascal void SetColWidth(short aCol, short numOfCols, short aWidth);
  354.                 /* Set the width of the specified columns to that given. */
  355.  
  356.     virtual pascal void SetRowHeight(short aRow, short numOfRows, short aHeight);
  357.                 /* Set the height of the specified rows to that given. */
  358.  
  359.     virtual pascal void SelectCell(Point theCell, Boolean extendSelection, Boolean highlight, 
  360.        Boolean select);
  361.                 /* Set the current selection to the specified cell. Sets up a region and then calls
  362.                 SetSelection. */
  363.  
  364.     virtual pascal void SetEmptySelection(Boolean highlight);
  365.                 /* Set the current selection to be empty or nothing. If highlight is kHighlight then
  366.                 the appropriate highlighting is performed. */
  367.  
  368.     virtual pascal void SetSelection(RgnHandle cellsToSelect, Boolean extendSelection, Boolean 
  369.        highlight, Boolean select);
  370.                 /* Set the current selections to the specified region. If extend is kExtend then
  371.                 cellsToSelect is "added" to that already selected, if highlight is kHighlight then
  372.                 cellsToSelect is highlighted as well. IF select is kSelect then cellsToSelect is
  373.                 selected, if kDeSelect then de-selected*/
  374.  
  375.     virtual pascal void SetSelectionRect(short left, short top, short right, short bottom, Boolean 
  376.        extendSelection, Boolean highlight, Boolean select);
  377.                 /* Set the current selections to the specified rectangle. and call SetSelection. */
  378.  
  379.     virtual pascal void SetSingleSelection(Boolean theSetting);
  380.                 /* If TRUE then only one item/cell can be selected at a time */
  381.  
  382.     virtual pascal Point VPointToCell(VPoint *aPoint);
  383.                 /* Determine the cell in which a given point lies, or (0, 0) if the given point
  384.                 doesn't lie within any cell. */
  385.  
  386.     virtual pascal Point VPointToLastCell(VPoint *aPoint);
  387.  
  388.         /* Returns the cell in which the given point lies, or the last cell of the row/column
  389.                 if the horizontal/vertical coordinate lies beyond the last cell of the row/column.*/
  390.  
  391.                 /*  Debugging Methods     */
  392.  
  393.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  394.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  395.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  396.                 fields. */
  397.  
  398. };
  399.  
  400. class TTextGridView : public TGridView {
  401.   public:        /* A sub-class of TGridView that can handle
  402.                                                          the display of text in its cells. */
  403.     TextStyle fTextStyle;                                /* The text style (color, size, etc. ) */
  404.     short fLineHeight;                                    /* height of each item including leading */
  405.     short fLineAscent;
  406.        /* pos. of baseline relative to top of line */
  407.  
  408.                                 /*  Initialization and Free Methods    */
  409.  
  410.     virtual pascal void ITextGridView(TDocument *itsDocument, TView *itsSuperView, VPoint *
  411.        itsLocation, VPoint *itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short 
  412.        numOfRows, short numOfCols, short rowHeight, short colWidth, Boolean adornRows, Boolean 
  413.        adornCols, short rowInset, short colInset, Boolean singleSelection, TextStyle *itsTextStyle);
  414.        /* size, color, etc.
  415.                     font info */
  416.  
  417.                 /* Initialize the TextGridView. If numOfRows or numOfCols is non-zero then the
  418.                 gridview is initialized to the specified size. The row and height of the cells is
  419.                 determine by the font size, style etc. The default size may be changed with calls
  420.                 to the the SetRowHeight and SetColWidth methods. If either adorn is kDontAdorn,
  421.  
  422.                 then that adorn will not be called. The "Insets" allow space between cells and may
  423.                 be used to draw row and column adornments. */
  424.  
  425.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  426.                 /* Initialize the view template. */
  427.  
  428.     virtual pascal void WRes(ViewRsrcHandle theResource, Ptr *itsParams);
  429.                 /* Write this object out as a view resource. */
  430.  
  431.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  432.                 /* Set up the type and signature of this object and call WRes. */
  433.  
  434.                 /*  Methods To OVERRIDE    */
  435.  
  436.     virtual pascal void GetText(Point aCell, StringPtr aString);
  437.                 /* This routine gets the text to be draw in a given cell. IT MUST BE OVERRIDDEN! */
  438.  
  439.                 /*  General Methods     */
  440.  
  441.     virtual pascal void DrawCell(Point aCell, Rect *aQDRect);
  442.                 /* Calls GetText and then draws the text */
  443.  
  444.     virtual pascal Boolean Focus(void);
  445.                 /* Calls inherited focus and calls SetUpFont */
  446.  
  447.     virtual pascal void SetUpFont(void);
  448.                 /* Sets up the font for this view. */
  449.  
  450.     virtual pascal void SetPen(void);
  451.                 /* Sets the font characteristics of the current port. Called at the beginning of the
  452.                 Draw method.*/
  453.  
  454.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  455.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  456.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  457.                 fields. */
  458.  
  459. };
  460.  
  461. class TTextListView : public TTextGridView {
  462.   public:     /* This subclass of TTextGridView handles
  463.                                                           lists in a manner similar to the List
  464.                                                           Manager in the toolbox. These lists
  465.                                                           typically consist of single columns and
  466.                                                           the case of this subclass handle the
  467.                                                           placeme { Initialization and Free Methods
  468.                                                           */
  469.  
  470.     virtual pascal void ITextListView(TDocument *itsDocument, TView *itsSuperView, VPoint *
  471.        itsLocation, VPoint *itsSize, SizeDeterminer itsHSizeDet, SizeDeterminer itsVSizeDet, short 
  472.        numOfItems, short rowHeight, short colWidth, Boolean adornRows, Boolean adornCols, short 
  473.        rowInset, short colInset, Boolean singleSelection, TextStyle *itsTextStyle);
  474.  
  475.                 /* Initialize the TextListView. If numOfItems is non-zero then the listview is
  476.                 initialized to the specified size. The width and height of the items are determined
  477.                 by the font size, style etc. The default size may be changed with calls to the the
  478.                 SetItemHeight and SetItemWidth methods. The "Insets" allow space between items. */
  479.  
  480.     virtual pascal void WriteRes(ViewRsrcHandle theResource, Ptr *itsParams);
  481.                 /* Set up the type and signature of this object and call WRes. */
  482.  
  483.                 /*  Methods To OVERRIDE    */
  484.  
  485.     virtual pascal void GetItemText(short anItem, StringPtr aString);
  486.                 /* Get the text to be drawn for a given item. THIS METHOD MUST BE OVERRIDDEN !! */
  487.  
  488.     virtual pascal Boolean CanSelectItem(short anItem);
  489.                 /* Determine if the item is selectable */
  490.  
  491.                 /*  General Methods     */
  492.     virtual pascal void AllItemsDo(pascal void (*DoToItem)(short anItem, void *DoToItem_StaticLink)
  493.        , void *DoToItem_StaticLink);
  494.                 /* For all the items in the view perform "DoToItem". */
  495.  
  496.     virtual pascal Boolean CanSelectCell(Point aCell);
  497.                 /* This method checks to see if a cell can be selected. This method simply calls
  498.                 CanSelectItem */
  499.  
  500.     virtual pascal void DelItemAt(short anItem, short numOfItems);
  501.                 /* Delete the specified items.  This causes a redraw of only the necessary cells. */
  502.  
  503.     virtual pascal void DelItemFirst(short numOfItems);
  504.                 /* Delete the specified items.  This causes a redraw of only the necessary cells. */
  505.  
  506.     virtual pascal void DelItemLast(short numOfItems);
  507.                 /* Delete the specified items.  This causes a redraw of only the necessary cells. */
  508.  
  509.     virtual pascal void EachItemDo(short start, short stop, pascal void (*DoToItem)(short anItem, 
  510.        void *DoToItem_StaticLink), void *DoToItem_StaticLink);
  511.                 /* For each item in the specified range perform "DoToItem". */
  512.  
  513.     virtual pascal void EachSelectedItemDo(pascal void (*DoToItem)(short anItem, void *
  514.        DoToItem_StaticLink), void *DoToItem_StaticLink);
  515.                 /* For each item selected perform "DoToItem". */
  516.  
  517.     virtual pascal short GetItemHeight(short anItem);
  518.                 /* Return the height of the specified item. */
  519.  
  520.     virtual pascal short GetItemWidth(void);
  521.                 /* Return the width of the view. */
  522.  
  523.     virtual pascal void GetText(Point aCell, StringPtr aString);
  524.                 /* Calls GetItemText with an item number. */
  525.  
  526.     virtual pascal void InsItemBefore(short anItem, short numOfItems);
  527.                 /* Insert numOfItems before anItem in the list. */
  528.  
  529.     virtual pascal void InsItemFirst(short numOfItems);
  530.                 /* Insert numOfItems at the beginning of the list. */
  531.  
  532.     virtual pascal void InsItemLast(short numOfItems);
  533.                 /* Insert numOfItems at the  end of the list. */
  534.  
  535.     virtual pascal Boolean IsItemSelected(short anItem);
  536.                 /* Check if the specified item is currently selected. */
  537.  
  538.     virtual pascal void Resize(VCoordinate width, VCoordinate height, Boolean invalidate);
  539.                 /* Resize the view. */
  540.  
  541.     virtual pascal void SelectCell(Point theCell, Boolean extendSelection, Boolean highlight, 
  542.        Boolean select);
  543.                 /* Calls SelectItem with the appropriate item number */
  544.  
  545.     virtual pascal void SelectItem(short anItem, Boolean extendSelection, Boolean highlight, Boolean
  546.         select);
  547.                 /* Select the given item. If extend is true then the item is added to the current
  548.                 selection. Otherwise the current selection is deselected. If highlight is true then
  549.                 the selected item is highlighted.*/
  550.  
  551.     virtual pascal void SetItemHeight(short anItem, short numOfItems, short aHeight);
  552.                 /* Set the height of an item to be different from the default.  This
  553.                 changes the height of only the specified items. */
  554.  
  555.     virtual pascal void SetItemWidth(short aWidth);
  556.                 /* Set the width of the view to aWidth.  (This changes the width of all
  557.                 the items. */
  558.  
  559.     virtual pascal short FirstSelectedItem(void);
  560.                 /* Returns the first item selected. */
  561.  
  562.     virtual pascal short LastSelectedItem(void);
  563.                 /* Returns the last item selected. */
  564.  
  565.     virtual pascal void InvalidateItem(short anItem);
  566.                 /* Invalidates the given item, causing it to be redrawn */
  567.  
  568.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  569.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  570.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  571.                 fields. */
  572.  
  573. };
  574.  
  575. class TCellSelectCommand : public TCommand {
  576.   public:
  577.     TGridView *fGridView;                                /* The associated GridView */
  578.     Boolean fShiftKey;                                    /* Shift Key down? */
  579.     Boolean fCmdKey;                                    /* Command Key down? */
  580.     Boolean fDeselecting;
  581.     Point fAnchorCell;
  582.     Point fPrevCell;
  583.     RgnHandle fThisSelection;
  584.     RgnHandle fPrevSelection;
  585.     RgnHandle fDifference;
  586.  
  587.     virtual pascal void ICellSelectCommand(TGridView *itsView, Boolean theShiftKey, Boolean 
  588.        theCmdKey);
  589.                 /* Initialize the command object. */
  590.  
  591.     virtual pascal void Free(void);
  592.                 /* If the region fPrevSelection and fDifference are not NIL then dispose of them
  593.                 before calling inherited Free. */
  594.  
  595.     virtual pascal void TrackFeedback(VPoint *anchorPoint, VPoint *nextPoint, Boolean turnItOn, 
  596.        Boolean mouseDidMove);
  597.                 /* Override this method to give feedback while the mouse button is down. The default
  598.                 does nothing. */
  599.  
  600.     virtual pascal TCommand *TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
  601.        previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
  602.                 /* Track the mouse when the button is down. */
  603.  
  604.     virtual pascal void DoIt(void);
  605.                 /* The method that will do the actual task to be performed by the command.  MUST BE
  606.                 OVERRIDDEN. */
  607.  
  608.     virtual pascal void ComputeAnchorCell(Point *clickedCell);
  609.                 /* Computes the cell that the mouse is first clicked in when making a selection. */
  610.  
  611.     virtual pascal void ComputeNewSelection(Point *clickedCell);
  612.                 /* Calculate what the new selection should be. */
  613.  
  614.     virtual pascal void HighlightNewSelection(void);
  615.                 /* Highlight the new selection. */
  616.  
  617.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  618.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  619.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  620.                 fields. */
  621.  
  622. };
  623.  
  624. class TRCSelectCommand : public TCellSelectCommand {
  625.   public:
  626.             /* An abstract superclass for row and column selection */
  627.  
  628.     virtual pascal void ComputeNewSelection(Point *clickedCell);
  629.                 /* Computes the new selection. */
  630.  
  631.     virtual pascal TCommand *TrackMouse(TrackPhase aTrackPhase, VPoint *anchorPoint, VPoint *
  632.        previousPoint, VPoint *nextPoint, Boolean mouseDidMove);
  633.                 /* Track the mouse during selection. */
  634.  
  635.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  636.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  637.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  638.                 fields. */
  639.  
  640. };
  641.  
  642. class TRowSelectCommand : public TRCSelectCommand {
  643.   public:
  644.    /* A subclass that performs selections on
  645.                                                              rows. */
  646.     virtual pascal void IRowSelectCommand(TGridView *itsView, Boolean theShiftKey, Boolean theCmdKey
  647.        );
  648.                 /* Initialization of command. */
  649.  
  650.     virtual pascal void ComputeAnchorCell(Point *clickedCell);
  651.                 /* Override of method to perform computations specific to row selection. */
  652.  
  653.     virtual pascal void ComputeNewSelection(Point *clickedCell);
  654.                 /* Override of method to perfom computation of new selection specific to row
  655.                 selection. */
  656.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  657.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  658.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  659.                 fields. */
  660.  
  661. };
  662.  
  663. class TColumnSelectCommand : public TRCSelectCommand {
  664.   public:
  665.    /* A subclass that handles the selection
  666.                                                               of columns in a GridView. */
  667.     virtual pascal void IColumnSelectCommand(TGridView *itsView, Boolean theShiftKey, Boolean 
  668.        theCmdKey);
  669.                 /* Initialization method. */
  670.  
  671.     virtual pascal void ComputeAnchorCell(Point *clickedCell);
  672.                 /* Override of method to perform computations specific to column selection. */
  673.  
  674.     virtual pascal void ComputeNewSelection(Point *clickedCell);
  675.                 /* Override of method to perform computation of new selection specific to column
  676.                 selection. */
  677.  
  678.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  679.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  680.                 /* Used by the Inspector and the Debugger to display the contents of this class's
  681.                 fields. */
  682.  
  683. };
  684.         /* These are intended to be private, but are in the interface so that you can use these
  685.         regions if you override the methods that use them. */
  686.  
  687. extern pascal RgnHandle pPixelsToHighlight;                /* Used by HighlightCells */
  688. extern pascal RgnHandle pPreviousSelection;                /* Used by SetSelection */
  689. extern pascal RgnHandle pDifference;                    /* Used by SetSelection */
  690. extern pascal RgnHandle pVisibleCells;                    /* Used by CellsToPixels */
  691. extern pascal RgnHandle pInvalidateRgn;                    /* Used by InvalidateSelection */
  692.  
  693. extern pascal void InitUGridView(void);
  694.                 /* Creates all the regions used by the GridView class and then sets the global flag
  695.                 'gUGridViewInitialized'. */
  696.  
  697. #endif
  698.  
  699.