From cdcb8a50e26d958a811342ff5cd77ed501f290ce Mon Sep 17 00:00:00 2001 From: Michael R Sweet Date: Mon, 7 Mar 2005 23:55:49 +0000 Subject: More guide stuff - most of the widgets that need it should have their own custom ideal_size() function, and we now snap when showing the alignment guides. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4086 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- fluid/Fl_Type.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'fluid/Fl_Type.h') diff --git a/fluid/Fl_Type.h b/fluid/Fl_Type.h index f5fd26924..77c7ee340 100644 --- a/fluid/Fl_Type.h +++ b/fluid/Fl_Type.h @@ -530,6 +530,10 @@ extern Fl_Menu_Item button_type_menu[]; class Fl_Menu_Button_Type : public Fl_Menu_Type { Fl_Menu_Item *subtypes() {return button_type_menu;} public: + virtual void ideal_size(int &w, int &h) { + Fl_Widget_Type::ideal_size(w, h); + w += 20; + } virtual const char *type_name() {return "Fl_Menu_Button";} Fl_Widget *widget(int X,int Y,int W,int H) { return new Fl_Menu_Button(X,Y,W,H,"menu");} @@ -542,6 +546,10 @@ extern Fl_Menu_Item dummymenu[]; #include class Fl_Choice_Type : public Fl_Menu_Type { public: + virtual void ideal_size(int &w, int &h) { + Fl_Widget_Type::ideal_size(w, h); + w += 20; + } virtual const char *type_name() {return "Fl_Choice";} Fl_Widget *widget(int X,int Y,int W,int H) { Fl_Choice *myo = new Fl_Choice(X,Y,W,H,"choice:"); @@ -566,6 +574,14 @@ class Fl_Input_Choice_Type : public Fl_Menu_Type { return 1; } public: + virtual void ideal_size(int &w, int &h) { + Fl_Input_Choice *myo = (Fl_Input_Choice *)o; + fl_font(myo->textfont(), myo->textsize()); + h = fl_height() + myo->textsize() - 6; + w = o->w() - 20 - Fl::box_dw(o->box()); + int ww = (int)fl_width('m'); + w = ((w + ww - 1) / ww) * ww + 20 + Fl::box_dw(o->box()); + } virtual const char *type_name() {return "Fl_Input_Choice";} Fl_Widget *widget(int X,int Y,int W,int H) { Fl_Input_Choice *myo = new Fl_Input_Choice(X,Y,W,H,"input choice:"); -- cgit v1.2.3