> I am in need of a rollover pushbutton that is made of nothing 
> more than 2 different PNGs (Up and Down states). Also, I 
> prefer to use the Fl_Image subclasses rather than calling 
> fl_draw_image().

It needen't even be that complex - you just make a subclass from
Fl_Button and in the overriden handle() method you change the button
image on FL_ENTER and FL_LEAVE events.

See the subwindow example in the test folder for an example - although I
don't think it changes the image, just the colour.

> This is where things get blurry. Is there a simple way to do 
> this with Fl_Button (simple subclass?). I am a little lost as 
> to what Fl_Widget::Image() does.

Yes, more or less.

> The other option I came up with was to subclass Fl_Group, add 
> Images as children, listen for the appropriate mouse events 
> (simple pushbutton only), and hide/show the appropriate Image.

Nah - too hard.

> I just havent yet come to learn what each class is capable of 
> doing, and when/where/what I need to be subclassing.

See the examples in the test folder, then take a look at Greg's cool
examples:

http://www.seriss.com/people/erco/fltk/


Actually: I think I might have a fluid-only example of this...
Nope, not quite, but close. 
Might show you how to manipulate the button images though... You'll need
to provide your own png's to make this work, of course, I think I had 2
little 40x40 pictures or something I used for this demo.

-------------------------------------------

# data file for the Fltk User Interface Designer (fluid)
version 1.0109 
header_name {.h} 
code_name {.cxx}
Function {} {open
} {
  Fl_Window {} {open
    xywh {523 161 452 401} type Double visible
  } {
    Fl_Group {} {open
      xywh {25 25 300 275} box ENGRAVED_FRAME
    } {
      Fl_Round_Button b1 {
        callback {int i = b1->value();

if(i)
{
  b1->image(hidden->image());
  b2->image(hidden->deimage());
}
else
{
  b1->image(hidden->deimage());
  b2->image(hidden->image());
}
b1->redraw();
b2->redraw();}
        image {up.png} deimage {dn.png} xywh {50 40 64 45} type Radio
down_box ROUND_DOWN_BOX value 1 when 1
      }
      Fl_Round_Button b2 {
        callback {int i = b1->value();

if(i)
{
  b1->image(hidden->image());
  b2->image(hidden->deimage());
}
else
{
  b1->image(hidden->deimage());
  b2->image(hidden->image());
}
b1->redraw();
b2->redraw();} selected
        image {dn.png} deimage {dn.png} xywh {55 158 64 53} type Radio
down_box ROUND_DOWN_BOX
      }
    }
    Fl_Button hidden {
      image {up.png} deimage {dn.png} xywh {40 310 64 70} when 0 hide
    }
  }
} 

-------------------------------------------




SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

Reply via email to