Hi,

  Thanks for sharing info. It seems to be more useful to me to develop. Can
I know where can I get these type of examples in google???

       So that I can easily refer and implement when ever I got struck.

On Thu, Mar 29, 2012 at 12:50 AM, Greg Ercolano <[email protected]> wrote:

> #include <FL/Fl.H>
> #include <FL/Fl_Window.H>
> #include <FL/Fl_Button.H>
> #include <FL/Fl_Select_Browser.H>
> //
> // Minimal example of a scrollable 'menu' like Fl_Choice. -erco 03/28/2012
> //
> class MyFloatingWindow : public Fl_Window {
> public:
>    MyFloatingWindow(int W,int H,const char *L=0) : Fl_Window(W,H,L) {
>    }
>    int handle(int e) {
>        // MOUSE LEAVES WINDOW? HIDE
>        if ( e == FL_LEAVE ) {
>            hide();
>        }
>        return(Fl_Window::handle(e));
>    }
> };
> class MyChoiceButton : public Fl_Button {
>    MyFloatingWindow *win;
>    Fl_Select_Browser *brow;
>
>    void Browser_CB() {
>        int i = brow->value();
>        if ( i ) {
>            const char *item = brow->text(brow->value());
>            printf("Clicked on: %s\n", item);
>            label(item);
>        }
>        win->hide();
>    }
>    static void Browser_CB(Fl_Widget *w, void *o) {
>        ((MyChoiceButton*)o)->Browser_CB();
>    }
>    void Button_CB() {
>        win->show();
>    }
>    static void Button_CB(Fl_Widget *w, void *o) {
>        ((MyChoiceButton*)o)->Button_CB();
>    }
> public:
>    MyChoiceButton(int X,int Y,int W,int H, const char *L=0) :
> Fl_Button(X,Y,W,H,L) {
>        align(FL_ALIGN_LEFT|FL_ALIGN_CLIP|FL_ALIGN_INSIDE);
>        Fl_Group *save = Fl_Group::current();
>        Fl_Group::current(0);
>        win = new MyFloatingWindow(150,200);            // whatever size is
> best
>        brow = new Fl_Select_Browser(0,0,win->w(),win->h());
>        win->end();
>        win->border(0);
>        Fl_Group::current(save);
>        callback(Button_CB, (void*)this);
>        brow->callback(Browser_CB, (void*)this);
>    }
>    void AddItem(const char *s) {
>        brow->add(s);
>        label(s);
>    }
> };
> int main() {
>  Fl_Window win(300,180);
>  MyChoiceButton but(20,30,100,25);
>  but.AddItem("I am using choice box in my application.");
>  but.AddItem("Choice box is expanding up to the maximum data size.");
>  but.AddItem("I think this is the general property, which seems to be
> fine.");
>  but.AddItem("But my resolution is 240*320.");
>  but.AddItem("So the data in choice box is going away out of my display.");
>  win.show();
>  return(Fl::run())
>



-- 
*
Thanks & Regards,
Rajesh Kumar P
*
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to