ARB
input_mask.hxx
Go to the documentation of this file.
1 // ==================================================================== //
2 // //
3 // File : input_mask.hxx //
4 // Purpose : General input masks //
5 // //
6 // //
7 // Coded by Ralf Westram (coder@reallysoft.de) in August 2001 //
8 // Copyright Department of Microbiology (Technical University Munich) //
9 // //
10 // Visit our web site at: http://www.arb-home.de/ //
11 // //
12 // //
13 // ==================================================================== //
14 
15 #ifndef INPUT_MASK_HXX
16 #define INPUT_MASK_HXX
17 
18 #ifndef _GLIBCXX_STRING
19 #include <string>
20 #endif
21 #ifndef AW_BASE_HXX
22 #include <aw_base.hxx>
23 #endif
24 #ifndef CB_H
25 #include <cb.h>
26 #endif
27 
28 
35 
37 };
38 
39 // -------------------------------------
40 // class awt_item_type_selector
41 // -------------------------------------
42 // awt_item_type_selector is an interface for specific item-types
43 //
44 // derive from awt_item_type_selector to get the functionality for
45 // other item types.
46 //
47 // (implemented for Species in nt_item_type_species_selector (see NTREE/NT_extern.cxx) )
48 //
49 
51 private:
52  awt_item_type my_type;
53 public:
54  awt_item_type_selector(awt_item_type for_type) : my_type(for_type) {}
56 
57  awt_item_type get_item_type() const { return my_type; }
58 
59  // add/remove callbacks to awars (i.e. to AWAR_SPECIES_NAME)
60  void add_awar_callbacks(AW_root *root, const RootCallback& cb) const;
61  void remove_awar_callbacks(AW_root *root, const RootCallback& cb) const;
62 
63  // returns the current item
64  virtual GBDATA *current(AW_root *root, GBDATA *gb_main) const = 0;
65 
66  // returns the keypath for items
67  virtual const char *getKeyPath() const = 0;
68 
69  // returns the name of an awar containing the name of the current item
70  virtual const char *get_self_awar() const = 0;
71 
72  // returns the maximum length of the name of the current item
73  virtual size_t get_self_awar_content_length() const = 0;
74 };
75 
76 typedef void (*AWT_OpenMaskWindowCallback)(AW_window* aww, int id, GBDATA *gb_main);
77 
78 awt_item_type AWT_getItemType(const std::string& itemtype_name);
79 void AWT_create_mask_submenu(class AW_window_menu_modes *awm, awt_item_type wanted_item_type, AWT_OpenMaskWindowCallback open_mask_window_cb, GBDATA *gb_main);
81 
82 // open database viewer using input-mask-file
83 GB_ERROR AWT_initialize_input_mask(AW_root *root, GBDATA *gb_main, const awt_item_type_selector *sel, const char* mask_name, bool localMask);
84 
85 // ----------------------------------------
86 
87 class awt_input_mask_descriptor FINAL_TYPE {
88 private:
89  char *title; // title of the input mask
90  char *internal_maskname; // starts with 0 for local mask and with 1 for global mask
91  // followed by file name w/o path
92  char *itemtypename; // name of the itemtype
93  bool local_mask; // true if mask file was found in "$ARB_PROP/inputMasks"
94  bool hidden; // if true, mask is NOT shown in Menus
95 
96 public:
97  awt_input_mask_descriptor(const char *title_, const char *maskname_, const char *itemtypename_, bool local, bool hidden_);
98  awt_input_mask_descriptor(const awt_input_mask_descriptor& other);
99  virtual ~awt_input_mask_descriptor();
100 
101  awt_input_mask_descriptor& operator = (const awt_input_mask_descriptor& other);
102 
103  const char *get_title() const { return title; }
104  const char *get_maskname() const { return internal_maskname+1; }
105  const char *get_internal_maskname() const { return internal_maskname; }
106  const char *get_itemtypename() const { return itemtypename; }
107 
108  bool is_local_mask() const { return local_mask; }
109  bool is_hidden() const { return hidden; }
110 };
111 
112 const awt_input_mask_descriptor *AWT_look_input_mask(int id); // id starts with 0; returns 0 if no more masks
113 
114 
115 #else
116 #error input_mask.hxx included twice
117 #endif // INPUT_MASK_HXX
118 
const char * GB_ERROR
Definition: arb_core.h:25
virtual const char * get_self_awar() const =0
awt_item_type get_item_type() const
Definition: input_mask.hxx:57
const char * id
Definition: AliAdmin.cxx:17
virtual size_t get_self_awar_content_length() const =0
return string(buffer, length)
const char * get_title() const
Definition: input_mask.hxx:103
const char * title
Definition: readseq.c:22
void AWT_create_mask_submenu(class AW_window_menu_modes *awm, awt_item_type wanted_item_type, AWT_OpenMaskWindowCallback open_mask_window_cb, GBDATA *gb_main)
#define cb(action)
const awt_input_mask_descriptor * AWT_look_input_mask(int id)
bool is_hidden() const
Definition: input_mask.hxx:109
const char * get_maskname() const
Definition: input_mask.hxx:104
const char * get_internal_maskname() const
Definition: input_mask.hxx:105
const char * get_itemtypename() const
Definition: input_mask.hxx:106
virtual ~awt_item_type_selector()
Definition: input_mask.hxx:55
awt_item_type_selector(awt_item_type for_type)
Definition: input_mask.hxx:54
void(* AWT_OpenMaskWindowCallback)(AW_window *aww, int id, GBDATA *gb_main)
Definition: input_mask.hxx:76
virtual const char * getKeyPath() const =0
virtual GBDATA * current(AW_root *root, GBDATA *gb_main) const =0
void AWT_destroy_input_masks()
static AW_window_menu_modes_opengl * awm
bool is_local_mask() const
Definition: input_mask.hxx:108
xml element
awt_item_type
Definition: input_mask.hxx:29
GB_ERROR AWT_initialize_input_mask(AW_root *root, GBDATA *gb_main, const awt_item_type_selector *sel, const char *mask_name, bool localMask)
void remove_awar_callbacks(AW_root *root, const RootCallback &cb) const
awt_item_type AWT_getItemType(const std::string &itemtype_name)
GBDATA * gb_main
Definition: adname.cxx:32
void add_awar_callbacks(AW_root *root, const RootCallback &cb) const