NEURON
symchoos.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 /*
3  * Copyright (c) 1991 Stanford University
4  * Copyright (c) 1991 Silicon Graphics, Inc.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and
7  * its documentation for any purpose is hereby granted without fee, provided
8  * that (i) the above copyright notices and this permission notice appear in
9  * all copies of the software and related documentation, and (ii) the names of
10  * Stanford and Silicon Graphics may not be used in any advertising or
11  * publicity relating to the software without the specific, prior written
12  * permission of Stanford and Silicon Graphics.
13  *
14  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR
19  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23  * OF THIS SOFTWARE.
24  */
25 
26 /* hacked by Michael Hines from filechooser.cpp */
27 
28 /*
29  * SymChooser -- select a name
30  */
31 
32 #if HAVE_IV
33 
34 #include <IV-look/choice.h>
35 #include <IV-look/dialogs.h>
36 #include <IV-look/fbrowser.h>
37 #include <IV-look/kit.h>
38 #include <InterViews/action.h>
39 #include <InterViews/event.h>
40 #include <InterViews/font.h>
41 #include <InterViews/hit.h>
42 #include <InterViews/input.h>
43 #include <InterViews/layout.h>
44 #include <InterViews/scrbox.h>
45 #include <InterViews/style.h>
46 #include <InterViews/target.h>
47 #include <InterViews/session.h>
48 #include <InterViews/display.h>
49 #include <OS/string.h>
50 #include <stdio.h>
51 
52 #include "symchoos.h"
53 #include "utility.h"
54 #include "symdir.h"
55 
56 #include "oc2iv.h"
57 #include "parse.hpp"
58 #include "ivoc.h"
59 #endif /* HAVE_IV */
60 
61 #include "classreg.h"
62 #include "gui-redirect.h"
63 extern Object** (*nrnpy_gui_helper_)(const char* name, Object* obj);
64 extern double (*nrnpy_object_to_double_)(Object*);
65 
66 #if HAVE_IV
67 
68 class SymChooserImpl {
69 private:
70  friend class SymChooser;
71  friend class SymBrowserAccept;
72  SymChooserImpl(int nbrowser);
73  ~SymChooserImpl();
74 
75  String* name_;
76  WidgetKit* kit_;
77  SymChooser* fchooser_;
78  int nbrowser_;
79  int browser_index_;
80  FileBrowser** fbrowser_;
81  FieldEditor* editor_;
82  FieldEditor* filter_;
83  FieldEditor* directory_filter_;
84  int* filter_map_;
85  SymDirectory** dir_;
86  SymChooserAction* action_;
87  const String* selected_;
88  CopyString last_selected_;
89  int last_index_;
90  Style* style_;
91  Action* update_;
92 
94  void scfree();
95  void build();
96  Menu* makeshowmenu();
97  void clear(int);
98  void load(int);
99  void show(int);
100  void show_all();
101  void show_var();
102  void show_objid();
103  void show_objref();
104  void show_sec();
105  void show_pysec();
106  double* selected_var();
107  int selected_vector_count();
108  FieldEditor* add_filter(
109  Style*,
110  const char* pattern_attribute, const char* default_pattern,
111  const char* caption_attribute, const char* default_caption,
113  );
114  bool filtered(const String&, FieldEditor*);
115  void accept_browser();
116  void accept_browser_index(int);
117  void cancel_browser();
118  void editor_accept(FieldEditor*);
119  void filter_accept(FieldEditor*);
120  bool chdir(int, int);
121 };
122 
123 /*static*/ class SymBrowserAccept : public Action {
124 public:
125  SymBrowserAccept(SymChooserImpl*, int);
126  virtual ~SymBrowserAccept();
127  virtual void execute();
128 private:
129  SymChooserImpl* sci_;
130  int browser_index_;
131 };
132 
133 SymBrowserAccept::SymBrowserAccept(SymChooserImpl* sci, int browser_index) {
134  sci_ = sci;
135  browser_index_ = browser_index;
136 }
137 
138 SymBrowserAccept::~SymBrowserAccept(){}
139 
141  sci_->accept_browser_index(browser_index_);
142 }
143 #endif /* HAVE_IV */
144 
145 static void* scons(Object*) {
146  TRY_GUI_REDIRECT_OBJ("SymChooser", NULL);
147 #if HAVE_IV
148  SymChooser* sc = NULL;
149 IFGUI
150  const char* caption = "Choose a Variable Name or";
151  if (ifarg(1)) {
152  caption = gargstr(1);
153  }
154  Style* style = new Style(Session::instance()->style());
155  style->attribute("caption", caption);
156  if (ifarg(2)) {
157  Symbol* sym = hoc_lookup(gargstr(2));
158  int type = RANGEVAR;
159  if (sym) {
160  type = sym->type;
161  }
162  sc = new SymChooser(new SymDirectory(type), WidgetKit::instance(), style, NULL, 1);
163  }else{
164  sc = new SymChooser(NULL, WidgetKit::instance(), style);
165  }
166  Resource::ref(sc);
167 ENDGUI
168  return (void*)sc;
169 #else
170  return nullptr;
171 #endif /* HAVE_IV */
172 }
173 static void sdestruct(void* v) {
174  TRY_GUI_REDIRECT_NO_RETURN("~SymChooser", v);
175 #if HAVE_IV
176  SymChooser* sc = (SymChooser*)v;
177  Resource::unref(sc);
178 #endif /* HAVE_IV */
179 }
180 static double srun(void* v) {
181  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SymChooser.run", v);
182 #if HAVE_IV
183  bool b = false;
184 IFGUI
185  SymChooser* sc = (SymChooser*)v;
186  Display* d = Session::instance()->default_display();
187  Coord x, y;
188  if (nrn_spec_dialog_pos(x, y)) {
189  b = sc->post_at_aligned(x, y, 0.0, 0.0);
190  }else{
191  b = sc->post_at_aligned(d->width()/2, d->height()/2, .5, .5);
192  }
193 ENDGUI
194  return double(b);
195 #else
196  return 0.;
197 #endif /* HAVE_IV */
198 }
199 static double text(void* v) {
200  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SymChooser.text", v);
201 #if HAVE_IV
202 IFGUI
203  SymChooser* sc = (SymChooser*)v;
204  hoc_assign_str(hoc_pgargstr(1), sc->selected()->string());
205 ENDGUI
206  return 0.;
207 #else
208  return 0.;
209 #endif /* HAVE_IV */
210 }
211 static Member_func members[] = {
212  "run", srun,
213  "text", text,
214  0, 0
215 };
217  class2oc("SymChooser", scons, sdestruct, members, NULL, NULL, NULL);
218 }
219 #if HAVE_IV
220 
221 declareActionCallback(SymChooserImpl)
222 implementActionCallback(SymChooserImpl)
223 
224 declareFieldEditorCallback(SymChooserImpl)
225 implementFieldEditorCallback(SymChooserImpl)
226 
227 #define SHOW_SECTION 1
228 
230  SymDirectory* dir, WidgetKit* kit, Style* s, SymChooserAction* a,
231  int nbrowser
232 ) : Dialog(NULL, s) {
233  impl_ = new SymChooserImpl(nbrowser);
234  SymChooserImpl& fc = *impl_;
235  if (dir) {
236  fc.dir_[0] = dir;
237  }else{
238 #if SHOW_SECTION
239  fc.dir_[0] = new SymDirectory(SECTION);
240 #else
241  fc.dir_[0] = new SymDirectory(-1);
242 #endif
243  }
244  Resource::ref(dir);
245 // fc.name_ = new CopyString(dir->name());
246  fc.kit_ = kit;
247  fc.init(this, s, a);
248 }
249 
251  impl_->scfree();
252  delete impl_;
253 }
254 
255 const String* SymChooser::selected() const {
256  return impl_->selected_;
257 }
258 
259 double* SymChooser::selected_var() {
260  return impl_->selected_var();
261 }
262 
264  return impl_->selected_vector_count();
265 }
266 
267 void SymChooser::reread() {
268  SymChooserImpl& fc = *impl_;
269 #if 0
270  if (!fc.chdir(fc.dir_->path())) {
271  /* should generate an error message */
272  }
273 #endif
274 }
275 
276 void SymChooser::dismiss(bool accept) {
277  Dialog::dismiss(accept);
278  SymChooserImpl& fc = *impl_;
279  if (fc.action_ != NULL) {
280  fc.action_->execute(this, accept);
281  }
282 }
283 
284 /** class SymChooserImpl **/
285 SymChooserImpl::SymChooserImpl(int nbrowser) {
286  nbrowser_ = nbrowser;
287  dir_ = new SymDirectory*[nbrowser];
288  fbrowser_ = new FileBrowser*[nbrowser];
289  last_index_ = -1;
290  for (int i=0; i < nbrowser_; ++i) {
291  dir_[i] = NULL;
292  fbrowser_[i] = NULL;
293  }
294 }
295 SymChooserImpl::~SymChooserImpl() {
296  delete [] dir_;
297  delete [] fbrowser_;
298 }
299 
301  SymChooser* chooser, Style* s, SymChooserAction* a
302 ) {
303  fchooser_ = chooser;
304  filter_map_ = NULL;
305  Resource::ref(a);
306  action_ = a;
307  style_ = new Style(s);
308  Resource::ref(style_);
309  style_->alias("FileChooser");
310  style_->alias("Dialog");
311  update_ = new ActionCallback(SymChooserImpl)(
312  this, &SymChooserImpl::build
313  );
314  style_->add_trigger_any(update_);
315  build();
316 }
317 
318 void SymChooserImpl::scfree() {
319 // delete name_;
320  for (int i=nbrowser_-1; i >= 0; --i) {
321  Resource::unref(dir_[i]);
322  }
323  delete [] filter_map_;
324  Resource::unref(action_);
325  style_->remove_trigger_any(update_);
326  Resource::unref(style_);
327 }
328 
329 void SymChooserImpl::build() {
330  WidgetKit& kit = *kit_;
331  const LayoutKit& layout = *LayoutKit::instance();
332  Style* s = style_;
333  kit.push_style();
334  kit.style(s);
335  String caption("");
336  s->find_attribute("caption", caption);
337  String subcaption("Enter Symbol name:");
338  s->find_attribute("subcaption", subcaption);
339  String open("Accept");
340  s->find_attribute("open", open);
341  String close("Cancel");
342  s->find_attribute("cancel", close);
343  long rows = 10;
344  s->find_attribute("rows", rows);
345  const Font* f = kit.font();
346  FontBoundingBox bbox;
347  f->font_bbox(bbox);
348  Coord height = rows * (bbox.ascent() + bbox.descent()) + 1.0;
349  Coord width;
350  if (!s->find_attribute("width", width)) {
351  width = 16 * f->width('m') + 3.0;
352  }
353 
354  int i;
355  Action* accept = new ActionCallback(SymChooserImpl)(
356  this, &SymChooserImpl::accept_browser
357  );
358  Action* cancel = new ActionCallback(SymChooserImpl)(
359  this, &SymChooserImpl::cancel_browser
360  );
361  editor_ = DialogKit::instance()->field_editor(
362  "", s,
363  new FieldEditorCallback(SymChooserImpl)(
364  this, &SymChooserImpl::editor_accept, NULL
365  )
366  );
367  browser_index_ = 0;
368  for (i=0; i < nbrowser_; ++i) {
369  fbrowser_[i] = new FileBrowser(kit_,
370  new SymBrowserAccept(this, i),
371  NULL);
372  }
373  fchooser_->remove_all_input_handlers();
374  fchooser_->append_input_handler(editor_);
375  for (i=0; i < nbrowser_; ++i) {
376  fchooser_->append_input_handler(fbrowser_[i]);
377  }
378  fchooser_->next_focus();
379 
380  Glyph* g = layout.vbox();
381  if (caption.length() > 0) {
382  g->append(layout.r_margin(kit.fancy_label(caption), 5.0, fil, 0.0));
383  }
384  if (subcaption.length() > 0) {
385  g->append(layout.r_margin(kit.fancy_label(subcaption), 5.0, fil, 0.0));
386  }
387  g->append(layout.vglue(5.0, 0.0, 2.0));
388  g->append(editor_);
389  g->append(layout.vglue(5.0, 0.0, 2.0));
390  g->append(makeshowmenu());
391  g->append(layout.vglue(15.0, 0.0, 12.0));
392  PolyGlyph* h = layout.hbox(nbrowser_);
393  Glyph* b;
394  for (i=0; i < nbrowser_; ++i) {
395  b = layout.hbox(
396  layout.vcenter(
397  kit.inset_frame(
398  layout.margin(
399  layout.natural_span(fbrowser_[i], width, height), 1.0
400  )
401  ),
402  1.0
403  ),
404  layout.hspace(4.0),
405  kit.vscroll_bar(fbrowser_[i]->adjustable())
406  );
407  h->append(b);
408  }
409  g->append(h);
410  g->append(layout.vspace(15.0));
411  if (s->value_is_on("filter")) {
412  FieldEditorAction* action = new FieldEditorCallback(SymChooserImpl)(
413  this, &SymChooserImpl::filter_accept, NULL
414  );
415  filter_ = add_filter(
416  s, "filterPattern", "", "filterCaption", "Filter:", g, action
417  );
418  if (s->value_is_on("directoryFilter")) {
419  directory_filter_ = add_filter(
420  s, "directoryFilterPattern", "",
421  "directoryFilterCaption", "Name Filter:", g, action
422  );
423  } else {
424  directory_filter_ = NULL;
425  }
426  } else {
427  filter_ = NULL;
428  directory_filter_ = NULL;
429  }
430  g->append(
431  layout.hbox(
432  layout.hglue(10.0),
433  layout.vcenter(kit.default_button(open, accept)),
434  layout.hglue(10.0, 0.0, 5.0),
435  layout.vcenter(kit.push_button(close, cancel)),
436  layout.hglue(10.0)
437  )
438  );
439 
440  fchooser_->body(
441  layout.vcenter(kit.outset_frame(layout.margin(g, 5.0)), 1.0)
442  );
443  kit.pop_style();
444  load(0);
445 }
446 
447 Menu* SymChooserImpl::makeshowmenu() {
448  WidgetKit& k = *WidgetKit::instance();
449  Menu* mb = k.menubar();
450  MenuItem* mi = k.menubar_item("Show");
451  mb->append_item(mi);
452  Menu* mp = k.pulldown();
453  mi->menu(mp);
454  TelltaleGroup* ttg = new TelltaleGroup();
455 
456  mi = K::radio_menu_item(ttg, "All");
457  mi->action(new ActionCallback(SymChooserImpl)(
458  this, &SymChooserImpl::show_all
459  ));
460  mp->append_item(mi);
461  mi->state()->set(TelltaleState::is_chosen, true);
462 
463  mi = K::radio_menu_item(ttg, "Variables");
464  mi->action(new ActionCallback(SymChooserImpl)(
465  this, &SymChooserImpl::show_var
466  ));
467  mp->append_item(mi);
468 
469  mi = K::radio_menu_item(ttg, "Object refs");
470  mi->action(new ActionCallback(SymChooserImpl)(
471  this, &SymChooserImpl::show_objref
472  ));
473  mp->append_item(mi);
474 
475  mi = K::radio_menu_item(ttg, "Objects");
476  mi->action(new ActionCallback(SymChooserImpl)(
477  this, &SymChooserImpl::show_objid
478  ));
479  mp->append_item(mi);
480 
481  mi = K::radio_menu_item(ttg, "Sections");
482  mi->action(new ActionCallback(SymChooserImpl)(
483  this, &SymChooserImpl::show_sec
484  ));
485  mp->append_item(mi);
486 #if SHOW_SECTION
487  mi->state()->set(TelltaleState::is_chosen, true);
488 #endif
489  mi = K::radio_menu_item(ttg, "Python Sections");
490  mi->action(new ActionCallback(SymChooserImpl)(
491  this, &SymChooserImpl::show_pysec
492  ));
493  mp->append_item(mi);
494 
495  return mb;
496 }
497 
498 void SymChooserImpl::show(int i) {
499  Resource::unref(dir_[0]);
500  dir_[0] = new SymDirectory(i);
501  clear(0);
502  load(0);
503 }
504 
505 void SymChooserImpl::show_all() {
506  show(-1);
507 }
508 void SymChooserImpl::show_var() {
509  show(VAR);
510 }
511 void SymChooserImpl::show_objref() {
512  show(OBJECTVAR);
513 }
514 void SymChooserImpl::show_objid() {
515  show(TEMPLATE);
516 }
517 void SymChooserImpl::show_sec() {
518  show(SECTION);
519 }
520 void SymChooserImpl::show_pysec() {
521  show(PYSEC);
522 }
523 
524 void SymChooserImpl::clear(int bindex) {
525  for (int bi = bindex ; bi < nbrowser_; ++bi) {
526 //printf("clearing %d\n", bi);
527  FileBrowser& b = *fbrowser_[bi];
528  b.select(-1);
529  GlyphIndex n = b.count();
530  for (GlyphIndex i = 0; i < n; i++) {
531  b.remove_selectable(0);
532  b.remove(0);
533  }
534  b.refresh();
535 // b.undraw(); // with this the slider gets changed. albeit the mouse has
536  //to run over it. But the new load doesn't appear til
537  //the mouse runs over it
538  }
539 }
540 
541 void SymChooserImpl::load(int bindex) {
542  SymDirectory& d = *dir_[bindex];
543  Browser& b = *fbrowser_[bindex];
544  WidgetKit& kit = *kit_;
545  kit.push_style();
546  kit.style(style_);
547  const LayoutKit& layout = *LayoutKit::instance();
548  int dircount = d.count();
549  delete [] filter_map_;
550  int* index = new int[dircount];
551  filter_map_ = index;
552 //printf("loading %d\n", bindex);
553  for (int i = 0; i < dircount; i++) {
554  const String& f = d.name(i);
555  bool is_dir = d.is_directory(i);
556  if ((is_dir && filtered(f, directory_filter_)) ||
557  (!is_dir && filtered(f, filter_))
558  ) {
559  Glyph* name = kit.label(f);
560  if (is_dir) {
561  if (d.symbol(i) && d.symbol(i)->type == TEMPLATE) {
562  name = layout.hbox(name, kit.label("_"));
563  }else{
564  name = layout.hbox(name, kit.label("."));
565  }
566  }
567  Glyph* label = new Target(
568  layout.h_margin(name, 3.0, 0.0, 0.0, 15.0, fil, 0.0),
569  TargetPrimitiveHit
570  );
571  TelltaleState* t = new TelltaleState(TelltaleState::is_enabled);
572  b.append_selectable(t);
573  b.append(new ChoiceItem(t, label, kit.bright_inset_frame(label)));
574  *index++ = i;
575  }
576  }
577  // the order of the following two statements is important for carbon
578  // to avoid a premature browser request which ends up showing an
579  // empty list.
580  fbrowser_[bindex]->refresh();
581  editor_->field(d.path());
582  kit.pop_style();
583 }
584 
585 FieldEditor* SymChooserImpl::add_filter(
586  Style* s,
587  const char* pattern_attribute, const char* default_pattern,
588  const char* caption_attribute, const char* default_caption,
589  Glyph* body, FieldEditorAction* action
590 ) {
591  String pattern(default_pattern);
592  s->find_attribute(pattern_attribute, pattern);
593  String caption(default_caption);
594  s->find_attribute(caption_attribute, caption);
595  FieldEditor* e = DialogKit::instance()->field_editor(pattern, s, action);
596  fchooser_->append_input_handler(e);
597  WidgetKit& kit = *kit_;
598  LayoutKit& layout = *LayoutKit::instance();
599  body->append(
600  layout.hbox(
601  layout.vcenter(kit.fancy_label(caption), 0.5),
602  layout.hspace(2.0),
603  layout.vcenter(e, 0.5)
604  )
605  );
606  body->append(layout.vspace(10.0));
607  return e;
608 }
609 
610 bool SymChooserImpl::filtered(const String& name, FieldEditor* e) {
611  if (e == NULL) {
612  return true;
613  }
614  const String* s = e->text();
615  if (s == NULL || s->length() == 0) {
616  return true;
617  }
618  return s == NULL || s->length() == 0 || SymDirectory::match(name, *s);
619 }
620 
621 void SymChooserImpl::accept_browser_index(int bindex) {
622  int i = int(fbrowser_[bindex]->selected());
623  if (i == -1) {
624  return;
625  }
626 // i = filter_map_[i];
627  SymDirectory* dir = dir_[bindex];
628  const String& path = dir->path();
629  const String& name = dir->name(i);
630  Symbol* sym = dir->symbol(i);
631  int length = path.length() + name.length();
632  char* tmp = new char[length + 2];
633  sprintf(
634  tmp, "%.*s%.*s",
635  path.length(), path.string(), name.length(), name.string()
636  );
637  editor_->field(tmp);
638  last_selected_ = tmp;
639  last_index_ = i;
640  selected_ = editor_->text();
641  if (dir->is_directory(i)) {
642  if (chdir(bindex, i)) {
643  fchooser_->focus(editor_);
644  } else {
645  /* should generate an error message */
646  }
647  } else {
648  clear(bindex+1);
649  browser_index_ = bindex;
650 // fchooser_->dismiss(true);
651  }
652  delete [] tmp;
653 }
654 
655 double* SymChooserImpl::selected_var() {
656  if (last_index_ != -1
657  && strcmp(selected_->string(), last_selected_.string()) == 0) {
658  SymDirectory* dir = dir_[browser_index_];
659  return dir->variable(last_index_);
660  }else{
661  return NULL;
662  }
663 }
664 
665 int SymChooserImpl::selected_vector_count() {
666  if (last_index_ != -1
667  && strcmp(selected_->string(), last_selected_.string()) == 0) {
668  SymDirectory* dir = dir_[browser_index_];
669  return dir->whole_vector(last_index_);
670  }else{
671  return 0;
672  }
673 }
674 
675 void SymChooserImpl::accept_browser() {
676  int bi = browser_index_;
677  int i = int(fbrowser_[bi]->selected());
678  if (i == -1) {
679  editor_accept(editor_);
680  return;
681  }
682 // i = filter_map_[i];
683  const String& path = dir_[bi]->path();
684  const String& name = dir_[bi]->name(i);
685  int length = path.length() + name.length();
686  char* tmp = new char[length + 1];
687  sprintf(
688  tmp, "%.*s%.*s",
689  path.length(), path.string(), name.length(), name.string()
690  );
691 //printf("accept_browser %s\n", tmp);
692  editor_->field(tmp);
693  selected_ = editor_->text();
694  if (dir_[bi]->is_directory(i)) {
695  if (chdir(bi, i)) {
696  fchooser_->focus(editor_);
697  } else {
698  /* should generate an error message */
699  }
700  } else {
701  fchooser_->dismiss(true);
702  }
703  delete [] tmp;
704 }
705 
706 void SymChooserImpl::cancel_browser() {
707  selected_ = NULL;
708  fchooser_->dismiss(false);
709 }
710 
711 void SymChooserImpl::editor_accept(FieldEditor* e) {
712  int i;
713  int bi = browser_index_;
714  if ((i = dir_[bi]->index(*e->text())) >= 0 ) {
715  if (!chdir(bi, i)) {
716  selected_ = &dir_[bi]->name(i);
717  fchooser_->dismiss(true);
718  }
719  return;
720  }else{
721  selected_ = e->text();
722  fchooser_->dismiss(true);
723  }
724 }
725 
726 void SymChooserImpl::filter_accept(FieldEditor*) {
727  clear(0);
728  load(0);
729 }
730 
731 bool SymChooserImpl::chdir(int bindex, int index) {
732  if (dir_[bindex]->is_directory(index)) {
733  int bi;
734  SymDirectory* d;
735 if (dir_[bindex]->obj(index)) {
736  d = new SymDirectory(dir_[bindex]->obj(index));
737  bi = bindex;
738 }else if (dir_[bindex]->is_pysec(index)) {
739  d = dir_[bindex]->newsymdir(index);
740  bi = bindex + 1;
741 }else{
742  d = new SymDirectory(
743  dir_[bindex]->path(),
744  dir_[bindex]->object(),
745  dir_[bindex]->symbol(index),
746  dir_[bindex]->array_index(index));
747  bi = bindex + 1;
748 }
749  if (bi > nbrowser_-1) {
750  bi = nbrowser_-1;
751  // rotate
752  }
753  Resource::ref(d);
754  browser_index_ = bi;
755  Resource::unref(dir_[bi]);
756  dir_[bi] = d;
757  clear(bi);
758  load(bi);
759  return true;
760  }
761  return false;
762 }
763 
764 /** class SymChooserAction **/
765 
768 void SymChooserAction::execute(SymChooser*, bool) { }
769 #endif /* HAVE_IV */
SymDirectory * newsymdir(int index)
Definition: symdir.cpp:185
#define TelltaleGroup
Definition: _defines.h:295
#define Display
Definition: _defines.h:97
#define Target
Definition: _defines.h:292
short type
Definition: cabvars.h:10
virtual ~SymChooser()
void execute(Inst *p)
Definition: code.cpp:2651
static char * pattern
Definition: regexp.cpp:82
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
Definition: gui-redirect.h:44
#define WidgetKit
Definition: _defines.h:331
short type
Definition: model.h:58
static void * scons(Object *)
Definition: symchoos.cpp:145
static void sdestruct(void *v)
Definition: symchoos.cpp:173
#define g
Definition: passive0.cpp:23
virtual const String & name(int index) const
Definition: symdir.cpp:330
#define Glyph
Definition: _defines.h:132
#define Coord
Definition: _defines.h:19
Symbol * hoc_lookup(const char *)
virtual int whole_vector(int index)
Definition: symdir.cpp:320
virtual int selected_vector_count()
#define Browser
Definition: _defines.h:57
virtual void dismiss(bool)
int length() const
Definition: string.h:140
static MenuItem * radio_menu_item(TelltaleGroup *, const char *)
#define v
Definition: md1redef.h:4
static bool match(const String &name, const String &pattern)
Definition: symdir.cpp:357
char ** hoc_pgargstr(int narg)
Definition: code.cpp:1580
virtual void ref() const
Definition: resource.cpp:47
double(* nrnpy_object_to_double_)(Object *)
Definition: xmenu.cpp:14
static philox4x32_key_t k
Definition: nrnran123.cpp:11
#define PolyGlyph
Definition: _defines.h:207
sprintf(buf," if (secondorder) {\ " int _i;\" " for(_i=0;_i< %d;++_i) {\" " _p[_slist%d[_i]]+=dt *_p[_dlist%d[_i]];\" " }}\", numeqn, listnum, listnum)
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
Definition: gui-redirect.h:66
virtual int count() const
Definition: symdir.cpp:327
#define e
Definition: passive0.cpp:24
#define gargstr
Definition: hocdec.h:14
#define FontBoundingBox
Definition: _defines.h:121
const char * string() const
Definition: string.h:139
void init()
Definition: init.cpp:169
void hoc_assign_str(char **cpp, const char *buf)
Definition: code.cpp:2337
#define Font
Definition: _defines.h:120
virtual void reread()
#define Dialog
Definition: _defines.h:94
int const size_t const size_t n
Definition: nrngsl.h:12
#define Menu
Definition: _defines.h:176
Symbol * symbol(int index) const
Definition: symdir.cpp:360
#define FileBrowser
Definition: _defines.h:114
virtual double * variable(int index)
Definition: symdir.cpp:269
_CONST char * s
Definition: system.cpp:74
bool nrn_spec_dialog_pos(Coord &x, Coord &y)
true if Style &#39;dialog_spec_position: on&#39; and fills x,y with dialog_left_position and dialog_bottom_po...
virtual double * selected_var()
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
Definition: hoc_oop.cpp:1581
int
Definition: nrnmusic.cpp:71
virtual ~SymChooserAction()
#define LayoutKit
Definition: _defines.h:161
#define GlyphIndex
Definition: _defines.h:23
#define ENDGUI
Definition: hocdec.h:352
virtual void execute(SymChooser *, bool accept)
Definition: model.h:57
virtual void unref() const
Definition: resource.cpp:52
char * name
Definition: init.cpp:16
#define FieldEditor
Definition: _defines.h:111
#define fil
Definition: coord.h:42
int ifarg(int)
Definition: code.cpp:1562
#define FieldEditorAction
Definition: _defines.h:112
virtual const String & path() const
Definition: symdir.cpp:324
#define TRY_GUI_REDIRECT_OBJ(name, obj)
Definition: gui-redirect.h:12
static Member_func members[]
Definition: symchoos.cpp:211
virtual bool is_directory(int index) const
Definition: symdir.cpp:354
Definition: hocdec.h:226
void SymChooser_reg()
Definition: symchoos.cpp:216
static double srun(void *v)
Definition: symchoos.cpp:180
#define i
Definition: md1redef.h:12
#define Action
Definition: _defines.h:27
Definition: string.h:34
virtual const String * selected() const
#define Style
Definition: _defines.h:281
SymChooser(SymDirectory *, WidgetKit *, Style *, SymChooserAction *=NULL, int nbrowser=3)
#define ChoiceItem
Definition: _defines.h:72
#define MenuItem
Definition: _defines.h:179
static double text(void *v)
Definition: symchoos.cpp:199
#define TelltaleState
Definition: _defines.h:296
#define IFGUI
Definition: hocdec.h:351
double t
Definition: init.cpp:123
int close(int)
static PyObject * is_pysec(NPySecObj *self)
Definition: nrnpy_nrn.cpp:863
return NULL
Definition: cabcode.cpp:461
short index
Definition: cabvars.h:11