Class: HinnerStringDialog

Inherits:
HinnerDialog show all
Defined in:
lib/a-tkcommons.rb

Instance Method Summary collapse

Methods inherited from HinnerDialog

#is_modal?, #make_scrollable_frame, #release, #show_modal

Constructor Details

#initialize(label = nil, side = 'top', args = nil) ⇒ HinnerStringDialog

Returns a new instance of HinnerStringDialog.



3869
3870
3871
3872
3873
3874
# 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

Instance Method Details

#build_guiObject



3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
3893
3894
3895
3896
3897
3898
3899
3900
3901
3902
3903
3904
3905
3906
3907
3908
3909
3910
3911
3912
3913
3914
3915
3916
3917
3918
3919
3920
3921
3922
3923
3924
# 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

#closeObject



3940
3941
3942
3943
3944
# File 'lib/a-tkcommons.rb', line 3940

def close
  @closed=true
  self.release
  destroy  
end

#stringObject



3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
# 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