Class: OutputView
- Inherits:
-
Object
- Object
- OutputView
- Defined in:
- ext/ae-output/ae-output.rb
Overview
require “base/a-utils”
Instance Attribute Summary collapse
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(parent = nil) ⇒ OutputView
constructor
A new instance of OutputView.
- #pop_up_menu ⇒ Object
- #save ⇒ Object
- #save_as ⇒ Object
Constructor Details
#initialize(parent = nil) ⇒ OutputView
Returns a new instance of OutputView.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'ext/ae-output/ae-output.rb', line 14 def initialize(parent=nil) left_frame = TkFrame.new(parent.frame.hinner_frame, Arcadia.style('panel')).place('x' => '0','y' => '0','relheight' => '1','width' => '25') right_frame = TkFrame.new(parent.frame.hinner_frame, Arcadia.style('panel')).place('x' => '25','y' => '0','relheight' => '1','relwidth' => '1','width' => '-25') @button_u = Tk::BWidget::Button.new(left_frame, Arcadia.style('toolbarbutton')){ image TkPhotoImage.new('dat' => CLEAR_GIF) helptext 'Clear' #foreground 'blue' command proc{parent.main_frame.text.delete('1.0','end')} #relief 'groove' pack('side' =>'top', 'anchor'=>'n',:padx=>0, :pady=>0) } @text = TkArcadiaText.new(right_frame, {'wrap'=> 'none'}.update(Arcadia.style('edit')) ) @text.extend(TkScrollableWidget).show @text.tag_configure('simple_msg', # 'background' => '#d9d994', 'borderwidth'=>1, 'relief'=> 'flat' ) @text.tag_configure('debug_msg', # 'background' => '#f6c9f6', # 'foreground' => '#000000', 'borderwidth'=>1, 'relief'=> 'flat' ) @text.tag_configure('error_msg', # 'background' => '#f6c9f6', 'foreground' => Arcadia.conf('hightlight.string.foreground'), 'borderwidth'=>1, 'relief'=> 'flat' ) @text.tag_configure('bord_msg', #'foreground' => '#b9b8b9' 'foreground' => Arcadia.conf('hightlight.comment.foreground') ) @text.tag_configure('sel', 'background'=>Arcadia.conf('hightlight.sel.background'), 'foreground'=>Arcadia.conf('hightlight.sel.foreground') ) end |
Instance Attribute Details
#text ⇒ Object (readonly)
Returns the value of attribute text.
13 14 15 |
# File 'ext/ae-output/ae-output.rb', line 13 def text @text end |
Instance Method Details
#pop_up_menu ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'ext/ae-output/ae-output.rb', line 60 def @pop_up = TkMenu.new( :parent=>@text, :tearoff=>0, :title => 'Menu' ) @pop_up.extend(TkAutoPostMenu) @pop_up.configure(Arcadia.style('menu')) @pop_up.insert('end', :command, :state=>'disabled', :label=>'Output', :background=>Arcadia.conf('titlelabel.background'), :font => "#{Arcadia.conf('menu.font')} bold", :hidemargin => true ) #Arcadia.instance.main_menu.update_style(@pop_up) @pop_up.insert('end', :command, :label=>'Save', :hidemargin => false, :command=> proc{save_as} ) @pop_up.insert('end', :command, :label=>'Set wrap', :hidemargin => false, :command=> proc{@text.configure('wrap'=>'word');@text.hide_h_scroll} ) @pop_up.insert('end', :command, :label=>'Set no wrap', :hidemargin => false, :command=> proc{@text.configure('wrap'=>'none');@text.show_h_scroll} ) @text.bind("Button-3", proc{|x,y| _x = TkWinfo.pointerx(@text) _y = TkWinfo.pointery(@text) @pop_up.popup(_x,_y) }, "%x %y") end |
#save ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'ext/ae-output/ae-output.rb', line 115 def save if !@file save_as else f = File.new(@file, "w") begin if f f.syswrite(@text.value) end ensure f.close unless f.nil? end end end |
#save_as ⇒ Object
130 131 132 133 134 135 136 |
# File 'ext/ae-output/ae-output.rb', line 130 def save_as @file = Tk.getSaveFile("filetypes"=>[["Ruby Files", [".rb", ".rbw"]],["All Files", [".*"]]]) @file = nil if @file == "" # cancelled if @file save end end |