Class: QDA::GUI::CompositeText
- Inherits:
-
HighlightingTextCtrl
- Object
- Wx::TextCtrl
- TrueSelectionTextCtrl
- HighlightingTextCtrl
- QDA::GUI::CompositeText
- Includes:
- FindableText
- Defined in:
- lib/weft/wxgui/controls/textcontrols.rb
Overview
a text display that is made up of text fragments from multiple documents. It keeps track of which fragment is found at which point, so that when passages are marked they are routed back to the source document.
Defined Under Namespace
Classes: TextTable
Constant Summary collapse
- HEADER_STYLE =
Wx::TextAttr.new(Wx::RED)
- NORMAL_STYLE =
Wx::TextAttr.new(Wx::BLACK)
Constants included from HighlightingTextCtrl::TextColourHighlighter
HighlightingTextCtrl::TextColourHighlighter::HIGHLIGHTED_STYLE
Constants inherited from TrueSelectionTextCtrl
TrueSelectionTextCtrl::NEWLINE_CORRECTION_FACTOR
Instance Method Summary collapse
-
#highlight_codingtable(codingtable) ⇒ Object
highlights the coded vectors or fragments.
-
#initialize(parent, text, offset, app) ⇒ CompositeText
constructor
A new instance of CompositeText.
- #jump_to_fragment(evt) ⇒ Object
-
#populate(fragments) ⇒ Object
displays the hash table of fragments, keyed on document title as a set of results, ordered by case-insensitive document title order.
- #selection_to_fragments ⇒ Object
-
#set_font(font) ⇒ Object
need to repaint headers and so on.
Methods included from FindableText
#get_subject, #on_find, #on_find_close, #searching_down?, #searching_up?, #start_find
Methods included from HighlightingTextCtrl::TextColourHighlighter
#clear, #highlight, #unhighlight
Methods included from HighlightingTextCtrl::NullHighlighter
Methods inherited from TrueSelectionTextCtrl
#save_position, #true_index_to_pos, #true_insertion_point, #true_point, #true_selection
Constructor Details
#initialize(parent, text, offset, app) ⇒ CompositeText
Returns a new instance of CompositeText.
380 381 382 383 384 385 386 387 388 389 |
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 380 def initialize(parent, text, offset, app) @saved_styles = Hash.new() super(parent, -1, text, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::TE_MULTILINE|Wx::TE_READONLY|Wx::TE_RICH|Wx::TE_NOHIDESEL) @app = app evt_enter_window do | e | set_cursor Wx::Cursor.new(Wx::CURSOR_IBEAM) end set_font( @app.display_font ) end |
Instance Method Details
#highlight_codingtable(codingtable) ⇒ Object
highlights the coded vectors or fragments
450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 450 def highlight_codingtable(codingtable) return unless @fragments areas = @fragments.to_codingtable.join(codingtable) save_position do unhighlight() areas.each do | docid, codes | codes.each do | code | translated = @table.translate(docid, code.offset) next if translated.nil? highlight(translated, translated + code.length) end end end end |
#jump_to_fragment(evt) ⇒ Object
434 435 436 437 438 439 440 441 |
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 434 def jump_to_fragment(evt) frag, offset = *@table.fetch(true_insertion_point) # if we've clicked on a text bit return unless frag @app.on_document_open( frag.docid, frag.offset + offset ) end |
#populate(fragments) ⇒ Object
displays the hash table of fragments, keyed on document title as a set of results, ordered by case-insensitive document title order.
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 |
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 393 def populate(fragments) self.clear() @table = TextTable.new() @cursor = 0 @fragments = fragments # sort by document title save_position() do fragments.each_title do | doc_title, frags | frags.each { | frag | write_frag(frag) } write_range("\n", nil) end end evt_left_dclick() { | e | jump_to_fragment(e) } self.insertion_point = 0 end |
#selection_to_fragments ⇒ Object
443 444 445 446 447 |
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 443 def selection_to_fragments() cursor, finish = *true_selection() length = finish - cursor results = @table.range_to_vectors(cursor, length) end |
#set_font(font) ⇒ Object
need to repaint headers and so on
466 467 468 469 470 471 472 473 |
# File 'lib/weft/wxgui/controls/textcontrols.rb', line 466 def set_font(font) super(font) @saved_styles.each do | style, segments | segments.each do | seg | set_style(seg[0], seg[1], style) end end end |