Greg Ercolano wrote:
> Edward ffolliott Hull wrote:
>> I'm playing with writing a 'map viewer' for role-playing games using
>> grids or hexagonal cells. As these are all tightly packed, at the
>> moment I am subclassing Fl_Button (FLTK 1.1.8/suse 11.0), specifying the
>> dimensions as the rectangular area and drawing out-side of the bounding
>> box.
>
> No, draw /inside/ the bounding box.
> Widgets should not draw outside their xywh.
I agree entirely, which is why I came here looking for a better
solution.
>
>> This results in the triangular ends not being active. I would like
>> to implement a hexagonal button but need a few pointers as to
>> controlling the 'clickable' area of a widget.
>
> If you're deriving from Fl_Button, the sensitive area
> will be the entire xywh area.
So I think I'm going to need to derive from Fl_Widget.
>
> I'd think you'd be OK not to have to bother limiting the
> clickable area away from the small triangles around the hexagon.
This resulted in clicking in one hexagon's end and the click
registering in the more-recently added hexagon (hence the drawing
outside of the active area hack).
>
>> For information, previously I was drawing the hexagon entirely inside
>> the boundary, but this results in overlapping boundaries.
>
> Not sure what you mean by overlapping boundaries. Don't
> overlap the widget areas (xywh) when you create the buttons
> and all should work well.
I'm not sure I described what I was doing very well, I'm aiming for
something a little like this: http://effh.homeip.net/subsector.png (I
won't leave the server up indefinitely, it is noisy so I need somewhere
quieter/less used than my sitting room for it.)
>
>> Inactive
>> regions are better than this, but I would ideally like to solve the
>> clickable region issue.
>
> If you really want to go there, you can probably overload the
> handle() method, and on mouse clicks, check to see if the xy
> position of the mouse is inside one of those triangles, and if
> so, ignore the clicks by not passing the events on to the
> Fl_Button::handle() from your handler, effectively 'masking'
> those regions.
I think for what I'm doing I need to go there. I've been using FLTK
for a few years now on more normal projects (inc. my final year project)
and it is my preferred GUI tool-kit, (Fast, Light, <i>easy to use</i>
Tool Kit) but this is the most complex thing I've done with it widget
and layout wise.
By the way Greg, Thank you for responding and even more thanks for your
fltk cheat page, it has been a lot of help.
--
-Ted
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk