?? factory.cxx
字號:
//// "$Id: factory.cxx,v 1.1.1.1 2003/08/07 21:18:39 jasonk Exp $"//// Widget factory code for the Fast Light Tool Kit (FLTK).//// Type classes for most of the fltk widgets. Most of the work// is done by code in Fl_Widget_Type.C. Also a factory instance// of each of these type classes.//// This file also contains the "new" menu, which has a pointer// to a factory instance for every class (both the ones defined// here and ones in other files)//// Copyright 1998-1999 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.//// Please report all bugs and problems to "fltk-bugs@easysw.com".//#include <FL/Fl.H>#include <FL/Fl_Group.H>#include <FL/Fl_Menu_Item.H>#include <string.h>#include <stdio.h>#if defined(WIN32) || defined(__EMX__)#define strcasecmp stricmp#endif#include "Fl_Widget_Type.h"////////////////////////////////////////////////////////////////#include <FL/Fl_Box.H>class Fl_Box_Type : public Fl_Widget_Type {public: virtual const char *type_name() {return "Fl_Box";} Fl_Widget *widget(int x,int y,int w, int h) { return new Fl_Box(x,y,w,h,"label");} Fl_Widget_Type *_make() {return new Fl_Box_Type();}};static Fl_Box_Type Fl_Box_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Button.H>static Fl_Menu_Item buttontype_menu[] = { {"Normal",0,0,(void*)0}, {"Toggle",0,0,(void*)FL_TOGGLE_BUTTON}, {"Radio",0,0,(void*)FL_RADIO_BUTTON}, {0}};class Fl_Button_Type : public Fl_Widget_Type { Fl_Menu_Item *subtypes() {return buttontype_menu;}public: virtual const char *type_name() {return "Fl_Button";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Button(x,y,w,h,"button");} Fl_Widget_Type *_make() {return new Fl_Button_Type();} int is_button() const {return 1;}};static Fl_Button_Type Fl_Button_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Return_Button.H>class Fl_Return_Button_Type : public Fl_Button_Type {public: virtual const char *type_name() {return "Fl_Return_Button";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Return_Button(x,y,w,h,0);} Fl_Widget_Type *_make() {return new Fl_Return_Button_Type();}};static Fl_Return_Button_Type Fl_Return_Button_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Repeat_Button.H>class Fl_Repeat_Button_Type : public Fl_Widget_Type {public: virtual const char *type_name() {return "Fl_Repeat_Button";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Repeat_Button(x,y,w,h,0);} Fl_Widget_Type *_make() {return new Fl_Repeat_Button_Type();}};static Fl_Repeat_Button_Type Fl_Repeat_Button_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Light_Button.H>class Fl_Light_Button_Type : public Fl_Button_Type {public: virtual const char *type_name() {return "Fl_Light_Button";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Light_Button(x,y,w,h,"button");} Fl_Widget_Type *_make() {return new Fl_Light_Button_Type();}};static Fl_Light_Button_Type Fl_Light_Button_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Check_Button.H>class Fl_Check_Button_Type : public Fl_Button_Type {public: virtual const char *type_name() {return "Fl_Check_Button";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Check_Button(x,y,w,h,"button");} Fl_Widget_Type *_make() {return new Fl_Check_Button_Type();}};static Fl_Check_Button_Type Fl_Check_Button_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Round_Button.H>class Fl_Round_Button_Type : public Fl_Button_Type {public: virtual const char *type_name() {return "Fl_Round_Button";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Round_Button(x,y,w,h,"button");} Fl_Widget_Type *_make() {return new Fl_Round_Button_Type();}};static Fl_Round_Button_Type Fl_Round_Button_type;////////////////////////////////////////////////////////////////extern int compile_only;#include <FL/Fl_Browser.H>static Fl_Menu_Item browser_type_menu[] = { {"No Select",0,0,(void*)FL_NORMAL_BROWSER}, {"Select",0,0,(void*)FL_SELECT_BROWSER}, {"Hold",0,0,(void*)FL_HOLD_BROWSER}, {"Multi",0,0,(void*)FL_MULTI_BROWSER}, {0}};class Fl_Browser_Type : public Fl_Widget_Type { Fl_Menu_Item *subtypes() {return browser_type_menu;} int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);public: virtual const char *type_name() {return "Fl_Browser";} Fl_Widget *widget(int x,int y,int w,int h) { Fl_Browser* b = new Fl_Browser(x,y,w,h); // Fl_Browser::add calls fl_height(), which requires the X display open. // Avoid this when compiling so it works w/o a display: if (!compile_only) { char buffer[20]; for (int i = 1; i <= 20; i++) { sprintf(buffer,"Browser Line %d",i); b->add(buffer); } } return b; } Fl_Widget_Type *_make() {return new Fl_Browser_Type();}};static Fl_Browser_Type Fl_Browser_type;int Fl_Browser_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) { Fl_Browser *o = (Fl_Browser*)(w==4 ? ((Fl_Widget_Type*)this->factory)->o : this->o); switch (w) { case 4: case 0: f = o->textfont(); s = o->textsize(); c = o->textcolor(); break; case 1: o->textfont(f); break; case 2: o->textsize(s); break; case 3: o->textcolor(c); break; } return 1;}////////////////////////////////////////////////////////////////#include <FL/Fl_Counter.H>static Fl_Menu_Item counter_type_menu[] = { {"Normal",0,0,(void*)FL_NORMAL_COUNTER}, {"Simple",0,0,(void*)FL_SIMPLE_COUNTER}, {0}};class Fl_Counter_Type : public Fl_Widget_Type { Fl_Menu_Item *subtypes() {return counter_type_menu;} int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c); int is_valuator() const {return 1;}public: virtual const char *type_name() {return "Fl_Counter";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Counter(x,y,w,h,"counter:");} Fl_Widget_Type *_make() {return new Fl_Counter_Type();}};static Fl_Counter_Type Fl_Counter_type;int Fl_Counter_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) { Fl_Counter *o = (Fl_Counter*)(w==4 ? ((Fl_Widget_Type*)this->factory)->o : this->o); switch (w) { case 4: case 0: f = o->textfont(); s = o->textsize(); c = o->textcolor(); break; case 1: o->textfont(f); break; case 2: o->textsize(s); break; case 3: o->textcolor(c); break; } return 1;}////////////////////////////////////////////////////////////////#include <FL/Fl_Input.H>static Fl_Menu_Item input_type_menu[] = { {"Normal",0,0,(void*)FL_NORMAL_INPUT}, {"Multiline",0,0,(void*)FL_MULTILINE_INPUT}, {"Secret",0,0,(void*)FL_SECRET_INPUT}, {"Int",0,0,(void*)FL_INT_INPUT}, {"Float",0,0,(void*)FL_FLOAT_INPUT}, {0}};class Fl_Input_Type : public Fl_Widget_Type { Fl_Menu_Item *subtypes() {return input_type_menu;} int textstuff(int w, Fl_Font& f, int& s, Fl_Color& c);public: virtual const char *type_name() {return "Fl_Input";} Fl_Widget *widget(int x,int y,int w,int h) { Fl_Input *o = new Fl_Input(x,y,w,h,"input:"); o->value("Text Input"); return o; } Fl_Widget_Type *_make() {return new Fl_Input_Type();}};static Fl_Input_Type Fl_Input_type;int Fl_Input_Type::textstuff(int w, Fl_Font& f, int& s, Fl_Color& c) { Fl_Input_ *o = (Fl_Input_*)(w==4 ? ((Fl_Widget_Type*)this->factory)->o : this->o); switch (w) { case 4: case 0: f = o->textfont(); s = o->textsize(); c = o->textcolor(); break; case 1: o->textfont(f); break; case 2: o->textsize(s); break; case 3: o->textcolor(c); break; } return 1;}////////////////////////////////////////////////////////////////#include <FL/Fl_Clock.H>class Fl_Clock_Type : public Fl_Widget_Type {public: virtual const char *type_name() {return "Fl_Clock";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Clock(x,y,w,h);} Fl_Widget_Type *_make() {return new Fl_Clock_Type();}};static Fl_Clock_Type Fl_Clock_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Adjuster.H>class Fl_Adjuster_Type : public Fl_Widget_Type { int is_valuator() const {return 1;}public: virtual const char *type_name() {return "Fl_Adjuster";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Adjuster(x,y,w,h);} Fl_Widget_Type *_make() {return new Fl_Adjuster_Type();}};static Fl_Adjuster_Type Fl_Adjuster_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Dial.H>static Fl_Menu_Item dial_type_menu[] = { {"Dot",0,0,(void*)0}, {"Line",0,0,(void*)FL_LINE_DIAL}, {"Fill",0,0,(void*)FL_FILL_DIAL}, {0}};class Fl_Dial_Type : public Fl_Widget_Type { Fl_Menu_Item *subtypes() {return dial_type_menu;} int is_valuator() const {return 1;}public: virtual const char *type_name() {return "Fl_Dial";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Dial(x,y,w,h);} Fl_Widget_Type *_make() {return new Fl_Dial_Type();}};static Fl_Dial_Type Fl_Dial_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Roller.H>static Fl_Menu_Item roller_type_menu[] = { {"Vertical",0,0,(void*)0}, {"Horizontal",0,0,(void*)FL_HORIZONTAL}, {0}};class Fl_Roller_Type : public Fl_Widget_Type { Fl_Menu_Item *subtypes() {return roller_type_menu;} int is_valuator() const {return 1;}public: virtual const char *type_name() {return "Fl_Roller";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Roller(x,y,w,h);} Fl_Widget_Type *_make() {return new Fl_Roller_Type();}};static Fl_Roller_Type Fl_Roller_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Scrollbar.H>static Fl_Menu_Item slider_type_menu[] = { {"Vertical",0,0,(void*)FL_VERT_SLIDER}, {"Horizontal",0,0,(void*)FL_HOR_SLIDER}, {"Vert Fill",0,0,(void*)FL_VERT_FILL_SLIDER}, {"Horz Fill",0,0,(void*)FL_HOR_FILL_SLIDER}, {"Vert Knob",0,0,(void*)FL_VERT_NICE_SLIDER}, {"Horz Knob",0,0,(void*)FL_HOR_NICE_SLIDER}, {0}};class Fl_Slider_Type : public Fl_Widget_Type { Fl_Menu_Item *subtypes() {return slider_type_menu;} int is_valuator() const {return 2;}public: virtual const char *type_name() {return "Fl_Slider";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Slider(x,y,w,h);} Fl_Widget_Type *_make() {return new Fl_Slider_Type();}};static Fl_Slider_Type Fl_Slider_type;static Fl_Menu_Item scrollbar_type_menu[] = { {"Vertical",0,0,(void*)FL_VERT_SLIDER}, {"Horizontal",0,0,(void*)FL_HOR_SLIDER}, {0}};class Fl_Scrollbar_Type : public Fl_Slider_Type { Fl_Menu_Item *subtypes() {return scrollbar_type_menu;}public: virtual const char *type_name() {return "Fl_Scrollbar";} Fl_Widget *widget(int x,int y,int w,int h) { return new Fl_Scrollbar(x,y,w,h);} Fl_Widget_Type *_make() {return new Fl_Scrollbar_Type();}};static Fl_Scrollbar_Type Fl_Scrollbar_type;////////////////////////////////////////////////////////////////#include <FL/Fl_Output.H>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -