25 #include <X11/cursorfont.h>
43 XtAppProcessEvent(
p_r->context, XtIMAll);
46 XtInputMask pending = XtAppPending(
p_r->context);
48 XtAppProcessEvent(
p_r->context, pending);
49 pending = XtAppPending(
p_r->context);
61 if ((xevent.type != KeyPress) && (xevent.type != KeyRelease))
return NO_EVENT;
68 if (strcmp(varname,
"ARB_PROP") == 0) {
80 AW_default AW_root::load_properties(
const char *default_name) {
99 const char *shown_name = strrchr(default_name,
'/');
100 if (!shown_name) shown_name = default_name;
101 error =
GBS_global_string(
"Error loading properties '%s': %s", shown_name, error);
114 static int fallback_attempt = 0;
117 fputs(error, stderr);
125 if (sys_error) fprintf(stderr,
"Fatal error: %s\n", sys_error);
127 switch (fallback_attempt) {
130 gb_default = load_properties(default_name);
135 gb_default = load_properties(
".FUBAR.arb");
154 AW_root::SINGLETON =
NULp;
159 : tracker(user_tracker),
160 changer_of_variable(
NULp),
161 focus_follows_mouse(
false),
162 number_of_toggle_fields(0),
163 number_of_option_menus(0),
164 disable_callbacks(
false),
165 current_modal_window(
NULp),
169 AW_root::SINGLETON =
this;
173 init_variables(load_properties(propertyFile));
174 init_root(program, no_exit);
176 tracker = user_tracker;
181 #if defined(UNIT_TESTS)
183 : button_sens_list(
NULp),
186 value_changed(
false),
187 changer_of_variable(
NULp),
188 y_correction_for_input_labels(0),
190 focus_follows_mouse(
false),
191 number_of_toggle_fields(0),
192 number_of_option_menus(0),
194 disable_callbacks(
false),
195 current_modal_window(
NULp),
200 color_mode(AW_MONO_COLOR)
203 AW_root::SINGLETON =
this;
205 init_variables(load_properties(propertyFile));
215 tracker = user_tracker;
220 size_t off = strcspn(label,
"/ ");
222 if (label[off] ==
'/') {
238 #if defined(DEVEL_RALF) && 1
265 for (list = button_sens_list; list; list = list->
next) {
266 XtSetSensitive(list->
button, (list->
mask & mask) ? True : False);
279 {
"FontList",
"window/font",
"8x13bold" },
280 {
"background",
"window/background",
"grey" },
281 {
"foreground",
"window/foreground",
"Black", },
282 {
NULp,
"window/color_1",
"red", },
283 {
NULp,
"window/color_2",
"green", },
284 {
NULp,
"window/color_3",
"blue", },
289 void AW_root::init_variables(
AW_default database) {
290 application_database = database;
294 for (
int i=0; aw_fb[i].
awar; ++i) {
301 fprintf(stderr,
"ARB: %s\n", msg);
306 fprintf(stdout,
"ARB: %s\n", msg);
331 void AW_root::init_root(
const char *programname,
bool no_exit) {
334 XFontStruct *fontstruct;
335 const int MAX_FALLBACKS = 30;
336 char *fallback_resources[MAX_FALLBACKS];
340 p_r-> no_exit = no_exit;
344 for (i=0; aw_fb[i].
fb; i++) {
348 fallback_resources[i] =
NULp;
354 p_r->toplevel_widget = XtOpenApplication(&(
p_r->context), programname,
359 applicationShellWidgetClass,
362 for (i=0; fallback_resources[i]; i++) free(fallback_resources[i]);
364 p_r->display = XtDisplay(
p_r->toplevel_widget);
367 printf(
"cannot open display\n");
373 if (!(fontstruct = XLoadQueryFont(
p_r->display, font))) {
374 if (!(fontstruct = XLoadQueryFont(
p_r->display,
"fixed"))) {
375 printf(
"can not load font\n");
381 if (fontstruct->max_bounds.width == fontstruct->min_bounds.width) {
386 + fontstruct->max_bounds.width) / 2;
390 + fontstruct->max_bounds.descent;
393 p_r->fontlist = XmFontListCreate(fontstruct, XmSTRING_DEFAULT_CHARSET);
395 button_sens_list =
NULp;
397 p_r->last_option_menu =
p_r->current_option_menu =
p_r->option_menu_list =
NULp;
398 p_r->last_toggle_field =
p_r->toggle_field_list =
NULp;
399 p_r->last_selection_list =
p_r->selection_list =
NULp;
405 p_r->screen_depth = PlanesOfScreen(XtScreen(
p_r->toplevel_widget));
406 if (
p_r->screen_depth == 1) {
412 p_r->colormap = DefaultColormapOfScreen(XtScreen(
p_r->toplevel_widget));
413 p_r->clock_cursor = XCreateFontCursor(XtDisplay(
p_r->toplevel_widget), XC_watch);
414 p_r->question_cursor = XCreateFontCursor(XtDisplay(
p_r->toplevel_widget), XC_question_arrow);
423 delete tracker; tracker =
NULp;
424 delete button_sens_list; button_sens_list =
NULp;
434 AW_root::SINGLETON =
NULp;
449 void AW_root::create_colormap() {
451 XColor xcolor_returned, xcolor_exakt;
456 const char **awar_2_color;
458 for (color = 0, awar_2_color = aw_awar_2_color;
460 awar_2_color++, color++)
464 fprintf(stderr,
"XAllocColor failed: %s\n", name_of_color);
501 static void install(
AW_root *aw_root,
const TimedCallback& tcb,
unsigned ms, timer_callback tc) {
564 vs =
new AW_awar(
AW_FLOAT, var_name,
"", default_value, default_file,
this);
574 vs =
new AW_awar(
AW_STRING, var_name, default_value, 0.0, default_file,
this);
584 vs =
new AW_awar(
AW_INT, var_name, (
const char *)default_value, 0.0, default_file,
this);
594 vs =
new AW_awar(
AW_POINTER, var_name, (
const char *)default_value, 0.0, default_file,
this);
626 XtAppMainLoop(
p_r->context);
648 bool has_savable_child =
false;
655 if (!is_tmp) has_savable_child =
true;
658 if (!error && !has_savable_child) {
660 made_temp.push_back(gbd);
669 for (DataPointers::iterator mt = made_temp.begin(); mt != made_temp.end() && !
error; ++mt) {
677 GBDATA *gb_prop = application_database;
680 error =
"No properties loaded - won't save";
690 DataPointers made_temp;
GB_ERROR GBK_system(const char *system_command)
XtTimerCallbackProc timer_callback
static GB_ERROR set_parents_with_only_temp_childs_temp(GBDATA *gbd, DataPointers &made_temp)
enum AW_root::@65 color_mode
GBDATA * GB_open(const char *path, const char *opent)
void define_remote_command(class AW_cb *cbs)
AW_root(const char *propertyFile, const char *program, bool no_exit, UserActionTracker *user_tracker)
GBDATA * GB_child(GBDATA *father)
void aw_install_xkeys(Display *display)
long GBS_write_hash(GB_HASH *hs, const char *key, long val)
bool GB_is_temporary(GBDATA *gbd)
void aw_openstatus(const char *title)
GB_HASH * hash_for_windows
GB_ERROR GB_write_string(GBDATA *gbd, const char *s)
AW_awar * label_is_awar(const char *label)
static struct fallbacks aw_fb[]
GB_ERROR save_properties(const char *filename=NULp) __ATTR__USERESULT
void dont_save_awars_with_default_value(GBDATA *gb_db)
AW_window * current_modal_window
char * ARB_strdup(const char *str)
int y_correction_for_input_labels
void aw_status_title(const char *new_title)
const char * GBS_global_string(const char *templat,...)
void AW_normal_cursor(AW_root *awr)
virtual bool is_replaceable() const =0
static void free_action(long action)
GB_HASH * GBS_create_dynaval_hash(long estimated_elements, GB_CASE case_sens, void(*freefun)(long))
void GBK_terminatef(const char *templat,...)
void AW_POPDOWN(AW_window *window)
void add_timed_callback_never_disabled(int ms, const TimedCallback &tcb)
void add_timed_callback(int ms, const TimedCallback &tcb)
AW_cb * search_remote_command(const char *action)
static void dump_stdout(const char *msg)
NOT4PERL gb_getenv_hook GB_install_getenv_hook(gb_getenv_hook hook)
static const char * aw_awar_2_color[]
GB_ERROR GB_push_transaction(GBDATA *gbd)
void AW_clock_cursor(AW_root *awr)
std::list< GBDATA * > DataPointers
static void AW_timer_callback_never_disabled(XtPointer aw_timer_cb_struct, XtIntervalId *)
void setUserActionTracker(UserActionTracker *user_tracker)
static const char * ignore_arb_prop(const char *varname)
GB_HASH * hash_table_for_variables
GB_ERROR GB_clear_temporary(GBDATA *gbd)
GB_ERROR GB_await_error()
static AW_root * SINGLETON
GB_TYPES GB_read_type(GBDATA *gbd)
bool contains(AnyWinCB g)
AW_awar * awar_float(const char *var_name, float default_value=0.0, AW_default default_file=AW_ROOT_DEFAULT)
void process_pending_events()
AW_default check_properties(AW_default aw_props)
void GBS_hash_do_const_loop(const GB_HASH *hs, gb_hash_const_loop_type func, void *client_data)
void GBK_terminate(const char *error) __ATTR__NORETURN
bool is_equal(const AW_cb &other) const
static void AW_timer_callback(XtPointer aw_timer_cb_struct, XtIntervalId *)
unsigned callOrDelayIfDisabled()
static arb_status_implementation AW_status_impl
static void error(const char *msg)
GBDATA * GB_get_root(GBDATA *gbd)
static void awar_set_temp_if_is_default(const char *, long val, void *cl_gb_db)
bool unlink_from_DB(GBDATA *gb_main)
static arb_handlers aw_handlers
void aw_status_subtitle(const char *text)
const char *(* gb_getenv_hook)(const char *varname)
void set_temp_if_is_default(GBDATA *gb_db)
GB_CSTR GB_path_in_ARBLIB(const char *relative_path)
AW_awar * awar_no_error(const char *awar)
end timer stuff
AW_awar * awar(const char *awar)
void aw_root_init_font(Display *tool_d)
GB_ERROR GB_pop_transaction(GBDATA *gbd)
GB_ERROR GB_save_in_arbprop(GBDATA *gb, const char *path, const char *savetype)
static GB_ERROR clear_temp_flags(DataPointers &made_temp)
void unlink_awars_from_DB(GBDATA *gb_main)
GB_CSTR GB_getenv(const char *env)
WindowCallbackSimple AnyWinCB
void aw_update_all_window_geometry_awars(AW_root *awr)
GB_ERROR GB_set_temporary(GBDATA *gbd) __ATTR__USERESULT
static void set_focus_policy(const char *, long cl_aww, void *)
fputs(TRACE_PREFIX, stderr)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
TYPE * ARB_calloc(size_t nelem)
void AW_help_entry_pressed(AW_window *aww)
char * GBK_singlequote(const char *arg)
static void destroy_AW_root()
void apply_focus_policy(bool follow_mouse)
static void aw_message_and_dump_stderr(const char *msg)
static ARB_init_perl_interface init
void ARB_install_handlers(arb_handlers &handlers)
void apply_sensitivity(AW_active mask)
void aw_message(const char *msg)
static void install(AW_root *aw_root, const TimedCallback &tcb, unsigned ms, timer_callback tc)
void aw_status_gauge(double gauge)
void set_cursor(Display *d, Window w, Cursor c)
static void unlink_awar_from_DB(const char *, long cl_awar, void *cl_gb_main)
GB_ERROR GB_no_transaction(GBDATA *gbd) __ATTR__USERESULT
GBDATA * GB_nextChild(GBDATA *child)
AW_ProcessEventType peek_key_event(AW_window *)
GB_transaction ta(gb_var)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
void callAfter(unsigned ms, timer_callback tc)
AW_awar * awar_pointer(const char *var_name, GBDATA *default_value=NULp, AW_default default_file=AW_ROOT_DEFAULT)
void recallOrUninstall(unsigned restart, timer_callback tc)
static gb_getenv_hook orig_hook
long GBS_read_hash(const GB_HASH *hs, const char *key)
void window_hide(AW_window *aww)
char * GBS_global_string_copy(const char *templat,...)
void GB_close(GBDATA *gbd)
GB_HASH * GBS_create_hash(long estimated_elements, GB_CASE case_sens)