|
From: Takaaki T. <tt...@kt...> - 2002-11-06 07:41:18
|
Hello,
At Tue, 5 Nov 2002 14:04:20 +0000 (GMT),
> Now Browser_ automatically adds a horizontal scrollbar if the item_widths
> exceed the size of the browser. The user can now scroll the browser
> left-right.
...
> I want to get the header widget to redraw when the browser is scrolled -
I don't exactly understand your trouble.
After you call Browser_#has_scrollbar(Browser_::BOTH), a scrollbar is
automatically added if the item_widths exceed the width of browser.
Of course, the browser can be automatically scrolled if you scroll the
scrollbar. So I think you don't need to redraw.
I checked with the following scripts.
PS. Browser_::BOTH is not defined in Ruby/FLTK. Use `3' instead of it.
require 'fltk'
class MyBrowser < Fltk::Browser_
include Fltk::Drawable
def initialize(x,y,w,h,args)
super(x,y,w,h)
@selected_items = {}
@items = args.collect{|arg| arg.to_s}
end
def handle(e)
case e
when FLTK::PUSH
item = find_item(FLTK::event_y())
bx,by,bw,bh = bbox()
if( item && (FLTK::event_x() < bx + bw) && (FLTK::event_y() < by + bh) )
select(item,true)
return true
end
end
return super(e)
end
def item_next(obj)
@items[@items.index(obj) + 1]
end
def item_prev(obj)
idx = @items.index(obj)
if( idx > 0 )
@items[idx - 1]
else
nil
end
end
def item_first()
@items[0]
end
def item_draw(obj, x, y, w, h)
color(textcolor())
text_draw(obj, x, y + bbox()[1])
end
def item_height(obj)
15
end
def item_width(obj)
text_width(obj)
end
def full_height
p :full_height
super
end
def full_width
p :full_width
super
end
def item_select(item, s)
@selected_items[item] = true
end
def item_selected(item)
p @selected_items
@selected_items[item]
end
end
items = ["one", "two-----------long....", "three", "four", "five", "six", "seven", "eight"]
w = Fltk::Window.new(0,0,100,120,"Label"){|w|
b = MyBrowser.new(5,5,90,90,items)
b.textcolor = FLTK::RED
b.has_scrollbar(3)
}
GC.start
w.show
FLTK.font(FLTK::HELVETICA,14)
Fltk.run
--
Takaaki Tateishi <tt...@kt...>
|