fltk summer course - part iii - third impact

Download FLTK Summer Course - Part III - Third Impact

Post on 10-May-2015

312 views

Category:

Education

3 download

Embed Size (px)

DESCRIPTION

FLTK (pronounced "fulltick") is a cross-platform C++ GUI toolkit for UNIX/Linux (X11), Microsoft Windows, and MacOS X. FLTK provides modern GUI functionality without the bloat and supports 3D graphics via OpenGL and its built-in GLUT emulation. FLTK is designed to be small and modular enough to be statically linked, but works fine as a shared library. FLTK also includes an excellent UI builder called FLUID that can be used to create applications in minutes. FLTK is provided under the terms of the GNU Library Public License, Version 2 with exceptions that allow for static linking. More informations in http://www.fltk.org.

TRANSCRIPT

  • 1.1 de 15INTRODUO AO FAST LIGHT TOOLKIT - FLTK The Fast Light ToolKit Curso de Vero Instituto de Computao & CA Computao Michel Alves dos Santos - UFAL Bolsista do Centro de Pesquisa em Matemtica Computacional 3 Impacto

2. 2 de 15 Componentes oferecidos pelo FLUID [Paleta de componentes da ferramenta FLUID] FLUID E SUA PALETA DE COMPONENTES Componentes de codificao: Code, Class, Containers : Group, Window, Pack, Tile, Tabs, Buttons: Button, Return_Button, Light_Button, Valuators : Slider, Adjuster, Spinner, Dial, Text : Input, Output, Text_Editor, Menus : Menu_Bar, MenuButton, Choice, Browsers : Browser, Check_Browser, 3. 3 de 15 Mas antes ... MAS ANTES VAMOS CODIFICAR UM POUCO MANUALMENTE 4. 4 de 15 Codificao do exemplo Al, Mundo ! #include #include #include int main(int argc, char* argv[]) { Fl_Window *window = new Fl_Window(300,180); Fl_Box *box = new Fl_Box(20,40,260,100,Al, Mundo!"); box->box(FL_UP_BOX); box->labelsize(36); box->labelfont(FL_BOLD+FL_ITALIC); box->labeltype(FL_SHADOW_LABEL); window->end(); window->show(argc, argv); return Fl::run(); } O CLSSICO EXEMPLO HELLO WORLD ! 5. 5 de 15 Uso de Callbacks - Exemplo COMO RESPONDER A EVENTOS DENTRO DO FLTK USO DE CALLBACKS - EXEMPLO #include #include #include #include void MyCallback(Fl_Widget* mywidget, void* userdata) { fl_message(Saindo "); exit(0); } int main(int argc, char* argv[]) { Fl_Window *window = new Fl_Window(300,180); window->callback(MyCallback,0); window->show(argc, argv); return Fl::run(); } 6. 6 de 15 Mudando o Scheme COMO MUDAR O ESQUEMA DAS APLICAES EM FLTK Implemente uma classe que herde de Fl_Window e possua a seguinte aparncia : A janela deve possuir um grupo [Fl_Group] e 3 botes do tipo Fl_Button [com os rtulos visualizados acima]. #include #include #include #include [Cabealhos necessrios] 7. 7 de 15 class WindowChangeSchema : public Fl_Window { public: WindowChangeSchema(const char *L = 0); WindowChangeSchema(int W, int H, const char *L = 0); Fl_Group *grpGrupo; Fl_Button *btnSchemaNativo; Fl_Button *btnSchemaPlastic; Fl_Button *btnSchemaGtk; private: /*Mtodo que auxilia no desenho da janela*/ void _WindowChangeSchema(); /*Mtodos para callback*/ void cb_btnSchemaNativo_i(Fl_Button*, void*); static void cb_btnSchemaNativo(Fl_Button*, void*); void cb_btnSchemaPlastic_i(Fl_Button*, void*); static void cb_btnSchemaPlastic(Fl_Button*, void*); void cb_btnSchemaGtk_i(Fl_Button*, void*); static void cb_btnSchemaGtk(Fl_Button*, void*); }; CDIGO DA CLASSE WINDOWCHANGESCHEMA 8. 8 de 15CDIGO DO MTODO QUE DESENHA A INTERFACE void WindowChangeSchema::_WindowChangeSchema() { grpGrupo = new Fl_Group(25, 15, 300, 50, GRUPO"); grpGrupo->box(FL_ENGRAVED_FRAME); grpGrupo->labelsize(20); grpGrupo->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); grpGrupo->end(); btnSchemaNativo = new Fl_Button(25, 83, 80, 50, &Nativo"); btnSchemaNativo->callback((Fl_Callback*)cb_btnSchemaNativo, (void*)(this)); btnSchemaPlastic = new Fl_Button(135, 83, 80, 50, &Plastic"); btnSchemaPlastic->callback((Fl_Callback*)cb_btnSchemaPlastic, (void*)(this)); btnSchemaGtk = new Fl_Button(245, 83, 80, 50, &GTK+"); btnSchemaGtk->callback((Fl_Callback*)cb_btnSchemaGtk, (void*)(this)); end(); } struindo a interface manualmente 9. 9 de 15 Construtores da classe CONSTRUTORES DA CLASSE WindowChangeSchema::WindowChangeSchema(const char *L) :Fl_Window(0, 0, 350, 150, L) { clear_flag(16); _WindowChangeSchema(); } WindowChangeSchema::WindowChangeSchema(int W, int H, const char *L) :Fl_Window(0, 0, W, H, L) { clear_flag(16); _WindowChangeSchema(); } 10. 10 de 15 void WindowChangeSchema::cb_btnSchemaNativo_i(Fl_Button* o, void*) { Fl::scheme("none"); } void WindowChangeSchema::cb_btnSchemaPlastic_i(Fl_Button* o, void*) { Fl::scheme("plastic"); } void WindowChangeSchema::cb_btnSchemaGtk_i(Fl_Button* o, void*) { Fl::scheme("gtk+"); } Callbacks internos CALLBACKS INTERNOS A CLASSE 11. 11 de 15 Callbacks estticos CALLBACKS ESTTICOS MANIPULADOS DIRETAMENTE NOS EVENTOS void WindowChangeSchema::cb_btnSchemaNativo(Fl_Button* o, void* v) { ((WindowChangeSchema*)(v))->cb_btnSchemaNativo_i(o,v); } void WindowChangeSchema::cb_btnSchemaPlastic(Fl_Button* o, void* v) { ((WindowChangeSchema*)(v))->cb_btnSchemaPlastic_i(o,v); } void WindowChangeSchema::cb_btnSchemaGtk(Fl_Button* o, void* v) { ((WindowChangeSchema*)(v))->cb_btnSchemaGtk_i(o,v); } 12. 12 de 15 int main(int argc, char** argv) { WindowChangeSchema win("Muda Schema !!!"); win.show(argc,argv); return Fl::run(); } Funo Principal FUNO PRINCIPAL DO PROGRAMA [Os trs schemes suportados pelo pacote FLTK None (Nativo), Plastic e GTK+] 13. 13 de 15DVIDAS ? Dvidas ? 14. 14 de 15PENSAMENTO DO DIA ! Provrbio japons um grande erro no fazer nada, quando se pode fazer pouco... 15. 15 de 15FIM !!!