SlideShare a Scribd company logo
1 #include <iostream>
2 #include <FL/Fl.H>
3 #include <FL/Fl_Window.H>
4 #include <FL/Fl_Button.H>
5
6 /*Declaração de namespace para uso das funções de iostream*/
7 using namespace std;
8
9 /**
10 * Classe para verificação de eventos em um botão ...
11 **/
12 class MyButton : public Fl_Button
13 {
14 /*Variável estática para contagem de eventos*/
15 static int count;
16
17 public:
18
19 /*Construtor*/
20 MyButton(int x,int y,int w,int h,const char*l=0):Fl_Button(x,y,w,h,l){};
21
22 /*Sobreposição do método manipulador de eventos*/
23 int handle(int event)
24 {
25 int retorno = Fl_Button::handle(event);
26 cout << endl << count++ << " ******** button " << this->label() << " receives ";
27
28 switch(event)
29 {
30 case FL_PUSH:
31 cout << "push" << " event and returns:" << retorno << endl;
32 break;
33
34 case FL_RELEASE:
35 cout << "release" << " event and returns:" << retorno << endl;
36 break;
37
38 case FL_ENTER:
39 color(FL_CYAN);
40 cout << "enter" << " event and returns:" << retorno << endl;
41 redraw();
42 break;
43
44 case FL_LEAVE:
45 color(FL_BACKGROUND_COLOR);
46 cout << "leave" << " event and returns:" << retorno << endl;
47 redraw();
48 break;
49
50 case FL_DRAG:
51 cout << "drag" << " event and returns:" << retorno << endl;
52 break;
53
54 case FL_FOCUS:
55 cout << "focus" << " event and returns:" << retorno << endl;
56 break;
57
58 case FL_UNFOCUS:
59 cout << "unfocus" << " event and returns:" << retorno << endl;
60 break;
61
62 case FL_KEYDOWN:
63 cout << "keydown" << " event and returns:" << retorno << endl;
64 break;
65
66 case FL_KEYUP:
67 if ( Fl::event_key() == shortcut() )
68 {
69 box(FL_UP_BOX);
70 redraw();
71 retorno = 1; //return handled so keyup event stops
72 } //being sent to ALL other buttons unecessarily
73
74 cout << "keyup" << " event and returns:" << retorno << endl;
75 break;
76
77 case FL_CLOSE:
78 cout << "close" << " event and returns:" << retorno << endl;
79 break;
80
81 case FL_MOVE:
82 cout << "move" << " event and returns:" << retorno << endl;
83 break;
84
85 case FL_SHORTCUT:
86 if ( Fl::event_key() == shortcut() )
87 {
88 box(FL_DOWN_BOX);
89 redraw();
90 }
91 cout << "shortcut" << " event and returns:" << retorno << endl;
92 break;
93
94 case FL_DEACTIVATE:
95 cout << "deactivate" << " event and returns:" << retorno << endl;
96 break;
97
98 case FL_ACTIVATE:
99 cout << "activate" << " event and returns:" << retorno << endl;
100 break;
101
102 case FL_HIDE:
103 cout << "hide" << " event and returns:" << retorno << endl;
104 break;
105
106 case FL_SHOW:
107 cout << "show" << " event and returns:" << retorno << endl;
108 break;
109
110 case FL_PASTE:
111 cout << "paste" << " event and returns:" << retorno << endl;
112 break;
113
114 case FL_SELECTIONCLEAR:
115 cout << "selectionclear" << " event and returns:" << retorno << endl;
116 break;
117
118 case FL_MOUSEWHEEL:
119 cout << "mousewheel" << " event and returns:" << retorno << endl;
120 break;
121
122 case FL_NO_EVENT:
123 cout << "no event" << " and returns:" << retorno << endl;
124 break;
125 }
126
127 /*Retorno do método ...*/
128 return(retorno);
129 }
130 };
131
132 /**
133 * Atribuição inicial da variável estática ...
134 */
135 int MyButton::count=0;
136
137 /**
138 * Funções que respondem aos callbacks
139 */
140 void but_a_cb(Fl_Widget* w, void* v)
141 {
142 cout << endl << "Button A callback!" << endl;
143 }
144
145 void but_b_cb(Fl_Widget* w, void* v)
146 {
147 cout << endl << "Button B callback!" << endl;
148 }
149
150 void but_c_cb(Fl_Widget* w, void* v)
151 {
152 cout << endl << "Button C callback!" << endl;
153 }
154
155 /**
156 * Função principal do programa.
157 */
158 int main(int argc, char* argv[])
159 {
160 Fl_Window win(120,150);
161 win.begin();
162 MyButton but_a(10,10,100,25,"A");
163 but_a.shortcut('a');
164 but_a.callback(but_a_cb);
165 MyButton but_b(10,50,100,25,"B");
166 but_b.shortcut('b');
167 but_b.callback(but_b_cb);
168 MyButton but_c(10,90,100,25,"C");
169 but_c.shortcut('c');
170 but_c.callback(but_c_cb);
171 win.end();
172 win.show();
173 return(Fl::run());
174 }
175

More Related Content

PDF
The Ring programming language version 1.8 book - Part 62 of 202
PDF
The Ring programming language version 1.5.4 book - Part 55 of 185
PDF
The Ring programming language version 1.5.1 book - Part 54 of 180
DOCX
Calculadora
PDF
The Ring programming language version 1.5.1 book - Part 56 of 180
DOCX
VISUALIZAR REGISTROS EN UN JTABLE
PDF
The Ring programming language version 1.8 book - Part 12 of 202
The Ring programming language version 1.8 book - Part 62 of 202
The Ring programming language version 1.5.4 book - Part 55 of 185
The Ring programming language version 1.5.1 book - Part 54 of 180
Calculadora
The Ring programming language version 1.5.1 book - Part 56 of 180
VISUALIZAR REGISTROS EN UN JTABLE
The Ring programming language version 1.8 book - Part 12 of 202

What's hot (20)

PDF
The Ring programming language version 1.9 book - Part 14 of 210
PDF
The Ring programming language version 1.8 book - Part 64 of 202
PDF
The Ring programming language version 1.7 book - Part 61 of 196
PDF
The Ring programming language version 1.7 book - Part 59 of 196
PDF
The Ring programming language version 1.7 book - Part 60 of 196
PDF
The Ring programming language version 1.5.2 book - Part 55 of 181
PDF
Open GL Tutorial07
PDF
The Ring programming language version 1.6 book - Part 58 of 189
PDF
The Ring programming language version 1.5.1 book - Part 55 of 180
DOCX
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
PDF
The Ring programming language version 1.5.2 book - Part 54 of 181
PDF
The Ring programming language version 1.8 book - Part 63 of 202
PPTX
Diagrama de flujo de simulacion de variables
DOCX
Project fast food automaton
PDF
The Ring programming language version 1.9 book - Part 67 of 210
PPTX
Building powerful desktop and MR applications with new windowing apis
PDF
The Ring programming language version 1.5.3 book - Part 67 of 184
DOC
Electricitybillsystemreport
PDF
The Ring programming language version 1.5 book - Part 10 of 31
PDF
The Ring programming language version 1.6 book - Part 57 of 189
The Ring programming language version 1.9 book - Part 14 of 210
The Ring programming language version 1.8 book - Part 64 of 202
The Ring programming language version 1.7 book - Part 61 of 196
The Ring programming language version 1.7 book - Part 59 of 196
The Ring programming language version 1.7 book - Part 60 of 196
The Ring programming language version 1.5.2 book - Part 55 of 181
Open GL Tutorial07
The Ring programming language version 1.6 book - Part 58 of 189
The Ring programming language version 1.5.1 book - Part 55 of 180
Sumsem2014 15 cp0399-13-jun-2015_rm01_programs
The Ring programming language version 1.5.2 book - Part 54 of 181
The Ring programming language version 1.8 book - Part 63 of 202
Diagrama de flujo de simulacion de variables
Project fast food automaton
The Ring programming language version 1.9 book - Part 67 of 210
Building powerful desktop and MR applications with new windowing apis
The Ring programming language version 1.5.3 book - Part 67 of 184
Electricitybillsystemreport
The Ring programming language version 1.5 book - Part 10 of 31
The Ring programming language version 1.6 book - Part 57 of 189
Ad

Viewers also liked (20)

ODP
Servicios web con Python
PDF
FLTK Summer Course - Part II - Second Impact - Exercises
PDF
Git hooks For PHP Developers
PDF
Using Git on the Command Line
PPT
Introduction to Git Commands and Concepts
PDF
Advanced Git
PDF
"Git Hooked!" Using Git hooks to improve your software development process
PDF
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
PDF
FLTK Summer Course - Part VIII - Eighth Impact
PDF
FLTK Summer Course - Part VII - Seventh Impact
PDF
FLTK Summer Course - Part I - First Impact - Exercises
PDF
FLTK Summer Course - Part II - Second Impact
PPTX
Manipulating file in Python
PDF
Blisstering drupal module development ppt v1.2
PDF
Code Refactoring - Live Coding Demo (JavaDay 2014)
PDF
FLTK Summer Course - Part III - Third Impact
PPT
Creating Custom Drupal Modules
PDF
TMS - Schedule of Presentations and Reports
PPT
13 Graph Classes
PPTX
Internal Anatomy of an Update
Servicios web con Python
FLTK Summer Course - Part II - Second Impact - Exercises
Git hooks For PHP Developers
Using Git on the Command Line
Introduction to Git Commands and Concepts
Advanced Git
"Git Hooked!" Using Git hooks to improve your software development process
EuroPython 2013 - FAST, DOCUMENTED AND RELIABLE JSON BASED WEBSERVICES WITH P...
FLTK Summer Course - Part VIII - Eighth Impact
FLTK Summer Course - Part VII - Seventh Impact
FLTK Summer Course - Part I - First Impact - Exercises
FLTK Summer Course - Part II - Second Impact
Manipulating file in Python
Blisstering drupal module development ppt v1.2
Code Refactoring - Live Coding Demo (JavaDay 2014)
FLTK Summer Course - Part III - Third Impact
Creating Custom Drupal Modules
TMS - Schedule of Presentations and Reports
13 Graph Classes
Internal Anatomy of an Update
Ad

Similar to FLTK Summer Course - Part VI - Sixth Impact - Exercises (20)

DOC
Advanced pointer
PDF
MVI - Managing State The Kotlin Way
PDF
The Ring programming language version 1.10 book - Part 68 of 212
PPTX
Introducing Wire for Drupal, the Livewire concepts adapted to work with Drupal
PDF
The Ring programming language version 1.10 book - Part 16 of 212
TXT
Penjualan swalayan
PDF
The Ring programming language version 1.5.3 book - Part 66 of 184
DOCX
PDF
The Ring programming language version 1.5.4 book - Part 57 of 185
PPT
Lecture#5 Operators in C++
PDF
I hope the below code is helpful to you, please give me rewards.im.pdf
PDF
The Ring programming language version 1.9 book - Part 66 of 210
PDF
Yahoo presentation: JavaScript Events
PDF
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
PDF
551 pd fsam_fayed_ring_doc_1.5.2
PPT
PPT
Powerpoint loop examples a
PDF
The Ring programming language version 1.5.4 book - Part 56 of 185
DOCX
verilog code
PDF
The Ring programming language version 1.6 book - Part 59 of 189
Advanced pointer
MVI - Managing State The Kotlin Way
The Ring programming language version 1.10 book - Part 68 of 212
Introducing Wire for Drupal, the Livewire concepts adapted to work with Drupal
The Ring programming language version 1.10 book - Part 16 of 212
Penjualan swalayan
The Ring programming language version 1.5.3 book - Part 66 of 184
The Ring programming language version 1.5.4 book - Part 57 of 185
Lecture#5 Operators in C++
I hope the below code is helpful to you, please give me rewards.im.pdf
The Ring programming language version 1.9 book - Part 66 of 210
Yahoo presentation: JavaScript Events
Matteo Antony Mistretta - Refactoring into React hooks - Codemotion Rome 2019
551 pd fsam_fayed_ring_doc_1.5.2
Powerpoint loop examples a
The Ring programming language version 1.5.4 book - Part 56 of 185
verilog code
The Ring programming language version 1.6 book - Part 59 of 189

More from Michel Alves (20)

PDF
Texture Synthesis: An Approach Based on GPU Use
PDF
Intelligent Transfer of Thematic Harmonic Color Palettes
PDF
A Framework for Harmonic Color Measures
PDF
Effectiveness of Image Quality Assessment Indexes
PDF
Introduction to Kernel Functions
PDF
About Perception and Hue Histograms in HSV Space
PDF
Color Harmonization - Results
PDF
Wave Simulation Using Perlin Noise
PDF
Similarity Maps Using SSIM Index
PDF
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
PDF
Month Presentations Schedule - March/2015 - LCG/UFRJ
PDF
Color Palettes in R
PDF
Sigmoid Curve Erf
PDF
Hue Wheel Prototype
PDF
Cosine Curve
PDF
Triangle Mesh Plot
PDF
Triangle Plot
PDF
Capacity-Constrained Point Distributions :: Video Slides
PDF
Capacity-Constrained Point Distributions :: Density Function Catalog
PDF
Capacity-Constrained Point Distributions :: Complementary Results
Texture Synthesis: An Approach Based on GPU Use
Intelligent Transfer of Thematic Harmonic Color Palettes
A Framework for Harmonic Color Measures
Effectiveness of Image Quality Assessment Indexes
Introduction to Kernel Functions
About Perception and Hue Histograms in HSV Space
Color Harmonization - Results
Wave Simulation Using Perlin Noise
Similarity Maps Using SSIM Index
Qualifying Exam - Image-Based Reconstruction With Color Harmonization
Month Presentations Schedule - March/2015 - LCG/UFRJ
Color Palettes in R
Sigmoid Curve Erf
Hue Wheel Prototype
Cosine Curve
Triangle Mesh Plot
Triangle Plot
Capacity-Constrained Point Distributions :: Video Slides
Capacity-Constrained Point Distributions :: Density Function Catalog
Capacity-Constrained Point Distributions :: Complementary Results

Recently uploaded (20)

PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
PPH.pptx obstetrics and gynecology in nursing
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
master seminar digital applications in india
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Supply Chain Operations Speaking Notes -ICLT Program
Week 4 Term 3 Study Techniques revisited.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
O7-L3 Supply Chain Operations - ICLT Program
Final Presentation General Medicine 03-08-2024.pptx
human mycosis Human fungal infections are called human mycosis..pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPH.pptx obstetrics and gynecology in nursing
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Microbial diseases, their pathogenesis and prophylaxis
FourierSeries-QuestionsWithAnswers(Part-A).pdf
master seminar digital applications in india
O5-L3 Freight Transport Ops (International) V1.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Microbial disease of the cardiovascular and lymphatic systems
Supply Chain Operations Speaking Notes -ICLT Program

FLTK Summer Course - Part VI - Sixth Impact - Exercises

  • 1. 1 #include <iostream> 2 #include <FL/Fl.H> 3 #include <FL/Fl_Window.H> 4 #include <FL/Fl_Button.H> 5 6 /*Declaração de namespace para uso das funções de iostream*/ 7 using namespace std; 8 9 /** 10 * Classe para verificação de eventos em um botão ... 11 **/ 12 class MyButton : public Fl_Button 13 { 14 /*Variável estática para contagem de eventos*/ 15 static int count; 16 17 public: 18 19 /*Construtor*/ 20 MyButton(int x,int y,int w,int h,const char*l=0):Fl_Button(x,y,w,h,l){}; 21 22 /*Sobreposição do método manipulador de eventos*/ 23 int handle(int event) 24 { 25 int retorno = Fl_Button::handle(event); 26 cout << endl << count++ << " ******** button " << this->label() << " receives "; 27 28 switch(event) 29 { 30 case FL_PUSH: 31 cout << "push" << " event and returns:" << retorno << endl; 32 break; 33 34 case FL_RELEASE: 35 cout << "release" << " event and returns:" << retorno << endl; 36 break; 37 38 case FL_ENTER: 39 color(FL_CYAN); 40 cout << "enter" << " event and returns:" << retorno << endl; 41 redraw(); 42 break; 43 44 case FL_LEAVE: 45 color(FL_BACKGROUND_COLOR); 46 cout << "leave" << " event and returns:" << retorno << endl; 47 redraw(); 48 break; 49 50 case FL_DRAG: 51 cout << "drag" << " event and returns:" << retorno << endl; 52 break; 53 54 case FL_FOCUS: 55 cout << "focus" << " event and returns:" << retorno << endl; 56 break; 57 58 case FL_UNFOCUS: 59 cout << "unfocus" << " event and returns:" << retorno << endl; 60 break; 61 62 case FL_KEYDOWN: 63 cout << "keydown" << " event and returns:" << retorno << endl; 64 break; 65 66 case FL_KEYUP: 67 if ( Fl::event_key() == shortcut() ) 68 { 69 box(FL_UP_BOX); 70 redraw(); 71 retorno = 1; //return handled so keyup event stops 72 } //being sent to ALL other buttons unecessarily
  • 2. 73 74 cout << "keyup" << " event and returns:" << retorno << endl; 75 break; 76 77 case FL_CLOSE: 78 cout << "close" << " event and returns:" << retorno << endl; 79 break; 80 81 case FL_MOVE: 82 cout << "move" << " event and returns:" << retorno << endl; 83 break; 84 85 case FL_SHORTCUT: 86 if ( Fl::event_key() == shortcut() ) 87 { 88 box(FL_DOWN_BOX); 89 redraw(); 90 } 91 cout << "shortcut" << " event and returns:" << retorno << endl; 92 break; 93 94 case FL_DEACTIVATE: 95 cout << "deactivate" << " event and returns:" << retorno << endl; 96 break; 97 98 case FL_ACTIVATE: 99 cout << "activate" << " event and returns:" << retorno << endl; 100 break; 101 102 case FL_HIDE: 103 cout << "hide" << " event and returns:" << retorno << endl; 104 break; 105 106 case FL_SHOW: 107 cout << "show" << " event and returns:" << retorno << endl; 108 break; 109 110 case FL_PASTE: 111 cout << "paste" << " event and returns:" << retorno << endl; 112 break; 113 114 case FL_SELECTIONCLEAR: 115 cout << "selectionclear" << " event and returns:" << retorno << endl; 116 break; 117 118 case FL_MOUSEWHEEL: 119 cout << "mousewheel" << " event and returns:" << retorno << endl; 120 break; 121 122 case FL_NO_EVENT: 123 cout << "no event" << " and returns:" << retorno << endl; 124 break; 125 } 126 127 /*Retorno do método ...*/ 128 return(retorno); 129 } 130 }; 131 132 /** 133 * Atribuição inicial da variável estática ... 134 */ 135 int MyButton::count=0; 136 137 /** 138 * Funções que respondem aos callbacks 139 */ 140 void but_a_cb(Fl_Widget* w, void* v) 141 { 142 cout << endl << "Button A callback!" << endl; 143 } 144
  • 3. 145 void but_b_cb(Fl_Widget* w, void* v) 146 { 147 cout << endl << "Button B callback!" << endl; 148 } 149 150 void but_c_cb(Fl_Widget* w, void* v) 151 { 152 cout << endl << "Button C callback!" << endl; 153 } 154 155 /** 156 * Função principal do programa. 157 */ 158 int main(int argc, char* argv[]) 159 { 160 Fl_Window win(120,150); 161 win.begin(); 162 MyButton but_a(10,10,100,25,"A"); 163 but_a.shortcut('a'); 164 but_a.callback(but_a_cb); 165 MyButton but_b(10,50,100,25,"B"); 166 but_b.shortcut('b'); 167 but_b.callback(but_b_cb); 168 MyButton but_c(10,90,100,25,"C"); 169 but_c.shortcut('c'); 170 but_c.callback(but_c_cb); 171 win.end(); 172 win.show(); 173 return(Fl::run()); 174 } 175