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(Style*,
109  const char* pattern_attribute,
110  const char* default_pattern,
111  const char* caption_attribute,
112  const char* default_caption,
113  Glyph*,
115  bool filtered(const String&, FieldEditor*);
116  void accept_browser();
117  void accept_browser_index(int);
118  void cancel_browser();
119  void editor_accept(FieldEditor*);
120  void filter_accept(FieldEditor*);
121  bool chdir(int, int);
122 };
123 
124 /*static*/ class SymBrowserAccept: public Action {
125  public:
126  SymBrowserAccept(SymChooserImpl*, int);
127  virtual ~SymBrowserAccept();
128  virtual void execute();
129 
130  private:
131  SymChooserImpl* sci_;
132  int browser_index_;
133 };
134 
135 SymBrowserAccept::SymBrowserAccept(SymChooserImpl* sci, int browser_index) {
136  sci_ = sci;
137  browser_index_ = browser_index;
138 }
139 
140 SymBrowserAccept::~SymBrowserAccept() {}
141 
143  sci_->accept_browser_index(browser_index_);
144 }
145 #endif /* HAVE_IV */
146 
147 static void* scons(Object*) {
148  TRY_GUI_REDIRECT_OBJ("SymChooser", NULL);
149 #if HAVE_IV
150  SymChooser* sc = NULL;
151  IFGUI
152  const char* caption = "Choose a Variable Name or";
153  if (ifarg(1)) {
154  caption = gargstr(1);
155  }
156  Style* style = new Style(Session::instance()->style());
157  style->attribute("caption", caption);
158  if (ifarg(2)) {
159  Symbol* sym = hoc_lookup(gargstr(2));
160  int type = RANGEVAR;
161  if (sym) {
162  type = sym->type;
163  }
164  sc = new SymChooser(new SymDirectory(type), WidgetKit::instance(), style, NULL, 1);
165  } else {
166  sc = new SymChooser(NULL, WidgetKit::instance(), style);
167  }
168  Resource::ref(sc);
169  ENDGUI
170  return (void*) sc;
171 #else
172  return nullptr;
173 #endif /* HAVE_IV */
174 }
175 static void sdestruct(void* v) {
176  TRY_GUI_REDIRECT_NO_RETURN("~SymChooser", v);
177 #if HAVE_IV
178  SymChooser* sc = (SymChooser*) v;
179  Resource::unref(sc);
180 #endif /* HAVE_IV */
181 }
182 static double srun(void* v) {
183  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SymChooser.run", v);
184 #if HAVE_IV
185  bool b = false;
186  IFGUI
187  SymChooser* sc = (SymChooser*) v;
188  Display* d = Session::instance()->default_display();
189  Coord x, y;
190  if (nrn_spec_dialog_pos(x, y)) {
191  b = sc->post_at_aligned(x, y, 0.0, 0.0);
192  } else {
193  b = sc->post_at_aligned(d->width() / 2, d->height() / 2, .5, .5);
194  }
195  ENDGUI
196  return double(b);
197 #else
198  return 0.;
199 #endif /* HAVE_IV */
200 }
201 static double text(void* v) {
202  TRY_GUI_REDIRECT_ACTUAL_DOUBLE("SymChooser.text", v);
203 #if HAVE_IV
204  IFGUI
205  SymChooser* sc = (SymChooser*) v;
206  hoc_assign_str(hoc_pgargstr(1), sc->selected()->string());
207  ENDGUI
208  return 0.;
209 #else
210  return 0.;
211 #endif /* HAVE_IV */
212 }
213 static Member_func members[] = {"run", srun, "text", text, 0, 0};
215  class2oc("SymChooser", scons, sdestruct, members, NULL, NULL, NULL);
216 }
217 #if HAVE_IV
218 
219 declareActionCallback(SymChooserImpl) implementActionCallback(SymChooserImpl)
220 
221  declareFieldEditorCallback(SymChooserImpl) implementFieldEditorCallback(SymChooserImpl)
222 #define SHOW_SECTION 1
223 
225  WidgetKit* kit,
226  Style* s,
227  SymChooserAction* a,
228  int nbrowser)
229  : Dialog(NULL, s) {
230  impl_ = new SymChooserImpl(nbrowser);
231  SymChooserImpl& fc = *impl_;
232  if (dir) {
233  fc.dir_[0] = dir;
234  } else {
235 #if SHOW_SECTION
236  fc.dir_[0] = new SymDirectory(SECTION);
237 #else
238  fc.dir_[0] = new SymDirectory(-1);
239 #endif
240  }
241  Resource::ref(dir);
242  // fc.name_ = new CopyString(dir->name());
243  fc.kit_ = kit;
244  fc.init(this, s, a);
245 }
246 
248  impl_->scfree();
249  delete impl_;
250 }
251 
252 const String* SymChooser::selected() const {
253  return impl_->selected_;
254 }
255 
256 double* SymChooser::selected_var() {
257  return impl_->selected_var();
258 }
259 
261  return impl_->selected_vector_count();
262 }
263 
264 void SymChooser::reread() {
265  SymChooserImpl& fc = *impl_;
266 #if 0
267  if (!fc.chdir(fc.dir_->path())) {
268  /* should generate an error message */
269  }
270 #endif
271 }
272 
273 void SymChooser::dismiss(bool accept) {
274  Dialog::dismiss(accept);
275  SymChooserImpl& fc = *impl_;
276  if (fc.action_ != NULL) {
277  fc.action_->execute(this, accept);
278  }
279 }
280 
281 /** class SymChooserImpl **/
282 SymChooserImpl::SymChooserImpl(int nbrowser) {
283  nbrowser_ = nbrowser;
284  dir_ = new SymDirectory*[nbrowser];
285  fbrowser_ = new FileBrowser*[nbrowser];
286  last_index_ = -1;
287  for (int i = 0; i < nbrowser_; ++i) {
288  dir_[i] = NULL;
289  fbrowser_[i] = NULL;
290  }
291 }
292 SymChooserImpl::~SymChooserImpl() {
293  delete[] dir_;
294  delete[] fbrowser_;
295 }
296 
297 void SymChooserImpl::init(SymChooser* chooser, Style* s, SymChooserAction* a) {
298  fchooser_ = chooser;
299  filter_map_ = NULL;
300  Resource::ref(a);
301  action_ = a;
302  style_ = new Style(s);
303  Resource::ref(style_);
304  style_->alias("FileChooser");
305  style_->alias("Dialog");
306  update_ = new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::build);
307  style_->add_trigger_any(update_);
308  build();
309 }
310 
311 void SymChooserImpl::scfree() {
312  // delete name_;
313  for (int i = nbrowser_ - 1; i >= 0; --i) {
314  Resource::unref(dir_[i]);
315  }
316  delete[] filter_map_;
317  Resource::unref(action_);
318  style_->remove_trigger_any(update_);
319  Resource::unref(style_);
320 }
321 
322 void SymChooserImpl::build() {
323  WidgetKit& kit = *kit_;
324  const LayoutKit& layout = *LayoutKit::instance();
325  Style* s = style_;
326  kit.push_style();
327  kit.style(s);
328  String caption("");
329  s->find_attribute("caption", caption);
330  String subcaption("Enter Symbol name:");
331  s->find_attribute("subcaption", subcaption);
332  String open("Accept");
333  s->find_attribute("open", open);
334  String close("Cancel");
335  s->find_attribute("cancel", close);
336  long rows = 10;
337  s->find_attribute("rows", rows);
338  const Font* f = kit.font();
339  FontBoundingBox bbox;
340  f->font_bbox(bbox);
341  Coord height = rows * (bbox.ascent() + bbox.descent()) + 1.0;
342  Coord width;
343  if (!s->find_attribute("width", width)) {
344  width = 16 * f->width('m') + 3.0;
345  }
346 
347  int i;
348  Action* accept = new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::accept_browser);
349  Action* cancel = new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::cancel_browser);
350  editor_ = DialogKit::instance()->field_editor(
351  "", s, new FieldEditorCallback(SymChooserImpl)(this, &SymChooserImpl::editor_accept, NULL));
352  browser_index_ = 0;
353  for (i = 0; i < nbrowser_; ++i) {
354  fbrowser_[i] = new FileBrowser(kit_, new SymBrowserAccept(this, i), NULL);
355  }
356  fchooser_->remove_all_input_handlers();
357  fchooser_->append_input_handler(editor_);
358  for (i = 0; i < nbrowser_; ++i) {
359  fchooser_->append_input_handler(fbrowser_[i]);
360  }
361  fchooser_->next_focus();
362 
363  Glyph* g = layout.vbox();
364  if (caption.length() > 0) {
365  g->append(layout.r_margin(kit.fancy_label(caption), 5.0, fil, 0.0));
366  }
367  if (subcaption.length() > 0) {
368  g->append(layout.r_margin(kit.fancy_label(subcaption), 5.0, fil, 0.0));
369  }
370  g->append(layout.vglue(5.0, 0.0, 2.0));
371  g->append(editor_);
372  g->append(layout.vglue(5.0, 0.0, 2.0));
373  g->append(makeshowmenu());
374  g->append(layout.vglue(15.0, 0.0, 12.0));
375  PolyGlyph* h = layout.hbox(nbrowser_);
376  Glyph* b;
377  for (i = 0; i < nbrowser_; ++i) {
378  b = layout.hbox(layout.vcenter(kit.inset_frame(layout.margin(
379  layout.natural_span(fbrowser_[i], width, height), 1.0)),
380  1.0),
381  layout.hspace(4.0),
382  kit.vscroll_bar(fbrowser_[i]->adjustable()));
383  h->append(b);
384  }
385  g->append(h);
386  g->append(layout.vspace(15.0));
387  if (s->value_is_on("filter")) {
388  FieldEditorAction* action = new FieldEditorCallback(
389  SymChooserImpl)(this, &SymChooserImpl::filter_accept, NULL);
390  filter_ = add_filter(s, "filterPattern", "", "filterCaption", "Filter:", g, action);
391  if (s->value_is_on("directoryFilter")) {
392  directory_filter_ = add_filter(s,
393  "directoryFilterPattern",
394  "",
395  "directoryFilterCaption",
396  "Name Filter:",
397  g,
398  action);
399  } else {
400  directory_filter_ = NULL;
401  }
402  } else {
403  filter_ = NULL;
404  directory_filter_ = NULL;
405  }
406  g->append(layout.hbox(layout.hglue(10.0),
407  layout.vcenter(kit.default_button(open, accept)),
408  layout.hglue(10.0, 0.0, 5.0),
409  layout.vcenter(kit.push_button(close, cancel)),
410  layout.hglue(10.0)));
411 
412  fchooser_->body(layout.vcenter(kit.outset_frame(layout.margin(g, 5.0)), 1.0));
413  kit.pop_style();
414  load(0);
415 }
416 
417 Menu* SymChooserImpl::makeshowmenu() {
418  WidgetKit& k = *WidgetKit::instance();
419  Menu* mb = k.menubar();
420  MenuItem* mi = k.menubar_item("Show");
421  mb->append_item(mi);
422  Menu* mp = k.pulldown();
423  mi->menu(mp);
424  TelltaleGroup* ttg = new TelltaleGroup();
425 
426  mi = K::radio_menu_item(ttg, "All");
427  mi->action(new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::show_all));
428  mp->append_item(mi);
429  mi->state()->set(TelltaleState::is_chosen, true);
430 
431  mi = K::radio_menu_item(ttg, "Variables");
432  mi->action(new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::show_var));
433  mp->append_item(mi);
434 
435  mi = K::radio_menu_item(ttg, "Object refs");
436  mi->action(new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::show_objref));
437  mp->append_item(mi);
438 
439  mi = K::radio_menu_item(ttg, "Objects");
440  mi->action(new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::show_objid));
441  mp->append_item(mi);
442 
443  mi = K::radio_menu_item(ttg, "Sections");
444  mi->action(new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::show_sec));
445  mp->append_item(mi);
446 #if SHOW_SECTION
447  mi->state()->set(TelltaleState::is_chosen, true);
448 #endif
449  mi = K::radio_menu_item(ttg, "Python Sections");
450  mi->action(new ActionCallback(SymChooserImpl)(this, &SymChooserImpl::show_pysec));
451  mp->append_item(mi);
452 
453  return mb;
454 }
455 
456 void SymChooserImpl::show(int i) {
457  Resource::unref(dir_[0]);
458  dir_[0] = new SymDirectory(i);
459  clear(0);
460  load(0);
461 }
462 
463 void SymChooserImpl::show_all() {
464  show(-1);
465 }
466 void SymChooserImpl::show_var() {
467  show(VAR);
468 }
469 void SymChooserImpl::show_objref() {
470  show(OBJECTVAR);
471 }
472 void SymChooserImpl::show_objid() {
473  show(TEMPLATE);
474 }
475 void SymChooserImpl::show_sec() {
476  show(SECTION);
477 }
478 void SymChooserImpl::show_pysec() {
479  show(PYSEC);
480 }
481 
482 void SymChooserImpl::clear(int bindex) {
483  for (int bi = bindex; bi < nbrowser_; ++bi) {
484  // printf("clearing %d\n", bi);
485  FileBrowser& b = *fbrowser_[bi];
486  b.select(-1);
487  GlyphIndex n = b.count();
488  for (GlyphIndex i = 0; i < n; i++) {
489  b.remove_selectable(0);
490  b.remove(0);
491  }
492  b.refresh();
493  // b.undraw(); // with this the slider gets changed. albeit the mouse has
494  // to run over it. But the new load doesn't appear til
495  // the mouse runs over it
496  }
497 }
498 
499 void SymChooserImpl::load(int bindex) {
500  SymDirectory& d = *dir_[bindex];
501  Browser& b = *fbrowser_[bindex];
502  WidgetKit& kit = *kit_;
503  kit.push_style();
504  kit.style(style_);
505  const LayoutKit& layout = *LayoutKit::instance();
506  int dircount = d.count();
507  delete[] filter_map_;
508  int* index = new int[dircount];
509  filter_map_ = index;
510  // printf("loading %d\n", bindex);
511  for (int i = 0; i < dircount; i++) {
512  const String& f = d.name(i);
513  bool is_dir = d.is_directory(i);
514  if ((is_dir && filtered(f, directory_filter_)) || (!is_dir && filtered(f, filter_))) {
515  Glyph* name = kit.label(f);
516  if (is_dir) {
517  if (d.symbol(i) && d.symbol(i)->type == TEMPLATE) {
518  name = layout.hbox(name, kit.label("_"));
519  } else {
520  name = layout.hbox(name, kit.label("."));
521  }
522  }
523  Glyph* label = new Target(layout.h_margin(name, 3.0, 0.0, 0.0, 15.0, fil, 0.0),
524  TargetPrimitiveHit);
525  TelltaleState* t = new TelltaleState(TelltaleState::is_enabled);
526  b.append_selectable(t);
527  b.append(new ChoiceItem(t, label, kit.bright_inset_frame(label)));
528  *index++ = i;
529  }
530  }
531  // the order of the following two statements is important for carbon
532  // to avoid a premature browser request which ends up showing an
533  // empty list.
534  fbrowser_[bindex]->refresh();
535  editor_->field(d.path());
536  kit.pop_style();
537 }
538 
539 FieldEditor* SymChooserImpl::add_filter(Style* s,
540  const char* pattern_attribute,
541  const char* default_pattern,
542  const char* caption_attribute,
543  const char* default_caption,
544  Glyph* body,
545  FieldEditorAction* action) {
546  String pattern(default_pattern);
547  s->find_attribute(pattern_attribute, pattern);
548  String caption(default_caption);
549  s->find_attribute(caption_attribute, caption);
550  FieldEditor* e = DialogKit::instance()->field_editor(pattern, s, action);
551  fchooser_->append_input_handler(e);
552  WidgetKit& kit = *kit_;
553  LayoutKit& layout = *LayoutKit::instance();
554  body->append(layout.hbox(layout.vcenter(kit.fancy_label(caption), 0.5),
555  layout.hspace(2.0),
556  layout.vcenter(e, 0.5)));
557  body->append(layout.vspace(10.0));
558  return e;
559 }
560 
561 bool SymChooserImpl::filtered(const String& name, FieldEditor* e) {
562  if (e == NULL) {
563  return true;
564  }
565  const String* s = e->text();
566  if (s == NULL || s->length() == 0) {
567  return true;
568  }
569  return s == NULL || s->length() == 0 || SymDirectory::match(name, *s);
570 }
571 
572 void SymChooserImpl::accept_browser_index(int bindex) {
573  int i = int(fbrowser_[bindex]->selected());
574  if (i == -1) {
575  return;
576  }
577  // i = filter_map_[i];
578  SymDirectory* dir = dir_[bindex];
579  const String& path = dir->path();
580  const String& name = dir->name(i);
581  Symbol* sym = dir->symbol(i);
582  int length = path.length() + name.length();
583  char* tmp = new char[length + 2];
584  sprintf(tmp, "%.*s%.*s", path.length(), path.string(), name.length(), name.string());
585  editor_->field(tmp);
586  last_selected_ = tmp;
587  last_index_ = i;
588  selected_ = editor_->text();
589  if (dir->is_directory(i)) {
590  if (chdir(bindex, i)) {
591  fchooser_->focus(editor_);
592  } else {
593  /* should generate an error message */
594  }
595  } else {
596  clear(bindex + 1);
597  browser_index_ = bindex;
598  // fchooser_->dismiss(true);
599  }
600  delete[] tmp;
601 }
602 
603 double* SymChooserImpl::selected_var() {
604  if (last_index_ != -1 && strcmp(selected_->string(), last_selected_.string()) == 0) {
605  SymDirectory* dir = dir_[browser_index_];
606  return dir->variable(last_index_);
607  } else {
608  return NULL;
609  }
610 }
611 
612 int SymChooserImpl::selected_vector_count() {
613  if (last_index_ != -1 && strcmp(selected_->string(), last_selected_.string()) == 0) {
614  SymDirectory* dir = dir_[browser_index_];
615  return dir->whole_vector(last_index_);
616  } else {
617  return 0;
618  }
619 }
620 
621 void SymChooserImpl::accept_browser() {
622  int bi = browser_index_;
623  int i = int(fbrowser_[bi]->selected());
624  if (i == -1) {
625  editor_accept(editor_);
626  return;
627  }
628  // i = filter_map_[i];
629  const String& path = dir_[bi]->path();
630  const String& name = dir_[bi]->name(i);
631  int length = path.length() + name.length();
632  char* tmp = new char[length + 1];
633  sprintf(tmp, "%.*s%.*s", path.length(), path.string(), name.length(), name.string());
634  // printf("accept_browser %s\n", tmp);
635  editor_->field(tmp);
636  selected_ = editor_->text();
637  if (dir_[bi]->is_directory(i)) {
638  if (chdir(bi, i)) {
639  fchooser_->focus(editor_);
640  } else {
641  /* should generate an error message */
642  }
643  } else {
644  fchooser_->dismiss(true);
645  }
646  delete[] tmp;
647 }
648 
649 void SymChooserImpl::cancel_browser() {
650  selected_ = NULL;
651  fchooser_->dismiss(false);
652 }
653 
654 void SymChooserImpl::editor_accept(FieldEditor* e) {
655  int i;
656  int bi = browser_index_;
657  if ((i = dir_[bi]->index(*e->text())) >= 0) {
658  if (!chdir(bi, i)) {
659  selected_ = &dir_[bi]->name(i);
660  fchooser_->dismiss(true);
661  }
662  return;
663  } else {
664  selected_ = e->text();
665  fchooser_->dismiss(true);
666  }
667 }
668 
669 void SymChooserImpl::filter_accept(FieldEditor*) {
670  clear(0);
671  load(0);
672 }
673 
674 bool SymChooserImpl::chdir(int bindex, int index) {
675  if (dir_[bindex]->is_directory(index)) {
676  int bi;
677  SymDirectory* d;
678  if (dir_[bindex]->obj(index)) {
679  d = new SymDirectory(dir_[bindex]->obj(index));
680  bi = bindex;
681  } else if (dir_[bindex]->is_pysec(index)) {
682  d = dir_[bindex]->newsymdir(index);
683  bi = bindex + 1;
684  } else {
685  d = new SymDirectory(dir_[bindex]->path(),
686  dir_[bindex]->object(),
687  dir_[bindex]->symbol(index),
688  dir_[bindex]->array_index(index));
689  bi = bindex + 1;
690  }
691  if (bi > nbrowser_ - 1) {
692  bi = nbrowser_ - 1;
693  // rotate
694  }
695  Resource::ref(d);
696  browser_index_ = bi;
697  Resource::unref(dir_[bi]);
698  dir_[bi] = d;
699  clear(bi);
700  load(bi);
701  return true;
702  }
703  return false;
704 }
705 
706 /** class SymChooserAction **/
707 
711 #endif /* HAVE_IV */
#define TelltaleState
Definition: _defines.h:296
#define Menu
Definition: _defines.h:176
#define Target
Definition: _defines.h:292
#define FileBrowser
Definition: _defines.h:114
#define FontBoundingBox
Definition: _defines.h:121
#define Browser
Definition: _defines.h:57
#define Style
Definition: _defines.h:281
#define FieldEditorAction
Definition: _defines.h:112
#define Coord
Definition: _defines.h:19
#define Display
Definition: _defines.h:97
#define Dialog
Definition: _defines.h:94
#define WidgetKit
Definition: _defines.h:331
#define GlyphIndex
Definition: _defines.h:23
#define MenuItem
Definition: _defines.h:179
#define PolyGlyph
Definition: _defines.h:207
#define Font
Definition: _defines.h:120
#define ChoiceItem
Definition: _defines.h:72
#define TelltaleGroup
Definition: _defines.h:295
#define FieldEditor
Definition: _defines.h:111
#define LayoutKit
Definition: _defines.h:161
#define Action
Definition: _defines.h:27
#define Glyph
Definition: _defines.h:132
short index
Definition: cabvars.h:10
short type
Definition: cabvars.h:9
static MenuItem * radio_menu_item(TelltaleGroup *, const char *)
virtual void ref() const
Definition: resource.cpp:47
virtual void unref() const
Definition: resource.cpp:52
Definition: string.h:34
const char * string() const
Definition: string.h:139
int length() const
Definition: string.h:140
virtual void execute(SymChooser *, bool accept)
virtual ~SymChooserAction()
virtual void reread()
virtual void dismiss(bool)
virtual ~SymChooser()
virtual double * selected_var()
SymChooserImpl * impl_
Definition: symchoos.h:100
virtual const String * selected() const
virtual int selected_vector_count()
SymChooser(SymDirectory *, WidgetKit *, Style *, SymChooserAction *=NULL, int nbrowser=3)
virtual const String & path() const
Definition: symdir.cpp:331
virtual int count() const
Definition: symdir.cpp:334
virtual double * variable(int index)
Definition: symdir.cpp:273
static bool match(const String &name, const String &pattern)
Definition: symdir.cpp:364
virtual int whole_vector(int index)
Definition: symdir.cpp:327
Symbol * symbol(int index) const
Definition: symdir.cpp:367
SymDirectory * newsymdir(int index)
Definition: symdir.cpp:189
virtual const String & name(int index) const
Definition: symdir.cpp:337
virtual bool is_directory(int index) const
Definition: symdir.cpp:361
void execute(Inst *p)
Definition: code.cpp:2661
#define fil
Definition: coord.h:42
double t
Definition: cvodeobj.cpp:59
sprintf(buf, " if (secondorder) {\n" " int _i;\n" " for (_i = 0; _i < %d; ++_i) {\n" " _p[_slist%d[_i]] += dt*_p[_dlist%d[_i]];\n" " }}\n", numeqn, listnum, listnum)
void hoc_assign_str(char **cpp, const char *buf)
Definition: code.cpp:2350
Symbol * hoc_lookup(const char *)
char ** hoc_pgargstr(int narg)
Definition: code.cpp:1599
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
Definition: gui-redirect.h:71
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
Definition: gui-redirect.h:47
#define TRY_GUI_REDIRECT_OBJ(name, obj)
Definition: gui-redirect.h:12
#define IFGUI
Definition: hocdec.h:372
#define gargstr
Definition: hocdec.h:14
#define ENDGUI
Definition: hocdec.h:373
int ifarg(int)
Definition: code.cpp:1581
#define v
Definition: md1redef.h:4
#define i
Definition: md1redef.h:12
void init()
Definition: init.cpp:291
char * name
Definition: init.cpp:16
int const size_t const size_t n
Definition: nrngsl.h:11
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:1560
static PyObject * is_pysec(NPySecObj *self)
Definition: nrnpy_nrn.cpp:857
static philox4x32_key_t k
Definition: nrnran123.cpp:11
static char * pattern
Definition: regexp.cpp:82
#define g
Definition: passive0.cpp:21
#define e
Definition: passive0.cpp:22
#define NULL
Definition: sptree.h:16
Definition: hocdec.h:227
Definition: model.h:57
short type
Definition: model.h:58
void SymChooser_reg()
Definition: symchoos.cpp:214
static double text(void *v)
Definition: symchoos.cpp:201
static Member_func members[]
Definition: symchoos.cpp:213
double(* nrnpy_object_to_double_)(Object *)
Definition: xmenu.cpp:14
static double srun(void *v)
Definition: symchoos.cpp:182
static void * scons(Object *)
Definition: symchoos.cpp:147
static void sdestruct(void *v)
Definition: symchoos.cpp:175
bool nrn_spec_dialog_pos(Coord &x, Coord &y)
true if Style 'dialog_spec_position: on' and fills x,y with dialog_left_position and dialog_bottom_po...