1 #include <../../nrnconf.h> 2 #if HAVE_IV // to end of file 9 #include <InterViews/dialog.h> 10 #include <InterViews/session.h> 11 #include <InterViews/display.h> 12 #include <InterViews/action.h> 13 #include <InterViews/layout.h> 14 #include <InterViews/style.h> 15 #include <InterViews/hit.h> 16 #include <InterViews/event.h> 17 #include <IV-look/kit.h> 18 #include <IV-look/dialogs.h> 22 #define Output IOS_OUT 23 #define Append IOS_APP|IOS_OUT 32 extern Object** (*nrnpy_gui_helper3_)(
const char*
name,
Object* obj,
int handle_strptr);
35 Style*
s = Session::instance()->style();
36 if (s->value_is_on(
"dialog_spec_position")) {
37 s->find_attribute(
"dialog_left_position", x);
38 s->find_attribute(
"dialog_bottom_position", y);
46 return d->post_at_aligned(x, y, 0.0, 0.0);
48 if (x != 400. || y != 400.) {
49 return d->post_at_aligned(x, y, .5,.5);
51 Display* dis = Session::instance()->default_display();
52 return d->post_at_aligned(dis->width()/2, dis->height()/2, .5,.5);
59 class OcGlyphDialog :
public Dialog {
62 virtual ~OcGlyphDialog();
66 class DialogAction :
public Action {
68 DialogAction(
Dialog*,
bool);
69 virtual ~DialogAction();
70 virtual void execute() { d_->dismiss(accept_); }
75 DialogAction::DialogAction(
Dialog* d,
bool accept) {
79 DialogAction::~DialogAction(){
90 k.outset_frame(l.margin(vbox, 5)),
91 Session::instance()->style()
94 vbox->append(l.hcenter(k.inset_frame(l.margin(k.label(label), 10))));
98 k.push_button(accept,
new DialogAction(d,
true)),
100 k.push_button(cancel,
new DialogAction(d,
false))
107 ok = oc_post_dialog(d, x, y);
118 k.outset_frame(l.margin(vbox, 5)),
119 Session::instance()->style()
122 vbox->append(l.hcenter(k.inset_frame(l.margin(k.label(label), 10))));
125 k.push_button(
"Continue",
new DialogAction(d,
true))
131 oc_post_dialog(d, x, y);
136 static bool ok_if_already_exists(
const char* s,
Window* w) {
138 sprintf(buf,
"%s already exists: Write?", s);
142 static void open_fail(
const char* s,
Window* w,
const char* io) {
144 sprintf(buf,
"Couldn't open %s for %sing", s, io);
150 if (obuf.open(s, Input)) {
152 if (!ok_if_already_exists(s, w)) {
157 if (obuf.open(s, Append)) {
160 open_fail(s, w,
"writ");
170 if (obuf.open(s, Input)) {
175 open_fail(s, w,
"read");
188 if (sscanf(buf,
"%f%f", &x1, &y1) == 2) {
192 continue_dialog(
"Invalid entry: Enter pair of numbers separated by space.", w);
204 style->attribute(
"caption", caption);
211 ok = oc_post_dialog(d, x,y);
231 fe_->select(0, fe_->text()->length());
240 Dialog::dismiss(accept);
247 WidgetKit& widgets = *WidgetKit::instance();
248 DialogKit& dialogs = *DialogKit::instance();
249 LayoutKit& layout = *LayoutKit::instance();
254 style->find_attribute(
"caption", caption);
255 style->find_attribute(
"accept", accept);
256 style->find_attribute(
"cancel", cancel);
262 layout.flexible(vb,
fil, 0),
276 fd->
s_ = *fe->text();
278 vb->append(layout.flexible(widgets.label(caption)));
279 vb->append(layout.vglue(10));
282 vb->append(layout.vglue(10));
285 vb->append(layout.vglue(10));
288 hb->append(layout.hglue(20,
fil, 20));
289 hb->append(widgets.default_button(accept,
new DialogAction(fd,
true)));
290 hb->append(layout.hglue(5));
291 hb->append(widgets.push_button(cancel,
new DialogAction(fd,
false)));
292 hb->append(layout.hglue(20,
fil, 20));
345 class LabelChooserAction :
public Action {
347 LabelChooserAction(
GLabel*);
348 virtual ~LabelChooserAction();
360 style->attribute(
"caption", caption);
362 LabelChooserAction* lca =
new LabelChooserAction(gl);
363 Button* b = k.check_box(
"vfixed", lca);
364 lca->state(b->state());
369 ok = oc_post_dialog(d, x, y);
377 LabelChooserAction::LabelChooserAction(
GLabel* gl) {
382 LabelChooserAction::~LabelChooserAction() {
390 ts_->set(TelltaleState::is_chosen,
false);
392 ts_->set(TelltaleState::is_chosen,
true);
397 if (ts_->test(TelltaleState::is_chosen)) {
399 gl_->vfixed(gl_->scale());
403 gl_->fixed(gl_->scale());
417 const char* cancel) {
422 d_ =
new OcGlyphDialog(
423 k.outset_frame(l.margin(vbox, 5)),
424 Session::instance()->style()
427 vbox->append(l.hcenter(l.hflexible(l.margin(k.label(label), 10),
fil, 0)));
428 vbox->append(l.hcenter(
this));
433 k.push_button(accept,
new DialogAction(d_,
true)),
435 k.push_button(cancel,
new DialogAction(d_,
false))
442 ok = oc_post_dialog(d_, 400., 400.);
450 OcGlyphDialog::~OcGlyphDialog() {}
452 const Event*
e = h.event();
457 body()->pick(c, a, depth + 1, h);
461 Dialog::pick(c, a, depth, h);
bool ok_to_write(const String &, Window *w=NULL)
FieldDialog(Glyph *, Style *)
static double inside(void *)
virtual void cancel(FieldEditor *)
char ** hoc_pgargstr(int narg)
static philox4x32_key_t k
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_DOUBLE_SEND_STRREF(name, obj)
Object **(* nrnpy_gui_helper_)(const char *name, Object *obj)
void hoc_boolean_dialog()
virtual void accept(FieldEditor *)
const char * string() const
bool var_pair_chooser(const char *, float &x, float &y, Window *w=NULL, Coord x1=400., Coord y1=400.)
void hoc_assign_str(char **cpp, const char *buf)
static bool label_chooser(const char *, char *, GLabel *, Coord x=400., Coord y=400.)
double(* nrnpy_object_to_double_)(Object *)
#define TRY_GUI_REDIRECT_DOUBLE(name, obj)
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...
void hoc_continue_dialog()
virtual void unref() const
bool ok_to_read(const String &, Window *w=NULL)
const String * text() const
static FieldDialog * field_dialog_instance(const char *, Style *, Glyph *extra=NULL)
bool str_chooser(const char *, char *, Window *w=NULL, Coord x=400., Coord y=400.)
bool dialog_dismiss(bool b)
void continue_dialog(const char *label, Window *w=NULL, Coord x=400., Coord y=400.)
bool boolean_dialog(const char *label, const char *accept, const char *cancel, Window *w=NULL, Coord x=400., Coord y=400.)
virtual void dismiss(bool accept)
virtual bool dialog(const char *label, const char *accept, const char *cancel)