NEURON
scenepic.cpp
Go to the documentation of this file.
1 #include <../../nrnconf.h>
2 #if HAVE_IV // to end of file
3 
4 #include <IV-look/kit.h>
5 #include <InterViews/layout.h>
6 #include <InterViews/telltale.h>
7 #include <InterViews/window.h>
8 #include <OS/list.h>
9 #include <OS/string.h>
10 #include <stdio.h>
11 #include "ivoc.h"
12 #include "mymath.h"
13 #include "scenevie.h"
14 #include "scenepic.h"
15 #include "rubband.h"
16 #include "apwindow.h"
17 #include "utility.h"
18 #include "oc2iv.h"
19 
20 #define Scene_SceneMover_ "Translate Scene"
21 #define Scene_SceneZoom_ "ZoomInOut Scene"
22 #define Scene_RoundView_ "RoundView Scene"
23 #define Scene_WholeSceneView_ "WholeScene Scene"
24 #define Scene_WholePlotView_ "View_equal_Plot Scene"
25 #define Scene_ZoomOut10_ "ZoomOut10 Scene"
26 #define Scene_ZoomeIn10_ "ZoomIn10 Scene"
27 #define Scene_SpecView_ "SetView Scene"
28 #define Scene_SizeScene_ "Scene_equal_View Scene"
29 #define Scene_NewView_ "NewView Scene"
30 #define Scene_ShowMenu_ "Scene"
31 #define Scene_ObjectName_ "ObjectName"
32 
33 MenuItem* K::menu_item(const char* name) {
34  Glyph* g = LayoutKit::instance()->r_margin(
35  WidgetKit::instance()->fancy_label(name), 0.0, fil, 0.0
36  );
37  return WidgetKit::instance()->menu_item(g);
38 }
39 
40 MenuItem* K::check_menu_item(const char* name) {
41  Glyph* g = LayoutKit::instance()->r_margin(
42  WidgetKit::instance()->fancy_label(name), 0.0, fil, 0.0
43  );
44  return WidgetKit::instance()->check_menu_item(g);
45 }
46 
47 MenuItem* K::radio_menu_item(TelltaleGroup* tg, const char* name) {
48  Glyph* g = LayoutKit::instance()->r_margin(
49  WidgetKit::instance()->fancy_label(name), 0.0, fil, 0.0
50  );
51  return WidgetKit::instance()->radio_menu_item(tg, g);
52 }
53 
54 /*static*/ class ButtonItemInfo {
55 public:
56  ButtonItemInfo(const char* name, Action*, TelltaleState*, MenuItem* mi = NULL, Menu* m = NULL);
57  virtual ~ButtonItemInfo();
58  GlyphIndex menu_index();
59  TelltaleState* s_;
60  CopyString name_;
61  Action* a_;
62  Menu* parent_;
63  MenuItem* mi_;
64 };
65 ButtonItemInfo::ButtonItemInfo(const char* name, Action* a, TelltaleState* s, MenuItem* mi, Menu* parent)
66 {
67  name_ = name;
68  s_ = s;
69  a_ = a;
70  parent_ = parent;
71  mi_ = mi;
72 }
73 ButtonItemInfo::~ButtonItemInfo(){}
74 
75 GlyphIndex ButtonItemInfo::menu_index() {
76  GlyphIndex i, cnt;
77  if (parent_ && mi_) {
78  cnt = parent_->item_count();
79  for (i=0; i < cnt; ++i) {
80  if (parent_->item(i) == mi_) {
81  return i;
82  }
83  }
84  }
85  return -1;
86 }
87 
88 declarePtrList(ButtonItemInfoList,ButtonItemInfo)
89 implementPtrList(ButtonItemInfoList,ButtonItemInfo)
90 
91 /*static*/ class SceneMover : public OcHandler {
92 public:
93  SceneMover();
94  virtual ~SceneMover();
95  virtual bool event(Event&);
96  virtual void help();
97 private:
98  Coord x_, y_;
99  XYView* view_;
100 };
101 
102 /*static*/ class SceneZoom : public OcHandler {
103 public:
104  SceneZoom();
105  virtual ~SceneZoom();
106  virtual bool event(Event&);
107  virtual void help();
108 private:
109  Coord x_, y_, xorg_, yorg_;
110  XYView* view_;
111 };
112 
113 /*static*/ class NewView : public RubberAction {
114 public:
115  NewView();
116  virtual ~NewView();
117  virtual void execute(Rubberband*);
118  virtual void help();
119 };
120 
121 /*static*/ class RoundView : public Action {
122  virtual void execute();
123 };
124 
125 /*static*/ class WholeSceneView : public Action {
126  virtual void execute();
127 };
128 
129 /*static*/ class WholePlotView : public Action {
130  virtual void execute();
131 };
132 
133 /*static*/ class SpecView : public Action {
134  virtual void execute();
135 };
136 
137 /*static*/ class SizeScene : public Action {
138  virtual void execute();
139 };
140 
141 /*static*/ class ZoomOut10: public Action {
142  virtual void execute();
143 };
144 
145 /*static*/ class ZoomIn10: public Action {
146  virtual void execute();
147 };
148 
149 /*static*/ class SPObjectName: public Action {
150  virtual void execute();
151 };
152 
153 /*static*/ class ShowMenu: public Action {
154 public:
155  ShowMenu(Menu*);
156  virtual ~ShowMenu();
157  virtual void execute();
158 private:
159  Menu* m_;
160 };
161 
163  if (!picker_) {
164  WidgetKit& k = *WidgetKit::instance();
165  picker_ = new ScenePicker(this);
166 
167  SceneZoom* z = new SceneZoom();
168  SceneMover* m = new SceneMover();
169 
170  Menu* men = k.pulldown();
171  MenuItem* mi = K::menu_item("View . . .");
172  mi->menu(men);
173  picker_->add_menu(mi);
174 
175  picker_->add_menu("View = plot", new WholePlotView(), men);
176  picker_->add_menu("Set View", new SpecView(), men);
177  picker_->add_menu("10% Zoom out", new ZoomOut10(), men);
178  picker_->add_menu("10% Zoom in", new ZoomIn10(), men);
179  picker_->add_radio_menu("NewView", new RubberRect(new NewView()),0 , 0, men);
180  picker_->add_radio_menu("Zoom in/out", z, 0, men);
181  picker_->add_radio_menu("Translate", m, 0, men);
182  picker_->add_menu("Round View", new RoundView(), men);
183  picker_->add_menu("Whole Scene", new WholeSceneView() , men);
184  picker_->add_menu("Scene=View", new SizeScene(), men);
185  picker_->add_menu("Object Name", new SPObjectName(), men);
186 // picker_->add_menu("Show Menu", new ShowMenu(men), men);
187 // picker_->add_menu(k.menu_item("Undo"));
188 // picker_->add_menu(k.menu_item("Redo"));
189  picker_->add_menu(k.menu_item_separator());
190  picker_->bind_select(z);
191  picker_->bind_adjust(m);
192  }
193  return picker_;
194 }
195 
196 /*static*/ class ScenePickerImpl : public OcHandler {
197 public:
198  ScenePickerImpl(Scene* );
199  virtual ~ScenePickerImpl();
200  virtual bool event(Event&);
201  long info_index(const char*);
202 public:
203  friend class ScenePicker;
204  PopupMenu* menu_;
205  Scene* scene_;
206  TelltaleGroup* tg_;
207  CopyString sel_name_;
208  ButtonItemInfoList* bil_;
209  static DismissableWindow* window_;
210 };
211 
212 void ScenePicker::pick_menu(Glyph* glyph, int depth, Hit& h) {
213  h.target(depth, glyph, 0, spi_);
214 }
215 
216 DismissableWindow* ScenePickerImpl::window_;
217 
218 /*static*/ class RadioSelect: public Action {
219 public:
220  RadioSelect(const char*, Action*, Scene*);
221  virtual ~RadioSelect();
222  virtual void execute();
223 private:
224  Action* a_;
225  CopyString name_;
226  Scene* s_;
227 };
228 
229 /*static*/ class RubberTool: public Action {
230 public:
231  RubberTool(Action* sel, Rubberband*, ScenePicker*, int);
232  virtual ~RubberTool();
233  virtual void execute();
234 private:
235  Action* sel_;
236  Rubberband* rb_;
237  ScenePicker* sp_;
238  int tool_;
239 };
240 
241 /*static*/ class HandlerTool: public Action {
242 public:
243  HandlerTool(OcHandler*, ScenePicker*, int);
244  virtual ~HandlerTool();
245  virtual void execute();
246 private:
247  OcHandler* h_;
248  ScenePicker* sp_;
249  int tool_;
250 };
251 
253  spi_ = new ScenePickerImpl(scene);
254  spi_->ref();
255  bind_menu(spi_);
256 }
257 
259  return ScenePickerImpl::window_;
260 }
261 
263  spi_->unref();
264 }
265 
266 
267 TelltaleGroup* ScenePicker::telltale_group(){return spi_->tg_;}
268 
270  if (m) {
271  m->append_item(mi);
272  }else{
273  spi_->menu_->append_item(mi);
274  }
275  return mi;
276 }
277 
278 MenuItem* ScenePicker::add_menu(const char* name, MenuItem* mi, Menu* m) {
279  Menu* mm;
280  if (m) {
281  mm = m;
282  }else{
283  mm = spi_->menu_->menu();
284  }
285  mm->append_item(mi);
286  spi_->bil_->append(new ButtonItemInfo(name, mi->action(), mi->state(), mi, mm));
287  return mi;
288 }
289 
290 MenuItem* ScenePicker::add_menu(const char* name, Action* a, Menu* m) {
291  MenuItem* mi = K::menu_item(name);
292  mi->action(a);
293  return add_menu(name, mi, m);
294 }
295 MenuItem* ScenePicker::add_radio_menu(const char* name, Action* a, Menu* m) {
296  MenuItem* mi = K::radio_menu_item(spi_->tg_, name);
297  mi->action(new RadioSelect(name, a, spi_->scene_));
298  return add_menu(name, mi, m);
299 }
300 Button* ScenePicker::radio_button(const char* name, Action* a) {
301  Button* mi = WidgetKit::instance()->radio_button(spi_->tg_, name,
302  new RadioSelect(name, a, spi_->scene_));
303  spi_->bil_->append(new ButtonItemInfo(name, mi->action(), mi->state()));
304  return mi;
305 }
306 MenuItem* ScenePicker::add_radio_menu(const char* name, Rubberband* rb, Action* sel, int tool, Menu* m) {
307  return add_radio_menu(name, new RubberTool(sel, rb, this, tool), m);
308 }
309 Button* ScenePicker::radio_button(const char* name, Rubberband* rb, Action* sel, int tool) {
310  return radio_button(name, new RubberTool(sel, rb, this, tool));
311 }
312 MenuItem* ScenePicker::add_radio_menu(const char* name, OcHandler* h, int tool, Menu* m) {
313  return add_radio_menu(name, new HandlerTool(h, this, tool), m);
314 }
315 
316 long ScenePickerImpl::info_index(const char* name) {
317  long i, cnt;
318  cnt = bil_->count();
319  for (i=0; i < cnt; ++i) {
320  ButtonItemInfo* b = bil_->item(i);
321  if (strcmp(b->name_.string(), name) == 0) {
322  return i;
323  }
324  }
325  return -1;
326 }
327 void ScenePicker::exec_item(const char* name) {
328  long i;
329  Scene* s = spi_->scene_;
330  if (s->view_count()) {
331  XYView* v = s->sceneview(0);
333  if (v->canvas()) {
334  ScenePickerImpl::window_ = (DismissableWindow*)v->canvas()->window();
335  }
336  }else{
338  ScenePickerImpl::window_ = NULL;
339  }
340  i = spi_->info_index(name);
341  if (i > -1) {
342  ButtonItemInfo* b = spi_->bil_->item(i);
343  TelltaleState* t = b->s_;
344  bool chosen = t->test(TelltaleState::is_chosen);
345  bool act = !chosen;
346  if (t->test(TelltaleState::is_toggle)) {
347  t->set(TelltaleState::is_chosen, act);
348  act = true;
349  }else if (t->test(TelltaleState::is_choosable)) {
350  t->set(TelltaleState::is_chosen, true);
351  }
352  t->notify();
353  if (act && b->a_ != NULL) {
354  b->a_->execute();
355  }
356  }
357 }
358 
359 void ScenePicker::remove_item(const char* name) {
360  long i;
361  i = spi_->info_index(name);
362  if (i > -1) {
363  ButtonItemInfo* b = spi_->bil_->item(i);
364  spi_->bil_->remove(i);
365  GlyphIndex j = b->menu_index();
366  if (j > -1) {
367  b->parent_->remove_item(j);
368  }
369 // if (b->mi_) {
370 // delete b->mi_;
371 // }
372  delete b;
373  }
374 }
375 
376 void ScenePicker::insert_item(const char* insert, const char* name, MenuItem* mi) {
377  long i;
378  i = spi_->info_index(insert);
379  if (i > -1) {
380  ButtonItemInfo* b = spi_->bil_->item(i);
381  GlyphIndex j = b->menu_index();
382  if (j > -1) {
383  b->parent_->insert_item(j, mi);
384  spi_->bil_->insert(i, new ButtonItemInfo(name,
385  mi->action(), mi->state(), mi, b->parent_));
386  }
387  }
388 }
389 
390 void ScenePicker::set_scene_tool(int t) {
391  spi_->scene_->tool(t);
392 }
393 
394 void ScenePicker::help() {
395  spi_->scene_->help();
396 }
397 
398 void ScenePicker::select_name(const char* name) {
399  spi_->sel_name_ = name;
400 }
401 
402 const char* ScenePicker::select_name() {
403  return spi_->sel_name_.string();
404 }
405 
406 ScenePickerImpl::ScenePickerImpl(Scene* scene) : sel_name_(""){
407  menu_ = new PopupMenu();
408  menu_->ref();
409  tg_ = new TelltaleGroup();
410  tg_->ref();
411  scene_ = scene; // not ref'ed since picker deleted when scene is deleted
412  bil_ = new ButtonItemInfoList(20);
413 }
414 
415 ScenePickerImpl::~ScenePickerImpl() {
416  Resource::unref(menu_);
417  Resource::unref(tg_);
418  for (long i=bil_->count() - 1; i >= 0; --i) {
419  delete bil_->item(i);
420  }
421  delete bil_;
422 }
423 
424 bool ScenePickerImpl::event(Event& e) {
425 //printf("ScenePickerImpl::event\n");
426  window_ = (DismissableWindow*)e.window();
427  menu_->event(e);
428  return false;
429 }
430 
431 RubberTool::RubberTool(Action* sel, Rubberband* rb, ScenePicker* sp, int tool) {
432  sel_ = sel;
433  sp_ = sp;
434  rb_ = rb;
435  Resource::ref(rb_);
436  Resource::ref(sel_);
437  tool_ = tool;
438 }
439 
440 RubberTool::~RubberTool() {
441  Resource::unref(rb_);
442  Resource::unref(sel_);
443 }
444 
445 void RubberTool::execute() {
446  sp_->bind_select(rb_);
447  sp_->set_scene_tool(tool_);
448  if (Oc::helpmode()) {
449  rb_->help();
450  }else if (sel_) {
451  sel_->execute();
452  }
453 }
454 
455 RadioSelect::RadioSelect(const char* name, Action* a, Scene* s) : name_(name) {
456  a_ = a;
457  Resource::ref(a_);
458  s_ = s; // not referenced
459 }
460 
461 RadioSelect::~RadioSelect() {
463 }
464 
465 void RadioSelect::execute() {
467  a_->execute();
468  s_->picker()->select_name(this->name_.string());
469  for (int i=0; i < s_->view_count(); ++i) {
470  XYView* v = s_->sceneview(i);
471  v->notify();
472  }
473 }
474 
475 HandlerTool::HandlerTool(OcHandler* h, ScenePicker* sp, int tool) {
476  sp_ = sp;
477  h_ = h;
478  Resource::ref(h_);
479  tool_ = tool;
480 }
481 
482 HandlerTool::~HandlerTool() {
483  Resource::unref(h_);
484 }
485 
486 void HandlerTool::execute() {
487  sp_->bind_select(h_);
488  sp_->set_scene_tool(tool_);
489  if (Oc::helpmode()) {
490  if (h_) {
491  h_->help();
492  }else{
493  sp_->help();
494  }
495  }
496 }
497 
498 SceneMover::SceneMover(){
499  x_ = 0;
500  y_ = 0;
501 }
502 
503 SceneMover::~SceneMover(){}
504 
505 void SceneMover::help() {
506  Oc::help(Scene_SceneMover_);
507 }
508 
509 bool SceneMover::event(Event& e) {
510  if (Oc::helpmode()) {
511  if (e.type() == Event::down) {
512  help();
513  }
514  }
515  Coord xold = x_, yold = y_;
516  x_ = e.pointer_x();
517  y_ = e.pointer_y();
518 
519  switch(e.type()) {
520  case Event::down:
521  view_ = XYView::current_pick_view();
522 // view_->rebind();
523  e.grab(this);
524 #ifdef WIN32
525  e.window()->grab_pointer();
526 #endif
527  break;
528  case Event::motion:
529  view_->move_view(x_ - xold, y_ - yold);
530  break;
531  case Event::up:
532  e.ungrab(this);
533 #ifdef WIN32
534  e.window()->ungrab_pointer();
535 #endif
536  break;
537  }
538  return true;
539 }
540 
541 SceneZoom::SceneZoom(){
542  x_ = 0;
543  y_ = 0;
544  xorg_ = 0;
545  yorg_ = 0;
546 }
547 
548 SceneZoom::~SceneZoom(){}
549 
550 void SceneZoom::help() {
551  Oc::help(Scene_SceneZoom_);
552 }
553 
554 bool SceneZoom::event(Event& e) {
555  if (Oc::helpmode()) {
556  if (e.type() == Event::down) {
557  help();
558  }
559  }
560  Coord xold = x_, yold = y_;
561  x_ = e.pointer_x();
562  y_ = e.pointer_y();
563 
564  switch(e.type()) {
565  case Event::down:
566  view_ = XYView::current_pick_view();
567 // view_->rebind();
568  e.grab(this);
569 #ifdef WIN32
570  e.window()->grab_pointer();
571 #endif
572  xorg_ = x_;
573  yorg_ = y_;
574  break;
575  case Event::motion:
576  xold = (x_ - xold)/50;
577  yold = (y_ - yold)/50;
578  if (xold > .5) xold = .5;
579  if (yold > .5) yold = .5;
580  if (xold < -.5) xold = -.5;
581  if (yold < -.5) yold = -.5;
582  view_->scale_view(xorg_, yorg_, xold, yold);
583  break;
584  case Event::up:
585  e.ungrab(this);
586 #ifdef WIN32
587  e.window()->ungrab_pointer();
588 #endif
589  break;
590  }
591  return true;
592 }
593 
594 void RoundView::execute() {
595  if (Oc::helpmode()) {
596  Oc::help(Scene_RoundView_);
597  return;
598  }
600  if (!v) return;
601  Coord x1, y1, x2, y2;
602  v->zin(x1, y1, x2, y2);
603  double d1, d2; int ntic;
604  MyMath::round_range_down(x1, x2, d1, d2, ntic);
605  x1 = d1;
606  x2 = d2;
607  MyMath::round_range_down(y1, y2, d1, d2, ntic);
608  y1 = d1;
609  y2 = d2;
610 
611  v->size(x1, y1, x2, y2);
612  v->zout(x1, y1, x2, y2);
613  v->size(x1, y1, x2, y2);
614  v->damage_all();
615 }
616 
618  if (Oc::helpmode()) {
619  Oc::help(Scene_WholeSceneView_);
620  return;
621  }
623  if (!v) return;
624  Scene& s = *v->scene();
625  v->size(s.x1(), s.y1(), s.x2(), s.y2());
626  Coord x1, y1, x2, y2;
627  v->zout(x1, y1, x2, y2);
628  v->size(x1, y1, x2, y2);
629  v->damage_all();
630 }
631 
632 void WholePlotView::execute() {
633  if (Oc::helpmode()) {
634  Oc::help(Scene_WholePlotView_);
635  return;
636  }
638  if (!v) return;
639  Scene& s = *v->scene();
640  Coord x1, y1, x2, y2;
641  s.wholeplot(x1, y1, x2, y2);
642  MyMath::round(x1, x2, MyMath::Expand, 2);
643  MyMath::round(y1, y2, MyMath::Expand, 2);
644  v->box_size(x1, y1, x2, y2);
645  v->zout(x1, y1, x2, y2);
646  v->box_size(x1, y1, x2, y2);
647  v->damage_all();
648 }
649 
650 void ZoomOut10::execute() {
651  if (Oc::helpmode()) {
652  Oc::help(Scene_ZoomOut10_);
653  return;
654  }
656  Coord x1, x2, y1, y2;
657  v->zout(x1, y1, x2, y2);
658  v->size(x1, y1, x2, y2);
659  v->damage_all();
660 }
661 
662 void ZoomIn10::execute() {
663  if (Oc::helpmode()) {
664  Oc::help(Scene_ZoomeIn10_);
665  return;
666  }
668  if (!v) return;
669  Coord x1, x2, y1, y2;
670  v->zin(x1, y1, x2, y2);
671  v->size(x1, y1, x2, y2);
672  v->damage_all();
673 }
674 
675 void SPObjectName::execute() {
676  if (Oc::helpmode()) {
677  Oc::help(Scene_ObjectName_);
678  }
680  printf("%s\n", hoc_object_name(s->hoc_obj_ptr()));
681 }
682 
683 void SpecView::execute() {
684  if (Oc::helpmode()) {
685  Oc::help(Scene_SpecView_);
686  }
688  if(!v) return;
689  Coord x1, x2, y1, y2;
690  v->zin(x1, y1, x2, y2);
691  bool bx = var_pair_chooser("X size", x1, x2, v->canvas()->window());
692  bool by = var_pair_chooser("Y size", y1, y2, v->canvas()->window());
693  v->size(x1, y1, x2, y2);
694  v->zout(x1, y1, x2, y2);
695  v->size(x1, y1, x2, y2);
696  v->damage_all();
697 }
698 
699 void SizeScene::execute() {
700  if (Oc::helpmode()) {
701  Oc::help(Scene_SizeScene_);
702  return;
703  }
705  if (!v) return;
706  Coord x1, x2, y1, y2;
707  v->zin(x1, y1, x2, y2);
708  v->scene()->new_size(x1, y1, x2, y2);
709  v->zout(x1, y1, x2, y2);
710  v->size(x1, y1, x2, y2);
711 }
712 
713 NewView::NewView(){}
714 NewView::~NewView(){}
715 void NewView::help() {
716  Oc::help(Scene_NewView_);
717 }
718 
719 void NewView::execute(Rubberband* rb) {
720  if (Oc::helpmode()) {
721  help();
722  return;
723  }
724  const Event& e = rb->event();
726  Coord l, b, r, t;
727  Coord x1,y1, x2, y2;
728  ((RubberRect*)rb)->get_rect_canvas(l, b, r, t);
729  ((RubberRect*)rb)->get_rect(x1, y1, x2, y2);
730  XYView* v = cv->new_view(x1,y1,x2,y2);
731  ViewWindow* w = new ViewWindow(v,
732  ((PrintableWindow*)(cv->canvas()->window()))->type());
733  w->place(l + e.pointer_root_x() - e.pointer_x(),
734  b + e.pointer_root_y() - e.pointer_y());
735  w->map();
736 }
737 
738 ShowMenu::ShowMenu(Menu* m) {
739  m_ = m;
740  m->ref();
741 }
742 ShowMenu::~ShowMenu() {
743  Resource::unref(m_);
744 }
745 void ShowMenu::execute() {
746  if (Oc::helpmode()) {
747  Oc::help(Scene_ShowMenu_);
748  return;
749  }
751  v->parent()->viewmenu(m_);
752 }
753 
754 // following doesn't work correctly yet
755 void OcViewGlyph::viewmenu(Glyph* m) {
756  printf("OcViewGlyph::viewmenu()\n");
757  if (!g_) {
758  g_ = body();
759  Resource::ref(g_);
760  LayoutKit& lk = *LayoutKit::instance();
761  WidgetKit& wk = *WidgetKit::instance();
762  PolyGlyph* hbox = lk.hbox(2);
763  hbox->append(lk.center(m, 0, 1));
764  hbox->append(lk.center(view(), 0, 1));
765  body(hbox);
766  printf("add menu\n");
767  }else{
768  printf("delete menu\n");
769  body(g_);
771  g_ = NULL;
772  }
773 }
774 
776  menu_ = WidgetKit::instance()->pulldown();
777  menu_->ref();
778  w_ = NULL;
779  grabbed_ = false;
780 }
781 
783  Resource::unref(menu_);
784  if (w_) {
785  delete w_;
786  }
787 }
788 
789 bool PopupMenu::event(Event& e) {
790  if (!w_) {
791  w_ = new PopupWindow(menu_);
792 #if MAC
793  w_->place(10000,10000);
794  w_->map();
795  w_->unmap();
796 #endif
797  }
798  switch (e.type()) {
799  case Event::down:
800  if (!grabbed_) {Coord l, b;
801  w_->place(e.pointer_root_x(), e.pointer_root_y());
802  w_->align(.8,.9);
803 #if defined(WIN32) || MAC
804  l = w_->left();
805  b = w_->bottom();
806  if (b < 0. || l < 0.) {
807  w_->align(0., 0.);
808  w_->place((l>0.)?l:1., (b>0.)?b:20.);
809  }
810  w_->map();
811 #else
812  w_->map();
813  l = w_->left();
814  b = w_->bottom();
815  if (b < 0. || l < 0.) {
816  w_->unmap();
817  w_->align(0., 0.);
818  w_->place((l>0.)?l:1., (b>0.)?b:20.);
819  w_->map();
820  }
821 #endif
822  e.grab(this);
823  grabbed_ = true;
824  menu_->press(e);
825  }
826  break;
827  case Event::motion:
828  if (grabbed_) {
829  menu_->drag(e);
830  }
831  break;
832  case Event::up:
833  if (grabbed_) {
834  e.ungrab(this);
835  grabbed_ = false;
836  w_->unmap();
837  menu_->release(e);
838  }
839  break;
840  }
841  return true;
842 }
843 
845  menu_->append_item(mi);
846 }
847 #endif
virtual bool event(Event &)
static MenuItem * menu_item(const char *)
virtual void damage_all()
void remove_item(const char *)
Glyph * g_
Definition: scenevie.h:100
#define TelltaleGroup
Definition: _defines.h:295
#define declarePtrList(PtrList, T)
static bool helpmode()
Definition: ivoc.h:66
virtual int view_count() const
void execute(Inst *p)
Definition: code.cpp:2651
void append_item(MenuItem *)
#define WidgetKit
Definition: _defines.h:331
virtual XYView * new_view(Coord x1, Coord y1, Coord x2, Coord y2)
#define g
Definition: passive0.cpp:23
void insert_item(const char *, const char *, MenuItem *)
#define Glyph
Definition: _defines.h:132
#define Coord
Definition: _defines.h:19
char * hoc_object_name(Object *ob)
Definition: hoc_oop.cpp:84
virtual const char * select_name()
virtual Coord x2() const
Definition: scenevie.h:318
#define RubberRect
Definition: _defines.h:240
static void help(const char *)
virtual bool event(Event &)
static MenuItem * check_menu_item(const char *)
static void round_range_down(Coord x1, Coord x2, double &y1, double &y2, int &ntic)
Definition: mymath.cpp:306
virtual void box_size(Coord x1, Coord y1, Coord x2, Coord y2)
static MenuItem * radio_menu_item(TelltaleGroup *, const char *)
virtual void notify()
Definition: observe.cpp:75
#define v
Definition: md1redef.h:4
ScenePicker(Scene *)
virtual void ref() const
Definition: resource.cpp:47
static philox4x32_key_t k
Definition: nrnran123.cpp:11
#define PolyGlyph
Definition: _defines.h:207
virtual void set_scene_tool(int)
void size(Coord x1, Coord y1, Coord x2, Coord y2)
static double round(float &x1, float &x2, int direction, int digits)
Definition: mymath.cpp:335
#define e
Definition: passive0.cpp:24
XYView * view()
Definition: scenevie.h:95
#define PopupWindow
Definition: _defines.h:210
virtual void wholeplot(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
bool var_pair_chooser(const char *, float &x, float &y, Window *w=NULL, Coord x1=400., Coord y1=400.)
virtual void map()
virtual void help()
#define implementPtrList(PtrList, T)
virtual void bind_menu(Handler *h)
Definition: ocinput.h:17
double mm
#define Menu
Definition: _defines.h:176
PrintableWindow * w_
Definition: ocglyph.h:36
_CONST char * s
Definition: system.cpp:74
virtual Coord x1() const
Definition: scenevie.h:317
#define printf
Definition: mwprefix.h:26
static N_Vector x_
static double insert(void *v)
Definition: tqueue.cpp:22
#define LayoutKit
Definition: _defines.h:161
#define PopupMenu
Definition: _defines.h:209
#define GlyphIndex
Definition: _defines.h:23
static void help(const char *)
Definition: hel2mos.cpp:104
MenuItem * add_radio_menu(const char *, Action *, Menu *=NULL)
void viewmenu(Glyph *)
#define cnt
Definition: spt2queue.cpp:19
virtual void exec_item(const char *)
size_t j
virtual XYView * sceneview(int) const
virtual void unref() const
Definition: resource.cpp:52
virtual void zout(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
char * name
Definition: init.cpp:16
virtual void new_size(Coord x1, Coord y1, Coord x2, Coord y2)
static N_Vector y_
virtual void pick_menu(Glyph *, int, Hit &)
ScenePickerImpl * spi_
Definition: scenepic.h:53
#define parent
Definition: rbtqueue.cpp:47
#define Event
Definition: _defines.h:107
OcViewGlyph * parent()
Definition: scenevie.h:151
#define fil
Definition: coord.h:42
virtual void unmap()
virtual Coord y2() const
Definition: scenevie.h:320
MenuItem * add_menu(MenuItem *, Menu *=NULL)
Canvas * canvas()
virtual Scene * scene() const
static realtype a_
#define i
Definition: md1redef.h:12
#define Action
Definition: _defines.h:27
Button * radio_button(const char *, Action *)
Object * hoc_obj_ptr()
Definition: scenevie.h:275
virtual ~PopupMenu()
#define MenuItem
Definition: _defines.h:179
#define TelltaleState
Definition: _defines.h:296
virtual Coord y1() const
Definition: scenevie.h:319
double t
Definition: init.cpp:123
static XYView * current_pick_view()
ScenePicker * picker()
virtual ~ScenePicker()
virtual void zin(Coord &x1, Coord &y1, Coord &x2, Coord &y2) const
return NULL
Definition: cabcode.cpp:461
static DismissableWindow * last_window()
void handle_old_focus()
#define Button
Definition: _defines.h:62
#define Hit
Definition: _defines.h:147
TelltaleGroup * telltale_group()