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> 11 #include <IV-look/kit.h> 12 #include <InterViews/input.h> 34 class NrnFixedLayout :
public Layout {
37 virtual ~NrnFixedLayout();
42 virtual void allocate(
46 virtual void span(
Coord);
47 virtual Coord span() {
return span_; }
48 virtual bool vertical() {
return dimension_ ==
Dimension_Y; }
67 Coord next_map_adjust_;
79 NrnFixedLayout* fixlay_;
83 Coord pstart_, fstart_;
89 virtual ~BoxDismiss();
106 BoxDismiss::~BoxDismiss() {
110 if (
b_->dismissing() ==
true) {
125 if (
ifarg(2) &&
int(
chkarg(2,0,1)) == 1) { scroll =
true; }
167 ((
OcBox*)v)->intercept(b);
180 ((
OcBox*)v)->session_priority(p);
196 w = b->make_window(
float(*
getarg(2)),
float(*
getarg(3)),
199 w = b->make_window();
205 b->dismissing(
false);
207 if (b->full_request() && b->has_window()) {
208 b->window()->request_on_resize(
true);
210 b->dismiss_action(
NULL);
224 const char* a =
"Accept";
225 const char*
c =
"Cancel";
233 r = b->dialog(
gargstr(1), a, c);
248 accept = (bool)
chkarg(1, 0, 1);
250 if (b->dialog_dismiss(accept)) {
253 if (b->has_window()) {
256 b->window()->dismiss();
274 b = ((
OcBox*)v)->has_window();
312 bool x = ((
int)
chkarg(1, 0, 1) != 0) ?
true :
false;
315 return (b->full_request() ? 1. : 0.);
330 p[2] = b->
window()->width();
331 p[3] = b->
window()->height();
349 }
else if (
ifarg(2)) {
361 b->save_action(buf, 0);
455 hoc_execerror(
"Box or Deck is recursive. The GUI may no longer work correctly.\n",
456 "Exit program and eliminate the recursion");
463 bi_->full_request_ =
false;
464 bi_->dismissing_ =
false;
465 bi_->next_map_adjust_ = -1.;
474 box =
bi_->box_ = lk.hbox(3);
477 bi_->box_ = sb = lk.vscrollbox(10);
478 box = lk.hbox(sb, lk.hspace(4), wk.vscroll_bar(sb));
480 box =
bi_->box_ = lk.vbox(3);
492 wk.inset_frame(lk.variable_span(box)),
500 wk.outset_frame(lk.variable_span(box)),
508 wk.bright_inset_frame(lk.variable_span(box)),
537 for (i=0; i <
cnt; ++
i) {
538 ((
OcGlyph*)(
bi_->ocglyph_list_->component(i)))->parents(
false);
544 if (
bi_->save_action_) {
545 delete bi_->save_action_;
547 if (
bi_->save_pyact_) {
551 delete bi_->dis_act_;
553 if (
bi_->dis_pyact_) {
577 bi_->ocglyph_list_->append(g);
579 if (
bi_->next_map_adjust_ > 0.) {
580 BoxAdjust* ba =
new BoxAdjust(
this,
bi_, g,
bi_->next_map_adjust_);
581 if (!
bi_->ba_list_) {
583 bi_->ba_list_->ref();
585 bi_->ba_list_->append(ba);
586 bi_->box_->append(ba->ga_);
587 bi_->box_->append(ba);
588 bi_->next_map_adjust_ = -1.;
590 if (
bi_->type_ == V) {
591 bi_->box_->append(lk.hflexible(lk.vcenter(g, 1.)));
593 bi_->box_->append(lk.vflexible(lk.vcenter(g, 1.)));
600 body(
new Patch(body()));
608 if (
bi_->ba_list_ && index < bi_->
ba_list_->count()) {
609 BoxAdjust* ba = (BoxAdjust*)
bi_->ba_list_->component(index);
614 ba->fixlay_->span(natural);
616 bi_->box_->modified(0);
618 ((
Patch*)body())->redraw();
627 NrnFixedLayout::~NrnFixedLayout() { }
629 void NrnFixedLayout::request(
638 void NrnFixedLayout::allocate(
646 void NrnFixedLayout::span(
Coord s) {
655 ga_ = lk.vcenter(g, 1.);
657 ga_ = lk.hflexible(ga_);
660 ga_ = lk.vflexible(ga_);
666 BoxAdjust::~BoxAdjust() {
670 if (fixlay_->vertical()) {
671 pstart_ = e.pointer_y();
673 pstart_ = e.pointer_x();
675 fstart_ = fixlay_->span();
680 if (fixlay_->vertical()) {
681 d = e.pointer_y() - pstart_;
684 d = e.pointer_x() - pstart_;
702 *
bi_->o_ << creat <<
"\n";
705 bi_->save_pyact_ = pyact;
716 bi_->dis_pyact_ = pyact;
718 delete bi_->dis_act_;
722 if (
bi_->dis_pyact_) {
727 *
bi_->dis_act_ = act;
732 if ((
bi_->dis_act_ ||
bi_->dis_pyact_) && has_window()) {
733 window()->replace_dismiss_action(
734 new BoxDismiss(window(),
bi_->dis_act_,
this,
bi_->dis_pyact_));
740 if (
bi_->save_action_ ||
bi_->save_pyact_) {
741 if (
bi_->save_action_ && strcmp(
bi_->save_action_->string(),
"") == 0) {
750 if (
bi_->save_pyact_) {
759 if (
bi_->type_ == H) {
760 o <<
"{\nocbox_ = new HBox()" << endl;
762 o <<
"{\nocbox_ = new VBox()" << endl;
764 o <<
"ocbox_list_.prepend(ocbox_)" << endl;
765 o <<
"ocbox_.intercept(1)\n}" << endl;
766 long i,
cnt =
bi_->ocglyph_list_->count();
767 for (i=0; i <
cnt; ++
i) {
770 o <<
"{\nocbox_ = ocbox_list_.object(0)" << endl;
771 o <<
"ocbox_.intercept(0)" << endl;
776 if (strchr(window()->
name(),
'"')) {
779 cp1 = window()->name();
781 sprintf(buf,
"ocbox_.map(\"%s\", %g, %g, %g, %g)\n}",
784 sprintf(buf,
"ocbox_.map(\"%s\", %g, %g, %g, %g)\n}",
787 window()->save_left(), window()->save_bottom(),
789 window()->canvas()->width(), window()->canvas()->height());
791 window()->width(), window()->height());
795 o <<
"ocbox_.map()\n}" << endl;
800 o <<
"ocbox_list_.remove(0)" << endl;
802 o <<
"objref ocbox_" << endl;
803 if (
bi_->save_action_ && has_window()) {
812 if (
bi_->keep_ref_) {
virtual bool has_window()
Allotment & allotment(DimensionName)
static double dialog(void *v)
#define TRY_GUI_REDIRECT_NO_RETURN(name, obj)
int hoc_is_double_arg(int narg)
OcBox(int type, int frame=INSET, bool scroll=false)
const char * pwm_session_filename()
double(* nrnpy_object_to_double_)(Object *)
char ** hoc_pgargstr(int narg)
static Member_func members[]
const Requirement & x_requirement() const
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)
virtual const char * name() const
static double adjust(void *v)
double * hoc_pgetarg(int narg)
const char * string() const
static double full_request(void *v)
virtual void box_append(OcGlyph *)
static double dismiss_action(void *v)
void hoc_assign_str(char **cpp, const char *buf)
const Requirement & requirement(DimensionName) const
virtual void request(Requisition &) const
static double ref(void *v)
const Requirement & y_requirement() const
virtual void save_action(const char *, Object *)
virtual PrintableWindow * window()
static double adjuster(void *v)
int execute(bool notify=true)
void class2oc(const char *, void *(*cons)(Object *), void(*destruct)(void *), Member_func *, int(*checkpoint)(void **), Member_ret_obj_func *, Member_ret_str_func *)
void hoc_obj_unref(Object *obj)
static double ses_pri(void *v)
virtual void dismiss_action(const char *, Object *pyact=NULL)
static double intercept(void *v)
virtual void save(ostream &)
void hoc_execerror(const char *, const char *)
virtual void intercept(bool)
virtual void unref() const
unsigned int DimensionName
static void * hcons(Object *)
void hoc_obj_ref(Object *obj)
virtual Coord save_bottom() const
virtual void no_parents()
static void destruct(void *v)
#define TRY_GUI_REDIRECT_OBJ(name, obj)
virtual void adjuster(Coord natural)
static double unmap(void *v)
static double map(void *v)
static double b_size(void *v)
char * hoc_object_pathname(Object *ob)
static double ismapped(void *v)
static OcGlyphContainer * intercept(OcGlyphContainer *)
int hoc_is_object_arg(int narg)
virtual Coord save_left() const
static void * vcons(Object *)
Object ** hoc_objgetarg(int)
double chkarg(int, double low, double high)
virtual void adjust(Coord natural, int)