Max 5 API Reference
00001 #ifndef _JPATCHER_API_H_ 00002 #define _JPATCHER_API_H_ 00003 00004 #include "jpatcher_syms.h" 00005 00006 BEGIN_USING_C_LINKAGE 00007 00008 #if C74_PRAGMA_STRUCT_PACKPUSH 00009 #pragma pack(push, 2) 00010 #elif C74_PRAGMA_STRUCT_PACK 00011 #pragma pack(2) 00012 #endif 00013 00014 00015 #define JPATCHER_API_CURRENT_FILE_VERSION 1 00016 00017 00018 // ddz changed enum below to a mask so it can be returned by clipboard_datatypes() 00019 00020 typedef enum _clipboard_datatype { 00021 JCLIPBOARD_TYPE_TEXT = 1, 00022 JCLIPBOARD_TYPE_BINBUF = 2, 00023 JCLIPBOARD_TYPE_JSON = 4, 00024 JCLIPBOARD_TYPE_IMAGE = 8, 00025 JCLIPBOARD_TYPE_JSON_ATTRIBUTES = 16, 00026 JCLIPBOARD_TYPE_UNKNOWN = 256 00027 } t_clipboard_datatype; 00028 00029 00030 00031 t_symbol *fontmap_getmapping(t_symbol *from, char *mapped); 00032 double fontinfo_getsize(short oldsize); // tranlsate max 4.6 font size to max 5 font size 00033 t_symbol *fontinfo_getname(short number); 00034 short fontinfo_getnumber(t_symbol *s); 00035 00036 00037 // Core structs 00038 00039 /** 00040 Coordinates for specifying a rectangular region. 00041 @ingroup datatypes 00042 @see t_pt 00043 @see t_size */ 00044 typedef struct _rect 00045 { 00046 double x; ///< The horizontal origin 00047 double y; ///< The vertical origin 00048 double width; ///< The width 00049 double height; ///< The height 00050 } t_rect; 00051 00052 00053 /** 00054 Coordinates for specifying a point. 00055 @ingroup datatypes 00056 @see t_rect 00057 @see t_size */ 00058 typedef struct _pt 00059 { 00060 double x; ///< The horizontal coordinate 00061 double y; ///< The vertical coordinate 00062 } t_pt; 00063 00064 00065 /** 00066 Coordinates for specifying the size of a region. 00067 @ingroup datatypes 00068 @see t_rect 00069 @see t_pt */ 00070 typedef struct _size 00071 { 00072 double width; ///< The width 00073 double height; ///< The height 00074 } t_size; 00075 00076 00077 /** A color composed of red, green, and blue components. 00078 Typically such a color is assumed to be completely opaque (with no transparency). 00079 @ingroup color 00080 @see t_jrgba */ 00081 typedef struct _jrgb { 00082 double red; ///< Red component in the range [0.0, 1.0] 00083 double green; ///< Green component in the range [0.0, 1.0] 00084 double blue; ///< Blue component in the range [0.0, 1.0] 00085 } t_jrgb; 00086 00087 00088 /** A color composed of red, green, blue, and alpha components. 00089 @ingroup color */ 00090 typedef struct _jrgba { 00091 double red; ///< Red component in the range [0.0, 1.0] 00092 double green; ///< Green component in the range [0.0, 1.0] 00093 double blue; 00094 double alpha; ///< Alpha (transparency) component in the range [0.0, 1.0] 00095 } t_jrgba; 00096 00097 00098 /** 00099 The t_jboxdrawparams structure. This struct is provided for debugging convenience, 00100 but should be considered opaque and is subject to change without notice. 00101 00102 @ingroup jbox 00103 */ 00104 typedef struct _jboxdrawparams { 00105 float d_inletheight; 00106 float d_inletvoffset; 00107 float d_outletheight; 00108 float d_outletvoffset; 00109 float d_reserved1; // was d_inletinset. unused and can chop but will require rebuild all so for now I'm renaming 00110 float d_cornersize; // how rounded is the box 00111 float d_borderthickness; 00112 t_jrgba d_bordercolor; 00113 t_jrgba d_boxfillcolor; 00114 } t_jboxdrawparams; 00115 00116 #define JBOX_SPOOL_CONTENTS 1 00117 #define JBOX_SPOOL_WHOLEBOX 2 00118 00119 00120 /** The t_jbox struct provides the header for a Max user-interface object. 00121 This struct should be considered opaque and is subject to change without notice. 00122 Do not access it's members directly any code. 00123 00124 @ingroup patcher 00125 */ 00126 typedef struct _jbox 00127 { 00128 t_object b_ob; 00129 void *obex; 00130 t_object *b_patcher; 00131 t_rect b_patching_rect; 00132 t_rect b_presentation_rect; 00133 t_symbol *b_name; 00134 t_symbol *b_id; // immutable box ID 00135 t_object *b_firstin; // the object, could be the box 00136 t_object *b_textfield; // optional text field. 00137 t_symbol *b_fontname; 00138 double b_fontsize; 00139 char* b_hint; 00140 t_jrgba b_color; 00141 double b_unused; // we can chop this or make it do something different 00142 void *b_binbuf; // really an atombuf :) 00143 long b_temp; 00144 char b_spooled; 00145 char b_hidden; 00146 char b_hilitable; 00147 char b_background; 00148 char b_ignoreclick; 00149 char b_bogus; 00150 char b_drawfirstin; 00151 char b_outline; 00152 char b_growy; 00153 char b_growboth; 00154 char b_nogrow; 00155 char b_drawinlast; 00156 char b_paintoverchildren; 00157 char b_mousedragdelta; // hide mouse during drag, and send mousedragdelta instead of mousedrag for infinite scrolling 00158 char b_presentation; 00159 char b_drawiolocked; 00160 char b_dragactive; 00161 char b_drawbackground; 00162 char b_hinttrack; 00163 char b_fontface; 00164 char *b_annotation; 00165 char b_opaque; 00166 char b_useimagebuffer; 00167 char b_noinspectfirstin; 00168 char b_editactive; // editing via inspector 00169 t_symbol *b_prototypename; 00170 void *b_preserved7; 00171 void *b_preserved8; 00172 } t_jbox; 00173 00174 00175 // selection information -- private 00176 typedef struct _pvselinfo 00177 { 00178 long nboxselect; 00179 long nlineselect; 00180 long nselboxhidden; // how many of the selected boxes are hidden 00181 long nsellinehidden; // how many of the selected lines are hidden 00182 long ncanignoreclick; // how many of the selected items could accept the ingore click command 00183 long ncanrespondtoclick;// how many of the selected items could accept the respond to click command 00184 long nbg; // how many of the selected items are in the background 00185 long nboxcolorable; // how many respond to the color message 00186 long colorindex; // index if one object is selected 00187 long nselboxbg; // how many of the selected boxes are in the background 00188 long nboxinfo; // how many of the selected boxes respond to the info message 00189 long nboxfixwidth; // how many of the selected boxes respond to the fixwidth message 00190 long nboxpatcher; // how many of the selected boxes are patchers 00191 long nboxpresent; // how many of the selected boxes are in the presentation 00192 long nwiretaplines; // how many of the selected lines have wiretaps (breakpoint + monitor) 00193 long nenabledwiretaplines; // how many of the selected lines are enabled 00194 long sameclass; // are all selected items of the same class (true for one object, N patchlines, or N boxes of the same class) 00195 long editbox; // is a text box currently being edited 00196 } t_pvselinfo; 00197 00198 00199 // jpatcher interface 00200 00201 /** Gets the value of a #t_rect attribute, given its parent object and name. 00202 Do not use this on a jbox object -- use jbox_get_rect_for_view() instead! 00203 00204 @ingroup attr 00205 @param o The attribute's parent object 00206 @param name The attribute's name 00207 @param rect The address of a valid #t_rect whose values will be filled-in from the attribute. 00208 00209 @return This function returns the error code #MAX_ERR_NONE if successful, 00210 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00211 t_max_err object_attr_get_rect(t_object *o, t_symbol *name, t_rect *rect); 00212 00213 /** Sets the value of a #t_rect attribute, given its parent object and name. 00214 Do not use this on a jbox object -- use jbox_get_rect_for_view() instead! 00215 00216 @ingroup attr 00217 @param o The attribute's parent object 00218 @param name The attribute's name 00219 @param rect The address of a valid #t_rect whose values will be used to set the attribute. 00220 00221 @return This function returns the error code #MAX_ERR_NONE if successful, 00222 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00223 t_max_err object_attr_set_rect(t_object *o, t_symbol *name, t_rect *rect); 00224 00225 00226 /** Gets the value of a #t_pt attribute, given its parent object and name. 00227 00228 @ingroup attr 00229 @param o The attribute's parent object 00230 @param name The attribute's name 00231 @param pt The address of a valid #t_pt whose values will be filled-in from the attribute. 00232 00233 @return This function returns the error code #MAX_ERR_NONE if successful, 00234 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00235 t_max_err object_attr_getpt(t_object *o, t_symbol *name, t_pt *pt); 00236 00237 /** Sets the value of a #t_pt attribute, given its parent object and name. 00238 00239 @ingroup attr 00240 @param o The attribute's parent object 00241 @param name The attribute's name 00242 @param pt The address of a valid #t_pt whose values will be used to set the attribute. 00243 00244 @return This function returns the error code #MAX_ERR_NONE if successful, 00245 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00246 t_max_err object_attr_setpt(t_object *o, t_symbol *name, t_pt *pt); 00247 00248 00249 /** Gets the value of a #t_size attribute, given its parent object and name. 00250 00251 @ingroup attr 00252 @param o The attribute's parent object 00253 @param name The attribute's name 00254 @param size The address of a valid #t_size whose values will be filled-in from the attribute. 00255 00256 @return This function returns the error code #MAX_ERR_NONE if successful, 00257 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00258 t_max_err object_attr_getsize(t_object *o, t_symbol *name, t_size *size); 00259 00260 /** Sets the value of a #t_size attribute, given its parent object and name. 00261 00262 @ingroup attr 00263 @param o The attribute's parent object 00264 @param name The attribute's name 00265 @param size The address of a valid #t_size whose values will be used to set the attribute. 00266 00267 @return This function returns the error code #MAX_ERR_NONE if successful, 00268 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00269 t_max_err object_attr_setsize(t_object *o, t_symbol *name, t_size *size); 00270 00271 00272 /** Gets the value of a #t_jrgba attribute, given its parent object and name. 00273 00274 @ingroup attr 00275 @param b The attribute's parent object 00276 @param attrname The attribute's name 00277 @param prgba The address of a valid #t_jrgba whose values will be filled-in from the attribute. 00278 00279 @return This function returns the error code #MAX_ERR_NONE if successful, 00280 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00281 t_max_err object_attr_getcolor(t_object *b, t_symbol *attrname, t_jrgba *prgba); 00282 00283 /** Sets the value of a #t_jrgba attribute, given its parent object and name. 00284 00285 @ingroup attr 00286 @param b The attribute's parent object 00287 @param attrname The attribute's name 00288 @param prgba The address of a valid #t_jrgba whose values will be used to set the attribute. 00289 00290 @return This function returns the error code #MAX_ERR_NONE if successful, 00291 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00292 t_max_err object_attr_setcolor(t_object *b, t_symbol *attrname, t_jrgba *prgba); 00293 00294 00295 /** Get the value of a #t_jrgba struct, returned as an array of atoms with the values for each component. 00296 00297 @ingroup color 00298 @param jrgba The color struct whose color will be retrieved. 00299 @param argc The address of a variable that will be set with the number of atoms in the argv array. 00300 The returned value should be 4. 00301 The value of the int should be set to 0 prior to calling this function. 00302 @param argv The address of a #t_atom pointer that will receive the a new array of atoms set to the values of the jrgba struct. 00303 The pointer should be set to NULL prior to calling this function. 00304 There should be 4 atoms returned, representing alpha, red, green, and blue components. 00305 When you are done using the atoms, you are responsible for freeing the pointer using sysmem_freeptr(). 00306 @return This function returns the error code #MAX_ERR_NONE if successful, 00307 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00308 t_max_err jrgba_attr_get(t_jrgba *jrgba, long *argc, t_atom **argv); 00309 00310 /** Set the value of a #t_jrgba struct, given an array of atoms with the values to use. 00311 00312 @ingroup color 00313 @param jrgba The color struct whose color will be set. 00314 @param argc The number of atoms in the array. This must be 4. 00315 @param argv The address of the first of the atoms in the array. 00316 There must be 4 atoms, representing alpha, red, green, and blue components. 00317 00318 @return This function returns the error code #MAX_ERR_NONE if successful, 00319 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 00320 t_max_err jrgba_attr_set(t_jrgba *jrgba, long argc, t_atom *argv); 00321 00322 00323 00324 00325 // various utilities 00326 void set_jrgba_from_palette_index(short index, t_jrgba *jrgba); 00327 void set_jrgba_from_boxcolor_index(short index, t_jrgba *jrgba); 00328 short get_boxcolor_index_from_jrgba(t_jrgba *jrgba); 00329 void jgraphics_clip_rgba(t_jrgba *rgba); 00330 00331 00332 /** Open the help patcher for a given instance of an object. 00333 @ingroup obj 00334 @param x The object instance for which to open the help patcher. */ 00335 void object_openhelp(t_object *x); 00336 00337 /** Open the reference page for a given instance of an object. 00338 @ingroup obj 00339 @param x The object instance for which to open the reference page. */ 00340 void object_openrefpage(t_object *x); 00341 00342 /** Open a search in the file browser for files with the name of the given object. 00343 @ingroup obj 00344 @param x The object instance for which to query. */ 00345 void object_openquery(t_object *x); 00346 00347 00348 /** Open the help patcher for a given object class name. 00349 @ingroup obj 00350 @param classname The class name for which to open the help patcher. */ 00351 void classname_openhelp(char *classname); 00352 00353 /** Open the reference page for a given object class name. 00354 @ingroup obj 00355 @param classname The class name for which to open the reference page.*/ 00356 void classname_openrefpage(char *classname); 00357 00358 /** Open a search in the file browser for files with the name of the given class. 00359 @ingroup obj 00360 @param classname The class name for which to query. */ 00361 void classname_openquery(char *classname); 00362 00363 00364 /** Find a patcherview at the given screen coords. 00365 @ingroup jpatcherview 00366 @param x The horizontal coordinate at which to find a patcherview. 00367 @param y The vertical coordinate at which to find a patcherview. 00368 @return A pointer to the patcherview at the specified location, 00369 or NULL if no patcherview exists at that location. */ 00370 t_object* patcherview_findpatcherview(int x, int y); 00371 00372 00373 // private (initialize object palette -- separated so it can be moved to optimize startup experience) 00374 void patcherview_makepalette(void); 00375 00376 00377 // Utilities to get/set patcher attributes 00378 00379 /** Determine of a #t_object* is a patcher object. 00380 @ingroup jpatcher 00381 @param p The object pointer to test. 00382 @return Returns true if the object is a patcher, otherwise returns non-zero. */ 00383 int jpatcher_is_patcher(t_object *p); 00384 00385 /** If a patcher is inside a box, return its box. 00386 @ingroup jpatcher 00387 @param p The patcher to be queried. 00388 @return A pointer to the box containing the patcher, otherwise NULL. */ 00389 t_object* jpatcher_get_box(t_object *p); 00390 00391 /** Determine the number of boxes in a patcher. 00392 @ingroup jpatcher 00393 @param p The patcher to be queried. 00394 @return The number of boxes in the patcher. */ 00395 long jpatcher_get_count(t_object *p); 00396 00397 00398 /** To determine whether a patcher is currently in a locked state, 00399 you should actually query the patcherview using patcherview_get_locked(). 00400 This is because, for any given patcher, there may be multiple views with differing locked states. 00401 00402 @param p The patcher to be queried. 00403 @return True if the patcher is locked, otherwise false. 00404 @see patcherview_get_locked() */ 00405 char jpatcher_get_locked(t_object *p); 00406 00407 /** Lock or unlock a patcher. 00408 @ingroup jpatcher 00409 @param p The patcher whose locked state will be changed. 00410 @param c Pass true to lock a patcher, otherwise pass false. 00411 @return A Max error code. */ 00412 t_max_err jpatcher_set_locked(t_object *p, char c); 00413 00414 00415 /** Determine whether a patcher is currently in presentation mode. 00416 @ingroup jpatcher 00417 @param p The patcher to be queried. 00418 @return True if the patcher is in presentation mode, otherwise false. */ 00419 char jpatcher_get_presentation(t_object *p); 00420 00421 /** Set a patcher to presentation mode. 00422 @ingroup jpatcher 00423 @param p The patcher whose locked state will be changed. 00424 @param c Pass true to switch the patcher to presentation mode, otherwise pass false. 00425 @return A Max error code. */ 00426 t_max_err jpatcher_set_presentation(t_object *p, char c); 00427 00428 00429 /** Get the first box in a patcher. 00430 All boxes in a patcher are maintained internally in a #t_linklist. 00431 Use this function together with jbox_get_nextobject() to traverse a patcher. 00432 @ingroup jpatcher 00433 @param p The patcher to be queried. 00434 @return The first box in a patcher. 00435 @see jbox_get_prevobject() 00436 jbox_get_nextobject() 00437 jpatcher_get_lastobject() */ 00438 t_object* jpatcher_get_firstobject(t_object *p); 00439 00440 /** Get the last box in a patcher. 00441 All boxes in a patcher are maintained internally in a #t_linklist. 00442 Use this function together with jbox_get_prevobject() to traverse a patcher. 00443 @ingroup jpatcher 00444 @param p The patcher to be queried. 00445 @return The last box in a patcher. 00446 @see jbox_get_prevobject() 00447 jbox_get_nextobject() 00448 jpatcher_get_firstobject() */ 00449 t_object* jpatcher_get_lastobject(t_object *p); 00450 00451 00452 /** Get the first line (patch-cord) in a patcher. 00453 All lines in a patcher are maintained internally in a #t_linklist. 00454 Use this function to begin traversing a patcher's lines. 00455 @ingroup jpatcher 00456 @param p The patcher to be queried. 00457 @return The first jpatchline in a patcher. */ 00458 t_object* jpatcher_get_firstline(t_object *p); 00459 00460 /** Get the first view (jpatcherview) for a given patcher. 00461 All views of a patcher are maintained internally as a #t_linklist. 00462 Use this function to begin traversing a patcher's views. 00463 @ingroup jpatcher 00464 @param p The patcher to be queried. 00465 @return The first view of a patcher. */ 00466 t_object* jpatcher_get_firstview(t_object *p); 00467 00468 00469 /** Retrieve a patcher's title. 00470 @ingroup jpatcher 00471 @param p The patcher to be queried. 00472 @return The patcher's title. */ 00473 t_symbol* jpatcher_get_title(t_object *p); 00474 00475 /** Set a patcher's title. 00476 @ingroup jpatcher 00477 @param p The patcher whose locked state will be changed. 00478 @param ps The new title for the patcher. 00479 @return A Max error code. */ 00480 t_max_err jpatcher_set_title(t_object *p, t_symbol *ps); 00481 00482 00483 /** Retrieve a patcher's name. 00484 @ingroup jpatcher 00485 @param p The patcher to be queried. 00486 @return The patcher's name. */ 00487 t_symbol* jpatcher_get_name(t_object *p); 00488 00489 /** Retrieve a patcher's file path. 00490 @ingroup jpatcher 00491 @param p The patcher to be queried. 00492 @return The patcher's file path. */ 00493 t_symbol* jpatcher_get_filepath(t_object *p); 00494 00495 /** Retrieve a patcher's file name. 00496 @ingroup jpatcher 00497 @param p The patcher to be queried. 00498 @return The patcher's file name. */ 00499 t_symbol* jpatcher_get_filename(t_object *p); 00500 00501 00502 /** Determine whether a patcher's dirty bit has been set. 00503 @ingroup jpatcher 00504 @param p The patcher to be queried. 00505 @return True if the patcher is dirty, otherwise false. */ 00506 char jpatcher_get_dirty(t_object *p); 00507 00508 /** Set a patcher's dirty bit. 00509 @ingroup jpatcher 00510 @param p The patcher whose dirty bit will be set. 00511 @param c The new value for the patcher's dirty bit (pass true or false). 00512 @return A Max error code. */ 00513 t_max_err jpatcher_set_dirty(t_object *p, char c); 00514 00515 00516 /** Determine whether a patcher's background layer is locked. 00517 @ingroup jpatcher 00518 @param p The patcher to be queried. 00519 @return True if the background layer is locked, otherwise false. */ 00520 char jpatcher_get_bglocked(t_object *p); 00521 00522 /** Set whether a patcher's background layer is locked. 00523 @ingroup jpatcher 00524 @param p The patcher whose dirty bit will be set. 00525 @param c Pass true to lock the patcher's background layer, otherwise pass false. 00526 @return A Max error code. */ 00527 t_max_err jpatcher_set_bglocked(t_object *p, char c); 00528 00529 00530 /** Determine whether a patcher's background layer is hidden. 00531 @ingroup jpatcher 00532 @param p The patcher to be queried. 00533 @return True if the background layer is hidden, otherwise false. */ 00534 char jpatcher_get_bghidden(t_object *p); 00535 00536 /** Set whether a patcher's background layer is hidden. 00537 @ingroup jpatcher 00538 @param p The patcher whose dirty bit will be set. 00539 @param c Pass true to hide the patcher's background layer, otherwise pass false. 00540 @return A Max error code. */ 00541 t_max_err jpatcher_set_bghidden(t_object *p, char c); 00542 00543 00544 /** Determine whether a patcher's foreground layer is hidden. 00545 @ingroup jpatcher 00546 @param p The patcher to be queried. 00547 @return True if the foreground layer is hidden, otherwise false. */ 00548 char jpatcher_get_fghidden(t_object *p); 00549 00550 /** Set whether a patcher's foreground layer is hidden. 00551 @ingroup jpatcher 00552 @param p The patcher whose dirty bit will be set. 00553 @param c Pass true to hide the patcher's foreground layer, otherwise pass false. 00554 @return A Max error code. */ 00555 t_max_err jpatcher_set_fghidden(t_object *p, char c); 00556 00557 00558 // TODO: unused? 00559 // t_object* jpatcher_get_font(t_object *p); 00560 00561 00562 /** Retrieve a patcher's editing background color. 00563 @ingroup jpatcher 00564 @param p The patcher to be queried. 00565 @param prgba The address of a valid #t_jrgba struct that will be filled-in with the current patcher color values. 00566 @return A Max error code. */ 00567 t_max_err jpatcher_get_editing_bgcolor(t_object *p, t_jrgba *prgba); 00568 00569 /** Set a patcher's editing background color. 00570 @ingroup jpatcher 00571 @param p The patcher to be queried. 00572 @param prgba The address of a #t_jrgba struct containing the new color to use. 00573 @return A Max error code. */ 00574 t_max_err jpatcher_set_editing_bgcolor(t_object *p, t_jrgba *prgba); 00575 00576 00577 /** Retrieve a patcher's locked background color. 00578 @ingroup jpatcher 00579 @param p The patcher to be queried. 00580 @param prgba The address of a valid #t_jrgba struct that will be filled-in with the current patcher color values. 00581 @return A Max error code. */ 00582 t_max_err jpatcher_get_bgcolor(t_object *p, t_jrgba *prgba); 00583 00584 /** Set a patcher's locked background color. 00585 @ingroup jpatcher 00586 @param p The patcher to be queried. 00587 @param prgba The address of a #t_jrgba struct containing the new color to use. 00588 @return A Max error code. */ 00589 t_max_err jpatcher_set_bgcolor(t_object *p, t_jrgba *prgba); 00590 00591 00592 /** Retrieve a patcher's grid size. 00593 @ingroup jpatcher 00594 @param p The patcher to be queried. 00595 @param gridsizeX The address of a double that will be set to the current horizontal grid spacing for the patcher. 00596 @param gridsizeY The address of a double that will be set to the current vertical grid spacing for the patcher. 00597 @return A Max error code. */ 00598 t_max_err jpatcher_get_gridsize(t_object *p, double *gridsizeX, double *gridsizeY); 00599 00600 /** Set a patcher's grid size. 00601 @ingroup jpatcher 00602 @param p The patcher to be queried. 00603 @param gridsizeX The new horizontal grid spacing for the patcher. 00604 @param gridsizeY The new vertical grid spacing for the patcher. 00605 @return A Max error code. */ 00606 t_max_err jpatcher_set_gridsize(t_object *p, double gridsizeX, double gridsizeY); 00607 00608 00609 // private 00610 t_object* jpatcher_get_controller(t_object *p); 00611 00612 00613 /** Delete an object that is in a patcher. 00614 @ingroup jpatcher 00615 @param p The patcher. 00616 @param b The object box to delete. */ 00617 void jpatcher_deleteobj(t_object *p, t_jbox *b); 00618 00619 00620 /** Given a patcher, return its parent patcher. 00621 @ingroup jpatcher 00622 @param p The patcher to be queried. 00623 @return The patcher's parent patcher, if there is one. 00624 If there is no parent patcher (this is a top-level patcher) then NULL is returned. */ 00625 t_object* jpatcher_get_parentpatcher(t_object *p); 00626 00627 /** Given a patcher, return the top-level patcher for the tree in which it exists. 00628 @ingroup jpatcher 00629 @param p The patcher to be queried. 00630 @return The patcher's top-level parent patcher. */ 00631 t_object* jpatcher_get_toppatcher(t_object *p); 00632 00633 00634 // unused 00635 t_symbol* jpatcher_get_maxclass(t_object *p); 00636 t_symbol* jpatcher_get_parentclass(t_object *p); 00637 00638 00639 /** Query a patcher to determine its location and size. 00640 @ingroup jpatcher 00641 @param p A pointer to a patcher instance. 00642 @param pr The address of valid #t_rect whose values will be filled-in upon return. 00643 @return A Max error code. */ 00644 t_max_err jpatcher_get_rect(t_object *p, t_rect *pr); 00645 00646 /** Set a patcher's location and size. 00647 @ingroup jpatcher 00648 @param p A pointer to a patcher instance. 00649 @param pr The address of a #t_rect with the new position and size. 00650 @return A Max error code. */ 00651 t_max_err jpatcher_set_rect(t_object *p, t_rect *pr); 00652 00653 00654 /** Query a patcher to determine the location and dimensions of its window when initially opened. 00655 @ingroup jpatcher 00656 @param p A pointer to a patcher instance. 00657 @param pr The address of valid #t_rect whose values will be filled-in upon return. 00658 @return A Max error code. */ 00659 t_max_err jpatcher_get_defrect(t_object *p, t_rect *pr); 00660 00661 /** Set a patcher's default location and size. 00662 @ingroup jpatcher 00663 @param p A pointer to a patcher instance. 00664 @param pr The address of a #t_rect with the new position and size. 00665 @return A Max error code. */ 00666 t_max_err jpatcher_set_defrect(t_object *p, t_rect *pr); 00667 00668 00669 // private 00670 char jpatcher_get_noedit(t_object *p); 00671 t_object *jpatcher_get_collective(t_object *p); 00672 char jpatcher_get_cansave(t_object *p); 00673 00674 00675 /** Generate a unique name for a box in patcher. 00676 @ingroup jpatcher 00677 @param p A pointer to a patcher instance. 00678 @param classname The name of an object's class. 00679 @return The newly-generated unique name. 00680 @remark This is the function used by pattr to assign names to objects in a patcher. */ 00681 t_symbol *jpatcher_uniqueboxname(t_object *p, t_symbol *classname); 00682 00683 00684 // private 00685 short jpatcher_getboxfont(t_object *p, short fnum, double *fsize, t_symbol **fontname); 00686 00687 00688 /** Return the name of the default font used for new objects in a patcher. 00689 @ingroup jpatcher 00690 @param p A pointer to a patcher instance. 00691 @return The name of the default font used for new objects in a patcher. 00692 */ 00693 t_symbol *jpatcher_get_default_fontname(t_object *p); 00694 00695 00696 /** Return the size of the default font used for new objects in a patcher. 00697 @ingroup jpatcher 00698 @param p A pointer to a patcher instance. 00699 @return The size of the default font used for new objects in a patcher. 00700 */ 00701 float jpatcher_get_default_fontsize(t_object *p); 00702 00703 00704 /** Return the index of the default font face used for new objects in a patcher. 00705 @ingroup jpatcher 00706 @param p A pointer to a patcher instance. 00707 @return The index of the default font face used for new objects in a patcher. 00708 */ 00709 long jpatcher_get_default_fontface(t_object *p); 00710 00711 00712 // private 00713 t_max_err jpatcher_set_imprint(t_object *p, char c); 00714 char jpatcher_get_imprint(t_object *p); 00715 00716 // private (only used by jdatatest) 00717 void jpatcher_addboxlistener(t_object *p, t_object *listener); 00718 void jpatcher_removeboxlistener(t_object *p, t_object *listener); 00719 00720 00721 /** Return the file version of the patcher. 00722 @ingroup jpatcher 00723 @param p A pointer to the patcher whose version number is desired. 00724 @return The file version number. */ 00725 long jpatcher_get_fileversion(t_object *p); 00726 00727 /** Return the file version for any new patchers, e.g. the current version created by Max. 00728 @ingroup jpatcher 00729 @return The file version number. */ 00730 long jpatcher_get_currentfileversion(void); 00731 00732 00733 00734 00735 // Utilities to get/set box attributes 00736 00737 /** Find the rect for a box in a given patcherview. 00738 @ingroup jbox 00739 @param box The box whose rect will be fetched. 00740 @param patcherview A patcherview in which the box exists. 00741 @param rect The address of a valid #t_rect whose members will be filled in by this function. 00742 @return A Max error code. */ 00743 t_max_err jbox_get_rect_for_view(t_object *box, t_object *patcherview, t_rect *rect); 00744 00745 /** Change the rect for a box in a given patcherview. 00746 @ingroup jbox 00747 @param box The box whose rect will be changed. 00748 @param patcherview A patcherview in which the box exists. 00749 @param rect The address of a valid #t_rect that will replace the current values used by the box in the given view. 00750 @return A Max error code. */ 00751 t_max_err jbox_set_rect_for_view(t_object *box, t_object *patcherview, t_rect *rect); 00752 00753 /** Find the rect for a box with a given attribute name. 00754 @ingroup jbox 00755 @param box The box whose rect will be fetched. 00756 @param which The name of the rect attribute to be fetched, for example <tt>_sym_presentation_rect</tt> or <tt>_sym_patching_rect</tt>. 00757 @param pr The address of a valid #t_rect whose members will be filled in by this function. 00758 @return A Max error code. */ 00759 t_max_err jbox_get_rect_for_sym(t_object *box, t_symbol *which, t_rect *pr); 00760 00761 /** Change the rect for a box with a given attribute name. 00762 @ingroup jbox 00763 @param box The box whose rect will be changed. 00764 @param which The name of the rect attribute to be changed, for example <tt>_sym_presentation_rect</tt> or <tt>_sym_patching_rect</tt>. 00765 @param pr The address of a valid #t_rect that will replace the current values used by the box. 00766 @return A Max error code. */ 00767 t_max_err jbox_set_rect_for_sym(t_object *box, t_symbol *which, t_rect *pr); 00768 00769 00770 /** Set both the presentation rect and the patching rect. 00771 @ingroup jbox 00772 @param box The box whose rect will be changed. 00773 @param pr The address of a #t_rect with the new rect values. 00774 @return A Max error code. */ 00775 t_max_err jbox_set_rect(t_object *box, t_rect *pr); 00776 00777 /** Retrieve the patching rect of a box. 00778 @ingroup jbox 00779 @param box The box whose rect values will be retrieved. 00780 @param pr The address of a valid #t_rect whose values will be filled in. 00781 @return A Max error code. */ 00782 t_max_err jbox_get_patching_rect(t_object *box, t_rect *pr); 00783 00784 /** Change the patching rect of a box. 00785 @ingroup jbox 00786 @param box The box whose rect will be changed. 00787 @param pr The address of a #t_rect with the new rect values. 00788 @return A Max error code. */ 00789 t_max_err jbox_set_patching_rect(t_object *box, t_rect *pr); 00790 00791 /** Retrieve the presentation rect of a box. 00792 @ingroup jbox 00793 @param box The box whose rect values will be retrieved. 00794 @param pr The address of a valid #t_rect whose values will be filled in. 00795 @return A Max error code. */ 00796 t_max_err jbox_get_presentation_rect(t_object *box, t_rect *pr); 00797 00798 /** Change the presentation rect of a box. 00799 @ingroup jbox 00800 @param box The box whose rect will be changed. 00801 @param pr The address of a #t_rect with the new rect values. 00802 @return A Max error code. */ 00803 t_max_err jbox_set_presentation_rect(t_object *box, t_rect *pr); 00804 00805 00806 /** Set the position of a box for both the presentation and patching views. 00807 @ingroup jbox 00808 @param box The box whose position will be changed. 00809 @param pos The address of a #t_pt with the new x and y values. 00810 @return A Max error code. */ 00811 t_max_err jbox_set_position(t_object *box, t_pt *pos); 00812 00813 /** Fetch the position of a box for the patching view. 00814 @ingroup jbox 00815 @param box The box whose position will be retrieved. 00816 @param pos The address of a valid #t_pt whose x and y values will be filled in. 00817 @return A Max error code. */ 00818 t_max_err jbox_get_patching_position(t_object *box, t_pt *pos); 00819 00820 /** Set the position of a box for the patching view. 00821 @ingroup jbox 00822 @param box The box whose positon will be changed. 00823 @param pos The address of a #t_pt with the new x and y values. 00824 @return A Max error code. */ 00825 t_max_err jbox_set_patching_position(t_object *box, t_pt *pos); 00826 00827 /** Fetch the position of a box for the presentation view. 00828 @ingroup jbox 00829 @param box The box whose position will be retrieved. 00830 @param pos The address of a valid #t_pt whose x and y values will be filled in. 00831 @return A Max error code. */ 00832 t_max_err jbox_get_presentation_position(t_object *box, t_pt *pos); 00833 00834 /** Set the position of a box for the presentation view. 00835 @ingroup jbox 00836 @param box The box whose rect will be changed. 00837 @param pos The address of a #t_pt with the new x and y values. 00838 @return A Max error code. */ 00839 t_max_err jbox_set_presentation_position(t_object *box, t_pt *pos); 00840 00841 00842 /** Set the size of a box for both the presentation and patching views. 00843 @ingroup jbox 00844 @param box The box whose size will be changed. 00845 @param size The address of a #t_size with the new size values. 00846 @return A Max error code. */ 00847 t_max_err jbox_set_size(t_object *box, t_size *size); 00848 00849 /** Fetch the size of a box for the patching view. 00850 @ingroup jbox 00851 @param box The box whose size will be retrieved. 00852 @param size The address of a valid #t_size whose width and height values will be filled in. 00853 @return A Max error code. */ 00854 t_max_err jbox_get_patching_size(t_object *box, t_size *size); 00855 00856 /** Set the size of a box for the patching view. 00857 @ingroup jbox 00858 @param box The box whose size will be changed. 00859 @param size The address of a #t_size with the new width and height values. 00860 @return A Max error code. */ 00861 t_max_err jbox_set_patching_size(t_object *box, t_size *size); 00862 00863 /** Fetch the size of a box for the presentation view. 00864 @ingroup jbox 00865 @param box The box whose size will be retrieved. 00866 @param size The address of a valid #t_size whose width and height values will be filled in. 00867 @return A Max error code. */ 00868 t_max_err jbox_get_presentation_size(t_object *box, t_size *size); 00869 00870 /** Set the size of a box for the presentation view. 00871 @ingroup jbox 00872 @param box The box whose size will be changed. 00873 @param size The address of a #t_size with the new width and height values. 00874 @return A Max error code. */ 00875 t_max_err jbox_set_presentation_size(t_object *box, t_size *size); 00876 00877 00878 00879 00880 /** Retrieve the name of the class of the box's object. 00881 @ingroup jbox 00882 @param b The box to query. 00883 @return The name of the class of the box's object. */ 00884 t_symbol* jbox_get_maxclass(t_object *b); 00885 00886 /** Retrieve a pointer to the box's object. 00887 @ingroup jbox 00888 @param b The box to query. 00889 @return A pointer to the box's object. */ 00890 t_object* jbox_get_object(t_object *b); 00891 00892 /** Retrieve a box's patcher. 00893 @ingroup jbox 00894 @param b The box to query. 00895 @return If the box has a patcher, the patcher's pointer is returned. 00896 Otherwise NULL is returned. */ 00897 t_object* jbox_get_patcher(t_object *b); 00898 00899 00900 /** Retrieve a box's 'hidden' attribute. 00901 @ingroup jbox 00902 @param b The box to query. 00903 @return True if the box is hidden, otherwise false. */ 00904 char jbox_get_hidden(t_object *b); 00905 00906 /** Set a box's 'hidden' attribute. 00907 @ingroup jbox 00908 @param b The box to query. 00909 @param c Set to true to hide the box, otherwise false. 00910 @return A Max error code. */ 00911 t_max_err jbox_set_hidden(t_object *b, char c); 00912 00913 00914 /** Retrieve a box's 'fontname' attribute. 00915 @ingroup jbox 00916 @param b The box to query. 00917 @return The font name. */ 00918 t_symbol* jbox_get_fontname(t_object *b); 00919 00920 /** Set a box's 'fontname' attribute. 00921 @ingroup jbox 00922 @param b The box to query. 00923 @param ps The font name. Note that the font name may be case-sensitive. 00924 @return A Max error code. */ 00925 t_max_err jbox_set_fontname(t_object *b, t_symbol *ps); 00926 00927 00928 /** Retrieve a box's 'fontsize' attribute. 00929 @ingroup jbox 00930 @param b The box to query. 00931 @return The font size in points. */ 00932 double jbox_get_fontsize(t_object *b); 00933 00934 /** Set a box's 'fontsize' attribute. 00935 @ingroup jbox 00936 @param b The box to query. 00937 @param d The fontsize in points. 00938 @return A Max error code. */ 00939 t_max_err jbox_set_fontsize(t_object *b, double d); 00940 00941 00942 /** Retrieve a box's 'color' attribute. 00943 @ingroup jbox 00944 @param b The box to query. 00945 @param prgba The address of a valid #t_rect whose values will be filled-in upon return. 00946 @return A Max error code. */ 00947 t_max_err jbox_get_color(t_object *b, t_jrgba *prgba); 00948 00949 /** Set a box's 'color' attribute. 00950 @ingroup jbox 00951 @param b The box to query. 00952 @param prgba The address of a #t_rect containing the desired color for the box/object. 00953 @return A Max error code. */ 00954 t_max_err jbox_set_color(t_object *b, t_jrgba *prgba); 00955 00956 00957 /** Retrieve a box's hint text as a symbol. 00958 @ingroup jbox 00959 @param b The box to query. 00960 @return The box's hint text. */ 00961 t_symbol *jbox_get_hint(t_object *b); 00962 00963 /** Set a box's hint text using a symbol. 00964 @ingroup jbox 00965 @param b The box to query. 00966 @param s The new text to use for the box's hint. 00967 @return A Max error code. */ 00968 t_max_err jbox_set_hint(t_object *b, t_symbol *s); 00969 00970 00971 /** Retrieve a box's hint text as a C-string. 00972 @ingroup jbox 00973 @param bb The box to query. 00974 @return The box's hint text. */ 00975 char *jbox_get_hintstring(t_object *bb); 00976 00977 /** Set a box's hint text using a C-string. 00978 @ingroup jbox 00979 @param bb The box to query. 00980 @param s The new text to use for the box's hint. 00981 @return A Max error code. */ 00982 void jbox_set_hintstring(t_object *bb, char *s); 00983 00984 00985 char jbox_get_hinttrack(t_object *b); 00986 t_max_err jbox_set_hinttrack(t_object *b, char h); 00987 00988 00989 /** Retrieve a box's annotation string, if the user has given it an annotation. 00990 @ingroup jbox 00991 @param bb The box to query. 00992 @return The user-created annotation string for a box, or NULL if no string exists. */ 00993 char *jbox_get_annotation(t_object *bb); 00994 00995 /** Set a box's annotation string. 00996 @ingroup jbox 00997 @param bb The box to query. 00998 @param s The annotation string for the box. 00999 @return A Max error code. */ 01000 void jbox_set_annotation(t_object *bb, char *s); 01001 01002 01003 /** The next box in the patcher's (linked) list of boxes. 01004 @ingroup jbox 01005 @param b The box to query. 01006 @return The next box in the list. */ 01007 t_object* jbox_get_nextobject(t_object *b); 01008 01009 /** The previous box in the patcher's (linked) list of boxes. 01010 @ingroup jbox 01011 @param b The box to query. 01012 @return The next box in the list. */ 01013 t_object* jbox_get_prevobject(t_object *b); 01014 01015 01016 // not implemented? 01017 // t_symbol* jbox_get_f(t_object *b); 01018 01019 01020 /** Retrieve a box's scripting name. 01021 @ingroup jbox 01022 @param b The box to query. 01023 @return The box's scripting name. */ 01024 t_symbol* jbox_get_varname(t_object *b); 01025 01026 /** Set a box's scripting name. 01027 @ingroup jbox 01028 @param b The box to query. 01029 @param ps The new scripting name for the box. 01030 @return A Max error code. */ 01031 t_max_err jbox_set_varname(t_object *b, t_symbol *ps); 01032 01033 01034 /** Retrieve a boxes unique id. 01035 @ingroup jbox 01036 @param b The box to query. 01037 @return The unique id of the object. This is a symbol that is referenced, for example, by patchlines. */ 01038 t_symbol* jbox_get_id(t_object *b); 01039 01040 01041 /** Retrieve a box flag value from a box. 01042 @ingroup jbox 01043 @param b The box to query. 01044 @return The value of the canhilite bit in the box's flags. */ 01045 char jbox_get_canhilite(t_object *b); 01046 01047 01048 /** Determine whether a box is located in the patcher's background layer. 01049 @ingroup jbox 01050 @param b The box to query. 01051 @return Zero if the object is in the foreground, otherwise non-zero. */ 01052 char jbox_get_background(t_object *b); 01053 01054 /** Set whether a box should be in the background or foreground layer of a patcher. 01055 @ingroup jbox 01056 @param b The box to query. 01057 @param c Pass zero to tell the box to appear in the foreground, or non-zero to indicate that the box should be in the background layer. 01058 @return A Max error code. */ 01059 t_max_err jbox_set_background(t_object *b, char c); 01060 01061 01062 /** Determine whether a box ignores clicks. 01063 @ingroup jbox 01064 @param b The box to query. 01065 @return Zero if the object responds to clicks, otherwise non-zero. */ 01066 char jbox_get_ignoreclick(t_object *b); 01067 01068 /** Set whether a box ignores clicks. 01069 @ingroup jbox 01070 @param b The box to query. 01071 @param c Pass zero to tell the box to respond to clicks, or non-zero to indicate that the box should ignore clicks. 01072 @return A Max error code. */ 01073 t_max_err jbox_set_ignoreclick(t_object *b, char c); 01074 01075 01076 /** Determine whether a box draws its first inlet. 01077 @ingroup jbox 01078 @param b The box to query. 01079 @return Zero if the inlet is not drawn, otherwise non-zero. */ 01080 char jbox_get_drawfirstin(t_object *b); 01081 01082 01083 /** Determine whether a box draws an outline. 01084 @ingroup jbox 01085 @param b The box to query. 01086 @return Zero if the outline is not drawn, otherwise non-zero. */ 01087 char jbox_get_outline(t_object *b); 01088 01089 /** Set whether a box draws an outline. 01090 @ingroup jbox 01091 @param b The box to query. 01092 @param c Pass zero to hide the outline, or non-zero to indicate that the box should draw the outline. 01093 @return A Max error code. */ 01094 t_max_err jbox_set_outline(t_object *b, char c); 01095 01096 01097 /** Retrieve a box flag value from a box. 01098 @ingroup jbox 01099 @param b The box to query. 01100 @return The value of the growy bit in the box's flags. */ 01101 char jbox_get_growy(t_object *b); 01102 01103 /** Retrieve a box flag value from a box. 01104 @ingroup jbox 01105 @param b The box to query. 01106 @return The value of the growboth bit in the box's flags. */ 01107 char jbox_get_growboth(t_object *b); 01108 01109 /** Retrieve a box flag value from a box. 01110 @ingroup jbox 01111 @param b The box to query. 01112 @return The value of the nogrow bit in the box's flags. */ 01113 char jbox_get_nogrow(t_object *b); 01114 01115 /** Retrieve a box flag value from a box. 01116 @ingroup jbox 01117 @param b The box to query. 01118 @return The value of the drawinlast bit in the box's flags. */ 01119 char jbox_get_drawinlast(t_object *b); 01120 01121 01122 // private? 01123 char jbox_get_mousedragdelta(t_object *b); 01124 t_max_err jbox_set_mousedragdelta(t_object *b, char c); 01125 01126 01127 /** Retrieve a pointer to a box's textfield. 01128 @ingroup jbox 01129 @param b The box to query. 01130 @return The textfield for the box, assuming it has one. 01131 If the box does not own a textfield then NULL is returned. */ 01132 t_object* jbox_get_textfield(t_object *b); 01133 01134 01135 // private 01136 long jbox_get_understanding(t_object *b, t_symbol *msg); 01137 01138 01139 /** Determine if a box is included in the presentation view. 01140 @ingroup jbox 01141 @param b The box to query. 01142 @return Non-zero if in presentation mode, otherwise zero. */ 01143 char jbox_get_presentation(t_object *b); 01144 01145 /** Determine if a box is included in the presentation view. 01146 @ingroup jbox 01147 @param b The box to query. 01148 @param c Pass zero to remove a box from the presention view, or non-zero to add it to the presentation view. 01149 @return Non-zero if in presentation mode, otherwise zero. */ 01150 t_max_err jbox_set_presentation(t_object *b, char c); 01151 01152 01153 // private 01154 t_object *jbox_get_autocompletion(t_object *b); 01155 t_symbol *jbox_get_prototypename(t_object *b); 01156 void jbox_set_prototypename(t_object *b, t_symbol *name); 01157 long jclipboard_datatypes(); 01158 01159 01160 01161 01162 // utilities to get/set patchline attributes 01163 01164 typedef enum _patchline_updatetype { 01165 JPATCHLINE_DISCONNECT=0, 01166 JPATCHLINE_CONNECT=1, 01167 JPATCHLINE_ORDER=2 01168 } t_patchline_updatetype; 01169 01170 /** Retrieve a patchline's starting point. 01171 @ingroup jpatchline 01172 @param l A pointer to the patchline's instance. 01173 @param x The address of a variable to hold the x-coordinate of the starting point's position upon return. 01174 @param y The address of a variable to hold the y-coordinate of the starting point's position upon return. 01175 @return A Max error code. */ 01176 t_max_err jpatchline_get_startpoint(t_object *l, double *x, double *y); 01177 01178 /** Retrieve a patchline's ending point. 01179 @ingroup jpatchline 01180 @param l A pointer to the patchline's instance. 01181 @param x The address of a variable to hold the x-coordinate of the ending point's position upon return. 01182 @param y The address of a variable to hold the y-coordinate of the ending point's position upon return. 01183 @return A Max error code. */ 01184 t_max_err jpatchline_get_endpoint(t_object *l, double *x, double *y); 01185 01186 /** Determine the number of midpoints (segments) in a patchline. 01187 @ingroup jpatchline 01188 @param l A pointer to the patchline's instance. 01189 @return The number of midpoints in the patchline. */ 01190 long jpatchline_get_nummidpoints(t_object *l); 01191 01192 char jpatchline_get_pending(t_object *l); 01193 01194 01195 /** Return the object box from which a patchline originates. 01196 @ingroup jpatchline 01197 @param l A pointer to the patchline's instance. 01198 @return The object box from which the patchline originates. */ 01199 t_object* jpatchline_get_box1(t_object *l); 01200 01201 /** Return the outlet number of the originating object box from which a patchline begins. 01202 @ingroup jpatchline 01203 @param l A pointer to the patchline's instance. 01204 @return The outlet number. */ 01205 long jpatchline_get_outletnum(t_object *l); 01206 01207 01208 /** Return the destination object box for a patchline. 01209 @ingroup jpatchline 01210 @param l A pointer to the patchline's instance. 01211 @return The destination object box for a patchline. */ 01212 t_object* jpatchline_get_box2(t_object *l); 01213 01214 /** Return the inlet number of the destination object box to which a patchline is connected. 01215 @ingroup jpatchline 01216 @param l A pointer to the patchline's instance. 01217 @return The inlet number. */ 01218 long jpatchline_get_inletnum(t_object *l); 01219 01220 01221 // private? 01222 double jpatchline_get_straightthresh(t_object *l); 01223 t_max_err jpatchline_set_straightthresh(t_object *l, double d); 01224 01225 // private? 01226 char jpatchline_get_straightstart(t_object *l); 01227 char jpatchline_get_straightend(t_object *l); 01228 01229 // private? 01230 t_max_err jpatchline_set_straightstart(t_object *l, char c); 01231 t_max_err jpatchline_set_straightend(t_object *l, char c); 01232 01233 01234 /** Given a patchline, traverse to the next patchline in the (linked) list. 01235 @ingroup jpatchline 01236 @param b A patchline instance. 01237 @return The next patchline. 01238 If the current patchline is at the end (tail) of the list, then NULL is returned. 01239 */ 01240 t_object* jpatchline_get_nextline(t_object *b); 01241 01242 01243 /** Determine if a patch line is hidden. 01244 @ingroup jpatchline 01245 @param l A patchline instance. 01246 @return Zero if the patchline is visible, non-zero if it is hidden. 01247 */ 01248 char jpatchline_get_hidden(t_object *l); 01249 01250 /** Set a patchline's visibility. 01251 @ingroup jpatchline 01252 @param l A patchline instance. 01253 @param c Pass 0 to make a patchline visible, or non-zero to hide it. 01254 @return An error code. 01255 */ 01256 t_max_err jpatchline_set_hidden(t_object *l, char c); 01257 01258 01259 /** Get the color of a patch line. 01260 @ingroup jpatchline 01261 @param l A patchline instance. 01262 @param prgba The address of a valid #t_jrgba struct that will be filled with the color values of the patch line. 01263 @return An error code. 01264 */ 01265 t_max_err jpatchline_get_color(t_object *l, t_jrgba *prgba); 01266 01267 /** Set the color of a patch line. 01268 @ingroup jpatchline 01269 @param l A patchline instance. 01270 @param prgba The address of a valid #t_jrgba struct containing the color to use. 01271 @return An error code. 01272 */ 01273 t_max_err jpatchline_set_color(t_object *l, t_jrgba *prgba); 01274 01275 01276 // private 01277 t_object *jpatchline_get_wiretap(t_object *l); 01278 long wiretap_get_id(t_object *w); 01279 long wiretap_get_flags(t_object *w); 01280 void wiretap_set_flags(t_object *w, long n); 01281 01282 01283 01284 01285 // utilities to get/set patcherview attributes 01286 01287 /** Query a patcherview to determine whether it is visible. 01288 @ingroup jpatcherview 01289 @param pv The patcherview instance to query. 01290 @return Returns zero if the patcherview is invisible, otherwise returns non-zero. */ 01291 char patcherview_get_visible(t_object *pv); 01292 01293 /** Set the 'visible' attribute of a patcherview. 01294 @ingroup jpatcherview 01295 @param pv The patcherview instance whose attribute will be set. 01296 @param c Whether or not the patcherview should be made visible. 01297 @return An error code. */ 01298 t_max_err patcherview_set_visible(t_object *pv, char c); 01299 01300 01301 /** Get the value of the rect attribute for a patcherview. 01302 @ingroup jpatcherview 01303 @param pv The patcherview instance whose attribute value will be fetched. 01304 @param pr The address of a valid #t_rect struct, whose contents will be filled upon return. 01305 @return An error code. */ 01306 t_max_err patcherview_get_rect(t_object *pv, t_rect *pr); 01307 01308 /** Set the value of the rect attribute for a patcherview. 01309 @ingroup jpatcherview 01310 @param pv The patcherview instance whose attribute value will be set. 01311 @param pr The address of a valid #t_rect struct. 01312 @return An error code. */ 01313 t_max_err patcherview_set_rect(t_object *pv, t_rect *pr); 01314 01315 01316 /** Find out if a patcherview is locked. 01317 @ingroup jpatcherview 01318 @param p The patcherview instance whose attribute value will be fetched. 01319 @return Returns 0 if unlocked, otherwise returns non-zero. */ 01320 char patcherview_get_locked(t_object *p); 01321 01322 /** Lock or unlock a patcherview. 01323 @ingroup jpatcherview 01324 @param p The patcherview instance whose attribute value will be set. 01325 @param c Set this value to zero to unlock the patcherview, otherwise pass a non-zero value. 01326 @return An error code. */ 01327 t_max_err patcherview_set_locked(t_object *p, char c); 01328 01329 01330 /** Find out if a patcherview is a presentation view. 01331 @ingroup jpatcherview 01332 @param pv The patcherview instance whose attribute value will be fetched. 01333 @return Returns 0 if the view is not a presentation view, otherwise returns non-zero. */ 01334 char patcherview_get_presentation(t_object *pv); 01335 01336 /** Set whether or not a patcherview is a presentation view. 01337 @ingroup jpatcherview 01338 @param p The patcherview instance whose attribute value will be set. 01339 @param c Set this value to non-zero to make the patcherview a presentation view, otherwise pass zero. 01340 @return An error code. */ 01341 t_max_err patcherview_set_presentation(t_object *p, char c); 01342 01343 01344 /** Fetch the zoom-factor of a patcherview. 01345 @ingroup jpatcherview 01346 @param pv The patcherview instance whose attribute value will be fetched. 01347 @return The factor by which the view is zoomed. */ 01348 double patcherview_get_zoomfactor(t_object *pv); 01349 01350 /** Set the zoom-factor of a patcherview. 01351 @ingroup jpatcherview 01352 @param pv The patcherview instance whose attribute value will be set. 01353 @param d The zoom-factor at which the patcherview should display the patcher. 01354 @return An error code. */ 01355 t_max_err patcherview_set_zoomfactor(t_object *pv, double d); 01356 01357 01358 /** Given a patcherview, find the next patcherview. 01359 The views of a patcher are maintained internally as a #t_linklist, 01360 and so the views can be traversed should you need to perform operations on all of a patcher's patcherviews. 01361 @ingroup jpatcherview 01362 @param pv The patcherview instance from which to find the next patcherview. 01363 @return The next patcherview in the list, or NULL if the patcherview passed in pv is the tail. */ 01364 t_object* patcherview_get_nextview(t_object *pv); 01365 01366 01367 /** Given a patcherview, return the #t_jgraphics context for that view. 01368 @ingroup jpatcherview 01369 @param pv The patcherview instance. 01370 @return The #t_jgraphics context for the view. */ 01371 t_object* patcherview_get_jgraphics(t_object *pv); 01372 01373 // private 01374 t_max_err patcherview_set_jgraphics(t_object *pv, t_object *po); 01375 01376 01377 /** Given a patcherview, return its patcher. 01378 @ingroup jpatcherview 01379 @param pv The patcherview instance for which to fetch the patcher. 01380 @return The patcher. */ 01381 t_object* patcherview_get_patcher(t_object *pv); 01382 01383 01384 01385 01386 // utilities to get/set textfield attributes 01387 01388 /** Return the object that owns a particular textfield. 01389 @ingroup textfield 01390 @param tf The textfield instance pointer. 01391 @return A pointer to the owning object. */ 01392 t_object* textfield_get_owner(t_object *tf); 01393 01394 01395 /** Retrieve the color of the text in a textfield. 01396 @ingroup textfield 01397 @param tf The textfield instance pointer. 01398 @param prgba The address of a valid #t_jrgba whose values will be filled-in upon return. 01399 @return A Max error code. */ 01400 t_max_err textfield_get_textcolor(t_object *tf, t_jrgba *prgba); 01401 01402 /** Set the color of the text in a textfield. 01403 @ingroup textfield 01404 @param tf The textfield instance pointer. 01405 @param prgba The address of a #t_jrgba containing the new color to use. 01406 @return A Max error code. */ 01407 t_max_err textfield_set_textcolor(t_object *tf, t_jrgba *prgba); 01408 01409 01410 /** Retrieve the background color of a textfield. 01411 @ingroup textfield 01412 @param tf The textfield instance pointer. 01413 @param prgba The address of a valid #t_jrgba whose values will be filled-in upon return. 01414 @return A Max error code. */ 01415 t_max_err textfield_get_bgcolor(t_object *tf, t_jrgba *prgba); 01416 01417 /** Set the background color of a textfield. 01418 @ingroup textfield 01419 @param tf The textfield instance pointer. 01420 @param prgba The address of a #t_jrgba containing the new color to use. 01421 @return A Max error code. */ 01422 t_max_err textfield_set_bgcolor(t_object *tf, t_jrgba *prgba); 01423 01424 01425 /** Retrieve the margins from the edge of the textfield to the text itself in a textfield. 01426 @ingroup textfield 01427 @param tf The textfield instance pointer. 01428 @param pleft The address of a variable to hold the value of the left margin upon return. 01429 @param ptop The address of a variable to hold the value of the top margin upon return. 01430 @param pright The address of a variable to hold the value of the right margin upon return. 01431 @param pbottom The address of a variable to hold the value of the bottom margin upon return. 01432 @return A Max error code. */ 01433 t_max_err textfield_get_textmargins(t_object *tf, double *pleft, double *ptop, double *pright, double *pbottom); 01434 01435 /** Set the margins from the edge of the textfield to the text itself in a textfield. 01436 @ingroup textfield 01437 @param tf The textfield instance pointer. 01438 @param left The new value for the left margin. 01439 @param top The new value for the top margin. 01440 @param right The new value for the right margin. 01441 @param bottom The new value for the bottom margin. 01442 @return A Max error code. */ 01443 t_max_err textfield_set_textmargins(t_object *tf, double left, double top, double right, double bottom); 01444 01445 01446 /** Return the value of the 'editonclick' attribute of a textfield. 01447 @ingroup textfield 01448 @param tf The textfield instance pointer. 01449 @return A value of the attribute. */ 01450 char textfield_get_editonclick(t_object *tf); 01451 01452 /** Set the 'editonclick' attribute of a textfield. 01453 @ingroup textfield 01454 @param tf The textfield instance pointer. 01455 @param c The new value for the attribute. 01456 @return A Max error code. */ 01457 t_max_err textfield_set_editonclick(t_object *tf, char c); 01458 01459 01460 /** Return the value of the 'selectallonedit' attribute of a textfield. 01461 @ingroup textfield 01462 @param tf The textfield instance pointer. 01463 @return A value of the attribute. */ 01464 char textfield_get_selectallonedit(t_object *tf); 01465 01466 /** Set the 'selectallonedit' attribute of a textfield. 01467 @ingroup textfield 01468 @param tf The textfield instance pointer. 01469 @param c The new value for the attribute. 01470 @return A Max error code. */ 01471 t_max_err textfield_set_selectallonedit(t_object *tf, char c); 01472 01473 01474 /** Return the value of the 'noactivate' attribute of a textfield. 01475 @ingroup textfield 01476 @param tf The textfield instance pointer. 01477 @return A value of the attribute. */ 01478 char textfield_get_noactivate(t_object *tf); 01479 01480 /** Set the 'noactivate' attribute of a textfield. 01481 @ingroup textfield 01482 @param tf The textfield instance pointer. 01483 @param c The new value for the attribute. 01484 @return A Max error code. */ 01485 t_max_err textfield_set_noactivate(t_object *tf, char c); 01486 01487 01488 /** Return the value of the 'readonly' attribute of a textfield. 01489 @ingroup textfield 01490 @param tf The textfield instance pointer. 01491 @return A value of the attribute. */ 01492 char textfield_get_readonly(t_object *tf); 01493 01494 /** Set the 'readonly' attribute of a textfield. 01495 @ingroup textfield 01496 @param tf The textfield instance pointer. 01497 @param c The new value for the attribute. 01498 @return A Max error code. */ 01499 t_max_err textfield_set_readonly(t_object *tf, char c); 01500 01501 01502 /** Return the value of the 'wordwrap' attribute of a textfield. 01503 @ingroup textfield 01504 @param tf The textfield instance pointer. 01505 @return A value of the attribute. */ 01506 char textfield_get_wordwrap(t_object *tf); 01507 01508 /** Set the 'wordwrap' attribute of a textfield. 01509 @ingroup textfield 01510 @param tf The textfield instance pointer. 01511 @param c The new value for the attribute. 01512 @return A Max error code. */ 01513 t_max_err textfield_set_wordwrap(t_object *tf, char c); 01514 01515 01516 /** Return the value of the 'useellipsis' attribute of a textfield. 01517 @ingroup textfield 01518 @param tf The textfield instance pointer. 01519 @return A value of the attribute. */ 01520 char textfield_get_useellipsis(t_object *tf); 01521 01522 /** Set the 'useellipsis' attribute of a textfield. 01523 @ingroup textfield 01524 @param tf The textfield instance pointer. 01525 @param c The new value for the attribute. 01526 @return A Max error code. */ 01527 t_max_err textfield_set_useellipsis(t_object *tf, char c); 01528 01529 01530 /** Return the value of the 'autoscroll' attribute of a textfield. 01531 @ingroup textfield 01532 @param tf The textfield instance pointer. 01533 @return A value of the attribute. */ 01534 char textfield_get_autoscroll(t_object *tf); 01535 01536 /** Set the 'autoscroll' attribute of a textfield. 01537 @ingroup textfield 01538 @param tf The textfield instance pointer. 01539 @param c The new value for the attribute. 01540 @return A Max error code. */ 01541 t_max_err textfield_set_autoscroll(t_object *tf, char c); 01542 01543 01544 /** Return the value of the 'wantsreturn' attribute of a textfield. 01545 @ingroup textfield 01546 @param tf The textfield instance pointer. 01547 @return A value of the attribute. */ 01548 char textfield_get_wantsreturn(t_object *tf); 01549 01550 /** Set the 'wantsreturn' attribute of a textfield. 01551 @ingroup textfield 01552 @param tf The textfield instance pointer. 01553 @param c The new value for the attribute. 01554 @return A Max error code. */ 01555 t_max_err textfield_set_wantsreturn(t_object *tf, char c); 01556 01557 01558 /** Return the value of the 'wantstab' attribute of a textfield. 01559 @ingroup textfield 01560 @param tf The textfield instance pointer. 01561 @return A value of the attribute. */ 01562 char textfield_get_wantstab(t_object *tf); 01563 01564 /** Set the 'wantstab' attribute of a textfield. 01565 @ingroup textfield 01566 @param tf The textfield instance pointer. 01567 @param c The new value for the attribute. 01568 @return A Max error code. */ 01569 t_max_err textfield_set_wantstab(t_object *tf, char c); 01570 01571 01572 /** Return the value of the 'underline' attribute of a textfield. 01573 @ingroup textfield 01574 @param tf The textfield instance pointer. 01575 @return A value of the attribute. */ 01576 char textfield_get_underline(t_object *tf); 01577 01578 /** Set the 'underline' attribute of a textfield. 01579 @ingroup textfield 01580 @param tf The textfield instance pointer. 01581 @param c The new value for the attribute. 01582 @return A Max error code. */ 01583 t_max_err textfield_set_underline(t_object *tf, char c); 01584 01585 01586 // private 01587 char textfield_get_justification(t_object *tf); 01588 t_max_err textfield_set_justification(t_object *tf, char c); 01589 char textfield_get_autofixwidth(t_object *tf); 01590 t_max_err textfield_set_autofixwidth(t_object *tf, char c); 01591 01592 01593 /** Set the 'empty' text of a textfield. 01594 The empty text is the text that is displayed in the textfield when no text is present. 01595 By default this is gensym(""). 01596 @ingroup textfield 01597 @param tf The textfield instance pointer. 01598 @param txt A symbol containing the new text to display when the textfield has no content. 01599 @return A Max error code. */ 01600 t_max_err textfield_set_emptytext(t_object *tf, t_symbol *txt); 01601 01602 /** Retrieve the 'empty' text of a textfield. 01603 The empty text is the text that is displayed in the textfield when no text is present. 01604 By default this is gensym(""). 01605 @ingroup textfield 01606 @param tf The textfield instance pointer. 01607 @return The current text used as the empty text. */ 01608 t_symbol *textfield_get_emptytext(t_object *tf); 01609 01610 01611 01612 // jbox flags 01613 // flags passed to box_new 01614 01615 // The following flags affect how the boxes are drawn 01616 #define JBOX_DRAWFIRSTIN (1<<0) ///< draw first inlet @ingroup jbox 01617 #define JBOX_NODRAWBOX (1<<1) ///< don't draw the frame @ingroup jbox 01618 #define JBOX_DRAWINLAST (1<<2) ///< draw inlets after update method @ingroup jbox 01619 01620 // JBOX_TRANSPARENT is unused -- box is always transparent by default 01621 #define JBOX_TRANSPARENT (1<<3) ///< don't make transparent unless you need it (for efficiency) @ingroup jbox 01622 01623 // Box growing: nogrow is clear -- box is not sizable. 01624 // Default (none of following three flags) means box width is only sizable. 01625 // JBOX_GROWY means that X and Y are sizable and the aspect ratio is fixed (or maybe it has to be square, like dial?). 01626 // JBOX_GROWBOTH means that X and Y are independently sizable. 01627 #define JBOX_NOGROW (1<<4) ///< don't even draw grow thingie @ingroup jbox 01628 #define JBOX_GROWY (1<<5) ///< can grow in y direction by dragging @ingroup jbox 01629 #define JBOX_GROWBOTH (1<<6) ///< can grow independently in both x and y @ingroup jbox 01630 01631 // Box interaction 01632 #define JBOX_IGNORELOCKCLICK (1<<7) ///< box should ignore a click if patcher is locked @ingroup jbox 01633 #define JBOX_HILITE (1<<8) ///< flag passed to jbox_new() to tell max that the UI object can receive the focus when clicked on -- may be replaced by JBOX_FOCUS in the future @ingroup jbox 01634 #define JBOX_BACKGROUND (1<<9) ///< immediately set box into the background @ingroup jbox 01635 #define JBOX_NOFLOATINSPECTOR (1<<10) ///< no floating inspector window @ingroup jbox 01636 01637 // textfield: give this flag for automatic textfield support 01638 #define JBOX_TEXTFIELD (1<<11) ///< save/load text from textfield, unless JBOX_BINBUF flag is set @ingroup jbox 01639 #define JBOX_FIXWIDTH (1<<19) ///< give the box a textfield based fix-width (bfixwidth) method @ingroup jbox 01640 #define JBOX_FONTATTR (1<<18) ///< if you want font related attribute you must add this to jbox_initclass() @ingroup jbox 01641 #define JBOX_BINBUF (1<<14) ///< save/load text from b_binbuf @ingroup jbox 01642 01643 #define JBOX_MOUSEDRAGDELTA (1<<12) ///< hides mouse cursor in drag and sends mousedragdelta instead of mousedrag (for infinite scrolling like number) @ingroup jbox 01644 01645 #define JBOX_COLOR (1<<13) ///< support the "color" method for color customization @ingroup jbox 01646 #define JBOX_DRAWIOLOCKED (1<<15) ///< draw inlets and outlets when locked (default is not to draw them) @ingroup jbox 01647 #define JBOX_DRAWBACKGROUND (1<<16) ///< set to have box bg filled in for you based on getdrawparams method or brgba attribute @ingroup jbox 01648 #define JBOX_NOINSPECTFIRSTIN (1<<17) ///< flag for objects such as bpatcher that have a different b_firstin, 01649 ///< but the attrs of the b_firstin should not be shown in the inspector @ingroup jbox 01650 01651 // JBOX_DEFAULTNAMES is unused -- box is attached automatically if needed 01652 #define JBOX_DEFAULTNAMES (1<<18) ///< flag instructing jbox_new to attach object to the defaults object for live defaults updating @ingroup jbox 01653 01654 #define JBOX_FOCUS (1<<20) ///< more advanced focus support (passed to jbox_initclass() to add "nextfocus" and "prevfocus" attributes to the UI object). Not implemented as of 2009-05-11 @ingroup jbox 01655 01656 01657 /** actual numerical values of the b_fontface attribute; use jbox_fontface() to weight 01658 @ingroup jbox */ 01659 enum { 01660 JBOX_FONTFACE_REGULAR = 0, ///< normal 01661 JBOX_FONTFACE_BOLD = 1, ///< bold 01662 JBOX_FONTFACE_ITALIC = 2, ///< italic 01663 JBOX_FONTFACE_BOLDITALIC = 3 ///< bold and italic 01664 }; 01665 01666 // The following two are not needed in the new world. 01667 // #define JBOX_MOVING 8 // object invalidates outside its defined clipping region 01668 // #define JBOX_SAVVY 2048 // calls box_enddraw after box_nodraw returns false 01669 01670 /** enumerations used for box decorators 01671 @ingroup jbox */ 01672 typedef enum _HitTestResult { 01673 HitNothing = 0, ///< a hole in the box 01674 HitBox = 1, ///< the body of the box 01675 HitInlet = 2, ///< an inlet 01676 HitOutlet = 3, ///< an outlet 01677 HitGrowBox = 4, ///< the grow handle 01678 HitLine = 5 ///< a line 01679 } HitTestResult; 01680 01681 // private 01682 typedef enum _DecoratorPaintFlags { 01683 BoxSelected = 1 << 0, 01684 DrawFirstIn = 1 << 1, 01685 NoGrow = 1 << 2, 01686 Outline = 1 << 3, 01687 Locked = 1 << 4, 01688 InletHighlighted = 1 << 5, // value tells index of highlighted inlet 01689 OutletHighlighted = 1 << 6 // value tells index of highlighted outlet (only one can be highlighted) 01690 } DecoratorPaintFlags; 01691 01692 01693 01694 // UI object functions for implementing your own UI objects 01695 01696 // private 01697 void jbox_initclass(t_class *c, long flags); 01698 01699 /** Set up your UI object's #t_jbox member. 01700 This should be called from your UI object's free method. 01701 @ingroup jbox 01702 @param b The address of your UI object's #t_jbox member (which should be the first member of the object's struct). 01703 @param flags Flags to set the box's behavior, such as #JBOX_NODRAWBOX. 01704 @param argc The count of atoms in the argv parameter. 01705 @param argv The address of the first in an array of atoms to be passed to the box constructor. 01706 Typically these are simply the argument passed to your object when it is created. 01707 @return A Max error code. */ 01708 t_max_err jbox_new(t_jbox *b, long flags, long argc, t_atom *argv); 01709 01710 /** Tear down your UI object's #t_jbox member. 01711 This should be called from your UI object's free method. 01712 @ingroup jbox 01713 @param b The address of your object's #t_jbox member (which should be the first member of the object's struct). */ 01714 void jbox_free(t_jbox *b); 01715 01716 /** Mark the box ready to be accessed and drawn by Max. 01717 This should typically be called at the end of your UI object's new method. 01718 @ingroup jbox 01719 @param b The address of your object's #t_jbox member. */ 01720 void jbox_ready(t_jbox *b); 01721 01722 01723 /** Request that your object/box be re-drawn by Max. 01724 @ingroup jbox 01725 @param b The address of your object's #t_jbox member. */ 01726 void jbox_redraw(t_jbox *b); 01727 01728 // private 01729 void jbox_redrawcontents(t_jbox *b); 01730 void *jbox_getoutlet(t_jbox *x, long index); 01731 void *jbox_getinlet(t_jbox *x, long index); 01732 void jbox_updatetextfield(t_jbox *b); 01733 01734 /** Send a notification to a box. This is the same as calling object_notify() for a box. 01735 @ingroup jbox 01736 @param b The address of your object's #t_jbox member. 01737 @param s The name of the send object. 01738 @param msg The notification name. 01739 @param sender The sending object's address. 01740 @param data A pointer to some data passed to the box's notify method. 01741 @return A Max error code. 01742 */ 01743 t_max_err jbox_notify(t_jbox *b, t_symbol *s, t_symbol *msg, void *sender, void *data); 01744 01745 // private 01746 t_max_err jbox_set_to_defaultsize(t_jbox *b, t_symbol *s, short argc, t_atom *argv); 01747 01748 01749 /** Grab the keyboard focus for your box. 01750 Calling this method should be considered exceptional, and its use is discouraged. 01751 @param b The address of your object's #t_jbox member. */ 01752 void jbox_grabfocus(t_jbox *b); 01753 01754 // private 01755 void jbox_redrawpeers(t_jbox *b); 01756 long jbox_getinletindex(t_jbox *b, void *inlet); 01757 long jbox_getoutletindex(t_jbox *b, void *outlet); 01758 01759 01760 void jbox_show_caption(t_jbox *b); 01761 void jbox_hide_caption(t_jbox *b); 01762 01763 01764 01765 01766 // dictionary stuff 01767 #define DICT_JRGBA 1 // convert RGB to jrgba when storing/retrieving from dictionary 01768 t_max_err dictionary_appendrgbcolor(t_dictionary *d, t_symbol *key, RGBColor *rgb, long flags); 01769 t_max_err dictionary_appendjrgba(t_dictionary *d, t_symbol *key, t_jrgba *jc); 01770 01771 t_max_err dictionary_getdefjrgba(t_dictionary *d, t_symbol *key, t_jrgba *jc, t_jrgba *def); 01772 t_max_err dictionary_getdefrgbcolor(t_dictionary *d, t_symbol *key, RGBColor *c, RGBColor *def, long flags); 01773 01774 t_max_err dictionary_gettrect(t_dictionary *d, t_symbol *key, t_rect *rect); 01775 t_max_err dictionary_appendtrect(t_dictionary *d, t_symbol *key, t_rect *rect); 01776 01777 t_max_err dictionary_getqdrect(t_dictionary *d, t_symbol *key, Rect *rect); 01778 t_max_err dictionary_appendqdrect(t_dictionary *d, t_symbol *key, Rect *rect); 01779 01780 t_max_err dictionary_gettpt(t_dictionary *d, t_symbol *key, t_pt *pt); 01781 t_max_err dictionary_appendtpt(t_dictionary *d, t_symbol *key, t_pt *pt); 01782 01783 void atomstorgb(long argc, t_atom *argv, RGBColor *dest, long flags); 01784 void atomstojrgba(long argc, t_atom *argv, t_jrgba *dest); 01785 void jrgbatoatoms(t_jrgba *src, t_atom *argv); 01786 void rgbtoatoms(RGBColor *src, t_atom *argv, long flags); 01787 01788 01789 // convenience for object-making 01790 01791 /** Read the specified JSON file and return a #t_dictionary object. 01792 You are responsible for freeing the dictionary with object_free(), 01793 subject to the caveats explained in @ref when_to_free_a_dictionary. 01794 @ingroup dictionary 01795 @param filename The name of the file. 01796 @param path The path of the file. 01797 @param d The address of a #t_dictionary pointer that will be set to the newly created dictionary. 01798 @return A Max error code 01799 */ 01800 t_max_err dictionary_read(char *filename, short path, t_dictionary **d); 01801 01802 /** Serialize the specified #t_dictionary object to a JSON file. 01803 @ingroup dictionary 01804 @param d The dictionary to serialize into JSON format and write to disk. 01805 @param filename The name of the file to write. 01806 @param path The path to which the file should be written. 01807 @return A Max error code. 01808 */ 01809 t_max_err dictionary_write(t_dictionary *d, char *filename, short path); 01810 01811 #define newobject_fromdictionary_delete(p,d) newobject_fromdictionary(p,d), freeobject((t_object *)d) 01812 01813 #ifdef MAC_VERSION 01814 #define strcmp_case_insensitive strcasecmp 01815 #endif 01816 #ifdef WIN_VERSION 01817 #if _MSC_VER < 1400 01818 #define strcmp_case_insensitive strcmpi 01819 #else 01820 #define strcmp_case_insensitive _strcmpi 01821 #endif 01822 #endif 01823 01824 01825 /** Bit mask values for various meta-key presses on the keyboard. 01826 @ingroup jmouse */ 01827 typedef enum _modifiers { 01828 eCommandKey = 1, ///< Command Key 01829 eShiftKey = 2, ///< Shift Key 01830 eControlKey = 4, ///< Control Key 01831 eAltKey = 8, ///< Alt Key 01832 eLeftButton = 16, ///< Left mouse button 01833 eRightButton = 32, ///< Right mouse button 01834 eMiddleButton = 64, ///< Middle mouse button 01835 ePopupMenu = 128, ///< Popup Menu (contextual menu requested) 01836 eCapsLock = 256, ///< Caps lock 01837 eAutoRepeat = 512 ///< Key is generated by key press auto-repeat 01838 } t_modifiers; 01839 01840 /** Return the last known combination of modifier keys being held by the user. 01841 @ingroup jmouse 01842 @return The current modifier keys that are activated. */ 01843 t_modifiers jkeyboard_getcurrentmodifiers(); 01844 01845 /** Return the current combination of modifier keys being held by the user. 01846 @ingroup jmouse 01847 @return The current modifier keys that are activated. */ 01848 t_modifiers jkeyboard_getcurrentmodifiers_realtime(); 01849 01850 // key codes 01851 // key/keyup objects fourth outlet and key message to objects uses 01852 // the following values for keycodes 01853 typedef enum _keycode { 01854 // keycode is ascii value with modifiers stripped 01855 // a-z keys thus report lowercase keycode regardless of shift key or capslock state 01856 JKEY_NONE = -1, 01857 JKEY_SPACEBAR = -2, 01858 JKEY_ESC = -3, 01859 JKEY_RETURN = -4, 01860 JKEY_ENTER = -4, // same as JKEY_RETURN 01861 JKEY_TAB = -5, 01862 JKEY_DELETE = -6, 01863 JKEY_BACKSPACE = -7, 01864 JKEY_INSERT = -8, 01865 JKEY_UPARROW = -9, 01866 JKEY_DOWNARROW = -10, 01867 JKEY_LEFTARROW = -11, 01868 JKEY_RIGHTARROW = -12, 01869 JKEY_PAGEUP = -13, 01870 JKEY_PAGEDOWN = -14, 01871 JKEY_HOME = -15, 01872 JKEY_END = -16, 01873 JKEY_F1 = -17, 01874 JKEY_F2 = -18, 01875 JKEY_F3 = -19, 01876 JKEY_F4 = -20, 01877 JKEY_F5 = -21, 01878 JKEY_F6 = -22, 01879 JKEY_F7 = -23, 01880 JKEY_F8 = -24, 01881 JKEY_F9 = -25, 01882 JKEY_F10 = -26, 01883 JKEY_F11 = -27, 01884 JKEY_F12 = -28, 01885 JKEY_F13 = -29, 01886 JKEY_F14 = -30, 01887 JKEY_F15 = -31, 01888 JKEY_F16 = -32, 01889 JKEY_NUMPAD0 = -33, 01890 JKEY_NUMPAD1 = -34, 01891 JKEY_NUMPAD2 = -35, 01892 JKEY_NUMPAD3 = -36, 01893 JKEY_NUMPAD4 = -37, 01894 JKEY_NUMPAD5 = -38, 01895 JKEY_NUMPAD6 = -39, 01896 JKEY_NUMPAD7 = -40, 01897 JKEY_NUMPAD8 = -41, 01898 JKEY_NUMPAD9 = -42, 01899 JKEY_NUMPADADD = -43, 01900 JKEY_NUMPADSUBTRACT = -44, 01901 JKEY_NUMPADMULTIPLY = -45, 01902 JKEY_NUMPADDIVIDE = -46, 01903 JKEY_NUMPADSEPARATOR = -47, 01904 JKEY_NUMPADDECIMALPOINT = -48, 01905 JKEY_NUMPADEQUALS = -49, 01906 JKEY_NUMPADDELETE = -50, 01907 JKEY_PLAYPAUSE = -51, 01908 JKEY_STOP = -52, 01909 JKEY_NEXTTRACK = -53, 01910 JKEY_PREVTRACK = -54, 01911 JKEY_HELP = -55 01912 } t_keycode; 01913 01914 // mouse cursor stuff 01915 01916 /** Get the position of the mouse cursor in screen coordinates. 01917 @ingroup jmouse 01918 @param x The address of a variable to hold the x-coordinate upon return. 01919 @param y The address of a variable to hold the y-coordinate upon return. */ 01920 void jmouse_getposition_global(int *x, int *y); 01921 01922 /** Set the position of the mouse cursor in screen coordinates. 01923 @ingroup jmouse 01924 @param x The new x-coordinate of the mouse cursor position. 01925 @param y The new y-coordinate of the mouse cursor position. */ 01926 void jmouse_setposition_global(int x, int y); 01927 01928 /** Set the position of the mouse cursor relative to the patcher canvas coordinates. 01929 @ingroup jmouse 01930 @param patcherview The patcherview upon which the mouse coordinates are based. 01931 @param cx The new x-coordinate of the mouse cursor position. 01932 @param cy The new y-coordinate of the mouse cursor position. */ 01933 void jmouse_setposition_view(t_object *patcherview, double cx, double cy); 01934 01935 /** Set the position of the mouse cursor relative to a box within the patcher canvas coordinates. 01936 @ingroup jmouse 01937 @param patcherview The patcherview containing the box upon which the mouse coordinates are based. 01938 @param box The box upon which the mouse coordinates are based. 01939 @param bx The new x-coordinate of the mouse cursor position. 01940 @param by The new y-coordinate of the mouse cursor position. */ 01941 void jmouse_setposition_box(t_object *patcherview, t_object *box, double bx, double by); 01942 01943 void *jmouse_getobject(); 01944 01945 /** Mouse cursor types. 01946 @ingroup jmouse */ 01947 typedef enum _jmouse_cursortype { 01948 JMOUSE_CURSOR_NONE, ///< None 01949 JMOUSE_CURSOR_ARROW, ///< Arrow 01950 JMOUSE_CURSOR_WAIT, ///< Wait 01951 JMOUSE_CURSOR_IBEAM, ///< I-Beam 01952 JMOUSE_CURSOR_CROSSHAIR, ///< Crosshair 01953 JMOUSE_CURSOR_COPYING, ///< Copying 01954 JMOUSE_CURSOR_POINTINGHAND, ///< Pointing Hand 01955 JMOUSE_CURSOR_DRAGGINGHAND, ///< Dragging Hand 01956 JMOUSE_CURSOR_RESIZE_LEFTRIGHT, ///< Left-Right 01957 JMOUSE_CURSOR_RESIZE_UPDOWN, ///< Up-Down 01958 JMOUSE_CURSOR_RESIZE_FOURWAY, ///< Four Way 01959 JMOUSE_CURSOR_RESIZE_TOPEDGE, ///< Top Edge 01960 JMOUSE_CURSOR_RESIZE_BOTTOMEDGE, ///< Bottom Edge 01961 JMOUSE_CURSOR_RESIZE_LEFTEDGE, ///< Left Edge 01962 JMOUSE_CURSOR_RESIZE_RIGHTEDGE, ///< Right Edge 01963 JMOUSE_CURSOR_RESIZE_TOPLEFTCORNER, ///< Top-Left Corner 01964 JMOUSE_CURSOR_RESIZE_TOPRIGHTCORNER, ///< Top-Right Corner 01965 JMOUSE_CURSOR_RESIZE_BOTTOMLEFTCORNER, ///< Bottom-Left Corner 01966 JMOUSE_CURSOR_RESIZE_BOTTOMRIGHTCORNER ///< Bottom-Right Corner 01967 } t_jmouse_cursortype; 01968 01969 01970 /** Set the mouse cursor. 01971 @ingroup jmouse 01972 @param patcherview The patcherview for which the cursor should be applied. 01973 @param box The box for which the cursor should be applied. 01974 @param type The type of cursor for the mouse to use. */ 01975 void jmouse_setcursor(t_object *patcherview, t_object *box, t_jmouse_cursortype type); 01976 01977 01978 01979 01980 /** Get the current window, if any. 01981 @ingroup jwind 01982 @return A pointer to the current window, if there is one. Otherwise returns NULL. */ 01983 t_object* jwind_getactive(void); 01984 01985 /** Determine how many windows exist. 01986 @ingroup jwind 01987 @return The number of windows. */ 01988 long jwind_getcount(void); 01989 01990 /** Return a pointer to the window with a given index. 01991 @ingroup jwind 01992 @param index Get window at index (0 to count-1). 01993 @return A pointer to a window object. */ 01994 t_object* jwind_getat(long index); 01995 01996 // private -- get next Untitled document number (i.e. "Untitled 1", etc). 01997 t_symbol* jwind_nextuntitled(); 01998 01999 02000 02001 02002 // functions to enumerate displays 02003 02004 /** Return the number of monitors on which can be displayed. 02005 @ingroup jmonitor 02006 @return The number of monitors. */ 02007 long jmonitor_getnumdisplays(); 02008 02009 /** Return the #t_rect for a given display. 02010 @ingroup jmonitor 02011 @param workarea Set workarea non-zero to clip out things like dock / task bar. 02012 @param displayindex The index number for a monitor. The primary monitor has an index of 0. 02013 @param rect The address of a valid #t_rect whose values will be filled-in upon return. */ 02014 void jmonitor_getdisplayrect(long workarea, long displayindex, t_rect *rect); 02015 02016 /** Return a union of all display rects. 02017 @ingroup jmonitor 02018 @param workarea Set workarea non-zero to clip out things like dock / task bar. 02019 @param rect The address of a valid #t_rect whose values will be filled-in upon return. */ 02020 void jmonitor_getdisplayrect_foralldisplays(long workarea, t_rect *rect); // get union of all display rects 02021 02022 /** Return the #t_rect for the display on which a point exists. 02023 @ingroup jmonitor 02024 @param workarea Set workarea non-zero to clip out things like dock / task bar. 02025 @param pt A point, for which the monitor will be determined and the rect recturned. 02026 @param rect The address of a valid #t_rect whose values will be filled-in upon return. */ 02027 void jmonitor_getdisplayrect_forpoint(long workarea, t_pt pt, t_rect *rect); 02028 02029 02030 // color support -- private 02031 void swatches_init(void); 02032 void swatches_shutdown(void); 02033 02034 #define JPATCHER_DEFAULT_EXTENSION ".maxpat" 02035 02036 #if C74_PRAGMA_STRUCT_PACKPUSH 02037 #pragma pack(pop) 02038 #elif C74_PRAGMA_STRUCT_PACK 02039 #pragma pack() 02040 #endif 02041 02042 END_USING_C_LINKAGE 02043 02044 #endif // #ifndef _JPATCHER_API_H_ 02045
Copyright © 2008, Cycling '74