home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dokpr1.zip / mesamod.h < prev    next >
C/C++ Source or Header  |  1995-10-02  |  19KB  |  494 lines

  1. /**************************************************************************
  2.  *                                                                        *
  3.  *                                                                        *
  4.  *          This code is copyright (c) 1994                               *
  5.  *                     Athena Design, Inc.                                *
  6.  *                                                                        *
  7.  *                                                                        *
  8.  *                ALL RIGHTS RESERVED                                     *
  9.  *                                                                        *
  10.  *                                                                        *
  11.  *                                                                        *
  12.  *                                                                        *
  13.  *                                                                        *
  14.  **************************************************************************/
  15.  
  16. /*
  17.     This class wraps the internal MModel class in a SOM wrapper.
  18.     This is so that a newer version of the DLL's can be placed "under"
  19.     an existing client application.  We would do MModel as a SOM class,
  20.     exception for the nasty overhead problems with SOM.
  21.  
  22.     6-25-94
  23.  
  24.     added support for changing fonts in an atomic operations 8/20/94 dpp
  25.     94-08-24 - dpp - support for column and row sizing
  26.     94-08-28 - dpp - included "rect.h"
  27.     94-08-31 dpp added the createGraph() method
  28.     94-09-03 dpp added isFrameAt()
  29.     94-09-11 dpp changed this module to support MSelection's
  30.     94-09-17 dpp added frameAtPoint()
  31.     94-09-18 dpp added colorDroppedOnFrameAt(), fontDroppedOnFrameAt(), and
  32.         bkgColorDroppedOnFrameAt()
  33. */
  34.  
  35. #ifndef _MH_MesaModel
  36.  
  37. #define _MH_MesaModel
  38.  
  39. #include "address.h"
  40. #include "action.h"
  41.  
  42. #include "os2h.h"
  43.  
  44. #include "color.h"
  45. #include "object.h"
  46.  
  47. // if we're not in the "dll" we only need pointers to certain classes
  48. #ifdef IN_DLL
  49. #include "model.h"
  50. #else
  51. class MModel;
  52. class MRect;
  53. class MPoint;
  54. class MEditString;
  55. #endif
  56.  
  57. class MFormat;
  58. class MRange;
  59. class MInterest;
  60. class MClipStream;
  61. class MException;
  62. class MGController;
  63. class MFont;
  64. class MSelection;
  65. class MImage;
  66. class MPrintHead;
  67. class MDraw;
  68. class MFrameXfer;
  69. class MFrame;
  70. class MPosition;
  71. class MPassword;
  72. #if defined(M2Z) //  || defined(M2NT)
  73. class MDDEClientItem;
  74. #endif
  75. class MPrintInfo;
  76.  
  77. #ifndef RULERWID
  78. // HARDWIRE - size of the rulers in a basic spreadsheet screen
  79. #define RULERWID 36
  80. #define RULERHI 18
  81.  
  82. // ifndef RULERWID
  83. #endif
  84.  
  85.  
  86. class MMesaModel : public MObject
  87. {
  88.     public:
  89.  
  90.     MMesaModel();
  91.     virtual ~MMesaModel();
  92.  
  93.     virtual void drawInto(MDraw *,const MRect *page,const MRect *area,
  94.              const MAddress *left, const MSelection *sel,int flags,
  95.             const MSelection *key = 0, float colhi = RULERHI,
  96.             float rowwid = RULERWID, int numTitle = -1,
  97.             const char **titles = NULL,const MAddress *inCell = NULL,
  98.             MEditString *es = NULL );
  99.  
  100.     void drawInCell(MDraw *md, const MAddress * left,int flags, float RulerHi, float RulerWid,
  101.             const MAddress * inCell, MEditString *es);
  102.  
  103.  
  104.     int clipGraphsFromMDraw(MDraw *md, const MRect *rct, const MAddress *left,
  105.               int flags);
  106.     void drawGraphsIntoMDraw(MDraw *md, const MRect *rct, const MAddress *left,
  107.                const MSelection *theSel, int flags);
  108.  
  109.  
  110.     virtual void rangeToStr(const MRange *ra,const MAddress *ad,char *&tmp,int &max);
  111.  
  112.     virtual void setCellToString(const MAddress *a1,const char *s,int action,
  113.         MException *me,const MSelection *);
  114.  
  115.     virtual void setCellToStringOrNumber(const MAddress *a1,const char *s,int action,
  116.         MException *me,const MSelection *);
  117.  
  118.     virtual int whichVisibleCol(int layer,int c);
  119.     virtual int whichVisibleRow(int layer,int r);
  120.     virtual int getNthVisibleCol(int layer,int n);
  121.     virtual int getNthVisibleRow(int layer,int n);
  122.     virtual int getLastVisibleCol(int layer);
  123.     virtual int getLastVisibleRow(int layer);
  124.     virtual void getNumVisible(int layer,int &nRows,int &nCols);
  125.  
  126.     virtual void getExtents(int layer,int &mr,int &mc);
  127.  
  128.     virtual void setExtents(int layer,int mr,int mc,int action,
  129.         const MSelection *,MException *me);
  130.  
  131.     virtual void adToStr(const MAddress *ad,char *s,int layer);
  132.  
  133.     virtual int isAddress(const char *,const MAddress *,MAddress *,int &len);
  134.     virtual int doesCellExist( const MAddress * );
  135.     virtual int isCellNonBlank( const MAddress * );
  136.     
  137.     virtual void getRectForAd(const MAddress *left,const MAddress *ad,MRect *re);
  138.  
  139.     virtual void getRectForRangeAd(const MAddress *left,const MAddress *ul,const MAddress *lr,
  140.         MRect *re);
  141.  
  142.     virtual void getRectForRange(const MAddress *left,const MRange *ra,MRect *re);
  143.     virtual int getRectForFrame(const MAddress *left,const char *,MRect *re);
  144.  
  145.     virtual void setRangeToFormat(const MRange *ra,const MFormat *fo,
  146.         int action,const MSelection *,MException *me);
  147.  
  148.     virtual void setRangeToFont(const MRange *ra,const MFont *fo,
  149.         int action,const MSelection *,MException *me);
  150.  
  151.     virtual void moveCells(const MRange *rtm,const MAddress * offset,int action,
  152.         MException *me,const MSelection *);
  153.     virtual void copyCells(const MRange *rtm,const MAddress * offset,int action,
  154.         MException *me,const MSelection *);
  155.  
  156.     virtual void autoRange(const MRange *ra,int type,const MSelection *,int action,MException *me);
  157.  
  158.     virtual void convertRange(const MRange *ra,int type,const MSelection *,
  159.         int action,MException *me);
  160.  
  161.     virtual void clearSpecialRange(const MRange *ra,int type,const MSelection *,
  162.         int action,MException *me);
  163.  
  164.     virtual void clearRange(const MRange *rp,const MSelection *,
  165.         int action,MException *me);
  166.  
  167.     virtual void clear(const MSelection *rp,const MSelection *,
  168.         int action,MException *me);
  169.  
  170.     virtual void fillSmartWithCell(const MAddress * cad,const MRange *cra,int action,
  171.         const MSelection *,MException *me);
  172.  
  173.     virtual void fillWithCell(const MAddress * cad,const MRange *cra,int action,
  174.         const MSelection *,MException *me);
  175.  
  176.     virtual void fillSmartRight(const MRange *cra,int action,
  177.         const MSelection *,MException *me);
  178.  
  179.     virtual void fillSmartDown(const MRange *cra,int action,
  180.         const MSelection *,MException *me);
  181.  
  182.     virtual void fillRight(const MRange *cra,int action,const MSelection *,
  183.         MException *me);
  184.  
  185.     virtual void fillDown(const MRange *cra,int action,
  186.         const MSelection *,MException *me);
  187.  
  188.     // set the size of all the rows or columns in the input range to the
  189.     // size in the second parameter 94-08-24 dpp
  190.     // if the size == -1, reset the size
  191.     // if size == -2, hide the row or column
  192.     // if size == -3, unhide the row or column
  193.     // if size == -4, set the page break
  194.     // if size == -5, clear the page break
  195.  
  196.     virtual void setColumnSize(const MRange *,int,const MSelection *,int,MException *);
  197.     virtual void setRowSize(const MRange *,int,const MSelection *,int,MException *);
  198.     
  199.     virtual int getColumnSize(int layer,int column);
  200.     virtual int getRowSize(int layer,int row);
  201.  
  202.     virtual int isRowHidden(int layer,int row);
  203.     virtual int isColHidden(int layer,int col);
  204.  
  205.  
  206.     virtual MAddress addressFromPoint(const MAddress * left,const MPoint *po,int clip = 1);
  207.  
  208.     virtual void setUp(MGController *gc);
  209.  
  210.     virtual void cleanUp(MGController *gc);
  211.  
  212.     virtual void setPathName(const char *s,int action);
  213.  
  214.     virtual void loadFromPath(int action,MException *me);
  215.     virtual void loadFromStream(MStream *ms,int action,MException *me);
  216.  
  217.     virtual char *getPathName();
  218.  
  219.     virtual int getHasPath();
  220.  
  221.     virtual void setHasPath(int i);
  222.  
  223.     virtual void unregisterInterest(MInterest *mi);
  224.  
  225.     virtual void registerInterest(MInterest *mi);
  226.  
  227.     virtual void saveToPath(MException *me);
  228.     
  229.     virtual void saveToStream(MStream *ms,MException *me);
  230.  
  231.     virtual int getHasChanged();
  232.  
  233.     virtual int getInterestCount();
  234.  
  235.     virtual int isMultiRange(const char *s,const MAddress * a1,MRange *ra,int &len);
  236.  
  237.     virtual int getUndoCnt();
  238.  
  239.     virtual int getRedoCnt();
  240.  
  241.     virtual void recalc(const MAddress *,int action);
  242.     virtual void recalcRange(const MAddress *,const MRange *,int action);
  243.     virtual void redisplay();
  244.  
  245.     virtual int undoLastCommand(const MSelection *,
  246.         int action,MSelection *);
  247.  
  248.     virtual int redoLastCommand(const MSelection *,
  249.         int action,MSelection *);
  250.  
  251.     virtual void copy(const MSelection *,int type,MClipStream *mcs);
  252.  
  253.     virtual void cut(const MSelection *,int type,MClipStream *mcs,
  254.         const MSelection *,int action,MException *me);
  255.  
  256.     virtual void paste(const MSelection *,int type,MClipStream *mcs,
  257.         const MSelection *,int action,MException *me);
  258.  
  259.     virtual char *getCellString(const MAddress * ad);
  260.     virtual char *getCellValue(const MAddress * ad);
  261.     virtual char **getLayerNames(int &);
  262.     virtual int getNumLayers();
  263.     virtual char *getLayerName(int);
  264.     virtual void newLayer(int,MException *,const MSelection *);
  265.     virtual void deleteLayer(int layer,int action,MException *,const MSelection *);
  266.     virtual void setLayerName(int lay,const char *newName,int action,const MSelection *);
  267.  
  268.     virtual void doGridBorder(const MSelection *,int type,int action,
  269.         const MSelection *,MException *);
  270.  
  271.     virtual int getHasFeed();
  272.  
  273.     virtual void setHasChanged(int i);
  274.  
  275.     virtual int getRulerWid();
  276.     virtual int getRulerHi();
  277.  
  278.     virtual char *getScript(const char *);
  279.     virtual int hasCloseScripts();
  280.     virtual void executeCloseScripts();
  281.     virtual void executeOpenScripts();
  282.     virtual int getScriptInfo(const char *);
  283.     virtual void setScriptInfo(const char *,int,int action,const MSelection *);
  284.  
  285.     // get the text of a script for a given layer number
  286.     virtual char *getScriptNum(int);
  287.     virtual void setScript(const char *name,const char *script,int info,int action,
  288.         const MSelection *);
  289.     virtual void deleteScript(const char *,int action,const MSelection *);
  290.     virtual char **getScriptNames(int &);
  291.     virtual char *getNextScriptName();
  292.     virtual int getNumScripts();
  293.     virtual char *getScriptName(int);
  294.     virtual void setScriptName(int,const char *,int action,const MSelection *);
  295.  
  296.     virtual char **getCurSymbols();
  297.     virtual void setCurSymbols(char **,int action,const MSelection *);
  298.  
  299.     // get the number of the font from the model
  300.     // add the font if it's not already in the list
  301.     virtual int getFontNum(const MFont *);
  302.  
  303.     // create a graph and return the name of the graph (which must be free'd)
  304.     // the rect is the offset from the "anchor" cell.
  305.     // The type is the graph type (see MFrame for a list)
  306.     // data is the range where the graph draws its data, action is the action to take
  307.     // and MAddress and MRange are the current selection
  308.     // 94-08-31 dpp
  309.     virtual char *createGraph(MRect *,const MAddress *anchor,int type,
  310.         const MRange *data,int action,const MSelection *);
  311.  
  312.     virtual MFrameXfer *getFrameInfo(const char *);
  313.     virtual void setFrameInfo(const char *,const MFrameXfer *,int action,const MSelection *);
  314.     virtual void setFrameToType(const char *,int type,int action,const MSelection *);
  315.     virtual int getCornerForFrame(const char *,const MAddress *,const MPoint *);
  316.     virtual void setFrameOrder(const char *frame,int order,int action,const MSelection *);
  317.     virtual char **getFrameNames(int &);
  318.  
  319.  
  320.     // add an image in a frame
  321.     // 94-09-22 dpp
  322.     virtual char *addImage(const MPoint *,const MAddress *anchor,MImage *,
  323.         int action,const MSelection *);
  324.  
  325.     virtual char *addFrame(const MPoint *,const MAddress *anchor,MFrame *,
  326.         int action,const MSelection *);
  327.  
  328.     virtual void newShape(int type,const MAddress *offset,const MRect *re,
  329.         int lWid,int arrow,int action,const MSelection *sel);
  330.  
  331.     // check to see if there is a graph in a certain rectangle (offset from cell A1)
  332.     // on a given layer.  This routine is used to check to see if it's okay to put a
  333.     // graph at a given rectangle
  334.     // 94-09-03 dpp
  335.     virtual int isFrameAt(int layer,const MRect *);
  336.  
  337.     // tries to find a graph at the given point.  If one is found, set the graph name
  338.     // in the char ** (this must be MFree'd) and return 1.  If 0 is returned, no matching
  339.     // graph was found and no freeing is necessary
  340.     // 94-09-17 dpp
  341.     virtual int frameAtPoint(const MAddress *,const MPoint *,char **);
  342.  
  343.     // drop stuff on a frame
  344.     // 94-09-18 dpp
  345.     virtual void colorDroppedOnFrameAt(MColor,const char *,const MAddress *,
  346.         const MPoint *,const MSelection *,int);
  347.     virtual void bkgColorDroppedOnFrameAt(MColor,const char *,const MAddress *,
  348.         const MPoint *,const MSelection *,int);
  349.     virtual void fontDroppedOnFrameAt(const MFont *,const char *,const MAddress *,
  350.         const MPoint *,const MSelection *,int);
  351.  
  352.     virtual char *getLabel(int,MRange *);
  353.     virtual int numberOfLabels();
  354.     virtual char **getLabelNames(int &);
  355.     virtual void setLabel(const char *,const MRange *,int action,const MSelection *);
  356.     virtual void deleteLabel(const char *,int action,const MSelection *);
  357.     virtual int findLabel(const char *,MRange *);
  358.  
  359.     virtual void setLayerColor(int layer,MColor,int type,int action,const MSelection *,
  360.         MException *me);
  361.  
  362.     virtual void setUndoMax(int);
  363.     virtual int getUndoMax();
  364.  
  365.     virtual int getLayerProtection(int);
  366.     virtual void setLayerProtection(int,int,int action,const MSelection *);
  367.  
  368.     virtual int getLayerGrid(int);
  369.     virtual void setLayerGrid(int,int,int action,const MSelection *);
  370.  
  371.     virtual void getDefaultCellSize(int,int &,int &);
  372.     virtual void setDefaultCellSize(int layer,int wid,int hi,int action,const MSelection *);
  373.  
  374.     virtual int getAutoRecalc();
  375.     virtual void setAutoRecalc(int,int action,const MSelection *);
  376.     virtual int getRecalcType();
  377.     virtual void setRecalcType(int,int action,const MSelection *);
  378.     virtual int getRecalcIterations();
  379.     virtual void setRecalcIterations(int,int action,const MSelection *);
  380.  
  381.     virtual int getFormatAndFontForCell(const MAddress *,MFormat *,MFont *);
  382.  
  383.     virtual void print(MDraw *,const MRect *,const MPrintHead *,int start,int end,MException *);
  384.  
  385.     virtual void print_nonThreaded(MDraw *,const MRect *,const MPrintHead *,
  386.         int start,int end,MException *);
  387.  
  388.     virtual void getDefaultPrintHead(MPrintHead *);
  389.  
  390.     virtual void setDefaultPrintHead(const MPrintHead *,int action,const MSelection *);
  391.  
  392.     virtual void setFontAttribute(int attrib,const MRange *,int action,const MSelection *,
  393.         MException *);
  394.     virtual void setFont(const char *,int size,const MRange *,int action,const MSelection *,
  395.         MException *);
  396.  
  397.         // changes the row/column header fonts
  398.         virtual void setFontForLayer( int layer, const MFont *, int action, const MSelection *,
  399.                 MException * );
  400.  
  401.     virtual void importText(MStream *,const MAddress *,int,const MSelection *,MException *);
  402.     virtual void importDelimitedText(MStream *ms,const MAddress *ad,int action,const MSelection *sel,MException *me,int);
  403.  
  404.     virtual void setPosition(const MPosition *);
  405.     virtual MPosition *getPosition();
  406.  
  407.     virtual MAddress find(const char *string,int flags,int order,const MRange *range,
  408.         const MAddress *start);
  409.     virtual void replace( const char *find, const char *repl, int flags, int, const MAddress *, MException *, const MSelection * );
  410.     virtual void replaceAll( const char *find, const char *repl, int flags, int, const MRange *, MException *, const MSelection * );
  411.  
  412.     virtual void sort(const MRange *ra,int hasTitles,int byCol,int numKey,int *keys,int *order,
  413.         int action,const MSelection *sel,MException *);
  414.  
  415.     virtual int getFileType();
  416.     virtual void setFileType( int );
  417.     
  418.     virtual MPassword *getPassword();
  419.  
  420. #if defined(M2Z) // || defined(M2NT)
  421.     virtual int getNumDDEItems();
  422.     virtual MDDEClientItem *getDDEItem( int i );
  423.     
  424.     virtual void addDDEItem( const char *, const char *, const char *, const char *, const char *, int action, const MSelection *, MException * );
  425.     virtual void deleteDDEItem( int, int action, const MSelection *, MException * );
  426.     
  427.     virtual MDDEClientItem *getNewDDEClientItem();
  428. // #if defined(M2Z) || defined(M2NT)
  429. #endif
  430.     virtual void getScale( float *scArray );
  431.     virtual void setScale( float *scArray );
  432.  
  433.     virtual void duplicateFrame( const char *, const MPoint *, const char *, int,
  434.         const MSelection * );
  435.  
  436.     virtual int frameHasText( const char *frame );
  437.     virtual char *getFrameText( const char *frame );
  438.     virtual void setFrameText( const char *frame, char *text, int action, const MSelection *sel );
  439.  
  440.     virtual void setBlobValue(const char *name,int len,const void *blob);
  441.     virtual int getBlobValue(const char *name,int &len, void *&blob);
  442.     
  443.     virtual int setCellToAddInValue(void *,int action);
  444.     virtual void getCellValueToAddInValue(void *);
  445.     
  446.     virtual int shouldAutoGrow(const MAddress *,const MRange *);
  447.     virtual void autoGrow(const MAddress *,const MRange *,int action,const MSelection *,
  448.         MException *);
  449.     virtual MPrintInfo *createPrintInfo(const MRect *ire,const MPrintHead *ph);
  450.     virtual void doPage(MDraw *,const MRect *,const MAddress *,const MAddress *,const MPrintHead *,
  451.         int thisPage,int totPage,double time, int precise=1);
  452.  
  453.     virtual void findPriorCellInRow( int, const MAddress *, MAddress * );
  454.     virtual void findNextCellInRow( int, const MAddress *, MAddress * );
  455.     virtual void findPriorCellInCol( int, const MAddress *, MAddress * );
  456.     virtual void findNextCellInCol( int, const MAddress *, MAddress * );
  457.     virtual void findLowerRightCell( MAddress * );
  458.  
  459.     virtual void smartSizeRows( const MRange *, int, const MSelection *, MException * );
  460.     virtual void smartSizeColumns( const MRange *, int, const MSelection *, MException * );
  461.  
  462.     private:
  463.     MModel *theModel;
  464. };
  465.  
  466. // flags for drawing the worksheet
  467. const int hideRowsDrawFlag = 1;
  468. const int hideColsDrawFlag = 2;
  469. const int noCurCellDrawFlag = 4;
  470. const int noSelRangeDrawFlag = 8;
  471. const int noGraphsDrawFlag = 16;
  472. const int printingDrawFlag = 32;
  473. const int preciseDrawFlag = 64;
  474. const int showGridDrawFlag = 128;
  475. const int dontLockDrawFlag = 256;
  476. const int onlyFramesDrawFlag = 512;
  477. const int drawPreciseGraphs = 1024;
  478. const int drawOnlyNonSolidGraphs = 2048;
  479. const int dontClipGraphsFlag     = 4096;
  480.  
  481. // variables for layer color settings
  482. const int bkgColorLayer = 0;
  483. const int rulerColorLayer = 1;
  484. const int gridColorLayer = 2;
  485. const int tabColorLayer = 3;
  486.  
  487.  
  488. // used to store the maximum row height/column width values...
  489. #define MAXROWSIZE    400
  490. #define MAXCOLSIZE    600
  491.  
  492. // ifndef _MH_MesaModel
  493. #endif
  494.