Jamoma API  0.6.0.a19
j.unfocus.cpp
Go to the documentation of this file.
1 /** @file
2  *
3  * @ingroup implementationMaxExternals
4  *
5  * @brief j.unfocus : Remove the focus from any specific object in a patcher
6  *
7  * @details
8  *
9  * @authors Tim Place, Trond Lossius
10  *
11  * @copyright © 2009 by Tim Place @n
12  * This code is licensed under the terms of the "New BSD License" @n
13  * http://creativecommons.org/licenses/BSD/
14  */
15 
16 
17 #include "JamomaForMax.h"
18 
19 
20 // Data Structure for this object
21 typedef struct _unfocus{
22  Object base;
23 } t_unfocus;
24 
25 
26 // Prototypes for methods: need a method for each incoming message type:
27 void *unfocus_new(t_symbol *msg, long argc, t_atom *argv);
28 void unfocus_assist(t_unfocus *x, void *b, long msg, long arg, char *dst);
29 void unfocus_bang(t_unfocus *x);
30 
31 
32 // Class Statics
33 static t_class* sUnfocusClass;
34 
35 
36 /************************************************************************************/
37 // Main() Function
38 
39 int JAMOMA_EXPORT_MAXOBJ main(void)
40 {
41  ClassPtr c = class_new("j.unfocus",(method)unfocus_new, (method)NULL, sizeof(t_unfocus), (method)0L, A_GIMME, 0);
42 
43  common_symbols_init();
44  class_addmethod(c, (method)unfocus_bang, "bang", 0L);
45  class_addmethod(c, (method)unfocus_assist, "assist", A_CANT, 0L);
46 
47  class_register(_sym_box, c);
48  sUnfocusClass = c;
49  return 0;
50 }
51 
52 
53 /************************************************************************************/
54 // Object Creation Method
55 
56 void *unfocus_new(t_symbol *msg, long argc, t_atom *argv)
57 {
58  t_unfocus *x;
59 
60  x = (t_unfocus*)object_alloc(sUnfocusClass);
61  if (x) {
62  //handle attribute args
63  // attr_args_process(x, argc, argv);
64  }
65  return (x);
66 }
67 
68 
69 /************************************************************************************/
70 // Methods bound to input/inlets
71 
72 // Method for Assistance Messages
73 void unfocus_assist(t_unfocus *x, void *b, long msg, long arg, char *dst)
74 {
75  if (msg==1) { // Inlets
76  switch (arg) {
77  case 0: strcpy(dst, "(bang) remove the focus from elsewhere and give it to the patcher view"); break;
78  }
79  }
80  else if (msg==2) { // Outlets
81  switch (arg) {
82  default: strcpy(dst, ""); break;
83  }
84  }
85 }
86 
87 
88 // METHOD: bang
89 void unfocus_bang(t_unfocus *x)
90 {
91  t_object* patcher = NULL;
92  t_object* patcherview = NULL;
93 
94  object_obex_lookup(x, gensym("#P"), &patcher);
95  if (patcher)
96  patcherview = object_attr_getobj(patcher, _sym_firstview);
97 // patcherview = jpatcher_get_firstview(patcher);
98  if (patcherview)
99  object_method(patcherview, _sym_select);
100 }
int JAMOMA_EXPORT_MAXOBJ main(void)
Set up this class as a Max external the first time an object of this kind is instantiated.
Definition: j.unfocus.cpp:39
Various utilities for interfacing with Max that are not specific to JamomaModular as such...