On 03/28/12 00:29, Rajesh Kumar wrote:
> Hi all,
> 
>            I am using choice box in my application. Choice box is expanding
> up to the maximum data size. I think this is the general property, which
> seems to be fine. But my resolution is 240*320. So the data in choice box
> is going away out of my display. And even choice box doesn't have
> horizontal and vertical scroll also. Can any body give suggestions, how to
> restrict the extending property of choice box. I am using FLTK1.3 on ARM
> linux platform.

        Perhaps use an Fl_Browser instead to let the user pick items.
        Have it appear when the user pushes a button that lets them
        change what's selected.

        Here's a quick example of what I mean.. flesh it out as needed.

#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());
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to