class HinnerStringDialog

Public Class Methods

new(label=nil, side='top',args=nil) click to toggle source
Calls superclass method HinnerDialog::new
# File lib/a-tkcommons.rb, line 3869
def initialize(label=nil, side='top',args=nil)
  super(side, args)
  @label = label
  build_gui
  @closed = false
end

Public Instance Methods

build_gui() click to toggle source
# File lib/a-tkcommons.rb, line 3876
def build_gui
  @font = Arcadia.conf('edit.font')
  @font_bold = "#{Arcadia.conf('edit.font')} bold"
  @font_metrics = TkFont.new(@font).metrics
  @font_metrics_bold = TkFont.new(@font_bold).metrics
  if !@label.nil?
    Arcadia.wf.label(self, 'text' => @label).pack('side' =>'left')
  end
  @string_text = TkText.new(self, Arcadia.style('text').update({"height"=>'1',"highlightcolor"=>Arcadia.conf('panel.background'), "bg"=>Arcadia.conf('panel.background')})).pack('side' =>'left','padx'=>5, 'pady'=>5, 'fill'=>'x', 'expand'=>'1')
  #{"bg"=>'white', "height"=>'1', "borderwidth"=>0, 'font'=>@font}
  @string_text.bind_append("Enter", proc{ @string_text.set_insert("end")})

  
  @tag_selected = "link_selected"
  @string_text.tag_configure(@tag_selected,'borderwidth'=>0, 'relief'=>'flat', 'underline'=>true)
  @string_text.tag_bind(@tag_selected,"ButtonRelease-1",  proc{ 
     self.release
  } )
  @string_text.tag_bind(@tag_selected,"Enter", proc{@string_text.configure('cursor'=> 'hand2')})
  @string_text.tag_bind(@tag_selected,"Leave", proc{@string_text.configure('cursor'=> @cursor)})
  _self=self
  @string_text.bind_append('KeyPress', "%K"){|_keysym|
    case _keysym
    when "Return"
      _self.release
    end
  }   
  @string_text.bind_append('KeyRelease', "%K"){|_keysym|
    case _keysym
    when 'Escape','Tab', "Return"
    else
      @string_text.tag_remove(@tag_selected,'1.0','end')
      @string_text.tag_add(@tag_selected ,'1.0','end')
    end
  }   
  
  @string_text.bind_append("Control-KeyPress", "%K"){|_keysym|
    case _keysym
    when 'd'
      _self.close
      Tk.callback_break
    end
  }    

  @close_button = Arcadia.wf.toolbutton(self){
    command proc{_self.close}
    image Arcadia.image_res(CLOSE_FRAME_GIF)
  }.pack('side' =>'right','padx'=>5, 'pady'=>0)
end
close() click to toggle source
# File lib/a-tkcommons.rb, line 3940
def close
  @closed=true
  self.release
  destroy  
end
string() click to toggle source
# File lib/a-tkcommons.rb, line 3926
def string
  @string_text.focus
  @string_text.set_insert("end")
  @string_text.see("end")

  show_modal(false)
  if @closed == false
    string_selected = @string_text.get("0.1","end").strip
    destroy  
    string_selected
  end
end