1 #include <../../nrnconf.h>
5 #include <InterViews/polyglyph.h>
6 #include <InterViews/layout.h>
7 #include <InterViews/place.h>
8 #include <InterViews/patch.h>
9 #include <InterViews/background.h>
10 #include <InterViews/box.h>
12 #include <IV-look/kit.h>
13 #include <InterViews/input.h>
29 class NrnFixedLayout:
public Layout {
32 virtual ~NrnFixedLayout();
39 virtual void span(
Coord);
40 virtual Coord span() {
43 virtual bool vertical() {
57 CopyString* save_action_;
65 Coord next_map_adjust_;
74 virtual void press(
const Event&);
75 virtual void drag(
const Event&);
76 virtual void release(
const Event&);
77 NrnFixedLayout* fixlay_;
81 Coord pstart_, fstart_;
87 virtual ~BoxDismiss();
104 BoxDismiss::~BoxDismiss() {
107 void BoxDismiss::execute() {
108 if (
b_->dismissing() ==
true) {
166 bool b = int(
chkarg(1, 0., 1.));
168 ((
OcBox*)
v)->intercept(b);
179 int p = int(
chkarg(1, -1000, 10000));
181 ((
OcBox*)
v)->session_priority(
p);
227 const char* a =
"Accept";
228 const char*
c =
"Cancel";
252 accept = (bool)
chkarg(1, 0, 1);
316 bool x = ((int)
chkarg(1, 0, 1) != 0) ?
true :
false;
353 }
else if (
ifarg(2)) {
458 hoc_execerror(
"Box or Deck is recursive. The GUI may no longer work correctly.\n",
459 "Exit program and eliminate the recursion");
467 bi_->full_request_ =
false;
468 bi_->dismissing_ =
false;
469 bi_->next_map_adjust_ = -1.;
471 bi_->ba_list_ =
NULL;
478 box = bi_->box_ = lk.hbox(3);
481 bi_->box_ = sb = lk.vscrollbox(10);
482 box = lk.hbox(sb, lk.hspace(4), wk.vscroll_bar(sb));
484 box = bi_->box_ = lk.vbox(3);
491 body(
new Background(wk.inset_frame(lk.variable_span(box)), wk.background()));
494 body(
new Background(wk.outset_frame(lk.variable_span(box)), wk.background()));
497 body(
new Background(wk.bright_inset_frame(lk.variable_span(box)), wk.background()));
500 body(
new Background(lk.variable_span(box), wk.background()));
506 bi_->save_action_ =
NULL;
507 bi_->save_pyact_ =
NULL;
509 bi_->keep_ref_ =
NULL;
510 bi_->dis_act_ =
NULL;
511 bi_->dis_pyact_ =
NULL;
517 for (
i = 0;
i <
cnt; ++
i) {
518 ((
OcGlyph*) (
bi_->ocglyph_list_->component(
i)))->parents(
false);
524 if (
bi_->save_action_) {
525 delete bi_->save_action_;
527 if (
bi_->save_pyact_) {
531 delete bi_->dis_act_;
533 if (
bi_->dis_pyact_) {
541 return bi_->full_request_;
544 bi_->full_request_ = b;
547 return bi_->dismissing_;
550 bi_->dismissing_ = d;
565 bi_->ocglyph_list_->append(g);
567 if (
bi_->next_map_adjust_ > 0.) {
568 BoxAdjust* ba =
new BoxAdjust(
this,
bi_, g,
bi_->next_map_adjust_);
569 if (!
bi_->ba_list_) {
571 bi_->ba_list_->ref();
573 bi_->ba_list_->append(ba);
574 bi_->box_->append(ba->ga_);
575 bi_->box_->append(ba);
576 bi_->next_map_adjust_ = -1.;
578 if (
bi_->type_ ==
V) {
579 bi_->box_->append(lk.hflexible(lk.vcenter(g, 1.)));
581 bi_->box_->append(lk.vflexible(lk.vcenter(g, 1.)));
588 body(
new Patch(body()));
593 bi_->next_map_adjust_ = natural;
598 if (
bi_->ba_list_ && index < bi_->
ba_list_->count()) {
599 BoxAdjust* ba = (BoxAdjust*)
bi_->ba_list_->component(
index);
604 ba->fixlay_->span(natural);
606 bi_->box_->modified(0);
608 ((
Patch*) body())->redraw();
617 NrnFixedLayout::~NrnFixedLayout() {}
626 void NrnFixedLayout::allocate(
const Allocation&,
634 void NrnFixedLayout::span(
Coord s) {
644 ga_ = lk.vcenter(g, 1.);
646 ga_ = lk.hflexible(ga_);
649 ga_ = lk.vflexible(ga_);
655 BoxAdjust::~BoxAdjust() {}
657 void BoxAdjust::press(
const Event& e) {
658 if (fixlay_->vertical()) {
659 pstart_ = e.pointer_y();
661 pstart_ = e.pointer_x();
663 fstart_ = fixlay_->span();
666 void BoxAdjust::drag(
const Event& e) {
668 if (fixlay_->vertical()) {
669 d = e.pointer_y() - pstart_;
672 d = e.pointer_x() - pstart_;
681 void BoxAdjust::release(
const Event& e) {
690 *
bi_->o_ << creat <<
"\n";
693 bi_->save_pyact_ = pyact;
696 bi_->save_action_ =
new CopyString(creat);
704 bi_->dis_pyact_ = pyact;
706 delete bi_->dis_act_;
710 if (
bi_->dis_pyact_) {
715 *
bi_->dis_act_ = act;
717 bi_->dis_act_ =
new CopyString(act);
722 new BoxDismiss(
window(),
bi_->dis_act_,
this,
bi_->dis_pyact_));
728 if (
bi_->save_action_ ||
bi_->save_pyact_) {
729 if (
bi_->save_action_ && strcmp(
bi_->save_action_->string(),
"") == 0) {
734 o <<
buf << std::endl;
736 o <<
"{" << std::endl;
738 if (
bi_->save_pyact_) {
747 if (
bi_->type_ ==
H) {
748 o <<
"{\nocbox_ = new HBox()" << std::endl;
750 o <<
"{\nocbox_ = new VBox()" << std::endl;
752 o <<
"ocbox_list_.prepend(ocbox_)" << std::endl;
753 o <<
"ocbox_.intercept(1)\n}" << std::endl;
754 long i,
cnt =
bi_->ocglyph_list_->count();
755 for (
i = 0;
i <
cnt; ++
i) {
758 o <<
"{\nocbox_ = ocbox_list_.object(0)" << std::endl;
759 o <<
"ocbox_.intercept(0)" << std::endl;
770 "ocbox_.map(\"%s\", %g, %g, %g, %g)\n}",
774 "ocbox_.map(\"%s\", %g, %g, %g, %g)\n}",
781 o <<
buf << std::endl;
783 o <<
"ocbox_.map()\n}" << std::endl;
786 Sprintf(buf,
"%s = ocbox_", hoc_object_pathname(bi_->oc_ref_));
787 o << buf << std::endl;
788 o <<
"ocbox_list_.remove(0)" << std::endl;
790 o <<
"objref ocbox_" << std::endl;
793 o <<
buf << std::endl;
800 if (
bi_->keep_ref_) {
809 if (
bi_->keep_ref_) {
816 return bi_->keep_ref_;
virtual const char * name() const
virtual void replace_dismiss_action(WinDismiss *)
OcBox(int type, int frame=INSET, bool scroll=false)
virtual void box_append(OcGlyph *)
virtual void no_parents()
virtual void save(std::ostream &)
virtual void dismiss_action(const char *, Object *pyact=NULL)
virtual void adjuster(Coord natural)
virtual void adjust(Coord natural, int)
virtual void save_action(const char *, Object *)
virtual void intercept(bool)
OcGlyphContainer * parent_
virtual void request(Requisition &) const
virtual bool dialog(const char *label, const char *accept, const char *cancel)
bool dialog_dismiss(bool b)
virtual PrintableWindow * make_window(Coord left=-1, Coord bottom=-1, Coord width=-1, Coord height=-1)
virtual PrintableWindow * window()
virtual bool has_window()
virtual void def_size(Coord &w, Coord &h) const
static OcGlyphContainer * intercept(OcGlyphContainer *)
virtual Coord save_left() const
virtual Coord save_bottom() const
void request_on_resize(bool)
const Requirement & x_requirement() const
const Requirement & y_requirement() const
virtual void unref() const
void class2oc(const char *, ctor_f *cons, dtor_f *destruct, Member_func *, Member_ret_obj_func *, Member_ret_str_func *)
HocReturnType hoc_return_type_code
double chkarg(int, double low, double high)
unsigned int DimensionName
int hoc_is_object_arg(int narg)
void hoc_assign_str(char **cpp, const char *buf)
int hoc_is_double_arg(int narg)
void hoc_obj_ref(Object *obj)
double * hoc_pgetarg(int narg)
void hoc_obj_unref(Object *obj)
char ** hoc_pgargstr(int narg)
#define TRY_GUI_REDIRECT_ACTUAL_DOUBLE(name, obj)
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
#define TRY_GUI_REDIRECT_OBJ(name, obj)
Object ** hoc_objgetarg(int)
void hoc_execerror(const char *s1, const char *s2)
int Sprintf(char(&buf)[N], const char *fmt, Args &&... args)
Redirect sprintf to snprintf if the buffer size can be deduced.
static double adjuster(void *v)
const char * pwm_session_filename()
static Member_func members[]
static double adjust(void *v)
static double dialog(void *v)
static void destruct(void *v)
static double unmap(void *v)
static double b_size(void *v)
static double full_request(void *v)
static double map(void *v)
static double ses_pri(void *v)
static double dismiss_action(void *v)
static void * vcons(Object *)
static double save(void *v)
static double ismapped(void *v)
static double ref(void *v)
static double intercept(void *v)
static void * hcons(Object *)