github.com/256dpi/max-go@v0.7.0/lib/max/jpatcher_api.h (about) 1 #ifndef _JPATCHER_API_H_ 2 #define _JPATCHER_API_H_ 3 4 #include "jpatcher_syms.h" 5 #include "ext_dictionary.h" 6 #include "max_keydefs.h" 7 8 BEGIN_USING_C_LINKAGE 9 10 #if C74_PRAGMA_STRUCT_PACKPUSH 11 #pragma pack(push, 2) 12 #elif C74_PRAGMA_STRUCT_PACK 13 #pragma pack(2) 14 #endif 15 16 17 #define JPATCHER_API_CURRENT_FILE_VERSION 1 18 19 20 // ddz changed enum below to a mask so it can be returned by clipboard_datatypes() 21 22 typedef enum _clipboard_datatype { 23 JCLIPBOARD_TYPE_TEXT = 1, 24 JCLIPBOARD_TYPE_BINBUF = 2, 25 JCLIPBOARD_TYPE_JSON = 4, 26 JCLIPBOARD_TYPE_IMAGE = 8, 27 JCLIPBOARD_TYPE_JSON_ATTRIBUTES = 16, 28 JCLIPBOARD_TYPE_UNKNOWN = 256 29 } t_clipboard_datatype; 30 31 32 33 t_symbol *fontmap_getmapping(t_symbol *from, char *mapped); 34 double fontinfo_getsize(short oldsize); // tranlsate max 4.6 font size to max 5 font size 35 t_symbol *fontinfo_getname(short number); 36 short fontinfo_getnumber(t_symbol *s); 37 38 39 // Core structs 40 41 /** 42 Coordinates for specifying a rectangular region. 43 @ingroup datatypes 44 @see t_pt 45 @see t_size */ 46 typedef struct _rect 47 { 48 double x; ///< The horizontal origin 49 double y; ///< The vertical origin 50 double width; ///< The width 51 double height; ///< The height 52 } t_rect; 53 54 55 /** 56 Coordinates for specifying a point. 57 @ingroup datatypes 58 @see t_rect 59 @see t_size */ 60 typedef struct _pt 61 { 62 double x; ///< The horizontal coordinate 63 double y; ///< The vertical coordinate 64 } t_pt; 65 66 67 /** 68 Coordinates for specifying the size of a region. 69 @ingroup datatypes 70 @see t_rect 71 @see t_pt */ 72 typedef struct _size 73 { 74 double width; ///< The width 75 double height; ///< The height 76 } t_size; 77 78 79 /** A color composed of red, green, and blue components. 80 Typically such a color is assumed to be completely opaque (with no transparency). 81 @ingroup color 82 @see t_jrgba */ 83 typedef struct _jrgb { 84 double red; ///< Red component in the range [0.0, 1.0] 85 double green; ///< Green component in the range [0.0, 1.0] 86 double blue; ///< Blue component in the range [0.0, 1.0] 87 } t_jrgb; 88 89 90 /** A color composed of red, green, blue, and alpha components. 91 @ingroup color */ 92 typedef struct _jrgba { 93 double red; ///< Red component in the range [0.0, 1.0] 94 double green; ///< Green component in the range [0.0, 1.0] 95 double blue; 96 double alpha; ///< Alpha (transparency) component in the range [0.0, 1.0] 97 } t_jrgba; 98 99 100 /** 101 The t_jboxdrawparams structure. This struct is provided for debugging convenience, 102 but should be considered opaque and is subject to change without notice. 103 104 @ingroup jbox 105 */ 106 typedef struct _jboxdrawparams { 107 float d_inletheight; 108 float d_inletvoffset; 109 float d_outletheight; 110 float d_outletvoffset; 111 float d_reserved1; // was d_inletinset. unused and can chop but will require rebuild all so for now I'm renaming 112 float d_cornersize; // how rounded is the box 113 float d_borderthickness; 114 t_jrgba d_bordercolor; 115 t_jrgba d_boxfillcolor; 116 } t_jboxdrawparams; 117 118 #define JBOX_SPOOL_CONTENTS 1 119 #define JBOX_SPOOL_WHOLEBOX 2 120 121 #define JBOX_FLAG_READY 0x01 // set once the box has finished construction 122 #define JBOX_FLAG_NOT_YET_VISIBLE 0x02 // used to defer expensive size calculations until will be visible 123 #define JBOX_FLAG_VALIDATE_RECT 0x04 // used to force rect to be validated despite size not changing 124 125 /** The t_jbox struct provides the header for a Max user-interface object. 126 This struct should be considered opaque and is subject to change without notice. 127 Do not access it's members directly any code. 128 129 @ingroup patcher 130 */ 131 typedef struct _jbox 132 { 133 t_object b_ob; 134 void *obex; 135 t_object *b_patcher; 136 t_rect b_patching_rect; 137 t_rect b_presentation_rect; 138 t_symbol *b_name; 139 t_symbol *b_id; // immutable box ID 140 t_object *b_firstin; // the object, could be the box 141 t_object *b_textfield; // optional text field. 142 t_symbol *b_fontname; 143 double b_fontsize; 144 char* b_hint; 145 t_jrgba b_color; 146 double b_unused; // we can chop this or make it do something different 147 void *b_binbuf; // really an atombuf :) 148 long b_temp; 149 char b_spooled; 150 char b_hidden; 151 char b_hilitable; 152 char b_background; 153 char b_ignoreclick; 154 char b_bogus; 155 char b_drawfirstin; 156 char b_outline; 157 char b_growy; 158 char b_growboth; 159 char b_nogrow; 160 char b_drawinlast; 161 char b_paintoverchildren; 162 char b_mousedragdelta; // hide mouse during drag, and send mousedragdelta instead of mousedrag for infinite scrolling 163 char b_presentation; 164 char b_drawiolocked; 165 char b_dragactive; 166 char b_drawbackground; 167 char b_unused2; // was b_hinttrack, now unused 168 char b_fontface; 169 char *b_annotation; 170 char b_opaque; 171 char b_useimagebuffer; 172 char b_noinspectfirstin; 173 char b_editactive; // editing via inspector 174 t_symbol *b_prototypename; 175 char b_commasupport; 176 char b_boxflags; 177 char b_textjustification; 178 char b_reserved3; 179 void *b_ptemp; 180 } t_jbox; 181 182 183 // selection information -- private 184 typedef struct _pvselinfo 185 { 186 long nboxselect; 187 long nlineselect; 188 long nselboxhidden; // how many of the selected boxes are hidden 189 long nsellinehidden; // how many of the selected lines are hidden 190 long ncanignoreclick; // how many of the selected items could accept the ingore click command 191 long ncanrespondtoclick;// how many of the selected items could accept the respond to click command 192 long nbg; // how many of the selected items are in the background 193 long nboxcolorable; // how many respond to the color message 194 long nselboxbg; // how many of the selected boxes are in the background 195 long nboxinfo; // how many of the selected boxes respond to the info message 196 long nboxfixwidth; // how many of the selected boxes respond to the fixwidth message 197 long nboxpatcher; // how many of the selected boxes are patchers 198 long nboxpresent; // how many of the selected boxes are in the presentation 199 long nwiretaplines; // how many of the selected lines have wiretaps (breakpoint, watchpoint, enabled or not) 200 long nwatchpointlines; // how many of the selected lines have watchpoints enabled 201 long nbreakpointlines; // how many of the selected lines have breakpoints enabled 202 long nenabledwiretaplines; // how many of the selected lines are enabled 203 long sameclass; // are all selected items of the same class (true for one object, N patchlines, or N boxes of the same class) 204 long editbox; // is a text box currently being edited 205 long nlineswithsegments;// how many of the selected lines have at least one segment 206 long nlinesdisabled; // how many of the selected lines are disabled 207 long nsignallines; // number of selected lines that are signal patch cords 208 long nboxdblclick; // how many of the selected boxes respond to the dblclick msg 209 } t_pvselinfo; 210 211 212 // jpatcher interface 213 214 /** Gets the value of a #t_rect attribute, given its parent object and name. 215 Do not use this on a jbox object -- use jbox_get_rect_for_view() instead! 216 217 @ingroup attr 218 @param o The attribute's parent object 219 @param name The attribute's name 220 @param rect The address of a valid #t_rect whose values will be filled-in from the attribute. 221 222 @return This function returns the error code #MAX_ERR_NONE if successful, 223 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 224 t_max_err object_attr_get_rect(t_object *o, t_symbol *name, t_rect *rect); 225 226 /** Sets the value of a #t_rect attribute, given its parent object and name. 227 Do not use this on a jbox object -- use jbox_get_rect_for_view() instead! 228 229 @ingroup attr 230 @param o The attribute's parent object 231 @param name The attribute's name 232 @param rect The address of a valid #t_rect whose values will be used to set the attribute. 233 234 @return This function returns the error code #MAX_ERR_NONE if successful, 235 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 236 t_max_err object_attr_set_rect(t_object *o, t_symbol *name, t_rect *rect); 237 238 239 /** Sets the value of a #t_rect attribute, given its parent object and name. 240 Do not use this on a jbox object -- use jbox_get_rect_for_view() instead! 241 242 @ingroup attr 243 @param o The attribute's parent object 244 @param attr The attribute's name 245 @param x A double containing the new x position. 246 @param y A double containing the new y position. 247 @param w A double containing the new width. 248 @param h A double containing the new height. 249 250 @return This function returns the error code #MAX_ERR_NONE if successful, 251 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 252 */ 253 void object_attr_set_xywh(t_object *o, t_symbol *attr, double x, double y, double w, double h); 254 255 256 /** Gets the value of a #t_pt attribute, given its parent object and name. 257 258 @ingroup attr 259 @param o The attribute's parent object 260 @param name The attribute's name 261 @param pt The address of a valid #t_pt whose values will be filled-in from the attribute. 262 263 @return This function returns the error code #MAX_ERR_NONE if successful, 264 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. 265 */ 266 t_max_err object_attr_getpt(t_object *o, t_symbol *name, t_pt *pt); 267 268 269 /** Sets the value of a #t_pt attribute, given its parent object and name. 270 271 @ingroup attr 272 @param o The attribute's parent object 273 @param name The attribute's name 274 @param pt The address of a valid #t_pt whose values will be used to set the attribute. 275 276 @return This function returns the error code #MAX_ERR_NONE if successful, 277 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 278 t_max_err object_attr_setpt(t_object *o, t_symbol *name, t_pt *pt); 279 280 281 /** Gets the value of a #t_size attribute, given its parent object and name. 282 283 @ingroup attr 284 @param o The attribute's parent object 285 @param name The attribute's name 286 @param size The address of a valid #t_size whose values will be filled-in from the attribute. 287 288 @return This function returns the error code #MAX_ERR_NONE if successful, 289 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 290 t_max_err object_attr_getsize(t_object *o, t_symbol *name, t_size *size); 291 292 /** Sets the value of a #t_size attribute, given its parent object and name. 293 294 @ingroup attr 295 @param o The attribute's parent object 296 @param name The attribute's name 297 @param size The address of a valid #t_size whose values will be used to set the attribute. 298 299 @return This function returns the error code #MAX_ERR_NONE if successful, 300 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 301 t_max_err object_attr_setsize(t_object *o, t_symbol *name, t_size *size); 302 303 304 /** Gets the value of a #t_jrgba attribute, given its parent object and name. 305 306 @ingroup attr 307 @param b The attribute's parent object 308 @param attrname The attribute's name 309 @param prgba The address of a valid #t_jrgba whose values will be filled-in from the attribute. 310 311 @return This function returns the error code #MAX_ERR_NONE if successful, 312 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 313 t_max_err object_attr_getcolor(t_object *b, t_symbol *attrname, t_jrgba *prgba); 314 315 /** Sets the value of a #t_jrgba attribute, given its parent object and name. 316 317 @ingroup attr 318 @param b The attribute's parent object 319 @param attrname The attribute's name 320 @param prgba The address of a valid #t_jrgba whose values will be used to set the attribute. 321 322 @return This function returns the error code #MAX_ERR_NONE if successful, 323 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 324 t_max_err object_attr_setcolor(t_object *b, t_symbol *attrname, t_jrgba *prgba); 325 326 327 /** Get the value of a #t_jrgba struct, returned as an array of atoms with the values for each component. 328 329 @ingroup color 330 @param jrgba The color struct whose color will be retrieved. 331 @param argc The address of a variable that will be set with the number of atoms in the argv array. 332 The returned value should be 4. 333 The value of the int should be set to 0 prior to calling this function. 334 @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. 335 The pointer should be set to NULL prior to calling this function. 336 There should be 4 atoms returned, representing alpha, red, green, and blue components. 337 When you are done using the atoms, you are responsible for freeing the pointer using sysmem_freeptr(). 338 @return This function returns the error code #MAX_ERR_NONE if successful, 339 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 340 t_max_err jrgba_attr_get(t_jrgba *jrgba, long *argc, t_atom **argv); 341 342 /** Set the value of a #t_jrgba struct, given an array of atoms with the values to use. 343 344 @ingroup color 345 @param jrgba The color struct whose color will be set. 346 @param argc The number of atoms in the array. This must be 4. 347 @param argv The address of the first of the atoms in the array. 348 There must be 4 atoms, representing alpha, red, green, and blue components. 349 350 @return This function returns the error code #MAX_ERR_NONE if successful, 351 or one of the other error codes defined in #e_max_errorcodes if unsuccessful. */ 352 t_max_err jrgba_attr_set(t_jrgba *jrgba, long argc, t_atom *argv); 353 354 355 356 357 // various utilities 358 void set_jrgba_from_palette_index(short index, t_jrgba *jrgba); 359 void set_jrgba_from_boxcolor_index(short index, t_jrgba *jrgba); 360 short get_boxcolor_index_from_jrgba(t_jrgba *jrgba); 361 void jgraphics_clip_rgba(t_jrgba *rgba); 362 363 364 /** Open the help patcher for a given instance of an object. 365 @ingroup obj 366 @param x The object instance for which to open the help patcher. */ 367 void object_openhelp(t_object *x); 368 369 /** Open the reference page for a given instance of an object. 370 @ingroup obj 371 @param x The object instance for which to open the reference page. */ 372 void object_openrefpage(t_object *x); 373 374 /** Open a search in the file browser for files with the name of the given object. 375 @ingroup obj 376 @param x The object instance for which to query. */ 377 void object_openquery(t_object *x); 378 379 380 /** Open the help patcher for a given object class name. 381 @ingroup obj 382 @param classname The class name for which to open the help patcher. */ 383 void classname_openhelp(char *classname); 384 385 /** Open the reference page for a given object class name. 386 @ingroup obj 387 @param classname The class name for which to open the reference page.*/ 388 void classname_openrefpage(char *classname); 389 390 /** Open a search in the file browser for files with the name of the given class. 391 @ingroup obj 392 @param classname The class name for which to query. */ 393 void classname_openquery(char *classname); 394 395 396 /** Find a patcherview at the given screen coords. 397 @ingroup jpatcherview 398 @param x The horizontal coordinate at which to find a patcherview. 399 @param y The vertical coordinate at which to find a patcherview. 400 @return A pointer to the patcherview at the specified location, 401 or NULL if no patcherview exists at that location. */ 402 t_object* patcherview_findpatcherview(int x, int y); 403 404 405 // private (initialize object palette -- separated so it can be moved to optimize startup experience) 406 void patcherview_makepalette(void); 407 408 409 // Utilities to get/set patcher attributes 410 411 /** Determine of a #t_object* is a patcher object. 412 @ingroup jpatcher 413 @param p The object pointer to test. 414 @return Returns true if the object is a patcher, otherwise returns non-zero. */ 415 int jpatcher_is_patcher(t_object *p); 416 417 /** If a patcher is inside a box, return its box. 418 @ingroup jpatcher 419 @param p The patcher to be queried. 420 @return A pointer to the box containing the patcher, otherwise NULL. */ 421 t_object* jpatcher_get_box(t_object *p); 422 423 /** Determine the number of boxes in a patcher. 424 @ingroup jpatcher 425 @param p The patcher to be queried. 426 @return The number of boxes in the patcher. */ 427 long jpatcher_get_count(t_object *p); 428 429 430 /** To determine whether a patcher is currently in a locked state, 431 you should actually query the patcherview using patcherview_get_locked(). 432 This is because, for any given patcher, there may be multiple views with differing locked states. 433 434 @param p The patcher to be queried. 435 @return True if the patcher is locked, otherwise false. 436 @see patcherview_get_locked() */ 437 char jpatcher_get_locked(t_object *p); 438 439 /** Lock or unlock a patcher. 440 @ingroup jpatcher 441 @param p The patcher whose locked state will be changed. 442 @param c Pass true to lock a patcher, otherwise pass false. 443 @return A Max error code. */ 444 t_max_err jpatcher_set_locked(t_object *p, char c); 445 446 447 /** Determine whether a patcher is currently in presentation mode. 448 @ingroup jpatcher 449 @param p The patcher to be queried. 450 @return True if the patcher is in presentation mode, otherwise false. */ 451 char jpatcher_get_presentation(t_object *p); 452 453 /** Set a patcher to presentation mode. 454 @ingroup jpatcher 455 @param p The patcher whose locked state will be changed. 456 @param c Pass true to switch the patcher to presentation mode, otherwise pass false. 457 @return A Max error code. */ 458 t_max_err jpatcher_set_presentation(t_object *p, char c); 459 460 461 /** Get the first box in a patcher. 462 All boxes in a patcher are maintained internally in a #t_linklist. 463 Use this function together with jbox_get_nextobject() to traverse a patcher. 464 @ingroup jpatcher 465 @param p The patcher to be queried. 466 @return The first box in a patcher. 467 @see jbox_get_prevobject() 468 jbox_get_nextobject() 469 jpatcher_get_lastobject() */ 470 t_object* jpatcher_get_firstobject(t_object *p); 471 472 /** Get the last box in a patcher. 473 All boxes in a patcher are maintained internally in a #t_linklist. 474 Use this function together with jbox_get_prevobject() to traverse a patcher. 475 @ingroup jpatcher 476 @param p The patcher to be queried. 477 @return The last box in a patcher. 478 @see jbox_get_prevobject() 479 jbox_get_nextobject() 480 jpatcher_get_firstobject() */ 481 t_object* jpatcher_get_lastobject(t_object *p); 482 483 484 /** Get the first line (patch-cord) in a patcher. 485 All lines in a patcher are maintained internally in a #t_linklist. 486 Use this function to begin traversing a patcher's lines. 487 @ingroup jpatcher 488 @param p The patcher to be queried. 489 @return The first jpatchline in a patcher. */ 490 t_object* jpatcher_get_firstline(t_object *p); 491 492 /** Get the first view (jpatcherview) for a given patcher. 493 All views of a patcher are maintained internally as a #t_linklist. 494 Use this function to begin traversing a patcher's views. 495 @ingroup jpatcher 496 @param p The patcher to be queried. 497 @return The first view of a patcher. */ 498 t_object* jpatcher_get_firstview(t_object *p); 499 500 501 /** Retrieve a patcher's title. 502 @ingroup jpatcher 503 @param p The patcher to be queried. 504 @return The patcher's title. */ 505 t_symbol* jpatcher_get_title(t_object *p); 506 507 /** Set a patcher's title. 508 @ingroup jpatcher 509 @param p The patcher whose locked state will be changed. 510 @param ps The new title for the patcher. 511 @return A Max error code. */ 512 t_max_err jpatcher_set_title(t_object *p, t_symbol *ps); 513 514 515 /** Retrieve a patcher's name. 516 @ingroup jpatcher 517 @param p The patcher to be queried. 518 @return The patcher's name. */ 519 t_symbol* jpatcher_get_name(t_object *p); 520 521 /** Retrieve a patcher's file path. 522 @ingroup jpatcher 523 @param p The patcher to be queried. 524 @return The patcher's file path. */ 525 t_symbol* jpatcher_get_filepath(t_object *p); 526 527 /** Retrieve a patcher's file name. 528 @ingroup jpatcher 529 @param p The patcher to be queried. 530 @return The patcher's file name. */ 531 t_symbol* jpatcher_get_filename(t_object *p); 532 533 534 /** Determine whether a patcher's dirty bit has been set. 535 @ingroup jpatcher 536 @param p The patcher to be queried. 537 @return True if the patcher is dirty, otherwise false. */ 538 char jpatcher_get_dirty(t_object *p); 539 540 /** Set a patcher's dirty bit. 541 @ingroup jpatcher 542 @param p The patcher whose dirty bit will be set. 543 @param c The new value for the patcher's dirty bit (pass true or false). 544 @return A Max error code. */ 545 t_max_err jpatcher_set_dirty(t_object *p, char c); 546 547 548 /** Determine whether a patcher's background layer is locked. 549 @ingroup jpatcher 550 @param p The patcher to be queried. 551 @return True if the background layer is locked, otherwise false. */ 552 char jpatcher_get_bglocked(t_object *p); 553 554 /** Set whether a patcher's background layer is locked. 555 @ingroup jpatcher 556 @param p The patcher whose dirty bit will be set. 557 @param c Pass true to lock the patcher's background layer, otherwise pass false. 558 @return A Max error code. */ 559 t_max_err jpatcher_set_bglocked(t_object *p, char c); 560 561 562 /** Determine whether a patcher's background layer is hidden. 563 @ingroup jpatcher 564 @param p The patcher to be queried. 565 @return True if the background layer is hidden, otherwise false. */ 566 char jpatcher_get_bghidden(t_object *p); 567 568 /** Set whether a patcher's background layer is hidden. 569 @ingroup jpatcher 570 @param p The patcher whose dirty bit will be set. 571 @param c Pass true to hide the patcher's background layer, otherwise pass false. 572 @return A Max error code. */ 573 t_max_err jpatcher_set_bghidden(t_object *p, char c); 574 575 576 /** Determine whether a patcher's foreground layer is hidden. 577 @ingroup jpatcher 578 @param p The patcher to be queried. 579 @return True if the foreground layer is hidden, otherwise false. */ 580 char jpatcher_get_fghidden(t_object *p); 581 582 /** Set whether a patcher's foreground layer is hidden. 583 @ingroup jpatcher 584 @param p The patcher whose dirty bit will be set. 585 @param c Pass true to hide the patcher's foreground layer, otherwise pass false. 586 @return A Max error code. */ 587 t_max_err jpatcher_set_fghidden(t_object *p, char c); 588 589 590 // TODO: unused? 591 // t_object* jpatcher_get_font(t_object *p); 592 593 594 /** Retrieve a patcher's editing background color. 595 @ingroup jpatcher 596 @param p The patcher to be queried. 597 @param prgba The address of a valid #t_jrgba struct that will be filled-in with the current patcher color values. 598 @return A Max error code. */ 599 t_max_err jpatcher_get_editing_bgcolor(t_object *p, t_jrgba *prgba); 600 601 /** Set a patcher's editing background color. 602 @ingroup jpatcher 603 @param p The patcher to be queried. 604 @param prgba The address of a #t_jrgba struct containing the new color to use. 605 @return A Max error code. */ 606 t_max_err jpatcher_set_editing_bgcolor(t_object *p, t_jrgba *prgba); 607 608 609 /** Retrieve a patcher's unlocked background color. 610 @ingroup jpatcher 611 @param p The patcher to be queried. 612 @param prgba The address of a valid #t_jrgba struct that will be filled-in with the current patcher color values. 613 @return A Max error code. */ 614 t_max_err jpatcher_get_bgcolor(t_object *p, t_jrgba *prgba); 615 616 /** Retrieve a patcher's locked background color. 617 @ingroup jpatcher 618 @param p The patcher to be queried. 619 @param prgba The address of a valid #t_jrgba struct that will be filled-in with the current patcher color values. 620 @return A Max error code. */ 621 t_max_err jpatcher_get_locked_bgcolor(t_object *p, t_jrgba *prgba); 622 623 /** Set a patcher's unlocked background color. 624 @ingroup jpatcher 625 @param p The patcher to be queried. 626 @param prgba The address of a #t_jrgba struct containing the new color to use. 627 @return A Max error code. */ 628 t_max_err jpatcher_set_bgcolor(t_object *p, t_jrgba *prgba); 629 630 /** Set a patcher's locked background color. 631 @ingroup jpatcher 632 @param p The patcher to be queried. 633 @param prgba The address of a #t_jrgba struct containing the new color to use. 634 @return A Max error code. */ 635 t_max_err jpatcher_set_locked_bgcolor(t_object *p, t_jrgba *prgba); 636 637 638 /** Retrieve a patcher's grid size. 639 @ingroup jpatcher 640 @param p The patcher to be queried. 641 @param gridsizeX The address of a double that will be set to the current horizontal grid spacing for the patcher. 642 @param gridsizeY The address of a double that will be set to the current vertical grid spacing for the patcher. 643 @return A Max error code. */ 644 t_max_err jpatcher_get_gridsize(t_object *p, double *gridsizeX, double *gridsizeY); 645 646 /** Set a patcher's grid size. 647 @ingroup jpatcher 648 @param p The patcher to be queried. 649 @param gridsizeX The new horizontal grid spacing for the patcher. 650 @param gridsizeY The new vertical grid spacing for the patcher. 651 @return A Max error code. */ 652 t_max_err jpatcher_set_gridsize(t_object *p, double gridsizeX, double gridsizeY); 653 654 655 // private 656 t_object* jpatcher_get_controller(t_object *p); 657 658 659 /** Delete an object that is in a patcher. 660 @ingroup jpatcher 661 @param p The patcher. 662 @param b The object box to delete. */ 663 void jpatcher_deleteobj(t_object *p, t_jbox *b); 664 665 666 /** Given a patcher, return its parent patcher. 667 @ingroup jpatcher 668 @param p The patcher to be queried. 669 @return The patcher's parent patcher, if there is one. 670 If there is no parent patcher (this is a top-level patcher) then NULL is returned. */ 671 t_object* jpatcher_get_parentpatcher(t_object *p); 672 673 /** Given a patcher, return the top-level patcher for the tree in which it exists. 674 @ingroup jpatcher 675 @param p The patcher to be queried. 676 @return The patcher's top-level parent patcher. */ 677 t_object* jpatcher_get_toppatcher(t_object *p); 678 679 /** Given a patcher, return the patcher that will be responsible for holding the parameter hub. 680 @ingroup jpatcher 681 @param p The patcher to be queried. 682 @return The patcher's parameter hub holder. */ 683 t_object* jpatcher_get_hubholder(t_object *p); 684 685 // unused 686 t_symbol* jpatcher_get_maxclass(t_object *p); 687 t_symbol* jpatcher_get_parentclass(t_object *p); 688 689 690 /** Query a patcher to determine its location and size. 691 @ingroup jpatcher 692 @param p A pointer to a patcher instance. 693 @param pr The address of valid #t_rect whose values will be filled-in upon return. 694 @return A Max error code. */ 695 t_max_err jpatcher_get_rect(t_object *p, t_rect *pr); 696 697 /** Set a patcher's location and size. 698 @ingroup jpatcher 699 @param p A pointer to a patcher instance. 700 @param pr The address of a #t_rect with the new position and size. 701 @return A Max error code. */ 702 t_max_err jpatcher_set_rect(t_object *p, t_rect *pr); 703 704 705 /** Query a patcher to determine the location and dimensions of its window when initially opened. 706 @ingroup jpatcher 707 @param p A pointer to a patcher instance. 708 @param pr The address of valid #t_rect whose values will be filled-in upon return. 709 @return A Max error code. */ 710 t_max_err jpatcher_get_defrect(t_object *p, t_rect *pr); 711 712 /** Set a patcher's default location and size. 713 @ingroup jpatcher 714 @param p A pointer to a patcher instance. 715 @param pr The address of a #t_rect with the new position and size. 716 @return A Max error code. */ 717 t_max_err jpatcher_set_defrect(t_object *p, t_rect *pr); 718 719 720 // private 721 char jpatcher_get_noedit(t_object *p); 722 t_object *jpatcher_get_collective(t_object *p); 723 char jpatcher_get_cansave(t_object *p); 724 725 726 /** Generate a unique name for a box in patcher. 727 @ingroup jpatcher 728 @param p A pointer to a patcher instance. 729 @param classname The name of an object's class. 730 @return The newly-generated unique name. 731 @remark This is the function used by pattr to assign names to objects in a patcher. */ 732 t_symbol *jpatcher_uniqueboxname(t_object *p, t_symbol *classname); 733 734 735 // private 736 short jpatcher_getboxfont(t_object *p, short fnum, double *fsize, t_symbol **fontname); 737 738 739 /** Return the name of the default font used for new objects in a patcher. 740 @ingroup jpatcher 741 @param p A pointer to a patcher instance. 742 @return The name of the default font used for new objects in a patcher. 743 */ 744 t_symbol *jpatcher_get_default_fontname(t_object *p); 745 746 747 /** Return the size of the default font used for new objects in a patcher. 748 @ingroup jpatcher 749 @param p A pointer to a patcher instance. 750 @return The size of the default font used for new objects in a patcher. 751 */ 752 float jpatcher_get_default_fontsize(t_object *p); 753 754 755 /** Return the index of the default font face used for new objects in a patcher. 756 @ingroup jpatcher 757 @param p A pointer to a patcher instance. 758 @return The index of the default font face used for new objects in a patcher. 759 */ 760 long jpatcher_get_default_fontface(t_object *p); 761 762 763 // private 764 t_max_err jpatcher_set_imprint(t_object *p, char c); 765 char jpatcher_get_imprint(t_object *p); 766 767 // private (only used by jdatatest) 768 void jpatcher_addboxlistener(t_object *p, t_object *listener); 769 void jpatcher_removeboxlistener(t_object *p, t_object *listener); 770 771 772 /** Return the file version of the patcher. 773 @ingroup jpatcher 774 @param p A pointer to the patcher whose version number is desired. 775 @return The file version number. */ 776 long jpatcher_get_fileversion(t_object *p); 777 778 /** Return the file version for any new patchers, e.g. the current version created by Max. 779 @ingroup jpatcher 780 @return The file version number. */ 781 long jpatcher_get_currentfileversion(void); 782 783 784 785 786 // Utilities to get/set box attributes 787 788 /** Find the rect for a box in a given patcherview. 789 @ingroup jbox 790 @param box The box whose rect will be fetched. 791 @param patcherview A patcherview in which the box exists. 792 @param rect The address of a valid #t_rect whose members will be filled in by this function. 793 @return A Max error code. */ 794 t_max_err jbox_get_rect_for_view(t_object *box, t_object *patcherview, t_rect *rect); 795 796 /** Change the rect for a box in a given patcherview. 797 @ingroup jbox 798 @param box The box whose rect will be changed. 799 @param patcherview A patcherview in which the box exists. 800 @param rect The address of a valid #t_rect that will replace the current values used by the box in the given view. 801 @return A Max error code. */ 802 t_max_err jbox_set_rect_for_view(t_object *box, t_object *patcherview, t_rect *rect); 803 804 /** Find the rect for a box with a given attribute name. 805 @ingroup jbox 806 @param box The box whose rect will be fetched. 807 @param which The name of the rect attribute to be fetched, for example <tt>_sym_presentation_rect</tt> or <tt>_sym_patching_rect</tt>. 808 @param pr The address of a valid #t_rect whose members will be filled in by this function. 809 @return A Max error code. */ 810 t_max_err jbox_get_rect_for_sym(t_object *box, t_symbol *which, t_rect *pr); 811 812 /** Change the rect for a box with a given attribute name. 813 @ingroup jbox 814 @param box The box whose rect will be changed. 815 @param which The name of the rect attribute to be changed, for example <tt>_sym_presentation_rect</tt> or <tt>_sym_patching_rect</tt>. 816 @param pr The address of a valid #t_rect that will replace the current values used by the box. 817 @return A Max error code. */ 818 t_max_err jbox_set_rect_for_sym(t_object *box, t_symbol *which, t_rect *pr); 819 820 821 /** Set both the presentation rect and the patching rect. 822 @ingroup jbox 823 @param box The box whose rect will be changed. 824 @param pr The address of a #t_rect with the new rect values. 825 @return A Max error code. */ 826 t_max_err jbox_set_rect(t_object *box, t_rect *pr); 827 828 /** Retrieve the patching rect of a box. 829 @ingroup jbox 830 @param box The box whose rect values will be retrieved. 831 @param pr The address of a valid #t_rect whose values will be filled in. 832 @return A Max error code. */ 833 t_max_err jbox_get_patching_rect(t_object *box, t_rect *pr); 834 835 /** Change the patching rect of a box. 836 @ingroup jbox 837 @param box The box whose rect will be changed. 838 @param pr The address of a #t_rect with the new rect values. 839 @return A Max error code. */ 840 t_max_err jbox_set_patching_rect(t_object *box, t_rect *pr); 841 842 /** Retrieve the presentation rect of a box. 843 @ingroup jbox 844 @param box The box whose rect values will be retrieved. 845 @param pr The address of a valid #t_rect whose values will be filled in. 846 @return A Max error code. */ 847 t_max_err jbox_get_presentation_rect(t_object *box, t_rect *pr); 848 849 /** Change the presentation rect of a box. 850 @ingroup jbox 851 @param box The box whose rect will be changed. 852 @param pr The address of a #t_rect with the new rect values. 853 @return A Max error code. */ 854 t_max_err jbox_set_presentation_rect(t_object *box, t_rect *pr); 855 856 857 /** Set the position of a box for both the presentation and patching views. 858 @ingroup jbox 859 @param box The box whose position will be changed. 860 @param pos The address of a #t_pt with the new x and y values. 861 @return A Max error code. */ 862 t_max_err jbox_set_position(t_object *box, t_pt *pos); 863 864 /** Fetch the position of a box for the patching view. 865 @ingroup jbox 866 @param box The box whose position will be retrieved. 867 @param pos The address of a valid #t_pt whose x and y values will be filled in. 868 @return A Max error code. */ 869 t_max_err jbox_get_patching_position(t_object *box, t_pt *pos); 870 871 /** Set the position of a box for the patching view. 872 @ingroup jbox 873 @param box The box whose positon will be changed. 874 @param pos The address of a #t_pt with the new x and y values. 875 @return A Max error code. */ 876 t_max_err jbox_set_patching_position(t_object *box, t_pt *pos); 877 878 /** Fetch the position of a box for the presentation view. 879 @ingroup jbox 880 @param box The box whose position will be retrieved. 881 @param pos The address of a valid #t_pt whose x and y values will be filled in. 882 @return A Max error code. */ 883 t_max_err jbox_get_presentation_position(t_object *box, t_pt *pos); 884 885 /** Set the position of a box for the presentation view. 886 @ingroup jbox 887 @param box The box whose rect will be changed. 888 @param pos The address of a #t_pt with the new x and y values. 889 @return A Max error code. */ 890 t_max_err jbox_set_presentation_position(t_object *box, t_pt *pos); 891 892 893 /** Set the size of a box for both the presentation and patching views. 894 @ingroup jbox 895 @param box The box whose size will be changed. 896 @param size The address of a #t_size with the new size values. 897 @return A Max error code. */ 898 t_max_err jbox_set_size(t_object *box, t_size *size); 899 900 /** Fetch the size of a box for the patching view. 901 @ingroup jbox 902 @param box The box whose size will be retrieved. 903 @param size The address of a valid #t_size whose width and height values will be filled in. 904 @return A Max error code. */ 905 t_max_err jbox_get_patching_size(t_object *box, t_size *size); 906 907 /** Set the size of a box for the patching view. 908 @ingroup jbox 909 @param box The box whose size will be changed. 910 @param size The address of a #t_size with the new width and height values. 911 @return A Max error code. */ 912 t_max_err jbox_set_patching_size(t_object *box, t_size *size); 913 914 /** Fetch the size of a box for the presentation view. 915 @ingroup jbox 916 @param box The box whose size will be retrieved. 917 @param size The address of a valid #t_size whose width and height values will be filled in. 918 @return A Max error code. */ 919 t_max_err jbox_get_presentation_size(t_object *box, t_size *size); 920 921 /** Set the size of a box for the presentation view. 922 @ingroup jbox 923 @param box The box whose size will be changed. 924 @param size The address of a #t_size with the new width and height values. 925 @return A Max error code. */ 926 t_max_err jbox_set_presentation_size(t_object *box, t_size *size); 927 928 929 930 931 /** Retrieve the name of the class of the box's object. 932 @ingroup jbox 933 @param b The box to query. 934 @return The name of the class of the box's object. */ 935 t_symbol* jbox_get_maxclass(t_object *b); 936 937 /** Retrieve a pointer to the box's object. 938 @ingroup jbox 939 @param b The box to query. 940 @return A pointer to the box's object. */ 941 t_object* jbox_get_object(t_object *b); 942 943 /** Retrieve a box's patcher. 944 @ingroup jbox 945 @param b The box to query. 946 @return If the box has a patcher, the patcher's pointer is returned. 947 Otherwise NULL is returned. */ 948 t_object* jbox_get_patcher(t_object *b); 949 950 951 /** Retrieve a box's 'hidden' attribute. 952 @ingroup jbox 953 @param b The box to query. 954 @return True if the box is hidden, otherwise false. */ 955 char jbox_get_hidden(t_object *b); 956 957 /** Set a box's 'hidden' attribute. 958 @ingroup jbox 959 @param b The box to query. 960 @param c Set to true to hide the box, otherwise false. 961 @return A Max error code. */ 962 t_max_err jbox_set_hidden(t_object *b, char c); 963 964 965 /** Retrieve a box's 'fontname' attribute. 966 @ingroup jbox 967 @param b The box to query. 968 @return The font name. */ 969 t_symbol* jbox_get_fontname(t_object *b); 970 971 /** Set a box's 'fontname' attribute. 972 @ingroup jbox 973 @param b The box to query. 974 @param ps The font name. Note that the font name may be case-sensitive. 975 @return A Max error code. */ 976 t_max_err jbox_set_fontname(t_object *b, t_symbol *ps); 977 978 979 /** Retrieve a box's 'fontsize' attribute. 980 @ingroup jbox 981 @param b The box to query. 982 @return The font size in points. */ 983 double jbox_get_fontsize(t_object *b); 984 985 /** Set a box's 'fontsize' attribute. 986 @ingroup jbox 987 @param b The box to query. 988 @param d The fontsize in points. 989 @return A Max error code. */ 990 t_max_err jbox_set_fontsize(t_object *b, double d); 991 992 993 /** Retrieve a box's 'color' attribute. 994 @ingroup jbox 995 @param b The box to query. 996 @param prgba The address of a valid #t_rect whose values will be filled-in upon return. 997 @return A Max error code. */ 998 t_max_err jbox_get_color(t_object *b, t_jrgba *prgba); 999 1000 /** Set a box's 'color' attribute. 1001 @ingroup jbox 1002 @param b The box to query. 1003 @param prgba The address of a #t_rect containing the desired color for the box/object. 1004 @return A Max error code. */ 1005 t_max_err jbox_set_color(t_object *b, t_jrgba *prgba); 1006 1007 1008 /** Retrieve a box's hint text as a symbol. 1009 @ingroup jbox 1010 @param b The box to query. 1011 @return The box's hint text. */ 1012 t_symbol *jbox_get_hint(t_object *b); 1013 1014 /** Set a box's hint text using a symbol. 1015 @ingroup jbox 1016 @param b The box to query. 1017 @param s The new text to use for the box's hint. 1018 @return A Max error code. */ 1019 t_max_err jbox_set_hint(t_object *b, t_symbol *s); 1020 1021 1022 /** Retrieve a box's hint text as a C-string. 1023 @ingroup jbox 1024 @param bb The box to query. 1025 @return The box's hint text. */ 1026 char *jbox_get_hintstring(t_object *bb); 1027 1028 /** Set a box's hint text using a C-string. 1029 @ingroup jbox 1030 @param bb The box to query. 1031 @param s The new text to use for the box's hint. 1032 @return A Max error code. */ 1033 void jbox_set_hintstring(t_object *bb, char *s); 1034 1035 1036 char jbox_get_hinttrack(t_object *b); 1037 t_max_err jbox_set_hinttrack(t_object *b, char h); 1038 1039 1040 /** Retrieve a box's annotation string, if the user has given it an annotation. 1041 @ingroup jbox 1042 @param bb The box to query. 1043 @return The user-created annotation string for a box, or NULL if no string exists. */ 1044 char *jbox_get_annotation(t_object *bb); 1045 1046 /** Set a box's annotation string. 1047 @ingroup jbox 1048 @param bb The box to query. 1049 @param s The annotation string for the box. 1050 @return A Max error code. */ 1051 void jbox_set_annotation(t_object *bb, char *s); 1052 1053 1054 /** The next box in the patcher's (linked) list of boxes. 1055 @ingroup jbox 1056 @param b The box to query. 1057 @return The next box in the list. */ 1058 t_object* jbox_get_nextobject(t_object *b); 1059 1060 /** The previous box in the patcher's (linked) list of boxes. 1061 @ingroup jbox 1062 @param b The box to query. 1063 @return The next box in the list. */ 1064 t_object* jbox_get_prevobject(t_object *b); 1065 1066 1067 // not implemented? 1068 // t_symbol* jbox_get_f(t_object *b); 1069 1070 1071 /** Retrieve a box's scripting name. 1072 @ingroup jbox 1073 @param b The box to query. 1074 @return The box's scripting name. */ 1075 t_symbol* jbox_get_varname(t_object *b); 1076 1077 /** Set a box's scripting name. 1078 @ingroup jbox 1079 @param b The box to query. 1080 @param ps The new scripting name for the box. 1081 @return A Max error code. */ 1082 t_max_err jbox_set_varname(t_object *b, t_symbol *ps); 1083 1084 1085 /** Retrieve a boxes unique id. 1086 @ingroup jbox 1087 @param b The box to query. 1088 @return The unique id of the object. This is a symbol that is referenced, for example, by patchlines. */ 1089 t_symbol* jbox_get_id(t_object *b); 1090 1091 1092 /** Retrieve a box flag value from a box. 1093 @ingroup jbox 1094 @param b The box to query. 1095 @return The value of the canhilite bit in the box's flags. */ 1096 char jbox_get_canhilite(t_object *b); 1097 1098 1099 /** Determine whether a box is located in the patcher's background layer. 1100 @ingroup jbox 1101 @param b The box to query. 1102 @return Zero if the object is in the foreground, otherwise non-zero. */ 1103 char jbox_get_background(t_object *b); 1104 1105 /** Set whether a box should be in the background or foreground layer of a patcher. 1106 @ingroup jbox 1107 @param b The box to query. 1108 @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. 1109 @return A Max error code. */ 1110 t_max_err jbox_set_background(t_object *b, char c); 1111 1112 1113 /** Determine whether a box ignores clicks. 1114 @ingroup jbox 1115 @param b The box to query. 1116 @return Zero if the object responds to clicks, otherwise non-zero. */ 1117 char jbox_get_ignoreclick(t_object *b); 1118 1119 /** Set whether a box ignores clicks. 1120 @ingroup jbox 1121 @param b The box to query. 1122 @param c Pass zero to tell the box to respond to clicks, or non-zero to indicate that the box should ignore clicks. 1123 @return A Max error code. */ 1124 t_max_err jbox_set_ignoreclick(t_object *b, char c); 1125 1126 1127 /** Determine whether a box draws its first inlet. 1128 @ingroup jbox 1129 @param b The box to query. 1130 @return Zero if the inlet is not drawn, otherwise non-zero. */ 1131 char jbox_get_drawfirstin(t_object *b); 1132 1133 1134 /** Determine whether a box draws an outline. 1135 @ingroup jbox 1136 @param b The box to query. 1137 @return Zero if the outline is not drawn, otherwise non-zero. */ 1138 char jbox_get_outline(t_object *b); 1139 1140 /** Set whether a box draws an outline. 1141 @ingroup jbox 1142 @param b The box to query. 1143 @param c Pass zero to hide the outline, or non-zero to indicate that the box should draw the outline. 1144 @return A Max error code. */ 1145 t_max_err jbox_set_outline(t_object *b, char c); 1146 1147 1148 /** Retrieve a box flag value from a box. 1149 @ingroup jbox 1150 @param b The box to query. 1151 @return The value of the growy bit in the box's flags. */ 1152 char jbox_get_growy(t_object *b); 1153 1154 /** Retrieve a box flag value from a box. 1155 @ingroup jbox 1156 @param b The box to query. 1157 @return The value of the growboth bit in the box's flags. */ 1158 char jbox_get_growboth(t_object *b); 1159 1160 /** Retrieve a box flag value from a box. 1161 @ingroup jbox 1162 @param b The box to query. 1163 @return The value of the nogrow bit in the box's flags. */ 1164 char jbox_get_nogrow(t_object *b); 1165 1166 /** Retrieve a box flag value from a box. 1167 @ingroup jbox 1168 @param b The box to query. 1169 @return The value of the drawinlast bit in the box's flags. */ 1170 char jbox_get_drawinlast(t_object *b); 1171 1172 1173 // private? 1174 char jbox_get_mousedragdelta(t_object *b); 1175 t_max_err jbox_set_mousedragdelta(t_object *b, char c); 1176 1177 1178 /** Retrieve a pointer to a box's textfield. 1179 @ingroup jbox 1180 @param b The box to query. 1181 @return The textfield for the box, assuming it has one. 1182 If the box does not own a textfield then NULL is returned. */ 1183 t_object* jbox_get_textfield(t_object *b); 1184 1185 1186 // private 1187 long jbox_get_understanding(t_object *b, t_symbol *msg); 1188 1189 1190 /** Determine if a box is included in the presentation view. 1191 @ingroup jbox 1192 @param b The box to query. 1193 @return Non-zero if in presentation mode, otherwise zero. */ 1194 char jbox_get_presentation(t_object *b); 1195 1196 /** Determine if a box is included in the presentation view. 1197 @ingroup jbox 1198 @param b The box to query. 1199 @param c Pass zero to remove a box from the presention view, or non-zero to add it to the presentation view. 1200 @return Non-zero if in presentation mode, otherwise zero. */ 1201 t_max_err jbox_set_presentation(t_object *b, char c); 1202 1203 1204 // private 1205 t_object *jbox_get_autocompletion(t_object *b); 1206 t_symbol *jbox_get_prototypename(t_object *b); 1207 void jbox_set_prototypename(t_object *b, t_symbol *name); 1208 t_atom_long jclipboard_datatypes(void); 1209 void jbox_validaterects(t_jbox *b); 1210 1211 1212 1213 // utilities to get/set patchline attributes 1214 1215 typedef enum _patchline_updatetype { 1216 JPATCHLINE_DISCONNECT=0, 1217 JPATCHLINE_CONNECT=1, 1218 JPATCHLINE_ORDER=2 1219 } t_patchline_updatetype; 1220 1221 /** Retrieve a patchline's starting point. 1222 @ingroup jpatchline 1223 @param l A pointer to the patchline's instance. 1224 @param x The address of a variable to hold the x-coordinate of the starting point's position upon return. 1225 @param y The address of a variable to hold the y-coordinate of the starting point's position upon return. 1226 @return A Max error code. */ 1227 t_max_err jpatchline_get_startpoint(t_object *l, double *x, double *y); 1228 1229 /** Retrieve a patchline's ending point. 1230 @ingroup jpatchline 1231 @param l A pointer to the patchline's instance. 1232 @param x The address of a variable to hold the x-coordinate of the ending point's position upon return. 1233 @param y The address of a variable to hold the y-coordinate of the ending point's position upon return. 1234 @return A Max error code. */ 1235 t_max_err jpatchline_get_endpoint(t_object *l, double *x, double *y); 1236 1237 /** Determine the number of midpoints (segments) in a patchline. 1238 @ingroup jpatchline 1239 @param l A pointer to the patchline's instance. 1240 @return The number of midpoints in the patchline. */ 1241 long jpatchline_get_nummidpoints(t_object *l); 1242 1243 char jpatchline_get_pending(t_object *l); 1244 1245 1246 /** Return the object box from which a patchline originates. 1247 @ingroup jpatchline 1248 @param l A pointer to the patchline's instance. 1249 @return The object box from which the patchline originates. */ 1250 t_object* jpatchline_get_box1(t_object *l); 1251 1252 /** Return the outlet number of the originating object box from which a patchline begins. 1253 @ingroup jpatchline 1254 @param l A pointer to the patchline's instance. 1255 @return The outlet number. */ 1256 long jpatchline_get_outletnum(t_object *l); 1257 1258 1259 /** Return the destination object box for a patchline. 1260 @ingroup jpatchline 1261 @param l A pointer to the patchline's instance. 1262 @return The destination object box for a patchline. */ 1263 t_object* jpatchline_get_box2(t_object *l); 1264 1265 /** Return the inlet number of the destination object box to which a patchline is connected. 1266 @ingroup jpatchline 1267 @param l A pointer to the patchline's instance. 1268 @return The inlet number. */ 1269 long jpatchline_get_inletnum(t_object *l); 1270 1271 1272 // private? 1273 double jpatchline_get_straightthresh(t_object *l); 1274 t_max_err jpatchline_set_straightthresh(t_object *l, double d); 1275 1276 // private? 1277 char jpatchline_get_straightstart(t_object *l); 1278 char jpatchline_get_straightend(t_object *l); 1279 1280 // private? 1281 t_max_err jpatchline_set_straightstart(t_object *l, char c); 1282 t_max_err jpatchline_set_straightend(t_object *l, char c); 1283 1284 1285 /** Given a patchline, traverse to the next patchline in the (linked) list. 1286 @ingroup jpatchline 1287 @param b A patchline instance. 1288 @return The next patchline. 1289 If the current patchline is at the end (tail) of the list, then NULL is returned. 1290 */ 1291 t_object* jpatchline_get_nextline(t_object *b); 1292 1293 1294 /** Determine if a patch line is hidden. 1295 @ingroup jpatchline 1296 @param l A patchline instance. 1297 @return Zero if the patchline is visible, non-zero if it is hidden. 1298 */ 1299 char jpatchline_get_hidden(t_object *l); 1300 1301 /** Set a patchline's visibility. 1302 @ingroup jpatchline 1303 @param l A patchline instance. 1304 @param c Pass 0 to make a patchline visible, or non-zero to hide it. 1305 @return An error code. 1306 */ 1307 t_max_err jpatchline_set_hidden(t_object *l, char c); 1308 1309 1310 /** Get the color of a patch line. 1311 @ingroup jpatchline 1312 @param l A patchline instance. 1313 @param prgba The address of a valid #t_jrgba struct that will be filled with the color values of the patch line. 1314 @return An error code. 1315 */ 1316 t_max_err jpatchline_get_color(t_object *l, t_jrgba *prgba); 1317 1318 /** Set the color of a patch line. 1319 @ingroup jpatchline 1320 @param l A patchline instance. 1321 @param prgba The address of a valid #t_jrgba struct containing the color to use. 1322 @return An error code. 1323 */ 1324 t_max_err jpatchline_set_color(t_object *l, t_jrgba *prgba); 1325 1326 1327 // private 1328 t_object *jpatchline_get_wiretap(t_object *l); 1329 long wiretap_get_id(t_object *w); 1330 long wiretap_get_flags(t_object *w); 1331 void wiretap_set_flags(t_object *w, long n); 1332 1333 1334 1335 1336 // utilities to get/set patcherview attributes 1337 1338 /** Query a patcherview to determine whether it is visible. 1339 @ingroup jpatcherview 1340 @param pv The patcherview instance to query. 1341 @return Returns zero if the patcherview is invisible, otherwise returns non-zero. */ 1342 char patcherview_get_visible(t_object *pv); 1343 1344 /** Set the 'visible' attribute of a patcherview. 1345 @ingroup jpatcherview 1346 @param pv The patcherview instance whose attribute will be set. 1347 @param c Whether or not the patcherview should be made visible. 1348 @return An error code. */ 1349 t_max_err patcherview_set_visible(t_object *pv, char c); 1350 1351 1352 /** Get the value of the rect attribute for a patcherview. 1353 @ingroup jpatcherview 1354 @param pv The patcherview instance whose attribute value will be fetched. 1355 @param pr The address of a valid #t_rect struct, whose contents will be filled upon return. 1356 @return An error code. */ 1357 t_max_err patcherview_get_rect(t_object *pv, t_rect *pr); 1358 1359 /** Set the value of the rect attribute for a patcherview. 1360 @ingroup jpatcherview 1361 @param pv The patcherview instance whose attribute value will be set. 1362 @param pr The address of a valid #t_rect struct. 1363 @return An error code. */ 1364 t_max_err patcherview_set_rect(t_object *pv, t_rect *pr); 1365 1366 /** Convert the point cx, cy in canvas coordinates to screen coordinates. 1367 @ingroup jpatcherview 1368 @param pv The patcherview instance the canvas coords are relative to. 1369 @param cx The x dimension of the canvas coordinate relative to the patcherview. 1370 @param cy The y dimension of the canvas coordinate relative to the patcherview. 1371 @param sx A pointer to a long to receive the screen coordinate x dimension. 1372 @param sy A pointer to a long to receive the screen coordinate y dimension. 1373 */ 1374 void patcherview_canvas_to_screen(t_object *pv, double cx, double cy, long *sx, long *sy); 1375 1376 /** Convert the point cx, cy in canvas coordinates to screen coordinates. 1377 @ingroup jpatcherview 1378 @param pv The patcherview instance the canvas coords are relative to. 1379 @param sx The screen position x coordinate. 1380 @param sy The screen position y coordinate 1381 @param cx A pointer to a double to receive the canvas coordinate for the given screen x position. 1382 @param cy A pointer to a double to receive the canvas coordinate for the given screen y position. 1383 */ 1384 void patcherview_screen_to_canvas(t_object *pv, long sx, long sy, double *cx, double *cy); 1385 1386 /** Find out if a patcherview is locked. 1387 @ingroup jpatcherview 1388 @param p The patcherview instance whose attribute value will be fetched. 1389 @return Returns 0 if unlocked, otherwise returns non-zero. */ 1390 char patcherview_get_locked(t_object *p); 1391 1392 /** Lock or unlock a patcherview. 1393 @ingroup jpatcherview 1394 @param p The patcherview instance whose attribute value will be set. 1395 @param c Set this value to zero to unlock the patcherview, otherwise pass a non-zero value. 1396 @return An error code. */ 1397 t_max_err patcherview_set_locked(t_object *p, char c); 1398 1399 1400 /** Find out if a patcherview is a presentation view. 1401 @ingroup jpatcherview 1402 @param pv The patcherview instance whose attribute value will be fetched. 1403 @return Returns 0 if the view is not a presentation view, otherwise returns non-zero. */ 1404 char patcherview_get_presentation(t_object *pv); 1405 1406 /** Set whether or not a patcherview is a presentation view. 1407 @ingroup jpatcherview 1408 @param p The patcherview instance whose attribute value will be set. 1409 @param c Set this value to non-zero to make the patcherview a presentation view, otherwise pass zero. 1410 @return An error code. */ 1411 t_max_err patcherview_set_presentation(t_object *p, char c); 1412 1413 1414 /** Fetch the zoom-factor of a patcherview. 1415 @ingroup jpatcherview 1416 @param pv The patcherview instance whose attribute value will be fetched. 1417 @return The factor by which the view is zoomed. */ 1418 double patcherview_get_zoomfactor(t_object *pv); 1419 1420 /** Set the zoom-factor of a patcherview. 1421 @ingroup jpatcherview 1422 @param pv The patcherview instance whose attribute value will be set. 1423 @param d The zoom-factor at which the patcherview should display the patcher. 1424 @return An error code. */ 1425 t_max_err patcherview_set_zoomfactor(t_object *pv, double d); 1426 1427 1428 /** Given a patcherview, find the next patcherview. 1429 The views of a patcher are maintained internally as a #t_linklist, 1430 and so the views can be traversed should you need to perform operations on all of a patcher's patcherviews. 1431 @ingroup jpatcherview 1432 @param pv The patcherview instance from which to find the next patcherview. 1433 @return The next patcherview in the list, or NULL if the patcherview passed in pv is the tail. */ 1434 t_object* patcherview_get_nextview(t_object *pv); 1435 1436 1437 /** Given a patcherview, return the #t_jgraphics context for that view. 1438 @ingroup jpatcherview 1439 @param pv The patcherview instance. 1440 @return The #t_jgraphics context for the view. */ 1441 t_object* patcherview_get_jgraphics(t_object *pv); 1442 1443 // private 1444 t_max_err patcherview_set_jgraphics(t_object *pv, t_object *po); 1445 1446 1447 /** Given a patcherview, return its patcher. 1448 @ingroup jpatcherview 1449 @param pv The patcherview instance for which to fetch the patcher. 1450 @return The patcher. */ 1451 t_object* patcherview_get_patcher(t_object *pv); 1452 1453 /** Given a patcherview, return the top patcherview (possibly itself). 1454 If the patcherview is inside a bpatcher which is in a patcher then 1455 this will give you the view the bpatcher view is inside of. 1456 @ingroup jpatcherview 1457 @param pv The patcherview instance whose top view you want to get. 1458 @return The top patcherview. */ 1459 t_object* patcherview_get_topview(t_object *pv); 1460 1461 1462 // utilities to get/set textfield attributes 1463 1464 /** Return the object that owns a particular textfield. 1465 @ingroup textfield 1466 @param tf The textfield instance pointer. 1467 @return A pointer to the owning object. */ 1468 t_object* textfield_get_owner(t_object *tf); 1469 1470 1471 /** Retrieve the color of the text in a textfield. 1472 @ingroup textfield 1473 @param tf The textfield instance pointer. 1474 @param prgba The address of a valid #t_jrgba whose values will be filled-in upon return. 1475 @return A Max error code. */ 1476 t_max_err textfield_get_textcolor(t_object *tf, t_jrgba *prgba); 1477 1478 /** Set the color of the text in a textfield. 1479 @ingroup textfield 1480 @param tf The textfield instance pointer. 1481 @param prgba The address of a #t_jrgba containing the new color to use. 1482 @return A Max error code. */ 1483 t_max_err textfield_set_textcolor(t_object *tf, t_jrgba *prgba); 1484 1485 1486 /** Retrieve the background color of a textfield. 1487 @ingroup textfield 1488 @param tf The textfield instance pointer. 1489 @param prgba The address of a valid #t_jrgba whose values will be filled-in upon return. 1490 @return A Max error code. */ 1491 t_max_err textfield_get_bgcolor(t_object *tf, t_jrgba *prgba); 1492 1493 /** Set the background color of a textfield. 1494 @ingroup textfield 1495 @param tf The textfield instance pointer. 1496 @param prgba The address of a #t_jrgba containing the new color to use. 1497 @return A Max error code. */ 1498 t_max_err textfield_set_bgcolor(t_object *tf, t_jrgba *prgba); 1499 1500 1501 /** Retrieve the margins from the edge of the textfield to the text itself in a textfield. 1502 @ingroup textfield 1503 @param tf The textfield instance pointer. 1504 @param pleft The address of a variable to hold the value of the left margin upon return. 1505 @param ptop The address of a variable to hold the value of the top margin upon return. 1506 @param pright The address of a variable to hold the value of the right margin upon return. 1507 @param pbottom The address of a variable to hold the value of the bottom margin upon return. 1508 @return A Max error code. */ 1509 t_max_err textfield_get_textmargins(t_object *tf, double *pleft, double *ptop, double *pright, double *pbottom); 1510 1511 /** Set the margins from the edge of the textfield to the text itself in a textfield. 1512 @ingroup textfield 1513 @param tf The textfield instance pointer. 1514 @param left The new value for the left margin. 1515 @param top The new value for the top margin. 1516 @param right The new value for the right margin. 1517 @param bottom The new value for the bottom margin. 1518 @return A Max error code. */ 1519 t_max_err textfield_set_textmargins(t_object *tf, double left, double top, double right, double bottom); 1520 1521 1522 /** Return the value of the 'editonclick' attribute of a textfield. 1523 @ingroup textfield 1524 @param tf The textfield instance pointer. 1525 @return A value of the attribute. */ 1526 char textfield_get_editonclick(t_object *tf); 1527 1528 /** Set the 'editonclick' attribute of a textfield. 1529 @ingroup textfield 1530 @param tf The textfield instance pointer. 1531 @param c The new value for the attribute. 1532 @return A Max error code. */ 1533 t_max_err textfield_set_editonclick(t_object *tf, char c); 1534 1535 1536 /** Return the value of the 'selectallonedit' attribute of a textfield. 1537 @ingroup textfield 1538 @param tf The textfield instance pointer. 1539 @return A value of the attribute. */ 1540 char textfield_get_selectallonedit(t_object *tf); 1541 1542 /** Set the 'selectallonedit' attribute of a textfield. 1543 @ingroup textfield 1544 @param tf The textfield instance pointer. 1545 @param c The new value for the attribute. 1546 @return A Max error code. */ 1547 t_max_err textfield_set_selectallonedit(t_object *tf, char c); 1548 1549 1550 /** Return the value of the 'noactivate' attribute of a textfield. 1551 @ingroup textfield 1552 @param tf The textfield instance pointer. 1553 @return A value of the attribute. */ 1554 char textfield_get_noactivate(t_object *tf); 1555 1556 /** Set the 'noactivate' attribute of a textfield. 1557 @ingroup textfield 1558 @param tf The textfield instance pointer. 1559 @param c The new value for the attribute. 1560 @return A Max error code. */ 1561 t_max_err textfield_set_noactivate(t_object *tf, char c); 1562 1563 1564 /** Return the value of the 'readonly' attribute of a textfield. 1565 @ingroup textfield 1566 @param tf The textfield instance pointer. 1567 @return A value of the attribute. */ 1568 char textfield_get_readonly(t_object *tf); 1569 1570 /** Set the 'readonly' attribute of a textfield. 1571 @ingroup textfield 1572 @param tf The textfield instance pointer. 1573 @param c The new value for the attribute. 1574 @return A Max error code. */ 1575 t_max_err textfield_set_readonly(t_object *tf, char c); 1576 1577 1578 /** Return the value of the 'wordwrap' attribute of a textfield. 1579 @ingroup textfield 1580 @param tf The textfield instance pointer. 1581 @return A value of the attribute. */ 1582 char textfield_get_wordwrap(t_object *tf); 1583 1584 /** Set the 'wordwrap' attribute of a textfield. 1585 @ingroup textfield 1586 @param tf The textfield instance pointer. 1587 @param c The new value for the attribute. 1588 @return A Max error code. */ 1589 t_max_err textfield_set_wordwrap(t_object *tf, char c); 1590 1591 1592 /** Return the value of the 'useellipsis' attribute of a textfield. 1593 @ingroup textfield 1594 @param tf The textfield instance pointer. 1595 @return A value of the attribute. */ 1596 char textfield_get_useellipsis(t_object *tf); 1597 1598 /** Set the 'useellipsis' attribute of a textfield. 1599 @ingroup textfield 1600 @param tf The textfield instance pointer. 1601 @param c The new value for the attribute. 1602 @return A Max error code. */ 1603 t_max_err textfield_set_useellipsis(t_object *tf, char c); 1604 1605 1606 /** Return the value of the 'autoscroll' attribute of a textfield. 1607 @ingroup textfield 1608 @param tf The textfield instance pointer. 1609 @return A value of the attribute. */ 1610 char textfield_get_autoscroll(t_object *tf); 1611 1612 /** Set the 'autoscroll' attribute of a textfield. 1613 @ingroup textfield 1614 @param tf The textfield instance pointer. 1615 @param c The new value for the attribute. 1616 @return A Max error code. */ 1617 t_max_err textfield_set_autoscroll(t_object *tf, char c); 1618 1619 1620 /** Return the value of the 'wantsreturn' attribute of a textfield. 1621 @ingroup textfield 1622 @param tf The textfield instance pointer. 1623 @return A value of the attribute. */ 1624 char textfield_get_wantsreturn(t_object *tf); 1625 1626 /** Set the 'wantsreturn' attribute of a textfield. 1627 @ingroup textfield 1628 @param tf The textfield instance pointer. 1629 @param c The new value for the attribute. 1630 @return A Max error code. */ 1631 t_max_err textfield_set_wantsreturn(t_object *tf, char c); 1632 1633 1634 /** Return the value of the 'wantstab' attribute of a textfield. 1635 @ingroup textfield 1636 @param tf The textfield instance pointer. 1637 @return A value of the attribute. */ 1638 char textfield_get_wantstab(t_object *tf); 1639 1640 /** Set the 'wantstab' attribute of a textfield. 1641 @ingroup textfield 1642 @param tf The textfield instance pointer. 1643 @param c The new value for the attribute. 1644 @return A Max error code. */ 1645 t_max_err textfield_set_wantstab(t_object *tf, char c); 1646 1647 1648 /** Return the value of the 'underline' attribute of a textfield. 1649 @ingroup textfield 1650 @param tf The textfield instance pointer. 1651 @return A value of the attribute. */ 1652 char textfield_get_underline(t_object *tf); 1653 1654 /** Set the 'underline' attribute of a textfield. 1655 @ingroup textfield 1656 @param tf The textfield instance pointer. 1657 @param c The new value for the attribute. 1658 @return A Max error code. */ 1659 t_max_err textfield_set_underline(t_object *tf, char c); 1660 1661 1662 // private 1663 char textfield_get_justification(t_object *tf); 1664 t_max_err textfield_set_justification(t_object *tf, char c); 1665 char textfield_get_autofixwidth(t_object *tf); 1666 t_max_err textfield_set_autofixwidth(t_object *tf, char c); 1667 1668 1669 /** Set the 'empty' text of a textfield. 1670 The empty text is the text that is displayed in the textfield when no text is present. 1671 By default this is gensym(""). 1672 @ingroup textfield 1673 @param tf The textfield instance pointer. 1674 @param txt A symbol containing the new text to display when the textfield has no content. 1675 @return A Max error code. */ 1676 t_max_err textfield_set_emptytext(t_object *tf, t_symbol *txt); 1677 1678 /** Retrieve the 'empty' text of a textfield. 1679 The empty text is the text that is displayed in the textfield when no text is present. 1680 By default this is gensym(""). 1681 @ingroup textfield 1682 @param tf The textfield instance pointer. 1683 @return The current text used as the empty text. */ 1684 t_symbol *textfield_get_emptytext(t_object *tf); 1685 1686 // textfield constants 1687 1688 #define TEXTFIELD_DEF_LEFTMARGIN (4) ///< textfield default left margin 1689 #define TEXTFIELD_DEF_TOPMARGIN (3) ///< textfield default top margin 1690 #define TEXTFIELD_DEF_RIGHTMARGIN (4) ///< textfield default right margin 1691 #define TEXTFIELD_DEF_BOTTOMMARGIN (3) ///< textfield default bottom margin 1692 1693 1694 // jbox flags 1695 // flags passed to box_new 1696 1697 // The following flags affect how the boxes are drawn 1698 #define JBOX_DRAWFIRSTIN (1<<0) ///< draw first inlet @ingroup jbox 1699 #define JBOX_NODRAWBOX (1<<1) ///< don't draw the frame @ingroup jbox 1700 #define JBOX_DRAWINLAST (1<<2) ///< draw inlets after update method @ingroup jbox 1701 1702 // JBOX_TRANSPARENT is unused -- box is always transparent by default 1703 #define JBOX_TRANSPARENT (1<<3) ///< don't make transparent unless you need it (for efficiency) @ingroup jbox 1704 1705 // Box growing: nogrow is clear -- box is not sizable. 1706 // Default (none of following three flags) means box width is only sizable. 1707 // JBOX_GROWY means that X and Y are sizable and the aspect ratio is fixed (or maybe it has to be square, like dial?). 1708 // JBOX_GROWBOTH means that X and Y are independently sizable. 1709 #define JBOX_NOGROW (1<<4) ///< don't even draw grow thingie @ingroup jbox 1710 #define JBOX_GROWY (1<<5) ///< can grow in y direction by dragging @ingroup jbox 1711 #define JBOX_GROWBOTH (1<<6) ///< can grow independently in both x and y @ingroup jbox 1712 1713 // Box interaction 1714 #define JBOX_IGNORELOCKCLICK (1<<7) ///< box should ignore a click if patcher is locked @ingroup jbox 1715 #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 1716 #define JBOX_BACKGROUND (1<<9) ///< immediately set box into the background @ingroup jbox 1717 #define JBOX_NOFLOATINSPECTOR (1<<10) ///< no floating inspector window @ingroup jbox 1718 1719 // textfield: give this flag for automatic textfield support 1720 #define JBOX_TEXTFIELD (1<<11) ///< save/load text from textfield, unless JBOX_BINBUF flag is set @ingroup jbox 1721 #define JBOX_FIXWIDTH (1<<19) ///< give the box a textfield based fix-width (bfixwidth) method @ingroup jbox 1722 #define JBOX_FONTATTR (1<<18) ///< if you want font related attribute you must add this to jbox_initclass() @ingroup jbox 1723 #define JBOX_TEXTJUSTIFICATIONATTR (1<<21) ///< give your object a textjustification attr to control textfield @ingroup jbox 1724 #define JBOX_BINBUF (1<<14) ///< save/load text from b_binbuf @ingroup jbox 1725 1726 #define JBOX_MOUSEDRAGDELTA (1<<12) ///< hides mouse cursor in drag and sends mousedragdelta instead of mousedrag (for infinite scrolling like number) @ingroup jbox 1727 1728 #define JBOX_COLOR (1<<13) ///< support the "color" method for color customization @ingroup jbox 1729 #define JBOX_DRAWIOLOCKED (1<<15) ///< draw inlets and outlets when locked (default is not to draw them) @ingroup jbox 1730 #define JBOX_DRAWBACKGROUND (1<<16) ///< set to have box bg filled in for you based on getdrawparams method or brgba attribute @ingroup jbox 1731 #define JBOX_NOINSPECTFIRSTIN (1<<17) ///< flag for objects such as bpatcher that have a different b_firstin, 1732 ///< but the attrs of the b_firstin should not be shown in the inspector @ingroup jbox 1733 1734 // JBOX_DEFAULTNAMES is unused -- box is attached automatically if needed 1735 // Since JBOX_DEFAULTNAMES was unused and used a conflicting flag bit with JBOX_FONTATTR it is being removed. 1736 // Just remove from your code if you have a compile error about JBOX_DEFAULTNAMES missing. 1737 //#define JBOX_DEFAULTNAMES (1<<18) ///< flag instructing jbox_new to attach object to the defaults object for live defaults updating @ingroup jbox 1738 1739 #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 1740 #define JBOX_BOXVIEW (1<<23) ///< enable jboxview methods @ingroup jbox 1741 1742 #define JBOX_LEGACYCOLOR (1<<22) ///< add undocumented color N message to objects from Max 4 that used it @ingroup jbox 1743 #define JBOX_COPYLEGACYDEFAULT (1<<24) ///< if there is a legacy default, copy it instead of the regular default @ingroup jbox 1744 #define JBOX_NOLEGACYDEFAULT (1<<25) ///< if there is a legacy default, don't copy any default @ingroup jbox 1745 1746 #define JBOX_MULTITOUCH (1<<26) ///< when passed to jbox_initclass box will be sent multitouch version of mouse messages 1747 1748 /** actual numerical values of the b_fontface attribute; use jbox_fontface() to weight 1749 @ingroup jbox */ 1750 enum { 1751 JBOX_FONTFACE_REGULAR = 0, ///< normal 1752 JBOX_FONTFACE_BOLD = 1, ///< bold 1753 JBOX_FONTFACE_ITALIC = 2, ///< italic 1754 JBOX_FONTFACE_BOLDITALIC = 3 ///< bold and italic 1755 }; 1756 1757 // The following two are not needed in the new world. 1758 // #define JBOX_MOVING 8 // object invalidates outside its defined clipping region 1759 // #define JBOX_SAVVY 2048 // calls box_enddraw after box_nodraw returns false 1760 1761 /** enumerations used for box decorators 1762 @ingroup jbox */ 1763 typedef enum _HitTestResult { 1764 HitNothing = 0, ///< a hole in the box 1765 HitBox = 1, ///< the body of the box 1766 HitInlet = 2, ///< an inlet 1767 HitOutlet = 3, ///< an outlet 1768 HitGrowBox = 4, ///< the grow handle 1769 HitLine = 5, ///< a line 1770 HitLineLocked = 6, ///< a line in a locked patcher (for probing) 1771 HitBorder = 7 ///< border around the box (drawn when selected), can use to select or move (only used when patch is unlocked) 1772 } HitTestResult; 1773 1774 // private 1775 typedef enum _DecoratorPaintFlags { 1776 BoxSelected = 1 << 0, 1777 DrawFirstIn = 1 << 1, 1778 NoGrow = 1 << 2, 1779 Outline = 1 << 3, 1780 Locked = 1 << 4, 1781 InletHighlighted = 1 << 5, // value tells index of highlighted inlet 1782 OutletHighlighted = 1 << 6 // value tells index of highlighted outlet (only one can be highlighted) 1783 } DecoratorPaintFlags; 1784 1785 1786 1787 // UI object functions for implementing your own UI objects 1788 1789 // private 1790 void jbox_initclass(t_class *c, long flags); 1791 1792 /** Set up your UI object's #t_jbox member. 1793 This should be called from your UI object's free method. 1794 @ingroup jbox 1795 @param b The address of your UI object's #t_jbox member (which should be the first member of the object's struct). 1796 @param flags Flags to set the box's behavior, such as #JBOX_NODRAWBOX. 1797 @param argc The count of atoms in the argv parameter. 1798 @param argv The address of the first in an array of atoms to be passed to the box constructor. 1799 Typically these are simply the argument passed to your object when it is created. 1800 @return A Max error code. */ 1801 t_max_err jbox_new(t_jbox *b, long flags, long argc, t_atom *argv); 1802 1803 /** Tear down your UI object's #t_jbox member. 1804 This should be called from your UI object's free method. 1805 @ingroup jbox 1806 @param b The address of your object's #t_jbox member (which should be the first member of the object's struct). */ 1807 void jbox_free(t_jbox *b); 1808 1809 /** Mark the box ready to be accessed and drawn by Max. 1810 This should typically be called at the end of your UI object's new method. 1811 @ingroup jbox 1812 @param b The address of your object's #t_jbox member. */ 1813 void jbox_ready(t_jbox *b); 1814 1815 1816 /** Request that your object/box be re-drawn by Max. 1817 @ingroup jbox 1818 @param b The address of your object's #t_jbox member. */ 1819 void jbox_redraw(t_jbox *b); 1820 1821 // private 1822 void jbox_redrawcontents(t_jbox *b); 1823 void *jbox_getoutlet(t_jbox *x, long index); 1824 void *jbox_getinlet(t_jbox *x, long index); 1825 void jbox_updatetextfield(t_jbox *b); 1826 1827 // fills in all missing legacy defaults if one is present 1828 1829 #define LEGACYDEFAULTS_FLAGS_FORCE 1 // forces it to happen 1830 1831 void jbox_processlegacydefaults(t_jbox *b, t_dictionary *d, long flags); 1832 1833 /** Send a notification to a box. This is the same as calling object_notify() for a box. 1834 @ingroup jbox 1835 @param b The address of your object's #t_jbox member. 1836 @param s The name of the send object. 1837 @param msg The notification name. 1838 @param sender The sending object's address. 1839 @param data A pointer to some data passed to the box's notify method. 1840 @return A Max error code. 1841 */ 1842 t_max_err jbox_notify(t_jbox *b, t_symbol *s, t_symbol *msg, void *sender, void *data); 1843 1844 // private 1845 t_max_err jbox_set_to_defaultsize(t_jbox *b, t_symbol *s, short argc, t_atom *argv); 1846 1847 1848 /** Grab the keyboard focus for your box. 1849 Calling this method should be considered exceptional, and its use is discouraged. 1850 @param b The address of your object's #t_jbox member. */ 1851 void jbox_grabfocus(t_jbox *b); 1852 1853 // private 1854 void jbox_redrawpeers(t_jbox *b); 1855 long jbox_getinletindex(t_jbox *b, void *inlet); 1856 long jbox_getoutletindex(t_jbox *b, void *outlet); 1857 t_symbol *jbox_get_boxpath(t_object *b); 1858 1859 void jbox_show_caption(t_jbox *b); 1860 void jbox_hide_caption(t_jbox *b); 1861 1862 1863 // dictionary stuff 1864 #define DICT_JRGBA 1 // convert RGB to jrgba when storing/retrieving from dictionary 1865 t_max_err dictionary_appendjrgba(t_dictionary *d, t_symbol *key, t_jrgba *jc); 1866 1867 t_max_err dictionary_getdefjrgba(t_dictionary *d, t_symbol *key, t_jrgba *jc, t_jrgba *def); 1868 1869 t_max_err dictionary_gettrect(t_dictionary *d, t_symbol *key, t_rect *rect); 1870 t_max_err dictionary_appendtrect(t_dictionary *d, t_symbol *key, t_rect *rect); 1871 1872 t_max_err dictionary_gettpt(t_dictionary *d, t_symbol *key, t_pt *pt); 1873 t_max_err dictionary_appendtpt(t_dictionary *d, t_symbol *key, t_pt *pt); 1874 1875 void atomstojrgba(long argc, t_atom *argv, t_jrgba *dest); 1876 void jrgbatoatoms(t_jrgba *src, t_atom *argv); 1877 1878 /** Read the specified YAML file and return a #t_dictionary object. 1879 You are responsible for freeing the dictionary with object_free(), 1880 subject to the caveats explained in @ref when_to_free_a_dictionary. 1881 @ingroup dictionary 1882 @param filename The name of the file. 1883 @param path The path of the file. 1884 @param d The address of a #t_dictionary pointer that will be set to the newly created dictionary. 1885 @return A Max error code 1886 */ 1887 1888 t_max_err dictionary_read_yaml(const char *filename, const short path, t_dictionary **d); 1889 1890 /** Serialize the specified #t_dictionary object to a YAML file. 1891 @ingroup dictionary 1892 @param d The dictionary to serialize into YAML format and write to disk. 1893 @param filename The name of the file to write. 1894 @param path The path to which the file should be written. 1895 @return A Max error code. 1896 */ 1897 t_max_err dictionary_write_yaml(const t_dictionary *d, const char *filename, const short path); 1898 1899 1900 // convenience for object-making 1901 1902 #define newobject_fromdictionary_delete(p,d) newobject_fromdictionary(p,d), freeobject((t_object *)d) 1903 1904 // private 1905 t_dictionary* dictionary_prototypefromclass(t_class *c); 1906 1907 /** 1908 Create a new object in a specified patcher with values using a combination of attribute and sprintf syntax. 1909 1910 @ingroup obj 1911 @param patcher An instance of a patcher object. 1912 @param fmt An sprintf-style format string specifying key-value pairs with attribute nomenclature. 1913 @param ... One or more arguments which are to be substituted into the format string. 1914 @return A pointer to the newly created object instance, or NULL if creation of the object fails. 1915 1916 @remark Max attribute syntax is used to define key-value pairs. For example, 1917 @code 1918 "@key1 value @key2 another_value" 1919 @endcode 1920 1921 @remark The example below creates a new object that in a patcher whose 1922 object pointer is stored in a variable called "aPatcher". 1923 @code 1924 t_object *my_comment; 1925 char text[4]; 1926 1927 strncpy_zero(text, "foo", 4); 1928 1929 my_comment = newobject_sprintf(aPatcher, "@maxclass comment @varname _name \ 1930 @text \"%s\" @patching_rect %.2f %.2f %.2f %.2f \ 1931 @fontsize %f @textcolor %f %f %f 1.0 \ 1932 @fontname %s @bgcolor 0.001 0.001 0.001 0.", 1933 text, 20.0, 20.0, 200.0, 24.0, 1934 18, 0.9, 0.9, 0.9, "Arial"); 1935 @endcode 1936 1937 @see dictionary_sprintf() 1938 @see newobject_fromdictionary() 1939 @see atom_setparse() 1940 */ 1941 t_object *newobject_sprintf(t_object *patcher, C74_CONST char *fmt, ...); 1942 1943 1944 /** 1945 Create an object from the passed in text. 1946 The passed in text is in the same format as would be typed into an object box. 1947 It can be used for UI objects or text objects so this is the simplest way to create objects from C. 1948 1949 @ingroup obj 1950 @param patcher An instance of a patcher object. 1951 @param text The text as if typed into an object box. 1952 @return A pointer to the newly created object instance, or NULL if creation of the object fails. 1953 1954 @see newobject_sprintf() 1955 */ 1956 t_object *newobject_fromboxtext(t_object *patcher, const char *text); 1957 1958 1959 /** 1960 Place a new object into a patcher. The new object will be created based on a specification 1961 contained in a @ref dictionary. 1962 1963 Create a new dictionary populated with values using a combination of attribute and sprintf syntax. 1964 1965 @ingroup obj 1966 @param patcher An instance of a patcher object. 1967 @param d A dictionary containing an object specification. 1968 @return A pointer to the newly created object instance, or NULL if creation of the object fails. 1969 1970 @remark Max attribute syntax is used to define key-value pairs. For example, 1971 @code 1972 "@key1 value @key2 another_value" 1973 @endcode 1974 1975 @remark The example below creates a new object that in a patcher whose 1976 object pointer is stored in a variable called "aPatcher". 1977 @code 1978 t_dictionary *d; 1979 t_object *o; 1980 char text[4]; 1981 1982 strncpy_zero(text, "foo", 4); 1983 1984 d = dictionary_sprintf("@maxclass comment @varname _name \ 1985 @text \"%s\" @patching_rect %.2f %.2f %.2f %.2f \ 1986 @fontsize %f @textcolor %f %f %f 1.0 \ 1987 @fontname %s @bgcolor 0.001 0.001 0.001 0.", 1988 text, 20.0, 20.0, 200.0, 24.0, 1989 18, 0.9, 0.9, 0.9, "Arial"); 1990 1991 o = newobject_fromdictionary(aPatcher, d); 1992 @endcode 1993 1994 @see newobject_sprintf() 1995 @see newobject_fromdictionary() 1996 @see atom_setparse() 1997 */ 1998 t_object *newobject_fromdictionary(t_object *patcher, t_dictionary *d); 1999 2000 /** Return the last known combination of modifier keys being held by the user. 2001 @ingroup jmouse 2002 @return The current modifier keys that are activated. */ 2003 t_modifiers jkeyboard_getcurrentmodifiers(void); 2004 2005 /** Return the current combination of modifier keys being held by the user. 2006 @ingroup jmouse 2007 @return The current modifier keys that are activated. */ 2008 t_modifiers jkeyboard_getcurrentmodifiers_realtime(void); 2009 2010 // mouse cursor stuff 2011 2012 /** Get the position of the mouse cursor in screen coordinates. 2013 @ingroup jmouse 2014 @param x The address of a variable to hold the x-coordinate upon return. 2015 @param y The address of a variable to hold the y-coordinate upon return. */ 2016 void jmouse_getposition_global(int *x, int *y); 2017 2018 /** Set the position of the mouse cursor in screen coordinates. 2019 @ingroup jmouse 2020 @param x The new x-coordinate of the mouse cursor position. 2021 @param y The new y-coordinate of the mouse cursor position. */ 2022 void jmouse_setposition_global(int x, int y); 2023 2024 /** Set the position of the mouse cursor relative to the patcher canvas coordinates. 2025 @ingroup jmouse 2026 @param patcherview The patcherview upon which the mouse coordinates are based. 2027 @param cx The new x-coordinate of the mouse cursor position. 2028 @param cy The new y-coordinate of the mouse cursor position. */ 2029 void jmouse_setposition_view(t_object *patcherview, double cx, double cy); 2030 2031 /** Set the position of the mouse cursor relative to a box within the patcher canvas coordinates. 2032 @ingroup jmouse 2033 @param patcherview The patcherview containing the box upon which the mouse coordinates are based. 2034 @param box The box upon which the mouse coordinates are based. 2035 @param bx The new x-coordinate of the mouse cursor position. 2036 @param by The new y-coordinate of the mouse cursor position. */ 2037 void jmouse_setposition_box(t_object *patcherview, t_object *box, double bx, double by); 2038 2039 void *jmouse_getobject(void); 2040 2041 /** Mouse cursor types. 2042 @ingroup jmouse */ 2043 typedef enum _jmouse_cursortype { 2044 JMOUSE_CURSOR_NONE, ///< None 2045 JMOUSE_CURSOR_ARROW, ///< Arrow 2046 JMOUSE_CURSOR_WAIT, ///< Wait 2047 JMOUSE_CURSOR_IBEAM, ///< I-Beam 2048 JMOUSE_CURSOR_CROSSHAIR, ///< Crosshair 2049 JMOUSE_CURSOR_COPYING, ///< Copying 2050 JMOUSE_CURSOR_POINTINGHAND, ///< Pointing Hand 2051 JMOUSE_CURSOR_DRAGGINGHAND, ///< Dragging Hand 2052 JMOUSE_CURSOR_RESIZE_LEFTRIGHT, ///< Left-Right 2053 JMOUSE_CURSOR_RESIZE_UPDOWN, ///< Up-Down 2054 JMOUSE_CURSOR_RESIZE_FOURWAY, ///< Four Way 2055 JMOUSE_CURSOR_RESIZE_TOPEDGE, ///< Top Edge 2056 JMOUSE_CURSOR_RESIZE_BOTTOMEDGE, ///< Bottom Edge 2057 JMOUSE_CURSOR_RESIZE_LEFTEDGE, ///< Left Edge 2058 JMOUSE_CURSOR_RESIZE_RIGHTEDGE, ///< Right Edge 2059 JMOUSE_CURSOR_RESIZE_TOPLEFTCORNER, ///< Top-Left Corner 2060 JMOUSE_CURSOR_RESIZE_TOPRIGHTCORNER, ///< Top-Right Corner 2061 JMOUSE_CURSOR_RESIZE_BOTTOMLEFTCORNER, ///< Bottom-Left Corner 2062 JMOUSE_CURSOR_RESIZE_BOTTOMRIGHTCORNER ///< Bottom-Right Corner 2063 } t_jmouse_cursortype; 2064 2065 2066 /** Set the mouse cursor. 2067 @ingroup jmouse 2068 @param patcherview The patcherview for which the cursor should be applied. 2069 @param box The box for which the cursor should be applied. 2070 @param type The type of cursor for the mouse to use. */ 2071 void jmouse_setcursor(t_object *patcherview, t_object *box, t_jmouse_cursortype type); 2072 2073 // UI objects are sent messages for each mouse event 2074 // object's that include JBOX_MULTITOUCH flag in jbox_initclass call are sent multitouch version of event 2075 // the multitouch messages are prefixed with "mt_" and have a different function prototype 2076 2077 // standard mouse events: 2078 // mouseenter, mousemove, mousedown, mousedrag, mouseup, mouseleave 2079 // mousedoubleclick will also be sent on double click 2080 // mousedragdelta is a special alternative -- see JBOX_MOUSEDRAGDELTA 2081 // function prototype is of form: 2082 // void myobj_mousemove(t_myobj *x, t_object *patcherview, t_pt position, long modifiers); 2083 2084 // mousewheel will be sent when the wheel moves over the box: 2085 // void myobj_mousewheel(t_myobj *x, t_object *patcherview, t_pt position, long modifiers, double wheelIncX, double wheelIncY); 2086 2087 // multitouch mouse events: 2088 // note, if machine doesn't support touch then these events are still sent but only for the one mouse of course 2089 // mt_mouseenter, mt_mousemove, mt_mousedown, mt_mousedrag, mt_mouseup, mt_mouseleave 2090 // function prototype is of form: 2091 // void myobj_mtmousemove(t_myobj *x, t_object *patcherview, t_mouseevent *mouseevent); 2092 2093 typedef enum _inputeventtype { 2094 eMouseEvent = 1, 2095 eTouchEvent = 2, 2096 ePenEvent = 3 2097 } t_inputeventtype; 2098 2099 typedef struct _mouseevent { 2100 t_inputeventtype type; 2101 t_atom_long index; 2102 t_pt position; 2103 t_modifiers modifiers; 2104 t_atom_float pressure; 2105 t_atom_float orientation; 2106 t_atom_float rotation; 2107 t_atom_float tiltX; 2108 t_atom_float tiltY; 2109 } t_mouseevent; 2110 2111 /** Get the current window, if any. 2112 @ingroup jwind 2113 @return A pointer to the current window, if there is one. Otherwise returns NULL. */ 2114 t_object* jwind_getactive(void); 2115 2116 /** Determine how many windows exist. 2117 @ingroup jwind 2118 @return The number of windows. */ 2119 long jwind_getcount(void); 2120 2121 /** Return a pointer to the window with a given index. 2122 @ingroup jwind 2123 @param index Get window at index (0 to count-1). 2124 @return A pointer to a window object. */ 2125 t_object* jwind_getat(long index); 2126 2127 // functions to enumerate displays 2128 2129 /** Return the number of monitors on which can be displayed. 2130 @ingroup jmonitor 2131 @return The number of monitors. */ 2132 long jmonitor_getnumdisplays(void); 2133 2134 /** Return the #t_rect for a given display. 2135 @ingroup jmonitor 2136 @param workarea Set workarea non-zero to clip out things like dock / task bar. 2137 @param displayindex The index number for a monitor. The primary monitor has an index of 0. 2138 @param rect The address of a valid #t_rect whose values will be filled-in upon return. */ 2139 void jmonitor_getdisplayrect(long workarea, long displayindex, t_rect *rect); 2140 2141 /** Return a union of all display rects. 2142 @ingroup jmonitor 2143 @param workarea Set workarea non-zero to clip out things like dock / task bar. 2144 @param rect The address of a valid #t_rect whose values will be filled-in upon return. */ 2145 void jmonitor_getdisplayrect_foralldisplays(long workarea, t_rect *rect); // get union of all display rects 2146 2147 /** Return the #t_rect for the display on which a point exists. 2148 @ingroup jmonitor 2149 @param workarea Set workarea non-zero to clip out things like dock / task bar. 2150 @param pt A point, for which the monitor will be determined and the rect recturned. 2151 @param rect The address of a valid #t_rect whose values will be filled-in upon return. */ 2152 void jmonitor_getdisplayrect_forpoint(long workarea, t_pt pt, t_rect *rect); 2153 2154 /** Return the scale factor for the display on which a point exists. 2155 @ingroup jmonitor 2156 @param displayindex Index of the monitor whose scale factor will be returned. */ 2157 double jmonitor_getdisplayscalefactor(long displayindex); 2158 2159 /** Return the scale factor for the display on which a point exists. 2160 @ingroup jmonitor 2161 @param pt A point, for which the monitor will be determined and the scale factor recturned. */ 2162 double jmonitor_getdisplayscalefactor_forpoint(t_pt pt); 2163 2164 /** take an unscaled point and convert it to a scaled point 2165 note -- most APIs take scaled coordinates so drawing doesn't need to consider scale factor for each monitor 2166 @ingroup jmonitor 2167 @param unscaled_pt the point to be scaled, should be in pixels on the global "virtual" screen consisting of all monitors 2168 @return pointer to receive the scaled point, scaled to normalize based on various scale factors and monitor arrangement 2169 */ 2170 t_pt jmonitor_scale_pt(t_pt unscaled_pt); 2171 2172 /** take an unscaled point and convert it to a scaled point 2173 note -- most APIs take scaled coordinates so drawing doesn't need to consider scale factor for each monitor 2174 @ingroup jmonitor 2175 @param scaled_pt the point to be unscaled, should be in normalized coordinates, scaled based on scale factors and monitor arrangement 2176 @return pointer to receive the unscaled point, which will be pixel-based coordinates relative to the main monitor origin 2177 */ 2178 t_pt jmonitor_unscale_pt(t_pt scaled_pt); 2179 2180 void jpatcher_bulk_load_begin(void); 2181 void jpatcher_bulk_load_end(void); 2182 2183 void *jpatcher_load(const char *name, short volume, short ac, t_atom *av); 2184 void *jpatcher_load_frombuffer(char *name, short vol, const char *json, long len, short ac, t_atom *av); 2185 void *jpatcher_load_fromdictionary(const char *name, short vol, t_object *rd, short ac, t_atom *av); 2186 2187 void *jpatcher_load_namespace(const char *name, short volume, short ac, t_atom *av, t_symbol *classnamespace); 2188 void *jpatcher_load_frombuffer_namespace(const char *name, short vol, const char *json, long len, short ac, t_atom *av, t_symbol *classnamespace); 2189 void *jpatcher_load_fromdictionary_namespace(const char *name, short vol, t_object *rd, short ac, t_atom *av, t_symbol *classnamespace); 2190 2191 // private -- internal use only 2192 long jpatcher_inc_maxsendcontext(void); 2193 2194 // private -- internal use only 2195 long jbox_is_selected_in_view(t_object *box, t_object *view); 2196 2197 // private -- internal use only 2198 t_atom_long jpatcher_dictionary_modernui(t_dictionary *d); 2199 t_atom_long jpatcher_dictionary_version(void); 2200 t_dictionary *jpatcher_fallback_version(void); 2201 long jbox_isdefaultattribute(t_jbox *x, t_symbol *attrname); 2202 2203 long jwind_canfullscreen(void); 2204 2205 2206 /** Retrieve the name of Max's system font. 2207 @ingroup jfont 2208 @return The name of Max's system font. 2209 */ 2210 const char *systemfontname(void); 2211 2212 /** Retrieve the name of Max's bold system font. 2213 @ingroup jfont 2214 @return The name of Max's bold system font. 2215 */ 2216 const char *systemfontname_bold(void); 2217 2218 /** Retrieve the name of Max's light system font. 2219 @ingroup jfont 2220 @return The name of Max's light system font. 2221 */ 2222 const char *systemfontname_light(void); 2223 2224 /** Retrieve the name of Max's system font as a symbol. 2225 @ingroup jfont 2226 @return The name of Max's system font. 2227 */ 2228 t_symbol *systemfontsym(void); 2229 2230 2231 #define JPATCHER_DEFAULT_EXTENSION ".maxpat" 2232 2233 #if C74_PRAGMA_STRUCT_PACKPUSH 2234 #pragma pack(pop) 2235 #elif C74_PRAGMA_STRUCT_PACK 2236 #pragma pack() 2237 #endif 2238 2239 END_USING_C_LINKAGE 2240 2241 #endif // #ifndef _JPATCHER_API_H_