FLTK Tutorial.

Slides:



Advertisements
Similar presentations
Chapter 16 Graphical User Interfaces
Advertisements

Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
QT GUI Programming CS340 – Software Design © 2009 – Jason Leigh University of Illinois at Chicago.
FLUID  The Fast Light User Interface Designer, or FLUID, is a graphical editor that is used to produce FLTK source code  Creates C++ code  Compile.fl.
Operating Systems First Program to load. Controls Hardware And software. Enable User to operate PC( Personal Computer) –Examples: DOS: Disk Operating.
CSE 557: Impressionist Help Session Ian Simon. What we’ll be going over Getting Set Up The Skeleton Code OpenGL Basic FLTK How to make a new brush Good.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Microsoft Windows Vista Chapter 6 Customizing Your Computer Using the Control Panel.
DT265-2 Object Oriented Software Development 2 Lecture 3 : Windows Programming Lecturer Pat Browne
Access Tutorial 10 Automating Tasks with Macros
Chapter 5 - Making Music: An On-Screen Piano
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
Java Beans.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
1 INF160 IS Development Environments AUBG, COS dept Lecture 06 Title: Dev Env: Code::Blocks (Extract from Syllabus) Reference:
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Bertrand Bellenot ROOT Users Workshop Mar ROOT GUI Builder Status & Plans ROOT & External GUI World MFC, FOX, Qt, PVSS… Snapshot of the Future.
Inspire students to develop ideas & organize thinking
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Chapter 8: Writing Graphical User Interfaces
Written by: Itzik Ben Shabat Technion - Israel Institute of Technology Faculty of Mechanical Engineering Laboratory for CAD & Lifecycle Engineering Lab.
Introduction to Matlab & Data Analysis
Introduction to OpenGL and GLUT GLUT. What is OpenGL? An application programming interface (API) A (low-level) Graphics rendering API Generate high-quality.
WINDOWS Part 1 – Start Up Basics
A First Look At Microsoft Visual Basic Lesson 1. What is Microsoft Visual Basic? Microsoft Visual Basic is a software development tool, which means it.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
XP New Perspectives on Windows XP Tutorial 1 Exploring the Basics.
1 Event Driven Programs Rick Mercer. 2 So what happens next?  You can layout a real pretty GUI  You can click on buttons, enter text into a text field,
FLTK Help Session By Richard Yu Gu CS 638 -Graphics Fall, 1999.
Computing Fundamentals Module Lesson 3 — Changing Settings and Customizing the Desktop Computer Literacy BASICS.
Copyright © 2010 Wolters Kluwer Health | Lippincott Williams & Wilkins Introduction to Windows Chapter 2.
Introduction to Windows Programming
CSCE 121: Introduction to Program Design and Concepts, Honors Dr. J. Michael Moore Spring 2015 Set 15: GUIs 1.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
WaveMaker Visual AJAX Studio 4.0 Training Basics: Building Your First Application Designer Basics.
FLTK. Objectives Install and Use FLTK Widgets ◦Callbacks Handling event ◦System events ◦Mouse events ◦Keyboard events.
1 Chapter 12 GUI C/C++ Language Programming Wanxiang Che.
1 CSC 222: Object-Oriented Programming Spring 2012 netBeans & GUIBuilder  netBeans IDE create/edit/run a project  GUIBuilder JFrame, JButton, JTextField,
Dale Roberts Introduction to Visual Programming Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.
Introduction to OpenGL and GLUT. What’s OpenGL? An Application Programming Interface (API) A low-level graphics programming API – Contains over 250 functions.
GUI With GTK+ Under Linux Fanfan Xiong. Introduction GTK+ (GIMP toolkit) : A library for creating graphical user interfaces(GUI) Two examples developed.
Build-A-Button Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Wednesday, October 8, 2003.
MS Visual Basic 6 Walter Milner. VB 6 0 Introduction –background to VB, A hello World program 1 Core language 1 –Projects, data types, variables, forms,
Lesson No: 6 Introduction to Windows XP CHBT-01 Basic Micro process & Computer Operation.
The Abstract Window Toolkit (AWT) supports Graphical User Interface (GUI) programming. AWT features include: a rich set of user interface components; a.
Microsoft Visual Basic 2012 CHAPTER ELEVEN Multiple Classes and Inheritance.
Class Builder Tutorial Presented By- Amit Singh & Sylendra Prasad.
July Doxygen A Code Documentation System Doxygen generates documentation directly from the structure and comments in the code –Browsable HTML documentation.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
GUIs Basic Concepts. GUI GUI : Graphical User Interface Window/Frame : a window on the screen Controls/Widgets : GUI components.
Introduction to Matlab Module #10 Page 1 Introduction to Matlab Module #10 – Creating Graphical User Interfaces Topics 1.Overview of GUI Development using.
OpenGL in FLTK  .
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
Project 1: Impressionist Help Session Zinnia Zheng
July FLTK The Fast Light Toolkit • A C++ graphical user interface toolkit • Can be used under X, Windows, MacOS • Supports OpenGL • Provides: – Interactive.
COMPUTER INPUT DEVICE Keyboard. Keyboard cont…… Print Screen Print contents of screen Pause/Break Terminate/Interrupt Scroll Lock Modify behavior of the.
1. 2 Qt Toolkit ● C++ toolkit for cross-platform GUI application development – GUI functions (GUI = graphical user interface) – Data access components,
CSC 222: Object-Oriented Programming
Java FX: Scene Builder.
Development Environment
Multiple Classes and Inheritance
FLTK The Fast Light Toolkit
Event Driven Programming
Introduction to Computing Using Java
Event Driven Programming Anatomy – Handle
Presentation transcript:

FLTK Tutorial

Introduction Installation Widgets Handling Event System events Mouse events Keyboard events

Introduction The Fast Light Tool Kit (“FLTK”, pronounced “fulltick”) is a cross-platform C++ GUI toolkit FLTK was originally developed by Mr. Bill Spitzak FLTK website: http://www.fltk.org/index.php Documentation: http://www.fltk.org/documentation.php

Why FLTK ? It’s Free Open Source Software It’s cross platform It supports OpenGL It has a graphical user interface builder called FLUID

Install FLTK http://www.fltk.org/software.php get source code and unzip it Linux/ Unix/ Mac OSX ./configure && make && make install Mac Xcode Xcode project file can be found in fltk-source/ide/ Windows Visual Studio Open fltk-source/ide/VisualC/fltk.sln and build In fltk-source copy FL folder to vc/include In fltk-source/lib copy all files to vc/lib

Linking Visual Studio Linux/ Unix Add fltk.lib, wsock32.lib, comctl32.lib,fltkgl.lib, fltkforms.lib, and fltkimages.lib (or fltkd.lib, etc.) to linker input Linux/ Unix `fltk-config --use-gl --use-images --use-forms --cxxflags –ldflags`

Widgets

Common FLTK Widgets Buttons Text box Valuators Groups Includes radio buttons and check boxes Text box Display and receive strings Valuators Display and receive numbers Groups Containers such as tabs and group boxes Also includes windows and OpenGL windows

FLTK Hello World #include <FL/Fl.H> //FLTK global class 180 300 20 40 260 100 #include <FL/Fl.H> //FLTK global class #include <FL/Fl_Window.H> #include <FL/Fl_Box.H> Int main(int argc, char **argv) { Fl_Window *window = new Fl_Window(300, 180); Fl_Box *box = new Fl_Box(20, 40, 260, 100, "Hello World"); box->box(FL_UP_BOX); //tell FLTK that we will not add any more widgets to window window->end(); //show the window and enter the FLTK event loop: window->show(argc, argv); return Fl::run(); }

FLTK Callbacks Sets a functions to call when the value of a widget changes void functionName(Fl_Widget*, void*) Called function passed pointer to the widget that changed and optional pointer to data Can be activated by keyboard shortcut

Callback Demo void button_cb(Fl_Widget *widget, void *data) { Fl_Button *button = (Fl_Button*)widget; button->label("Thank you"); } Int main(int argc, char **argv) ... Fl_Button *button = new Fl_Button(50, 70, 200, 40, "Click Me"); button->callback(button_cb);

Custom Widgets Subclass an existing widget hold a list of child widgets and handle them together

Custom Widget Composite widget Slider and text box When the value of one changes the other is updated Will use slider internally to store data Easier because already has min, max, etc.

Main function #include <FL/Fl.H> #include <FL/Fl_Window.H> #include "CustomWidget.h" int main(int argc, char **argv) { Fl_Window *window = new Fl_Window(300, 120); CustomWidget *customWidget = new CustomWidget(50, 50, 200, 20); window->end(); window->show(argc, argv); return Fl::run(); }

Widget is a composition so we will inherit Fl_Group Class CustomWidget : Fl_Group { Constructor with default FLTK parameters public: CustomWidget(int x, int y, int w, int h, char *l =0) : Fl_Group(x, y, w, h, l);

Slider will store our data Our two widgets private: Fl_Int_Input*input; Fl_Slider*slider; Slider will store our data Current value Bounds Step size

Common slider properties public: int value(); void value(intv); int minimum(); void minimum(int min); int maximum(); void maximum(int max); void bounds(int min, int max);

Internal callbacks static void input_cb(Fl_Widget *w, void *d); static void slider_cb(Fl_Widget *w, void *d); void input_cb2(); void slider_cb2();

Constructor: Layout Int const in_w = 40; input = new Fl_Int_Input(x, y, in_w, h); slider = new Fl_Slider(x + in_w, y, w- in_w, h); slider->type(FL_HOR_SLIDER);

Constructor: Data bounds(1, 100); value(1); Constructor: Callbacks //The callback is done each time the text is changed by the user input->when(FL_WHEN_CHANGED); input->callback(input_cb, this); slider->callback(slider_cb, this);

Static callbacks void CustomWidget::input_cb(Fl_Widget *w, void *d) { ((CustomWidget*)d)->input_cb2(); } void CustomWidget::slider_cb(Fl_Widget *w, ((CustomWidget*)d)->slider_cb2();

Callbacks: Update the other widget void CustomWidget::input_cb2() { Int val; sscanf(input->value(), "%d", &val); slider->value(val); } void CustomWidget::slider_cb2() char val[16]; sprintf(val, "%d", (int)(slider->value() + 0.5)); input->value(val);

Properties Int CustomWidget::value() { return (int)(slider->value() + 0.5); } void CustomWidget::value(intv) slider->value(v); slider_cb2();

System Events Focus events Clipboard events Widget events Mouse enters/leaves program Program gains/loses focus Clipboard events Widget events Activation/deactivation Show/hide

Mouse Events Button pushed down Mouse moved while button pressed (drag) Button release Mouse moved Mouse wheel

Keyboard Events Key Up/Down

FLTK Events Override int handle(int event) Return 0 if event unused Event will continue to be passed around Return 1 if event used Event is consumed Slider responds to up/down keys

Int CustomWidget::handle(int event) { if ( event == FL_KEYDOWN ) if ( Fl::event_key() == FL_Up ) value(value() + 1); return 1; } else if ( Fl::event_key() == FL_Down ) value(value() - 1); return Fl_Group::handle(event);