Class: RelationHandle
- Inherits:
-
Gtk::EventBox
- Object
- Gtk::EventBox
- RelationHandle
- Defined in:
- lib/RelationBuilder/Relation/RelationHandle.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
-
#dragging ⇒ Object
Returns the value of attribute dragging.
-
#widget ⇒ Object
readonly
Returns the value of attribute widget.
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#initialize(relation, x, y) ⇒ RelationHandle
constructor
A new instance of RelationHandle.
- #move_me(newx = x, newy = y) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(relation, x, y) ⇒ RelationHandle
Returns a new instance of RelationHandle.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# 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. when 1 @widget.set_active(!@widget.active?) when 2 @xshift=ev.x @yshift=ev.y @dragging=true when 3 =Gtk::Menu.new .signal_connect("deactivate"){|| @relation.parentM.set_focused_item(nil)} .append(er=Gtk::ImageMenuItem.new("properties").set_image(Gtk::Image.new(Gtk::Stock::PROPERTIES,Gtk::IconSize::MENU))) er.signal_connect("activate"){|me| @relation.edit} .append(rr=Gtk::ImageMenuItem.new("remove").set_image(Gtk::Image.new(Gtk::Stock::DISCONNECT,Gtk::IconSize::MENU))) rr.signal_connect("activate"){|me| @relation.remove} .show_all .popup(nil,nil,ev.,ev.time) end true } signal_connect('motion-notify-event'){|me,event| if @dragging @x=@relation.parentM..pointer[0]-@xshift @y=@relation.parentM..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 |
Instance Attribute Details
#dragging ⇒ Object
Returns the value of attribute dragging.
59 60 61 |
# File 'lib/RelationBuilder/Relation/RelationHandle.rb', line 59 def dragging @dragging end |
#widget ⇒ Object (readonly)
Returns the value of attribute widget.
58 59 60 |
# File 'lib/RelationBuilder/Relation/RelationHandle.rb', line 58 def @widget end |
#x ⇒ Object (readonly)
Returns the value of attribute x.
58 59 60 |
# File 'lib/RelationBuilder/Relation/RelationHandle.rb', line 58 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
58 59 60 |
# File 'lib/RelationBuilder/Relation/RelationHandle.rb', line 58 def y @y end |
Instance Method Details
#move_me(newx = x, newy = y) ⇒ Object
61 62 63 64 65 |
# 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 ⇒ Object
66 67 68 |
# File 'lib/RelationBuilder/Relation/RelationHandle.rb', line 66 def to_s "Handle of #{@relation}" end |