1 | #ifndef AWT_CANVAS_HXX |
---|
2 | #define AWT_CANVAS_HXX |
---|
3 | |
---|
4 | #ifndef AW_ROOT_HXX |
---|
5 | #include <aw_root.hxx> |
---|
6 | #endif |
---|
7 | #ifndef AW_POSITION_HXX |
---|
8 | #include <aw_position.hxx> |
---|
9 | #endif |
---|
10 | #ifndef AW_WINDOW_HXX |
---|
11 | #include <aw_window.hxx> |
---|
12 | #endif |
---|
13 | |
---|
14 | class AWT_canvas; |
---|
15 | class AW_device; |
---|
16 | class AW_clicked_line; |
---|
17 | class AW_clicked_text; |
---|
18 | |
---|
19 | typedef enum { |
---|
20 | AWT_MODE_NONE, |
---|
21 | AWT_MODE_SELECT, |
---|
22 | AWT_MODE_MARK, |
---|
23 | AWT_MODE_GROUP, |
---|
24 | AWT_MODE_ZOOM, // no command |
---|
25 | AWT_MODE_LZOOM, |
---|
26 | AWT_MODE_MOD, // species info |
---|
27 | AWT_MODE_WWW, |
---|
28 | AWT_MODE_LINE, |
---|
29 | AWT_MODE_ROT, |
---|
30 | AWT_MODE_SPREAD, |
---|
31 | AWT_MODE_SWAP, |
---|
32 | AWT_MODE_LENGTH, |
---|
33 | AWT_MODE_SWAP2, |
---|
34 | AWT_MODE_MOVE, |
---|
35 | AWT_MODE_SETROOT, |
---|
36 | AWT_MODE_RESET, |
---|
37 | |
---|
38 | AWT_MODE_KERNINGHAN, |
---|
39 | AWT_MODE_NNI, |
---|
40 | AWT_MODE_OPTIMIZE, |
---|
41 | AWT_MODE_PROINFO, |
---|
42 | AWT_MODE_STRETCH |
---|
43 | } AWT_COMMAND_MODE; |
---|
44 | |
---|
45 | class AWT_graphic_exports { |
---|
46 | public: |
---|
47 | unsigned int zoom_reset:1; |
---|
48 | unsigned int resize:1; |
---|
49 | unsigned int refresh:1; |
---|
50 | unsigned int save:1; |
---|
51 | unsigned int structure_change:1; // maybe useless |
---|
52 | unsigned int dont_fit_x:1; |
---|
53 | unsigned int dont_fit_y:1; |
---|
54 | unsigned int dont_fit_larger:1; // if xsize>ysize -> dont_fit_x (otherwise dont_fit_y) |
---|
55 | unsigned int dont_scroll:1; |
---|
56 | |
---|
57 | void init(void); // like clear, but resets fit/scroll state |
---|
58 | void clear(void); |
---|
59 | |
---|
60 | short left_offset; |
---|
61 | short right_offset; |
---|
62 | short top_offset; |
---|
63 | short bottom_offset; |
---|
64 | }; |
---|
65 | |
---|
66 | class AWT_graphic { |
---|
67 | friend class AWT_canvas; |
---|
68 | protected: |
---|
69 | AW_rectangle extends; |
---|
70 | int drag_gc; |
---|
71 | public: |
---|
72 | AWT_graphic_exports exports; |
---|
73 | |
---|
74 | AWT_graphic(); |
---|
75 | virtual ~AWT_graphic(); |
---|
76 | |
---|
77 | // pure virtual interface (methods implemented by AWT_nonDB_graphic) |
---|
78 | |
---|
79 | virtual GB_ERROR load(GBDATA *gb_main, const char *name, AW_CL cd1, AW_CL cd2) = 0; |
---|
80 | virtual GB_ERROR save(GBDATA *gb_main, const char *name, AW_CL cd1, AW_CL cd2) = 0; |
---|
81 | virtual int check_update(GBDATA *gb_main) = 0; // check whether anything changed |
---|
82 | virtual void update(GBDATA *gb_main) = 0; // mark the database |
---|
83 | |
---|
84 | // pure virtual interface (rest) |
---|
85 | |
---|
86 | virtual void show(AW_device *device) = 0; |
---|
87 | |
---|
88 | virtual void info(AW_device *device, AW_pos x, AW_pos y, AW_clicked_line *cl, AW_clicked_text *ct) = 0; /* double click */ |
---|
89 | virtual AW_gc_manager init_devices(AW_window *, AW_device *, AWT_canvas *ntw, AW_CL cd2) = 0; |
---|
90 | /* init gcs, if any gc is changed you may call |
---|
91 | AWT_expose_cb(aw_window, ntw, cd2); |
---|
92 | or AWT_resize_cb(aw_window, ntw, cd2); |
---|
93 | The function may return a pointer to a preset window */ |
---|
94 | |
---|
95 | // implemented interface (most are dummies doing nothing): |
---|
96 | |
---|
97 | virtual void push_transaction(GBDATA *gb_main); |
---|
98 | virtual void pop_transaction(GBDATA *gb_main); |
---|
99 | |
---|
100 | virtual void command(AW_device *device, AWT_COMMAND_MODE cmd, |
---|
101 | int button, AW_key_mod key_modifier, AW_key_code key_code, char key_char, |
---|
102 | AW_event_type type, AW_pos x, AW_pos y, |
---|
103 | AW_clicked_line *cl, AW_clicked_text *ct); |
---|
104 | virtual void text(AW_device *device, char *text); |
---|
105 | }; |
---|
106 | |
---|
107 | // a partly implementation of AWT_graphic |
---|
108 | class AWT_nonDB_graphic : public AWT_graphic { |
---|
109 | public: |
---|
110 | AWT_nonDB_graphic() {} |
---|
111 | virtual ~AWT_nonDB_graphic(); |
---|
112 | |
---|
113 | // dummy functions, only spittings out warnings: |
---|
114 | GB_ERROR load(GBDATA *gb_main, const char *name, AW_CL cd1, AW_CL cd2) __ATTR__USERESULT; |
---|
115 | GB_ERROR save(GBDATA *gb_main, const char *name, AW_CL cd1, AW_CL cd2) __ATTR__USERESULT; |
---|
116 | int check_update(GBDATA *gb_main); |
---|
117 | void update(GBDATA *gb_main); |
---|
118 | }; |
---|
119 | |
---|
120 | |
---|
121 | #define EPS 0.0001 /*div zero check*/ |
---|
122 | #define AWT_F_ALL ((AW_active)-1) |
---|
123 | #define CLIP_OVERLAP 15 |
---|
124 | #define AWT_CATCH_LINE 50 /*pixel*/ |
---|
125 | #define AWT_CATCH_TEXT 5 /*pixel*/ |
---|
126 | #define AWT_ZOOM_OUT_STEP 40 /* (pixel) rand um screen */ |
---|
127 | #define AWT_MIN_WIDTH 100 /* Minimum center screen (= screen-offset) */ |
---|
128 | enum { |
---|
129 | AWT_M_LEFT = 1, |
---|
130 | AWT_M_MIDDLE = 2, |
---|
131 | AWT_M_RIGHT = 3 |
---|
132 | }; |
---|
133 | |
---|
134 | enum { |
---|
135 | AWT_d_screen = 1 |
---|
136 | }; |
---|
137 | |
---|
138 | class AWT_canvas { |
---|
139 | public: |
---|
140 | /** too many callbacks -> public **/ |
---|
141 | /** in fact: private **/ |
---|
142 | char *user_awar; |
---|
143 | void init_device(AW_device *device); |
---|
144 | AW_pos trans_to_fit; |
---|
145 | AW_pos shift_x_to_fit; |
---|
146 | AW_pos shift_y_to_fit; |
---|
147 | |
---|
148 | int old_hor_scroll_pos; |
---|
149 | int old_vert_scroll_pos; |
---|
150 | AW_rectangle rect; // screen coordinates |
---|
151 | AW_world worldinfo; // real coordinates without transform. |
---|
152 | AW_world worldsize; |
---|
153 | int zoom_drag_sx; |
---|
154 | int zoom_drag_sy; |
---|
155 | int zoom_drag_ex; |
---|
156 | int zoom_drag_ey; |
---|
157 | int drag; |
---|
158 | AW_clicked_line clicked_line; |
---|
159 | AW_clicked_text clicked_text; |
---|
160 | |
---|
161 | void set_scrollbars(); |
---|
162 | void set_dragEndpoint(int x, int y); |
---|
163 | |
---|
164 | void set_horizontal_scrollbar_position(AW_window *aww, int pos); |
---|
165 | void set_vertical_scrollbar_position(AW_window *aww, int pos); |
---|
166 | |
---|
167 | |
---|
168 | /************* Read only public section : ************/ |
---|
169 | GBDATA *gb_main; |
---|
170 | AW_window *aww; |
---|
171 | AW_root *awr; |
---|
172 | AWT_graphic *tree_disp; |
---|
173 | |
---|
174 | AW_gc_manager gc_manager; |
---|
175 | int drag_gc; |
---|
176 | |
---|
177 | AWT_COMMAND_MODE mode; |
---|
178 | |
---|
179 | /** the real public section **/ |
---|
180 | |
---|
181 | AWT_canvas(GBDATA *gb_main, AW_window *aww, AWT_graphic *awd, AW_gc_manager &gc_manager, const char *user_awar); |
---|
182 | // gc_manager is the preset window |
---|
183 | |
---|
184 | void refresh(); |
---|
185 | void recalc_size(); // Calculate the size of the sb |
---|
186 | void zoom_reset(); // Calculate all |
---|
187 | void zoom(AW_device *device, bool zoomIn, const AW::Rectangle& wanted_part, const AW::Rectangle& current_part); |
---|
188 | |
---|
189 | void set_mode(AWT_COMMAND_MODE mo) { mode = mo; } |
---|
190 | |
---|
191 | void scroll(AW_window *aww, int delta_x, int delta_y, bool dont_update_scrollbars = false); |
---|
192 | void scroll(AW_window *aw, const AW::Vector& delta, bool dont_update_scrollbars = false) { |
---|
193 | scroll(aw, int(delta.x()), int(delta.y()), dont_update_scrollbars); |
---|
194 | } |
---|
195 | }; |
---|
196 | |
---|
197 | void AWT_input_event(AW_window *aww, AWT_canvas *ntw, AW_CL cd2); |
---|
198 | void AWT_motion_event(AW_window *aww, AWT_canvas *ntw, AW_CL cd2); |
---|
199 | void AWT_expose_cb(AW_window *dummy,AWT_canvas *ntw, AW_CL cl2); |
---|
200 | void AWT_resize_cb(AW_window *dummy, AWT_canvas *ntw, AW_CL cl2); |
---|
201 | |
---|
202 | #define AWAR_PRINT_TREE "NT/print/" |
---|
203 | #define AWAR_PRINT_TREE_LANDSCAPE AWAR_PRINT_TREE "landscape" |
---|
204 | #define AWAR_PRINT_TREE_MAGNIFICATION AWAR_PRINT_TREE "magnification" |
---|
205 | #define AWAR_PRINT_TREE_CLIP AWAR_PRINT_TREE "clip" |
---|
206 | #define AWAR_PRINT_TREE_HANDLES AWAR_PRINT_TREE "handles" |
---|
207 | #define AWAR_PRINT_TREE_COLOR AWAR_PRINT_TREE "color" |
---|
208 | #define AWAR_PRINT_TREE_DEST AWAR_PRINT_TREE "dest" |
---|
209 | #define AWAR_PRINT_TREE_PRINTER AWAR_PRINT_TREE "printer" |
---|
210 | #define AWAR_PRINT_TREE_OVERLAP AWAR_PRINT_TREE "overlap" |
---|
211 | #define AWAR_PRINT_TREE_OVERLAP_AMOUNT AWAR_PRINT_TREE "amount" |
---|
212 | |
---|
213 | #define AWAR_PRINT_TREE_TMP "tmp/" AWAR_PRINT_TREE |
---|
214 | #define AWAR_PRINT_TREE_GSIZEX AWAR_PRINT_TREE_TMP "gsizex" // graphic size |
---|
215 | #define AWAR_PRINT_TREE_GSIZEY AWAR_PRINT_TREE_TMP "gsizey" |
---|
216 | #define AWAR_PRINT_TREE_PSIZEX AWAR_PRINT_TREE_TMP "psizex" // print size |
---|
217 | #define AWAR_PRINT_TREE_PSIZEY AWAR_PRINT_TREE_TMP "psizey" |
---|
218 | #define AWAR_PRINT_TREE_SIZEX AWAR_PRINT_TREE_TMP "sizex" // size in pages |
---|
219 | #define AWAR_PRINT_TREE_SIZEY AWAR_PRINT_TREE_TMP "sizey" |
---|
220 | #define AWAR_PRINT_TREE_PAGES AWAR_PRINT_TREE_TMP "pages" |
---|
221 | |
---|
222 | #define AWAR_PRINT_TREE_FILE_BASE AWAR_PRINT_TREE_TMP "file" |
---|
223 | #define AWAR_PRINT_TREE_FILE_NAME AWAR_PRINT_TREE_FILE_BASE "/file_name" |
---|
224 | #define AWAR_PRINT_TREE_FILE_DIR AWAR_PRINT_TREE_FILE_BASE "/directory" |
---|
225 | #define AWAR_PRINT_TREE_FILE_FILTER AWAR_PRINT_TREE_FILE_BASE "/filter" |
---|
226 | |
---|
227 | void AWT_popup_tree_export_window(AW_window *parent_win, AW_CL cl_canvas, AW_CL); |
---|
228 | void AWT_popup_sec_export_window (AW_window *parent_win, AW_CL cl_canvas, AW_CL); |
---|
229 | void AWT_popup_print_window (AW_window *parent_win, AW_CL cl_canvas, AW_CL); |
---|
230 | |
---|
231 | |
---|
232 | #endif |
---|