NEURON
utility.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <InterViews/dialog.h>
4 #include <IV-look/field.h>
5 #include <OS/string.h>
6 #include <InterViews/handler.h>
7 
8 #undef PopupMenu
9 
10 class Window;
11 class FieldEditor;
12 class Menu;
13 class Event;
14 class MenuItem;
15 class PopupWindow;
16 class TelltaleGroup;
17 
18 class FieldDialog: public Dialog {
19  public:
20  static FieldDialog* field_dialog_instance(const char*, Style*, Glyph* extra = NULL);
21  virtual ~FieldDialog();
22  virtual void dismiss(bool accept);
23  const String* text() const {
24  return fe_->text();
25  }
26  virtual void keystroke(const Event& e) {
27  fe_->keystroke(e);
28  }
29  virtual void accept(FieldEditor*);
30  virtual void cancel(FieldEditor*);
31  virtual bool run();
32 
33  private:
36  CopyString s_;
37 };
38 
39 /** true if Style 'dialog_spec_position: on' and fills x,y with
40  * dialog_left_position and dialog_bottom_position.
41  **/
43 
44 bool ok_to_write(const String&, Window* w = NULL);
45 bool ok_to_write(const char*, Window* w = NULL);
46 bool ok_to_read(const String&, Window* w = NULL);
47 bool ok_to_read(const char*, Window* w = NULL);
48 bool boolean_dialog(const char* label,
49  const char* accept,
50  const char* cancel,
51  Window* w = NULL,
52  Coord x = 400.,
53  Coord y = 400.);
54 void continue_dialog(const char* label, Window* w = NULL, Coord x = 400., Coord y = 400.);
55 
56 bool str_chooser(const char*, char*, Window* w = NULL, Coord x = 400., Coord y = 400.);
57 bool var_pair_chooser(const char*,
58  float& x,
59  float& y,
60  Window* w = NULL,
61  Coord x1 = 400.,
62  Coord y1 = 400.);
63 
64 class PopupMenu: public Handler {
65  public:
67  virtual ~PopupMenu();
68  virtual bool event(Event&);
70  Menu* menu() {
71  return menu_;
72  }
73 
74  private:
77  bool grabbed_;
78 };
79 
80 // makes sure menuitem width is size of menu width
81 class K {
82  public:
83  static MenuItem* menu_item(const char*);
84  static MenuItem* radio_menu_item(TelltaleGroup*, const char*);
85  static MenuItem* check_menu_item(const char*);
86 };
87 
#define Window
Definition: _defines.h:330
#define Handler
Definition: _defines.h:144
#define Menu
Definition: _defines.h:174
#define PopupWindow
Definition: _defines.h:208
#define Style
Definition: _defines.h:278
#define Coord
Definition: _defines.h:17
#define Dialog
Definition: _defines.h:92
#define MenuItem
Definition: _defines.h:177
#define Event
Definition: _defines.h:105
#define TelltaleGroup
Definition: _defines.h:292
#define FieldEditor
Definition: _defines.h:109
#define Glyph
Definition: _defines.h:130
FieldDialog(Glyph *, Style *)
virtual void cancel(FieldEditor *)
CopyString s_
Definition: utility.h:36
virtual bool run()
virtual void accept(FieldEditor *)
virtual void keystroke(const Event &e)
Definition: utility.h:26
virtual void dismiss(bool accept)
static FieldDialog * field_dialog_instance(const char *, Style *, Glyph *extra=NULL)
const String * text() const
Definition: utility.h:23
virtual ~FieldDialog()
FieldEditor * fe_
Definition: utility.h:35
Definition: utility.h:81
static MenuItem * radio_menu_item(TelltaleGroup *, const char *)
static MenuItem * menu_item(const char *)
static MenuItem * check_menu_item(const char *)
bool grabbed_
Definition: utility.h:77
virtual bool event(Event &)
void append_item(MenuItem *)
Menu * menu()
Definition: utility.h:70
virtual ~PopupMenu()
Menu * menu_
Definition: utility.h:75
PopupWindow * w_
Definition: utility.h:76
#define NULL
Definition: spdefs.h:105
bool var_pair_chooser(const char *, float &x, float &y, Window *w=NULL, Coord x1=400., Coord y1=400.)
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...
bool str_chooser(const char *, char *, Window *w=NULL, Coord x=400., Coord y=400.)
bool ok_to_write(const String &, Window *w=NULL)
void handle_old_focus()
bool ok_to_read(const String &, Window *w=NULL)
bool boolean_dialog(const char *label, const char *accept, const char *cancel, Window *w=NULL, Coord x=400., Coord y=400.)
void continue_dialog(const char *label, Window *w=NULL, Coord x=400., Coord y=400.)