class RelationHandle
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
dragging[RW]
widget[R]
x[R]
y[R]
Public Class Methods
new(relation,x,y)
click to toggle source
Calls superclass method
# File lib/RelationBuilder/Relation/RelationHandle.rb, line 6 def initialize(relation,x,y) super() visible_window=false add(@widget=Gtk::ToggleButton.new) set_above_child(true) @widget.set_size_request(10,10) @dragging=false @relation=relation @x=x @y=y @widget.signal_connect("toggled"){|me,ev| @relation.parentM.review_all @relation.parentM.changed(@relation) } signal_connect('button-press-event'){|me,ev| @relation.parentM.set_focused_item(self) case ev.button when 1 @widget.set_active(!@widget.active?) when 2 @xshift=ev.x @yshift=ev.y @dragging=true when 3 menu=Gtk::Menu.new menu.signal_connect("deactivate"){|menu| @relation.parentM.set_focused_item(nil)} menu.append(er=Gtk::ImageMenuItem.new("properties").set_image(Gtk::Image.new(Gtk::Stock::PROPERTIES,Gtk::IconSize::MENU))) er.signal_connect("activate"){|me| @relation.edit} menu.append(rr=Gtk::ImageMenuItem.new("remove").set_image(Gtk::Image.new(Gtk::Stock::DISCONNECT,Gtk::IconSize::MENU))) rr.signal_connect("activate"){|me| @relation.remove} menu.show_all menu.popup(nil,nil,ev.button,ev.time) end true } signal_connect('motion-notify-event'){|me,event| if @dragging @x=@relation.parentM.widget.pointer[0]-@xshift @y=@relation.parentM.widget.pointer[1]-@yshift move_me end true } signal_connect('button-release-event'){|me,event| if @dragging @relation.save @dragging=false end @relation.parentM.set_focused_item(nil) true } end
Public Instance Methods
move_me(newx=x,newy=y)
click to toggle source
# File lib/RelationBuilder/Relation/RelationHandle.rb, line 61 def move_me(newx=x,newy=y) @x=newx @y=newy parent.move(self,x,y) if parent end
to_s()
click to toggle source
# File lib/RelationBuilder/Relation/RelationHandle.rb, line 66 def to_s "Handle of #{@relation}" end