Max 5 API Reference
00001 // jdataview.h copyright 2007 cycling '74 all rights reserved 00002 00003 00004 #ifndef _JDATAVIEW_H_ 00005 #define _JDATAVIEW_H_ 00006 00007 // symbols used 00008 00009 BEGIN_USING_C_LINKAGE 00010 00011 extern t_symbol *ps_jdv_update; 00012 00013 // a jdataview has columns 00014 00015 // constants 00016 00017 #define JDATAVIEW_CELLMAX MAX_PATH_CHARS // maximum number of chars in a cell, do not try to write more than 00018 // this number to the text buffer supplied by the 'getcelltext' functions 00019 00020 #define JCOLUMN_DEFAULT_WIDTH 50 00021 #define JCOLUMN_DEFAULT_MINWIDTH 50 00022 #define JCOLUMN_DEFAULT_MAXWIDTH 100 00023 00024 #define JCOLUMN_DEFAULT_FONTSIZE 10 00025 00026 #define JCOLUMN_DEFAULT_MAXTEXTLEN 256 00027 00028 // values for c_alignment 00029 00030 enum { 00031 JCOLUMN_ALIGN_LEFT = 1, 00032 JCOLUMN_ALIGN_CENTER, 00033 JCOLUMN_ALIGN_RIGHT 00034 }; 00035 00036 enum { 00037 JCOLUMN_STYLE_PLAIN = 0, 00038 JCOLUMN_STYLE_BOLD = 1, 00039 JCOLUMN_STYLE_ITALIC = 2 00040 }; 00041 00042 enum { 00043 JCOLUMN_MOUSE_ENTER = 0, 00044 JCOLUMN_MOUSE_MOVE = 1, 00045 JCOLUMN_MOUSE_EXIT = 2 00046 }; 00047 00048 enum { 00049 JCOLUMN_SORTDIRECTION_FORWARD = 1, 00050 JCOLUMN_SORTDIRECTION_BACKWARD = 0 00051 }; 00052 00053 enum { 00054 JCOLUMN_INITIALLYSORTED_NONE = 0, 00055 JCOLUMN_INITIALLYSORTED_FORWARDS = 1, 00056 JCOLUMN_INITIALLYSORTED_BACKWARDS = 2 00057 }; 00058 00059 // kinds of JUCE component style columns (or cells within columns) 00060 00061 enum { 00062 JCOLUMN_COMPONENT_NONE = 0, 00063 JCOLUMN_COMPONENT_CHECKBOX = 1, 00064 JCOLUMN_COMPONENT_TEXTEDITOR = 2, // eventually alphanumeric and numeric variants 00065 JCOLUMN_COMPONENT_SLIDER = 3, 00066 JCOLUMN_COMPONENT_COLOR = 4, 00067 JCOLUMN_COMPONENT_MENU = 5 00068 }; 00069 00070 enum { 00071 JCOLUMN_MENU_INDEX = 1, // report index chosen instead of value of item 00072 JCOLUMN_MENU_FONTMENU = 2, // flag for showing a font menu 00073 JCOLUMN_MENU_PAINT = 4, // cell is drawn with client paint method 00074 JCOLUMN_MENU_SELECT = 8, // row is selected on mouse down 00075 JCOLUMN_MENU_NOPANEL = 16, // for font menu, don't include the show fonts item 00076 JCOLUMN_MENU_CLEARITEM = 32 // for font menu, include a clear item 00077 }; 00078 00079 enum { 00080 JCOLUMN_TEXT_ONESYMBOL = 1, 00081 JCOLUMN_TEXT_COMMASEPARATED = 2, 00082 JCOLUMN_TEXT_ICON = 4, 00083 JCOLUMN_TEXT_HASBUTTON = 8, 00084 JCOLUMN_TEXT_FILECHOOSEBUTTON = 16, 00085 JCOLUMN_TEXT_VIEWBUTTON = 32, 00086 JCOLUMN_TEXT_EDITBUTTON = 64, 00087 JCOLUMN_TEXT_TIME = 128, 00088 JCOLUMN_TEXT_FLOAT = 256, 00089 JCOLUMN_TEXT_INT = 512, 00090 JCOLUMN_TEXT_CANTEDIT = 1024, 00091 JCOLUMN_TEXT_FONTSIZE = 2048, 00092 // 4096 is JCOLUMN_DISABLED -- do not use 00093 JCOLUMN_TEXT_FILTERED = 8192 00094 }; 00095 00096 enum { 00097 JCOLUMN_SLIDER_NOTEXTBOX = 1, 00098 JCOLUMN_SLIDER_ZERO_TO_ONE = 2 00099 }; 00100 00101 #define JCOLUMN_DISABLED 0x1000 00102 00103 00104 /** A dataview cell description. 00105 @ingroup jdataview */ 00106 typedef struct _celldesc 00107 { 00108 long row; 00109 long col; 00110 long data; 00111 } t_celldesc; 00112 00113 00114 /** A dataview column. 00115 Columns for a given dataview are stored in a #t_hashtab and accessed by name. 00116 @ingroup jdataview */ 00117 typedef struct _col 00118 { 00119 t_object c_obj; 00120 void *obex; 00121 t_symbol *c_name; ///< column name (hash) 00122 t_object *c_dv; ///< parent dataview 00123 int c_id; ///< id in DataViewComponent 00124 long c_width; ///< column width in pixels 00125 long c_maxwidth; ///< max column width 00126 long c_minwidth; ///< min column width 00127 char c_autosize; ///< determine width of text column automatically (true/false) 00128 char c_alignment; ///< display of text, left, right, center 00129 t_symbol *c_font; ///< name of font 00130 long c_fontsize; ///< font size (points?) 00131 t_symbol *c_label; ///< heading of column 00132 char c_separator; ///< separator mode 00133 char c_button; ///< column has a button (true/false) 00134 t_symbol *c_buttonlabel; ///< text in a button 00135 t_symbol *c_customsort; ///< message sent to sort this column -- if none, default sorting is used based on value c_numeric 00136 char c_overridesort; ///< if true only the sortdata method is called, not the sort method (true/false) 00137 t_symbol *c_custompaint; ///< send this msg name to client to paint this column 00138 t_symbol *c_valuemsg; ///< message sent when a component mode cell's value changes 00139 t_symbol *c_beginmsg; ///< message sent when a component mode cell's value is about to start changing 00140 t_symbol *c_endmsg; ///< message sent when a component mode cell's value is finished changing 00141 t_symbol *c_rowcomponentmsg;///< message sent to determine what kind of component should be created for each cell in a column 00142 t_symbol *c_custommenuset; ///< message to set a menu (for a readonly or custompaint column) 00143 t_symbol *c_custommenuresult; ///< message sent when an item is chosen from a custom menu 00144 char c_editable; ///< can you edit the data in a cell in this column 00145 char c_selectable; ///< can select the data in a cell in this column (possibly without being able to edit) 00146 char c_multiselectable; ///< can you select more than one cell in this column 00147 char c_sortable; ///< can you click on a column heading to sort the data 00148 long c_initiallysorted; ///< if this is set to JCOLUMN_INITIALLYSORTED_FORWARDS the column is displayed with the sort triangle 00149 long c_maxtextlen; ///< maximum text length: this is used to allocate a buffer to pass to gettext (but there is also a constant) 00150 long c_sortdirection; ///< 0 for ascending, 1 for descending 00151 long c_component; ///< enum of components (check box etc.) 00152 char c_canselect; ///< can select entire column 00153 char c_cancut; ///< can cut/clear entire column 00154 char c_cancopy; ///< can copy entire column 00155 char c_cancutcells; ///< can cut a single cell (assumes "editable" or "selectable") (probably won't be implemented) 00156 char c_cancopycells; ///< can copy a single cell 00157 char c_canpastecells; ///< can paste into a single cell 00158 char c_hideable; ///< can the column be hidden 00159 char c_hidden; ///< is the column hidden (set/get) 00160 char c_numeric; ///< is the data numeric (i.e., is getcellvalue implemented) 00161 char c_draggable; ///< can drag the column to rearrange it 00162 char c_casesensitive; ///< use case sensitive sorting (applies only to default text sorting) 00163 void *c_reference; ///< reference for the use of the client 00164 double c_indentspacing; ///< amount of space (in pixels) for one indent level 00165 t_symbol *c_insertbefore; ///< name of column before which this one should have been inserted (used only once) 00166 t_symbol *c_cellcluemsg; ///< message to send requesting clue text for a cell 00167 t_symbol *c_celltextcolormsg; ///< message to get the cell's text color 00168 t_symbol *c_celltextstylemsg; ///< message to get the cell's style and alignment 00169 } t_jcolumn; 00170 00171 00172 /** The dataview object. 00173 @ingroup jdataview */ 00174 typedef struct _jdataview 00175 { 00176 t_object d_obj; 00177 void *obex; 00178 t_linklist *d_components; ///< list of DataViewComponents showing this dataview 00179 t_object *d_client; ///< object that will be sent messages to get data to display 00180 t_hashtab *d_columns; ///< columns -- point to t_jcolumn objects 00181 t_hashtab *d_id2columns; ///< columns from column IDs 00182 t_linklist *d_colorder; ///< current order of columns 00183 t_indexmap *d_rowmap; ///< collection of rows (including number of rows) 00184 long d_numcols; ///< number of columns 00185 double d_rowheight; ///< fixed height of a row in pixels 00186 char d_autoheight; ///< height determined by font 00187 char d_hierarchical; ///< does it allow hierarchical disclosure (true / false) -- not implemented yet 00188 t_jrgba d_rowcolor1; ///< odd row color (striped) 00189 t_jrgba d_rowcolor2; ///< even row color 00190 t_jrgba d_selectcolor; ///< color when rows are selected 00191 t_jrgba d_bordercolor; ///< border color 00192 char d_bordercolorset; ///< was border color set? if not, use JUCE default 00193 char d_canselectmultiple; ///< multiple rows are selectable 00194 char d_cancopy; ///< copy enabled 00195 char d_cancut; ///< cut / clear enabled 00196 char d_canpaste; ///< paste enabled 00197 char d_canrearrangerows; ///< rows can be dragged to rearrange -- may not be implemented yet 00198 char d_canrearrangecolumns; ///< columns can be dragged to rearrange 00199 long d_viscount; ///< number of visible views of this dataview 00200 long d_inset; ///< inset for table inside containing component in pixels 00201 char d_autosizeright; ///< right side autosizes when top-level component changes 00202 char d_autosizebottom; ///< bottom autosizes when top-level component changes 00203 char d_dragenabled; ///< enabled for dragging (as in drag and drop) 00204 t_symbol *d_fontname; ///< font name 00205 double d_fontsize; ///< font size 00206 t_symbol *d_colheadercluemsg; ///< message to send requesting clue text for the column headers 00207 char d_autosizerightcolumn; ///< right column should stretch to remaining width of the dataview, regardless of column width 00208 char d_customselectcolor; ///< send getcellcolor message to draw selected cell, don't use select color 00209 void *d_qelem; ///< defer updating 00210 double d_colheaderheight; 00211 char d_drawgrid; 00212 long d_top_inset; ///< vertical inset for row background (default 0) 00213 long d_bottom_inset; ///< vertical inset for row background (default 0) 00214 long d_borderthickness; ///< border line thickness default 0 for no border 00215 char d_keyfocusable; ///< notify component to grab some keys 00216 char d_enabledeletekey; ///< delete key will delete selected rows 00217 char d_usegradient; ///< color rows with gradient between rowcolor1 (top) and rowcolor2 (bottom) 00218 char d_inchange; ///< in change flag for inspector end-change protection system 00219 char d_horizscrollvisible; ///< is horizontal scroll bar visible 00220 char d_vertscrollvisible; ///< is vertical scroll bar visible 00221 char d_scrollvisset; ///< has the scroll visibility ever been changed since the dv was created? 00222 char d_overridefocus; ///< override default focus behavior where ListBox is focused when assigning focus to the dataview 00223 char d_usesystemfont; ///< use system font (true by default) 00224 t_object *d_searchcolumn; ///< column we ask for celltext in order to navigate the selection via the keyboard 00225 t_object *d_returnkeycolumn;///< column that is sent the return key when a given row is selected 00226 void *d_navcache; ///< sorted list of column strings for key navigation 00227 char d_usecharheight; ///< use font specified in points rather than pixels (default is pixels) 00228 } t_jdataview; 00229 00230 00231 // private -- used to notify a component of a jdataview change 00232 typedef struct _jdv_notifier 00233 { 00234 t_jdataview *n_dataview; 00235 t_symbol *n_what; 00236 void *n_data; 00237 } t_jdv_notifier; 00238 00239 00240 /** used to pass data to a client sort function 00241 @ingroup jdataview */ 00242 typedef struct _privatesortrec 00243 { 00244 t_jcolumn *p_col; ///< column object to sort 00245 char p_fwd; ///< 1 if sorting "forwards" 00246 t_object *p_client; ///< pointer to the client object 00247 t_jdataview *p_dv; ///< pointer to the dataview 00248 } t_privatesortrec; 00249 00250 00251 // private 00252 void jdataview_initclass(void); 00253 00254 00255 /** Create a dataview. 00256 You should free it with object_free(). 00257 @ingroup jdataview 00258 @return A pointer to the new instance. */ 00259 void *jdataview_new(void); 00260 00261 00262 /** Set a dataview's client. 00263 The client is the object to which the dataview will send messages to get data, 00264 notify of changes to cells, etc. 00265 Typically this is the object in which you are creating the dataview. 00266 @ingroup jdataview 00267 @param dv The dataview instance. 00268 @param client The object to be assigned as the dataview's client. */ 00269 void jdataview_setclient(t_object *dv, t_object *client); 00270 00271 /** Get a pointer to a dataview's client. 00272 The client is the object to which the dataview will send messages to get data, 00273 notify of changes to cells, etc. 00274 @ingroup jdataview 00275 @param dv The dataview instance. 00276 @return A pointer to the dataview's client object. */ 00277 t_object *jdataview_getclient(t_object *dv); 00278 00279 00280 // make it visible 00281 00282 void jdataview_patchervis(t_object *dv, t_object *pv); 00283 void jdataview_patcherinvis(t_object *dv, t_object *pv); 00284 00285 00286 // set global attributes 00287 00288 void jdataview_setheight(t_object *dv, long height); 00289 long jdataview_getheight(t_object *dv); 00290 00291 void jdataview_setautoheight(t_object *dv, long way); 00292 short jdataview_getautoheight(t_object *dv); 00293 00294 void jdataview_setcolumnheaderheight(t_object *dv, double height); 00295 double jdataview_getcolumnheaderheight(t_object *dv); 00296 00297 void jdataview_setrowcolor1(t_object *dv, t_jrgba *c); 00298 void jdataview_getrowcolor1(t_object *dv, t_jrgba *c); 00299 void jdataview_setrowcolor2(t_object *dv, t_jrgba *c); 00300 void jdataview_getrowcolor2(t_object *dv, t_jrgba *c); 00301 00302 void jdataview_getselectcolor(t_object *dv, t_jrgba *c); 00303 void jdataview_setselectcolor(t_object *dv, t_jrgba *c); 00304 00305 void jdataview_setusegradient(t_object *dv, long way); 00306 long jdataview_getusegradient(t_object *dv); 00307 00308 void jdataview_setcanselectmultiple(t_object *dv, long way); 00309 short jdataview_getcanselectmultiple(t_object *dv); 00310 00311 void jdataview_setcancopy(t_object *dv, long way); 00312 short jdataview_getcancopy(t_object *dv); 00313 00314 void jdataview_setcanpaste(t_object *dv, long way); 00315 short jdataview_getcanpaste(t_object *dv); 00316 00317 void jdataview_setinset(t_object *dv, long inset); 00318 long jdataview_getinset(t_object *dv); 00319 00320 void jdataview_setautosizeright(t_object *dv, long way); 00321 long jdataview_getautosizeright(t_object *dv); 00322 00323 void jdataview_setautosizebottom(t_object *dv, long way); 00324 long jdataview_getautosizebottom(t_object *dv); 00325 00326 void jdataview_setautosizerightcolumn(t_object *dv, long way); 00327 long jdataview_getautosizerightcolumn(t_object *dv); 00328 00329 void jdataview_setusecharheightfont(t_object *dv, long way); 00330 00331 // standard containersizechange method for objects to use 00332 // i.e., class_addmethod(c, jdataview_containersizechange, "containersizechange", A_CANT, 0); 00333 00334 long jdataview_containersizechange(t_object *x, double cw, double ch, double *width, double *height, int asr, int asb); 00335 00336 t_max_err jdataview_gethorizscrollvalues(t_object *x, double *min, double *max, double *start, double *size); 00337 void jdataview_sethorizscrollvalues(t_object *x, double start, double size); 00338 00339 t_max_err jdataview_getvertscrollvalues(t_object *x, double *min, double *max, double *start, double *size); 00340 void jdataview_setvertscrollvalues(t_object *x, double start, double size); 00341 00342 t_max_err jdataview_setscrollvisible(t_object *x, long vbar, long hbar); 00343 00344 void jdataview_setborderthickness(t_object *dv, long val); 00345 long jdataview_getborderthickness(t_object *dv); 00346 00347 void jdataview_setkeyfocusable(t_object *x, long val); 00348 long jdataview_getkeyfocusable(t_object *x); 00349 00350 void jdataview_setenabledeletekey(t_object *dv, long way); 00351 long jdataview_getenabledeletekey(t_object *dv); 00352 00353 void jdataview_setfontname(t_object *dv, t_symbol *fontname); 00354 t_symbol *jdataview_getfontname(t_object *dv); 00355 void jdataview_setfontsize(t_object *dv, double fsize); 00356 double jdataview_getfontsize(t_object *dv); 00357 00358 double jdataview_getclientfontsize(t_object *dv); 00359 00360 void jdataview_columnheadermouse(t_object *dv, t_object *col, long msg); 00361 00362 int jdataview_getdragenabled(t_object *dv); 00363 void jdataview_setdragenabled(t_object *dv, long way); 00364 00365 void jdataview_setcolumnheadercluemsg(t_object *dv, t_symbol *msg); 00366 t_symbol *jdataview_getcolumnheadercluemsg(t_object *dv); 00367 00368 int jdataview_getdrawgrid(t_object *dv); 00369 void jdataview_setdrawgrid(t_object *dv, int way); 00370 void jdataview_setrowinset(t_object *dv, long top, long bottom); 00371 void jdataview_getrowinset(t_object *dv, long *top, long *bottom); 00372 00373 t_object *jdataview_getsearchcolumn(t_object *dv); 00374 void jdataview_setsearchcolumn(t_object *dv, t_object *col); 00375 void jdataview_setoverridefocus(t_object *dv, long way); 00376 long jdataview_getoverridefocus(t_object *dv); 00377 00378 void jdataview_setreturnkeycolumn(t_object *dv, t_object *col); 00379 t_object *jdataview_getreturnkeycolumn(t_object *dv); 00380 00381 int jdataview_keynavigate(t_object *dv, char *buffer); 00382 00383 // columns access 00384 00385 t_object *jdataview_addcolumn(t_object *dv, t_symbol *name, t_symbol *before, short unused); 00386 t_object *jdataview_addcolumn_hidden(t_object *dv, t_symbol *name, t_symbol *before, short unused); 00387 void *jcolumn_new(void); 00388 void jcolumn_setdataview(t_object *c, t_object *dv); 00389 00390 void jdataview_colname_delete(t_object *dv, t_symbol *name); 00391 void jdataview_deletecolumn(t_object *dv, t_object *col); 00392 t_object *jdataview_getnamedcolumn(t_object *dv, t_symbol *name); 00393 t_object *jdataview_getnthcolumn(t_object *dv, long index); 00394 void jdataview_colname_setvisible(t_object *dv, t_symbol *name, long way); 00395 short jdataview_colname_getvisible(t_object *dv, t_symbol *name); 00396 int jdataview_getnumcolumns(t_object *dv); 00397 00398 // column 00399 00400 int jcolumn_getwidth(t_object *col); 00401 void jcolumn_setwidth(t_object *col, long width); 00402 int jcolumn_getmaxwidth(t_object *col); 00403 void jcolumn_setmaxwidth(t_object *col, long width); 00404 int jcolumn_getminwidth(t_object *col); 00405 void jcolumn_setminwidth(t_object *col, long width); 00406 long jcolumn_getid(t_object *col); 00407 int jcolumn_getautosize(t_object *col); 00408 void jcolumn_setdataview(t_object *col, t_object *dv); 00409 t_symbol *jcolumn_getname(t_object *col); 00410 void jcolumn_setname(t_object *col, t_symbol *name); 00411 void jcolumn_setlabel(t_object *col, t_symbol *label); 00412 t_symbol *jcolumn_getlabel(t_object *col); 00413 void jcolumn_setinsertbefore(t_object *col, t_symbol *before); 00414 t_symbol *jcolumn_getinsertbefore(t_object *col); 00415 void jcolumn_setnumeric(t_object *col, long way); 00416 int jcolumn_getnumeric(t_object *col); 00417 void jcolumn_setcustomsort(t_object *col, t_symbol *msg); 00418 t_symbol *jcolumn_getcustomsort(t_object *col); 00419 void jcolumn_setoverridesort(t_object *col, char val); 00420 char jcolumn_getoverridesort(t_object *col); 00421 void jcolumn_setcustompaint(t_object *col, t_symbol *msg); 00422 t_symbol *jcolumn_getcustompaint(t_object *col); 00423 void jcolumn_setcustommenu(t_object *col, t_symbol *setmsg, t_symbol *resultmsg); 00424 t_symbol *jcolumn_getcustommenu_setmsg(t_object *col); 00425 t_symbol *jcolumn_getcustommenu_resultmsg(t_object *col); 00426 void jcolumn_setsortable(t_object *col, long way); 00427 int jcolumn_getsortable(t_object *col); 00428 void jcolumn_setdraggable(t_object *col, long way); 00429 int jcolumn_getdraggable(t_object *col); 00430 void jcolumn_setinitiallysorted(t_object *col, long way); 00431 int jcolumn_getinitiallysorted(t_object *col); 00432 void jcolumn_sethideable(t_object *col, long way); 00433 int jcolumn_gethideable(t_object *col); 00434 void jcolumn_setvisible(t_object *col, long way); 00435 int jcolumn_getvisible(t_object *col); 00436 void jcolumn_setcasesensitive(t_object *col, long way); 00437 int jcolumn_getcasesensitive(t_object *col); 00438 void jcolumn_setreference(t_object *col, void *ref); 00439 void *jcolumn_getreference(t_object *col); 00440 void jcolumn_setcheckbox(t_object *col, t_symbol *msg); 00441 void jcolumn_setvaluemsg(t_object *col, t_symbol *msg, t_symbol *beginmsg, t_symbol *endmsg); 00442 t_symbol *jcolumn_getvaluemsg(t_object *col); 00443 t_symbol *jcolumn_getbeginchangemsg(t_object *col); 00444 t_symbol *jcolumn_getendchangemsg(t_object *col); 00445 int jcolumn_getcomponent(t_object *col); 00446 void jcolumn_setrowcomponentmsg(t_object *col, t_symbol *msg); 00447 t_symbol *jcolumn_getrowcomponentmsg(t_object *col); 00448 double jcolumn_getindentspacing(t_object *col); 00449 void jcolumn_setindentspacing(t_object *col, double spacing); 00450 00451 void jcolumn_setcellcluemsg(t_object *col, t_symbol *msg); 00452 t_symbol *jcolumn_getcellcluemsg(t_object *col); 00453 t_symbol *jcolumn_getcelltextcolormsg(t_object *col); 00454 void jcolumn_setcelltextcolormsg(t_object *col, t_symbol *msg); 00455 t_symbol *jcolumn_getcelltextstylemsg(t_object *col); 00456 void jcolumn_setcelltextstylemsg(t_object *col, t_symbol *msg); 00457 00458 // visual update of a change to a column 00459 00460 void jcolumn_update(t_object *col, t_symbol *msg); 00461 00462 // define a column based on a dictionary 00463 00464 t_object *jdataview_addcolumnfromdictionary(t_object *dv, t_object *d); 00465 00466 // adding rows 00467 00468 // 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. 00469 // for example, it could be a pointer to an entry in a database 00470 // or if you are displaying attributes it could be a symbol 00471 00472 typedef void *t_rowref; 00473 00474 void jdataview_addrow(t_object *dv, t_rowref rr); 00475 void jdataview_addrows(t_object *dv, long count, t_rowref *rrs); 00476 void jdataview_deleterow(t_object *dv, t_rowref rr); 00477 void jdataview_deleterows(t_object *dv, long count, t_rowref *rrs); 00478 void jdataview_deleteselectedrows(t_object *dv); 00479 void jdataview_clear(t_object *dv); 00480 int jdataview_getnumrows(t_object *dv); 00481 void jdataview_gettextinrows(t_object *dv, t_rowref *rows, char *cellsep, char **text); 00482 int jdataview_selectedrowcount(t_object *dv); 00483 t_rowref *jdataview_getallrows(t_object *dv); 00484 t_rowref *jdataview_getselectedrows(t_object *dv); 00485 void jdataview_applytoselectedrows(t_object *dv, t_symbol *msg, long bycell); 00486 00487 void jdataview_enablerow(t_object *dv, t_rowref rr, long way); 00488 00489 void jdataview_selectall(t_object *dv); 00490 void jdataview_selectnone(t_object *dv); 00491 00492 // row and column conversion (used by DataViewComponent mostly) 00493 00494 t_object *jdataview_id2column(t_object *dv, int id); 00495 t_symbol *jdataview_id2colname(t_object *dv, int id); 00496 int jdataview_colname2id(t_object *dv, t_symbol *name); 00497 int jdataview_column2id(t_object *dv, t_object *col); 00498 int jdataview_row2id(t_object *dv, t_rowref rr); 00499 t_rowref jdataview_id2row(t_object *dv, int id); 00500 00501 void jdataview_showrow(t_object *dv, t_rowref rr); 00502 00503 // cells 00504 00505 void jdataview_celldesc(t_jdataview *x, t_symbol *colname, t_rowref rr, t_celldesc *desc); 00506 void jdataview_selectcellinview(t_object *dv, t_object *pv, t_symbol *colname, t_rowref rr); 00507 void jdataview_selectcell(t_object *dv, t_symbol *colname, t_rowref rr); 00508 int jdataview_getcelltextlength(t_object *dv, t_symbol *colname, t_rowref rr, long *length); 00509 int jdataview_getcelltext(t_object *dv, t_symbol *colname, t_rowref rr, char *text, long maxlen); 00510 int jdataview_getcellunits(t_object *dv, t_symbol *colname, t_rowref rr, char *text, long maxlen); 00511 int jdataview_setcellunits(t_object *dv, t_symbol *colname, t_rowref rr, t_symbol *val); 00512 int jdataview_getcellunitsyms(t_object *dv, t_symbol *colname, t_rowref rr, long *argc, t_atom **argv); 00513 int jdataview_getcelldescription(t_object *dv, t_symbol *colname, t_rowref rr, char *text); 00514 int jdataview_getcellvalue(t_object *dv, t_symbol *colname, t_rowref rr, long *argc, t_atom *argv); 00515 void jdataview_getcelltextcolor(t_object *dv, t_symbol *colname, t_rowref rr, t_jrgba *color); 00516 void jdataview_getcelltextstyle(t_object *dv, t_symbol *colname, t_rowref rr, long *style, long *align); 00517 int jdataview_getcellmenu(t_object *dv, t_symbol *colname, t_rowref rr, long *argc, t_atom *argv, char **enabled); 00518 void jdataview_setcellvalue(t_object *dv, t_symbol *colname, t_rowref rr, long argc, t_atom *argv); 00519 void jdataview_editcell(t_object *dv, t_symbol *colname, t_rowref rr); 00520 int jdataview_iscelltextselected(t_object *dv, char justfocused); 00521 void jdataview_cellclear(t_object *dv); 00522 void jdataview_cellcut(t_object *dv); 00523 void jdataview_cellcopy(t_object *dv); 00524 void jdataview_cellpaste(t_object *dv); 00525 00526 int jdataview_getcellcomponent(t_object *dv, int columnId, int rowNumber, long *options); 00527 int jdataview_getcellfiletypes(t_object *dv, t_symbol *colname, t_rowref rr, long *count, long **types, char *alloc); 00528 t_symbol *jdataview_getcellfilterval(t_object *dv, t_symbol *colname, t_rowref rr); 00529 void jdataview_redrawcell(t_object *dv, t_symbol *colname, t_rowref rr); 00530 void jdataview_begincellchange(t_object *dv, t_symbol *colname, t_rowref rr); 00531 void jdataview_endcellchange(t_object *dv, t_symbol *colname, t_rowref rr); 00532 void jdataview_selected(t_object *dv, t_symbol *colname, t_rowref rr); 00533 void jdataview_selectedrow(t_object *dv, t_rowref rr); 00534 void jdataview_doubleclick(t_object *dv, t_symbol *colname, t_rowref rr); 00535 void jdataview_contextualclick(t_object *dv, t_symbol *colname, t_rowref rr); 00536 void jdataview_getcellicon(t_object *dv, t_symbol *colname, t_rowref rr, t_jsurface **surf); 00537 void jdataview_getrowcolor(t_object *dv, t_rowref rr, long isoddrow, t_jrgba *c); 00538 int jdataview_colorbycell(t_object *dv); 00539 void jdataview_getcellcolor(t_object *dv, t_symbol *colname, t_rowref rr, long isoddrow, t_jrgba *c); 00540 int jdataview_getcustomselectcolor(t_object *dv); 00541 void jdataview_setcustomselectcolor(t_object *dv, int way); 00542 double jdataview_getcellindent(t_object *dv, t_symbol *colname, t_rowref rr); 00543 void jdataview_cellenter(t_object *dv, t_symbol *colname, t_rowref rr); 00544 void jdataview_cellexit(t_object *dv, t_symbol *colname, t_rowref rr); 00545 00546 int jdataview_getcelleditable(t_object *dv, t_symbol *colname, t_rowref rr); 00547 00548 long jdataview_getbordercolor(t_object *dv, t_jrgba *c); // returns non-zero if border color set 00549 void jdataview_setbordercolor(t_object *dv, t_jrgba *c); 00550 00551 long jdataview_getusesystemfont(t_object *dv); 00552 void jdataview_setusesystemfont(t_object *dv, long way); 00553 00554 void jdataview_enablecell(t_object *dv, t_symbol *colname, t_rowref rr, long way); 00555 void jdataview_forcecellvisible(t_object *x, t_symbol *colname, t_rowref rr); 00556 00557 // DataViewComponent calls this for a custom paint method for a column 00558 00559 void jdataview_clientpaintcell(t_object *dv, t_symbol *msg, t_object *pv, int columnId, int rowNumber, int width, int height, int rowIsSelected); 00560 00561 // custom paint method should be declared as: 00562 // void myobject_paint(t_myobject *x, t_object *patcherview, t_symbol *colname, t_rowref rr, int width, int height, int rowIsSelected) 00563 // to obtain the graphics context call patcherview_getjgraphics() on the patcherview arg 00564 // use jcolumn_setcustompaint to set the message symbol for this method for a column 00565 00566 // the jdataview doesn't hold data. It just sends messages to an owning object to display it 00567 // the messages may be cached for speed. The first level interface just defines a textual 00568 // display. Eventually there will be a custom component for a row. 00569 00570 // sorting: columns can be textual (c_numeric == 0) or numeric or they can define a custom sort 00571 // method by calling jcolumn_setcustomsort to a symbol. This symbol names a method that will be 00572 // called to sort the data for this column. It is of the form: 00573 // long myobject_sort(t_rowref a, t_rowref b) -- which will be passed two rowrefs. In addition, 00574 // custom sort clients need to implement the sortdata message, which is passed a pointer to 00575 // a t_privatesortrec. It needs to store this statically as it is sent before the custom sort message is 00576 // received. 00577 void jdataview_getcolumnmenuforcell(t_object *dv, t_symbol *colname, t_rowref rr, long *argc, t_atom **argv, char **enabled); 00578 void jdataview_cellcolumnmenuresult(t_object *dv, t_symbol *colname, t_rowref rr, long result); 00579 00580 void jdataview_sortcolumn(t_object *x, t_symbol *colname, int fwd); 00581 void jdataview_sort(t_object *x, t_symbol *colname, int fwd); 00582 void jdataview_resort(t_object *x); 00583 long jdataview_getsortcolumn(t_object *x); 00584 00585 // selection 00586 00587 void jdataview_selectcell(t_object *dv, t_symbol *colname, t_rowref rr); 00588 void jdataview_selectrow(t_jdataview *x, t_rowref rr); 00589 void jdataview_selectcolumn(t_jdataview *x, t_symbol *colname); 00590 void jdataview_selectallrows(t_jdataview *x); 00591 00592 long jdataview_iscellselected(t_jdataview *x, t_symbol *colname, t_rowref rr); 00593 long jdataview_isrowselected(t_jdataview *x, t_rowref rr); 00594 long jdataview_iscolumnselected(t_jdataview *x, t_symbol *colname); 00595 00596 void jdataview_savecolumnwidths(t_object *dv, t_dictionary **d); 00597 void jdataview_restorecolumnwidths(t_object *dv, t_dictionary *d); 00598 00599 void jdataview_updatefontpanelforclient(t_object *dv, long show); 00600 00601 // utilities for painting 00602 00603 void jdataview_redrawrow(t_object *dv, t_rowref rr); 00604 00605 00606 #ifdef CUSTOMPAINT 00607 void jdataview_getcellrect(t_jdataview *x, t_symbol *colname, t_rowref rr, t_rect *r); 00608 t_max_err jdataview_jgraphics_from_paintcontext(t_jdataview *x, void *ctx, t_jgraphics **g); 00609 #endif 00610 00611 // handle resizing 00612 00613 long jdataview_containersize(t_object *dv, double cw, double ch, double *width, double *height); 00614 00615 void jdataview_forcecellvisible(t_object *x, t_symbol *colname, t_rowref rr); 00616 00617 00618 // messages to the owner 00619 00620 t_object *jdataview_getrowobject(t_object *dv, t_rowref rr); // return object associated with the row, if any (used for dragging) 00621 00622 /* 00623 00624 -- "columncreated": notification of a column being created 00625 00626 void myobject_columncreated(t_myobject *x, t_symbol *colname); 00627 00628 -- "rowadded" / "rowdeleted": notification of a row being added / deleted 00629 00630 void myobject_rowadded(t_myobject *x, t_rowref rr); 00631 void myobject_rowdeleted(t_myobject *x, t_rowref rr); 00632 00633 -- "sortstarted": notification of a sort starting (will get sort messages) 00634 00635 void myobject_sortstarted(t_myobject *x, t_symbol *colname, long direction); 00636 00637 -- "compare": sort the data according to column / direction, return 1 if r1 > r2, -1 if r2 > r1 00638 00639 long myobject_compare(t_myobject *x, t_symbol *colname, long direction, t_rowref r1, t_rowref r2); 00640 00641 -- "gettext": get string to show in a cell 00642 00643 void myobject_gettext(t_myobject *x, t_symbol *colname, t_rowref rr, char *text); 00644 00645 -- "editstarted": notification that editing is starting in a cell 00646 00647 void myobject_editstarted(t_myobject *x, t_symbol *colname, t_rowref rr); 00648 00649 -- "editentered": editing has finished and here is some new text for a cell 00650 00651 void myobject_editenter(t_myobject *x, t_symbol *colname, t_rowref rr, char *newtext); 00652 00653 // plus, a message specific to a button clicked in a cell (this allows for multiple buttons per column) 00654 00655 void myobject_buttonmessage(t_myobject *x, t_symbol *colname, t_rowref rr, t_symbol *msg); 00656 00657 // editing operations, "cutcell", "copycell", "pastecell", "clearcell" 00658 00659 void myobject_cutcell(t_myobject *x, t_symbol *colname, t_rowref rr); 00660 void myobject_copycell(t_myobject *x, t_symbol *colname, t_rowref rr); 00661 void myobject_pastecell(t_myobject *x, t_symbol *colname, t_rowref rr); 00662 void myobject_clearcell(t_myobject *x, t_symbol *colname, t_rowref rr); 00663 00664 // "cutcolumn", "copycolumn", "pastecolumn", "clearcolumn" 00665 00666 void myobject_cutcolumn(t_myobject *x, t_symbol *colname); 00667 void myobject_copycolumn(t_myobject *x, t_symbol *colname); 00668 void myobject_pastecolumn(t_myobject *x, t_symbol *colname); 00669 void myobject_clearcolumn(t_myobject *x, t_symbol *colname); 00670 00671 // "cutrow", "copyrow", "pasterow", "clearrow", "deleterow" 00672 00673 void myobject_cutrow(t_myobject *x, t_rowref rr); 00674 void myobject_copyrow(t_myobject *x, t_rowref rr); 00675 void myobject_pasterow(t_myobject *x, t_rowref rr); 00676 void myobject_clearrow(t_myobject *x, t_rowref rr); 00677 void myobject_deleterow(t_myobject *x, t_rowref rr); 00678 00679 // customization: an object can have a paintcell method instead of displaying text 00680 00681 void myobject_paintcell(t_myobject *x, t_symbol *colname, t_rowref rr, void *ctx); 00682 00683 // implementation notes: 00684 00685 JUCE refreshComponentForCell needs to have the ability to create a custom component given a 00686 class name. How can that be done, with templates? 00687 00688 Yes you can use template argument passed to new, i.e., 00689 00690 template<class T> 00691 blah<T>::blah 00692 { 00693 foo (which could be a member of blah?) = new T; 00694 } 00695 00696 */ 00697 00698 END_USING_C_LINKAGE 00699 00700 #endif // _JDATAVIEW_H_
Copyright © 2008, Cycling '74