Class: ImageButton

Inherits:
Gtk::EventBox
  • Object
show all
Defined in:
lib/gswax/shared.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeImageButton

Returns a new instance of ImageButton.



139
140
141
142
143
144
145
# File 'lib/gswax/shared.rb', line 139

def initialize
	super
	self.set_visible_window(false)
	self.signal_connect("enter_notify_event"){enter_event}
	self.signal_connect("leave_notify_event"){leave_event}
	self.signal_connect("button_press_event"){yield if block_given?}
end

Instance Attribute Details

#cold_pixObject

Returns the value of attribute cold_pix.



137
138
139
# File 'lib/gswax/shared.rb', line 137

def cold_pix
  @cold_pix
end

#hot_pixObject

Returns the value of attribute hot_pix.



137
138
139
# File 'lib/gswax/shared.rb', line 137

def hot_pix
  @hot_pix
end

#imageObject

Returns the value of attribute image.



137
138
139
# File 'lib/gswax/shared.rb', line 137

def image
  @image
end

Instance Method Details

#enter_eventObject



156
157
158
# File 'lib/gswax/shared.rb', line 156

def enter_event
	@image.pixbuf = @hot_pix if @image
end

#leave_eventObject



160
161
162
# File 'lib/gswax/shared.rb', line 160

def leave_event
	@image.pixbuf = @cold_pix if @image
end

#set_images(img_file, hov_file, width, height = width) ⇒ Object



147
148
149
150
151
152
153
154
# File 'lib/gswax/shared.rb', line 147

def set_images(img_file, hov_file, width, height= width)
	self.remove(@image) if @image
	@cold_pix = Gdk::Pixbuf.new(img_file, width, height)
	@hot_pix = Gdk::Pixbuf.new(hov_file, width, height)
	@image = Gtk::Image.new(@cold_pix)
	self.add(@image)

end