1 | // =============================================================== // |
---|
2 | // // |
---|
3 | // File : sec_graphic.hxx // |
---|
4 | // Purpose : interface to structure GUI // |
---|
5 | // Time-stamp: <Wed Oct/31/2007 12:16 MET Coder@ReallySoft.de> // |
---|
6 | // // |
---|
7 | // Institute of Microbiology (Technical University Munich) // |
---|
8 | // http://www.arb-home.de/ // |
---|
9 | // // |
---|
10 | // =============================================================== // |
---|
11 | |
---|
12 | |
---|
13 | #ifndef SEC_GRAPHIC_HXX |
---|
14 | #define SEC_GRAPHIC_HXX |
---|
15 | |
---|
16 | #ifndef _STRING_H |
---|
17 | #include "string.h" |
---|
18 | #endif |
---|
19 | #ifndef _CTYPE_H |
---|
20 | #include "ctype.h" |
---|
21 | #endif |
---|
22 | |
---|
23 | #ifndef AWT_CANVAS_HXX |
---|
24 | #include <awt_canvas.hxx> |
---|
25 | #endif |
---|
26 | #ifndef AW_POSITION_HXX |
---|
27 | #include <aw_position.hxx> |
---|
28 | #endif |
---|
29 | |
---|
30 | using namespace AW; |
---|
31 | |
---|
32 | // names for database: |
---|
33 | #define NAME_OF_STRUCT_SEQ "_STRUCT" |
---|
34 | #define NAME_OF_REF_SEQ "_REF" |
---|
35 | |
---|
36 | class SEC_root; |
---|
37 | |
---|
38 | enum SEC_update_request { |
---|
39 | SEC_UPDATE_OK = 0, // no update needed |
---|
40 | SEC_UPDATE_ZOOM_RESET = 1, // zoom reset needed |
---|
41 | SEC_UPDATE_SHOWN_POSITIONS = 2, // recalculation of shown positions needed |
---|
42 | SEC_UPDATE_RECOUNT = 4, // complete relayout needed |
---|
43 | SEC_UPDATE_RELOAD = 8, // reload structure from DB |
---|
44 | }; |
---|
45 | |
---|
46 | class SEC_base; |
---|
47 | |
---|
48 | class SEC_graphic: public AWT_graphic { |
---|
49 | SEC_update_request update_requested; |
---|
50 | char *load_error; // error occurred during load() |
---|
51 | |
---|
52 | protected: |
---|
53 | |
---|
54 | // variables - tree compatibility |
---|
55 | AW_clicked_line rot_cl; |
---|
56 | AW_clicked_text rot_ct; |
---|
57 | AW_clicked_line old_rot_cl; |
---|
58 | |
---|
59 | AW_device *disp_device; // device for recursive functions |
---|
60 | |
---|
61 | GB_ERROR handleKey(AW_event_type event, AW_key_mod key_modifier, AW_key_code key_code, char key_char); |
---|
62 | GB_ERROR handleMouse(AW_device *device, AW_event_type event, int button, AWT_COMMAND_MODE cmd, const Position& world, SEC_base *elem, int abspos); |
---|
63 | |
---|
64 | public: |
---|
65 | |
---|
66 | GBDATA *gb_main; |
---|
67 | AW_root *aw_root; |
---|
68 | SEC_root *sec_root; |
---|
69 | // SEC_bond_def bond; |
---|
70 | |
---|
71 | GBDATA *gb_struct; // used to save the structure |
---|
72 | GBDATA *gb_struct_ref; // used to save reference numbers |
---|
73 | |
---|
74 | mutable long last_saved; // the transaction serial id when we last saved everything |
---|
75 | |
---|
76 | // *********** public section |
---|
77 | SEC_graphic(AW_root *aw_root, GBDATA *gb_main); |
---|
78 | virtual ~SEC_graphic(void); |
---|
79 | |
---|
80 | virtual AW_gc_manager init_devices(AW_window *,AW_device *,AWT_canvas *ntw,AW_CL); |
---|
81 | |
---|
82 | virtual void show(AW_device *device); |
---|
83 | virtual void info(AW_device *device, AW_pos x, AW_pos y, AW_clicked_line *cl, AW_clicked_text *ct); |
---|
84 | virtual void command(AW_device *device, AWT_COMMAND_MODE cmd, int button, AW_key_mod key_modifier, AW_key_code key_code, char key_char, AW_event_type type, |
---|
85 | AW_pos x, AW_pos y, AW_clicked_line *cl, AW_clicked_text *ct); |
---|
86 | |
---|
87 | GB_ERROR load(GBDATA *gb_main, const char *name, AW_CL cd1, AW_CL cd2); // load structure from DB |
---|
88 | GB_ERROR save(GBDATA *gb_main, const char *name, AW_CL cd1, AW_CL cd2); // save structure to DB |
---|
89 | int check_update(GBDATA *gb_main); // perform requested updates |
---|
90 | void update(GBDATA *gb_main); |
---|
91 | |
---|
92 | GB_ERROR write_data_to_db(const char *data, const char *x_string) const; |
---|
93 | GB_ERROR read_data_from_db(char **data, char **x_string) const; |
---|
94 | |
---|
95 | void request_update(SEC_update_request req) { update_requested = static_cast<SEC_update_request>(update_requested|req); } |
---|
96 | }; |
---|
97 | |
---|
98 | // extern SEC_graphic *SEC_GRAPHIC; |
---|
99 | |
---|
100 | |
---|
101 | #endif |
---|