40 typedef map<string, AW_window*>
WinMap;
55 : awar_name(awar_name_)
59 virtual const char *get_macro_id()
const = 0;
60 virtual const char *get_title()
const = 0;
69 WinMap::iterator found = window_map.find(awar_name);
70 if (found == window_map.end()) {
71 AW_window_simple *aws =
new AW_window_simple;
73 aws->load_xfig(
"select_simple.fig");
81 aws->create_button(
"CLOSE",
"CLOSE",
"C");
85 window_map[awar_name] = aws;
89 found->second->activate();
95 WinMap SelectionListSpec::window_map;
111 char *ali_type_match;
115 ali_type_match(nulldup(ali_type_match_))
119 GBDATA *gb_presets = get_gbd();
126 char *alignment_type =
GBT_read_string(gb_alignment,
"alignment_type");
129 if (!alignment_type) alignment_type =
ARB_strdup(
"<undef>");
133 if (!*str) insert(alignment_name, alignment_name);
135 free(alignment_type);
136 free(alignment_name);
142 freedup(ali_type_match, new_ali_type_match);
149 string ali_type_match;
160 ali_type_match(ali_type_match_)
164 const char *
get_title()
const {
return "Select alignment"; }
178 (
new ALI_sellst_spec(varname, gb_main, ali_type_match))->createButton(aws);
201 if (!tree_names.
empty()) {
202 int maxTreeNameLen = 0;
203 for (
int i = 0; tree_names[i]; ++i) {
204 const char *
tree = tree_names[i];
205 int len = strlen(tree);
206 if (len>maxTreeNameLen) maxTreeNameLen = len;
208 for (
int i = 0; tree_names[i]; ++i) {
209 const char *
tree = tree_names[i];
240 #define PT_SERVERNAME_LENGTH 23 // that's for buttons
241 #define PT_SERVERNAME_SELLIST_WIDTH 30 // this for lists
244 typedef list<PT_selection*> PT_selections;
246 static PT_selections ptserver_selections;
252 static void refresh_all();
255 PT_selection::PT_selections PT_selection::ptserver_selections;
261 while (pt_servers[count]) count++;
263 for (
int i=0; i<count; i++) {
269 insert(choice, (
long)i);
273 insert_default(
"-undefined-", (
long)-1);
277 PT_selections::iterator end = ptserver_selections.end();
278 for (PT_selections::iterator pts_sel = ptserver_selections.begin(); pts_sel != end; ++pts_sel) {
279 (*pts_sel)->refresh();
289 if (ptserver_selections.empty()) {
293 ptserver_selections.push_back(
this);
311 char *fullname =
NULp;
316 printf(
"awar given to ptserver-selection does not contain a valid index (index=%i)\n", index);
322 if (!fullname) fullname =
ARB_strdup(
"-undefined-");
324 int len = strlen(fullname);
327 int remove = len-maxlength;
330 strcpy(fullname+2, fullname+2+
remove);
343 AW_window_simple *aw_popup =
new AW_window_simple;
345 aw_popup->init(aw_root,
"SELECT_PT_SERVER",
"Select a PT-Server");
348 const char *CLOSE_ID =
"CLOSE";
350 aw_popup->at_newline();
354 aw_popup->at_newline();
356 aw_popup->create_button(CLOSE_ID,
"CLOSE",
"C");
358 aw_popup->window_fit();
370 int ptserver_index = awar_ptserver->
read_int();
372 if (ptserver_index<0) {
374 awar_ptserver->
write_int(ptserver_index);
393 free(awar_buttontext_name);
415 comment = null2empty(cmt);
416 for (
int area = 0; area<2; ++area) {
435 if (!config.
empty()) {
438 int *count =
new int[config.
size()];
439 string *comment =
new string[config.
size()];
441 for (
int c = 0; config[c]; ++c) {
442 maxlen =
max(maxlen,
int(strlen(config[c])));
444 maxcount =
max(maxcount, count[c]);
447 for (
int c = 0; config[c]; ++c) {
449 insert(
GBS_global_string(
"%-*s %*s(%i) %s", maxlen, config[c], (maxdigits-digits),
"", count[c], comment[c].c_str()), config[c]);
459 GBDATA *gb_configuration_data;
486 static SaiSelectionlistFilterCallback std_SAI_filter_cb = makeSaiSelectionlistFilterCallback(
get_SAI_description);
487 return std_SAI_filter_cb;
491 SaiSelectionlistFilterCallback filter_cb;
514 char *res = filter_cb(gb_extended);
520 sel->
sort(
false,
false);
528 SaiSelectionlistFilterCallback filter_cb;
570 for (
size_t i = 0; i<display.
size() && !
error; ++i) {
571 const char *disp = display[i];
573 if (disp[0] ==
'#') {
574 error =
"Invalid character '#' at start of displayed text (won't load)";
577 if (strchr(disp,
',')) {
579 error =
"Invalid character ',' in displayed text (won't load correctly)";
584 const char *val = value[i];
585 if (strcmp(disp, val) == 0) {
602 for (
size_t i = 0; i<line.
size(); ++i) {
603 if (line[i][0] ==
'#')
continue;
605 const char *comma = strchr(line[i],
',');
610 const char *rest = comma+strspn(comma,
" \t");
612 value.put(unescaped);
642 StrArray display, values;
650 if (number_of_lines>0) {
651 display.resize(number_of_lines);
652 values.resize(number_of_lines);
656 if (display.size()<1) {
657 error =
"List is empty (did not save)";
661 error = list2file(display, values, line);
664 error =
"list>file conversion produced nothing (internal error)";
667 FILE *out = fopen(filename,
"wt");
673 for (
size_t i = 0; i<line.size(); ++i) {
674 if (!warning && strchr(line[i],
'\n')) {
675 warning =
"Warning: Saved content contains LFs (loading will be impossible)";
697 "(one possibility is to enter '*.%s')'",
706 for (
int f = 0; fnames[f] && !
error; ++f) {
707 FILE *in = fopen(fnames[f],
"rb");
721 if (!append) sellist->
clear();
724 StrArray displayed, values;
725 error = file2list(lines, displayed, values);
727 int dsize = displayed.size();
728 int vsize = values.size();
730 if (dsize != vsize) {
731 error =
GBS_global_string(
"Error in translation (value/display mismatch: %i!=%i)", vsize, dsize);
734 for (
int i = 0; i<dsize; ++i) {
735 sellist->
insert(displayed[i], values[i]);
798 AW_window_simple *aws =
new AW_window_simple;
803 aws->init(aw_root, window_id, window_title);
804 aws->load_xfig(
"sl_s_box.fig");
806 aws->button_length(10);
810 aws->create_button(
"CANCEL",
"CANCEL",
"C");
814 aws->callback(makeWindowCallback(
save_list_cb, storabsellist));
815 aws->create_button(
"SAVE",
"SAVE",
"S");
818 aws->create_option_menu(awar_line_anz);
819 aws->insert_default_option(
"all",
"a", 0);
820 aws->insert_option (
"10",
"", 10);
821 aws->insert_option (
"50",
"", 50);
822 aws->insert_option (
"100",
"", 100);
823 aws->insert_option (
"500",
"", 500);
824 aws->insert_option (
"1000",
"", 1000);
825 aws->insert_option (
"5000",
"", 5000);
826 aws->insert_option (
"10000",
"", 10000);
827 aws->update_option_menu();
850 AW_window_simple *aws =
new AW_window_simple;
855 aws->init(aw_root, window_id, window_title);
856 aws->load_xfig(
"sl_l_box.fig");
860 aws->create_button(
"CANCEL",
"CANCEL",
"C");
864 aws->callback(makeWindowCallback(
load_list_cb, storabsellist));
865 aws->create_button(
"LOAD",
"LOAD",
"L");
868 aws->label(
"Append?");
869 aws->create_toggle(awar_append);
878 free(awar_base_name);
898 const char *default_directory,
899 const char *file_extension,
900 char **set_file_name_awar,
901 const WindowCallback& ok_cb,
902 const WindowCallback& close_cb,
903 const char *close_button_text)
937 if (set_file_name_awar) {
941 AW_window_simple *aws =
new AW_window_simple;
944 sprintf(title,
"%s %s", action, what);
945 aws->init(aw_root, title, title);
946 aws->load_xfig(
"load_box.fig");
950 aws->callback(close_cb);
951 if (close_button_text) {
952 aws->create_button(
"CLOSE", close_button_text,
"");
955 aws->create_button(
"CLOSE",
"CLOSE",
"C");
962 aws->create_button(
"HELP",
"HELP");
966 aws->callback(ok_cb);
967 aws->create_autosize_button(
"GO", action);
979 #define SUBSET_NOELEM_DISPLAY "<none>"
993 const char *parent_awar_name = parent_sellist.
get_awar_name();
1000 aw_root->awar_string(awar_name);
1003 finish_fill_box(&parent_sellist, sub_sellist);
1010 void callChangedCallback(
bool interactive_change) {
if (subChanged_cb) subChanged_cb(
this, interactive_change, cl_user); }
1015 parent_sellist(parent_sellist_),
1016 subChanged_cb(subChanged_cb_),
1019 callChangedCallback(
false);
1036 if (subset_list->
get_index_of(*listEntry.get_value()) == -1) {
1037 subset_list->
insert(listEntry.get_displayed(), *listEntry.get_value());
1040 finish_fill_box(whole_list, subset_list);
1063 int old_position = subset_list->
get_index_of(selected);
1066 finish_fill_box(whole_list, subset_list);
1074 subset_list->
clear();
1075 finish_fill_box(whole_list, subset_list);
1078 callChangedCallback(
true);
1086 StrArray listContent;
1087 subset_list->
to_array(listContent,
true);
1089 int old_pos = listContent.index_of(selected.
get_string());
1093 case ARM_TOP: new_pos= 0;
break;
1094 case ARM_UP: new_pos= old_pos-1;
break;
1095 case ARM_DOWN: new_pos= old_pos+1;
break;
1098 if (old_pos != new_pos) {
1099 listContent.move(old_pos, new_pos);
1104 callChangedCallback(
true);
1110 typedef std::set<const char*, charpLess> Entries;
1112 bool deleted =
false;
1123 int size = subsel->
size();
1125 for (
int i = 0; i<size; ++i) {
1135 callChangedCallback(
false);
1141 subset_list->
clear();
1143 for (
size_t e = 0; e<values.
size(); ++e) {
1144 const char *value = values[e];
1156 finish_fill_box(&parent_sellist, subset_list);
1157 callChangedCallback(
false);
1185 bool move_rightwards = x_list>x_buttons;
const char * GBS_ptserver_logname(void)
const char * default_select_value() const
char * get_shared_sellist_awar_name(const TypedSelectionList &typedsellst, const char *name)
void insert_default(const char *displayed, const char *value)
GBDATA * GBT_first_SAI(GBDATA *gb_main)
void sort(bool backward, bool case_sensitive)
AW_DB_selection * awt_create_SAI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, const SaiSelectionlistFilterCallback &fcb)
void button_length(int length)
#define PT_SERVERNAME_LENGTH
int get_at_xposition() const
static void collect_subset_cb(AW_window *, awt_collect_mode what, AW_subset_selection *subsel)
static void popup_SelectionListSpec_cb(UNFIXED, const SelectionListSpec *spec)
bool getLine(string &line)
static void reorder_subset_cb(AW_window *, awt_reorder_mode dest, AW_subset_selection *subsel)
void createButton(AW_window *aws) const
SAI_sellst_spec(const char *awar_name_, GBDATA *gb_main_, const SaiSelectionlistFilterCallback &fcb)
void select_element_at(int wanted_index)
const char * get_awar_name() const
const TypedSelectionList & get_typedsellist() const
void insert_default(const char *displayed, const AW_scalar &value)
AW_window * awt_create_load_box(AW_root *aw_root, const char *action, const char *what, const char *default_directory, const char *file_extension, char **set_file_name_awar, const WindowCallback &ok_cb, const WindowCallback &close_cb, const char *close_button_text)
SelectionListSpec(const char *awar_name_)
GBDATA * GB_nextEntry(GBDATA *entry)
AW_selection * awt_create_subset_selection_list(AW_window *aww, AW_selection_list *parent_selection, const char *at_box, const char *at_add, const char *at_sort, bool autocorrect_subselection, SubsetChangedCb subChanged_cb, AW_CL cl_user)
static void arbtcpdat_changed_cb(const char *)
void awt_clear_selection_list_cb(AW_window *, AW_selection_list *sellist)
void AW_create_standard_fileselection(AW_window *aws, const char *awar_prefix)
void AW_edit_notified(const char *path, const FileChangedCallback &callback)
const SaiSelectionlistFilterCallback & awt_std_SAI_filter_cb()
GB_ERROR GB_IO_error(const char *action, const char *filename)
char * ARB_strdup(const char *str)
#define PT_SERVERNAME_SELLIST_WIDTH
void awt_create_ALI_selection_button(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match)
AW_subset_selection(AW_window *aww, AW_selection_list &parent_sellist_, SubsetChangedCb subChanged_cb_, AW_CL cl_user_)
void set_awar_value(const AW_scalar &new_value)
void delete_element_at(int index)
const char * GBS_global_string(const char *templat,...)
void warning(int warning_num, const char *warning_message)
char * AW_get_selected_fullname(AW_root *awr, const char *awar_prefix)
static char * alignment_name
int getConfigInfo(const char *name, string &comment)
AW_DB_selection * awt_create_TREE_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname)
char * GBS_string_eval(const char *insource, const char *icommand)
void AW_POPDOWN(AW_window *window)
char * GBS_escape_string(const char *str, const char *chars_to_escape, char escape_char)
char * ARB_stringdup(const std::string &str)
char * GBS_string_2_key(const char *str)
bool default_is_selected() const
GBDATA * GBT_get_tree_data(GBDATA *gb_main)
char * ARB_strpartdup(const char *start, const char *end)
AW_selection_list * get_sellist() const
void awt_create_SAI_selection_button(GBDATA *gb_main, AW_window *aws, const char *varname, const SaiSelectionlistFilterCallback &fcb)
char * GBS_ptserver_id_to_choice(int i, int showBuild)
AWT_configuration_selection(AW_selection_list *sellist_, GBDATA *gb_configuration_data)
void(* SubsetChangedCb)(AW_selection *, bool interactive_change, AW_CL cl_user)
void insert(const char *displayed, const char *value)
GB_ERROR GB_incur_error_if(bool error_may_occur)
AW_awar * add_callback(const RootCallback &cb)
struct Unfixed_cb_parameter * UNFIXED
void collect_subset_cb(awt_collect_mode what)
void awt_popup_SAI_selection_list(AW_window *, const char *awar_name, GBDATA *gb_main)
void insert(const char *displayed, const AW_scalar &value)
const char * get_title() const
const char * get_string() const
const char * get_macro_id() const
void to_array(StrArray &array, bool values)
GB_ERROR GB_await_error()
static AW_root * SINGLETON
WindowCallback makeHelpCallback(const char *helpfile)
void awt_auto_popdown_cb(AW_root *, AW_window_simple *aw_popup)
char * GBT_read_string(GBDATA *gb_container, const char *fieldpath)
static AW_window * create_PTSERVER_selection_window(AW_root *aw_root, const char *varname)
static void load_list_cb(AW_window *aww, const StorableSelectionList *storabsellist)
void awt_edit_arbtcpdat_cb(AW_window *)
ALI_selection(AW_selection_list *sellist_, GBDATA *gb_presets, const char *ali_type_match_)
const AW_scalar * get_value_at(int index)
GB_TYPES get_awar_type() const
const char * GBT_tree_info_string(GBDATA *gb_main, const char *tree_name, int maxTreeNameLen)
void set_update_callback(sellist_update_cb ucb, AW_CL cl_user)
CONSTEXPR_INLINE int digits(int parts)
void AW_add_inotification(const char *file, const FileChangedCallback &fccb)
GBT_CONFIG_ITEM_TYPE type
AW_DB_selection * awt_create_CONFIG_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname)
const char * get_macro_id() const
const char * get_filter() const
static void refresh_all()
char * get_shared_sellist_awar_base(const TypedSelectionList &typedsellst)
int get_index_of(const AW_scalar &searched_value)
const char * get_comment() const
static void error(const char *msg)
#define NO_CONFIG_SELECTED
void AW_create_fileselection_awars(AW_root *awr, const char *awar_base, const char *directories, const char *filter, const char *file_name)
const char * get_displayed()
void create_print_box_for_selection_lists(AW_window *aw_window, const TypedSelectionList *typedsellist)
const char * default_select_display() const
PT_selection(AW_selection_list *sellist_)
virtual ~SelectionListSpec()
void reorder_subset_cb(awt_reorder_mode dest)
SAI_selection(AW_selection_list *sellist_, GBDATA *gb_sai_data, const SaiSelectionlistFilterCallback &fcb)
AW_awar * awar(const char *awar)
void awt_create_order_buttons(AW_window *aws, awt_orderfun reorder_cb, AW_CL cl_user)
void awt_set_subset_selection_content(AW_selection *subset_sel_, const CharPtrArray &values)
void GBS_read_dir(StrArray &names, const char *dir, const char *mask)
int get_button_length() const
void AW_refresh_fileselection(AW_root *awr, const char *awar_prefix)
void awt_create_PTSERVER_selection_list(AW_window *aws, const char *varname)
AW_window * create_load_box_for_selection_lists(AW_root *aw_root, const StorableSelectionList *storabsellist)
const char * get_title() const
void awt_create_PTSERVER_selection_button(AW_window *aws, const char *varname)
map< string, AW_window * > WinMap
AW_selection_list * awt_create_selection_list_with_input_field(AW_window *aww, const char *awar_name, const char *at_box, const char *at_field)
char * GBS_unescape_string(const char *str, const char *escaped_chars, char escape_char)
AWT_tree_selection(AW_selection_list *sellist_, GBDATA *gb_tree_data)
AW_DB_selection * awt_create_ALI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match)
GBDATA * GBT_next_SAI(GBDATA *gb_sai)
const char *const * GBS_get_arb_tcp_entries(const char *matching)
void create_input_field(const char *awar_name, int columns=0)
fputs(TRACE_PREFIX, stderr)
static void correct_subselection_cb(AW_selection_list *parent_sel, AW_CL cl_subsel)
AW_awar * awar_int(const char *var_name, long default_value=0, AW_default default_file=AW_ROOT_DEFAULT)
void auto_space(int xspace, int yspace)
#define IF_ASSERTION_USED(x)
void awt_create_collect_buttons(AW_window *aws, bool collect_rightwards, awt_collectfun collect_cb, AW_CL cl_user)
const AW_scalar * get_value() const
void delete_entries_missing_in_parent()
static char * get_SAI_description(GBDATA *gb_extended)
void AWT_create_ascii_print_window(AW_root *awr, const char *text_to_print, const char *title=NULp)
const GBT_config_item & nextItem(GB_ERROR &error)
bool GB_is_directory(const char *path)
char * get_content_as_string(long number_of_lines)
const char * get_awar_name() const
AW_selection_list * get_parent_sellist() const
static char * readable_pt_servername(int index, int maxlength)
static void save_list_cb(AW_window *aww, const StorableSelectionList *storabsellist)
AW_selection_list * create_selection_list(const char *awar_name, int columns, int rows)
AW_window * create_save_box_for_selection_lists(AW_root *aw_root, const StorableSelectionList *storabsellist)
void awt_reconfigure_ALI_selection_list(AW_DB_selection *dbsel, const char *ali_type_match)
void GBT_get_tree_names(ConstStrArray &names, GBDATA *gb_main, bool sorted)
char * GB_arbtcpdat_path(void)
static ARB_init_perl_interface init
void aw_message(const char *msg)
const char * get_default_display() const
void GBT_get_configuration_names(ConstStrArray &configNames, GBDATA *gb_main)
GB_ERROR save(const char *filename, long number_of_lines=0) const
static void ptserverlog_changed_cb(const char *)
void AW_create_fileselection(AW_window *aws, const char *awar_prefix, const char *at_prefix, const char *pwd, DirDisplay disp_dirs, bool allow_wildcards)
const char * whats_contained() const
GB_ERROR write_string(const char *aw_string)
const char * get_awar_name(const char *awar_base_name, const char *entry)
const char * get_unique_id() const
AW_DB_selection * create_list(AW_window *aws) const
const AW_scalar * get_default_value() const
GB_ERROR load(const char *filemask, bool append) const
GB_transaction ta(gb_var)
void callback(const WindowCallback &cb)
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
void fill_entries_matching_values(const CharPtrArray &values)
void init_from_array(const CharPtrArray &entries, const char *default_displayed, const char *default_value)
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
GBDATA * GBT_get_presets(GBDATA *gb_main)
GBDATA * GBT_get_SAI_data(GBDATA *gb_main)
static void update_ptserver_button(AW_root *, AW_awar *awar_ptserver, AW_awar *awar_buttontext_name)
GBDATA * GB_search(GBDATA *gbd, const char *fieldpath, GB_TYPES create)
void hide_or_notify(const char *error)
GB_CSTR GBT_get_name_or_description(GBDATA *gb_item)
static GB_ERROR standard_file2list(const CharPtrArray &line, StrArray &display, StrArray &value)
GBDATA * get_gb_main(DbSel db)
static int info[maxsites+1]
void reconfigure(const char *new_ali_type_match)
static GB_ERROR standard_list2file(const CharPtrArray &display, const CharPtrArray &value, StrArray &line)
const char * get_shared_id() const
GB_ERROR write_int(long aw_int)
StorableSelectionList(const TypedSelectionList &tsl_)
GBDATA * GB_entry(GBDATA *father, const char *key)
AW_scalar get_awar_value() const
AW_selection_list * get_sellist()
char * GBS_global_string_copy(const char *templat,...)
ALI_sellst_spec(const char *awar_name_, GBDATA *gb_main_, const char *ali_type_match_)
void create_button(const char *macro_name, AW_label label, const char *mnemonic=NULp, const char *color=NULp)