github.com/256dpi/max-go@v0.7.0/lib/max/jdataview.h (about) 1 // jdataview.h copyright 2007 cycling '74 all rights reserved 2 3 4 #ifndef _JDATAVIEW_H_ 5 #define _JDATAVIEW_H_ 6 7 #include "indexmap.h" 8 #include "jpatcher_api.h" 9 #include "jgraphics.h" 10 11 // symbols used 12 13 BEGIN_USING_C_LINKAGE 14 15 extern t_symbol *ps_jdv_update; 16 17 // a jdataview has columns 18 19 // constants 20 21 #define JDATAVIEW_CELLMAX MAX_PATH_CHARS // maximum number of chars in a cell, do not try to write more than 22 // this number to the text buffer supplied by the 'getcelltext' functions 23 24 #define JCOLUMN_DEFAULT_WIDTH 50 25 #define JCOLUMN_DEFAULT_MINWIDTH 50 26 #define JCOLUMN_DEFAULT_MAXWIDTH 100 27 28 #define JCOLUMN_DEFAULT_FONTSIZE 10 29 30 #define JCOLUMN_DEFAULT_MAXTEXTLEN 256 31 32 // values for c_alignment 33 34 enum { 35 JCOLUMN_ALIGN_LEFT = 1, 36 JCOLUMN_ALIGN_CENTER, 37 JCOLUMN_ALIGN_RIGHT 38 }; 39 40 enum { 41 JCOLUMN_STYLE_PLAIN = 0, 42 JCOLUMN_STYLE_BOLD = 1, 43 JCOLUMN_STYLE_ITALIC = 2 44 }; 45 46 enum { 47 JCOLUMN_MOUSE_ENTER = 0, 48 JCOLUMN_MOUSE_MOVE = 1, 49 JCOLUMN_MOUSE_EXIT = 2 50 }; 51 52 enum { 53 JCOLUMN_SORTDIRECTION_FORWARD = 1, 54 JCOLUMN_SORTDIRECTION_BACKWARD = 0 55 }; 56 57 enum { 58 JCOLUMN_INITIALLYSORTED_NONE = 0, 59 JCOLUMN_INITIALLYSORTED_FORWARDS = 1, 60 JCOLUMN_INITIALLYSORTED_BACKWARDS = 2 61 }; 62 63 // kinds of JUCE component style columns (or cells within columns) 64 65 enum { 66 JCOLUMN_COMPONENT_NONE = 0, 67 JCOLUMN_COMPONENT_CHECKBOX = 1, 68 JCOLUMN_COMPONENT_TEXTEDITOR = 2, // eventually alphanumeric and numeric variants 69 JCOLUMN_COMPONENT_SLIDER = 3, 70 JCOLUMN_COMPONENT_COLOR = 4, 71 JCOLUMN_COMPONENT_MENU = 5 72 }; 73 74 enum { 75 JCOLUMN_MENU_INDEX = 1, // report index chosen instead of value of item 76 JCOLUMN_MENU_FONTMENU = 2, // flag for showing a font menu 77 JCOLUMN_MENU_PAINT = 4, // cell is drawn with client paint method 78 JCOLUMN_MENU_SELECT = 8, // row is selected on mouse down 79 JCOLUMN_MENU_NOPANEL = 16, // for font menu, don't include the show fonts item 80 JCOLUMN_MENU_CLEARITEM = 32, // for font menu, include a clear item 81 JCOLUMN_MENU_STYLEMENU = 64, // show a menu of all current styles 82 JCOLUMN_MENU_FONTFIXEDWIDTHONLY = 128 83 }; 84 85 enum { 86 JCOLUMN_TEXT_ONESYMBOL = 1, 87 JCOLUMN_TEXT_COMMASEPARATED = 2, 88 JCOLUMN_TEXT_ICON = 4, 89 JCOLUMN_TEXT_HASBUTTON = 8, 90 JCOLUMN_TEXT_FILECHOOSEBUTTON = 16, 91 JCOLUMN_TEXT_VIEWBUTTON = 32, 92 JCOLUMN_TEXT_EDITBUTTON = 64, 93 JCOLUMN_TEXT_TIME = 128, 94 JCOLUMN_TEXT_FLOAT = 256, 95 JCOLUMN_TEXT_INT = 512, 96 JCOLUMN_TEXT_CANTEDIT = 1024, 97 JCOLUMN_TEXT_FONTSIZE = 2048, 98 // 4096 is JCOLUMN_DISABLED -- do not use 99 JCOLUMN_TEXT_FILTERED = 8192, 100 JCOLUMN_TEXT_STRINGOBJECT = 16384, 101 JCOLUMN_TEXT_PITCH = 32768, 102 JCOLUMN_TEXT_FILECLEARBUTTON = 65536, 103 JCOLUMN_TEXT_SCANBUTTON = 131072 104 }; 105 106 enum { 107 JCOLUMN_SLIDER_NOTEXTBOX = 1, 108 JCOLUMN_SLIDER_ZERO_TO_ONE = 2 109 }; 110 111 #define JCOLUMN_DISABLED 0x1000 112 113 114 /** A dataview cell description. 115 @ingroup jdataview */ 116 typedef struct _celldesc 117 { 118 long row; 119 long col; 120 void *section; 121 long data; 122 } t_celldesc; 123 124 125 /** A dataview column. 126 Columns for a given dataview are stored in a #t_hashtab and accessed by name. 127 @ingroup jdataview */ 128 typedef struct _col 129 { 130 t_object c_obj; 131 void *obex; 132 t_symbol *c_name; ///< column name (hash) 133 t_object *c_dv; ///< parent dataview 134 int c_id; ///< id in DataViewComponent 135 long c_width; ///< column width in pixels 136 long c_maxwidth; ///< max column width 137 long c_minwidth; ///< min column width 138 char c_autosize; ///< determine width of text column automatically (true/false) 139 char c_alignment; ///< display of text, left, right, center 140 t_symbol *c_font; ///< name of font 141 long c_fontsize; ///< font size (points?) 142 t_symbol *c_label; ///< heading of column 143 char c_separator; ///< separator mode 144 char c_button; ///< column has a button (true/false) 145 t_symbol *c_buttonlabel; ///< text in a button 146 t_symbol *c_customsort; ///< message sent to sort this column -- if none, default sorting is used based on value c_numeric 147 char c_overridesort; ///< if true only the sortdata method is called, not the sort method (true/false) 148 t_symbol *c_custompaint; ///< send this msg name to client to paint this column 149 t_symbol *c_valuemsg; ///< message sent when a component mode cell's value changes 150 t_symbol *c_beginmsg; ///< message sent when a component mode cell's value is about to start changing 151 t_symbol *c_endmsg; ///< message sent when a component mode cell's value is finished changing 152 t_symbol *c_rowcomponentmsg;///< message sent to determine what kind of component should be created for each cell in a column 153 t_symbol *c_custommenuset; ///< message to set a menu (for a readonly or custompaint column) 154 t_symbol *c_custommenuresult; ///< message sent when an item is chosen from a custom menu 155 char c_editable; ///< can you edit the data in a cell in this column 156 char c_selectable; ///< can select the data in a cell in this column (possibly without being able to edit) 157 char c_multiselectable; ///< can you select more than one cell in this column 158 char c_sortable; ///< can you click on a column heading to sort the data 159 long c_initiallysorted; ///< if this is set to JCOLUMN_INITIALLYSORTED_FORWARDS the column is displayed with the sort triangle 160 long c_maxtextlen; ///< maximum text length: this is used to allocate a buffer to pass to gettext (but there is also a constant) 161 long c_sortdirection; ///< 0 for ascending, 1 for descending 162 long c_component; ///< enum of components (check box etc.) 163 char c_canselect; ///< can select entire column 164 char c_cancut; ///< can cut/clear entire column 165 char c_cancopy; ///< can copy entire column 166 char c_cancutcells; ///< can cut a single cell (assumes "editable" or "selectable") (probably won't be implemented) 167 char c_cancopycells; ///< can copy a single cell 168 char c_canpastecells; ///< can paste into a single cell 169 char c_hideable; ///< can the column be hidden 170 char c_hidden; ///< is the column hidden (set/get) 171 char c_numeric; ///< is the data numeric (i.e., is getcellvalue implemented) 172 char c_draggable; ///< can drag the column to rearrange it 173 char c_casesensitive; ///< use case sensitive sorting (applies only to default text sorting) 174 char c_showinfo; ///< show info button for cell clue on mouse over 175 void *c_reference; ///< reference for the use of the client 176 double c_indentspacing; ///< amount of space (in pixels) for one indent level 177 t_symbol *c_insertbefore; ///< name of column before which this one should have been inserted (used only once) 178 t_symbol *c_cellcluemsg; ///< message to send requesting clue text for a cell 179 t_symbol *c_celltextcolormsg; ///< message to get the cell's text color 180 t_symbol *c_celltextstylemsg; ///< message to get the cell's style and alignment 181 t_symbol *c_cellentermsg; ///< message for cell enter 182 t_symbol *c_cellexitmsg; ///< message for cell exit 183 t_symbol *c_cellmovedmsg; ///< message for cell mouse move 184 t_symbol *c_cellclickmsg; ///< message for custom cell click action 185 } t_jcolumn; 186 187 188 /** The dataview object. 189 @ingroup jdataview */ 190 typedef struct _jdataview 191 { 192 t_object d_obj; 193 void *obex; 194 t_linklist *d_components; ///< list of DataViewComponents showing this dataview 195 t_object *d_client; ///< object that will be sent messages to get data to display 196 t_hashtab *d_columns; ///< columns -- point to t_jcolumn objects 197 t_hashtab *d_id2columns; ///< columns from column IDs 198 t_linklist *d_colorder; ///< current order of columns 199 void *d_rowmap_obsolete; ///< no longer used 200 long d_numcols; ///< number of columns 201 double d_rowheight; ///< fixed height of a row in pixels 202 char d_autoheight; ///< height determined by font 203 char d_hierarchical; ///< does it allow hierarchical disclosure (true / false) -- not implemented yet 204 t_jrgba d_rowcolor1; ///< odd row color (striped) 205 t_jrgba d_rowcolor2; ///< even row color 206 t_jrgba d_selectcolor; ///< color when rows are selected 207 t_jrgba d_bordercolor; ///< border color 208 char d_bordercolorset; ///< was border color set? if not, use JUCE default 209 char d_canselectmultiple; ///< multiple rows are selectable 210 char d_cancopy; ///< copy enabled 211 char d_cancut; ///< cut / clear enabled 212 char d_canpaste; ///< paste enabled 213 char d_canrearrangerows; ///< rows can be dragged to rearrange -- may not be implemented yet 214 char d_canrearrangecolumns; ///< columns can be dragged to rearrange 215 long d_viscount; ///< number of visible views of this dataview 216 long d_inset; ///< inset for table inside containing component in pixels 217 char d_autosizeright; ///< right side autosizes when top-level component changes 218 char d_autosizebottom; ///< bottom autosizes when top-level component changes 219 char d_dragenabled; ///< enabled for dragging (as in drag and drop) 220 t_symbol *d_fontname; ///< font name 221 double d_fontsize; ///< font size 222 t_symbol *d_colheadercluemsg; ///< message to send requesting clue text for the column headers 223 char d_autosizerightcolumn; ///< right column should stretch to remaining width of the dataview, regardless of column width 224 char d_customselectcolor; ///< send getcellcolor message to draw selected cell, don't use select color 225 void *d_qelem; ///< defer updating 226 double d_colheaderheight; 227 char d_drawgrid; 228 long d_top_inset; ///< vertical inset for row background (default 0) 229 long d_bottom_inset; ///< vertical inset for row background (default 0) 230 long d_borderthickness; ///< border line thickness default 0 for no border 231 char d_keyfocusable; ///< notify component to grab some keys 232 char d_enabledeletekey; ///< delete key will delete selected rows 233 char d_usegradient; ///< color rows with gradient between rowcolor1 (top) and rowcolor2 (bottom) 234 char d_inchange; ///< in change flag for inspector end-change protection system 235 char d_horizscrollvisible; ///< is horizontal scroll bar visible 236 char d_vertscrollvisible; ///< is vertical scroll bar visible 237 char d_scrollvisset; ///< has the scroll visibility ever been changed since the dv was created? 238 char d_overridefocus; ///< override default focus behavior where ListBox is focused when assigning focus to the dataview 239 char d_usesystemfont; ///< use system font (true by default) 240 t_object *d_searchcolumn; ///< column we ask for celltext in order to navigate the selection via the keyboard 241 t_object *d_returnkeycolumn;///< column that is sent the return key when a given row is selected 242 void *d_navcache; ///< sorted list of column strings for key navigation 243 char d_usecharheight; ///< use font specified in points rather than pixels (default is pixels) 244 t_linklist *d_sections; ///< list of sections 245 char d_paintcellseparator; ///< should paint a line below a cell (grayish) 246 t_object *d_sortset; ///< sort col saved when dv is invisible 247 char d_solidheadercolor; 248 t_jrgba d_headerbgcolor; 249 t_jrgba d_headertextcolor; 250 void *d_context; 251 char d_drawheadertopline; 252 char d_drawheaderbottomline; 253 t_jrgba d_headerlinecolor; 254 char d_showcolumnheadercaptions; 255 } t_jdataview; 256 257 258 // private -- used to notify a component of a jdataview change 259 typedef struct _jdv_notifier 260 { 261 t_jdataview *n_dataview; 262 t_symbol *n_what; 263 void *n_data; 264 } t_jdv_notifier; 265 266 267 /** used to pass data to a client sort function 268 @ingroup jdataview */ 269 typedef struct _privatesortrec 270 { 271 t_jcolumn *p_col; ///< column object to sort 272 char p_fwd; ///< 1 if sorting "forwards" 273 t_object *p_client; ///< pointer to the client object 274 t_jdataview *p_dv; ///< pointer to the dataview 275 } t_privatesortrec; 276 277 typedef struct _jsection 278 { 279 t_symbol *s_name; // section name 280 char s_open; // is section disclosed? 281 char s_headervisible; // is header visible? 282 t_indexmap *s_rowmap; // map of rowrefs to row indices 283 void *s_data; // some data (not used yet) 284 t_jsurface *s_icon; // associated icon to display in header 285 t_jrgba s_bgcolor; // background color 286 char s_solidcolor; // uses solid color, not gradient 287 } t_jsection; 288 289 // private 290 void jdataview_initclass(void); 291 292 293 /** Create a dataview. 294 You should free it with object_free(). 295 @ingroup jdataview 296 @return A pointer to the new instance. */ 297 void *jdataview_new(void); 298 299 300 /** Set a dataview's client. 301 The client is the object to which the dataview will send messages to get data, 302 notify of changes to cells, etc. 303 Typically this is the object in which you are creating the dataview. 304 @ingroup jdataview 305 @param dv The dataview instance. 306 @param client The object to be assigned as the dataview's client. */ 307 void jdataview_setclient(t_object *dv, t_object *client); 308 309 /** Get a pointer to a dataview's client. 310 The client is the object to which the dataview will send messages to get data, 311 notify of changes to cells, etc. 312 @ingroup jdataview 313 @param dv The dataview instance. 314 @return A pointer to the dataview's client object. */ 315 t_object *jdataview_getclient(t_object *dv); 316 317 // section support 318 319 void *jdataview_newsection(t_object *dv, char *name, void *assoc, t_jsurface *icon, char initiallyopen, char headervisible); 320 int jdataview_numsections(t_object *dv); 321 void *jdataview_getnthsection(t_object *dv, long index); 322 int jdataview_section_getnumrows(t_object *dv, void *section); 323 long jdataview_section_isopen(t_object *dv, void *section); 324 void jdataview_section_setopen(t_object *dv, void *section, long way); 325 void jdataview_getsectionopenness(t_object *dv, char **state); 326 void jdataview_setsectionopenness(t_object *dv, char *state); 327 long jdataview_section_headervisible(t_object *dv, void *section); 328 void jdataview_section_setheadervisible(t_object *dv, void *section, long way); 329 t_symbol *jdataview_section_getname(t_object *dv, void *section); 330 t_jsurface *jdataview_section_geticon(t_object *dv, void *section); 331 332 333 // make it visible 334 335 void jdataview_patchervis(t_object *dv, t_object *pv, t_object *box); 336 void jdataview_patcherinvis(t_object *dv, t_object *pv); 337 void jdataview_obscuring(t_object *dv, t_object *pv); 338 339 void jdataview_repaintforview(t_object *dv, t_object *patcherview); 340 341 // set global attributes 342 343 void jdataview_setheight(t_object *dv, long height); 344 long jdataview_getheight(t_object *dv); 345 346 void jdataview_setautoheight(t_object *dv, long way); 347 short jdataview_getautoheight(t_object *dv); 348 349 void jdataview_setcolumnheaderheight(t_object *dv, double height); 350 double jdataview_getcolumnheaderheight(t_object *dv); 351 352 void jdataview_setrowcolor1(t_object *dv, t_jrgba *c); 353 void jdataview_getrowcolor1(t_object *dv, t_jrgba *c); 354 void jdataview_setrowcolor2(t_object *dv, t_jrgba *c); 355 void jdataview_getrowcolor2(t_object *dv, t_jrgba *c); 356 357 void jdataview_getselectcolor(t_object *dv, t_jrgba *c); 358 void jdataview_setselectcolor(t_object *dv, t_jrgba *c); 359 360 void jdataview_setusegradient(t_object *dv, long way); 361 long jdataview_getusegradient(t_object *dv); 362 363 void jdataview_setcanselectmultiple(t_object *dv, long way); 364 short jdataview_getcanselectmultiple(t_object *dv); 365 366 void jdataview_setcancopy(t_object *dv, long way); 367 short jdataview_getcancopy(t_object *dv); 368 369 void jdataview_setcanpaste(t_object *dv, long way); 370 short jdataview_getcanpaste(t_object *dv); 371 372 void jdataview_setinset(t_object *dv, long inset); 373 long jdataview_getinset(t_object *dv); 374 375 void jdataview_setautosizeright(t_object *dv, long way); 376 long jdataview_getautosizeright(t_object *dv); 377 378 void jdataview_setautosizebottom(t_object *dv, long way); 379 long jdataview_getautosizebottom(t_object *dv); 380 381 void jdataview_setautosizerightcolumn(t_object *dv, long way); 382 long jdataview_getautosizerightcolumn(t_object *dv); 383 384 void jdataview_setusecharheightfont(t_object *dv, long way); 385 386 // standard containersizechange method for objects to use 387 // i.e., class_addmethod(c, jdataview_containersizechange, "containersizechange", A_CANT, 0); 388 389 typedef long (*t_containersizechange_fun)(t_object *x, double cw, double ch, double *width, double *height, int asr, int asb); 390 391 t_atom_long jdataview_containersizechange(t_object *x, double cw, double ch, double *width, double *height, int asr, int asb); 392 393 t_max_err jdataview_gethorizscrollvalues(t_object *x, double *min, double *max, double *start, double *size); 394 void jdataview_sethorizscrollvalues(t_object *x, double start, double size); 395 396 t_max_err jdataview_getvertscrollvalues(t_object *x, double *min, double *max, double *start, double *size); 397 void jdataview_setvertscrollvalues(t_object *x, double start, double size); 398 399 t_max_err jdataview_setscrollvisible(t_object *x, long vbar, long hbar); 400 401 void jdataview_setborderthickness(t_object *dv, long val); 402 long jdataview_getborderthickness(t_object *dv); 403 404 void jdataview_setkeyfocusable(t_object *x, long val); 405 long jdataview_getkeyfocusable(t_object *x); 406 407 void jdataview_focusgained(t_object *x, t_object *patcherview); 408 void jdataview_focuslost(t_object *x, t_object *patcherview); 409 410 void jdataview_setenabledeletekey(t_object *dv, long way); 411 long jdataview_getenabledeletekey(t_object *dv); 412 413 void jdataview_setfontname(t_object *dv, t_symbol *fontname); 414 t_symbol *jdataview_getfontname(t_object *dv); 415 void jdataview_setfontsize(t_object *dv, double fsize); 416 double jdataview_getfontsize(t_object *dv); 417 418 double jdataview_getclientfontsize(t_object *dv); 419 420 void jdataview_columnheadermouse(t_object *dv, t_object *col, long msg); 421 422 int jdataview_getdragenabled(t_object *dv); 423 void jdataview_setdragenabled(t_object *dv, long way); 424 425 void jdataview_setcolumnheadercluemsg(t_object *dv, t_symbol *msg); 426 t_symbol *jdataview_getcolumnheadercluemsg(t_object *dv); 427 void jdataview_getcolumnheaderclue(t_object *dv, t_object *col, const char **a, const char **b); 428 void jdataview_setshowcolumnheadercaptions(t_object *dv, long way); 429 long jdataview_getshowcolumnheadercaptions(t_object *dv); 430 431 int jdataview_getdrawgrid(t_object *dv); 432 void jdataview_setdrawgrid(t_object *dv, int way); 433 void jdataview_setrowinset(t_object *dv, long top, long bottom); 434 void jdataview_getrowinset(t_object *dv, long *top, long *bottom); 435 436 t_object *jdataview_getsearchcolumn(t_object *dv); 437 void jdataview_setsearchcolumn(t_object *dv, t_object *col); 438 void jdataview_setoverridefocus(t_object *dv, long way); 439 long jdataview_getoverridefocus(t_object *dv); 440 441 void jdataview_setreturnkeycolumn(t_object *dv, t_object *col); 442 t_object *jdataview_getreturnkeycolumn(t_object *dv); 443 444 int jdataview_keynavigate(t_object *dv, const char *buffer); 445 446 // header color 447 448 void jdataview_setheaderbgcolor(t_object *dv, t_jrgba *c); 449 void jdataview_setheadertextcolor(t_object *dv, t_jrgba *c); 450 void jdataview_getheaderbgcolor(t_object *dv, t_jrgba *c); 451 void jdataview_getheadertextcolor(t_object *dv, t_jrgba *c); 452 long jdataview_getheadersolidcolor(t_object *dv); 453 void jdataview_setheadersolidcolor(t_object *dv, long way); 454 long jdataview_getdrawheadertopline(t_object *dv); 455 void jdataview_setdrawheadertopline(t_object *dc, long way); 456 long jdataview_getdrawheaderbottomline(t_object *dv); 457 void jdataview_setdrawheaderbottomline(t_object *d, long way); 458 459 // context 460 461 void jdataview_setcontext(t_object *dv, void *context); 462 void *jdataview_getcontext(t_object *dv); 463 464 // columns access 465 466 t_object *jdataview_addcolumn(t_object *dv, t_symbol *name, t_symbol *before, short unused); 467 t_object *jdataview_addcolumn_hidden(t_object *dv, t_symbol *name, t_symbol *before, short unused); 468 void *jcolumn_new(void); 469 void jcolumn_free(t_jcolumn *x); 470 void jcolumn_setdataview(t_object *c, t_object *dv); 471 472 void jdataview_colname_delete(t_object *dv, t_symbol *name); 473 void jdataview_deletecolumn(t_object *dv, t_object *col); 474 void jdataview_movecolumn(t_object *dv, t_object *col, long toindex); 475 t_object *jdataview_getnamedcolumn(t_object *dv, t_symbol *name); 476 t_object *jdataview_getnthcolumn(t_object *dv, long index); 477 int jdataview_colname2index(t_object *dv, t_symbol *name); 478 void jdataview_colname_setvisible(t_object *dv, t_symbol *name, long way); 479 short jdataview_colname_getvisible(t_object *dv, t_symbol *name); 480 int jdataview_getnumcolumns(t_object *dv); 481 int jdataview_column2visibleindex(t_object *dv, t_object *col); 482 483 // column 484 485 int jcolumn_getwidth(t_object *col); 486 void jcolumn_setwidth(t_object *col, long width); 487 int jcolumn_getmaxwidth(t_object *col); 488 void jcolumn_setmaxwidth(t_object *col, long width); 489 int jcolumn_getminwidth(t_object *col); 490 void jcolumn_setminwidth(t_object *col, long width); 491 long jcolumn_getid(t_object *col); 492 int jcolumn_getautosize(t_object *col); 493 void jcolumn_setautosize(t_object *col, long way); 494 void jcolumn_setdataview(t_object *col, t_object *dv); 495 t_symbol *jcolumn_getname(t_object *col); 496 void jcolumn_setname(t_object *col, t_symbol *name); 497 void jcolumn_setlabel(t_object *col, t_symbol *label); 498 t_symbol *jcolumn_getlabel(t_object *col); 499 void jcolumn_setinsertbefore(t_object *col, t_symbol *before); 500 t_symbol *jcolumn_getinsertbefore(t_object *col); 501 void jcolumn_setnumeric(t_object *col, long way); 502 int jcolumn_getnumeric(t_object *col); 503 void jcolumn_setcustomsort(t_object *col, t_symbol *msg); 504 t_symbol *jcolumn_getcustomsort(t_object *col); 505 void jcolumn_setoverridesort(t_object *col, char val); 506 char jcolumn_getoverridesort(t_object *col); 507 char jcolumn_getsortdirection(t_object *col); 508 void jcolumn_setcustompaint(t_object *col, t_symbol *msg); 509 t_symbol *jcolumn_getcustompaint(t_object *col); 510 void jcolumn_setcustommenu(t_object *col, t_symbol *setmsg, t_symbol *resultmsg); 511 t_symbol *jcolumn_getcustommenu_setmsg(t_object *col); 512 t_symbol *jcolumn_getcustommenu_resultmsg(t_object *col); 513 void jcolumn_setsortable(t_object *col, long way); 514 int jcolumn_getsortable(t_object *col); 515 void jcolumn_setdraggable(t_object *col, long way); 516 int jcolumn_getdraggable(t_object *col); 517 void jcolumn_setinitiallysorted(t_object *col, long way); 518 int jcolumn_getinitiallysorted(t_object *col); 519 void jcolumn_sethideable(t_object *col, long way); 520 int jcolumn_gethideable(t_object *col); 521 void jcolumn_setvisible(t_object *col, long way); 522 int jcolumn_getvisible(t_object *col); 523 void jcolumn_setcasesensitive(t_object *col, long way); 524 int jcolumn_getcasesensitive(t_object *col); 525 void jcolumn_setreference(t_object *col, void *ref); 526 void *jcolumn_getreference(t_object *col); 527 void jcolumn_setcheckbox(t_object *col, t_symbol *msg); 528 void jcolumn_setvaluemsg(t_object *col, t_symbol *msg, t_symbol *beginmsg, t_symbol *endmsg); 529 t_symbol *jcolumn_getvaluemsg(t_object *col); 530 t_symbol *jcolumn_getbeginchangemsg(t_object *col); 531 t_symbol *jcolumn_getendchangemsg(t_object *col); 532 int jcolumn_getcomponent(t_object *col); 533 void jcolumn_setrowcomponentmsg(t_object *col, t_symbol *msg); 534 t_symbol *jcolumn_getrowcomponentmsg(t_object *col); 535 double jcolumn_getindentspacing(t_object *col); 536 void jcolumn_setindentspacing(t_object *col, double spacing); 537 538 void jcolumn_setcellcluemsg(t_object *col, t_symbol *msg); 539 t_symbol *jcolumn_getcellcluemsg(t_object *col); 540 t_symbol *jcolumn_getcelltextcolormsg(t_object *col); 541 void jcolumn_setcelltextcolormsg(t_object *col, t_symbol *msg); 542 t_symbol *jcolumn_getcelltextstylemsg(t_object *col); 543 void jcolumn_setcelltextstylemsg(t_object *col, t_symbol *msg); 544 545 void jcolumn_setcellentermsg(t_object *col, t_symbol *msg); 546 void jcolumn_setcellexitmsg(t_object *col, t_symbol *msg); 547 void jcolumn_setcellmovedmsg(t_object *col, t_symbol *msg); 548 void jcolumn_setcellclickmsg(t_object *col, t_symbol *msg); 549 550 void jcolumn_setshowinfobutton(t_object *col, long way); 551 long jcolumn_getshowinfobutton(t_object *col); 552 553 t_symbol *jcolumn_getcellentermsg(t_object *col); 554 t_symbol *jcolumn_getcellexitmsg(t_object *col); 555 t_symbol *jcolumn_getcellmovedmsg(t_object *col); 556 t_symbol *jcolumn_getcellclickmsg(t_object *col); 557 558 // visual update of a change to a column 559 560 void jcolumn_update(t_object *col, t_symbol *msg); 561 562 // define a column based on a dictionary 563 564 t_object *jdataview_addcolumnfromdictionary(t_object *dv, t_object *d); 565 566 // adding rows 567 568 // a row reference is a way of distinguishing a row to the owning object. This is up to the object whose data is being displayed. 569 // for example, it could be a pointer to an entry in a database 570 // or if you are displaying attributes it could be a symbol 571 572 typedef void *t_rowref; 573 574 void jdataview_addrowtosection(t_object *dv, void *section, t_rowref rr); 575 void jdataview_addrow(t_object *dv, t_rowref rr); 576 void jdataview_addrowstosection(t_object *dv, void *section, long count, t_rowref *rrs); 577 void jdataview_addrows(t_object *dv, long count, t_rowref *rrs); 578 579 void jdataview_insertrow(t_object *dv, long loc, t_rowref rr); 580 void jdataview_insertrowinsection(t_object *dv, void *section, long loc, t_rowref rr); 581 void jdataview_deleterowfromsection(t_object *dv, void *section, t_rowref rr); 582 void jdataview_deleterow(t_object *dv, t_rowref rr); 583 void jdataview_deleterowsfromsection(t_object *dv, void *section, long count, t_rowref *rrs); 584 void jdataview_deleterows(t_object *dv, long count, t_rowref *rrs); 585 void jdataview_deleteselectedrows(t_object *dv); 586 void jdataview_deleteselectedrowsforview(t_object *dv, t_object *patcherview); 587 void jdataview_clear(t_object *dv); 588 int jdataview_getnumrows(t_object *dv); 589 void jdataview_gettextinrows(t_object *dv, t_rowref *rows, char *cellsep, char **text); 590 int jdataview_selectedrowcountforview(t_object *dv, t_object *patcherview); 591 int jdataview_selectedrowcount(t_object *dv); 592 t_rowref *jdataview_getallrows(t_object *dv); 593 t_rowref *jdataview_section_getallrows(t_object *dv, void *section, long *count); 594 t_rowref *jdataview_getselectedrowsforview(t_object *dv, t_object *patcherview); 595 t_rowref *jdataview_getselectedrows(t_object *dv); 596 t_bool jdataview_has_selection(t_object *dv); 597 void jdataview_applytoselectedrows(t_object *dv, t_symbol *msg, long bycell); 598 void jdataview_applytorows(t_object *dv, t_symbol *msg, long bycell, t_rowref *srs); 599 600 void jdataview_enablerow(t_object *dv, t_rowref rr, long way); 601 602 void jdataview_selectall(t_object *dv); 603 void jdataview_selectallforview(t_object *dv, t_object *patcherview); 604 void jdataview_selectnone(t_object *dv); 605 void jdataview_selectnoneforview(t_object *dv, t_object *patcherview); 606 607 // row and column conversion (used by DataViewComponent mostly) 608 609 t_object *jdataview_id2column(t_object *dv, int id); 610 t_symbol *jdataview_id2colname(t_object *dv, int id); 611 int jdataview_colname2id(t_object *dv, t_symbol *name); 612 int jdataview_column2id(t_object *dv, t_object *col); 613 int jdataview_row2id(t_object *dv, t_rowref rr, void **section); 614 t_rowref jdataview_id2row(t_object *dv, void *section, int id); 615 616 void jdataview_showrow(t_object *dv, t_rowref rr); 617 618 // cells 619 620 void jdataview_celldesc(t_jdataview *x, t_symbol *colname, t_rowref rr, t_celldesc *desc); 621 void jdataview_selectcellinview(t_object *dv, t_object *pv, t_symbol *colname, t_rowref rr); 622 void jdataview_selectcell(t_object *dv, t_symbol *colname, t_rowref rr); 623 int jdataview_getcelltextlength(t_object *dv, t_symbol *colname, t_rowref rr, long *length); 624 int jdataview_getcelltext(t_object *dv, t_symbol *colname, t_rowref rr, char *text, long maxlen); 625 int jdataview_getcellunits(t_object *dv, t_symbol *colname, t_rowref rr, char *text, long maxlen); 626 int jdataview_setcellunits(t_object *dv, t_symbol *colname, t_rowref rr, t_symbol *val); 627 int jdataview_getcellunitsyms(t_object *dv, t_symbol *colname, t_rowref rr, long *argc, t_atom **argv); 628 int jdataview_getcelldescription(t_object *dv, t_symbol *colname, t_rowref rr, char *text); 629 int jdataview_getcellvalue(t_object *dv, t_symbol *colname, t_rowref rr, long *argc, t_atom *argv); 630 void jdataview_getcelltextcolor(t_object *dv, t_symbol *colname, t_rowref rr, t_jrgba *color); 631 void jdataview_getcelltextstyle(t_object *dv, t_symbol *colname, t_rowref rr, long *style, long *align); 632 int jdataview_getcellmenu(t_object *dv, t_symbol *colname, t_rowref rr, long *argc, t_atom *argv, char **enabled, long *currentitemindex); 633 int jdataview_getcelltooltip(t_object *dv, t_symbol *colname, t_rowref rr, t_rect *cellrect, char *text, long maxlen); 634 void jdataview_setcellvalue(t_object *dv, t_symbol *colname, t_rowref rr, long argc, t_atom *argv); 635 void jdataview_editcell(t_object *dv, t_symbol *colname, t_rowref rr); 636 int jdataview_iscelltextselected(t_object *dv, char justfocused); 637 void jdataview_cellclear(t_object *dv); 638 void jdataview_cellcut(t_object *dv); 639 void jdataview_cellcopy(t_object *dv); 640 void jdataview_cellpaste(t_object *dv); 641 642 int jdataview_getcellcomponent(t_object *dv, t_symbol *colname, t_rowref rr, long *options, t_symbol **label); 643 int jdataview_getcellfiletypes(t_object *dv, t_symbol *colname, t_rowref rr, long *count, t_fourcc **types, char *alloc); 644 t_symbol *jdataview_getcellfilterval(t_object *dv, t_symbol *colname, t_rowref rr); 645 void jdataview_redrawcell(t_object *dv, t_symbol *colname, t_rowref rr); 646 void jdataview_redrawcolumn(t_object *dv, t_symbol *colname); 647 void jdataview_begincellchange(t_object *dv, t_symbol *colname, t_rowref rr); 648 void jdataview_endcellchange(t_object *dv, t_symbol *colname, t_rowref rr); 649 void jdataview_selected(t_object *dv, t_symbol *colname, t_rowref rr); 650 void jdataview_selectedrow(t_object *dv, t_rowref rr); 651 void jdataview_doubleclick(t_object *dv, t_symbol *colname, t_rowref rr); 652 void jdataview_contextualclick(t_object *dv, t_symbol *colname, t_rowref rr); 653 void jdataview_getcellicon(t_object *dv, t_symbol *colname, t_rowref rr, t_jsurface **surf); 654 void jdataview_getrowcolor(t_object *dv, t_rowref rr, long isoddrow, t_jrgba *c); 655 int jdataview_colorbycell(t_object *dv); 656 void jdataview_getcellcolor(t_object *dv, t_symbol *colname, t_rowref rr, long isoddrow, t_jrgba *c); 657 int jdataview_getcustomselectcolor(t_object *dv); 658 void jdataview_setcustomselectcolor(t_object *dv, int way); 659 double jdataview_getcellindent(t_object *dv, t_symbol *colname, t_rowref rr); 660 void jdataview_cellenter(t_object *dv, t_symbol *colname, t_rowref rr, int px, int py); 661 void jdataview_cellexit(t_object *dv, t_symbol *colname, t_rowref rr, int px, int py); 662 void jdataview_cellmove(t_object *dv, t_symbol *colname, t_rowref rr, int px, int py); 663 void jdataview_cellclick(t_object *dv, t_symbol *colname, t_rowref rr, int px, int py); 664 665 void jdataview_setfontmenurow(t_object *dv, t_rowref rr); 666 667 t_atom_long jdataview_getcelleditable(t_object *dv, t_symbol *colname, t_rowref rr); 668 669 long jdataview_getbordercolor(t_object *dv, t_jrgba *c); // returns non-zero if border color set 670 void jdataview_setbordercolor(t_object *dv, t_jrgba *c); 671 672 long jdataview_getusesystemfont(t_object *dv); 673 void jdataview_setusesystemfont(t_object *dv, long way); 674 675 void jdataview_enablecell(t_object *dv, t_symbol *colname, t_rowref rr, long way); 676 void jdataview_forcecellvisible(t_object *x, t_symbol *colname, t_rowref rr); 677 void jdataview_scrolltosection(t_object *dv, void *section); 678 void jdataview_scrolltotop(t_object *dv); 679 680 int jdataview_getpaintcellseparator(t_object *dv); 681 void jdataview_setpaintcellseparator(t_object *dv, int way); 682 683 void jdataview_getcellclue(t_object *dv, t_symbol *colname, t_rowref rr, char **str); 684 685 686 // DataViewComponent calls this for a custom paint method for a column 687 688 void jdataview_clientpaintcell(t_object *dv, t_symbol *msg, t_object *pv, t_symbol *colname, t_rowref rr, int width, int height, int rowIsSelected, int rowNumber); 689 690 // custom paint method should be declared as: 691 // void myobject_paint(t_myobject *x, t_object *patcherview, t_symbol *colname, t_rowref rr, int width, int height, int rowIsSelected) 692 // to obtain the graphics context call patcherview_getjgraphics() on the patcherview arg 693 // use jcolumn_setcustompaint to set the message symbol for this method for a column 694 695 // the jdataview doesn't hold data. It just sends messages to an owning object to display it 696 // the messages may be cached for speed. The first level interface just defines a textual 697 // display. Eventually there will be a custom component for a row. 698 699 // sorting: columns can be textual (c_numeric == 0) or numeric or they can define a custom sort 700 // method by calling jcolumn_setcustomsort to a symbol. This symbol names a method that will be 701 // called to sort the data for this column. It is of the form: 702 // long myobject_sort(t_rowref a, t_rowref b) -- which will be passed two rowrefs. In addition, 703 // custom sort clients need to implement the sortdata message, which is passed a pointer to 704 // a t_privatesortrec. It needs to store this statically as it is sent before the custom sort message is 705 // received. 706 void jdataview_getcolumnmenuforcell(t_object *dv, t_symbol *colname, t_rowref rr, long *argc, t_atom **argv, char **enabled); 707 void jdataview_cellcolumnmenuresult(t_object *dv, t_symbol *colname, t_rowref rr, long result); 708 709 void jdataview_sortcolumn(t_object *x, t_symbol *colname, int fwd); 710 void jdataview_sort(t_object *x, t_symbol *colname, int fwd); 711 void jdataview_resort(t_object *x); 712 long jdataview_getsortcolumn(t_object *x); 713 714 // selection 715 716 void jdataview_selectcell(t_object *dv, t_symbol *colname, t_rowref rr); 717 void jdataview_selectrow(t_jdataview *x, t_rowref rr, t_bool unselect); 718 void jdataview_selectcolumn(t_jdataview *x, t_symbol *colname); 719 void jdataview_selectallrows(t_jdataview *x); 720 721 long jdataview_iscellselected(t_jdataview *x, t_symbol *colname, t_rowref rr); 722 long jdataview_isrowselected(t_jdataview *x, t_rowref rr); 723 long jdataview_iscolumnselected(t_jdataview *x, t_symbol *colname); 724 725 void jdataview_savecolumnwidths(t_object *dv, t_dictionary **d); 726 void jdataview_restorecolumnwidths(t_object *dv, t_dictionary *d); 727 728 void jdataview_updatefontpanelforclient(t_object *dv, long show); 729 730 void jdataview_unselected(t_object *dv); 731 732 // utilities for painting 733 734 void jdataview_redrawrow(t_object *dv, t_rowref rr); 735 736 737 738 739 #ifdef CUSTOMPAINT 740 void jdataview_getcellrect(t_jdataview *x, t_symbol *colname, t_rowref rr, t_rect *r); 741 t_max_err jdataview_jgraphics_from_paintcontext(t_jdataview *x, void *ctx, t_jgraphics **g); 742 #endif 743 744 // handle resizing 745 746 long jdataview_containersize(t_object *dv, t_object *box, double cw, double ch, double *width, double *height); 747 748 void jdataview_forcecellvisible(t_object *x, t_symbol *colname, t_rowref rr); 749 750 751 // messages to the owner 752 753 t_object *jdataview_getrowobject(t_object *dv, t_rowref rr); // return object associated with the row, if any (used for dragging) 754 755 void jdataview_entermodalstate(t_object *dv, long way); 756 757 void *jdataview_getdragreceiver(t_object *dv); 758 759 long jdataview_getpaintoverchildren(t_object *dv); 760 void jdataview_paintoverchildren(t_object *dv, t_object *pv); 761 762 /* 763 764 -- "columncreated": notification of a column being created 765 766 void myobject_columncreated(t_myobject *x, t_symbol *colname); 767 768 -- "rowadded" / "rowdeleted": notification of a row being added / deleted 769 770 void myobject_rowadded(t_myobject *x, t_rowref rr); 771 void myobject_rowdeleted(t_myobject *x, t_rowref rr); 772 773 -- "sortstarted": notification of a sort starting (will get sort messages) 774 775 void myobject_sortstarted(t_myobject *x, t_symbol *colname, long direction); 776 777 -- "compare": sort the data according to column / direction, return 1 if r1 > r2, -1 if r2 > r1 778 779 long myobject_compare(t_myobject *x, t_symbol *colname, long direction, t_rowref r1, t_rowref r2); 780 781 -- "gettext": get string to show in a cell 782 783 void myobject_gettext(t_myobject *x, t_symbol *colname, t_rowref rr, char *text); 784 785 -- "editstarted": notification that editing is starting in a cell 786 787 void myobject_editstarted(t_myobject *x, t_symbol *colname, t_rowref rr); 788 789 -- "editentered": editing has finished and here is some new text for a cell 790 791 void myobject_editenter(t_myobject *x, t_symbol *colname, t_rowref rr, char *newtext); 792 793 // plus, a message specific to a button clicked in a cell (this allows for multiple buttons per column) 794 795 void myobject_buttonmessage(t_myobject *x, t_symbol *colname, t_rowref rr, t_symbol *msg); 796 797 // editing operations, "cutcell", "copycell", "pastecell", "clearcell" 798 799 void myobject_cutcell(t_myobject *x, t_symbol *colname, t_rowref rr); 800 void myobject_copycell(t_myobject *x, t_symbol *colname, t_rowref rr); 801 void myobject_pastecell(t_myobject *x, t_symbol *colname, t_rowref rr); 802 void myobject_clearcell(t_myobject *x, t_symbol *colname, t_rowref rr); 803 804 // "cutcolumn", "copycolumn", "pastecolumn", "clearcolumn" 805 806 void myobject_cutcolumn(t_myobject *x, t_symbol *colname); 807 void myobject_copycolumn(t_myobject *x, t_symbol *colname); 808 void myobject_pastecolumn(t_myobject *x, t_symbol *colname); 809 void myobject_clearcolumn(t_myobject *x, t_symbol *colname); 810 811 // "cutrow", "copyrow", "pasterow", "clearrow", "deleterow" 812 813 void myobject_cutrow(t_myobject *x, t_rowref rr); 814 void myobject_copyrow(t_myobject *x, t_rowref rr); 815 void myobject_pasterow(t_myobject *x, t_rowref rr); 816 void myobject_clearrow(t_myobject *x, t_rowref rr); 817 void myobject_deleterow(t_myobject *x, t_rowref rr); 818 819 // customization: an object can have a paintcell method instead of displaying text 820 821 void myobject_paintcell(t_myobject *x, t_symbol *colname, t_rowref rr, void *ctx); 822 823 // implementation notes: 824 825 JUCE refreshComponentForCell needs to have the ability to create a custom component given a 826 class name. How can that be done, with templates? 827 828 Yes you can use template argument passed to new, i.e., 829 830 template<class T> 831 blah<T>::blah 832 { 833 foo (which could be a member of blah?) = new T; 834 } 835 836 */ 837 838 END_USING_C_LINKAGE 839 840 #endif // _JDATAVIEW_H_