Class: FormatTag
- Inherits:
-
Gtk::TextTag
- Object
- Gtk::TextTag
- FormatTag
- Defined in:
- lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb
Overview
this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint([email protected])
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
Instance Method Summary collapse
- #export ⇒ Object
- #import(arg) ⇒ Object
-
#initialize(table, arg = nil) ⇒ FormatTag
constructor
A new instance of FormatTag.
- #save ⇒ Object
- #set_code(c) ⇒ Object
Constructor Details
#initialize(table, arg = nil) ⇒ FormatTag
Returns a new instance of FormatTag.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb', line 6 def initialize(table,arg=nil) @tag_table=table @link=nil @code=nil case arg.class.name when "String" @link=arg super(@link) set_foreground("#0000BB") set_background("white") signal_connect("event"){|tag,text_view,ev,iter| if ev.event_type == Gdk::Event::Type::BUTTON_PRESS @tag_table.browser.help.index.set_cursor(@link) end } when "Hash" if arg.has_key?("name") super(arg["name"]) arg.delete("name") import(arg) end else p "unalble to create tag:#{arg.inspect}" super() end end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
32 33 34 |
# File 'lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb', line 32 def code @code end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
32 33 34 |
# File 'lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb', line 32 def link @link end |
Instance Method Details
#export ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb', line 39 def export unless @link e={"name"=>name, "code"=>@code ? Regexp.escape(@code) : "\\.", "foreground"=>foreground_gdk.to_a, "foreground_set"=>foreground_set?, "background"=>background_gdk.to_a, "background_set"=>background_set?, "justification"=>case justification when Gtk::Justification::LEFT then 0 when Gtk::Justification::RIGHT then 1 when Gtk::Justification::CENTER then 2 when Gtk::Justification::FILL then 3 else 0 end, "font"=>font, "underline"=>case underline when Pango::AttrUnderline::Underline::SINGLE then 1 when Pango::AttrUnderline::Underline::NONE then 0 else 0 end, "strikethrough"=>strikethrough? } return e end end |
#import(arg) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb', line 65 def import(arg) @code=arg["code"] set_foreground_gdk(Gdk::Color.new(arg["foreground"][0],arg["foreground"][1],arg["foreground"][2])) if arg["foreground"] set_foreground_set(arg["foreground_set"] == true) set_background_gdk(Gdk::Color.new(arg["background"][0],arg["background"][1],arg["background"][2])) if arg["background"] set_background_set(arg["background_set"] == true) if arg["justification"] set_justification(arg["justification"]).set_justification_set(true) else set_justification_set(false) end set_underline(arg["underline"]).set_underline_set(true) if arg["underline"] set_font(arg["font"]) if arg["font"] end |
#save ⇒ Object
80 81 82 |
# File 'lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb', line 80 def save ManqodDB.instance.manqod_db.save_help_format(name,export) end |
#set_code(c) ⇒ Object
34 35 36 37 |
# File 'lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb', line 34 def set_code(c) @code=c self end |