ARB
AWT_misc.cxx
Go to the documentation of this file.
1 // ============================================================ //
2 // //
3 // File : AWT_misc.cxx //
4 // Purpose : //
5 // //
6 // Coded by Ralf Westram (coder@reallysoft.de) in July 2015 //
7 // http://www.arb-home.de/ //
8 // //
9 // ============================================================ //
10 
11 #include "awt_misc.hxx"
12 
13 #include <arb_strarray.h>
14 
15 #include <aw_root.hxx>
16 #include <aw_window.hxx>
17 #include <aw_awar.hxx>
18 #include <aw_advice.hxx>
19 #include <aw_msg.hxx>
20 
22  // Open window showing IUPAC tables
23  static AW_window_simple *aws = NULp;
24  if (!aws) {
25  aws = new AW_window_simple;
26 
27  aws->init(aw_root, "SHOW_IUPAC", "IUPAC info");
28  aws->load_xfig("iupac.fig");
29 
30  aws->button_length(7);
31 
32  aws->at("ok");
33  aws->callback(AW_POPDOWN);
34  aws->create_button("CLOSE", "CLOSE", "O");
35  }
36  return aws;
37 }
38 
39 void AWT_insert_DBsaveType_selector(AW_window *aww, const char *awar_name) {
40  aww->get_root()->awar_string(awar_name, "b"); // default=save binary database
41 
42  aww->label("Type ");
43  aww->create_option_menu(awar_name);
44  aww->insert_default_option("Binary", "B", "b");
45  aww->insert_option ("Bin (+FastLoad)", "F", "bm");
46  aww->insert_option ("Ascii", "A", "a");
47  aww->update_option_menu();
48 }
49 
50 static void warn_compression_type(AW_root*, AW_awar *awar_compression) {
51  if (awar_compression->read_char_pntr()[0]) { // not empty
52  AW_advice("Using extra compression is not compatible with older\n"
53  "arb-versions (prior to arb-7.0)!\n"
54  "\n"
55  "Databases will fail to load there..",
57  "Extra database compression warning",
58  NULp);
59  }
60 }
61 
62 void AWT_insert_DBcompression_selector(AW_window *aww, const char *awar_name) {
63  AW_awar *awar_compression = aww->get_root()->awar_string(awar_name, ""); // default = do not use extra compression
64 
65  aww->label("Compression ");
66 
67  ConstStrArray compressor;
69  arb_assert((compressor.size()%2) == 0); // should contain alternating flag/name entries
70 
71  aww->create_option_menu(awar_name);
72  aww->insert_default_option("none", "N", "");
73  for (int c = 0; compressor[c]; c += 2) {
74  const char *flag = compressor[c];
75  const char *name = compressor[c+1];
76  arb_assert(strlen(flag) == 1);
77  aww->insert_option(name, NULp, flag);
78  }
79  aww->update_option_menu();
80 
81  awar_compression->add_callback(makeRootCallback(warn_compression_type, awar_compression));
82 }
83 
84 void AWT_system_cb(AW_window *, const char *command) {
85  aw_message_if(GBK_system(command));
86 }
89 }
90 void AWT_system_in_console_cb(AW_window*, const char *command, XCMD_TYPE exectype) {
91  aw_message_if(GB_xcmd(command, exectype));
92 }
93 
void insert_option(AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color=NULp)
GB_ERROR GBK_system(const char *system_command)
Definition: arb_msg.cxx:571
#define arb_assert(cond)
Definition: arb_assert.h:245
size_t size() const
Definition: arb_strarray.h:85
const char * GBS_global_string(const char *templat,...)
Definition: arb_msg.cxx:203
void AW_advice(const char *message, AW_Advice_Type type, const char *title, const char *corresponding_help)
Show a message box with an advice for the user.
Definition: AW_advice.cxx:160
void AW_POPDOWN(AW_window *window)
Definition: AW_window.cxx:52
XCMD_TYPE
Definition: arbdb.h:115
void update_option_menu()
void AWT_insert_DBcompression_selector(AW_window *aww, const char *awar_name)
Definition: AWT_misc.cxx:62
AW_awar * add_callback(const RootCallback &cb)
Definition: AW_awar.cxx:231
const char * read_char_pntr() const
Definition: AW_awar.cxx:168
AW_window * AWT_create_IUPAC_info_window(AW_root *aw_root)
Definition: AWT_misc.cxx:21
void label(const char *label)
Definition: AW_window.cxx:102
static void warn_compression_type(AW_root *, AW_awar *awar_compression)
Definition: AWT_misc.cxx:50
NOT4PERL GB_ERROR GB_xcmd(const char *cmd, XCMD_TYPE exectype) __ATTR__USERESULT_TODO
Definition: adsocket.cxx:906
void AWT_insert_DBsaveType_selector(AW_window *aww, const char *awar_name)
Definition: AWT_misc.cxx:39
void insert_default_option(AW_label choice_label, const char *mnemonic, const char *var_value, const char *name_of_color=NULp)
long int flag
Definition: f2c.h:39
AW_option_menu_struct * create_option_menu(const char *awar_name)
AW_root * get_root()
Definition: aw_window.hxx:359
#define NULp
Definition: cxxforward.h:116
void AWT_system_in_console_cb(AW_window *, const char *command, XCMD_TYPE exectype)
Definition: AWT_misc.cxx:90
static char * command
Definition: arb_a2ps.c:319
void GBT_split_string(ConstStrArray &dest, const char *namelist, const char *separator, SplitMode mode)
Definition: arb_strarray.h:223
AW_awar * awar_string(const char *var_name, const char *default_value="", AW_default default_file=AW_ROOT_DEFAULT)
Definition: AW_root.cxx:570
GB_CSTR GB_getenvARB_XTERM(void)
Definition: adsocket.cxx:523
const char * GB_get_supported_compression_flags(bool verboose)
void AWT_console(AW_window *)
Definition: AWT_misc.cxx:87
void aw_message_if(GB_ERROR error)
Definition: aw_msg.hxx:21
void AWT_system_cb(AW_window *, const char *command)
Definition: AWT_misc.cxx:84