ARB
aw_root.hxx
Go to the documentation of this file.
1 #ifndef AW_ROOT_HXX
2 #define AW_ROOT_HXX
3 
4 #ifndef ARBTOOLS_H
5 #include <arbtools.h>
6 #endif
7 #ifndef ARB_ERROR_H
8 #include <arb_error.h>
9 #endif
10 #ifndef CB_H
11 #include <cb.h>
12 #endif
13 #ifndef ATTRIBUTES_H
14 #include <attributes.h>
15 #endif
16 #ifndef AW_BASE_HXX
17 #include "aw_base.hxx" // @@@ remove later
18 #endif
19 
20 #ifndef aw_assert
21 #define aw_assert(bed) arb_assert(bed)
22 #endif
23 
24 #if defined(ASSERTION_USED)
25 #define legal_mask(m) (((m)&AWM_ALL) == (m))
26 #endif // ASSERTION_USED
27 
28 typedef char *AW_error;
29 
30 // asynchronous messages:
31 extern char AW_ERROR_BUFFER[1024];
32 
33 void aw_set_local_message(); // no message window, AWAR_ERROR_MESSAGES instead (used by EDIT4)
34 
35 // Read a string from the user :
36 char *aw_input(const char *title, const char *prompt, const char *default_input);
37 char *aw_input(const char *prompt, const char *default_input);
38 inline char *aw_input(const char *prompt) { return aw_input(prompt, NULp); }
39 
40 char *aw_modal_file_selection(const char *title, const char *dir, const char *def_name, const char *suffix);
41 
42 class AW_root_Motif;
43 class AW_awar;
44 struct AW_buttons_struct;
45 class AW_root_cblist;
46 struct GB_HASH;
47 class AW_cb;
48 
50  NO_EVENT = 0,
53 };
54 
55 void aw_initstatus();
56 
57 // ---------------------------
58 // UserActionTracker
59 
60 class UserActionTracker : virtual Noncopyable {
61  bool tracking;
62 
63 protected:
64  void set_tracking(bool track) { tracking = track; }
65 
66 public:
67  UserActionTracker() : tracking(false) {}
68  virtual ~UserActionTracker() {}
69 
70  bool is_tracking() const { return tracking; }
71 
72  virtual void track_action(const char *action_id) = 0;
73  virtual void track_awar_change(AW_awar *awar) = 0;
74  virtual bool is_replaceable() const = 0;
75 };
77 public:
78  void track_action(const char */*action_id*/) OVERRIDE {}
79  void track_awar_change(AW_awar */*awar*/) OVERRIDE {}
80  bool is_replaceable() const OVERRIDE { return true; }
81 };
82 
83 // -----------------
84 // AW_root
85 
86 class AW_root : virtual Noncopyable {
87  AW_default application_database;
88  AW_buttons_struct *button_sens_list;
89 
90  UserActionTracker *tracker;
91 
92  void create_colormap();
93 
94  void init_variables(AW_default database);
95  void exit_variables();
96 
97  void init_root(const char *programname, bool no_exit);
98  void exit_root();
99  AW_default load_properties(const char *default_name);
100 
101 public:
103 
104  AW_root_Motif *prvt; // Do not use !!!
117 
118  void window_show(); // a window is set to screen
119  void window_hide(AW_window *aww);
120 
121  // the read only public section:
122  short font_width;
123  short font_height;
124  short font_ascent;
126 
127  // the real public section:
128  AW_root(const char *propertyFile, const char *program, bool no_exit, UserActionTracker *user_tracker);
129 #if defined(UNIT_TESTS) // UT_DIFF
130  AW_root(const char *properties, UnittestMock mock); // fake-root for unit-tests (allows access to awar-subsystem)
131 #endif
132  ~AW_root();
133 
134  void setUserActionTracker(UserActionTracker *user_tracker);
135  UserActionTracker *getTracker() { return tracker; }
136 
138 
139  void main_loop();
140 
141  void process_events(); // might block
142  void process_pending_events(); // non-blocking
144 
145  void add_timed_callback(int ms, const TimedCallback& tcb);
146  void add_timed_callback_never_disabled(int ms, const TimedCallback& tcb);
147 
148  AW_awar *awar(const char *awar);
149  AW_awar *awar_no_error(const char *awar);
150 
152 
153  AW_awar *awar_string (const char *var_name, const char *default_value = "", AW_default default_file = AW_ROOT_DEFAULT);
154  AW_awar *awar_int (const char *var_name, long default_value = 0, AW_default default_file = AW_ROOT_DEFAULT);
155  AW_awar *awar_float (const char *var_name, float default_value = 0.0, AW_default default_file = AW_ROOT_DEFAULT);
156  AW_awar *awar_pointer(const char *var_name, GBDATA *default_value = NULp, AW_default default_file = AW_ROOT_DEFAULT);
157 
158  AW_awar *label_is_awar(const char *label); // returns awar, if label refers to one (used by buttons, etc.)
159 
160  void unlink_awars_from_DB(GBDATA *gb_main); // use before calling GB_close for 'gb_main', if you have AWARs in DB
161 
163  return aw_props ? aw_props : application_database;
164  }
165 
166  GB_ERROR save_properties(const char *filename = NULp) __ATTR__USERESULT;
167 
168  // Control sensitivity of buttons etc.:
169  void apply_sensitivity(AW_active mask);
170  void apply_focus_policy(bool follow_mouse);
171  void make_sensitive(Widget w, AW_active mask);
173 
174  void set_active(Widget w, bool active);
175 
176  void track_action(const char *action_id) { tracker->track_action(action_id); }
177  void track_awar_change(AW_awar *changed_awar) { tracker->track_awar_change(changed_awar); }
178 
179  bool is_tracking() const { return tracker->is_tracking(); }
180  UserActionTracker *get_tracker() { return tracker; }
181 
182  void define_remote_command(class AW_cb *cbs);
183  AW_cb *search_remote_command(const char *action);
184 
185 #if defined(DEBUG)
186  size_t callallcallbacks(int mode);
187  class ConstStrArray *get_action_ids();
188 #endif // DEBUG
189 };
190 
192 bool ARB_in_expert_mode(AW_root *awr);
193 inline bool ARB_in_novice_mode(AW_root *awr) { return !ARB_in_expert_mode(awr); }
194 
195 void ARB_declare_global_awars(AW_root *aw_root, AW_default aw_def);
197 
199  ARB_declare_global_awars(aw_root, aw_def);
200  return ARB_bind_global_awars(gb_main);
201 }
202 
204 
205 #else
206 #error aw_root.hxx included twice
207 #endif
208 
209 
void track_action(const char *) OVERRIDE
Definition: aw_root.hxx:78
enum AW_root::@65 color_mode
const char * GB_ERROR
Definition: arb_core.h:25
AW_bitset AW_active
Definition: aw_base.hxx:45
AW_active global_mask
Definition: aw_root.hxx:108
void define_remote_command(class AW_cb *cbs)
Definition: AW_root.cxx:228
bool ARB_global_awars_initialized()
AW_root(const char *propertyFile, const char *program, bool no_exit, UserActionTracker *user_tracker)
Definition: AW_root.cxx:158
bool is_tracking() const
Definition: aw_root.hxx:179
virtual void track_action(const char *action_id)=0
__ATTR__USERESULT_TODO GB_ERROR ARB_init_global_awars(AW_root *aw_root, AW_default aw_def, GBDATA *gb_main)
Definition: aw_root.hxx:198
bool is_tracking() const
Definition: aw_root.hxx:70
GB_HASH * hash_for_windows
Definition: aw_root.hxx:125
bool remove_button_from_sens_list(Widget button)
Definition: AW_window.cxx:3316
AW_awar * label_is_awar(const char *label)
Definition: AW_root.cxx:218
void aw_set_local_message()
Definition: AW_status.cxx:1137
UserActionTracker * get_tracker()
Definition: aw_root.hxx:180
int active_windows
Definition: aw_root.hxx:116
GB_ERROR save_properties(const char *filename=NULp) __ATTR__USERESULT
Definition: AW_root.cxx:675
bool ARB_in_expert_mode(AW_root *awr)
void aw_initstatus()
Definition: AW_status.cxx:966
void dont_save_awars_with_default_value(GBDATA *gb_db)
Definition: AW_root.cxx:605
AW_window * current_modal_window
Definition: aw_root.hxx:115
int y_correction_for_input_labels
Definition: aw_root.hxx:107
virtual bool is_replaceable() const =0
const char * title
Definition: readseq.c:22
AW_root_Motif * prvt
Definition: aw_root.hxx:104
void add_timed_callback_never_disabled(int ms, const TimedCallback &tcb)
Definition: AW_root.cxx:541
void add_timed_callback(int ms, const TimedCallback &tcb)
Definition: AW_root.cxx:538
AW_cb * search_remote_command(const char *action)
Definition: AW_root.cxx:247
char * program_name
Definition: aw_root.hxx:113
void setUserActionTracker(UserActionTracker *user_tracker)
Definition: AW_root.cxx:210
GB_HASH * hash_table_for_variables
Definition: aw_root.hxx:110
char AW_ERROR_BUFFER[1024]
static AW_root * SINGLETON
Definition: aw_root.hxx:102
short font_height
Definition: aw_root.hxx:123
AW_awar * awar_float(const char *var_name, float default_value=0.0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:560
void process_pending_events()
Definition: AW_root.cxx:45
AW_default check_properties(AW_default aw_props)
Definition: aw_root.hxx:162
#define false
Definition: ureadseq.h:13
virtual ~UserActionTracker()
Definition: aw_root.hxx:68
void track_awar_change(AW_awar *changed_awar)
Definition: aw_root.hxx:177
AW_default get_AW_ROOT_DEFAULT()
Definition: aw_root.hxx:203
void set_active(Widget w, bool active)
Definition: AW_window.cxx:3296
int number_of_option_menus
Definition: aw_root.hxx:112
void process_events()
Definition: AW_root.cxx:42
short font_width
Definition: aw_root.hxx:122
void window_show()
Definition: AW_root.cxx:486
bool focus_follows_mouse
Definition: aw_root.hxx:109
bool is_replaceable() const OVERRIDE
Definition: aw_root.hxx:80
AW_awar * awar_no_error(const char *awar)
end timer stuff
Definition: AW_root.cxx:549
bool ARB_in_novice_mode(AW_root *awr)
Definition: aw_root.hxx:193
void set_tracking(bool track)
Definition: aw_root.hxx:64
AW_awar * awar(const char *awar)
Definition: AW_root.cxx:554
short font_ascent
Definition: aw_root.hxx:124
void unlink_awars_from_DB(GBDATA *gb_main)
Definition: AW_root.cxx:635
void main_loop()
Definition: AW_root.cxx:625
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:580
bool disable_callbacks
Definition: aw_root.hxx:114
#define OVERRIDE
Definition: cxxforward.h:112
void apply_focus_policy(bool follow_mouse)
Definition: AW_root.cxx:255
#define __ATTR__USERESULT
Definition: attributes.h:58
void make_sensitive(Widget w, AW_active mask)
Definition: AW_window.cxx:3279
void apply_sensitivity(AW_active mask)
Definition: AW_root.cxx:260
#define NULp
Definition: cxxforward.h:116
UserActionTracker * getTracker()
Definition: aw_root.hxx:135
virtual void track_awar_change(AW_awar *awar)=0
bool value_changed
Definition: aw_root.hxx:105
AW_ProcessEventType peek_key_event(AW_window *)
Definition: AW_root.cxx:54
Widget changer_of_variable
Definition: aw_root.hxx:106
char * aw_input(const char *title, const char *prompt, const char *default_input)
Definition: AW_modal.cxx:251
char * AW_error
Definition: aw_root.hxx:28
GBDATA * gb_main
Definition: adname.cxx:32
#define __ATTR__USERESULT_TODO
Definition: attributes.h:103
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
char * aw_modal_file_selection(const char *title, const char *dir, const char *def_name, const char *suffix)
Definition: AW_modal.cxx:310
AW_awar * awar_pointer(const char *var_name, GBDATA *default_value=NULp, AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:590
int number_of_toggle_fields
Definition: aw_root.hxx:111
void track_awar_change(AW_awar *) OVERRIDE
Definition: aw_root.hxx:79
void ARB_declare_global_awars(AW_root *aw_root, AW_default aw_def)
#define AW_ROOT_DEFAULT
Definition: aw_base.hxx:106
struct _WidgetRec * Widget
Definition: aw_base.hxx:48
void window_hide(AW_window *aww)
Definition: AW_root.cxx:477
GB_ERROR ARB_bind_global_awars(GBDATA *gb_main) __ATTR__USERESULT
void track_action(const char *action_id)
Definition: aw_root.hxx:176
const char * label
~AW_root()
Definition: AW_root.cxx:422
AW_ProcessEventType
Definition: aw_root.hxx:49