Class: LayLabel

Inherits:
Gtk::EventBox
  • Object
show all
Defined in:
lib/wysiwyg-print-label.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

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ LayLabel

Returns a new instance of LayLabel.



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
# File 'lib/wysiwyg-print-label.rb', line 6

def initialize(text)
	@x=0
	@y=0
  @text=text
  @dragging=false
  @myobject=Gtk::Label.new(@text)
  super()
  add(@myobject)

#	set_events(Gdk::Event::MOTION_NOTIFY | Gdk::Event::BUTTON_MOTION_MASK)
#	set_can_focus(true)
signal_connect('event'){|me,event|
  case event.event_type
	when Gdk::Event::BUTTON_PRESS
	  @xshift=event.x
	  @yshift=event.y
	  @dragging=true
	  get_ancestor(WysiwygPrintEditor).set_focused_item(self)
#		  set_visible_window(true)
#		  @myobject.style.base_gc(Gtk::STATE_NORMAL).background.set_red(65535)
	when Gdk::Event::MOTION_NOTIFY
	  @x=@x+event.x-@xshift if (@x+event.x-@xshift).to_i.modulo(10)==0 
	  @y=@y+event.y-@yshift if (@y+event.y-@yshift).to_i.modulo(10)==0
	  move_me
	when Gdk::Event::BUTTON_RELEASE
	  @dragging=false
#		  set_state(Gtk::STATE_NORMAL)
	else 
#		  print "unhandled: ",event.inspect,"\n"
  end
}
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



40
41
42
# File 'lib/wysiwyg-print-label.rb', line 40

def text
  @text
end

#xObject

Returns the value of attribute x.



38
39
40
# File 'lib/wysiwyg-print-label.rb', line 38

def x
  @x
end

#yObject

Returns the value of attribute y.



39
40
41
# File 'lib/wysiwyg-print-label.rb', line 39

def y
  @y
end

Instance Method Details

#modify_font(new_font) ⇒ Object



46
47
48
49
50
# File 'lib/wysiwyg-print-label.rb', line 46

def modify_font(new_font)
  super(new_font)
  @myobject.modify_font(new_font)
  self
end

#move_me(newx = @x, newy = @y) ⇒ Object



41
42
43
44
45
# File 'lib/wysiwyg-print-label.rb', line 41

def move_me(newx=@x,newy=@y)
  @x=newx
  @y=newy
  parent.move(self)
end

#set_text(newtext = @text) ⇒ Object



51
52
53
54
55
# File 'lib/wysiwyg-print-label.rb', line 51

def set_text(newtext=@text)
  @text=newtext
  @myobject.text=@text
  self
end