Changeset 1594:0bd9e53c8b28 in lemon-0.x
- Timestamp:
- 07/27/05 12:47:38 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2098
- Location:
- gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/graph_displayer_canvas-event.cc
r1592 r1594 425 425 { 426 426 case GDK_BUTTON_PRESS: 427 //finding the clicked items 427 428 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 428 429 active_item=(get_item_at(clicked_x, clicked_y)); 429 430 active_node=INVALID; 430 431 active_edge=INVALID; 432 433 //was it a node? 431 434 for (NodeIt i(g); i!=INVALID; ++i) 432 435 { … … 436 439 } 437 440 } 441 //or was it an edge? 438 442 if(active_node==INVALID) 439 443 { … … 446 450 } 447 451 } 452 453 //recolor activated item 448 454 if(active_item) 449 455 { … … 456 462 if(active_item) 457 463 { 464 //the cursor was not moved since pressing it 458 465 if( active_item == ( get_item_at (clicked_x, clicked_y) ) ) 459 466 { 467 //a node was found 460 468 if(active_node!=INVALID) 461 469 { … … 523 531 { 524 532 case GDK_KEY_PRESS: 533 //for Escape or Enter hide the displayed widget 525 534 { 526 535 nodeMapEditEventHandler(e); … … 528 537 } 529 538 case GDK_BUTTON_PRESS: 539 //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. 530 540 { 541 //find the activated item 531 542 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 532 543 active_item=(get_item_at(clicked_x, clicked_y)); 544 545 //determine, whether it was an edge 533 546 Graph::EdgeIt clicked_edge=INVALID; 534 547 for (EdgeIt i(g); i!=INVALID; ++i) … … 539 552 } 540 553 } 554 //if it was really an edge... 541 555 if(clicked_edge!=INVALID) 542 556 { 543 if(edgetextmap[clicked_edge]->property_text().get_value()!="") 544 { 545 active_edge=clicked_edge; 546 if(canvasentrywidget) 557 //If there is already edited edge, it has to be saved first 558 if(entrywidget.is_visible()) 559 { 560 GdkEvent * generated=new GdkEvent(); 561 generated->type=GDK_KEY_PRESS; 562 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; 563 entryWidgetChangeHandler(generated); 564 } 565 //If the previous value could be saved, we can go further, otherwise not 566 if(!entrywidget.is_visible()) 567 { 568 //and there is activated map 569 if(edgetextmap[clicked_edge]->property_text().get_value()!="") 547 570 { 548 delete(canvasentrywidget); 571 //activate the general variable for it 572 active_edge=clicked_edge; 573 //delete visible widget if there is 574 if(canvasentrywidget) 575 { 576 delete(canvasentrywidget); 577 } 578 579 //initialize the entry 580 entrywidget.show(); 581 582 //fill in the correct value 583 entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value()); 584 585 //replace and resize the entry to the activated edge and put it in a Canvas::Widget to be able to display it on gdc 586 xy<double> entry_coos; 587 entry_coos.x=(edgetextmap[active_edge])->property_x().get_value(); 588 entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2; 589 entry_coos.y=(edgetextmap[active_edge])->property_y().get_value(); 590 entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2; 591 canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); 592 canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*1.5); 593 canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5); 549 594 } 550 entrywidget.show();551 entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value());552 xy<double> entry_coos;553 entry_coos.x=(edgetextmap[active_edge])->property_x().get_value();554 entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2;555 entry_coos.y=(edgetextmap[active_edge])->property_y().get_value();556 entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2;557 canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);558 canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*1.5);559 canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5);560 595 } 561 596 } 597 //if it was not an edge... 562 598 else 563 599 { 600 //In this case the click did not happen on an edge 601 //if there is visible entry we save the value in it 602 //we pretend like an Enter was presse din the Entry widget 564 603 GdkEvent * generated=new GdkEvent(); 565 604 generated->type=GDK_KEY_PRESS; … … 580 619 { 581 620 case GDK_KEY_PRESS: 621 //for Escape or Enter hide the displayed widget 582 622 { 583 623 switch(((GdkEventKey*)e)->keyval) … … 597 637 } 598 638 case GDK_BUTTON_PRESS: 639 //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. 599 640 { 641 //find the activated item 600 642 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 601 643 active_item=(get_item_at(clicked_x, clicked_y)); 644 645 //determine, whether it was a node 602 646 Graph::NodeIt clicked_node=INVALID; 603 647 for (NodeIt i(g); i!=INVALID; ++i) … … 608 652 } 609 653 } 654 655 //if it was really an edge... 610 656 if(clicked_node!=INVALID) 611 657 { … … 621 667 if(!entrywidget.is_visible()) 622 668 { 623 669 //and there is activated map 624 670 if(nodetextmap[clicked_node]->property_text().get_value()!="") 625 671 { 672 //activate the general variable for it 626 673 active_node=clicked_node; 674 //delete visible widget if there is 627 675 if(canvasentrywidget) 628 676 { 629 677 delete(canvasentrywidget); 630 678 } 679 680 //initialize the entry 631 681 entrywidget.show(); 682 683 //fill in the correct value 632 684 entrywidget.set_text(nodetextmap[active_node]->property_text().get_value()); 685 686 //replace and resize the entry to the activated node and put it in a Canvas::Widget to be able to display it on gdc 633 687 xy<double> entry_coos; 634 688 entry_coos.x=(nodetextmap[active_node])->property_x().get_value(); … … 642 696 } 643 697 } 698 //if it was not an edge... 644 699 else 645 700 { 701 //In this case the click did not happen on an edge 702 //if there is visible entry we save the value in it 703 //we pretend like an Enter was presse din the Entry widget 646 704 GdkEvent * generated=new GdkEvent(); 647 705 generated->type=GDK_KEY_PRESS; … … 671 729 case GDK_Return: 672 730 { 731 //these variables check whether the text in the entry is valid 673 732 bool valid_double=true; 674 733 int point_num=0; 734 735 //getting the value from the entry and converting it to double 675 736 Glib::ustring mapvalue_str = entrywidget.get_text(); 676 737 … … 694 755 double mapvalue_d=atof(mapvalue_ch); 695 756 696 // double double_map_fract_value=0; 697 // double double_map_value=0; 698 // int offset=0; 699 // int found_letter=0; 700 //converting text to double 701 // for(int i=0;i<(int)(mapvalue.length());i++) 702 // { 703 // if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.')) 704 // { 705 // if(mapvalue[i]=='.') 706 // { 707 // //for calculating non-integer part of double we step backward from the end 708 // //after each step the number will be divided by ten, and the new value will be added 709 // //to step backward from the end until the point the actual character of the string is the following: 710 // // mapvalue.length()-(i-position_of_point) 711 // //if i was the number of the first character after the decimal point the selected character will be the last 712 // //if i was the number of the last character, the selected character will be the first after the decimal point 713 // offset=mapvalue.length()+i; 714 // } 715 // else 716 // { 717 // if(!offset) 718 // { 719 // double_map_value=10*double_map_value+mapvalue[i]-'0'; 720 // } 721 // else 722 // { 723 // double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10; 724 // } 725 // } 726 // } 727 // else 728 // { 729 // found_letter++; 730 // continue; 731 // } 732 // } 733 757 //if the text in the entry was correct 734 758 if((point_num<=1)&&(valid_double)) 735 759 { 760 //save the value to the correct place 736 761 switch(actual_tool) 737 762 { … … 749 774 entrywidget.hide(); 750 775 } 776 //the text in the entry was not correct for a double 751 777 else 752 778 { … … 827 853 void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname) 828 854 { 855 //create the new map 829 856 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,default_value); 830 857 mapstorage.addEdgeMap(mapname,emptr); 858 859 //add it to the list of the displayable maps 831 860 mapwin->registerNewEdgeMap(mapname); 861 862 //display it 832 863 changeEdgeText(mapname); 833 864 } … … 835 866 void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname) 836 867 { 868 //create the new map 837 869 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (g,default_value); 838 870 mapstorage.addNodeMap(mapname,emptr); 871 872 //add it to the list of the displayable maps 839 873 mapwin->registerNewNodeMap(mapname); 874 875 //display it 840 876 changeNodeText(mapname); 841 877 } -
gui/map_win.cc
r1592 r1594 260 260 e_combo_array[i].set_popdown_strings(listStrings); 261 261 } 262 //setting text property for the new map 262 263 Gtk::Entry* entry = e_combo_array[E_TEXT].get_entry(); 263 264 entry->set_text((Glib::ustring)newmapname); … … 273 274 n_combo_array[i].set_popdown_strings(listStrings); 274 275 } 276 //setting text property for the new map 275 277 Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry(); 276 278 entry->set_text((Glib::ustring)newmapname);
Note: See TracChangeset
for help on using the changeset viewer.