Class: Watobo::Gui::FuzzerGenSelect
- Inherits:
-
FXVerticalFrame
- Object
- FXVerticalFrame
- Watobo::Gui::FuzzerGenSelect
- Defined in:
- lib/watobo/gui/fuzzer_gui.rb
Instance Method Summary collapse
- #addValue(sender, sel, ptr) ⇒ Object
- #createGenerator(fuzzer) ⇒ Object
- #disableFrame(frame) ⇒ Object
- #enableFrame(frame) ⇒ Object
-
#initialize(owner, interface, opts) ⇒ FuzzerGenSelect
constructor
A new instance of FuzzerGenSelect.
- #onValueSelect(sender, sel, selected) ⇒ Object
- #removeValue(sender, sel, ptr) ⇒ Object
- #selectFile(sender, sel, ptr) ⇒ Object
- #updateFields ⇒ Object
Constructor Details
#initialize(owner, interface, opts) ⇒ FuzzerGenSelect
Returns a new instance of FuzzerGenSelect.
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 670 def initialize(owner, interface, opts) super(owner, opts) @interface = interface group_box = FXGroupBox.new(self, "Select Source", LAYOUT_SIDE_TOP|FRAME_GROOVE|LAYOUT_FILL_X|LAYOUT_FILL_Y, 0, 0, 0, 0) @source_dt = FXDataTarget.new(0) @source_dt.connect(SEL_COMMAND) do case @source_dt.value when 0 # puts "File" enableFrame(@file_select_frame) disableFrame(@counter_frame) disableFrame(@list_frame) when 1 disableFrame(@file_select_frame) disableFrame(@list_frame) enableFrame(@counter_frame) # puts "Generator" when 2 disableFrame(@counter_frame) enableFrame(@list_frame) disableFrame(@file_select_frame) # puts "List" end @file_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil) @gen_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil) @list_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil) end file_rb_frame = FXHorizontalFrame.new(group_box, :opts => LAYOUT_FILL_X) @file_rb = FXRadioButton.new(file_rb_frame, "File", @source_dt, FXDataTarget::ID_OPTION) @file_select_frame = FXHorizontalFrame.new(group_box, :opts => LAYOUT_FILL_X, :padding => 0) @source_file = FXDataTarget.new('') @sourceFileText = FXTextField.new(@file_select_frame, 1, :target => @source_file, :selector => FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_X|LAYOUT_FILL_COLUMN) = FXButton.new(@file_select_frame, "Select") .connect(SEL_COMMAND, method(:selectFile) ) counter_rb_frame = FXHorizontalFrame.new(group_box, LAYOUT_FILL_X) @gen_rb = FXRadioButton.new(counter_rb_frame, "Counter", @source_dt, FXDataTarget::ID_OPTION + 1) @counter_frame = FXHorizontalFrame.new(group_box, LAYOUT_FILL_X, :padding => 0 ) @cstep = FXDataTarget.new(0) @cstepText = FXTextField.new(@counter_frame, 3, :target => @cstep, :selector => FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_RIGHT) FXLabel.new(@counter_frame, "Step",nil, :opts => LAYOUT_RIGHT) @cstop = FXDataTarget.new(0) @cstopText = FXTextField.new(@counter_frame, 3, :target => @cstop, :selector => FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_RIGHT) FXLabel.new(@counter_frame, "Stop",nil, :opts => LAYOUT_RIGHT) @cstart = FXDataTarget.new(0) @cstartText = FXTextField.new(@counter_frame, 3, :target => @cstart, :selector => FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|LAYOUT_FILL_COLUMN|LAYOUT_RIGHT) FXLabel.new(@counter_frame, "Start",nil, :opts => LAYOUT_RIGHT) list_rb_frame = FXHorizontalFrame.new(group_box, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y) @list_rb = FXRadioButton.new(list_rb_frame, "List", @source_dt, FXDataTarget::ID_OPTION + 2) @list_frame = FXVerticalFrame.new(list_rb_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y, :padding => 0) frame = FXHorizontalFrame.new(@list_frame, :opts => LAYOUT_FILL_X, :padding => 0) @new_list_item_dt = FXDataTarget.new('') @new_list_item = FXTextField.new(frame, 10, :target => @new_list_item_dt, :selector => FXDataTarget::ID_VALUE, :opts => TEXTFIELD_NORMAL|LAYOUT_SIDE_LEFT|LAYOUT_FILL_X) # FXLabel.new(frame, "Value: ") @addButton = FXButton.new(frame, "Add", nil, nil, 0, :opts => FRAME_RAISED|FRAME_THICK) @addButton.connect(SEL_COMMAND, method(:addValue)) @remButton = FXButton.new(frame, "Remove", nil, nil, 0, :opts => FRAME_RAISED|FRAME_THICK) @remButton.connect(SEL_COMMAND, method(:removeValue)) list_border = FXVerticalFrame.new(@list_frame, :opts => LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_SUNKEN|FRAME_GROOVE, :padding => 0) @valueList = FXList.new(list_border, :opts => LIST_EXTENDEDSELECT|LAYOUT_FILL_X|LAYOUT_FILL_Y) @valueList.numVisible = 4 @valueList.connect(SEL_COMMAND, method(:onValueSelect)) enableFrame(@file_select_frame) disableFrame(@counter_frame) disableFrame(@list_frame) updateFields() end |
Instance Method Details
#addValue(sender, sel, ptr) ⇒ Object
613 614 615 616 617 618 619 620 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 613 def addValue(sender, sel, ptr) if @new_list_item_dt.value != '' then index = @valueList.appendItem(@new_list_item_dt.value ) @valueList.makeItemVisible(index) @new_list_item_dt.value = '' @new_list_item.handle(self, FXSEL(SEL_UPDATE, 0), nil) end end |
#createGenerator(fuzzer) ⇒ Object
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 622 def createGenerator(fuzzer) gen = case @source_dt.value when 0 #puts "File Generator Selected" Watobo::FuzzFile.new(fuzzer, @source_file.value) when 1 # counter selected Watobo::FuzzCounter.new(fuzzer, :start => @cstart.value.to_i, :stop => @cstop.value.to_i, #:count => @ccount.value.to_i, :step => @cstep.value.to_i) when 2 list = [] @valueList.each do |item| # puts item list.push item.text end Watobo::FuzzList.new(fuzzer, list) end return gen end |
#disableFrame(frame) ⇒ Object
648 649 650 651 652 653 654 655 656 657 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 648 def disableFrame(frame) frame.children.each do |c| c.children.each do |sc| sc.disable sc.selBackColor = sc.parent.backColor if sc.respond_to? :selBackColor end c.disable c.selBackColor = c.parent.backColor if c.respond_to? :selBackColor end end |
#enableFrame(frame) ⇒ Object
659 660 661 662 663 664 665 666 667 668 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 659 def enableFrame(frame) frame.children.each do |c| c.children.each do |sc| sc.enable sc.selBackColor = FXColor::White if sc.respond_to? :selBackColor end c.enable c.selBackColor = FXColor::White if c.respond_to? :selBackColor end end |
#onValueSelect(sender, sel, selected) ⇒ Object
599 600 601 602 603 604 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 599 def onValueSelect(sender, sel, selected) item = @valueList.currentItem if item >= 0 then @new_list_item_dt.value = @valueList.getItemText(item) end end |
#removeValue(sender, sel, ptr) ⇒ Object
606 607 608 609 610 611 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 606 def removeValue(sender, sel, ptr) item = @valueList.currentItem if item >= 0 then @valueList.removeItem(item) end end |
#selectFile(sender, sel, ptr) ⇒ Object
588 589 590 591 592 593 594 595 596 597 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 588 def selectFile(sender, sel, ptr) filename = FXFileDialog.getOpenFilename(self, "Select Source File", @source_file.value) if filename != "" then if File.exists?(filename) then @source_file.value = filename @sourceFileText.handle(self, FXSEL(SEL_UPDATE, 0), nil) end end end |
#updateFields ⇒ Object
578 579 580 581 582 583 584 585 586 |
# File 'lib/watobo/gui/fuzzer_gui.rb', line 578 def updateFields @file_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil) @gen_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil) @list_rb.handle(self, FXSEL(SEL_UPDATE, 0), nil) @sourceFileText.handle(self, FXSEL(SEL_UPDATE, 0), nil) @cstartText.handle(self, FXSEL(SEL_UPDATE, 0), nil) @cstopText.handle(self, FXSEL(SEL_UPDATE, 0), nil) @cstepText.handle(self, FXSEL(SEL_UPDATE, 0), nil) end |