// ========================================================= //
//                                                           //
//   File      : nds.h                                       //
//   Purpose   : Node Display Setup                          //
//                                                           //
//   Institute of Microbiology (Technical University Munich) //
//   http://www.arb-home.de/                                 //
//                                                           //
// ========================================================= //

#ifndef NDS_H
#define NDS_H

#ifndef ARBDB_BASE_H
#include <arbdb_base.h>
#endif
#ifndef AW_BASE_HXX
#include <aw_base.hxx>
#endif
#ifndef ARB_ASSERT_H
#include <arb_assert.h>
#endif
#ifndef ARBTOOLS_H
#include <arbtools.h>
#endif
#ifndef TREELABELER_H
#include <TreeLabeler.h>
#endif

#define AWAR_SELECT_ACISRT     "tmp/acisrt/select"
#define AWAR_SELECT_ACISRT_PRE "tmp/acisrt/select_pre"

// --------------------------------------------------------------------------------

enum NDS_Type {
    NDS_OUTPUT_LEAFTEXT           = 0, // compress info (no tabbing, separate single fields by comma, completely skip empty fields);   used in: ARB_NTREE-tree-display
    NDS_OUTPUT_LEAFTEXT_UNLIMITED = 1, // like NDS_OUTPUT_LEAFTEXT, but unlimited                                                      used in: ARB_NTREE-tree-export + ARB_DIST-matrix-export
    NDS_OUTPUT_TAB_SEPARATED      = 2, // format info (using 1 tab per column - for easy import into star-calc, excel, etc. );         used in: ARB_NTREE-nds-export + -nds-list-display
    NDS_OUTPUT_COMMA_SEPARATED    = 3, // like NDS_OUTPUT_TAB_SEPARATED, but using commas;                                             used in: ARB_NTREE-nds-export
};

class NDS_Labeler FINAL_TYPE : public TreeLabeler, virtual Noncopyable {
    NDS_Type type;

    mutable class NodeTextBuilder *builder; // pimpl
    NodeTextBuilder& theBuilder(GBDATA *gb_main) const;

public:

    explicit NDS_Labeler(NDS_Type type_);
    virtual ~NDS_Labeler();

    const char *speciesLabel(GBDATA *gb_main, GBDATA *gb_species, TreeNode *species, const char *tree_name) const OVERRIDE;
    const char *groupLabel(GBDATA *gb_main, GBDATA *gb_group, TreeNode *species, const char *tree_name) const OVERRIDE;

    NDS_Type get_NDS_Type() const { return type; }

    long max_columns(GBDATA *gb_main) const;
};

// --------------------------------------------------------------------------------

AW_window *NDS_create_window(AW_root *aw_root, GBDATA *gb_main);
void       NDS_create_vars(AW_root *aw_root, AW_default awdef, GBDATA *gb_main);
void       NDS_popup_select_srtaci_window(AW_window *aww, const char *acisrt_awarname);
char      *NDS_mask_nonprintable_chars(char *inStr);

#else
#error nds.h included twice
#endif // NDS_H
