home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / tool / database / cktbl / cktbl.h_ / cktbl.h
C/C++ Source or Header  |  1994-06-27  |  19KB  |  382 lines

  1. /*------------------------------------------------------------------------------
  2.  *  CKTBL.DLL   Table Control for Windows
  3.  *  Copyright(C) 1994 by CK Softwareentwicklung
  4.  *
  5.  *  File: cktbl.h
  6.  *
  7.  *----------------------------------------------------------------------------*/
  8. #ifndef CKTBL_H
  9. #define CKTBL_H
  10.  
  11. #define CKTBL_CLASS         "CKTBL16"
  12. #define CKTBL_VBX_CLASS     "CKTBL16V"
  13.  
  14. #ifndef CKTBL_NOCOLORS
  15. #define CLR_BLACK           RGB(0,0,0)
  16. #define CLR_DARKGRAY        RGB(128,128,128)
  17. #define CLR_LIGHTGRAY       RGB(192,192,192)
  18. #define CLR_WHITE           RGB(255,255,255)
  19.  
  20. #define CLR_BLUE            RGB(0,0,255)
  21. #define CLR_GREEN           RGB(0,255,0)
  22. #define CLR_CYAN            RGB(0,255,255)
  23. #define CLR_RED             RGB(255,0,0)
  24. #define CLR_PINK            RGB(255,0,255)
  25. #define CLR_YELLOW          RGB(255,255,0)
  26. #endif
  27.            
  28. #ifdef CKTBL_LIBRARY                
  29. #define CKAPI               FAR __cdecl 
  30. #define CKCALLBACK          CALLBACK  
  31. #else                
  32. #define CKAPI               FAR __cdecl __loadds
  33. #define CKCALLBACK          CALLBACK __loadds                 
  34. #endif
  35.                  
  36. /*------------------------------------------------------------------------------
  37.     CKTBL Messages
  38. ------------------------------------------------------------------------------*/
  39.  
  40. #define CKTBL_BASEID                WM_USER
  41.  
  42. #define CKTBL_EDIT_START            CKTBL_BASEID + 100
  43. #define CKTBL_EDIT_END              CKTBL_BASEID + 101 
  44. #define CKTBL_EDIT_CANCELLED        CKTBL_BASEID + 102
  45.  
  46. #define CKTBL_SET_SELECTION         CKTBL_BASEID + 110
  47. #define CKTBL_ADD_SELECTION         CKTBL_BASEID + 111
  48. #define CKTBL_EXTEND_SELECTION      CKTBL_BASEID + 112
  49.  
  50. #define CKTBL_RESIZE_COLUMN_START   CKTBL_BASEID + 140
  51. #define CKTBL_RESIZE_COLUMN_END     CKTBL_BASEID + 141
  52. #define CKTBL_RESIZE_ROW_START      CKTBL_BASEID + 142
  53. #define CKTBL_RESIZE_ROW_END        CKTBL_BASEID + 143
  54.  
  55. #define CKTBL_CHANGED_CURRENTCELL   CKTBL_BASEID + 150
  56. #define CKTBL_CHANGED_SELECTION     CKTBL_BASEID + 151
  57. #define CKTBL_CLICKED_CELL          CKTBL_BASEID + 152
  58. #define CKTBL_DOUBLECLICKED_CELL    CKTBL_BASEID + 153
  59.  
  60. #define CKTBL_CHANGE_CURSOR         CKTBL_BASEID + 160
  61.                             
  62. #define CKTBL_HSCROLL_BEGIN         CKTBL_BASEID + 170  
  63. #define CKTBL_HSCROLL_END           CKTBL_BASEID + 171                            
  64. #define CKTBL_VSCROLL_BEGIN         CKTBL_BASEID + 172                            
  65. #define CKTBL_VSCROLL_END           CKTBL_BASEID + 173                            
  66.                            
  67.                             
  68.  
  69. /*------------------------------------------------------------------------------ 
  70.  *  passed as wParam of CKTBL_CHANGE_CURSOR message
  71.  *----------------------------------------------------------------------------*/
  72.  
  73. #define CKTBL_CURSOR_NULL           0
  74. #define CKTBL_CURSOR_STD            1
  75. #define CKTBL_CURSOR_RESIZE_ROW     2
  76. #define CKTBL_CURSOR_RESIZE_COL     3  
  77.  
  78. /*------------------------------------------------------------------------------
  79.  *  CKTBL Flags
  80.  *----------------------------------------------------------------------------*/
  81.  
  82. #define CKTBL_RESIZE_ROWS           0x00000001l     /* allow user to resize rows */
  83. #define CKTBL_RESIZE_COLUMNS        0x00000002l     /* allow user to resize columns */
  84.  
  85. #define CKTBL_EDIT_ROW_LABELS       0x00000004l     /* allow user to edit row labels */
  86. #define CKTBL_EDIT_COLUMN_LABELS    0x00000008l     /* allow user to edit column labels */
  87. #define CKTBL_EDIT_CELLS            0x00000010l     /* allow user to edit cells */
  88.  
  89. #define CKTBL_SHOW_GRID             0x00000020l     /* show grid */
  90. #define CKTBL_SHOW_SELECTION        0x00000040l     /* show selection */
  91.  
  92. #define CKTBL_SELECT_ALL            0x00000080l     /* allow selecting all cells */
  93. #define CKTBL_SELECT_CELLS          0x00000100l     /* allow selecting cells */
  94. #define CKTBL_SELECT_ROWS           0x00000200l     /* allow selecting full rows */
  95. #define CKTBL_SELECT_COLUMNS        0x00000400l     /* allow selecting full columns */
  96.  
  97. #define CKTBL_EXTENDED_SELECT       0x00000800l     /* allow selecting a range of cells at once */
  98. #define CKTBL_SHIFT_SELECT          0x00001000l     /* allow extending selections using shift-key */
  99. #define CKTBL_CONTROL_SELECT        0x00002000l     /* allow multiple selections usgin control-key */
  100.  
  101. #define CKTBL_HSCROLL               0x00004000l     /* enable horizontal scroll bar */
  102. #define CKTBL_VSCROLL               0x00008000l     /* enable vertical scroll bar */
  103.                                             
  104. #define CKTBL_AUTOROWHEIGHT         0x00010000l     /* adjust row height when changing text, or fonts */
  105.                      
  106. #define CKTBL_HSCROLL_MASK          0x00020000l     /* horizontal scroll mode */
  107. # define CKTBL_HSCROLL_EXTRA        0x00000000l     /* scroll into gray area past last column */
  108. # define CKTBL_HSCROLL_STOP         0x00020000l     /* stop at last column */
  109.  
  110. #define CKTBL_VSCROLL_MASK          0x00040000l     /* vertical scroll mode */
  111. # define CKTBL_VSCROLL_EXTRA        0x00000000l     /* scroll into gray area past last row */
  112. # define CKTBL_VSCROLL_STOP         0x00040000l     /* stop at last row */
  113.                         
  114. #define CKTBL_ROWLABEL_MASK         0x00300000l     
  115. # define CKTBL_ROWLABEL_EMPTY       0x00000000l     /* empty row labels */
  116. # define CKTBL_ROWLABEL_NUMERIC     0x00100000l     /* numeric row labels */
  117. # define CKTBL_ROWLABEL_ALPHA       0x00200000l     /* alphabetic row labels */
  118.  
  119. #define CKTBL_COLLABEL_MASK         0x00C00000l     
  120. # define CKTBL_COLLABEL_EMPTY       0x00000000l     /* empty column labels */
  121. # define CKTBL_COLLABEL_NUMERIC     0x00400000l     /* numeric column labels */
  122. # define CKTBL_COLLABEL_ALPHA       0x00800000l     /* alphabetic column labels */
  123.                    
  124. #define CKTBL_ROWLABEL_3D           0x01000000l     /* draw 3D Row Labels */
  125. #define CKTBL_COLLABEL_3D           0x02000000l     /* draw 3D Column Labels */
  126.                                                              
  127. #define CKTBL_CREATE_LABELSIZE      0x10000000l     /* use columnLabelWidth,rowLabelHeight from CKTBL_CREATE */
  128. #define CKTBL_CREATE_CELLSIZE       0x20000000l     /* use defaultRowHeight,defaultColumnWidth from CKTBL_CREATE */
  129.  
  130. #define CKTBL_DEFAULT_FLAGS                         \
  131.    (CKTBL_RESIZE_ROWS | CKTBL_RESIZE_COLUMNS |      \
  132.     CKTBL_EDIT_CELLS |                              \
  133.     CKTBL_SHOW_GRID |  CKTBL_SHOW_SELECTION  |      \
  134.     CKTBL_SELECT_ALL | CKTBL_SELECT_CELLS |         \
  135.     CKTBL_SELECT_ROWS | CKTBL_SELECT_COLUMNS |      \
  136.     CKTBL_EXTENDED_SELECT | CKTBL_SHIFT_SELECT | CKTBL_CONTROL_SELECT | \
  137.     CKTBL_HSCROLL | CKTBL_VSCROLL |                 \
  138.     CKTBL_ROWLABEL_NUMERIC | CKTBL_COLLABEL_ALPHA )
  139.  
  140.  
  141. #define CKTBL_CHECK( flags, mask )      (((flags)&(mask))==(mask))
  142. #define CKTBL_SETFLAG( flags, mask )    ((flags)|(mask))
  143. #define CKTBL_CLEARFLAG( flags, mask )  ((flags)&(~(long)(mask)))
  144.  
  145.  
  146. /*------------------------------------------------------------------------------
  147.  *  Cell Format flags
  148.  *----------------------------------------------------------------------------*/
  149.  
  150. #define CKTBL_MASK_HALIGN           (CKTBL_FMT_LEFT|CKTBL_FMT_CENTER|CKTBL_FMT_RIGHT)
  151. # define CKTBL_FMT_LEFT             0x0000      /* left justified text */
  152. # define CKTBL_FMT_CENTER           0x0001      /* centered text */
  153. # define CKTBL_FMT_RIGHT            0x0002      /* right justified text */
  154.  
  155. #define CKTBL_MASK_VALIGN           (CKTBL_FMT_TOP|CKTBL_FMT_BOTTOM)
  156. # define CKTBL_FMT_TOP              0x1000
  157. # define CKTBL_FMT_BOTTOM           0x0000
  158.  
  159. #define CKTBL_MASK_CELLTYPE         (CKTBL_FMT_SINGLE_LINE|CKTBL_FMT_MULTI_LINE)
  160. # define CKTBL_FMT_SINGLE_LINE      0x0000      /* single line of text */
  161. # define CKTBL_FMT_MULTI_LINE       0x0010      /* multiple line text */
  162.  
  163. #define CKTBL_FMT_HSCROLL           0x0020      /* WS_HSCROLL   horizontal scroll bar */
  164. #define CKTBL_FMT_VSCROLL           0x0040      /* WS_VSCROLL   vertical scroll bar */
  165. #define CKTBL_FMT_AUTOHSCROLL       0x0080      /* ES_AUTOHSCROLL   */
  166. #define CKTBL_FMT_AUTOVSCROLL       0x0100      /* ES_AUTOVSCROLL   */
  167. #define CKTBL_FMT_WORDBREAK         0x0200      /* word wrap (only with CKTBL_FMT_MULTI_LINE) */
  168.  
  169. #define CKTBL_FMT_VGROW             0x0400      /* grow horizontally with text, only with CKTBL_FMT_MULTILINE */
  170. #define CKTBL_FMT_VSHRINK           0x0800      /* shrink vertically with text, only with CKTBL_FMT_MULTILINE */
  171.  
  172. /*-----------------------------------------------------------------------------
  173. ------------------------------------------------------------------------------*/
  174.  
  175. #define CKTBL_MULTILINEBREAK                    \
  176.     (CKTBL_FMT_MULTI_LINE|                      \
  177.     CKTBL_FMT_AUTOVSCROLL|                      \
  178.     CKTBL_FMT_VGROW|CKTBL_FMT_VSHRINK|          \
  179.     CKTBL_FMT_WORDBREAK)
  180.  
  181. #define CKTBL_MULTILINE                         \
  182.     (CKTBL_FMT_MULTI_LINE|                      \
  183.     CKTBL_FMT_HSCROLL|CKTBL_FMT_AUTOHSCROLL|    \
  184.     CKTBL_FMT_AUTOVSCROLL|                      \
  185.     CKTBL_FMT_VGROW|CKTBL_FMT_VSHRINK )
  186.  
  187. #define CKTBL_SINGLELINE_TOP                    \
  188.     (CKTBL_FMT_SINGLE_LINE|                     \
  189.     CKTBL_FMT_AUTOHSCROLL|                      \
  190.     CKTBL_FMT_TOP)
  191.  
  192. #define CKTBL_SINGLELINE_BOTTOM                 \
  193.     (CKTBL_FMT_SINGLE_LINE|                     \
  194.     CKTBL_FMT_AUTOHSCROLL|                      \
  195.     CKTBL_FMT_BOTTOM)
  196.  
  197. #define CKTBL_SINGLELINE    CKTBL_SINGLELINE_TOP
  198.  
  199. /*-----------------------------------------------------------------------------
  200.  *  Create struct for use in CREATESTRUCT of CreateWindow()
  201.  *----------------------------------------------------------------------------*/
  202.  
  203. typedef struct tagCKTBL_CREATE {
  204.         long    flags;
  205.         int     rows;
  206.         int     columns;
  207.         int     columnLabelWidth;
  208.         int     rowLabelHeight;
  209.         int     defaultColumnWidth;
  210.         int     defaultRowHeight;
  211.         char    reserved[16];
  212.     } CKTBL_CREATE;
  213.  
  214. /*------------------------------------------------------------------------------
  215.  * a pointer to a CKTBL_EDITARG is passed as lParam in following messages
  216.  *  CKTBL_EDIT_START    call CKTBLStartEdit() if ok
  217.  *  CKTBL_EDIT_END      call CKTBLSetText() if ok
  218.  *----------------------------------------------------------------------------*/
  219.  
  220. typedef struct tagCKTBL_EDITARG {
  221.         int     row;
  222.         int     column;
  223.         LPSTR   text;
  224.     } CKTBL_EDITARG;
  225.  
  226. /*------------------------------------------------------------------------------
  227.  *----------------------------------------------------------------------------*/
  228.  
  229. typedef struct tagCKTBL_ATTRIB {
  230.         DWORD       format;
  231.         COLORREF    foreColor;
  232.         COLORREF    backColor;
  233.  
  234.         LPSTR       fontName;
  235.         int         fontSize;               /* font size in 1/10 points */
  236.         BOOL        fontBold;
  237.         BOOL        fontItalic;
  238.         BOOL        fontStrikeOut;
  239.         BOOL        fontUnderline;
  240.  
  241.         HFONT       hFont;                  /* overrides above, not deleted by CKTBLL */
  242.     } CKTBL_ATTRIB;
  243.  
  244. /*------------------------------------------------------------------------------
  245. ------------------------------------------------------------------------------*/
  246.  
  247. #define CKTBL_ATTR_FORMAT           0x0001
  248. #define CKTBL_ATTR_BACKCOLOR        0x0002
  249. #define CKTBL_ATTR_FORECOLOR        0x0004
  250. #define CKTBL_ATTR_FONT                             \
  251.         (CKTBL_ATTR_FONTNAME|CKTBL_ATTR_FONTSIZE|   \
  252.          CKTBL_ATTR_FONTBOLD|CKTBL_ATTR_FONTITALIC| \
  253.          CKTBL_ATTR_FONTUNDERLINE|CKTBL_ATTR_FONTSTRIKEOUT )
  254. # define CKTBL_ATTR_FONTNAME        0x0008
  255. # define CKTBL_ATTR_FONTSIZE        0x0010
  256. # define CKTBL_ATTR_FONTBOLD        0x0020
  257. # define CKTBL_ATTR_FONTITALIC      0x0040
  258. # define CKTBL_ATTR_FONTUNDERLINE   0x0080
  259. # define CKTBL_ATTR_FONTSTRIKEOUT   0x0100
  260. #define CKTBL_ATTR_HFONT            0x0200
  261.   
  262.    
  263. /*------------------------------------------------------------------------------
  264.  *  Helper functions
  265.  *----------------------------------------------------------------------------*/
  266.  
  267. void CKAPI CKTBLModifyAttrStruct( CKTBL_ATTRIB FAR* dst, CKTBL_ATTRIB FAR* src, short fields, DWORD formatMask );   //NEW
  268. LPSTR CKAPI CKTBLIndexAsNumber( int index, LPSTR buffer );
  269. LPSTR CKAPI CKTBLIndexAsAlpha( int index, LPSTR buffer, int bufferSize );                           
  270.   
  271. /*------------------------------------------------------------------------------
  272.  *  Public Protocol
  273.  *----------------------------------------------------------------------------*/
  274.  
  275. LRESULT CKCALLBACK CKTBLWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
  276.  
  277. void    CKAPI CKTBLClear            ( HWND hWnd );
  278. void    CKAPI CKTBLSetSize          ( HWND hWnd, int rows, int columns );
  279. void    CKAPI CKTBLSetColumns       ( HWND hWnd, int columns );
  280. void    CKAPI CKTBLSetRows          ( HWND hWnd, int rows );
  281.  
  282. int     CKAPI CKTBLGetColumns       ( HWND hWnd );
  283. int     CKAPI CKTBLGetRows          ( HWND hWnd );
  284.  
  285. void    CKAPI CKTBLSetFlags         ( HWND hWnd, DWORD flags );
  286. long    CKAPI CKTBLGetFlags         ( HWND hWnd );
  287.  
  288. int     CKAPI CKTBLGetCurrentRow    ( HWND hWnd );                      //NEW
  289. int     CKAPI CKTBLGetCurrentColumn ( HWND hWnd );                      //NEW
  290. void    CKAPI CKTBLSetCurrentCell   ( HWND hWnd, int row, int col );    //NEW
  291.  
  292. int     CKAPI CKTBLGetTopRow        ( HWND hWnd );                      //NEW
  293. int     CKAPI CKTBLGetLeftColumn    ( HWND hWnd );                      //NEW
  294. void    CKAPI CKTBLSetLeftTop       ( HWND hWnd, int left, int top );   //NEW
  295.  
  296. BOOL    CKAPI CKTBLInEdit           ( HWND hWnd );                      //NEW
  297. void    CKAPI CKTBLStartEdit        ( HWND hWnd, int row, int column, LPSTR text ); //NEW
  298. void    CKAPI CKTBLStartEditRequest ( HWND hWnd, int row, int column, LPSTR text ); //NEW
  299. BOOL    CKAPI CKTBLEndEdit          ( HWND Hwnd, BOOL acceptChanges );  //NEW
  300. void    CKAPI CKTBLShowCell         ( HWND hWnd, int row, int col  );   //NEW
  301.  
  302. void    CKAPI CKTBLSetCellAttr      ( HWND hWnd, CKTBL_ATTRIB FAR* attrib );
  303. void    CKAPI CKTBLGetCellAttr      ( HWND hWnd, CKTBL_ATTRIB FAR* attrib );
  304.  
  305. void    CKAPI CKTBLSetLabelAttr     ( HWND hWnd, CKTBL_ATTRIB FAR* attrib );
  306. void    CKAPI CKTBLGetLabelAttr     ( HWND hWnd, CKTBL_ATTRIB FAR* attrib );
  307.  
  308. void    CKAPI CKTBLSetDefaultColumnWidth( HWND hWnd, int width );
  309. void    CKAPI CKTBLSetDefaultRowHeight  ( HWND hWnd, int height );
  310.  
  311. int     CKAPI CKTBLGetDefaultColumnWidth( HWND hWnd );
  312. int     CKAPI CKTBLGetDefaultRowHeight  ( HWND hWnd );
  313.  
  314. void    CKAPI CKTBLSetColumnWidth       ( HWND hWnd, int column, int width );
  315. void    CKAPI CKTBLSetRowHeight         ( HWND hWnd, int row, int height );
  316.  
  317. int     CKAPI CKTBLGetColumnWidth       ( HWND hWnd, int column  );
  318. int     CKAPI CKTBLGetRowHeight         ( HWND hWnd, int row );
  319.  
  320. int     CKAPI CKTBLGetTextHeight        ( HWND hWnd, int row, int col, LPCSTR text );   //NEW
  321. int     CKAPI CKTBLGetRowTextHeight     ( HWND hWnd, int row, int skipColumn );         //NEW
  322. void    CKAPI CKTBLUpdateRowHeight      ( HWND hWnd, int row );
  323.  
  324. void    CKAPI CKTBLInsertRowsAfter      ( HWND hWnd, int row, int number );
  325. void    CKAPI CKTBLInsertColumnsAfter   ( HWND hWnd, int column ,int number );
  326.  
  327. void    CKAPI CKTBLRemoveRows           ( HWND hWnd, int rowStart, int rowEnd );
  328. void    CKAPI CKTBLRemoveColumns        ( HWND hWnd, int columnStart, int columnEnd);
  329.  
  330. void    CKAPI CKTBLSetText          ( HWND hWnd, int row, int column, LPCSTR text );
  331. void    CKAPI CKTBLSetTextPrim      ( HWND hWnd, int row, int column, LPCSTR text );
  332. void    CKAPI CKTBLSetRowText       ( HWND hWnd, int row, LPCSTR text, int colSep, int lineSep );  //NEW
  333.  
  334. int     CKAPI CKTBLGetTextLength    ( HWND hWnd, int row, int column );
  335. void    CKAPI CKTBLGetText          ( HWND hWnd, int row, int column, LPSTR text, int maxLength );
  336.   
  337. int     CKAPI CKTBLGetRowTextLength ( HWND hWnd, int row  );  //NEW
  338. void    CKAPI CKTBLGetRowText       ( HWND hWnd, int row, LPSTR text, int maxLength, int colSep, int lineSep );  //NEW
  339.   
  340. void    CKAPI CKTBLSetAttr          ( HWND hWnd, int row, int column, CKTBL_ATTRIB FAR* attrib );
  341. void    CKAPI CKTBLModifyAttr       ( HWND hWnd, int row, int column, CKTBL_ATTRIB FAR* attrib, short fields, DWORD formatMask  );   // NEW
  342. void    CKAPI CKTBLGetAttr          ( HWND hWnd, int row, int column, CKTBL_ATTRIB FAR* attrib );
  343.  
  344. void    CKAPI CKTBLSetRectText      ( HWND hWnd, RECT FAR* rect, LPSTR text );
  345. void    CKAPI CKTBLSetRectAttr      ( HWND hWnd, RECT FAR* rect, CKTBL_ATTRIB FAR* attrib );
  346. void    CKAPI CKTBLModifyRectAttr   ( HWND hWnd, RECT FAR* rect, CKTBL_ATTRIB FAR* attrib, short fields, DWORD formatMask );
  347.                                         
  348. void    CKAPI CKTBLSetSelAttr       ( HWND hWnd, CKTBL_ATTRIB FAR* attrib );    //NEW
  349. void    CKAPI CKTBLModifySelAttr    ( HWND hWnd, CKTBL_ATTRIB FAR* attrib, short fields, DWORD formtMask );     //NEW
  350.  
  351. /*------------------------------------------------------------------------------
  352.  *  Selections are stored as rectangles
  353.  *  left,top specify the column and row of the leftTop cell in the selection
  354.  *  right,bottom specify the column and row of the rightBottom cell in the selection
  355.  *
  356.  *  left==0 indicates a row selection
  357.  *  top==0 indicats a column selection
  358.  *  left==0 && top==0 indicates total selection
  359.  *----------------------------------------------------------------------------*/
  360.  
  361. void    CKAPI CKTBLClearSelection   ( HWND hWnd );
  362. void    CKAPI CKTBLSetSelection     ( HWND hWnd, RECT FAR* cells );
  363. void    CKAPI CKTBLChangeSelection  ( HWND hWnd, RECT FAR* cells, int index );
  364. void    CKAPI CKTBLAddSelection     ( HWND hWnd, RECT FAR* cells );
  365.  
  366. void    CKAPI CKTBLSetSelectionOrg  ( HWND hWnd, RECT FAR* cells, POINT FAR* origin );
  367. void    CKAPI CKTBLAddSelectionOrg  ( HWND hWnd, RECT FAR* cells, POINT FAR* origin );
  368.  
  369. int     CKAPI CKTBLGetSelectionSize ( HWND hWnd );
  370. BOOL    CKAPI CKTBLGetSelection     ( HWND hWnd, RECT FAR* cells, int n );
  371.  
  372. #ifdef CKTBL_LIBRARY
  373. BOOL    CKAPI CKTBLInitLib( HANDLE hInstanceExe );
  374. void    CKAPI CKTBLExitLib();
  375. #endif
  376.  
  377.  
  378.  
  379. #endif
  380.  
  381.  
  382.