| 1 | #include <stdio.h> |
|---|
| 2 | #include <stdlib.h> // wegen exit(); |
|---|
| 3 | #include <memory.h> |
|---|
| 4 | // #include <malloc.h> |
|---|
| 5 | #include <string.h> |
|---|
| 6 | |
|---|
| 7 | #include <arbdb.h> |
|---|
| 8 | #include <arbdbt.h> |
|---|
| 9 | |
|---|
| 10 | #include <aw_root.hxx> |
|---|
| 11 | #include <aw_window.hxx> |
|---|
| 12 | #include <aw_awars.hxx> |
|---|
| 13 | #include <aw_preset.hxx> |
|---|
| 14 | #include <adtools.hxx> |
|---|
| 15 | #include <AW_helix.hxx> |
|---|
| 16 | #include <st_window.hxx> |
|---|
| 17 | #include <edit.hxx> |
|---|
| 18 | #include "ed_conf.hxx" |
|---|
| 19 | #include <awt_map_key.hxx> |
|---|
| 20 | #include "gde.hxx" |
|---|
| 21 | #include <awt.hxx> |
|---|
| 22 | |
|---|
| 23 | // #include <fast_aligner.hxx> |
|---|
| 24 | |
|---|
| 25 | AW_HEADER_MAIN |
|---|
| 26 | |
|---|
| 27 | AD_MAIN *ad_main; |
|---|
| 28 | GBDATA *GLOBAL_gb_main; |
|---|
| 29 | ST_ML *st_ml = 0; |
|---|
| 30 | |
|---|
| 31 | void AD_map_viewer(GBDATA *dummy,AD_MAP_VIEWER_TYPE ) |
|---|
| 32 | { |
|---|
| 33 | AWUSE(dummy); |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | struct ed_global { |
|---|
| 37 | AW_helix *helix; |
|---|
| 38 | BI_ecoli_ref *ref; |
|---|
| 39 | ed_key *edk; |
|---|
| 40 | } edg; |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | void aed_expose_info_area(AW_window *aw, AW_CL cd1, AW_CL cd2); |
|---|
| 44 | |
|---|
| 45 | AED_dlist::AED_dlist(){ |
|---|
| 46 | memset((char *)this,0,sizeof(AED_dlist)); |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | AED_root::AED_root(void) { |
|---|
| 50 | ad_main = new AD_MAIN; |
|---|
| 51 | aw_root = new AW_root; |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | AED_window::AED_window(void) { |
|---|
| 57 | memset((char *)this,0,sizeof(AED_window)); |
|---|
| 58 | |
|---|
| 59 | config_window_created = false; |
|---|
| 60 | global_focus_use = false; |
|---|
| 61 | last_slider_position = 0; |
|---|
| 62 | quickdraw = false; |
|---|
| 63 | |
|---|
| 64 | show_dlist_left_side = new AED_dlist_left_side; |
|---|
| 65 | hide_dlist_left_side = new AED_dlist_left_side; |
|---|
| 66 | |
|---|
| 67 | |
|---|
| 68 | area_top = new AED_dlist; |
|---|
| 69 | area_bottom = new AED_dlist; |
|---|
| 70 | area_middle = new AED_dlist; |
|---|
| 71 | |
|---|
| 72 | alignment = new ADT_ALI; |
|---|
| 73 | |
|---|
| 74 | cursor_is_managed = false; |
|---|
| 75 | one_area_entry_is_selected = false; |
|---|
| 76 | |
|---|
| 77 | edit_modus = AED_ALIGN; |
|---|
| 78 | |
|---|
| 79 | info_area_height = 50; |
|---|
| 80 | edit_info_area = false; |
|---|
| 81 | |
|---|
| 82 | selected_area_entry_is_visible = false; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | AED_window::~AED_window(void) { |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | void AED_window::init(AED_root *rootin) { |
|---|
| 91 | root = rootin; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | /***************************************************************************************************************************/ |
|---|
| 97 | /***************************************************************************************************************************/ |
|---|
| 98 | /***************************************************************************************************************************/ |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | static void aed_use_focus(AW_window *aw, AW_CL , AW_CL cd2) { |
|---|
| 102 | //AED_window *aedw = (AED_window *)cd1; |
|---|
| 103 | AW_root *awr = aw->get_root(); |
|---|
| 104 | if (cd2) { |
|---|
| 105 | long pos; |
|---|
| 106 | pos = awr->awar(AWAR_CURSOR_POSITION_LOCAL)->read_int(); |
|---|
| 107 | awr->awar(AWAR_CURSOR_POSITION_LOCAL)->map(AWAR_CURSOR_POSITION); |
|---|
| 108 | awr->awar(AWAR_CURSOR_POSITION_LOCAL)->write_int(pos); |
|---|
| 109 | |
|---|
| 110 | // name = awr->awar(AWAR_SPECIES_NAME_LOCAL)->read_string(); |
|---|
| 111 | //awr->awar(AWAR_SPECIES_NAME_LOCAL)->map(AWAR_SPECIES_NAME); |
|---|
| 112 | //awr->awar(AWAR_SPECIES_NAME_LOCAL)->write_string(name); |
|---|
| 113 | |
|---|
| 114 | }else{ |
|---|
| 115 | //awr->awar(AWAR_SPECIES_NAME_LOCAL)->unmap(); |
|---|
| 116 | awr->awar(AWAR_CURSOR_POSITION_LOCAL)->unmap(); |
|---|
| 117 | } |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | static void set_security(AW_window *aw, AW_CL cd1, AW_CL cd2){ |
|---|
| 121 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 122 | if (!aedw->selected_area_entry) { |
|---|
| 123 | aw_message("Please select a secuence first"); |
|---|
| 124 | return; |
|---|
| 125 | } |
|---|
| 126 | GB_transaction dummy(GLOBAL_gb_main); |
|---|
| 127 | GB_push_my_security(GLOBAL_gb_main); |
|---|
| 128 | GBDATA *gbd = aedw->selected_area_entry->adt_sequence->get_GBDATA(); |
|---|
| 129 | if (gbd) { |
|---|
| 130 | GB_ERROR error = GB_write_security_write(gbd,cd2); |
|---|
| 131 | if (error) aw_message(error); |
|---|
| 132 | }else{ |
|---|
| 133 | aw_message("Cannot change security level when there is no sequence"); |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | GB_pop_my_security(GLOBAL_gb_main); |
|---|
| 137 | aedw->expose(aw); |
|---|
| 138 | } |
|---|
| 139 | static void set_mark_cb(AW_window *aw, AW_CL cd1, AW_CL cd2){ |
|---|
| 140 | AWUSE(aw); |
|---|
| 141 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 142 | GB_transaction dummy(GLOBAL_gb_main); |
|---|
| 143 | AED_area_entry *ae; |
|---|
| 144 | for (ae = aedw->area_top->first; ae ; ae = ae->next) { |
|---|
| 145 | GBDATA *gbd = ae->ad_species->get_GBDATA(); if (!gbd) continue; |
|---|
| 146 | GB_write_flag( gbd, cd2 ); |
|---|
| 147 | } |
|---|
| 148 | for (ae = aedw->area_middle->first; ae ; ae = ae->next) { |
|---|
| 149 | GBDATA *gbd = ae->ad_species->get_GBDATA(); if (!gbd) continue; |
|---|
| 150 | GB_write_flag( gbd, cd2 ); |
|---|
| 151 | } |
|---|
| 152 | for (ae = aedw->area_bottom->first; ae ; ae = ae->next) { |
|---|
| 153 | GBDATA *gbd = ae->ad_species->get_GBDATA(); if (!gbd) continue; |
|---|
| 154 | GB_write_flag( gbd, cd2 ); |
|---|
| 155 | } |
|---|
| 156 | aedw->expose( aw ); |
|---|
| 157 | } |
|---|
| 158 | |
|---|
| 159 | static void set_smark_cb(AW_window *aw, AW_CL cd1, AW_CL cd2){ |
|---|
| 160 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 161 | GB_transaction dummy(GLOBAL_gb_main); |
|---|
| 162 | AED_area_entry *ae = aedw->selected_area_entry; |
|---|
| 163 | if (!ae) return; |
|---|
| 164 | GBDATA *gbd = ae->ad_species->get_GBDATA(); if (!gbd) return; |
|---|
| 165 | GB_write_flag( gbd, cd2 ); |
|---|
| 166 | aedw->expose( aw ); |
|---|
| 167 | } |
|---|
| 168 | |
|---|
| 169 | static void aed_changesecurity(AW_root *dummy, AW_CL cd1) { |
|---|
| 170 | AWUSE(dummy); |
|---|
| 171 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 172 | long level = aedw->root->aw_root->awar(AWAR_SECURITY_LEVEL)->read_int(); |
|---|
| 173 | aedw->root->ad_main->change_security_level((int)level); |
|---|
| 174 | } |
|---|
| 175 | |
|---|
| 176 | |
|---|
| 177 | |
|---|
| 178 | static AD_ERR *aed_adopen(const char *server, AD_MAIN *admain ) { |
|---|
| 179 | return admain->open(server,MAXCACH); |
|---|
| 180 | } |
|---|
| 181 | |
|---|
| 182 | |
|---|
| 183 | /* |
|---|
| 184 | void aed_save(AW_window *aw, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 185 | AWUSE(aw);AWUSE(cd2); |
|---|
| 186 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 187 | aedw->root->ad_main->save("ascii"); |
|---|
| 188 | } |
|---|
| 189 | */ |
|---|
| 190 | |
|---|
| 191 | static void aed_save_bin(AW_window *aw, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 192 | AWUSE(aw);AWUSE(cd2); |
|---|
| 193 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 194 | aedw->root->ad_main->save("bin"); |
|---|
| 195 | } |
|---|
| 196 | |
|---|
| 197 | |
|---|
| 198 | static void aed_quit(AW_window *aw, AW_CL cd1, AW_CL cd2) __ATTR__NORETURN; |
|---|
| 199 | static void aed_quit(AW_window *aw, AW_CL cd1, AW_CL cd2) { |
|---|
| 200 | AWUSE(aw);AWUSE(cd2); |
|---|
| 201 | AED_root *root = (AED_root *)cd1; |
|---|
| 202 | root->ad_main->close(); |
|---|
| 203 | exit(0); |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | void AED_window::calculate_size(AW_window *awmm) |
|---|
| 207 | { |
|---|
| 208 | AW_device *device; |
|---|
| 209 | AW_device *size_device; |
|---|
| 210 | |
|---|
| 211 | device = awmm->get_device (AW_MIDDLE_AREA ); |
|---|
| 212 | device->set_filter(AED_F_ALL); |
|---|
| 213 | size_device = awmm->get_size_device (AW_MIDDLE_AREA ); |
|---|
| 214 | size_device->set_filter(AED_F_ALL); |
|---|
| 215 | |
|---|
| 216 | AED_area_display_struct display_struct; |
|---|
| 217 | display_struct.clear = false; |
|---|
| 218 | display_struct.calc_size = true; |
|---|
| 219 | display_struct.visible_control = true; |
|---|
| 220 | display_struct.top_indent = 0; |
|---|
| 221 | display_struct.bottom_indent = 0; |
|---|
| 222 | display_struct.left_indent = 0; |
|---|
| 223 | display_struct.slider_pos_horizontal = 0; |
|---|
| 224 | display_struct.slider_pos_vertical = 0; |
|---|
| 225 | display_struct.picture_l = 0; |
|---|
| 226 | display_struct.picture_t = 0; |
|---|
| 227 | |
|---|
| 228 | size_device->reset(); |
|---|
| 229 | show_bottom_data( size_device, awmm, display_struct ); |
|---|
| 230 | size_device->get_size_information( &size_information ); |
|---|
| 231 | awmm->set_vertical_scrollbar_bottom_indent( (int)(size_information.b - size_information.t +5.0) ); |
|---|
| 232 | size_device->reset(); |
|---|
| 233 | show_top_data( size_device, awmm, display_struct ); |
|---|
| 234 | size_device->get_size_information( &size_information ); |
|---|
| 235 | awmm->set_vertical_scrollbar_top_indent( (int)size_information.b ); |
|---|
| 236 | |
|---|
| 237 | show_middle_data( size_device, awmm, display_struct ); |
|---|
| 238 | size_device->get_size_information( &size_information ); |
|---|
| 239 | size_information.b += 20; // show helix at bottom |
|---|
| 240 | awmm->tell_scrolled_picture_size( size_information ); |
|---|
| 241 | |
|---|
| 242 | awmm->calculate_scrollbars(); |
|---|
| 243 | this->expose(awmm); |
|---|
| 244 | } |
|---|
| 245 | |
|---|
| 246 | // static void aed_weg(AW_window *aw, AW_CL cd1, AW_CL cd2) { |
|---|
| 247 | // AWUSE(aw);AWUSE(cd2); |
|---|
| 248 | // AED_window *aedw = (AED_window *)cd1; |
|---|
| 249 | // AW_window *awmm = aedw->aww; |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | // if ( aedw->one_area_entry_is_selected ) { |
|---|
| 253 | |
|---|
| 254 | // aedw->selected_area_entry->in_area->remove_entry( aedw->selected_area_entry ); |
|---|
| 255 | // aedw->deselect_area_entry(); |
|---|
| 256 | // aedw->calculate_size(awmm); |
|---|
| 257 | // } |
|---|
| 258 | // } |
|---|
| 259 | |
|---|
| 260 | |
|---|
| 261 | /***************************************************************************************************************************/ |
|---|
| 262 | /***************************************************************************************************************************/ |
|---|
| 263 | /***************************************************************************************************************************/ |
|---|
| 264 | |
|---|
| 265 | void AED_window::select_area_entry( AED_area_entry *area_entry, AW_pos cursor_position ) { |
|---|
| 266 | selected_area_entry = area_entry; |
|---|
| 267 | area_entry->is_selected = true; |
|---|
| 268 | one_area_entry_is_selected = true; |
|---|
| 269 | |
|---|
| 270 | if (cursor_position >=0) cursor = (int)cursor_position; |
|---|
| 271 | root->aw_root->awar( AWAR_SPECIES_NAME_LOCAL)->write_string( area_entry->ad_species->name() ); |
|---|
| 272 | root->aw_root->awar( AWAR_CURSOR_POSITION_LOCAL)->write_int( (int)cursor_position ); |
|---|
| 273 | } |
|---|
| 274 | |
|---|
| 275 | |
|---|
| 276 | |
|---|
| 277 | void AED_window::deselect_area_entry( void ) { |
|---|
| 278 | selected_area_entry->is_selected = false; |
|---|
| 279 | selected_area_entry = NULL; |
|---|
| 280 | one_area_entry_is_selected = false; |
|---|
| 281 | } |
|---|
| 282 | |
|---|
| 283 | |
|---|
| 284 | /***************************************************************************************************************************/ |
|---|
| 285 | /***************************************************************************************************************************/ |
|---|
| 286 | /***************************************************************************************************************************/ |
|---|
| 287 | |
|---|
| 288 | int AED_window::load_data(void) { |
|---|
| 289 | AED_area_entry *help_area_entry; |
|---|
| 290 | int i = 0; |
|---|
| 291 | AD_SPECIES sp; |
|---|
| 292 | AD_SAI ex; |
|---|
| 293 | root->ad_main->begin_transaction(); |
|---|
| 294 | area_top->create_hash(GLOBAL_gb_main,"top_area_species"); |
|---|
| 295 | area_bottom->create_hash(GLOBAL_gb_main,"bottom_area_species"); |
|---|
| 296 | sp.init(root->ad_main); |
|---|
| 297 | ex.init(root->ad_main); |
|---|
| 298 | alignment->init(root->ad_main); |
|---|
| 299 | alignment->ddefault(); |
|---|
| 300 | if (alignment->eof()) { |
|---|
| 301 | aw_popup_exit("Error: Cannot start the EDITOR: Please select a valid alignment"); |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | for (ex.first(); !ex.eof() ;ex.next()) { |
|---|
| 305 | help_area_entry = new AED_area_entry; |
|---|
| 306 | help_area_entry->ad_extended = new AD_SAI; |
|---|
| 307 | help_area_entry->ad_species = (AD_SPECIES *)help_area_entry->ad_extended; |
|---|
| 308 | *(help_area_entry->ad_extended) = ex; |
|---|
| 309 | help_area_entry->ad_container = new AD_CONT; |
|---|
| 310 | help_area_entry->ad_container->init(help_area_entry->ad_extended,(AD_ALI *)alignment); |
|---|
| 311 | if (!help_area_entry->ad_container->eof()) { |
|---|
| 312 | help_area_entry->ad_stat = new AD_STAT ; |
|---|
| 313 | help_area_entry->adt_sequence = new ADT_SEQUENCE; |
|---|
| 314 | help_area_entry->ad_stat->init(help_area_entry->ad_container); |
|---|
| 315 | help_area_entry->adt_sequence->init((ADT_ALI *)alignment,help_area_entry->ad_container); |
|---|
| 316 | }else{ |
|---|
| 317 | help_area_entry->ad_stat = 0; |
|---|
| 318 | help_area_entry->adt_sequence = 0; |
|---|
| 319 | } |
|---|
| 320 | const char *name = help_area_entry->ad_species->name(); |
|---|
| 321 | if (area_top->read_hash(name)){ |
|---|
| 322 | area_top->append(help_area_entry); |
|---|
| 323 | }else if (area_bottom->read_hash(name)){ |
|---|
| 324 | area_bottom->append(help_area_entry); |
|---|
| 325 | }else{ |
|---|
| 326 | area_middle->append(help_area_entry); |
|---|
| 327 | } |
|---|
| 328 | } |
|---|
| 329 | ex.exit(); |
|---|
| 330 | |
|---|
| 331 | for (sp.firstmarked(); !sp.eof() ;sp.nextmarked()) { |
|---|
| 332 | help_area_entry = new AED_area_entry; |
|---|
| 333 | help_area_entry->ad_species = new AD_SPECIES; |
|---|
| 334 | help_area_entry->ad_extended = 0; |
|---|
| 335 | *(help_area_entry->ad_species) = sp; |
|---|
| 336 | help_area_entry->ad_container = new AD_CONT; |
|---|
| 337 | help_area_entry->ad_container->init(help_area_entry->ad_species,(AD_ALI *)alignment); |
|---|
| 338 | if (!help_area_entry->ad_container->eof()) { |
|---|
| 339 | help_area_entry->ad_stat = new AD_STAT ; |
|---|
| 340 | help_area_entry->adt_sequence = new ADT_SEQUENCE; |
|---|
| 341 | help_area_entry->ad_stat->init(help_area_entry->ad_container); |
|---|
| 342 | help_area_entry->adt_sequence->init((ADT_ALI *)alignment,help_area_entry->ad_container); |
|---|
| 343 | }else{ |
|---|
| 344 | help_area_entry->ad_stat = 0; |
|---|
| 345 | help_area_entry->adt_sequence = 0; |
|---|
| 346 | } |
|---|
| 347 | const char *name = help_area_entry->ad_species->name(); |
|---|
| 348 | if (area_top->read_hash(name)){ |
|---|
| 349 | area_top->append(help_area_entry); |
|---|
| 350 | }else if (area_bottom->read_hash(name)){ |
|---|
| 351 | area_bottom->append(help_area_entry); |
|---|
| 352 | }else{ |
|---|
| 353 | area_middle->append(help_area_entry); |
|---|
| 354 | } |
|---|
| 355 | i++; |
|---|
| 356 | if (i== AED_MAX_SPECIES) { |
|---|
| 357 | char buffer[256]; |
|---|
| 358 | sprintf(buffer, " You try to load more than %li Sequences:", AED_MAX_SPECIES); |
|---|
| 359 | if(aw_question(buffer,"LOAD ALL,LOAD 100,EXIT")) |
|---|
| 360 | break; |
|---|
| 361 | } |
|---|
| 362 | } |
|---|
| 363 | sp.exit(); |
|---|
| 364 | edg.helix = new AW_helix(root->aw_root); |
|---|
| 365 | const char *err = edg.helix->init(GLOBAL_gb_main); |
|---|
| 366 | if (err) aw_message(err); |
|---|
| 367 | |
|---|
| 368 | edg.ref = new BI_ecoli_ref(); |
|---|
| 369 | err = edg.ref->init(GLOBAL_gb_main); |
|---|
| 370 | if (err){ |
|---|
| 371 | AW_POPUP_HELP(aww,(AW_CL)"ecoliref.hlp"); |
|---|
| 372 | aw_message(err); |
|---|
| 373 | } |
|---|
| 374 | area_top->optimize_hash(); |
|---|
| 375 | area_bottom->optimize_hash(); |
|---|
| 376 | root->ad_main->commit_transaction(); |
|---|
| 377 | |
|---|
| 378 | return i; |
|---|
| 379 | } |
|---|
| 380 | |
|---|
| 381 | static void reload_helix(AW_window *aww, AED_window *aedw) |
|---|
| 382 | { |
|---|
| 383 | AWUSE(aww); |
|---|
| 384 | const char *err = edg.helix->init(GLOBAL_gb_main); |
|---|
| 385 | if (err) aw_message(err); |
|---|
| 386 | aedw->expose(aww); |
|---|
| 387 | } |
|---|
| 388 | |
|---|
| 389 | static void reload_ref(AW_window *aww) |
|---|
| 390 | { |
|---|
| 391 | AWUSE(aww); |
|---|
| 392 | const char *err = edg.ref->init(GLOBAL_gb_main); |
|---|
| 393 | if (err) aw_message(err); |
|---|
| 394 | } |
|---|
| 395 | /****************************************************************************************************/ |
|---|
| 396 | |
|---|
| 397 | static GB_ERROR species_copy_cb(const char *source, char *dest){ |
|---|
| 398 | GB_ERROR error = 0; |
|---|
| 399 | GBDATA *gb_species_data = GB_search(GLOBAL_gb_main,"species_data",GB_CREATE_CONTAINER); |
|---|
| 400 | GBDATA *gb_species = GBT_find_species_rel_species_data(gb_species_data,source); |
|---|
| 401 | GBDATA *gb_dest = GBT_find_species_rel_species_data(gb_species_data,dest); |
|---|
| 402 | |
|---|
| 403 | if (gb_dest) { |
|---|
| 404 | error = "Sorry: species already exists"; |
|---|
| 405 | }else if (gb_species) { |
|---|
| 406 | gb_dest = GB_create_container(gb_species_data,"species"); |
|---|
| 407 | error = GB_copy(gb_dest,gb_species); |
|---|
| 408 | if (!error) { |
|---|
| 409 | GBDATA *gb_name = |
|---|
| 410 | GB_search(gb_dest,"name",GB_STRING); |
|---|
| 411 | error = GB_write_string(gb_name,dest); |
|---|
| 412 | } |
|---|
| 413 | }else{ |
|---|
| 414 | error = "Please select a species first"; |
|---|
| 415 | } |
|---|
| 416 | |
|---|
| 417 | return error; |
|---|
| 418 | } |
|---|
| 419 | |
|---|
| 420 | /** searches a species and returns TRUE if species exists */ |
|---|
| 421 | |
|---|
| 422 | inline bool does_species_exists(char *name) { |
|---|
| 423 | return GBT_find_species(GLOBAL_gb_main,name) != 0; |
|---|
| 424 | } |
|---|
| 425 | |
|---|
| 426 | |
|---|
| 427 | static void create_new_sequence(AW_window *aww,AED_window *aedw, int do_what) // dowhat = 0 open old 1: create new 2: copy seque |
|---|
| 428 | { |
|---|
| 429 | AED_area_entry *help_area_entry; |
|---|
| 430 | AD_SPECIES sp; |
|---|
| 431 | GB_ERROR error = 0; |
|---|
| 432 | aedw->root->ad_main->begin_transaction(); |
|---|
| 433 | char *spname = aww->get_root()->awar(AWAR_SPECIES_DEST)->read_string(); |
|---|
| 434 | |
|---|
| 435 | do { |
|---|
| 436 | switch (do_what){ |
|---|
| 437 | case 2: |
|---|
| 438 | if (!aedw->selected_area_entry) { |
|---|
| 439 | error = "Error: Please select a sequence first"; |
|---|
| 440 | }else{ |
|---|
| 441 | const char *source = aedw->selected_area_entry->ad_species->name(); |
|---|
| 442 | error = species_copy_cb(source,spname); |
|---|
| 443 | } |
|---|
| 444 | break; |
|---|
| 445 | default: |
|---|
| 446 | if (does_species_exists(spname)) { |
|---|
| 447 | if (do_what == 1) error = GB_export_errorf("Species %s already exists",spname); |
|---|
| 448 | }else{ |
|---|
| 449 | if (do_what == 0) error = GB_export_errorf("Cannot find species %s",spname); |
|---|
| 450 | } |
|---|
| 451 | } |
|---|
| 452 | if (error) break; |
|---|
| 453 | |
|---|
| 454 | sp.init(aedw->root->ad_main); |
|---|
| 455 | AD_ERR *ad_err = sp.create(spname); |
|---|
| 456 | if (!ad_err) { |
|---|
| 457 | help_area_entry = new AED_area_entry; |
|---|
| 458 | help_area_entry->ad_species = new AD_SPECIES; |
|---|
| 459 | help_area_entry->ad_extended = 0; |
|---|
| 460 | *(help_area_entry->ad_species) = sp; |
|---|
| 461 | help_area_entry->ad_container = new AD_CONT; |
|---|
| 462 | if (do_what != 1) { |
|---|
| 463 | help_area_entry->ad_container->init(help_area_entry->ad_species, |
|---|
| 464 | (AD_ALI *)aedw->alignment); |
|---|
| 465 | }else{ |
|---|
| 466 | help_area_entry->ad_container->create(help_area_entry->ad_species, |
|---|
| 467 | (AD_ALI *)aedw->alignment); |
|---|
| 468 | } |
|---|
| 469 | if (!help_area_entry->ad_container->eof()) { |
|---|
| 470 | help_area_entry->ad_stat = new AD_STAT ; |
|---|
| 471 | help_area_entry->adt_sequence = new ADT_SEQUENCE; |
|---|
| 472 | help_area_entry->ad_stat->init(help_area_entry->ad_container); |
|---|
| 473 | help_area_entry->adt_sequence->init((ADT_ALI *)aedw->alignment,help_area_entry->ad_container); |
|---|
| 474 | }else{ |
|---|
| 475 | help_area_entry->ad_stat = 0; |
|---|
| 476 | help_area_entry->adt_sequence = 0; |
|---|
| 477 | } |
|---|
| 478 | help_area_entry->in_area = aedw->area_top; |
|---|
| 479 | aedw->area_top->append(help_area_entry); |
|---|
| 480 | }else{ |
|---|
| 481 | aw_message(ad_err->show()); |
|---|
| 482 | delete ad_err; |
|---|
| 483 | } |
|---|
| 484 | sp.exit(); |
|---|
| 485 | } while (0); |
|---|
| 486 | if (error){ |
|---|
| 487 | aedw->root->ad_main->abort_transaction(); |
|---|
| 488 | aw_message(error); |
|---|
| 489 | }else{ |
|---|
| 490 | aedw->root->ad_main->commit_transaction(); |
|---|
| 491 | aww->get_root()->awar(AWAR_SPECIES_DEST)->write_string(""); |
|---|
| 492 | aww->hide(); |
|---|
| 493 | } |
|---|
| 494 | |
|---|
| 495 | aedw->calculate_size(aedw->aww); |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | |
|---|
| 499 | static AW_window *create_new_seq_window(AW_root *root, AED_window *aedw) |
|---|
| 500 | { |
|---|
| 501 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 502 | aws->init( root, "CREATE_SEQUENCE","CREATE SEQUENCE"); |
|---|
| 503 | aws->load_xfig("ad_al_si.fig"); |
|---|
| 504 | |
|---|
| 505 | aws->callback( (AW_CB0)AW_POPDOWN); |
|---|
| 506 | aws->at("close"); |
|---|
| 507 | aws->create_button("CLOSE", "CLOSE","C"); |
|---|
| 508 | |
|---|
| 509 | aws->at("label"); |
|---|
| 510 | aws->create_autosize_button(0,"Please enter the name\nof the new species"); |
|---|
| 511 | |
|---|
| 512 | aws->at("input"); |
|---|
| 513 | aws->create_input_field(AWAR_SPECIES_DEST,15); |
|---|
| 514 | |
|---|
| 515 | aws->at("ok"); |
|---|
| 516 | aws->callback((AW_CB)create_new_sequence,(AW_CL)aedw,1); |
|---|
| 517 | aws->create_button("GO","GO","g"); |
|---|
| 518 | |
|---|
| 519 | return (AW_window *)aws; |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | static AW_window *create_old_seq_window(AW_root *root, AED_window *aedw) |
|---|
| 523 | { |
|---|
| 524 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 525 | aws->init( root, "OPEN_SEQUENCE", "OPEN SEQUENCE"); |
|---|
| 526 | aws->load_xfig("ad_al_si.fig"); |
|---|
| 527 | |
|---|
| 528 | aws->callback( (AW_CB0)AW_POPDOWN); |
|---|
| 529 | aws->at("close"); |
|---|
| 530 | aws->create_button("CLOSE", "CLOSE","C"); |
|---|
| 531 | |
|---|
| 532 | aws->at("label"); |
|---|
| 533 | aws->create_autosize_button(0,"Please enter the name\nof the existing species"); |
|---|
| 534 | |
|---|
| 535 | aws->at("input"); |
|---|
| 536 | aws->create_input_field(AWAR_SPECIES_DEST,15); |
|---|
| 537 | |
|---|
| 538 | aws->at("ok"); |
|---|
| 539 | aws->callback((AW_CB)create_new_sequence,(AW_CL)aedw,0); |
|---|
| 540 | aws->create_button("GO","GO","G"); |
|---|
| 541 | |
|---|
| 542 | return (AW_window *)aws; |
|---|
| 543 | } |
|---|
| 544 | |
|---|
| 545 | static AW_window *create_new_copy_window(AW_root *root, AED_window *aedw) |
|---|
| 546 | { |
|---|
| 547 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 548 | aws->init( root, "COPY_SELECTED_SEQUENCE", "COPY SELECTED SEQUENCE"); |
|---|
| 549 | aws->load_xfig("ad_al_si.fig"); |
|---|
| 550 | |
|---|
| 551 | aws->callback( (AW_CB0)AW_POPDOWN); |
|---|
| 552 | aws->at("close"); |
|---|
| 553 | aws->create_button("CLOSE", "CLOSE","C"); |
|---|
| 554 | |
|---|
| 555 | aws->at("label"); |
|---|
| 556 | aws->create_autosize_button(0,"Please enter the name\nof the new sequence"); |
|---|
| 557 | |
|---|
| 558 | aws->at("input"); |
|---|
| 559 | aws->create_input_field(AWAR_SPECIES_DEST,15); |
|---|
| 560 | |
|---|
| 561 | aws->at("ok"); |
|---|
| 562 | aws->callback((AW_CB)create_new_sequence,(AW_CL)aedw,2); |
|---|
| 563 | aws->create_button("GO","GO","G"); |
|---|
| 564 | |
|---|
| 565 | return (AW_window *)aws; |
|---|
| 566 | } |
|---|
| 567 | |
|---|
| 568 | /****************************************************************************************************/ |
|---|
| 569 | /****************************************************************************************************/ |
|---|
| 570 | |
|---|
| 571 | void AED_window::make_left_text( char *string, AED_area_entry *area_entry ) { |
|---|
| 572 | AED_left_side *current_entry_of_dlist; |
|---|
| 573 | char tmp[100]; |
|---|
| 574 | char left_text[200]; |
|---|
| 575 | |
|---|
| 576 | left_text[0] = '\0'; |
|---|
| 577 | |
|---|
| 578 | current_entry_of_dlist = show_dlist_left_side->first; |
|---|
| 579 | while ( current_entry_of_dlist ) { |
|---|
| 580 | tmp[0] = '\0'; |
|---|
| 581 | current_entry_of_dlist->make_text( this, area_entry, tmp ); |
|---|
| 582 | strcat( left_text, tmp ); |
|---|
| 583 | current_entry_of_dlist = current_entry_of_dlist->next; |
|---|
| 584 | } |
|---|
| 585 | |
|---|
| 586 | sprintf( string, "%s", left_text ); |
|---|
| 587 | |
|---|
| 588 | } |
|---|
| 589 | |
|---|
| 590 | |
|---|
| 591 | |
|---|
| 592 | void AED_window::show_top_data(AW_device *device, AW_window *awmm, AED_area_display_struct& display_struct ) { |
|---|
| 593 | AW_pos y = 0; |
|---|
| 594 | |
|---|
| 595 | area_top->current = area_top->first; |
|---|
| 596 | while (area_top->current != NULL) { |
|---|
| 597 | this->show_single_top_data( device, awmm, area_top->current, display_struct, &y ); |
|---|
| 598 | area_top->current = area_top->current->next; |
|---|
| 599 | } |
|---|
| 600 | if ( area_top->first ) |
|---|
| 601 | device->invisible( 1, 0, y+5, AED_F_NAME | AED_F_SEQUENCE, (AW_CL)0, (AW_CL)0 ); |
|---|
| 602 | } |
|---|
| 603 | |
|---|
| 604 | |
|---|
| 605 | void AED_window::show_single_top_data(AW_device *device, AW_window *awmm, AED_area_entry *area_entry, AED_area_display_struct& display_struct, AW_pos *y ) { |
|---|
| 606 | AWUSE(awmm); |
|---|
| 607 | AW_pos width; |
|---|
| 608 | AW_pos height; |
|---|
| 609 | AW_rectangle screen; |
|---|
| 610 | char left_text[100]; |
|---|
| 611 | bool tmp; |
|---|
| 612 | |
|---|
| 613 | const AW_font_information *font_information = device->get_font_information(AED_GC_SEQUENCE, 'A'); |
|---|
| 614 | device->get_area_size( &screen ); |
|---|
| 615 | |
|---|
| 616 | if ( display_struct.calc_size ) { |
|---|
| 617 | *y += AED_TOP_LINE + font_information->max_letter.ascent; |
|---|
| 618 | area_entry->absolut_x = 2; |
|---|
| 619 | area_entry->absolut_y = *y; |
|---|
| 620 | } |
|---|
| 621 | |
|---|
| 622 | |
|---|
| 623 | if ( !quickdraw ) { |
|---|
| 624 | |
|---|
| 625 | // display species names on the left side |
|---|
| 626 | device->push_clip_scale(); |
|---|
| 627 | device->set_offset(AW::Vector()); |
|---|
| 628 | device->set_bottom_clip_border( display_struct.top_indent ); |
|---|
| 629 | device->set_right_clip_border( display_struct.left_indent ); |
|---|
| 630 | |
|---|
| 631 | device->invisible( AED_GC_NAME, 0, 0, AED_F_NAME | AED_F_SEQUENCE, (AW_CL)0 ,(AW_CL)0 ); |
|---|
| 632 | |
|---|
| 633 | |
|---|
| 634 | this->make_left_text( left_text, area_entry ); |
|---|
| 635 | |
|---|
| 636 | if( !area_entry->is_selected ) { |
|---|
| 637 | if ( display_struct.clear ) { |
|---|
| 638 | width = strlen( left_text ) * font_information->max_letter.width + 4; |
|---|
| 639 | height = font_information->max_letter.height + 2; |
|---|
| 640 | device->clear_part( 0, *y - font_information->max_letter.ascent - 1, width+1, height+1, AED_F_NAME); |
|---|
| 641 | } |
|---|
| 642 | device->text( AED_GC_NAME, left_text, |
|---|
| 643 | 4, *y, 0.0, AED_F_NAME, (AW_CL)area_entry, AED_F_NAME ); |
|---|
| 644 | } |
|---|
| 645 | else { |
|---|
| 646 | AW_pos help_y = *y + font_information->max_letter.descent + 1; |
|---|
| 647 | |
|---|
| 648 | width = strlen( left_text ) * font_information->max_letter.width + 4; |
|---|
| 649 | height = font_information->max_letter.height + 2; |
|---|
| 650 | |
|---|
| 651 | if ( display_struct.clear ) |
|---|
| 652 | device->clear_part( 0, *y - font_information->max_letter.ascent - 1, width+1, height+1, AED_F_ALL); |
|---|
| 653 | |
|---|
| 654 | if ( (tmp = device->text( AED_GC_SELECTED, left_text, 4, *y, 0.0,AED_F_NAME, (AW_CL)area_entry, AED_F_NAME )) ) { |
|---|
| 655 | device->box(AED_GC_SELECTED, false, 2, help_y-height, width, height, AED_F_ALL, (AW_CL)"box", 0); |
|---|
| 656 | } |
|---|
| 657 | if ( display_struct.visible_control ) { |
|---|
| 658 | selected_area_entry_is_visible = tmp; |
|---|
| 659 | } |
|---|
| 660 | } |
|---|
| 661 | device->pop_clip_scale(); |
|---|
| 662 | } |
|---|
| 663 | |
|---|
| 664 | |
|---|
| 665 | // display sequences of the species on the right side |
|---|
| 666 | device->push_clip_scale(); |
|---|
| 667 | device->set_offset(AW::Vector(display_struct.left_indent - (display_struct.picture_l + display_struct.slider_pos_horizontal), 0)); |
|---|
| 668 | |
|---|
| 669 | device->set_bottom_clip_border( display_struct.top_indent ); |
|---|
| 670 | device->set_left_clip_border( display_struct.left_indent ); |
|---|
| 671 | if ( quickdraw ) { |
|---|
| 672 | device->set_left_clip_border( quickdraw_left_indent ); |
|---|
| 673 | device->set_right_clip_border( quickdraw_right_indent ); |
|---|
| 674 | } |
|---|
| 675 | |
|---|
| 676 | if ( display_struct.clear ) { |
|---|
| 677 | width = screen.r; |
|---|
| 678 | height = font_information->max_letter.height+AED_LINE_SPACING+AED_TOP_LINE; |
|---|
| 679 | device->clear_part((display_struct.picture_l + display_struct.slider_pos_horizontal), |
|---|
| 680 | *y - font_information->max_letter.ascent - 1, |
|---|
| 681 | width+1, |
|---|
| 682 | height+1, AED_F_ALL); |
|---|
| 683 | } |
|---|
| 684 | if (area_entry->adt_sequence) { |
|---|
| 685 | |
|---|
| 686 | if (aed_root.helix_at_extendeds || !area_entry->ad_extended) { |
|---|
| 687 | edg.helix->show_helix( (void*)device, AED_GC_HELIX , |
|---|
| 688 | area_entry->adt_sequence->show_get(), 0.0, |
|---|
| 689 | *y + font_information->max_letter.ascent + AED_CENTER_SPACING, |
|---|
| 690 | AED_F_HELIX, (AW_CL)area_entry, AED_F_HELIX); |
|---|
| 691 | } |
|---|
| 692 | device->text( AED_GC_SEQUENCE, area_entry->adt_sequence->show_get(), 0, *y, 0.0, |
|---|
| 693 | AED_F_SEQUENCE, (AW_CL)area_entry, AED_F_SEQUENCE, area_entry->adt_sequence->show_len() ); } |
|---|
| 694 | device->pop_clip_scale(); |
|---|
| 695 | |
|---|
| 696 | if ( display_struct.calc_size ) { |
|---|
| 697 | area_entry->in_line = *y; |
|---|
| 698 | *y += AED_LINE_SPACING + font_information->max_letter.descent; |
|---|
| 699 | } |
|---|
| 700 | |
|---|
| 701 | device->invisible( AED_GC_NAME, 0, *y, AED_F_NAME | AED_F_SEQUENCE, (AW_CL)0, (AW_CL)0 ); |
|---|
| 702 | } |
|---|
| 703 | |
|---|
| 704 | |
|---|
| 705 | void AED_window::show_middle_data(AW_device *device, AW_window *awmm, AED_area_display_struct& display_struct ) { |
|---|
| 706 | AW_pos y = 0; |
|---|
| 707 | |
|---|
| 708 | area_middle->current = area_middle->first; |
|---|
| 709 | while (area_middle->current != NULL) { |
|---|
| 710 | this->show_single_middle_data(device, awmm, area_middle->current, display_struct, &y ); |
|---|
| 711 | area_middle->current = area_middle->current->next; |
|---|
| 712 | } |
|---|
| 713 | } |
|---|
| 714 | |
|---|
| 715 | // @@@@@ |
|---|
| 716 | static int AED_show_colored_sequence(AW_device *device, int gc, const char *opt_string, size_t /*opt_strlen*/,size_t start, size_t size, |
|---|
| 717 | AW_pos x,AW_pos y, AW_pos /*opt_ascent*/,AW_pos /*opt_descent*/, |
|---|
| 718 | AW_CL cduser, AW_CL cd1, AW_CL cd2){ |
|---|
| 719 | char *sname = (char *)cduser; // The name of the species |
|---|
| 720 | ST_ML_Color *colors = st_ml_get_color_string( st_ml, sname, 0, start, start+size ); |
|---|
| 721 | if (colors) { |
|---|
| 722 | const AW_font_information *font_information = device->get_font_information( AED_GC_SEQUENCE, 'A' ); |
|---|
| 723 | int i; |
|---|
| 724 | long len = start+size; |
|---|
| 725 | AW_pos height = font_information->max_letter.ascent; |
|---|
| 726 | AW_pos width = font_information->max_letter.width; |
|---|
| 727 | AW_pos x2 = x; |
|---|
| 728 | AW_pos y2 = y - height; |
|---|
| 729 | int old_color = AED_GC_0; |
|---|
| 730 | int color = AED_GC_0; |
|---|
| 731 | |
|---|
| 732 | for ( x2 = x, i = start; i < len; i++,x2 += width) { |
|---|
| 733 | color = colors[i] + AED_GC_0; |
|---|
| 734 | if (color > AED_GC_9) color = AED_GC_9; |
|---|
| 735 | if (color != old_color) { // draw till oldcolor |
|---|
| 736 | device->box(old_color, true, x, y2, x2-x, height, -1, cd1,cd2); |
|---|
| 737 | x = x2; |
|---|
| 738 | old_color = color; |
|---|
| 739 | } |
|---|
| 740 | } |
|---|
| 741 | device->box(color, true, x, y2, x2-x, height, -1, cd1,cd2); |
|---|
| 742 | } |
|---|
| 743 | return device->text(gc, opt_string,0,y,0.0, -1,cd1,cd2,size+start); |
|---|
| 744 | } |
|---|
| 745 | |
|---|
| 746 | |
|---|
| 747 | void AED_window::show_single_middle_data(AW_device *device, AW_window *awmm, AED_area_entry *area_entry, AED_area_display_struct& display_struct, AW_pos *y ) { |
|---|
| 748 | AWUSE(awmm); |
|---|
| 749 | AW_pos width; |
|---|
| 750 | AW_pos height; |
|---|
| 751 | AW_rectangle screen; |
|---|
| 752 | char left_text[100]; |
|---|
| 753 | bool tmp; |
|---|
| 754 | |
|---|
| 755 | const AW_font_information *font_information = device->get_font_information( AED_GC_SEQUENCE, 'A' ); |
|---|
| 756 | device->get_area_size( &screen ); |
|---|
| 757 | |
|---|
| 758 | if ( display_struct.calc_size ) { |
|---|
| 759 | *y += AED_TOP_LINE + font_information->max_letter.ascent; |
|---|
| 760 | area_entry->absolut_x = 2; |
|---|
| 761 | area_entry->absolut_y = *y - (display_struct.picture_t + display_struct.slider_pos_vertical) + display_struct.top_indent; |
|---|
| 762 | } |
|---|
| 763 | |
|---|
| 764 | if ( !quickdraw ) { |
|---|
| 765 | |
|---|
| 766 | // display species names on the left side |
|---|
| 767 | device->push_clip_scale(); |
|---|
| 768 | device->set_offset(AW::Vector(0, display_struct.top_indent - (display_struct.picture_t + display_struct.slider_pos_vertical))); |
|---|
| 769 | device->set_top_clip_border( display_struct.top_indent ); |
|---|
| 770 | device->set_bottom_clip_margin( display_struct.bottom_indent ); |
|---|
| 771 | device->set_right_clip_border( display_struct.left_indent ); |
|---|
| 772 | |
|---|
| 773 | |
|---|
| 774 | device->invisible(AED_GC_NAME, 0, 0, AED_F_NAME, (AW_CL)0, (AW_CL)0 ); |
|---|
| 775 | |
|---|
| 776 | |
|---|
| 777 | this->make_left_text( left_text, area_entry ); |
|---|
| 778 | |
|---|
| 779 | if( !area_entry->is_selected ) { |
|---|
| 780 | if ( display_struct.clear ) { |
|---|
| 781 | width = strlen( left_text ) * font_information->max_letter.width + 4; |
|---|
| 782 | height = font_information->max_letter.height + 2; |
|---|
| 783 | device->clear_part( 2, *y - font_information->max_letter.ascent - 1, width+1, height+1, AED_F_NAME); |
|---|
| 784 | } |
|---|
| 785 | device->text( AED_GC_NAME, left_text, 4, *y, 0.0, AED_F_NAME, (AW_CL)area_entry, AED_F_NAME ); |
|---|
| 786 | } |
|---|
| 787 | else { |
|---|
| 788 | AW_pos help_y = *y + font_information->max_letter.descent + 1; |
|---|
| 789 | |
|---|
| 790 | width = strlen( left_text ) * font_information->max_letter.width + 4; |
|---|
| 791 | height = font_information->max_letter.height + 2; |
|---|
| 792 | |
|---|
| 793 | if ( display_struct.clear ) |
|---|
| 794 | device->clear_part( 2, *y - font_information->max_letter.ascent - 1, width+1, height+1, AED_F_ALL); |
|---|
| 795 | |
|---|
| 796 | if ( (tmp = device->text( AED_GC_SELECTED, left_text, 4, *y, 0.0,AED_F_NAME, (AW_CL)area_entry, AED_F_NAME )) ) { |
|---|
| 797 | device->box(AED_GC_SELECTED, false, 2, help_y-height, width, height, AED_F_ALL, (AW_CL)"box", 0); |
|---|
| 798 | } |
|---|
| 799 | if ( display_struct.visible_control ) { |
|---|
| 800 | selected_area_entry_is_visible = tmp; |
|---|
| 801 | } |
|---|
| 802 | } |
|---|
| 803 | device->pop_clip_scale(); |
|---|
| 804 | } |
|---|
| 805 | |
|---|
| 806 | |
|---|
| 807 | // display sequences of the species on the right side |
|---|
| 808 | device->push_clip_scale(); |
|---|
| 809 | device->set_offset(AW::Vector(display_struct.left_indent - (display_struct.picture_l + display_struct.slider_pos_horizontal), |
|---|
| 810 | display_struct.top_indent - (display_struct.picture_t + display_struct.slider_pos_vertical))); |
|---|
| 811 | device->set_top_clip_border( display_struct.top_indent ); |
|---|
| 812 | device->set_bottom_clip_margin( display_struct.bottom_indent ); |
|---|
| 813 | device->set_left_clip_border( display_struct.left_indent ); |
|---|
| 814 | if ( quickdraw ) { |
|---|
| 815 | device->set_left_clip_border( quickdraw_left_indent ); |
|---|
| 816 | device->set_right_clip_border( quickdraw_right_indent ); |
|---|
| 817 | } |
|---|
| 818 | |
|---|
| 819 | |
|---|
| 820 | device->invisible( AED_GC_NAME, 0, 0, AED_F_SEQUENCE, (AW_CL)0, (AW_CL)0 ); |
|---|
| 821 | if ( display_struct.clear ) { |
|---|
| 822 | width = screen.r; |
|---|
| 823 | height = font_information->max_letter.height+AED_LINE_SPACING+AED_TOP_LINE; |
|---|
| 824 | |
|---|
| 825 | device->clear_part( (display_struct.picture_l + display_struct.slider_pos_horizontal), *y - font_information->max_letter.ascent - 1, width+1, height+1, AED_F_ALL); |
|---|
| 826 | } |
|---|
| 827 | |
|---|
| 828 | if (area_entry->adt_sequence) { |
|---|
| 829 | if (aed_root.helix_at_extendeds || !area_entry->ad_extended) { |
|---|
| 830 | edg.helix->show_helix( (void*)device, AED_GC_HELIX , |
|---|
| 831 | area_entry->adt_sequence->show_get(), 0.0, |
|---|
| 832 | *y + font_information->max_letter.ascent + AED_CENTER_SPACING, |
|---|
| 833 | AED_F_HELIX, (AW_CL)area_entry, AED_F_HELIX); |
|---|
| 834 | } |
|---|
| 835 | if (st_ml && st_is_inited(st_ml) && device->type() == AW_DEVICE_SCREEN ){ |
|---|
| 836 | device->text_overlay( AED_GC_SEQUENCE, area_entry->adt_sequence->show_get(), area_entry->adt_sequence->show_len(), |
|---|
| 837 | 0, *y, 0.0, // x, y, alignment |
|---|
| 838 | AED_F_SEQUENCE, // filter |
|---|
| 839 | (AW_CL)area_entry->ad_species->name(), // cl for AED_show_colored_sequence |
|---|
| 840 | (AW_CL)area_entry, AED_F_SEQUENCE, |
|---|
| 841 | 0,0, // use font to get ascent/descent |
|---|
| 842 | AED_show_colored_sequence); // the real drawing function ); |
|---|
| 843 | }else{ |
|---|
| 844 | device->text( AED_GC_SEQUENCE, area_entry->adt_sequence->show_get(), 0, *y, 0.0, |
|---|
| 845 | AED_F_SEQUENCE, (AW_CL)area_entry, AED_F_SEQUENCE, area_entry->adt_sequence->show_len() ); |
|---|
| 846 | } |
|---|
| 847 | } |
|---|
| 848 | |
|---|
| 849 | |
|---|
| 850 | if ( display_struct.calc_size ) { |
|---|
| 851 | area_entry->in_line = *y; |
|---|
| 852 | *y += AED_LINE_SPACING + font_information->max_letter.descent; |
|---|
| 853 | AW_pos help; |
|---|
| 854 | help = ( alignment->len()+50) * font_information->max_letter.width; |
|---|
| 855 | // printf("width %f\n",help); |
|---|
| 856 | device->invisible( AED_GC_NAME, help, *y, AED_F_ALL, (AW_CL)0, (AW_CL)0 ); |
|---|
| 857 | } |
|---|
| 858 | |
|---|
| 859 | |
|---|
| 860 | device->pop_clip_scale(); |
|---|
| 861 | } |
|---|
| 862 | |
|---|
| 863 | |
|---|
| 864 | void AED_window::show_bottom_data(AW_device *device, AW_window *awmm, AED_area_display_struct& display_struct ) { |
|---|
| 865 | AW_pos y = 0; |
|---|
| 866 | |
|---|
| 867 | area_bottom->current = area_bottom->first; |
|---|
| 868 | while ( area_bottom->current != NULL ) { |
|---|
| 869 | this->show_single_bottom_data( device, awmm, area_bottom->current, display_struct, &y ); |
|---|
| 870 | area_bottom->current = area_bottom->current->next; |
|---|
| 871 | } |
|---|
| 872 | } |
|---|
| 873 | |
|---|
| 874 | |
|---|
| 875 | void AED_window::show_single_bottom_data(AW_device *device, AW_window *awmm, AED_area_entry *area_entry, AED_area_display_struct& display_struct, AW_pos *y ) { |
|---|
| 876 | AWUSE(awmm); |
|---|
| 877 | AW_pos width; |
|---|
| 878 | AW_pos height; |
|---|
| 879 | AW_rectangle screen; |
|---|
| 880 | char left_text[100]; |
|---|
| 881 | bool tmp; |
|---|
| 882 | |
|---|
| 883 | const AW_font_information *font_information = device->get_font_information(AED_GC_SEQUENCE, 'A'); |
|---|
| 884 | device->get_area_size( &screen ); |
|---|
| 885 | |
|---|
| 886 | if ( display_struct.calc_size ) { |
|---|
| 887 | *y += AED_TOP_LINE + font_information->max_letter.ascent; |
|---|
| 888 | area_entry->absolut_x = 2; |
|---|
| 889 | area_entry->absolut_y = *y + screen.b - display_struct.bottom_indent; |
|---|
| 890 | } |
|---|
| 891 | |
|---|
| 892 | |
|---|
| 893 | if ( !quickdraw ) { |
|---|
| 894 | |
|---|
| 895 | // display species names on the left side |
|---|
| 896 | device->push_clip_scale(); |
|---|
| 897 | device->set_offset(AW::Vector(0, screen.b - display_struct.bottom_indent)); |
|---|
| 898 | device->set_right_clip_border( display_struct.left_indent ); |
|---|
| 899 | |
|---|
| 900 | device->invisible( AED_GC_NAME, 0, 0, AED_F_ALL, (AW_CL)0, (AW_CL)0 ); |
|---|
| 901 | |
|---|
| 902 | this->make_left_text( left_text, area_entry ); |
|---|
| 903 | |
|---|
| 904 | if( !area_entry->is_selected ) { |
|---|
| 905 | if ( display_struct.clear ) { |
|---|
| 906 | width = strlen( left_text ) * font_information->max_letter.width + 4; |
|---|
| 907 | height = font_information->max_letter.height + 2; |
|---|
| 908 | device->clear_part( 2, *y - font_information->max_letter.ascent - 1, width+1, height+1, AED_F_NAME); |
|---|
| 909 | } |
|---|
| 910 | device->text( AED_GC_NAME, left_text, 4, *y , 0.0, AED_F_NAME, (AW_CL)area_entry, AED_F_NAME ); |
|---|
| 911 | } |
|---|
| 912 | else { |
|---|
| 913 | AW_pos help_y = *y + font_information->max_letter.descent + 1; |
|---|
| 914 | |
|---|
| 915 | width = strlen( left_text ) * font_information->max_letter.width + 4; |
|---|
| 916 | height = font_information->max_letter.height + 2; |
|---|
| 917 | |
|---|
| 918 | if ( display_struct.clear ) |
|---|
| 919 | device->clear_part( 2, *y - font_information->max_letter.ascent - 1, width+1, height+1, AED_F_ALL); |
|---|
| 920 | |
|---|
| 921 | if ( (tmp = device->text( AED_GC_SELECTED, left_text, 4, *y, 0.0,AED_F_NAME, (AW_CL)area_entry, AED_F_NAME )) ) { |
|---|
| 922 | device->box(AED_GC_SELECTED, false, 2, help_y-height, width, height, AED_F_ALL, (AW_CL)"box", 0); |
|---|
| 923 | } |
|---|
| 924 | if ( display_struct.visible_control ) { |
|---|
| 925 | selected_area_entry_is_visible = tmp; |
|---|
| 926 | } |
|---|
| 927 | } |
|---|
| 928 | device->pop_clip_scale(); |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | |
|---|
| 932 | // display sequences of the species on the right side |
|---|
| 933 | device->push_clip_scale(); |
|---|
| 934 | device->set_offset(AW::Vector(display_struct.left_indent - (display_struct.picture_l + display_struct.slider_pos_horizontal), |
|---|
| 935 | screen.b - display_struct.bottom_indent)); |
|---|
| 936 | device->set_left_clip_border( display_struct.left_indent ); |
|---|
| 937 | if ( quickdraw ) { |
|---|
| 938 | device->set_left_clip_border( quickdraw_left_indent ); |
|---|
| 939 | device->set_right_clip_border( quickdraw_right_indent ); |
|---|
| 940 | } |
|---|
| 941 | |
|---|
| 942 | if ( display_struct.clear ) { |
|---|
| 943 | width = screen.r; |
|---|
| 944 | height = font_information->max_letter.height+AED_LINE_SPACING+AED_TOP_LINE ; |
|---|
| 945 | device->clear_part( (display_struct.picture_l + display_struct.slider_pos_horizontal), *y - font_information->max_letter.ascent - 1, width+1, height+1, AED_F_ALL); |
|---|
| 946 | } |
|---|
| 947 | if (area_entry->adt_sequence) { |
|---|
| 948 | |
|---|
| 949 | if (aed_root.helix_at_extendeds || !area_entry->ad_extended) { |
|---|
| 950 | edg.helix->show_helix( (void*)device, AED_GC_HELIX , |
|---|
| 951 | area_entry->adt_sequence->show_get(), 0.0, |
|---|
| 952 | *y + font_information->max_letter.ascent + AED_CENTER_SPACING, |
|---|
| 953 | AED_F_HELIX, (AW_CL)area_entry, AED_F_HELIX); |
|---|
| 954 | } |
|---|
| 955 | device->text( AED_GC_SEQUENCE, area_entry->adt_sequence->show_get(), 0, *y, 0.0, |
|---|
| 956 | AED_F_SEQUENCE, (AW_CL)area_entry, AED_F_SEQUENCE, area_entry->adt_sequence->show_len() ); |
|---|
| 957 | } |
|---|
| 958 | |
|---|
| 959 | if ( display_struct.calc_size ) { |
|---|
| 960 | area_entry->in_line = *y; |
|---|
| 961 | *y += AED_LINE_SPACING + font_information->max_letter.descent; |
|---|
| 962 | } |
|---|
| 963 | |
|---|
| 964 | device->invisible( AED_GC_NAME, 0, *y, AED_F_ALL, (AW_CL)0, (AW_CL)0 ); |
|---|
| 965 | device->pop_clip_scale(); |
|---|
| 966 | } |
|---|
| 967 | |
|---|
| 968 | |
|---|
| 969 | void AED_window::show_data( AW_device *device, AW_window *awmm, bool visibility_control ) { |
|---|
| 970 | AW_rectangle screen; |
|---|
| 971 | |
|---|
| 972 | AED_area_display_struct display_struct; |
|---|
| 973 | display_struct.clear = false; |
|---|
| 974 | display_struct.calc_size = true; |
|---|
| 975 | display_struct.visible_control = visibility_control; |
|---|
| 976 | display_struct.top_indent = awmm->top_indent_of_vertical_scrollbar; |
|---|
| 977 | display_struct.bottom_indent = awmm->bottom_indent_of_vertical_scrollbar; |
|---|
| 978 | display_struct.left_indent = awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 979 | display_struct.slider_pos_horizontal = awmm->slider_pos_horizontal; |
|---|
| 980 | display_struct.slider_pos_vertical = awmm->slider_pos_vertical; |
|---|
| 981 | display_struct.picture_l = awmm->picture->l; |
|---|
| 982 | display_struct.picture_t = awmm->picture->t; |
|---|
| 983 | |
|---|
| 984 | device->get_area_size( &screen ); |
|---|
| 985 | GB_transaction dummy(GLOBAL_gb_main); |
|---|
| 986 | this->show_top_data( device, awmm, display_struct ); |
|---|
| 987 | this->show_middle_data( device, awmm, display_struct ); |
|---|
| 988 | this->show_bottom_data( device, awmm, display_struct ); |
|---|
| 989 | |
|---|
| 990 | device->get_area_size( &screen ); |
|---|
| 991 | device->set_offset(AW::Vector()); |
|---|
| 992 | if ( area_top ) |
|---|
| 993 | device->line( AED_GC_NAME, screen.l, awmm->top_indent_of_vertical_scrollbar-2, screen.r, awmm->top_indent_of_vertical_scrollbar-2, AED_F_NAME, (AW_CL)"Loben", 0 ); |
|---|
| 994 | if ( area_bottom ) |
|---|
| 995 | device->line( AED_GC_NAME, screen.l, screen.b-awmm->bottom_indent_of_vertical_scrollbar+1, screen.r, |
|---|
| 996 | screen.b-awmm->bottom_indent_of_vertical_scrollbar+1, AED_F_NAME, (AW_CL)"Lunten", 0 ); |
|---|
| 997 | |
|---|
| 998 | } // end: AED_window::show_data |
|---|
| 999 | |
|---|
| 1000 | void AED_window::expose( AW_window *awmm ) { |
|---|
| 1001 | AW_device *device; |
|---|
| 1002 | |
|---|
| 1003 | device = awmm->get_device (AW_MIDDLE_AREA ); |
|---|
| 1004 | device->reset(); |
|---|
| 1005 | device->set_filter(AED_F_ALL); |
|---|
| 1006 | device->clear(AED_F_ALL); |
|---|
| 1007 | this->show_data( device, awmm, true ); |
|---|
| 1008 | |
|---|
| 1009 | if ( this->cursor_is_managed ) { |
|---|
| 1010 | this->manage_cursor( device, awmm, false ); |
|---|
| 1011 | } |
|---|
| 1012 | |
|---|
| 1013 | } // end: aed_expose |
|---|
| 1014 | |
|---|
| 1015 | void AED_undo_cb(AW_window *aw, AW_CL cd1, AW_CL undo_type){ |
|---|
| 1016 | GB_ERROR error = GB_undo(GLOBAL_gb_main,(GB_UNDO_TYPE)undo_type); |
|---|
| 1017 | if (error) aw_message(error); |
|---|
| 1018 | else{ |
|---|
| 1019 | GB_begin_transaction(GLOBAL_gb_main); |
|---|
| 1020 | GB_commit_transaction(GLOBAL_gb_main); |
|---|
| 1021 | aed_expose(aw,cd1,0); |
|---|
| 1022 | } |
|---|
| 1023 | } |
|---|
| 1024 | |
|---|
| 1025 | |
|---|
| 1026 | |
|---|
| 1027 | void aed_expose( AW_window *aw, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 1028 | AWUSE(cd2); |
|---|
| 1029 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 1030 | aedw->expose(aw); |
|---|
| 1031 | } // end: aed_expose |
|---|
| 1032 | |
|---|
| 1033 | |
|---|
| 1034 | void aed_resize( AW_window *dummy, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 1035 | AWUSE(cd2); |
|---|
| 1036 | AWUSE(dummy); |
|---|
| 1037 | AW_device *device; |
|---|
| 1038 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 1039 | AW_window *aw = aedw->aww; |
|---|
| 1040 | |
|---|
| 1041 | device = aw->get_device (AW_MIDDLE_AREA ); |
|---|
| 1042 | device->set_filter(AED_F_ALL); |
|---|
| 1043 | |
|---|
| 1044 | char left_text[200]; |
|---|
| 1045 | aedw->make_left_text( left_text, NULL ); |
|---|
| 1046 | aw->set_horizontal_scrollbar_left_indent( (int)(device->get_string_size( AED_GC_NAME, left_text,0 )) + 20 ); |
|---|
| 1047 | |
|---|
| 1048 | aw->calculate_scrollbars(); |
|---|
| 1049 | aedw->expose( aw ); |
|---|
| 1050 | |
|---|
| 1051 | |
|---|
| 1052 | } // end: aed_resize |
|---|
| 1053 | |
|---|
| 1054 | |
|---|
| 1055 | static void aed_horizontal( AW_window *aw, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 1056 | AW_device *device; |
|---|
| 1057 | AW_device *info_device; |
|---|
| 1058 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 1059 | bool handle_cursor = (bool)cd2; |
|---|
| 1060 | AW_window *awmm = aedw->aww; |
|---|
| 1061 | AW_rectangle screen; |
|---|
| 1062 | AW_pos src_x; |
|---|
| 1063 | AW_pos src_y; |
|---|
| 1064 | AW_pos width; |
|---|
| 1065 | AW_pos height; |
|---|
| 1066 | AW_pos dest_x; |
|---|
| 1067 | AW_pos dest_y; |
|---|
| 1068 | |
|---|
| 1069 | device = aw->get_device (AW_MIDDLE_AREA ); |
|---|
| 1070 | device->reset(); |
|---|
| 1071 | device->set_filter(AED_F_ALL); |
|---|
| 1072 | info_device = aw->get_device (AW_INFO_AREA ); |
|---|
| 1073 | device->reset(); |
|---|
| 1074 | info_device->set_filter(AED_F_ALL); |
|---|
| 1075 | device->get_area_size( &screen ); |
|---|
| 1076 | |
|---|
| 1077 | if ( handle_cursor && aedw->cursor_is_managed ) { |
|---|
| 1078 | aedw->manage_cursor( device, awmm, true ); |
|---|
| 1079 | } |
|---|
| 1080 | |
|---|
| 1081 | src_x = awmm->left_indent_of_horizontal_scrollbar + (AW_pos)awmm->slider_pos_horizontal - aedw->last_slider_position; |
|---|
| 1082 | |
|---|
| 1083 | if ( src_x < screen.r ) { |
|---|
| 1084 | if ( (AW_pos)awmm->slider_pos_horizontal > aedw->last_slider_position ) { // nach rechts gescrollt |
|---|
| 1085 | aedw->quickdraw = true; |
|---|
| 1086 | src_y = 0; |
|---|
| 1087 | width = screen.r - awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1088 | height = screen.b; |
|---|
| 1089 | dest_x = awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1090 | dest_y = 0; |
|---|
| 1091 | |
|---|
| 1092 | aedw->quickdraw_left_indent = screen.r - ( awmm->slider_pos_horizontal - aedw->last_slider_position ) - 10; |
|---|
| 1093 | if ( aedw->quickdraw_left_indent < awmm->left_indent_of_horizontal_scrollbar ) { |
|---|
| 1094 | aedw->quickdraw_left_indent = awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1095 | } |
|---|
| 1096 | aedw->quickdraw_right_indent = screen.r; |
|---|
| 1097 | |
|---|
| 1098 | device->move_region( src_x , src_y, width, height, dest_x, dest_y ); |
|---|
| 1099 | aedw->show_data( device, awmm, true ); |
|---|
| 1100 | aedw->quickdraw = false; |
|---|
| 1101 | } |
|---|
| 1102 | if ( (AW_pos)awmm->slider_pos_horizontal < aedw->last_slider_position ) { // nach links gescrollt |
|---|
| 1103 | |
|---|
| 1104 | aedw->quickdraw = true; |
|---|
| 1105 | |
|---|
| 1106 | src_x = awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1107 | src_y = 0; |
|---|
| 1108 | width = screen.r - awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1109 | height = screen.b; |
|---|
| 1110 | dest_x = awmm->left_indent_of_horizontal_scrollbar + aedw->last_slider_position - (AW_pos)awmm->slider_pos_horizontal; |
|---|
| 1111 | dest_y = 0; |
|---|
| 1112 | |
|---|
| 1113 | device->move_region( src_x , src_y, width, height, dest_x, dest_y ); |
|---|
| 1114 | |
|---|
| 1115 | aedw->quickdraw_left_indent = awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1116 | aedw->quickdraw_right_indent = awmm->left_indent_of_horizontal_scrollbar - awmm->slider_pos_horizontal + aedw->last_slider_position + 10; |
|---|
| 1117 | device->set_offset(AW::Vector()); |
|---|
| 1118 | device->clear_part( awmm->left_indent_of_horizontal_scrollbar, 0, aedw->last_slider_position - (AW_pos)awmm->slider_pos_horizontal, screen.b, AED_F_ALL); |
|---|
| 1119 | aedw->show_data( device, awmm, true ); |
|---|
| 1120 | aedw->quickdraw = false; |
|---|
| 1121 | } |
|---|
| 1122 | } |
|---|
| 1123 | else { // mehr als eine Seite gescrollt |
|---|
| 1124 | aedw->quickdraw = true; |
|---|
| 1125 | device->set_offset(AW::Vector()); |
|---|
| 1126 | device->clear_part( awmm->left_indent_of_horizontal_scrollbar, 0, screen.r - awmm->left_indent_of_horizontal_scrollbar, screen.b, AED_F_ALL); |
|---|
| 1127 | aedw->quickdraw_left_indent = awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1128 | aedw->quickdraw_right_indent = screen.r; |
|---|
| 1129 | aedw->show_data( device, awmm, true ); |
|---|
| 1130 | aedw->quickdraw = false; |
|---|
| 1131 | } |
|---|
| 1132 | |
|---|
| 1133 | aedw->last_slider_position = awmm->slider_pos_horizontal; |
|---|
| 1134 | |
|---|
| 1135 | if ( handle_cursor && aedw->cursor_is_managed ) { |
|---|
| 1136 | aedw->cursor_is_managed = aedw->manage_cursor( device, awmm, false ); |
|---|
| 1137 | } |
|---|
| 1138 | |
|---|
| 1139 | |
|---|
| 1140 | } // end: aed_horizontal |
|---|
| 1141 | |
|---|
| 1142 | |
|---|
| 1143 | |
|---|
| 1144 | static void aed_vertical( AW_window *aw, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 1145 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 1146 | AW_window *awmm = aedw->aww; |
|---|
| 1147 | bool handle_cursor = (bool)cd2; |
|---|
| 1148 | AW_device *device; |
|---|
| 1149 | AW_device *info_device; |
|---|
| 1150 | AW_rectangle screen; |
|---|
| 1151 | GB_transaction dummy(GLOBAL_gb_main); |
|---|
| 1152 | |
|---|
| 1153 | device = aw->get_device (AW_MIDDLE_AREA ); |
|---|
| 1154 | device->reset(); |
|---|
| 1155 | device->set_filter(AED_F_ALL); |
|---|
| 1156 | info_device = aw->get_device (AW_INFO_AREA ); |
|---|
| 1157 | info_device->reset(); |
|---|
| 1158 | info_device->set_filter(AED_F_ALL); |
|---|
| 1159 | device->get_area_size( &screen ); |
|---|
| 1160 | |
|---|
| 1161 | if ( handle_cursor && aedw->cursor_is_managed && aedw->selected_area_entry_is_visible ) { |
|---|
| 1162 | aedw->manage_cursor( device, awmm, false ); |
|---|
| 1163 | } |
|---|
| 1164 | |
|---|
| 1165 | device->set_offset(AW::Vector()); |
|---|
| 1166 | |
|---|
| 1167 | device->clear_part( 0, awmm->top_indent_of_vertical_scrollbar, |
|---|
| 1168 | screen.r, screen.b - awmm->top_indent_of_vertical_scrollbar - awmm->bottom_indent_of_vertical_scrollbar, AED_F_ALL); |
|---|
| 1169 | |
|---|
| 1170 | AED_area_display_struct display_struct; |
|---|
| 1171 | display_struct.clear = false; |
|---|
| 1172 | display_struct.calc_size = true; |
|---|
| 1173 | display_struct.visible_control = true; |
|---|
| 1174 | display_struct.top_indent = awmm->top_indent_of_vertical_scrollbar; |
|---|
| 1175 | display_struct.bottom_indent = awmm->bottom_indent_of_vertical_scrollbar; |
|---|
| 1176 | display_struct.left_indent = awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1177 | display_struct.slider_pos_horizontal = awmm->slider_pos_horizontal; |
|---|
| 1178 | display_struct.slider_pos_vertical = awmm->slider_pos_vertical; |
|---|
| 1179 | display_struct.picture_l = awmm->picture->l; |
|---|
| 1180 | display_struct.picture_t = awmm->picture->t; |
|---|
| 1181 | |
|---|
| 1182 | aedw->show_middle_data( device, awmm, display_struct ); |
|---|
| 1183 | |
|---|
| 1184 | if ( handle_cursor && aedw->cursor_is_managed && aedw->selected_area_entry_is_visible ) { |
|---|
| 1185 | aedw->manage_cursor( device, awmm, false ); |
|---|
| 1186 | } |
|---|
| 1187 | |
|---|
| 1188 | |
|---|
| 1189 | } // end: aed_vertical |
|---|
| 1190 | |
|---|
| 1191 | |
|---|
| 1192 | |
|---|
| 1193 | void AED_window::hide_cursor( AW_device *device, AW_window *awmm ) { |
|---|
| 1194 | |
|---|
| 1195 | if ( cursor_is_managed ) { |
|---|
| 1196 | this->manage_cursor( device, awmm, false ); |
|---|
| 1197 | } |
|---|
| 1198 | |
|---|
| 1199 | } // end: AED_window::hide_cursor |
|---|
| 1200 | |
|---|
| 1201 | |
|---|
| 1202 | |
|---|
| 1203 | void AED_window::show_cursor( AW_device *device, AW_window *awmm ) { |
|---|
| 1204 | |
|---|
| 1205 | if ( cursor_is_managed ) { |
|---|
| 1206 | this->manage_cursor( device, awmm, false ); |
|---|
| 1207 | } |
|---|
| 1208 | |
|---|
| 1209 | } // end: AED_window::show_cursor |
|---|
| 1210 | |
|---|
| 1211 | |
|---|
| 1212 | |
|---|
| 1213 | bool AED_window::manage_cursor( AW_device *device, AW_window *awmm, bool use_last_slider_position ) { |
|---|
| 1214 | AW_rectangle screen; |
|---|
| 1215 | AW_pos slider_position_horizontal; |
|---|
| 1216 | bool cursor_drawn; |
|---|
| 1217 | |
|---|
| 1218 | if (!selected_area_entry) return false; |
|---|
| 1219 | const AW_font_information *font_information = device->get_font_information( AED_GC_SEQUENCE, 'A' ); |
|---|
| 1220 | if ( use_last_slider_position ) { |
|---|
| 1221 | slider_position_horizontal = last_slider_position; |
|---|
| 1222 | } |
|---|
| 1223 | else { |
|---|
| 1224 | slider_position_horizontal = awmm->slider_pos_horizontal; |
|---|
| 1225 | } |
|---|
| 1226 | |
|---|
| 1227 | device->push_clip_scale(); |
|---|
| 1228 | double offsetx = awmm->left_indent_of_horizontal_scrollbar - (awmm->picture->l + slider_position_horizontal); |
|---|
| 1229 | device->set_left_clip_border(awmm->left_indent_of_horizontal_scrollbar); |
|---|
| 1230 | |
|---|
| 1231 | if ( selected_area_entry->in_area == area_top ) { |
|---|
| 1232 | device->set_offset(AW::Vector(offsetx, 0)); |
|---|
| 1233 | device->set_bottom_clip_border( awmm->top_indent_of_vertical_scrollbar ); |
|---|
| 1234 | device->set_left_clip_border( awmm->left_indent_of_horizontal_scrollbar ); |
|---|
| 1235 | } |
|---|
| 1236 | |
|---|
| 1237 | if ( selected_area_entry->in_area == area_middle ) { |
|---|
| 1238 | device->set_offset(AW::Vector(offsetx, awmm->top_indent_of_vertical_scrollbar - (awmm->picture->t + awmm->slider_pos_vertical))); |
|---|
| 1239 | device->set_top_clip_border( awmm->top_indent_of_vertical_scrollbar ); |
|---|
| 1240 | device->set_bottom_clip_margin( awmm->bottom_indent_of_vertical_scrollbar ); |
|---|
| 1241 | } |
|---|
| 1242 | |
|---|
| 1243 | if ( selected_area_entry->in_area == area_bottom ) { |
|---|
| 1244 | device->get_area_size(&screen); |
|---|
| 1245 | device->set_offset(AW::Vector(offsetx, screen.b - awmm->bottom_indent_of_vertical_scrollbar)); |
|---|
| 1246 | device->set_top_clip_border( screen.b - awmm->bottom_indent_of_vertical_scrollbar ); |
|---|
| 1247 | } |
|---|
| 1248 | cursor_drawn = (bool)device->cursor( AED_GC_NAME_DRAG, cursor * font_information->max_letter.width, selected_area_entry->in_line, AW_cursor_insert, AED_F_CURSOR, 0, 0 ); |
|---|
| 1249 | device->pop_clip_scale(); |
|---|
| 1250 | root->aw_root->awar( AWAR_CURSOR_POSITION_LOCAL)->write_int( cursor ); |
|---|
| 1251 | |
|---|
| 1252 | return cursor_drawn; |
|---|
| 1253 | |
|---|
| 1254 | } // end: AED_window::manage_cursor |
|---|
| 1255 | |
|---|
| 1256 | |
|---|
| 1257 | |
|---|
| 1258 | void AED_window::show_single_area_entry( AW_device *device, AW_window *awmm, AED_area_entry *area_entry ) { |
|---|
| 1259 | AW_pos y = area_entry->in_line; |
|---|
| 1260 | GB_transaction dummy(GLOBAL_gb_main); |
|---|
| 1261 | AED_area_display_struct display_struct; |
|---|
| 1262 | |
|---|
| 1263 | display_struct.clear = true; |
|---|
| 1264 | display_struct.calc_size = false; |
|---|
| 1265 | display_struct.visible_control = true; |
|---|
| 1266 | display_struct.top_indent = awmm->top_indent_of_vertical_scrollbar; |
|---|
| 1267 | display_struct.bottom_indent = awmm->bottom_indent_of_vertical_scrollbar; |
|---|
| 1268 | display_struct.left_indent = awmm->left_indent_of_horizontal_scrollbar; |
|---|
| 1269 | display_struct.slider_pos_horizontal = awmm->slider_pos_horizontal; |
|---|
| 1270 | display_struct.slider_pos_vertical = awmm->slider_pos_vertical; |
|---|
| 1271 | display_struct.picture_l = awmm->picture->l; |
|---|
| 1272 | display_struct.picture_t = awmm->picture->t; |
|---|
| 1273 | |
|---|
| 1274 | if( area_entry->in_area == area_top ) { |
|---|
| 1275 | this->show_single_top_data( device, awmm, area_entry, display_struct, &y ); |
|---|
| 1276 | } |
|---|
| 1277 | |
|---|
| 1278 | if( area_entry->in_area == area_middle ) { |
|---|
| 1279 | this->show_single_middle_data( device, awmm, area_entry, display_struct, &y ); |
|---|
| 1280 | } |
|---|
| 1281 | |
|---|
| 1282 | if( area_entry->in_area == area_bottom ) { |
|---|
| 1283 | this->show_single_bottom_data( device, awmm, area_entry, display_struct, &y ); |
|---|
| 1284 | } |
|---|
| 1285 | |
|---|
| 1286 | } // end: AED_window::show_single_area_entry |
|---|
| 1287 | |
|---|
| 1288 | |
|---|
| 1289 | |
|---|
| 1290 | void drag_box(AW_device *device, int gc, AW_pos x, AW_pos y, AW_pos width, AW_pos height, char *str) { |
|---|
| 1291 | if( width == 0 ) { |
|---|
| 1292 | const AW_font_information *font_information = device->get_font_information( AED_GC_SELECTED_DRAG, 'A' ); |
|---|
| 1293 | |
|---|
| 1294 | width = strlen( str ) * font_information->max_letter.width + 4; |
|---|
| 1295 | height = font_information->max_letter.height + 4; |
|---|
| 1296 | } |
|---|
| 1297 | AW_pos y_help = y + 2; |
|---|
| 1298 | device->box(gc, false, x, y_help-height, width, height, AED_F_ALL, (AW_CL)"drag_box", 0); |
|---|
| 1299 | device->text( gc, str, x+2, y-2, 0, AED_F_ALL, (AW_CL)"drag_box", 0 ); // Text |
|---|
| 1300 | } |
|---|
| 1301 | |
|---|
| 1302 | |
|---|
| 1303 | |
|---|
| 1304 | void AED_dlist::remove_entry(AED_area_entry *to_be_removed) { |
|---|
| 1305 | if ( first == to_be_removed ) { |
|---|
| 1306 | if(to_be_removed->next) { |
|---|
| 1307 | first = to_be_removed->next; |
|---|
| 1308 | to_be_removed->next->previous = NULL; |
|---|
| 1309 | } |
|---|
| 1310 | else |
|---|
| 1311 | first = NULL; |
|---|
| 1312 | } |
|---|
| 1313 | else { |
|---|
| 1314 | to_be_removed->previous->next = to_be_removed->next; |
|---|
| 1315 | if(to_be_removed->next) |
|---|
| 1316 | to_be_removed->next->previous = to_be_removed->previous; |
|---|
| 1317 | } |
|---|
| 1318 | if( last == to_be_removed ) { |
|---|
| 1319 | if( to_be_removed->previous ) |
|---|
| 1320 | last = to_be_removed->previous; |
|---|
| 1321 | else |
|---|
| 1322 | last = NULL; |
|---|
| 1323 | } |
|---|
| 1324 | size--; |
|---|
| 1325 | to_be_removed->in_area = 0; |
|---|
| 1326 | this->remove_hash(to_be_removed->ad_species->name()); |
|---|
| 1327 | } |
|---|
| 1328 | void AED_dlist::insert_after_entry(AED_area_entry *add_after_this, AED_area_entry *to_be_inserted) { |
|---|
| 1329 | if( last == add_after_this ) |
|---|
| 1330 | last = to_be_inserted; |
|---|
| 1331 | to_be_inserted->next = add_after_this->next; |
|---|
| 1332 | to_be_inserted->previous = add_after_this; |
|---|
| 1333 | if ( add_after_this->next ) |
|---|
| 1334 | add_after_this->next->previous = to_be_inserted; |
|---|
| 1335 | add_after_this->next = to_be_inserted; |
|---|
| 1336 | |
|---|
| 1337 | size++; |
|---|
| 1338 | to_be_inserted->in_area = this; |
|---|
| 1339 | this->insert_hash(to_be_inserted->ad_species->name()); |
|---|
| 1340 | } |
|---|
| 1341 | void AED_dlist::insert_before_entry(AED_area_entry *add_before_this, AED_area_entry *to_be_inserted) { |
|---|
| 1342 | |
|---|
| 1343 | if( (add_before_this)->previous ) |
|---|
| 1344 | (add_before_this)->previous->next = to_be_inserted; |
|---|
| 1345 | else |
|---|
| 1346 | first = to_be_inserted; |
|---|
| 1347 | to_be_inserted->next = add_before_this; |
|---|
| 1348 | to_be_inserted->previous = add_before_this->previous; |
|---|
| 1349 | add_before_this->previous = to_be_inserted; |
|---|
| 1350 | |
|---|
| 1351 | size++; |
|---|
| 1352 | to_be_inserted->in_area = this; |
|---|
| 1353 | this->insert_hash(to_be_inserted->ad_species->name()); |
|---|
| 1354 | } |
|---|
| 1355 | void AED_dlist::append(AED_area_entry *to_be_inserted) { |
|---|
| 1356 | |
|---|
| 1357 | if(last) { |
|---|
| 1358 | last->next = to_be_inserted; |
|---|
| 1359 | to_be_inserted->previous = last; |
|---|
| 1360 | to_be_inserted->next = NULL; |
|---|
| 1361 | } |
|---|
| 1362 | else { |
|---|
| 1363 | first = last = to_be_inserted; |
|---|
| 1364 | to_be_inserted->previous = NULL; |
|---|
| 1365 | to_be_inserted->next = NULL; |
|---|
| 1366 | } |
|---|
| 1367 | last = to_be_inserted; |
|---|
| 1368 | size++; |
|---|
| 1369 | to_be_inserted->in_area = this; |
|---|
| 1370 | this->insert_hash(to_be_inserted->ad_species->name()); |
|---|
| 1371 | } |
|---|
| 1372 | /********************************************************************************************************/ |
|---|
| 1373 | /********************************************************************************************************/ |
|---|
| 1374 | void AED_dlist::create_hash(GBDATA *gb_maini,const char *awar_suffix){ |
|---|
| 1375 | char awar_buffer[1024]; |
|---|
| 1376 | this->gb_main = gb_maini; |
|---|
| 1377 | sprintf(awar_buffer,"arb_edit/%s",awar_suffix); |
|---|
| 1378 | this->hash_awar = strdup(awar_buffer); |
|---|
| 1379 | char *data = GBT_readOrCreate_string(gb_main, hash_awar, ""); |
|---|
| 1380 | hash = GBS_create_hash(100, GB_MIND_CASE); |
|---|
| 1381 | GBS_string_2_hashtab(hash,data); |
|---|
| 1382 | hash_level = 0; |
|---|
| 1383 | free(data); |
|---|
| 1384 | } |
|---|
| 1385 | |
|---|
| 1386 | long AED_dlist::read_hash(const char *name){ |
|---|
| 1387 | if (!hash) return 0; |
|---|
| 1388 | long val = GBS_read_hash(hash,name); |
|---|
| 1389 | if (!val) return val; |
|---|
| 1390 | if (!hash_level) GBS_write_hash(hash,name,val+1); |
|---|
| 1391 | return val; |
|---|
| 1392 | } |
|---|
| 1393 | |
|---|
| 1394 | static long aeddlist_optimizehash(const char *key, long val, void*) { |
|---|
| 1395 | if (val>1) return 1; |
|---|
| 1396 | key = key; |
|---|
| 1397 | return 0; |
|---|
| 1398 | } |
|---|
| 1399 | |
|---|
| 1400 | void AED_dlist::optimize_hash(void){ |
|---|
| 1401 | if (!hash) return; |
|---|
| 1402 | hash_level = 1; |
|---|
| 1403 | GBS_hash_do_loop(hash, aeddlist_optimizehash, NULL); |
|---|
| 1404 | } |
|---|
| 1405 | void AED_dlist::insert_hash(const char *name){ |
|---|
| 1406 | if (!hash) return; |
|---|
| 1407 | GB_transaction dummy(gb_main); |
|---|
| 1408 | if (hash_level) { |
|---|
| 1409 | GBS_write_hash(hash,name,1); |
|---|
| 1410 | char *str = GBS_hashtab_2_string(hash); |
|---|
| 1411 | GBT_write_string(gb_main,hash_awar, str); |
|---|
| 1412 | delete str; |
|---|
| 1413 | } |
|---|
| 1414 | } |
|---|
| 1415 | void AED_dlist::remove_hash(const char *name){ |
|---|
| 1416 | if (!hash) return; |
|---|
| 1417 | GB_transaction dummy(gb_main); |
|---|
| 1418 | GBS_write_hash(hash,name,0); |
|---|
| 1419 | char *str = GBS_hashtab_2_string(hash); |
|---|
| 1420 | GBT_write_string(gb_main,hash_awar, str); |
|---|
| 1421 | delete str; |
|---|
| 1422 | } |
|---|
| 1423 | |
|---|
| 1424 | |
|---|
| 1425 | /********************************************************************************************************/ |
|---|
| 1426 | /********************************************************************************************************/ |
|---|
| 1427 | /********************************************************************************************************/ |
|---|
| 1428 | |
|---|
| 1429 | void set_cursor_to( AED_window *aedw, long cursor, class AED_area_entry *aed ) { |
|---|
| 1430 | AW_window *awmm; |
|---|
| 1431 | AW_device *device; |
|---|
| 1432 | const int AED_WINBORDER = 50; |
|---|
| 1433 | |
|---|
| 1434 | awmm = aedw->aww; |
|---|
| 1435 | device = awmm->get_device (AW_MIDDLE_AREA ); |
|---|
| 1436 | device->set_filter(AED_F_ALL); |
|---|
| 1437 | |
|---|
| 1438 | const AW_font_information *font_information = device->get_font_information(AED_GC_SEQUENCE, 'A' ); |
|---|
| 1439 | AW_rectangle screen; |
|---|
| 1440 | device->get_area_size(&screen); |
|---|
| 1441 | |
|---|
| 1442 | long wincursor = cursor*font_information->max_letter.width; |
|---|
| 1443 | long widthofscrolledwin = (long)(screen.r - awmm->left_indent_of_horizontal_scrollbar); |
|---|
| 1444 | long worldwidth = (long) aedw->size_information.r; |
|---|
| 1445 | |
|---|
| 1446 | aedw->hide_cursor( device, awmm ); |
|---|
| 1447 | |
|---|
| 1448 | if (aed) { |
|---|
| 1449 | if ( aedw->one_area_entry_is_selected ) { |
|---|
| 1450 | AED_area_entry *help_area_entry = aedw->selected_area_entry; |
|---|
| 1451 | aedw->deselect_area_entry(); |
|---|
| 1452 | aedw->show_single_area_entry(device, awmm, help_area_entry); |
|---|
| 1453 | } |
|---|
| 1454 | aedw->select_area_entry( aed,-10 ); |
|---|
| 1455 | aedw->show_single_area_entry(device, awmm, aed); |
|---|
| 1456 | } |
|---|
| 1457 | |
|---|
| 1458 | aedw->cursor = (int)cursor; |
|---|
| 1459 | aedw->cursor_is_managed = true; |
|---|
| 1460 | |
|---|
| 1461 | if( wincursor < awmm->slider_pos_horizontal + AED_WINBORDER && awmm->slider_pos_horizontal > 0) { |
|---|
| 1462 | long h = wincursor - AED_WINBORDER; |
|---|
| 1463 | if ( h < 0 ) h = 0; |
|---|
| 1464 | if ( h > worldwidth - widthofscrolledwin ) h = (long)(worldwidth - widthofscrolledwin); |
|---|
| 1465 | awmm->set_horizontal_scrollbar_position( (int)h ); |
|---|
| 1466 | aed_horizontal( awmm, (AW_CL)aedw, (AW_CL)false ); |
|---|
| 1467 | }else if ( wincursor > awmm->slider_pos_horizontal + widthofscrolledwin - AED_WINBORDER ){ |
|---|
| 1468 | long h = wincursor - (widthofscrolledwin - AED_WINBORDER); |
|---|
| 1469 | if ( h < 0 ) h = 0; |
|---|
| 1470 | if ( h > worldwidth - widthofscrolledwin ) h = (long)(worldwidth - widthofscrolledwin); |
|---|
| 1471 | awmm->set_horizontal_scrollbar_position( (int)h ); |
|---|
| 1472 | aed_horizontal( awmm, (AW_CL)aedw, (AW_CL)false ); |
|---|
| 1473 | } |
|---|
| 1474 | if (!aed || aedw->area_middle != aed->in_area){ |
|---|
| 1475 | aedw->show_cursor( device, awmm ); |
|---|
| 1476 | return; |
|---|
| 1477 | } |
|---|
| 1478 | aedw->cursor_is_managed = false; |
|---|
| 1479 | |
|---|
| 1480 | AW_pos y_pos = aed->absolut_y - awmm->top_indent_of_vertical_scrollbar; |
|---|
| 1481 | AW_pos hight_of_scrolled_window = screen.b - awmm->bottom_indent_of_vertical_scrollbar |
|---|
| 1482 | - awmm->top_indent_of_vertical_scrollbar; |
|---|
| 1483 | if ( y_pos < AED_WINBORDER && |
|---|
| 1484 | awmm->slider_pos_vertical > 0) { |
|---|
| 1485 | y_pos = awmm->slider_pos_vertical + y_pos - AED_WINBORDER; |
|---|
| 1486 | if (y_pos <= 0 ) y_pos = 0; |
|---|
| 1487 | awmm->set_vertical_scrollbar_position( (int)y_pos ); |
|---|
| 1488 | aed_vertical( awmm, (AW_CL)aedw, (AW_CL)false ); |
|---|
| 1489 | }else if (y_pos > hight_of_scrolled_window - AED_WINBORDER){ |
|---|
| 1490 | y_pos = awmm->slider_pos_vertical + y_pos - hight_of_scrolled_window + AED_WINBORDER; |
|---|
| 1491 | if (y_pos <= 0 ) y_pos = 0; |
|---|
| 1492 | awmm->set_vertical_scrollbar_position( (int)y_pos ); |
|---|
| 1493 | aed_vertical( awmm, (AW_CL)aedw, (AW_CL)false ); |
|---|
| 1494 | } |
|---|
| 1495 | aedw->cursor_is_managed = true; |
|---|
| 1496 | aedw->show_cursor( device, awmm ); |
|---|
| 1497 | } // end: set_cursor_to |
|---|
| 1498 | |
|---|
| 1499 | static void jump_to_cursor_position(AW_window *aww, AED_window *aedw, char *awar_name) |
|---|
| 1500 | { |
|---|
| 1501 | AW_root *root = aww->get_root(); |
|---|
| 1502 | long pos = root->awar(awar_name)->read_int(); |
|---|
| 1503 | if (strcmp(awar_name,AWAR_CURSOR_POSITION_LOCAL) ) { |
|---|
| 1504 | long apos = edg.ref->rel_2_abs(pos); // rel->abs |
|---|
| 1505 | root->awar(AWAR_CURSOR_POSITION_LOCAL)->write_int(apos); |
|---|
| 1506 | pos = apos; |
|---|
| 1507 | } |
|---|
| 1508 | set_cursor_to(aedw,pos,0); |
|---|
| 1509 | } |
|---|
| 1510 | |
|---|
| 1511 | |
|---|
| 1512 | static void set_cursor_up_down(AED_window *aedw, int direction) |
|---|
| 1513 | { |
|---|
| 1514 | AW_window *awmm = aedw->aww; |
|---|
| 1515 | AW_device *device = awmm->get_device (AW_MIDDLE_AREA ); |
|---|
| 1516 | device->set_filter(AED_F_ALL); |
|---|
| 1517 | |
|---|
| 1518 | const AW_font_information *font_information = device->get_font_information( AED_GC_SEQUENCE, 'A' ); |
|---|
| 1519 | AW_rectangle screen; |
|---|
| 1520 | device->get_area_size(&screen); |
|---|
| 1521 | |
|---|
| 1522 | int jump = (font_information->max_letter.height + AED_LINE_SPACING) * (direction == -1 ? -1 : 1); |
|---|
| 1523 | int d_x = 0; |
|---|
| 1524 | int d_y = 0; |
|---|
| 1525 | |
|---|
| 1526 | if (aedw->selected_area_entry->in_area == aedw->area_top) { |
|---|
| 1527 | d_x = awmm->left_indent_of_horizontal_scrollbar - awmm->picture->l - awmm->slider_pos_horizontal; |
|---|
| 1528 | d_y = 0; |
|---|
| 1529 | } |
|---|
| 1530 | if (aedw->selected_area_entry->in_area == aedw->area_middle) { |
|---|
| 1531 | d_x = awmm->left_indent_of_horizontal_scrollbar - awmm->picture->l - awmm->slider_pos_horizontal; |
|---|
| 1532 | d_y = awmm->top_indent_of_vertical_scrollbar - awmm->picture->t - awmm->slider_pos_vertical; |
|---|
| 1533 | } |
|---|
| 1534 | if (aedw->selected_area_entry->in_area == aedw->area_bottom) { |
|---|
| 1535 | d_x = awmm->left_indent_of_horizontal_scrollbar - awmm->picture->l - awmm->slider_pos_horizontal; |
|---|
| 1536 | d_y = screen.b - awmm->bottom_indent_of_vertical_scrollbar; |
|---|
| 1537 | } |
|---|
| 1538 | |
|---|
| 1539 | AW_device *click_device = awmm->get_click_device (AW_MIDDLE_AREA, |
|---|
| 1540 | 1 + aedw->cursor * font_information->max_letter.width + d_x, |
|---|
| 1541 | (int)aedw->selected_area_entry->in_line + d_y + jump, |
|---|
| 1542 | 10, 5, 0); |
|---|
| 1543 | click_device->reset(); |
|---|
| 1544 | click_device->set_filter(AED_F_NAME | AED_F_SEQUENCE); |
|---|
| 1545 | aedw->show_data(click_device, awmm, false); |
|---|
| 1546 | |
|---|
| 1547 | AW_clicked_text clicked_text; |
|---|
| 1548 | click_device->get_clicked_text(&clicked_text); |
|---|
| 1549 | |
|---|
| 1550 | if (clicked_text.exists == true) { |
|---|
| 1551 | AED_area_entry *new_selected_area_entry = (AED_area_entry *) clicked_text.client_data1; |
|---|
| 1552 | if (clicked_text.client_data2 == AED_F_SEQUENCE) { |
|---|
| 1553 | if (aedw->one_area_entry_is_selected) { |
|---|
| 1554 | //alten area_entry ent - selektieren |
|---|
| 1555 | aedw->hide_cursor(device, awmm); |
|---|
| 1556 | AED_area_entry *help_area_entry = aedw->selected_area_entry; |
|---|
| 1557 | aedw->deselect_area_entry(); |
|---|
| 1558 | aedw->show_single_area_entry(device, awmm, help_area_entry); |
|---|
| 1559 | } |
|---|
| 1560 | aedw->select_area_entry(new_selected_area_entry, clicked_text.cursor); |
|---|
| 1561 | aedw->show_single_area_entry(device, awmm, new_selected_area_entry); |
|---|
| 1562 | aedw->show_cursor(device, awmm); |
|---|
| 1563 | } |
|---|
| 1564 | } else { |
|---|
| 1565 | aedw->selected_area_entry_is_visible = true; |
|---|
| 1566 | } |
|---|
| 1567 | } |
|---|
| 1568 | |
|---|
| 1569 | static void change_direction(AW_window *aww,AED_window *aedw) |
|---|
| 1570 | { |
|---|
| 1571 | switch(aedw->edit_direction) { |
|---|
| 1572 | case 1: aedw->edit_direction = 0;break; |
|---|
| 1573 | default: aedw->edit_direction = 1;break; |
|---|
| 1574 | } |
|---|
| 1575 | aww->get_root()->awar(AWAR_EDIT_DIRECTION)->write_int(aedw->edit_direction); |
|---|
| 1576 | } |
|---|
| 1577 | |
|---|
| 1578 | static void change_insert_mode(AW_window *aww,AED_window *aedw) |
|---|
| 1579 | { |
|---|
| 1580 | switch(aedw->edit_modus) { |
|---|
| 1581 | case AED_ALIGN: aedw->edit_modus = AED_INSERT;break; |
|---|
| 1582 | case AED_INSERT: aedw->edit_modus = AED_REPLACE;break; |
|---|
| 1583 | case AED_REPLACE: aedw->edit_modus = AED_ALIGN;break; |
|---|
| 1584 | } |
|---|
| 1585 | aww->get_root()->awar(AWAR_EDIT_MODE)->write_int(aedw->edit_modus); |
|---|
| 1586 | } |
|---|
| 1587 | |
|---|
| 1588 | static void aed_double_click( AW_window *aw, AED_window *aedw ) { |
|---|
| 1589 | AWUSE(aedw); |
|---|
| 1590 | AW_root *awr = aw->get_root(); |
|---|
| 1591 | GB_transaction dummy(GLOBAL_gb_main); |
|---|
| 1592 | |
|---|
| 1593 | char *name; |
|---|
| 1594 | name = awr->awar(AWAR_SPECIES_NAME_LOCAL)->read_string(); |
|---|
| 1595 | GBDATA *gb_species = GBT_find_species(GLOBAL_gb_main,name); |
|---|
| 1596 | if (gb_species){ |
|---|
| 1597 | GB_write_flag(gb_species,1-GB_read_flag(gb_species)); |
|---|
| 1598 | } |
|---|
| 1599 | delete name; |
|---|
| 1600 | } |
|---|
| 1601 | |
|---|
| 1602 | static void aed_input( AW_window *aw, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 1603 | AWUSE(cd2); |
|---|
| 1604 | AW_event event; |
|---|
| 1605 | AW_device *device,*info_device,*click_device; |
|---|
| 1606 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 1607 | AW_window *awmm = aedw->aww; |
|---|
| 1608 | AW_clicked_text clicked_text; |
|---|
| 1609 | AED_area_entry *area_entry = aedw->selected_area_entry; |
|---|
| 1610 | AD_ERR *error_flag = 0; |
|---|
| 1611 | char left_text[100]; |
|---|
| 1612 | AED_area_entry *first_entry, *last_entry; |
|---|
| 1613 | |
|---|
| 1614 | aw->get_event( &event ); |
|---|
| 1615 | |
|---|
| 1616 | device = awmm->get_device (AW_MIDDLE_AREA ); |
|---|
| 1617 | device->reset(); |
|---|
| 1618 | device->set_filter(AED_F_ALL); |
|---|
| 1619 | info_device = awmm->get_device (AW_INFO_AREA ); |
|---|
| 1620 | info_device->reset(); |
|---|
| 1621 | info_device->set_filter(AED_F_ALL); |
|---|
| 1622 | click_device = aw->get_click_device (AW_MIDDLE_AREA, event.x, event.y, 10, 10, 0 ); |
|---|
| 1623 | click_device->reset(); |
|---|
| 1624 | click_device->set_filter(AED_F_NAME | AED_F_SEQUENCE); |
|---|
| 1625 | |
|---|
| 1626 | int direction = 1; |
|---|
| 1627 | int changeflag = 0; |
|---|
| 1628 | long cursor; |
|---|
| 1629 | if (event.type == AW_Keyboard_Press && event.keycode == AW_KEY_F1){ |
|---|
| 1630 | change_insert_mode(aedw->aww,aedw); |
|---|
| 1631 | }else if (event.type == AW_Keyboard_Press && event.keycode == AW_KEY_F2){ |
|---|
| 1632 | change_direction(aedw->aww,aedw); |
|---|
| 1633 | }else if ( event.type == AW_Keyboard_Press && aedw->cursor_is_managed ) { |
|---|
| 1634 | switch(aedw->edit_modus) { |
|---|
| 1635 | case AED_ALIGN: area_entry->adt_sequence->changemode(AD_allign);break; |
|---|
| 1636 | case AED_INSERT: area_entry->adt_sequence->changemode(AD_insert);break; |
|---|
| 1637 | case AED_REPLACE: area_entry->adt_sequence->changemode(AD_replace);break; |
|---|
| 1638 | } |
|---|
| 1639 | switch (event.keycode) { |
|---|
| 1640 | case AW_KEY_F1: |
|---|
| 1641 | break; |
|---|
| 1642 | case AW_KEY_UP: |
|---|
| 1643 | direction = -1; |
|---|
| 1644 | case AW_KEY_DOWN: |
|---|
| 1645 | set_cursor_up_down(aedw,direction); |
|---|
| 1646 | break; |
|---|
| 1647 | default: |
|---|
| 1648 | if (awmm->get_root()->awar(AWAR_EDIT_MULTI_SEQ)->read_int()){ |
|---|
| 1649 | first_entry = area_entry->in_area->first; |
|---|
| 1650 | last_entry = NULL; |
|---|
| 1651 | }else{ |
|---|
| 1652 | first_entry = area_entry; |
|---|
| 1653 | last_entry = area_entry->next; |
|---|
| 1654 | } |
|---|
| 1655 | error_flag = NULL; |
|---|
| 1656 | for ( area_entry = first_entry; area_entry != last_entry && !error_flag; area_entry = area_entry->next){ |
|---|
| 1657 | cursor = aedw->cursor; |
|---|
| 1658 | int changed; |
|---|
| 1659 | error_flag = area_entry->adt_sequence->show_command( event.keymodifier, event.keycode, |
|---|
| 1660 | edg.edk->map_key(event.character), |
|---|
| 1661 | aedw->edit_direction, cursor, changed); |
|---|
| 1662 | changeflag |= changed; |
|---|
| 1663 | } |
|---|
| 1664 | |
|---|
| 1665 | if (!error_flag && changeflag) { |
|---|
| 1666 | aedw->root->ad_main->begin_transaction(); |
|---|
| 1667 | for ( area_entry = first_entry; |
|---|
| 1668 | area_entry != last_entry; |
|---|
| 1669 | area_entry = area_entry->next){ |
|---|
| 1670 | AD_ERR *h = area_entry->adt_sequence->show_put(); |
|---|
| 1671 | if (!error_flag) error_flag = h; |
|---|
| 1672 | } |
|---|
| 1673 | aedw->owntimestamp = aedw->root->ad_main->time_stamp(); |
|---|
| 1674 | aedw->root->ad_main->commit_transaction(); |
|---|
| 1675 | }else if (changeflag) { |
|---|
| 1676 | aedw->root->ad_main->begin_transaction(); |
|---|
| 1677 | for ( area_entry = first_entry; |
|---|
| 1678 | area_entry != last_entry; |
|---|
| 1679 | area_entry = area_entry->next){ |
|---|
| 1680 | area_entry->adt_sequence->update(); |
|---|
| 1681 | area_entry->adt_sequence->show_update(); |
|---|
| 1682 | } |
|---|
| 1683 | aedw->root->ad_main->commit_transaction(); |
|---|
| 1684 | } |
|---|
| 1685 | |
|---|
| 1686 | if (changeflag) { |
|---|
| 1687 | aedw->hide_cursor( device, awmm ); |
|---|
| 1688 | for ( area_entry = first_entry; |
|---|
| 1689 | area_entry != last_entry; |
|---|
| 1690 | area_entry = area_entry->next){ |
|---|
| 1691 | aedw->show_single_area_entry(device, awmm, area_entry); |
|---|
| 1692 | } |
|---|
| 1693 | aedw->show_cursor( device, awmm ); |
|---|
| 1694 | } |
|---|
| 1695 | |
|---|
| 1696 | set_cursor_to(aedw,cursor,0); |
|---|
| 1697 | break; |
|---|
| 1698 | } |
|---|
| 1699 | |
|---|
| 1700 | } // end: if ( event.type == AW_Keyboard_Press && aedw->cursor_is_managed ) |
|---|
| 1701 | |
|---|
| 1702 | |
|---|
| 1703 | |
|---|
| 1704 | if ( event.type == AW_Mouse_Press ) { |
|---|
| 1705 | aedw->show_data( click_device, awmm, false ); |
|---|
| 1706 | click_device->get_clicked_text( &clicked_text ); |
|---|
| 1707 | |
|---|
| 1708 | if ( clicked_text.exists == true ) { |
|---|
| 1709 | AED_area_entry *new_selected_area_entry = (AED_area_entry *)clicked_text.client_data1; |
|---|
| 1710 | if( clicked_text.client_data2 == AED_F_NAME ) { |
|---|
| 1711 | if( aedw->one_area_entry_is_selected ) { |
|---|
| 1712 | if ( aedw->selected_area_entry_is_visible ) { |
|---|
| 1713 | aedw->hide_cursor( device, awmm ); |
|---|
| 1714 | } |
|---|
| 1715 | AED_area_entry *help_area_entry = aedw->selected_area_entry; |
|---|
| 1716 | aedw->deselect_area_entry(); |
|---|
| 1717 | aedw->show_single_area_entry( device, awmm, help_area_entry ); |
|---|
| 1718 | } |
|---|
| 1719 | aedw->select_area_entry( new_selected_area_entry, clicked_text.cursor ); |
|---|
| 1720 | aedw->show_single_area_entry(device, awmm, new_selected_area_entry); |
|---|
| 1721 | aedw->cursor_is_managed = false; |
|---|
| 1722 | } |
|---|
| 1723 | if( clicked_text.client_data2 == AED_F_SEQUENCE ) { |
|---|
| 1724 | if( aedw->one_area_entry_is_selected ) { |
|---|
| 1725 | if ( aedw->selected_area_entry_is_visible ) { |
|---|
| 1726 | aedw->hide_cursor( device, awmm ); |
|---|
| 1727 | } |
|---|
| 1728 | AED_area_entry *help_area_entry = aedw->selected_area_entry; |
|---|
| 1729 | aedw->deselect_area_entry(); |
|---|
| 1730 | aedw->show_single_area_entry( device, awmm, help_area_entry ); |
|---|
| 1731 | } |
|---|
| 1732 | aedw->select_area_entry( new_selected_area_entry, clicked_text.cursor ); |
|---|
| 1733 | aedw->show_single_area_entry( device, awmm, new_selected_area_entry ); |
|---|
| 1734 | aedw->cursor_is_managed = true; |
|---|
| 1735 | aedw->show_cursor( device, awmm ); |
|---|
| 1736 | } |
|---|
| 1737 | aedw->selected_area_entry_is_visible = true; |
|---|
| 1738 | } |
|---|
| 1739 | } // end: if ( event.type == AW_Mouse_Press ) |
|---|
| 1740 | |
|---|
| 1741 | |
|---|
| 1742 | if ( event.type == AW_Mouse_Release ) { |
|---|
| 1743 | |
|---|
| 1744 | if( aedw->drag ) { |
|---|
| 1745 | aedw->drag = false; // drag beendet |
|---|
| 1746 | aedw->make_left_text( left_text, aedw->selected_area_entry ); |
|---|
| 1747 | drag_box( device, AED_GC_NAME_DRAG, aedw->drag_x - aedw->drag_x_correcting, aedw->drag_y - aedw->drag_y_correcting, 0, 0, left_text ); // vorher gemalte Box entfernen |
|---|
| 1748 | click_device = aw->get_click_device (AW_MIDDLE_AREA,event.x, event.y, 10, 8, 0); |
|---|
| 1749 | click_device->reset(); |
|---|
| 1750 | click_device->set_filter(AED_F_NAME); |
|---|
| 1751 | |
|---|
| 1752 | aedw->show_data( click_device, awmm, false ); |
|---|
| 1753 | click_device->get_clicked_text(&clicked_text); |
|---|
| 1754 | |
|---|
| 1755 | AW_rectangle screen; |
|---|
| 1756 | device->get_area_size(&screen); |
|---|
| 1757 | if (event.x > 0 && event.x < screen.r && event.y > 0 && event.y < screen.b) { // man ist innerhalb der draw area |
|---|
| 1758 | if ( clicked_text.exists && clicked_text.client_data2 == AED_F_NAME) { // drag auf gueltiger Zeile beendet |
|---|
| 1759 | AED_area_entry *destination_area_entry = (AED_area_entry *)clicked_text.client_data1; |
|---|
| 1760 | if( strcmp(destination_area_entry->ad_species->name(),aedw->selected_area_entry->ad_species->name()) != 0 ) { |
|---|
| 1761 | // nicht auf sich selber abgelegt |
|---|
| 1762 | aedw->selected_area_entry->in_area->remove_entry(aedw->selected_area_entry); |
|---|
| 1763 | if( clicked_text.distance > 0 ) |
|---|
| 1764 | destination_area_entry->in_area->insert_after_entry(destination_area_entry, aedw->selected_area_entry); |
|---|
| 1765 | else |
|---|
| 1766 | destination_area_entry->in_area->insert_before_entry(destination_area_entry, aedw->selected_area_entry); |
|---|
| 1767 | aedw->calculate_size(awmm); |
|---|
| 1768 | } |
|---|
| 1769 | }else { |
|---|
| 1770 | if( event.y > awmm->top_indent_of_vertical_scrollbar && |
|---|
| 1771 | event.y < screen.b - awmm->bottom_indent_of_vertical_scrollbar ) { |
|---|
| 1772 | // man ist im mittleren Bereich |
|---|
| 1773 | if(!aedw->area_middle->first) { |
|---|
| 1774 | // der mittlere Bereich ist leer, man will da anfuegen |
|---|
| 1775 | aedw->selected_area_entry->in_area->remove_entry( |
|---|
| 1776 | aedw->selected_area_entry); |
|---|
| 1777 | aedw->area_middle->append(aedw->selected_area_entry); |
|---|
| 1778 | aedw->calculate_size(awmm); |
|---|
| 1779 | } |
|---|
| 1780 | } |
|---|
| 1781 | } |
|---|
| 1782 | }else { // drag auf ungueltiger Zeile beendet |
|---|
| 1783 | if(event.y < screen.t) { // drag oberhalb des Bildschirmes beendet |
|---|
| 1784 | aedw->selected_area_entry->in_area->remove_entry(aedw->selected_area_entry); |
|---|
| 1785 | aedw->area_top->append(aedw->selected_area_entry); |
|---|
| 1786 | aedw->selected_area_entry->in_area = aedw->area_top; |
|---|
| 1787 | |
|---|
| 1788 | aedw->calculate_size(aw); |
|---|
| 1789 | } |
|---|
| 1790 | if(event.y > screen.b) { // drag unterhalb des Bildschirmes beendet |
|---|
| 1791 | aedw->selected_area_entry->in_area->remove_entry(aedw->selected_area_entry); |
|---|
| 1792 | aedw->area_bottom->append(aedw->selected_area_entry); |
|---|
| 1793 | |
|---|
| 1794 | aedw->calculate_size(awmm); |
|---|
| 1795 | } |
|---|
| 1796 | } |
|---|
| 1797 | } // end if ( aedw->drag ) |
|---|
| 1798 | } // end if ( event.type == AW_Mouse_Release ) |
|---|
| 1799 | if (error_flag&&error_flag->show()) aw_message(error_flag->show()); |
|---|
| 1800 | delete error_flag; |
|---|
| 1801 | } // end: aed_input |
|---|
| 1802 | |
|---|
| 1803 | |
|---|
| 1804 | |
|---|
| 1805 | static void aed_motion( AW_window *aw, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 1806 | AWUSE(cd2); |
|---|
| 1807 | AW_event event; |
|---|
| 1808 | AW_event motion_event; |
|---|
| 1809 | AW_device *device; |
|---|
| 1810 | AW_device *click_device; |
|---|
| 1811 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 1812 | AW_window *awmm = aedw->aww; |
|---|
| 1813 | AW_clicked_text clicked_text; |
|---|
| 1814 | char left_text[100]; |
|---|
| 1815 | |
|---|
| 1816 | device = aw->get_device (AW_MIDDLE_AREA ); |
|---|
| 1817 | device->set_filter(AED_F_ALL); |
|---|
| 1818 | |
|---|
| 1819 | if ( aedw->drag ) { // mitten im dragging |
|---|
| 1820 | aw->get_event ( &motion_event ); |
|---|
| 1821 | device->set_offset(AW::Vector()); |
|---|
| 1822 | aedw->make_left_text( left_text, aedw->selected_area_entry ); |
|---|
| 1823 | drag_box( device, AED_GC_NAME_DRAG, aedw->drag_x - aedw->drag_x_correcting, aedw->drag_y - aedw->drag_y_correcting, 0, 0, left_text ); // vorher gemalte Box entfernen |
|---|
| 1824 | aedw->drag_x = motion_event.x; |
|---|
| 1825 | aedw->drag_y = motion_event.y; |
|---|
| 1826 | drag_box( device, AED_GC_NAME_DRAG, motion_event.x - aedw->drag_x_correcting , motion_event.y - aedw->drag_y_correcting, 0, 0, left_text ); |
|---|
| 1827 | } // end: if ( aedw->drag ) |
|---|
| 1828 | |
|---|
| 1829 | |
|---|
| 1830 | if( !aedw->drag && aedw->selected_area_entry) { // Beginn des draggings |
|---|
| 1831 | aw->get_event( &event ); |
|---|
| 1832 | click_device = aw->get_click_device (AW_MIDDLE_AREA, event.x, event.y, 10, 5, 0 ); |
|---|
| 1833 | click_device->reset(); |
|---|
| 1834 | click_device->set_filter(AED_F_NAME); |
|---|
| 1835 | aedw->show_data( click_device, awmm, false ); |
|---|
| 1836 | click_device->get_clicked_text( &clicked_text ); |
|---|
| 1837 | |
|---|
| 1838 | if( clicked_text.exists && clicked_text.client_data2 == AED_F_NAME ) { |
|---|
| 1839 | AED_area_entry *area_entry = (AED_area_entry *)clicked_text.client_data1; |
|---|
| 1840 | if( strcmp(area_entry->ad_species->name(),aedw->selected_area_entry->ad_species->name()) == 0 ) { |
|---|
| 1841 | aedw->drag = true; |
|---|
| 1842 | aw->get_event ( &motion_event ); |
|---|
| 1843 | aedw->drag_x_correcting = event.x - (int)aedw->selected_area_entry->absolut_x; |
|---|
| 1844 | aedw->drag_y_correcting = event.y - (int)aedw->selected_area_entry->absolut_y; |
|---|
| 1845 | device->set_offset(AW::Vector()); |
|---|
| 1846 | aedw->make_left_text( left_text, aedw->selected_area_entry ); |
|---|
| 1847 | drag_box( device, AED_GC_NAME_DRAG, motion_event.x - aedw->drag_x_correcting , motion_event.y - aedw->drag_y_correcting, 0, 0, left_text ); |
|---|
| 1848 | aedw->drag_x = motion_event.x; |
|---|
| 1849 | aedw->drag_y = motion_event.y; |
|---|
| 1850 | } |
|---|
| 1851 | } |
|---|
| 1852 | } // end: if( !aedw->drag ) |
|---|
| 1853 | |
|---|
| 1854 | } // end: aed_motion |
|---|
| 1855 | |
|---|
| 1856 | |
|---|
| 1857 | |
|---|
| 1858 | static void aed_timer( AW_root *ar, AW_CL cd1, AW_CL cd2 ) { |
|---|
| 1859 | AWUSE(ar); |
|---|
| 1860 | AED_window *aedw = (AED_window *)cd1; |
|---|
| 1861 | AW_window *aw = (AW_window *)cd2; |
|---|
| 1862 | AW_window *awmm = aedw->aww; |
|---|
| 1863 | AW_device *device; |
|---|
| 1864 | if ( GB_read_transaction(GLOBAL_gb_main) <=0){ |
|---|
| 1865 | aedw->root->ad_main->begin_transaction(); |
|---|
| 1866 | GB_tell_server_dont_wait(GLOBAL_gb_main); |
|---|
| 1867 | if ( aedw->owntimestamp != aedw->root->ad_main->time_stamp() ) { |
|---|
| 1868 | aedw->owntimestamp = aedw->root->ad_main->time_stamp(); |
|---|
| 1869 | aedw->root->ad_main->commit_transaction(); |
|---|
| 1870 | device = awmm->get_device (AW_MIDDLE_AREA ); |
|---|
| 1871 | device->clear(AED_F_ALL); |
|---|
| 1872 | device = awmm->get_device (AW_INFO_AREA ); |
|---|
| 1873 | aed_expose((AW_window *)cd2,cd1,0); |
|---|
| 1874 | } |
|---|
| 1875 | else { |
|---|
| 1876 | ar->check_for_remote_command((AW_default)GLOBAL_gb_main,"ARB_EDIT"); |
|---|
| 1877 | aedw->root->ad_main->commit_transaction(); |
|---|
| 1878 | } |
|---|
| 1879 | |
|---|
| 1880 | aw->get_root()->add_timed_callback(500,aed_timer,cd1,cd2); |
|---|
| 1881 | } |
|---|
| 1882 | } // end: aed_timer |
|---|
| 1883 | |
|---|
| 1884 | |
|---|
| 1885 | |
|---|
| 1886 | |
|---|
| 1887 | |
|---|
| 1888 | /****************************************************************************************************/ |
|---|
| 1889 | /****************************************************************************************************/ |
|---|
| 1890 | /****************************************************************************************************/ |
|---|
| 1891 | |
|---|
| 1892 | // static void Probebutton(AW_window *aw, AW_CL cd1, AW_CL cd2) { |
|---|
| 1893 | // AWUSE(aw); |
|---|
| 1894 | // printf("Probebutton:%li:%li\n",cd1,cd2); |
|---|
| 1895 | // } |
|---|
| 1896 | |
|---|
| 1897 | |
|---|
| 1898 | void aed_initialize_device(AW_device *device) { |
|---|
| 1899 | device->new_gc( 0 ); |
|---|
| 1900 | device->set_line_attributes( 0, 0.3, AW_SOLID ); |
|---|
| 1901 | device->set_font( 0, AW_DEFAULT_BOLD_FONT/*AW_LUCIDA_SANS_BOLD*/, 12, 0); |
|---|
| 1902 | device->set_foreground_color( 0, AW_WINDOW_FG ); |
|---|
| 1903 | |
|---|
| 1904 | device->new_gc( 1 ); |
|---|
| 1905 | device->set_font( 1, AW_DEFAULT_BOLD_FONT/*AW_LUCIDA_SANS_BOLD*/, 12, 0); |
|---|
| 1906 | device->set_foreground_color( 1, AW_WINDOW_FG ); |
|---|
| 1907 | |
|---|
| 1908 | device->new_gc( 2 ); |
|---|
| 1909 | device->set_font( 2, AW_DEFAULT_BOLD_FONT/*AW_LUCIDA_SANS_BOLD*/, 12, 0); |
|---|
| 1910 | device->set_foreground_color( 2,AW_WINDOW_DRAG ); |
|---|
| 1911 | device->set_function( 2, AW_XOR ); |
|---|
| 1912 | |
|---|
| 1913 | } |
|---|
| 1914 | static void ED_calc_ecoli_pos(AW_root *root){ |
|---|
| 1915 | long apos = root->awar(AWAR_CURSOR_POSITION_LOCAL)->read_int(); |
|---|
| 1916 | long rpos = edg.ref->abs_2_rel(apos); |
|---|
| 1917 | |
|---|
| 1918 | root->awar(AWAR_CURSER_POS_REF_ECOLI)->write_int(rpos); |
|---|
| 1919 | } |
|---|
| 1920 | |
|---|
| 1921 | static char *ED_create_sequences_for_gde(void *THIS, GBDATA **&the_species, |
|---|
| 1922 | uchar **&the_names, uchar **&the_sequences, |
|---|
| 1923 | long &numberspecies,long &maxalignlen) |
|---|
| 1924 | { |
|---|
| 1925 | AED_window *aedw = (AED_window *)THIS; |
|---|
| 1926 | long top = aedw->root->aw_root->awar("gde/top_area")->read_int(); |
|---|
| 1927 | long tops = aedw->root->aw_root->awar("gde/top_area_sai")->read_int(); |
|---|
| 1928 | long toph = aedw->root->aw_root->awar("gde/top_area_helix")->read_int(); |
|---|
| 1929 | long middle = aedw->root->aw_root->awar("gde/middle_area")->read_int(); |
|---|
| 1930 | long middles = aedw->root->aw_root->awar("gde/middle_area_sai")->read_int(); |
|---|
| 1931 | long middleh = aedw->root->aw_root->awar("gde/middle_area_helix")->read_int(); |
|---|
| 1932 | long bottom = aedw->root->aw_root->awar("gde/bottom_area")->read_int(); |
|---|
| 1933 | long bottoms = aedw->root->aw_root->awar("gde/bottom_area_sai")->read_int(); |
|---|
| 1934 | long bottomh = aedw->root->aw_root->awar("gde/bottom_area_helix")->read_int(); |
|---|
| 1935 | |
|---|
| 1936 | numberspecies = 0; |
|---|
| 1937 | AED_area_entry *ae; |
|---|
| 1938 | if (aedw->area_top) for ( ae = aedw->area_top->first; ae ;ae=ae->next) { |
|---|
| 1939 | if ( !((!ae->ad_extended && top ) || (ae->ad_extended && tops)) ) continue; |
|---|
| 1940 | numberspecies++; |
|---|
| 1941 | if (toph) numberspecies++; |
|---|
| 1942 | } |
|---|
| 1943 | if (aedw->area_middle) for ( ae = aedw->area_middle->first; ae ;ae=ae->next) { |
|---|
| 1944 | if ( !((!ae->ad_extended && middle ) || (ae->ad_extended && middles)) ) continue; |
|---|
| 1945 | numberspecies++; |
|---|
| 1946 | if (middleh) numberspecies++; |
|---|
| 1947 | } |
|---|
| 1948 | if (aedw->area_bottom) for ( ae = aedw->area_bottom->first; ae ;ae=ae->next) { |
|---|
| 1949 | if ( !((!ae->ad_extended && bottom ) || (ae->ad_extended && bottoms)) ) continue; |
|---|
| 1950 | numberspecies++; |
|---|
| 1951 | if (bottomh) numberspecies++; |
|---|
| 1952 | } |
|---|
| 1953 | the_species = (GBDATA **)GB_calloc(sizeof(void *),(size_t)numberspecies+1); |
|---|
| 1954 | the_names = 0; |
|---|
| 1955 | the_sequences = (uchar **)GB_calloc(sizeof(uchar *),(size_t)numberspecies+1); |
|---|
| 1956 | long i = 0; |
|---|
| 1957 | maxalignlen = 0; |
|---|
| 1958 | if (aedw->area_top) for ( ae = aedw->area_top->first; ae ;ae=ae->next) { |
|---|
| 1959 | if ( !((!ae->ad_extended && top ) || (ae->ad_extended && tops)) ) continue; |
|---|
| 1960 | the_sequences[i] = (uchar *)strdup(ae->adt_sequence->show_get()); |
|---|
| 1961 | the_species[i] = ae->ad_species->get_GBDATA(); |
|---|
| 1962 | maxalignlen = ae->adt_sequence->show_len(); |
|---|
| 1963 | i++; |
|---|
| 1964 | if (toph) { |
|---|
| 1965 | the_sequences[i] = (uchar *)edg.helix->seq_2_helix(ae->adt_sequence->show_get(),'.'); |
|---|
| 1966 | the_species[i] = ae->ad_species->get_GBDATA(); |
|---|
| 1967 | i++; |
|---|
| 1968 | } |
|---|
| 1969 | } |
|---|
| 1970 | if (aedw->area_middle) for ( ae = aedw->area_middle->first; ae ;ae=ae->next) { |
|---|
| 1971 | if ( !((!ae->ad_extended && middle ) || (ae->ad_extended && middles)) ) continue; |
|---|
| 1972 | the_sequences[i] = (uchar *)strdup(ae->adt_sequence->show_get()); |
|---|
| 1973 | the_species[i] = ae->ad_species->get_GBDATA(); |
|---|
| 1974 | maxalignlen = ae->adt_sequence->show_len(); |
|---|
| 1975 | i++; |
|---|
| 1976 | if (middleh) { |
|---|
| 1977 | the_sequences[i] = (uchar *)edg.helix->seq_2_helix(ae->adt_sequence->show_get(),'.'); |
|---|
| 1978 | the_species[i] = ae->ad_species->get_GBDATA(); |
|---|
| 1979 | i++; |
|---|
| 1980 | } |
|---|
| 1981 | } |
|---|
| 1982 | if (aedw->area_bottom) for ( ae = aedw->area_bottom->first; ae ;ae=ae->next) { |
|---|
| 1983 | if ( !((!ae->ad_extended && bottom ) || (ae->ad_extended && bottoms)) ) continue; |
|---|
| 1984 | the_sequences[i] = (uchar *)strdup(ae->adt_sequence->show_get()); |
|---|
| 1985 | the_species[i] = ae->ad_species->get_GBDATA(); |
|---|
| 1986 | maxalignlen = ae->adt_sequence->show_len(); |
|---|
| 1987 | i++; |
|---|
| 1988 | if (bottomh) { |
|---|
| 1989 | the_sequences[i] = (uchar *)edg.helix->seq_2_helix(ae->adt_sequence->show_get(),'.'); |
|---|
| 1990 | the_species[i] = ae->ad_species->get_GBDATA(); |
|---|
| 1991 | i++; |
|---|
| 1992 | } |
|---|
| 1993 | } |
|---|
| 1994 | return 0; |
|---|
| 1995 | } |
|---|
| 1996 | |
|---|
| 1997 | static void create_edit_variables(AW_root *root, AW_default awr, AED_window *aedw){ |
|---|
| 1998 | AWUSE(awr); |
|---|
| 1999 | root->awar_string( AWAR_SPECIES_DEST,"", AW_ROOT_DEFAULT); |
|---|
| 2000 | root->awar_string( AWAR_SPECIES_NAME_LOCAL, "", AW_ROOT_DEFAULT); |
|---|
| 2001 | root->awar_string( AWAR_SPECIES_NAME, "", GLOBAL_gb_main); |
|---|
| 2002 | root->awar_int( AWAR_CURSOR_POSITION_LOCAL, 0, AW_ROOT_DEFAULT); |
|---|
| 2003 | root->awar_int( AWAR_CURSOR_POSITION, 0, GLOBAL_gb_main); |
|---|
| 2004 | root->awar_int( AWAR_CURSER_POS_REF_ECOLI, 0,AW_ROOT_DEFAULT); |
|---|
| 2005 | root->awar_int( AWAR_LINE_SPACING, 7) ->add_target_var(&aed_root.line_spacing); |
|---|
| 2006 | root->awar_int( AWAR_CENTER_SPACING, -1) ->add_target_var(&aed_root.center_spacing); |
|---|
| 2007 | root->awar_int( AWAR_HELIX_AT_SAIS, 1) ->add_target_var((long *)&aed_root.helix_at_extendeds); |
|---|
| 2008 | root->awar_int( AWAR_SECURITY_LEVEL, 0,AW_ROOT_DEFAULT); |
|---|
| 2009 | root->awar(AWAR_SECURITY_LEVEL)->add_callback(aed_changesecurity,(AW_CL)aedw); |
|---|
| 2010 | root->awar_int( AWAR_EDIT_MODE, aedw->edit_modus) ->add_target_var((long *)&aedw->edit_modus); |
|---|
| 2011 | root->awar_int( AWAR_EDIT_DIRECTION, 1) ->add_target_var((long *)&aedw->edit_direction); |
|---|
| 2012 | root->awar_int( AWAR_EDIT_MULTI_SEQ, 0,AW_ROOT_DEFAULT); |
|---|
| 2013 | root->awar(AWAR_CURSOR_POSITION_LOCAL)->add_callback(ED_calc_ecoli_pos); |
|---|
| 2014 | |
|---|
| 2015 | root->awar(AWAR_SPECIES_NAME_LOCAL)->map(AWAR_SPECIES_NAME); |
|---|
| 2016 | |
|---|
| 2017 | create_gde_var(root,awr, ED_create_sequences_for_gde,CGSS_WT_EDIT,(void *)aedw); |
|---|
| 2018 | |
|---|
| 2019 | GB_ERROR error = ARB_init_global_awars(root, awr, GLOBAL_gb_main); |
|---|
| 2020 | if (error) aw_message(error); |
|---|
| 2021 | } |
|---|
| 2022 | |
|---|
| 2023 | static AW_window *create_edit_preset_window(AW_root *awr){ |
|---|
| 2024 | AW_window_simple *aws = new AW_window_simple; |
|---|
| 2025 | aws->init( awr, "EDIT_PROPS", "EDIT_PROPERTIES"); |
|---|
| 2026 | aws->label_length( 25 ); |
|---|
| 2027 | aws->button_length( 20 ); |
|---|
| 2028 | |
|---|
| 2029 | aws->at ( 10,10 ); |
|---|
| 2030 | aws->auto_space(10,10); |
|---|
| 2031 | aws->callback ( AW_POPDOWN ); |
|---|
| 2032 | aws->create_button( "CLOSE", "CLOSE", "C" ); |
|---|
| 2033 | aws->at_newline(); |
|---|
| 2034 | |
|---|
| 2035 | aws->create_option_menu( AWAR_HELIX_AT_SAIS, "Show Helix at SAIs", "R" ); |
|---|
| 2036 | aws->insert_option ( "no", "n", 0 ); |
|---|
| 2037 | aws->insert_option ( "yes", "r", 1 ); |
|---|
| 2038 | aws->update_option_menu(); |
|---|
| 2039 | aws->at_newline(); |
|---|
| 2040 | |
|---|
| 2041 | aws->label("Vert. Line Space"); |
|---|
| 2042 | aws->create_input_field(AWAR_LINE_SPACING,4); |
|---|
| 2043 | aws->at_newline(); |
|---|
| 2044 | |
|---|
| 2045 | aws->label("Seq. - Helix Space"); |
|---|
| 2046 | aws->create_input_field(AWAR_CENTER_SPACING,4); |
|---|
| 2047 | aws->at_newline(); |
|---|
| 2048 | |
|---|
| 2049 | aws->window_fit(); |
|---|
| 2050 | return (AW_window *)aws; |
|---|
| 2051 | } |
|---|
| 2052 | |
|---|
| 2053 | static void ED_focus_cb(AW_root *,GBDATA *) |
|---|
| 2054 | { |
|---|
| 2055 | GB_transaction dummy(GLOBAL_gb_main); |
|---|
| 2056 | } |
|---|
| 2057 | |
|---|
| 2058 | void aed_create_window(AED_root *aedr) { |
|---|
| 2059 | |
|---|
| 2060 | AED_window *aed_window; |
|---|
| 2061 | AW_device *device; |
|---|
| 2062 | AW_device *info_device; |
|---|
| 2063 | |
|---|
| 2064 | AW_window_menu *awmm; |
|---|
| 2065 | char left_text[100]; |
|---|
| 2066 | AED_left_side *left_side; |
|---|
| 2067 | int is_client = (GB_read_clients(GLOBAL_gb_main)<0); |
|---|
| 2068 | |
|---|
| 2069 | aed_window = new AED_window; |
|---|
| 2070 | aed_window->init(aedr); |
|---|
| 2071 | |
|---|
| 2072 | aed_window->aww = awmm = new AW_window_menu; |
|---|
| 2073 | awmm->init(aedr->aw_root,"ARB_EDIT", "ARB_EDIT",800,600); |
|---|
| 2074 | |
|---|
| 2075 | create_edit_variables(awmm->get_root(),aed_window->root->db,aed_window); |
|---|
| 2076 | |
|---|
| 2077 | AW_gc_manager preset_window = |
|---|
| 2078 | AW_manage_GC (awmm,awmm->get_device(AW_MIDDLE_AREA), AED_GC_NAME, AED_GC_NAME_DRAG, AW_GCM_DATA_AREA, |
|---|
| 2079 | (AW_CB)aed_resize,(AW_CL)aed_window,0, |
|---|
| 2080 | false, |
|---|
| 2081 | "#CCF177", |
|---|
| 2082 | "NAMES$#0000B9", |
|---|
| 2083 | "SELECTED$#FF0000", |
|---|
| 2084 | "#SEQUENCES$black", |
|---|
| 2085 | "#HELIX$#FF5500", |
|---|
| 2086 | "-CS_NORMAL$black", |
|---|
| 2087 | "-CS_1$#eee", |
|---|
| 2088 | "-CS_2$#ddd", |
|---|
| 2089 | "-CS_3$#ccc", |
|---|
| 2090 | "-CS_4$#bbb", |
|---|
| 2091 | "-CS_5$#aaa", |
|---|
| 2092 | "-CS_6$#999", |
|---|
| 2093 | "-CS_7$#888", |
|---|
| 2094 | "-CS_8$#777", |
|---|
| 2095 | "-CS_9$#666", |
|---|
| 2096 | NULL); |
|---|
| 2097 | |
|---|
| 2098 | char source[256]; |
|---|
| 2099 | char dest[256]; |
|---|
| 2100 | sprintf(source,AWP_FONTNAME_TEMPLATE,awmm->window_defaults_name,"HELIX"); |
|---|
| 2101 | sprintf(dest,AWP_FONTNAME_TEMPLATE,awmm->window_defaults_name,"SEQUENCES"); |
|---|
| 2102 | awmm->get_root()->awar(source)->map(dest); |
|---|
| 2103 | |
|---|
| 2104 | sprintf(source,AWP_FONTSIZE_TEMPLATE,awmm->window_defaults_name,"HELIX"); |
|---|
| 2105 | sprintf(dest,AWP_FONTSIZE_TEMPLATE,awmm->window_defaults_name,"SEQUENCES"); |
|---|
| 2106 | awmm->get_root()->awar(source)->map(dest); |
|---|
| 2107 | |
|---|
| 2108 | st_ml = new_ST_ML(GLOBAL_gb_main); |
|---|
| 2109 | |
|---|
| 2110 | awmm->create_menu("File", "F" ); |
|---|
| 2111 | |
|---|
| 2112 | if (!is_client){ |
|---|
| 2113 | awmm->insert_menu_topic("save_bin","Save BIN","B","save_bin.hlp", AWM_ALL,aed_save_bin,(AW_CL)aed_window,0); |
|---|
| 2114 | awmm->insert_separator(); |
|---|
| 2115 | } |
|---|
| 2116 | |
|---|
| 2117 | awmm->insert_separator(); |
|---|
| 2118 | GDE_load_menu(awmm,AWM_ALL,"Print"); |
|---|
| 2119 | awmm->insert_separator(); |
|---|
| 2120 | awmm->insert_menu_topic("quit","Quit","Q","quit.hlp", AWM_ALL, aed_quit,(AW_CL)aed_window->root,1); |
|---|
| 2121 | |
|---|
| 2122 | |
|---|
| 2123 | |
|---|
| 2124 | |
|---|
| 2125 | awmm->create_menu("EDIT","E"); |
|---|
| 2126 | awmm->insert_menu_topic("search", "Search ...", "S","ne_search.hlp", AWM_ALL, AW_POPUP, (AW_CL)create_tool_search, (AW_CL)aed_window); |
|---|
| 2127 | awmm->insert_menu_topic("replace", "Replace ...", "R","ne_replace.hlp", AWM_ALL, AW_POPUP, (AW_CL)create_tool_replace, (AW_CL)aed_window); |
|---|
| 2128 | awmm->insert_menu_topic("complement", "Complement ...", "C","ne_compl.hlp", AWM_ALL, AW_POPUP, (AW_CL)create_tool_complement, (AW_CL)aed_window ); |
|---|
| 2129 | awmm->insert_separator(); |
|---|
| 2130 | awmm->insert_menu_topic("create_sequence","Create Sequence ...", "e","ne_new_sequence.hlp", AWM_ALL,AW_POPUP, (AW_CL)create_new_seq_window, (AW_CL)aed_window); |
|---|
| 2131 | awmm->insert_menu_topic("open_sequence","Open Existing Sequence ...", "O","ne_new_sequence.hlp", AWM_ALL,AW_POPUP, (AW_CL)create_old_seq_window, (AW_CL)aed_window); |
|---|
| 2132 | awmm->insert_menu_topic("copy_sequence","Copy Selected Sequence ...", "p","ne_copy_sequence.hlp", AWM_ALL,AW_POPUP, (AW_CL)create_new_copy_window, (AW_CL)aed_window); |
|---|
| 2133 | awmm->insert_separator(); |
|---|
| 2134 | // awmm->insert_menu_topic(0,"Align Sequence (V1.0)...", "A","ne_align_seq.hlp", AWM_ALL,AW_POPUP, (AW_CL)create_aligner_window, 0 ); |
|---|
| 2135 | awmm->insert_menu_topic("align_sequence","Align Sequence (V2.0)...", "2","ne_align_seq.hlp", AWM_ALL,AW_POPUP, (AW_CL)create_naligner_window, 0 ); |
|---|
| 2136 | awmm->insert_separator(); |
|---|
| 2137 | awmm->insert_menu_topic("s_prot_to_0", "Set Protection Level of selected Sequence to 0","0","security.hlp", AWM_ALL, (AW_CB)set_security, (AW_CL)aed_window, 0); |
|---|
| 2138 | awmm->insert_menu_topic("s_prot_to_1", "Set Protection Level of selected Sequence to 1","1","security.hlp", AWM_ALL, (AW_CB)set_security, (AW_CL)aed_window, 1); |
|---|
| 2139 | awmm->insert_menu_topic("s_prot_to_2", "Set Protection Level of selected Sequence to 2","2","security.hlp", AWM_ALL, (AW_CB)set_security, (AW_CL)aed_window, 2); |
|---|
| 2140 | awmm->insert_menu_topic("s_prot_to_3", "Set Protection Level of selected Sequence to 3","3","security.hlp", AWM_ALL, (AW_CB)set_security, (AW_CL)aed_window, 3); |
|---|
| 2141 | awmm->insert_menu_topic("s_prot_to_4", "Set Protection Level of selected Sequence to 4","4","security.hlp", AWM_ALL, (AW_CB)set_security, (AW_CL)aed_window, 4); |
|---|
| 2142 | awmm->insert_menu_topic("s_prot_to_5", "Set Protection Level of selected Sequence to 5","5","security.hlp", AWM_ALL, (AW_CB)set_security, (AW_CL)aed_window, 5); |
|---|
| 2143 | awmm->insert_separator(); |
|---|
| 2144 | awmm->insert_menu_topic("mark_all_editor", "Mark All Sequences in Editor", "M","mark.hlp", AWM_ALL, (AW_CB)set_mark_cb, (AW_CL)aed_window, 1); |
|---|
| 2145 | awmm->insert_menu_topic("unmark_all_editor", "Unmark All Sequences in Editor", "U","mark.hlp", AWM_ALL, (AW_CB)set_mark_cb, (AW_CL)aed_window, 0); |
|---|
| 2146 | awmm->insert_menu_topic("mark_selected", "Mark Selected Sequence", "k","mark.hlp", AWM_ALL, (AW_CB)set_smark_cb, (AW_CL)aed_window, 1); |
|---|
| 2147 | awmm->insert_menu_topic("unmark_selected", "Unmark Selected Sequence", "n","mark.hlp", AWM_ALL, (AW_CB)set_smark_cb, (AW_CL)aed_window, 0); |
|---|
| 2148 | |
|---|
| 2149 | awmm->create_menu("Props","P"); |
|---|
| 2150 | awmm->insert_menu_topic("props_menu", "Menu: Colors and Fonts ...", "M","props_frame.hlp", AWM_ALL, AW_POPUP, (AW_CL)AW_preset_window, 0 ); |
|---|
| 2151 | awmm->insert_menu_topic("props_seq", "Sequences: Colors and Fonts ...", "C","neprops_data.hlp", AWM_ALL, AW_POPUP, (AW_CL)AW_create_gc_window, (AW_CL)preset_window ); |
|---|
| 2152 | awmm->insert_menu_topic("props_etc", "ETC ...", "E","neprops.hlp", AWM_ALL, AW_POPUP, (AW_CL)create_edit_preset_window, (AW_CL)0 ); |
|---|
| 2153 | // awmm->insert_menu_topic(0,"NDS ...", "N","neprops_nds.hlp", AWM_ALL, aed_popup_config_window, (AW_CL)aed_window, true ); |
|---|
| 2154 | awmm->insert_menu_topic("props_key_map","Key Mappings ...", "K","nekey_map.hlp", AWM_ALL, AW_POPUP, (AW_CL)create_key_map_window, 0 ); |
|---|
| 2155 | awmm->insert_menu_topic("props_helix", "Helix Symbols ...", "H","helixsym.hlp", AWM_ALL, AW_POPUP, (AW_CL)create_helix_props_window, (AW_CL) |
|---|
| 2156 | new AW_cb_struct(awmm,(AW_CB)aed_resize,(AW_CL)aed_window,0) ); |
|---|
| 2157 | awmm->insert_separator(); |
|---|
| 2158 | awmm->insert_menu_topic("save_props", "Save Properties (in ~/.arb_prop/edit.arb)","S","savedef.hlp", AWM_ALL, (AW_CB) AW_save_defaults, 0, 0 ); |
|---|
| 2159 | awmm->create_menu("ETC","C"); |
|---|
| 2160 | awmm->insert_menu_topic("synchronize", "Synchronize Cursor Position", "S","exportcursor.hlp", AWM_ALL, aed_use_focus, (AW_CL)aed_window, true ); |
|---|
| 2161 | awmm->insert_menu_topic("unsynchronize","Don't Synchronize Cursor", "D","exportcursor.hlp", AWM_ALL, aed_use_focus, (AW_CL)aed_window, false ); |
|---|
| 2162 | awmm->insert_menu_topic("refresh_helix","Reload Helix (SAI 'HELIXNR/HELIX')", "H","helix.hlp", AWM_ALL, (AW_CB)reload_helix, (AW_CL)aed_window, 0 ); |
|---|
| 2163 | awmm->insert_menu_topic("refresh_ecoli","Reload Reference (SAI 'ECOLI')", "R","ecoliref.hlp", AWM_ALL, (AW_CB)reload_ref, (AW_CL)aed_window, 0 ); |
|---|
| 2164 | awmm->insert_menu_topic("enable_col_stat","Enable Column Statistic", "C","st_ml.hlp", AWM_ALL,AW_POPUP,(AW_CL)st_create_main_window,(AW_CL)st_ml); |
|---|
| 2165 | // awmm->insert_menu_topic("submission", "Submission ...", "S","submission.hlp", AWM_ALL, AW_POPUP, (AW_CL)create_submission_window, (AW_CL)aed_window ); |
|---|
| 2166 | awmm->insert_separator(); |
|---|
| 2167 | awmm->insert_sub_menu("GDE Specials","G"); |
|---|
| 2168 | GDE_load_menu(awmm,AWM_ALL,0,0); |
|---|
| 2169 | awmm->close_sub_menu(); |
|---|
| 2170 | |
|---|
| 2171 | awmm->set_info_area_height( 250 ); |
|---|
| 2172 | awmm->at(5,2); |
|---|
| 2173 | awmm->auto_space(5,-2); |
|---|
| 2174 | // awmm->shadow_width(1); |
|---|
| 2175 | |
|---|
| 2176 | int db_pathx,db_pathy; |
|---|
| 2177 | awmm->get_at_position( &db_pathx,&db_pathy ); |
|---|
| 2178 | awmm->callback( aed_quit,(AW_CL)aed_window->root,1); |
|---|
| 2179 | awmm->button_length(0); |
|---|
| 2180 | awmm->help_text("quit.hlp"); |
|---|
| 2181 | awmm->create_button("QUIT", "QUIT"); |
|---|
| 2182 | |
|---|
| 2183 | |
|---|
| 2184 | awmm->callback(AED_undo_cb,(AW_CL)aed_window,(AW_CL)GB_UNDO_UNDO); |
|---|
| 2185 | awmm->help_text("undo.hlp"); |
|---|
| 2186 | awmm->create_button("UNDO", "#undo.bitmap",0); |
|---|
| 2187 | |
|---|
| 2188 | awmm->callback(AED_undo_cb,(AW_CL)aed_window,(AW_CL)GB_UNDO_REDO); |
|---|
| 2189 | awmm->help_text("undo.hlp"); |
|---|
| 2190 | awmm->create_button("REDO", "#redo.bitmap",0); |
|---|
| 2191 | |
|---|
| 2192 | int db_treex,db_treey; |
|---|
| 2193 | awmm->get_at_position( &db_treex,&db_treey ); |
|---|
| 2194 | awmm->button_length(16); |
|---|
| 2195 | // awmm->help_text("nt_tree_select.hlp"); |
|---|
| 2196 | awmm->label("Pos."); |
|---|
| 2197 | awmm->callback((AW_CB)jump_to_cursor_position,(AW_CL)aed_window, |
|---|
| 2198 | (AW_CL)AWAR_CURSOR_POSITION_LOCAL); |
|---|
| 2199 | awmm->create_input_field(AWAR_CURSOR_POSITION_LOCAL,4); |
|---|
| 2200 | |
|---|
| 2201 | awmm->label("E.coli"); |
|---|
| 2202 | awmm->callback((AW_CB)jump_to_cursor_position,(AW_CL)aed_window, |
|---|
| 2203 | (AW_CL)AWAR_CURSER_POS_REF_ECOLI); |
|---|
| 2204 | awmm->create_input_field(AWAR_CURSER_POS_REF_ECOLI,4); |
|---|
| 2205 | |
|---|
| 2206 | awmm->label("Mode"); |
|---|
| 2207 | awmm->create_option_menu(AWAR_EDIT_MODE,0,0); |
|---|
| 2208 | awmm->insert_option("align",0,(int)AED_ALIGN); |
|---|
| 2209 | awmm->insert_option("insert",0,(int)AED_INSERT); |
|---|
| 2210 | awmm->insert_default_option("replace",0,(int)AED_REPLACE); |
|---|
| 2211 | awmm->update_option_menu(); |
|---|
| 2212 | |
|---|
| 2213 | awmm->label("Protection"); |
|---|
| 2214 | awmm->create_option_menu(AWAR_SECURITY_LEVEL); |
|---|
| 2215 | awmm->insert_option("0",0,0); |
|---|
| 2216 | awmm->insert_option("1",0,1); |
|---|
| 2217 | awmm->insert_option("2",0,2); |
|---|
| 2218 | awmm->insert_option("3",0,3); |
|---|
| 2219 | awmm->insert_option("4",0,4); |
|---|
| 2220 | awmm->insert_option("5",0,5); |
|---|
| 2221 | awmm->insert_default_option("6",0,6); |
|---|
| 2222 | awmm->update_option_menu(); |
|---|
| 2223 | |
|---|
| 2224 | awmm->create_toggle(AWAR_EDIT_DIRECTION,"#edit/r2l.bitmap","#edit/l2r.bitmap"); |
|---|
| 2225 | |
|---|
| 2226 | awmm->label("MG"); |
|---|
| 2227 | awmm->create_toggle(AWAR_EDIT_MULTI_SEQ); |
|---|
| 2228 | |
|---|
| 2229 | awmm->callback(AW_POPUP_HELP,(AW_CL)"arb_edit.hlp"); |
|---|
| 2230 | awmm->button_length(0); |
|---|
| 2231 | awmm->help_text("help.hlp"); |
|---|
| 2232 | awmm->create_button("HELP", "HELP","H"); |
|---|
| 2233 | |
|---|
| 2234 | awmm->callback( AW_help_entry_pressed ); |
|---|
| 2235 | awmm->create_button(0,"?"); |
|---|
| 2236 | |
|---|
| 2237 | awmm->set_info_area_height( 30 ); |
|---|
| 2238 | awmm->set_bottom_area_height( 0 ); |
|---|
| 2239 | |
|---|
| 2240 | |
|---|
| 2241 | info_device = awmm->get_device (AW_INFO_AREA); |
|---|
| 2242 | aed_initialize_device(info_device); |
|---|
| 2243 | |
|---|
| 2244 | info_device->set_foreground_color( 2, AW_WINDOW_DRAG ); |
|---|
| 2245 | |
|---|
| 2246 | left_side = new AED_left_side( aed_left_security, "Security" ); |
|---|
| 2247 | left_side->in_side = aed_window->show_dlist_left_side; |
|---|
| 2248 | aed_window->show_dlist_left_side->append( left_side ); |
|---|
| 2249 | |
|---|
| 2250 | left_side = new AED_left_side( aed_left_name, "Species Name" ); |
|---|
| 2251 | left_side->in_side = aed_window->show_dlist_left_side; |
|---|
| 2252 | aed_window->show_dlist_left_side->append( left_side ); |
|---|
| 2253 | |
|---|
| 2254 | #if 0 |
|---|
| 2255 | left_side = new AED_left_side( aed_left_CA, "Number of 'A's" ); |
|---|
| 2256 | left_side->in_side = aed_window->hide_dlist_left_side; |
|---|
| 2257 | aed_window->hide_dlist_left_side->append( left_side ); |
|---|
| 2258 | |
|---|
| 2259 | left_side = new AED_left_side( aed_left_CC, "Number of 'C's" ); |
|---|
| 2260 | left_side->in_side = aed_window->hide_dlist_left_side; |
|---|
| 2261 | aed_window->hide_dlist_left_side->append( left_side ); |
|---|
| 2262 | |
|---|
| 2263 | left_side = new AED_left_side( aed_left_CG, "Number of 'G's" ); |
|---|
| 2264 | left_side->in_side = aed_window->hide_dlist_left_side; |
|---|
| 2265 | aed_window->hide_dlist_left_side->append( left_side ); |
|---|
| 2266 | |
|---|
| 2267 | left_side = new AED_left_side( aed_left_CT, "Number of 'T's" ); |
|---|
| 2268 | left_side->in_side = aed_window->hide_dlist_left_side; |
|---|
| 2269 | aed_window->hide_dlist_left_side->append( left_side ); |
|---|
| 2270 | |
|---|
| 2271 | left_side = new AED_left_side( aed_left_ACGT, "Number of 'ACGT's" ); |
|---|
| 2272 | left_side->in_side = aed_window->show_dlist_left_side; |
|---|
| 2273 | aed_window->show_dlist_left_side->append( left_side ); |
|---|
| 2274 | |
|---|
| 2275 | left_side = new AED_left_side( aed_left_GC, "GC-quota" ); |
|---|
| 2276 | left_side->in_side = aed_window->show_dlist_left_side; |
|---|
| 2277 | aed_window->show_dlist_left_side->append( left_side ); |
|---|
| 2278 | #endif |
|---|
| 2279 | device = awmm->get_device (AW_MIDDLE_AREA ); |
|---|
| 2280 | device->set_filter(AED_F_ALL); |
|---|
| 2281 | aed_window->make_left_text( left_text, NULL ); |
|---|
| 2282 | awmm->set_horizontal_scrollbar_left_indent( device->get_string_size( AED_GC_NAME, left_text,0 ) + 20 ); |
|---|
| 2283 | |
|---|
| 2284 | awmm->set_expose_callback (AW_MIDDLE_AREA, aed_expose,(AW_CL)aed_window,0); |
|---|
| 2285 | awmm->set_resize_callback (AW_MIDDLE_AREA, aed_resize,(AW_CL)aed_window,0); |
|---|
| 2286 | awmm->get_root()->set_focus_callback((AW_RCB)ED_focus_cb,(AW_CL)GLOBAL_gb_main,0); |
|---|
| 2287 | |
|---|
| 2288 | awmm->set_vertical_change_callback( aed_vertical,(AW_CL)aed_window, (AW_CL)true ); |
|---|
| 2289 | awmm->set_horizontal_change_callback( aed_horizontal,(AW_CL)aed_window, (AW_CL)true ); |
|---|
| 2290 | |
|---|
| 2291 | awmm->set_input_callback (AW_MIDDLE_AREA,aed_input,(AW_CL)aed_window,0); |
|---|
| 2292 | awmm->set_motion_callback (AW_MIDDLE_AREA,aed_motion,(AW_CL)aed_window,0); |
|---|
| 2293 | awmm->set_double_click_callback (AW_MIDDLE_AREA,(AW_CB)aed_double_click,(AW_CL)aed_window,0); |
|---|
| 2294 | |
|---|
| 2295 | awmm->get_root()->add_timed_callback(2000,aed_timer,(AW_CL)aed_window,(AW_CL)awmm); |
|---|
| 2296 | |
|---|
| 2297 | awmm->get_root()->awar(AWAR_HELIX_AT_SAIS)->add_callback( (AW_RCB)aed_resize, (AW_CL)aed_window,0); |
|---|
| 2298 | awmm->get_root()->awar(AWAR_LINE_SPACING)->add_callback( (AW_RCB)aed_resize, (AW_CL)aed_window,0); |
|---|
| 2299 | awmm->get_root()->awar(AWAR_CENTER_SPACING)->add_callback( (AW_RCB)aed_resize, (AW_CL)aed_window,0); |
|---|
| 2300 | create_naligner_variables(awmm->get_root(),aed_window->root->db); |
|---|
| 2301 | create_tool_variables(awmm->get_root(),aed_window->root->db); |
|---|
| 2302 | // create_submission_variables(awmm->get_root(),aed_window->root->db); |
|---|
| 2303 | edg.edk = new ed_key; |
|---|
| 2304 | edg.edk->create_awars(awmm->get_root()); |
|---|
| 2305 | |
|---|
| 2306 | aed_window->load_data(); |
|---|
| 2307 | awmm->reset_scrolled_picture_size(); // middle_area berechnen |
|---|
| 2308 | aed_window->calculate_size(awmm); |
|---|
| 2309 | |
|---|
| 2310 | awmm->show(); |
|---|
| 2311 | |
|---|
| 2312 | } |
|---|
| 2313 | |
|---|
| 2314 | |
|---|
| 2315 | /****************************************************************************************************/ |
|---|
| 2316 | /****************************************************************************************************/ |
|---|
| 2317 | /****************************************************************************************************/ |
|---|
| 2318 | |
|---|
| 2319 | AED_root aed_root; |
|---|
| 2320 | |
|---|
| 2321 | |
|---|
| 2322 | int main(int argc,char **argv) { |
|---|
| 2323 | const char *path; |
|---|
| 2324 | aw_initstatus(); |
|---|
| 2325 | |
|---|
| 2326 | if (argc > 2 || (argc == 2 && strcmp(argv[1], "--help") == 0)) { |
|---|
| 2327 | fprintf(stderr, |
|---|
| 2328 | "\n" |
|---|
| 2329 | "Purpose: Start the old editor.\n" |
|---|
| 2330 | "Usage: arb_edit [database]\n" |
|---|
| 2331 | "\n" |
|---|
| 2332 | ); |
|---|
| 2333 | return EXIT_FAILURE; |
|---|
| 2334 | } |
|---|
| 2335 | |
|---|
| 2336 | if (argc == 1) path = ":"; |
|---|
| 2337 | else path = argv[1]; |
|---|
| 2338 | |
|---|
| 2339 | if (aed_adopen(path,aed_root.ad_main)){ // Database is opened |
|---|
| 2340 | fprintf(stderr, "arb_edit: could not open database '%s'\n", path); |
|---|
| 2341 | return EXIT_FAILURE; |
|---|
| 2342 | } |
|---|
| 2343 | ad_main = aed_root.ad_main; |
|---|
| 2344 | GLOBAL_gb_main = ad_main->get_GBDATA(); |
|---|
| 2345 | |
|---|
| 2346 | aed_root.db = aed_root.aw_root->open_default( ".arb_prop/edit.arb" ); |
|---|
| 2347 | |
|---|
| 2348 | aed_root.aw_root->init_variables( aed_root.db ); |
|---|
| 2349 | aed_root.aw_root->init_root("ARB_EDITOR", false); // initialize window-system |
|---|
| 2350 | |
|---|
| 2351 | aed_create_window(&aed_root); // creates editor window and inserts callbacks |
|---|
| 2352 | aed_root.aw_root->main_loop(); // let's enter main-loop |
|---|
| 2353 | |
|---|
| 2354 | return EXIT_SUCCESS; |
|---|
| 2355 | } |
|---|
| 2356 | |
|---|