Class: QDA::GUI::CodeTextCtrl

Inherits:
Wx::TextCtrl
  • Object
show all
Defined in:
lib/weft/wxgui/inspectors/script.rb

Instance Method Summary collapse

Constructor Details

#initialize(parent, code = '') ⇒ CodeTextCtrl

Returns a new instance of CodeTextCtrl.



10
11
12
13
14
15
# File 'lib/weft/wxgui/inspectors/script.rb', line 10

def initialize(parent, code = '')
  super( parent, -1, code, DEF_POS, DEF_SIZE,
         Wx::TE_MULTILINE|Wx::TE_RICH|Wx::TE_PROCESS_TAB )
  set_default_style( normal_style )
  evt_set_focus() { reset() }
end

Instance Method Details

#bold_fontObject



27
28
29
# File 'lib/weft/wxgui/inspectors/script.rb', line 27

def bold_font
  @bold_font ||= Wx::Font.new( 10, Wx::MODERN, Wx::NORMAL, Wx::BOLD )
end

#bold_styleObject



31
32
33
# File 'lib/weft/wxgui/inspectors/script.rb', line 31

def bold_style
  @bold_style ||= Wx::TextAttr.new(Wx::RED, Wx::WHITE, bold_font)
end

#highlight_line(lineno) ⇒ Object



35
36
37
38
39
# File 'lib/weft/wxgui/inspectors/script.rb', line 35

def highlight_line(lineno)
  line_start = xy_to_position(0, lineno)
  line_end   = line_start + get_line_length(lineno)
  set_style(line_start, line_end, bold_style)
end

#normal_fontObject



21
22
23
# File 'lib/weft/wxgui/inspectors/script.rb', line 21

def normal_font
  @normal_font ||= Wx::Font.new( 10, Wx::MODERN, Wx::NORMAL, Wx::NORMAL )
end

#normal_styleObject



24
25
26
# File 'lib/weft/wxgui/inspectors/script.rb', line 24

def normal_style
  @normal_style ||= Wx::TextAttr.new(Wx::BLACK, Wx::WHITE, normal_font)
end

#resetObject



17
18
19
# File 'lib/weft/wxgui/inspectors/script.rb', line 17

def reset
  set_style(0, get_last_position, normal_style)
end