source: tags/ms_r16q2/AWT/AWT_misc.cxx

Last change on this file was 14561, checked in by westram, 8 years ago
  • fix include error (gtk-branch)
File size: 3.0 KB
Line 
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 <arbdb.h>
16
17#include <aw_root.hxx>
18#include <aw_window.hxx>
19#include <aw_awar.hxx>
20#include <aw_advice.hxx>
21
22AW_window *AWT_create_IUPAC_info_window(AW_root *aw_root) {
23    // Open window showing IUPAC tables
24    static AW_window_simple *aws = NULL;
25    if (!aws) {
26        aws = new AW_window_simple;
27
28        aws->init(aw_root, "SHOW_IUPAC", "IUPAC info");
29        aws->load_xfig("iupac.fig");
30
31        aws->button_length(7);
32
33        aws->at("ok");
34        aws->callback(AW_POPDOWN);
35        aws->create_button("CLOSE", "CLOSE", "O");
36    }
37    return aws;
38}
39
40void AWT_insert_DBsaveType_selector(AW_window *aww, const char *awar_name) {
41    aww->get_root()->awar_string(awar_name, "b"); // default=save binary database
42
43    aww->label("Type ");
44    aww->create_option_menu(awar_name, true);
45    aww->insert_default_option("Binary",          "B", "b");
46    aww->insert_option        ("Bin (+FastLoad)", "F", "bm");
47    aww->insert_option        ("Ascii",           "A", "a");
48    aww->update_option_menu();
49}
50
51static void warn_compression_type(AW_root*, AW_awar *awar_compression) {
52    if (awar_compression->read_char_pntr()[0]) { // not empty
53        AW_advice("Using extra compression is not compatible with older\n"
54                  "arb-versions (prior to arb 6.1)!\n"
55                  "\n"
56                  "Databases will fail to load there..",
57                  AW_ADVICE_TOGGLE,
58                  "Extra database compression warning",
59                  NULL);
60    }
61}
62
63void AWT_insert_DBcompression_selector(AW_window *aww, const char *awar_name) {
64    AW_awar *awar_compression = aww->get_root()->awar_string(awar_name, ""); // default = do not use extra compression
65
66    aww->label("Compression ");
67
68    ConstStrArray compressor;
69    GBT_split_string(compressor, GB_get_supported_compression_flags(true), "=, ", true);
70    arb_assert((compressor.size()%2) == 0); // should contain alternating flag/name entries
71
72    aww->create_option_menu(awar_name, true);
73    aww->insert_default_option("none", "N", "");
74    for (int c = 0; compressor[c]; c += 2) {
75        const char *flag = compressor[c];
76        const char *name = compressor[c+1];
77        arb_assert(strlen(flag) == 1);
78        aww->insert_option(name, NULL, flag);
79    }
80    aww->update_option_menu();
81
82    awar_compression->add_callback(makeRootCallback(warn_compression_type, awar_compression));
83}
Note: See TracBrowser for help on using the repository browser.