On 05.02.2009, at 00:07, 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

Hi Edward,

Stacking hexagonal buttons creates overlaps, which are not tested or  
FLTK. Nevertheless, you can have overlapping widgets if you replace  
parts of the Fl__...::handle(int event) function. That is a virtual  
function that you can override.

You then have to improve handling of all mouse position related  
events. Out of the top of my head, these would be FL_PUSH, MOVE, DRAG,  
RELEASE, DND_..., ENTER, and LEAVE. Make sure that those events are  
handled correctly if you are inside the enclosing rectangle, but  
outside of the hexagon.

For example:

int Fl_Hex_Button::handle(int event) {
   switch (event) {
     case FL_PUSH:
       if (inside_hexagon(Fl::event_x(), Fl::event_y()) {
         return Fl_Button::handle(FL_PUSH);
       } else {
         return 0; // tel Fl_Group that we could not handle this event
       }
     ...
   }
   return Fl_Button::handle(event);
}

You may have to slightly modify the "handle" function of your  
enclosing Fl_Group to make up for ENTER and LEAVE events that expect  
all children to be non-overlapping rectangles.

Anyway, I'd go ahead with the above mentioned handling of your hex  
button and see if there are any side effects. I am sure we can help  
you if new issues arise.


----
http://robowerk.com/


_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to