Browse Source

Added Greg Ercolano's simple Fl_Input_Choice widget which is a

combination of the Fl_Input and Fl_Menu_Button widgets (STR
#650)

FL/Fl_Input_Choice.H:


documentation/Fl_Input_Choice.html:
    - Added.

documentation/fltk.book:
    - Added Fl_Input_Choice.html + --no-embedfonts option.

documentation/index.html:
    - Update version number and revision.

documentation/input_choice.jpg:
    - Added.

documentation/preface.html:
    - Update version number and revision.

documentation/widgets.html:
    - Add Fl_Input_Choice to lists.

fluid/Fl_Menu_Type.cxx:
    - Add Fl_Input_Choice_Type class and instance.

fluid/Fl_Type.h:
    - Add Fl_Input_Choice_Type class and instance.

fluid/factory.cxx:
    - Add Fl_Input_Choice menu item.

test/Makefile:
    - Add input_choice example.

test/input_choice.cxx:
    - Added.

test/demo.menu:
    - Add input_choice example.




git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4050 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
pull/168/head
Michael R Sweet 21 years ago
parent
commit
2df3459457
  1. 3
      CHANGES
  2. 128
      FL/Fl_Input_Choice.H
  3. 100
      documentation/Fl_Input_Choice.html
  4. 3
      documentation/fltk.book
  5. 6
      documentation/index.html
  6. BIN
      documentation/input_choice.jpg
  7. 4
      documentation/preface.html
  8. 2
      documentation/widgets.html
  9. 2
      fluid/Fl_Menu_Type.cxx
  10. 18
      fluid/Fl_Type.h
  11. 2
      fluid/factory.cxx
  12. 8
      test/Makefile
  13. 1
      test/demo.menu
  14. 57
      test/input_choice.cxx

3
CHANGES

@ -1,6 +1,9 @@ @@ -1,6 +1,9 @@
CHANGES IN FLTK 1.1.7
- Documentation fixes (STR #648, STR #692)
- Added Greg Ercolano's simple Fl_Input_Choice widget
which is a combination of the Fl_Input and
Fl_Menu_Button widgets (STR #650)
- Fl_Multiline_Input now scrolls the full height of the
widget instead of 5 lines when the user presses PageUp
or PageDown (STR #727)

128
FL/Fl_Input_Choice.H

@ -0,0 +1,128 @@ @@ -0,0 +1,128 @@
//
// "$Id$"
//
// An input/chooser widget.
// ______________ ____
// | || __ |
// | input area || \/ |
// |______________||____|
//
// Copyright 1998-2005 by Bill Spitzak and others.
// Copyright 2004 by Greg Ercolano.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
// Please report all bugs and problems to "fltk-bugs@fltk.org".
//
#ifndef Fl_Input_Choice_H
#define Fl_Input_Choice_H
#include <FL/Fl.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/fl_draw.H>
class Fl_Input_Choice : public Fl_Group {
// Private class to handle slightly 'special' behavior of menu button
class InputMenuButton : public Fl_Menu_Button {
void draw() {
draw_box(FL_UP_BOX, color());
fl_color(active_r() ? labelcolor() : fl_inactive(labelcolor()));
int xc = x()+w()/2, yc=y()+h()/2;
fl_polygon(xc-5,yc-3,xc+5,yc-3,xc,yc+3);
if (Fl::focus() == this) draw_focus();
}
public:
InputMenuButton(int x,int y,int w,int h,const char*l=0) :
Fl_Menu_Button(x,y,w,h,l) { box(FL_UP_BOX); }
};
Fl_Input *inp_;
InputMenuButton *menu_;
static void menu_cb(Fl_Widget*, void *data) {
Fl_Input_Choice *o=(Fl_Input_Choice *)data;
o->inp_->value(o->menu_->text());
o->do_callback();
}
static void inp_cb(Fl_Widget*, void *data) {
Fl_Input_Choice *o=(Fl_Input_Choice *)data;
o->do_callback();
}
// Custom resize behavior -- input stretches, menu button doesn't
inline int inp_x() { return(x() + Fl::box_dx(box())); }
inline int inp_y() { return(y() + Fl::box_dy(box())); }
inline int inp_w() { return(w() - Fl::box_dw(box()) - 20); }
inline int inp_h() { return(h() - Fl::box_dh(box())); }
inline int menu_x() { return(x() + w() - 20 - Fl::box_dx(box())); }
inline int menu_y() { return(y() + Fl::box_dy(box()) + (Fl::scheme()?1:0)); }
inline int menu_w() { return(20); }
inline int menu_h() { return(h() - Fl::box_dh(box()) - (Fl::scheme()?1:0)); }
public:
Fl_Input_Choice (int x,int y,int w,int h,const char*l=0) : Fl_Group(x,y,w,h,l) {
Fl_Group::box(FL_DOWN_BOX);
align(FL_ALIGN_LEFT); // default like Fl_Input
inp_ = new Fl_Input(inp_x(), inp_y(),
inp_w(), inp_h());
inp_->callback(inp_cb, (void*)this);
inp_->box(FL_FLAT_BOX); // cosmetic
menu_ = new InputMenuButton(menu_x(), menu_y(),
menu_w(), menu_h());
menu_->callback(menu_cb, (void*)this);
menu_->box(FL_FLAT_BOX); // cosmetic
end();
}
void add(const char *s) {
menu_->add(s);
}
void clear() {
menu_->clear();
}
const Fl_Menu_Item *menu() {
return (menu_->menu());
}
void menu(const Fl_Menu_Item *m) {
menu_->menu(m);
}
void resize(int X, int Y, int W, int H) {
Fl_Group::resize(X,Y,W,H);
inp_->resize(inp_x(), inp_y(), inp_w(), inp_h());
menu_->resize(menu_x(), menu_y(), menu_w(), menu_h());
}
const char* value() const {
return(inp_->value());
}
void value(const char *val) {
inp_->value(val);
}
void value(int val) {
menu_->value(val);
inp_->value(menu_->text(val));
}
Fl_Menu_Button *menubutton() { return menu_; }
Fl_Input *input() { return inp_; }
};
#endif // !Fl_Input_Choice_H
//
// End of "$Id$".
//

100
documentation/Fl_Input_Choice.html

@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
<HTML>
<BODY>
<!-- NEW PAGE -->
<H2><A name=Fl_Input_Choice>class Fl_Input_Choice</A></H2>
<HR>
<H3>Class Hierarchy</H3>
<UL><PRE>
<A href=Fl_Group.html#Fl_Group>Fl_Group</A>
|
+----<B>Fl_Input_Choice</B>
|
+----<A href=Fl_Input.html#Fl_Input>Fl_Input</A>
<A href=Fl_Menu_Button.html#Fl_Menu_Button>Fl_Menu_Button</A>
</PRE></UL>
<H3>Include Files</H3>
<UL><PRE>
#include &lt;FL/Fl_Input_Choice.H&gt;
</PRE></UL>
<P align='center'>
<IMG SRC='input_choice.jpg'><BR>
<I>Plastic and normal Fl::scheme()s.</I>
</P>
<H3>Description</H3>
<P>A combination of the input widget and a menu button.
The user can either type into the input area, or use the
menu button chooser on the right, which loads the input area
with predefined text. Normally it is drawn with an inset box
and a white background.
<P>
The application can directly access both the input and menu
widgets directly, using the <A HREF=#Fl_Input_Choice.menubutton>menubutton()</A>
and <A HREF=#Fl_Input_Choice.input>input()</A> accessor methods.
<H3>Methods</H3>
<CENTER>
<TABLE width=90% summary="Fl_Input_Choice methods."><TR><TD align=left valign=top>
<UL TYPE=DISC>
<LI><A href='#Fl_Input_Choice.Fl_Input_Choice'>Fl_Input_Choice</A></LI>
<LI><A href='#Fl_Input_Choice.~Fl_Input_Choice'>~Fl_Input_Choice</A></LI>
<LI><A href='#Fl_Input_Choice.add'>add</A></LI>
<LI><A href='#Fl_Input_Choice.clear'>clear</A></LI>
<LI><A href='#Fl_Input_Choice.input'>input</A></LI>
<LI><A href='#Fl_Input_Choice.menu'>menu</A></LI>
<LI><A href='#Fl_Input_Choice.menubutton'>menubutton</A></LI>
<LI><A href='#Fl_Input_Choice.value'>value</A></LI>
</TD></TR></TABLE>
</CENTER>
<H4><A name="Fl_Input_Choice.Fl_Input_Choice">Fl_Input_Choice::Fl_Input_Choice(int x, int y, int w,
int h, const char *label = 0)</A></H4>
<P>Creates a new <TT>Fl_Input_Choice</TT> widget using the given position, size,
and label string.
<H4><A name="Fl_Input_Choice.~Fl_Input_Choice">virtual Fl_Input_Choice::~Fl_Input_Choice()</A></H4>
<P>Destroys the widget and any value associated with it.
<h4><a name='#Fl_Input_Choice.add'>void Fl_Input_Choice::add(const char *s)</a></h4>
<p>Adds an item to the menu.</p>
<h4><a name='#Fl_Input_Choice.clear'>void Fl_Input_Choice::clear()</a></h4>
<p>Removes all items from the menu.</p>
<H4><A name="Fl_Input_Choice.input">Fl_Input *Fl_Input_Choice::input()</A></H4>
<p>Returns a reference to the internal <tt>Fl_Input</tt> widget.</p>
<h4><a name='#Fl_Input_Choice.menu'>void Fl_Input_Choice::menu(const Fl_Menu_Item *m)<br>
const Fl_Menu_Item *menu()</A></h4>
<p>Gets or sets the <tt>Fl_Menu_Item</tt> array used for the menu.</p>
<H4><A name="Fl_Input_Choice.menubutton">Fl_Menu_Button *Fl_Input_Choice::menubutton()</A></H4>
<P>Returns a reference to the internal <tt>Fl_Menu_Button</tt> widget.
<H4><A name="Fl_Input_Choice.value">void Fl_Input_Choice::value(const char *s)<br>
void Fl_Input_Choice::value(int v)<br>
const char *Fl_Input_Choice::value() const</A></H4>
<P>Sets or returns the input widget's current contents. The
second form sets the contents using the index into the menu
which you can set as an integer. Setting the value effectively
'chooses' this menu item, and sets it as the new input text,
deleting the previous text.</p>
</BODY>
</HTML>

3
documentation/fltk.book

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#HTMLDOC 1.8.20
-t pdf13 -f fltk.pdf --book --toclevels 2 --no-numbered --toctitle "Table of Contents" --title --titleimage FL.gif --linkstyle underline --size Universal --left 1.00in --right 0.50in --top 0.50in --bottom 0.50in --header .t. --footer h.1 --tocheader .t. --tocfooter ..i --duplex --portrait --color --no-pscommands --no-xrxcomments --compression=9 --jpeg=50 --fontsize 11.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Times --headfootsize 11.0 --headfootfont Helvetica --charset 8859-1 --links --no-truetype --pagemode outline --pagelayout single --firstpage c1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password "" --user-password "" --browserwidth 680
-t pdf13 -f fltk.pdf --book --toclevels 2 --no-numbered --toctitle "Table of Contents" --title --titleimage FL.gif --linkstyle underline --size Universal --left 1.00in --right 0.50in --top 0.50in --bottom 0.50in --header .t. --footer h.1 --tocheader .t. --tocfooter ..i --duplex --portrait --color --no-pscommands --no-xrxcomments --compression=9 --jpeg=50 --no-embedfonts --fontsize 11.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Times --headfootsize 11.0 --headfootfont Helvetica --charset 8859-1 --links --no-truetype --pagemode outline --pagelayout single --firstpage c1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password "" --user-password "" --browserwidth 680
preface.html
intro.html
basics.html
@ -44,6 +44,7 @@ Fl_Hold_Browser.html @@ -44,6 +44,7 @@ Fl_Hold_Browser.html
Fl_Image.html
Fl_Input.html
Fl_Input_.html
Fl_Input_Choice.html
Fl_Int_Input.html
Fl_JPEG_Image.html
Fl_Light_Button.html

6
documentation/index.html

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
<HTML>
<HEAD>
<META NAME="robots" CONTENT="noindex">
<TITLE>FLTK 1.1.6 Programming Manual</TITLE>
<TITLE>FLTK 1.1.7 Programming Manual</TITLE>
</HEAD>
<BODY>
@ -10,8 +10,8 @@ @@ -10,8 +10,8 @@
<TD VALIGN="MIDDLE">
<IMG SRC="FL.gif" WIDTH="200" HEIGHT="100" ALIGN="ABSMIDDLE" ALT="FL"></TD>
<TD ALIGN="CENTER" VALIGN="MIDDLE">
<H1>FLTK 1.1.6 Programming Manual</H1>
<P>Revision 6 by Michael Sweet, Craig P. Earls, and Bill Spitzak<BR>
<H1>FLTK 1.1.7 Programming Manual</H1>
<P>Revision 7 by Michael Sweet, Craig P. Earls, and Bill Spitzak<BR>
Copyright 1998-2004 by Bill Spitzak and others.</P>
</TD>
</TR>

BIN
documentation/input_choice.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

4
documentation/preface.html

@ -3,14 +3,14 @@ @@ -3,14 +3,14 @@
<META CONTENT="Written by Michael Sweet, Craig P. Earls, and Bill Spitzak" NAME="Author">
<META CONTENT="Copyright 1998-2004 by Bill Spitzak and Others." NAME="Copyright">
<META CONTENT="Revision 6" NAME="DocNumber">
<TITLE>FLTK 1.1.6 Programming Manual</TITLE>
<TITLE>FLTK 1.1.7 Programming Manual</TITLE>
</HEAD>
<BODY>
<H1 ALIGN="RIGHT"><A NAME="preface">Preface</A></H1>
<P>This manual describes the Fast Light Tool Kit (&quot;FLTK&quot;)
version 1.1.6, a C++ Graphical User Interface
version 1.1.7, a C++ Graphical User Interface
(&quot;GUI&quot;) toolkit for UNIX, Microsoft Windows and MacOS. Each
of the chapters in this manual is designed as a tutorial for
using FLTK, while the appendices provide a convenient reference

2
documentation/widgets.html

@ -45,6 +45,7 @@ description of the <TT>fl_</TT> functions, see @@ -45,6 +45,7 @@ description of the <TT>fl_</TT> functions, see
<A HREF="Fl_Image.html">Fl_Image</A><BR>
<A HREF="Fl_Input_.html">Fl_Input_</A><BR>
<A HREF="Fl_Input.html">Fl_Input</A><BR>
<A HREF="Fl_Input_Choice.html">Fl_Input_Choice</A><BR>
<A HREF="Fl_Int_Input.html">Fl_Int_Input</A><BR>
<A HREF="Fl_JPEG_Image.html">Fl_JPEG_Image</A><BR>
<A HREF="Fl_Light_Button.html">Fl_Light_Button</A><BR>
@ -161,6 +162,7 @@ description of the <TT>fl_</TT> functions, see @@ -161,6 +162,7 @@ description of the <TT>fl_</TT> functions, see
<LI><A HREF="Fl_File_Chooser.html#Fl_File_Chooser">Fl_File_Chooser</A>
<LI><A HREF="Fl_Help_Dialog.html#Fl_Help_Dialog">Fl_Help_Dialog</A>
<LI><A HREF="Fl_Help_View.html#Fl_Help_View">Fl_Help_View</A>
<LI><A HREF="Fl_Input_Choice.html">Fl_Input_Choice</A>
<LI><A HREF="Fl_Pack.html#Fl_Pack">Fl_Pack</A>
<LI><A HREF="Fl_Scroll.html#Fl_Scroll">Fl_Scroll</A>
<LI><A HREF="Fl_Tabs.html#Fl_Tabs">Fl_Tabs</A>

2
fluid/Fl_Menu_Type.cxx

@ -419,6 +419,8 @@ Fl_Menu_Item dummymenu[] = {{"CHOICE"},{0}}; @@ -419,6 +419,8 @@ Fl_Menu_Item dummymenu[] = {{"CHOICE"},{0}};
Fl_Choice_Type Fl_Choice_type;
Fl_Input_Choice_Type Fl_Input_Choice_type;
////////////////////////////////////////////////////////////////
Fl_Menu_Bar_Type Fl_Menu_Bar_type;

18
fluid/Fl_Type.h

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
//
// "$Id: Fl_Type.h,v 1.5.2.11.2.13 2004/04/11 04:38:55 easysw Exp $"
// "$Id$"
//
// Widget type header file for the Fast Light Tool Kit (FLTK).
//
@ -549,6 +549,20 @@ public: @@ -549,6 +549,20 @@ public:
int pixmapID() { return 15; }
};
#include <FL/Fl_Input_Choice.H>
class Fl_Input_Choice_Type : public Fl_Menu_Type {
public:
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:");
myo->menu(dummymenu);
myo->value("input");
return myo;
}
Fl_Widget_Type *_make() {return new Fl_Input_Choice_Type();}
int pixmapID() { return 15; }
};
#include <FL/Fl_Menu_Bar.H>
class Fl_Menu_Bar_Type : public Fl_Menu_Type {
public:
@ -599,5 +613,5 @@ int storestring(const char *n, const char * & p, int nostrip=0); @@ -599,5 +613,5 @@ int storestring(const char *n, const char * & p, int nostrip=0);
extern int include_H_from_C;
//
// End of "$Id: Fl_Type.h,v 1.5.2.11.2.13 2004/04/11 04:38:55 easysw Exp $".
// End of "$Id$".
//

2
fluid/factory.cxx

@ -690,6 +690,7 @@ extern class Fl_Pack_Type Fl_Pack_type; @@ -690,6 +690,7 @@ extern class Fl_Pack_Type Fl_Pack_type;
extern class Fl_Tabs_Type Fl_Tabs_type;
extern class Fl_Scroll_Type Fl_Scroll_type;
extern class Fl_Tile_Type Fl_Tile_type;
extern class Fl_Input_Choice_Type Fl_Input_Choice_type;
extern class Fl_Choice_Type Fl_Choice_type;
extern class Fl_Menu_Bar_Type Fl_Menu_Bar_type;
extern class Fl_Menu_Button_Type Fl_Menu_Button_type;
@ -753,6 +754,7 @@ Fl_Menu_Item New_Menu[] = { @@ -753,6 +754,7 @@ Fl_Menu_Item New_Menu[] = {
{0,0,cb,(void*)&Fl_Menu_Bar_type},
{0,0,cb,(void*)&Fl_Menu_Button_type},
{0,0,cb,(void*)&Fl_Choice_type},
{0,0,cb,(void*)&Fl_Input_Choice_type},
{0,0,cb, (void*)&Fl_Submenu_type},
{0,0,cb, (void*)&Fl_Menu_Item_type},
{0},

8
test/Makefile

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#
# "$Id: Makefile,v 1.19.2.7.2.42 2004/08/26 22:24:24 matthiaswm Exp $"
# "$Id$"
#
# Test/example program makefile for the Fast Light Tool Kit (FLTK).
#
@ -61,6 +61,7 @@ CPPFILES =\ @@ -61,6 +61,7 @@ CPPFILES =\
image.cxx \
inactive.cxx \
input.cxx \
input_choice.cxx \
keyboard.cxx \
label.cxx \
line_style.cxx \
@ -118,6 +119,7 @@ ALL = \ @@ -118,6 +119,7 @@ ALL = \
image$(EXEEXT) \
inactive$(EXEEXT) \
input$(EXEEXT) \
input_choice$(EXEEXT) \
keyboard$(EXEEXT) \
label$(EXEEXT) \
line_style$(EXEEXT) \
@ -259,6 +261,8 @@ inactive.cxx: inactive.fl @@ -259,6 +261,8 @@ inactive.cxx: inactive.fl
input$(EXEEXT): input.o
input_choice$(EXEEXT): input_choice.o
keyboard$(EXEEXT): keyboard_ui.o keyboard.o
echo Linking $@...
$(CXX) -I.. $(CXXFLAGS) -o $@ keyboard.o keyboard_ui.o $(LINKFLTK) $(LDLIBS)
@ -376,5 +380,5 @@ shape$(EXEEXT): shape.o @@ -376,5 +380,5 @@ shape$(EXEEXT): shape.o
#
# End of "$Id: Makefile,v 1.19.2.7.2.42 2004/08/26 22:24:24 matthiaswm Exp $".
# End of "$Id$".
#

1
test/demo.menu

@ -65,6 +65,7 @@ @@ -65,6 +65,7 @@
@o:File Chooser:file_chooser
@o:Fonts:fonts
@o:HelpDialog:help
@o:Input Choice:input_choice
@o:Preferences:preferences
@o:Threading:threads
@o:XForms Emulation:forms

57
test/input_choice.cxx

@ -0,0 +1,57 @@ @@ -0,0 +1,57 @@
// Test program for Fl_Input_Choice
//
// Copyright 1998-2004 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Library General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA.
//
#include <stdio.h>
#include <FL/Fl_Button.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Input_Choice.H>
void buttcb(Fl_Widget*,void*data) {
Fl_Input_Choice *in=(Fl_Input_Choice *)data;
static int flag = 1;
flag ^= 1;
if ( flag ) in->activate();
else in->deactivate();
}
void input_choice_cb(Fl_Widget*,void*data) {
Fl_Input_Choice *in=(Fl_Input_Choice *)data;
fprintf(stderr, "Value='%s'\n", (const char*)in->value());
}
int main(int argc, char **argv) {
Fl::scheme("plastic"); // optional
Fl_Window win(300, 200);
Fl_Input_Choice in(40,40,100,28,"Test");
in.callback(input_choice_cb, (void*)&in);
in.add("one");
in.add("two");
in.add("three");
in.value(1);
Fl_Button onoff(40,150,200,28,"Activate/Deactivate");
onoff.callback(buttcb, (void*)&in);
win.end();
win.resizable(win);
win.show(argc, argv);
return Fl::run();
}
Loading…
Cancel
Save