class FormatTag

this file is part of manqod manqod is distributed under the CDDL licence the author of manqod is Dobai-Pataky Balint(dpblnt@gmail.com)

Attributes

code[R]

Public Class Methods

new(table,arg=nil) click to toggle source
Calls superclass method
# 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

Public Instance Methods

export() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb, line 80
def save
        ManqodDB.instance.manqod_db.save_help_format(name,export)
end
set_code(c) click to toggle source
# File lib/ManqodHelp/HelpBrowser/FormatTagTable/FormatTag.rb, line 34
def set_code(c)
        @code=c
        self
end