[773] | 1 | // |
---|
| 2 | // "$Id: InputBrowser.h 4538 2005-08-26 10:29:43Z dejan $" |
---|
| 3 | // |
---|
| 4 | // MicroSoft style "ComboBox" with the menu appearing below with a |
---|
| 5 | // scrollbar. I would like to use the name "ComboBox" or "InputChoice" |
---|
| 6 | // for a more user-friendly version which uses pop-up menus and |
---|
| 7 | // positions the menu with the cursor pointing at the current item, |
---|
| 8 | // but this version can be used to get what MicroSoft users expect. |
---|
| 9 | // The implementation is a good example of how to get a widget to appear |
---|
| 10 | // in a modal pop-up window. |
---|
| 11 | // |
---|
| 12 | // Copyright 1998-2003 by Bill Spitzak and others. |
---|
| 13 | // |
---|
| 14 | // This library is free software; you can redistribute it and/or |
---|
| 15 | // modify it under the terms of the GNU Library General Public |
---|
| 16 | // License as published by the Free Software Foundation; either |
---|
| 17 | // version 2 of the License, or (at your option) any later version. |
---|
| 18 | // |
---|
| 19 | // This library is distributed in the hope that it will be useful, |
---|
| 20 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 21 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
| 22 | // Library General Public License for more details. |
---|
| 23 | // |
---|
| 24 | // You should have received a copy of the GNU Library General Public |
---|
| 25 | // License along with this library; if not, write to the Free Software |
---|
| 26 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
---|
| 27 | // USA. |
---|
| 28 | // |
---|
| 29 | // Please report all bugs and problems to "fltk-bugs@fltk.org". |
---|
| 30 | // |
---|
| 31 | |
---|
| 32 | #ifndef fltk_InputBrowser_h |
---|
| 33 | #define fltk_InputBrowser_h |
---|
| 34 | |
---|
| 35 | #include <fltk/Menu.h> |
---|
| 36 | #include <fltk/Input.h> |
---|
| 37 | |
---|
| 38 | class ComboBrowser; |
---|
| 39 | class ComboWindow; |
---|
| 40 | |
---|
| 41 | namespace fltk { |
---|
| 42 | |
---|
| 43 | class FL_API InputBrowser : public Menu { |
---|
| 44 | public: |
---|
| 45 | enum { // values for type() |
---|
| 46 | NORMAL = 0, |
---|
| 47 | NONEDITABLE = 1, |
---|
| 48 | INDENTED = 2, |
---|
| 49 | NONEDITABLE_INDENTED = 3 |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | InputBrowser(int,int,int,int,const char * = 0); |
---|
| 53 | ~InputBrowser(); |
---|
| 54 | static NamedStyle* default_style; |
---|
| 55 | |
---|
| 56 | void popup(); |
---|
| 57 | void hide_popup(); |
---|
| 58 | virtual int popup(int x, int y, int w, int h) { InputBrowser::popup(); return Menu::popup(Rectangle(x,y,w,h)); } |
---|
| 59 | |
---|
| 60 | virtual int handle(int); |
---|
| 61 | |
---|
| 62 | Widget* item() const ; |
---|
| 63 | Widget* item(Widget* v) const ; |
---|
| 64 | |
---|
| 65 | void maxw(int i) { maxw_ = i; } |
---|
| 66 | void maxh(int i) { maxh_ = i; } |
---|
| 67 | int maxw() { return maxw_; } |
---|
| 68 | int maxh() { return maxh_; } |
---|
| 69 | |
---|
| 70 | void value(const char *v) { m_input.value(v); } |
---|
| 71 | const char *value() { return m_input.value(); } |
---|
| 72 | |
---|
| 73 | protected: |
---|
| 74 | virtual void draw(); |
---|
| 75 | static void input_cb(Input *w, InputBrowser *ib); |
---|
| 76 | |
---|
| 77 | Input m_input; |
---|
| 78 | |
---|
| 79 | ComboWindow *win; |
---|
| 80 | ComboBrowser *list; |
---|
| 81 | |
---|
| 82 | friend class ComboWindow; |
---|
| 83 | friend class ComboBrowser; |
---|
| 84 | |
---|
| 85 | |
---|
| 86 | int minw_, minh_, maxw_, maxh_; |
---|
| 87 | int over_now, over_last; |
---|
| 88 | }; |
---|
| 89 | |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | #endif |
---|
| 93 | |
---|
| 94 | // |
---|
| 95 | // End of "$Id: InputBrowser.h 4538 2005-08-26 10:29:43Z dejan $". |
---|
| 96 | // |
---|