home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / YellowBox / Kits / MiscTableScroll-138.1 / Palettes / MiscTableScroll / Framework / MiscTableScroll.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-03-31  |  31.6 KB  |  886 lines

  1. #ifndef __MiscTableScroll_h
  2. #define __MiscTableScroll_h
  3. //=============================================================================
  4. //
  5. //  Copyright (C) 1995,1996,1997,1998 by Paul S. McCarthy and Eric Sunshine.
  6. //        Written by Paul S. McCarthy and Eric Sunshine.
  7. //                All Rights Reserved.
  8. //
  9. //    This notice may not be removed from this source code.
  10. //
  11. //    This object is included in the MiscKit by permission from the authors
  12. //    and its use is governed by the MiscKit license, found in the file
  13. //    "License.rtf" in the MiscKit distribution.  Please refer to that file
  14. //    for a list of all applicable permissions and restrictions.
  15. //    
  16. //=============================================================================
  17. //-----------------------------------------------------------------------------
  18. // <MiscTableScroll.h>
  19. //
  20. //    ScrollView class that displays a 2-D table of cells.
  21. //
  22. //-----------------------------------------------------------------------------
  23. //-----------------------------------------------------------------------------
  24. // $Id: MiscTableScroll.h,v 1.31 98/03/29 23:54:21 sunshine Exp $
  25. // $Log:    MiscTableScroll.h,v $
  26. // Revision 1.31  98/03/29  23:54:21  sunshine
  27. // v138.1: Added -tableScroll:shouldDelayWindowOrderingForEvent:.
  28. // Worked around OPENSTEP 4.2 for NT bug where compiler crashes when
  29. // sending a message to 'super' from within a category.
  30. // 
  31. // Revision 1.30  98/03/23  07:47:32  sunshine
  32. // v134.1: Added -suspendEditing, -resumeEditing.
  33. // 
  34. // Revision 1.29  98/03/22  13:15:25  sunshine
  35. // v133.1: Scrollers are no longer forced on.  nullView -> cornerView.
  36. // Eliminated constrain-max functionality.  Constrain-min functionality
  37. // is now implicit based on presence/absence of auto-size slots.
  38. // Eliminated {get|set}{Min|Max}Total{Size|Height|Width} methods.
  39. // Eliminated data-sizing.  Added sizeToFit.  Added {get|set}cornerTitle.
  40. // Added {get|set}{min|max}Uniform{Size|Height|Width} methods.
  41. // Added {get|set}drawClippedText methods.
  42. // Broke off MiscTableScrollIO.M
  43. //-----------------------------------------------------------------------------
  44. #import <MiscTableScroll/MiscTableTypes.h>
  45.  
  46. MISC_TS_EXTERN_BEGIN( "Objective-C" )
  47. #import <AppKit/NSScrollView.h>
  48. MISC_TS_EXTERN_END
  49.  
  50. MISC_TS_CLASS_DEF( MiscTableBorder );
  51. MISC_TS_CLASS_DEF( MiscDelegateFlags );
  52. @class MiscTableScroll, MiscTableView, MiscBorderView, MiscCornerView;
  53. @class NSCell, NSClipView, NSFont, NSText;
  54.  
  55.  
  56. typedef struct MiscCellEditInfo
  57.     {
  58.     BOOL            editing;    // Is editing in progress?
  59.     MiscCoord_P        row;        // Coords of edited cell.
  60.     MiscCoord_P        col;
  61.     NSText*            editor;        // Field editor.
  62.     id            cell;        // Temporary editing cell.
  63.     int            suspended;    // Suspend/resume counter.
  64.     } MiscCellEditInfo;
  65.  
  66.  
  67. typedef struct MiscBorderInfo
  68.     {
  69.     MiscTableBorder*    border;
  70.     MiscBorderView*        view;
  71.     NSClipView*        clip;
  72.     NSArray*        sort_vector;
  73.     BOOL            isOn;
  74.     BOOL            autoSort;
  75.     } MiscBorderInfo;
  76.  
  77.  
  78. @interface MiscTableScroll : NSScrollView
  79.     {
  80. @private
  81.     MiscTableView*    tableView;
  82.     MiscBorderInfo*    info[2];    // { &colInfo, &rowInfo }
  83.     MiscBorderInfo    colInfo;
  84.     MiscBorderInfo    rowInfo;
  85.     MiscCornerView*    cornerView;
  86.     NSFont*        font;
  87.     NSColor*        textColor;
  88.     NSColor*        backgroundColor;
  89.     NSColor*        selectedTextColor;
  90.     NSColor*        selectedBackgroundColor;
  91.     id            delegate;
  92.     id            dataDelegate;
  93.     MiscDelegateFlags*    delegateFlags;
  94.     MiscDelegateFlags*    dataDelegateFlags;
  95.     id            target;
  96.     id            doubleTarget;
  97.     SEL            action;
  98.     SEL            doubleAction;
  99.     int            tag;
  100.     MiscCompareEntryFunc sort_entry_func;
  101.     MiscCompareSlotFunc    sort_slot_func;
  102.     MiscSelectionMode    mode;
  103.     int            num_cols;    // Currently active number of
  104.     int            num_rows;    // columns and rows.
  105.     int            max_rows;    // Highwater mark for Cell allocations.
  106.     int            max_cells;
  107.     id*            cells;
  108.     id            pageHeader;
  109.     id            pageFooter;
  110.     MiscCellEditInfo    editInfo;
  111.     BOOL        tracking;
  112.     BOOL        enabled;
  113.     BOOL        lazy;
  114.     BOOL        drawClippedText;
  115.     }
  116.  
  117. - (id)initWithFrame:(NSRect)frameRect;
  118. - (void)dealloc;
  119.  
  120.  
  121. // DELEGATE / TAG -------------------------------------------------------------
  122. - (id)delegate;
  123. - (void)setDelegate:(id)obj;
  124. - (id)dataDelegate;
  125. - (void)setDataDelegate:(id)obj;
  126.  
  127. - (int)tag;
  128. - (void)setTag:(int)x;
  129.  
  130. // TARGET / ACTION ------------------------------------------------------------
  131. - (id)target;
  132. - (void)setTarget:(id)obj;
  133. - (id)doubleTarget;
  134. - (void)setDoubleTarget:(id)obj;
  135. - (SEL)action;
  136. - (void)setAction:(SEL)new_sel;
  137. - (SEL)doubleAction;
  138. - (void)setDoubleAction:(SEL)new_sel;
  139.  
  140. - (BOOL)sendAction:(SEL)theAction to:(id)theTarget;
  141. - (BOOL)sendAction;
  142. - (BOOL)sendActionIfEnabled;
  143. - (BOOL)sendDoubleAction;
  144. - (BOOL)sendDoubleActionIfEnabled;
  145.  
  146.  
  147. // FONT -----------------------------------------------------------------------
  148. - (NSFont*)font;
  149. - (void)setFont:(NSFont*)newFont;
  150. - (void)changeFont:(id)sender;
  151. + (NSFont*)defaultFont;
  152.  
  153.  
  154. // COLOR ----------------------------------------------------------------------
  155. - (NSColor*)backgroundColor;
  156. - (void)setBackgroundColor:(NSColor*)value;        // Sent to all cells.
  157. - (NSColor*)textColor;
  158. - (void)setTextColor:(NSColor*)value;            // Sent to all cells.
  159. - (NSColor*)selectedBackgroundColor;
  160. - (void)setSelectedBackgroundColor:(NSColor*)value;    // Sent to all cells.
  161. - (NSColor*)selectedTextColor;
  162. - (void)setSelectedTextColor:(NSColor*)value;        // Sent to all cells.
  163.  
  164. - (void)setColor:(NSColor*)value;    // Alias for -setBackgroundColor:
  165. - (NSColor*)color;            // Alias for -backgroundColor
  166.  
  167. + (NSColor*)defaultBackgroundColor;
  168. + (NSColor*)defaultTextColor;
  169. + (NSColor*)defaultSelectedBackgroundColor;
  170. + (NSColor*)defaultSelectedTextColor;
  171.  
  172.  
  173. // SLOT ORDER -----------------------------------------------------------------
  174. - (NSArray*)slotOrder:(MiscBorderType)b;
  175. - (NSArray*)columnOrder;
  176. - (NSArray*)rowOrder;
  177.  
  178. - (BOOL)border:(MiscBorderType)b setSlotOrder:(NSArray*)list;
  179. - (BOOL)setColumnOrder:(NSArray*)list;
  180. - (BOOL)setRowOrder:(NSArray*)list;
  181.  
  182. - (NSString*)slotOrderAsString:(MiscBorderType)b;
  183. - (NSString*)columnOrderAsString;
  184. - (NSString*)rowOrderAsString;
  185.  
  186. - (BOOL)border:(MiscBorderType)b setSlotOrderFromString:(NSString*)s;
  187. - (BOOL)setColumnOrderFromString:(NSString*)s;
  188. - (BOOL)setRowOrderFromString:(NSString*)s;
  189.  
  190.  
  191. // SLOT SIZES -----------------------------------------------------------------
  192. - (NSArray*)slotSizes:(MiscBorderType)b;
  193. - (NSArray*)columnSizes;
  194. - (NSArray*)rowSizes;
  195.  
  196. - (BOOL)border:(MiscBorderType)b setSlotSizes:(NSArray*)list;
  197. - (BOOL)setColumnSizes:(NSArray*)list;
  198. - (BOOL)setRowSizes:(NSArray*)list;
  199.  
  200. - (NSString*)slotSizesAsString:(MiscBorderType)b;
  201. - (NSString*)columnSizesAsString;
  202. - (NSString*)rowSizesAsString;
  203.  
  204. - (BOOL)border:(MiscBorderType)b setSlotSizesFromString:(NSString*)s;
  205. - (BOOL)setColumnSizesFromString:(NSString*)s;
  206. - (BOOL)setRowSizesFromString:(NSString*)s;
  207.  
  208.  
  209. // MULTICAST MESSAGES ---------------------------------------------------------
  210. - (void)sendAction:(SEL)aSelector to:(id)anObject forAllCells:(BOOL)flag;
  211.  
  212. - (int)makeCellsPerformSelector:(SEL)aSel selectedOnly:(BOOL)flag;
  213. - (int)makeCellsPerformSelector:(SEL)aSel with:(id)arg1 selectedOnly:(BOOL)f;
  214. - (int)makeCellsPerformSelector:(SEL)aSel with:(id)arg1 with:(id)arg2
  215.         selectedOnly:(BOOL)flag;
  216.  
  217. - (int)makeCellsPerformSelector:(SEL)aSel;
  218. - (int)makeCellsPerformSelector:(SEL)aSel with:(id)arg1;
  219. - (int)makeCellsPerformSelector:(SEL)aSel with:(id)arg1 with:(id)arg2;
  220.  
  221.  
  222. // FINDING CELLS --------------------------------------------------------------
  223. - (int)border:(MiscBorderType)b slotWithTag:(int)x;
  224. - (int)columnWithTag:(int)x;
  225. - (int)rowWithTag:(int)x;
  226. - (id)cellWithTag:(int)x;
  227. - (BOOL)getRow:(int*)row column:(int*)col ofCellWithTag:(int)x;
  228. - (BOOL)getRow:(int*)row column:(int*)col ofCell:(NSCell*)cell;
  229.  
  230.  
  231. // TOTAL SIZE -----------------------------------------------------------------
  232. - (float)totalSize:(MiscBorderType)b;
  233. - (float)totalWidth;
  234. - (float)totalHeight;
  235.  
  236. - (void)constrainSize;        // Applies constraints, updates views.
  237.  
  238.  
  239. // CORNER VIEW ----------------------------------------------------------------
  240. - (NSString*)cornerTitle;
  241. - (void)setCornerTitle:(NSString*)s;
  242.  
  243.  
  244. // SLOTS ----------------------------------------------------------------------
  245. - (MiscTableBorder*)border:(MiscBorderType)b;
  246. - (BOOL)slotTitlesOn:(MiscBorderType)b;
  247. - (BOOL)border:(MiscBorderType)b setSlotTitlesOn:(BOOL)on_off;
  248.     // -border:setTitlesOn: Returns YES if changed.
  249. - (MiscTableTitleMode)slotTitleMode:(MiscBorderType)b;
  250. - (void)border:(MiscBorderType)b setSlotTitleMode:(MiscTableTitleMode)x;
  251. - (float)slotTitlesSize:(MiscBorderType)b;
  252. - (void)border:(MiscBorderType)b setSlotTitlesSize:(float)x;
  253.  
  254. - (void)border:(MiscBorderType)b moveSlotFrom:(int)pos to:(int)pos;
  255. - (int)border:(MiscBorderType)b slotPosition:(int)slot;
  256. - (int)border:(MiscBorderType)b slotAtPosition:(int)pos;
  257. - (NSArray*)border:(MiscBorderType)b physicalToVisual:(NSArray*)list;
  258. - (NSArray*)border:(MiscBorderType)b visualToPhysical:(NSArray*)list;
  259.  
  260. - (BOOL)sizeableSlots:(MiscBorderType)b;
  261. - (BOOL)draggableSlots:(MiscBorderType)b;
  262. - (BOOL)modifierDragSlots:(MiscBorderType)b;
  263. - (float)uniformSizeSlots:(MiscBorderType)b;
  264. - (float)minUniformSizeSlots:(MiscBorderType)b;
  265. - (float)maxUniformSizeSlots:(MiscBorderType)b;
  266.  
  267. - (float)border:(MiscBorderType)b slotAdjustedSize:(int)slot;
  268. - (float)border:(MiscBorderType)b slotSize:(int)slot;
  269. - (float)border:(MiscBorderType)b slotMinSize:(int)slot;
  270. - (float)border:(MiscBorderType)b slotMaxSize:(int)slot;
  271. - (BOOL)border:(MiscBorderType)b slotIsSizeable:(int)slot;
  272. - (BOOL)border:(MiscBorderType)b slotIsAutosize:(int)slot;
  273. - (NSString*)border:(MiscBorderType)b slotTitle:(int)slot;
  274. - (int)border:(MiscBorderType)b slotTag:(int)slot;
  275. - (MiscTableCellStyle)border:(MiscBorderType)b slotCellType:(int)slot;
  276. - (id)border:(MiscBorderType)b slotCellPrototype:(int)slot;
  277.  
  278. - (void)border:(MiscBorderType)b setSizeableSlots:(BOOL)flag;
  279. - (void)border:(MiscBorderType)b setDraggableSlots:(BOOL)flag;
  280. - (void)border:(MiscBorderType)b setModifierDragSlots:(BOOL)flag;
  281. - (void)border:(MiscBorderType)b setUniformSizeSlots:(float)uniform_size;
  282. - (void)border:(MiscBorderType)b setMinUniformSizeSlots:(float)size;
  283. - (void)border:(MiscBorderType)b setMaxUniformSizeSlots:(float)size;
  284.  
  285. - (void)border:(MiscBorderType)b setSlot:(int)n size:(float)size;
  286. - (void)border:(MiscBorderType)b setSlot:(int)n minSize:(float)size;
  287. - (void)border:(MiscBorderType)b setSlot:(int)n maxSize:(float)size;
  288. - (void)border:(MiscBorderType)b setSlot:(int)n sizeable:(BOOL)flag;
  289. - (void)border:(MiscBorderType)b setSlot:(int)n autosize:(BOOL)flag;
  290. - (void)border:(MiscBorderType)b setSlot:(int)n title:(NSString*)title;
  291. - (void)border:(MiscBorderType)b setSlot:(int)n tag:(int)tag;
  292. - (void)border:(MiscBorderType)b setSlot:(int)n
  293.         cellType:(MiscTableCellStyle)t;
  294. - (void)border:(MiscBorderType)b setSlot:(int)n cellPrototype:(id)cell;
  295.  
  296.  
  297. // COLS -----------------------------------------------------------------------
  298. - (MiscTableBorder*)columnBorder;
  299. - (BOOL)columnTitlesOn;
  300. - (BOOL)setColumnTitlesOn:(BOOL)on_off;    // Returns YES if changed.
  301. - (MiscTableTitleMode)columnTitleMode;
  302. - (void)setColumnTitleMode:(MiscTableTitleMode)x;
  303. - (float)columnTitlesHeight;
  304. - (void)setColumnTitlesHeight:(float)x;
  305.  
  306. - (void)moveColumnFrom:(int)pos to:(int)pos;
  307. - (int)columnPosition:(int)col;
  308. - (int)columnAtPosition:(int)pos;
  309.  
  310. - (float)uniformSizeColumns;
  311. - (float)minUniformSizeColumns;
  312. - (float)maxUniformSizeColumns;
  313. - (BOOL)sizeableColumns;
  314. - (BOOL)draggableColumns;
  315. - (BOOL)modifierDragColumns;
  316. - (float)columnAdjustedSize:(int)col;
  317. - (float)columnSize:(int)col;
  318. - (float)columnMinSize:(int)col;
  319. - (float)columnMaxSize:(int)col;
  320. - (BOOL)columnIsSizeable:(int)col;
  321. - (BOOL)columnIsAutosize:(int)col;
  322. - (NSString*)columnTitle:(int)col;
  323. - (int)columnTag:(int)col;
  324. - (MiscTableCellStyle)columnCellType:(int)col;
  325. - (id)columnCellPrototype:(int)col;
  326.  
  327. - (void)setSizeableColumns:(BOOL)flag;
  328. - (void)setDraggableColumns:(BOOL)flag;
  329. - (void)setModifierDragColumns:(BOOL)flag;
  330. - (void)setUniformSizeColumns:(float)uniform_size;
  331. - (void)setMinUniformSizeColumns:(float)size;
  332. - (void)setMaxUniformSizeColumns:(float)size;
  333.  
  334. - (void)setColumn:(int)col size:(float)size;
  335. - (void)setColumn:(int)col minSize:(float)size;
  336. - (void)setColumn:(int)col maxSize:(float)size;
  337. - (void)setColumn:(int)col sizeable:(BOOL)flag;
  338. - (void)setColumn:(int)col autosize:(BOOL)flag;
  339. - (void)setColumn:(int)col title:(NSString*)title;
  340. - (void)setColumn:(int)col tag:(int)tag;
  341. - (void)setColumn:(int)col cellType:(MiscTableCellStyle)type;
  342. - (void)setColumn:(int)col cellPrototype:(id)cell;
  343.  
  344. - (int)numberOfVisibleColumns;
  345. - (int)firstVisibleColumn;
  346. - (int)lastVisibleColumn;
  347. - (BOOL)columnIsVisible:(int)n;
  348. - (void)setFirstVisibleColumn:(int)n;
  349. - (void)setLastVisibleColumn:(int)n;
  350.  
  351.  
  352. // ROWS -----------------------------------------------------------------------
  353. - (MiscTableBorder*)rowBorder;
  354. - (BOOL)rowTitlesOn;
  355. - (BOOL)setRowTitlesOn:(BOOL)on_off;
  356. - (MiscTableTitleMode)rowTitleMode;
  357. - (void)setRowTitleMode:(MiscTableTitleMode)x;
  358. - (float)rowTitlesWidth;
  359. - (void)setRowTitlesWidth:(float)x;
  360.  
  361. - (void)moveRowFrom:(int)fromPos to:(int)toPos;
  362. - (int)rowPosition:(int)row;
  363. - (int)rowAtPosition:(int)pos;
  364.  
  365. - (BOOL)sizeableRows;
  366. - (BOOL)draggableRows;
  367. - (BOOL)modifierDragRows;
  368. - (float)uniformSizeRows;
  369. - (float)minUniformSizeRows;
  370. - (float)maxUniformSizeRows;
  371. - (float)rowAdjustedSize:(int)row;
  372. - (float)rowSize:(int)row;
  373. - (float)rowMinSize:(int)row;
  374. - (float)rowMaxSize:(int)row;
  375. - (BOOL)rowIsSizeable:(int)row;
  376. - (BOOL)rowIsAutosize:(int)row;
  377. - (NSString*)rowTitle:(int)row;
  378. - (int)rowTag:(int)row;
  379. - (MiscTableCellStyle)rowCellType:(int)row;
  380. - (id)rowCellPrototype:(int)row;
  381.  
  382. - (void)setSizeableRows:(BOOL)flag;
  383. - (void)setDraggableRows:(BOOL)flag;
  384. - (void)setModifierDragRows:(BOOL)flag;
  385. - (void)setUniformSizeRows:(float)uniform_size;
  386. - (void)setMinUniformSizeRows:(float)size;
  387. - (void)setMaxUniformSizeRows:(float)size;
  388.  
  389. - (void)setRow:(int)row size:(float)size;
  390. - (void)setRow:(int)row minSize:(float)size;
  391. - (void)setRow:(int)row maxSize:(float)size;
  392. - (void)setRow:(int)row sizeable:(BOOL)flag;
  393. - (void)setRow:(int)row autosize:(BOOL)flag;
  394. - (void)setRow:(int)row title:(NSString*)title;
  395. - (void)setRow:(int)row tag:(int)tag;
  396. - (void)setRow:(int)row cellType:(MiscTableCellStyle)type;
  397. - (void)setRow:(int)row cellPrototype:(id)cell;
  398.  
  399. - (int)numberOfVisibleRows;
  400. - (int)firstVisibleRow;
  401. - (int)lastVisibleRow;
  402. - (BOOL)rowIsVisible:(int)n;
  403. - (void)setFirstVisibleRow:(int)n;
  404. - (void)setLastVisibleRow:(int)n;
  405.  
  406.  
  407. // DRAWING --------------------------------------------------------------------
  408. - (NSRect)documentClipRect;
  409.  
  410. - (void)drawCellAtRow:(int)row column:(int)col;    // Physical coords
  411.  
  412. - (void)drawRow:(int)row;                // Physical coords
  413. - (void)drawColumn:(int)col;                // Physical coords
  414. - (void)border:(MiscBorderType)b drawSlot:(int)n;
  415.  
  416. - (int)numberOfVisibleSlots:(MiscBorderType)b;
  417. - (int)firstVisibleSlot:(MiscBorderType)b;
  418. - (int)lastVisibleSlot:(MiscBorderType)b;
  419. - (BOOL)border:(MiscBorderType)b slotIsVisible:(int)n;
  420. - (void)border:(MiscBorderType)b setFirstVisibleSlot:(int)n;
  421. - (void)border:(MiscBorderType)b setLastVisibleSlot:(int)n;
  422.  
  423. - (void)scrollCellToVisibleAtRow:(int)row column:(int)col; // Physical coords
  424. - (void)scrollRowToVisible:(int)row;            // Physical coord
  425. - (void)scrollColumnToVisible:(int)col;            // Physical coord
  426. - (void)scrollSelectionToVisible;
  427.  
  428. - (void)border:(MiscBorderType)b drawSlotTitle:(int)n;
  429. - (void)drawRowTitle:(int)n;
  430. - (void)drawColumnTitle:(int)n;
  431.  
  432. - (void)sizeToCells;
  433. - (void)sizeToFit;
  434.  
  435. - (BOOL)drawClippedText;
  436. - (void)setDrawClippedText:(BOOL)x;
  437.  
  438.  
  439. // INTERNAL COMMUNICATIONS ON USER-ACTIONS FOR SUBCLASSES ONLY ----------------
  440. // Private: BorderView -> TableScroll
  441. - (void)border:(MiscBorderType)b slotDraggedFrom:(int)fromPos to:(int)toPos;
  442. - (void)border:(MiscBorderType)b slotSortReversed:(int)n;
  443. - (void)border:(MiscBorderType)b slotResized:(int)n;
  444.  
  445. // OPENSTEP 4.2/NT COMPILER BUG WORK-AROUND; DO NOT USE THESE METHODS ---------
  446. // See implementation for an explanation.
  447. - (id)superInitWithCoder:(NSCoder*)coder;
  448. - (void)superEncodeWithCoder:(NSCoder*)coder;
  449. - (void)superKeyDown:(NSEvent*)p;
  450. - (id)superValidRequestorForSendType:(NSString*)s returnType:(NSString*)r;
  451.  
  452. @end
  453.  
  454.  
  455. // SELECTION ------------------------------------------------------------------
  456. @interface MiscTableScroll(Selection)
  457. - (MiscSelectionMode)selectionMode;
  458. - (void)setSelectionMode:(MiscSelectionMode)x;
  459.  
  460. - (BOOL)hasSlotSelection:(MiscBorderType)b;
  461. - (BOOL)hasRowSelection;
  462. - (BOOL)hasColumnSelection;
  463. - (BOOL)hasMultipleSlotSelection:(MiscBorderType)b;
  464. - (BOOL)hasMultipleRowSelection;
  465. - (BOOL)hasMultipleColumnSelection;
  466. - (unsigned int)numberOfSelectedSlots:(MiscBorderType)b;
  467. - (unsigned int)numberOfSelectedRows;
  468. - (unsigned int)numberOfSelectedColumns;
  469. - (BOOL)border:(MiscBorderType)b slotIsSelected:(MiscCoord_P)slot;
  470. - (BOOL)rowIsSelected:(MiscCoord_P)row;
  471. - (BOOL)columnIsSelected:(MiscCoord_P)col;
  472. - (BOOL)cellIsSelectedAtRow:(MiscCoord_P)row column:(MiscCoord_P)col;
  473.  
  474. - (MiscCoord_P)selectedSlot:(MiscBorderType)b;
  475. - (MiscCoord_P)selectedRow;
  476. - (MiscCoord_P)selectedColumn;
  477. - (id)selectedCell;
  478. - (NSArray*)selectedSlotTags:(MiscBorderType)b;
  479. - (NSArray*)selectedRowTags;
  480. - (NSArray*)selectedColumnTags;
  481. - (NSArray*)selectedSlots:(MiscBorderType)b;
  482. - (NSArray*)selectedRows;
  483. - (NSArray*)selectedColumns;
  484.  
  485. - (void)border:(MiscBorderType)b selectSlot:(MiscCoord_P)slot
  486.     byExtension:(BOOL)flag;
  487. - (void)border:(MiscBorderType)b selectSlot:(MiscCoord_P)slot;
  488. - (void)selectRow:(MiscCoord_P)row byExtension:(BOOL)flag;
  489. - (void)selectRow:(MiscCoord_P)row;
  490. - (void)selectColumn:(MiscCoord_P)col byExtension:(BOOL)flag;
  491. - (void)selectColumn:(MiscCoord_P)col;
  492. - (void)border:(MiscBorderType)b selectSlotTags:(NSArray*)tags
  493.      byExtension:(BOOL)flag;
  494. - (void)border:(MiscBorderType)b selectSlotTags:(NSArray*)tags;
  495. - (void)selectRowTags:(NSArray*)tags byExtension:(BOOL)flag;
  496. - (void)selectRowTags:(NSArray*)tags;
  497. - (void)selectColumnTags:(NSArray*)tags byExtension:(BOOL)flag;
  498. - (void)selectColumnTags:(NSArray*)tags;
  499. - (void)border:(MiscBorderType)b selectSlots:(NSArray*)slots
  500.      byExtension:(BOOL)flag;
  501. - (void)border:(MiscBorderType)b selectSlots:(NSArray*)slots;
  502. - (void)selectRows:(NSArray*)rows byExtension:(BOOL)flag;
  503. - (void)selectRows:(NSArray*)rows;
  504. - (void)selectColumns:(NSArray*)cols byExtension:(BOOL)flag;
  505. - (void)selectColumns:(NSArray*)cols;
  506. - (void)selectAllSlots:(MiscBorderType)b;
  507. - (void)selectAllRows;
  508. - (void)selectAllColumns;
  509. - (void)selectAll:(id)sender;    // -selectAllRows and sends action to target.
  510.  
  511. - (void)border:(MiscBorderType)b deselectSlot:(MiscCoord_P)slot;
  512. - (void)deselectRow:(MiscCoord_P)row;
  513. - (void)deselectColumn:(MiscCoord_P)col;
  514. - (void)border:(MiscBorderType)b deselectSlotTags:(NSArray*)tags;
  515. - (void)deselectRowTags:(NSArray*)tags;
  516. - (void)deselectColumnTags:(NSArray*)tags;
  517. - (void)border:(MiscBorderType)b deselectSlots:(NSArray*)slots;
  518. - (void)deselectRows:(NSArray*)rows;
  519. - (void)deselectColumns:(NSArray*)cols;
  520. - (void)clearSlotSelection:(MiscBorderType)b;
  521. - (void)clearRowSelection;
  522. - (void)clearColumnSelection;
  523. - (void)clearSelection;
  524. - (void)deselectAll:(id)sender;    // -clearSelection and sends action to target.
  525.  
  526. - (void)selectionChanged;    // Subclasses may want to override.
  527.  
  528.  
  529. // MOUSE & KEYBOARD TRACKING (SELECTION ORIENTATION) --------------------------
  530. - (void)trackBy:(MiscBorderType)b;
  531. - (MiscBorderType)trackingBy;
  532.  
  533. - (BOOL)tracking;
  534. - (MiscCoord_P)clickedSlot:(MiscBorderType)b;
  535. - (MiscCoord_P)clickedRow;
  536. - (MiscCoord_P)clickedColumn;
  537. - (id)clickedCell;
  538.  
  539.  
  540. // KEYBOARD CURSOR ------------------------------------------------------------
  541. - (MiscCoord_P)cursorSlot:(MiscBorderType)b;
  542. - (MiscCoord_P)cursorRow;
  543. - (MiscCoord_P)cursorColumn;
  544. - (void)border:(MiscBorderType)b setCursorSlot:(MiscCoord_P)slot;
  545. - (void)setCursorRow:(MiscCoord_P)row;
  546. - (void)setCursorColumn:(MiscCoord_P)col;
  547. - (void)clearCursorSlot:(MiscBorderType)b;
  548. - (void)clearCursorRow;
  549. - (void)clearCursorColumn;
  550. - (void)clearCursor;
  551. - (BOOL)hasValidCursorSlot:(MiscBorderType)b;
  552. - (BOOL)hasValidCursorRow;
  553. - (BOOL)hasValidCursorColumn;
  554. - (void)disableCursor;        // Can nest.
  555. - (void)enableCursor;
  556. - (BOOL)isCursorEnabled;
  557.  
  558.  
  559. // ENABLED --------------------------------------------------------------------
  560. - (BOOL)isEnabled;
  561. - (void)setEnabled:(BOOL)flag;
  562. @end
  563.  
  564.  
  565. // SORTING --------------------------------------------------------------------
  566. @interface MiscTableScroll(Sort)
  567.  
  568. - (MiscCompareSlotFunc)compareSlotFunction;
  569. - (void)setCompareSlotFunction:(MiscCompareSlotFunc)f;
  570.  
  571. - (void)sortInfoInit:(MiscSlotSortInfo*)ip border:(MiscBorderType)b;
  572. - (void)sortInfoDone:(MiscSlotSortInfo*)ip;
  573.  
  574. // Slots
  575. - (BOOL)autoSortSlots:(MiscBorderType)b;
  576. - (void)border:(MiscBorderType)b setAutoSortSlots:(BOOL)flag;
  577. - (NSArray*)slotSortVector:(MiscBorderType)b;
  578. - (void)border:(MiscBorderType)b setSlotSortVector:(NSArray*)v;
  579.  
  580. - (void)sortSlots:(MiscBorderType)b;
  581. - (BOOL)slotsAreSorted:(MiscBorderType)b;
  582. - (BOOL)border:(MiscBorderType)b sortSlot:(int)n;
  583. - (BOOL)border:(MiscBorderType)b slotIsSorted:(int)n;
  584.  
  585. - (int)border:(MiscBorderType)b compareSlots:(int)slot1 :(int)slot2
  586.     info:(MiscSlotSortInfo*)ip;
  587. - (int)border:(MiscBorderType)b compareSlots:(int)slot1 :(int)slot2;
  588.  
  589.  
  590. - (MiscCompareEntryFunc)border:(MiscBorderType)b slotSortFunction:(int)n;
  591. - (MiscSortDirection)border:(MiscBorderType)b slotSortDirection:(int)n;
  592. - (MiscSortType)border:(MiscBorderType)b slotSortType:(int)n;
  593. - (void)border:(MiscBorderType)b setSlot:(int)n
  594.         sortFunction:(MiscCompareEntryFunc)x;
  595. - (void)border:(MiscBorderType)b setSlot:(int)n
  596.         sortDirection:(MiscSortDirection)x;
  597. - (void)border:(MiscBorderType)b setSlot:(int)n
  598.         sortType:(MiscSortType)x;
  599.  
  600. // Cols
  601. - (BOOL)autoSortColumns;
  602. - (void)setAutoSortColumns:(BOOL)flag;
  603. - (NSArray*)columnSortVector;
  604. - (void)setColumnSortVector:(NSArray*)v;
  605.  
  606. - (void)sortColumns;
  607. - (BOOL)columnsAreSorted;
  608. - (BOOL)sortColumn:(int)n;
  609. - (BOOL)columnIsSorted:(int)n;
  610. - (int)compareColumns:(int)c1 :(int)c2 info:(MiscSlotSortInfo*)ip;
  611. - (int)compareColumns:(int)c1 :(int)c2;
  612.  
  613. - (MiscCompareEntryFunc)columnSortFunction:(int)n;
  614. - (MiscSortDirection)columnSortDirection:(int)n;
  615. - (MiscSortType)columnSortType:(int)n;
  616. - (void)setColumn:(int)n sortFunction:(MiscCompareEntryFunc)x;
  617. - (void)setColumn:(int)n sortDirection:(MiscSortDirection)x;
  618. - (void)setColumn:(int)n sortType:(MiscSortType)x;
  619.  
  620. // Rows
  621. - (BOOL)autoSortRows;
  622. - (void)setAutoSortRows:(BOOL)flag;
  623. - (NSArray*)rowSortVector;
  624. - (void)setRowSortVector:(NSArray*)v;
  625.  
  626. - (void)sortRows;
  627. - (BOOL)rowsAreSorted;
  628. - (BOOL)sortRow:(int)n;
  629. - (BOOL)rowIsSorted:(int)n;
  630. - (int)compareRows:(int)r1 :(int)r2 info:(MiscSlotSortInfo*)ip;
  631. - (int)compareRows:(int)r1 :(int)r2;
  632.  
  633. - (MiscCompareEntryFunc)rowSortFunction:(int)n;
  634. - (MiscSortDirection)rowSortDirection:(int)n;
  635. - (MiscSortType)rowSortType:(int)n;
  636. - (void)setRow:(int)n sortFunction:(MiscCompareEntryFunc)x;
  637. - (void)setRow:(int)n sortDirection:(MiscSortDirection)x;
  638. - (void)setRow:(int)n sortType:(MiscSortType)x;
  639. @end
  640.  
  641.  
  642. // DATA MANIPULATION ----------------------------------------------------------
  643. @interface MiscTableScroll(Data)
  644. - (BOOL)isLazy;
  645. - (void)setLazy:(BOOL)flag;
  646.  
  647. - (id)cellAtRow:(int)row column:(int)col;
  648.  
  649. // Lazy mode tables that perform multiple-buffering:
  650. - (int)bufferCount;
  651.  
  652. // Lazy mode asks delegate/dataDelegate first then uses cellAtRow:column:
  653. // Eager mode goes straight to cellAtRow:column:
  654. - (int)tagAtRow:(int)row column:(int)col;
  655. - (int)intValueAtRow:(int)row column:(int)col;
  656. - (float)floatValueAtRow:(int)row column:(int)col;
  657. - (double)doubleValueAtRow:(int)row column:(int)col;
  658. - (NSString*)stringValueAtRow:(int)row column:(int)col;
  659. // For ButtonCells.
  660. - (NSString*)titleAtRow:(int)row column:(int)col;
  661. - (int)stateAtRow:(int)row column:(int)col;
  662.  
  663. // Invoke delegate methods if possible.
  664. - (id)reviveCell:(id)cell atRow:(int)row column:(int)col;
  665. - (id)retireCell:(id)cell atRow:(int)row column:(int)col;
  666.  
  667. // Builtin default implementation.
  668. - (id)doReviveCell:(id)cell atRow:(int)row column:(int)col;
  669. - (id)doRetireCell:(id)cell atRow:(int)row column:(int)col;
  670.  
  671. - (void)addSlot:(MiscBorderType)b;
  672. - (void)border:(MiscBorderType)b insertSlot:(int)pos;
  673. - (void)border:(MiscBorderType)b removeSlot:(int)pos;
  674. - (int)numberOfSlots:(MiscBorderType)b;
  675.  
  676. - (void)addColumn;
  677. - (void)insertColumn:(int)pos;
  678. - (void)removeColumn:(int)pos;
  679. - (int)numberOfColumns;
  680.  
  681. - (void)addRow;
  682. - (void)insertRow:(int)pos;
  683. - (void)removeRow:(int)pos;
  684. - (int)numberOfRows;
  685.  
  686. - (void)renewRows:(int)count;
  687. - (void)empty;                    // [self renewRows:0];
  688. - (void)emptyAndReleaseCells;
  689. @end
  690.  
  691.  
  692. // READ / WRITE ---------------------------------------------------------------
  693. @interface MiscTableScroll(IO) <NSCoding>
  694. - (void)awakeFromNib;
  695. - (id)initWithCoder:(NSCoder*)coder;
  696. - (void)encodeWithCoder:(NSCoder*)coder;
  697. @end
  698.  
  699.  
  700. // PASTEBOARD SUPPORT ---------------------------------------------------------
  701. @interface MiscTableScroll(Pasteboard)
  702. - (void)copy:(id)sender;
  703. - (void)cut:(id)sender;
  704. - (id)validRequestorForSendType:(NSString*)t_send
  705.     returnType:(NSString*)t_return;
  706. - (id)builtinValidRequestorForSendType:(NSString*)t_send
  707.     returnType:(NSString*)t_return;
  708. - (BOOL)canWritePboardType:(NSString*)type;
  709. - (BOOL)builtinCanWritePboardType:(NSString*)type;
  710. - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard types:(NSArray*)types;
  711. - (BOOL)builtinWriteSelectionToPasteboard:(NSPasteboard*)pboard
  712.     types:(NSArray*)types;
  713. - (NSString*)stringForPboardType:(NSString*)type;
  714. - (NSString*)builtinStringForPboardType:(NSString*)type;
  715. - (NSString*)stringForNSStringPboardType;
  716. - (NSString*)stringForNSTabularTextPBoardType;
  717. - (BOOL)readSelectionFromPasteboard:(NSPasteboard*)pboard;
  718. - (BOOL)builtinReadSelectionFromPasteboard:(NSPasteboard*)pboard;
  719. - (void)builtinRegisterServicesTypes;
  720. - (void)registerServicesTypes;
  721. @end
  722.  
  723.  
  724. // INCREMENTAL SEARCH ---------------------------------------------------------
  725. @interface MiscTableScroll(IncrementalSearch)
  726. - (BOOL)incrementalSearch:(NSEvent*)p;
  727. - (BOOL)doIncrementalSearch:(NSEvent*)p column:(int)col;
  728. - (BOOL)getISearchColumn:(int*)col;
  729. - (BOOL)doGetISearchColumn:(int*)col;
  730. @end
  731.  
  732.  
  733. // KEYBOARD EVENTS ------------------------------------------------------------
  734. @interface MiscTableScroll(Keyboard)
  735. - (void)keyDown:(NSEvent*)event;
  736. @end
  737.  
  738.  
  739. // EDITING --------------------------------------------------------------------
  740. @interface MiscTableScroll(Edit)
  741. - (NSRect)cellFrameAtRow:(int)row column:(int)col;    // Physical coords
  742. - (BOOL)getRow:(int*)row column:(int*)col forPoint:(NSPoint)point; // Physical.
  743. - (BOOL)getPreviousEditRow:(MiscCoord_P*)p_row column:(MiscCoord_P*)p_col;
  744. - (BOOL)getNextEditRow:(MiscCoord_P*)p_row column:(MiscCoord_P*)p_col;
  745. - (BOOL)getNext:(BOOL)foreward
  746.     editRow:(MiscCoord_P*)p_row column:(MiscCoord_P*)p_col;
  747. - (BOOL)isEditing;
  748. - (BOOL)finishEditing;        // Normal, conditional termination.
  749. - (BOOL)abortEditing;        // Forcibly abort the editing session.
  750. - (void)suspendEditing;        // Temporary suspension while resizing.
  751. - (void)resumeEditing;        // Resume editing after resizing.
  752. - (void)textDidEndEditing:(NSNotification*)notification;
  753. - (void)textDidBeginEditing:(NSNotification*)notification;
  754. - (void)textDidChange:(NSNotification*)notification;
  755. - (BOOL)textShouldBeginEditing:(NSText*)sender;
  756. - (BOOL)textShouldEndEditing:(NSText*)sender;
  757. - (void)edit:(NSEvent*)ev atRow:(MiscCoord_P)row column:(MiscCoord_P)col;
  758. - (BOOL)canEdit:(NSEvent*)ev atRow:(MiscCoord_P)row column:(MiscCoord_P)col;
  759. - (BOOL)editIfAble:(NSEvent*)ev atRow:(MiscCoord_P)row column:(MiscCoord_P)col;
  760. - (void)editCellAtRow:(MiscCoord_P)row column:(MiscCoord_P)col;
  761. @end
  762.  
  763.  
  764. // PRINTING -------------------------------------------------------------------
  765. @interface MiscTableScroll(Print)
  766. - (void)print:(id)sender;
  767. - (MiscTablePrintInfo const*)getPrintInfo;
  768. - (id)getPageHeader;
  769. - (id)getPageFooter;
  770. - (void)setPageHeader:(id)obj;
  771. - (void)setPageFooter:(id)obj;
  772. @end
  773.  
  774.  
  775. // DELEGATE PROTOCOL ----------------------------------------------------------
  776. @interface MiscTableScroll(Delegate)
  777. - (void)tableScroll:(MiscTableScroll*)scroll border:(MiscBorderType)b
  778.     slotDraggedFrom:(int)fromPos to:(int)toPos;
  779. - (void)tableScroll:(MiscTableScroll*)scroll border:(MiscBorderType)b
  780.     slotSortReversed:(int)n;
  781. - (void)tableScroll:(MiscTableScroll*)scroll border:(MiscBorderType)b
  782.     slotResized:(int)n;
  783.  
  784. - (void)tableScroll:(MiscTableScroll*)scroll
  785.     changeFont:(NSFont*)oldFont to:(NSFont*)newFont;
  786. - (void)tableScroll:(MiscTableScroll*)scroll
  787.     fontChangedFrom:(NSFont*)oldFont to:(NSFont*)newFont;
  788.  
  789. - (void)tableScroll:(MiscTableScroll*)scroll
  790.     backgroundColorChangedTo:(NSColor*)x;
  791. - (void)tableScroll:(MiscTableScroll*)scroll
  792.     selectedBackgroundColorChangedTo:(NSColor*)x;
  793. - (void)tableScroll:(MiscTableScroll*)scroll
  794.     selectedTextColorChangedTo:(NSColor*)x;
  795. - (void)tableScroll:(MiscTableScroll*)scroll
  796.     textColorChangedTo:(NSColor*)x;
  797.  
  798. - (BOOL)tableScroll:(MiscTableScroll*)scroll getISearchColumn:(int*)col;
  799. - (int)tableScrollBufferCount:(MiscTableScroll*)scroll;
  800.  
  801. - (id)tableScroll:(MiscTableScroll*)scroll
  802.     border:(MiscBorderType)b slotPrototype:(int)slot;
  803. - (NSString*)tableScroll:(MiscTableScroll*)scroll
  804.     border:(MiscBorderType)b slotTitle:(int)slot;
  805.  
  806. - (id)tableScroll:(MiscTableScroll*)scroll cellAtRow:(int)row column:(int)col;
  807. - (id)tableScroll:(MiscTableScroll*)scroll reviveCell:(id)cell
  808.     atRow:(int)row column:(int)col;
  809. - (id)tableScroll:(MiscTableScroll*)scroll retireCell:(id)cell
  810.     atRow:(int)row column:(int)col;
  811.  
  812. - (int)tableScroll:(MiscTableScroll*)scroll
  813.     tagAtRow:(int)row column:(int)col;
  814. - (int)tableScroll:(MiscTableScroll*)scroll
  815.     intValueAtRow:(int)row column:(int)col;
  816. - (float)tableScroll:(MiscTableScroll*)scroll
  817.     floatValueAtRow:(int)row column:(int)col;
  818. - (double)tableScroll:(MiscTableScroll*)scroll
  819.     doubleValueAtRow:(int)row column:(int)col;
  820. - (NSString*)tableScroll:(MiscTableScroll*)scroll
  821.     stringValueAtRow:(int)row column:(int)col;
  822. - (NSString*)tableScroll:(MiscTableScroll*)scroll
  823.     titleAtRow:(int)row column:(int)col;
  824. - (int)tableScroll:(MiscTableScroll*)scroll
  825.     stateAtRow:(int)row column:(int)col;
  826.  
  827. - (BOOL)tableScroll:(MiscTableScroll*)scroll
  828.     allowDragOperationAtRow:(int)row column:(int)col;
  829. - (void)tableScroll:(MiscTableScroll*)scroll
  830.     preparePasteboard:(NSPasteboard*)pb
  831.     forDragOperationAtRow:(int)row column:(int)col;
  832. - (NSImage*)tableScroll:(MiscTableScroll*)scroll
  833.     imageForDragOperationAtRow:(int)row column:(int)col;
  834. - (unsigned int)tableScroll:(MiscTableScroll*)scroll
  835.     draggingSourceOperationMaskForLocal:(BOOL)isLocal;
  836. - (BOOL)tableScrollIgnoreModifierKeysWhileDragging:(MiscTableScroll*)scroll;
  837. - (BOOL)tableScroll:(MiscTableScroll*)scroll
  838.     shouldDelayWindowOrderingForEvent:(NSEvent*)event;
  839.  
  840. - (void)tableScrollRegisterServicesTypes:(MiscTableScroll*)scroll;
  841. - (id)tableScroll:(MiscTableScroll*)scroll
  842.     validRequestorForSendType:(NSString*)t_write
  843.     returnType:(NSString*)t_read;
  844. - (BOOL)tableScroll:(MiscTableScroll*)scroll 
  845.     canWritePboardType:(NSString*)type;
  846. - (NSString*)tableScroll:(MiscTableScroll*)scroll
  847.     stringForPboardType:(NSString*)type;
  848. - (BOOL)tableScroll:(MiscTableScroll*)scroll
  849.     writeSelectionToPasteboard:(NSPasteboard*)pboard types:(NSArray*)types;
  850. - (BOOL)tableScroll:(MiscTableScroll*)scroll
  851.     readSelectionFromPasteboard:(NSPasteboard*)pboard;
  852.  
  853. - (void)tableScrollWillPrint:(MiscTableScroll*)scroll;
  854. - (void)tableScrollDidPrint:(MiscTableScroll*)scroll;
  855. - (void)tableScroll:(MiscTableScroll*)scroll
  856.     willPrintPageHeader:(id)pageHeader
  857.     info:(MiscTablePrintInfo const*)info;
  858. - (void)tableScroll:(MiscTableScroll*)scroll
  859.     willPrintPageFooter:(id)pageFooter
  860.     info:(MiscTablePrintInfo const*)info;
  861.  
  862. - (BOOL)tableScroll:(MiscTableScroll*)scroll
  863.     canEdit:(NSEvent*)ev atRow:(int)row column:(int)col;
  864. - (void)tableScroll:(MiscTableScroll*)scroll
  865.     edit:(NSEvent*)ev atRow:(int)row column:(int)col;
  866. - (BOOL)tableScroll:(MiscTableScroll*)scroll
  867.     setStringValue:(NSString*)s atRow:(int)row column:(int)col;
  868. - (void)tableScroll:(MiscTableScroll*)scroll
  869.     abortEditAtRow:(int)row column:(int)col;
  870. - (void)tableScroll:(MiscTableScroll*)scroll
  871.     willEditAtRow:(int)row column:(int)col;
  872. - (void)tableScroll:(MiscTableScroll*)scroll
  873.     didEdit:(BOOL)changed atRow:(int)row column:(int)col;
  874. @end
  875.  
  876.  
  877. // DATA CELL PROTOCOL ---------------------------------------------------------
  878. @interface MiscTableScroll(DataCell)
  879. - (id)tableScroll:(MiscTableScroll*)scroll
  880.     reviveAtRow:(int)row column:(int)col;
  881. - (id)tableScroll:(MiscTableScroll*)scroll
  882.     retireAtRow:(int)row column:(int)col;
  883. @end
  884.  
  885. #endif // __MiscTableScroll_h
  886.