Max 5 API Reference

jbox
[Patcher]

A box in the patcher. More...

Collaboration diagram for jbox:

Data Structures

struct  t_jboxdrawparams
 The t_jboxdrawparams structure. More...

Defines

#define JBOX_DRAWFIRSTIN   (1<<0)
 draw first inlet
#define JBOX_NODRAWBOX   (1<<1)
 don't draw the frame
#define JBOX_DRAWINLAST   (1<<2)
 draw inlets after update method
#define JBOX_TRANSPARENT   (1<<3)
 don't make transparent unless you need it (for efficiency)
#define JBOX_NOGROW   (1<<4)
 don't even draw grow thingie
#define JBOX_GROWY   (1<<5)
 can grow in y direction by dragging
#define JBOX_GROWBOTH   (1<<6)
 can grow independently in both x and y
#define JBOX_IGNORELOCKCLICK   (1<<7)
 box should ignore a click if patcher is locked
#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
#define JBOX_BACKGROUND   (1<<9)
 immediately set box into the background
#define JBOX_NOFLOATINSPECTOR   (1<<10)
 no floating inspector window
#define JBOX_TEXTFIELD   (1<<11)
 save/load text from textfield, unless JBOX_BINBUF flag is set
#define JBOX_FIXWIDTH   (1<<19)
 give the box a textfield based fix-width (bfixwidth) method
#define JBOX_FONTATTR   (1<<18)
 if you want font related attribute you must add this to jbox_initclass()
#define JBOX_BINBUF   (1<<14)
 save/load text from b_binbuf
#define JBOX_MOUSEDRAGDELTA   (1<<12)
 hides mouse cursor in drag and sends mousedragdelta instead of mousedrag (for infinite scrolling like number)
#define JBOX_COLOR   (1<<13)
 support the "color" method for color customization
#define JBOX_DRAWIOLOCKED   (1<<15)
 draw inlets and outlets when locked (default is not to draw them)
#define JBOX_DRAWBACKGROUND   (1<<16)
 set to have box bg filled in for you based on getdrawparams method or brgba attribute
#define JBOX_NOINSPECTFIRSTIN   (1<<17)
 flag for objects such as bpatcher that have a different b_firstin,
#define JBOX_DEFAULTNAMES   (1<<18)
 flag instructing jbox_new to attach object to the defaults object for live defaults updating
#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

Enumerations

enum  {
  JBOX_FONTFACE_REGULAR = 0,
  JBOX_FONTFACE_BOLD = 1,
  JBOX_FONTFACE_ITALIC = 2,
  JBOX_FONTFACE_BOLDITALIC = 3
}
 

actual numerical values of the b_fontface attribute; use jbox_fontface() to weight

More...
enum  HitTestResult {
  HitNothing = 0,
  HitBox = 1,
  HitInlet = 2,
  HitOutlet = 3,
  HitGrowBox = 4,
  HitLine = 5
}
 

enumerations used for box decorators

More...

Functions

t_max_err jbox_get_rect_for_view (t_object *box, t_object *patcherview, t_rect *rect)
 Find the rect for a box in a given patcherview.
t_max_err jbox_set_rect_for_view (t_object *box, t_object *patcherview, t_rect *rect)
 Change the rect for a box in a given patcherview.
t_max_err jbox_get_rect_for_sym (t_object *box, t_symbol *which, t_rect *pr)
 Find the rect for a box with a given attribute name.
t_max_err jbox_set_rect_for_sym (t_object *box, t_symbol *which, t_rect *pr)
 Change the rect for a box with a given attribute name.
t_max_err jbox_set_rect (t_object *box, t_rect *pr)
 Set both the presentation rect and the patching rect.
t_max_err jbox_get_patching_rect (t_object *box, t_rect *pr)
 Retrieve the patching rect of a box.
t_max_err jbox_set_patching_rect (t_object *box, t_rect *pr)
 Change the patching rect of a box.
t_max_err jbox_get_presentation_rect (t_object *box, t_rect *pr)
 Retrieve the presentation rect of a box.
t_max_err jbox_set_presentation_rect (t_object *box, t_rect *pr)
 Change the presentation rect of a box.
t_max_err jbox_set_position (t_object *box, t_pt *pos)
 Set the position of a box for both the presentation and patching views.
t_max_err jbox_get_patching_position (t_object *box, t_pt *pos)
 Fetch the position of a box for the patching view.
t_max_err jbox_set_patching_position (t_object *box, t_pt *pos)
 Set the position of a box for the patching view.
t_max_err jbox_get_presentation_position (t_object *box, t_pt *pos)
 Fetch the position of a box for the presentation view.
t_max_err jbox_set_presentation_position (t_object *box, t_pt *pos)
 Set the position of a box for the presentation view.
t_max_err jbox_set_size (t_object *box, t_size *size)
 Set the size of a box for both the presentation and patching views.
t_max_err jbox_get_patching_size (t_object *box, t_size *size)
 Fetch the size of a box for the patching view.
t_max_err jbox_set_patching_size (t_object *box, t_size *size)
 Set the size of a box for the patching view.
t_max_err jbox_get_presentation_size (t_object *box, t_size *size)
 Fetch the size of a box for the presentation view.
t_max_err jbox_set_presentation_size (t_object *box, t_size *size)
 Set the size of a box for the presentation view.
t_symboljbox_get_maxclass (t_object *b)
 Retrieve the name of the class of the box's object.
t_objectjbox_get_object (t_object *b)
 Retrieve a pointer to the box's object.
t_objectjbox_get_patcher (t_object *b)
 Retrieve a box's patcher.
char jbox_get_hidden (t_object *b)
 Retrieve a box's 'hidden' attribute.
t_max_err jbox_set_hidden (t_object *b, char c)
 Set a box's 'hidden' attribute.
t_symboljbox_get_fontname (t_object *b)
 Retrieve a box's 'fontname' attribute.
t_max_err jbox_set_fontname (t_object *b, t_symbol *ps)
 Set a box's 'fontname' attribute.
double jbox_get_fontsize (t_object *b)
 Retrieve a box's 'fontsize' attribute.
t_max_err jbox_set_fontsize (t_object *b, double d)
 Set a box's 'fontsize' attribute.
t_max_err jbox_get_color (t_object *b, t_jrgba *prgba)
 Retrieve a box's 'color' attribute.
t_max_err jbox_set_color (t_object *b, t_jrgba *prgba)
 Set a box's 'color' attribute.
t_symboljbox_get_hint (t_object *b)
 Retrieve a box's hint text as a symbol.
t_max_err jbox_set_hint (t_object *b, t_symbol *s)
 Set a box's hint text using a symbol.
char * jbox_get_hintstring (t_object *bb)
 Retrieve a box's hint text as a C-string.
void jbox_set_hintstring (t_object *bb, char *s)
 Set a box's hint text using a C-string.
char * jbox_get_annotation (t_object *bb)
 Retrieve a box's annotation string, if the user has given it an annotation.
void jbox_set_annotation (t_object *bb, char *s)
 Set a box's annotation string.
t_objectjbox_get_nextobject (t_object *b)
 The next box in the patcher's (linked) list of boxes.
t_objectjbox_get_prevobject (t_object *b)
 The previous box in the patcher's (linked) list of boxes.
t_symboljbox_get_varname (t_object *b)
 Retrieve a box's scripting name.
t_max_err jbox_set_varname (t_object *b, t_symbol *ps)
 Set a box's scripting name.
t_symboljbox_get_id (t_object *b)
 Retrieve a boxes unique id.
char jbox_get_canhilite (t_object *b)
 Retrieve a box flag value from a box.
char jbox_get_background (t_object *b)
 Determine whether a box is located in the patcher's background layer.
t_max_err jbox_set_background (t_object *b, char c)
 Set whether a box should be in the background or foreground layer of a patcher.
char jbox_get_ignoreclick (t_object *b)
 Determine whether a box ignores clicks.
t_max_err jbox_set_ignoreclick (t_object *b, char c)
 Set whether a box ignores clicks.
char jbox_get_drawfirstin (t_object *b)
 Determine whether a box draws its first inlet.
char jbox_get_outline (t_object *b)
 Determine whether a box draws an outline.
t_max_err jbox_set_outline (t_object *b, char c)
 Set whether a box draws an outline.
char jbox_get_growy (t_object *b)
 Retrieve a box flag value from a box.
char jbox_get_growboth (t_object *b)
 Retrieve a box flag value from a box.
char jbox_get_nogrow (t_object *b)
 Retrieve a box flag value from a box.
char jbox_get_drawinlast (t_object *b)
 Retrieve a box flag value from a box.
t_objectjbox_get_textfield (t_object *b)
 Retrieve a pointer to a box's textfield.
char jbox_get_presentation (t_object *b)
 Determine if a box is included in the presentation view.
t_max_err jbox_set_presentation (t_object *b, char c)
 Determine if a box is included in the presentation view.
t_max_err jbox_new (t_jbox *b, long flags, long argc, t_atom *argv)
 Set up your UI object's t_jbox member.
void jbox_free (t_jbox *b)
 Tear down your UI object's t_jbox member.
void jbox_ready (t_jbox *b)
 Mark the box ready to be accessed and drawn by Max.
void jbox_redraw (t_jbox *b)
 Request that your object/box be re-drawn by Max.
t_max_err jbox_notify (t_jbox *b, t_symbol *s, t_symbol *msg, void *sender, void *data)
 Send a notification to a box.

Detailed Description

A box in the patcher.


Define Documentation

#define JBOX_NOINSPECTFIRSTIN   (1<<17)

flag for objects such as bpatcher that have a different b_firstin,

but the attrs of the b_firstin should not be shown in the inspector


Enumeration Type Documentation

anonymous enum

actual numerical values of the b_fontface attribute; use jbox_fontface() to weight

Enumerator:
JBOX_FONTFACE_REGULAR 

normal

JBOX_FONTFACE_BOLD 

bold

JBOX_FONTFACE_ITALIC 

italic

JBOX_FONTFACE_BOLDITALIC 

bold and italic

enumerations used for box decorators

Enumerator:
HitNothing 

a hole in the box

HitBox 

the body of the box

HitInlet 

an inlet

HitOutlet 

an outlet

HitGrowBox 

the grow handle

HitLine 

a line


Function Documentation

void jbox_free ( t_jbox b  ) 

Tear down your UI object's t_jbox member.

This should be called from your UI object's free method.

Parameters:
b The address of your object's t_jbox member (which should be the first member of the object's struct).
char* jbox_get_annotation ( t_object bb  ) 

Retrieve a box's annotation string, if the user has given it an annotation.

Parameters:
bb The box to query.
Returns:
The user-created annotation string for a box, or NULL if no string exists.
char jbox_get_background ( t_object b  ) 

Determine whether a box is located in the patcher's background layer.

Parameters:
b The box to query.
Returns:
Zero if the object is in the foreground, otherwise non-zero.
char jbox_get_canhilite ( t_object b  ) 

Retrieve a box flag value from a box.

Parameters:
b The box to query.
Returns:
The value of the canhilite bit in the box's flags.
t_max_err jbox_get_color ( t_object b,
t_jrgba prgba 
)

Retrieve a box's 'color' attribute.

Parameters:
b The box to query.
prgba The address of a valid t_rect whose values will be filled-in upon return.
Returns:
A Max error code.
char jbox_get_drawfirstin ( t_object b  ) 

Determine whether a box draws its first inlet.

Parameters:
b The box to query.
Returns:
Zero if the inlet is not drawn, otherwise non-zero.
char jbox_get_drawinlast ( t_object b  ) 

Retrieve a box flag value from a box.

Parameters:
b The box to query.
Returns:
The value of the drawinlast bit in the box's flags.
t_symbol* jbox_get_fontname ( t_object b  ) 

Retrieve a box's 'fontname' attribute.

Parameters:
b The box to query.
Returns:
The font name.
double jbox_get_fontsize ( t_object b  ) 

Retrieve a box's 'fontsize' attribute.

Parameters:
b The box to query.
Returns:
The font size in points.
char jbox_get_growboth ( t_object b  ) 

Retrieve a box flag value from a box.

Parameters:
b The box to query.
Returns:
The value of the growboth bit in the box's flags.
char jbox_get_growy ( t_object b  ) 

Retrieve a box flag value from a box.

Parameters:
b The box to query.
Returns:
The value of the growy bit in the box's flags.
char jbox_get_hidden ( t_object b  ) 

Retrieve a box's 'hidden' attribute.

Parameters:
b The box to query.
Returns:
True if the box is hidden, otherwise false.
t_symbol* jbox_get_hint ( t_object b  ) 

Retrieve a box's hint text as a symbol.

Parameters:
b The box to query.
Returns:
The box's hint text.
char* jbox_get_hintstring ( t_object bb  ) 

Retrieve a box's hint text as a C-string.

Parameters:
bb The box to query.
Returns:
The box's hint text.
t_symbol* jbox_get_id ( t_object b  ) 

Retrieve a boxes unique id.

Parameters:
b The box to query.
Returns:
The unique id of the object. This is a symbol that is referenced, for example, by patchlines.
char jbox_get_ignoreclick ( t_object b  ) 

Determine whether a box ignores clicks.

Parameters:
b The box to query.
Returns:
Zero if the object responds to clicks, otherwise non-zero.
t_symbol* jbox_get_maxclass ( t_object b  ) 

Retrieve the name of the class of the box's object.

Parameters:
b The box to query.
Returns:
The name of the class of the box's object.
t_object* jbox_get_nextobject ( t_object b  ) 

The next box in the patcher's (linked) list of boxes.

Parameters:
b The box to query.
Returns:
The next box in the list.
char jbox_get_nogrow ( t_object b  ) 

Retrieve a box flag value from a box.

Parameters:
b The box to query.
Returns:
The value of the nogrow bit in the box's flags.
t_object* jbox_get_object ( t_object b  ) 

Retrieve a pointer to the box's object.

Parameters:
b The box to query.
Returns:
A pointer to the box's object.
char jbox_get_outline ( t_object b  ) 

Determine whether a box draws an outline.

Parameters:
b The box to query.
Returns:
Zero if the outline is not drawn, otherwise non-zero.
t_object* jbox_get_patcher ( t_object b  ) 

Retrieve a box's patcher.

Parameters:
b The box to query.
Returns:
If the box has a patcher, the patcher's pointer is returned. Otherwise NULL is returned.
t_max_err jbox_get_patching_position ( t_object box,
t_pt pos 
)

Fetch the position of a box for the patching view.

Parameters:
box The box whose position will be retrieved.
pos The address of a valid t_pt whose x and y values will be filled in.
Returns:
A Max error code.
t_max_err jbox_get_patching_rect ( t_object box,
t_rect pr 
)

Retrieve the patching rect of a box.

Parameters:
box The box whose rect values will be retrieved.
pr The address of a valid t_rect whose values will be filled in.
Returns:
A Max error code.
t_max_err jbox_get_patching_size ( t_object box,
t_size size 
)

Fetch the size of a box for the patching view.

Parameters:
box The box whose size will be retrieved.
size The address of a valid t_size whose width and height values will be filled in.
Returns:
A Max error code.
char jbox_get_presentation ( t_object b  ) 

Determine if a box is included in the presentation view.

Parameters:
b The box to query.
Returns:
Non-zero if in presentation mode, otherwise zero.
t_max_err jbox_get_presentation_position ( t_object box,
t_pt pos 
)

Fetch the position of a box for the presentation view.

Parameters:
box The box whose position will be retrieved.
pos The address of a valid t_pt whose x and y values will be filled in.
Returns:
A Max error code.
t_max_err jbox_get_presentation_rect ( t_object box,
t_rect pr 
)

Retrieve the presentation rect of a box.

Parameters:
box The box whose rect values will be retrieved.
pr The address of a valid t_rect whose values will be filled in.
Returns:
A Max error code.
t_max_err jbox_get_presentation_size ( t_object box,
t_size size 
)

Fetch the size of a box for the presentation view.

Parameters:
box The box whose size will be retrieved.
size The address of a valid t_size whose width and height values will be filled in.
Returns:
A Max error code.
t_object* jbox_get_prevobject ( t_object b  ) 

The previous box in the patcher's (linked) list of boxes.

Parameters:
b The box to query.
Returns:
The next box in the list.
t_max_err jbox_get_rect_for_sym ( t_object box,
t_symbol which,
t_rect pr 
)

Find the rect for a box with a given attribute name.

Parameters:
box The box whose rect will be fetched.
which The name of the rect attribute to be fetched, for example _sym_presentation_rect or _sym_patching_rect.
pr The address of a valid t_rect whose members will be filled in by this function.
Returns:
A Max error code.
t_max_err jbox_get_rect_for_view ( t_object box,
t_object patcherview,
t_rect rect 
)

Find the rect for a box in a given patcherview.

Parameters:
box The box whose rect will be fetched.
patcherview A patcherview in which the box exists.
rect The address of a valid t_rect whose members will be filled in by this function.
Returns:
A Max error code.
t_object* jbox_get_textfield ( t_object b  ) 

Retrieve a pointer to a box's textfield.

Parameters:
b The box to query.
Returns:
The textfield for the box, assuming it has one. If the box does not own a textfield then NULL is returned.
t_symbol* jbox_get_varname ( t_object b  ) 

Retrieve a box's scripting name.

Parameters:
b The box to query.
Returns:
The box's scripting name.
t_max_err jbox_new ( t_jbox b,
long  flags,
long  argc,
t_atom argv 
)

Set up your UI object's t_jbox member.

This should be called from your UI object's free method.

Parameters:
b The address of your UI object's t_jbox member (which should be the first member of the object's struct).
flags Flags to set the box's behavior, such as JBOX_NODRAWBOX.
argc The count of atoms in the argv parameter.
argv The address of the first in an array of atoms to be passed to the box constructor. Typically these are simply the argument passed to your object when it is created.
Returns:
A Max error code.
t_max_err jbox_notify ( t_jbox b,
t_symbol s,
t_symbol msg,
void *  sender,
void *  data 
)

Send a notification to a box.

This is the same as calling object_notify() for a box.

Parameters:
b The address of your object's t_jbox member.
s The name of the send object.
msg The notification name.
sender The sending object's address.
data A pointer to some data passed to the box's notify method.
Returns:
A Max error code.
void jbox_ready ( t_jbox b  ) 

Mark the box ready to be accessed and drawn by Max.

This should typically be called at the end of your UI object's new method.

Parameters:
b The address of your object's t_jbox member.
void jbox_redraw ( t_jbox b  ) 

Request that your object/box be re-drawn by Max.

Parameters:
b The address of your object's t_jbox member.
void jbox_set_annotation ( t_object bb,
char *  s 
)

Set a box's annotation string.

Parameters:
bb The box to query.
s The annotation string for the box.
Returns:
A Max error code.
t_max_err jbox_set_background ( t_object b,
char  c 
)

Set whether a box should be in the background or foreground layer of a patcher.

Parameters:
b The box to query.
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.
Returns:
A Max error code.
t_max_err jbox_set_color ( t_object b,
t_jrgba prgba 
)

Set a box's 'color' attribute.

Parameters:
b The box to query.
prgba The address of a t_rect containing the desired color for the box/object.
Returns:
A Max error code.
t_max_err jbox_set_fontname ( t_object b,
t_symbol ps 
)

Set a box's 'fontname' attribute.

Parameters:
b The box to query.
ps The font name. Note that the font name may be case-sensitive.
Returns:
A Max error code.
t_max_err jbox_set_fontsize ( t_object b,
double  d 
)

Set a box's 'fontsize' attribute.

Parameters:
b The box to query.
d The fontsize in points.
Returns:
A Max error code.
t_max_err jbox_set_hidden ( t_object b,
char  c 
)

Set a box's 'hidden' attribute.

Parameters:
b The box to query.
c Set to true to hide the box, otherwise false.
Returns:
A Max error code.
t_max_err jbox_set_hint ( t_object b,
t_symbol s 
)

Set a box's hint text using a symbol.

Parameters:
b The box to query.
s The new text to use for the box's hint.
Returns:
A Max error code.
void jbox_set_hintstring ( t_object bb,
char *  s 
)

Set a box's hint text using a C-string.

Parameters:
bb The box to query.
s The new text to use for the box's hint.
Returns:
A Max error code.
t_max_err jbox_set_ignoreclick ( t_object b,
char  c 
)

Set whether a box ignores clicks.

Parameters:
b The box to query.
c Pass zero to tell the box to respond to clicks, or non-zero to indicate that the box should ignore clicks.
Returns:
A Max error code.
t_max_err jbox_set_outline ( t_object b,
char  c 
)

Set whether a box draws an outline.

Parameters:
b The box to query.
c Pass zero to hide the outline, or non-zero to indicate that the box should draw the outline.
Returns:
A Max error code.
t_max_err jbox_set_patching_position ( t_object box,
t_pt pos 
)

Set the position of a box for the patching view.

Parameters:
box The box whose positon will be changed.
pos The address of a t_pt with the new x and y values.
Returns:
A Max error code.
t_max_err jbox_set_patching_rect ( t_object box,
t_rect pr 
)

Change the patching rect of a box.

Parameters:
box The box whose rect will be changed.
pr The address of a t_rect with the new rect values.
Returns:
A Max error code.
t_max_err jbox_set_patching_size ( t_object box,
t_size size 
)

Set the size of a box for the patching view.

Parameters:
box The box whose size will be changed.
size The address of a t_size with the new width and height values.
Returns:
A Max error code.
t_max_err jbox_set_position ( t_object box,
t_pt pos 
)

Set the position of a box for both the presentation and patching views.

Parameters:
box The box whose position will be changed.
pos The address of a t_pt with the new x and y values.
Returns:
A Max error code.
t_max_err jbox_set_presentation ( t_object b,
char  c 
)

Determine if a box is included in the presentation view.

Parameters:
b The box to query.
c Pass zero to remove a box from the presention view, or non-zero to add it to the presentation view.
Returns:
Non-zero if in presentation mode, otherwise zero.
t_max_err jbox_set_presentation_position ( t_object box,
t_pt pos 
)

Set the position of a box for the presentation view.

Parameters:
box The box whose rect will be changed.
pos The address of a t_pt with the new x and y values.
Returns:
A Max error code.
t_max_err jbox_set_presentation_rect ( t_object box,
t_rect pr 
)

Change the presentation rect of a box.

Parameters:
box The box whose rect will be changed.
pr The address of a t_rect with the new rect values.
Returns:
A Max error code.
t_max_err jbox_set_presentation_size ( t_object box,
t_size size 
)

Set the size of a box for the presentation view.

Parameters:
box The box whose size will be changed.
size The address of a t_size with the new width and height values.
Returns:
A Max error code.
t_max_err jbox_set_rect ( t_object box,
t_rect pr 
)

Set both the presentation rect and the patching rect.

Parameters:
box The box whose rect will be changed.
pr The address of a t_rect with the new rect values.
Returns:
A Max error code.
t_max_err jbox_set_rect_for_sym ( t_object box,
t_symbol which,
t_rect pr 
)

Change the rect for a box with a given attribute name.

Parameters:
box The box whose rect will be changed.
which The name of the rect attribute to be changed, for example _sym_presentation_rect or _sym_patching_rect.
pr The address of a valid t_rect that will replace the current values used by the box.
Returns:
A Max error code.
t_max_err jbox_set_rect_for_view ( t_object box,
t_object patcherview,
t_rect rect 
)

Change the rect for a box in a given patcherview.

Parameters:
box The box whose rect will be changed.
patcherview A patcherview in which the box exists.
rect The address of a valid t_rect that will replace the current values used by the box in the given view.
Returns:
A Max error code.
t_max_err jbox_set_size ( t_object box,
t_size size 
)

Set the size of a box for both the presentation and patching views.

Parameters:
box The box whose size will be changed.
size The address of a t_size with the new size values.
Returns:
A Max error code.
t_max_err jbox_set_varname ( t_object b,
t_symbol ps 
)

Set a box's scripting name.

Parameters:
b The box to query.
ps The new scripting name for the box.
Returns:
A Max error code.

Copyright © 2008, Cycling '74