FLTK学习笔记三
来源:互联网 发布:主流的数据分析工具 编辑:程序博客网 时间:2024/05/22 15:24
There are only certain places you can execute drawing code in FLTK. Calling these functions at other places will result in undefined behavior!
• The most common place is inside the virtual Fl_Widget::draw() method. To write code here, you must subclass one of the existing Fl_Widget classes and implement your own version of draw().
• You can also create custom boxtypes and labeltypes. These involve writing small procedures that can be called by existing Fl_Widget::draw() methods. These "types" are identified by an 8-bit index that is stored in the widget’s box(), labeltype(), and possibly other properties.
• You can call Fl_Window::make_current() to do incremental update of a widget. Use Fl_Widget::window() to find the window.
Handling Events
Events are identified by the integer argument passed to a handle() method that overrides the Fl_Widget::handle() virtual method. Other information about the most recent event is stored in static locations and acquired by calling the Fl::event_*() methods.
Example:
CXX = $(shell /cygdrive/d/bin/fltk/bin/fltk-config --cxx)DEBUG = -gCXXFLAGS = $(shell /cygdrive/d/bin/fltk/bin/fltk-config --cxxflags ) -I.LDFLAGS = $(shell /cygdrive/d/bin/fltk/bin/fltk-config --ldflags )LDSTATIC = $(shell /cygdrive/d/bin/fltk/bin/fltk-config --ldstaticflags)FLTKPREFIX = $(shell /cygdrive/d/bin/fltk/bin/fltk-config --prefix)LINK = $(CXX)TARGET = helloOBJS = hello.oSRCS = hello.cxx.SUFFIXES: .o .cxx%.o: %.cxx$(CXX) $(CXXFLAGS) $(DEBUG) -c $<all: $(OBJS)$(LINK) -o $(TARGET) $(OBJS) $(LDSTATIC)$(TARGET): $(OBJS)hello.o: hello.cxxclean:rm -f hello.o 2> /dev/nullrm -f $(TARGET) 2> /dev/null
#include <FL/Fl.H>#include <FL/Fl_Window.H>#include <FL/Fl_Box.H>#include <FL/fl_draw.H>class MyDraw: public Fl_Widget{ void draw(){ fl_color(FL_RED); fl_rectf(x(),y(),w(),h()); }public: MyDraw(int X, int Y, int W, int H): Fl_Widget(X,Y,W,H){}};int main(int argc, char **argv) { Fl_Window *window = new Fl_Window(340,180); Fl_Box *box = new Fl_Box(20,40,300,100,"Hello, World!"); box->box(FL_UP_BOX); box->labelfont(FL_BOLD+FL_ITALIC); box->labelsize(36); box->labeltype(FL_SHADOW_LABEL); MyDraw *draw = new MyDraw(10,10,20,30); window->end(); window->show(argc, argv); return Fl::run();}
- FLTK学习笔记三
- FLTK学习笔记一
- FLTK学习笔记二
- fltk程序开发笔记
- FLTK
- FLTK学习-2-新手入门参考
- FLTK学习-2-新手入门参考
- FLTK学习-1-VC中安装
- FLTK学习-8-鼠标事件处理
- FLTK学习-1-VC中安装
- FLTK学习-8-鼠标事件处理
- 在Ubuntu 9.04上编译安装FLTK 1.1.9笔记
- JDBC学习笔记(三)
- C#学习笔记(三)
- AIX学习笔记(三)
- VC++学习笔记(三)
- AspectJ学习笔记(三)
- CSS学习笔记三
- 6月28日SQL基本语句
- 大家好。
- android应用程序fps meter[帧数显示]的分析 —— 浅谈root的风险 (2)
- 7月02日SQL server条件以及高级查询
- 20130704 移植apache2到arm Linux上
- FLTK学习笔记三
- ListActivity的onListItemClick不响应的解决办法
- 7月3日JDBC
- 使用SharedPreferences快速实现APP个性化设置参数的保存
- 毕业周年纪
- NYOJ2 括号配对问题
- 交通灯管理系统
- android studio-2013.7.4
- linux x86系统调用拦截