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.



142
143
144
145
146
147
148
# File 'lib/gswax/shared.rb', line 142

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.



140
141
142
# File 'lib/gswax/shared.rb', line 140

def cold_pix
  @cold_pix
end

#hot_pixObject

Returns the value of attribute hot_pix.



140
141
142
# File 'lib/gswax/shared.rb', line 140

def hot_pix
  @hot_pix
end

#imageObject

Returns the value of attribute image.



140
141
142
# File 'lib/gswax/shared.rb', line 140

def image
  @image
end

Instance Method Details

#enter_eventObject



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

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

#leave_eventObject



163
164
165
# File 'lib/gswax/shared.rb', line 163

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

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



150
151
152
153
154
155
156
157
# File 'lib/gswax/shared.rb', line 150

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