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 | |
---|
21 | AW_window *AWT_create_IUPAC_info_window(AW_root *aw_root) { |
---|
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..", |
---|
56 | AW_ADVICE_TOGGLE, |
---|
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; |
---|
68 | GBT_split_string(compressor, GB_get_supported_compression_flags(true), "=, ", SPLIT_DROPEMPTY); |
---|
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 | } |
---|
87 | void AWT_console(AW_window*) { |
---|
88 | AWT_system_cb(GBS_global_string("%s &", GB_getenvARB_XTERM())); |
---|
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 | |
---|