ARB
awt_sel_boxes.hxx
Go to the documentation of this file.
1 // ==================================================================== //
2 // //
3 // File : awt_sel_boxes.hxx //
4 // Purpose : //
5 // //
6 // //
7 // Coded by Ralf Westram (coder@reallysoft.de) in May 2005 //
8 // Copyright Department of Microbiology (Technical University Munich) //
9 // //
10 // Visit our web site at: http://www.arb-home.de/ //
11 // //
12 // ==================================================================== //
13 #ifndef AWT_SEL_BOXES_HXX
14 #define AWT_SEL_BOXES_HXX
15 
16 #ifndef _GLIBCXX_STRING
17 #include <string>
18 #endif
19 #ifndef CB_H
20 #include <cb.h>
21 #endif
22 #ifndef AW_WINDOW_HXX
23 #include <aw_window.hxx>
24 #endif
25 
26 class AP_filter;
27 class AW_DB_selection;
28 class AW_selection;
29 class AW_selection_list;
30 struct StrArray;
31 struct ConstStrArray;
32 struct CharPtrArray;
33 struct adfiltercbstruct;
34 
36  AW_selection_list& selection_list;
37 
38  std::string content; // what is contained in the selection list ? (e.g. "probes")
39  std::string filetype_id; // shared by all selection lists with same content type; used as file-extension for save/load
40  std::string unique_id; // a unique id
41 
42 public:
43  TypedSelectionList(const char *filetype_id_, AW_selection_list *selection_list_, const char *content_, const char *unique_id_)
44  : selection_list(*selection_list_),
45  content(content_),
46  filetype_id(filetype_id_),
47  unique_id(unique_id_)
48  {}
49 
50  AW_selection_list *get_sellist() const { return &selection_list; }
51  const char *whats_contained() const { return content.c_str(); }
52  const char *get_unique_id() const { return unique_id.c_str(); }
53  const char *get_shared_id() const { return filetype_id.c_str(); }
54 };
55 
56 DECLARE_CBTYPE_FVV_AND_BUILDERS(SaiSelectionlistFilterCallback, char*, GBDATA*); // generates makeSaiSelectionlistFilterCallback
57 // (result of callback: - NULp if SAI unwanted; heap-allocated selection-list display-string otherwise)
58 const SaiSelectionlistFilterCallback& awt_std_SAI_filter_cb();
59 
60 
61 // -----------------------------------------
62 // various database selection boxes
63 
64 void awt_create_ALI_selection_button(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match);
65 AW_DB_selection *awt_create_ALI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match);
66 void awt_reconfigure_ALI_selection_list(AW_DB_selection *alisel, const char *ali_type_match);
67 
68 AW_DB_selection *awt_create_TREE_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default);
69 
70 void awt_create_PTSERVER_selection_button(AW_window *aws, const char *varname);
71 void awt_create_PTSERVER_selection_list(AW_window *aws, const char *varname);
72 
73 void awt_create_SAI_selection_button(GBDATA *gb_main, AW_window *aws, const char *varname, const SaiSelectionlistFilterCallback& fcb = awt_std_SAI_filter_cb());
74 AW_DB_selection *awt_create_SAI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default, const SaiSelectionlistFilterCallback& fcb = awt_std_SAI_filter_cb());
75 void awt_popup_SAI_selection_list(AW_window *aww, const char *awar_name, GBDATA *gb_main);
76 
77 AW_DB_selection *awt_create_CONFIG_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default);
78 
79 void awt_auto_popdown_cb(AW_root*, AW_window_simple *aw_popup);
80 
81 // ---------------------------
82 // related functions
83 
85 
86 // --------------------------
87 // subset selection
88 
89 typedef void (*SubsetChangedCb)(AW_selection*, bool interactive_change, AW_CL cl_user);
90 AW_selection *awt_create_subset_selection_list(AW_window *aww, AW_selection_list *select_subset_from, const char *at_box, const char *at_add, const char *at_sort, bool autocorrect_subselection = true, SubsetChangedCb subChanged_cb = NULp, AW_CL cl_user = 0);
91 void awt_set_subset_selection_content(AW_selection *subset_sel_, const CharPtrArray& values);
92 
93 // -------------------------------
94 // generic file prompter
95 
97  const char *action,
98  const char *what,
99  const char *default_directory,
100  const char *file_extension,
101  char **set_file_name_awar,
102  const WindowCallback& ok_cb,
103  const WindowCallback& abort_cb = makeWindowCallback(AW_POPDOWN),
104  const char *close_button_text = NULp);
105 
106 // ------------------------------------------
107 // save/load selection list content
108 
109 typedef GB_ERROR (*ssl_to_storage)(const CharPtrArray& display, const CharPtrArray& value, StrArray& line);
110 typedef GB_ERROR (*ssl_from_storage)(const CharPtrArray& line, StrArray& display, StrArray& value);
111 
113  TypedSelectionList tsl;
114  ssl_to_storage list2file;
115  ssl_from_storage file2list;
116 
117 public:
120  : tsl(tsl_),
121  list2file(list2file_),
122  file2list(file2list_)
123  {}
124 
125  const TypedSelectionList& get_typedsellist() const { return tsl; }
126  const char *get_filter() const { return tsl.get_shared_id(); }
127 
128  GB_ERROR save(const char *filename, long number_of_lines = 0) const;
129  GB_ERROR load(const char *filemask, bool append) const;
130 };
131 
134 
135 void create_print_box_for_selection_lists(AW_window *aw_window, const TypedSelectionList *typedsellist);
136 
138 
139 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);
140 
141 #else
142 #error awt_sel_boxes.hxx included twice
143 #endif // AWT_SEL_BOXES_HXX
144 
const char * GB_ERROR
Definition: arb_core.h:25
const SaiSelectionlistFilterCallback & awt_std_SAI_filter_cb()
void awt_edit_arbtcpdat_cb(AW_window *aww)
return string(buffer, length)
const TypedSelectionList & get_typedsellist() const
AW_window * create_load_box_for_selection_lists(AW_root *aw_root, const StorableSelectionList *storabsellist)
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)
void awt_auto_popdown_cb(AW_root *, AW_window_simple *aw_popup)
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
AW_DB_selection * awt_create_SAI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default, const SaiSelectionlistFilterCallback &fcb=awt_std_SAI_filter_cb())
TypedSelectionList(const char *filetype_id_, AW_selection_list *selection_list_, const char *content_, const char *unique_id_)
AW_selection_list * get_sellist() const
void(* SubsetChangedCb)(AW_selection *, bool interactive_change, AW_CL cl_user)
DECLARE_CBTYPE_FVV_AND_BUILDERS(SaiSelectionlistFilterCallback, char *, GBDATA *)
void awt_popup_SAI_selection_list(AW_window *aww, const char *awar_name, GBDATA *gb_main)
void awt_create_ALI_selection_button(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match)
AW_DB_selection * awt_create_CONFIG_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default)
void awt_create_PTSERVER_selection_list(AW_window *aws, const char *varname)
AW_selection * awt_create_subset_selection_list(AW_window *aww, AW_selection_list *select_subset_from, const char *at_box, const char *at_add, const char *at_sort, bool autocorrect_subselection=true, SubsetChangedCb subChanged_cb=NULp, AW_CL cl_user=0)
const char * get_filter() const
void awt_create_SAI_selection_button(GBDATA *gb_main, AW_window *aws, const char *varname, const SaiSelectionlistFilterCallback &fcb=awt_std_SAI_filter_cb())
AW_DB_selection * awt_create_ALI_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, const char *ali_type_match)
GB_ERROR(* ssl_from_storage)(const CharPtrArray &line, StrArray &display, StrArray &value)
void awt_clear_selection_list_cb(AW_window *, AW_selection_list *sellist)
void create_print_box_for_selection_lists(AW_window *aw_window, const TypedSelectionList *typedsellist)
long AW_CL
Definition: cb.h:21
void awt_set_subset_selection_content(AW_selection *subset_sel_, const CharPtrArray &values)
GB_ERROR(* ssl_to_storage)(const CharPtrArray &display, const CharPtrArray &value, StrArray &line)
AW_DB_selection * awt_create_TREE_selection_list(GBDATA *gb_main, AW_window *aws, const char *varname, bool fallback2default)
static int line
Definition: arb_a2ps.c:296
#define NULp
Definition: cxxforward.h:97
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 &abort_cb=makeWindowCallback(AW_POPDOWN), const char *close_button_text=NULp)
GB_ERROR save(const char *filename, long number_of_lines=0) const
StorableSelectionList(const TypedSelectionList &tsl_, ssl_to_storage list2file_, ssl_from_storage file2list_)
const char * whats_contained() const
const char * get_unique_id() const
void awt_create_PTSERVER_selection_button(AW_window *aws, const char *varname)
GB_ERROR load(const char *filemask, bool append) const
GBDATA * gb_main
Definition: adname.cxx:33
AW_window * create_save_box_for_selection_lists(AW_root *aw_root, const StorableSelectionList *storabsellist)
const char * get_shared_id() const
StorableSelectionList(const TypedSelectionList &tsl_)
void awt_reconfigure_ALI_selection_list(AW_DB_selection *alisel, const char *ali_type_match)