0% found this document useful (0 votes)
6 views

FLTK

Uploaded by

Pedro Llamoca
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

FLTK

Uploaded by

Pedro Llamoca
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 997

FLTK 1.3.

3 Programming Manual

Revision 9 by F. Costantini, D. Gibson, M. Melcher,


A. Schlosser, B. Spitzak, and M. Sweet.

Copyright 1998-2014 by Bill Spitzak and others.

This software and manual are provided under the terms of the GNU Library General Public License.
Permission is granted to reproduce this manual or any portion for any purpose,
provided this copyright and permission notice are preserved.

Generated by Doxygen 1.8.6

November 3, 2014
Contents

1 FLTK Programming Manual 3

2 Preface 5
2.1 Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Copyrights and Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Introduction to FLTK 7
3.1 History of FLTK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3 Licensing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4 What Does ”FLTK” Mean? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.5 Building and Installing FLTK Under UNIX and Apple OS X . . . . . . . . . . . . . . . . 9
3.6 Building FLTK Under Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.7 Internet Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.8 Reporting Bugs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

4 FLTK Basics 13
4.1 Writing Your First FLTK Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.2 Compiling Programs with Standard Compilers . . . . . . . . . . . . . . . . . . . . . . . . 15
4.3 Compiling Programs with Makefiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.4 Compiling Programs with Microsoft Visual C++ . . . . . . . . . . . . . . . . . . . . . . . 17
4.5 Naming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.6 Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

5 Common Widgets and Attributes 19


5.1 Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.2 Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.3 Valuators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.4 Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
5.5 Setting the Size and Position of Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.6 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.7 Box Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.8 Labels and Label Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.9 Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.10 Shortcuts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

6 Designing a Simple Text Editor 31


6.1 Determining the Goals of the Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.2 Designing the Main Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
6.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
6.4 Menubars and Menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

i
ii CONTENTS

6.5 Editing the Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32


6.6 The Replace Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.7 Callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
6.8 Other Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
6.9 The main() Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.10 Compiling the Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
6.11 The Final Product . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
6.12 Advanced Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

7 Drawing Things in FLTK 43


7.1 When Can You Draw Things in FLTK? . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7.2 Drawing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
7.3 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
7.4 Drawing Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

8 Handling Events 59
8.1 The FLTK Event Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
8.2 Mouse Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
8.3 Focus Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
8.4 Keyboard Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
8.5 Widget Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
8.6 Clipboard Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.7 Drag and Drop Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.8 Other events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.9 Fl::event ∗() methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
8.10 Event Propagation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
8.11 FLTK Compose-Character Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

9 Adding and Extending Widgets 65


9.1 Subclassing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
9.2 Making a Subclass of Fl Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
9.3 The Constructor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
9.4 Protected Methods of Fl Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
9.5 Handling Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
9.6 Drawing the Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
9.7 Resizing the Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
9.8 Making a Composite Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
9.9 Cut and Paste Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
9.10 Drag And Drop Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
9.11 Making a subclass of Fl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

10 Using OpenGL 73
10.1 Using OpenGL in FLTK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
10.2 Making a Subclass of Fl Gl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
10.3 Using OpenGL in Normal FLTK Windows . . . . . . . . . . . . . . . . . . . . . . . . . 75
10.4 OpenGL Drawing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
10.5 Speeding up OpenGL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
10.6 Using OpenGL Optimizer with FLTK . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

11 Programming with FLUID 79


11.1 What is FLUID? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
11.2 Running FLUID Under UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
11.3 Running FLUID Under Microsoft Windows . . . . . . . . . . . . . . . . . . . . . . . . . 80
11.4 Compiling .fl files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
CONTENTS iii

11.5 A Short Tutorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81


11.6 FLUID Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
11.7 GUI Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
11.8 Selecting and Moving Widgets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
11.9 Image Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
11.10Internationalization with FLUID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
11.11Known limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

12 Advanced FLTK 107


12.1 Multithreading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

13 Unicode and UTF-8 Support 109


13.1 About Unicode, ISO 10646 and UTF-8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
13.2 Unicode in FLTK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
13.3 Illegal Unicode and UTF-8 sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
13.4 FLTK Unicode and UTF-8 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
13.5 FLTK Unicode versions of system calls . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

14 FLTK Enumerations 117


14.1 Version Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
14.2 Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
14.3 Callback ”When” Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
14.4 Fl::event button() Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
14.5 Fl::event key() Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
14.6 Fl::event state() Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
14.7 Alignment Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
14.8 Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
14.9 Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
14.10Cursors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
14.11FD ”When” Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
14.12Damage Masks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124

15 GLUT Compatibility 125


15.1 Using the GLUT Compatibility Header File . . . . . . . . . . . . . . . . . . . . . . . . . 125
15.2 Known Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
15.3 Mixing GLUT and FLTK Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
15.4 class Fl Glut Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

16 Forms Compatibility 129


16.1 Importing Forms Layout Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
16.2 Using the Compatibility Header File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
16.3 Problems You Will Encounter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
16.4 Additional Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

17 Operating System Issues 135


17.1 Accessing the OS Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
17.2 The UNIX (X11) Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135
17.3 The Windows (WIN32) Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
17.4 The Apple OS X Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
iv CONTENTS

18 Migrating Code from FLTK 1.0 to 1.1 147


18.1 Color Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
18.2 Cut and Paste Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
18.3 File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
18.4 Function Names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
18.5 Image Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
18.6 Keyboard Navigation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

19 Migrating Code from FLTK 1.1 to 1.3 149


19.1 Migrating From FLTK 1.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
19.2 Fl Scroll Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
19.3 Unicode (UTF-8) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
19.4 Widget Coordinate Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

20 Developer Information 151


20.1 Non-ASCII Characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
20.2 Document Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
20.3 Creating Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
20.4 Paragraph Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
20.5 Navigation Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

21 Software License 157

22 Example Source Code 163


22.1 Example Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

23 FAQ (Frequently Asked Questions) 173


23.1 Where do I start learning FLTK? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
23.2 How do I make a box with text? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
23.3 Can I use FLTK to make closed-source commercial applications? . . . . . . . . . . . . . 174
23.4 Hitting the ’Escape’ key closes windows - how do I prevent this? . . . . . . . . . . . . . . 174

24 Todo List 177

25 Deprecated List 181

26 Module Index 183


26.1 Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

27 Hierarchical Index 185


27.1 Class Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

28 Class Index 189


28.1 Class List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

29 File Index 197


29.1 File List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

30 Module Documentation 203


30.1 Callback function typedefs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
30.2 Windows handling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
30.3 Events handling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
30.4 Selection & Clipboard functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
30.5 Screen functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
30.6 Color & Font functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
30.7 Drawing functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
CONTENTS v

30.8 Multithreading support functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255


30.9 Safe widget deletion support functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
30.10Cairo support functions and classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
30.11Unicode and UTF-8 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
30.12Mac OS X-specific symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
30.13Common Dialogs classes and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
30.14File names and URI utility functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

31 Class Documentation 291


31.1 Fl Preferences::Entry Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
31.2 Fl Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
31.3 Fl Adjuster Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
31.4 Fl Bitmap Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
31.5 Fl BMP Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
31.6 Fl Box Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
31.7 Fl Browser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
31.8 Fl Browser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
31.9 Fl Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
31.10Fl Cairo State Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
31.11Fl Cairo Window Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
31.12Fl Chart Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
31.13FL CHART ENTRY Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
31.14Fl Check Browser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
31.15Fl Check Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
31.16Fl Choice Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
31.17Fl Clock Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
31.18Fl Clock Output Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
31.19Fl Color Chooser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
31.20Fl Copy Surface Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
31.21Fl Counter Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
31.22Fl Device Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
31.23Fl Device Plugin Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
31.24Fl Dial Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
31.25Fl Display Device Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
31.26Fl Double Window Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
31.27Fl End Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
31.28Fl File Browser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
31.29Fl File Chooser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
31.30Fl File Icon Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
31.31Fl File Input Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
31.32Fl Fill Dial Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
31.33Fl Fill Slider Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
31.34Fl Float Input Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
31.35Fl FLTK File Chooser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
31.36Fl Font Descriptor Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
31.37Fl Fontdesc Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
31.38Fl FormsBitmap Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
31.39Fl FormsPixmap Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
31.40Fl FormsText Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
31.41Fl Free Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
31.42Fl GDI Graphics Driver Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 421
31.43Fl GDI Printer Graphics Driver Class Reference . . . . . . . . . . . . . . . . . . . . . . 425
31.44Fl GIF Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
31.45Fl Gl Choice Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
vi CONTENTS

31.46Fl Gl Window Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427


31.47Fl Glut Bitmap Font Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
31.48Fl Glut StrokeChar Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
31.49Fl Glut StrokeFont Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
31.50Fl Glut StrokeStrip Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
31.51Fl Glut StrokeVertex Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
31.52Fl Glut Window Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
31.53Fl Graphics Driver Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
31.54Fl Group Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
31.55Fl GTK File Chooser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
31.56Fl Help Block Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
31.57Fl Help Dialog Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
31.58Fl Help Font Stack Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
31.59Fl Help Font Style Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
31.60Fl Help Link Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
31.61Fl Help Target Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
31.62Fl Help View Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
31.63Fl Hold Browser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
31.64Fl Hor Fill Slider Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
31.65Fl Hor Nice Slider Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
31.66Fl Hor Slider Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
31.67Fl Hor Value Slider Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
31.68Fl Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
31.69Fl Image Surface Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
31.70Fl Input Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
31.71Fl Input Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
31.72Fl Input Choice Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
31.73Fl Int Input Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
31.74Fl JPEG Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
31.75Fl Label Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
31.76Fl Light Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
31.77Fl Line Dial Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
31.78Fl Mac App Menu Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
31.79Fl Menu Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
31.80Fl Menu Bar Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
31.81Fl Menu Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
31.82Fl Menu Item Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
31.83Fl Menu Window Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
31.84Fl Multi Browser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
31.85Fl Multi Label Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
31.86Fl Multiline Input Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
31.87Fl Multiline Output Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
31.88Fl Native File Chooser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
31.89Fl Nice Slider Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
31.90Fl Output Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
31.91Fl Overlay Window Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
31.92Fl Pack Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
31.93Fl Paged Device Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
31.94Fl Pixmap Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
31.95Fl Plugin Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
31.96Fl Plugin Manager Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
31.97Fl PNG Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
31.98Fl PNM Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
31.99Fl Positioner Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
CONTENTS vii

31.100Fl PostScript File Device Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 576


31.101Fl PostScript Graphics Driver Class Reference . . . . . . . . . . . . . . . . . . . . . . . 581
31.102Fl PostScript Printer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590
31.103Fl Preferences Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
31.104Fl Printer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
31.105Fl Progress Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609
31.106Fl Quartz Graphics Driver Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . 611
31.107Fl Radio Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
31.108Fl Radio Light Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
31.109Fl Radio Round Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
31.110Fl Scroll::ScrollInfo::Fl Region LRTB Struct Reference . . . . . . . . . . . . . . . . . . 616
31.111Fl Scroll::ScrollInfo::Fl Region XYWH Struct Reference . . . . . . . . . . . . . . . . . 617
31.112Fl Repeat Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
31.113Fl Return Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618
31.114Fl RGB Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
31.115Fl Roller Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624
31.116Fl Round Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626
31.117Fl Round Clock Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
31.118Fl Scroll Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
31.119Fl Scrollbar Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
31.120Fl Scroll::ScrollInfo::Fl Scrollbar Data Struct Reference . . . . . . . . . . . . . . . . . . 635
31.121Fl Secret Input Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
31.122Fl Select Browser Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
31.123Fl Shared Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
31.124Fl Simple Counter Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642
31.125Fl Single Window Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
31.126Fl Slider Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
31.127Fl Spinner Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
31.128Fl Surface Device Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
31.129Fl Sys Menu Bar Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
31.130Fl System Printer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
31.131Fl Table Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
31.132Fl Table Row Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
31.133Fl Tabs Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
31.134Fl Text Buffer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
31.135Fl Text Display Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
31.136Fl Text Editor Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
31.137Fl Text Selection Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738
31.138Fl Tile Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
31.139Fl Tiled Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743
31.140Fl Timer Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
31.141Fl Toggle Button Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
31.142Fl Tooltip Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748
31.143Fl Tree Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752
31.144Fl Tree Item Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
31.145Fl Tree Item Array Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803
31.146Fl Tree Prefs Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806
31.147Fl Valuator Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810
31.148Fl Value Input Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814
31.149Fl Value Output Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818
31.150Fl Value Slider Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 821
31.151Fl Widget Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823
31.152Fl Widget Tracker Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857
31.153Fl Window Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
CONTENTS 1

31.154Fl Wizard Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874


31.155Fl XBM Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
31.156Fl XColor Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
31.157Fl Xlib Graphics Driver Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 877
31.158Fl XPM Image Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
31.159Fl Text Editor::Key Binding Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . 881
31.160Fl Graphics Driver::matrix Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . . 881
31.161Fl Preferences::Name Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882
31.162Fl Preferences::Node Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
31.163Fl Paged Device::page format Struct Reference . . . . . . . . . . . . . . . . . . . . . . . 883
31.164Fl Preferences::RootNode Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . 884
31.165Fl Window::shape data type Struct Reference . . . . . . . . . . . . . . . . . . . . . . . . 884
31.166Fl Text Display::Style Table Entry Struct Reference . . . . . . . . . . . . . . . . . . . . 884

32 File Documentation 889


32.1 Enumerations.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 889
32.2 filename.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 909
32.3 Fl.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 910
32.4 fl arc.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 911
32.5 fl arci.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 911
32.6 fl ask.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 912
32.7 fl ask.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 913
32.8 fl boxtype.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 915
32.9 fl color.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 916
32.10Fl Color Chooser.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
32.11Fl compose.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
32.12fl curve.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
32.13Fl Device.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
32.14Fl Double Window.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . 920
32.15fl draw.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 920
32.16Fl Image.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 926
32.17fl line style.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 927
32.18Fl Native File Chooser.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . 927
32.19Fl Paged Device.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 927
32.20Fl Paged Device.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928
32.21Fl PostScript.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 928
32.22Fl Printer.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 930
32.23fl rect.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931
32.24Fl Shared Image.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931
32.25fl show colormap.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 932
32.26Fl Tree.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 932
32.27Fl Tree Item.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 933
32.28Fl Tree Item Array.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 933
32.29Fl Tree Prefs.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 934
32.30fl types.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 935
32.31fl utf8.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 936
32.32fl vertex.cxx File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938
32.33Fl Widget.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938
32.34Fl Window.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 939
32.35gl.h File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 939
32.36mac.H File Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 942
2 CONTENTS
Chapter 1

FLTK Programming Manual

FLTK 1.3.3 Programming Manual

Revision 9 by F. Costantini, D. Gibson,


M. Melcher, A. Schlosser, B. Spitzak and
M. Sweet.

Copyright 1998-2014 by Bill Spitzak and others.

This software and manual are provided under the terms of the GNU Library General Public License.
Permission is granted to reproduce this manual or any portion for any purpose, provided this copyright
and permission notice are preserved.

3
4 CHAPTER 1. FLTK PROGRAMMING MANUAL

Preface Advanced FLTK


Introduction to FLTK Unicode and UTF-8 Support
FLTK Basics
Common Widgets and Attributes Appendices:
• Colors • FLTK Enumerations

• Box Types • GLUT Compatibility


• Labels and Label Types – class Fl Glut Window
• Drawing Images • Forms Compatibility
Designing a Simple Text Editor • Operating System Issues
Drawing Things in FLTK
Handling Events • Migrating Code from FLTK 1.0 to 1.1

• Fl::event ∗() methods • Migrating Code from FLTK 1.1 to 1.3

• Event Propagation • Developer Information

Adding and Extending Widgets • Software License


Using OpenGL • Example Source Code
Programming with FLUID
• FAQ (Frequently Asked Questions)
• GUI Attributes
• Selecting and Moving Widgets

• Image Labels
Chapter 2

Preface

This manual describes the Fast Light Tool Kit (”FLTK”) version 1.3.3, a C++ Graphical User Interface
(”GUI”) toolkit for UNIX, Microsoft Windows and Apple OS X.
Each of the chapters in this manual is designed as a tutorial for using FLTK, while the appendices
provide a convenient reference for all FLTK widgets, functions, and operating system interfaces.
This manual may be printed, modified, and/or used under the terms of the FLTK license provided
in Software License.

2.1 Organization
This manual is organized into the following chapters and appendices:

• Introduction to FLTK

• FLTK Basics

• Common Widgets and Attributes

• Designing a Simple Text Editor

• Drawing Things in FLTK

• Handling Events

• Adding and Extending Widgets

• Using OpenGL

• Programming with FLUID

• Advanced FLTK

• Unicode and UTF-8 Support

• FLTK Enumerations

• GLUT Compatibility

• Forms Compatibility

• Operating System Issues

• Migrating Code from FLTK 1.0 to 1.1

• Migrating Code from FLTK 1.1 to 1.3

5
6 CHAPTER 2. PREFACE

• Developer Information
• Software License

• Example Source Code

2.2 Conventions
This manual was generated using Doxygen (see http://www.doxygen.org/) to process the source
code itself, special comments in the code, and additional documentation files. In general, Doxygen recog-
nizes and denotes the following entities as shown:

• classes, such as Fl Widget,


• methods, such as Fl Widget::callback(Fl Callback∗ cb, void∗ p),
• functions, such as fl draw(const char ∗str, int x, int y),
• internal links, such as Conventions,

• external links, such as http://www.stack.nl/∼dimitri/doxygen/


Other code samples and commands are shown in regular courier type.

2.3 Abbreviations
The following abbreviations are used in this manual:
X11
The X Window System version 11.
Xlib
The X Window System interface library.
MS Windows, WIN32
The Microsoft Windows Application Programmer’s Interface for Windows 2000, Windows XP, Win-
dows Vista, and Windows 7. FLTK uses the preprocessor definition WIN32 for the 32 bit and 64 bit
MS Windows API.
OS X, APPLE
The Apple desktop operating sytem OS X 10.0 and later. MacOS 8 and 9 support was dropped after
FLTK 1.0.10. FLTK uses the preprocessor definition APPLE for OS X.

2.4 Copyrights and Trademarks


FLTK is Copyright 1998-2014 by Bill Spitzak and others. Use and distribution of FLTK is governed by
the GNU Library General Public License with 4 exceptions, located in Software License.
UNIX is a registered trademark of the X Open Group, Inc. Microsoft and Windows are registered
trademarks of Microsoft Corporation. OpenGL is a registered trademark of Silicon Graphics, Inc. Apple,
Macintosh, MacOS, and Mac OS X are registered trademarks of Apple Computer, Inc.
Chapter 3

Introduction to FLTK

The Fast Light Tool Kit (”FLTK”, pronounced ”fulltick”) is a cross-platform C++ GUI toolkit for UNI-
X®/Linux® (X11), Microsoft® Windows®, and Apple® OS X®.
FLTK provides modern GUI functionality without the bloat and supports 3D graphics via OpenG-
L® and its built-in GLUT emulation. It was originally developed by Mr. Bill Spitzak and is currently
maintained by a small group of developers across the world with a central repository in the US.

3.1 History of FLTK


It has always been Bill’s belief that the GUI API of all modern systems is much too high level. Toolkits
(even FLTK) are not what should be provided and documented as part of an operating system. The system
only has to provide arbitrary shaped but featureless windows, a powerful set of graphics drawing calls, and
a simple unalterable method of delivering events to the owners of the windows. NeXT (if you ignored
NextStep) provided this, but they chose to hide it and tried to push their own baroque toolkit instead.
Many of the ideas in FLTK were developed on a NeXT (but not using NextStep) in 1987 in a C toolkit
Bill called ”views”. Here he came up with passing events downward in the tree and having the handle
routine return a value indicating whether it used the event, and the table-driven menus. In general he
was trying to prove that complex UI ideas could be entirely implemented in a user space toolkit, with no
knowledge or support by the system.
After going to film school for a few years, Bill worked at Sun Microsystems on the (doomed) NeW-
S project. Here he found an even better and cleaner windowing system, and he reimplemented ”views”
atop that. NeWS did have an unnecessarily complex method of delivering events which hurt it. But the
designers did admit that perhaps the user could write just as good of a button as they could, and officially
exposed the lower level interface.
With the death of NeWS Bill realized that he would have to live with X. The biggest problem with X is
the ”window manager”, which means that the toolkit can no longer control the window borders or drag the
window around.
At Digital Domain Bill discovered another toolkit, ”Forms”. Forms was similar to his work, but pro-
vided many more widgets, since it was used in many real applications, rather than as theoretical work. He
decided to use Forms, except he integrated his table-driven menus into it. Several very large programs were
created using this version of Forms.
The need to switch to OpenGL and GLX, portability, and a desire to use C++ subclassing required
a rewrite of Forms. This produced the first version of FLTK. The conversion to C++ required so many
changes it made it impossible to recompile any Forms objects. Since it was incompatible anyway, Bill
decided to incorporate his older ideas as much as possible by simplifying the lower level interface and the
event passing mechanism.
Bill received permission to release it for free on the Internet, with the GNU general public license.
Response from Internet users indicated that the Linux market dwarfed the SGI and high-speed GL market,

7
8 CHAPTER 3. INTRODUCTION TO FLTK

so he rewrote it to use X for all drawing, greatly speeding it up on these machines. That is the version you
have now.
Digital Domain has since withdrawn support for FLTK. While Bill is no longer able to actively develop
it, he still contributes to FLTK in his free time and is a part of the FLTK development team.

3.2 Features
FLTK was designed to be statically linked. This was done by splitting it into many small objects and
designing it so that functions that are not used do not have pointers to them in the parts that are used, and
thus do not get linked in. This allows you to make an easy-to-install program or to modify FLTK to the
exact requirements of your application without worrying about bloat. FLTK works fine as a shared library,
though, and is now included with several Linux distributions.
Here are some of the core features unique to FLTK:
• sizeof(Fl Widget) == 64 to 92.
• The ”core” (the ”hello” program compiled & linked with a static FLTK library using gcc on a 486
and then stripped) is 114K.
• The FLUID program (which includes every widget) is 538k.
• Written directly atop core libraries (Xlib, WIN32 or Cocoa) for maximum speed, and carefully opti-
mized for code size and performance.
• Precise low-level compatibility between the X11, WIN32 and MacOS versions - only about 10% of
the code is different.
• Interactive user interface builder program. Output is human-readable and editable C++ source code.
• Support for overlay hardware, with emulation if none is available.
• Very small & fast portable 2-D drawing library to hide Xlib, WIN32, or QuickDraw.
• OpenGL/Mesa drawing area widget.
• Support for OpenGL overlay hardware on both X11 and WIN32, with emulation if none is available.
• Text widgets with cut & paste, undo, and support for Unicode text and international input methods.
• Compatibility header file for the GLUT library.
• Compatibility header file for the XForms library.

3.3 Licensing
FLTK comes with complete free source code. FLTK is available under the terms of the GNU Library
General Public License with exceptions that allow for static linking. Contrary to popular belief, it can be
used in commercial software - even Bill Gates could use it!

3.4 What Does ”FLTK” Mean?


FLTK was originally designed to be compatible with the Forms Library written for SGI machines. In that
library all the functions and structures started with ”fl ”. This naming was extended to all new methods
and widgets in the C++ library, and this prefix was taken as the name of the library. It is almost impossible
to search for ”FL” on the Internet, due to the fact that it is also the abbreviation for Florida. After much
debating and searching for a new name for the toolkit, which was already in use by several people, Bill
came up with ”FLTK”, including a bogus excuse that it stands for ”The Fast Light Toolkit”.
3.5. BUILDING AND INSTALLING FLTK UNDER UNIX AND APPLE OS X 9

3.5 Building and Installing FLTK Under UNIX and Apple OS X


In most cases you can just type ”make”. This will run configure with the default of no options and then
compile everything.
For OS X, Xcode 3 project files can be found in the ’ide’ directory.
FLTK uses GNU autoconf to configure itself for your UNIX platform. The main things that the con-
figure script will look for are the X11 and OpenGL (or Mesa) header and library files. If these cannot
be found in the standard include/library locations you’ll need to define the CFLAGS, CXXFLAGS, and
LDFLAGS environment variables. For the Bourne and Korn shells you’d use:
CFLAGS=-Iincludedir; export CFLAGS
CXXFLAGS=-Iincludedir; export CXXFLAGS
LDFLAGS=-Llibdir; export LDFLAGS

For C shell and tcsh, use:


setenv CFLAGS "-Iincludedir"
setenv CXXFLAGS "-Iincludedir"
setenv LDFLAGS "-Llibdir"

By default configure will look for a C++ compiler named CC, c++, g++, or gcc in that order. To use
another compiler you need to set the CXX environment variable:
CXX=xlC; export CXX
setenv CXX "xlC"

The CC environment variable can also be used to override the default C compiler (cc or gcc), which
is used for a few FLTK source files.
You can run configure yourself to get the exact setup you need. Type ”./configure <options>”, where
options are:
–enable-cygwin

Enable the Cygwin libraries under WIN32


–enable-debug

Enable debugging code & symbols


–disable-gl

Disable OpenGL support


–enable-shared
Enable generation of shared libraries
–enable-threads
Enable multithreading support
–enable-xdbe
Enable the X double-buffer extension
–enable-xft
Enable the Xft library for anti-aliased fonts under X11
–enable-x11
When targeting cygwin, build with X11 GUI instead of windows GDI
–enable-cp936

Under X11, enable use of the GB2312 locale


10 CHAPTER 3. INTRODUCTION TO FLTK

–bindir=/path

Set the location for executables [default = $prefix/bin]

–datadir=/path

Set the location for data files. [default = $prefix/share]

–libdir=/path

Set the location for libraries [default = $prefix/lib]

–includedir=/path

Set the location for include files. [default = $prefix/include]

–mandir=/path

Set the location for man pages. [default = $prefix/man]

–prefix=/dir

Set the directory prefix for files [default = /usr/local]

When the configure script is done you can just run the ”make” command. This will build the library, FLUID
tool, and all of the test programs.
To install the library, become root and type ”make install”. This will copy the ”fluid” executable to
”bindir”, the header files to ”includedir”, and the library files to ”libdir”.

3.6 Building FLTK Under Microsoft Windows


NOTE: This documentation section is currently under review. More up-to-date information for this release
may be available in the file ”README.MSWindows.txt” and you should read that file to determine if there
are changes that may be applicable to your build environment.
FLTK 1.3 is officially supported on Windows (2000,) 2003, XP, and later. Older Windows versions
prior to Windows 2000 are not officially supported, but may still work. The main reason is that the O-
S version needs to support UTF-8. FLTK 1.3 is known to work on recent versions of Windows such as
Windows 7 and Vista and has been reported to work in both 32-bit and 64-bit versions of these.
FLTK currently supports the following development environments on the Windows platform:
CAUTION: Libraries built by any one of these build environments can not be mixed with object files
from any of the other environments! (They use incompatible C++ conventions internally.)
Free Microsoft Visual C++ 2008 Express and Visual C++ 2010 Express using the supplied workspace
and project files. Older versions, and the commercial versions, can be used as well, if they can open the
project files. Be sure to get your service packs!
The project files can be found in the ”ide/” directory. Please read ”ide/README.IDE” for more info
about this.

3.6.1 GNU toolsets (Cygwin or MinGW) hosted on Windows


If using Cygwin with the Cygwin shell, or MinGW with the Msys shell, these build environments behave
very much like a Unix or OS X build and the notes above in the section on Building and Installing FLTK
Under UNIX and Apple OS X apply, in particular the descriptions of using the ”configure” script and its
related options.
In general for a build using these tools, e.g. for the Msys shell with MinGW, it should suffice to ”cd”
into the directory where you have extracted the fltk tarball and type:
./configure
make
3.7. INTERNET RESOURCES 11

This will build the fltk libraries and they can then be utilised directly from the build location. NOTE:
this may be simpler than ”installing” them in many cases as different tool chains on Windows have different
ideas about where the files should be ”installed” to.
For example, if you ”install” the libraries using Msys/MinGW with the following command:
make install

Then Msys will ”install” the libraries to where it thinks the path ”/usr/local/” leads to. If you only ever
build code from within the Msys environment this works well, but the actual ”Windows path” these files
are located in will be something like ”C:\msys\1.0\local\lib”, depending on where your Msys installation
is rooted, which may not be useful to other tools.
If you want to install your built fltk libraries in a non-standard location you may do:
sh configure --prefix=C:/FLTK
make

Where the value passed to ”prefix” is the path at which you would like fltk to be installed.
A subsequent invocation of ”make install” will then place the fltk libraries and header files into that
path.
The other options to ”configure” may also be used to tailor the build to suit your environment.

3.6.2 Using the Visual C++ DLL Library


The ”fltkdll.dsp” project file builds a DLL-version of the FLTK library. Because of name mangling differ-
ences between PC compilers (even between different versions of Visual C++!) you can only use the DLL
that is generated with the same version compiler that you built it with.
When compiling an application or DLL that uses the FLTK DLL, you will need to define the FL DLL
preprocessor symbol to get the correct linkage commands embedded within the FLTK header files.

3.7 Internet Resources


FLTK is available on the ’net in a bunch of locations:
WWW
http://www.fltk.org/
http://www.fltk.org/str.php [for reporting bugs]
http://www.fltk.org/software.php [source code]
http://www.fltk.org/newsgroups.php [newsgroup/forums]
FTP
ftp://ftp.funet.fi/pub/mirrors/ftp.easysw.com/pub/fltk [Espoo, Finland]
NNTP Newsgroups

https://groups.google.com/forum/#!forum/fltkgeneral [Google Groups interface]


news://fltk.org:1024/ [NNTP interface]
http://fltk.org/newsgroups.php [web interface]

3.8 Reporting Bugs


To report a bug in FLTK, or for feature requests, please use the form at http://www.fltk.org/str.-
php, and click on ”Submit Bug or Feature Request”.
You’ll be prompted for the FLTK version, operating system & version, and compiler that you are using.
We will be unable to provide any kind of help without that basic information.
For general support and questions, please use the fltk.general newsgroup (see above, ”NNTP News-
groups”) or the web interface to the newsgroups at http://fltk.org/newsgroups.php.
12 CHAPTER 3. INTRODUCTION TO FLTK
Chapter 4

FLTK Basics

This chapter teaches you the basics of compiling programs that use FLTK.

4.1 Writing Your First FLTK Program


All programs must include the file <FL/Fl.H>. In addition the program must include a header file for
each FLTK class it uses. Listing 1 shows a simple ”Hello, World!” program that uses FLTK to display the
window.
Listing 1 - ”hello.cxx”

#include <FL/Fl.H>
#include <FL/Fl Window.H>
#include <FL/Fl Box.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);
window->end();
window->show(argc, argv);
return Fl::run();
}

After including the required header files, the program then creates a window. All following widgets will
automatically be children of this window.
Fl Window *window = new Fl Window(340,180);

Then we create a box with the ”Hello, World!” string in it. FLTK automatically adds the new box to
window, the current grouping widget.
Fl Box *box = new Fl Box(20,40,300,100,"Hello, World!");

Next, we set the type of box and the font, size, and style of the label:
box->box(FL UP BOX);
box->labelfont(FL BOLD+FL ITALIC);
box->labelsize(36);
box->labeltype(FL SHADOW LABEL);

We tell FLTK that we will not add any more widgets to window.
window->end();

Finally, we show the window and enter the FLTK event loop:

13
14 CHAPTER 4. FLTK BASICS

window->show(argc, argv);
return Fl::run();

The resulting program will display the window in Figure 4.1. You can quit the program by closing the
window or pressing the ESCape key.

Figure 4.1: The Hello, World! Window

4.1.1 Creating the Widgets


The widgets are created using the C++ new operator. For most widgets the arguments to the constructor
are:
Fl Widget(x, y, width, height, label)

The x and y parameters determine where the widget or window is placed on the screen. In FLTK the
top left corner of the window or screen is the origin (i.e. x = 0, y = 0) and the units are in pixels.
The width and height parameters determine the size of the widget or window in pixels. The maxi-
mum widget size is typically governed by the underlying window system or hardware.
label is a pointer to a character string to label the widget with or NULL. If not specified the label
defaults to NULL. The label string must be in static storage such as a string constant because FLTK does
not make a copy of it - it just uses the pointer.

4.1.2 Creating Widget hierarchies


Widgets are commonly ordered into functional groups, which in turn may be grouped again, creating a
hierarchy of widgets. FLTK makes it easy to fill groups by automatically adding all widgets that are
created between a myGroup->begin() and myGroup->end(). In this example, myGroup would
be the current group.
Newly created groups and their derived widgets implicitly call begin() in the constructor, effectively
adding all subsequently created widgets to itself until end() is called.
Setting the current group to NULL will stop automatic hierarchies. New widgets can now be added
manually using Fl Group::add(...) and Fl Group::insert(...).

4.1.3 Get/Set Methods


box->box(FL UP BOX) sets the type of box the Fl Box draws, changing it from the default of FL N-
O BOX, which means that no box is drawn. In our ”Hello, World!” example we use FL UP BOX, which
means that a raised button border will be drawn around the widget. More details are available in the Box
Types section.
You could examine the boxtype in by doing box->box(). FLTK uses method name overloading to
make short names for get/set methods. A ”set” method is always of the form ”void name(type)”, and a
”get” method is always of the form ”type name() const”.
4.2. COMPILING PROGRAMS WITH STANDARD COMPILERS 15

4.1.4 Redrawing After Changing Attributes


Almost all of the set/get pairs are very fast, short inline functions and thus very efficient. However, the
”set” methods do not call redraw() - you have to call it yourself. This greatly reduces code size and
execution time. The only common exceptions are value() which calls redraw() and label() which
calls redraw label() if necessary.

4.1.5 Labels
All widgets support labels. In the case of window widgets, the label is used for the label in the title bar.
Our example program calls the labelfont(), labelsize(), and labeltype() methods.
The labelfont() method sets the typeface and style that is used for the label, which for this example
we are using FL BOLD and FL ITALIC. You can also specify typefaces directly.
The labelsize() method sets the height of the font in pixels.
The labeltype() method sets the type of label. FLTK supports normal, embossed, and shadowed
labels internally, and more types can be added as desired.
A complete list of all label options can be found in the section on Labels and Label Types.

4.1.6 Showing the Window


The show() method shows the widget or window. For windows you can also provide the command-line
arguments to allow users to customize the appearance, size, and position of your windows.

4.1.7 The Main Event Loop


All FLTK applications (and most GUI applications in general) are based on a simple event processing
model. User actions such as mouse movement, button clicks, and keyboard activity generate events that
are sent to an application. The application may then ignore the events or respond to the user, typically by
redrawing a button in the ”down” position, adding the text to an input field, and so forth.
FLTK also supports idle, timer, and file pseudo-events that cause a function to be called when they
occur. Idle functions are called when no user input is present and no timers or files need to be handled - in
short, when the application is not doing anything. Idle callbacks are often used to update a 3D display or
do other background processing.
Timer functions are called after a specific amount of time has expired. They can be used to pop up a
progress dialog after a certain amount of time or do other things that need to happen at more-or-less regular
intervals. FLTK timers are not 100% accurate, so they should not be used to measure time intervals, for
example.
File functions are called when data is ready to read or write, or when an error condition occurs on a
file. They are most often used to monitor network connections (sockets) for data-driven displays.
FLTK applications must periodically check (Fl::check()) or wait (Fl::wait()) for events or use the Fl-
::run() method to enter a standard event processing loop. Calling Fl::run() is equivalent to the following
code:
while (Fl::wait());

Fl::run() does not return until all of the windows under FLTK control are closed by the user or your
program.

4.2 Compiling Programs with Standard Compilers


Under UNIX (and under Microsoft Windows when using the GNU development tools) you will probably
need to tell the compiler where to find the header files. This is usually done using the -I option:
CC -I/usr/local/include ...
gcc -I/usr/local/include ...
16 CHAPTER 4. FLTK BASICS

The fltk-config script included with FLTK can be used to get the options that are required by your
compiler:
CC ‘fltk-config --cxxflags‘ ...

Similarly, when linking your application you will need to tell the compiler to use the FLTK library:
CC ... -L/usr/local/lib -lfltk -lXext -lX11 -lm
gcc ... -L/usr/local/lib -lfltk -lXext -lX11 -lm

Aside from the ”fltk” library, there is also a ”fltk forms” library for the XForms compatibility classes,
”fltk gl” for the OpenGL and GLUT classes, and ”fltk images” for the image file classes, Fl Help Dialog
widget, and system icon support.
Note
The libraries are named ”fltk.lib”, ”fltkgl.lib”, ”fltkforms.lib”, and ”fltkimages.lib”, respectively un-
der Windows.
As before, the fltk-config script included with FLTK can be used to get the options that are required
by your linker:
CC ... ‘fltk-config --ldflags‘

The forms, GL, and images libraries are included with the ”--use-foo” options, as follows:
CC ... ‘fltk-config --use-forms --ldflags‘
CC ... ‘fltk-config --use-gl --ldflags‘
CC ... ‘fltk-config --use-images --ldflags‘
CC ... ‘fltk-config --use-forms --use-gl --use-images --ldflags‘

Finally, you can use the fltk-config script to compile a single source file as a FLTK program:
fltk-config --compile filename.cpp
fltk-config --use-forms --compile filename.cpp
fltk-config --use-gl --compile filename.cpp
fltk-config --use-images --compile filename.cpp
fltk-config --use-forms --use-gl --use-images --compile filename.cpp

Any of these will create an executable named filename.

4.3 Compiling Programs with Makefiles


The previous section described how to use fltk-config to build a program consisting of a single source
file from the command line, and this is very convenient for small test programs. But fltk-config can
also be used to set the compiler and linker options as variables within a Makefile that can be used to
build programs out of multiple source files:
CXX = $(shell fltk-config --cxx)
DEBUG = -g
CXXFLAGS = $(shell fltk-config --use-gl --use-images --cxxflags ) -I.
LDFLAGS = $(shell fltk-config --use-gl --use-images --ldflags )
LDSTATIC = $(shell fltk-config --use-gl --use-images --ldstaticflags )
LINK = $(CXX)

TARGET = cube
OBJS = CubeMain.o CubeView.o CubeViewUI.o
SRCS = CubeMain.cxx CubeView.cxx CubeViewUI.cxx

.SUFFIXES: .o .cxx
%.o: %.cxx
$(CXX) $(CXXFLAGS) $(DEBUG) -c $<

all: $(TARGET)
$(LINK) -o $(TARGET) $(OBJS) $(LDSTATIC)

$(TARGET): $(OBJS)
CubeMain.o: CubeMain.cxx CubeViewUI.h
CubeView.o: CubeView.cxx CubeView.h CubeViewUI.h
CubeViewUI.o: CubeViewUI.cxx CubeView.h

clean: $(TARGET) $(OBJS)


rm -f *.o 2> /dev/null
rm -f $(TARGET) 2> /dev/null
4.4. COMPILING PROGRAMS WITH MICROSOFT VISUAL C++ 17

4.4 Compiling Programs with Microsoft Visual C++


In Visual C++ you will need to tell the compiler where to find the FLTK header files. This can be done by
selecting ”Settings” from the ”Project” menu and then changing the ”Preprocessor” settings under the ”C/-
C++” tab. You will also need to add the FLTK (FLTK.LIB or FLTKD.LIB) and the Windows Common
Controls (COMCTL32.LIB) libraries to the ”Link” settings. You must also define WIN32.
More information can be found in README.MSWindows.txt.
You can build your Microsoft Windows applications as Console or Desktop applications. If you want
to use the standard C main() function as the entry point, FLTK includes a WinMain() function that
will call your main() function for you.

4.5 Naming
All public symbols in FLTK start with the characters ’F’ and ’L’:

• Functions are either Fl::foo() or fl foo().

• Class and type names are capitalized: Fl Foo.

• Constants and enumerations are uppercase: FL FOO.

• All header files start with <FL/...>.

4.6 Header Files


The proper way to include FLTK header files is:
#include <FL/Fl xyz.H>

Note
Case is significant on many operating systems, and the C standard uses the forward slash (/) to sepa-
rate directories. Do not use any of the following include lines:
#include <FL\Fl xyz.H>
#include <fl/fl xyz.h>
#include <Fl/fl xyz.h>
18 CHAPTER 4. FLTK BASICS
Chapter 5

Common Widgets and Attributes

This chapter describes many of the widgets that are provided with FLTK and covers how to query and set
the standard attributes.

5.1 Buttons
FLTK provides many types of buttons:

• Fl Button - A standard push button.

• Fl Check Button - A button with a check box.

• Fl Light Button - A push button with a light.

• Fl Repeat Button - A push button that repeats when held.

• Fl Return Button - A push button that is activated by the Enter key.

• Fl Round Button - A button with a radio circle.

Figure 5.1: FLTK Button Widgets

All of these buttons just need the corresponding <FL/Fl xyz Button.H> header file. The con-
structor takes the bounding box of the button and optionally a label string:
Fl Button *button = new Fl Button(x, y, width, height, "label");
Fl Light Button *lbutton = new Fl Light Button(x, y, width, height);
Fl Round Button *rbutton = new Fl Round Button(x, y, width, height, "label");

Each button has an associated type() which allows it to behave as a push button, toggle button, or
radio button:

19
20 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES

button->type(FL NORMAL BUTTON);


lbutton->type(FL TOGGLE BUTTON);
rbutton->type(FL RADIO BUTTON);

For toggle and radio buttons, the value() method returns the current button state (0 = off, 1 = on). The
set() and clear() methods can be used on toggle buttons to turn a toggle button on or off, respectively.
Radio buttons can be turned on with the setonly() method; this will also turn off other radio buttons in
the same group.

5.2 Text
FLTK provides several text widgets for displaying and receiving text:

• Fl Input - A one-line text input field.

• Fl Output - A one-line text output field.

• Fl Multiline Input - A multi-line text input field.

• Fl Multiline Output - A multi-line text output field.

• Fl Text Display - A multi-line text display widget.

• Fl Text Editor - A multi-line text editing widget.

• Fl Help View - A HTML text display widget.

The Fl Output and Fl Multiline Output widgets allow the user to copy text from the output field but not
change it.
The value() method is used to get or set the string that is displayed:

Fl Input *input = new Fl Input(x, y, width, height, "label");


input->value("Now is the time for all good men...");

The string is copied to the widget’s own storage when you set the value() of the widget.
The Fl Text Display and Fl Text Editor widgets use an associated Fl Text Buffer class for the value,
instead of a simple string.

5.3 Valuators
Unlike text widgets, valuators keep track of numbers instead of strings. FLTK provides the following
valuators:

• Fl Counter - A widget with arrow buttons that shows the current value.

• Fl Dial - A round knob.

• Fl Roller - An SGI-like dolly widget.

• Fl Scrollbar - A standard scrollbar widget.

• Fl Slider - A scrollbar with a knob.

• Fl Value Slider - A slider that shows the current value.


5.4. GROUPS 21

Figure 5.2: FLTK valuator widgets

The value() method gets and sets the current value of the widget. The minimum() and maximum()
methods set the range of values that are reported by the widget.

5.4 Groups
The Fl Group widget class is used as a general purpose ”container” widget. Besides grouping radio buttons,
the groups are used to encapsulate windows, tabs, and scrolled windows. The following group classes are
available with FLTK:

• Fl Double Window - A double-buffered window on the screen.

• Fl Gl Window - An OpenGL window on the screen.

• Fl Group - The base container class; can be used to group any widgets together.

• Fl Pack - A collection of widgets that are packed into the group area.

• Fl Scroll - A scrolled window area.

• Fl Tabs - Displays child widgets as tabs.

• Fl Tile - A tiled window area.

• Fl Window - A window on the screen.

• Fl Wizard - Displays one group of widgets at a time.


22 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES

5.5 Setting the Size and Position of Widgets


The size and position of widgets is usually set when you create them. You can access them with the x(),
y(), w(), and h() methods.
You can change the size and position by using the position(), resize(), and size() methods:
button->position(x, y);
group->resize(x, y, width, height);
window->size(width, height);

If you change a widget’s size or position after it is displayed you will have to call redraw() on the
widget’s parent.

5.6 Colors
FLTK stores the colors of widgets as an 32-bit unsigned number that is either an index into a color palette
of 256 colors or a 24-bit RGB color. The color palette is not the X or MS Windows colormap, but instead
is an internal table with fixed contents.
See the Colors section of Drawing Things in FLTK for implementation details.
There are symbols for naming some of the more common colors:

• FL BLACK
• FL RED
• FL GREEN
• FL YELLOW
• FL BLUE
• FL MAGENTA
• FL CYAN
• FL WHITE
• FL WHITE

Other symbols are used as the default colors for all FLTK widgets.

• FL FOREGROUND COLOR
• FL BACKGROUND COLOR
• FL INACTIVE COLOR
• FL SELECTION COLOR

The full list of named color values can be found in FLTK Enumerations.
A color value can be created from its RGB components by using the fl rgb color() function, and
decomposed again with Fl::get color():
Fl Color c = fl rgb color(85, 170, 255); // RGB to Fl Color
Fl::get color(c, r, g, b); // Fl Color to RGB

The widget color is set using the color() method:


button->color(FL RED); // set color using named value

Similarly, the label color is set using the labelcolor() method:


5.7. BOX TYPES 23

button->labelcolor(FL WHITE);

The Fl Color encoding maps to a 32-bit unsigned integer representing RGBI, so it is also possible to
specify a color using a hex constant as a color map index:
button->color(0x000000ff); // colormap index #255 (FL WHITE)

or specify a color using a hex constant for the RGB components:


button->color(0xff000000); // RGB: red
button->color(0x00ff0000); // RGB: green
button->color(0x0000ff00); // RGB: blue
button->color(0xffffff00); // RGB: white

Note
If TrueColor is not available, any RGB colors will be set to the nearest entry in the colormap.

5.7 Box Types


The type Fl Boxtype stored and returned in Fl Widget::box() is an enumeration defined in Enumerations.H.
Figure 3-3 shows the standard box types included with FLTK.

Figure 5.3: FLTK box types

FL NO BOX means nothing is drawn at all, so whatever is already on the screen remains. The FL -
... FRAME types only draw their edges, leaving the interior unchanged. The blue color in Figure 3-3 is
the area that is not drawn by the frame types.

5.7.1 Making Your Own Boxtypes


You can define your own boxtypes by making a small function that draws the box and adding it to the table
of boxtypes.
24 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES

Note:
This interface has changed in FLTK 2.0!

The Drawing Function

The drawing function is passed the bounding box and background color for the widget:

void xyz draw(int x, int y, int w, int h, Fl Color c) {


...
}

A simple drawing function might fill a rectangle with the given color and then draw a black outline:

void xyz draw(int x, int y, int w, int h, Fl Color c) {


fl color(c);
fl rectf(x, y, w, h);
fl color(FL BLACK);
fl rect(x, y, w, h);
}

Fl Boxtype fl down(Fl Boxtype b)

fl down() returns the ”pressed” or ”down” version of a box. If no ”down” version of a given box exists,
the behavior of this function is undefined and some random box or frame is returned. See Drawing
Functions for more details.

Fl Boxtype fl frame(Fl Boxtype b)

fl frame() returns the unfilled, frame-only version of a box. If no frame version of a given box exists,
the behavior of this function is undefined and some random box or frame is returned. See Drawing
Functions for more details.

Fl Boxtype fl box(Fl Boxtype b)

fl box() returns the filled version of a frame. If no filled version of a given frame exists, the behavior
of this function is undefined and some random box or frame is returned. See Drawing Functions for
more details.
Adding Your Box Type

The Fl::set boxtype() method adds or replaces the specified box type:

#define XYZ BOX FL FREE BOXTYPE

Fl::set boxtype(XYZ BOX, xyz draw, 1, 1, 2, 2);

The last 4 arguments to Fl::set boxtype() are the offsets for the x, y, width, and height values that
should be subtracted when drawing the label inside the box.
A complete box design contains four box types in this order: a filled, neutral box (UP BOX), a filled,
depressed box (DOWN BOX), and the same as outlines only (UP FRAME and DOWN FRAME). The function
fl down(Fl Boxtype) expects the neutral design on a boxtype with a numerical value evenly dividable by
two. fl frame(Fl Boxtype) expects the UP BOX design at a value dividable by four.
5.8. LABELS AND LABEL TYPES 25

5.8 Labels and Label Types


The label(), align(), labelfont(), labelsize(), labeltype(), image(), and deimage()
methods control the labeling of widgets.

label()

The label() method sets the string that is displayed for the label. Symbols can be included with the
label string by escaping them using the ”@” symbol - ”@@” displays a single at sign. Figure 3-4 shows
the available symbols.

Figure 5.4: FLTK label symbols

The @ sign may also be followed by the following optional ”formatting” characters, in this order:

• ’#’ forces square scaling, rather than distortion to the widget’s shape.

• +[1-9] or -[1-9] tweaks the scaling a little bigger or smaller.

• ’$’ flips the symbol horizontally, ’%’ flips it vertically.

• [0-9] - rotates by a multiple of 45 degrees. ’5’ and ’6’ do no rotation while the others point in the
direction of that key on a numeric keypad. ’0’, followed by four more digits rotates the symbol by
that amount in degrees.

Thus, to show a very large arrow pointing downward you would use the label string ”@+92->”.
26 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES

align()

The align() method positions the label. The following constants are defined and may be OR’d together
as needed:

• FL ALIGN CENTER - center the label in the widget.

• FL ALIGN TOP - align the label at the top of the widget.

• FL ALIGN BOTTOM - align the label at the bottom of the widget.

• FL ALIGN LEFT - align the label to the left of the widget.

• FL ALIGN RIGHT - align the label to the right of the widget.

• FL ALIGN LEFT TOP - The label appears to the left of the widget, aligned at the top. Outside
labels only.

• FL ALIGN RIGHT TOP - The label appears to the right of the widget, aligned at the top. Outside
labels only.

• FL ALIGN LEFT BOTTOM - The label appears to the left of the widget, aligned at the bottom.
Outside labels only.

• FL ALIGN RIGHT BOTTOM - The label appears to the right of the widget, aligned at the bottom.
Outside labels only.

• FL ALIGN INSIDE - align the label inside the widget.

• FL ALIGN CLIP - clip the label to the widget’s bounding box.

• FL ALIGN WRAP - wrap the label text as needed.

• FL ALIGN TEXT OVER IMAGE - show the label text over the image.

• FL ALIGN IMAGE OVER TEXT - show the label image over the text (default).

• FL ALIGN IMAGE NEXT TO TEXT - The image will appear to the left of the text.

• FL ALIGN TEXT NEXT TO IMAGE - The image will appear to the right of the text.

• FL ALIGN IMAGE BACKDROP - The image will be used as a background for the widget.

labeltype()

The labeltype() method sets the type of the label. The following standard label types are included:

• FL NORMAL LABEL - draws the text.

• FL NO LABEL - does nothing.

• FL SHADOW LABEL - draws a drop shadow under the text.

• FL ENGRAVED LABEL - draws edges as though the text is engraved.

• FL EMBOSSED LABEL - draws edges as thought the text is raised.

• FL ICON LABEL - draws the icon associated with the text.


5.8. LABELS AND LABEL TYPES 27

image() and deimage()

The image() and deimage() methods set an image that will be displayed with the widget. The
deimage() method sets the image that is shown when the widget is inactive, while the image() method
sets the image that is shown when the widget is active.
To make an image you use a subclass of Fl Image.
Making Your Own Label Types

Label types are actually indexes into a table of functions that draw them. The primary purpose of this is to
use this to draw the labels in ways inaccessible through the fl font() mechanism (e.g. FL ENGRAVED L-
ABEL) or with program-generated letters or symbology.
Label Type Functions

To setup your own label type you will need to write two functions: one to draw and one to measure the
label. The draw function is called with a pointer to a Fl Label structure containing the label information,
the bounding box for the label, and the label alignment:
void xyz draw(const Fl Label *label, int x, int y, int w, int h,
Fl Align align) {
...
}

The label should be drawn inside this bounding box, even if FL ALIGN INSIDE is not enabled. The
function is not called if the label value is NULL.
The measure function is called with a pointer to a Fl Label structure and references to the width and
height:
void xyz measure(const Fl Label *label, int &w, int &h) {
...
}

The function should measure the size of the label and set w and h to the size it will occupy.
Adding Your Label Type

The Fl::set labeltype() method creates a label type using your draw and measure functions:
#define XYZ LABEL FL FREE LABELTYPE

Fl::set labeltype(XYZ LABEL, xyz draw, xyz measure);

The label type number n can be any integer value starting at the constant FL FREE LABELTYPE. Once
you have added the label type you can use the labeltype() method to select your label type.
The Fl::set labeltype() method can also be used to overload an existing label type such as FL NORMA-
L LABEL.
Making your own symbols

It is also possible to define your own drawings and add them to the symbol list, so they can be rendered as
part of any label.
To create a new symbol, you implement a drawing function void drawit(Fl Color c) which
typically uses the functions described in Drawing Complex Shapes to generate a vector shape inside a
two-by-two units sized box around the origin. This function is then linked into the symbols table using
fl add symbol():
28 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES

int fl add symbol(const char *name, void (*drawit)(Fl Color), int scalable)

name is the name of the symbol without the ”@”; scalable must be set to 1 if the symbol is
generated using scalable vector drawing functions.

int fl draw symbol(const char *name,int x,int y,int w,int h,


Fl Color col)

This function draws a named symbol fitting the given rectangle.

5.9 Callbacks
Callbacks are functions that are called when the value of a widget changes. A callback function is sent a
Fl Widget pointer of the widget that changed and a pointer to data that you provide:

void xyz callback(Fl Widget *w, void *data) {


...
}

The callback() method sets the callback function for a widget. You can optionally pass a pointer
to some data needed for the callback:

int xyz data;

button->callback(xyz callback, &xyz data);

Normally callbacks are performed only when the value of the widget changes. You can change this
using the Fl Widget::when() method:

button->when(FL WHEN NEVER);


button->when(FL WHEN CHANGED);
button->when(FL WHEN RELEASE);
button->when(FL WHEN RELEASE ALWAYS);
button->when(FL WHEN ENTER KEY);
button->when(FL WHEN ENTER KEY ALWAYS);
button->when(FL WHEN CHANGED | FL WHEN NOT CHANGED);

Note:
You cannot delete a widget inside a callback, as the widget may still be accessed by FLTK after your
callback is completed. Instead, use the Fl::delete widget() method to mark your widget for deletion
when it is safe to do so.
Hint:
Many programmers new to FLTK or C++ try to use a non-static class method instead of a static class
method or function for their callback. Since callbacks are done outside a C++ class, the this pointer
is not initialized for class methods.
To work around this problem, define a static method in your class that accepts a pointer to the class,
and then have the static method call the class method(s) as needed. The data pointer you provide to the
callback() method of the widget can be a pointer to the instance of your class.
class Foo {
void my callback(Fl Widget *w);
static void my static callback(Fl Widget *w, void *f) { ((Foo *)f)->my callback(w); }
...
}

...

w->callback(my static callback, (void *)this);


5.10. SHORTCUTS 29

5.10 Shortcuts
Shortcuts are key sequences that activate widgets such as buttons or menu items. The shortcut()
method sets the shortcut for a widget:
button->shortcut(FL Enter);
button->shortcut(FL SHIFT + ’b’);
button->shortcut(FL CTRL + ’b’);
button->shortcut(FL ALT + ’b’);
button->shortcut(FL CTRL + FL ALT + ’b’);
button->shortcut(0); // no shortcut

The shortcut value is the key event value - the ASCII value or one of the special keys described in
Fl::event key() Values combined with any modifiers like Shift , Alt , and Control.
30 CHAPTER 5. COMMON WIDGETS AND ATTRIBUTES
Chapter 6

Designing a Simple Text Editor

This chapter takes you through the design of a simple FLTK-based text editor.

6.1 Determining the Goals of the Text Editor


Since this will be the first big project you’ll be doing with FLTK, lets define what we want our text editor
to do:

1. Provide a menubar/menus for all functions.

2. Edit a single text file, possibly with multiple views.

3. Load from a file.

4. Save to a file.

5. Cut/copy/delete/paste functions.

6. Search and replace functions.

7. Keep track of when the file has been changed.

6.2 Designing the Main Window


Now that we’ve outlined the goals for our editor, we can begin with the design of our GUI. Obviously the
first thing that we need is a window, which we’ll place inside a class called EditorWindow:

class EditorWindow : public Fl Double Window {


public:
EditorWindow(int w, int h, const char* t);
˜EditorWindow();

Fl Window *replace dlg;


Fl Input *replace find;
Fl Input *replace with;
Fl Button *replace all;
Fl Return Button *replace next;
Fl Button *replace cancel;

Fl Text Editor *editor;


char search[256];
};

31
32 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR

6.3 Variables
Our text editor will need some global variables to keep track of things:
int changed = 0;
char filename[256] = "";
Fl Text Buffer *textbuf;

The textbuf variable is the text editor buffer for our window class described previously. We’ll cover
the other variables as we build the application.

6.4 Menubars and Menus


The first goal requires us to use a menubar and menus that define each function the editor needs to perform.
The Fl Menu Item structure is used to define the menus and items in a menubar:
Fl Menu Item menuitems[] = {
{ "&File", 0, 0, 0, FL SUBMENU },
{ "&New File", 0, (Fl Callback *)new cb },
{ "&Open File...", FL COMMAND + ’o’, (Fl Callback *)open cb },
{ "&Insert File...", FL COMMAND + ’i’, (Fl Callback *)insert cb, 0,
FL MENU DIVIDER },
{ "&Save File", FL COMMAND + ’s’, (Fl Callback *)save cb },
{ "Save File &As...", FL COMMAND + FL SHIFT + ’s’, (
Fl Callback *)saveas cb, 0, FL MENU DIVIDER },
{ "New &View", FL ALT + ’v’, (Fl Callback *)view cb, 0 },
{ "&Close View", FL COMMAND + ’w’, (Fl Callback *)close cb, 0, FL MENU DIVIDER },
{ "E&xit", FL COMMAND + ’q’, (Fl Callback *)quit cb, 0 },
{ 0 },

{ "&Edit", 0, 0, 0, FL SUBMENU },
{ "&Undo", FL COMMAND + ’z’, (Fl Callback *)undo cb, 0, FL MENU DIVIDER },
{ "Cu&t", FL COMMAND + ’x’, (Fl Callback *)cut cb },
{ "&Copy", FL COMMAND + ’c’, (Fl Callback *)copy cb },
{ "&Paste", FL COMMAND + ’v’, (Fl Callback *)paste cb },
{ "&Delete", 0, (Fl Callback *)delete cb },
{ 0 },

{ "&Search", 0, 0, 0, FL SUBMENU },
{ "&Find...", FL COMMAND + ’f’, (Fl Callback *)find cb },
{ "F&ind Again", FL COMMAND + ’g’, find2 cb },
{ "&Replace...", FL COMMAND + ’r’, replace cb },
{ "Re&place Again", FL COMMAND + ’t’, replace2 cb },
{ 0 },

{ 0 }
};

Once we have the menus defined we can create the Fl Menu Bar widget and assign the menus to it
with:
Fl Menu Bar *m = new Fl Menu Bar(0, 0, 640, 30);
m->copy(menuitems);

We’ll define the callback functions later.

6.5 Editing the Text


To keep things simple our text editor will use the Fl Text Editor widget to edit the text:
w->editor = new Fl Text Editor(0, 30, 640, 370);
w->editor->buffer(textbuf);

So that we can keep track of changes to the file, we also want to add a ”modify” callback:
textbuf->add modify callback(changed cb, w);
textbuf->call modify callbacks();

Finally, we want to use a mono-spaced font like FL COURIER:


w->editor->textfont(FL COURIER);
6.6. THE REPLACE DIALOG 33

6.6 The Replace Dialog


We can use the FLTK convenience functions for many of the editor’s dialogs, however the replace dialog
needs its own custom window. To keep things simple we will have a ”find” string, a ”replace” string, and
”replace all”, ”replace next”, and ”cancel” buttons. The strings are just Fl Input widgets, the ”replace all”
and ”cancel” buttons are Fl Button widgets, and the ”replace next ” button is a Fl Return Button widget:

Figure 6.1: The search and replace dialog

Fl Window *replace dlg = new Fl Window(300, 105, "Replace");


Fl Input *replace find = new Fl Input(70, 10, 200, 25, "Find:");
Fl Input *replace with = new Fl Input(70, 40, 200, 25, "Replace:");
Fl Button *replace all = new Fl Button(10, 70, 90, 25, "Replace All");
Fl Button *replace next = new Fl Button(105, 70, 120, 25, "Replace Next");
Fl Button *replace cancel = new Fl Button(230, 70, 60, 25, "Cancel");

6.7 Callbacks
Now that we’ve defined the GUI components of our editor, we need to define our callback functions.

6.7.1 changed cb()


This function will be called whenever the user changes any text in the editor widget:
void changed cb(int, int nInserted, int nDeleted,int, const char*, void* v) {
if ((nInserted || nDeleted) && !loading) changed = 1;
EditorWindow *w = (EditorWindow *)v;
set title(w);
if (loading) w->editor->show insert position();
}

The set title() function is one that we will write to set the changed status on the current file.
We’re doing it this way because we want to show the changed status in the window’s title bar.

6.7.2 copy cb()


This callback function will call Fl Text Editor::kf copy() to copy the currently selected text to the clipboard-
:
void copy cb(Fl Widget*, void* v) {
EditorWindow* e = (EditorWindow*)v;
Fl Text Editor::kf copy(0, e->editor);
}

6.7.3 cut cb()


This callback function will call Fl Text Editor::kf cut() to cut the currently selected text to the clipboard:
void cut cb(Fl Widget*, void* v) {
EditorWindow* e = (EditorWindow*)v;
Fl Text Editor::kf cut(0, e->editor);
}
34 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR

6.7.4 delete cb()


This callback function will call Fl Text Buffer::remove selection() to delete the currently selected text to
the clipboard:

void delete cb(Fl Widget*, void* v) {


textbuf->remove selection();
}

6.7.5 find cb()


This callback function asks for a search string using the fl input() convenience function and then calls the
find2 cb() function to find the string:

void find cb(Fl Widget* w, void* v) {


EditorWindow* e = (EditorWindow*)v;
const char *val;

val = fl input("Search String:", e->search);


if (val != NULL) {
// User entered a string - go find it!
strcpy(e->search, val);
find2 cb(w, v);
}

6.7.6 find2 cb()


This function will find the next occurrence of the search string. If the search string is blank then we want
to pop up the search dialog:

void find2 cb(Fl Widget* w, void* v) {


EditorWindow* e = (EditorWindow*)v;
if (e->search[0] == ’\0’) {
// Search string is blank; get a new one...
find cb(w, v);
return;
}

int pos = e->editor->insert position();


int found = textbuf->search forward(pos, e->search, &pos);
if (found) {
// Found a match; select and update the position...
textbuf->select(pos, pos+strlen(e->search));
e->editor->insert position(pos+strlen(e->search));
e->editor->show insert position();
}
else fl alert("No occurrences of \’%s\’ found!", e->search);
}

If the search string cannot be found we use the fl alert() convenience function to display a message to
that effect.

6.7.7 new cb()


This callback function will clear the editor widget and current filename. It also calls the check save()
function to give the user the opportunity to save the current file first as needed:

void new cb(Fl Widget*, void*) {


if (!check save()) return;

filename[0] = ’\0’;
textbuf->select(0, textbuf->length());
textbuf->remove selection();
changed = 0;
textbuf->call modify callbacks();
}
6.7. CALLBACKS 35

6.7.8 open cb()


This callback function will ask the user for a filename and then load the specified file into the input widget
and current filename. It also calls the check save() function to give the user the opportunity to save the
current file first as needed:
void open cb(Fl Widget*, void*) {
if (!check save()) return;

char *newfile = fl file chooser("Open File?", "*", filename);


if (newfile != NULL) load file(newfile, -1);
}

We call the load file() function to actually load the file.

6.7.9 paste cb()


This callback function will call Fl Text Editor::kf paste() to paste the clipboard at the current position:
void paste cb(Fl Widget*, void* v) {
EditorWindow* e = (EditorWindow*)v;
Fl Text Editor::kf paste(0, e->editor);
}

6.7.10 quit cb()


The quit callback will first see if the current file has been modified, and if so give the user a chance to save
it. It then exits from the program:
void quit cb(Fl Widget*, void*) {
if (changed && !check save())
return;

exit(0);
}

6.7.11 replace cb()


The replace callback just shows the replace dialog:
void replace cb(Fl Widget*, void* v) {
EditorWindow* e = (EditorWindow*)v;
e->replace dlg->show();
}

6.7.12 replace2 cb()


This callback will replace the next occurrence of the replacement string. If nothing has been entered for
the replacement string, then the replace dialog is displayed instead:
void replace2 cb(Fl Widget*, void* v) {
EditorWindow* e = (EditorWindow*)v;
const char *find = e->replace find->value();
const char *replace = e->replace with->value();

if (find[0] == ’\0’) {
// Search string is blank; get a new one...
e->replace dlg->show();
return;
}

e->replace dlg->hide();

int pos = e->editor->insert position();


int found = textbuf->search forward(pos, find, &pos);

if (found) {
// Found a match; update the position and replace text...
textbuf->select(pos, pos+strlen(find));
36 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR

textbuf->remove selection();
textbuf->insert(pos, replace);
textbuf->select(pos, pos+strlen(replace));
e->editor->insert position(pos+strlen(replace));
e->editor->show insert position();
}
else fl alert("No occurrences of \’%s\’ found!", find);
}

6.7.13 replall cb()


This callback will replace all occurrences of the search string in the file:
void replall cb(Fl Widget*, void* v) {
EditorWindow* e = (EditorWindow*)v;
const char *find = e->replace find->value();
const char *replace = e->replace with->value();

find = e->replace find->value();


if (find[0] == ’\0’) {
// Search string is blank; get a new one...
e->replace dlg->show();
return;
}

e->replace dlg->hide();

e->editor->insert position(0);
int times = 0;

// Loop through the whole string


for (int found = 1; found;) {
int pos = e->editor->insert position();
found = textbuf->search forward(pos, find, &pos);

if (found) {
// Found a match; update the position and replace text...
textbuf->select(pos, pos+strlen(find));
textbuf->remove selection();
textbuf->insert(pos, replace);
e->editor->insert position(pos+strlen(replace));
e->editor->show insert position();
times++;
}
}

if (times) fl message("Replaced %d occurrences.", times);


else fl alert("No occurrences of \’%s\’ found!", find);
}

6.7.14 replcan cb()


This callback just hides the replace dialog:
void replcan cb(Fl Widget*, void* v) {
EditorWindow* e = (EditorWindow*)v;
e->replace dlg->hide();
}

6.7.15 save cb()


This callback saves the current file. If the current filename is blank it calls the ”save as” callback:
void save cb(void) {
if (filename[0] == ’\0’) {
// No filename - get one!
saveas cb();
return;
}
else save file(filename);
}

The save file() function saves the current file to the specified filename.
6.8. OTHER FUNCTIONS 37

6.7.16 saveas cb()


This callback asks the user for a filename and saves the current file:

void saveas cb(void) {


char *newfile;

newfile = fl file chooser("Save File As?", "*", filename);


if (newfile != NULL) save file(newfile);
}

The save file() function saves the current file to the specified filename.

6.8 Other Functions


Now that we’ve defined the callback functions, we need our support functions to make it all work:

6.8.1 check save()


This function checks to see if the current file needs to be saved. If so, it asks the user if they want to save
it:

int check save(void) {


if (!changed) return 1;

int r = fl choice("The current file has not been saved.\n"


"Would you like to save it now?",
"Cancel", "Save", "Discard");

if (r == 1) {
save cb(); // Save the file...
return !changed;
}

return (r == 2) ? 1 : 0;
}

6.8.2 load file()


This function loads the specified file into the textbuf variable:

int loading = 0;
void load file(char *newfile, int ipos) {
loading = 1;
int insert = (ipos != -1);
changed = insert;
if (!insert) strcpy(filename, "");
int r;
if (!insert) r = textbuf->loadfile(newfile);
else r = textbuf->insertfile(newfile, ipos);
if (r)
fl alert("Error reading from file \’%s\’:\n%s.", newfile, strerror(errno));
else
if (!insert) strcpy(filename, newfile);
loading = 0;
textbuf->call modify callbacks();
}

When loading the file we use the Fl Text Buffer::loadfile() method to ”replace” the text in the buffer,
or the Fl Text Buffer::insertfile() method to insert text in the buffer from the named file.

6.8.3 save file()


This function saves the current buffer to the specified file:
38 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR

void save file(char *newfile) {


if (textbuf->savefile(newfile))
fl alert("Error writing to file \’%s\’:\n%s.", newfile, strerror(errno));
else
strcpy(filename, newfile);
changed = 0;
textbuf->call modify callbacks();
}

6.8.4 set title()


This function checks the changed variable and updates the window label accordingly:
void set title(Fl Window* w) {
if (filename[0] == ’\0’) strcpy(title, "Untitled");
else {
char *slash;
slash = strrchr(filename, ’/’);
#ifdef WIN32
if (slash == NULL) slash = strrchr(filename, ’\\’);
#endif
if (slash != NULL) strcpy(title, slash + 1);
else strcpy(title, filename);
}

if (changed) strcat(title, " (modified)");

w->label(title);
}

6.9 The main() Function


Once we’ve created all of the support functions, the only thing left is to tie them all together with the
main() function. The main() function creates a new text buffer, creates a new view (window) for the
text, shows the window, loads the file on the command-line (if any), and then enters the FLTK event loop:
int main(int argc, char **argv) {
textbuf = new Fl Text Buffer;

Fl Window* window = new view();

window->show(1, argv);

if (argc > 1) load file(argv[1], -1);

return Fl::run();
}

6.10 Compiling the Editor


The complete source for our text editor can be found in the test/editor.cxx source file. Both the
Makefile and Visual C++ workspace include the necessary rules to build the editor. You can also compile
it using a standard compiler with:
CC -o editor editor.cxx -lfltk -lXext -lX11 -lm

or by using the fltk-config script with:


fltk-config --compile editor.cxx

As noted in Compiling Programs with Standard Compilers, you may need to include compiler and
linker options to tell them where to find the FLTK library. Also, the CC command may also be called gcc
or c++ on your system.
Congratulations, you’ve just built your own text editor!
6.11. THE FINAL PRODUCT 39

6.11 The Final Product


The final editor window should look like the image in Figure 4-2.

Figure 6.2: The completed editor window

6.12 Advanced Features


Now that we’ve implemented the basic functionality, it is time to show off some of the advanced features
of the Fl Text Editor widget.

6.12.1 Syntax Highlighting


The Fl Text Editor widget supports highlighting of text with different fonts, colors, and sizes. The imple-
mentation is based on the excellent NEdit text editor core, from http://www.nedit.org/, which
uses a parallel ”style” buffer which tracks the font, color, and size of the text that is drawn.
Styles are defined using the Fl Text Display::Style Table Entry structure defined in <FL/Fl Text-
Display.H>:
struct Style Table Entry {
Fl Color color;
Fl Font font;
int size;
unsigned attr;
};

The color member sets the color for the text, the font member sets the FLTK font index to use, and
the size member sets the pixel size of the text. The attr member is currently not used.
For our text editor we’ll define 7 styles for plain code, comments, keywords, and preprocessor directives-
:
Fl Text Display::Style Table Entry styletable[] = { // Style table
{ FL BLACK, FL COURIER, FL NORMAL SIZE }, // A - Plain
40 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR

{ FL DARK GREEN, FL COURIER ITALIC, FL NORMAL SIZE }, // B - Line comments


{ FL DARK GREEN, FL COURIER ITALIC, FL NORMAL SIZE }, // C - Block
comments
{ FL BLUE, FL COURIER, FL NORMAL SIZE }, // D - Strings
{ FL DARK RED, FL COURIER, FL NORMAL SIZE }, // E - Directives
{ FL DARK RED, FL COURIER BOLD, FL NORMAL SIZE }, // F - Types
{ FL BLUE, FL COURIER BOLD, FL NORMAL SIZE } // G - Keywords
};

You’ll notice that the comments show a letter next to each style - each style in the style buffer is
referenced using a character starting with the letter ’A’.
You call the highlight data() method to associate the style data and buffer with the text editor
widget:
Fl Text Buffer *stylebuf;

w->editor->highlight data(stylebuf, styletable,


sizeof(styletable) / sizeof(styletable[0]),
’A’, style unfinished cb, 0);

Finally, you need to add a callback to the main text buffer so that changes to the text buffer are mirrored
in the style buffer:
textbuf->add modify callback(style update, w->editor);

The style update() function, like the change cb() function described earlier, is called when-
ever text is added or removed from the text buffer. It mirrors the changes in the style buffer and then updates
the style data as necessary:
//
// ’style update()’ - Update the style buffer...
//

void
style update(int pos, // I - Position of update
int nInserted, // I - Number of inserted chars
int nDeleted, // I - Number of deleted chars
int nRestyled, // I - Number of restyled chars
const char *deletedText, // I - Text that was deleted
void *cbArg) { // I - Callback data
int start, // Start of text
end; // End of text
char last, // Last style on line
style, // Style data
text; // Text data

// If this is just a selection change, just unselect the style buffer...


if (nInserted == 0 && nDeleted == 0) {
stylebuf->unselect();
return;
}

// Track changes in the text buffer...


if (nInserted > 0) {
// Insert characters into the style buffer...
style = new char[nInserted + 1];
memset(style, ’A’, nInserted);
style[nInserted] = ’\0’;

stylebuf->replace(pos, pos + nDeleted, style);


delete[] style;
} else {
// Just delete characters in the style buffer...
stylebuf->remove(pos, pos + nDeleted);
}

// Select the area that was just updated to avoid unnecessary


// callbacks...
stylebuf->select(pos, pos + nInserted - nDeleted);

// Re-parse the changed region; we do this by parsing from the


// beginning of the line of the changed region to the end of
// the line of the changed region... Then we check the last
// style character and keep updating if we have a multi-line
6.12. ADVANCED FEATURES 41

// comment character...
start = textbuf->line start(pos);
end = textbuf->line end(pos + nInserted - nDeleted);
text = textbuf->text range(start, end);
style = stylebuf->text range(start, end);
last = style[end - start - 1];

style parse(text, style, end - start);

stylebuf->replace(start, end, style);


((Fl Text Editor *)cbArg)->redisplay range(start, end);

if (last != style[end - start - 1]) {


// The last character on the line changed styles, so reparse the
// remainder of the buffer...
free(text);
free(style);

end = textbuf->length();
text = textbuf->text range(start, end);
style = stylebuf->text range(start, end);

style parse(text, style, end - start);

stylebuf->replace(start, end, style);


((Fl Text Editor *)cbArg)->redisplay range(start, end);
}

free(text);
free(style);
}

The style parse() function scans a copy of the text in the buffer and generates the necessary style
characters for display. It assumes that parsing begins at the start of a line:
//
// ’style parse()’ - Parse text and produce style data.
//

void
style parse(const char *text,
char *style,
int length) {
char current;
int col;
int last;
char buf[255],
bufptr;
const char *temp;

for (current = *style, col = 0, last = 0; length > 0; length --, text ++) {
if (current == ’A’) {
// Check for directives, comments, strings, and keywords...
if (col == 0 && *text == ’#’) {
// Set style to directive
current = ’E’;
} else if (strncmp(text, "//", 2) == 0) {
current = ’B’;
} else if (strncmp(text, "/*", 2) == 0) {
current = ’C’;
} else if (strncmp(text, "\\\"", 2) == 0) {
// Quoted quote...
*style++ = current;
*style++ = current;
text ++;
length --;
col += 2;
continue;
} else if (*text == ’\"’) {
current = ’D’;
} else if (!last && islower(*text)) {
// Might be a keyword...
for (temp = text, bufptr = buf;
islower(*temp) && bufptr < (buf + sizeof(buf) - 1);
*bufptr++ = *temp++);

if (!islower(*temp)) {
*bufptr = ’\0’;
42 CHAPTER 6. DESIGNING A SIMPLE TEXT EDITOR

bufptr = buf;

if (bsearch(&bufptr, code types,


sizeof(code types) / sizeof(code types[0]),
sizeof(code types[0]), compare keywords)) {
while (text < temp) {
*style++ = ’F’;
text ++;
length --;
col ++;
}

text --;
length ++;
last = 1;
continue;
} else if (bsearch(&bufptr, code keywords,
sizeof(code keywords) / sizeof(code keywords[0]),
sizeof(code keywords[0]), compare keywords)) {
while (text < temp) {
*style++ = ’G’;
text ++;
length --;
col ++;
}

text --;
length ++;
last = 1;
continue;
}
}
}
} else if (current == ’C’ && strncmp(text, "*/", 2) == 0) {
// Close a C comment...
style++ = current;
style++ = current;
text ++;
length --;
current = ’A’;
col += 2;
continue;
} else if (current == ’D’) {
// Continuing in string...
if (strncmp(text, "\\\"", 2) == 0) {
// Quoted end quote...
style++ = current;
style++ = current;
text ++;
length --;
col += 2;
continue;
} else if (*text == ’\"’) {
// End quote...
style++ = current;
col ++;
current = ’A’;
continue;
}
}

// Copy style info...


if (current == ’A’ && (*text == ’{’ || *text == ’}’)) *style++ = ’G’;
else *style++ = current;
col ++;

last = isalnum(*text) || *text == ’.’;

if (*text == ’\n’) {
// Reset column and possibly reset the style
col = 0;
if (current == ’B’ || current == ’E’) current = ’A’;
}
}
}
Chapter 7

Drawing Things in FLTK

This chapter covers the drawing functions that are provided with FLTK.

7.1 When Can You Draw Things in FLTK?


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.

7.2 Drawing Functions


To use the drawing functions you must first include the <FL/fl draw.H> header file. FLTK provides the
following types of drawing functions:

• Boxes

• Clipping

• Colors

• Line Dashes and Thickness

• Drawing Fast Shapes

• Drawing Complex Shapes

• Drawing Text

• Fonts

• Character Encoding

• Drawing Overlays

43
44 CHAPTER 7. DRAWING THINGS IN FLTK

• Drawing Images

• Direct Image Drawing

• Direct Image Reading

• Image Classes

• Offscreen Drawing

7.2.1 Boxes
FLTK provides three functions that can be used to draw boxes for buttons and other UI controls. Each
function uses the supplied upper-lefthand corner and width and height to determine where to draw the box.
void fl draw box(Fl Boxtype b, int x, int y, int w, int h, Fl Color c);

The fl draw box() function draws a standard boxtype b in the specified color c.

void fl frame(const char ∗s, int x, int y, int w, int h)


void fl frame2(const char ∗s, int x, int y, int w, int h)

The fl frame() and fl frame2() functions draw a series of line segments around the given box.
The string s must contain groups of 4 letters which specify one of 24 standard grayscale values, where
’A’ is black and ’X’ is white. The results of calling these functions with a string that is not a multiple
of 4 characters in length are undefined.

The only difference between fl frame() and fl frame2() is the order of the line segments:
• For fl frame() the order of each set of 4 characters is: top, left, bottom, right.
• For fl frame2() the order of each set of 4 characters is: bottom, right, top, left.

Note that fl frame(Fl Boxtype b) is described in the Box Types section.

7.2.2 Clipping
You can limit all your drawing to a rectangular region by calling fl push clip(), and put the drawings
back by using fl pop clip(). This rectangle is measured in pixels and is unaffected by the current
transformation matrix.
In addition, the system may provide clipping when updating windows which may be more complex
than a simple rectangle.
void fl push clip(int x, int y, int w, int h)
void fl clip(int x, int y, int w, int h)

Intersect the current clip region with a rectangle and push this new region onto the stack.

The fl clip() version is deprecated and will be removed from future releases.

void fl push no clip()

Pushes an empty clip region on the stack so nothing will be clipped.

void fl pop clip()


7.3. COLORS 45

Restore the previous clip region.

Note: You must call fl pop clip() once for every time you call fl push clip(). If you return to
FLTK with the clip stack not empty unpredictable results occur.

int fl not clipped(int x, int y, int w, int h)

Returns non-zero if any of the rectangle intersects the current clip region. If this returns 0 you don’t
have to draw the object.

Note: Under X this returns 2 if the rectangle is partially clipped, and 1 if it is entirely inside the clip
region.

int fl clip box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H)

Intersect the rectangle x,y,w,h with the current clip region and returns the bounding box of the
result in X,Y,W,H. Returns non-zero if the resulting rectangle is different than the original. This
can be used to limit the necessary drawing to a rectangle. W and H are set to zero if the rectangle is
completely outside the region.

void fl clip region(Fl Region r)


Fl Region fl clip region()

Replace the top of the clip stack with a clipping region of any shape. Fl Region is an operating system
specific type. The second form returns the current clipping region.

7.3 Colors
FLTK manages colors as 32-bit unsigned integers, encoded as RGBI. When the ”RGB” bytes are non-zero,
the value is treated as RGB. If these bytes are zero, the ”I” byte will be used as an index into the colormap.
Colors with both ”RGB” set and an ”I” >0 are reserved for special use.
Values from 0 to 255, i.e. the ”I” index value, represent colors from the FLTK 1.3.x standard colormap
and are allocated as needed on screens without TrueColor support. The Fl Color enumeration type defines
the standard colors and color cube for the first 256 colors. All of these are named with symbols in <FL/-
Enumerations.H>. Example:
\image html fltk-colormap.png "FLTK default colormap (Fl_Color 0x00 - 0xff)"
\image latex fltk-colormap.png "FLTK default colormap (Fl_Color 0x00 - 0xff)" width=6cm

Color values greater than 255 are treated as 24-bit RGB values. These are mapped to the closest color
supported by the screen, either from one of the 256 colors in the FLTK 1.3.x colormap or a direct RGB
value on TrueColor screens.
Fl Color fl rgb color(uchar r, uchar g, uchar b)
Fl Color fl rgb color(uchar grayscale)

Generate Fl Color out of specified 8-bit RGB values or one 8-bit grayscale value.

void fl color(Fl Color c)


void fl color(int c)

Sets the color for all subsequent drawing operations. Please use the first form: the second form is only
provided for back compatibility.
46 CHAPTER 7. DRAWING THINGS IN FLTK

For colormapped displays, a color cell will be allocated out of fl colormap the first time you use a
color. If the colormap fills up then a least-squares algorithm is used to find the closest color.

Fl Color fl color()

Returns the last color that was set using fl color(). This can be used for state save/restore.

void fl color(uchar r, uchar g, uchar b)

Set the color for all subsequent drawing operations. The closest possible match to the RGB color is
used. The RGB color is used directly on TrueColor displays. For colormap visuals the nearest index
in the gray ramp or color cube is used.

unsigned Fl::get color(Fl Color i)


void Fl::get color(Fl Color i, uchar &red, uchar &green, uchar &blue)

Generate RGB values from a colormap index value i. The first returns the RGB as a 32-bit unsigned
integer, and the second decomposes the RGB into three 8-bit values.

Fl::get system colors()


Fl::foreground()
Fl::background()
Fl::background2()

The first gets color values from the user preferences or the system, and the other routines are used to
apply those values.

Fl::own colormap()
Fl::free color(Fl Color i, int overlay)
Fl::set color(Fl Color i, unsigned c)

Fl::own colormap() is used to install a local colormap [X11 only].

Fl::free color() and Fl::set color() are used to remove and replace entries from the
colormap.

There are two predefined graphical interfaces for choosing colors. The function fl show colormap() shows
a table of colors and returns an Fl Color index value. The Fl Color Chooser widget provides a standard
RGB color chooser.
As the Fl Color encoding maps to a 32-bit unsigned integer representing RGBI, it is also possible to
specify a color using a hex constant as a color map index:
// COLOR MAP INDEX
color(0x000000II)
------ |
| |
| Color map index (8 bits)
Must be zero

button->color(0x000000ff); // colormap index #255 (FL WHITE)

or specify a color using a hex constant for the RGB components:


7.3. COLORS 47

// RGB COLOR ASSIGNMENTS


color(0xRRGGBB00)
| | | |
| | | Must be zero
| | Blue (8 bits)
| Green (8 bits)
Red (8 bits)

button->color(0xff000000); // RGB: red


button->color(0x00ff0000); // RGB: green
button->color(0x0000ff00); // RGB: blue
button->color(0xffffff00); // RGB: white

Note
If TrueColor is not available, any RGB colors will be set to the nearest entry in the colormap.

7.3.1 Line Dashes and Thickness


FLTK supports drawing of lines with different styles and widths. Full functionality is not available under
Windows 95, 98, and Me due to the reduced drawing functionality these operating systems provide.
void fl line style(int style, int width, char∗ dashes)

Set how to draw lines (the ”pen”). If you change this it is your responsibility to set it back to the default
with fl line style(0).

Note: Because of how line styles are implemented on MS Windows systems, you must set the line
style after setting the drawing color. If you set the color after the line style you will lose the line style
settings!

style is a bitmask which is a bitwise-OR of the following values. If you don’t specify a dash type
you will get a solid line. If you don’t specify a cap or join type you will get a system-defined default
of whatever value is fastest.

• FL SOLID -------
• FL DASH - - - -
• FL DOT .......
• FL DASHDOT - . - .
• FL DASHDOTDOT - .. -
• FL CAP FLAT
• FL CAP ROUND
• FL CAP SQUARE (extends past end point 1/2 line width)
• FL JOIN MITER (pointed)
• FL JOIN ROUND
• FL JOIN BEVEL (flat)

width is the number of pixels thick to draw the lines. Zero results in the system-defined default,
which on both X and Windows is somewhat different and nicer than 1.
48 CHAPTER 7. DRAWING THINGS IN FLTK

dashes is a pointer to an array of dash lengths, measured in pixels. The first location is how long to
draw a solid portion, the next is how long to draw the gap, then the solid, etc. It is terminated with a
zero-length entry. A NULL pointer or a zero-length array results in a solid line. Odd array sizes are not
supported and result in undefined behavior.

Note: The dashes array does not work under Windows 95, 98, or Me, since those operating systems
do not support complex line styles.

7.3.2 Drawing Fast Shapes


These functions are used to draw almost all the FLTK widgets. They draw on exact pixel boundaries and
are as fast as possible. Their behavior is duplicated exactly on all platforms FLTK is ported. It is undefined
whether these are affected by the transformation matrix, so you should only call these while the matrix is
set to the identity matrix (the default).
void fl point(int x, int y)

Draw a single pixel at the given coordinates.

void fl rectf(int x, int y, int w, int h)


void fl rectf(int x, int y, int w, int h, Fl Color c)

Color a rectangle that exactly fills the given bounding box.

void fl rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b)

Color a rectangle with ”exactly” the passed r,g,b color. On screens with less than 24 bits of color
this is done by drawing a solid-colored block using fl draw image() so that the correct color shade is
produced.

void fl rect(int x, int y, int w, int h)


void fl rect(int x, int y, int w, int h, Fl Color c)

Draw a 1-pixel border inside this bounding box.

void fl line(int x, int y, int x1, int y1)


void fl line(int x, int y, int x1, int y1, int x2, int y2)

Draw one or two lines between the given points.

void fl loop(int x, int y, int x1, int y1, int x2, int y2)
void fl loop(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)

Outline a 3 or 4-sided polygon with lines.

void fl polygon(int x, int y, int x1, int y1, int x2, int y2)
void fl polygon(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)

Fill a 3 or 4-sided polygon. The polygon must be convex.


7.3. COLORS 49

void fl xyline(int x, int y, int x1)


void fl xyline(int x, int y, int x1, int y2)
void fl xyline(int x, int y, int x1, int y2, int x3)

Draw horizontal and vertical lines. A horizontal line is drawn first, then a vertical, then a horizontal.

void fl yxline(int x, int y, int y1)


void fl yxline(int x, int y, int y1, int x2)
void fl yxline(int x, int y, int y1, int x2, int y3)

Draw vertical and horizontal lines. A vertical line is drawn first, then a horizontal, then a vertical.

void fl arc(int x, int y, int w, int h, double a1, double a2)


void fl pie(int x, int y, int w, int h, double a1, double a2)

Draw ellipse sections using integer coordinates. These functions match the rather limited circle draw-
ing code provided by X and MS Windows. The advantage over using fl arc() with floating point
coordinates is that they are faster because they often use the hardware, and they draw much nicer small
circles, since the small sizes are often hard-coded bitmaps.

If a complete circle is drawn it will fit inside the passed bounding box. The two angles are measured
in degrees counter-clockwise from 3’oclock and are the starting and ending angle of the arc, a2 must
be greater or equal to a1.

fl arc() draws a series of lines to approximate the arc. Notice that the integer version of fl arc()
has a different number of arguments to the other fl arc() function described later in this chapter.

fl pie() draws a filled-in pie slice. This slice may extend outside the line drawn by fl arc(); to
avoid this use w-1 and h-1.

Todo add an Fl Draw Area Cb typedef to allow fl scroll(...) to be doxygenated?

void fl scroll(int X, int Y, int W, int H, int dx, int dy, void (draw area)(void, int,int,int,int), void∗ data)

Scroll a rectangle and draw the newly exposed portions. The contents of the rectangular area is first
shifted by dx and dy pixels. The callback is then called for every newly exposed rectangular area,

7.3.3 Drawing Complex Shapes


The complex drawing functions let you draw arbitrary shapes with 2-D linear transformations. The func-
tionality matches that found in the Adobe® PostScript™ language. The exact pixels that are filled are less
defined than for the fast drawing functions so that FLTK can take advantage of drawing hardware. On both
X and MS Windows the transformed vertices are rounded to integers before drawing the line segments:
this severely limits the accuracy of these functions for complex graphics, so use OpenGL when greater
accuracy and/or performance is required.
void fl push matrix()
void fl pop matrix()

Save and restore the current transformation. The maximum depth of the stack is 32 entries.
50 CHAPTER 7. DRAWING THINGS IN FLTK

void fl scale(double x,double y)


void fl scale(double x)
void fl translate(double x,double y)
void fl rotate(double d)
void fl mult matrix(double a,double b,double c,double d,double x,double y)

Concatenate another transformation onto the current one. The rotation angle is in degrees (not radians)
and is counter-clockwise.

double fl transform x(double x, double y)


double fl transform y(double x, double y)
double fl transform dx(double x, double y)
double fl transform dy(double x, double y)
void fl transformed vertex(double xf, double yf)

Transform a coordinate or a distance using the current transformation matrix. After transforming a co-
ordinate pair, it can be added to the vertex list without any further translations using fl transformed-
vertex().

void fl begin points()


void fl end points()

Start and end drawing a list of points. Points are added to the list with fl vertex().

void fl begin line()


void fl end line()

Start and end drawing lines.

void fl begin loop()


void fl end loop()

Start and end drawing a closed sequence of lines.

void fl begin polygon()


void fl end polygon()

Start and end drawing a convex filled polygon.

void fl begin complex polygon()


void fl gap()
void fl end complex polygon()

Start and end drawing a complex filled polygon. This polygon may be concave, may have holes in it,
or may be several disconnected pieces. Call fl gap() to separate loops of the path. It is unnecessary
but harmless to call fl gap() before the first vertex, after the last one, or several times in a row.

fl gap() should only be called between fl begin complex polygon() and fl end complex-
polygon(). To outline the polygon, use fl begin loop() and replace each fl gap() with a
fl end loop();fl begin loop() pair.
7.3. COLORS 51

Note: For portability, you should only draw polygons that appear the same whether ”even/odd” or
”non-zero” winding rules are used to fill them. Holes should be drawn in the opposite direction of the
outside loop.

void fl vertex(double x,double y)

Add a single vertex to the current path.

void fl curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3)

Add a series of points on a Bezier curve to the path. The curve ends (and two of the points are) at
X0,Y0 and X3,Y3.

void fl arc(double x, double y, double r, double start, double end)

Add a series of points to the current path on the arc of a circle; you can get elliptical paths by using
scale and rotate before calling fl arc(). The center of the circle is given by x and y, and r is its
radius. fl arc() takes start and end angles that are measured in degrees counter-clockwise from
3 o’clock. If end is less than start then it draws the arc in a clockwise direction.

void fl circle(double x, double y, double r)

fl circle(...) is equivalent to fl arc(...,0,360) but may be faster. It must be the only thing in the
path: if you want a circle as part of a complex polygon you must use fl arc().

Note: fl circle() draws incorrectly if the transformation is both rotated and non-square scaled.

7.3.4 Drawing Text


All text is drawn in the current font. It is undefined whether this location or the characters are modified by
the current transformation.
void fl draw(const char ∗, int x, int y)
void fl draw(const char ∗, int n, int x, int y)

Draw a nul-terminated string or an array of n characters starting at the given location. Text is aligned
to the left and to the baseline of the font. To align to the bottom, subtract fl descent() from y. To
align to the top, subtract fl descent() and add fl height(). This version of fl draw() provides
direct access to the text drawing function of the underlying OS. It does not apply any special handling
to control characters.

void fl draw(const char∗ str, int x, int y, int w, int h, Fl Align align, Fl Image∗ img, int draw symbols)

Fancy string drawing function which is used to draw all the labels. The string is formatted and aligned
inside the passed box. Handles ’\t’ and ’\n’, expands all other control characters to ∧ X, and aligns
inside or against the edges of the box described by x, y, w and h. See Fl Widget::align() for values for
align. The value FL ALIGN INSIDE is ignored, as this function always prints inside the box.

If img is provided and is not NULL, the image is drawn above or below the text as specified by the
align value.
52 CHAPTER 7. DRAWING THINGS IN FLTK

The draw symbols argument specifies whether or not to look for symbol names starting with the
”@” character.
void fl measure(const char ∗str, int& w, int& h, int draw symbols)

Measure how wide and tall the string will be when printed by the fl draw(...align) function. This
includes leading/trailing white space in the string, kerning, etc.

If the incoming w is non-zero it will wrap to that width.

Refer to the full documentation for fl measure() for details on usage and how to avoid common pitfalls.

See Also
fl text extents() – measure the ’inked’ area of a string
fl width() – measure the pixel width of a string or single character
fl height() – measure the pixel height of the current font
fl descent() – the height of the descender for the current font
int fl height()

Recommended minimum line spacing for the current font. You can also just use the value of size
passed to fl font().

See Also
fl text extents(), fl measure(), fl width(), fl descent()
int fl descent()

Recommended distance above the bottom of a fl height() tall box to draw the text at so it looks
centered vertically in that box.
double fl width(const char∗ txt)
double fl width(const char∗ txt, int n)
double fl width(unsigned int unicode char)

Return the pixel width of a nul-terminated string, a sequence of n characters, or a single character in
the current font.

See Also
fl measure(), fl text extents(), fl height(), fl descent()
void fl text extents(const char∗ txt, int& dx, int& dy, int& w, int& h)

Determines the minimum pixel dimensions of a nul-terminated string, ie. the ’inked area’.

Given a string ”txt” drawn using fl draw(txt, x, y) you would determine its pixel extents on the display
using fl text extents(txt, dx, dy, wo, ho) such that a bounding box that exactly fits around the inked
area of the text could be drawn with fl rect(x+dx, y+dy, wo, ho).

Refer to the full documentation for fl text extents() for details on usage.
7.3. COLORS 53

See Also
fl measure(), fl width(), fl height(), fl descent()
const char∗ fl shortcut label(int shortcut)

Unparse a shortcut value as used by Fl Button or Fl Menu Item into a human-readable string like ”-
Alt+N”. This only works if the shortcut is a character key or a numbered function key. If the shortcut
is zero an empty string is returned. The return value points at a static buffer that is overwritten with
each call.

7.3.5 Fonts
FLTK supports a set of standard fonts based on the Times, Helvetica/Arial, Courier, and Symbol typefaces,
as well as custom fonts that your application may load. Each font is accessed by an index into a font table.
Initially only the first 16 faces are filled in. There are symbolic names for them: FL HELVETICA,
FL TIMES, FL COURIER, and modifier values FL BOLD and FL ITALIC which can be added to these,
and FL SYMBOL and FL ZAPF DINGBATS. Faces greater than 255 cannot be used in Fl Widget labels,
since Fl Widget stores the index as a byte.
void fl font(int face, int size)

Set the current font, which is then used by the routines described above. You may call this outside a
draw context if necessary to call fl width(), but on X this will open the display.

The font is identified by a face and a size. The size of the font is measured in pixels and not
”points”. Lines should be spaced size pixels apart or more.
int fl font()
int fl size()

Returns the face and size set by the most recent call to fl font(a,b). This can be used to
save/restore the font.

7.3.6 Character Encoding


FLTK 1.3 expects all text in Unicode UTF-8 encoding. UTF-8 is ASCII compatible for the first 128
characters. International characters are encoded in multibyte sequences.
FLTK expects individual characters, characters that are not part of a string, in UCS-4 encoding, which
is also ASCII compatible, but requires 4 bytes to store a Unicode character.
For more information about character encodings, see the chapter on Unicode and UTF-8 Support.

7.3.7 Drawing Overlays


These functions allow you to draw interactive selection rectangles without using the overlay hardware.
FLTK will XOR a single rectangle outline over a window.
void fl overlay rect(int x, int y, int w, int h);
void fl overlay clear();

fl overlay rect() draws a selection rectangle, erasing any previous rectangle by XOR’ing it first.
fl overlay clear() will erase the rectangle without drawing a new one.

Using these functions is tricky. You should make a widget with both a handle() and draw()
method. draw() should call fl overlay clear() before doing anything else. Your handle()
method should call window()->make current() and then fl overlay rect() after FL D-
RAG events, and should call fl overlay clear() after a FL RELEASE event.
54 CHAPTER 7. DRAWING THINGS IN FLTK

7.4 Drawing Images


To draw images, you can either do it directly from data in your memory, or you can create a Fl Image object.
The advantage of drawing directly is that it is more intuitive, and it is faster if the image data changes more
often than it is redrawn. The advantage of using the object is that FLTK will cache translated forms of the
image (on X it uses a server pixmap) and thus redrawing is much faster.

7.4.1 Direct Image Drawing


The behavior when drawing images when the current transformation matrix is not the identity is not defined,
so you should only draw images when the matrix is set to the identity.
void fl draw image(const uchar ∗buf,int X,int Y,int W,int H,int D,int L)
void fl draw image mono(const uchar ∗buf,int X,int Y,int W,int H,int D,int L)

Draw an 8-bit per color RGB or luminance image. The pointer points at the ”r” data of the top-left
pixel. Color data must be in r,g,b order. The top left corner is given by X and Y and the size of
the image is given by W and H. D is the delta to add to the pointer between pixels, it may be any value
greater or equal to 3, or it can be negative to flip the image horizontally. L is the delta to add to the
pointer between lines (if 0 is passed it uses W∗D). and may be larger than W∗D to crop data, or negative
to flip the image vertically.

It is highly recommended that you put the following code before the first show() of any window in
your program to get rid of the dithering if possible:
Fl::visual(FL RGB);

Gray scale (1-channel) images may be drawn. This is done if abs(D) is less than 3, or by calling
fl draw image mono(). Only one 8-bit sample is used for each pixel, and on screens with different
numbers of bits for red, green, and blue only gray colors are used. Setting D greater than 1 will let you
display one channel of a color image.

Note: The X version does not support all possible visuals. If FLTK cannot draw the image in the
current visual it will abort. FLTK supports any visual of 8 bits or less, and all common TrueColor
visuals up to 32 bits.
typedef void (∗Fl Draw Image Cb)(void ∗data,int x,int y,int w,uchar ∗buf)
void fl draw image(Fl Draw Image Cb cb,void ∗data,int X,int Y,int W,int H,int D)
void fl draw image mono(Fl Draw Image Cb cb,void ∗data,int X,int Y,int W,int H,int D)

Call the passed function to provide each scan line of the image. This lets you generate the image as
it is being drawn, or do arbitrary decompression of stored data, provided it can be decompressed to
individual scan lines easily.

The callback is called with the void∗ user data pointer which can be used to point at a structure of
information about the image, and the x, y, and w of the scan line desired from the image. 0,0 is the
upper-left corner of the image, not X,Y. A pointer to a buffer to put the data into is passed. You must
copy w pixels from scanline y, starting at pixel x, to this buffer.

Due to cropping, less than the whole image may be requested. So x may be greater than zero, the first
y may be greater than zero, and w may be less than W. The buffer is long enough to store the entire
W∗D pixels, this is for convenience with some decompression schemes where you must decompress
the entire line at once: decompress it into the buffer, and then if x is not zero, copy the data over so the
x’th pixel is at the start of the buffer.
7.4. DRAWING IMAGES 55

You can assume the y’s will be consecutive, except the first one may be greater than zero.

If D is 4 or more, you must fill in the unused bytes with zero.

int fl draw pixmap(char∗ const∗ data, int x, int y, Fl Color bg)


int fl draw pixmap(const char∗ const∗ cdata, int x, int y, Fl Color bg)

Draws XPM image data, with the top-left corner at the given position. The image is dithered on 8-
bit displays so you won’t lose color space for programs displaying both images and pixmaps. This
function returns zero if there was any error decoding the XPM data.

To use an XPM, do:


#include "foo.xpm"
...
fl draw pixmap(foo, X, Y);

Transparent colors are replaced by the optional Fl Color argument. To draw with true transparency
you must use the Fl Pixmap class.

int fl measure pixmap(char∗ const∗ data, int &w, int &h)


int fl measure pixmap(const char∗ const∗ cdata, int &w, int &h)

An XPM image contains the dimensions in its data. This function finds and returns the width and
height. The return value is non-zero if the dimensions were parsed ok and zero if there was any
problem.

7.4.2 Direct Image Reading


FLTK provides a single function for reading from the current window or off-screen buffer into a RGB(A)
image buffer.
uchar∗ fl read image(uchar ∗p, int X, int Y, int W, int H, int alpha)

Read a RGB(A) image from the current window or off-screen buffer. The p argument points to a buffer
that can hold the image and must be at least W∗H∗3 bytes when reading RGB images and W∗H∗4 bytes
when reading RGBA images. If NULL, fl read image() will create an array of the proper size
which can be freed using delete[].

The alpha parameter controls whether an alpha channel is created and the value that is placed in the
alpha channel. If 0, no alpha channel is generated.

7.4.3 Image Classes


FLTK provides a base image class called Fl Image which supports creating, copying, and drawing images
of various kinds, along with some basic color operations. Images can be used as labels for widgets using
the image() and deimage() methods or drawn directly.
The Fl Image class does almost nothing by itself, but is instead supported by three basic image types:

• Fl Bitmap

• Fl Pixmap
56 CHAPTER 7. DRAWING THINGS IN FLTK

• Fl RGB Image

The Fl Bitmap class encapsulates a mono-color bitmap image. The draw() method draws the image
using the current drawing color.
The Fl Pixmap class encapsulates a colormapped image. The draw() method draws the image using
the colors in the file, and masks off any transparent colors automatically.
The Fl RGB Image class encapsulates a full-color (or grayscale) image with 1 to 4 color components.
Images with an even number of components are assumed to contain an alpha channel that is used for
transparency. The transparency provided by the draw() method is either a 24-bit blend against the existing
window contents or a ”screen door” transparency mask, depending on the platform and screen color depth.
char fl can do alpha blending()

fl can do alpha blending() will return 1, if your platform supports true alpha blending for
RGBA images, or 0, if FLTK will use screen door transparency.

FLTK also provides several image classes based on the three standard image types for common file formats:

• Fl GIF Image

• Fl JPEG Image

• Fl PNG Image

• Fl PNM Image

• Fl XBM Image

• Fl XPM Image

Each of these image classes load a named file of the corresponding format. The Fl Shared Image class
can be used to load any type of image file - the class examines the file and constructs an image of the
appropriate type.
Finally, FLTK provides a special image class called Fl Tiled Image to tile another image object in the
specified area. This class can be used to tile a background image in a Fl Group widget, for example.
virtual void Fl Tiled Image::copy();
virtual Fl Image∗ Fl Tiled Image::copy(int w, int h);

The copy() method creates a copy of the image. The second form specifies the new size of the image
- the image is resized using the nearest-neighbor algorithm.

void Fl Tiled Image::draw(int x, int y, int w, int h, int ox, int oy);

The draw() method draws the image object. x,y,w,h indicates a destination rectangle. ox,oy,w,h
is a source rectangle. This source rectangle is copied to the destination. The source rectangle may ex-
tend outside the image, i.e. ox and oy may be negative and w and h may be bigger than the image,
and this area is left unchanged.

void Fl Tiled Image::draw(int x, int y)

Draws the image with the upper-left corner at x,y. This is the same as doing draw(x,y,img->w(),img-
>h(),0,0).
7.4. DRAWING IMAGES 57

7.4.4 Offscreen Drawing


Sometimes it can be very useful to generate a complex drawing in memory first and copy it to the screen
at a later point in time. This technique can significantly reduce the amount of repeated drawing. Off-
screen drawing functions are declared in <FL/x.H>. Fl Double Window uses offscreen rendering to avoid
flickering on systems that don’t support double-buffering natively.
Fl Offscreen fl create offscreen(int w, int h)

Create an RGB offscreen buffer with w∗h pixels.

void fl delete offscreen(Fl Offscreen)

Delete a previously created offscreen buffer. All drawings are lost.

void fl begin offscreen(Fl Offscreen)

Send all subsequent drawing commands to this offscreen buffer. FLTK can draw into a buffer at any
time. There is no need to wait for an Fl Widget::draw() to occur.

void fl end offscreen()

Quit sending drawing commands to this offscreen buffer.

void fl copy offscreen(int x, int y, int w, int h, Fl Offscreen osrc, int srcx, int srcy)

Copy a rectangular area of the size w∗h from srcx,srcy in the offscreen buffer into the current buffer
at x,y.
58 CHAPTER 7. DRAWING THINGS IN FLTK
Chapter 8

Handling Events

This chapter discusses the FLTK event model and how to handle events in your program or widget.

8.1 The FLTK Event Model


Every time a user moves the mouse pointer, clicks a button, or presses a key, an event is generated and sent
to your application. Events can also come from other programs like the window manager.
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. This static information remains valid until the next event
is read from the window system, so it is ok to look at it outside of the handle() method.
Event numbers can be converted to their actual names using the fl eventnames[] array defined in #in-
clude <FL/names.h>; see next chapter for details.
In the next chapter, the MyClass::handle() example shows how to override the Fl Widget::handle()
method to accept and process specific events.

8.2 Mouse Events


8.2.1 FL PUSH
A mouse button has gone down with the mouse pointing at this widget. You can find out what button by
calling Fl::event button(). You find out the mouse position by calling Fl::event x() and Fl::event y().
A widget indicates that it ”wants” the mouse click by returning non-zero from its handle() method,
as in the MyClass::handle() example. It will then become the Fl::pushed() widget and will get FL DR-
AG and the matching FL RELEASE events. If handle() returns zero then FLTK will try sending the
FL PUSH to another widget.

8.2.2 FL DRAG
The mouse has moved with a button held down. The current button state is in Fl::event state(). The mouse
position is in Fl::event x() and Fl::event y().
In order to receive FL DRAG events, the widget must return non-zero when handling FL PUSH.

8.2.3 FL RELEASE
A mouse button has been released. You can find out what button by calling Fl::event button().
In order to receive the FL RELEASE event, the widget must return non-zero when handling FL PUSH.

59
60 CHAPTER 8. HANDLING EVENTS

8.2.4 FL MOVE
The mouse has moved without any mouse buttons held down. This event is sent to the Fl::belowmouse()
widget.
In order to receive FL MOVE events, the widget must return non-zero when handling FL ENTER.

8.2.5 FL MOUSEWHEEL
The user has moved the mouse wheel. The Fl::event dx() and Fl::event dy() methods can be used to find
the amount to scroll horizontally and vertically.

8.3 Focus Events


8.3.1 FL ENTER
The mouse has been moved to point at this widget. This can be used for highlighting feedback. If a widget
wants to highlight or otherwise track the mouse, it indicates this by returning non-zero from its handle()
method. It then becomes the Fl::belowmouse() widget and will receive FL MOVE and FL LEAVE events.

8.3.2 FL LEAVE
The mouse has moved out of the widget.
In order to receive the FL LEAVE event, the widget must return non-zero when handling FL ENTER.

8.3.3 FL FOCUS
This indicates an attempt to give a widget the keyboard focus.
If a widget wants the focus, it should change itself to display the fact that it has the focus, and return
non-zero from its handle() method. It then becomes the Fl::focus() widget and gets FL KEYDOWN,
FL KEYUP, and FL UNFOCUS events.
The focus will change either because the window manager changed which window gets the focus, or
because the user tried to navigate using tab, arrows, or other keys. You can check Fl::event key() to figure
out why it moved. For navigation it will be the key pressed and for interaction with the window manager it
will be zero.

8.3.4 FL UNFOCUS
This event is sent to the previous Fl::focus() widget when another widget gets the focus or the window
loses focus.

8.4 Keyboard Events


8.4.1 FL KEYBOARD, FL KEYDOWN, FL KEYUP
A key was pressed (FL KEYDOWN) or released (FL KEYUP). FL KEYBOARD is a synonym for FL -
KEYDOWN, and both names are used interchangeably in this documentation.
The key can be found in Fl::event key(). The text that the key should insert can be found with Fl::event-
text() and its length is in Fl::event length().
If you use the key, then handle() should return 1. If you return zero then FLTK assumes you ignored
the key and will then attempt to send it to a parent widget. If none of them want it, it will change the event
into a FL SHORTCUT event. FL KEYBOARD events are also generated by the character palette/map.
To receive FL KEYBOARD events you must also respond to the FL FOCUS and FL UNFOCUS events
by returning 1. This way FLTK knows whether to bother sending your widget keyboard events. (Some
widgets don’t need them, e.g. Fl Box.)
8.5. WIDGET EVENTS 61

If you are writing a text-editing widget you may also want to call the Fl::compose() function to translate
individual keystrokes into characters.
FL KEYUP events are sent to the widget that currently has focus. This is not necessarily the same
widget that received the corresponding FL KEYDOWN event because focus may have changed between
events.

Todo Add details on how to detect repeating keys, since on some X servers a repeating key will generate
both FL KEYUP and FL KEYDOWN, such that to tell if a key is held, you need Fl::event key(int)
to detect if the key is being held down during FL KEYUP or not.

8.4.2 FL SHORTCUT
If the Fl::focus() widget is zero or ignores an FL KEYBOARD event then FLTK tries sending this event to
every widget it can, until one of them returns non-zero. FL SHORTCUT is first sent to the Fl::belowmouse()
widget, then its parents and siblings, and eventually to every widget in the window, trying to find an object
that returns non-zero. FLTK tries really hard to not to ignore any keystrokes!
You can also make ”global” shortcuts by using Fl::add handler(). A global shortcut will work no matter
what windows are displayed or which one has the focus.

8.5 Widget Events


8.5.1 FL DEACTIVATE
This widget is no longer active, due to deactivate() being called on it or one of its parents. Please note
that although active() may still return true for this widget after receiving this event, it is only truly active if
active() is true for both it and all of its parents. (You can use active r() to check this).

8.5.2 FL ACTIVATE
This widget is now active, due to activate() being called on it or one of its parents.

8.5.3 FL HIDE
This widget is no longer visible, due to hide() being called on it or one of its parents, or due to a parent
window being minimized. Please note that although visible() may still return true for this widget after
receiving this event, it is only truly visible if visible() is true for both it and all of its parents. (You can use
visible r() to check this).

8.5.4 FL SHOW
This widget is visible again, due to show() being called on it or one of its parents, or due to a parent window
being restored. A child Fl Window will respond to this by actually creating the window if not done already,
so if you subclass a window, be sure to pass FL SHOW to the base class handle() method!

Note
The events in this chapter (”Widget Events”), i.e. FL ACTIVATE, FL DEACTIVATE, FL SHOW,
and FL HIDE, are the only events deactivated and invisible widgets can usually get, depending on
their states. Under certain circumstances, there may also be FL LEAVE or FL UNFOCUS events
delivered to deactivated or hidden widgets.
62 CHAPTER 8. HANDLING EVENTS

8.6 Clipboard Events


8.6.1 FL PASTE
You should get this event some time after you call Fl::paste(). The contents of Fl::event text() is the text to
insert and the number of characters is in Fl::event length().

8.6.2 FL SELECTIONCLEAR
The Fl::selection owner() will get this event before the selection is moved to another widget. This indicates
that some other widget or program has claimed the selection. Motif programs used this to clear the selection
indication. Most modern programs ignore this.

8.7 Drag and Drop Events


FLTK supports drag and drop of text and files from any application on the desktop to an FLTK widget.
Text is transferred using UTF-8 encoding. Files are received as a list of full path and file names, separated
by newline.
On some X11 platforms, files are received as a URL-encoded UTF-8 string, that is, non-ASCII bytes
(and a few others such as space and %) are replaced by the 3 bytes ”%XY” where XY are the byte’s
hexadecimal value. The fl decode uri() function can be used to transform in-place the received string into
a proper UTF-8 string. On these platforms, strings corresponding to dropped files are further prepended by
file:// (or other prefixes such as computer://).
See Fl::dnd() for drag and drop from an FLTK widget.
The drag and drop data is available in Fl::event text() at the concluding FL PASTE. On some platforms,
the event text is also available for the FL DND ∗ events, however application must not depend on that
behavior because it depends on the protocol used on each platform.
FL DND ∗ events cannot be used in widgets derived from Fl Group or Fl Window.

8.7.1 FL DND ENTER


The mouse has been moved to point at this widget. A widget that is interested in receiving drag’n’drop data
must return 1 to receive FL DND DRAG, FL DND LEAVE and FL DND RELEASE events.

8.7.2 FL DND DRAG


The mouse has been moved inside a widget while dragging data. A widget that is interested in receiving
drag’n’drop data should indicate the possible drop position.

8.7.3 FL DND LEAVE


The mouse has moved out of the widget.

8.7.4 FL DND RELEASE


The user has released the mouse button dropping data into the widget. If the widget returns 1, it will receive
the data in the immediately following FL PASTE event.

8.8 Other events


8.8.1 FL SCREEN CONFIGURATION CHANGED
Sent whenever the screen configuration changes (a screen is added/removed, a screen resolution is changed,
screens are moved). Use Fl::add handler() to be notified of this event.
8.9. FL::EVENT ∗() METHODS 63

8.8.2 FL FULLSCREEN
The application window has been changed from normal to fullscreen, or from fullscreen to normal. If you
are using a X window manager which supports Extended Window Manager Hints, this event will not be
delivered until the change has actually happened.

8.9 Fl::event ∗() methods


FLTK keeps the information about the most recent event in static storage. This information is good until
the next event is processed. Thus it is valid inside handle() and callback() methods.
These are all trivial inline functions and thus very fast and small:

• Fl::event button()
• Fl::event clicks()
• Fl::event dx()
• Fl::event dy()
• Fl::event inside()
• Fl::event is click()
• Fl::event key()
• Fl::event length()
• Fl::event state()
• Fl::event text()
• Fl::event x()
• Fl::event x root()
• Fl::event y()
• Fl::event y root()
• Fl::get key()
• Fl::get mouse()
• Fl::test shortcut()

8.10 Event Propagation


Widgets receive events via the virtual handle() function. The argument indicates the type of event that
can be handled. The widget must indicate if it handled the event by returning 1. FLTK will then remove
the event and wait for further events from the host. If the widget’s handle function returns 0, FLTK may
redistribute the event based on a few rules.
Most events are sent directly to the handle() method of the Fl Window that the window system
says they belong to. The window (actually the Fl Group that Fl Window is a subclass of) is responsible
for sending the events on to any child widgets. To make the Fl Group code somewhat easier, FLTK sends
some events (FL DRAG, FL RELEASE, FL KEYBOARD, FL SHORTCUT, FL UNFOCUS, and FL LEAVE)
directly to leaf widgets. These procedures control those leaf widgets:

• Fl::add handler()
64 CHAPTER 8. HANDLING EVENTS

• Fl::belowmouse()
• Fl::focus()

• Fl::grab()
• Fl::modal()
• Fl::pushed()
• Fl::release() (deprecated, see Fl::grab(0))

• Fl Widget::take focus()

FLTK propagates events along the widget hierarchy depending on the kind of event and the status of the
UI. Some events are injected directly into the widgets, others may be resent as new events to a different
group of receivers.
Mouse click events are first sent to the window that caused them. The window then forwards the event
down the hierarchy until it reaches the widget that is below the click position. If that widget uses the given
event, the widget is marked ”pushed” and will receive all following mouse motion (FL DRAG) events until
the mouse button is released.
Mouse motion (FL MOVE) events are sent to the Fl::belowmouse() widget, i.e. the widget that returned
1 on the last FL ENTER event.
Mouse wheel events are sent to the window that caused the event. The window propagates the event
down the tree, first to the widget that is below the mouse pointer, and if that does not succeed, to all other
widgets in the group. This ensures that scroll widgets work as expected with the widget furthest down in
the hierarchy getting the first opportunity to use the wheel event, but also giving scroll bars, that are not
directly below the mouse a chance.
Keyboard events are sent directly to the widget that has keyboard focus. If the focused widget rejects
the event, it is resent as a shortcut event, first to the top-most window, then to the widget below the mouse
pointer, propagating up the hierarchy to all its parents. Those send the event also to all widgets that are
not below the mouse pointer. Now if that did not work out, the shortcut is sent to all registered shortcut
handlers.
If we are still unsuccessful, the event handler flips the case of the shortcut letter and starts over. Finally,
if the key is ”escape”, FLTK sends a close event to the top-most window.
All other events are pretty much sent right away to the window that created the event.
Widgets can ”grab” events. The grabbing window gets all events exclusively, but usually by the same
rules as described above.
Windows can also request exclusivity in event handling by making the window modal.

8.11 FLTK Compose-Character Sequences


The character composition done by Fl Input widget requires that you call the Fl::compose() function if you
are writing your own text editor widget.
Currently, all characters made by single key strokes with or without modifier keys, or by system-defined
character compose sequences (that can involve dead keys or a compose key) can be input. You should call
Fl::compose() in case any enhancements to this processing are done in the future. The interface has been
designed to handle arbitrary UTF-8 encoded text.
The following methods are provided for character composition:

• Fl::compose()
• Fl::compose reset()

Under Mac OS X, FLTK ”previews” partially composed sequences.


Chapter 9

Adding and Extending Widgets

This chapter describes how to add your own widgets or extend existing widgets in FLTK.

9.1 Subclassing
New widgets are created by subclassing an existing FLTK widget, typically Fl Widget for controls and
Fl Group for composite widgets.
A control widget typically interacts with the user to receive and/or display a value of some sort.
A composite widget holds a list of child widgets and handles moving, sizing, showing, or hiding them
as needed. Fl Group is the main composite widget class in FLTK, and all of the other composite widgets
(Fl Pack, Fl Scroll, Fl Tabs, Fl Tile, and Fl Window) are subclasses of it.
You can also subclass other existing widgets to provide a different look or user-interface. For example,
the button widgets are all subclasses of Fl Button since they all interact with the user via a mouse button
click. The only difference is the code that draws the face of the button.

9.2 Making a Subclass of Fl Widget


Your subclasses can directly descend from Fl Widget or any subclass of Fl Widget. Fl Widget has only
four virtual methods, and overriding some or all of these may be necessary.

9.3 The Constructor


The constructor should have the following arguments:
MyClass(int x, int y, int w, int h, const char *label = 0);

This will allow the class to be used in FLUID without problems.


The constructor must call the constructor for the base class and pass the same arguments:
MyClass::MyClass(int x, int y, int w, int h, const char *label)
: Fl Widget(x, y, w, h, label) {
// do initialization stuff...
}

Fl Widget’s protected constructor sets x(), y(), w(), h(), and label() to the passed values and
initializes the other instance variables to:
type(0);
box(FL NO BOX);
color(FL BACKGROUND COLOR);
selection color(FL BACKGROUND COLOR);
labeltype(FL NORMAL LABEL);
labelstyle(FL NORMAL STYLE);

65
66 CHAPTER 9. ADDING AND EXTENDING WIDGETS

labelsize(FL NORMAL SIZE);


labelcolor(FL FOREGROUND COLOR);
align(FL ALIGN CENTER);
callback(default callback,0);
flags(ACTIVE|VISIBLE);
image(0);
deimage(0);

9.4 Protected Methods of Fl Widget


The following methods are provided for subclasses to use:

• clear visible()
• damage()
• draw box()
• draw focus()
• draw label()
• set flag()
• set visible()
• test shortcut()
• type()

void Fl Widget::damage(uchar mask)


void Fl Widget::damage(uchar mask, int x, int y, int w, int h)
uchar Fl Widget::damage()

The first form indicates that a partial update of the object is needed. The bits in mask are OR’d into
damage(). Your draw() routine can examine these bits to limit what it is drawing. The public method
Fl Widget::redraw() simply does Fl Widget::damage(FL DAMAGE ALL), but the implementa-
tion of your widget can call the public damage(n).

The second form indicates that a region is damaged. If only these calls are done in a window (no calls
to damage(n)) then FLTK will clip to the union of all these calls before drawing anything. This
can greatly speed up incremental displays. The mask bits are OR’d into damage() unless this is a
Fl Window widget.

The third form returns the bitwise-OR of all damage(n) calls done since the last draw().

When redrawing your widgets you should look at the damage bits to see what parts of your widget
need redrawing. The handle() method can then set individual damage bits to limit the amount of
drawing that needs to be done:
MyClass::handle(int event) {
...
if (change to part1) damage(1);
if (change to part2) damage(2);
if (change to part3) damage(4);
}

MyClass::draw() {
if (damage() & FL DAMAGE ALL) {
... draw frame/box and other static stuff ...
9.4. PROTECTED METHODS OF FL WIDGET 67

if (damage() & (FL DAMAGE ALL | 1)) draw part1();


if (damage() & (FL DAMAGE ALL | 2)) draw part2();
if (damage() & (FL DAMAGE ALL | 4)) draw part3();
}

Todo Clarify Fl Window::damage(uchar) handling - seems confused/wrong? ORing value doesn’t match
setting behaviour in FL Widget.H!
void Fl Widget::draw box() const
void Fl Widget::draw box(Fl Boxtype t, Fl Color c) const

The first form draws this widget’s box(), using the dimensions of the widget. The second form uses
t as the box type and c as the color for the box.
void Fl Widget::draw focus()
void Fl Widget::draw focus(Fl Boxtype t, int x, int y, int w, int h) const

Draws a focus box inside the widget’s bounding box. The second form allows you to specify a different
bounding box.
void Fl Widget::draw label() const
void Fl Widget::draw label(int x, int y, int w, int h) const
void Fl Widget::draw label(int x, int y, int w, int h, Fl Align align) const

The first form is the usual function for a draw() method to call to draw the widget’s label. It does
not draw the label if it is supposed to be outside the box (on the assumption that the enclosing group
will draw those labels).

The second form uses the passed bounding box instead of the widget’s bounding box. This is useful
so ”centered” labels are aligned with some feature, like a moving slider.

The third form draws the label anywhere. It acts as though FL ALIGN INSIDE has been forced on
so the label will appear inside the passed bounding box. This is designed for parent groups to draw
labels with.
void Fl Widget::set flag(int c)

Calling set flag(SHORTCUT LABEL) modifies the behavior of draw label() so that ’&’ characters
cause an underscore to be printed under the next letter.
void Fl Widget::set visible()
void Fl Widget::clear visible()

Fast inline versions of Fl Widget::hide() and Fl Widget::show(). These do not send the FL HIDE and
FL SHOW events to the widget.
int Fl Widget::test shortcut()
static int Fl Widget::test shortcut(const char ∗s)

The first version tests Fl Widget::label() against the current event (which should be a FL SHORTCUT
event). If the label contains a ’&’ character and the character after it matches the keypress, this returns
true. This returns false if the SHORTCUT LABEL flag is off, if the label is NULL, or does not have a
’&’ character in it, or if the keypress does not match the character.
68 CHAPTER 9. ADDING AND EXTENDING WIDGETS

The second version lets you do this test against an arbitrary string.

Todo Clarify Fl Widget::test shortcut() explanations. Fl Widget.h says Internal Use only, but subclassing
chapter gives details!

uchar Fl Widget::type() const


void Fl Widget::type(uchar t)

The property Fl Widget::type() can return an arbitrary 8-bit identifier, and can be set with the protected
method type(uchar t). This value had to be provided for Forms compatibility, but you can use it
for any purpose you want. Try to keep the value less than 100 to not interfere with reserved values.

FLTK does not use RTTI (Run Time Typing Information), to enhance portability. But this may change
in the near future if RTTI becomes standard everywhere.

If you don’t have RTTI you can use the clumsy FLTK mechanism, by having type() use a unique
value. These unique values must be greater than the symbol FL RESERVED TYPE (which is 100) and
less than FL WINDOW (unless you make a subclass of Fl Window). Look through the header files for
FL RESERVED TYPE to find an unused number. If you make a subclass of Fl Window you must use
FL WINDOW + n (where n must be in the range 1 to 7).

9.5 Handling Events


The virtual method Fl Widget::handle(int event) is called to handle each event passed to the widget. It can:

• Change the state of the widget.


• Call Fl Widget::redraw() if the widget needs to be redisplayed.
• Call Fl Widget::damage(uchar c) if the widget needs a partial-update (assuming you provide support
for this in your draw() method).
• Call Fl Widget::do callback() if a callback should be generated.
• Call Fl Widget::handle() on child widgets.

Events are identified by the integer argument. Other information about the most recent event is stored in
static locations and acquired by calling the Fl::event ∗() methods. This information remains valid until
another event is handled.
Here is a sample handle() method for a widget that acts as a pushbutton and also accepts the
keystroke ’x’ to cause the callback:
int MyClass::handle(int event) {
switch(event) {
case FL PUSH:
highlight = 1;
redraw();
return 1;
case FL DRAG: {
int t = Fl::event inside(this);
if (t != highlight) {
highlight = t;
redraw();
}
}
return 1;
case FL RELEASE:
if (highlight) {
highlight = 0;
9.6. DRAWING THE WIDGET 69

redraw();
do callback();
// never do anything after a callback, as the callback
// may delete the widget!
}
return 1;
case FL SHORTCUT:
if (Fl::event key() == ’x’) {
do callback();
return 1;
}
return 0;
default:
return Fl Widget::handle(event);
}
}

You must return non-zero if your handle() method uses the event. If you return zero, the parent
widget will try sending the event to another widget.
For debugging purposes, event numbers can be printed as their actual event names using the fl -
eventnames[] array, e.g.:
#include <FL/names.h> // defines fl eventnames[]
[..]
int MyClass::handle(int e) {
printf("Event was %s (%d)\n", fl eventnames[e], e); // e.g. "Event was FL PUSH (1)"
[..]

9.6 Drawing the Widget


The draw() virtual method is called when FLTK wants you to redraw your widget. It will be called if
and only if damage() is non-zero, and damage() will be cleared to zero after it returns. The draw()
method should be declared protected so that it can’t be called from non-drawing code.
The damage() value contains the bitwise-OR of all the damage(n) calls to this widget since it was
last drawn. This can be used for minimal update, by only redrawing the parts whose bits are set. FLTK will
turn on the FL DAMAGE ALL bit if it thinks the entire widget must be redrawn, e.g. for an expose event.
Expose events (and the damage(mask,x,y,w,h) function described above) will cause draw() to be
called with FLTK’s clipping turned on. You can greatly speed up redrawing in some cases by testing
fl not clipped(x,y,w,h) or fl clip box() and skipping invisible parts.
Besides the protected methods described above, FLTK provides a large number of basic drawing func-
tions, which are described in the chapter Drawing Things in FLTK.

9.7 Resizing the Widget


The resize(x,y,w,h) method is called when the widget is being resized or moved. The arguments
are the new position, width, and height. x(), y(), w(), and h() still remain the old size. You must call
resize() on your base class with the same arguments to get the widget size to actually change.
This should not call redraw(), at least if only the x() and y() change. This is because composite
widgets like Fl Scroll may have a more efficient way of drawing the new position.

9.8 Making a Composite Widget


A ”composite” widget contains one or more ”child” widgets. To make a composite widget you should
subclass Fl Group. It is possible to make a composite object that is not a subclass of Fl Group, but you’ll
have to duplicate the code in Fl Group anyways.
Instances of the child widgets may be included in the parent:
class MyClass : public Fl Group {
Fl Button the button;
Fl Slider the slider;
70 CHAPTER 9. ADDING AND EXTENDING WIDGETS

...
};

The constructor has to initialize these instances. They are automatically added to the group, since
the Fl Group constructor does Fl Group::begin(). Don’t forget to call Fl Group::end() or use the Fl End
pseudo-class:

MyClass::MyClass(int x, int y, int w, int h) :


Fl Group(x, y, w, h),
the button(x + 5, y + 5, 100, 20),
the slider(x, y + 50, w, 20)
{
...(you could add dynamically created child widgets here)...
end(); // don’t forget to do this!
}

The child widgets need callbacks. These will be called with a pointer to the children, but the widget
itself may be found in the parent() pointer of the child. Usually these callbacks can be static private
methods, with a matching private method:

void MyClass::static slider cb(Fl Widget* v, void *) { // static method


((MyClass*)(v->parent())->slider cb();
}
void MyClass::slider cb() { // normal method
use(the slider->value());
}

If you make the handle() method, you can quickly pass all the events to the children using the Fl-
Group::handle() method. You don’t need to override handle() if your composite widget does nothing
other than pass events to the children:

int MyClass::handle(int event) {


if (Fl Group::handle(event)) return 1;
... handle events that children don’t want ...
}

If you override draw() you need to draw all the children. If redraw() or damage() is called on
a child, damage(FL DAMAGE CHILD) is done to the group, so this bit of damage() can be used to
indicate that a child needs to be drawn. It is fastest if you avoid drawing anything else in this case:

int MyClass::draw() {
Fl Widget *const*a = array();
if (damage() == FL DAMAGE CHILD) { // only redraw some children
for (int i = children(); i --; a ++) update child(**a);
} else { // total redraw
... draw background graphics ...
// now draw all the children atop the background:
for (int i = children ; i --; a ++) {
draw child(**a);
draw outside label(**a); // you may not need to do this
}
}
}

Fl Group provides some protected methods to make drawing easier:

• draw child()

• draw children()

• draw outside label()

• update child()

void Fl Group::draw child(Fl Widget &widget) const


9.9. CUT AND PASTE SUPPORT 71

This will force the child’s damage() bits all to one and call draw() on it, then clear the damage().
You should call this on all children if a total redraw of your widget is requested, or if you draw some-
thing (like a background box) that damages the child. Nothing is done if the child is not visible()
or if it is clipped.

void Fl Group::draw children()

A convenience function that draws all children of the group. This is useful if you derived a widget
from Fl Group and want to draw a special border or background. You can call draw children()
from the derived draw() method after drawing the box, border, or background.

void Fl Group::draw outside label(const Fl Widget &widget) const

Draw the labels that are not drawn by draw label(). If you want more control over the label positions
you might want to call child->draw label(x,y,w,h,a).

void Fl Group::update child(Fl Widget& widget) const

Draws the child only if its damage() is non-zero. You should call this on all the children if your own
damage is equal to FL DAMAGE CHILD. Nothing is done if the child is not visible() or if it is
clipped.

9.9 Cut and Paste Support


FLTK provides routines to cut and paste 8-bit text (in the future this may be UTF-8) between applications:

• Fl::paste()

• Fl::selection()

• Fl::selection owner()

It may be possible to cut/paste non-text data by using Fl::add handler(). Note that handling events beyond
those provided by FLTK may be operating system specific. See Operating System Issues for more details.

9.10 Drag And Drop Support


FLTK provides routines to drag and drop 8-bit text between applications:
Drag’n’drop operations are initiated by copying data to the clipboard and calling the function Fl::dnd().
Drop attempts are handled via the following events, already described under Drag and Drop Events in
a previous chapter:

• FL DND ENTER

• FL DND DRAG

• FL DND LEAVE

• FL DND RELEASE

• FL PASTE
72 CHAPTER 9. ADDING AND EXTENDING WIDGETS

9.11 Making a subclass of Fl Window


You may want your widget to be a subclass of Fl Window, Fl Double Window, or Fl Gl Window. This
can be useful if your widget wants to occupy an entire window, and can also be used to take advantage of
system-provided clipping, or to work with a library that expects a system window ID to indicate where to
draw.
Subclassing Fl Window is almost exactly like subclassing Fl Group, and in fact you can easily switch
a subclass back and forth. Watch out for the following differences:

1. Fl Window is a subclass of Fl Group so make sure your constructor calls end() unless you actually
want children added to your window.

2. When handling events and drawing, the upper-left corner is at 0,0, not x(),y() as in other Fl -
Widget’s. For instance, to draw a box around the widget, call draw box(0,0,w(),h()), rather
than draw box(x(),y(),w(),h()).

You may also want to subclass Fl Window in order to get access to different visuals or to change other
attributes of the windows. See the Operating System Issues chapter for more information.
Chapter 10

Using OpenGL

This chapter discusses using FLTK for your OpenGL applications.

10.1 Using OpenGL in FLTK


The easiest way to make an OpenGL display is to subclass Fl Gl Window. Your subclass must implement a
draw() method which uses OpenGL calls to draw the display. Your main program should call redraw()
when the display needs to change, and (somewhat later) FLTK will call draw().
With a bit of care you can also use OpenGL to draw into normal FLTK windows. This allows you to
use Gouraud shading for drawing your widgets. To do this you use the gl start() and gl finish() functions
around your OpenGL code.
You must include FLTK’s <FL/gl.h> header file. It will include the file <GL/gl.h>, define some
extra drawing functions provided by FLTK, and include the <windows.h> header file needed by WIN32
applications.

10.2 Making a Subclass of Fl Gl Window


To make a subclass of Fl Gl Window, you must provide:

• A class definition.

• A draw() method.

• A handle() method if you need to receive input from the user.

If your subclass provides static controls in the window, they must be redrawn whenever the FL DAMA-
GE ALL bit is set in the value returned by damage(). For double-buffered windows you will need to
surround the drawing code with the following code to make sure that both buffers are redrawn:
#ifndef MESA
glDrawBuffer(GL FRONT AND BACK);
#endif // !MESA
... draw stuff here ...
#ifndef MESA
glDrawBuffer(GL BACK);
#endif // !MESA

Note:
If you are using the Mesa graphics library, the call to glDrawBuffer() is not required and will
slow down drawing considerably. The preprocessor instructions shown above will optimize your code
based upon the graphics library used.

73
74 CHAPTER 10. USING OPENGL

10.2.1 Defining the Subclass


To define the subclass you just subclass the Fl Gl Window class:
class MyWindow : public Fl Gl Window {
void draw();
int handle(int);

public:
MyWindow(int X, int Y, int W, int H, const char *L)
: Fl Gl Window(X, Y, W, H, L) {}
};

The draw() and handle() methods are described below. Like any widget, you can include addi-
tional private and public data in your class (such as scene graph information, etc.)

10.2.2 The draw() Method


The draw() method is where you actually do your OpenGL drawing:
void MyWindow::draw() {
if (!valid()) {
... set up projection, viewport, etc ...
... window size is in w() and h().
... valid() is turned on by FLTK after draw() returns
}
... draw ...
}

10.2.3 The handle() Method


The handle() method handles mouse and keyboard events for the window:
int MyWindow::handle(int event) {
switch(event) {
case FL PUSH:
... mouse down event ...
... position in Fl::event x() and Fl::event y()
return 1;
case FL DRAG:
... mouse moved while down event ...
return 1;
case FL RELEASE:
... mouse up event ...
return 1;
case FL FOCUS :
case FL UNFOCUS :
... Return 1 if you want keyboard events, 0 otherwise
return 1;
case FL KEYBOARD:
... keypress, key is in Fl::event key(), ascii in Fl::event text()
... Return 1 if you understand/use the keyboard event, 0 otherwise...
return 1;
case FL SHORTCUT:
... shortcut, key is in Fl::event key(), ascii in Fl::event text()
... Return 1 if you understand/use the shortcut event, 0 otherwise...
return 1;
default:
// pass other events to the base class...
return Fl Gl Window::handle(event);
}
}

When handle() is called, the OpenGL context is not set up! If your display changes, you should
call redraw() and let draw() do the work. Don’t call any OpenGL drawing functions from inside
handle()!
You can call some OpenGL stuff like hit detection and texture loading functions by doing:
case FL PUSH:
make current(); // make OpenGL context current
if (!valid()) {
10.3. USING OPENGL IN NORMAL FLTK WINDOWS 75

... set up projection exactly the same as draw ...

valid(1); // stop it from doing this next time


}
... ok to call NON-DRAWING OpenGL code here, such as hit
detection, loading textures, etc...

Your main program can now create one of your windows by doing new MyWindow(...).
You can also use your new window class in FLUID by:

1. Putting your class definition in a MyWindow.H file.

2. Creating a Fl Box widget in FLUID.

3. In the widget panel fill in the ”class” field with MyWindow. This will make FLUID produce con-
structors for your new class.

4. In the ”Extra Code” field put #include "MyWindow.H", so that the FLUID output file will
compile.

You must put glwindow->show() in your main code after calling show() on the window con-
taining the OpenGL window.

10.3 Using OpenGL in Normal FLTK Windows


You can put OpenGL code into the draw() method, as described in Drawing the Widget in the previous
chapter, or into the code for a boxtype or other places with some care.
Most importantly, before you show any windows, including those that don’t have OpenGL drawing,
you must initialize FLTK so that it knows it is going to use OpenGL. You may use any of the symbols
described for Fl Gl Window::mode() to describe how you intend to use OpenGL:
Fl::gl visual(FL RGB);

You can then put OpenGL drawing code anywhere you can draw normally by surrounding it with gl-
start() and gl finish() to set up, and later release, an OpenGL context with an orthographic projection so
that 0,0 is the lower-left corner of the window and each pixel is one unit. The current clipping is reproduced
with OpenGL glScissor() commands. These functions also synchronize the OpenGL graphics stream
with the drawing done by other X, WIN32, or FLTK functions.
gl start();
... put your OpenGL code here ...
gl finish();

The same context is reused each time. If your code changes the projection transformation or anything
else you should use glPushMatrix() and glPopMatrix() functions to put the state back before
calling gl finish().
You may want to use Fl Window::current()->h() to get the drawable height so that you can
flip the Y coordinates.
Unfortunately, there are a bunch of limitations you must adhere to for maximum portability:

• You must choose a default visual with Fl::gl visual().

• You cannot pass FL DOUBLE to Fl::gl visual().

• You cannot use Fl Double Window or Fl Overlay Window.

Do not call gl start() or gl finish() when drawing into an Fl Gl Window !


76 CHAPTER 10. USING OPENGL

10.4 OpenGL Drawing Functions


FLTK provides some useful OpenGL drawing functions. They can be freely mixed with any OpenGL
calls, and are defined by including <FL/gl.h> which you should include instead of the OpenGL header
<GL/gl.h>.
void gl color(Fl Color)

Sets the current OpenGL color to a FLTK color. For color-index modes it will use fl xpixel(c),
which is only right if this window uses the default colormap!

void gl rect(int x, int y, int w, int h)


void gl rectf(int x, int y, int w, int h)

Outlines or fills a rectangle with the current color. If Fl Gl Window::ortho() has been called, then the
rectangle will exactly fill the pixel rectangle passed.

void gl font(Fl Font fontid, int size)

Sets the current OpenGL font to the same font you get by calling fl font().

int gl height()
int gl descent()
float gl width(const char ∗s)
float gl width(const char ∗s, int n)
float gl width(uchar c)

Returns information about the current OpenGL font.

void gl draw(const char ∗s)


void gl draw(const char ∗s, int n)

Draws a nul-terminated string or an array of n characters in the current OpenGL font at the current
raster position.

void gl draw(const char ∗s, int x, int y)


void gl draw(const char ∗s, int n, int x, int y)
void gl draw(const char ∗s, float x, float y)
void gl draw(const char ∗s, int n, float x, float y)

Draws a nul-terminated string or an array of n characters in the current OpenGL font at the given
position.

void gl draw(const char ∗s, int x, int y, int w, int h, Fl Align)

Draws a string formatted into a box, with newlines and tabs expanded, other control characters changed
to ∧ X, and aligned with the edges or center. Exactly the same output as fl draw().
10.5. SPEEDING UP OPENGL 77

10.5 Speeding up OpenGL


Performance of Fl Gl Window may be improved on some types of OpenGL implementations, in particular
MESA and other software emulators, by setting the GL SWAP TYPE environment variable. This variable
declares what is in the backbuffer after you do a swapbuffers.

• setenv GL SWAP TYPE COPY


This indicates that the back buffer is copied to the front buffer, and still contains its old data. This
is true of many hardware implementations. Setting this will speed up emulation of overlays, and
widgets that can do partial update can take advantage of this as damage() will not be cleared to -1.

• setenv GL SWAP TYPE NODAMAGE


This indicates that nothing changes the back buffer except drawing into it. This is true of MESA and
Win32 software emulation and perhaps some hardware emulation on systems with lots of memory.

• All other values for GL SWAP TYPE, and not setting the variable, cause FLTK to assume that the
back buffer must be completely redrawn after a swap.

This is easily tested by running the gl overlay demo program and seeing if the display is correct when you
drag another window over it or if you drag the window off the screen and back on. You have to exit and
run the program again for it to see any changes to the environment variable.

10.6 Using OpenGL Optimizer with FLTK


OpenGL Optimizer is a scene graph toolkit for OpenGL available from Silicon Graphics for IRIX and
Microsoft Windows. It allows you to view large scenes without writing a lot of OpenGL code.

OptimizerWindow Class Definition

To use OpenGL Optimizer with FLTK you’ll need to create a subclass of Fl Gl Widget that in-
cludes several state variables:
class OptimizerWindow : public Fl Gl Window {
csContext *context ; // Initialized to 0 and set by draw()...
csDrawAction *draw action ; // Draw action...
csGroup *scene ; // Scene to draw...
csCamara *camera ; // Viewport for scene...

void draw();

public:
OptimizerWindow(int X, int Y, int W, int H, const char *L)
: Fl Gl Window(X, Y, W, H, L) {
context = (csContext *)0;
draw action = (csDrawAction *)0;
scene = (csGroup *)0;
camera = (csCamera *)0;
}

void scene(csGroup *g) { scene = g; redraw(); }

void camera(csCamera *c) {


camera = c;
if (context ) {
draw action ->setCamera(camera );
camera ->draw(draw action );
redraw();
}
}
};
78 CHAPTER 10. USING OPENGL

The camera() Method

The camera() method sets the camera (projection and viewpoint) to use when drawing the scene.
The scene is redrawn after this call.
The draw() Method

The draw() method performs the needed initialization and does the actual drawing:
void OptimizerWindow::draw() {
if (!context ) {
// This is the first time we’ve been asked to draw; create the
// Optimizer context for the scene...

#ifdef WIN32
context = new csContext((HDC)fl getHDC());
context ->ref();
context ->makeCurrent((HDC)fl getHDC());
#else
context = new csContext(fl display, fl visual);
context ->ref();
context ->makeCurrent(fl display, fl window);
#endif // WIN32

... perform other context setup as desired ...

// Then create the draw action to handle drawing things...

draw action = new csDrawAction;


if (camera ) {
draw action ->setCamera(camera );
camera ->draw(draw action );
}
} else {
#ifdef WIN32
context ->makeCurrent((HDC)fl getHDC());
#else
context ->makeCurrent(fl display, fl window);
#endif // WIN32
}

if (!valid()) {
// Update the viewport for this context...
context ->setViewport(0, 0, w(), h());
}

// Clear the window...


context ->clear(csContext::COLOR CLEAR | csContext::DEPTH CLEAR,
0.0f, // Red
0.0f, // Green
0.0f, // Blue
1.0f); // Alpha

// Then draw the scene (if any)...


if (scene )
draw action ->apply(scene );
}

The scene() Method

The scene() method sets the scene to be drawn. The scene is a collection of 3D objects in a cs-
Group. The scene is redrawn after this call.
Chapter 11

Programming with FLUID

This chapter shows how to use the Fast Light User-Interface Designer (”FLUID”) to create your GUIs.
Subchapters:

• What is FLUID?

• Running FLUID Under UNIX

• Running FLUID Under Microsoft Windows

• Compiling .fl files

• A Short Tutorial

• FLUID Reference

• Internationalization with FLUID

• Known limitations

11.1 What is FLUID?


The Fast Light User Interface Designer, or FLUID, is a graphical editor that is used to produce FLTK
source code. FLUID edits and saves its state in .fl files. These files are text, and you can (with care) edit
them in a text editor, perhaps to get some special effects.
FLUID can ”compile” the .fl file into a .cxx and a .h file. The .cxx file defines all the objects
from the .fl file and the .h file declares all the global ones. FLUID also supports localization (Interna-
tionalization) of label strings using message files and the GNU gettext or POSIX catgets interfaces.
A simple program can be made by putting all your code (including a main() function) into the .fl
file and thus making the .cxx file a single source file to compile. Most programs are more complex than
this, so you write other .cxx files that call the FLUID functions. These .cxx files must #include the
.h file or they can #include the .cxx file so it still appears to be a single source file.

79
80 CHAPTER 11. PROGRAMMING WITH FLUID

Figure 11.1: FLUID organization

Normally the FLUID file defines one or more functions or classes which output C++ code. Each
function defines one or more FLTK windows, and all the widgets that go inside those windows.
Widgets created by FLUID are either ”named”, ”complex named” or ”unnamed”. A named widget has
a legal C++ variable identifier as its name (i.e. only alphanumeric and underscore). In this case FLUID
defines a global variable or class member that will point at the widget after the function defining it is called.
A complex named object has punctuation such as ’.’ or ’->’ or any other symbols in its name. In this
case FLUID assigns a pointer to the widget to the name, but does not attempt to declare it. This can be
used to get the widgets into structures. An unnamed widget has a blank name and no pointer is stored.
Widgets may either call a named callback function that you write in another source file, or you can
supply a small piece of C++ source and FLUID will write a private callback function into the .cxx file.

11.2 Running FLUID Under UNIX


To run FLUID under UNIX, type:
fluid filename.fl &

to edit the .fl file filename.fl. If the file does not exist you will get an error pop-up, but if you
dismiss it you will be editing a blank file of that name. You can run FLUID without any name, in which
case you will be editing an unnamed blank setup (but you can use save-as to write it to a file).
You can provide any of the standard FLTK switches before the filename:
-display host:n.n
-geometry WxH+X+Y
-title windowtitle
-name classname
-iconic
-fg color
-bg color
-bg2 color
-scheme schemename

Changing the colors may be useful to see what your interface will look at if the user calls it with the
same switches. Similarly, using ”-scheme plastic” will show how the interface will look using the ”plastic”
scheme.
In the current version, if you don’t put FLUID into the background with ’&’ then you will be able to
abort FLUID by typing CTRL-C on the terminal. It will exit immediately, losing any changes.

11.3 Running FLUID Under Microsoft Windows


To run FLUID under WIN32, double-click on the FLUID.exe file. You can also run FLUID from the
Command Prompt window. FLUID always runs in the background under WIN32.
11.4. COMPILING .FL FILES 81

11.4 Compiling .fl files


FLUID can also be called as a command-line ”compiler” to create the .cxx and .h file from a .fl file.
To do this type:

fluid -c filename.fl

This will read the filename.fl file and write filename.cxx and filename.h. Any leading
directory on filename.fl will be stripped, so they are always written to the current directory. If there
are any errors reading or writing the files, FLUID will print the error and exit with a non-zero code. You
can use the following lines in a makefile to automate the creation of the source and header files:

my panels.h my panels.cxx: my panels.fl


fluid -c my panels.fl

Most versions of make support rules that cause .fl files to be compiled:

.SUFFIXES: .fl .cxx .h


.fl.h .fl.cxx:
fluid -c $<

11.5 A Short Tutorial


FLUID is an amazingly powerful little program. However, this power comes at a price as it is not always
obvious how to accomplish seemingly simple tasks with it. This tutorial will show you how to generate a
complete user interface class with FLUID that is used for the CubeView program provided with FLTK.

Figure 11.2: CubeView demo


82 CHAPTER 11. PROGRAMMING WITH FLUID

The window is of class CubeViewUI, and is completely generated by FLUID, including class member
functions. The central display of the cube is a separate subclass of Fl Gl Window called CubeView. Cube-
ViewUI manages CubeView using callbacks from the various sliders and rollers to manipulate the viewing
angle and zoom of CubeView.
At the completion of this tutorial you will (hopefully) understand how to:

1. Use FLUID to create a complete user interface class, including constructor and any member functions
necessary.

2. Use FLUID to set callbacks member functions of a custom widget classes.

3. Subclass an Fl Gl Window to suit your purposes.

11.5.1 The CubeView Class


The CubeView class is a subclass of Fl Gl Window. It has methods for setting the zoom, the x and y pan,
and the rotation angle about the x and y axes.
You can safely skip this section as long as you realize that CubeView is a sublass of Fl Gl Window and
will respond to calls from CubeViewUI, generated by FLUID.

The CubeView Class Definition

Here is the CubeView class definition, as given by its header file ”test/CubeView.h”:
class CubeView : public Fl Gl Window {
public:
CubeView(int x,int y,int w,int h,const char *l=0);
// this value determines the scaling factor used to draw the cube.
double size;
/* Set the rotation about the vertical (y ) axis.

* This function is called by the horizontal roller in CubeViewUI


* and the initialize button in CubeViewUI.
*/
void v angle(float angle){vAng=angle;};
// Return the rotation about the vertical (y ) axis.
float v angle(){return vAng;};
/* Set the rotation about the horizontal (x ) axis.

* This function is called by the vertical roller in CubeViewUI


and the
* initialize button in CubeViewUI.
*/
void h angle(float angle){hAng=angle;};
// the rotation about the horizontal (x ) axis.
float h angle(){return hAng;};
/* Sets the x shift of the cube view camera.

* This function is called by the slider in CubeViewUI and the


* initialize button in CubeViewUI.
*/
void panx(float x){xshift=x;};
/* Sets the y shift of the cube view camera.

* This function is called by the slider in CubeViewUI and the


* initialize button in CubeViewUI.
*/
void pany(float y){yshift=y;};
/* The widget class draw() override.
* The draw() function initialize Gl for another round of
* drawing then calls specialized functions for drawing each
* of the entities displayed in the cube view.
*/
void draw();

private:
/* Draw the cube boundaries
* Draw the faces of the cube using the boxv[] vertices, using
* GL LINE LOOP for the faces. The color is #defined by
11.5. A SHORT TUTORIAL 83

* CUBECOLOR.
*/
void drawCube();

float vAng,hAng; float xshift,yshift;

float boxv0[3];float boxv1[3]; float boxv2[3];float boxv3[3];


float boxv4[3];float boxv5[3]; float boxv6[3];float boxv7[3];
};

The CubeView Class Implementation

Here is the CubeView implementation. It is very similar to the ”cube” demo included with FLTK.
#include "CubeView.h"
#include <math.h>

CubeView::CubeView(int x,int y,int w,int h,const char *l)


: Fl Gl Window(x,y,w,h,l)
{
vAng = 0.0; hAng=0.0; size=10.0;
/* The cube definition. These are the vertices of a unit cube
* centered on the origin.*/
boxv0[0] = -0.5; boxv0[1] = -0.5; boxv0[2] = -0.5; boxv1[0] = 0.5;
boxv1[1] = -0.5; boxv1[2] = -0.5; boxv2[0] = 0.5; boxv2[1] = 0.5;
boxv2[2] = -0.5; boxv3[0] = -0.5; boxv3[1] = 0.5; boxv3[2] = -0.5;
boxv4[0] = -0.5; boxv4[1] = -0.5; boxv4[2] = 0.5; boxv5[0] = 0.5;
boxv5[1] = -0.5; boxv5[2] = 0.5; boxv6[0] = 0.5; boxv6[1] = 0.5;
boxv6[2] = 0.5; boxv7[0] = -0.5; boxv7[1] = 0.5; boxv7[2] = 0.5;
};

// The color used for the edges of the bounding cube.


#define CUBECOLOR 255,255,255,255

void CubeView::drawCube() {
/* Draw a colored cube */
#define ALPHA 0.5
glShadeModel(GL FLAT);

glBegin(GL QUADS);
glColor4f(0.0, 0.0, 1.0, ALPHA);
glVertex3fv(boxv0);
glVertex3fv(boxv1);
glVertex3fv(boxv2);
glVertex3fv(boxv3);

glColor4f(1.0, 1.0, 0.0, ALPHA);


glVertex3fv(boxv0);
glVertex3fv(boxv4);
glVertex3fv(boxv5);
glVertex3fv(boxv1);

glColor4f(0.0, 1.0, 1.0, ALPHA);


glVertex3fv(boxv2);
glVertex3fv(boxv6);
glVertex3fv(boxv7);
glVertex3fv(boxv3);

glColor4f(1.0, 0.0, 0.0, ALPHA);


glVertex3fv(boxv4);
glVertex3fv(boxv5);
glVertex3fv(boxv6);
glVertex3fv(boxv7);

glColor4f(1.0, 0.0, 1.0, ALPHA);


glVertex3fv(boxv0);
glVertex3fv(boxv3);
glVertex3fv(boxv7);
glVertex3fv(boxv4);

glColor4f(0.0, 1.0, 0.0, ALPHA);


glVertex3fv(boxv1);
glVertex3fv(boxv5);
glVertex3fv(boxv6);
glVertex3fv(boxv2);
glEnd();
84 CHAPTER 11. PROGRAMMING WITH FLUID

glColor3f(1.0, 1.0, 1.0);


glBegin(GL LINES);
glVertex3fv(boxv0);
glVertex3fv(boxv1);

glVertex3fv(boxv1);
glVertex3fv(boxv2);

glVertex3fv(boxv2);
glVertex3fv(boxv3);

glVertex3fv(boxv3);
glVertex3fv(boxv0);

glVertex3fv(boxv4);
glVertex3fv(boxv5);

glVertex3fv(boxv5);
glVertex3fv(boxv6);

glVertex3fv(boxv6);
glVertex3fv(boxv7);

glVertex3fv(boxv7);
glVertex3fv(boxv4);

glVertex3fv(boxv0);
glVertex3fv(boxv4);

glVertex3fv(boxv1);
glVertex3fv(boxv5);

glVertex3fv(boxv2);
glVertex3fv(boxv6);

glVertex3fv(boxv3);
glVertex3fv(boxv7);
glEnd();
};//drawCube

void CubeView::draw() {
if (!valid()) {
glLoadIdentity(); glViewport(0,0,w(),h());
glOrtho(-10,10,-10,10,-20000,10000); glEnable(GL BLEND);
glBlendFunc(GL SRC ALPHA, GL ONE MINUS SRC ALPHA);
}

glClear(GL COLOR BUFFER BIT | GL DEPTH BUFFER BIT);


glPushMatrix(); glTranslatef(xshift, yshift, 0);
glRotatef(hAng,0,1,0); glRotatef(vAng,1,0,0);
glScalef(float(size),float(size),float(size)); drawCube();
glPopMatrix();
};

11.5.2 The CubeViewUI Class

We will completely construct a window to display and control the CubeView defined in the previous section
using FLUID.

Defining the CubeViewUI Class

Once you have started FLUID, the first step in defining a class is to create a new class within FLUID using
the New->Code->Class menu item. Name the class ”CubeViewUI” and leave the subclass blank. We do
not need any inheritance for this window. You should see the new class declaration in the FLUID browser
window.
11.5. A SHORT TUTORIAL 85

Figure 11.3: FLUID file for CubeView

Adding the Class Constructor

Click on the CubeViewUI class in the FLUID window and add a new method by selecting New->Code-
>Function/Method. The name of the function will also be CubeViewUI. FLUID will understand that this
will be the constructor for the class and will generate the appropriate code. Make sure you declare the
constructor public.
Then add a window to the CubeViewUI class. Highlight the name of the constructor in the FLUID
browser window and click on New->Group->Window. In a similar manner add the following to the
CubeViewUI constructor:

• A horizontal roller named hrot

• A vertical roller named vrot

• A horizontal slider named xpan

• A vertical slider named ypan

• A horizontal value slider named zoom

None of these additions need be public. And they shouldn’t be unless you plan to expose them as part of
the interface for CubeViewUI.
When you are finished you should have something like this:
86 CHAPTER 11. PROGRAMMING WITH FLUID

Figure 11.4: FLUID window containing CubeView demo

We will talk about the show() method that is highlighted shortly.

Adding the CubeView Widget

What we have is nice, but does little to show our cube. We have already defined the CubeView class and
we would like to show it within the CubeViewUI.

The CubeView class inherits the Fl Gl Window class, which is created in the same way as a Fl Box
widget. Use New->Other->Box to add a square box to the main window. This will be no ordinary box,
however.

The Box properties window will appear. The key to letting CubeViewUI display CubeView is to enter
CubeView in the Class: text entry box. This tells FLUID that it is not an Fl Box, but a similar widget with
the same constructor.

In the Extra Code: field enter #include "CubeView.h"

This #include is important, as we have just included CubeView as a member of CubeViewUI, so


any public CubeView methods are now available to CubeViewUI.
11.5. A SHORT TUTORIAL 87

Figure 11.5: CubeView methods

Defining the Callbacks

Each of the widgets we defined before adding CubeView can have callbacks that call CubeView methods.
You can call an external function or put in a short amount of code in the Callback field of the widget panel.
For example, the callback for the ypan slider is:

cube->pany(((Fl Slider *)o)->value());


cube->redraw();

We call cube->redraw() after changing the value to update the CubeView window. CubeView
could easily be modified to do this, but it is nice to keep this exposed. In the case where you may want to
do more than one view change only redrawing once saves a lot of time.
There is no reason to wait until after you have added CubeView to enter these callbacks. FLUID
assumes you are smart enough not to refer to members or functions that don’t exist.

Adding a Class Method

You can add class methods within FLUID that have nothing to do with the GUI. As an example add a show
function so that CubeViewUI can actually appear on the screen.
Make sure the top level CubeViewUI is selected and select New->Code->Function/Method. Just use
the name show(). We don’t need a return value here, and since we will not be adding any widgets to this
method FLUID will assign it a return type of void.
88 CHAPTER 11. PROGRAMMING WITH FLUID

Figure 11.6: CubeView constructor

Once the new method has been added, highlight its name and select New->Code->Code. Enter the
method’s code in the code window.

11.5.3 Adding Constructor Initialization Code


If you need to add code to initialize a class, for example setting initial values of the horizontal and vertical
angles in the CubeView, you can simply highlight the constructor and select New->Code->Code. Add
any required code.

11.5.4 Generating the Code


Now that we have completely defined the CubeViewUI, we have to generate the code. There is one last
trick to ensure this all works. Open the preferences dialog from Edit->Preferences.
At the bottom of the preferences dialog box is the key: ”Include Header from Code”. Select that
option and set your desired file extensions and you are in business. You can include the CubeViewUI.h (or
whatever extension you prefer) as you would any other C++ class.

11.6 FLUID Reference


The following sections describe each of the windows in FLUID.

11.6.1 The Widget Browser


The main window shows a menu bar and a scrolling browser of all the defined widgets. The name of the
.fl file being edited is shown in the window title.
The widgets are stored in a hierarchy. You can open and close a level by clicking the ”triangle” at
the left of a widget. The leftmost widgets are the parents, and all the widgets listed below them are their
children. Parents don’t have to have any children.
The top level of the hierarchy is composed of functions and classes. Each of these will produce a single
C++ public function or class in the output .cxx file. Calling the function or instantiating the class will
create all of the child widgets.
The second level of the hierarchy contains the windows. Each of these produces an instance of class
Fl Window.
11.6. FLUID REFERENCE 89

Below that are either widgets (subclasses of Fl Widget) or groups of widgets (including other groups).
Plain groups are for layout, navigation, and resize purposes. Tab groups provide the well-known file-card
tab interface.
Widgets are shown in the browser by either their name (such as ”main panel” in the example), or by
their type and label (such as ”Button ”the green””).
You select widgets by clicking on their names, which highlights them (you can also select widgets
from any displayed window). You can select many widgets by dragging the mouse across them, or by
using Shift+Click to toggle them on and off. To select no widgets, click in the blank area under the last
widget. Note that hidden children may be selected even when there is no visual indication of this.
You open widgets by double-clicking on them, or (to open several widgets you have picked) by typing
the F1 key. A control panel will appear so you can change the widget(s).

11.6.2 Menu Items


The menu bar at the top is duplicated as a pop-up menu on any displayed window. The shortcuts for all the
menu items work in any window. The menu items are:
File/Open... (Ctrl+o)

Discards the current editing session and reads in a different .fl file. You are asked for confirmation
if you have changed the current file.

FLUID can also read .fd files produced by the Forms and XForms ”fdesign” programs. It is best to
File/Merge them instead of opening them. FLUID does not understand everything in a .fd file, and
will print a warning message on the controlling terminal for all data it does not understand. You will
probably need to edit the resulting setup to fix these errors. Be careful not to save the file without
changing the name, as FLUID will write over the .fd file with its own format, which fdesign cannot
read!
File/Insert... (Ctrl+i)

Inserts the contents of another .fl file, without changing the name of the current .fl file. All the
functions (even if they have the same names as the current ones) are added, and you will have to use
cut/paste to put the widgets where you want.
File/Save (Ctrl+s)

Writes the current data to the .fl file. If the file is unnamed then FLUID will ask for a filename.
File/Save As... (Ctrl+Shift+S)

Asks for a new filename and saves the file.


File/Write Code (Ctrl+Shift+C)

”Compiles” the data into a .cxx and .h file. These are exactly the same as the files you get when you
run FLUID with the -c switch.
90 CHAPTER 11. PROGRAMMING WITH FLUID

The output file names are the same as the .fl file, with the leading directory and trailing ”.fl” stripped,
and ”.h” or ”.cxx” appended.
File/Write Strings (Ctrl+Shift+W)

Writes a message file for all of the text labels defined in the current file.

The output file name is the same as the .fl file, with the leading directory and trailing ”.fl” stripped,
and ”.txt”, ”.po”, or ”.msg” appended depending on the Internationalization Mode.
File/Quit (Ctrl+q)

Exits FLUID. You are asked for confirmation if you have changed the current file.
Edit/Undo (Ctrl+z)

This isn’t implemented yet. You should do save often so you can recover from any mistakes you make.
Edit/Cut (Ctrl+x)

Deletes the selected widgets and all of their children. These are saved to a ”clipboard” file and can be
pasted back into any FLUID window.
Edit/Copy (Ctrl+c)

Copies the selected widgets and all of their children to the ”clipboard” file.
Edit/Paste (Ctrl+c)

Pastes the widgets from the clipboard file.

If the widget is a window, it is added to whatever function is selected, or contained in the current
selection.

If the widget is a normal widget, it is added to whatever window or group is selected. If none is, it is
added to the window or group that is the parent of the current selection.

To avoid confusion, it is best to select exactly one widget before doing a paste.

Cut/paste is the only way to change the parent of a widget.


11.6. FLUID REFERENCE 91

Edit/Select All (Ctrl+a)

Selects all widgets in the same group as the current selection.

If they are all selected already then this selects all widgets in that group’s parent. Repeatedly typing
Ctrl+a will select larger and larger groups of widgets until everything is selected.
Edit/Open... (F1 or double click)

Displays the current widget in the attributes panel. If the widget is a window and it is not visible then
the window is shown instead.
Edit/Sort

Sorts the selected widgets into left to right, top to bottom order. You need to do this to make navigation
keys in FLTK work correctly. You may then fine-tune the sorting with ”Earlier” and ”Later”. This does
not affect the positions of windows or functions.
Edit/Earlier (F2)

Moves all of the selected widgets one earlier in order among the children of their parent (if possible).
This will affect navigation order, and if the widgets overlap it will affect how they draw, as the later
widget is drawn on top of the earlier one. You can also use this to reorder functions, classes, and
windows within functions.
Edit/Later (F3)

Moves all of the selected widgets one later in order among the children of their parent (if possible).
Edit/Group (F7)

Creates a new Fl Group and make all the currently selected widgets children of it.
Edit/Ungroup (F8)

Deletes the parent group if all the children of a group are selected.
Edit/Overlays on/off (Ctrl+Shift+O)

Toggles the display of the red overlays off, without changing the selection. This makes it easier to see
box borders and how the layout looks. The overlays will be forced back on if you change the selection.
92 CHAPTER 11. PROGRAMMING WITH FLUID

Edit/Project Settings... (Ctrl+p)

Displays the project settings panel. The output filenames control the extensions or names of the files
that are generated by FLUID. If you check the ”Include Header from Code” button the code file will
include the header file automatically.

The internationalization options are described later in this chapter.

Figure 11.7: FLUID Preferences Window

Edit/Project Settings... (Shift+Ctrl+p)

Displays the project settings (”Preferences”) panel. This panel is used to control the user interface
settings.
New/Code/Function

Creates a new C function. You will be asked for a name for the function. This name should be a legal
C++ function template, without the return type. You can pass arguments which can be referred to by
code you type into the individual widgets.

If the function contains any unnamed windows, it will be declared as returning a Fl Window pointer.
The unnamed window will be returned from it (more than one unnamed window is useless). If the
function contains only named windows, it will be declared as returning nothing (void ).
11.6. FLUID REFERENCE 93

It is possible to make the .cxx output be a self-contained program that can be compiled and executed.
This is done by deleting the function name so main(argc,argv) is used. The function will call
show() on all the windows it creates and then call Fl::run(). This can also be used to test resize
behavior or other parts of the user interface.

You can change the function name by double-clicking on the function.


New/Window

Creates a new Fl Window widget. The window is added to the currently selected function, or to the
function containing the currently selected item. The window will appear, sized to 100x100. You can
resize it to whatever size you require.

The widget panel will also appear and is described later in this chapter.
New/...

All other items on the New menu are subclasses of Fl Widget. Creating them will add them to the
currently selected group or window, or the group or window containing the currently selected widget.
The initial dimensions and position are chosen by copying the current widget, if possible.

When you create the widget you will get the widget’s control panel, which is described later in this
chapter.
Layout/Align/...

Align all selected widgets to the first widget in the selection.


Layout/Space Evenly/...

Space all selected widgets evenly inside the selected space. Widgets will be sorted from first to last.
Layout/Make Same Size/...

Make all selected widgets the same size as the first selected widget.
Layout/Center in Group/...

Center all selected widgets relative to their parent widget


Layout/Grid... (Ctrl+g)
94 CHAPTER 11. PROGRAMMING WITH FLUID

Displays the grid settings panel. This panel controls the grid that all widgets snap to when you move
and resize them, and for the ”snap” which is how far a widget has to be dragged from its original
position to actually change.

Shell/Execute Command... (Alt+x)

Displays the shell command panel. The shell command is commonly used to run a ’make’ script to
compile the FLTK output.

Shell/Execute Again (Alt+g)

Run the shell command again.

Help/About FLUID

Pops up a panel showing the version of FLUID.

Help/On FLUID

Shows this chapter of the manual.

Help/Manual

Shows the contents page of the manual

11.6.3 The Widget Panel


When you double-click on a widget or a set of widgets you will get the ”widget attribute panel”.
When you change attributes using this panel, the changes are reflected immediately in the window. It
is useful to hit the ”no overlay” button (or type Ctrl+Shift+O) to hide the red overlay so you can see the
widgets more accurately, especially when setting the box type.
If you have several widgets selected, they may have different values for the fields. In this case the value
for one of the widgets is shown. But if you change this value, all of the selected widgets are changed to the
new value.
Hitting ”OK” makes the changes permanent. Selecting a different widget also makes the changes
permanent. FLUID checks for simple syntax errors such as mismatched parenthesis in any code before
saving any text.
”Revert” or ”Cancel” put everything back to when you last brought up the panel or hit OK. However in
the current version of FLUID, changes to ”visible” attributes (such as the color, label, box) are not undone
by revert or cancel. Changes to code like the callbacks are undone, however.
11.7. GUI ATTRIBUTES 95

Figure 11.8: The FLUID widget GUI attributes

11.7 GUI Attributes


Label (text field)

String to print next to or inside the button. You can put newlines into the string to make multiple lines.
The easiest way is by typing Ctrl+j.

Symbols can be added to the label using the at sign (”@”).

Label (pull down menu)

How to draw the label. Normal, shadowed, engraved, and embossed change the appearance of the text.

Image

The active image for the widget. Click on the Browse... button to pick an image file using the file
chooser.
Inactive
96 CHAPTER 11. PROGRAMMING WITH FLUID

The inactive image for the widget. Click on the Browse... button to pick an image file using the file
chooser.
Alignment (buttons)

Where to draw the label. The arrows put it on that side of the widget, you can combine them to put it
in the corner. The ”box” button puts the label inside the widget, rather than outside.

The clip button clips the label to the widget box, the wrap button wraps any text in the label, and the
text image button puts the text over the image instead of under the image.
Position (text fields)

The position fields show the current position and size of the widget box. Enter new values to move
and/or resize a widget.
Values (text fields)

The values and limits of the current widget. Depending on the type of widget, some or all of these
fields may be inactive.
Shortcut

The shortcut key to activate the widget. Click on the shortcut button and press any key sequence to set
the shortcut.
Attributes (buttons)

The Visible button controls whether the widget is visible (on) or hidden (off) initially. Don’t change
this for windows or for the immediate children of a Tabs group.

The Active button controls whether the widget is activated (on) or deactivated (off) initially. Most
widgets appear greyed out when deactivated.

The Resizable button controls whether the window is resizeable. In addition all the size changes of
a window or group will go ”into” the resizable child. If you have a large data display surrounded by
buttons, you probably want that data area to be resizable. You can get more complex behavior by
making invisible boxes the resizable widget, or by using hierarchies of groups. Unfortunately the only
way to test it is to compile the program. Resizing the FLUID window is not the same as what will
happen in the user program.

The Hotspot button causes the parent window to be positioned with that widget centered on the mouse.
This position is determined when the FLUID function is called, so you should call it immediately
before showing the window. If you want the window to hide and then reappear at a new position, you
should have your program set the hotspot itself just before show().
11.7. GUI ATTRIBUTES 97

The Border button turns the window manager border on or off. On most window managers you will
have to close the window and reopen it to see the effect.

X Class (text field)

The string typed into here is passed to the X window manager as the class. This can change the icon or
window decorations. On most (all?) window managers you will have to close the window and reopen
it to see the effect.

Figure 11.9: The FLUID widget Style attributes

11.7.1 Style Attributes


Label Font (pulldown menu)

Font to draw the label in. Ignored by symbols, bitmaps, and pixmaps. Your program can change the
actual font used by these ”slots” in case you want some font other than the 16 provided.

Label Size (pulldown menu)

Pixel size (height) for the font to draw the label in. Ignored by symbols, bitmaps, and pixmaps. To see
the result without dismissing the panel, type the new number and then Tab.
98 CHAPTER 11. PROGRAMMING WITH FLUID

Label Color (button)

Color to draw the label. Ignored by pixmaps (bitmaps, however, do use this color as the foreground
color).

Box (pulldown menu)

The boxtype to draw as a background for the widget.

Many widgets will work, and draw faster, with a ”frame” instead of a ”box”. A frame does not draw
the colored interior, leaving whatever was already there visible. Be careful, as FLUID may draw this
ok but the real program may leave unwanted stuff inside the widget.

If a window is filled with child widgets, you can speed up redrawing by changing the window’s box
type to ”NO BOX”. FLUID will display a checkerboard for any areas that are not colored in by boxes.
Note that this checkerboard is not drawn by the resulting program. Instead random garbage will be
displayed.

Down Box (pulldown menu)

The boxtype to draw when a button is pressed or for some parts of other widgets like scrollbars and
valuators.

Color (button)

The color to draw the box with.

Select Color (button)

Some widgets will use this color for certain parts. FLUID does not always show the result of this: this
is the color buttons draw in when pushed down, and the color of input fields when they have the focus.

Text Font, Size, and Color

Some widgets display text, such as input fields, pull-down menus, and browsers.
11.7. GUI ATTRIBUTES 99

Figure 11.10: The FLUID widget C++ attributes

11.7.2 C++ Attributes


Class

This is how you use your own subclasses of Fl Widget. Whatever identifier you type in here will be
the class that is instantiated.

In addition, no #include header file is put in the .h file. You must provide a #include line as the
first line of the ”Extra Code” which declares your subclass.

The class must be similar to the class you are spoofing. It does not have to be a subclass. It is sometimes
useful to change this to another FLTK class. Currently the only way to get a double-buffered window
is to change this field for the window to ”Fl Double Window” and to add
#include <FL/Fl Double Window.h>

to the extra code.


Type (upper-right pulldown menu)

Some classes have subtypes that modify their appearance or behavior. You pick the subtype off of this
menu.
Name (text field)
100 CHAPTER 11. PROGRAMMING WITH FLUID

Name of a variable to declare, and to store a pointer to this widget into. This variable will be of type
”<class>∗”. If the name is blank then no variable is created.

You can name several widgets with ”name[0]”, ”name[1]”, ”name[2]”, etc. This will cause FLUID to
declare an array of pointers. The array is big enough that the highest number found can be stored. All
widgets in the array must be the same type.
Public (button)

Controls whether the widget is publicly accessible. When embedding widgets in a C++ class, this
controls whether the widget is public or private in the class. Otherwise it controls whether the
widget is declared static or global (extern ).
Extra Code (text fields)

These four fields let you type in literal lines of code to dump into the .h or .cxx files.

If the text starts with a # or the word extern then FLUID thinks this is an ”include” line, and it is
written to the .h file. If the same include line occurs several times then only one copy is written.

All other lines are ”code” lines. The current widget is pointed to by the local variable o. The window
being constructed is pointed to by the local variable w. You can also access any arguments passed to
the function here, and any named widgets that are before this one.

FLUID will check for matching parenthesis, braces, and quotes, but does not do much other error
checking. Be careful here, as it may be hard to figure out what widget is producing an error in the
compiler. If you need more than four lines you probably should call a function in your own .cxx
code.
Callback (text field)

This can either be the name of a function, or a small snippet of code. If you enter anything other than
letters, numbers, and the underscore then FLUID treats it as code.

A name refers to a function in your own code. It must be declared as void name(<class>∗,void∗).

A code snippet is inserted into a static function in the .cxx output file. The function prototype is
void name(class ∗o, void ∗v) so that you can refer to the widget as o and the user -
data() as v. FLUID will check for matching parenthesis, braces, and quotes, but does not do much
other error checking. Be careful here, as it may be hard to figure out what widget is producing an error
in the compiler.

If the callback is blank then no callback is set.


User Data (text field)
11.8. SELECTING AND MOVING WIDGETS 101

This is a value for the user data() of the widget. If blank the default value of zero is used. This
can be any piece of C code that can be cast to a void pointer.
Type (text field)

The void∗ in the callback function prototypes is replaced with this. You may want to use long for
old XForms code. Be warned that anything other than void∗ is not guaranteed to work! However on
most architectures other pointer types are ok, and long is usually ok, too.
When (pulldown menu)

When to do the callback. This can be Never, Changed, Release, or Enter Key. The value of Enter
Key is only useful for text input fields.

There are other rare but useful values for the when() field that are not in the menu. You should use
the extra code fields to put these values in.
No Change (button)

The No Change button means the callback is done on the matching event even if the data is not
changed.

11.8 Selecting and Moving Widgets


Double-clicking a window name in the browser will display it, if not displayed yet. From this display you
can select widgets, sets of widgets, and move or resize them. To close a window either double-click it or
type ESC.
To select a widget, click it. To select several widgets drag a rectangle around them. Holding down shift
will toggle the selection of the widgets instead.
You cannot pick hidden widgets. You also cannot choose some widgets if they are completely over-
lapped by later widgets. Use the browser to select these widgets.
The selected widgets are shown with a red ”overlay” line around them. You can move the widgets by
dragging this box. Or you can resize them by dragging the outer edges and corners. Hold down the Alt key
while dragging the mouse to defeat the snap-to-grid effect for fine positioning.
If there is a tab box displayed you can change which child is visible by clicking on the file tabs. The
child you pick is selected.
The arrow, tab, and shift+tab keys ”navigate” the selection. Left, right, tab, or shift+tab move to the
next or previous widgets in the hierarchy. Hit the right arrow enough and you will select every widget in the
window. Up/down widgets move to the previous/next widgets that overlap horizontally. If the navigation
does not seem to work you probably need to ”Sort” the widgets. This is important if you have input fields,
as FLTK uses the same rules when using arrow keys to move between input fields.
To ”open” a widget, double click it. To open several widgets select them and then type F1 or pick
”Edit/Open” off the pop-up menu.
Type Ctrl+o to temporarily toggle the overlay off without changing the selection, so you can see the
widget borders.
You can resize the window by using the window manager border controls. FLTK will attempt to round
the window size to the nearest multiple of the grid size and makes it big enough to contain all the widgets
102 CHAPTER 11. PROGRAMMING WITH FLUID

(it does this using illegal X methods, so it is possible it will barf with some window managers!). Notice
that the actual window in your program may not be resizable, and if it is, the effect on child widgets may
be different.
The panel for the window (which you get by double-clicking it) is almost identical to the panel for any
other Fl Widget. There are three extra items:

11.9 Image Labels


The contents of the image files in the Image and Inactive text fields are written to the .cxx file. If many
widgets share the same image then only one copy is written. Since the image data is embedded in the
generated source code, you need only distribute the C++ code and not the image files themselves.
However, the filenames are stored in the .fl file so you will need the image files as well to read the
.fl file. Filenames are relative to the location of the .fl file and not necessarily the current directory. We
recommend you either put the images in the same directory as the .fl file, or use absolute path names.

Notes for All Image Types

FLUID runs using the default visual of your X server. This may be 8 bits, which will give you dithered
images. You may get better results in your actual program by adding the code ”Fl::visual(FL RGB)”
to your code right before the first window is displayed.

All widgets with the same image on them share the same code and source X pixmap. Thus once you
have put an image on a widget, it is nearly free to put the same image on many other widgets.

If you edit an image at the same time you are using it in FLUID, the only way to convince FLUID to
read the image file again is to remove the image from all widgets that are using it or re-load the .fl
file.

Don’t rely on how FLTK crops images that are outside the widget, as this may change in future
versions! The cropping of inside labels will probably be unchanged.

To more accurately place images, make a new ”box” widget and put the image in that as the label.

XBM (X Bitmap) Files

FLUID reads X bitmap files which use C source code to define a bitmap. Sometimes they are stored
with the ”.h” or ”.bm” extension rather than the standard ”.xbm” extension.

FLUID writes code to construct an Fl Bitmap image and use it to label the widget. The ’1’ bits in the
bitmap are drawn using the label color of the widget. You can change this color in the FLUID widget
attributes panel. The ’0’ bits are transparent.

The program ”bitmap” on the X distribution does an adequate job of editing bitmaps.

XPM (X Pixmap) Files


11.10. INTERNATIONALIZATION WITH FLUID 103

FLUID reads X pixmap files as used by the libxpm library. These files use C source code to define a
pixmap. The filenames usually have the ”.xpm” extension.

FLUID writes code to construct an Fl Pixmap image and use it to label the widget. The label color of
the widget is ignored, even for 2-color images that could be a bitmap. XPM files can mark a single
color as being transparent, and FLTK uses this information to generate a transparency mask for the
image.

We have not found any good editors for small iconic pictures. For pixmaps we have used XPaint and
the KDE icon editor.

BMP Files

FLUID reads Windows BMP image files which are often used in WIN32 applications for icons. F-
LUID converts BMP files into (modified) XPM format and uses a Fl BMP Image image to label the
widget. Transparency is handled the same as for XPM files. All image data is uncompressed when
written to the source file, so the code may be much bigger than the .bmp file.

GIF Files

FLUID reads GIF image files which are often used in HTML documents to make icons. FLUID
converts GIF files into (modified) XPM format and uses a Fl GIF Image image to label the widget.
Transparency is handled the same as for XPM files. All image data is uncompressed when written to
the source file, so the code may be much bigger than the .gif file. Only the first image of an animated
GIF file is used.

JPEG Files

If FLTK is compiled with JPEG support, FLUID can read JPEG image files which are often used for
digital photos. FLUID uses a Fl JPEG Image image to label the widget, and writes uncompressed
RGB or grayscale data to the source file.

PNG (Portable Network Graphics) Files

If FLTK is compiled with PNG support, FLUID can read PNG image files which are often used in
HTML documents. FLUID uses a Fl PNG Image image to label the widget, and writes uncompressed
RGB or grayscale data to the source file. PNG images can provide a full alpha channel for partial
transparency, and FLTK supports this as best as possible on each platform.

11.10 Internationalization with FLUID


FLUID supports internationalization (I18N for short) of label strings used by widgets. The preferences
window (Ctrl+p) provides access to the I18N options.
104 CHAPTER 11. PROGRAMMING WITH FLUID

11.10.1 I18N Methods


FLUID supports three methods of I18N: use none, use GNU gettext, and use POSIX catgets. The ”use
none” method is the default and just passes the label strings as-is to the widget constructors.
The ”GNU gettext” method uses GNU gettext (or a similar text-based I18N library) to retrieve a local-
ized string before calling the widget constructor.
The ”POSIX catgets” method uses the POSIX catgets function to retrieve a numbered message from a
message catalog before calling the widget constructor.

11.10.2 Using GNU gettext for I18N


FLUID’s code support for GNU gettext is limited to calling a function or macro to retrieve the localized
label; you still need to call setlocale() and textdomain() or bindtextdomain() to select the
appropriate language and message file.
To use GNU gettext for I18N, open the preferences window and choose ”GNU gettext” from the Use:
chooser. Two new input fields will then appear to control the include file and function/macro name to use
when retrieving the localized label strings.

Figure 11.11: Internationalization using GNU gettext

The #include field controls the header file to include for I18N; by default this is <libintl.h>, the
standard I18N file for GNU gettext.
The Function: field controls the function (or macro) that will retrieve the localized message; by default
the gettext function will be called.

11.10.3 Using POSIX catgets for I18N


FLUID’s code support for POSIX catgets allows you to use a global message file for all interfaces or a file
specific to each .fl file; you still need to call setlocale() to select the appropriate language.
11.11. KNOWN LIMITATIONS 105

To use POSIX catgets for I18N, open the preferences window and choose ”POSIX catgets” from the
Use: chooser. Three new input fields will then appear to control the include file, catalog file, and set
number for retrieving the localized label strings.

Figure 11.12: Internationalization using POSIX catgets

The #include field controls the header file to include for I18N; by default this is <nl types.h>, the
standard I18N file for POSIX catgets.
The File: field controls the name of the catalog file variable to use when retrieving localized messages;
by default the file field is empty which forces a local (static) catalog file to be used for all of the windows
defined in your .fl file.
The Set: field controls the set number in the catalog file. The default set is 1 and rarely needs to be
changed.

11.11 Known limitations


Declaration Blocks can be used to temporarily block out already designed code using #if 0 and #endif
type construction. This will effectively avoid compilation of blocks of code. However, static code and data
generated by this segment (menu items, images, include statements, etc.) will still be generated and likely
cause compile-time warnings.
106 CHAPTER 11. PROGRAMMING WITH FLUID
Chapter 12

Advanced FLTK

This chapter explains advanced programming and design topics that will help you to get the most out of
FLTK.

12.1 Multithreading
FLTK supports multithreaded applications using a locking mechanism based on ”pthreads”. We do not
provide a threading interface as part of the library. However a simple example how threads can be imple-
mented for all supported platforms can be found in test/threads.h and test/threads.cxx.
To use the locking mechanism, FLTK must be compiled with --enable-threads set during the
configure process. IDE-based versions of FLTK are automatically compiled with locking enabled if
possible.
In main(), call Fl::lock() before Fl::run() or Fl::wait() to start the runtime multithreading support for
your program. All callbacks and derived functions like handle() and draw() will now be properly
locked:
int main() {
Fl::lock();
/* run thread */
while (Fl::wait() > 0) {
if (Fl::thread message()) {
/* process your data */
}
}
}

You can now start as many threads as you like. From within a thread (other than the main thread) FLTK
calls must be wrapped with calls to Fl::lock() and Fl::unlock():
Fl::lock(); // avoid conflicting calls
... // your code here
Fl::unlock(); // allow other threads to access FLTK again

You can send messages from child threads to the main thread using Fl::awake(void∗ message):
void *msg; // "msg" is a pointer to your message
Fl::awake(msg); // send "msg" to main thread

A message can be anything you like. The main thread can retrieve the message by calling Fl::thread -
message(). See example above.
You can also tell the main thread to call a function for you as soon as possible by using Fl::awake(Fl -
Awake Handler cb, void∗ userdata):
void do something(void *userdata) {
// running with the main thread
}

// running in another thread


void *data; // "data" is a pointer to your user data
Fl::awake(do something, data); // call something in main thread

107
108 CHAPTER 12. ADVANCED FLTK

FLTK supports multiple platforms, some of which allow only the main thread to handle system events
and open or close windows. The safe thing to do is to adhere to the following rules for threads on all
operating systems:

• Don’t show() or hide() anything that contains widgets derived from Fl Window, including di-
alogs, file choosers, subwindows or those using Fl Gl Window.

• Don’t call Fl::run(), Fl::wait(), Fl::flush() or any related methods that will handle system messages

• Don’t start or cancel timers

• Don’t change window decorations or titles

• The make current() method may or may not work well for regular windows, but should always
work for a Fl Gl Window to allow for high speed rendering on graphics cards with multiple pipelines

See also: Fl::awake(void∗ message), Fl::lock(), Fl::thread message(), Fl::unlock().


Chapter 13

Unicode and UTF-8 Support

This chapter explains how FLTK handles international text via Unicode and UTF-8.
Unicode support was only recently added to FLTK and is still incomplete. This chapter is Work in
Progress, reflecting the current state of Unicode support.

13.1 About Unicode, ISO 10646 and UTF-8


The summary of Unicode, ISO 10646 and UTF-8 given below is deliberately brief, and provides just
enough information for the rest of this chapter. For further information, please see:
• http://www.unicode.org
• http://www.iso.org
• http://en.wikipedia.org/wiki/Unicode
• http://www.cl.cam.ac.uk/∼mgk25/unicode.html
• http://www.apps.ietf.org/rfc/rfc3629.html
The Unicode Standard

The Unicode Standard was originally developed by a consortium of mainly US computer manufacturers
and developers of multi-lingual software. It has now become a defacto standard for character encoding,
and is supported by most of the major computing companies in the world.
Before Unicode, many different systems, on different platforms, had been developed for encoding
characters for different languages, but no single encoding could satisfy all languages. Unicode provides
access to over 100,000 characters used in all the major languages written today, and is independent of
platform and language.
Unicode also provides higher-level concepts needed for text processing and typographic publishing
systems, such as algorithms for sorting and comparing text, composite character and text rendering, right-
to-left and bi-directional text handling.
There are currently no plans to add this extra functionality to FLTK.
ISO 10646

The International Organisation for Standardization (ISO) had also been trying to develop a single unified
character set. Although both ISO and the Unicode Consortium continue to publish their own standards,
they have agreed to coordinate their work so that specific versions of the Unicode and ISO 10646 standards
are compatible with each other.

109
110 CHAPTER 13. UNICODE AND UTF-8 SUPPORT

The international standard ISO 10646 defines the Universal Character Set (UCS) which contains the
characters required for almost all known languages. The standard also defines three different implementa-
tion levels specifying how these characters can be combined.
There are currently no plans for handling the different implementation levels or the combining charac-
ters in FLTK.
In UCS, characters have a unique numerical code and an official name, and are usually shown using
’U+’ and the code in hexadecimal, e.g. U+0041 is the ”Latin capital letter A”. The UCS characters U+0000
to U+007F correspond to US-ASCII, and U+0000 to U+00FF correspond to ISO 8859-1 (Latin1).
ISO 10646 was originally designed to handle a 31-bit character set from U+00000000 to U+7FFFFFFF,
but the current idea is that 21-bits will be sufficient for all future needs, giving characters up to U+10FFFF.
The complete character set is sub-divided into planes. Plane 0, also known as the Basic Multilingual
Plane (BMP), ranges from U+0000 to U+FFFD and consists of the most commonly used characters from
previous encoding standards. Other planes contain characters for specialist applications.
Todo Do we need this info about planes?
The UCS also defines various methods of encoding characters as a sequence of bytes. UCS-2 encodes
Unicode characters into two bytes, which is wasteful if you are only dealing with ASCII or Latin1 text, and
insufficient if you need characters above U+00FFFF. UCS-4 uses four bytes, which lets it handle higher
characters, but this is even more wasteful for ASCII or Latin1.
UTF-8

The Unicode standard defines various UCS Transformation Formats. UTF-16 and UTF-32 are based on
units of two and four bytes. UCS characters requiring more than 16 bits are encoded using ”surrogate
pairs” in UTF-16.
UTF-8 encodes all Unicode characters into variable length sequences of bytes. Unicode characters in
the 7-bit ASCII range map to the same value and are represented as a single byte, making the transformation
to Unicode quick and easy.
All UCS characters above U+007F are encoded as a sequence of several bytes. The top bits of the first
byte are set to show the length of the byte sequence, and subseqent bytes are always in the range 0x80 to
0x8F. This combination provides some level of synchronisation and error detection.
Unicode range Byte sequences
U+00000000 - U+0000007F 0xxxxxxx
U+00000080 - U+000007FF 110xxxxx 10xxxxxx
U+00000800 - U+0000FFFF 1110xxxx 10xxxxxx 10xxxxxx
U+00010000 - U+001FFFFF 11110xxx 10xxxxxx 10xxxxxx
10xxxxxx
U+00200000 - U+03FFFFFF 111110xx 10xxxxxx 10xxxxxx
10xxxxxx 10xxxxxx
U+04000000 - U+7FFFFFFF 1111110x 10xxxxxx 10xxxxxx
10xxxxxx 10xxxxxx 10xxxxxx
Moving from ASCII encoding to Unicode will allow all new FLTK applications to be easily interna-
tionalized and used all over the world. By choosing UTF-8 encoding, FLTK remains largely source-code
compatible to previous iterations of the library.

13.2 Unicode in FLTK


Todo Work through the code and this documentation to harmonize the [OksiD] and [fltk2] functions.

FLTK will be entirely converted to Unicode using UTF-8 encoding. If a different encoding is required
by the underlying operating system, FLTK will convert the string as needed.
It is important to note that the initial implementation of Unicode and UTF-8 in FLTK involves three
important areas:
13.3. ILLEGAL UNICODE AND UTF-8 SEQUENCES 111

• provision of Unicode character tables and some simple related functions;


• conversion of char∗ variables and function parameters from single byte per character representation
to UTF-8 variable length sequences;
• modifications to the display font interface to accept general Unicode character or UCS code numbers
instead of just ASCII or Latin1 characters.

The current implementation of Unicode / UTF-8 in FLTK will impose the following limitations:

• An implementation note in the [OksiD] code says that all functions are LIMITED to 24 bit Unicode
values, but also says that only 16 bits are really used under linux and win32. [Can we verify this?]
• The [fltk2] fl utf8encode() and fl utf8decode() functions are designed to handle Unicode characters
in the range U+000000 to U+10FFFF inclusive, which covers all UTF-16 characters, as specified in
RFC 3629. Note that the user must first convert UTF-16 surrogate pairs to UCS.
• FLTK will only handle single characters, so composed characters consisting of a base character and
floating accent characters will be treated as multiple characters;
• FLTK will only compare or sort strings on a byte by byte basis and not on a general Unicode character
basis;
• FLTK will not handle right-to-left or bi-directional text;

Todo Verify 16/24 bit Unicode limit for different character sets? OksiD’s code appears limited to 16-
bit whereas the FLTK2 code appears to handle a wider set. What about illegal characters? See
comments in fl utf8fromwc() and fl utf8toUtf16().

13.3 Illegal Unicode and UTF-8 sequences


Three pre-processor variables are defined in the source code that determine how fl utf8decode() handles
illegal UTF-8 sequences:

• if ERRORS TO CP1252 is set to 1 (the default), fl utf8decode() will assume that a byte sequence
starting with a byte in the range 0x80 to 0x9f represents a Microsoft CP1252 character, and will
instead return the value of an equivalent UCS character. Otherwise, it will be processed as an illegal
byte value as described below.
• if STRICT RFC3629 is set to 1 (not the default!) then UTF-8 sequences that correspond to illegal U-
CS values are treated as errors. Illegal UCS values include those above U+10FFFF, or corresponding
to UTF-16 surrogate pairs. Illegal byte values are handled as described below.
• if ERRORS TO ISO8859 1 is set to 1 (the default), the illegal byte value is returned unchanged,
otherwise 0xFFFD, the Unicode REPLACEMENT CHARACTER, is returned instead.

fl utf8encode() is less strict, and only generates the UTF-8 sequence for 0xFFFD, the Unicode REPL-
ACEMENT CHARACTER, if it is asked to encode a UCS value above U+10FFFF.
Many of the [fltk2] functions below use fl utf8decode() and fl utf8encode() in their own implementa-
tion, and are therefore somewhat protected from bad UTF-8 sequences.
The [OksiD] fl utf8len() function assumes that the byte it is passed is the first byte in a UTF-8 sequence,
and returns the length of the sequence. Trailing bytes in a UTF-8 sequence will return -1.

• WARNING: fl utf8len() can not distinguish between single bytes representing Microsoft CP1252
characters 0x80-0x9f and those forming part of a valid UTF-8 sequence. You are strongly advised
not to use fl utf8len() in your own code unless you know that the byte sequence contains only valid
UTF-8 sequences.
112 CHAPTER 13. UNICODE AND UTF-8 SUPPORT

• WARNING: Some of the [OksiD] functions below still use fl utf8len() in their implementations.
These may need further validation.

Please see the individual function description for further details about error handling and return values.

13.4 FLTK Unicode and UTF-8 functions


This section currently provides a brief overview of the functions. For more details, consult the main text
for each function via its link.
int fl utf8locale() FLTK2

fl utf8locale() returns true if the ”locale” seems to indicate that UTF-8 encoding is used.

It is highly recommended that you change your system so this does return true!

int fl utf8test(const char ∗src, unsigned len) FLTK2

fl utf8test() examines the first len bytes of src. It returns 0 if there are any illegal UTF-8
sequences; 1 if src contains plain ASCII or if len is zero; or 2, 3 or 4 to indicate the range of
Unicode characters found.

int fl utf nb char(const unsigned char ∗buf, int len) OksiD

Returns the number of UTF-8 characters in the first len bytes of buf.

int fl unichar to utf8 size(Fl Unichar)


int fl utf8bytes(unsigned ucs)

Returns the number of bytes needed to encode ucs in UTF-8.

int fl utf8len(char c) OksiD

If c is a valid first byte of a UTF-8 encoded character sequence, fl utf8len() will return the number
of bytes in that sequence. It returns -1 if c is not a valid first byte.

unsigned int fl nonspacing(unsigned int ucs) OksiD

Returns true if ucs is a non-spacing character. [What are non-spacing characters?]

const char∗ fl utf8back(const char ∗p, const char ∗start, const char ∗end) FLTK2
const char∗ fl utf8fwd(const char ∗p, const char ∗start, const char ∗end) FLTK2

If p already points to the start of a UTF-8 character sequence, these functions will return p. Otherwise
fl utf8back() searches backwards from p and fl utf8fwd() searches forwards from p, within
the start and end limits, looking for the start of a UTF-8 character.

unsigned int fl utf8decode(const char ∗p, const char ∗end, int ∗len) FLTK2
int fl utf8encode(unsigned ucs, char ∗buf) FLTK2
13.4. FLTK UNICODE AND UTF-8 FUNCTIONS 113

fl utf8decode() attempts to decode the UTF-8 character that starts at p and may not extend past
end. It returns the Unicode value, and the length of the UTF-8 character sequence is returned via
the len argument. fl utf8encode() writes the UTF-8 encoding of ucs into buf and returns the
number of bytes in the sequence. See the main documentation for the treatment of illegal Unicode and
UTF-8 sequences.

unsigned int fl utf8froma(char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen) FLTK2
unsigned int fl utf8toa(const char ∗src, unsigned srclen, char ∗dst, unsigned dstlen) FLTK2

fl utf8froma() converts a character string containing single bytes per character (i.e. ASCII or IS-
O-8859-1) into UTF-8. If the src string contains only ASCII characters, the return value will be the
same as srclen.

fl utf8toa() converts a string containing UTF-8 characters into single byte characters. UTF-8
characters that do not correspond to ASCII or ISO-8859-1 characters below 0xFF are replaced with
’?’.

Both functions return the number of bytes that would be written, not counting the null terminator.
destlen provides a means of limiting the number of bytes written, so setting destlen to zero is a
means of measuring how much storage would be needed before doing the real conversion.

char∗ fl utf2mbcs(const char ∗src) OksiD

converts a UTF-8 string to a local multi-byte character string. [More info required here!]

unsigned int fl utf8fromwc(char ∗dst, unsigned dstlen, const wchar t ∗src, unsigned srclen) FLTK2
unsigned int fl utf8towc(const char ∗src, unsigned srclen, wchar t ∗dst, unsigned dstlen) FLTK2
unsigned int fl utf8toUtf16(const char ∗src, unsigned srclen, unsigned short ∗dst, unsigned dstlen) FL-
TK2

These routines convert between UTF-8 and wchar t or ”wide character” strings. The difficulty lies
in the fact that sizeof(wchar t) is 2 on Windows and 4 on Linux and most other systems. There-
fore some ”wide characters” on Windows may be represented as ”surrogate pairs” of more than one
wchar t.

fl utf8fromwc() converts from a ”wide character” string to UTF-8. Note that srclen is the
number of wchar t elements in the source string and on Windows this might be larger than the
number of characters. dstlen specifies the maximum number of bytes to copy, including the null
terminator.

fl utf8towc() converts a UTF-8 string into a ”wide character” string. Note that on Windows, some
”wide characters” might result in ”surrogate pairs” and therefore the return value might be more than
the number of characters. dstlen specifies the maximum number of wchar t elements to copy,
including a zero terminating element. [Is this all worded correctly?]

fl utf8toUtf16() converts a UTF-8 string into a ”wide character” string using UTF-16 encoding
to handle the ”surrogate pairs” on Windows. dstlen specifies the maximum number of wchar t
elements to copy, including a zero terminating element. [Is this all worded correctly?]
114 CHAPTER 13. UNICODE AND UTF-8 SUPPORT

These routines all return the number of elements that would be required for a full conversion of the
src string, including the zero terminator. Therefore setting dstlen to zero is a way of measuring
how much storage would be needed before doing the real conversion.

unsigned int fl utf8from mb(char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen) FLTK2
unsigned int fl utf8to mb(const char ∗src, unsigned srclen, char ∗dst, unsigned dstlen) FLTK2

These functions convert between UTF-8 and the locale-specific multi-byte encodings used on some
systems for filenames, etc. If fl utf8locale() returns true, these functions don’t do anything useful. [Is
this all worded correctly?]

int fl tolower(unsigned int ucs) OksiD


int fl toupper(unsigned int ucs) OksiD
int fl utf tolower(const unsigned char ∗str, int len, char ∗buf) OksiD
int fl utf toupper(const unsigned char ∗str, int len, char ∗buf) OksiD

fl tolower() and fl toupper() convert a single Unicode character from upper to lower case, and
vice versa. fl utf tolower() and fl utf toupper() convert a string of bytes, some of which
may be multi-byte UTF-8 encodings of Unicode characters, from upper to lower case, and vice versa.

Warning: to be safe, buf length must be at least 3∗len [for 16-bit Unicode]

int fl utf strcasecmp(const char ∗s1, const char ∗s2) OksiD


int fl utf strncasecmp(const char ∗s1, const char ∗s2, int n) OksiD

fl utf strcasecmp() is a UTF-8 aware string comparison function that converts the strings to
lower case Unicode as part of the comparison. flt utf strncasecmp() only compares the first n
characters [bytes?]

13.5 FLTK Unicode versions of system calls


• int fl access(const char∗ f, int mode) OksiD

• int fl chmod(const char∗ f, int mode) OksiD

• int fl execvp(const char∗ file, char∗ const∗ argv) OksiD

• FILE∗ fl fopen(cont char∗ f, const char∗ mode) OksiD

• char∗ fl getcwd(char∗ buf, int maxlen) OksiD

• char∗ fl getenv(const char∗ name) OksiD

• char fl make path(const char∗ path) - returns char ? OksiD

• void fl make path for file(const char∗ path) OksiD

• int fl mkdir(const char∗ f, int mode) OksiD

• int fl open(const char∗ f, int o, ...) OksiD

• int fl rename(const char∗ f, const char∗ t) OksiD

• int fl rmdir(const char∗ f) OksiD


13.5. FLTK UNICODE VERSIONS OF SYSTEM CALLS 115

• int fl stat(const char∗ path, struct stat∗ buffer) OksiD


• int fl system(const char∗ f) OksiD

• int fl unlink(const char∗ f) OksiD


TODO:

• more doc on unicode, add links


• write something about filename encoding on OS X...

• explain the fl utf8 ... commands


• explain issues with Fl Preferences
• why FLTK has no Fl String class
116 CHAPTER 13. UNICODE AND UTF-8 SUPPORT
Chapter 14

FLTK Enumerations
Note
This file is not actively maintained any more, but is left here as a reference, until the doxygen docu-
mentation is completed.

See Also
FL/Enumerations.H.

This appendix lists the enumerations provided in the <FL/Enumerations.H> header file, organized by
section. Constants whose value are zero are marked with ”(0)”, this is often useful to know when program-
ming.

14.1 Version Numbers


The FLTK version number is stored in a number of compile-time constants:

• FL MAJOR VERSION - The major release number, currently 1

• FL MINOR VERSION - The minor release number, currently 3

• FL PATCH VERSION - The patch release number, currently 3

• FL VERSION - A combined floating-point version number for the major, minor, and patch release
numbers, currently 1.0303

14.2 Events
Events are identified by an Fl Event enumeration value. The following events are currently defined:

• FL NO EVENT - No event (or an event fltk does not understand) occurred (0).

• FL PUSH - A mouse button was pushed.

• FL RELEASE - A mouse button was released.

• FL ENTER - The mouse pointer entered a widget.

• FL LEAVE - The mouse pointer left a widget.

• FL DRAG - The mouse pointer was moved with a button pressed.

117
118 CHAPTER 14. FLTK ENUMERATIONS

• FL FOCUS - A widget should receive keyboard focus.

• FL UNFOCUS - A widget loses keyboard focus.

• FL KEYBOARD - A key was pressed.

• FL CLOSE - A window was closed.

• FL MOVE - The mouse pointer was moved with no buttons pressed.

• FL SHORTCUT - The user pressed a shortcut key.

• FL DEACTIVATE - The widget has been deactivated.

• FL ACTIVATE - The widget has been activated.

• FL HIDE - The widget has been hidden.

• FL SHOW - The widget has been shown.

• FL PASTE - The widget should paste the contents of the clipboard.

• FL SELECTIONCLEAR - The widget should clear any selections made for the clipboard.

• FL MOUSEWHEEL - The horizontal or vertical mousewheel was turned.

• FL DND ENTER - The mouse pointer entered a widget dragging data.

• FL DND DRAG - The mouse pointer was moved dragging data.

• FL DND LEAVE - The mouse pointer left a widget still dragging data.

• FL DND RELEASE - Dragged data is about to be dropped.

• FL SCREEN CONFIGURATION CHANGED - The screen configuration (number, positions) was


changed.

• FL FULLSCREEN - The fullscreen state of the window has changed.

14.3 Callback ”When” Conditions


The following constants determine when a callback is performed:

• FL WHEN NEVER - Never call the callback (0).

• FL WHEN CHANGED - Do the callback only when the widget value changes.

• FL WHEN NOT CHANGED - Do the callback whenever the user interacts with the widget.

• FL WHEN RELEASE - Do the callback when the button or key is released and the value changes.

• FL WHEN ENTER KEY - Do the callback when the user presses the ENTER key and the value
changes.

• FL WHEN RELEASE ALWAYS - Do the callback when the button or key is released, even if the
value doesn’t change.

• FL WHEN ENTER KEY ALWAYS - Do the callback when the user presses the ENTER key, even
if the value doesn’t change.
14.4. FL::EVENT BUTTON() VALUES 119

14.4 Fl::event button() Values


The following constants define the button numbers for FL PUSH and FL RELEASE events:

• FL LEFT MOUSE - the left mouse button

• FL MIDDLE MOUSE - the middle mouse button

• FL RIGHT MOUSE - the right mouse button

14.5 Fl::event key() Values


The following constants define the non-ASCII keys on the keyboard for FL KEYBOARD and FL SHOR-
TCUT events:

• FL Button - A mouse button; use Fl Button + n for mouse button n.

• FL BackSpace - The backspace key.

• FL Tab - The tab key.

• FL Enter - The enter key.

• FL Pause - The pause key.

• FL Scroll Lock - The scroll lock key.

• FL Escape - The escape key.

• FL Home - The home key.

• FL Left - The left arrow key.

• FL Up - The up arrow key.

• FL Right - The right arrow key.

• FL Down - The down arrow key.

• FL Page Up - The page-up key.

• FL Page Down - The page-down key.

• FL End - The end key.

• FL Print - The print (or print-screen) key.

• FL Insert - The insert key.

• FL Menu - The menu key.

• FL Num Lock - The num lock key.

• FL KP - One of the keypad numbers; use FL KP + n for number n.

• FL KP Enter - The enter key on the keypad.

• FL F - One of the function keys; use FL F + n for function key n.

• FL Shift L - The lefthand shift key.

• FL Shift R - The righthand shift key.


120 CHAPTER 14. FLTK ENUMERATIONS

• FL Control L - The lefthand control key.

• FL Control R - The righthand control key.

• FL Caps Lock - The caps lock key.

• FL Meta L - The left meta/Windows key.

• FL Meta R - The right meta/Windows key.

• FL Alt L - The left alt key.

• FL Alt R - The right alt key.

• FL Delete - The delete key.

14.6 Fl::event state() Values


The following constants define bits in the Fl::event state() value:

• FL SHIFT - One of the shift keys is down.

• FL CAPS LOCK - The caps lock is on.

• FL CTRL - One of the ctrl keys is down.

• FL ALT - One of the alt keys is down.

• FL NUM LOCK - The num lock is on.

• FL META - One of the meta/Windows keys is down.

• FL COMMAND - An alias for FL CTRL on WIN32 and X11, or FL META on MacOS X.

• FL SCROLL LOCK - The scroll lock is on.

• FL BUTTON1 - Mouse button 1 is pushed.

• FL BUTTON2 - Mouse button 2 is pushed.

• FL BUTTON3 - Mouse button 3 is pushed.

• FL BUTTONS - Any mouse button is pushed.

• FL BUTTON(n) - Mouse button n ( where n > 0) is pushed.

14.7 Alignment Values


The following constants define bits that can be used with Fl Widget::align() to control the positioning of
the label:

• FL ALIGN CENTER - The label is centered (0).

• FL ALIGN TOP - The label is top-aligned.

• FL ALIGN BOTTOM - The label is bottom-aligned.

• FL ALIGN LEFT - The label is left-aligned.

• FL ALIGN RIGHT - The label is right-aligned.


14.8. FONTS 121

• FL ALIGN CLIP - The label is clipped to the widget.

• FL ALIGN WRAP - The label text is wrapped as needed.

• FL ALIGN TOP LEFT - The label appears at the top of the widget, aligned to the left.

• FL ALIGN TOP RIGHT - The label appears at the top of the widget, aligned to the right.

• FL ALIGN BOTTOM LEFT - The label appears at the bottom of the widget, aligned to the left.

• FL ALIGN BOTTOM RIGHT - The label appears at the bottom of the widget, aligned to the right.

• FL ALIGN LEFT TOP - The label appears to the left of the widget, aligned at the top. Outside
labels only.

• FL ALIGN RIGHT TOP - The label appears to the right of the widget, aligned at the top. Outside
labels only.

• FL ALIGN LEFT BOTTOM - The label appears to the left of the widget, aligned at the bottom.
Outside labels only.

• FL ALIGN RIGHT BOTTOM - The label appears to the right of the widget, aligned at the bottom.
Outside labels only.

• FL ALIGN INSIDE - ’or’ this with other values to put label inside the widget.

• FL ALIGN TEXT OVER IMAGE - Label text will appear above the image.

• FL ALIGN IMAGE OVER TEXT - Label text will be below the image.

• FL ALIGN IMAGE NEXT TO TEXT - The image will appear to the left of the text.

• FL ALIGN TEXT NEXT TO IMAGE - The image will appear to the right of the text.

• FL ALIGN IMAGE BACKDROP - The image will be used as a background for the widget.

14.8 Fonts
The following constants define the standard FLTK fonts:

• FL HELVETICA - Helvetica (or Arial) normal (0).

• FL HELVETICA BOLD - Helvetica (or Arial) bold.

• FL HELVETICA ITALIC - Helvetica (or Arial) oblique.

• FL HELVETICA BOLD ITALIC - Helvetica (or Arial) bold-oblique.

• FL COURIER - Courier normal.

• FL COURIER BOLD - Courier bold.

• FL COURIER ITALIC - Courier italic.

• FL COURIER BOLD ITALIC - Courier bold-italic.

• FL TIMES - Times roman.

• FL TIMES BOLD - Times bold.

• FL TIMES ITALIC - Times italic.


122 CHAPTER 14. FLTK ENUMERATIONS

• FL TIMES BOLD ITALIC - Times bold-italic.

• FL SYMBOL - Standard symbol font.

• FL SCREEN - Default monospaced screen font.

• FL SCREEN BOLD - Default monospaced bold screen font.

• FL ZAPF DINGBATS - Zapf-dingbats font.

14.9 Colors
The Fl Color enumeration type holds a FLTK color value. Colors are either 8-bit indexes into a virtual
colormap or 24-bit RGB color values. Color indices occupy the lower 8 bits of the value, while RGB
colors occupy the upper 24 bits, for a byte organization of RGBI.

14.9.1 Color Constants


Constants are defined for the user-defined foreground and background colors, as well as specific colors and
the start of the grayscale ramp and color cube in the virtual colormap. Inline functions are provided to
retrieve specific grayscale, color cube, or RGB color values.
The following color constants can be used to access the user-defined colors:

• FL BACKGROUND COLOR - the default background color

• FL BACKGROUND2 COLOR - the default background color for text, list, and valuator widgets

• FL FOREGROUND COLOR - the default foreground color (0) used for labels and text

• FL INACTIVE COLOR - the inactive foreground color

• FL SELECTION COLOR - the default selection/highlight color

The following color constants can be used to access the colors from the FLTK standard color cube:

• FL BLACK

• FL BLUE

• FL CYAN

• FL DARK BLUE

• FL DARK CYAN

• FL DARK GREEN

• FL DARK MAGENTA

• FL DARK RED

• FL DARK YELLOW

• FL GREEN

• FL MAGENTA

• FL RED

• FL WHITE
14.10. CURSORS 123

• FL YELLOW

The following are named values within the standard grayscale:

• FL GRAY0

• FL DARK3

• FL DARK2

• FL DARK1

• FL LIGHT1

• FL LIGHT2

• FL LIGHT3

The inline methods for getting a grayscale, color cube, or RGB color value are described in the Colors
section of the Drawing Things in FLTK chapter.

14.10 Cursors
The following constants define the mouse cursors that are available in FLTK. The double-headed arrows
are bitmaps provided by FLTK on X, the others are provided by system-defined cursors.

• FL CURSOR DEFAULT - the default cursor, usually an arrow (0)

• FL CURSOR ARROW - an arrow pointer

• FL CURSOR CROSS - crosshair

• FL CURSOR WAIT - watch or hourglass

• FL CURSOR INSERT - I-beam

• FL CURSOR HAND - hand (uparrow on MSWindows)

• FL CURSOR HELP - question mark

• FL CURSOR MOVE - 4-pointed arrow

• FL CURSOR NS - up/down arrow

• FL CURSOR WE - left/right arrow

• FL CURSOR NWSE - diagonal arrow

• FL CURSOR NESW - diagonal arrow

• FL CURSOR NONE - invisible

14.11 FD ”When” Conditions


• FL READ - Call the callback when there is data to be read.

• FL WRITE - Call the callback when data can be written without blocking.

• FL EXCEPT - Call the callback if an exception occurs on the file.


124 CHAPTER 14. FLTK ENUMERATIONS

14.12 Damage Masks


The following damage mask bits are used by the standard FLTK widgets:

• FL DAMAGE CHILD - A child needs to be redrawn.

• FL DAMAGE EXPOSE - The window was exposed.


• FL DAMAGE SCROLL - The Fl Scroll widget was scrolled.
• FL DAMAGE OVERLAY - The overlay planes need to be redrawn.
• FL DAMAGE USER1 - First user-defined damage bit.

• FL DAMAGE USER2 - Second user-defined damage bit.


• FL DAMAGE ALL - Everything needs to be redrawn.
Chapter 15

GLUT Compatibility

This appendix describes the GLUT compatibility header file supplied with FLTK.
FLTK’s GLUT compatibility is based on the original GLUT 3.7 and the follow-on FreeGLUT 2.4.0
libraries.

15.1 Using the GLUT Compatibility Header File


You should be able to compile existing GLUT source code by including <FL/glut.H> instead of <G-
L/glut.h>. This can be done by editing the source, by changing the -I switches to the compiler, or by
providing a symbolic link from GL/glut.h to FL/glut.H.
All files calling GLUT procedures must be compiled with C++. You may have to alter them slightly
to get them to compile without warnings, and you may have to rename them to get make to use the C++
compiler.
You must link with the FLTK library. Most of FL/glut.H is inline functions. You should take a look
at it (and maybe at test/glpuzzle.cxx in the FLTK source) if you are having trouble porting your
GLUT program.
This has been tested with most of the demo programs that come with the GLUT and FreeGLUT distri-
butions.

15.2 Known Problems


The following functions and/or arguments to functions are missing, and you will have to replace them or
comment them out for your code to compile:

• glutGet(GLUT ELAPSED TIME)

• glutGet(GLUT SCREEN HEIGHT MM)

• glutGet(GLUT SCREEN WIDTH MM)

• glutGet(GLUT WINDOW NUM CHILDREN)

• glutInitDisplayMode(GLUT LUMINANCE)

• glutLayerGet(GLUT HAS OVERLAY)

• glutLayerGet(GLUT LAYER IN USE)

• glutPushWindow()

• glutSetColor(), glutGetColor(), glutCopyColormap()

125
126 CHAPTER 15. GLUT COMPATIBILITY

• glutVideoResize() missing.
• glutWarpPointer()
• glutWindowStatusFunc()
• Spaceball, buttonbox, dials, and tablet functions

Most of the symbols/enumerations have different values than GLUT uses. This will break code that relies
on the actual values. The only symbols guaranteed to have the same values are true/false pairs like GLUT-
DOWN and GLUT UP, mouse buttons GLUT LEFT BUTTON, GLUT MIDDLE BUTTON, GLUT R-
IGHT BUTTON, and GLUT KEY F1 thru GLUT KEY F12.
The strings passed as menu labels are not copied.
glutPostRedisplay() does not work if called from inside a display function. You must use
glutIdleFunc() if you want your display to update continuously.
glutSwapBuffers() does not work from inside a display function. This is on purpose, because
FLTK swaps the buffers for you.
glutUseLayer() does not work well, and should only be used to initialize transformations inside a
resize callback. You should redraw overlays by using glutOverlayDisplayFunc().
Overlays are cleared before the overlay display function is called. glutLayerGet(GLUT OVERLA-
Y DAMAGED) always returns true for compatibility with some GLUT overlay programs. You must rewrite
your code so that gl color() is used to choose colors in an overlay, or you will get random overlay
colors.
glutSetCursor(GLUT CURSOR FULL CROSSHAIR) just results in a small crosshair.
The fonts used by glutBitmapCharacter() and glutBitmapWidth() may be different.
glutInit(argc,argv) will consume different switches than GLUT does. It accepts the switches
recognized by Fl::args(), and will accept any abbreviation of these switches (such as ”-di” for ”-display”).

15.3 Mixing GLUT and FLTK Code


You can make your GLUT window a child of a Fl Window with the following scheme. The biggest trick is
that GLUT insists on a call to show() the window at the point it is created, which means the Fl Window
parent window must already be shown.

• Don’t call glutInit().


• Create your Fl Window, and any FLTK widgets. Leave a blank area in the window for your GLUT
window.
• show() the Fl Window. Perhaps call show(argc,argv).
• Call window->begin() so that the GLUT window will be automatically added to it.
• Use glutInitWindowSize() and glutInitWindowPosition() to set the location in the
parent window to put the GLUT window.
• Put your GLUT code next. It probably does not need many changes. Call window->end()
immediately after the glutCreateWindow()!
• You can call either glutMainLoop(), Fl::run(), or loop calling Fl::wait() to run the program.

15.4 class Fl Glut Window


15.4.1 Class Hierarchy
Fl Gl Window
|
+----Fl Glut Window
15.4. CLASS FL GLUT WINDOW 127

15.4.2 Include Files


#include <FL/glut.H>

15.4.3 Description
Each GLUT window is an instance of this class. You may find it useful to manipulate instances directly
rather than use GLUT window id’s. These may be created without opening the display, and thus can fit
better into FLTK’s method of creating windows.
The current GLUT window is available in the global variable glut window.
new Fl Glut Window(...) is the same as glutCreateWindow() except it does not show()
the window or make the window current.
window->make current() is the same as glutSetWindow(number). If the window has not
had show() called on it yet, some functions that assume an OpenGL context will not work. If you do
show() the window, call make current() again to set the context.
∼Fl Glut Window() is the same as glutDestroyWindow().

15.4.4 Members
The Fl Glut Window class contains several public members that can be altered directly:

member description
display A pointer to the function to call to draw the
normal planes.
entry A pointer to the function to call when the mouse
moves into or out of the window.
keyboard A pointer to the function to call when a regular
key is pressed.
menu[3] The menu to post when one of the mouse buttons
is pressed.
mouse A pointer to the function to call when a button is
pressed or released.
motion A pointer to the function to call when the mouse
is moved with a button down.
overlaydisplay A pointer to the function to call to draw the
overlay planes.
passivemotion A pointer to the function to call when the mouse
is moved with no buttons down.
reshape A pointer to the function to call when the window
is resized.
special A pointer to the function to call when a special
key is pressed.
visibility A pointer to the function to call when the window
is iconified or restored (made visible.)

15.4.5 Methods
Fl Glut Window::Fl Glut Window(int x, int y, int w, int h, const char ∗title = 0)
Fl Glut Window::Fl Glut Window(int w, int h, const char ∗title = 0)

The first constructor takes 4 int arguments to create the window with a preset position and size. The
second constructor with 2 arguments will create the window with a preset size, but the window manager
will choose the position according to its own whims.

virtual Fl Glut Window::∼Fl Glut Window()


128 CHAPTER 15. GLUT COMPATIBILITY

Destroys the GLUT window.

void Fl Glut Window::make current()

Switches all drawing functions to the GLUT window.


Chapter 16

Forms Compatibility

This appendix describes the Forms compatibility included with FLTK.

Warning: The Forms compatility is deprecated and no longer maintained in FLTK1, and is
likely to be removed completely after the next official release.

16.1 Importing Forms Layout Files


FLUID can read the .fd files put out by all versions of Forms and XForms fdesign. However, it will
mangle them a bit, but it prints a warning message about anything it does not understand. FLUID cannot
write fdesign files, so you should save to a new name so you don’t write over the old one.
You will need to edit your main code considerably to get it to link with the output from FLUID. If
you are not interested in this you may have more immediate luck with the forms compatibility header,
<FL/forms.H>.

16.2 Using the Compatibility Header File


You should be able to compile existing Forms or XForms source code by changing the include directory
switch to your compiler so that the forms.h file supplied with FLTK is included. The forms.h file
simply pulls in <FL/forms.H> so you don’t need to change your source code. Take a look at <FL/forms.-
H> to see how it works, but the basic trick is lots of inline functions. Most of the XForms demo programs
work without changes.
You will also have to compile your Forms or XForms program using a C++ compiler. The FLTK library
does not provide C bindings or header files.
Although FLTK was designed to be compatible with the GL Forms library (version 0.3 or so), XForms
has bloated severely and its interface is X-specific. Therefore, XForms compatibility is no longer a goal of
FLTK. Compatibility was limited to things that were free, or that would add code that would not be linked
in if the feature is unused, or that was not X-specific.
To use any new features of FLTK, you should rewrite your code to not use the inline functions and
instead use ”pure” FLTK. This will make it a lot cleaner and make it easier to figure out how to call the
FLTK functions. Unfortunately this conversion is harder than expected and even Digital Domain’s inhouse
code still uses forms.H a lot.

16.3 Problems You Will Encounter


Many parts of XForms use X-specific structures like XEvent in their interface. I did not emulate these!
Unfortunately these features (such as the ”canvas” widget) are needed by most large programs. You will
need to rewrite these to use FLTK subclasses.

129
130 CHAPTER 16. FORMS COMPATIBILITY

Fl Free widgets emulate the old Forms ”free” widget. It may be useful for porting programs that change
the handle() function on widgets, but you will still need to rewrite things.
Fl Timer widgets are provided to emulate the XForms timer. These work, but are quite inefficient and
inaccurate compared to using Fl::add timeout().
All instance variables are hidden. If you directly refer to the x, y, w, h, label, or other fields of your
Forms widgets you will have to add empty parenthesis after each reference. The easiest way to do this is
to globally replace "->x" with "->x()", etc. Replace "boxtype" with "box()".
const char ∗ arguments to most FLTK methods are simply stored, while Forms would strdup()
the passed string. This is most noticeable with the label of widgets. Your program must always pass static
data such as a string constant or malloc’d buffer to label(). If you are using labels to display program
output you may want to try the Fl Output widget.
The default fonts and sizes are matched to the older GL version of Forms, so all labels will draw
somewhat larger than an XForms program does.
fdesign outputs a setting of a ”fdui” instance variable to the main window. I did not emulate this because
I wanted all instance variables to be hidden. You can store the same information in the user data()
field of a window. To do this, search through the fdesign output for all occurrences of "->fdui" and edit
to use "->user data()" instead. This will require casts and is not trivial.
The prototype for the functions passed to fl add timeout() and fl set idle callback()
callback are different.
All the following XForms calls are missing:

• FL REVISION, fl library version()


• FL RETURN DBLCLICK (use Fl::event clicks())
• fl add signal callback()
• fl set form atactivate() fl set form atdeactivate()
• fl set form property()
• fl set app mainform(), fl get app mainform()
• fl set form minsize(), fl set form maxsize()
• fl set form event cmask(), fl get form event cmask()
• fl set form dblbuffer(), fl set object dblbuffer() (use an Fl Double Window in-
stead)
• fl adjust form size()
• fl register raw callback()
• fl set object bw(), fl set border width()
• fl set object resize(), fl set object gravity()
• fl set object shortcutkey()
• fl set object automatic()
• fl get object bbox() (maybe FLTK should do this)
• fl set object prehandler(), fl set object posthandler()
• fl enumerate fonts()
• Most drawing functions
• fl set coordunit() (FLTK uses pixels all the time)
16.4. ADDITIONAL NOTES 131

• fl ringbell()

• fl gettime()

• fl win∗() (all these functions)

• fl initialize(argc,argv,x,y,z) ignores last 3 arguments

• fl read bitmapfile(), fl read pixmapfile()

• fl addto browser chars()

• FL MENU BUTTON just draws normally

• fl set bitmapbutton file(), fl set pixmapbutton file()

• FL CANVAS objects

• FL DIGITAL CLOCK (comes out analog)

• fl create bitmap cursor(), fl set cursor color()

• fl set dial angles()

• fl show oneliner()

• fl set choice shortcut(a,b,c)

• command log

• Only some of file selector is emulated

• FL DATE INPUT

• fl pup∗() (all these functions)

• textbox object (should be easy but I had no sample programs)

• xyplot object

16.4 Additional Notes


These notes were written for porting programs written with the older IRISGL version of Forms. Most of
these problems are the same ones encountered when going from old Forms to XForms:

Does Not Run In Background

The IRISGL library always forked when you created the first window, unless ”foreground()” was called.
FLTK acts like ”foreground()” is called all the time. If you really want the fork behavior do ”if (fork())
exit(0)” right at the start of your program.

You Cannot Use IRISGL Windows or fl queue


132 CHAPTER 16. FORMS COMPATIBILITY

If a Forms (not XForms) program if you wanted your own window for displaying things you would create
a IRISGL window and draw in it, periodically calling Forms to check if the user hit buttons on the panels.
If the user did things to the IRISGL window, you would find this out by having the value FL EVENT
returned from the call to Forms.
None of this works with FLTK. Nor will it compile, the necessary calls are not in the interface.
You have to make a subclass of Fl Gl Window and write a draw() method and handle() method.
This may require anywhere from a trivial to a major rewrite.
If you draw into the overlay planes you will have to also write a draw overlay() method and call
redraw overlay() on the OpenGL window.
One easy way to hack your program so it works is to make the draw() and handle() methods
on your window set some static variables, storing what event happened. Then in the main loop of your
program, call Fl::wait() and then check these variables, acting on them as though they are events read from
fl queue.

You Must Use OpenGL to Draw Everything

The file <FL/gl.h> defines replacements for a lot of IRISGL calls, translating them to OpenGL. There are
much better translators available that you might want to investigate.

You Cannot Make Forms Subclasses

Programs that call fl make object or directly setting the handle routine will not compile. You have
to rewrite them to use a subclass of Fl Widget. It is important to note that the handle() method is not
exactly the same as the handle() function of Forms. Where a Forms handle() returned non-zero, your
handle() must call do callback(). And your handle() must return non-zero if it ”understood”
the event.
An attempt has been made to emulate the ”free” widget. This appears to work quite well. It may be
quicker to modify your subclass into a ”free” widget, since the ”handle” functions match.
If your subclass draws into the overlay you are in trouble and will have to rewrite things a lot.

You Cannot Use <device.h>

If you have written your own ”free” widgets you will probably get a lot of errors about ”getvaluator”. You
should substitute:

Forms FLTK
MOUSE X Fl::event x root()
MOUSE Y Fl::event y root()
LEFTSHIFTKEY,RIGHTSHIFTKEY Fl::event shift()
CAPSLOCKKEY Fl::event capslock()
LEFTCTRLKEY,RIGHTCTRLKEY Fl::event ctrl()
LEFTALTKEY,RIGHTALTKEY Fl::event alt()
MOUSE1,RIGHTMOUSE Fl::event state()
MOUSE2,MIDDLEMOUSE Fl::event state()
MOUSE3,LEFTMOUSE Fl::event state()

Anything else in getvaluator and you are on your own...

Font Numbers Are Different


16.4. ADDITIONAL NOTES 133

The ”style” numbers have been changed because I wanted to insert bold-italic versions of the normal fonts.
If you use Times, Courier, or Bookman to display any text you will get a different font out of FLTK. If you
are really desperate to fix this use the following code:
fl font name(3,"*courier-medium-r-no*");
fl font name(4,"*courier-bold-r-no*");
fl font name(5,"*courier-medium-o-no*");
fl font name(6,"*times-medium-r-no*");
fl font name(7,"*times-bold-r-no*");
fl font name(8,"*times-medium-i-no*");
fl font name(9,"*bookman-light-r-no*");
fl font name(10,"*bookman-demi-r-no*");
fl font name(11,"*bookman-light-i-no*");
134 CHAPTER 16. FORMS COMPATIBILITY
Chapter 17

Operating System Issues

This appendix describes the operating system specific interfaces in FLTK:

• Accessing the OS Interfaces


• The UNIX (X11) Interface
• The Windows (WIN32) Interface
• The Apple OS X Interface

17.1 Accessing the OS Interfaces


All programs that need to access the operating system specific interfaces must include the following header
file:
#include <FL/x.H>

Despite the name, this header file will define the appropriate interface for your environment. The pages
that follow describe the functionality that is provided for each operating system.

WARNING:
The interfaces provided by this header file may change radically in new FLTK releases. Use them only
when an existing generic FLTK interface is not sufficient.

17.2 The UNIX (X11) Interface


The UNIX interface provides access to the X Window System state information and data structures.

17.2.1 Handling Other X Events


void Fl::add handler(int (∗f)(int))

Installs a function to parse unrecognized events. If FLTK cannot figure out what to do with an event,
it calls each of these functions (most recent first) until one of them returns non-zero. If none of them
returns non-zero then the event is ignored.

FLTK calls this for any X events it does not recognize, or X events with a window ID that FLTK does
not recognize. You can look at the X event in the fl xevent variable.

135
136 CHAPTER 17. OPERATING SYSTEM ISSUES

The argument is the FLTK event type that was not handled, or zero for unrecognized X events. These
handlers are also called for global shortcuts and some other events that the widget they were passed to
did not handle, for example FL SHORTCUT.

extern XEvent ∗fl xevent

This variable contains the most recent X event.

extern ulong fl event time

This variable contains the time stamp from the most recent X event that reported it; not all events do.
Many X calls like cut and paste need this value.

Window fl xid(const Fl Window ∗)

Returns the XID for a window, or zero if not shown().

Fl Window ∗fl find(ulong xid)

Returns the Fl Window that corresponds to the given XID, or NULL if not found. This function uses a
cache so it is slightly faster than iterating through the windows yourself.

int fl handle(const XEvent &)

This call allows you to supply the X events to FLTK, which may allow FLTK to cooperate with another
toolkit or library. The return value is non-zero if FLTK understood the event. If the window does not
belong to FLTK and the add handler() functions all return 0, this function will return false.

Besides feeding events your code should call Fl::flush() periodically so that FLTK redraws its win-
dows.

This function will call the callback functions. It will not return until they complete. In particular, if
a callback pops up a modal window by calling fl ask(), for instance, it will not return until the modal
function returns.

17.2.2 Drawing using Xlib


The following global variables are set before Fl Widget::draw() is called, or by Fl Window::make current()-
:
extern Display *fl display;
extern Window fl window;
extern GC fl gc;
extern int fl screen;
extern XVisualInfo *fl visual;
extern Colormap fl colormap;

You must use them to produce Xlib calls. Don’t attempt to change them. A typical X drawing call is
written like this:
XDrawSomething(fl display, fl window, fl gc, ...);

Other information such as the position or size of the X window can be found by looking at Fl Window-
::current(), which returns a pointer to the Fl Window being drawn.
unsigned long fl xpixel(Fl Color i)
unsigned long fl xpixel(uchar r, uchar g, uchar b)
17.2. THE UNIX (X11) INTERFACE 137

Returns the X pixel number used to draw the given FLTK color index or RGB color. This is the X
pixel that fl color() would use.

int fl parse color(const char∗ p, uchar& r, uchar& g, uchar& b)

Convert a name into the red, green, and blue values of a color by parsing the X11 color names. On
other systems, fl parse color() can only convert names in hexadecimal encoding, for example
#ff8083.

extern XFontStruct ∗fl xfont

Points to the font selected by the most recent fl font(). This is not necessarily the current font of fl -
gc, which is not set until fl draw() is called. If FLTK was compiled with Xft support, fl xfont will
usually be 0 and fl xftfont will contain a pointer to the XftFont structure instead.

extern void ∗fl xftfont

If FLTK was compiled with Xft support enabled, fl xftfont points to the xft font selected by the
most recent fl font(). Otherwise it will be 0. fl xftfont should be cast to XftFont∗.

17.2.3 Changing the Display, Screen, or X Visual


FLTK uses only a single display, screen, X visual, and X colormap. This greatly simplifies its internal
structure and makes it much smaller and faster. You can change which it uses by setting global variables
before the first Fl Window::show() is called. You may also want to call Fl::visual(), which is a portable
interface to get a full color and/or double buffered visual.
int Fl::display(const char ∗)

Set which X display to use. This actually does putenv("DISPLAY=...") so that child programs
will display on the same screen if called with exec(). This must be done before the display is opened.
This call is provided under MacOS and WIN32 but it has no effect.

extern Display ∗fl display

The open X display. This is needed as an argument to most Xlib calls. Don’t attempt to change it!
This is NULL before the display is opened.

void fl open display()

Opens the display. Does nothing if it is already open. This will make sure fl display is non-zero.
You should call this if you wish to do X calls and there is a chance that your code will be called before
the first show() of a window.

This may call Fl::abort() if there is an error opening the display.

void fl close display()

This closes the X connection. You do not need to call this to exit, and in fact it is faster to not do so! It
may be useful to call this if you want your program to continue without the X connection. You cannot
open the display again, and probably cannot call any FLTK functions.
138 CHAPTER 17. OPERATING SYSTEM ISSUES

extern int fl screen

Which screen number to use. This is set by fl open display() to the default screen. You can
change it by setting this to a different value immediately afterwards. It can also be set by changing the
last number in the Fl::display() string to ”host:0.#”.

extern XVisualInfo ∗fl visual


extern Colormap fl colormap

The visual and colormap that FLTK will use for all windows. These are set by fl open display()
to the default visual and colormap. You can change them before calling show() on the first window.
Typical code for changing the default visual is:
Fl::args(argc, argv); // do this first so $DISPLAY is set
fl open display();
fl visual = find a good visual(fl display, fl screen);
if (!fl visual) Fl::abort("No good visual");
fl colormap = make a colormap(fl display, fl visual->visual, fl visual->depth);
// it is now ok to show() windows:
window->show(argc, argv);

17.2.4 Using a Subclass of Fl Window for Special X Stuff


FLTK can manage an X window on a different screen, visual and/or colormap, you just can’t use FLTK’s
drawing routines to draw into it. But you can write your own draw() method that uses Xlib (and/or
OpenGL) calls only.
FLTK can also manage XID’s provided by other libraries or programs, and call those libraries when
the window needs to be redrawn.
To do this, you need to make a subclass of Fl Window and override some of these virtual functions:
virtual void Fl Window::show()

If the window is already shown() this must cause it to be raised, this can usually be done by calling
Fl Window::show(). If not shown() your implementation must call either Fl X::set xid() or Fl X-
::make xid().

An example:
void MyWindow::show() {
if (shown()) {Fl Window::show(); return;} // you must do this!
fl open display(); // necessary if this is first window
// we only calculate the necessary visual colormap once:
static XVisualInfo *visual;
static Colormap colormap;
if (!visual) {
visual = figure out visual();
colormap = XCreateColormap(fl display, RootWindow(fl display,fl screen),
vis->visual, AllocNone);
}
Fl X::make xid(this, visual, colormap);
}

Fl_X *Fl_X::set_xid(Fl_Window*, Window xid)

Allocate a hidden class called an Fl X, put the XID into it, and set a pointer to it from the Fl Window.
This causes Fl Window::shown() to return true.

void Fl X::make xid(Fl Window∗, XVisualInfo∗ = fl visual, Colormap = fl colormap)

This static method does the most onerous parts of creating an X window, including setting the label,
resize limitations, etc. It then does Fl X::set xid() with this new window and maps the window.
17.2. THE UNIX (X11) INTERFACE 139

virtual void Fl Window::flush()

This virtual function is called by Fl::flush() to update the window. For FLTK’s own windows it does
this by setting the global variables fl window and fl gc and then calling the draw() method. For
your own windows you might just want to put all the drawing code in here.

The X region that is a combination of all damage() calls done so far is in Fl X::i(this)->region.
If NULL then you should redraw the entire window. The undocumented function fl clip region(-
XRegion) will initialize the FLTK clip stack with a region or NULL for no clipping. You must set
region to NULL afterwards as fl clip region() will own and delete it when done.

If damage() & FL DAMAGE EXPOSE then only X expose events have happened. This may be
useful if you have an undamaged image (such as a backing buffer) around.

Here is a sample where an undamaged image is kept somewhere:


void MyWindow::flush() {
fl clip region(Fl X::i(this)->region);
Fl X::i(this)->region = 0;
if (damage() != 2) {... draw things into backing store ...}
... copy backing store to window ...
}

virtual void Fl Window::hide()

Destroy the window server copy of the window. Usually you will destroy contexts, pixmaps, or other
resources used by the window, and then call Fl Window::hide() to get rid of the main window identified
by xid(). If you override this, you must also override the destructor as shown:
void MyWindow::hide() {
if (mypixmap) {
XFreePixmap(fl display,mypixmap);
mypixmap = 0;
}
Fl Window::hide(); // you must call this
}

virtual void Fl Window::∼Fl Window()

Because of the way C++ works, if you override hide() you must override the destructor as well
(otherwise only the base class hide() is called):
MyWindow::˜MyWindow() {
hide();
}

Note
Access to the Fl X hidden class requires to #define FL INTERNALS before compilation.

17.2.5 Setting the Icon of a Window


FLTK currently supports setting a window’s icon before it is shown using the Fl Window::icon() method.
void Fl Window::icon(const void ∗)

Sets the icon for the window to the passed pointer. You will need to cast the icon Pixmap to a char∗
when calling this method. To set a monochrome icon using a bitmap compiled with your application
use:
140 CHAPTER 17. OPERATING SYSTEM ISSUES

#include "icon.xbm"

fl open display(); // needed if display has not been previously opened

Pixmap p = XCreateBitmapFromData(fl display, DefaultRootWindow(fl display),


icon bits, icon width, icon height);

window->icon((const void*)p);

To use a multi-colored icon, the XPM format and library should be used as follows:
#include <X11/xpm.h>
#include "icon.xpm"

fl open display(); // needed if display has not been previously opened

Pixmap p, mask;

XpmCreatePixmapFromData(fl display, DefaultRootWindow(fl display),


icon xpm, &p, &mask, NULL);

window->icon((const void *)p);

When using the Xpm library, be sure to include it in the list of libraries that are used to link the
application (usually ”-lXpm”).

NOTE:
You must call Fl Window::show(int argc, char∗∗ argv) for the icon to be used. The Fl Window::show()
method does not bind the icon to the window.

17.2.6 X Resources
When the Fl Window::show(int argc, char∗∗ argv) method is called, FLTK looks for the following X
resources:

• background - The default background color for widgets (color).

• dndTextOps - The default setting for drag and drop text operations (boolean).

• foreground - The default foreground (label) color for widgets (color).

• scheme - The default scheme to use (string).

• selectBackground - The default selection color for menus, etc. (color).

• Text.background - The default background color for text fields (color).

• tooltips - The default setting for tooltips (boolean).

• visibleFocus - The default setting for visible keyboard focus on non-text widgets (boolean).

Resources associated with the first window’s Fl Window::xclass() string are queried first, or if no class has
been specified then the class ”fltk” is used (e.g. fltk.background). If no match is found, a global
search is done (e.g. ∗background).

17.3 The Windows (WIN32) Interface


The Windows interface provides access to the WIN32 GDI state information and data structures.
17.3. THE WINDOWS (WIN32) INTERFACE 141

17.3.1 Using filenames with non-ASCII characters


In FLTK, all strings, including filenames, are UTF-8 encoded. The utility functions fl fopen() and fl open()
allow to open files potentially having non-ASCII names in a cross-platform fashion, whereas the standard
fopen()/open() functions fail to do so.

17.3.2 Responding to WM QUIT


FLTK will intercept WM QUIT messages that are directed towards the thread that runs the main loop.
These are converted to SIGTERM signals via raise(). This allows you to deal with outside termination
requests with the same code on both Windows and UNIX systems. Other processes can send this message
via PostThreadMessage() in order to request, rather than force your application to terminate.

17.3.3 Handling Other WIN32 Messages


By default a single WNDCLASSEX called ”FLTK” is created. All Fl Window ’s are of this class unless
you use Fl Window::xclass(). The window class is created the first time Fl Window::show() is called.
You can probably combine FLTK with other libraries that make their own WIN32 window classes.
The easiest way is to call Fl::wait(), as it will call DispatchMessage() for all messages to the other
windows. If necessary you can let the other library take over as long as it calls DispatchMessage(),
but you will have to arrange for the function Fl::flush() to be called regularly so that widgets are updated,
timeouts are handled, and the idle functions are called.
extern MSG fl msg

This variable contains the most recent message read by GetMessage(), which is called by Fl-
::wait(). This may not be the most recent message sent to an FLTK window, because silly WIN32 calls
the handle procedures directly for some events (sigh).

void Fl::add handler(int (∗f)(int))

Installs a function to parse unrecognized messages sent to FLTK windows. If FLTK cannot figure out
what to do with a message, it calls each of these functions (most recent first) until one of them returns
non-zero. The argument passed to the functions is the FLTK event that was not handled or zero for
unknown messages. If all the handlers return zero then FLTK calls DefWindowProc().

HWND fl xid(const Fl Window ∗)

Returns the window handle for a Fl Window, or zero if not shown().

Fl Window ∗fl find(HWND xid)

Returns the Fl Window that corresponds to the given window handle, or NULL if not found. This
function uses a cache so it is slightly faster than iterating through the windows yourself.

17.3.4 Drawing Things Using the WIN32 GDI


When the virtual function Fl Widget::draw() is called, FLTK stores all the extra arguments you need to
make a proper GDI call in some global variables:
extern HINSTANCE fl display;
extern HWND fl window;
extern HDC fl gc;
COLORREF fl RGB();
HPEN fl pen();
HBRUSH fl brush();
142 CHAPTER 17. OPERATING SYSTEM ISSUES

These global variables are set before Fl Widget::draw() is called, or by Fl Window::make current().
You can refer to them when needed to produce GDI calls, but don’t attempt to change them. The functions
return GDI objects for the current color set by fl color() and are created as needed and cached. A typical
GDI drawing call is written like this:
DrawSomething(fl gc, ..., fl brush());

It may also be useful to refer to Fl Window::current() to get the window’s size or position.

17.3.5 Setting the Icon of a Window


FLTK currently supports setting a window’s icon before it is shown using the Fl Window::icon() method.
void Fl Window::icon(const void ∗)

Sets the icon for the window to the passed pointer. You will need to cast the HICON handle to a char∗
when calling this method. To set the icon using an icon resource compiled with your application use:
window->icon((const void *)LoadIcon(fl display, MAKEINTRESOURCE(IDI ICON)));

You can also use the LoadImage() and related functions to load specific resolutions or create the
icon from bitmap data.

NOTE:
You must call Fl Window::show(int argc, char∗∗ argv) for the icon to be used. The Fl Window::show()
method does not bind the icon to the window.

17.3.6 How to Not Get a MSDOS Console Window


WIN32 has a really stupid mode switch stored in the executables that controls whether or not to make a
console window.
To always get a console window you simply create a console application (the ”/SUBSYSTEM:CONS-
OLE” option for the linker). For a GUI-only application create a WIN32 application (the ”/SUBSYSTE-
M:WINDOWS” option for the linker).
FLTK includes a WinMain() function that calls the ANSI standard main() entry point for you. This
function creates a console window when you use the debug version of the library.
WIN32 applications without a console cannot write to stdout or stderr, even if they are run from
a console window. Any output is silently thrown away. Additionally, WIN32 applications are run in the
background by the console, although you can use ”start /wait program” to run them in the foreground.

17.3.7 Known WIN32 Bugs and Problems


The following is a list of known bugs and problems in the WIN32 version of FLTK:

• If a program is deactivated, Fl::wait() does not return until it is activated again, even though
many events are delivered to the program. This can cause idle background processes to stop unex-
pectedly. This also happens while the user is dragging or resizing windows or otherwise holding the
mouse down. We were forced to remove most of the efficiency FLTK uses for redrawing in order to
get windows to update while being moved. This is a design error in WIN32 and probably impossible
to get around.

• Fl Gl Window::can do overlay() returns true until the first time it attempts to draw an over-
lay, and then correctly returns whether or not there is overlay hardware.

• SetCapture (used by Fl::grab()) doesn’t work, and the main window title bar turns gray
while menus are popped up.
17.4. THE APPLE OS X INTERFACE 143

• Compilation with gcc 3.4.4 and -Os exposes an optimisation bug in gcc. The symptom is that
when drawing filled circles only the perimeter is drawn. This can for instance be seen in the symbols
demo. Other optimisation options such as -O2 and -O3 seem to work OK. More details can be found
in STR#1656

17.4 The Apple OS X Interface


FLTK supports Apple OS X using the Apple Cocoa library. Older versions of MacOS are no longer
supported.
Control, Option, and Command Modifier Keys

FLTK maps the Mac ’control’ key to FL CTRL, the ’option’ key to FL ALT and the ’Apple’ key to
FL META. Furthermore, FL COMMAND designates the ’Apple’ key on Mac OS X and the ’control’
key on other platforms. Keyboard events return the key name in Fl::event key() and the keystroke
translation in Fl::event text(). For example, typing Option-Y on a Mac US keyboard will set FL ALT
in Fl::event state(), set Fl::event key() to ’y’ and return the Yen symbol in Fl::event text().
Apple ”Quit” Event

When the user presses Cmd-Q or requests a termination of the application, OS X will send a ”Quit”
Apple Event. FLTK handles this event by sending an FL CLOSE event to all open windows. If all
windows close, the application will terminate.
Apple ”Open” Event

Whenever the user drops a file onto an application icon, OS X generates an Apple Event of the type
”Open”. You can have FLTK notify you of an Open event by calling the fl open callback function.
void fl open display()

Opens the display. Does nothing if it is already open. You should call this if you wish to do Cocoa or
Quartz calls and there is a chance that your code will be called before the first show() of a window.
Window fl xid(const Fl Window ∗)

Returns the window reference for an Fl Window, or NULL if the window has not been shown. This
reference is a pointer to an instance of the subclass FLWindow of Cocoa’s NSWindow class.
Fl Window ∗fl find(Window xid)

Returns the Fl Window that corresponds to the given window reference, or NULL if not found. FLTK
windows that are children of top-level windows share the Window of the top-level window.
void fl mac set about( Fl Callback ∗cb, void ∗user data, int shortcut)

Attaches the callback cb to the ”About myprog” item of the system application menu. cb will be
called with NULL first argument and user data second argument.
Fl Sys Menu Bar class

The Fl Sys Menu Bar class allows to build menu bars that, on Mac OS X, are placed in the system
menu bar (at top-left of display), and, on other platforms, at a user-chosen location of a user-chosen
window.
144 CHAPTER 17. OPERATING SYSTEM ISSUES

17.4.1 Setting the icon of an application


• First, create a .icns file containing several copies of your icon of decreasing sizes. This can be done
using the Preview application or the Icon Composer application available in ”Graphics Tools for
Xcode”. To create a high resolution icon file, it is necessary to use the iconutil command-line utility.
• Put your .icns file in the Resources subdirectory of your application bundle.
• Add these two lines to the Info.plist file of your application bundle

<key>CFBundleIconFile</key>
<string>foo.icns</string>

replacing foo by your application name. If you use Xcode, just add your .icns file to your application
target.

17.4.2 Drawing Things Using Quartz


All code inside Fl Widget::draw() is expected to call Quartz drawing functions. The Quartz coordinate
system is flipped to match FLTK’s coordinate system. The origin for all drawing is in the top left corner of
the enclosing Fl Window. The global variable fl gc (of type CGContextRef) is the appropriate Quartz
2D drawing environment. Include FL/x.H to declare the fl gc variable.

17.4.3 Internationalization
All FLTK programs contain an application menu with, e.g., the About xxx, Hide xxx, and Quit xxx items.
This menu can be internationalized/localized by any of two means.
• using the Fl Mac App Menu class.
• using the standard Mac OS X localization procedure. Create a language-specific .lproj directory
(e.g., German.lproj) in the Resources subdirectory of the application bundle. Create therein
a Localizable.strings file that translates all menu items to this language. The German
Localizable.strings file, for example, contains:

"About %@" = "Über %@";


"Print Front Window"="Frontfenster drucken";
"Services" = "Dienste";
"Hide %@"="%@ ausblenden";
"Hide Others"="Andere ausblenden";
"Show All"="Alle einblenden";
"Quit %@"="%@ beenden";

Set "Print Front Window" = ""; therein so the application menu doesn’t show a ”Print
Front Window” item. To localize the application name itself, create a file InfoPlist.strings
in each .lproj directory and put CFBundleName = "localized name"; in each such file.
Fl Double Window
OS X double-buffers all windows automatically. On OS X, Fl Window and Fl Double Window are
handled internally in the same way.

17.4.4 Mac File System Specifics


Resource Forks

FLTK does not access the resource fork of an application. However, a minimal resource fork must be
created for OS X applications. Starting with OS X 10.6, resource forks are no longer needed.
17.4. THE APPLE OS X INTERFACE 145

Caution (OS X 10.2 and older):


When using UNIX commands to copy or move executables, OS X will NOT copy any resource forks!
For copying and moving use CpMac and MvMac respectively. For creating a tar archive, all
executables need to be stripped from their Resource Fork before packing, e.g. ”DeRez fluid > fluid.r”.
After unpacking the Resource Fork needs to be reattached, e.g. ”Rez fluid.r -o fluid”.

It is advisable to use the Finder for moving and copying and Mac archiving tools like Sit for distribution
as they will handle the Resource Fork correctly.
Mac File Paths

FLTK uses UTF-8-encoded UNIX-style filenames and paths.


See Also
Mac OS X-specific symbols
146 CHAPTER 17. OPERATING SYSTEM ISSUES
Chapter 18

Migrating Code from FLTK 1.0 to 1.1

This appendix describes the differences between the FLTK 1.0.x and FLTK 1.1.x functions and classes.

18.1 Color Values


Color values are now stored in a 32-bit unsigned integer instead of the unsigned character in 1.0.x. This
allows for the specification of 24-bit RGB values or 8-bit FLTK color indices.
FL BLACK and FL WHITE now remain black and white, even if the base color of the gray ramp is
changed using Fl::background(). FL DARK3 and FL LIGHT3 can be used instead to draw a very dark or
a very bright background hue.
Widgets use the new color symbols FL FOREGROUND COLOR, FL BACKGROUND COLOR, FL BA-
CKGROUND2 COLOR, FL INACTIVE COLOR, and FL SELECTION COLOR. More details can be found
in the chapter FLTK Enumerations.

18.2 Cut and Paste Support


The FLTK clipboard is now broken into two parts - a local selection value and a cut-and-paste value. This
allows FLTK to support things like highlighting and replacing text that was previously cut or copied, which
makes FLTK applications behave like traditional GUI applications.

18.3 File Chooser


The file chooser in FLTK 1.1.x is significantly different than the one supplied with FLTK 1.0.x. Any code
that directly references the old FCB class or members will need to be ported to the new Fl File Chooser
class.

18.4 Function Names


Some function names have changed from FLTK 1.0.x to 1.1.x in order to avoid name space collisions.
You can still use the old function names by defining the FLTK 1 0 COMPAT symbol on the command-line
when you compile (-DFLTK 1 0 COMPAT) or in your source, e.g.:
#define FLTK 1 0 COMPAT
#include <FL/Fl.H>
#include <FL/Enumerations.H>
#include <FL/filename.H>

The following table shows the old and new function names:

147
148 CHAPTER 18. MIGRATING CODE FROM FLTK 1.0 TO 1.1

Old 1.0.x Name New 1.1.x Name


contrast() fl contrast()
down() fl down()
filename absolute() fl filename absolute()
filename expand() fl filename expand()
filename ext() fl filename ext()
filename isdir() fl filename isdir()
filename list() fl filename list()
filename match() fl filename match()
filename name() fl filename name()
filename relative() fl filename relative()
filename setext() fl filename setext()
frame() fl frame()
inactive() fl inactive()
numericsort() fl numericsort()

18.5 Image Support


Image support in FLTK has been significantly revamped in 1.1.x. The Fl Image class is now a proper base
class, with the core image drawing functionality in the Fl Bitmap, Fl Pixmap, and Fl RGB Image classes.
BMP, GIF, JPEG, PNG, XBM, and XPM image files can now be loaded using the appropriate image
classes, and the Fl Shared Image class can be used to cache images in memory.
Image labels are no longer provided as an add-on label type. If you use the old label() methods on
an image, the widget’s image() method is called to set the image as the label.
Image labels in menu items must still use the old labeltype mechanism to preserve source compatibility.

18.6 Keyboard Navigation


FLTK 1.1.x now supports keyboard navigation and control with all widgets. To restore the old FLTK 1.0.x
behavior so that only text widgets get keyboard focus, call the Fl::visible focus() method to disable it:
Fl::visible focus(0);
Chapter 19

Migrating Code from FLTK 1.1 to 1.3

This appendix describes the differences between the FLTK 1.1.x and FLTK 1.3.x functions and classes.

19.1 Migrating From FLTK 1.0


If you want to migrate your code from FLTK 1.0 to FLTK 1.3, then you should first consult Appendix
Migrating Code from FLTK 1.0 to 1.1.

19.2 Fl Scroll Widget


Fl Scroll::scroll to(int x, int y) replaces Fl Scroll::position(int x, int y).
This change was needed because Fl Scroll::position(int,int) redefined Fl Widget::position(int,int), but
with a completely different function (moving the scrollbars instead of moving the widget).
Please be aware that you need to change your application’s code for all Fl Scroll-derived widgets, if
you used Fl Scroll::position(int x, int y) to position the scrollbars (not the widget itself).
The compiler will not detect any errors, because your calls to position(int x, int y) will be calling
Fl Widget::position(int x, int y).

19.3 Unicode (UTF-8)


FLTK 1.3 uses Unicode (UTF-8) encoding internally. If you are only using characters in the ASCII range
(32-127), there is a high probability that you don’t need to modify your code. However, if you use in-
ternational characters (128-255), encoded as e.g. Windows codepage 1252, ISO-8859-1, ISO-8859-15 or
any other encoding, then you will need to update your character string constants and widget input data
accordingly.
Please refer to the Unicode and UTF-8 Support chapter for more details.
Note
It is important that, although your software uses only ASCII characters for input to FLTK widgets, the
user may enter non-ASCII characters, and FLTK will return these characters with UTF-8 encoding
to your application, e.g. via Fl Input::value(). You will need to re-encode them to your (non-UTF-8)
encoding, otherwise you might see or print garbage in your data.

19.4 Widget Coordinate Representation


FLTK 1.3 changed all Widget coordinate variables and methods, e.g. Fl Widget::x(), Fl Widget::y(), Fl -
Widget::w(), Fl Widget::h(), from short (16-bit) to int (32-bit) representation. This should not affect any
existing code, but makes it possible to use bigger scroll areas (e.g. Fl Scroll widget).

149
150 CHAPTER 19. MIGRATING CODE FROM FLTK 1.1 TO 1.3
Chapter 20

Developer Information

This chapter describes FLTK development and documentation.

Example
/** \file
Fl_Clock, Fl_Clock_Output widgets. */

/**
\class Fl_Clock_Output
\brief This widget can be used to display a program-supplied time.

The time shown on the clock is not updated. To display the current time,
use Fl_Clock instead.

\image html clock.png


\image latex clock.png "" width=10cm
\image html round_clock.png
\image latex clock.png "" width=10cm
\image html round_clock.png "" width=10cm */

/**
Returns the displayed time.
Returns the time in seconds since the UNIX epoch (January 1, 1970).
\see value(ulong)
*/
ulong value() const {return value_;}

/**
Set the displayed time.
Set the time in seconds since the UNIX epoch (January 1, 1970).
\param[in] v seconds since epoch
\see value()
*/
void Fl_Clock_Output::value(ulong v) {
[...]
}

/**
Create an Fl_Clock widget using the given position, size, and label string.
The default boxtype is \c FL_NO_BOX.
\param[in] X, Y, W, H position and size of the widget
\param[in] L widget label, default is no label
*/
Fl_Clock::Fl_Clock(int X, int Y, int W, int H, const char *L)
: Fl_Clock_Output(X, Y, W, H, L) {}

/**

151
152 CHAPTER 20. DEVELOPER INFORMATION

Create an Fl_Clock widget using the given boxtype, position, size, and
label string.
\param[in] t boxtype
\param[in] X, Y, W, H position and size of the widget
\param[in] L widget label, default is no label
*/
Fl_Clock::Fl_Clock(uchar t, int X, int Y, int W, int H, const char *L)
: Fl_Clock_Output(X, Y, W, H, L) {
type(t);
box(t==FL_ROUND_CLOCK ? FL_NO_BOX : FL_UP_BOX);
}

Note

From Duncan: (will be removed later, just for now as a reminder)


I’ve just added comments for the fl color chooser() functions, and in order to keep them and the general
Function Reference information for them together, I created a new doxygen group, and used \ingroup in
the three comment blocks. This creates a new Modules page (which may not be what we want) with links
to it from the File Members and Fl Color Chooser.H pages. It needs a bit more experimentation on my
part unless someone already knows how this should be handled. (Maybe we can add it to a functions.dox
file that defines a functions group and do that for all of the function documentation?)
Update: the trick is not to create duplicate entries in a new group, but to move the function information
into the doxygen comments for the class, and use the navigation links provided. Simply using \relatesalso
as the first doxygen command in the function’s comment puts it in the appropriate place. There is no need
to have \defgroup and \ingroup as well, and indeed they don’t work. So, to summarize:
Gizmo.H
/** \class Gizmo
A gizmo that does everything
*/
class Gizmo {
etc
};
extern int popup_gizmo(...);

Gizmo.cxx:
/** \relatesalso Gizmo
Pops up a gizmo dialog with a Gizmo in it
*/
int popup_gizmo(...);

Comments Within Doxygen Comment Blocks


You can use HTML comment statements to embed comments in doxygen comment blocks. These com-
ments will not be visible in the generated document.
The following text is a developer comment.
<!-- *** This *** is *** invisible *** -->
This will be visible again.

will be shown as:


The following text is a developer comment.

This will be visible again.

Different Headlines
You can use HTML tags <H1> ... <H4> for headlines with different sizes. As of doxygen 1.8.x there
must not be more than three spaces at the beginning of the line for this to work. Currently (doxygen 1.8.6)
there seems to be no difference in the font sizes of <H3> and <H4> in the pdf output, whereas the html
output uses different font sizes.
20.1. NON-ASCII CHARACTERS 153

<H1>Headline in big text (H1)</H1>


<H2>Headline in big text (H2)</H2>
<H3>Headline in big text (H3)</H3>
<H4>Headline in big text (H4)</H4>

Headline in big text (H1)


Headline in big text (H2)
Headline in big text (H3)
Headline in big text (H4)

20.1 Non-ASCII Characters


Doxygen understands many HTML quoting characters like
&quot;, &uuml;, &ccedil;, &Ccedil;, but not all HTML quoting characters.

This will appear in the document:


Doxygen understands many HTML quoting characters like
&quot;, &uuml;, &ccedil;, &Ccedil;, but not all HTML quoting characters.

For further informations about HTML quoting characters see


http://www.doxygen.org/htmlcmds.html
Alternatively you can use UTF-8 encoding within Doxygen comments.

20.2 Document Structure


• \page creates a named page
• \section creates a named section within that page
• \subsection creates a named subsection within the current section
• \subsubsection creates a named subsubsection within the current subsection
All these statements take a ”name” as their first argument, and a title as their second argument. The title
can contain spaces.
The page, section, and subsection titles are formatted in blue color and a size like ”<H1>”, ”<H2>”,
and ”<H3>”, and ”<H4>”, respectively.
By FLTK documentation convention, a file like this one with a doxygen documentation chapter has
the name ”<chapter>.dox”. The \page statement at the top of the page is ”\page <chapter> This
is the title”. Sections within a documentation page must be called ”<chapter> <section>”, where
”<chapter>” is the name part of the file, and ”<section>” is a unique section name within the page that
can be referenced in links. The same for subsections and subsubsections.
These doxygen page and section commands work only in special documentation chapters, not within
normal source or header documentation blocks. However, links from normal (e.g. class) documentation to
documentation sections do work.
This page has
\page development I - Developer Information

at its top.
This section is
\section development structure Document Structure

The following section is


\section development links Creating Links
154 CHAPTER 20. DEVELOPER INFORMATION

20.3 Creating Links


Links to other documents and external links can be embedded with

• doxygen \ref links to other doxygen \page, \section, \subsection and \anchor locations
• HTML links without markup - doxygen creates ”http://...” links automatically
• standard, non-Doxygen, HTML links
- see chapter \ref unicode creates a link to the named chapter
unicode that has been created with a \\page statement.

- For further informations about quoting see


http://www.doxygen.org/htmlcmds.html

- see <a href="http://www.nedit.org/">Nedit</a> creates


a standard HTML link

appears as:

• see chapter Unicode and UTF-8 Support creates a link to the named chapter unicode that has been
created with a \page statement.
• For further informations about quoting see http://www.doxygen.org/htmlcmds.html
• see Nedit creates a standard HTML link

20.4 Paragraph Layout


There is no real need to use HTML <P> and </P> tags within the text to tell doxygen to start or stop a
paragraph. In most cases, when doxygen encounters a blank line or some, but not all, \commands in the
text it knows that it has reached the start or end of a paragraph. Doxygen also offers the \par command
for special paragraph handling. It can be used to provide a paragraph title and also to indent a paragraph.
Unfortunately \par won’t do what you expect if you want to have doxygen links and sometimes html tags
don’t work either.
\par Normal Paragraph with title

This paragraph will have a title, but because there is a blank line
between the \par and the text, it will have the normal layout.

\par Indented Paragraph with title


This paragraph will also have a title, but because there is no blank
line between the \par and the text, it will be indented.

\par
It is also possible to have an indented paragraph without title.
This is how you indent subsequent paragraphs.

\par No link to Fl_Widget::draw()


Note that the paragraph title is treated as plain text.
Doxygen type links will not work.
HTML characters and tags may or may not work.

Fl_Widget::draw() links and &quot;html&quot; tags work<br>


\par
Use a single line ending with <br> for complicated paragraph titles.

The above code produces the following paragraphs:


Normal Paragraph with title
20.5. NAVIGATION ELEMENTS 155

This paragraph will have a title, but because there is a blank line between the \par and the text, it will have
the normal layout.
Indented Paragraph with title

This paragraph will also have a title, but because there is no blank line between the \par and the text,
it will be indented.

It is also possible to have an indented paragraph without title. This is how you indent subsequent
paragraphs.
No link to Fl Widget::draw()

Note that the paragraph title is treated as plain text. Doxygen type links will not work. HTML charac-
ters and tags may or may not work.

Fl Widget::draw() links and ”html” tags work

Use a single line ending with <br> for complicated paragraph titles.

20.5 Navigation Elements


Each introduction (tutorial) page ends with navigation elements. These elements must only be included in
the html documentation, therefore they must be separated with \htmlonly and \endhtmlonly.
The following code gives the navigation bar at the bottom of this page:
\htmlonly
<hr>
<table summary="navigation bar" width="100%" border="0">
<tr>
<td width="45%" align="LEFT">
<a class="el" href="migration_1_3.html">
[Prev]
Migrating Code from FLTK 1.1 to 1.3
</a>
</td>
<td width="10%" align="CENTER">
<a class="el" href="index.html">[Index]</a>
</td>
<td width="45%" align="RIGHT">
<a class="el" href="license.html">
Software License
[Next]
</a>
</td>
</tr>
</table>
\endhtmlonly
156 CHAPTER 20. DEVELOPER INFORMATION
Chapter 21

Software License
December 11, 2001

The FLTK library and included programs are provided under the terms of the GNU Library General Public
License (LGPL) with the following exceptions:
1. Modifications to the FLTK configure script, config header file, and makefiles by themselves to sup-
port a specific platform do not constitute a modified or derivative work.
The authors do request that such modifications be contributed to the FLTK project - send all con-
tributions through the ”Software Trouble Report” on the following page: http://www.fltk.-
org/str.php
2. Widgets that are subclassed from FLTK widgets do not constitute a derivative work.
3. Static linking of applications and widgets to the FLTK library does not constitute a derivative work
and does not require the author to provide source code for the application or widget, use the shared
FLTK libraries, or link their applications or widgets against a user-supplied version of FLTK.
If you link the application or widget to a modified version of FLTK, then the changes to FLTK must
be provided under the terms of the LGPL in sections 1, 2, and 4.
4. You do not have to provide a copy of the FLTK license with programs that are linked to the FLTK
library, nor do you have to identify the FLTK license in your program or documentation as required
by section 6 of the LGPL.
However, programs must still identify their use of FLTK. The following example statement can be
included in user documentation to satisfy this requirement:
[program/widget] is based in part on the work of the FLTK project (http://www.fltk.org).
GNU LIBRARY GENERAL PUBLIC LICENSE

Version 2, June 1991


Copyright (C) 1991 Free Software Foundation, Inc.
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it
is not allowed.
[This is the first released version of the library GPL. It is numbered 2 because it goes with version 2 of
the ordinary GPL.]
Preamble

157
158 CHAPTER 21. SOFTWARE LICENSE

The licenses for most software are designed to take away your freedom to share and change it. By con-
trast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free
software–to make sure the software is free for all its users.
This license, the Library General Public License, applies to some specially designated Free Software
Foundation software, and to any other libraries whose authors decide to use it. You can use it for your
libraries, too.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses
are designed to make sure that you have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it if you want it, that you can change the
software or use pieces of it in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask
you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute
copies of the library, or if you modify it.
For example, if you distribute copies of the library, whether gratis or for a fee, you must give the
recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source
code. If you link a program with the library, you must provide complete object files to the recipients so
that they can relink them with the library, after making changes to the library and recompiling it. And you
must show them these terms so they know their rights.
Our method of protecting your rights has two steps: (1) copyright the library, and (2) offer you this
license which gives you legal permission to copy, distribute and/or modify the library.
Also, for each distributor’s protection, we want to make certain that everyone understands that there
is no warranty for this free library. If the library is modified by someone else and passed on, we want its
recipients to know that what they have is not the original version, so that any problems introduced by others
will not reflect on the original authors’ reputations.
Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that
companies distributing free software will individually obtain patent licenses, thus in effect transforming the
program into proprietary software. To prevent this, we have made it clear that any patent must be licensed
for everyone’s free use or not licensed at all.
Most GNU software, including some libraries, is covered by the ordinary GNU General Public License,
which was designed for utility programs. This license, the GNU Library General Public License, applies
to certain designated libraries. This license is quite different from the ordinary one; be sure to read it in
full, and don’t assume that anything in it is the same as in the ordinary license.
The reason we have a separate public license for some libraries is that they blur the distinction we
usually make between modifying or adding to a program and simply using it. Linking a program with a
library, without changing the library, is in some sense simply using the library, and is analogous to running
a utility program or application program. However, in a textual and legal sense, the linked executable is
a combined work, a derivative of the original library, and the ordinary General Public License treats it as
such.
Because of this blurred distinction, using the ordinary General Public License for libraries did not
effectively promote software sharing, because most developers did not use the libraries. We concluded that
weaker conditions might promote sharing better.
However, unrestricted linking of non-free programs would deprive the users of those programs of all
benefit from the free status of the libraries themselves. This Library General Public License is intended to
permit developers of non-free programs to use free libraries, while preserving your freedom as a user of
such programs to change the free libraries that are incorporated in them. (We have not seen how to achieve
this as regards changes in header files, but we have achieved it as regards changes in the actual functions
of the Library.) The hope is that this will lead to faster development of free libraries.
The precise terms and conditions for copying, distribution and modification follow. Pay close attention
to the difference between a ”work based on the libary” and a ”work that uses the library”. The former
contains code derived from the library, while the latter only works together with the library.
Note that it is possible for a library to be covered by the ordinary General Public License rather than by
this special one.
159

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License Agreement applies to any software library which contains a notice placed by the copyright
holder or other authorized party saying it may be distributed under the terms of this Library General Public
License (also called ”this License”). Each licensee is addressed as ”you”.
A ”library” means a collection of software functions and/or data prepared so as to be conveniently
linked with application programs (which use some of those functions and data) to form executables.
The ”Library”, below, refers to any such software library or work which has been distributed under these
terms. A ”work based on the Library” means either the Library or any derivative work under copyright law:
that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or
translated straightforwardly into another language. (Hereinafter, translation is included without limitation
in the term ”modification”.)
”Source code” for a work means the preferred form of the work for making modifications to it. For
a library, complete source code means all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation and installation of the library.
Activities other than copying, distribution and modification are not covered by this License; they are
outside its scope. The act of running a program using the Library is not restricted, and output from such a
program is covered only if its contents constitute a work based on the Library (independent of the use of
the Library in a tool for writing it). Whether that is true depends on what the Library does and what the
program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library’s complete source code as you receive
it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the
absence of any warranty; and distribute a copy of this License along with the Library.
You may charge a fee for the physical act of transferring a copy, and you may at your option offer
warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based
on the Library, and copy and distribute such modifications or work under the terms of Section 1 above,
provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices stating that you changed the files and
the date of any change.
c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms
of this License.
d) If a facility in the modified Library refers to a function or a table of data to be supplied by an
application program that uses the facility, other than as an argument passed when the facility is invoked,
then you must make a good faith effort to ensure that, in the event an application does not supply such
function or table, the facility still operates, and performs whatever part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has a purpose that is entirely well-defined
independent of the application. Therefore, Subsection 2d requires that any application-supplied function or
table used by this function must be optional: if the application does not supply it, the square root function
must still compute square roots.)
These requirements apply to the modified work as a whole. If identifiable sections of that work are not
derived from the Library, and can be reasonably considered independent and separate works in themselves,
then this License, and its terms, do not apply to those sections when you distribute them as separate works.
But when you distribute the same sections as part of a whole which is a work based on the Library, the
distribution of the whole must be on the terms of this License, whose permissions for other licensees extend
to the entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely
by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works
based on the Library.
In addition, mere aggregation of another work not based on the Library with the Library (or with a
work based on the Library) on a volume of a storage or distribution medium does not bring the other work
160 CHAPTER 21. SOFTWARE LICENSE

under the scope of this License.


3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License
to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that
they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer
version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that
version instead if you wish.) Do not make any other change in these notices.
Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General
Public License applies to all subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the Library into a program that is not a
library.
4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object
code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with
the complete corresponding machine-readable source code, which must be distributed under the terms of
Sections 1 and 2 above on a medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from a designated place, then offering
equivalent access to copy the source code from the same place satisfies the requirement to distribute the
source code, even though third parties are not compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the Library, but is designed to work with
the Library by being compiled or linked with it, is called a ”work that uses the Library”. Such a work, in
isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License.
However, linking a ”work that uses the Library” with the Library creates an executable that is a deriva-
tive of the Library (because it contains portions of the Library), rather than a ”work that uses the library”.
The executable is therefore covered by this License. Section 6 states terms for distribution of such executa-
bles.
When a ”work that uses the Library” uses material from a header file that is part of the Library, the
object code for the work may be a derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be linked without the Library, or if the work is
itself a library. The threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data structure layouts and accessors, and small
macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted,
regardless of whether it is legally a derivative work. (Executables containing this object code plus portions
of the Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work
under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or
not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also compile or link a ”work that uses the Library”
with the Library to produce a work containing portions of the Library, and distribute that work under terms
of your choice, provided that the terms permit modification of the work for the customer’s own use and
reverse engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the Library is used in it and that the
Library and its use are covered by this License. You must supply a copy of this License. If the work during
execution displays copyright notices, you must include the copyright notice for the Library among them,
as well as a reference directing the user to the copy of this License. Also, you must do one of these things:
a) Accompany the work with the complete corresponding machine-readable source code for the Library
including whatever changes were used in the work (which must be distributed under Sections 1 and 2
above); and, if the work is an executable linked with the Library, with the complete machine-readable
”work that uses the Library”, as object code and/or source code, so that the user can modify the Library
and then relink to produce a modified executable containing the modified Library. (It is understood that the
user who changes the contents of definitions files in the Library will not necessarily be able to recompile
the application to use the modified definitions.)
b) Accompany the work with a written offer, valid for at least three years, to give the same user the ma-
terials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution.
c) If distribution of the work is made by offering access to copy from a designated place, offer equivalent
access to copy the above specified materials from the same place.
161

d) Verify that the user has already received a copy of these materials or that you have already sent this
user a copy.
For an executable, the required form of the ”work that uses the Library” must include any data and
utility programs needed for reproducing the executable from it. However, as a special exception, the source
code distributed need not include anything that is normally distributed (in either source or binary form)
with the major components (compiler, kernel, and so on) of the operating system on which the executable
runs, unless that component itself accompanies the executable.
It may happen that this requirement contradicts the license restrictions of other proprietary libraries that
do not normally accompany the operating system. Such a contradiction means you cannot use both them
and the Library together in an executable that you distribute.
7. You may place library facilities that are a work based on the Library side-by-side in a single library
together with other library facilities not covered by this License, and distribute such a combined library,
provided that the separate distribution of the work based on the Library and of the other library facilities is
otherwise permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work based on the Library, uncombined
with any other library facilities. This must be distributed under the terms of the Sections above.
b) Give prominent notice with the combined library of the fact that part of it is a work based on the
Library, and explaining where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly
provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute
the Library is void, and will automatically terminate your rights under this License. However, parties who
have received copies, or rights, from you under this License will not have their licenses terminated so long
as such parties remain in full compliance.
9. You are not required to accept this License, since you have not signed it. However, nothing else grants
you permission to modify or distribute the Library or its derivative works. These actions are prohibited by
law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work
based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions
for copying, distributing or modifying the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the Library), the recipient automati-
cally receives a license from the original licensor to copy, distribute, link with or modify the Library subject
to these terms and conditions. You may not impose any further restrictions on the recipients’ exercise of
the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.
11. If, as a consequence of a court judgment or allegation of patent infringement or for any other
reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this
License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any
other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if
a patent license would not permit royalty-free redistribution of the Library by all those who receive copies
directly or indirectly through you, then the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any particular circumstance, the
balance of the section is intended to apply, and the section as a whole is intended to apply in other circum-
stances.
It is not the purpose of this section to induce you to infringe any patents or other property right claims
or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of
the free software distribution system which is implemented by public license practices. Many people have
made generous contributions to the wide range of software distributed through that system in reliance on
consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute
software through any other system and a licensee cannot impose that choice.
This section is intended to make thoroughly clear what is believed to be a consequence of the rest of
this License.
12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by
copyrighted interfaces, the original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries, so that distribution is permitted
162 CHAPTER 21. SOFTWARE LICENSE

only in or among countries not thus excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new versions of the Library General
Public License from time to time. Such new versions will be similar in spirit to the present version, but
may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library specifies a version number of
this License which applies to it and ”any later version”, you have the option of following the terms and
conditions either of that version or of any later version published by the Free Software Foundation. If the
Library does not specify a license version number, you may choose any version ever published by the Free
Software Foundation.
14. If you wish to incorporate parts of the Library into other free programs whose distribution con-
ditions are incompatible with these, write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make
exceptions for this. Our decision will be guided by the two goals of preserving the free status of all deriva-
tives of our free software and of promoting the sharing and reuse of software generally.
NO WARRANTY

15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR
THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHER-
WISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE
THE LIBRARY ”AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLI-
ED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILIT-
Y AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE,
YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITI-
NG WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARIS-
ING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTH-
ER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Chapter 22

Example Source Code

The FLTK distribution contains over 60 sample applications written in, or ported to, FLTK.
If the FLTK archive you received does not contain either an ’examples’ or ’test’ directory, you can
download the complete FLTK distribution from http://fltk.org/software.php .
Most of the example programs were created while testing a group of widgets. They are not meant to be
great achievements in clean C++ programming, but merely a test platform to verify the functionality of the
FLTK library.
Note that extra example programs are also available in an additional ’examples’ directory, but these are
NOT built automatically when you build FLTK, unlike those in the ’test’ directory shown below.

22.1 Example Applications


adjuster arc ask bitmap blocks boxtype
browser button buttons checkers clock colbrowser
color chooser cube CubeView cursor curve demo
device doublebuffer editor fast slow file chooser fluid
fonts forms fractals fullscreen gl overlay glpuzzle
hello help iconize image inactive input
input choice keyboard label line style list visuals mandelbrot
menubar message minimum navigation output overlay
pack pixmap - pixmap preferences radio resizebox
browser
resize scroll shape subwindow sudoku symbols
tabs threads tile tiled image unittests utf8
valuators

22.1.1 adjuster

adjuster shows a nifty little widget for quickly setting values in a great range.

22.1.2 arc

The arc demo explains how to derive your own widget to generate some custom drawings. The
sample drawings use the matrix based arc drawing for some fun effects.

163
164 CHAPTER 22. EXAMPLE SOURCE CODE

22.1.3 ask

ask shows some of FLTK’s standard dialog boxes. Click the correct answers or you may end up in a
loop, or you may end up in a loop, or you... .

22.1.4 bitmap

This simple test shows the use of a single color bitmap as a label for a box widget. Bitmaps are stored
in the X11 ’.bmp’ file format and can be part of the source code.

22.1.5 blocks

A wonderful and addictive game that shows the usage of FLTK timers, graphics, and how to implement
sound on all platforms. blocks is also a good example for the Mac OS X specific bundle format.

22.1.6 boxtype

boxtype gives an overview of readily available boxes and frames in FLTK. More types can be added
by the application programmer. When using themes, FLTK shuffles boxtypes around to give your
program a new look.

22.1.7 browser

browser shows the capabilities of the Fl Browser widget. Important features tested are loading of
files, line formatting, and correct positioning of the browser data window.

22.1.8 button

The button test is a simple demo of push-buttons and callbacks.

22.1.9 buttons

buttons shows a sample of FLTK button types.

22.1.10 checkers

Written by Steve Poulsen in early 1979, checkers shows how to convert a VT100 text-terminal
based program into a neat application with a graphical UI. Check out the code that drags the pieces,
and how the pieces are drawn by layering. Then tell me how to beat the computer at Checkers.

22.1.11 clock

The clock demo shows two analog clocks. The innards of the Fl Clock widget are pretty interesting,
explaining the use of timeouts and matrix based drawing.
22.1. EXAMPLE APPLICATIONS 165

22.1.12 colbrowser

colbrowser runs only on X11 systems. It reads /usr/lib/X11/rgb.txt to show the color representation
of every text entry in the file. This is beautiful, but only moderately useful unless your UI is written in
Motif.

22.1.13 color chooser

The color chooser gives a short demo of FLTK’s palette based color chooser and of the RGB
based color wheel.

22.1.14 cube

The cube demo shows the speed of OpenGL. It also tests the ability to render two OpenGL buffers
into a single window, and shows OpenGL text.

22.1.15 CubeView

CubeView shows how to create a UI containing OpenGL with Fluid.

22.1.16 cursor

The cursor demo shows all mouse cursor shapes that come standard with FLTK. The fgcolor and
bgcolor sliders work only on few systems (some version of Irix for example).

22.1.17 curve

curve draws a nice Bezier curve into a custom widget. The points option for splines is not supported
on all platforms.

22.1.18 demo

This tool allows quick access to all programs in the test directory. demo is based on the visuals of
the IrixGL demo program. The menu tree can be changed by editing test/demo.menu.

22.1.19 device

Exercises the Fl Image Surface, Fl Copy Surface, and Fl Printer classes to draw to an Fl Image ob-
ject, copy graphical data to the clipboard, and for print support.

Note
The clipboard.cxx program of the ’examples’ directory is a clipboard watching application that con-
tinuously displays the textual or graphical content of the system clipboard (a.k.a pasteboard on Mac
OS X) exercising Fl::paste().
166 CHAPTER 22. EXAMPLE SOURCE CODE

22.1.20 doublebuffer

The doublebuffer demo shows the difference between a single buffered window, which may
flicker during a slow redraw, and a double buffered window, which never flickers, but uses twice the
amount of RAM. Some modern OS’s double buffer all windows automatically to allow transparency
and shadows on the desktop. FLTK is smart enough to not tripple buffer a window in that case.

22.1.21 editor

FLTK has two very different text input widgets. Fl Input and derived classes are rather light weight,
however Fl Text Editor is a complete port of nedit (with permission). The editor test is almost a
full application, showing custom syntax highlighting and dialog creation.

22.1.22 fast slow

fast slow shows how an application can use the Fl Widget::when() setting to receive different kinds
of callbacks.

22.1.23 file chooser

The standard FLTK file chooser is the result of many iterations, trying to find a middle ground
between a complex browser and a fast light implementation.

22.1.24 fonts

fonts shows all available text fonts on the host system. If your machine still has some pixmap based
fonts, the supported sizes will be shown in bold face. Only the first 256 fonts will be listed.

22.1.25 forms

forms is an XForms program with very few changes. Search for ”fltk” to find all changes necessary
to port to fltk. This demo shows the different boxtypes. Note that some boxtypes are not appropriate
for some objects.

22.1.26 fractals

fractals shows how to mix OpenGL, Glut and FLTK code. FLTK supports a rather large subset of
Glut, so that many Glut applications compile just fine.

22.1.27 fullscreen

This demo shows how to do many of the window manipulations that are popular for games. You
can toggle the border on/off, switch between single- and double-buffered rendering, and take over the
entire screen. More information in the source code.

22.1.28 gl overlay

gl overlay shows OpenGL overlay plane rendering. If no hardware overlay plane is available,
FLTK will simulate it for you.
22.1. EXAMPLE APPLICATIONS 167

22.1.29 glpuzzle

The glpuzzle test shows how most Glut source code compiles easily under FLTK.

22.1.30 hello

hello: Hello, World. Need I say more? Well, maybe. This tiny demo shows how little is needed to
get a functioning application running with FLTK. Quite impressive, I’d say.

22.1.31 help

help displays the built-in FLTK help browser. The Fl Help Dialog understands a subset of html and
renders various image formats. This widget makes it easy to provide help pages to the user without
depending on the operating system’s html browser.

22.1.32 iconize

iconize demonstrates the effect of the window functions hide(), iconize(), and show().

22.1.33 image

The image demo shows how an image can be created on the fly. This generated image contains an al-
pha (transparency) channel which lets previous renderings ’shine through’, either via true transparency
or by using screen door transparency (pixelation).

22.1.34 inactive

inactive tests the correct rendering of inactive widgets. To see the inactive version of images, you
can check out the pixmap or image test.

22.1.35 input

This tool shows and tests different types of text input fields based on Fl Input . The input program
also tests various settings of Fl Input::when().

22.1.36 input choice

input choice tests the latest addition to FLTK1, a text input field with an attached pulldown menu.
Windows users will recognize similarities to the ’ComboBox’. input choice starts up in ’plastic’
scheme, but the traditional scheme is also supported.

22.1.37 keyboard

FLTK unifies keyboard events for all platforms. The keyboard test can be used to check the return
values of Fl::event key() and Fl::event text(). It is also great to see the modifier buttons and the scroll
wheel at work. Quit this application by closing the window. The ESC key will not work.
168 CHAPTER 22. EXAMPLE SOURCE CODE

22.1.38 label

Every FLTK widget can have a label attached to it. The label demo shows alignment, clipping, and
wrapping of text labels. Labels can contain symbols at the start and end of the text, like @FLTK or
@circle uh-huh @square.

22.1.39 line style

Advanced line drawing can be tested with line style. Not all platforms support all line styles.

22.1.40 list visuals

This little app finds all available pixel formats for the current X11 screen. But since you are now an
FLTK user, you don’t have to worry about any of this.

22.1.41 mandelbrot

mandelbrot shows two advanced topics in one test. It creates grayscale images on the fly, updating
them via the idle callback system. This is one of the few occasions where the idle callback is very
useful by giving all available processor time to the application without blocking the UI or other apps.

22.1.42 menubar

The menubar tests many aspects of FLTK’s popup menu system. Among the features are radio
buttons, menus taller than the screen, arbitrary sub menu depth, and global shortcuts.

22.1.43 message

message pops up a few of FLTK’s standard message boxes.

22.1.44 minimum

The minimum test program verifies that the update regions are set correctly. In a real life application,
the trail would be avoided by choosing a smaller label or by setting label clipping differently.

22.1.45 navigation

navigation demonstrates how the text cursor moves from text field to text field when using the
arrow keys, tab, and shift-tab.

22.1.46 output

output shows the difference between the single line and multi line mode of the Fl Output widget.
Fonts can be selected from the FLTK standard list of fonts.
22.1. EXAMPLE APPLICATIONS 169

22.1.47 overlay

The overlay test app shows how easy an FLTK window can be layered to display cursor and ma-
nipulator style elements. This example derives a new class from Fl Overlay Window and provides a
new function to draw custom overlays.

22.1.48 pack

The pack test program demonstrates the resizing and repositioning of children of the Fl Pack group.
Putting an Fl Pack into an Fl Scroll is a useful way to create a browser for large sets of data.

22.1.49 pixmap browser

pixmap browser tests the shared-image interface. When using the same image multiple times,
Fl Shared Image will keep it only once in memory.

22.1.50 pixmap

This simple test shows the use of a LUT based pixmap as a label for a box widget. Pixmaps are stored
in the X11 ’.xpm’ file format and can be part of the source code. Pixmaps support one transparent
color.

22.1.51 preferences

I do have my preferences in the morning, but sometimes I just can’t remember a thing. This is
where the Fl Preferences come in handy. They remember any kind of data between program launches.

22.1.52 radio

The radio tool was created entirely with fluid. It shows some of the available button types and tests
radio button behavior.

22.1.53 resizebox

resizebox shows some possible ways of FLTK’s automatic resize behavior.

22.1.54 resize

The resize demo tests size and position functions with the given window manager.

22.1.55 scroll

scroll shows how to scroll an area of widgets, one of them being a slow custom drawing. Fl Scroll
uses clipping and smart window area copying to improve redraw speed. The buttons at the bottom of
the window control decoration rendering and updates.
170 CHAPTER 22. EXAMPLE SOURCE CODE

22.1.56 shape

shape is a very minimal demo that shows how to create your own OpenGL rendering widget. Now
that you know that, go ahead and write that flight simulator you always dreamt of.

22.1.57 subwindow

The subwindow demo tests messaging and drawing between the main window and ’true’ sub win-
dows. A sub window is different to a group by resetting the FLTK coordinate system to 0, 0 in the top
left corner. On Win32 and X11, subwindows have their own operating system specific handle.

22.1.58 sudoku

Another highly addictive game - don’t play it, I warned you. The implementation shows how to create
application icons, how to deal with OS specifics, and how to generate sound.

22.1.59 symbols

symbols are a speciality of FLTK. These little vector drawings can be integrated into labels. They
scale and rotate, and with a little patience, you can define your own. The rotation number refers to 45
degree rotations if you were looking at a numeric keypad (2 is down, 6 is right, etc.).

22.1.60 tabs

The tabs tool was created with fluid. It tests correct hiding and redisplaying of tabs, navigation across
tabs, resize behavior, and no unneeded redrawing of invisible widgets.

The tabs application shows the Fl Tabs widget on the left and the Fl Wizard widget on the right side
for direct comparison of these two panel management widgets.

22.1.61 threads

FLTK can be used in a multithreading environment. There are some limitations, mostly due to the
underlying operating system. threads shows how to use Fl::lock(), Fl::unlock(), and Fl::awake() in
secondary threads to keep FLTK happy. Although locking works on all platforms, this demo is not
available on every machine.

22.1.62 tile

The tile tool shows a nice way of using Fl Tile. To test correct resizing of subwindows, the widget
for region 1 is created from an Fl Window class.

22.1.63 tiled image

The tiled image demo uses an image as the background for a window by repeating it over the full
size of the widget. The window is resizable and shows how the image gets repeated.
22.1. EXAMPLE APPLICATIONS 171

22.1.64 unittests

unittests exercises all of FLTK’s drawing features (e.g., text, lines, circles, images), as well as
scrollbars and schemes.

22.1.65 utf8

utf8 shows all fonts available to the platform that runs it, and how each font draws each of the
Unicode code points ranging between U+0020 and U+FFFF.

22.1.66 valuators

valuators shows all of FLTK’s nifty widgets to change numeric values.

22.1.67 fluid

fluid is not only a big test program, but also a very useful visual UI designer. Many parts of fluid
were created using fluid. See the Fluid Tutorial for more details.
172 CHAPTER 22. EXAMPLE SOURCE CODE
Chapter 23

FAQ (Frequently Asked Questions)

A list of frequently asked questions about FLTK.


This appendix describes various frequently asked questions regarding FLTK.

• Where do I start learning FLTK?

• How do I make a box with text?

• Can I use FLTK to make closed-source commercial applications?

• Hitting the ’Escape’ key closes windows - how do I prevent this?

23.1 Where do I start learning FLTK?


It is assumed you know C++, which is the language all FLTK programs are written in, including FLTK
itself.
If you like reading manuals to work your way into things, a good start is the FLTK documentation’s
Introduction to FLTK. Under the FLTK Basics section there’s an example ’hello world’ program that
includes a line-by-line description.
If you like looking at simple code first to pique your interest, and then read up from there, start with
the example programs in the test/ and examples/ directory that is included with the source code. A good
place to start is the ’hello world’ program in test/hello.cxx. Also do a google search for ”FLTK example
programs”. ”Erco’s Cheat Page” is one that shows many simple examples of how to do specific things.
If you like to run example programs and look for ones that are like yours and then read them, download
and build FLTK from the source, then run the test/demo program. Also, go into the ’examples/’ directory
and run ’make’, then run some of those programs.
If you prefer watching TV to reading books and code, google search for ”FLTK video tutorials” which
has some introductory examples of how to write FLTK programs in C++ and build them.

23.2 How do I make a box with text?


The ’hello world’ program shows how to make a box with text. All widgets have labels, so picking a simple
widget like Fl Box and setting its label() and using align() to align the label and labelfont() to set the font,
and labelsize() to set the size, you can get text just how you want.
Labels are not selectable though; if you want selectable text, you can use Fl Output or Fl Multiline -
Output for simple text that doesn’t include scrollbars. For more complex text that might want scrollbars and
multiple colors/fonts, use either Fl Text Display which handles plain text, or Fl Help View which handles
simple HTML formatted text.

173
174 CHAPTER 23. FAQ (FREQUENTLY ASKED QUESTIONS)

23.3 Can I use FLTK to make closed-source commercial applica-


tions?
Yes. The FLTK Software License is standard LGPL, but also includes a special clause (”exception”) to
allow for static linking. Specifically:
[from the top of the FLTK LGPL License section on exceptions]

3. Static linking of applications and widgets to the FLTK library does


not constitute a derivative work and does not require the author to
provide source code for the application or widget, use the shared FLTK
libraries, or link their applications or widgets against a user-supplied
version of FLTK.

If you link the application or widget to a modified version of FLTK,


then the changes to FLTK must be provided under the terms of the LGPL
in sections 1, 2, and 4.

4. You do not have to provide a copy of the FLTK license with programs
that are linked to the FLTK library, nor do you have to identify the
FLTK license in your program or documentation as required by section 6
of the LGPL.

However, programs must still identify their use of FLTK. The following
example statement can be included in user documentation to satisfy
this requirement:

[program/widget] is based in part on the work of the


FLTK project (http://www.fltk.org).

23.4 Hitting the ’Escape’ key closes windows - how do I prevent this?
[From FLTK article #378]
1. FLTK has a ”global event handler” that makes Escape try to close the window, the same as clicking
the close box. To disable this everywhere you can install your own that pretends it wants the escape
key and thus stops the default one from seeing it (this may not be what you want, see below about
the callbacks):
static int my handler(int event) {
if (event == FL SHORTCUT) return 1; // eat all shortcut keys
return 0;
}
...in main():
Fl::add handler(my handler);
...

1. Attempts to close a window (both clicking the close box or typing Escape) call that window’s call-
back. The default version of the callback does hide(). To make the window not close or otherwise
do something different you replace the callback. To make the main window exit the program:
void my callback(Fl Widget*, void*) {
exit(0);
}
...
main window->callback(my callback);
...

If you don’t want Escape to close the main window and exit you can check for and ignore it. This is
better than replacing the global handler because Escape will still close pop-up windows:
void my callback(Fl Widget*, void*) {
if (Fl::event()==FL SHORTCUT && Fl::event key()==
FL Escape)
return; // ignore Escape
exit(0);
}
23.4. HITTING THE ’ESCAPE’ KEY CLOSES WINDOWS - HOW DO I PREVENT THIS? 175

It is very common to ask for confirmation before exiting, this can be done with:
void my callback(Fl Widget*, void*) {
if (fl ask("Are you sure you want to quit?"))
exit(0);
}
176 CHAPTER 23. FAQ (FREQUENTLY ASKED QUESTIONS)
Chapter 24

Todo List
Page Adding and Extending Widgets
Clarify Fl Window::damage(uchar) handling - seems confused/wrong? ORing value doesn’t match set-
ting behaviour in FL Widget.H!
Clarify Fl Widget::test shortcut() explanations. Fl Widget.h says Internal Use only, but subclassing
chapter gives details!
Group Box Types
Description of boxtypes is incomplete. See below for the defined enum Fl Boxtype.
See Also
src/Fl get system colors.cxx
Page Drawing Things in FLTK
add an Fl Draw Area Cb typedef to allow fl scroll(...) to be doxygenated?
Member Fl Browser ::scrollbar width (int width)
This method should eventually be removed in 1.4+
Member Fl Browser ::scrollbar width () const
This method should eventually be removed in 1.4+
Member Fl Browser ::sort (int flags=0)
Add a flag to ignore case
Class Fl Button
Refactor the doxygen comments for Fl Button type() documentation.
Refactor the doxygen comments for Fl Button when() documentation.
Class Fl Chart
Refactor Fl Chart::type() information.
Class Fl Choice
Refactor the doxygen comments for Fl Choice changed() documentation.
Class Fl Counter
Refactor the doxygen comments for Fl Counter type() documentation.
Member Fl Cursor
enum Fl Cursor needs maybe an image.
Member Fl File Input::errorcolor () const
Better docs for Fl File Input::errorcolor() - is it even used?

177
178 CHAPTER 24. TODO LIST

Member Fl Group::sizes ()
Should the internal representation of the sizes() array be documented?
Member fl height (int font, int size)
In the future, when the XFT issues are resolved, this function should simply return the ’size’ value.
Member Fl Input ::handle mouse (int, int, int, int, int keepmark=0)
Add comment and parameters
Member Fl Input ::handletext (int e, int, int, int, int)
Add comment and parameters
Member fl intptr t
typedef’s fl intptr t and fl uintptr t should be documented.
Class Fl Label
For FLTK 1.3, the Fl Label type will become a widget by itself. That way we will be avoiding a lot of
code duplication by handling labels in a similar fashion to widgets containing text. We also provide an
easy interface for very complex labels, containing html or vector graphics.
Member Fl Labeltype
The doxygen comments are incomplete, and some labeltypes are starting with an underscore. Also,
there are three external functions undocumented (yet):

• fl define FL SHADOW LABEL()


• fl define FL ENGRAVED LABEL()
• fl define FL EMBOSSED LABEL()
Member Fl Menu ::add (const char ∗, int shortcut, Fl Callback ∗, void ∗=0, int=0)
Raw integer shortcut needs examples. Dependent on responses to http://fltk.org/newsgroups.-
php?gfltk.development+v:10086 and results of STR#2344
Member fl nonspacing (unsigned int ucs)
explain what non-spacing means.
Member fl old shortcut (const char ∗s)
Fix these silly legacy issues in a future release to support more predictable behavior for the modifier
keys.
Member Fl Preferences::get (const char ∗entry, void ∗value, const void ∗defaultValue, int default-
Size, int maxSize)
maxSize should receive the number of bytes that were read.
Member fl reset spot (void)
provide user documentation for fl reset spot function
Member Fl Scroll::bbox (int &, int &, int &, int &)
The visibility of the scrollbars ought to be checked/calculated outside of the draw() method (STR
#1895).
Member fl set spot (int font, int size, int X, int Y, int W, int H, Fl Window ∗win=0)
provide user documentation for fl set spot function
Member fl set status (int X, int Y, int W, int H)
provide user documentation for fl set status function
Member Fl String
FIXME: temporary (?) typedef to mark UTF8 and Unicode conversions
179

Member Fl Text Display::display insert ()


Unicode?
Member Fl Text Display::extend range for styles (int ∗start, int ∗end)
Unicode?
Member Fl Text Display::handle vline (int mode, int lineStart, int lineLen, int leftChar, int right-
Char, int topClip, int bottomClip, int leftClip, int rightClip) const
we need to handle hidden hyphens and tabs here!
we handle all styles and selections
we must provide code to get pixel positions of the middle of a character as well
Member Fl Text Display::overstrike (const char ∗text)
Unicode? Find out exactly what we do here and simplify.
Member Fl Text Display::position to line (int pos, int ∗lineNum) const
What does this do?
Member Fl Text Display::position to linecol (int pos, int ∗lineNum, int ∗column) const
a column number makes little sense in the UTF-8/variable font width environment. We will have to fur-
ther define what exactly we want to return. Please check the functions that call this particular function.
Member Fl Text Display::scroll (int topLineNum, int horizOffset)
Column numbers make little sense here.
Member Fl Text Display::shortcut () const
FIXME : get set methods pointing on shortcut have no effects as shortcut is unused in this class and
derived!
Returns
the current shortcut key
Member Fl Text Display::shortcut (int s)
FIXME : get set methods pointing on shortcut have no effects as shortcut is unused in this class and
derived!
Parameters
s the new shortcut key

Member Fl Text Display::wrap mode (int wrap, int wrap margin)


we need new wrap modes to wrap at the window edge and based on pixel width or average character
width.
Member Fl Text Display::wrapped column (int row, int column) const
What does this do and how is it useful? Column numbers mean little in this context. Which functions
depend on this one?
Unicode?
Member Fl Text Display::wrapped row (int row) const
What does this do and how is it useful? Column numbers mean little in this context. Which functions
depend on this one?
Member Fl Tree::handle (int e)
add Fl Widget Tracker (see Fl Browser .cxx::handle())
Member Fl Tree::is scrollbar (Fl Widget ∗w)
should be const
180 CHAPTER 24. TODO LIST

Member Fl Tree::show self ()


should be const
Version
1.3.0

Member Fl When
doxygen comments for values are incomplete and maybe wrong or unclear
Member Fl Widget::argument (long v)
The user data value must be implemented using intptr t or similar to avoid 64-bit machine incompati-
bilities.
Member Fl Widget::type () const
Explain ”simulate RTTI” (currently only used to decide if a widget is a window, i.e. type()>=FL WI-
NDOW ?). Is type() really used in a way that ensures ”Forms compatibility” ?
Member Fl Window::show (int argc, char ∗∗argv)
explain which system parameters are set up.
Page Handling Events
Add details on how to detect repeating keys, since on some X servers a repeating key will generate both
FL KEYUP and FL KEYDOWN, such that to tell if a key is held, you need Fl::event key(int) to detect
if the key is being held down during FL KEYUP or not.
Group Mouse and Keyboard Events
FL Button and FL key... constants could be structured better (use an enum or some doxygen grouping
?)
Page Unicode and UTF-8 Support
Do we need this info about planes?
Work through the code and this documentation to harmonize the [OksiD] and [fltk2] functions.
Verify 16/24 bit Unicode limit for different character sets? OksiD’s code appears limited to 16-bit
whereas the FLTK2 code appears to handle a wider set. What about illegal characters? See comments
in fl utf8fromwc() and fl utf8toUtf16().
Chapter 25

Deprecated List

Member Fl::release ()
Use Fl::grab(0) instead.
See Also
grab(Fl Window∗)
Member Fl::set idle (Fl Old Idle Handler cb)
This method is obsolete - use the add idle() method instead.
Member fl clip
fl clip(int, int, int, int) is deprecated and will be removed from future releases. Please use fl push -
clip(int x, int y, int w, int h) instead.
Member Fl Group::focus (Fl Widget ∗W)
This is for backwards compatibility only. You should use W->take focus() instead.
See Also
Fl Widget::take focus();
Member Fl Menu Item::check ()
.
Member Fl Menu Item::checked () const
.
Member Fl Menu Item::uncheck ()
.
Member Fl Spinner::maxinum () const

Member Fl Spinner::mininum () const

Member Fl Tree::first visible ()


in 1.3.3 ABI – use first visible item() instead.
Member Fl Tree::item clicked (Fl Tree Item ∗val)
in 1.3.3 ABI – use callback item() instead.
Member Fl Tree::item clicked ()
in 1.3.3 ABI – use callback item() instead.

181
182 CHAPTER 25. DEPRECATED LIST

Member Fl Tree::last visible ()


in 1.3.3 – use last visible item() instead.
Member Fl Tree Item::next displayed (Fl Tree Prefs &prefs)
in 1.3.3 for confusing name, use next visible() instead
Member Fl Tree Item::prev displayed (Fl Tree Prefs &prefs)
in 1.3.3 for confusing name, use prev visible()
Member Fl Widget::color2 (unsigned a)
Use selection color(unsigned) instead.
Member Fl Widget::color2 () const
Use selection color() instead.
Member Fl Window::free position ()
please use force position(0) instead
Member Fl Window::icon () const
in 1.3.3
Member Fl Window::icon (const void ∗ic)
in 1.3.3
Chapter 26

Module Index

26.1 Modules
Here is a list of all modules:
Callback function typedefs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Windows handling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Events handling functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Selection & Clipboard functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
Screen functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224
Color & Font functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
Drawing functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236
Multithreading support functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255
Safe widget deletion support functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257
Cairo support functions and classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Unicode and UTF-8 functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
Mac OS X-specific symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Common Dialogs classes and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
File names and URI utility functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

183
184 CHAPTER 26. MODULE INDEX
Chapter 27

Hierarchical Index

27.1 Class Hierarchy


This inheritance list is sorted roughly, but not completely, alphabetically:
Fl Preferences::Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Fl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Fl Cairo State . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357
FL CHART ENTRY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Fl Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
Fl Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
Fl GDI Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 421
Fl GDI Printer Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425
Fl PostScript Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Fl Quartz Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 611
Fl Xlib Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 877
Fl Surface Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 652
Fl Copy Surface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 381
Fl Display Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 390
Fl Image Surface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486
Fl Paged Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 560
Fl PostScript File Device . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 576
Fl PostScript Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 590
Fl Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Fl System Printer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 657
Fl End . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Fl File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395
Fl File Icon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Fl FLTK File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Fl GTK File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Fl Font Descriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Fl Fontdesc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Fl Gl Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Fl Glut Bitmap Font . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Fl Glut StrokeChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Fl Glut StrokeFont . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Fl Glut StrokeStrip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Fl Glut StrokeVertex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Fl Help Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468

185
186 CHAPTER 27. HIERARCHICAL INDEX

Fl Help Dialog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468


Fl Help Font Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Fl Help Font Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Fl Help Link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 472
Fl Help Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Fl Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483
Fl Bitmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315
Fl XBM Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
Fl Pixmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
Fl GIF Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426
Fl XPM Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
Fl RGB Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
Fl BMP Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317
Fl JPEG Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 510
Fl PNG Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Fl PNM Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Fl Shared Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
Fl Tiled Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 743
Fl Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 511
Fl Mac App Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Fl Menu Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Fl Multi Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Fl Native File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Fl Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 569
Fl Device Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Fl Preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 591
Fl Plugin Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 570
Fl Scroll::ScrollInfo::Fl Region LRTB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 616
Fl Scroll::ScrollInfo::Fl Region XYWH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
Fl Scroll::ScrollInfo::Fl Scrollbar Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 635
Fl Text Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 686
Fl Text Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738
Fl Tooltip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 748
Fl Tree Item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
Fl Tree Item Array . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 803
Fl Tree Prefs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806
Fl Widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 823
Fl Box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 318
Fl Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353
Fl Light Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
Fl Check Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367
Fl Radio Light Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
Fl Round Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 626
Fl Radio Round Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
Fl Radio Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
Fl Repeat Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 617
Fl Return Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 618
Fl Toggle Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
Fl Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
Fl Clock Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
Fl Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371
Fl Round Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 627
27.1. CLASS HIERARCHY 187

Fl FormsBitmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Fl FormsPixmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Fl FormsText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Fl Free . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 419
Fl Group . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Fl Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Fl Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 319
Fl File Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Fl Hold Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 479
Fl Multi Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 546
Fl Select Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Fl Check Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Fl Color Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Fl Help View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Fl Input Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
Fl Pack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Fl Scroll . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
Fl Spinner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
Fl Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 661
Fl Table Row . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
Fl Tabs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
Fl Text Display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Fl Text Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 733
Fl Tile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 741
Fl Tree . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752
Fl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
Fl Double Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391
Fl Cairo Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 358
Fl Overlay Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 556
Fl Gl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Fl Glut Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Fl Single Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
Fl Menu Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Fl Wizard . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874
Fl Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 490
Fl Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488
Fl File Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
Fl Float Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Fl Int Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
Fl Multiline Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Fl Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 555
Fl Multiline Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 548
Fl Secret Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 636
Fl Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 516
Fl Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368
Fl Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
Fl Sys Menu Bar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
Fl Menu Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Fl Positioner . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 573
Fl Progress . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 609
Fl Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
Fl Valuator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 810
188 CHAPTER 27. HIERARCHICAL INDEX

Fl Adjuster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Fl Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 382
Fl Simple Counter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 642
Fl Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 388
Fl Fill Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Fl Line Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Fl Roller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 624
Fl Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
Fl Fill Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 411
Fl Hor Fill Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Fl Hor Nice Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Fl Hor Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Fl Nice Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Fl Scrollbar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
Fl Value Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 821
Fl Hor Value Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Fl Value Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814
Fl Value Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818
Fl Widget Tracker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857
Fl XColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
Fl Text Editor::Key Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881
Fl Graphics Driver::matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 881
Fl Preferences::Name . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 882
Fl Preferences::Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
Fl Paged Device::page format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
Fl Preferences::RootNode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
Fl Window::shape data type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
Fl Text Display::Style Table Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
Chapter 28

Class Index

28.1 Class List


Here are the classes, structs, unions and interfaces with brief descriptions:
Fl Preferences::Entry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Fl
The Fl is the FLTK global (static) class containing state information and global
methods for the current application . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
Fl Adjuster
Was stolen from Prisms, and has proven to be very useful for values that need a
large dynamic range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 312
Fl Bitmap
Supports caching and drawing of mono-color (bitmap) images . . . . . . . . . . . 315
Fl BMP Image
Supports loading, caching, and drawing of Windows Bitmap (BMP) image files . . 317
Fl Box
This widget simply draws its box, and possibly its label . . . . . . . . . . . . . . 318
Fl Browser
Displays a scrolling list of text lines, and manages all the storage for the text . . . 319
Fl Browser
This is the base class for browsers . . . . . . . . . . . . . . . . . . . . . . . . . . 338
Fl Button
Buttons generate callbacks when they are clicked by the user . . . . . . . . . . . . 353
Fl Cairo State
Contains all the necessary info on the current cairo context . . . . . . . . . . . . . 357
Fl Cairo Window
This defines a pre-configured cairo fltk window . . . . . . . . . . . . . . . . . . . 358
Fl Chart
Fl Chart displays simple charts . . . . . . . . . . . . . . . . . . . . . . . . . . . 359
FL CHART ENTRY
For internal use only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363
Fl Check Browser
Displays a scrolling list of text lines that may be selected and/or checked by the user 363
Fl Check Button
A button with a ”checkmark” to show its status . . . . . . . . . . . . . . . . . . . 367
Fl Choice
A button that is used to pop up a menu . . . . . . . . . . . . . . . . . . . . . . . 368
Fl Clock
This widget provides a round analog clock display . . . . . . . . . . . . . . . . . 371

189
190 CHAPTER 28. CLASS INDEX

Fl Clock Output
This widget can be used to display a program-supplied time . . . . . . . . . . . . 374
Fl Color Chooser
Standard RGB color chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 377
Fl Copy Surface
Supports copying of graphical data to the clipboard . . . . . . . . . . . . . . . . . 381
Fl Counter
Controls a single floating point value with button (or keyboard) arrows . . . . . . 382
Fl Device
All graphical output devices and all graphics systems . . . . . . . . . . . . . . . . 385
Fl Device Plugin
This plugin socket allows the integration of new device drivers for special window
or screen types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 387
Fl Dial
Circular dial to control a single floating point value . . . . . . . . . . . . . . . . . 388
Fl Display Device
A display to which the computer can draw . . . . . . . . . . . . . . . . . . . . . 390
Fl Double Window
The Fl Double Window provides a double-buffered window . . . . . . . . . . . . 391
Fl End
This is a dummy class that allows you to end a Fl Group in a constructor list of a
class: . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 393
Fl File Browser
Displays a list of filenames, optionally with file-specific icons . . . . . . . . . . . 393
Fl File Chooser
Displays a standard file selection dialog that supports various selection modes . . . 395
Fl File Icon
Manages icon images that can be used as labels in other widgets and as icons in the
FileBrowser widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
Fl File Input
This widget displays a pathname in a text input field . . . . . . . . . . . . . . . . 408
Fl Fill Dial
Draws a dial with a filled arc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
Fl Fill Slider
Widget that draws a filled horizontal slider, useful as a progress or value meter . . 411
Fl Float Input
Subclass of Fl Input that only allows the user to type floating point numbers (sign,
digits, decimal point, more digits, ’E’ or ’e’, sign, digits) . . . . . . . . . . . . . . . . 412
Fl FLTK File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 412
Fl Font Descriptor
This a structure for an actual system font, with junk to help choose it and info on
character sizes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Fl Fontdesc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 414
Fl FormsBitmap
Forms compatibility Bitmap Image Widget . . . . . . . . . . . . . . . . . . . . . 414
Fl FormsPixmap
Forms pixmap drawing routines . . . . . . . . . . . . . . . . . . . . . . . . . . . 415
Fl FormsText . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 418
Fl Free
Emulation of the Forms ”free” widget . . . . . . . . . . . . . . . . . . . . . . . . 419
Fl GDI Graphics Driver
The MSWindows-specific graphics class . . . . . . . . . . . . . . . . . . . . . . 421
Fl GDI Printer Graphics Driver
The graphics driver used when printing on MSWindows . . . . . . . . . . . . . . 425
28.1. CLASS LIST 191

Fl GIF Image
Supports loading, caching, and drawing of Compuserve GIFSM images . . . . . . 426
Fl Gl Choice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Fl Gl Window
Sets things up so OpenGL works . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
Fl Glut Bitmap Font
Fltk glut font/size attributes used in the glutXXX functions . . . . . . . . . . . . . 433
Fl Glut StrokeChar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Fl Glut StrokeFont . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
Fl Glut StrokeStrip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Fl Glut StrokeVertex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434
Fl Glut Window
GLUT is emulated using this window class and these static variables (plus several
more static variables hidden in glut compatability.cxx): . . . . . . . . . . . . . . . . 434
Fl Graphics Driver
A virtual class subclassed for each graphics driver FLTK uses . . . . . . . . . . . 436
Fl Group
FLTK container widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
Fl GTK File Chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Fl Help Block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 468
Fl Help Dialog
Displays a standard help dialog window using the Fl Help View widget . . . . . . 468
Fl Help Font Stack . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
Fl Help Font Style
Fl Help View font stack element definition . . . . . . . . . . . . . . . . . . . . . 472
Fl Help Link
Definition of a link for the html viewer . . . . . . . . . . . . . . . . . . . . . . . 472
Fl Help Target
Fl Help Target structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Fl Help View
Displays HTML text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 473
Fl Hold Browser
The Fl Hold Browser is a subclass of Fl Browser which lets the user select a single
item, or no items by clicking on the empty space . . . . . . . . . . . . . . . . . . . . 479
Fl Hor Fill Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 480
Fl Hor Nice Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Fl Hor Slider
Horizontal Slider class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 481
Fl Hor Value Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 482
Fl Image
Fl Image is the base class used for caching and drawing all kinds of images in FLTK 483
Fl Image Surface
Directs all graphics requests to an Fl Image . . . . . . . . . . . . . . . . . . . . . 486
Fl Input
This is the FLTK text input widget . . . . . . . . . . . . . . . . . . . . . . . . . . 488
Fl Input
This class provides a low-overhead text input field . . . . . . . . . . . . . . . . . 490
Fl Input Choice
A combination of the input widget and a menu button . . . . . . . . . . . . . . . 505
Fl Int Input
Subclass of Fl Input that only allows the user to type decimal digits (or hex numbers
of the form 0xaef) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 509
192 CHAPTER 28. CLASS INDEX

Fl JPEG Image
Supports loading, caching, and drawing of Joint Photographic Experts Group (JPE-
G) File Interchange Format (JFIF) images . . . . . . . . . . . . . . . . . . . . . . . . 510
Fl Label
This struct stores all information for a text or mixed graphics label . . . . . . . . . 511
Fl Light Button
This subclass displays the ”on” state by turning on a light, rather than drawing
pushed in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 513
Fl Line Dial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515
Fl Mac App Menu
Mac OS-specific class allowing to localize the application menu . . . . . . . . . . 515
Fl Menu
Base class of all widgets that have a menu in FLTK . . . . . . . . . . . . . . . . . 516
Fl Menu Bar
This widget provides a standard menubar interface . . . . . . . . . . . . . . . . . 528
Fl Menu Button
This is a button that when pushed pops up a menu (or hierarchy of menus) defined
by an array of Fl Menu Item objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 530
Fl Menu Item
The Fl Menu Item structure defines a single menu item that is used by the Fl Menu-
class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 533
Fl Menu Window
Window type used for menus . . . . . . . . . . . . . . . . . . . . . . . . . . . . 544
Fl Multi Browser
Subclass of Fl Browser which lets the user select any set of the lines . . . . . . . . 546
Fl Multi Label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547
Fl Multiline Input
This input field displays ’\n’ characters as new lines rather than ∧ J, and accepts the
Return, Tab, and up and down arrow keys . . . . . . . . . . . . . . . . . . . . . . . . 547
Fl Multiline Output
This widget is a subclass of Fl Output that displays multiple lines of text . . . . . 548
Fl Native File Chooser
This class lets an FLTK application easily and consistently access the operating
system’s native file chooser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 549
Fl Nice Slider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 554
Fl Output
This widget displays a piece of text . . . . . . . . . . . . . . . . . . . . . . . . . 555
Fl Overlay Window
This window provides double buffering and also the ability to draw the ”overlay”
which is another picture placed on top of the main image . . . . . . . . . . . . . . . . 556
Fl Pack
This widget was designed to add the functionality of compressing and aligning wid-
gets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 559
Fl Paged Device
Represents page-structured drawing surfaces . . . . . . . . . . . . . . . . . . . . 560
Fl Pixmap
Supports caching and drawing of colormap (pixmap) images, including transparency
566
Fl Plugin
Fl Plugin allows link-time and run-time integration of binary modules . . . . . . . 569
Fl Plugin Manager
Fl Plugin Manager manages link-time and run-time plugin binaries . . . . . . . . 570
28.1. CLASS LIST 193

Fl PNG Image
Supports loading, caching, and drawing of Portable Network Graphics (PNG) image
files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
Fl PNM Image
Supports loading, caching, and drawing of Portable Anymap (PNM, PBM, PGM,
PPM) image files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 572
Fl Positioner
This class is provided for Forms compatibility . . . . . . . . . . . . . . . . . . . 573
Fl PostScript File Device
To send graphical output to a PostScript file . . . . . . . . . . . . . . . . . . . . . 576
Fl PostScript Graphics Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 581
Fl PostScript Printer
Print support under Unix/Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . 590
Fl Preferences
Fl Preferences provides methods to store user settings between application starts . 591
Fl Printer
OS-independent print support . . . . . . . . . . . . . . . . . . . . . . . . . . . . 603
Fl Progress
Displays a progress bar for the user . . . . . . . . . . . . . . . . . . . . . . . . . 609
Fl Quartz Graphics Driver
The Mac OS X-specific graphics class . . . . . . . . . . . . . . . . . . . . . . . . 611
Fl Radio Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
Fl Radio Light Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
Fl Radio Round Button . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 615
Fl Scroll::ScrollInfo::Fl Region LRTB
A local struct to manage a region defined by left/right/top/bottom . . . . . . . . . 616
Fl Scroll::ScrollInfo::Fl Region XYWH
A local struct to manage a region defined by xywh . . . . . . . . . . . . . . . . . 617
Fl Repeat Button
The Fl Repeat Button is a subclass of Fl Button that generates a callback when it
is pressed and then repeatedly generates callbacks as long as it is held down . . . . . . 617
Fl Return Button
The Fl Return Button is a subclass of Fl Button that generates a callback when it is
pressed or when the user presses the Enter key . . . . . . . . . . . . . . . . . . . . . 618
Fl RGB Image
Supports caching and drawing of full-color images with 1 to 4 channels of color
information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 620
Fl Roller
”dolly” control commonly used to move 3D objects . . . . . . . . . . . . . . . . . 624
Fl Round Button
Buttons generate callbacks when they are clicked by the user . . . . . . . . . . . . 626
Fl Round Clock
A clock widget of type FL ROUND CLOCK . . . . . . . . . . . . . . . . . . . . 627
Fl Scroll
This container widget lets you maneuver around a set of widgets much larger than
your window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 628
Fl Scrollbar
Displays a slider with arrow buttons at the ends of the scrollbar . . . . . . . . . . 632
Fl Scroll::ScrollInfo::Fl Scrollbar Data
A local struct to manage a scrollbar’s xywh region and tab values . . . . . . . . . 635
Fl Secret Input
Subclass of Fl Input that displays its input as a string of placeholders . . . . . . . 636
194 CHAPTER 28. CLASS INDEX

Fl Select Browser
The class is a subclass of Fl Browser which lets the user select a single item, or no
items by clicking on the empty space . . . . . . . . . . . . . . . . . . . . . . . . . . 637
Fl Shared Image
This class supports caching, loading, and drawing of image files . . . . . . . . . . 638
Fl Simple Counter
This widget creates a counter with only 2 arrow buttons . . . . . . . . . . . . . . 642
Fl Single Window
This is the same as Fl Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
Fl Slider
Sliding knob inside a box . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 644
Fl Spinner
This widget is a combination of the input widget and repeat buttons . . . . . . . . 647
Fl Surface Device
A surface that’s susceptible to receive graphical output . . . . . . . . . . . . . . . 652
Fl Sys Menu Bar
A class to create, modify and delete menus that appear on Mac OS X in the menu
bar at the top of the screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
Fl System Printer
Print support under MSWindows and Mac OS . . . . . . . . . . . . . . . . . . . . 657
Fl Table
A table of widgets or other content . . . . . . . . . . . . . . . . . . . . . . . . . . 661
Fl Table Row
A table with row selection capabilities . . . . . . . . . . . . . . . . . . . . . . . . 677
Fl Tabs
”file card tabs” interface that allows you to put lots and lots of buttons and switches
in a panel, as popularized by many toolkits . . . . . . . . . . . . . . . . . . . . . . . 680
Fl Text Buffer
This class manages unicode displayed in one or more Fl Text Display widgets . . 686
Fl Text Display
Rich text display widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
Fl Text Editor
This is the FLTK text editor widget . . . . . . . . . . . . . . . . . . . . . . . . . 733
Fl Text Selection
This is an internal class for Fl Text Buffer to manage text selections . . . . . . . . 738
Fl Tile
Lets you resize its children by dragging the border between them . . . . . . . . . 741
Fl Tiled Image
This class supports tiling of images over a specified area . . . . . . . . . . . . . . 743
Fl Timer
This is provided only to emulate the Forms Timer widget . . . . . . . . . . . . . . 745
Fl Toggle Button
The toggle button is a push button that needs to be clicked once to toggle on, and
one more time to toggle off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 747
Fl Tooltip
Tooltip support for all FLTK widgets . . . . . . . . . . . . . . . . . . . . . . . . 748
Fl Tree
Tree widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752
Fl Tree Item
Tree widget item . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
Fl Tree Item Array
Manages an array of Fl Tree Item pointers . . . . . . . . . . . . . . . . . . . . . 803
Fl Tree Prefs
Tree widget’s preferences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 806
28.1. CLASS LIST 195

Fl Valuator
Controls a single floating-point value and provides a consistent interface to set the
value, range, and step, and insures that callbacks are done the same for every object . . 810
Fl Value Input
Displays a numeric value . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 814
Fl Value Output
Displays a floating point value . . . . . . . . . . . . . . . . . . . . . . . . . . . . 818
Fl Value Slider
Fl Slider widget with a box displaying the current value . . . . . . . . . . . . . . 821
Fl Widget
Fl Widget is the base class for all widgets in FLTK . . . . . . . . . . . . . . . . . 823
Fl Widget Tracker
This class should be used to control safe widget deletion . . . . . . . . . . . . . . 857
Fl Window
This widget produces an actual window . . . . . . . . . . . . . . . . . . . . . . . 858
Fl Wizard
This widget is based off the Fl Tabs widget, but instead of displaying tabs it only
changes ”tabs” under program control . . . . . . . . . . . . . . . . . . . . . . . . . . 874
Fl XBM Image
Supports loading, caching, and drawing of X Bitmap (XBM) bitmap files . . . . . 876
Fl XColor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 876
Fl Xlib Graphics Driver
The Xlib-specific graphics class . . . . . . . . . . . . . . . . . . . . . . . . . . . 877
Fl XPM Image
Supports loading, caching, and drawing of X Pixmap (XPM) images, including
transparency . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 880
Fl Text Editor::Key Binding
Simple linked list associating a key/state to a function . . . . . . . . . . . . . . . 881
Fl Graphics Driver::matrix
A 2D coordinate transformation matrix . . . . . . . . . . . . . . . . . . . . . . . 881
Fl Preferences::Name
’Name’ provides a simple method to create numerical or more complex procedural
names for entries and groups on the fly . . . . . . . . . . . . . . . . . . . . . . . . . 882
Fl Preferences::Node . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 883
Fl Paged Device::page format
Width, height and name of a page format . . . . . . . . . . . . . . . . . . . . . . 883
Fl Preferences::RootNode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
Fl Window::shape data type
Data supporting a non-rectangular window shape . . . . . . . . . . . . . . . . . . 884
Fl Text Display::Style Table Entry
This structure associates the color, font, andsize of a string to draw with an attribute
mask matching attr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 884
196 CHAPTER 28. CLASS INDEX
Chapter 29

File Index

29.1 File List


Here is a list of all documented files with brief descriptions:
armscii 8.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
ascii.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
big5.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
big5 emacs.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
case.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
cgdebug.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
cp1133.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
cp1251.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
cp1255.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
cp1256.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
cp936ext.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
dingbats .h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
dirent.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Enumerations.H
This file contains type definitions and general enumerations . . . . . . . . . . . . 889
fastarrow.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
filename.H
File names and URI utility functions . . . . . . . . . . . . . . . . . . . . . . . . . 909
Fl.H
Fl static class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 910
Fl Adjuster.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl arc.cxx
Utility functions for drawing arcs and circles . . . . . . . . . . . . . . . . . . . . 911
fl arci.cxx
Utility functions for drawing circles using integers . . . . . . . . . . . . . . . . . 911
fl ask.cxx
Utility functions for common dialogs . . . . . . . . . . . . . . . . . . . . . . . . 912
fl ask.H
API for common dialogs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 913
Fl Bitmap.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl BMP Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Box.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl boxtype.cxx
Drawing code for common box types . . . . . . . . . . . . . . . . . . . . . . . . 915
Fl Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??

197
198 CHAPTER 29. FILE INDEX

Fl Browser .H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Cairo.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Cairo Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Chart.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Check Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Check Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Choice.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Clock.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl cmap.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl color.cxx
Color handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 916
Fl Color Chooser.H
Fl Color Chooser widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
Fl compose.cxx
Utility functions to support text input . . . . . . . . . . . . . . . . . . . . . . . . 918
Fl Copy Surface.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Counter.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl curve.cxx
Utility for drawing Bezier curves, adding the points to the current fl begin/fl -
vertex/fl end path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
Fl Device.H
Declaration of classes Fl Device, Fl Graphics Driver, Fl Surface Device, Fl Display-
Device, Fl Device Plugin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 918
Fl Dial.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Double Window.cxx
Fl Double Window implementation . . . . . . . . . . . . . . . . . . . . . . . . . 920
Fl Double Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl draw.H
Utility header to pull drawing functions together . . . . . . . . . . . . . . . . . . 920
Fl Export.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl File Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl File Chooser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl File Icon.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl File Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Fill Dial.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Fill Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Float Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Font.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl FormsBitmap.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl FormsPixmap.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Free.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl GIF Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Gl Choice.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Gl Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Group.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Help Dialog.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Help View.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hold Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hor Fill Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hor Nice Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hor Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Hor Value Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
29.1. FILE LIST 199

Fl Image.H
Fl Image, Fl RGB Image classes . . . . . . . . . . . . . . . . . . . . . . . . . . 926
Fl Image Surface.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Input .H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Input Choice.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Int Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl JPEG Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Light Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Line Dial.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl line style.cxx
Line style drawing utility hiding different platforms . . . . . . . . . . . . . . . . . 927
Fl Menu.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu .H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu Bar.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu Item.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Menu Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl message.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Multi Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Multi Label.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Multiline Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Multiline Output.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Native File Chooser.H
Fl Native File Chooser widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . 927
Fl Nice Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Object.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Output.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Overlay Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Pack.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Paged Device.cxx
Implementation of class Fl Paged Device . . . . . . . . . . . . . . . . . . . . . . 927
Fl Paged Device.H
Declaration of class Fl Paged Device . . . . . . . . . . . . . . . . . . . . . . . . 928
Fl Pixmap.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Plugin.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl PNG Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl PNM Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Positioner.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl PostScript.H
Declaration of classes Fl PostScript Graphics Driver, Fl PostScript File Device . 928
Fl Preferences.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Printer.H
Declaration of classes Fl Printer, Fl System Printer and Fl PostScript Printer . . . 930
Fl Progress.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Radio Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Radio Light Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Radio Round Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl rect.cxx
Drawing and clipping routines for rectangles . . . . . . . . . . . . . . . . . . . . 931
Fl Repeat Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Return Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl RGB Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Roller.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
200 CHAPTER 29. FILE INDEX

Fl Round Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Round Clock.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Scroll.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Scrollbar.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Secret Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Select Browser.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Shared Image.H
Fl Shared Image class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 931
fl show colormap.H
The fl show colormap() function hides the implementation classes used to provide
the popup window and color selection mechanism . . . . . . . . . . . . . . . . . . . 932
fl show input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Simple Counter.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Single Window.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Spinner.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Sys Menu Bar.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Table.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Table Row.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tabs.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Text Buffer.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Text Display.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Text Editor.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tile.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tiled Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Timer.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Toggle Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Toggle Light Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Toggle Round Button.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tooltip.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Tree.H
This file contains the definitions of the Fl Tree class . . . . . . . . . . . . . . . . 932
Fl Tree Item.H
This file contains the definitions for Fl Tree Item . . . . . . . . . . . . . . . . . . 933
Fl Tree Item Array.H
This file defines a class that manages an array of Fl Tree Item pointers . . . . . . 933
Fl Tree Prefs.H
This file contains the definitions for Fl Tree’s preferences . . . . . . . . . . . . . 934
fl types.h
This file contains simple ”C”-style type definitions . . . . . . . . . . . . . . . . . 935
fl utf8.h
Header for Unicode and UTF8 chracter handling . . . . . . . . . . . . . . . . . . 936
Fl Valuator.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Value Input.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Value Output.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl Value Slider.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
fl vertex.cxx
Portable drawing code for drawing arbitrary shapes with simple 2D transformations 938
Fl Widget.H
Fl Widget, Fl Label classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 938
Fl Window.H
Fl Window widget . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 939
Fl Wizard.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl XBM Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
29.1. FILE LIST 201

Fl XColor.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Fl XPM Image.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
flstring.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
forms.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
freeglut teapot data.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
gb2312.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
georgian academy.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
georgian ps.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
gl.h
This file defines wrapper functions for OpenGL in FLTK . . . . . . . . . . . . . . 939
gl2opengl.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
gl draw.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
glu.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
glut.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 1.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 10.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 11.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 13.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 14.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 15.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 16.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 2.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 3.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 4.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 5.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 6.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 7.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 8.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 9.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
iso8859 9e.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
jisx0201.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
jisx0208.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
jisx0212.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
koi8 c.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
koi8 r.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
koi8 u.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
ksc5601.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
mac.H
Mac OS X-specific symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 942
math.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
mediumarrow.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
mulelao.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
names.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
print panel.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
slowarrow.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
spacing.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
symbol .h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
tatar cyr.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
tcvn.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
tis620.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
ucs2be.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
utf8.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
viscii.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
win32.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
202 CHAPTER 29. FILE INDEX

x.H . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Ximint.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Xlibint.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Xutf8.h . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ??
Chapter 30

Module Documentation

30.1 Callback function typedefs


Typedefs defined in <FL/Fl.H> for callback or handler functions passed as function parameters.

Typedefs
• typedef void(∗ Fl Abort Handler )(const char ∗format,...)
Signature of set abort functions passed as parameters.
• typedef int(∗ Fl Args Handler )(int argc, char ∗∗argv, int &i)
Signature of args functions passed as parameters.
• typedef void(∗ Fl Atclose Handler )(Fl Window ∗window, void ∗data)
Signature of set atclose functions passed as parameters.
• typedef void(∗ Fl Awake Handler )(void ∗data)
Signature of some wakeup callback functions passed as parameters.
• typedef void( Fl Box Draw F )(int x, int y, int w, int h, Fl Color color)
Signature of some box drawing functions passed as parameters.
• typedef void(∗ Fl Clipboard Notify Handler )(int source, void ∗data)
Signature of add clipboard notify functions passed as parameters.
• typedef int(∗ Fl Event Dispatch )(int event, Fl Window ∗w)
Signature of event dispatch functions passed as parameters.
• typedef int(∗ Fl Event Handler )(int event)
Signature of add handler functions passed as parameters.
• typedef void(∗ Fl FD Handler )(FL SOCKET fd, void ∗data)
Signature of add fd functions passed as parameters.
• typedef void(∗ Fl Idle Handler )(void ∗data)
Signature of add idle callback functions passed as parameters.
• typedef void( Fl Label Draw F )(const Fl Label ∗label, int x, int y, int w, int h, Fl Align align)
Signature of some label drawing functions passed as parameters.
• typedef void( Fl Label Measure F )(const Fl Label ∗label, int &width, int &height)
Signature of some label measurement functions passed as parameters.
• typedef void(∗ Fl Old Idle Handler )()
Signature of set idle callback functions passed as parameters.
• typedef int(∗ Fl System Handler )(void ∗event, void ∗data)
Signature of add system handler functions passed as parameters.
• typedef void(∗ Fl Timeout Handler )(void ∗data)
Signature of some timeout callback functions passed as parameters.

203
204 CHAPTER 30. MODULE DOCUMENTATION

30.1.1 Detailed Description


Typedefs defined in <FL/Fl.H> for callback or handler functions passed as function parameters. FLTK
uses callback functions as parameters for some function calls, e.g. to set up global event handlers (Fl::add-
handler()), to add a timeout handler (Fl::add timeout()), and many more.
The typedefs defined in this group describe the function parameters used to set up or clear the callback
functions and should also be referenced to define the callback function to handle such events in the user’s
code.
See Also
Fl::add handler(), Fl::add timeout(), Fl::repeat timeout(), Fl::remove timeout() and others

30.1.2 Typedef Documentation


typedef int(∗ Fl Event Dispatch)(int event, Fl Window ∗w)
Signature of event dispatch functions passed as parameters.
See Also
Fl::event dispatch(Fl Event Dispatch)
30.2. WINDOWS HANDLING FUNCTIONS 205

30.2 Windows handling functions


Windows and standard dialogs handling declared in <FL/Fl.H>

Functions
• static void Fl::default atclose (Fl Window ∗, void ∗)
Default callback for window widgets.
• static Fl Window ∗ Fl::first window ()
Returns the first top-level window in the list of shown() windows.
• static void Fl::first window (Fl Window ∗)
Sets the window that is returned by first window().
• static Fl Window ∗ Fl::grab ()
Returns the window that currently receives all events.
• static void Fl::grab (Fl Window ∗)
Selects the window to grab.
• static Fl Window ∗ Fl::modal ()
Returns the top-most modal() window currently shown.
• static Fl Window ∗ Fl::next window (const Fl Window ∗)
Returns the next top-level window in the list of shown() windows.
• static void Fl::set abort (Fl Abort Handler f)
For back compatibility, sets the void Fl::fatal handler callback.
• static void Fl::set atclose (Fl Atclose Handler f)
For back compatibility, sets the Fl::atclose handler callback.

Variables
• static void(∗ Fl::atclose )(Fl Window ∗, void ∗)
Back compatibility: default window callback handler.

30.2.1 Detailed Description


Windows and standard dialogs handling declared in <FL/Fl.H>

30.2.2 Function Documentation


void Fl::default atclose ( Fl Window ∗ window, void ∗ v ) [static]
Default callback for window widgets.
It hides the window and then calls the default widget callback.

Fl Window ∗ Fl::first window ( ) [static]


Returns the first top-level window in the list of shown() windows.
If a modal() window is shown this is the top-most modal window, otherwise it is the most recent window
to get an event.

void Fl::first window ( Fl Window ∗ window ) [static]


Sets the window that is returned by first window().
The window is removed from wherever it is in the list and inserted at the top. This is not done if Fl-
::modal() is on or if the window is not shown(). Because the first window is used to set the ”parent” of
modal windows, this is often useful.
206 CHAPTER 30. MODULE DOCUMENTATION

static Fl Window∗ Fl::grab ( ) [inline], [static]


Returns the window that currently receives all events.
Returns
The window that currently receives all events, or NULL if event grabbing is currently OFF.

void Fl::grab ( Fl Window ∗ win ) [static]


Selects the window to grab.
This is used when pop-up menu systems are active.
Send all events to the passed window no matter where the pointer or focus is (including in other pro-
grams). The window does not have to be shown() , this lets the handle() method of a ”dummy” window
override all event handling and allows you to map and unmap a complex set of windows (under both X and
WIN32 some window must be mapped because the system interface needs a window id).
If grab() is on it will also affect show() of windows by doing system-specific operations (on X it turns
on override-redirect). These are designed to make menus popup reliably and faster on the system.
To turn off grabbing do Fl::grab(0).
Be careful that your program does not enter an infinite loop while grab() is on. On X this will lock
up your screen! To avoid this potential lockup, all newer operating systems seem to limit mouse pointer
grabbing to the time during which a mouse button is held down. Some OS’s may not support grabbing at
all.

static Fl Window∗ Fl::modal ( ) [inline], [static]


Returns the top-most modal() window currently shown.
This is the most recently shown() window with modal() true, or NULL if there are no modal() windows
shown(). The modal() window has its handle() method called for all events, and no other windows will
have handle() called (grab() overrides this).

Fl Window ∗ Fl::next window ( const Fl Window ∗ window ) [static]


Returns the next top-level window in the list of shown() windows.
You can use this call to iterate through all the windows that are shown().
Parameters
in window must be shown and not NULL

static void Fl::set atclose ( Fl Atclose Handler f ) [inline], [static]


For back compatibility, sets the Fl::atclose handler callback.
You can now simply change the callback for the window instead.
See Also
Fl Window::callback(Fl Callback∗)

30.2.3 Variable Documentation


void(∗ Fl::atclose)(Fl Window ∗, void ∗)=default atclose [static], [default]
Back compatibility: default window callback handler.
See Also
Fl::set atclose()
30.3. EVENTS HANDLING FUNCTIONS 207

30.3 Events handling functions


Fl class events handling API declared in <FL/Fl.H>

Functions
• static void Fl::add handler (Fl Event Handler h)
Install a function to parse unrecognized events.
• static void Fl::add system handler (Fl System Handler h, void ∗data)
Install a function to intercept system events.
• static Fl Widget ∗ Fl::belowmouse ()
Gets the widget that is below the mouse.
• static void Fl::belowmouse (Fl Widget ∗)
Sets the widget that is below the mouse.
• static int Fl::compose (int &del)
Any text editing widget should call this for each FL KEYBOARD event.
• static void Fl::compose reset ()
If the user moves the cursor, be sure to call Fl::compose reset().
• static void Fl::disable im ()
Disables the system input methods facilities.
• static void Fl::enable im ()
Enables the system input methods facilities.
• static int Fl::event ()
Returns the last event that was processed.
• static int Fl::event alt ()
Returns non-zero if the Alt key is pressed.
• static int Fl::event button ()
Gets which particular mouse button caused the current event.
• static int Fl::event button1 ()
Returns non-zero if mouse button 1 is currently held down.
• static int Fl::event button2 ()
Returns non-zero if button 2 is currently held down.
• static int Fl::event button3 ()
Returns non-zero if button 3 is currently held down.
• static int Fl::event buttons ()
Returns the mouse buttons state bits; if non-zero, then at least one button is pressed now.
• static int Fl::event clicks ()
Returns non zero if we had a double click event.
• static void Fl::event clicks (int i)
Manually sets the number returned by Fl::event clicks().
• static void ∗ Fl::event clipboard ()
During an FL PASTE event of non-textual data, returns a pointer to the pasted data.
• static const char ∗ Fl::event clipboard type ()
Returns the type of the pasted data during an FL PASTE event.
• static int Fl::event command ()
Returns non-zero if the FL COMMAND key is pressed, either FL CTRL or on OSX FL META.
• static int Fl::event ctrl ()
208 CHAPTER 30. MODULE DOCUMENTATION

Returns non-zero if the Control key is pressed.


• static void Fl::event dispatch (Fl Event Dispatch d)
Set a new event dispatch function.
• static Fl Event Dispatch Fl::event dispatch ()
Return the current event dispatch function.
• static int Fl::event dx ()
Returns the current horizontal mouse scrolling associated with the FL MOUSEWHEEL event.
• static int Fl::event dy ()
Returns the current vertical mouse scrolling associated with the FL MOUSEWHEEL event.
• static int Fl::event inside (int, int, int, int)
Returns whether or not the mouse event is inside the given rectangle.
• static int Fl::event inside (const Fl Widget ∗)
Returns whether or not the mouse event is inside a given child widget.
• static int Fl::event is click ()
Returns non-zero if the mouse has not moved far enough and not enough time has passed since the last
FL PUSH or FL KEYBOARD event for it to be considered a ”drag” rather than a ”click”.
• static void Fl::event is click (int i)
Clears the value returned by Fl::event is click().
• static int Fl::event key ()
Gets which key on the keyboard was last pushed.
• static int Fl::event key (int key)
Returns true if the given key was held down (or pressed) during the last event.
• static int Fl::event length ()
Returns the length of the text in Fl::event text().
• static int Fl::event original key ()
Returns the keycode of the last key event, regardless of the NumLock state.
• static int Fl::event shift ()
Returns non-zero if the Shift key is pressed.
• static int Fl::event state ()
This is a bitfield of what shift states were on and what mouse buttons were held down during the most recent
event.
• static int Fl::event state (int i)
See int event state()
• static const char ∗ Fl::event text ()
Returns the text associated with the current event, including FL PASTE or FL DND RELEASE events.
• static int Fl::event x ()
Returns the mouse position of the event relative to the Fl Window it was passed to.
• static int Fl::event x root ()
Returns the mouse position on the screen of the event.
• static int Fl::event y ()
Returns the mouse position of the event relative to the Fl Window it was passed to.
• static int Fl::event y root ()
Returns the mouse position on the screen of the event.
• static Fl Widget ∗ Fl::focus ()
Gets the current Fl::focus() widget.
• static void Fl::focus (Fl Widget ∗)
Sets the widget that will receive FL KEYBOARD events.
30.3. EVENTS HANDLING FUNCTIONS 209

• static int Fl::get key (int key)


Returns true if the given key is held down now.
• static void Fl::get mouse (int &, int &)
Return where the mouse is on the screen by doing a round-trip query to the server.
• static int Fl::handle (int, Fl Window ∗)
Handle events from the window system.
• static int Fl::handle (int, Fl Window ∗)
Handle events from the window system.
• static Fl Widget ∗ Fl::pushed ()
Gets the widget that is being pushed.
• static void Fl::pushed (Fl Widget ∗)
Sets the widget that is being pushed.
• static void Fl::remove handler (Fl Event Handler h)
Removes a previously added event handler.
• static void Fl::remove system handler (Fl System Handler h)
Removes a previously added system event handler.
• static int Fl::test shortcut (Fl Shortcut)
Tests the current event, which must be an FL KEYBOARD or FL SHORTCUT, against a shortcut value
(described in Fl Button).

Variables
• const char ∗const fl eventnames [ ]
This is an array of event names you can use to convert event numbers into names.
• const char ∗const fl fontnames [ ]
This is an array of font names you can use to convert font numbers into names.

30.3.1 Detailed Description


Fl class events handling API declared in <FL/Fl.H>

30.3.2 Function Documentation


void Fl::add handler ( Fl Event Handler ha ) [static]
Install a function to parse unrecognized events.
If FLTK cannot figure out what to do with an event, it calls each of these functions (most recent first)
until one of them returns non-zero. If none of them returns non-zero then the event is ignored. Events that
cause this to be called are:

• FL SHORTCUT events that are not recognized by any widget. This lets you provide global shortcut
keys.
• FL SCREEN CONFIGURATION CHANGED events. Under X11, this event requires the libXrandr.-
so shared library to be loadable at run-time and the X server to implement the RandR extension.
• FL FULLSCREEN events sent to a window that enters of leaves fullscreen mode.
• System events that FLTK does not recognize. See fl xevent.
• Some other events when the widget FLTK selected returns zero from its handle() method. Exactly
which ones may change in future versions, however.
210 CHAPTER 30. MODULE DOCUMENTATION

See Also
Fl::remove handler(Fl Event Handler)
Fl::event dispatch(Fl Event Dispatch d)
Fl::handle(int, Fl Window∗)

void Fl::add system handler ( Fl System Handler ha, void ∗ data ) [static]
Install a function to intercept system events.
FLTK calls each of these functions as soon as a new system event is received. The processing will stop
at the first function to return non-zero. If all functions return zero then the event is passed on for normal
handling by FLTK.
Each function will be called with a pointer to the system event as the first argument and data as
the second argument. The system event pointer will always be void ∗, but will point to different objects
depending on the platform:
• X11: XEvent
• Windows: MSG
• OS X: NSEvent
Parameters
ha The event handler function to register
data User data to include on each call

See Also
Fl::remove system handler(Fl System Handler)

static Fl Widget∗ Fl::belowmouse ( ) [inline], [static]


Gets the widget that is below the mouse.
See Also
belowmouse(Fl Widget∗)

void Fl::belowmouse ( Fl Widget ∗ o ) [static]


Sets the widget that is below the mouse.
This is for highlighting buttons. It is not used to send FL PUSH or FL MOVE directly, for several
obscure reasons, but those events typically go to this widget. This is also the first widget tried for FL SH-
ORTCUT events.
If you change the belowmouse widget, the previous one and all parents (that don’t contain the new
widget) are sent FL LEAVE events. Changing this does not send FL ENTER to this or any widget, because
sending FL ENTER is supposed to test if the widget wants the mouse (by it returning non-zero from
handle()).

int Fl::compose ( int & del ) [static]


Any text editing widget should call this for each FL KEYBOARD event.
Use of this function is very simple.
If true is returned, then it has modified the Fl::event text() and Fl::event length() to a set of bytes to
insert (it may be of zero length!). It will also set the ”del” parameter to the number of bytes to the left of
the cursor to delete, this is used to delete the results of the previous call to Fl::compose().
30.3. EVENTS HANDLING FUNCTIONS 211

If false is returned, the keys should be treated as function keys, and del is set to zero. You could insert
the text anyways, if you don’t know what else to do.
On the Mac OS platform, text input can involve marked text, that is, temporary text replaced by other
text during the input process. This occurs, e.g., when using dead keys or when entering CJK charac-
ters. Text editing widgets should preferentially signal marked text, usually underlining it. Widgets can
use int Fl::compose state after having called Fl::compose(int&) to obtain the length in bytes of
marked text that always finishes at the current insertion point. It’s the widget’s task to underline marked
text. Widgets should also call void Fl::reset marked text() when processing FL UNFOCUS
events. Optionally, widgets can also call void Fl::insertion point location(int x, int
y, int height) to indicate the window coordinates of the bottom of the current insertion point and
the line height. This way, auxiliary windows that help choosing among alternative characters appear just
below the insertion point. If widgets don’t do that, auxiliary windows appear at the widget’s bottom. The
Fl Input and Fl Text Editor widgets underline marked text. If none of this is done by a user-defined text
editing widget, text input will work, but will not signal to the user what text is marked. Finally, text editing
widgets should call set flag(MAC USE ACCENTS MENU); in their constructor if they want to use the
feature introduced with Mac OS 10.7 ”Lion” where pressing and holding a key on the keyboard opens an
accented-character menu window.
Though the current implementation returns immediately, future versions may take quite awhile, as they
may pop up a window or do other user-interface things to allow characters to be selected.

void Fl::compose reset ( ) [static]


If the user moves the cursor, be sure to call Fl::compose reset().
The next call to Fl::compose() will start out in an initial state. In particular it will not set ”del” to
non-zero. This call is very fast so it is ok to call it many times and in many places.

static void Fl::disable im ( ) [static]


Disables the system input methods facilities.
See Also
enable im()

static void Fl::enable im ( ) [static]


Enables the system input methods facilities.
This is the default.
See Also
disable im()

static int Fl::event ( ) [inline], [static]


Returns the last event that was processed.
This can be used to determine if a callback is being done in response to a keypress, mouse click, etc.

static int Fl::event alt ( ) [inline], [static]


Returns non-zero if the Alt key is pressed.

static int Fl::event button ( ) [inline], [static]


Gets which particular mouse button caused the current event.
This returns garbage if the most recent event was not a FL PUSH or FL RELEASE event.
212 CHAPTER 30. MODULE DOCUMENTATION

Return values
FL LEFT MOUSE
FL MIDDLE MOUSE
FL RIGHT MOUSE.

See Also
Fl::event buttons()

static int Fl::event button1 ( ) [inline], [static]


Returns non-zero if mouse button 1 is currently held down.
For more details, see Fl::event buttons().

static int Fl::event button2 ( ) [inline], [static]


Returns non-zero if button 2 is currently held down.
For more details, see Fl::event buttons().

static int Fl::event button3 ( ) [inline], [static]


Returns non-zero if button 3 is currently held down.
For more details, see Fl::event buttons().

static int Fl::event buttons ( ) [inline], [static]


Returns the mouse buttons state bits; if non-zero, then at least one button is pressed now.
This function returns the button state at the time of the event. During an FL RELEASE event, the state
of the released button will be 0. To find out, which button caused an FL RELEASE event, you can use
Fl::event button() instead.
Returns
a bit mask value like { [FL BUTTON1] | [FL BUTTON2] | [FL BUTTON3] }

static int Fl::event clicks ( ) [inline], [static]


Returns non zero if we had a double click event.
Return values
Non-zero if the most recent FL PUSH or FL KEYBOARD was a ”double click”.
N-1 for N clicks. A double click is counted if the same button is pressed again
while event is click() is true.

static void Fl::event clicks ( int i ) [inline], [static]


Manually sets the number returned by Fl::event clicks().
This can be used to set it to zero so that later code does not think an item was double-clicked.
Parameters
30.3. EVENTS HANDLING FUNCTIONS 213

in i corresponds to no double-click if 0, i+1 mouse clicks otherwise

See Also
int event clicks()

static void∗ Fl::event clipboard ( ) [inline], [static]


During an FL PASTE event of non-textual data, returns a pointer to the pasted data.
The returned data is an Fl Image ∗ when the result of Fl::event clipboard type() is Fl::clipboard image.

static const char∗ Fl::event clipboard type ( ) [inline], [static]


Returns the type of the pasted data during an FL PASTE event.
This type can be Fl::clipboard plain text or Fl::clipboard image.

static int Fl::event command ( ) [inline], [static]


Returns non-zero if the FL COMMAND key is pressed, either FL CTRL or on OSX FL META.

static int Fl::event ctrl ( ) [inline], [static]


Returns non-zero if the Control key is pressed.

void Fl::event dispatch ( Fl Event Dispatch d ) [static]


Set a new event dispatch function.
The event dispatch function is called after native events are converted to FLTK events, but before they
are handled by FLTK. If the dispatch function Fl Event Dispatch d is set, it is up to the dispatch function
to call Fl::handle (int, Fl Window∗) or to ignore the event.
The dispatch function itself must return 0 if it ignored the event, or non-zero if it used the event. If you
call Fl::handle (), then this will return the correct value.
The event dispatch can be used to handle exceptions in FLTK events and callbacks before they reach
the native event handler:
int myHandler(int e, Fl Window *w) {
try {
return Fl::handle (e, w);
} catch () {
...
}
}

main() {
Fl::event dispatch(myHandler);
...
Fl::run();
}

Parameters
d new dispatch function, or NULL

See Also
Fl::add handler(Fl Event Handler)
Fl::handle(int, Fl Window∗)
Fl::handle (int, Fl Window∗)
214 CHAPTER 30. MODULE DOCUMENTATION

static int Fl::event dx ( ) [inline], [static]


Returns the current horizontal mouse scrolling associated with the FL MOUSEWHEEL event.
Right is positive.

static int Fl::event dy ( ) [inline], [static]


Returns the current vertical mouse scrolling associated with the FL MOUSEWHEEL event.
Down is positive.

int Fl::event inside ( int xx, int yy, int ww, int hh ) [static]
Returns whether or not the mouse event is inside the given rectangle.
Returns non-zero if the current Fl::event x() and Fl::event y() put it inside the given arbitrary bounding
box.
You should always call this rather than doing your own comparison so you are consistent about edge
effects.
To find out, whether the event is inside a child widget of the current window, you can use Fl::event -
inside(const Fl Widget ∗).
Parameters
in xx,yy,ww,hh bounding box

Returns
non-zero, if mouse event is inside

int Fl::event inside ( const Fl Widget ∗ o ) [static]


Returns whether or not the mouse event is inside a given child widget.
Returns non-zero if the current Fl::event x() and Fl::event y() put it inside the given child widget’s
bounding box.
This method can only be used to check whether the mouse event is inside a child widget of the window
that handles the event, and there must not be an intermediate subwindow (i.e. the widget must not be inside
a subwindow of the current window). However, it is valid if the widget is inside a nested Fl Group.
You must not use it with the window itself as the o argument in a window’s handle() method.

Note
The mentioned restrictions are necessary, because this method does not transform coordinates of child
widgets, and thus the given widget o must be within the same window that is handling the current
event. Otherwise the results are undefined.

You should always call this rather than doing your own comparison so you are consistent about edge effects.

See Also
Fl::event inside(int, int, int, int)

Parameters
in o child widget to be tested

Returns
non-zero, if mouse event is inside the widget
30.3. EVENTS HANDLING FUNCTIONS 215

static int Fl::event is click ( ) [inline], [static]


Returns non-zero if the mouse has not moved far enough and not enough time has passed since the last
FL PUSH or FL KEYBOARD event for it to be considered a ”drag” rather than a ”click”.
You can test this on FL DRAG, FL RELEASE, and FL MOVE events.

static void Fl::event is click ( int i ) [inline], [static]


Clears the value returned by Fl::event is click().
Useful to prevent the next click from being counted as a double-click or to make a popup menu pick an
item with a single click. Don’t pass non-zero to this.

static int Fl::event key ( ) [inline], [static]


Gets which key on the keyboard was last pushed.
The returned integer ’key code’ is not necessarily a text equivalent for the keystroke. For instance: if
someone presses ’5’ on the numeric keypad with numlock on, Fl::event key() may return the ’key code’
for this key, and NOT the character ’5’. To always get the ’5’, use Fl::event text() instead.
Returns
an integer ’key code’, or 0 if the last event was not a key press or release.

See Also
int event key(int), event text(), compose(int&).

int Fl::event key ( int key ) [static]


Returns true if the given key was held down (or pressed) during the last event.
This is constant until the next event is read from the server.
Fl::get key(int) returns true if the given key is held down now. Under X this requires a round-trip to the
server and is much slower than Fl::event key(int).
Keys are identified by the unshifted values. FLTK defines a set of symbols that should work on most
modern machines for every key on the keyboard:

• All keys on the main keyboard producing a printable ASCII character use the value of that ASCII
character (as though shift, ctrl, and caps lock were not on). The space bar is 32.
• All keys on the numeric keypad producing a printable ASCII character use the value of that ASCII
character plus FL KP. The highest possible value is FL KP Last so you can range-check to see if
something is on the keypad.
• All numbered function keys use the number on the function key plus FL F. The highest possible
number is FL F Last, so you can range-check a value.
• Buttons on the mouse are considered keys, and use the button number (where the left button is 1)
plus FL Button.
• All other keys on the keypad have a symbol: FL Escape, FL BackSpace, FL Tab, FL Enter, FL -
Print, FL Scroll Lock, FL Pause, FL Insert, FL Home, FL Page Up, FL Delete, FL End, FL Page-
Down, FL Left, FL Up, FL Right, FL Down, FL Iso Key, FL Shift L, FL Shift R, FL Control L,
FL Control R, FL Caps Lock, FL Alt L, FL Alt R, FL Meta L, FL Meta R, FL Menu, FL Num -
Lock, FL KP Enter. Be careful not to confuse these with the very similar, but all-caps, symbols used
by Fl::event state().

On X Fl::get key(FL Button+n) does not work.


On WIN32 Fl::get key(FL KP Enter) and Fl::event key(FL KP Enter) do not work.
216 CHAPTER 30. MODULE DOCUMENTATION

static int Fl::event length ( ) [inline], [static]


Returns the length of the text in Fl::event text().
There will always be a nul at this position in the text. However there may be a nul before that if the
keystroke translates to a nul character or you paste a nul character.

static int Fl::event original key ( ) [inline], [static]


Returns the keycode of the last key event, regardless of the NumLock state.
If NumLock is deactivated, FLTK translates events from the numeric keypad into the corresponding
arrow key events. event key() returns the translated key code, whereas event original key() returns the
keycode before NumLock translation.

static int Fl::event shift ( ) [inline], [static]


Returns non-zero if the Shift key is pressed.

static int Fl::event state ( ) [inline], [static]


This is a bitfield of what shift states were on and what mouse buttons were held down during the most
recent event.
The second version returns non-zero if any of the passed bits are turned on. The legal bits are:
• FL SHIFT
• FL CAPS LOCK
• FL CTRL
• FL ALT
• FL NUM LOCK
• FL META
• FL SCROLL LOCK
• FL BUTTON1
• FL BUTTON2
• FL BUTTON3
X servers do not agree on shift states, and FL NUM LOCK, FL META, and FL SCROLL LOCK may not
work. The values were selected to match the XFree86 server on Linux. In addition there is a bug in the
way X works so that the shift state is not correctly reported until the first event after the shift key is pressed
or released.

static const char∗ Fl::event text ( ) [inline], [static]


Returns the text associated with the current event, including FL PASTE or FL DND RELEASE events.
This can be used in response to FL KEYUP, FL KEYDOWN, FL PASTE, and FL DND RELEASE.
When responding to FL KEYUP/FL KEYDOWN, use this function instead of Fl::event key() to get
the text equivalent of keystrokes suitable for inserting into strings and text widgets.
The returned string is guaranteed to be NULL terminated. However, see Fl::event length() for the actual
length of the string, in case the string itself contains NULLs that are part of the text data.
Returns
A NULL terminated text string equivalent of the last keystroke.
30.3. EVENTS HANDLING FUNCTIONS 217

static int Fl::event x root ( ) [inline], [static]


Returns the mouse position on the screen of the event.
To find the absolute position of an Fl Window on the screen, use the difference between event x -
root(),event y root() and event x(),event y().

static int Fl::event y root ( ) [inline], [static]


Returns the mouse position on the screen of the event.
To find the absolute position of an Fl Window on the screen, use the difference between event x -
root(),event y root() and event x(),event y().

static Fl Widget∗ Fl::focus ( ) [inline], [static]


Gets the current Fl::focus() widget.
See Also
Fl::focus(Fl Widget∗)

void Fl::focus ( Fl Widget ∗ o ) [static]


Sets the widget that will receive FL KEYBOARD events.
If you change Fl::focus(), the previous widget and all parents (that don’t contain the new widget)
are sent FL UNFOCUS events. Changing the focus does not send FL FOCUS to this or any widget,
because sending FL FOCUS is supposed to test if the widget wants the focus (by it returning non-zero
from handle()).
See Also
Fl Widget::take focus()

int Fl::get key ( int key ) [static]


Returns true if the given key is held down now.
Under X this requires a round-trip to the server and is much slower than Fl::event key(int).
See Also
event key(int)

static void Fl::get mouse ( int & , int & ) [static]


Return where the mouse is on the screen by doing a round-trip query to the server.
You should use Fl::event x root() and Fl::event y root() if possible, but this is necessary if you are not
sure if a mouse event has been processed recently (such as to position your first window). If the display is
not open, this will open it.

int Fl::handle ( int e, Fl Window ∗ window ) [static]


Handle events from the window system.
This is called from the native event dispatch after native events have been converted to FLTK notation.
This function calls Fl::handle (int, Fl Window∗) unless the user sets a dispatch function. If a user dispatch
function is set, the user must make sure that Fl::handle () is called, or the event will be ignored.
218 CHAPTER 30. MODULE DOCUMENTATION

Parameters
e the event type (Fl::event number() is not yet set)
window the window that caused this event

Returns
0 if the event was not handled

See Also
Fl::add handler(Fl Event Handler)
Fl::event dispatch(Fl Event Dispatch)

int Fl::handle ( int e, Fl Window ∗ window ) [static]


Handle events from the window system.
This function is called from the native event dispatch, unless the user sets another dispatch function. In
that case, the user dispatch function must decide when to call Fl::handle (int, Fl Window∗)
Parameters
e the event type (Fl::event number() is not yet set)
window the window that caused this event

Returns
0 if the event was not handled

See Also
Fl::event dispatch(Fl Event Dispatch)

static Fl Widget∗ Fl::pushed ( ) [inline], [static]


Gets the widget that is being pushed.
See Also
void pushed(Fl Widget∗)

void Fl::pushed ( Fl Widget ∗ o ) [static]


Sets the widget that is being pushed.
FL DRAG or FL RELEASE (and any more FL PUSH) events will be sent to this widget.
If you change the pushed widget, the previous one and all parents (that don’t contain the new widget) are
sent FL RELEASE events. Changing this does not send FL PUSH to this or any widget, because sending
FL PUSH is supposed to test if the widget wants the mouse (by it returning non-zero from handle()).

void Fl::remove handler ( Fl Event Handler ha ) [static]


Removes a previously added event handler.
See Also
Fl::handle(int, Fl Window∗)

void Fl::remove system handler ( Fl System Handler ha ) [static]


Removes a previously added system event handler.
30.3. EVENTS HANDLING FUNCTIONS 219

Parameters
ha The event handler function to remove

See Also
Fl::add system handler(Fl System Handler)

int Fl::test shortcut ( Fl Shortcut shortcut ) [static]

Tests the current event, which must be an FL KEYBOARD or FL SHORTCUT, against a shortcut value
(described in Fl Button).
Not to be confused with Fl Widget::test shortcut().

Returns
non-zero if there is a match.

30.3.3 Variable Documentation


const char∗ const fl eventnames[ ]

Initial value:

=
{
"FL NO EVENT",
"FL PUSH",
"FL RELEASE",
"FL ENTER",
"FL LEAVE",
"FL DRAG",
"FL FOCUS",
"FL UNFOCUS",
"FL KEYDOWN",
"FL KEYUP",
"FL CLOSE",
"FL MOVE",
"FL SHORTCUT",
"FL DEACTIVATE",
"FL ACTIVATE",
"FL HIDE",
"FL SHOW",
"FL PASTE",
"FL SELECTIONCLEAR",
"FL MOUSEWHEEL",
"FL DND ENTER",
"FL DND DRAG",
"FL DND LEAVE",
"FL DND RELEASE",
"FL SCREEN CONFIGURATION CHANGED",
"FL FULLSCREEN"
}

This is an array of event names you can use to convert event numbers into names.
The array gets defined inline wherever your ’#include <FL/names.h>’ appears.
Example:

#include <FL/names.h> // array will be defined here


int MyClass::handle(int e) {
printf("Event was %s (%d)\n", fl eventnames[e], e);
// ..resulting output might be e.g. "Event was FL PUSH (1)"..
[..]
}
220 CHAPTER 30. MODULE DOCUMENTATION

const char∗ const fl fontnames[ ]


Initial value:
=
{
"FL HELVETICA",
"FL HELVETICA BOLD",
"FL HELVETICA ITALIC",
"FL HELVETICA BOLD ITALIC",
"FL COURIER",
"FL COURIER BOLD",
"FL COURIER ITALIC",
"FL COURIER BOLD ITALIC",
"FL TIMES",
"FL TIMES BOLD",
"FL TIMES ITALIC",
"FL TIMES BOLD ITALIC",
"FL SYMBOL",
"FL SCREEN",
"FL SCREEN BOLD",
"FL ZAPF DINGBATS",
}

This is an array of font names you can use to convert font numbers into names.
The array gets defined inline wherever your ’#include <FL/names.h>’ appears.
Example:
#include <FL/names.h> // array will be defined here
int MyClass::my callback(Fl Widget *w, void*) {
int fnum = w->labelfont();
// Resulting output might be e.g. "Label’s font is FL HELVETICA (0)"
printf("Label’s font is %s (%d)\n", fl fontnames[fnum], fnum);
// ..resulting output might be e.g. "Label’s font is FL HELVETICA (0)"..
[..]
}
30.4. SELECTION & CLIPBOARD FUNCTIONS 221

30.4 Selection & Clipboard functions


FLTK global copy/cut/paste functions declared in <FL/Fl.H>

Functions
• static void Fl::add clipboard notify (Fl Clipboard Notify Handler h, void ∗data=0)
FLTK will call the registered callback whenever there is a change to the selection buffer or the clipboard.
• static int Fl::clipboard contains (const char ∗type)
Returns non 0 if the clipboard contains data matching type.
• static void Fl::copy (const char ∗stuff, int len, int destination=0, const char ∗type=Fl::clipboard -
plain text)
Copies the data pointed to by stuff to the selection buffer (destination is 0) or the clipboard
(destination is 1).
• static int Fl::dnd ()
Initiate a Drag And Drop operation.
• static void Fl::paste (Fl Widget &receiver, int source, const char ∗type=Fl::clipboard plain text)
Pastes the data from the selection buffer (source is 0) or the clipboard (source is 1) into receiver.
• static void Fl::paste (Fl Widget &receiver)
Backward compatibility only.
• static void Fl::remove clipboard notify (Fl Clipboard Notify Handler h)
Stop calling the specified callback when there are changes to the selection buffer or the clipboard.
• static void Fl::selection (Fl Widget &owner, const char ∗, int len)
Changes the current selection.
• static Fl Widget ∗ Fl::selection owner ()
back-compatibility only: Gets the widget owning the current selection
• static void Fl::selection owner (Fl Widget ∗)
Back-compatibility only: The single-argument call can be used to move the selection to another widget or
to set the owner to NULL, without changing the actual text of the selection.

Variables
• static char const ∗const Fl::clipboard image = ”image”
Denotes image data.
• static char const ∗const Fl::clipboard plain text = ”text/plain”
Denotes plain textual data.

30.4.1 Detailed Description


FLTK global copy/cut/paste functions declared in <FL/Fl.H>

30.4.2 Function Documentation


void Fl::add clipboard notify ( Fl Clipboard Notify Handler h, void ∗ data = 0 ) [static]
FLTK will call the registered callback whenever there is a change to the selection buffer or the clipboard.
The source argument indicates which of the two has changed. Only changes by other applications are
reported.
Example:
222 CHAPTER 30. MODULE DOCUMENTATION

void clip callback(int source, void *data) {


if ( source == 0 ) printf("CLIP CALLBACK: selection buffer changed\n");
if ( source == 1 ) printf("CLIP CALLBACK: clipboard changed\n");
}
[..]
int main() {
[..]
Fl::add clipboard notify(clip callback);
[..]
}

Note
Some systems require polling to monitor the clipboard and may therefore have some delay in detect-
ing changes.

static int Fl::clipboard contains ( const char ∗ type ) [static]


Returns non 0 if the clipboard contains data matching type.
type can be Fl::clipboard plain text or Fl::clipboard image.

static void Fl::copy ( const char ∗ stuff, int len, int destination = 0, const char ∗ type =
Fl::clipboard plain text ) [static]
Copies the data pointed to by stuff to the selection buffer (destination is 0) or the clipboard
(destination is 1).
len is the number of relevant bytes in stuff. type is always Fl::clipboard plain text. The selec-
tion buffer is used for middle-mouse pastes and for drag-and-drop selections. The clipboard is used for
traditional copy/cut/paste operations.
Note
This function is, at present, intended only to copy UTF-8 encoded textual data. To copy graphical
data, use the Fl Copy Surface class. The type argument may allow in the future to copy other kinds
of data.

int Fl::dnd ( ) [static]


Initiate a Drag And Drop operation.
The selection buffer should be filled with relevant data before calling this method. FLTK will then
initiate the system wide drag and drop handling. Dropped data will be marked as text.
Create a selection first using: Fl::copy(const char ∗stuff, int len, 0)

static void Fl::paste ( Fl Widget & receiver, int source, const char ∗ type = Fl::clipboard plain text
) [static]
Pastes the data from the selection buffer (source is 0) or the clipboard (source is 1) into receiver.
If source is 1, the optional type argument indicates what type of data is requested from the clipboard
(at present, Fl::clipboard plain text - requesting text data - and Fl::clipboard image - requesting image data
- are possible). Set things up so the handle function of the receiver widget will be called with an F-
L PASTE event some time in the future if the clipboard does contain data of the requested type. During
processing of this event, and if type is Fl::clipboard plain text, the text data from the specified source
are in Fl::event text() with UTF-8 encoding, and the number of characters in Fl::event length(); if type
is Fl::clipboard image, Fl::event clipboard() returns a pointer to the image data, as an Fl Image ∗. The
receiver should be prepared to be called directly by this, or for it to happen later, or possibly not at all.
This allows the window system to take as long as necessary to retrieve the paste buffer (or even to screw
up completely) without complex and error-prone synchronization code in FLTK.
The selection buffer is used for middle-mouse pastes and for drag-and-drop selections. The clipboard
is used for traditional copy/cut/paste operations.
30.4. SELECTION & CLIPBOARD FUNCTIONS 223

Platform details for image data:

• Unix/Linux platform: Image data in PNG or BMP formats are recognized. Requires linking with
the fltk images library.
• MSWindows platform: Both bitmap and vectorial (Enhanced metafile) data from clipboard can
be pasted as image data.
• Mac OS X platform: Both bitmap (TIFF) and vectorial (PDF) data from clipboard can be pasted
as image data.

void Fl::paste ( Fl Widget & receiver ) [static]


Backward compatibility only.
This calls Fl::paste(receiver, 0);
See Also
Fl::paste(Fl Widget &receiver, int clipboard, const char∗ type)

void Fl::selection ( Fl Widget & owner, const char ∗ text, int len ) [static]
Changes the current selection.
The block of text is copied to an internal buffer by FLTK (be careful if doing this in response to an
FL PASTE as this may be the same buffer returned by event text()). The selection owner() widget is set to
the passed owner.

static Fl Widget∗ Fl::selection owner ( ) [inline], [static]


back-compatibility only: Gets the widget owning the current selection
See Also
Fl Widget∗ selection owner(Fl Widget∗)

void Fl::selection owner ( Fl Widget ∗ owner ) [static]


Back-compatibility only: The single-argument call can be used to move the selection to another widget or
to set the owner to NULL, without changing the actual text of the selection.
FL SELECTIONCLEAR is sent to the previous selection owner, if any.
Copying the buffer every time the selection is changed is obviously wasteful, especially for large se-
lections. An interface will probably be added in a future version to allow the selection to be made by a
callback function. The current interface will be emulated on top of this.
224 CHAPTER 30. MODULE DOCUMENTATION

30.5 Screen functions


fl global screen functions declared in <FL/Fl.H>

Functions
• static int Fl::h ()
Returns the height in pixels of the main screen work area.
• static int Fl::screen count ()
Gets the number of available screens.
• static void Fl::screen dpi (float &h, float &v, int n=0)
Gets the screen resolution in dots-per-inch for the given screen.
• static int Fl::screen num (int x, int y)
Gets the screen number of a screen that contains the specified screen position x, y.
• static int Fl::screen num (int x, int y, int w, int h)
Gets the screen number for the screen which intersects the most with the rectangle defined by x, y, w, h.
• static void Fl::screen work area (int &X, int &Y, int &W, int &H, int mx, int my)
Gets the bounding box of the work area of a screen that contains the specified screen position mx, my.
• static void Fl::screen work area (int &X, int &Y, int &W, int &H, int n)
Gets the bounding box of the work area of the given screen.
• static void Fl::screen work area (int &X, int &Y, int &W, int &H)
Gets the bounding box of the work area of the screen that contains the mouse pointer.
• static void Fl::screen xywh (int &X, int &Y, int &W, int &H)
Gets the bounding box of a screen that contains the mouse pointer.
• static void Fl::screen xywh (int &X, int &Y, int &W, int &H, int mx, int my)
Gets the bounding box of a screen that contains the specified screen position mx, my.
• static void Fl::screen xywh (int &X, int &Y, int &W, int &H, int n)
Gets the screen bounding rect for the given screen.
• static void Fl::screen xywh (int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh)
Gets the screen bounding rect for the screen which intersects the most with the rectangle defined by mx, my,
mw, mh.
• static int Fl::w ()
Returns the width in pixels of the main screen work area.
• static int Fl::x ()
Returns the leftmost x coordinate of the main screen work area.
• static int Fl::y ()
Returns the topmost y coordinate of the main screen work area.

30.5.1 Detailed Description


fl global screen functions declared in <FL/Fl.H>

30.5.2 Function Documentation


static int Fl::h ( ) [static]
Returns the height in pixels of the main screen work area.

void Fl::screen dpi ( float & h, float & v, int n = 0 ) [static]


Gets the screen resolution in dots-per-inch for the given screen.
30.5. SCREEN FUNCTIONS 225

Parameters
out h,v horizontal and vertical resolution
in n the screen number (0 to Fl::screen count() - 1)

See Also
void screen xywh(int &x, int &y, int &w, int &h, int mx, int my)

int Fl::screen num ( int x, int y ) [static]


Gets the screen number of a screen that contains the specified screen position x, y.
Parameters
in x,y the absolute screen position

int Fl::screen num ( int x, int y, int w, int h ) [static]


Gets the screen number for the screen which intersects the most with the rectangle defined by x, y, w, h.
Parameters
in x,y,w,h the rectangle to search for intersection with

void Fl::screen work area ( int & X, int & Y, int & W, int & H, int mx, int my ) [static]
Gets the bounding box of the work area of a screen that contains the specified screen position mx, my.
Parameters
out X,Y,W,H the work area bounding box
in mx,my the absolute screen position

void Fl::screen work area ( int & X, int & Y, int & W, int & H, int n ) [static]
Gets the bounding box of the work area of the given screen.
Parameters
out X,Y,W,H the work area bounding box
in n the screen number (0 to Fl::screen count() - 1)

See Also
void screen xywh(int &x, int &y, int &w, int &h, int mx, int my)

static void Fl::screen work area ( int & X, int & Y, int & W, int & H ) [inline], [static]
Gets the bounding box of the work area of the screen that contains the mouse pointer.
Parameters
out X,Y,W,H the work area bounding box

See Also
void screen work area(int &x, int &y, int &w, int &h, int mx, int my)
226 CHAPTER 30. MODULE DOCUMENTATION

static void Fl::screen xywh ( int & X, int & Y, int & W, int & H ) [inline], [static]
Gets the bounding box of a screen that contains the mouse pointer.
30.5. SCREEN FUNCTIONS 227

Parameters
out X,Y,W,H the corresponding screen bounding box

See Also
void screen xywh(int &x, int &y, int &w, int &h, int mx, int my)

void Fl::screen xywh ( int & X, int & Y, int & W, int & H, int mx, int my ) [static]
Gets the bounding box of a screen that contains the specified screen position mx, my.
Parameters
out X,Y,W,H the corresponding screen bounding box
in mx,my the absolute screen position

void Fl::screen xywh ( int & X, int & Y, int & W, int & H, int n ) [static]
Gets the screen bounding rect for the given screen.
Under MSWindows, Mac OS X, and the Gnome desktop, screen #0 contains the menubar/taskbar
Parameters
out X,Y,W,H the corresponding screen bounding box
in n the screen number (0 to Fl::screen count() - 1)

See Also
void screen xywh(int &x, int &y, int &w, int &h, int mx, int my)

void Fl::screen xywh ( int & X, int & Y, int & W, int & H, int mx, int my, int mw, int mh )
[static]
Gets the screen bounding rect for the screen which intersects the most with the rectangle defined by mx,
my, mw, mh.
Parameters
out X,Y,W,H the corresponding screen bounding box
in mx,my,mw,mh the rectangle to search for intersection with

See Also
void screen xywh(int &X, int &Y, int &W, int &H, int n)

static int Fl::w ( ) [static]


Returns the width in pixels of the main screen work area.

static int Fl::x ( ) [static]


Returns the leftmost x coordinate of the main screen work area.

static int Fl::y ( ) [static]


Returns the topmost y coordinate of the main screen work area.
228 CHAPTER 30. MODULE DOCUMENTATION

30.6 Color & Font functions


fl global color, font functions.

Functions
• void fl color (Fl Color c)
Sets the color for all subsequent drawing operations.
• void fl color (int c)
for back compatibility - use fl color(Fl Color c) instead
• void fl color (uchar r, uchar g, uchar b)
Sets the color for all subsequent drawing operations.
• Fl Color fl color ()
Returns the last fl color() that was set.
• Fl Color fl color average (Fl Color color1, Fl Color color2, float weight)
Returns the weighted average color between the two given colors.
• Fl Color fl contrast (Fl Color fg, Fl Color bg)
Returns a color that contrasts with the background color.
• int fl descent ()
Returns the recommended distance above the bottom of a fl height() tall box to draw the text at so it looks
centered vertically in that box.
• void fl font (Fl Font face, Fl Fontsize fsize)
Sets the current font, which is then used in various drawing routines.
• Fl Font fl font ()
Returns the face set by the most recent call to fl font().
• int fl height ()
Returns the recommended minimum line spacing for the current font.
• FL EXPORT int fl height (int font, int size)
This function returns the actual height of the specified font and size.
• Fl Color fl inactive (Fl Color c)
Returns the inactive, dimmed version of the given color.
• FL EXPORT const char ∗ fl latin1 to local (const char ∗t, int n=-1)
Converts text from Windows/X11 latin1 character set to local encoding.
• FL EXPORT const char ∗ fl local to latin1 (const char ∗t, int n=-1)
Converts text from local encoding to Windowx/X11 latin1 character set.
• FL EXPORT const char ∗ fl local to mac roman (const char ∗t, int n=-1)
Converts text from local encoding to Mac Roman character set.
• FL EXPORT const char ∗ fl mac roman to local (const char ∗t, int n=-1)
Converts text from Mac Roman character set to local encoding.
• FL EXPORT Fl Color fl show colormap (Fl Color oldcol)
Pops up a window to let the user pick a colormap entry.
• Fl Fontsize fl size ()
Returns the size set by the most recent call to fl font().
• FL EXPORT void fl text extents (const char ∗, int &dx, int &dy, int &w, int &h)
Determines the minimum pixel dimensions of a nul-terminated string.
• void fl text extents (const char ∗t, int n, int &dx, int &dy, int &w, int &h)
Determines the minimum pixel dimensions of a sequence of n characters.
• FL EXPORT double fl width (const char ∗txt)
30.6. COLOR & FONT FUNCTIONS 229

Returns the typographical width of a nul-terminated string using the current font face and size.
• double fl width (const char ∗txt, int n)
Returns the typographical width of a sequence of n characters using the current font face and size.
• double fl width (unsigned int c)
Returns the typographical width of a single character using the current font face and size.
• ulong fl xpixel (uchar r, uchar g, uchar b)
Returns the X pixel number used to draw the given rgb color.
• ulong fl xpixel (Fl Color i)
Returns the X pixel number used to draw the given FLTK color index.
• static void Fl::free color (Fl Color i, int overlay=0)
Frees the specified color from the colormap, if applicable.
• static unsigned Fl::get color (Fl Color i)
Returns the RGB value(s) for the given FLTK color index.
• static void Fl::get color (Fl Color i, uchar &red, uchar &green, uchar &blue)
Returns the RGB value(s) for the given FLTK color index.
• static const char ∗ Fl::get font (Fl Font)
Gets the string for this face.
• static const char ∗ Fl::get font name (Fl Font, int ∗attributes=0)
Get a human-readable string describing the family of this face.
• static int Fl::get font sizes (Fl Font, int ∗&sizep)
Return an array of sizes in sizep.
• static void Fl::set color (Fl Color, uchar, uchar, uchar)
Sets an entry in the fl color index table.
• static void Fl::set color (Fl Color i, unsigned c)
Sets an entry in the fl color index table.
• static void Fl::set font (Fl Font, const char ∗)
Changes a face.
• static void Fl::set font (Fl Font, Fl Font)
Copies one face to another.
• static Fl Font Fl::set fonts (const char ∗=0)
FLTK will open the display, and add every fonts on the server to the face table.

30.6.1 Detailed Description


fl global color, font functions. These functions are declared in <FL/Fl.H> or <FL/fl draw.H>.

30.6.2 Function Documentation


void fl color ( Fl Color c ) [inline]
Sets the color for all subsequent drawing operations.
For colormapped displays, a color cell will be allocated out of fl colormap the first time you use a
color. If the colormap fills up then a least-squares algorithm is used to find the closest color. If no valid
graphical context (fl gc) is available, the foreground is not set for the current window.
230 CHAPTER 30. MODULE DOCUMENTATION

Parameters
in c color

void fl color ( uchar r, uchar g, uchar b ) [inline]


Sets the color for all subsequent drawing operations.
The closest possible match to the RGB color is used. The RGB color is used directly on TrueColor
displays. For colormap visuals the nearest index in the gray ramp or color cube is used. If no valid
graphical context (fl gc) is available, the foreground is not set for the current window.
Parameters
in r,g,b color components

Fl Color fl color ( void ) [inline]


Returns the last fl color() that was set.
This can be used for state save/restore.

Fl Color fl color average ( Fl Color color1, Fl Color color2, float weight )


Returns the weighted average color between the two given colors.
The red, green and blue values are averages using the following formula:

color = color1 * weight + color2 * (1 - weight)

Thus, a weight value of 1.0 will return the first color, while a value of 0.0 will return the second color.
Parameters
in color1,color2 boundary colors
in weight weighting factor

Fl Color fl contrast ( Fl Color fg, Fl Color bg )


Returns a color that contrasts with the background color.
This will be the foreground color if it contrasts sufficiently with the background color. Otherwise,
returns FL WHITE or FL BLACK depending on which color provides the best contrast.
Parameters
in fg,bg foreground and background colors

Returns
contrasting color

void fl font ( Fl Font face, Fl Fontsize fsize ) [inline]


Sets the current font, which is then used in various drawing routines.
You may call this outside a draw context if necessary to call fl width(), but on X this will open the
display.
The font is identified by a face and a size. The size of the font is measured in pixels and not
”points”. Lines should be spaced size pixels apart or more.
30.6. COLOR & FONT FUNCTIONS 231

Fl Font fl font ( void ) [inline]


Returns the face set by the most recent call to fl font().
This can be used to save/restore the font.

int fl height ( ) [inline]


Returns the recommended minimum line spacing for the current font.
You can also use the value of size passed to fl font()

FL EXPORT int fl height ( int font, int size )


This function returns the actual height of the specified font and size.
Normally the font height should always be ’size’, but with the advent of XFT, there are (currently)
complexities that seem to only be solved by asking the font what its actual font height is. (See STR#2115)
This function was originally undocumented in 1.1.x, and was used only by Fl Text Display. We’re now
documenting it in 1.3.x so that apps that need precise height info can get it with this function.
Returns
the height of the font in pixels.

Todo In the future, when the XFT issues are resolved, this function should simply return the ’size’ value.

FL EXPORT const char∗ fl latin1 to local ( const char ∗ t, int n = -1 )


Converts text from Windows/X11 latin1 character set to local encoding.
Parameters
in t character string (latin1 encoding)
in n optional number of characters to convert (default is all)

Returns
pointer to internal buffer containing converted characters

FL EXPORT const char∗ fl local to latin1 ( const char ∗ t, int n = -1 )


Converts text from local encoding to Windowx/X11 latin1 character set.
Parameters
in t character string (local encoding)
in n optional number of characters to convert (default is all)

Returns
pointer to internal buffer containing converted characters

FL EXPORT const char∗ fl local to mac roman ( const char ∗ t, int n = -1 )


Converts text from local encoding to Mac Roman character set.
232 CHAPTER 30. MODULE DOCUMENTATION

Parameters
in t character string (local encoding)
in n optional number of characters to convert (default is all)

Returns
pointer to internal buffer containing converted characters

FL EXPORT const char∗ fl mac roman to local ( const char ∗ t, int n = -1 )


Converts text from Mac Roman character set to local encoding.
Parameters
in t character string (Mac Roman encoding)
in n optional number of characters to convert (default is all)

Returns
pointer to internal buffer containing converted characters

FL EXPORT Fl Color fl show colormap ( Fl Color oldcol )


Pops up a window to let the user pick a colormap entry.

Figure 30.1: fl show colormap


30.6. COLOR & FONT FUNCTIONS 233

Parameters
in oldcol color to be highlighted when grid is shown.
Return values
Fl Color value of the chosen colormap entry.

See Also
Fl Color Chooser

Fl Fontsize fl size ( ) [inline]


Returns the size set by the most recent call to fl font().
This can be used to save/restore the font.

FL EXPORT void fl text extents ( const char ∗ , int & dx, int & dy, int & w, int & h )
Determines the minimum pixel dimensions of a nul-terminated string.
Usage: given a string ”txt” drawn using fl draw(txt, x, y) you would determine its pixel extents on the
display using fl text extents(txt, dx, dy, wo, ho) such that a bounding box that exactly fits around the text
could be drawn with fl rect(x+dx, y+dy, wo, ho). Note the dx, dy values hold the offset of the first ”colored
in” pixel of the string, from the draw origin.
No FLTK symbol expansion will be performed.

void fl text extents ( const char ∗ t, int n, int & dx, int & dy, int & w, int & h ) [inline]
Determines the minimum pixel dimensions of a sequence of n characters.
See Also
fl text extents(const char∗, int& dx, int& dy, int& w, int& h)

FL EXPORT double fl width ( const char ∗ txt )


Returns the typographical width of a nul-terminated string using the current font face and size.

double fl width ( const char ∗ txt, int n ) [inline]


Returns the typographical width of a sequence of n characters using the current font face and size.

double fl width ( unsigned int c ) [inline]


Returns the typographical width of a single character using the current font face and size.
Note
if a valid fl gc is NOT found then it uses the first window gc, or the screen gc if no fltk window is
available when called.

ulong fl xpixel ( uchar r, uchar g, uchar b )


Returns the X pixel number used to draw the given rgb color.
This is the X pixel that fl color() would use.
234 CHAPTER 30. MODULE DOCUMENTATION

Parameters
in r,g,b color components

Returns
X pixel number

ulong fl xpixel ( Fl Color i )


Returns the X pixel number used to draw the given FLTK color index.
This is the X pixel that fl color() would use.
Parameters
in i color index

Returns
X pixel number

void Fl::free color ( Fl Color i, int overlay = 0 ) [static]


Frees the specified color from the colormap, if applicable.
Free color i if used, and clear mapping table entry.
If overlay is non-zero then the color is freed from the overlay colormap.
Parameters
in i color index
in overlay 0 for normal, 1 for overlay color

unsigned Fl::get color ( Fl Color i ) [static]


Returns the RGB value(s) for the given FLTK color index.
This form returns the RGB values packed in a 32-bit unsigned integer with the red value in the upper 8
bits, the green value in the next 8 bits, and the blue value in bits 8-15. The lower 8 bits will always be 0.

void Fl::get color ( Fl Color i, uchar & red, uchar & green, uchar & blue ) [static]
Returns the RGB value(s) for the given FLTK color index.
This form returns the red, green, and blue values separately in referenced variables.
See also unsigned get color(Fl Color c)

const char ∗ Fl::get font ( Fl Font fnum ) [static]


Gets the string for this face.
This string is different for each face. Under X this value is passed to XListFonts to get all the sizes of
this face.

const char ∗ Fl::get font name ( Fl Font fnum, int ∗ attributes = 0 ) [static]
Get a human-readable string describing the family of this face.
This is useful if you are presenting a choice to the user. There is no guarantee that each face has a
different name. The return value points to a static buffer that is overwritten each call.
The integer pointed to by attributes (if the pointer is not zero) is set to zero, FL BOLD or FL I-
TALIC or FL BOLD | FL ITALIC. To locate a ”family” of fonts, search forward and back for a set with
non-zero attributes, these faces along with the face with a zero attribute before them constitute a family.
30.6. COLOR & FONT FUNCTIONS 235

int Fl::get font sizes ( Fl Font fnum, int ∗& sizep ) [static]
Return an array of sizes in sizep.
The return value is the length of this array. The sizes are sorted from smallest to largest and indicate
what sizes can be given to fl font() that will be matched exactly (fl font() will pick the closest size for other
sizes). A zero in the first location of the array indicates a scalable font, where any size works, although the
array may list sizes that work ”better” than others. Warning: the returned array points at a static buffer that
is overwritten each call. Under X this will open the display.

void Fl::set color ( Fl Color i, uchar red, uchar green, uchar blue ) [static]
Sets an entry in the fl color index table.
You can set it to any 8-bit RGB color. The color is not allocated until fl color(i) is used.

void Fl::set color ( Fl Color i, unsigned c ) [static]


Sets an entry in the fl color index table.
Set color mapping table entry i to color c.
You can set it to any 8-bit RGB color. The color is not allocated until fl color(i) is used.
Parameters
in i color index
in c color

void Fl::set font ( Fl Font fnum, const char ∗ name ) [static]


Changes a face.
The string pointer is simply stored, the string is not copied, so the string must be in static memory.

void Fl::set font ( Fl Font fnum, Fl Font from ) [static]


Copies one face to another.

Fl Font Fl::set fonts ( const char ∗ xstarname = 0 ) [static]


FLTK will open the display, and add every fonts on the server to the face table.
It will attempt to put ”families” of faces together, so that the normal one is first, followed by bold, italic,
and bold italic.
The optional argument is a string to describe the set of fonts to add. Passing NULL will select only
fonts that have the ISO8859-1 character set (and are thus usable by normal text). Passing ”-∗” will select
all fonts with any encoding as long as they have normal X font names with dashes in them. Passing ”∗”
will list every font that exists (on X this may produce some strange output). Other values may be useful but
are system dependent. With WIN32 NULL selects fonts with ISO8859-1 encoding and non-NULL selects
all fonts.
The return value is how many faces are in the table after this is done.
236 CHAPTER 30. MODULE DOCUMENTATION

30.7 Drawing functions


FLTK global graphics and GUI drawing functions.

Macros
• #define fl clip fl push clip
Intersects the current clip region with a rectangle and pushes this new region onto the stack (deprecated).

Enumerations
• enum {
FL SOLID = 0, FL DASH = 1, FL DOT = 2, FL DASHDOT = 3,
FL DASHDOTDOT = 4, FL CAP FLAT = 0x100, FL CAP ROUND = 0x200, FL CAP SQUARE
= 0x300,
FL JOIN MITER = 0x1000, FL JOIN ROUND = 0x2000, FL JOIN BEVEL = 0x3000 }

Functions
• void Fl Quartz Graphics Driver::copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap,
int srcx, int srcy)
• FL EXPORT int fl add symbol (const char ∗name, void(∗drawit)(Fl Color), int scalable)
Adds a symbol to the system.
• void fl arc (int x, int y, int w, int h, double a1, double a2)
Draw ellipse sections using integer coordinates.
• void fl arc (double x, double y, double r, double start, double end)
Adds a series of points to the current path on the arc of a circle.
• void fl begin complex polygon ()
Starts drawing a complex filled polygon.
• void fl begin line ()
Starts drawing a list of lines.
• void fl begin loop ()
Starts drawing a closed sequence of lines.
• void fl begin offscreen (Fl Offscreen ctx)
Send all subsequent drawing commands to this offscreen buffer.
• void fl begin points ()
Starts drawing a list of points.
• void fl begin polygon ()
Starts drawing a convex filled polygon.
• FL EXPORT char fl can do alpha blending ()
Checks whether platform supports true alpha blending for RGBA images.
• FL EXPORT void fl chord (int x, int y, int w, int h, double a1, double a2)
fl chord declaration is a place holder - the function does not yet exist
• void fl circle (double x, double y, double r)
fl circle() is equivalent to fl arc(x,y,r,0,360), but may be faster.
• int fl clip box (int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
Intersects the rectangle with the current clip region and returns the bounding box of the result.
• void fl clip region (Fl Region r)
Replaces the top of the clipping stack with a clipping region of any shape.
30.7. DRAWING FUNCTIONS 237

• Fl Region fl clip region ()


Returns the current clipping region.
• void fl copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
• Fl Offscreen fl create offscreen (int w, int h)
Creation of an offscreen graphics buffer.
• FL EXPORT void fl cursor (Fl Cursor)
Sets the cursor for the current window to the specified shape and colors.
• FL EXPORT void fl cursor (Fl Cursor, Fl Color fg, Fl Color bg=FL WHITE)
• void fl curve (double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3)
Adds a series of points on a Bezier curve to the path.
• void fl delete offscreen (Fl Offscreen ctx)
Deletion of an offscreen graphics buffer.
• FL EXPORT void fl draw (const char ∗str, int x, int y)
Draws a nul-terminated UTF-8 string starting at the given x, y location.
• FL EXPORT void fl draw (int angle, const char ∗str, int x, int y)
Draws a nul-terminated UTF-8 string starting at the given x, y location and rotating angle degrees
counter-clockwise.
• void fl draw (const char ∗str, int n, int x, int y)
Draws starting at the given x, y location a UTF-8 string of length n bytes.
• void fl draw (int angle, const char ∗str, int n, int x, int y)
Draws at the given x, y location a UTF-8 string of length n bytes rotating angle degrees counter-
clockwise.
• FL EXPORT void fl draw (const char ∗str, int x, int y, int w, int h, Fl Align align, Fl Image ∗img=0,
int draw symbols=1)
Fancy string drawing function which is used to draw all the labels.
• FL EXPORT void fl draw (const char ∗str, int x, int y, int w, int h, Fl Align align, void(∗callthis)(const
char ∗, int, int, int), Fl Image ∗img=0, int draw symbols=1)
The same as fl draw(const char∗,int,int,int,int,Fl Align,Fl Image∗,int) with the addition of the callthis
parameter, which is a pointer to a text drawing function such as fl draw(const char∗, int, int, int) to do the
real work.
• FL EXPORT void fl draw box (Fl Boxtype, int x, int y, int w, int h, Fl Color)
Draws a box using given type, position, size and color.
• void fl draw image (const uchar ∗buf, int X, int Y, int W, int H, int D=3, int L=0)
Draws an 8-bit per color RGB or luminance image.
• void fl draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=3)
Draws an image using a callback function to generate image data.
• void fl draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D=1, int L=0)
Draws a gray-scale (1 channel) image.
• void fl draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=1)
Draws a gray-scale image using a callback function to generate image data.
• FL EXPORT int fl draw pixmap (char ∗const ∗data, int x, int y, Fl Color=FL GRAY)
Draw XPM image data, with the top-left corner at the given position.
• FL EXPORT int fl draw pixmap (const char ∗const ∗cdata, int x, int y, Fl Color=FL GRAY)
Draw XPM image data, with the top-left corner at the given position.
• FL EXPORT int fl draw symbol (const char ∗label, int x, int y, int w, int h, Fl Color)
Draw the named symbol in the given rectangle using the given color.
238 CHAPTER 30. MODULE DOCUMENTATION

• void fl end complex polygon ()


Ends complex filled polygon, and draws.
• void fl end line ()
Ends list of lines, and draws.
• void fl end loop ()
Ends closed sequence of lines, and draws.
• void fl end offscreen ()
Quit sending drawing commands to the current offscreen buffer.
• void fl end points ()
Ends list of points, and draws.
• void fl end polygon ()
Ends convex filled polygon, and draws.
• FL EXPORT const char ∗ fl expand text (const char ∗from, char ∗buf, int maxbuf, double maxw, int
&n, double &width, int wrap, int draw symbols=0)
Copy from to buf, replacing control characters with ∧ X.
• FL EXPORT void fl frame (const char ∗s, int x, int y, int w, int h)
Draws a series of line segments around the given box.
• FL EXPORT void fl frame2 (const char ∗s, int x, int y, int w, int h)
Draws a series of line segments around the given box.
• void fl gap ()
Call fl gap() to separate loops of the path.
• void fl line (int x, int y, int x1, int y1)
Draws a line from (x,y) to (x1,y1)
• void fl line (int x, int y, int x1, int y1, int x2, int y2)
Draws a line from (x,y) to (x1,y1) and another from (x1,y1) to (x2,y2)
• void fl line style (int style, int width=0, char ∗dashes=0)
Sets how to draw lines (the ”pen”).
• void fl loop (int x, int y, int x1, int y1, int x2, int y2)
Outlines a 3-sided polygon with lines.
• void fl loop (int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
Outlines a 4-sided polygon with lines.
• FL EXPORT void fl measure (const char ∗str, int &x, int &y, int draw symbols=1)
Measure how wide and tall the string will be when printed by the fl draw() function with align parameter.
• FL EXPORT int fl measure pixmap (char ∗const ∗data, int &w, int &h)
Get the dimensions of a pixmap.
• FL EXPORT int fl measure pixmap (const char ∗const ∗cdata, int &w, int &h)
Get the dimensions of a pixmap.
• void fl mult matrix (double a, double b, double c, double d, double x, double y)
Concatenates another transformation onto the current one.
• int fl not clipped (int x, int y, int w, int h)
Does the rectangle intersect the current clip region?
• FL EXPORT unsigned int fl old shortcut (const char ∗s)
Emulation of XForms named shortcuts.
• FL EXPORT void fl overlay clear ()
Erase a selection rectangle without drawing a new one.
• FL EXPORT void fl overlay rect (int x, int y, int w, int h)
Draws a selection rectangle, erasing a previous one by XOR’ing it first.
30.7. DRAWING FUNCTIONS 239

• void fl pie (int x, int y, int w, int h, double a1, double a2)
Draw filled ellipse sections using integer coordinates.
• void fl point (int x, int y)
Draws a single pixel at the given coordinates.
• void fl polygon (int x, int y, int x1, int y1, int x2, int y2)
Fills a 3-sided polygon.
• void fl polygon (int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
Fills a 4-sided polygon.
• void fl pop clip ()
Restores the previous clip region.
• void fl pop matrix ()
Restores the current transformation matrix from the stack.
• void fl push clip (int x, int y, int w, int h)
Intersects the current clip region with a rectangle and pushes this new region onto the stack.
• void fl push matrix ()
Saves the current transformation matrix on the stack.
• void fl push no clip ()
Pushes an empty clip region onto the stack so nothing will be clipped.
• FL EXPORT uchar ∗ fl read image (uchar ∗p, int X, int Y, int W, int H, int alpha=0)
Reads an RGB(A) image from the current window or off-screen buffer.
• void fl rect (int x, int y, int w, int h)
Draws a 1-pixel border inside the given bounding box.
• void fl rect (int x, int y, int w, int h, Fl Color c)
Draws with passed color a 1-pixel border inside the given bounding box.
• void fl rectf (int x, int y, int w, int h)
Colors with current color a rectangle that exactly fills the given bounding box.
• void fl rectf (int x, int y, int w, int h, Fl Color c)
Colors with passed color a rectangle that exactly fills the given bounding box.
• FL EXPORT void fl rectf (int x, int y, int w, int h, uchar r, uchar g, uchar b)
Colors a rectangle with ”exactly” the passed r,g,b color.
• FL EXPORT void fl reset spot (void)
• void fl restore clip ()
Undoes any clobbering of clip done by your program.
• void fl rotate (double d)
Concatenates rotation transformation onto the current one.
• void fl rtl draw (const char ∗str, int n, int x, int y)
Draws a UTF-8 string of length n bytes right to left starting at the given x, y location.
• void fl scale (double x, double y)
Concatenates scaling transformation onto the current one.
• void fl scale (double x)
Concatenates scaling transformation onto the current one.
• FL EXPORT void fl scroll (int X, int Y, int W, int H, int dx, int dy, void(∗draw area)(void ∗, int, int,
int, int), void ∗data)
Scroll a rectangle and draw the newly exposed portions.
• FL EXPORT void fl set spot (int font, int size, int X, int Y, int W, int H, Fl Window ∗win=0)
• FL EXPORT void fl set status (int X, int Y, int W, int H)
• FL EXPORT const char ∗ fl shortcut label (unsigned int shortcut)
240 CHAPTER 30. MODULE DOCUMENTATION

Get a human-readable string from a shortcut value.


• FL EXPORT const char ∗ fl shortcut label (unsigned int shortcut, const char ∗∗eom)
Get a human-readable string from a shortcut value.
• double fl transform dx (double x, double y)
Transforms distance using current transformation matrix.
• double fl transform dy (double x, double y)
Transforms distance using current transformation matrix.
• double fl transform x (double x, double y)
Transforms coordinate using the current transformation matrix.
• double fl transform y (double x, double y)
Transforms coordinate using the current transformation matrix.
• void fl transformed vertex (double xf, double yf)
Adds coordinate pair to the vertex list without further transformations.
• void fl translate (double x, double y)
Concatenates translation transformation onto the current one.
• void fl vertex (double x, double y)
Adds a single vertex to the current path.
• void fl xyline (int x, int y, int x1)
Draws a horizontal line from (x,y) to (x1,y)
• void fl xyline (int x, int y, int x1, int y2)
Draws a horizontal line from (x,y) to (x1,y), then vertical from (x1,y) to (x1,y2)
• void fl xyline (int x, int y, int x1, int y2, int x3)
Draws a horizontal line from (x,y) to (x1,y), then a vertical from (x1,y) to (x1,y2) and then another horizontal
from (x1,y2) to (x3,y2)
• void fl yxline (int x, int y, int y1)
Draws a vertical line from (x,y) to (x,y1)
• void fl yxline (int x, int y, int y1, int x2)
Draws a vertical line from (x,y) to (x,y1), then a horizontal from (x,y1) to (x2,y1)
• void fl yxline (int x, int y, int y1, int x2, int y3)
Draws a vertical line from (x,y) to (x,y1) then a horizontal from (x,y1) to (x2,y1), then another vertical from
(x2,y1) to (x2,y3)

Variables
• const int stack max = 16

30.7.1 Detailed Description


FLTK global graphics and GUI drawing functions. These functions are declared in <FL/fl draw.H>, and
in <FL/x.H> for offscreen buffer-related ones.

30.7.2 Macro Definition Documentation


#define fl clip fl push clip
Intersects the current clip region with a rectangle and pushes this new region onto the stack (deprecated).
30.7. DRAWING FUNCTIONS 241

Parameters
in x,y,w,h position and size

Deprecated fl clip(int, int, int, int) is deprecated and will be removed from future releases. Please use
fl push clip(int x, int y, int w, int h) instead.

30.7.3 Enumeration Type Documentation


anonymous enum
Enumerator
FL SOLID line style:
FL DASH line style:
FL DOT line style: . . . . . .
FL DASHDOT line style: . . .
FL DASHDOTDOT line style: . . . .
FL CAP FLAT cap style: end is flat
FL CAP ROUND cap style: end is round
FL CAP SQUARE cap style: end wraps end point
FL JOIN MITER join style: line join extends to a point
FL JOIN ROUND join style: line join is rounded
FL JOIN BEVEL join style: line join is tidied

30.7.4 Function Documentation


FL EXPORT int fl add symbol ( const char ∗ name, void(∗)(Fl Color) drawit, int scalable )
Adds a symbol to the system.
Parameters
in name name of symbol (without the ”@”)
in drawit function to draw symbol
in scalable set to 1 if drawit uses scalable vector drawing

Returns
1 on success, 0 on failure

void fl arc ( int x, int y, int w, int h, double a1, double a2 ) [inline]
Draw ellipse sections using integer coordinates.
These functions match the rather limited circle drawing code provided by X and WIN32. The advantage
over using fl arc with floating point coordinates is that they are faster because they often use the hardware,
and they draw much nicer small circles, since the small sizes are often hard-coded bitmaps.
If a complete circle is drawn it will fit inside the passed bounding box. The two angles are measured
in degrees counter-clockwise from 3 o’clock and are the starting and ending angle of the arc, a2 must be
greater or equal to a1.
fl arc() draws a series of lines to approximate the arc. Notice that the integer version of fl arc() has
a different number of arguments than the double version fl arc(double x, double y, double r, double start,
double end)
242 CHAPTER 30. MODULE DOCUMENTATION

Parameters
in x,y,w,h bounding box of complete circle
in a1,a2 start and end angles of arc measured in degrees counter-clockwise from
3 o’clock. a2 must be greater than or equal to a1.

void fl arc ( double x, double y, double r, double start, double end ) [inline]
Adds a series of points to the current path on the arc of a circle.
You can get elliptical paths by using scale and rotate before calling fl arc().
Parameters
in x,y,r center and radius of circular arc
in start,end angles of start and end of arc measured in degrees counter-clockwise
from 3 o’clock. If end is less than start then it draws the arc in a
clockwise direction.
Examples:
// Draw an arc of points
fl begin points();
fl arc(100.0, 100.0, 50.0, 0.0, 180.0);
fl end points();

// Draw arc with a line


fl begin line();
fl arc(200.0, 100.0, 50.0, 0.0, 180.0);
fl end line();

// Draw filled arc


fl begin polygon();
fl arc(300.0, 100.0, 50.0, 0.0, 180.0);
fl end polygon();

void fl begin complex polygon ( ) [inline]


Starts drawing a complex filled polygon.
The polygon may be concave, may have holes in it, or may be several disconnected pieces. Call fl gap()
to separate loops of the path.
To outline the polygon, use fl begin loop() and replace each fl gap() with fl end loop();fl begin loop()
pairs.

Note
For portability, you should only draw polygons that appear the same whether ”even/odd” or ”non-
zero” winding rules are used to fill them. Holes should be drawn in the opposite direction to the
outside loop.

void fl begin offscreen ( Fl Offscreen ctx )


Send all subsequent drawing commands to this offscreen buffer.
Parameters
ctx the offscreen buffer.

void fl begin points ( ) [inline]


Starts drawing a list of points.
Points are added to the list with fl vertex()
30.7. DRAWING FUNCTIONS 243

FL EXPORT char fl can do alpha blending ( )


Checks whether platform supports true alpha blending for RGBA images.
Returns
1 if true alpha blending supported by platform
0 not supported so FLTK will use screen door transparency

void fl circle ( double x, double y, double r ) [inline]


fl circle() is equivalent to fl arc(x,y,r,0,360), but may be faster.
It must be the only thing in the path: if you want a circle as part of a complex polygon you must use
fl arc()
Parameters
in x,y,r center and radius of circle

int fl clip box ( int x, int y, int w, int h, int & X, int & Y, int & W, int & H ) [inline]
Intersects the rectangle with the current clip region and returns the bounding box of the result.
Returns non-zero if the resulting rectangle is different to the original. This can be used to limit the
necessary drawing to a rectangle. W and H are set to zero if the rectangle is completely outside the region.
Parameters
in x,y,w,h position and size of rectangle
out X,Y,W,H position and size of resulting bounding box.

Returns
Non-zero if the resulting rectangle is different to the original.

void fl clip region ( Fl Region r ) [inline]


Replaces the top of the clipping stack with a clipping region of any shape.
Fl Region is an operating system specific type.
Parameters
in r clipping region

void fl copy offscreen ( int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy )
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
Parameters
x,y position where to draw the copied rectangle
w,h size of the copied rectangle
pixmap offscreen buffer containing the rectangle to copy
srcx,srcy origin in offscreen buffer of rectangle to copy

Fl Offscreen fl create offscreen ( int w, int h )


Creation of an offscreen graphics buffer.
244 CHAPTER 30. MODULE DOCUMENTATION

Parameters
w,h width and height in pixels of the buffer.

Returns
the created graphics buffer.

FL EXPORT void fl cursor ( Fl Cursor c )


Sets the cursor for the current window to the specified shape and colors.
The cursors are defined in the <FL/Enumerations.H> header file.

void fl curve ( double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3 ) [inline]
Adds a series of points on a Bezier curve to the path.
The curve ends (and two of the points) are at X0,Y0 and X3,Y3.
Parameters
in X0,Y0 curve start point
in X1,Y1 curve control point
in X2,Y2 curve control point
in X3,Y3 curve end point

void fl delete offscreen ( Fl Offscreen ctx )


Deletion of an offscreen graphics buffer.
Parameters
ctx the buffer to be deleted.

FL EXPORT void fl draw ( const char ∗ str, int x, int y )


Draws a nul-terminated UTF-8 string starting at the given x, y location.
Text is aligned to the left and to the baseline of the font. To align to the bottom, subtract fl descent()
from y. To align to the top, subtract fl descent() and add fl height(). This version of fl draw provides direct
access to the text drawing function of the underlying OS. It does not apply any special handling to control
characters.

FL EXPORT void fl draw ( int angle, const char ∗ str, int x, int y )
Draws a nul-terminated UTF-8 string starting at the given x, y location and rotating angle degrees
counter-clockwise.
This version of fl draw provides direct access to the text drawing function of the underlying OS and is
supported by Xft, Win32 and MacOS fltk subsets.

FL EXPORT void fl draw ( const char ∗ str, int x, int y, int w, int h, Fl Align align, Fl Image ∗
img, int draw symbols )
Fancy string drawing function which is used to draw all the labels.
The string is formatted and aligned inside the passed box. Handles ’\t’ and ’\n’, expands all other
control characters to ’∧ X’, and aligns inside or against the edges of the box. See Fl Widget::align() for
values of align. The value FL ALIGN INSIDE is ignored, as this function always prints inside the box.
30.7. DRAWING FUNCTIONS 245

If img is provided and is not NULL, the image is drawn above or below the text as specified by the align
value. The draw symbols argument specifies whether or not to look for symbol names starting with the
’@’ character’

FL EXPORT void fl draw box ( Fl Boxtype t, int x, int y, int w, int h, Fl Color c )
Draws a box using given type, position, size and color.
Parameters
in t box type
in x,y,w,h position and size
in c color

void fl draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D = 3, int L = 0 )
[inline]
Draws an 8-bit per color RGB or luminance image.
Parameters
in buf points at the ”r” data of the top-left pixel. Color data must be in r,g,b
order. Luminance data is only one gray byte.
in X,Y position where to put top-left corner of image
in W,H size of the image
in D delta to add to the pointer between pixels. It may be any value greater
than or equal to 1, or it can be negative to flip the image horizontally
in L delta to add to the pointer between lines (if 0 is passed it uses W ∗ D),
and may be larger than W ∗ D to crop data, or negative to flip the image
vertically
It is highly recommended that you put the following code before the first show() of any window in your
program to get rid of the dithering if possible:
Fl::visual(FL RGB);

Gray scale (1-channel) images may be drawn. This is done if abs(D) is less than 3, or by calling fl -
draw image mono(). Only one 8-bit sample is used for each pixel, and on screens with different numbers
of bits for red, green, and blue only gray colors are used. Setting D greater than 1 will let you display one
channel of a color image.
Note:
The X version does not support all possible visuals. If FLTK cannot draw the image in the current
visual it will abort. FLTK supports any visual of 8 bits or less, and all common TrueColor visuals up
to 32 bits.

void fl draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int W, int H, int D = 3 )
[inline]
Draws an image using a callback function to generate image data.
You can generate the image as it is being drawn, or do arbitrary decompression of stored data, provided
it can be decompressed to individual scan lines easily.
246 CHAPTER 30. MODULE DOCUMENTATION

Parameters
in cb callback function to generate scan line data
in data user data passed to callback function
in X,Y screen position of top left pixel
in W,H image width and height
in D data size in bytes (must be greater than 0)

See Also
fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L)

The callback function cb is called with the void∗ data user data pointer to allow access to a structure
of information about the image, and the x, y, and w of the scan line desired from the image. 0,0 is the
upper-left corner of the image, not x, y. A pointer to a buffer to put the data into is passed. You must copy
w pixels from scanline y, starting at pixel x, to this buffer.
Due to cropping, less than the whole image may be requested. So x may be greater than zero, the first
y may be greater than zero, and w may be less than W. The buffer is long enough to store the entire W ∗ D
pixels, this is for convenience with some decompression schemes where you must decompress the entire
line at once: decompress it into the buffer, and then if x is not zero, copy the data over so the x’th pixel
is at the start of the buffer.
You can assume the y’s will be consecutive, except the first one may be greater than zero.
If D is 4 or more, you must fill in the unused bytes with zero.

void fl draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H, int D = 1, int L = 0 )
[inline]
Draws a gray-scale (1 channel) image.
See Also
fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L)

void fl draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int W, int H, int D =
1 ) [inline]
Draws a gray-scale image using a callback function to generate image data.
See Also
fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D)

FL EXPORT int fl draw pixmap ( char ∗const ∗ data, int x, int y, Fl Color bg )
Draw XPM image data, with the top-left corner at the given position.
The image is dithered on 8-bit displays so you won’t lose color space for programs displaying both
images and pixmaps.
Parameters
in data pointer to XPM image data
in x,y position of top-left corner
30.7. DRAWING FUNCTIONS 247

in bg background color

Returns
0 if there was any error decoding the XPM data.

FL EXPORT int fl draw pixmap ( const char ∗const ∗ cdata, int x, int y, Fl Color bg )
Draw XPM image data, with the top-left corner at the given position.
See Also
fl draw pixmap(char∗ const∗ data, int x, int y, Fl Color bg)

FL EXPORT int fl draw symbol ( const char ∗ label, int x, int y, int w, int h, Fl Color col )
Draw the named symbol in the given rectangle using the given color.
Parameters
in label name of symbol
in x,y position of symbol
in w,h size of symbol
in col color of symbox

Returns
1 on success, 0 on failure

FL EXPORT const char∗ fl expand text ( const char ∗ from, char ∗ buf, int maxbuf, double maxw,
int & n, double & width, int wrap, int draw symbols )
Copy from to buf, replacing control characters with ∧ X.
Stop at a newline or if maxbuf characters written to buffer. Also word-wrap if width exceeds maxw.
Returns a pointer to the start of the next line of characters. Sets n to the number of characters put into the
buffer. Sets width to the width of the string in the current font.

FL EXPORT void fl frame ( const char ∗ s, int x, int y, int w, int h )


Draws a series of line segments around the given box.
The string s must contain groups of 4 letters which specify one of 24 standard grayscale values, where
’A’ is black and ’X’ is white. The order of each set of 4 characters is: top, left, bottom, right. The result
of calling fl frame() with a string that is not a multiple of 4 characters in length is undefined. The only
difference between this function and fl frame2() is the order of the line segments.
Parameters
in s sets of 4 grayscale values in top, left, bottom, right order
in x,y,w,h position and size

FL EXPORT void fl frame2 ( const char ∗ s, int x, int y, int w, int h )


Draws a series of line segments around the given box.
The string s must contain groups of 4 letters which specify one of 24 standard grayscale values, where
’A’ is black and ’X’ is white. The order of each set of 4 characters is: bottom, right, top, left. The result
of calling fl frame2() with a string that is not a multiple of 4 characters in length is undefined. The only
difference between this function and fl frame() is the order of the line segments.
248 CHAPTER 30. MODULE DOCUMENTATION

Parameters
in s sets of 4 grayscale values in bottom, right, top, left order
in x,y,w,h position and size

void fl gap ( ) [inline]


Call fl gap() to separate loops of the path.
It is unnecessary but harmless to call fl gap() before the first vertex, after the last vertex, or several
times in a row.

void fl line style ( int style, int width = 0, char ∗ dashes = 0 ) [inline]
Sets how to draw lines (the ”pen”).
If you change this it is your responsibility to set it back to the default using fl line style(0).
Parameters
in style A bitmask which is a bitwise-OR of a line style, a cap style, and a join
style. If you don’t specify a dash type you will get a solid line. If you
don’t specify a cap or join type you will get a system-defined default of
whatever value is fastest.
in width The thickness of the lines in pixels. Zero results in the system defined
default, which on both X and Windows is somewhat different and nicer
than 1.
in dashes A pointer to an array of dash lengths, measured in pixels. The first lo-
cation is how long to draw a solid portion, the next is how long to draw
the gap, then the solid, etc. It is terminated with a zero-length entry. A
NULL pointer or a zero-length array results in a solid line. Odd array
sizes are not supported and result in undefined behavior.

Note
Because of how line styles are implemented on Win32 systems, you must set the line style after
setting the drawing color. If you set the color after the line style you will lose the line style settings.
The dashes array does not work under Windows 95, 98 or Me, since those operating systems do
not support complex line styles.

FL EXPORT void fl measure ( const char ∗ str, int & w, int & h, int draw symbols )
Measure how wide and tall the string will be when printed by the fl draw() function with align parameter.
If the incoming w is non-zero it will wrap to that width.
The ’current font’ is used to do the width/height calculations, so unless its value is known at the time
fl measure() is called, it is advised to first set the current font with fl font().
Note: In the general use case, it’s a common error to forget to set w to 0 before calling fl measure()
when wrap behavior isn’t needed.
Parameters
in str nul-terminated string
out w,h width and height of string in current font
30.7. DRAWING FUNCTIONS 249

in draw symbols non-zero to enable @symbol handling [default=1]

// Example: Common use case for fl measure()


const char *s = "This is a test";
int wi=0, hi=0; // initialize to zero before calling fl measure()
fl font(FL HELVETICA, 14); // set current font face/size to be used for measuring
fl measure(s, wi, hi); // returns pixel width/height of string in current font

FL EXPORT int fl measure pixmap ( char ∗const ∗ data, int & w, int & h )
Get the dimensions of a pixmap.
An XPM image contains the dimensions in its data. This function returns the width and height.
Parameters
in data pointer to XPM image data.
out w,h width and height of image

Returns
non-zero if the dimensions were parsed OK
0 if there were any problems

FL EXPORT int fl measure pixmap ( const char ∗const ∗ cdata, int & w, int & h )
Get the dimensions of a pixmap.

See Also
fl measure pixmap(char∗ const∗ data, int &w, int &h)

void fl mult matrix ( double a, double b, double c, double d, double x, double y ) [inline]
Concatenates another transformation onto the current one.
Parameters
in a,b,c,d,x,y transformation matrix elements such that X’ = aX + cY + x and
Y’ = bX +dY + y

int fl not clipped ( int x, int y, int w, int h ) [inline]


Does the rectangle intersect the current clip region?
Parameters
in x,y,w,h position and size of rectangle

Returns
non-zero if any of the rectangle intersects the current clip region. If this returns 0 you don’t have to
draw the object.

Note
Under X this returns 2 if the rectangle is partially clipped, and 1 if it is entirely inside the clip region.
250 CHAPTER 30. MODULE DOCUMENTATION

FL EXPORT unsigned int fl old shortcut ( const char ∗ s )


Emulation of XForms named shortcuts.
Converts ascii shortcut specifications (eg. ”∧ c”) into the FLTK integer equivalent (eg. FL CTRL+’c’)
These ascii characters are used to specify the various keyboard modifier keys:
# - Alt
+ - Shift
ˆ - Control
! - Meta
@ - Command (Ctrl on linux/win, Meta on OSX)

These special characters can be combined to form chords of modifier keys. (See ’Remarks’ below)
After the optional modifier key prefixes listed above, one can either specify a single keyboard character
to use as the shortcut, or a numeric sequence in hex, decimal or octal.
Examples:
"c" -- Uses ’c’ as the shortcut
"#ˆc" -- Same as FL_ALT|FL_CTRL|’c’
"#ˆ!c" -- Same as FL_ALT|FL_CTRL|FL_META|’c’
"@c" -- Same as FL_COMMAND|’c’ (see FL_COMMAND for platform specific behavior)
"0x63" -- Same as "c" (hex 63==’c’)
"99" -- Same as "c" (dec 99==’c’)
"0143" -- Same as "c" (octal 0143==’c’)
"ˆ0x63" -- Same as (FL_CTRL|’c’), or (FL_CTRL|0x63)
"ˆ99" -- Same as (FL_CTRL|’c’), or (FL_CTRL|99)
"ˆ0143" -- Same as (FL_CTRL|’c’), or (FL_CTRL|0143)

Remarks
Due to XForms legacy, there are some odd things to consider when using the modifier characters.
(1) You can use the special modifier keys for chords only if the modifiers are provided in this order:
#, +, ∧ , !, @. Other ordering can yield undefined results.
So for instance, Ctrl-Alt-c must be specified as ”#∧ c” (and not ”∧ #c”), due to the above ordering rule.
(2) If you want to make a shortcut that uses one of the special modifier characters (as the character
being modified), then to avoid confusion, specify the numeric equivalent, e.g.
If you want.. Then use..
----------------------------- ------------------------------
’#’ as the shortcut.. "0x23" (instead of just "#").
’+’ as the shortcut.. "0x2b" (instead of just "+").
’ˆ’ as the shortcut.. "0x5e" (instead of just "ˆ").
Alt-+ as the shortcut.. "#0x2b" (instead of "#+").
Alt-ˆ as the shortcut.. "#0x5e" (instead of "#ˆ").
..etc..

As a general rule that’s easy to remember, unless the shortcut key to be modified is a single alpha-
numeric character [A-Z,a-z,0-9), it’s probably best to use the numeric equivalents.

Todo Fix these silly legacy issues in a future release to support more predictable behavior for the modifier
keys.

void fl pie ( int x, int y, int w, int h, double a1, double a2 ) [inline]
Draw filled ellipse sections using integer coordinates.
Like fl arc(), but fl pie() draws a filled-in pie slice. This slice may extend outside the line drawn by
fl arc(); to avoid this use w - 1 and h - 1.
30.7. DRAWING FUNCTIONS 251

Parameters
in x,y,w,h bounding box of complete circle
in a1,a2 start and end angles of arc measured in degrees counter-clockwise from
3 o’clock. a2 must be greater than or equal to a1.

void fl polygon ( int x, int y, int x1, int y1, int x2, int y2 ) [inline]
Fills a 3-sided polygon.
The polygon must be convex.

void fl polygon ( int x, int y, int x1, int y1, int x2, int y2, int x3, int y3 ) [inline]
Fills a 4-sided polygon.
The polygon must be convex.

void fl pop clip ( ) [inline]


Restores the previous clip region.
You must call fl pop clip() once for every time you call fl push clip(). Unpredictable results may occur
if the clip stack is not empty when you return to FLTK.

void fl push clip ( int x, int y, int w, int h ) [inline]


Intersects the current clip region with a rectangle and pushes this new region onto the stack.
Parameters
in x,y,w,h position and size

void fl push matrix ( ) [inline]


Saves the current transformation matrix on the stack.
The maximum depth of the stack is 32.

FL EXPORT uchar∗ fl read image ( uchar ∗ p, int X, int Y, int W, int H, int alpha = 0 )
Reads an RGB(A) image from the current window or off-screen buffer.
Parameters
in p pixel buffer, or NULL to allocate one
in X,Y position of top-left of image to read
in W,H width and height of image to read
in alpha alpha value for image (0 for none)

Returns
pointer to pixel buffer, or NULL if allocation failed.

The p argument points to a buffer that can hold the image and must be at least W∗H∗3 bytes when reading
RGB images, or W∗H∗4 bytes when reading RGBA images. If NULL, fl read image() will create an array
of the proper size which can be freed using delete[].
The alpha parameter controls whether an alpha channel is created and the value that is placed in the
alpha channel. If 0, no alpha channel is generated.
252 CHAPTER 30. MODULE DOCUMENTATION

void fl rect ( int x, int y, int w, int h ) [inline]

Draws a 1-pixel border inside the given bounding box.


This function is meant for quick drawing of simple boxes. The behavior is undefined for line widths
that are not 1.

FL EXPORT void fl rectf ( int x, int y, int w, int h, uchar r, uchar g, uchar b )

Colors a rectangle with ”exactly” the passed r,g,b color.


On screens with less than 24 bits of color this is done by drawing a solid-colored block using fl draw -
image() so that the correct color shade is produced.

FL EXPORT void fl reset spot ( void )

Todo provide user documentation for fl reset spot function

void fl rotate ( double d ) [inline]

Concatenates rotation transformation onto the current one.


Parameters
in d - rotation angle, counter-clockwise in degrees (not radians)

void fl scale ( double x, double y ) [inline]

Concatenates scaling transformation onto the current one.


Parameters
in x,y scale factors in x-direction and y-direction

void fl scale ( double x ) [inline]

Concatenates scaling transformation onto the current one.


Parameters
in x scale factor in both x-direction and y-direction

FL EXPORT void fl scroll ( int X, int Y, int W, int H, int dx, int dy, void(∗)(void ∗, int, int, int,
int) draw area, void ∗ data )

Scroll a rectangle and draw the newly exposed portions.


Parameters
in X,Y position of top-left of rectangle
in W,H size of rectangle
in dx,dy pixel offsets for shifting rectangle
in draw area callback function to draw rectangular areas
in data pointer to user data for callback The contents of the rectangular area
is first shifted by dx and dy pixels. The draw area callback is then
called for every newly exposed rectangular area.
30.7. DRAWING FUNCTIONS 253

FL EXPORT void fl set spot ( int font, int size, int X, int Y, int W, int H, Fl Window ∗ win = 0 )
Todo provide user documentation for fl set spot function

FL EXPORT void fl set status ( int X, int Y, int W, int H )


Todo provide user documentation for fl set status function

FL EXPORT const char∗ fl shortcut label ( unsigned int shortcut )


Get a human-readable string from a shortcut value.
Unparse a shortcut value as used by Fl Button or Fl Menu Item into a human-readable string like ”-
Alt+N”. This only works if the shortcut is a character key or a numbered function key. If the shortcut is
zero then an empty string is returned. The return value points at a static buffer that is overwritten with each
call.
Parameters
in shortcut the integer value containing the ascii character or extended keystroke
plus modifiers

Returns
a pointer to a static buffer containing human readable text for the shortcut

FL EXPORT const char∗ fl shortcut label ( unsigned int shortcut, const char ∗∗ eom )
Get a human-readable string from a shortcut value.
Parameters
in shortcut the integer value containing the ascii character or extended keystroke
plus modifiers
in eom if this pointer is set, it will receive a pointer to the end of the modifier
text

Returns
a pointer to a static buffer containing human readable text for the shortcut

See Also
fl shortcut label(unsigned int shortcut)

double fl transform dx ( double x, double y ) [inline]


Transforms distance using current transformation matrix.
Parameters
in x,y coordinate

double fl transform dy ( double x, double y ) [inline]


Transforms distance using current transformation matrix.
254 CHAPTER 30. MODULE DOCUMENTATION

Parameters
in x,y coordinate

double fl transform x ( double x, double y ) [inline]


Transforms coordinate using the current transformation matrix.
Parameters
in x,y coordinate

double fl transform y ( double x, double y ) [inline]


Transforms coordinate using the current transformation matrix.
Parameters
in x,y coordinate

void fl transformed vertex ( double xf, double yf ) [inline]


Adds coordinate pair to the vertex list without further transformations.
Parameters
in xf,yf transformed coordinate

void fl translate ( double x, double y ) [inline]


Concatenates translation transformation onto the current one.
Parameters
in x,y translation factor in x-direction and y-direction

void fl vertex ( double x, double y ) [inline]


Adds a single vertex to the current path.
Parameters
in x,y coordinate
30.8. MULTITHREADING SUPPORT FUNCTIONS 255

30.8 Multithreading support functions


fl multithreading support functions declared in <FL/Fl.H>

Functions
• static void Fl::awake (void ∗message=0)
Sends a message pointer to the main thread, causing any pending Fl::wait() call to terminate so that the
main thread can retrieve the message and any pending redraws can be processed.
• static int Fl::awake (Fl Awake Handler cb, void ∗message=0)
See void awake(void∗ message=0).
• static int Fl::lock ()
The lock() method blocks the current thread until it can safely access FLTK widgets and data.
• static void ∗ Fl::thread message ()
The thread message() method returns the last message that was sent from a child by the awake() method.
• static void Fl::unlock ()
The unlock() method releases the lock that was set using the lock() method.

30.8.1 Detailed Description


fl multithreading support functions declared in <FL/Fl.H>

30.8.2 Function Documentation


void Fl::awake ( void ∗ msg = 0 ) [static]

Sends a message pointer to the main thread, causing any pending Fl::wait() call to terminate so that the
main thread can retrieve the message and any pending redraws can be processed.
Multiple calls to Fl::awake() will queue multiple pointers for the main thread to process, up to a system-
defined (typically several thousand) depth. The default message handler saves the last message which can
be accessed using the Fl::thread message() function.
In the context of a threaded application, a call to Fl::awake() with no argument will trigger event loop
handling in the main thread. Since it is not possible to call Fl::flush() from a subsidiary thread, Fl::awake()
is the best (and only, really) substitute.
See also: Multithreading

int Fl::awake ( Fl Awake Handler func, void ∗ data = 0 ) [static]

See void awake(void∗ message=0).


Let the main thread know an update is pending and have it call a specific function.
Registers a function that will be called by the main thread during the next message handling cycle.
Returns 0 if the callback function was registered, and -1 if registration failed. Over a thousand awake
callbacks can be registered simultaneously.

See Also
Fl::awake(void∗ message=0)
256 CHAPTER 30. MODULE DOCUMENTATION

int Fl::lock ( ) [static]


The lock() method blocks the current thread until it can safely access FLTK widgets and data.
Child threads should call this method prior to updating any widgets or accessing data. The main thread
must call lock() to initialize the threading support in FLTK. lock() will return non-zero if threading is not
available on the platform.
Child threads must call unlock() when they are done accessing FLTK.
When the wait() method is waiting for input or timeouts, child threads are given access to FLTK.
Similarly, when the main thread needs to do processing, it will wait until all child threads have called
unlock() before processing additional data.
Returns
0 if threading is available on the platform; non-zero otherwise.

See also: Multithreading

void ∗ Fl::thread message ( ) [static]


The thread message() method returns the last message that was sent from a child by the awake() method.
See also: Multithreading

void Fl::unlock ( ) [static]


The unlock() method releases the lock that was set using the lock() method.
Child threads should call this method as soon as they are finished accessing FLTK.
See also: Multithreading
30.9. SAFE WIDGET DELETION SUPPORT FUNCTIONS 257

30.9 Safe widget deletion support functions


These functions, declared in <FL/Fl.H>, support deletion of widgets inside callbacks.

Functions
• static void Fl::clear widget pointer (Fl Widget const ∗w)
Clears a widget pointer in the watch list.
• static void Fl::delete widget (Fl Widget ∗w)
Schedules a widget for deletion at the next call to the event loop.
• static void Fl::do widget deletion ()
Deletes widgets previously scheduled for deletion.
• static void Fl::release widget pointer (Fl Widget ∗&w)
Releases a widget pointer from the watch list.
• static void Fl::watch widget pointer (Fl Widget ∗&w)
Adds a widget pointer to the widget watch list.

30.9.1 Detailed Description


These functions, declared in <FL/Fl.H>, support deletion of widgets inside callbacks. Fl::delete widget()
should be called when deleting widgets or complete widget trees (Fl Group, Fl Window, ...) inside call-
backs.
The other functions are intended for internal use. The preferred way to use them is by using the helper
class Fl Widget Tracker.
The following is to show how it works ...
There are three groups of related methods:

1. scheduled widget deletion

• Fl::delete widget() schedules widgets for deletion


• Fl::do widget deletion() deletes all scheduled widgets

2. widget watch list (”smart pointers”)

• Fl::watch widget pointer() adds a widget pointer to the watch list


• Fl::release widget pointer() removes a widget pointer from the watch list
• Fl::clear widget pointer() clears a widget pointer in the watch list

3. the class Fl Widget Tracker:

• the constructor calls Fl::watch widget pointer()


• the destructor calls Fl::release widget pointer()
• the access methods can be used to test, if a widget has been deleted
See Also
Fl Widget Tracker.
258 CHAPTER 30. MODULE DOCUMENTATION

30.9.2 Function Documentation


void Fl::clear widget pointer ( Fl Widget const ∗ w ) [static]
Clears a widget pointer in the watch list.
This is called when a widget is destroyed (by its destructor). You should never call this directly.

Note
Internal use only !

This method searches the widget watch list for pointers to the widget and clears each pointer that points to
it. Widget pointers can be added to the widget watch list by calling Fl::watch widget pointer() or by using
the helper class Fl Widget Tracker (recommended).

See Also
Fl::watch widget pointer()
class Fl Widget Tracker

void Fl::delete widget ( Fl Widget ∗ wi ) [static]


Schedules a widget for deletion at the next call to the event loop.
Use this method to delete a widget inside a callback function.
To avoid early deletion of widgets, this function should be called toward the end of a callback and only
after any call to the event loop (Fl::wait(), Fl::flush(), Fl::check(), fl ask(), etc.).
When deleting groups or windows, you must only delete the group or window widget and not the
individual child widgets.

Since
FLTK 1.3 it is not necessary to remove widgets from their parent groups or windows before calling
this, because it will be done in the widget’s destructor, but it is not a failure to do this nevertheless.

Note
In FLTK 1.1 you must remove widgets from their parent group (or window) before deleting them.

See Also
Fl Widget::∼Fl Widget()

void Fl::do widget deletion ( ) [static]


Deletes widgets previously scheduled for deletion.
This is for internal use only. You should never call this directly.
Fl::do widget deletion() is called from the FLTK event loop or whenever you call Fl::wait(). The
previously scheduled widgets are deleted in the same order they were scheduled by calling Fl::delete -
widget().

See Also
Fl::delete widget(Fl Widget ∗wi)
30.9. SAFE WIDGET DELETION SUPPORT FUNCTIONS 259

void Fl::release widget pointer ( Fl Widget ∗& w ) [static]


Releases a widget pointer from the watch list.
This is used to remove a widget pointer that has been added to the watch list with Fl::watch widget -
pointer(), when it is not needed anymore.
Note
Internal use only, please use class Fl Widget Tracker instead.

See Also
Fl::watch widget pointer()

void Fl::watch widget pointer ( Fl Widget ∗& w ) [static]


Adds a widget pointer to the widget watch list.
Note
Internal use only, please use class Fl Widget Tracker instead.

This can be used, if it is possible that a widget might be deleted during a callback or similar function. The
widget pointer must be added to the watch list before calling the callback. After the callback the widget
pointer can be queried, if it is NULL. If it is NULL, then the widget has been deleted during the callback
and must not be accessed anymore. If the widget pointer is not NULL, then the widget has not been deleted
and can be accessed safely.
After accessing the widget, the widget pointer must be released from the watch list by calling Fl-
::release widget pointer().
Example for a button that is clicked (from its handle() method):
Fl Widget *wp = this; // save ’this’ in a pointer variable
Fl::watch widget pointer(wp); // add the pointer to the watch list
set changed(); // set the changed flag
do callback(); // call the callback
if (!wp) { // the widget has been deleted

// DO NOT ACCESS THE DELETED WIDGET !

} else { // the widget still exists


clear changed(); // reset the changed flag
}

Fl::release widget pointer(wp); // remove the pointer from the watch list

This works, because all widgets call Fl::clear widget pointer() in their destructors.
See Also
Fl::release widget pointer()
Fl::clear widget pointer()

An easier and more convenient method to control widget deletion during callbacks is to use the class Fl -
Widget Tracker with a local (automatic) variable.
See Also
class Fl Widget Tracker
260 CHAPTER 30. MODULE DOCUMENTATION

30.10 Cairo support functions and classes


Classes
• class Fl Cairo State
Contains all the necessary info on the current cairo context.
• class Fl Cairo Window
This defines a pre-configured cairo fltk window.

Functions
• static void Fl::cairo autolink context (bool alink)
when FLTK HAVE CAIRO is defined and cairo autolink context() is true, any current window dc is linked
to a current context.
• static bool Fl::cairo autolink context ()
Gets the current autolink mode for cairo support.
• static cairo t ∗ Fl::cairo cc ()
Gets the current cairo context linked with a fltk window.
• static void Fl::cairo cc (cairo t ∗c, bool own=false)
Sets the current cairo context to c.
• static cairo t ∗ Fl::cairo make current (Fl Window ∗w)
Provides a corresponding cairo context for window wi.

30.10.1 Detailed Description


30.10.2 Function Documentation
static void Fl::cairo autolink context ( bool alink ) [inline], [static]
when FLTK HAVE CAIRO is defined and cairo autolink context() is true, any current window dc is linked
to a current context.
This is not the default, because it may not be necessary to add cairo support to all fltk supported
windows. When you wish to associate a cairo context in this mode, you need to call explicitly in your draw()
overridden method, FL::cairo make current(Fl Window∗). This will create a cairo context but only for this
Window. Still in custom cairo application it is possible to handle completely this process automatically by
setting alink to true. In this last case, you don’t need anymore to call Fl::cairo make current(). You can
use Fl::cairo cc() to get the current cairo context anytime.
Note
Only available when configure has the –enable-cairo option

static bool Fl::cairo autolink context ( ) [inline], [static]


Gets the current autolink mode for cairo support.
Return values
false if no cairo context autolink is made for each window.
true if any fltk window is attached a cairo context when it is current.

See Also
void cairo autolink context(bool alink)
30.10. CAIRO SUPPORT FUNCTIONS AND CLASSES 261

Note
Only available when configure has the –enable-cairo option

static cairo t∗ Fl::cairo cc ( ) [inline], [static]


Gets the current cairo context linked with a fltk window.

static void Fl::cairo cc ( cairo t ∗ c, bool own = false ) [inline], [static]


Sets the current cairo context to c.
Set own to true if you want fltk to handle this cc deletion.
Note
Only available when configure has the –enable-cairo option

cairo t ∗ Fl::cairo make current ( Fl Window ∗ wi ) [static]


Provides a corresponding cairo context for window wi.
This is needed in a draw() override if Fl::cairo autolink context() returns false, which is the default.
The cairo context() does not need to be freed as it is freed every time a new cairo context is created. When
the program terminates, a call to Fl::cairo make current(0) will destroy any residual context.
Note
A new cairo context is not always re-created when this method is used. In particular, if the cur-
rent graphical context and the current window didn’t change between two calls, the previous gc is
internally kept, thus optimizing the drawing performances. Also, after this call, Fl::cairo gc() is
adequately updated with this cairo context.
Only available when configure has the –enable-cairo option

Returns
the valid cairo t∗ cairo context associated to this window.
262 CHAPTER 30. MODULE DOCUMENTATION

30.11 Unicode and UTF-8 functions


fl global Unicode and UTF-8 handling functions declared in <FL/fl utf8.h>

Macros
• #define ERRORS TO CP1252 1
• #define ERRORS TO ISO8859 1 1
• #define NBC 0xFFFF + 1
• #define STRICT RFC3629 0

Functions
• FL EXPORT int fl access (const char ∗f, int mode)
• FL EXPORT int fl chmod (const char ∗f, int mode)
• FL EXPORT int fl execvp (const char ∗file, char ∗const ∗argv)
• FL EXPORT FILE ∗ fl fopen (const char ∗f, const char ∗mode)
Cross-platform function to open files with a UTF-8 encoded name.
• FL EXPORT char ∗ fl getcwd (char ∗buf, int maxlen)
• FL EXPORT char ∗ fl getenv (const char ∗name)
• FL EXPORT char fl make path (const char ∗path)
• FL EXPORT void fl make path for file (const char ∗path)
• FL EXPORT int fl mkdir (const char ∗f, int mode)
• FL EXPORT unsigned int fl nonspacing (unsigned int ucs)
returns true if the character is non-spacing.
• FL EXPORT int fl open (const char ∗f, int oflags,...)
Cross-platform function to open files with a UTF-8 encoded name.
• FL EXPORT int fl rename (const char ∗f, const char ∗t)
• FL EXPORT int fl rmdir (const char ∗f)
• FL EXPORT int fl stat (const char ∗path, struct stat ∗buffer)
• FL EXPORT int fl system (const char ∗f)
• FL EXPORT int fl tolower (unsigned int ucs)
return the Unicode lower case value of ucs
• FL EXPORT int fl toupper (unsigned int ucs)
return the Unicode upper case value of ucs
• FL EXPORT unsigned fl ucs to Utf16 (const unsigned ucs, unsigned short ∗dst, const unsigned
dstlen)
• FL EXPORT int fl unlink (const char ∗f)
• FL EXPORT char ∗ fl utf2mbcs (const char ∗s)
converts UTF8 to a local multi-byte character string.
• FL EXPORT const char ∗ fl utf8back (const char ∗p, const char ∗start, const char ∗end)
• FL EXPORT int fl utf8bytes (unsigned ucs)
Return the number of bytes needed to encode the given UCS4 character in UTF8.
• FL EXPORT unsigned fl utf8decode (const char ∗p, const char ∗end, int ∗len)
• FL EXPORT int fl utf8encode (unsigned ucs, char ∗buf)
• FL EXPORT unsigned fl utf8from mb (char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen)
• FL EXPORT unsigned fl utf8froma (char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen)
• FL EXPORT unsigned fl utf8fromwc (char ∗dst, unsigned dstlen, const wchar t ∗src, unsigned sr-
clen)
• FL EXPORT const char ∗ fl utf8fwd (const char ∗p, const char ∗start, const char ∗end)
30.11. UNICODE AND UTF-8 FUNCTIONS 263

• FL EXPORT int fl utf8len (char c)


return the byte length of the UTF-8 sequence with first byte c, or -1 if c is not valid.
• FL EXPORT int fl utf8len1 (char c)
Return the byte length of the UTF-8 sequence with first byte c, or 1 if c is not valid.
• FL EXPORT int fl utf8locale ()
• FL EXPORT int fl utf8test (const char ∗src, unsigned len)
• FL EXPORT unsigned fl utf8to mb (const char ∗src, unsigned srclen, char ∗dst, unsigned dstlen)
• FL EXPORT unsigned fl utf8toa (const char ∗src, unsigned srclen, char ∗dst, unsigned dstlen)
• FL EXPORT unsigned fl utf8toUtf16 (const char ∗src, unsigned srclen, unsigned short ∗dst, un-
signed dstlen)
• FL EXPORT unsigned fl utf8towc (const char ∗src, unsigned srclen, wchar t ∗dst, unsigned dstlen)
Converts a UTF-8 string into a wide character string.
• FL EXPORT int fl utf nb char (const unsigned char ∗buf, int len)
returns the number of Unicode chars in the UTF-8 string
• FL EXPORT int fl utf strcasecmp (const char ∗s1, const char ∗s2)
UTF-8 aware strcasecmp - converts to Unicode and tests.
• FL EXPORT int fl utf strncasecmp (const char ∗s1, const char ∗s2, int n)
UTF-8 aware strncasecmp - converts to lower case Unicode and tests.
• FL EXPORT int fl utf tolower (const unsigned char ∗str, int len, char ∗buf)
converts the str string to the lower case equivalent into buf.
• FL EXPORT int fl utf toupper (const unsigned char ∗str, int len, char ∗buf)
converts the str string to the upper case equivalent into buf.
• FL EXPORT int fl wcwidth (const char ∗src)
extended wrapper around fl wcwidth (unsigned int ucs) function.
• FL EXPORT int fl wcwidth (unsigned int ucs)
wrapper to adapt Markus Kuhn’s implementation of wcwidth() for FLTK

30.11.1 Detailed Description


fl global Unicode and UTF-8 handling functions declared in <FL/fl utf8.h>

30.11.2 Macro Definition Documentation


#define ERRORS TO CP1252 1
Set to 1 to turn bad UTF8 bytes in the 0x80-0x9f range into the Unicode index for Microsoft’s CP1252
character set. You should also set ERRORS TO ISO8859 1. With this a huge amount of more available
text (such as all web pages) are correctly converted to Unicode.

#define ERRORS TO ISO8859 1 1


Set to 1 to turn bad UTF8 bytes into ISO-8859-1. If this is to zero they are instead turned into the Unicode
REPLACEMENT CHARACTER, of value 0xfffd. If this is on fl utf8decode() will correctly map most
(perhaps all) human-readable text that is in ISO-8859-1. This may allow you to completely ignore character
sets in your code because virtually everything is either ISO-8859-1 or UTF-8.

#define STRICT RFC3629 0


A number of Unicode code points are in fact illegal and should not be produced by a UTF-8 converter.
Turn this on will replace the bytes in those encodings with errors. If you do this then converting arbitrary
16-bit data to UTF-8 and then back is not an identity, which will probably break a lot of software.
264 CHAPTER 30. MODULE DOCUMENTATION

30.11.3 Function Documentation


FILE ∗ fl fopen ( const char ∗ f, const char ∗ mode )
Cross-platform function to open files with a UTF-8 encoded name.
This function is especially useful under the MSWindows platform where the standard fopen() function
fails with UTF-8 encoded non-ASCII filenames.
Parameters
f the UTF-8 encoded filename
mode same as the second argument of the standard fopen() function

Returns
a FILE pointer upon successful completion, or NULL in case of error.

See Also
fl open().

unsigned int fl nonspacing ( unsigned int ucs )


returns true if the character is non-spacing.

Todo explain what non-spacing means.

int fl open ( const char ∗ f, int oflags, ... )


Cross-platform function to open files with a UTF-8 encoded name.
This function is especially useful under the MSWindows platform where the standard open() function
fails with UTF-8 encoded non-ASCII filenames.
Parameters
f the UTF-8 encoded filename
oflags other arguments are as in the standard open() function

Returns
a file descriptor upon successful completion, or -1 in case of error.

See Also
fl fopen().

unsigned fl ucs to Utf16 ( const unsigned ucs, unsigned short ∗ dst, const unsigned dstlen )
Convert a single 32-bit Unicode codepoint into an array of 16-bit characters. These are used by some
system calls, especially on Windows.
ucs is the value to convert.
dst points at an array to write, and dstlen is the number of locations in this array. At most dstlen
words will be written, and a 0 terminating word will be added if dstlen is large enough. Thus this
function will never overwrite the buffer and will attempt return a zero-terminated string if space permits. If
dstlen is zero then dst can be set to NULL and no data is written, but the length is returned.
The return value is the number of 16-bit words that would be written to dst if it is large enough, not
counting any terminating zero.
30.11. UNICODE AND UTF-8 FUNCTIONS 265

If the return value is greater than dstlen it indicates truncation, you should then allocate a new array
of size return+1 and call this again.
Unicode characters in the range 0x10000 to 0x10ffff are converted to ”surrogate pairs” which take two
words each (in UTF-16 encoding). Typically, setting dstlen to 2 will ensure that any valid Unicode value
can be converted, and setting dstlen to 3 or more will allow a NULL terminated sequence to be returned.

const char ∗ fl utf8back ( const char ∗ p, const char ∗ start, const char ∗ end )
Move p backward until it points to the start of a UTF-8 character. If it already points at the start of one then
it is returned unchanged. Any UTF-8 errors are treated as though each byte of the error is an individual
character.
start is the start of the string and is used to limit the backwards search for the start of a UTF-8 character.
end is the end of the string and is assumed to be a break between characters. It is assumed to be greater
than p.
If you wish to decrement a UTF-8 pointer, pass p-1 to this.

int fl utf8bytes ( unsigned ucs )


Return the number of bytes needed to encode the given UCS4 character in UTF8.
Parameters
in ucs UCS4 encoded character

Returns
number of bytes required

Returns number of bytes that utf8encode() will use to encode the character ucs.

unsigned fl utf8decode ( const char ∗ p, const char ∗ end, int ∗ len )


Decode a single UTF-8 encoded character starting at p. The resulting Unicode value (in the range 0-
0x10ffff) is returned, and len is set to the number of bytes in the UTF-8 encoding (adding len to p will
point at the next character).
If p points at an illegal UTF-8 encoding, including one that would go past end, or where a code is uses
more bytes than necessary, then ∗(unsigned char∗)p is translated as though it is in the Microsoft CP1252
character set and len is set to 1. Treating errors this way allows this to decode almost any ISO-8859-1 or
CP1252 text that has been mistakenly placed where UTF-8 is expected, and has proven very useful.
If you want errors to be converted to error characters (as the standards recommend), adding a test to see
if the length is unexpectedly 1 will work:
if (*p & 0x80) { // what should be a multibyte encoding
code = fl utf8decode(p,end,&len);
if (len<2) code = 0xFFFD; // Turn errors into REPLACEMENT CHARACTER
} else { // handle the 1-byte utf8 encoding:
code = *p;
len = 1;
}

Direct testing for the 1-byte case (as shown above) will also speed up the scanning of strings where the
majority of characters are ASCII.

int fl utf8encode ( unsigned ucs, char ∗ buf )


Write the UTF-8 encoding of ucs into buf and return the number of bytes written. Up to 4 bytes may be
written. If you know that ucs is less than 0x10000 then at most 3 bytes will be written. If you wish to
speed this up, remember that anything less than 0x80 is written as a single byte.
266 CHAPTER 30. MODULE DOCUMENTATION

If ucs is greater than 0x10ffff this is an illegal character according to RFC 3629. These are converted
as though they are 0xFFFD (REPLACEMENT CHARACTER).
RFC 3629 also says many other values for ucs are illegal (in the range 0xd800 to 0xdfff, or ending
with 0xfffe or 0xffff). However I encode these as though they are legal, so that utf8encode/fl utf8decode
will be the identity for all codes between 0 and 0x10ffff.

unsigned fl utf8from mb ( char ∗ dst, unsigned dstlen, const char ∗ src, unsigned srclen )
Convert a filename from the locale-specific multibyte encoding used by Windows to UTF-8 as used by
FLTK.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
On Unix or on Windows when a UTF-8 locale is in effect, this does not change the data. You may also
want to check if fl utf8test() returns non-zero, so that the filesystem can store filenames in UTF-8 encoding
regardless of the locale.

unsigned fl utf8froma ( char ∗ dst, unsigned dstlen, const char ∗ src, unsigned srclen )
Convert an ISO-8859-1 (ie normal c-string) byte stream to UTF-8.
It is possible this should convert Microsoft’s CP1252 to UTF-8 instead. This would translate the codes
in the range 0x80-0x9f to different characters. Currently it does not do this.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
srclen is the number of bytes in src to convert.
If the return value equals srclen then this indicates that no conversion is necessary, as only ASCII
characters are in the string.

unsigned fl utf8fromwc ( char ∗ dst, unsigned dstlen, const wchar t ∗ src, unsigned srclen )
Turn ”wide characters” as returned by some system calls (especially on Windows) into UTF-8.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
srclen is the number of words in src to convert. On Windows this is not necessarily the number of
characters, due to there possibly being ”surrogate pairs” in the UTF-16 encoding used. On Unix wchar t is
32 bits and each location is a character.
On Unix if a src word is greater than 0x10ffff then this is an illegal character according to RFC 3629.
These are converted as though they are 0xFFFD (REPLACEMENT CHARACTER). Characters in the
range 0xd800 to 0xdfff, or ending with 0xfffe or 0xffff are also illegal according to RFC 3629. However I
encode these as though they are legal, so that fl utf8towc will return the original data.
On Windows ”surrogate pairs” are converted to a single character and UTF-8 encoded (as 4 bytes).
Mismatched halves of surrogate pairs are converted as though they are individual characters.

const char ∗ fl utf8fwd ( const char ∗ p, const char ∗ start, const char ∗ end )
Move p forward until it points to the start of a UTF-8 character. If it already points at the start of one then
it is returned unchanged. Any UTF-8 errors are treated as though each byte of the error is an individual
character.
start is the start of the string and is used to limit the backwards search for the start of a utf8 character.
30.11. UNICODE AND UTF-8 FUNCTIONS 267

end is the end of the string and is assumed to be a break between characters. It is assumed to be greater
than p.
This function is for moving a pointer that was jumped to the middle of a string, such as when doing a
binary search for a position. You should use either this or fl utf8back() depending on which direction your
algorithim can handle the pointer moving. Do not use this to scan strings, use fl utf8decode() instead.

int fl utf8len ( char c )


return the byte length of the UTF-8 sequence with first byte c, or -1 if c is not valid.
This function is helpful for finding faulty UTF8 sequences.

See Also
fl utf8len1

int fl utf8len1 ( char c )


Return the byte length of the UTF-8 sequence with first byte c, or 1 if c is not valid.
This function can be used to scan faulty UTF8 sequence, albeit ignoring invalid codes.

See Also
fl utf8len

int fl utf8locale ( void )


Return true if the ”locale” seems to indicate that UTF-8 encoding is used. If true the fl utf8to mb and
fl utf8from mb don’t do anything useful.
It is highly recommended that you change your system so this does return true. On Windows this is
done by setting the ”codepage” to CP UTF8. On Unix this is done by setting $LC CTYPE to a string
containing the letters ”utf” or ”UTF” in it, or by deleting all $LC∗ and $LANG environment variables. In
the future it is likely that all non-Asian Unix systems will return true, due to the compatibility of UTF-8
with ISO-8859-1.

int fl utf8test ( const char ∗ src, unsigned srclen )


Examines the first srclen bytes in src and returns a verdict on whether it is UTF-8 or not.

• Returns 0 if there is any illegal UTF-8 sequences, using the same rules as fl utf8decode(). Note that
some UCS values considered illegal by RFC 3629, such as 0xffff, are considered legal by this.

• Returns 1 if there are only single-byte characters (ie no bytes have the high bit set). This is legal
UTF-8, but also indicates plain ASCII. It also returns 1 if srclen is zero.

• Returns 2 if there are only characters less than 0x800.

• Returns 3 if there are only characters less than 0x10000.

• Returns 4 if there are characters in the 0x10000 to 0x10ffff range.

Because there are many illegal sequences in UTF-8, it is almost impossible for a string in another
encoding to be confused with UTF-8. This is very useful for transitioning Unix to UTF-8 filenames, you
can simply test each filename with this to decide if it is UTF-8 or in the locale encoding. My hope is that
if this is done we will be able to cleanly transition to a locale-less encoding.
268 CHAPTER 30. MODULE DOCUMENTATION

unsigned fl utf8to mb ( const char ∗ src, unsigned srclen, char ∗ dst, unsigned dstlen )
Convert the UTF-8 used by FLTK to the locale-specific encoding used for filenames (and sometimes used
for data in files). Unfortunately due to stupid design you will have to do this as needed for filenames. This
is a bug on both Unix and Windows.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.
If fl utf8locale() returns true then this does not change the data.

unsigned fl utf8toa ( const char ∗ src, unsigned srclen, char ∗ dst, unsigned dstlen )
Convert a UTF-8 sequence into an array of 1-byte characters.
If the UTF-8 decodes to a character greater than 0xff then it is replaced with ’?’.
Errors in the UTF-8 are converted as individual bytes, same as fl utf8decode() does. This allows ISO-
8859-1 text mistakenly identified as UTF-8 to be printed correctly (and possibly CP1512 on Windows).
src points at the UTF-8, and srclen is the number of bytes to convert.
Up to dstlen bytes are written to dst, including a null terminator. The return value is the number
of bytes that would be written, not counting the null terminator. If greater or equal to dstlen then if you
malloc a new array of size n+1 you will have the space needed for the entire string. If dstlen is zero then
nothing is written and this call just measures the storage space needed.

unsigned fl utf8toUtf16 ( const char ∗ src, unsigned srclen, unsigned short ∗ dst, unsigned dstlen )
Convert a UTF-8 sequence into an array of 16-bit characters. These are used by some system calls, espe-
cially on Windows.
src points at the UTF-8, and srclen is the number of bytes to convert.
dst points at an array to write, and dstlen is the number of locations in this array. At most
dstlen-1 words will be written there, plus a 0 terminating word. Thus this function will never over-
write the buffer and will always return a zero-terminated string. If dstlen is zero then dst can be null
and no data is written, but the length is returned.
The return value is the number of 16-bit words that would be written to dst if it were long enough, not
counting the terminating zero. If the return value is greater or equal to dstlen it indicates truncation, you
can then allocate a new array of size return+1 and call this again.
Errors in the UTF-8 are converted as though each byte in the erroneous string is in the Microsoft C-
P1252 encoding. This allows ISO-8859-1 text mistakenly identified as UTF-8 to be printed correctly.
Unicode characters in the range 0x10000 to 0x10ffff are converted to ”surrogate pairs” which take two
words each (this is called UTF-16 encoding).

unsigned fl utf8towc ( const char ∗ src, unsigned srclen, wchar t ∗ dst, unsigned dstlen )
Converts a UTF-8 string into a wide character string.
This function generates 32-bit wchar t (e.g. ”ucs4” as it were) except on Windows where it is equivalent
to fl utf8toUtf16 and returns UTF-16.
src points at the UTF-8, and srclen is the number of bytes to convert.
dst points at an array to write, and dstlen is the number of locations in this array. At most
dstlen-1 wchar t will be written there, plus a 0 terminating wchar t.
The return value is the number of wchar t that would be written to dst if it were long enough, not
counting the terminating zero. If the return value is greater or equal to dstlen it indicates truncation, you
can then allocate a new array of size return+1 and call this again.
Notice that sizeof(wchar t) is 2 on Windows and is 4 on Linux and most other systems. Where wchar t
is 16 bits, Unicode characters in the range 0x10000 to 0x10ffff are converted to ”surrogate pairs” which
take two words each (this is called UTF-16 encoding). If wchar t is 32 bits this rather nasty problem is
avoided.
30.11. UNICODE AND UTF-8 FUNCTIONS 269

Note that Windows includes Cygwin, i.e. compiled with Cygwin’s POSIX layer (cygwin1.dll, –enable-
cygwin), either native (GDI) or X11.

int fl utf strcasecmp ( const char ∗ s1, const char ∗ s2 )


UTF-8 aware strcasecmp - converts to Unicode and tests.
Returns
0 if the strings are equal
1 if s1 is greater than s2
-1 if s1 is less than s2

int fl utf strncasecmp ( const char ∗ s1, const char ∗ s2, int n )
UTF-8 aware strncasecmp - converts to lower case Unicode and tests.
Parameters
s1,s2 the utf8 strings to compare
n the maximum number of utf8 characters to compare

Returns
0 if the strings are equal
>0 if s1 is greater than s2
<0 if s1 is less than s2

int fl utf tolower ( const unsigned char ∗ str, int len, char ∗ buf )
converts the str string to the lower case equivalent into buf.
Warning: to be safe buf length must be at least 3 ∗ len [for 16-bit Unicode]

int fl utf toupper ( const unsigned char ∗ str, int len, char ∗ buf )
converts the str string to the upper case equivalent into buf.
Warning: to be safe buf length must be at least 3 ∗ len [for 16-bit Unicode]

int fl wcwidth ( const char ∗ src )


extended wrapper around fl wcwidth (unsigned int ucs) function.
Parameters
in src pointer to start of UTF-8 byte sequence

Returns
width of character in columns

Depending on build options, this function may map C1 control characters (0x80 to 0x9f) to CP1252, and
return the width of that character instead. This is not the same behaviour as fl wcwidth (unsigned int ucs) .
Note that other control characters and DEL will still return -1, so if you want different behaviour, you
need to test for those characters before calling fl wcwidth(), and handle them separately.

int fl wcwidth ( unsigned int ucs )


wrapper to adapt Markus Kuhn’s implementation of wcwidth() for FLTK
270 CHAPTER 30. MODULE DOCUMENTATION

Parameters
in ucs Unicode character value

Returns
width of character in columns

See http://www.cl.cam.ac.uk/∼mgk25/ucs/wcwidth.c for Markus Kuhn’s original imple-


mentation of wcwidth() and wcswidth() (defined in IEEE Std 1002.1-2001) for Unicode.
WARNING: this function returns widths for ”raw” Unicode characters. It does not even try to map C1
control characters (0x80 to 0x9F) to CP1252, and C0/C1 control characters and DEL will return -1. You
are advised to use fl width(const char∗ src) instead.
30.12. MAC OS X-SPECIFIC SYMBOLS 271

30.12 Mac OS X-specific symbols


Mac OS X-specific symbols declared in <FL/x.H> or <FL/gl.h>

Classes
• class Fl Mac App Menu
Mac OS-specific class allowing to localize the application menu.

Functions
• void fl mac set about (Fl Callback ∗cb, void ∗user data, int shortcut=0)
Attaches a callback to the ”About myprog” item of the system application menu.
• void fl open callback (void(∗cb)(const char ∗))
Register a function called for each file dropped onto an application icon.
• int gl texture pile height (void)
Returns the current height of the pile of pre-computed string textures.
• void gl texture pile height (int max)
Changes the height of the pile of pre-computed string textures.

Variables
• int fl mac os version
The version number of the running Mac OS X (e.g., 100604 for 10.6.4)
• class Fl Sys Menu Bar ∗ fl sys menu bar
The system menu bar.

30.12.1 Detailed Description


Mac OS X-specific symbols declared in <FL/x.H> or <FL/gl.h>

See Also
The Apple OS X Interface

30.12.2 Function Documentation


void fl mac set about ( Fl Callback ∗ cb, void ∗ user data, int shortcut = 0 )
Attaches a callback to the ”About myprog” item of the system application menu.
Parameters
cb a callback that will be called by ”About myprog” menu item with NULL 1st argument.
user data a pointer transmitted as 2nd argument to the callback.
shortcut optional shortcut to attach to the ”About myprog” menu item (e.g., FL META+’a’)

void fl open callback ( void(∗)(const char ∗) cb )


Register a function called for each file dropped onto an application icon.
cb will be called with a single Unix-style file name and path. If multiple files were dropped, cb will be
called multiple times.
272 CHAPTER 30. MODULE DOCUMENTATION

int gl texture pile height ( void )


Returns the current height of the pile of pre-computed string textures.
The default value is 100

void gl texture pile height ( int max )


Changes the height of the pile of pre-computed string textures.
Strings that are often re-displayed can be processed much faster if this pile is set high enough to hold
all of them.
Parameters
max Height of the texture pile
30.13. COMMON DIALOGS CLASSES AND FUNCTIONS 273

30.13 Common Dialogs classes and functions


Classes
• class Fl Color Chooser
The Fl Color Chooser widget provides a standard RGB color chooser.
• class Fl File Chooser
The Fl File Chooser widget displays a standard file selection dialog that supports various selection modes.

Functions
• void fl alert (const char ∗fmt,...)
Shows an alert message dialog box.
• int fl ask (const char ∗fmt,...)
Shows a dialog displaying the fmt message, this dialog features 2 yes/no buttons.
• void fl beep (int type)
Emits a system beep message.
• int fl choice (const char ∗fmt, const char ∗b0, const char ∗b1, const char ∗b2,...)
Shows a dialog displaying the fmt message, this dialog features up to 3 customizable choice buttons.
• int fl color chooser (const char ∗name, double &r, double &g, double &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.
• int fl color chooser (const char ∗name, uchar &r, uchar &g, uchar &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.
• char ∗ fl dir chooser (const char ∗message, const char ∗fname, int relative)
Shows a file chooser dialog and gets a directory.
• char ∗ fl file chooser (const char ∗message, const char ∗pat, const char ∗fname, int relative)
Shows a file chooser dialog and gets a filename.
• void fl file chooser callback (void(∗cb)(const char ∗))
Set the file chooser callback.
• void fl file chooser ok label (const char ∗l)
Set the ”OK” button label.
• const char ∗ fl input (const char ∗fmt, const char ∗defstr,...)
Shows an input dialog displaying the fmt message.
• void fl message (const char ∗fmt,...)
Shows an information message dialog box.
• void fl message hotspot (int enable)
Sets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• int fl message hotspot (void)
Gets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• Fl Widget ∗ fl message icon ()
Gets the Fl Box icon container of the current default dialog used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password()
• void fl message title (const char ∗title)
Sets the title of the dialog window used in many common dialogs.
• void fl message title default (const char ∗title)
Sets the default title of the dialog window used in many common dialogs.
• const char ∗ fl password (const char ∗fmt, const char ∗defstr,...)
Shows an input dialog displaying the fmt message.
274 CHAPTER 30. MODULE DOCUMENTATION

Variables
• static void(∗ Fl::error )(const char ∗,...) = ::error
FLTK calls Fl::error() to output a normal error message.
• static void(∗ Fl::fatal )(const char ∗,...) = ::fatal
FLTK calls Fl::fatal() to output a fatal error message.
• const char ∗ fl cancel = ”Cancel”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl close = ”Close”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl no = ”No”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl ok = ”OK”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl yes = ”Yes”
string pointer used in common dialogs, you can change it to another language
• static void(∗ Fl::warning )(const char ∗,...) = ::warning
FLTK calls Fl::warning() to output a warning message.

30.13.1 Detailed Description


30.13.2 Function Documentation
void fl alert ( const char ∗ fmt, ... )
Shows an alert message dialog box.
Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>
Parameters
in fmt can be used as an sprintf-like format and variables for the message text

int fl ask ( const char ∗ fmt, ... )


Shows a dialog displaying the fmt message, this dialog features 2 yes/no buttons.
Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>
Parameters
in fmt can be used as an sprintf-like format and variables for the message text
30.13. COMMON DIALOGS CLASSES AND FUNCTIONS 275

Return values
0 if the no button is selected or another dialog box is still open
1 if yes is selected

void fl beep ( int type )

Emits a system beep message.


Parameters
in type The beep type from the Fl Beep enumeration.

Note
#include <FL/fl ask.H>

int fl choice ( const char ∗ fmt, const char ∗ b0, const char ∗ b1, const char ∗ b2, ... )

Shows a dialog displaying the fmt message, this dialog features up to 3 customizable choice buttons.

Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>

Parameters
in fmt can be used as an sprintf-like format and variables for the message text
in b0 text label of button 0
in b1 text label of button 1
in b2 text label of button 2

Return values
0 if the first button with b0 text is selected or another dialog box is still open
1 if the second button with b1 text is selected
2 if the third button with b2 text is selected

int fl color chooser ( const char ∗ name, double & r, double & g, double & b, int cmode )
[related]

Pops up a window to let the user pick an arbitrary RGB color.


276 CHAPTER 30. MODULE DOCUMENTATION

Note
#include <FL/Fl Color Chooser.H>

Figure 30.2: fl color chooser

Parameters
in name Title label for the window
in,out r,g,b Color components in the range 0.0 to 1.0.
in cmode Optional mode for color chooser. See mode(int). Default -1 if none (rgb
mode).

Return values
1 if user confirms the selection
0 if user cancels the dialog

int fl color chooser ( const char ∗ name, uchar & r, uchar & g, uchar & b, int cmode )
[related]

Pops up a window to let the user pick an arbitrary RGB color.


30.13. COMMON DIALOGS CLASSES AND FUNCTIONS 277

Note
#include <FL/Fl Color Chooser.H>

Figure 30.3: fl color chooser

Parameters
in name Title label for the window
in,out r,g,b Color components in the range 0 to 255.
in cmode Optional mode for color chooser. See mode(int). Default -1 if none (rgb
mode).

Return values
1 if user confirms the selection
0 if user cancels the dialog

char ∗ fl dir chooser ( const char ∗ message, const char ∗ fname, int relative ) [related]

Shows a file chooser dialog and gets a directory.

Note
#include <FL/Fl File Chooser.H>

Parameters
in message title bar text
in fname initial/default directory name
in relative 0 for absolute path return, relative otherwise

Returns
the directory path string chosen by the user or NULL if user cancels
278 CHAPTER 30. MODULE DOCUMENTATION

char ∗ fl file chooser ( const char ∗ message, const char ∗ pat, const char ∗ fname, int relative )
[related]
Shows a file chooser dialog and gets a filename.

Note
#include <FL/Fl File Chooser.H>

Figure 30.4: Fl File Chooser

Parameters
in message text in title bar
in pat filename pattern filter
in fname initial/default filename selection
in relative 0 for absolute path name, relative path name otherwise

Returns
the user selected filename, in absolute or relative format or NULL if user cancels

void fl file chooser callback ( void(∗)(const char ∗) cb ) [related]


Set the file chooser callback.
Note
#include <FL/Fl File Chooser.H>
30.13. COMMON DIALOGS CLASSES AND FUNCTIONS 279

void fl file chooser ok label ( const char ∗ l ) [related]


Set the ”OK” button label.
Note
#include <FL/Fl File Chooser.H>

const char∗ fl input ( const char ∗ fmt, const char ∗ defstr, ... )
Shows an input dialog displaying the fmt message.
Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>
Parameters
in fmt can be used as an sprintf-like format and variables for the message text
in defstr defines the default returned string if no text is entered

Returns
the user string input if OK was pushed, NULL if Cancel was pushed or another dialog box was still
open

void fl message ( const char ∗ fmt, ... )


Shows an information message dialog box.
Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>
Parameters
in fmt can be used as an sprintf-like format and variables for the message text

void fl message hotspot ( int enable )


Sets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
The default is enabled, so that the default button is the hotspot and appears at the mouse position.
Note
#include <FL/fl ask.H>
Parameters
280 CHAPTER 30. MODULE DOCUMENTATION

in enable non-zero enables hotspot behavior, 0 disables hotspot

int fl message hotspot ( void )


Gets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
Note
#include <FL/fl ask.H>

Returns
0 if disable, non-zero otherwise

See Also
fl message hotspot(int)

Fl Widget∗ fl message icon ( )


Gets the Fl Box icon container of the current default dialog used in many common dialogs like fl -
message(), fl alert(), fl ask(), fl choice(), fl input(), fl password()
Note
#include <FL/fl ask.H>

void fl message title ( const char ∗ title )


Sets the title of the dialog window used in many common dialogs.
This window title will be used in the next call of one of the common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password().
The title string is copied internally, so that you can use a local variable or free the string immediately
after this call. It applies only to the next call of one of the common dialogs and will be reset to an empty
title (the default for all dialogs) after that call.
Note
#include <FL/fl ask.H>
Parameters
in title window label, string copied internally

void fl message title default ( const char ∗ title )


Sets the default title of the dialog window used in many common dialogs.
This window title will be used in all subsequent calls of one of the common dialogs like fl -
message(), fl alert(), fl ask(), fl choice(), fl input(), fl password(), unless a specific title has been set with
fl message title(const char ∗title).
The default is no title. You can override the default title for a single dialog with fl message title(const
char ∗title).
The title string is copied internally, so that you can use a local variable or free the string immediately
after this call.
30.13. COMMON DIALOGS CLASSES AND FUNCTIONS 281

Note
#include <FL/fl ask.H>

Parameters
in title default window label, string copied internally

const char∗ fl password ( const char ∗ fmt, const char ∗ defstr, ... )
Shows an input dialog displaying the fmt message.
Like fl input() except the input text is not shown, ’∗’ characters are displayed instead.

Note
Common dialog boxes are application modal. No more than one common dialog box can be open at
any time. Requests for additional dialog boxes are ignored.
#include <FL/fl ask.H>

Parameters
in fmt can be used as an sprintf-like format and variables for the message text
in defstr defines the default returned string if no text is entered

Returns
the user string input if OK was pushed, NULL if Cancel was pushed or aother dialog box was still
open

30.13.3 Variable Documentation


void(∗ Fl::error)(const char ∗format,...) = ::error [static]
FLTK calls Fl::error() to output a normal error message.
The default version on Windows displays the error message in a MessageBox window.
The default version on all other platforms prints the error message to stderr.
You can override the behavior by setting the function pointer to your own routine.
Fl::error() means there is a recoverable error such as the inability to read an image file. The default
implementation returns after displaying the message.

Note
#include <FL/Fl.H>

void(∗ Fl::fatal)(const char ∗format,...) = ::fatal [static]


FLTK calls Fl::fatal() to output a fatal error message.
The default version on Windows displays the error message in a MessageBox window.
The default version on all other platforms prints the error message to stderr.
You can override the behavior by setting the function pointer to your own routine.
Fl::fatal() must not return, as FLTK is in an unusable state, however your version may be able to use
longjmp or an exception to continue, as long as it does not call FLTK again. The default implementation
exits with status 1 after displaying the message.

Note
#include <FL/Fl.H>
282 CHAPTER 30. MODULE DOCUMENTATION

void(∗ Fl::warning)(const char ∗format,...) = ::warning [static]


FLTK calls Fl::warning() to output a warning message.
The default version on Windows returns without printing a warning message, because Windows pro-
grams normally don’t have stderr (a console window) enabled.
The default version on all other platforms prints the warning message to stderr.
You can override the behavior by setting the function pointer to your own routine.
Fl::warning() means that there was a recoverable problem, the display may be messed up, but the user
can probably keep working - all X protocol errors call this, for example. The default implementation returns
after displaying the message.
Note
#include <FL/Fl.H>
30.14. FILE NAMES AND URI UTILITY FUNCTIONS 283

30.14 File names and URI utility functions


File names and URI functions defined in <FL/filename.H>

Macros
• #define fl dirent h cyclic include
• #define FL PATH MAX 2048
all path buffers should use this length

Typedefs
• typedef int( Fl File Sort F )(struct dirent ∗∗, struct dirent ∗∗)
File sorting function.

Functions
• FL EXPORT void fl decode uri (char ∗uri)
Decodes a URL-encoded string.
• FL EXPORT int fl filename absolute (char ∗to, int tolen, const char ∗from)
Makes a filename absolute from a relative filename.
• FL EXPORT int fl filename expand (char ∗to, int tolen, const char ∗from)
Expands a filename containing shell variables and tilde (∼).
• FL EXPORT const char ∗ fl filename ext (const char ∗buf)
Gets the extensions of a filename.
• FL EXPORT void fl filename free list (struct dirent ∗∗∗l, int n)
Free the list of filenames that is generated by fl filename list().
• FL EXPORT int fl filename isdir (const char ∗name)
Determines if a file exists and is a directory from its filename.
• FL EXPORT int fl filename list (const char ∗d, struct dirent ∗∗∗l, Fl File Sort F ∗s=fl numericsort)
Portable and const-correct wrapper for the scandir() function.
• FL EXPORT int fl filename match (const char ∗name, const char ∗pattern)
Checks if a string s matches a pattern p.
• FL EXPORT const char ∗ fl filename name (const char ∗filename)
Gets the file name from a path.
• FL EXPORT int fl filename relative (char ∗to, int tolen, const char ∗from)
Makes a filename relative to the current working directory.
• FL EXPORT char ∗ fl filename setext (char ∗to, int tolen, const char ∗ext)
Replaces the extension in buf of max.
• FL EXPORT int fl open uri (const char ∗uri, char ∗msg, int msglen)
Opens the specified Uniform Resource Identifier (URI).

30.14.1 Detailed Description


File names and URI functions defined in <FL/filename.H>
284 CHAPTER 30. MODULE DOCUMENTATION

30.14.2 Typedef Documentation


typedef int( Fl File Sort F)(struct dirent ∗∗, struct dirent ∗∗)
File sorting function.
See Also
fl filename list()

30.14.3 Function Documentation


void fl decode uri ( char ∗ uri )
Decodes a URL-encoded string.
In a Uniform Resource Identifier (URI), all non-ASCII bytes and several others (e.g., ’<’, ”, ’ ’) are
URL-encoded using 3 bytes by ”%XY” where XY is the hexadecimal value of the byte. This function
decodes the URI restoring its original UTF-8 encoded content. Decoding is done in-place.

FL EXPORT int fl filename absolute ( char ∗ to, int tolen, const char ∗ from )
Makes a filename absolute from a relative filename.
#include <FL/filename.H>
[..]
chdir("/var/tmp");
fl filename absolute(out, sizeof(out), "foo.txt"); // out="/var/tmp/foo.txt"
fl filename absolute(out, sizeof(out), "./foo.txt"); // out="/var/tmp/foo.txt"
fl filename absolute(out, sizeof(out), "../log/messages"); // out="/var/log/messages"

Parameters
out to resulting absolute filename
in tolen size of the absolute filename buffer
in from relative filename

Returns
0 if no change, non zero otherwise

FL EXPORT int fl filename expand ( char ∗ to, int tolen, const char ∗ from )
Expands a filename containing shell variables and tilde (∼).
Currently handles these variants:
"˜username" // if ’username’ does not exist, result will be unchanged
"˜/file"
"$VARNAME" // does NOT handle ${VARNAME}

Examples:
#include <FL/filename.H>
[..]
putenv("TMPDIR=/var/tmp");
fl filename expand(out, sizeof(out), "˜fred/.cshrc"); // out="/usr/fred/.cshrc"
fl filename expand(out, sizeof(out), "˜/.cshrc"); // out="/usr/<yourname>/.cshrc"
fl filename expand(out, sizeof(out), "$TMPDIR/foo.txt"); // out="/var/tmp/foo.txt"
30.14. FILE NAMES AND URI UTILITY FUNCTIONS 285

Parameters
out to resulting expanded filename
in tolen size of the expanded filename buffer
in from filename containing shell variables

Returns
0 if no change, non zero otherwise

FL EXPORT const char∗ fl filename ext ( const char ∗ buf )

Gets the extensions of a filename.

#include <FL/filename.H>
[..]
const char *out;
out = fl filename ext("/some/path/foo.txt"); // result: ".txt"
out = fl filename ext("/some/path/foo"); // result: NULL

Parameters
in buf the filename to be parsed

Returns
a pointer to the extension (including ’.’) if any or NULL otherwise

FL EXPORT void fl filename free list ( struct dirent ∗∗∗ list, int n )

Free the list of filenames that is generated by fl filename list().


Free everything that was allocated by a previous call to fl filename list(). Use the return values as
parameters for this function.
Parameters
in,out list table containing the resulting directory listing
in n number of entries in the list

FL EXPORT int fl filename isdir ( const char ∗ n )

Determines if a file exists and is a directory from its filename.

#include <FL/filename.H>
[..]
fl filename isdir("/etc"); // returns non-zero
fl filename isdir("/etc/hosts"); // returns 0

Parameters
in n the filename to parse

Returns
non zero if file exists and is a directory, zero otherwise
286 CHAPTER 30. MODULE DOCUMENTATION

FL EXPORT int fl filename list ( const char ∗ d, dirent ∗∗∗ list, Fl File Sort F ∗ sort )
Portable and const-correct wrapper for the scandir() function.
For each file in that directory a ”dirent” structure is created. The only portable thing about a dirent
is that dirent.d name is the nul-terminated file name. An pointers array to these dirent’s is created and a
pointer to the array is returned in ∗list. The number of entries is given as a return value. If there is an error
reading the directory a number less than zero is returned, and errno has the reason; errno does not work
under WIN32.
Include:
#include <FL/filename.H>

Parameters
in d the name of the directory to list. It does not matter if it has a trailing
slash.
out list table containing the resulting directory listing
in sort sorting functor:
• fl alphasort: The files are sorted in ascending alphabetical order;
upper and lowercase letters are compared according to their ASCII
ordering uppercase before lowercase.

• fl casealphasort: The files are sorted in ascending alphabetical or-


der; upper and lowercase letters are compared equally case is not
significant.
• fl casenumericsort: The files are sorted in ascending ”alphanu-
meric” order, where an attempt is made to put unpadded numbers
in consecutive order; upper and lowercase letters are compared
equally case is not significant.
• fl numericsort: The files are sorted in ascending ”alphanumeric”
order, where an attempt is made to put unpadded numbers in con-
secutive order; upper and lowercase letters are compared accord-
ing to their ASCII ordering - uppercase before lowercase.

Returns
the number of entries if no error, a negative value otherwise.

FL EXPORT int fl filename match ( const char ∗ s, const char ∗ p )


Checks if a string s matches a pattern p.
The following syntax is used for the pattern:

• ∗ matches any sequence of 0 or more characters.

• ? matches any single character.

• [set] matches any character in the set. Set can contain any single characters, or a-z to represent a
range. To match ] or - they must be the first characters. To match ∧ or ! they must not be the first
characters.

• [∧ set] or [!set] matches any character not in the set.

• {X|Y|Z} or {X,Y,Z} matches any one of the subexpressions literally.


30.14. FILE NAMES AND URI UTILITY FUNCTIONS 287

• \x quotes the character x so it has no special meaning.


• x all other characters must be matched exactly.
Include:
#include <FL/filename.H>

Parameters
in s the string to check for a match
in p the string pattern

Returns
non zero if the string matches the pattern

FL EXPORT const char∗ fl filename name ( const char ∗ filename )


Gets the file name from a path.
Similar to basename(3), exceptions shown below.
#include <FL/filename.H>
[..]
const char *out;
out = fl filename name("/usr/lib"); // out="lib"
out = fl filename name("/usr/"); // out="" (basename(3) returns "usr" instead)
out = fl filename name("/usr"); // out="usr"
out = fl filename name("/"); // out="" (basename(3) returns "/" instead)
out = fl filename name("."); // out="."
out = fl filename name(".."); // out=".."

Returns
a pointer to the char after the last slash, or to filename if there is none.

FL EXPORT int fl filename relative ( char ∗ to, int tolen, const char ∗ from )
Makes a filename relative to the current working directory.
#include <FL/filename.H>
[..]
chdir("/var/tmp/somedir"); // set cwd to /var/tmp/somedir
[..]
char out[FL PATH MAX];
fl filename relative(out, sizeof(out), "/var/tmp/somedir/foo.txt"); // out="foo.txt",
return=1
fl filename relative(out, sizeof(out), "/var/tmp/foo.txt"); //
out="../foo.txt", return=1
fl filename relative(out, sizeof(out), "foo.txt"); // out="foo.txt",
return=0 (no change)
fl filename relative(out, sizeof(out), "./foo.txt"); //
out="./foo.txt", return=0 (no change)
fl filename relative(out, sizeof(out), "../foo.txt"); //
out="../foo.txt", return=0 (no change)

Parameters
out to resulting relative filename
in tolen size of the relative filename buffer
in from absolute filename

Returns
0 if no change, non zero otherwise
288 CHAPTER 30. MODULE DOCUMENTATION

FL EXPORT char∗ fl filename setext ( char ∗ buf, int buflen, const char ∗ ext )
Replaces the extension in buf of max.
size buflen with the extension in ext.
If there’s no ’.’ in buf, ext is appended.
If ext is NULL, behaves as if it were an empty string (””).
Example
#include <FL/filename.H>
[..]
char buf[FL PATH MAX] = "/path/myfile.cxx";
fl filename setext(buf, sizeof(buf), ".txt"); // buf[] becomes "/path/myfile.txt"

Returns
buf itself for calling convenience.

int fl open uri ( const char ∗ uri, char ∗ msg, int msglen )
Opens the specified Uniform Resource Identifier (URI).
Uses an operating-system dependent program or interface. For URIs using the ”ftp”, ”http”, or ”https”
schemes, the system default web browser is used to open the URI, while ”mailto” and ”news” URIs are
typically opened using the system default mail reader and ”file” URIs are opened using the file system
navigator.
On success, the (optional) msg buffer is filled with the command that was run to open the URI; on
Windows, this will always be ”open uri”.
On failure, the msg buffer is filled with an English error message.
Note
Platform Specific Issues: Windows
With ”file:” based URIs on Windows, you may encounter issues with anchors being ignored. Example-
: ”file:///c:/some/index.html#anchor” may open in the browser without the ”#anchor” suffix. The be-
havior seems to vary across different Windows versions. Workaround: open a link to a separate html
file that redirects to the desired ”file:” URI.

Example
#include <FL/filename.H>
[..]
char errmsg[512];
if ( !fl open uri("http://google.com/", errmsg, sizeof(errmsg)) ) {
char warnmsg[768];
sprintf(warnmsg, "Error: %s", errmsg);
fl alert(warnmsg);
}

Parameters
uri The URI to open
msg Optional buffer which contains the command or error message
msglen Length of optional buffer

Returns
1 on success, 0 on failure
Chapter 31

Class Documentation

31.1 Fl Preferences::Entry Struct Reference


Public Attributes
• char ∗ name
• char ∗ value

The documentation for this struct was generated from the following file:

• Fl Preferences.H

31.2 Fl Class Reference


The Fl is the FLTK global (static) class containing state information and global methods for the current
application.
#include <Fl.H>

Public Types
• enum Fl Option {
OPTION ARROW FOCUS = 0, OPTION VISIBLE FOCUS, OPTION DND TEXT, OPTION S-
HOW TOOLTIPS,
OPTION FNFC USES GTK, OPTION LAST }
Enumerator for global FLTK options.

Static Public Member Functions


• static int add awake handler (Fl Awake Handler, void ∗)
Adds an awake handler for use in awake().
• static void add check (Fl Timeout Handler, void ∗=0)
FLTK will call this callback just before it flushes the display and waits for events.
• static void add clipboard notify (Fl Clipboard Notify Handler h, void ∗data=0)
FLTK will call the registered callback whenever there is a change to the selection buffer or the clipboard.
• static void add fd (int fd, int when, Fl FD Handler cb, void ∗=0)
Adds file descriptor fd to listen to.
• static void add fd (int fd, Fl FD Handler cb, void ∗=0)
See void add fd(int fd, int when, Fl FD Handler cb, void∗ = 0)

289
290 CHAPTER 31. CLASS DOCUMENTATION

• static void add handler (Fl Event Handler h)


Install a function to parse unrecognized events.
• static void add idle (Fl Idle Handler cb, void ∗data=0)
Adds a callback function that is called every time by Fl::wait() and also makes it act as though the timeout
is zero (this makes Fl::wait() return immediately, so if it is in a loop it is called repeatedly, and thus the idle
fucntion is called repeatedly).
• static void add system handler (Fl System Handler h, void ∗data)
Install a function to intercept system events.
• static void add timeout (double t, Fl Timeout Handler, void ∗=0)
Adds a one-shot timeout callback.
• static int arg (int argc, char ∗∗argv, int &i)
Parse a single switch from argv, starting at word i.
• static int args (int argc, char ∗∗argv, int &i, Fl Args Handler cb=0)
Parse command line switches using the cb argument handler.
• static void args (int argc, char ∗∗argv)
Parse all command line switches matching standard FLTK options only.
• static void awake (void ∗message=0)
Sends a message pointer to the main thread, causing any pending Fl::wait() call to terminate so that the
main thread can retrieve the message and any pending redraws can be processed.
• static int awake (Fl Awake Handler cb, void ∗message=0)
See void awake(void∗ message=0).
• static void background (uchar, uchar, uchar)
Changes fl color(FL BACKGROUND COLOR) to the given color, and changes the gray ramp from 32 to
56 to black to white.
• static void background2 (uchar, uchar, uchar)
Changes the alternative background color.
• static Fl Widget ∗ belowmouse ()
Gets the widget that is below the mouse.
• static void belowmouse (Fl Widget ∗)
Sets the widget that is below the mouse.
• static int box dh (Fl Boxtype)
Returns the height offset for the given boxtype.
• static int box dw (Fl Boxtype)
Returns the width offset for the given boxtype.
• static int box dx (Fl Boxtype)
Returns the X offset for the given boxtype.
• static int box dy (Fl Boxtype)
Returns the Y offset for the given boxtype.
• static void cairo autolink context (bool alink)
when FLTK HAVE CAIRO is defined and cairo autolink context() is true, any current window dc is linked
to a current context.
• static bool cairo autolink context ()
Gets the current autolink mode for cairo support.
• static cairo t ∗ cairo cc ()
Gets the current cairo context linked with a fltk window.
• static void cairo cc (cairo t ∗c, bool own=false)
Sets the current cairo context to c.
• static cairo t ∗ cairo make current (Fl Window ∗w)
31.2. FL CLASS REFERENCE 291

Provides a corresponding cairo context for window wi.


• static int check ()
Same as Fl::wait(0).
• static void clear widget pointer (Fl Widget const ∗w)
Clears a widget pointer in the watch list.
• static int clipboard contains (const char ∗type)
Returns non 0 if the clipboard contains data matching type.
• static int compose (int &del)
Any text editing widget should call this for each FL KEYBOARD event.
• static void compose reset ()
If the user moves the cursor, be sure to call Fl::compose reset().
• static void copy (const char ∗stuff, int len, int destination=0, const char ∗type=Fl::clipboard plain -
text)
Copies the data pointed to by stuff to the selection buffer (destination is 0) or the clipboard
(destination is 1).
• static void damage (int d)
If true then flush() will do something.
• static int damage ()
If true then flush() will do something.
• static void default atclose (Fl Window ∗, void ∗)
Default callback for window widgets.
• static void delete widget (Fl Widget ∗w)
Schedules a widget for deletion at the next call to the event loop.
• static void disable im ()
Disables the system input methods facilities.
• static void display (const char ∗)
Sets the X display to use for all windows.
• static int dnd ()
Initiate a Drag And Drop operation.
• static void dnd text ops (int v)
Gets or sets whether drag and drop text operations are supported.
• static int dnd text ops ()
Gets or sets whether drag and drop text operations are supported.
• static void do widget deletion ()
Deletes widgets previously scheduled for deletion.
• static int draw box active ()
Determines if the current draw box is active or inactive.
• static void enable im ()
Enables the system input methods facilities.
• static int event ()
Returns the last event that was processed.
• static int event alt ()
Returns non-zero if the Alt key is pressed.
• static int event button ()
Gets which particular mouse button caused the current event.
• static int event button1 ()
Returns non-zero if mouse button 1 is currently held down.
292 CHAPTER 31. CLASS DOCUMENTATION

• static int event button2 ()


Returns non-zero if button 2 is currently held down.
• static int event button3 ()
Returns non-zero if button 3 is currently held down.
• static int event buttons ()
Returns the mouse buttons state bits; if non-zero, then at least one button is pressed now.
• static int event clicks ()
Returns non zero if we had a double click event.
• static void event clicks (int i)
Manually sets the number returned by Fl::event clicks().
• static void ∗ event clipboard ()
During an FL PASTE event of non-textual data, returns a pointer to the pasted data.
• static const char ∗ event clipboard type ()
Returns the type of the pasted data during an FL PASTE event.
• static int event command ()
Returns non-zero if the FL COMMAND key is pressed, either FL CTRL or on OSX FL META.
• static int event ctrl ()
Returns non-zero if the Control key is pressed.
• static void event dispatch (Fl Event Dispatch d)
Set a new event dispatch function.
• static Fl Event Dispatch event dispatch ()
Return the current event dispatch function.
• static int event dx ()
Returns the current horizontal mouse scrolling associated with the FL MOUSEWHEEL event.
• static int event dy ()
Returns the current vertical mouse scrolling associated with the FL MOUSEWHEEL event.
• static int event inside (int, int, int, int)
Returns whether or not the mouse event is inside the given rectangle.
• static int event inside (const Fl Widget ∗)
Returns whether or not the mouse event is inside a given child widget.
• static int event is click ()
Returns non-zero if the mouse has not moved far enough and not enough time has passed since the last
FL PUSH or FL KEYBOARD event for it to be considered a ”drag” rather than a ”click”.
• static void event is click (int i)
Clears the value returned by Fl::event is click().
• static int event key ()
Gets which key on the keyboard was last pushed.
• static int event key (int key)
Returns true if the given key was held down (or pressed) during the last event.
• static int event length ()
Returns the length of the text in Fl::event text().
• static int event original key ()
Returns the keycode of the last key event, regardless of the NumLock state.
• static int event shift ()
Returns non-zero if the Shift key is pressed.
• static int event state ()
31.2. FL CLASS REFERENCE 293

This is a bitfield of what shift states were on and what mouse buttons were held down during the most recent
event.
• static int event state (int i)
See int event state()
• static const char ∗ event text ()
Returns the text associated with the current event, including FL PASTE or FL DND RELEASE events.
• static int event x ()
Returns the mouse position of the event relative to the Fl Window it was passed to.
• static int event x root ()
Returns the mouse position on the screen of the event.
• static int event y ()
Returns the mouse position of the event relative to the Fl Window it was passed to.
• static int event y root ()
Returns the mouse position on the screen of the event.
• static Fl Window ∗ first window ()
Returns the first top-level window in the list of shown() windows.
• static void first window (Fl Window ∗)
Sets the window that is returned by first window().
• static void flush ()
Causes all the windows that need it to be redrawn and graphics forced out through the pipes.
• static Fl Widget ∗ focus ()
Gets the current Fl::focus() widget.
• static void focus (Fl Widget ∗)
Sets the widget that will receive FL KEYBOARD events.
• static void foreground (uchar, uchar, uchar)
Changes fl color(FL FOREGROUND COLOR).
• static void free color (Fl Color i, int overlay=0)
Frees the specified color from the colormap, if applicable.
• static int get awake handler (Fl Awake Handler &, void ∗&)
Gets the last stored awake handler for use in awake().
• static Fl Box Draw F ∗ get boxtype (Fl Boxtype)
Gets the current box drawing function for the specified box type.
• static unsigned get color (Fl Color i)
Returns the RGB value(s) for the given FLTK color index.
• static void get color (Fl Color i, uchar &red, uchar &green, uchar &blue)
Returns the RGB value(s) for the given FLTK color index.
• static const char ∗ get font (Fl Font)
Gets the string for this face.
• static const char ∗ get font name (Fl Font, int ∗attributes=0)
Get a human-readable string describing the family of this face.
• static int get font sizes (Fl Font, int ∗&sizep)
Return an array of sizes in sizep.
• static int get key (int key)
Returns true if the given key is held down now.
• static void get mouse (int &, int &)
Return where the mouse is on the screen by doing a round-trip query to the server.
• static void get system colors ()
294 CHAPTER 31. CLASS DOCUMENTATION

Read the user preference colors from the system and use them to call Fl::foreground(), Fl::background(),
and Fl::background2().
• static int gl visual (int, int ∗alist=0)
This does the same thing as Fl::visual(int) but also requires OpenGL drawing to work.
• static Fl Window ∗ grab ()
Returns the window that currently receives all events.
• static void grab (Fl Window ∗)
Selects the window to grab.
• static void grab (Fl Window &win)
See grab(Fl Window∗)
• static int h ()
Returns the height in pixels of the main screen work area.
• static int handle (int, Fl Window ∗)
Handle events from the window system.
• static int handle (int, Fl Window ∗)
Handle events from the window system.
• static int has check (Fl Timeout Handler, void ∗=0)
Returns 1 if the check exists and has not been called yet, 0 otherwise.
• static int has idle (Fl Idle Handler cb, void ∗data=0)
Returns true if the specified idle callback is currently installed.
• static int has timeout (Fl Timeout Handler, void ∗=0)
Returns true if the timeout exists and has not been called yet.
• static int is scheme (const char ∗name)
Returns whether the current scheme is the given name.
• static int lock ()
The lock() method blocks the current thread until it can safely access FLTK widgets and data.
• static Fl Window ∗ modal ()
Returns the top-most modal() window currently shown.
• static Fl Window ∗ next window (const Fl Window ∗)
Returns the next top-level window in the list of shown() windows.
• static bool option (Fl Option opt)
FLTK library options management.
• static void option (Fl Option opt, bool val)
Override an option while the application is running.
• static void own colormap ()
Makes FLTK use its own colormap.
• static void paste (Fl Widget &receiver, int source, const char ∗type=Fl::clipboard plain text)
Pastes the data from the selection buffer (source is 0) or the clipboard (source is 1) into receiver.
• static void paste (Fl Widget &receiver)
Backward compatibility only.
• static Fl Widget ∗ pushed ()
Gets the widget that is being pushed.
• static void pushed (Fl Widget ∗)
Sets the widget that is being pushed.
• static Fl Widget ∗ readqueue ()
All Fl Widgets that don’t have a callback defined use a default callback that puts a pointer to the widget in
this queue, and this method reads the oldest widget out of this queue.
31.2. FL CLASS REFERENCE 295

• static int ready ()


This is similar to Fl::check() except this does not call Fl::flush() or any callbacks, which is useful if your
program is in a state where such callbacks are illegal.
• static void redraw ()
Redraws all widgets.
• static void release ()
Releases the current grabbed window, equals grab(0).
• static void release widget pointer (Fl Widget ∗&w)
Releases a widget pointer from the watch list.
• static int reload scheme ()
Called by scheme according to scheme name.
• static void remove check (Fl Timeout Handler, void ∗=0)
Removes a check callback.
• static void remove clipboard notify (Fl Clipboard Notify Handler h)
Stop calling the specified callback when there are changes to the selection buffer or the clipboard.
• static void remove fd (int, int when)
Removes a file descriptor handler.
• static void remove fd (int)
Removes a file descriptor handler.
• static void remove handler (Fl Event Handler h)
Removes a previously added event handler.
• static void remove idle (Fl Idle Handler cb, void ∗data=0)
Removes the specified idle callback, if it is installed.
• static void remove system handler (Fl System Handler h)
Removes a previously added system event handler.
• static void remove timeout (Fl Timeout Handler, void ∗=0)
Removes a timeout callback.
• static void repeat timeout (double t, Fl Timeout Handler, void ∗=0)
Repeats a timeout callback from the expiration of the previous timeout, allowing for more accurate timing.
• static int run ()
As long as any windows are displayed this calls Fl::wait() repeatedly.
• static int scheme (const char ∗name)
Sets the current widget scheme.
• static const char ∗ scheme ()
See void scheme(const char ∗name)
• static int screen count ()
Gets the number of available screens.
• static void screen dpi (float &h, float &v, int n=0)
Gets the screen resolution in dots-per-inch for the given screen.
• static int screen num (int x, int y)
Gets the screen number of a screen that contains the specified screen position x, y.
• static int screen num (int x, int y, int w, int h)
Gets the screen number for the screen which intersects the most with the rectangle defined by x, y, w, h.
• static void screen work area (int &X, int &Y, int &W, int &H, int mx, int my)
Gets the bounding box of the work area of a screen that contains the specified screen position mx, my.
• static void screen work area (int &X, int &Y, int &W, int &H, int n)
Gets the bounding box of the work area of the given screen.
296 CHAPTER 31. CLASS DOCUMENTATION

• static void screen work area (int &X, int &Y, int &W, int &H)
Gets the bounding box of the work area of the screen that contains the mouse pointer.
• static void screen xywh (int &X, int &Y, int &W, int &H)
Gets the bounding box of a screen that contains the mouse pointer.
• static void screen xywh (int &X, int &Y, int &W, int &H, int mx, int my)
Gets the bounding box of a screen that contains the specified screen position mx, my.
• static void screen xywh (int &X, int &Y, int &W, int &H, int n)
Gets the screen bounding rect for the given screen.
• static void screen xywh (int &X, int &Y, int &W, int &H, int mx, int my, int mw, int mh)
Gets the screen bounding rect for the screen which intersects the most with the rectangle defined by mx, my,
mw, mh.
• static int scrollbar size ()
Gets the default scrollbar size used by Fl Browser , Fl Help View, Fl Scroll, and Fl Text Display widgets.
• static void scrollbar size (int W)
Sets the default scrollbar size that is used by the Fl Browser , Fl Help View, Fl Scroll, and Fl Text Display
widgets.
• static void selection (Fl Widget &owner, const char ∗, int len)
Changes the current selection.
• static Fl Widget ∗ selection owner ()
back-compatibility only: Gets the widget owning the current selection
• static void selection owner (Fl Widget ∗)
Back-compatibility only: The single-argument call can be used to move the selection to another widget or
to set the owner to NULL, without changing the actual text of the selection.
• static void set abort (Fl Abort Handler f)
For back compatibility, sets the void Fl::fatal handler callback.
• static void set atclose (Fl Atclose Handler f)
For back compatibility, sets the Fl::atclose handler callback.
• static void set boxtype (Fl Boxtype, Fl Box Draw F ∗, uchar, uchar, uchar, uchar)
Sets the function to call to draw a specific boxtype.
• static void set boxtype (Fl Boxtype, Fl Boxtype from)
Copies the from boxtype.
• static void set color (Fl Color, uchar, uchar, uchar)
Sets an entry in the fl color index table.
• static void set color (Fl Color i, unsigned c)
Sets an entry in the fl color index table.
• static void set font (Fl Font, const char ∗)
Changes a face.
• static void set font (Fl Font, Fl Font)
Copies one face to another.
• static Fl Font set fonts (const char ∗=0)
FLTK will open the display, and add every fonts on the server to the face table.
• static void set idle (Fl Old Idle Handler cb)
Sets an idle callback.
• static void set labeltype (Fl Labeltype, Fl Label Draw F ∗, Fl Label Measure F ∗)
Sets the functions to call to draw and measure a specific labeltype.
• static void set labeltype (Fl Labeltype, Fl Labeltype from)
Sets the functions to call to draw and measure a specific labeltype.
31.2. FL CLASS REFERENCE 297

• static int test shortcut (Fl Shortcut)


Tests the current event, which must be an FL KEYBOARD or FL SHORTCUT, against a shortcut value
(described in Fl Button).
• static void ∗ thread message ()
The thread message() method returns the last message that was sent from a child by the awake() method.
• static void unlock ()
The unlock() method releases the lock that was set using the lock() method.
• static double version ()
Returns the compiled-in value of the FL VERSION constant.
• static void visible focus (int v)
Gets or sets the visible keyboard focus on buttons and other non-text widgets.
• static int visible focus ()
Gets or sets the visible keyboard focus on buttons and other non-text widgets.
• static int visual (int)
Selects a visual so that your graphics are drawn correctly.
• static int w ()
Returns the width in pixels of the main screen work area.
• static int wait ()
Waits until ”something happens” and then returns.
• static double wait (double time)
See int Fl::wait()
• static void watch widget pointer (Fl Widget ∗&w)
Adds a widget pointer to the widget watch list.
• static int x ()
Returns the leftmost x coordinate of the main screen work area.
• static int y ()
Returns the topmost y coordinate of the main screen work area.

Static Public Attributes


• static void(∗ atclose )(Fl Window ∗, void ∗)
Back compatibility: default window callback handler.
• static char const ∗const clipboard image = ”image”
Denotes image data.
• static char const ∗const clipboard plain text = ”text/plain”
Denotes plain textual data.
• static void(∗ error )(const char ∗,...) = ::error
FLTK calls Fl::error() to output a normal error message.
• static void(∗ fatal )(const char ∗,...) = ::fatal
FLTK calls Fl::fatal() to output a fatal error message.
• static const char ∗const help = helpmsg+13
Usage string displayed if Fl::args() detects an invalid argument.
• static void(∗ idle )()
The currently executing idle callback function: DO NOT USE THIS DIRECTLY!
• static void(∗ warning )(const char ∗,...) = ::warning
FLTK calls Fl::warning() to output a warning message.
298 CHAPTER 31. CLASS DOCUMENTATION

31.2.1 Detailed Description


The Fl is the FLTK global (static) class containing state information and global methods for the current
application.

31.2.2 Member Enumeration Documentation


enum Fl::Fl Option
Enumerator for global FLTK options.
These options can be set system wide, per user, or for the running application only.

See Also
Fl::option(Fl Option, bool)
Fl::option(Fl Option)

Enumerator
OPTION ARROW FOCUS When switched on, moving the text cursor beyond the start or end of a
text in a text widget will change focus to the next text widget. (This is considered ’old’ behavior)
When switched off (default), the cursor will stop at the end of the text. Pressing Tab or Ctrl-Tab
will advance the keyboard focus.
See also: Fl Input ::tab nav()
OPTION VISIBLE FOCUS If visible focus is switched on (default), FLTK will draw a dotted rect-
angle inside the widget that will receive the next keystroke. If switched off, no such indicator
will be drawn and keyboard navigation is disabled.
OPTION DND TEXT If text drag-and-drop is enabled (default), the user can select and drag text
from any text widget. If disabled, no dragging is possible, however dropping text from other
applications still works.
OPTION SHOW TOOLTIPS If tooltips are enabled (default), hovering the mouse over a widget
with a tooltip text will open a little tooltip window until the mouse leaves the widget. If disabled,
no tooltip is shown.
OPTION FNFC USES GTK When switched on (default), Fl Native File Chooser runs GTK file
dialogs if the GTK library is available on the platform (linux/unix only). When switched off,
GTK file dialogs aren’t used even if the GTK library is available.
OPTION LAST For internal use only.

31.2.3 Member Function Documentation


int Fl::add awake handler ( Fl Awake Handler func, void ∗ data ) [static]
Adds an awake handler for use in awake().

void Fl::add check ( Fl Timeout Handler cb, void ∗ argp = 0 ) [static]


FLTK will call this callback just before it flushes the display and waits for events.
This is different than an idle callback because it is only called once, then FLTK calls the system and
tells it not to return until an event happens.
This can be used by code that wants to monitor the application’s state, such as to keep a display up to
date. The advantage of using a check callback is that it is called only when no events are pending. If events
are coming in quickly, whole blocks of them will be processed before this is called once. This can save
significant time and avoid the application falling behind the events.
Sample code:
31.2. FL CLASS REFERENCE 299

bool state changed; // anything that changes the display turns this on

void callback(void*) {
if (!state changed) return;
state changed = false;
do expensive calculation();
widget-&gt;redraw();
}

main() {
Fl::add check(callback);
return Fl::run();
}

static void Fl::add fd ( int fd, int when, Fl FD Handler cb, void ∗ = 0 ) [static]

Adds file descriptor fd to listen to.


When the fd becomes ready for reading Fl::wait() will call the callback and then return. The callback
is passed the fd and the arbitrary void∗ argument.
The second version takes a when bitfield, with the bits FL READ, FL WRITE, and FL EXCEPT de-
fined, to indicate when the callback should be done.
There can only be one callback of each type for a file descriptor. Fl::remove fd() gets rid of all the
callbacks for a given file descriptor.
Under UNIX any file descriptor can be monitored (files, devices, pipes, sockets, etc.). Due to limitations
in Microsoft Windows, WIN32 applications can only monitor sockets.

void Fl::add idle ( Fl Idle Handler cb, void ∗ data = 0 ) [static]

Adds a callback function that is called every time by Fl::wait() and also makes it act as though the timeout
is zero (this makes Fl::wait() return immediately, so if it is in a loop it is called repeatedly, and thus the idle
fucntion is called repeatedly).
The idle function can be used to get background processing done.
You can have multiple idle callbacks. To remove an idle callback use Fl::remove idle().
Fl::wait() and Fl::check() call idle callbacks, but Fl::ready() does not.
The idle callback can call any FLTK functions, including Fl::wait(), Fl::check(), and Fl::ready().
FLTK will not recursively call the idle callback.

void Fl::add timeout ( double t, Fl Timeout Handler cb, void ∗ argp = 0 ) [static]

Adds a one-shot timeout callback.


The function will be called by Fl::wait() at t seconds after this function is called. The optional void∗
argument is passed to the callback.
You can have multiple timeout callbacks. To remove a timeout callback use Fl::remove timeout().
If you need more accurate, repeated timeouts, use Fl::repeat timeout() to reschedule the subsequent
timeouts.
The following code will print ”TICK” each second on stdout with a fair degree of accuracy:

void callback(void*) {
puts("TICK");
Fl::repeat timeout(1.0, callback);
}

int main() {
Fl::add timeout(1.0, callback);
return Fl::run();
}
300 CHAPTER 31. CLASS DOCUMENTATION

int Fl::arg ( int argc, char ∗∗ argv, int & i ) [static]

Parse a single switch from argv, starting at word i.


Returns the number of words eaten (1 or 2, or 0 if it is not recognized) and adds the same value to i.
This is the default argument handler used internally by Fl::args(...), but you can use this function if you
prefer to step through the standard FLTK switches yourself.
All standard FLTK switches except -bg2 may be abbreviated to just one letter and case is ignored:

• -bg color or -background color


Sets the background color using Fl::background().

• -bg2 color or -background2 color


Sets the secondary background color using Fl::background2().

• -display host:n.n
Sets the X display to use; this option is silently ignored under WIN32 and MacOS.

• -dnd and -nodnd


Enables or disables drag and drop text operations using Fl::dnd text ops().

• -fg color or -foreground color


Sets the foreground color using Fl::foreground().

• -geometry WxH+X+Y
Sets the initial window position and size according to the standard X geometry string.

• -iconic
Iconifies the window using Fl Window::iconize().

• -kbd and -nokbd


Enables or disables visible keyboard focus for non-text widgets using Fl::visible focus().

• -name string
Sets the window class using Fl Window::xclass().

• -scheme string
Sets the widget scheme using Fl::scheme().

• -title string
Sets the window title using Fl Window::label().

• -tooltips and -notooltips


Enables or disables tooltips using Fl Tooltip::enable().

If your program requires other switches in addition to the standard FLTK options, you will need to pass
your own argument handler to Fl::args(int,char∗∗,int&,Fl Args Handler) explicitly.
31.2. FL CLASS REFERENCE 301

int Fl::args ( int argc, char ∗∗ argv, int & i, Fl Args Handler cb = 0 ) [static]
Parse command line switches using the cb argument handler.
Returns 0 on error, or the number of words processed.
FLTK provides this as an entirely optional command line switch parser. You don’t have to call it if you
don’t want to. Everything it can do can be done with other calls to FLTK.
To use the switch parser, call Fl::args(...) near the start of your program. This does not open the display,
instead switches that need the display open are stashed into static variables. Then you must display your
first window by calling window->show(argc,argv), which will do anything stored in the static
variables.
Providing an argument handler callback cb lets you define your own switches. It is called with the same
argc and argv, and with i set to the index of the switch to be processed. The cb handler should return
zero if the switch is unrecognized, and not change i. It should return non-zero to indicate the number of
words processed if the switch is recognized, i.e. 1 for just the switch, and more than 1 for the switch plus
associated parameters. i should be incremented by the same amount.
The cb handler is called before any other tests, so you can also override any standard FLTK switch
(this is why FLTK can use very short switches instead of the long ones all other toolkits force you to use).
See Fl::arg() for descriptions of the standard switches.
On return i is set to the index of the first non-switch. This is either:

• The first word that does not start with ’-’.

• The word ’-’ (used by many programs to name stdin as a file)

• The first unrecognized switch (return value is 0).

• argc

The return value is i unless an unrecognized switch is found, in which case it is zero. If your program
takes no arguments other than switches you should produce an error if the return value is less than argc.
A usage string is displayed if Fl::args() detects an invalid argument on the command-line. You can
change the message by setting the Fl::help pointer.
A very simple command line parser can be found in examples/howto-parse-args.cxx
The simpler Fl::args(int argc, char ∗∗argv) form is useful if your program does not have command line
switches of its own.

void Fl::args ( int argc, char ∗∗ argv ) [static]


Parse all command line switches matching standard FLTK options only.
It parses all the switches, and if any are not recognized it calls Fl::abort(Fl::help), i.e. unlike the long
form, an unrecognized switch generates an error message and causes the program to exit.

void Fl::background ( uchar r, uchar g, uchar b ) [static]


Changes fl color(FL BACKGROUND COLOR) to the given color, and changes the gray ramp from 32 to
56 to black to white.
These are the colors used as backgrounds by almost all widgets and used to draw the edges of all the
boxtypes.

void Fl::background2 ( uchar r, uchar g, uchar b ) [static]


Changes the alternative background color.
This color is used as a background by Fl Input and other text widgets.
This call may change fl color(FL FOREGROUND COLOR) if it does not provide sufficient contrast
to FL BACKGROUND2 COLOR.
302 CHAPTER 31. CLASS DOCUMENTATION

int Fl::box dh ( Fl Boxtype t ) [static]


Returns the height offset for the given boxtype.

See Also
box dy().

int Fl::box dw ( Fl Boxtype t ) [static]


Returns the width offset for the given boxtype.

See Also
box dy().

int Fl::box dx ( Fl Boxtype t ) [static]


Returns the X offset for the given boxtype.

See Also
box dy()

int Fl::box dy ( Fl Boxtype t ) [static]


Returns the Y offset for the given boxtype.
These functions return the offset values necessary for a given boxtype, useful for computing the area
inside a box’s borders, to prevent overdrawing the borders.
For instance, in the case of a boxtype like FL DOWN BOX where the border width might be 2 pix-
els all around, the above functions would return 2, 2, 4, and 4 for box dx, box dy, box dw, and box dh
respectively.
An example to compute the area inside a widget’s box():
int X = yourwidget->x() + Fl::box dx(yourwidget->box());
int Y = yourwidget->y() + Fl::box dy(yourwidget->box());
int W = yourwidget->w() - Fl::box dw(yourwidget->box());
int H = yourwidget->h() - Fl::box dh(yourwidget->box());

These functions are mainly useful in the draw() code for deriving custom widgets, where one wants to
avoid drawing over the widget’s own border box().

int Fl::check ( ) [static]


Same as Fl::wait(0).
Calling this during a big calculation will keep the screen up to date and the interface responsive:
while (!calculation done()) {
calculate();
Fl::check();
if (user hit abort button()) break;
}

This returns non-zero if any windows are displayed, and 0 if no windows are displayed (this is likely to
change in future versions of FLTK).

static int Fl::damage ( ) [inline], [static]


If true then flush() will do something.
31.2. FL CLASS REFERENCE 303

void Fl::display ( const char ∗ d ) [static]

Sets the X display to use for all windows.


Actually this just sets the environment variable $DISPLAY to the passed string, so this only works
before you show() the first window or otherwise open the display, and does nothing useful under WIN32.

static void Fl::dnd text ops ( int v ) [inline], [static]

Gets or sets whether drag and drop text operations are supported.
This specifically affects whether selected text can be dragged from text fields or dragged within a text
field as a cut/paste shortcut.

static int Fl::dnd text ops ( ) [inline], [static]

Gets or sets whether drag and drop text operations are supported.
This specifically affects whether selected text can be dragged from text fields or dragged within a text
field as a cut/paste shortcut.

int Fl::draw box active ( ) [static]

Determines if the current draw box is active or inactive.


If inactive, the box color is changed by the inactive color.

void Fl::flush ( ) [static]

Causes all the windows that need it to be redrawn and graphics forced out through the pipes.
This is what wait() does before looking for events.
Note: in multi-threaded applications you should only call Fl::flush() from the main thread. If a child
thread needs to trigger a redraw event, it should instead call Fl::awake() to get the main thread to process
the event queue.

void Fl::foreground ( uchar r, uchar g, uchar b ) [static]

Changes fl color(FL FOREGROUND COLOR).

int Fl::get awake handler ( Fl Awake Handler & func, void ∗& data ) [static]

Gets the last stored awake handler for use in awake().

Fl Box Draw F ∗ Fl::get boxtype ( Fl Boxtype t ) [static]

Gets the current box drawing function for the specified box type.

void Fl::get system colors ( ) [static]

Read the user preference colors from the system and use them to call Fl::foreground(), Fl::background(),
and Fl::background2().
This is done by Fl Window::show(argc,argv) before applying the -fg and -bg switches.
On X this reads some common values from the Xdefaults database. KDE users can set these values
by running the ”krdb” program, and newer versions of KDE set this automatically if you check the ”apply
style to other X programs” switch in their control panel.
304 CHAPTER 31. CLASS DOCUMENTATION

int Fl::gl visual ( int mode, int ∗ alist = 0 ) [static]


This does the same thing as Fl::visual(int) but also requires OpenGL drawing to work.
This must be done if you want to draw in normal windows with OpenGL with gl start() and gl end().
It may be useful to call this so your X windows use the same visual as an Fl Gl Window, which on some
servers will reduce colormap flashing.
See Fl Gl Window for a list of additional values for the argument.

static int Fl::is scheme ( const char ∗ name ) [inline], [static]


Returns whether the current scheme is the given name.
This is a fast inline convenience function to support scheme-specific code in widgets, e.g. in their
draw() methods, if required.
Use a valid scheme name, not NULL (although NULL is allowed, this is not a useful argument - see
below).
If Fl::scheme() has not been set or has been set to the default scheme (”none” or ”base”), then this will
always return 0 regardless of the argument, because Fl::scheme() is NULL in this case.
Note
The stored scheme name is always lowercase, and this method will do a case-sensitive compare, so
you must provide a lowercase string to return the correct value. This is intentional for performance
reasons.

Example:
if (Fl::is scheme("gtk+")) { your code here(); }

Parameters
in name lowercase string of requested scheme name.

Returns
1 if the given scheme is active, 0 otherwise.

See Also
Fl::scheme(const char ∗name)

bool Fl::option ( Fl Option opt ) [static]


FLTK library options management.
This function needs to be documented in more detail. It can be used for more optional settings, such as
using a native file chooser instead of the FLTK one wherever possible, disabling tooltips, disabling visible
focus, disabling FLTK file chooser preview, etc. .
There should be a command line option interface.
There should be an application that manages options system wide, per user, and per application.
Example:
if ( Fl::option(Fl::OPTION ARROW FOCUS) )
{ ..on.. }
else
{ ..off.. }

Note
As of FLTK 1.3.0, options can be managed within fluid, using the menu Edit/Global FLTK Settings.
31.2. FL CLASS REFERENCE 305

Parameters
opt which option

Returns
true or false

See Also
enum Fl::Fl Option
Fl::option(Fl Option, bool)

Since
FLTK 1.3.0

void Fl::option ( Fl Option opt, bool val ) [static]


Override an option while the application is running.
This function does not change any system or user settings.
Example:
Fl::option(Fl::OPTION ARROW FOCUS, true); // on
Fl::option(Fl::OPTION ARROW FOCUS, false); // off

Parameters
opt which option
val set to true or false

See Also
enum Fl::Fl Option
bool Fl::option(Fl Option)

void Fl::own colormap ( ) [static]


Makes FLTK use its own colormap.
This may make FLTK display better and will reduce conflicts with other programs that want lots of
colors. However the colors may flash as you move the cursor between windows.
This does nothing if the current visual is not colormapped.

int Fl::ready ( ) [static]


This is similar to Fl::check() except this does not call Fl::flush() or any callbacks, which is useful if your
program is in a state where such callbacks are illegal.
This returns true if Fl::check() would do anything (it will continue to return true until you call Fl-
::check() or Fl::wait()).
while (!calculation done()) {
calculate();
if (Fl::ready()) {
do expensive cleanup();
Fl::check();
if (user hit abort button()) break;
}
}
306 CHAPTER 31. CLASS DOCUMENTATION

static void Fl::release ( ) [inline], [static]


Releases the current grabbed window, equals grab(0).

Deprecated Use Fl::grab(0) instead.

See Also
grab(Fl Window∗)

int Fl::reload scheme ( ) [static]


Called by scheme according to scheme name.
Loads or reloads the current scheme selection. See void scheme(const char ∗name)

void Fl::remove check ( Fl Timeout Handler cb, void ∗ argp = 0 ) [static]


Removes a check callback.
It is harmless to remove a check callback that no longer exists.

static void Fl::remove fd ( int , int when ) [static]


Removes a file descriptor handler.

static void Fl::remove fd ( int ) [static]


Removes a file descriptor handler.

void Fl::remove timeout ( Fl Timeout Handler cb, void ∗ argp = 0 ) [static]


Removes a timeout callback.
It is harmless to remove a timeout callback that no longer exists.

Note
This version removes all matching timeouts, not just the first one. This may change in the future.

void Fl::repeat timeout ( double t, Fl Timeout Handler cb, void ∗ argp = 0 ) [static]
Repeats a timeout callback from the expiration of the previous timeout, allowing for more accurate timing.
You may only call this method inside a timeout callback.
The following code will print ”TICK” each second on stdout with a fair degree of accuracy:
void callback(void*) {
puts("TICK");
Fl::repeat timeout(1.0, callback);
}

int main() {
Fl::add timeout(1.0, callback);
return Fl::run();
}

int Fl::run ( ) [static]


As long as any windows are displayed this calls Fl::wait() repeatedly.
When all the windows are closed it returns zero (supposedly it would return non-zero on any errors, but
FLTK calls exit directly for these). A normal program will end main() with return Fl::run();.
31.2. FL CLASS REFERENCE 307

int Fl::scheme ( const char ∗ s ) [static]


Sets the current widget scheme.
NULL will use the scheme defined in the FLTK SCHEME environment variable or the scheme resource
under X11. Otherwise, any of the following schemes can be used:
- "none" - This is the default look-n-feel which resembles old
Windows (95/98/Me/NT/2000) and old GTK/KDE

- "base" - This is an alias for "none"

- "plastic" - This scheme is inspired by the Aqua user interface


on Mac OS X

- "gtk+" - This scheme is inspired by the Red Hat Bluecurve theme

- "gleam" - This scheme is inspired by the Clearlooks Glossy scheme.


(Colin Jones and Edmanuel Torres).

Uppercase scheme names are equivalent, but the stored scheme name will always be lowercase and
Fl::scheme() will return this lowercase name.
If the resulting scheme name is not defined, the default scheme will be used and Fl::scheme() will return
NULL.

int Fl::scrollbar size ( ) [static]


Gets the default scrollbar size used by Fl Browser , Fl Help View, Fl Scroll, and Fl Text Display widgets.
Returns
The default size for widget scrollbars, in pixels.

void Fl::scrollbar size ( int W ) [static]


Sets the default scrollbar size that is used by the Fl Browser , Fl Help View, Fl Scroll, and Fl Text Display
widgets.
Parameters
in W The new default size for widget scrollbars, in pixels.

void Fl::set boxtype ( Fl Boxtype t, Fl Box Draw F ∗ f, uchar a, uchar b, uchar c, uchar d )
[static]
Sets the function to call to draw a specific boxtype.

void Fl::set boxtype ( Fl Boxtype to, Fl Boxtype from ) [static]


Copies the from boxtype.

static void Fl::set idle ( Fl Old Idle Handler cb ) [inline], [static]


Sets an idle callback.

Deprecated This method is obsolete - use the add idle() method instead.

void Fl::set labeltype ( Fl Labeltype t, Fl Label Draw F ∗ f, Fl Label Measure F ∗ m )


[static]
Sets the functions to call to draw and measure a specific labeltype.
308 CHAPTER 31. CLASS DOCUMENTATION

static void Fl::set labeltype ( Fl Labeltype , Fl Labeltype from ) [static]

Sets the functions to call to draw and measure a specific labeltype.

double Fl::version ( ) [static]

Returns the compiled-in value of the FL VERSION constant.


This is useful for checking the version of a shared library.

static void Fl::visible focus ( int v ) [inline], [static]

Gets or sets the visible keyboard focus on buttons and other non-text widgets.
The default mode is to enable keyboard focus for all widgets.

static int Fl::visible focus ( ) [inline], [static]

Gets or sets the visible keyboard focus on buttons and other non-text widgets.
The default mode is to enable keyboard focus for all widgets.

int Fl::visual ( int flags ) [static]

Selects a visual so that your graphics are drawn correctly.


This is only allowed before you call show() on any windows. This does nothing if the default visual
satisfies the capabilities, or if no visual satisfies the capabilities, or on systems that don’t have such brain-
dead notions.
Only the following combinations do anything useful:

• Fl::visual(FL RGB)
Full/true color (if there are several depths FLTK chooses the largest). Do this if you use fl draw -
image for much better (non-dithered) output.

• Fl::visual(FL RGB8)
Full color with at least 24 bits of color. FL RGB will always pick this if available, but if not it will
happily return a less-than-24 bit deep visual. This call fails if 24 bits are not available.

• Fl::visual(FL DOUBLE|FL INDEX)


Hardware double buffering. Call this if you are going to use Fl Double Window.

• Fl::visual(FL DOUBLE|FL RGB)

• Fl::visual(FL DOUBLE|FL RGB8)


Hardware double buffering and full color.

This returns true if the system has the capabilities by default or FLTK suceeded in turing them on. Your
program will still work even if this returns false (it just won’t look as good).
31.2. FL CLASS REFERENCE 309

int Fl::wait ( ) [static]


Waits until ”something happens” and then returns.
Call this repeatedly to ”run” your program. You can also check what happened each time after this
returns, which is quite useful for managing program state.
What this really does is call all idle callbacks, all elapsed timeouts, call Fl::flush() to get the screen to
update, and then wait some time (zero if there are idle callbacks, the shortest of all pending timeouts, or
infinity), for any events from the user or any Fl::add fd() callbacks. It then handles the events and calls the
callbacks and then returns.
The return value of Fl::wait() is non-zero if there are any visible windows - this may change in future
versions of FLTK.
Fl::wait(time) waits a maximum of time seconds. It can return much sooner if something happens.
The return value is positive if an event or fd happens before the time elapsed. It is zero if nothing
happens (on Win32 this will only return zero if time is zero). It is negative if an error occurs (this will
happen on UNIX if a signal happens).

31.2.4 Member Data Documentation


const char ∗const Fl::help = helpmsg+13 [static]
Usage string displayed if Fl::args() detects an invalid argument.
This may be changed to point to customized text at run-time.

void(∗ Fl::idle)() [static]


The currently executing idle callback function: DO NOT USE THIS DIRECTLY!
This is now used as part of a higher level system allowing multiple idle callback functions to be called.
See Also
add idle(), remove idle()

The documentation for this class was generated from the following files:
• Fl.H
• Fl.cxx
• Fl abort.cxx
• Fl add idle.cxx
• Fl arg.cxx
• fl boxtype.cxx
• fl color.cxx
• fl color mac.cxx
• fl color win32.cxx
• Fl compose.cxx
• Fl display.cxx
• fl dnd win32.cxx
• fl dnd x.cxx
• Fl get key.cxx
• Fl get key mac.cxx
• Fl get key win32.cxx
• Fl get system colors.cxx
• Fl grab.cxx
• fl labeltype.cxx
• Fl lock.cxx
• Fl own colormap.cxx
310 CHAPTER 31. CLASS DOCUMENTATION

• fl set font.cxx
• fl set fonts mac.cxx
• fl set fonts win32.cxx
• fl set fonts x.cxx
• fl set fonts xft.cxx
• fl shortcut.cxx
• Fl visual.cxx
• Fl Widget.cxx
• Fl Window.cxx
• gl start.cxx
• screen xywh.cxx
• Fl Cairo.cxx

31.3 Fl Adjuster Class Reference


The Fl Adjuster widget was stolen from Prisms, and has proven to be very useful for values that need a
large dynamic range.
#include <Fl Adjuster.H>
Inheritance diagram for Fl Adjuster:

Fl_Widget

Fl_Valuator

Fl_Adjuster

Public Member Functions


• Fl Adjuster (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Adjuster widget using the given position, size, and label string.
• void soft (int s)
If ”soft” is turned on, the user is allowed to drag the value outside the range.
• int soft () const
If ”soft” is turned on, the user is allowed to drag the value outside the range.

Protected Member Functions


• void draw ()
Draws the widget.
• int handle (int)
Handles the specified event.
• void value damage ()
Asks for partial redraw.
31.3. FL ADJUSTER CLASS REFERENCE 311

Additional Inherited Members


31.3.1 Detailed Description
The Fl Adjuster widget was stolen from Prisms, and has proven to be very useful for values that need a
large dynamic range.

Figure 31.1: Fl Adjuster

When you press a button and drag to the right the value increases. When you drag to the left it decreases.
The largest button adjusts by 100 ∗ step(), the next by 10 ∗ step() and that smallest button by step(). Clicking
on the buttons increments by 10 times the amount dragging by a pixel does. Shift + click decrements by 10
times the amount.

31.3.2 Constructor & Destructor Documentation


Fl Adjuster::Fl Adjuster ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Adjuster widget using the given position, size, and label string.
It looks best if one of the dimensions is 3 times the other.
Inherited destructor destroys the Valuator.

31.3.3 Member Function Documentation


void Fl Adjuster::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Adjuster::handle ( int event ) [protected], [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
312 CHAPTER 31. CLASS DOCUMENTATION

Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
31.4. FL BITMAP CLASS REFERENCE 313

Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.

void Fl Adjuster::soft ( int s ) [inline]


If ”soft” is turned on, the user is allowed to drag the value outside the range.
If they drag the value to one of the ends, let go, then grab again and continue to drag, they can get to
any value. Default is one.

int Fl Adjuster::soft ( ) const [inline]


If ”soft” is turned on, the user is allowed to drag the value outside the range.
If they drag the value to one of the ends, let go, then grab again and continue to drag, they can get to
any value. Default is one.
The documentation for this class was generated from the following files:
• Fl Adjuster.H
• Fl Adjuster.cxx

31.4 Fl Bitmap Class Reference


The Fl Bitmap class supports caching and drawing of mono-color (bitmap) images.
#include <Fl Bitmap.H>
Inheritance diagram for Fl Bitmap:

Fl_Image

Fl_Bitmap

Fl_XBM_Image

Public Member Functions


• virtual Fl Image ∗ copy (int W, int H)
The copy() method creates a copy of the specified image.
• Fl Image ∗ copy ()
• virtual void draw (int X, int Y, int W, int H, int cx=0, int cy=0)
Draws the image with a bounding box.
• void draw (int X, int Y)
• Fl Bitmap (const uchar ∗bits, int W, int H)
314 CHAPTER 31. CLASS DOCUMENTATION

The constructors create a new bitmap from the specified bitmap data.
• Fl Bitmap (const char ∗bits, int W, int H)
The constructors create a new bitmap from the specified bitmap data.
• virtual void label (Fl Widget ∗w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void label (Fl Menu Item ∗m)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.
• virtual ∼Fl Bitmap ()
The destructor free all memory and server resources that are used by the bitmap.

Public Attributes
• int alloc array
Non-zero if array points to bitmap data allocated internally.
• const uchar ∗ array
pointer to raw bitmap data

Friends
• class Fl GDI Graphics Driver
• class Fl GDI Printer Graphics Driver
• class Fl Quartz Graphics Driver
• class Fl Xlib Graphics Driver

Additional Inherited Members


31.4.1 Detailed Description
The Fl Bitmap class supports caching and drawing of mono-color (bitmap) images.
Images are drawn using the current color.

31.4.2 Constructor & Destructor Documentation


Fl Bitmap::Fl Bitmap ( const uchar ∗ bits, int W, int H ) [inline]
The constructors create a new bitmap from the specified bitmap data.

Fl Bitmap::Fl Bitmap ( const char ∗ array, int W, int H ) [inline]


The constructors create a new bitmap from the specified bitmap data.

31.4.3 Member Function Documentation


Fl Image ∗ Fl Bitmap::copy ( int W, int H ) [virtual]
The copy() method creates a copy of the specified image.
If the width and height are provided, the image is resized to the specified size. The image should be
deleted (or in the case of Fl Shared Image, released) when you are done with it.
Reimplemented from Fl Image.
31.5. FL BMP IMAGE CLASS REFERENCE 315

void Fl Bitmap::draw ( int X, int Y, int W, int H, int cx = 0, int cy = 0 ) [virtual]


Draws the image with a bounding box.
This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image
offset by the cx and cy arguments.
Reimplemented from Fl Image.

void Fl Bitmap::label ( Fl Widget ∗ widget ) [virtual]


The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented from Fl Image.

void Fl Bitmap::label ( Fl Menu Item ∗ m ) [virtual]


The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented from Fl Image.

void Fl Bitmap::uncache ( ) [virtual]


If the image has been cached for display, delete the cache data.
This allows you to change the data used for the image and then redraw it without recreating an image
object.
Reimplemented from Fl Image.
The documentation for this class was generated from the following files:
• Fl Bitmap.H
• Fl Bitmap.cxx

31.5 Fl BMP Image Class Reference


The Fl BMP Image class supports loading, caching, and drawing of Windows Bitmap (BMP) image files.
#include <Fl BMP Image.H>
Inheritance diagram for Fl BMP Image:

Fl_Image

Fl_RGB_Image

Fl_BMP_Image

Public Member Functions


• Fl BMP Image (const char ∗filename)
The constructor loads the named BMP image from the given bmp filename.

Additional Inherited Members


31.5.1 Detailed Description
The Fl BMP Image class supports loading, caching, and drawing of Windows Bitmap (BMP) image files.
316 CHAPTER 31. CLASS DOCUMENTATION

31.5.2 Constructor & Destructor Documentation


Fl BMP Image::Fl BMP Image ( const char ∗ bmp )
The constructor loads the named BMP image from the given bmp filename.
The inherited destructor free all memory and server resources that are used by the image.
The destructor free all memory and server resources that are used by the image
The documentation for this class was generated from the following files:
• Fl BMP Image.H
• Fl BMP Image.cxx

31.6 Fl Box Class Reference


This widget simply draws its box, and possibly its label.
#include <Fl Box.H>
Inheritance diagram for Fl Box:

Fl_Widget

Fl_Box

Public Member Functions


• Fl Box (int X, int Y, int W, int H, const char ∗l=0)
• Fl Box (Fl Boxtype b, int X, int Y, int W, int H, const char ∗l)
See Fl Box::Fl Box(int x, int y, int w, int h, const char ∗ = 0)
• virtual int handle (int)
Handles the specified event.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.6.1 Detailed Description
This widget simply draws its box, and possibly its label.
Putting it before some other widgets and making it big enough to surround them will let you draw a
frame around them.

31.6.2 Constructor & Destructor Documentation


Fl Box::Fl Box ( int X, int Y, int W, int H, const char ∗ l = 0 )
• The first constructor sets box() to FL NO BOX, which means it is invisible. However such widgets
are useful as placeholders or Fl Group::resizable() values. To change the box to something visible,
use box(n).
• The second form of the constructor sets the box to the specified box type.
The destructor removes the box.
31.7. FL BROWSER CLASS REFERENCE 317

31.6.3 Member Function Documentation


void Fl Box::draw ( ) [protected], [virtual]

Draws the widget.


Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:

Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar


s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Box::handle ( int event ) [virtual]

Handles the specified event.


You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.


The documentation for this class was generated from the following files:

• Fl Box.H
• Fl Box.cxx

31.7 Fl Browser Class Reference


The Fl Browser widget displays a scrolling list of text lines, and manages all the storage for the text.
#include <Fl Browser.H>
Inheritance diagram for Fl Browser:
318 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Group

Fl_Browser_

Fl_Browser

Fl_File_Browser Fl_Hold_Browser Fl_Multi_Browser Fl_Select_Browser

Public Types
• enum Fl Line Position { TOP, BOTTOM, MIDDLE }
For internal use only?

Public Member Functions


• void add (const char ∗newtext, void ∗d=0)
Adds a new line to the end of the browser.
• void bottomline (int line)
Scrolls the browser so the bottom item in the browser is showing the specified line.
• void clear ()
Removes all the lines in the browser.
• char column char () const
Gets the current column separator character.
• void column char (char c)
Sets the column separator to c.
• const int ∗ column widths () const
Gets the current column width array.
• void column widths (const int ∗arr)
Sets the current array to arr.
• void ∗ data (int line) const
Returns the user data() for specified line.
• void data (int line, void ∗d)
Sets the user data for specified line to d.
• void display (int line, int val=1)
For back compatibility.
• int displayed (int line) const
Returns non-zero if line has been scrolled to a position where it is being displayed.
• Fl Browser (int X, int Y, int W, int H, const char ∗L=0)
The constructor makes an empty browser.
• char format char () const
Gets the current format code prefix character, which by default is ’@’.
• void format char (char c)
Sets the current format code prefix character to c.
31.7. FL BROWSER CLASS REFERENCE 319

• void hide (int line)


Makes line invisible, preventing selection by the user.
• void hide ()
Hides the entire Fl Browser widget – opposite of show().
• void icon (int line, Fl Image ∗icon)
Set the image icon for line to the value icon.
• Fl Image ∗ icon (int line) const
Returns the icon currently defined for line.
• void insert (int line, const char ∗newtext, void ∗d=0)
Insert a new entry whose label is newtext above given line, optional data d.
• void lineposition (int line, Fl Line Position pos)
Updates the browser so that line is shown at position pos.
• int load (const char ∗filename)
Clears the browser and reads the file, adding each line from the file to the browser.
• void make visible (int line)
Make the item at the specified line visible().
• void middleline (int line)
Scrolls the browser so the middle item in the browser is showing the specified line.
• void move (int to, int from)
Line from is removed and reinserted at to.
• void remove (int line)
Remove entry for given line number, making the browser one line shorter.
• void remove icon (int line)
Removes the icon for line.
• void replace (int a, const char ∗b)
For back compatibility only.
• int select (int line, int val=1)
Sets the selection state of the item at line to the value val.
• int selected (int line) const
Returns 1 if specified line is selected, 0 if not.
• void show (int line)
Makes line visible, and available for selection by user.
• void show ()
Shows the entire Fl Browser widget – opposite of hide().
• int size () const
Returns how many lines are in the browser.
• void size (int W, int H)
• void swap (int a, int b)
Swaps two browser lines a and b.
• const char ∗ text (int line) const
Returns the label text for the specified line.
• void text (int line, const char ∗newtext)
Sets the text for the specified line to newtext.
• int topline () const
Returns the line that is currently visible at the top of the browser.
• void topline (int line)
320 CHAPTER 31. CLASS DOCUMENTATION

Scrolls the browser so the top item in the browser is showing the specified line.
• int value () const
Returns the line number of the currently selected line, or 0 if none.
• void value (int line)
Sets the browser’s value(), which selects the specified line.
• int visible (int line) const
Returns non-zero if the specified line is visible, 0 if hidden.
• ∼Fl Browser ()
The destructor deletes all list items and destroys the browser.

Protected Member Functions


• FL BLINE ∗ remove (int line)
Removes the item at the specified line.
• FL BLINE ∗ find line (int line) const
Returns the item for specified line.
• int full height () const
The height of the entire list of all visible() items in pixels.
• int incr height () const
The default ’average’ item height (including inter-item spacing) in pixels.
• void insert (int line, FL BLINE ∗item)
Insert specified item above line.
• void ∗ item at (int line) const
Return the item at specified line.
• void item draw (void ∗item, int X, int Y, int W, int H) const
Draws item at the position specified by X Y W H.
• void ∗ item first () const
Returns the very first item in the list.
• int item height (void ∗item) const
Returns height of item in pixels.
• void ∗ item last () const
Returns the very last item in the list.
• void ∗ item next (void ∗item) const
Returns the next item after item.
• void ∗ item prev (void ∗item) const
Returns the previous item before item.
• void item select (void ∗item, int val)
Change the selection state of item to the value val.
• int item selected (void ∗item) const
See if item is selected.
• void item swap (void ∗a, void ∗b)
Swap the items a and b.
• const char ∗ item text (void ∗item) const
Returns the label text for item.
• int item width (void ∗item) const
Returns width of item in pixels.
• int lineno (void ∗item) const
Returns line number corresponding to item, or zero if not found.
• void swap (FL BLINE ∗a, FL BLINE ∗b)
Swap the two items a and b.
31.7. FL BROWSER CLASS REFERENCE 321

Additional Inherited Members


31.7.1 Detailed Description
The Fl Browser widget displays a scrolling list of text lines, and manages all the storage for the text.
This is not a text editor or spreadsheet! But it is useful for showing a vertical list of named objects to
the user.
Each line in the browser is identified by number. The numbers start at one (this is so that zero can be
reserved for ”no line” in the selective browsers). Unless otherwise noted, the methods do not check to see
if the passed line number is in range and legal. It must always be greater than zero and <= size().
Each line contains a null-terminated string of text and a void ∗ data pointer. The text string is displayed,
the void ∗ pointer can be used by the callbacks to reference the object the text describes.
The base class does nothing when the user clicks on it. The subclasses Fl Select Browser, Fl Hold -
Browser, and Fl Multi Browser react to user clicks to select lines in the browser and do callbacks.
The base class Fl Browser provides the scrolling and selection mechanisms of this and all the sub-
classes, but the dimensions and appearance of each item are determined by the subclass. You can use
Fl Browser to display information other than text, or text that is dynamically produced from your own
data structures. If you find that loading the browser is a lot of work or is inefficient, you may want to make
a subclass of Fl Browser .
Some common coding patterns used for working with Fl Browser:
// How to loop through all the items in the browser
for ( int t=1; t<=browser->size(); t++ ) { // index 1 based..!
printf("item #%d, label=’%s’\n", t, browser->text(t));
}

Note: If you are subclassing Fl Browser, it’s more efficient to use the protected methods item first()
and item next(), since Fl Browser internally uses linked lists to manage the browser’s items. For more info,
see find item(int).

31.7.2 Constructor & Destructor Documentation


Fl Browser::Fl Browser ( int X, int Y, int W, int H, const char ∗ L = 0 )
The constructor makes an empty browser.
Parameters
in X,Y,W,H position and size.
in L label string, may be NULL.

31.7.3 Member Function Documentation


FL BLINE ∗ Fl Browser:: remove ( int line ) [protected]
Removes the item at the specified line.
Caveat: See efficiency note in find line(). You must call redraw() to make any changes visible.
Parameters
in line The line number to be removed. (1 based) Must be in range!

Returns
Pointer to browser item that was removed (and is no longer valid).

See Also
add(), insert(), remove(), swap(int,int), clear()
322 CHAPTER 31. CLASS DOCUMENTATION

void Fl Browser::add ( const char ∗ newtext, void ∗ d = 0 )

Adds a new line to the end of the browser.


The text string newtext may contain format characters; see format char() for details. newtext is
copied using the strdup() function, and can be NULL to make a blank line.
The optional void∗ argument d will be the data() for the new item.
Parameters
in newtext The label text used for the added item
in d Optional user data() for the item (0 if unspecified)

See Also
add(), insert(), remove(), swap(int,int), clear()

void Fl Browser::bottomline ( int line ) [inline]

Scrolls the browser so the bottom item in the browser is showing the specified line.
Parameters
in line The line to be displayed at the bottom.

See Also
topline(), middleline(), bottomline(), displayed(), lineposition()

void Fl Browser::clear ( )

Removes all the lines in the browser.

See Also
add(), insert(), remove(), swap(int,int), clear()

char Fl Browser::column char ( ) const [inline]

Gets the current column separator character.


The default is ’\t’ (tab).

See Also
column char(), column widths()

void Fl Browser::column char ( char c ) [inline]

Sets the column separator to c.


This will only have an effect if you also set column widths(). The default is ’\t’ (tab).

See Also
column char(), column widths()
31.7. FL BROWSER CLASS REFERENCE 323

const int∗ Fl Browser::column widths ( ) const [inline]

Gets the current column width array.


This array is zero-terminated and specifies the widths in pixels of each column. The text is split at each
column char() and each part is formatted into it’s own column. After the last column any remaining text is
formatted into the space between the last column and the right edge of the browser, even if the text contains
instances of column char() . The default value is a one-element array of just a zero, which means there are
no columns.
Example:

Fl Browser *b = new Fl Browser(..);


static int widths[] = { 50, 50, 50, 70, 70, 40, 40, 70, 70, 50, 0 }; // widths for each column
b->column widths(widths); // assign array to widget
b->column char(’\t’); // use tab as the column character
b->add("USER\tPID\tCPU\tMEM\tVSZ\tRSS\tTTY\tSTAT\tSTART\tTIME\tCOMMAND");
b->add("root\t2888\t0.0\t0.0\t1352\t0\ttty3\tSW\tAug15\t0:00\t@b@f/sbin/mingetty tty3");
b->add("root\t13115\t0.0\t0.0\t1352\t0\ttty2\tSW\tAug30\t0:00\t@b@f/sbin/mingetty tty2");
[..]

See Also
column char(), column widths()

void Fl Browser::column widths ( const int ∗ arr ) [inline]

Sets the current array to arr.


Make sure the last entry is zero.

See Also
column char(), column widths()

void ∗ Fl Browser::data ( int line ) const

Returns the user data() for specified line.


Return value can be NULL if line is out of range or no user data() was defined. The parameter line
is 1 based (1 will be the first item in the list).
Parameters
in line The line number of the item whose data() is returned. (1 based)

Returns
The user data pointer (can be NULL)

void Fl Browser::data ( int line, void ∗ d )

Sets the user data for specified line to d.


Does nothing if line is out of range.
Parameters
in line The line of the item whose data() is to be changed. (1 based)
in d The new data to be assigned to the item. (can be NULL)
324 CHAPTER 31. CLASS DOCUMENTATION

void Fl Browser::display ( int line, int val = 1 )


For back compatibility.
This calls show(line) if val is true, and hide(line) otherwise. If val is not specified, the default is 1
(makes the line visible).
See Also
show(int), hide(int), display(), visible(), make visible()

int Fl Browser::displayed ( int line ) const [inline]


Returns non-zero if line has been scrolled to a position where it is being displayed.
Checks to see if the item’s vertical position is within the top and bottom edges of the display window.
This does NOT take into account the hide()/show() status of the widget or item.
Parameters
in line The line to be checked

Returns
1 if visible, 0 if not visible.

See Also
topline(), middleline(), bottomline(), displayed(), lineposition()

FL BLINE ∗ Fl Browser::find line ( int line ) const [protected]


Returns the item for specified line.
Note: This call is slow. It’s fine for e.g. responding to user clicks, but slow if called often, such as
in a tight sorting loop. Finding an item ’by line’ involves a linear lookup on the internal linked list. The
performance hit can be significant if the browser’s contents is large, and the method is called often (e.g.
during a sort). If you’re writing a subclass, use the protected methods item first(), item next(), etc. to
access the internal linked list more efficiently.
Parameters
in line The line number of the item to return. (1 based)
Return values
item that was found.
NULL if line is out of range.

See Also
item at(), find line(), lineno()

char Fl Browser::format char ( ) const [inline]


Gets the current format code prefix character, which by default is ’@’.
A string of formatting codes at the start of each column are stripped off and used to modify how the
rest of the line is printed:

• ’@.’ Print rest of line, don’t look for more ’@’ signs
• ’@@’ Print rest of line starting with ’@’
31.7. FL BROWSER CLASS REFERENCE 325

• ’@l’ Use a LARGE (24 point) font


• ’@m’ Use a medium large (18 point) font
• ’@s’ Use a small (11 point) font
• ’@b’ Use a bold font (adds FL BOLD to font)
• ’@i’ Use an italic font (adds FL ITALIC to font)
• ’@f’ or ’@t’ Use a fixed-pitch font (sets font to FL COURIER)
• ’@c’ Center the line horizontally
• ’@r’ Right-justify the text
• ’@B0’, ’@B1’, ... ’@B255’ Fill the backgound with fl color(n)
• ’@C0’, ’@C1’, ... ’@C255’ Use fl color(n) to draw the text
• ’@F0’, ’@F1’, ... Use fl font(n) to draw the text
• ’@S1’, ’@S2’, ... Use point size n to draw the text
• ’@u’ or ’@ ’ Underline the text.
• ’@-’ draw an engraved line through the middle.
Notice that the ’@.’ command can be used to reliably terminate the parsing. To print a random string in
a random color, use sprintf("@C%d@.%s", color, string) and it will work even if the string
starts with a digit or has the format character in it.

void Fl Browser::format char ( char c ) [inline]


Sets the current format code prefix character to c.
The default prefix is ’@’. Set the prefix to 0 to disable formatting.
See Also
format char() for list of ’@’ codes

int Fl Browser::full height ( ) const [protected], [virtual]


The height of the entire list of all visible() items in pixels.
This returns the accumulated height of all the items in the browser that are not hidden with hide(),
including items scrolled off screen.
Returns
The accumulated size of all the visible items in pixels.

See Also
item height(), item width(),
incr height(), full height()
Reimplemented from Fl Browser .

void Fl Browser::hide ( int line )


Makes line invisible, preventing selection by the user.
The line can still be selected under program control. This changes the full height() if the state was
changed. When a line is made invisible, lines below it are moved up in the display. redraw() is called
automatically if a change occurred.
326 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in line The line to be hidden. (1 based)

See Also
show(int), hide(int), display(), visible(), make visible()

void Fl Browser::hide ( ) [inline], [virtual]


Hides the entire Fl Browser widget – opposite of show().
Reimplemented from Fl Widget.

void Fl Browser::icon ( int line, Fl Image ∗ icon )


Set the image icon for line to the value icon.
Caller is responsible for keeping the icon allocated. The line is automatically redrawn.
Parameters
in line The line to be modified. If out of range, nothing is done.
in icon The image icon to be assigned to the line. If NULL, any previous icon
is removed.

Fl Image ∗ Fl Browser::icon ( int line ) const


Returns the icon currently defined for line.
If no icon is defined, NULL is returned.
Parameters
in line The line whose icon is returned.

Returns
The icon defined, or NULL if none.

int Fl Browser::incr height ( ) const [protected], [virtual]


The default ’average’ item height (including inter-item spacing) in pixels.
This currently returns textsize() + 2.
Returns
The value in pixels.

See Also
item height(), item width(),
incr height(), full height()

Reimplemented from Fl Browser .

void Fl Browser::insert ( int line, FL BLINE ∗ item ) [protected]


Insert specified item above line.
If line > size() then the line is added to the end.
Caveat: See efficiency note in find line().
31.7. FL BROWSER CLASS REFERENCE 327

Parameters
in line The new line will be inserted above this line (1 based).
in item The item to be added.

void Fl Browser::insert ( int line, const char ∗ newtext, void ∗ d = 0 )


Insert a new entry whose label is newtext above given line, optional data d.
Text may contain format characters; see format char() for details. newtext is copied using the
strdup() function, and can be NULL to make a blank line.
The optional void ∗ argument d will be the data() of the new item.
Parameters
in line Line position for insert. (1 based)
If line > size(), the entry will be added at the end.
in newtext The label text for the new line.
in d Optional pointer to user data to be associated with the new line.

void∗ Fl Browser::item at ( int line ) const [inline], [protected], [virtual]


Return the item at specified line.
Parameters
in line The line of the item to return. (1 based)

Returns
The item, or NULL if line out of range.

See Also
item at(), find line(), lineno()

Reimplemented from Fl Browser .

void Fl Browser::item draw ( void ∗ item, int X, int Y, int W, int H ) const [protected],
[virtual]
Draws item at the position specified by X Y W H.
The W and H values are used for clipping. Should only be called within the context of an FLTK draw().
Parameters
in item The item to be drawn
in X,Y,W,H position and size.
Implements Fl Browser .

void ∗ Fl Browser::item first ( ) const [protected], [virtual]


Returns the very first item in the list.
Example of use:
// Walk the browser from beginning to end
for ( void *i=item first(); i; i=item next(i) ) {
printf("item label=’%s’\n", item text(i));
}
328 CHAPTER 31. CLASS DOCUMENTATION

Returns
The first item, or NULL if list is empty.

See Also
item first(), item last(), item next(), item prev()
Implements Fl Browser .

int Fl Browser::item height ( void ∗ item ) const [protected], [virtual]


Returns height of item in pixels.
This takes into account embedded @ codes within the text() label.
Parameters
in item The item whose height is returned.

Returns
The height of the item in pixels.

See Also
item height(), item width(),
incr height(), full height()
Implements Fl Browser .

void ∗ Fl Browser::item last ( ) const [protected], [virtual]


Returns the very last item in the list.
Example of use:
// Walk the browser in reverse, from end to start
for ( void *i=item last(); i; i=item prev(i) ) {
printf("item label=’%s’\n", item text(i));
}

Returns
The last item, or NULL if list is empty.

See Also
item first(), item last(), item next(), item prev()
Reimplemented from Fl Browser .

void ∗ Fl Browser::item next ( void ∗ item ) const [protected], [virtual]


Returns the next item after item.
Parameters
in item The ’current’ item

Returns
The next item after item, or NULL if there are none after this one.

See Also
item first(), item last(), item next(), item prev()
Implements Fl Browser .
31.7. FL BROWSER CLASS REFERENCE 329

void ∗ Fl Browser::item prev ( void ∗ item ) const [protected], [virtual]


Returns the previous item before item.
330 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in item The ’current’ item

Returns
The previous item before item, or NULL if there none before this one.

See Also
item first(), item last(), item next(), item prev()
Implements Fl Browser .

void Fl Browser::item select ( void ∗ item, int val ) [protected], [virtual]


Change the selection state of item to the value val.
Parameters
in item The item to be changed.
in val The new selection state: 1 selects, 0 de-selects.

See Also
select(), selected(), value(), item select(), item selected()
Reimplemented from Fl Browser .

int Fl Browser::item selected ( void ∗ item ) const [protected], [virtual]


See if item is selected.
Parameters
in item The item whose selection state is to be checked.

Returns
1 if selected, 0 if not.

See Also
select(), selected(), value(), item select(), item selected()
Reimplemented from Fl Browser .

void Fl Browser::item swap ( void ∗ a, void ∗ b ) [inline], [protected], [virtual]


Swap the items a and b.
You must call redraw() to make any changes visible.
Parameters
in a,b the items to be swapped.

See Also
swap(int,int), item swap()
Reimplemented from Fl Browser .

const char ∗ Fl Browser::item text ( void ∗ item ) const [protected], [virtual]


Returns the label text for item.
31.7. FL BROWSER CLASS REFERENCE 331

Parameters
in item The item whose label text is returned.

Returns
The item’s text string. (Can be NULL)

Reimplemented from Fl Browser .

int Fl Browser::item width ( void ∗ item ) const [protected], [virtual]


Returns width of item in pixels.
This takes into account embedded @ codes within the text() label.
Parameters
in item The item whose width is returned.

Returns
The width of the item in pixels.

See Also
item height(), item width(),
incr height(), full height()

Implements Fl Browser .

int Fl Browser::lineno ( void ∗ item ) const [protected]


Returns line number corresponding to item, or zero if not found.
Caveat: See efficiency note in find line().
Parameters
in item The item to be found

Returns
The line number of the item, or 0 if not found.

See Also
item at(), find line(), lineno()

void Fl Browser::lineposition ( int line, Fl Line Position pos )


Updates the browser so that line is shown at position pos.
Parameters
in line line number. (1 based)
in pos position.

See Also
topline(), middleline(), bottomline()
332 CHAPTER 31. CLASS DOCUMENTATION

int Fl Browser::load ( const char ∗ filename )


Clears the browser and reads the file, adding each line from the file to the browser.
If the filename is NULL or a zero-length string then this just clears the browser. This returns zero if
there was any error in opening or reading the file, in which case errno is set to the system error. The data()
of each line is set to NULL.
31.7. FL BROWSER CLASS REFERENCE 333

Parameters
in filename The filename to load

Returns
1 if OK, 0 on error (errno has reason)

See Also
add()

void Fl Browser::make visible ( int line ) [inline]


Make the item at the specified line visible().
Functionally similar to show(int line). If line is out of range, redisplay top or bottom of list as
appropriate.
Parameters
in line The line to be made visible.

See Also
show(int), hide(int), display(), visible(), make visible()

void Fl Browser::middleline ( int line ) [inline]


Scrolls the browser so the middle item in the browser is showing the specified line.
Parameters
in line The line to be displayed in the middle.

See Also
topline(), middleline(), bottomline(), displayed(), lineposition()

void Fl Browser::move ( int to, int from )


Line from is removed and reinserted at to.
Note: to is calculated after line from gets removed.
Parameters
in to Destination line number (calculated after line from is removed)
in from Line number of item to be moved

void Fl Browser::remove ( int line )


Remove entry for given line number, making the browser one line shorter.
You must call redraw() to make any changes visible.
334 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in line Line to be removed. (1 based)
If line is out of range, no action is taken.

See Also
add(), insert(), remove(), swap(int,int), clear()

void Fl Browser::remove icon ( int line )


Removes the icon for line.
It’s ok to remove an icon if none has been defined.
Parameters
in line The line whose icon is to be removed.

void Fl Browser::replace ( int a, const char ∗ b ) [inline]


For back compatibility only.

int Fl Browser::select ( int line, int val = 1 )


Sets the selection state of the item at line to the value val.
If val is not specified, the default is 1 (selects the item).
Parameters
in line The line number of the item to be changed. (1 based)
in val The new selection state (1=select, 0=de-select).

Returns
1 if the state changed, 0 if not.

See Also
select(), selected(), value(), item select(), item selected()

int Fl Browser::selected ( int line ) const


Returns 1 if specified line is selected, 0 if not.
Parameters
in line The line being checked (1 based)

Returns
1 if item selected, 0 if not.

See Also
select(), selected(), value(), item select(), item selected()

void Fl Browser::show ( int line )


Makes line visible, and available for selection by user.
Opposite of hide(int). This changes the full height() if the state was changed. redraw() is called auto-
matically if a change occurred.
31.7. FL BROWSER CLASS REFERENCE 335

Parameters
in line The line to be shown. (1 based)

See Also
show(int), hide(int), display(), visible(), make visible()

void Fl Browser::show ( ) [inline], [virtual]


Shows the entire Fl Browser widget – opposite of hide().
Reimplemented from Fl Widget.

int Fl Browser::size ( ) const [inline]


Returns how many lines are in the browser.
The last line number is equal to this. Returns 0 if browser is empty.

void Fl Browser::swap ( FL BLINE ∗ a, FL BLINE ∗ b ) [protected]


Swap the two items a and b.
Uses swapping() to ensure list updates correctly.
Parameters
in a,b The two items to be swapped.

See Also
swap(int,int), item swap()

void Fl Browser::swap ( int a, int b )


Swaps two browser lines a and b.
You must call redraw() to make any changes visible.
Parameters
in a,b The two lines to be swapped. (both 1 based)

See Also
swap(int,int), item swap()

const char ∗ Fl Browser::text ( int line ) const


Returns the label text for the specified line.
Return value can be NULL if line is out of range or unset. The parameter line is 1 based.
Parameters
in line The line number of the item whose text is returned. (1 based)

Returns
The text string (can be NULL)
336 CHAPTER 31. CLASS DOCUMENTATION

void Fl Browser::text ( int line, const char ∗ newtext )


Sets the text for the specified line to newtext.
Text may contain format characters; see format char() for details. newtext is copied using the
strdup() function, and can be NULL to make a blank line.
Does nothing if line is out of range.
Parameters
in line The line of the item whose text will be changed. (1 based)
in newtext The new string to be assigned to the item.

int Fl Browser::topline ( ) const


Returns the line that is currently visible at the top of the browser.
If there is no vertical scrollbar then this will always return 1.
Returns
The lineno() of the top() of the browser.

void Fl Browser::topline ( int line ) [inline]


Scrolls the browser so the top item in the browser is showing the specified line.
Parameters
in line The line to be displayed at the top.

See Also
topline(), middleline(), bottomline(), displayed(), lineposition()

int Fl Browser::value ( ) const


Returns the line number of the currently selected line, or 0 if none.
Returns
The line number of current selection, or 0 if none selected.

See Also
select(), selected(), value(), item select(), item selected()

void Fl Browser::value ( int line ) [inline]


Sets the browser’s value(), which selects the specified line.
This is the same as calling select(line).
See Also
select(), selected(), value(), item select(), item selected()

int Fl Browser::visible ( int line ) const


Returns non-zero if the specified line is visible, 0 if hidden.
Use show(int), hide(int), or make visible(int) to change an item’s visible state.
31.8. FL BROWSER CLASS REFERENCE 337

Parameters
in line The line in the browser to be tested. (1 based)

See Also
show(int), hide(int), display(), visible(), make visible()

The documentation for this class was generated from the following files:
• Fl Browser.H
• Fl Browser.cxx
• Fl Browser load.cxx

31.8 Fl Browser Class Reference


This is the base class for browsers.
#include <Fl Browser .H>
Inheritance diagram for Fl Browser :

Fl_Widget

Fl_Group

Fl_Browser_

Fl_Browser Fl_Check_Browser

Fl_File_Browser Fl_Hold_Browser Fl_Multi_Browser Fl_Select_Browser

Public Types
• enum {
HORIZONTAL = 1, VERTICAL = 2, BOTH = 3, ALWAYS ON = 4,
HORIZONTAL ALWAYS = 5, VERTICAL ALWAYS = 6, BOTH ALWAYS = 7 }
Values for has scrollbar().

Public Member Functions


• int deselect (int docallbacks=0)
Deselects all items in the list and returns 1 if the state changed or 0 if it did not.
• void display (void ∗item)
Displays the item, scrolling the list as necessary.
• int handle (int event)
Handles the event within the normal widget bounding box.
• uchar has scrollbar () const
Returns the current scrollbar mode, see Fl Browser ::has scrollbar(uchar)
• void has scrollbar (uchar mode)
Sets whether the widget should have scrollbars or not (default Fl Browser ::BOTH).
338 CHAPTER 31. CLASS DOCUMENTATION

• int hposition () const


Gets the horizontal scroll position of the list as a pixel position pos.
• void hposition (int)
Sets the horizontal scroll position of the list to pixel position pos.
• int position () const
Gets the vertical scroll position of the list as a pixel position pos.
• void position (int pos)
Sets the vertical scroll position of the list to pixel position pos.
• void resize (int X, int Y, int W, int H)
Repositions and/or resizes the browser.
• void scrollbar left ()
Moves the vertical scrollbar to the lefthand side of the list.
• void scrollbar right ()
Moves the vertical scrollbar to the righthand side of the list.
• int scrollbar size () const
Gets the current size of the scrollbars’ troughs, in pixels.
• void scrollbar size (int newSize)
Sets the pixel size of the scrollbars’ troughs to newSize, in pixels.
• int scrollbar width () const
This method has been deprecated, existing for backwards compatibility only.
• void scrollbar width (int width)
This method has been deprecated, existing for backwards compatibility only.
• int select (void ∗item, int val=1, int docallbacks=0)
Sets the selection state of item to val, and returns 1 if the state changed or 0 if it did not.
• int select only (void ∗item, int docallbacks=0)
Selects item and returns 1 if the state changed or 0 if it did not.
• void sort (int flags=0)
Sort the items in the browser based on flags.
• Fl Color textcolor () const
Gets the default text color for the lines in the browser.
• void textcolor (Fl Color col)
Sets the default text color for the lines in the browser to color col.
• Fl Font textfont () const
Gets the default text font for the lines in the browser.
• void textfont (Fl Font font)
Sets the default text font for the lines in the browser to font.
• Fl Fontsize textsize () const
Gets the default text size (in pixels) for the lines in the browser.
• void textsize (Fl Fontsize newSize)
Sets the default text size (in pixels) for the lines in the browser to size.

Public Attributes
• Fl Scrollbar hscrollbar
Horizontal scrollbar.
• Fl Scrollbar scrollbar
Vertical scrollbar.
31.8. FL BROWSER CLASS REFERENCE 339

Protected Member Functions


• void bbox (int &X, int &Y, int &W, int &H) const
Returns the bounding box for the interior of the list’s display window, inside the scrollbars.
• void deleting (void ∗item)
This method should be used when item is being deleted from the list.
• int displayed (void ∗item) const
Returns non-zero if item has been scrolled to a position where it is being displayed.
• void draw ()
Draws the list within the normal widget bounding box.
• void ∗ find item (int ypos)
This method returns the item under mouse y position ypos.
• Fl Browser (int X, int Y, int W, int H, const char ∗L=0)
The constructor makes an empty browser.
• virtual int full height () const
This method may be provided by the subclass to indicate the full height of the item list, in pixels.
• virtual int full width () const
This method may be provided by the subclass to indicate the full width of the item list, in pixels.
• virtual int incr height () const
This method may be provided to return the average height of all items to be used for scrolling.
• void inserting (void ∗a, void ∗b)
This method should be used when an item is in the process of being inserted into the list.
• virtual void ∗ item at (int index) const
This method must be provided by the subclass to return the item for the specified index.
• virtual void item draw (void ∗item, int X, int Y, int W, int H) const =0
This method must be provided by the subclass to draw the item in the area indicated by X, Y, W, H.
• virtual void ∗ item first () const =0
This method must be provided by the subclass to return the first item in the list.
• virtual int item height (void ∗item) const =0
This method must be provided by the subclass to return the height of item in pixels.
• virtual void ∗ item last () const
This method must be provided by the subclass to return the last item in the list.
• virtual void ∗ item next (void ∗item) const =0
This method must be provided by the subclass to return the item in the list after item.
• virtual void ∗ item prev (void ∗item) const =0
This method must be provided by the subclass to return the item in the list before item.
• virtual int item quick height (void ∗item) const
This method may be provided by the subclass to return the height of the item, in pixels.
• virtual void item select (void ∗item, int val=1)
This method must be implemented by the subclass if it supports multiple selections; sets the selection state
to val for the item.
• virtual int item selected (void ∗item) const
This method must be implemented by the subclass if it supports multiple selections; returns the selection
state for item.
• virtual void item swap (void ∗a, void ∗b)
This optional method should be provided by the subclass to efficiently swap browser items a and b, such as
for sorting.
• virtual const char ∗ item text (void ∗item) const
340 CHAPTER 31. CLASS DOCUMENTATION

This optional method returns a string (label) that may be used for sorting.
• virtual int item width (void ∗item) const =0
This method must be provided by the subclass to return the width of the item in pixels.
• int leftedge () const
This method returns the X position of the left edge of the list area after adjusting for the scrollbar and border,
if any.
• void new list ()
This method should be called when the list data is completely replaced or cleared.
• void redraw line (void ∗item)
This method should be called when the contents of item has changed, but not its height.
• void redraw lines ()
This method will cause the entire list to be redrawn.
• void replacing (void ∗a, void ∗b)
This method should be used when item a is being replaced by item b.
• void ∗ selection () const
Returns the item currently selected, or NULL if there is no selection.
• void swapping (void ∗a, void ∗b)
This method should be used when two items a and b are being swapped.
• void ∗ top () const
Returns the item that appears at the top of the list.

Additional Inherited Members


31.8.1 Detailed Description
This is the base class for browsers.
To be useful it must be subclassed and several virtual functions defined. The Forms-compatible browser
and the file chooser’s browser are subclassed off of this.
This has been designed so that the subclass has complete control over the storage of the data, although
because next() and prev() functions are used to index, it works best as a linked list or as a large block of
characters in which the line breaks must be searched for.
A great deal of work has been done so that the ”height” of a data object does not need to be determined
until it is drawn. This is useful if actually figuring out the size of an object requires accessing image data
or doing stat() on a file or doing some other slow operation.

Keyboard navigation of browser items

The keyboard navigation of browser items is only possible if visible focus() is enabled. If disabled, the
widget rejects keyboard focus; Tab and Shift-Tab focus navigation will skip the widget.
In ’Select’ and ’Normal’ mode, the widget rejects keyboard focus; no navigation keys are supported
(other than scrollbar positioning).
In ’Hold’ mode, the widget accepts keyboard focus, and Up/Down arrow keys can navigate the selected
item.
In ’Multi’ mode, the widget accepts keyboard focus, and Up/Down arrow keys navigate the focus box;
Space toggles the current item’s selection, Enter selects only the current item (deselects all others). If Shift
(or Ctrl) is combined with Up/Down arrow keys, the current item’s selection state is extended to the next
item. In this way one can extend a selection or de-selection.
31.8. FL BROWSER CLASS REFERENCE 341

31.8.2 Member Enumeration Documentation


anonymous enum
Values for has scrollbar().
Anonymous enum bit flags for has scrollbar().
• bit 0: horizontal

• bit 1: vertical
• bit 2: ’always’ (to be combined with bits 0 and 1)
• bit 3-31: reserved for future use
Enumerator
HORIZONTAL Only show horizontal scrollbar.
VERTICAL Only show vertical scrollbar.
BOTH Show both scrollbars. (default)
ALWAYS ON Specified scrollbar(s) should ’always’ be shown (to be used with HORIZONTAL/V-
ERTICAL)
HORIZONTAL ALWAYS Horizontal scrollbar always on.
VERTICAL ALWAYS Vertical scrollbar always on.
BOTH ALWAYS Both scrollbars always on.

31.8.3 Constructor & Destructor Documentation


Fl Browser ::Fl Browser ( int X, int Y, int W, int H, const char ∗ L = 0 ) [protected]
The constructor makes an empty browser.
Parameters
in X,Y,W,H position and size.
in L The label string, may be NULL.

31.8.4 Member Function Documentation


void Fl Browser ::bbox ( int & X, int & Y, int & W, int & H ) const [protected]
Returns the bounding box for the interior of the list’s display window, inside the scrollbars.
Parameters
out X,Y,W,H The returned bounding box.
(The original contents of these parameters are overwritten)

void Fl Browser ::deleting ( void ∗ item ) [protected]


This method should be used when item is being deleted from the list.
It allows the Fl Browser to discard any cached data it has on the item. This method does not actually
delete the item, but handles the follow up bookkeeping after the item has just been deleted.
342 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in item The item being deleted.

int Fl Browser ::deselect ( int docallbacks = 0 )


Deselects all items in the list and returns 1 if the state changed or 0 if it did not.
If the optional docallbacks parameter is non-zero, deselect tries to call the callback function for
the widget.
Parameters
in docallbacks If 1, invokes widget callback if item changed.
If 0, doesn’t do callback (default).

void Fl Browser ::display ( void ∗ item )


Displays the item, scrolling the list as necessary.
Parameters
in item The item to be displayed.

See Also
display(), displayed()

int Fl Browser ::displayed ( void ∗ item ) const [protected]


Returns non-zero if item has been scrolled to a position where it is being displayed.
Checks to see if the item’s vertical position is within the top and bottom edges of the display window.
This does NOT take into account the hide()/show() status of the widget or item.
Parameters
in item The item to check

Returns
1 if visible, 0 if not visible.

See Also
display(), displayed()

void ∗ Fl Browser ::find item ( int ypos ) [protected]


This method returns the item under mouse y position ypos.
NULL is returned if no item is displayed at that position.
Parameters
in ypos The y position (eg. Fl::event y()) to find an item under.

Returns
The item, or NULL if not found
31.8. FL BROWSER CLASS REFERENCE 343

int Fl Browser ::full height ( ) const [protected], [virtual]


This method may be provided by the subclass to indicate the full height of the item list, in pixels.
The default implementation computes the full height from the item heights. Includes the items that are
scrolled off screen.

Returns
The height of the entire list, in pixels.

Reimplemented in Fl Browser.

int Fl Browser ::full width ( ) const [protected], [virtual]


This method may be provided by the subclass to indicate the full width of the item list, in pixels.
The default implementation computes the full width from the item widths.

Returns
The maximum width of all the items, in pixels.

int Fl Browser ::handle ( int event ) [virtual]


Handles the event within the normal widget bounding box.
Parameters
in event The event to process.

Returns
1 if event was processed, 0 if not.

Reimplemented from Fl Widget.


Reimplemented in Fl Check Browser.

void Fl Browser ::has scrollbar ( uchar mode ) [inline]


Sets whether the widget should have scrollbars or not (default Fl Browser ::BOTH).
By default you can scroll in both directions, and the scrollbars disappear if the data will fit in the widget.
has scrollbar() changes this based on the value of mode:

• 0 - No scrollbars.

• Fl Browser ::HORIZONTAL - Only a horizontal scrollbar.

• Fl Browser ::VERTICAL - Only a vertical scrollbar.

• Fl Browser ::BOTH - The default is both scrollbars.

• Fl Browser ::HORIZONTAL ALWAYS - Horizontal scrollbar always on, vertical always off.

• Fl Browser ::VERTICAL ALWAYS - Vertical scrollbar always on, horizontal always off.

• Fl Browser ::BOTH ALWAYS - Both always on.


344 CHAPTER 31. CLASS DOCUMENTATION

int Fl Browser ::hposition ( ) const [inline]


Gets the horizontal scroll position of the list as a pixel position pos.
The position returned is how many pixels of the list are scrolled off the left edge of the screen. Example:
A position of ’18’ indicates the left 18 pixels of the list are scrolled off the left edge of the screen.
See Also
position(), hposition()

void Fl Browser ::hposition ( int pos )


Sets the horizontal scroll position of the list to pixel position pos.
The position is how many pixels of the list are scrolled off the left edge of the screen. Example: A
position of ’18’ scrolls the left 18 pixels of the list off the left edge of the screen.
Parameters
in pos The horizontal position (in pixels) to scroll the browser to.

See Also
position(), hposition()

int Fl Browser ::incr height ( ) const [protected], [virtual]


This method may be provided to return the average height of all items to be used for scrolling.
The default implementation uses the height of the first item.
Returns
The average height of items, in pixels.

Reimplemented in Fl Browser.

void Fl Browser ::inserting ( void ∗ a, void ∗ b ) [protected]


This method should be used when an item is in the process of being inserted into the list.
It allows the Fl Browser to update its cache data as needed, scheduling a redraw for the affected lines.
This method does not actually insert items, but handles the follow up bookkeeping after items have been
inserted.
Parameters
in a The starting item position
in b The new item being inserted

virtual void∗ Fl Browser ::item at ( int index ) const [inline], [protected], [virtual]
This method must be provided by the subclass to return the item for the specified index.
Parameters
in index The index of the item to be returned

Returns
The item at the specified index.

Reimplemented in Fl Browser.
31.8. FL BROWSER CLASS REFERENCE 345

virtual void∗ Fl Browser ::item first ( ) const [protected], [pure virtual]


This method must be provided by the subclass to return the first item in the list.
See Also
item first(), item next(), item last(), item prev()
Implemented in Fl Browser.

virtual int Fl Browser ::item height ( void ∗ item ) const [protected], [pure virtual]
This method must be provided by the subclass to return the height of item in pixels.
Allow for two additional pixels for the list selection box.
Parameters
in item The item whose height is returned.

Returns
The height of the specified item in pixels.

See Also
item height(), item width(), item quick height()
Implemented in Fl Browser.

virtual void∗ Fl Browser ::item last ( ) const [inline], [protected], [virtual]


This method must be provided by the subclass to return the last item in the list.
See Also
item first(), item next(), item last(), item prev()
Reimplemented in Fl Browser.

virtual void∗ Fl Browser ::item next ( void ∗ item ) const [protected], [pure virtual]
This method must be provided by the subclass to return the item in the list after item.
See Also
item first(), item next(), item last(), item prev()
Implemented in Fl Browser.

virtual void∗ Fl Browser ::item prev ( void ∗ item ) const [protected], [pure virtual]
This method must be provided by the subclass to return the item in the list before item.
See Also
item first(), item next(), item last(), item prev()
Implemented in Fl Browser.

int Fl Browser ::item quick height ( void ∗ item ) const [protected], [virtual]
This method may be provided by the subclass to return the height of the item, in pixels.
Allow for two additional pixels for the list selection box. This method differs from item height in that
it is only called for selection and scrolling operations. The default implementation calls item height.
346 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in item The item whose height to return.

Returns
The height, in pixels.

void Fl Browser ::item select ( void ∗ item, int val = 1 ) [protected], [virtual]
This method must be implemented by the subclass if it supports multiple selections; sets the selection state
to val for the item.
Sets the selection state for item, where optional val is 1 (select, the default) or 0 (de-select).
Parameters
in item The item to be selected
in val The optional selection state; 1=select, 0=de-select.
The default is to select the item (1).
Reimplemented in Fl Browser.

int Fl Browser ::item selected ( void ∗ item ) const [protected], [virtual]


This method must be implemented by the subclass if it supports multiple selections; returns the selection
state for item.
The method should return 1 if item is selected, or 0 otherwise.
Parameters
in item The item to test.
Reimplemented in Fl Browser.

virtual void Fl Browser ::item swap ( void ∗ a, void ∗ b ) [inline], [protected],


[virtual]
This optional method should be provided by the subclass to efficiently swap browser items a and b, such
as for sorting.
Parameters
in a,b The two items to be swapped.
Reimplemented in Fl Browser.

virtual const char∗ Fl Browser ::item text ( void ∗ item ) const [inline], [protected],
[virtual]
This optional method returns a string (label) that may be used for sorting.
Parameters
in item The item whose label text is returned.

Returns
The item’s text label. (Can be NULL if blank)
Reimplemented in Fl Browser.

virtual int Fl Browser ::item width ( void ∗ item ) const [protected], [pure virtual]
This method must be provided by the subclass to return the width of the item in pixels.
Allow for two additional pixels for the list selection box.
31.8. FL BROWSER CLASS REFERENCE 347

Parameters
in item The item whose width is returned.

Returns
The width of the item in pixels.

Implemented in Fl Browser.

int Fl Browser ::leftedge ( ) const [protected]


This method returns the X position of the left edge of the list area after adjusting for the scrollbar and
border, if any.
Returns
The X position of the left edge of the list, in pixels.

See Also
Fl Browser ::bbox()

void Fl Browser ::new list ( ) [protected]


This method should be called when the list data is completely replaced or cleared.
It informs the Fl Browser widget that any cached information it has concerning the items is invalid.
This method does not clear the list, it just handles the follow up bookkeeping after the list has been cleared.

int Fl Browser ::position ( ) const [inline]


Gets the vertical scroll position of the list as a pixel position pos.
The position returned is how many pixels of the list are scrolled off the top edge of the screen. Example:
A position of ’3’ indicates the top 3 pixels of the list are scrolled off the top edge of the screen.
See Also
position(), hposition()

void Fl Browser ::position ( int pos )


Sets the vertical scroll position of the list to pixel position pos.
The position is how many pixels of the list are scrolled off the top edge of the screen. Example: A
position of ’3’ scrolls the top three pixels of the list off the top edge of the screen.
Parameters
in pos The vertical position (in pixels) to scroll the browser to.

See Also
position(), hposition()

void Fl Browser ::redraw line ( void ∗ item ) [protected]


This method should be called when the contents of item has changed, but not its height.
348 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in item The item that needs to be redrawn.

See Also
redraw lines(), redraw line()

void Fl Browser ::redraw lines ( ) [inline], [protected]


This method will cause the entire list to be redrawn.
See Also
redraw lines(), redraw line()

void Fl Browser ::replacing ( void ∗ a, void ∗ b ) [protected]


This method should be used when item a is being replaced by item b.
It allows the Fl Browser to update its cache data as needed, schedules a redraw for the item being
changed, and tries to maintain the selection. This method does not actually replace the item, but handles
the follow up bookkeeping after the item has just been replaced.
Parameters
in a Item being replaced
in b Item to replace ’a’

void Fl Browser ::resize ( int X, int Y, int W, int H ) [virtual]


Repositions and/or resizes the browser.
Parameters
in X,Y,W,H The new position and size for the browser, in pixels.
Reimplemented from Fl Widget.

void Fl Browser ::scrollbar left ( ) [inline]


Moves the vertical scrollbar to the lefthand side of the list.
For back compatibility.

void Fl Browser ::scrollbar right ( ) [inline]


Moves the vertical scrollbar to the righthand side of the list.
For back compatibility.

int Fl Browser ::scrollbar size ( ) const [inline]


Gets the current size of the scrollbars’ troughs, in pixels.
If this value is zero (default), this widget will use the Fl::scrollbar size() value as the scrollbar’s width.
Returns
Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used.

See Also
Fl::scrollbar size(int)
31.8. FL BROWSER CLASS REFERENCE 349

void Fl Browser ::scrollbar size ( int newSize ) [inline]


Sets the pixel size of the scrollbars’ troughs to newSize, in pixels.
Normally you should not need this method, and should use Fl::scrollbar size(int) instead to manage
the size of ALL your widgets’ scrollbars. This ensures your application has a consistent UI, is the default
behavior, and is normally what you want.
Only use THIS method if you really need to override the global scrollbar size. The need for this should
be rare.
Setting newSize to the special value of 0 causes the widget to track the global Fl::scrollbar size(),
which is the default.
Parameters
in newSize Sets the scrollbar size in pixels.
If 0 (default), scrollbar size tracks the global Fl::scrollbar size()

See Also
Fl::scrollbar size()

int Fl Browser ::scrollbar width ( ) const [inline]


This method has been deprecated, existing for backwards compatibility only.
Use scrollbar size() instead. This method always returns the global value Fl::scrollbar size().
Returns
Always returns the global value Fl::scrollbar size().
Todo This method should eventually be removed in 1.4+

void Fl Browser ::scrollbar width ( int width ) [inline]


This method has been deprecated, existing for backwards compatibility only.
Use scrollbar size(int) instead. This method sets the global Fl::scrollbar size(), and forces this instance
of the widget to use it.
Todo This method should eventually be removed in 1.4+

int Fl Browser ::select ( void ∗ item, int val = 1, int docallbacks = 0 )


Sets the selection state of item to val, and returns 1 if the state changed or 0 if it did not.
If docallbacks is non-zero, select tries to call the callback function for the widget.
Parameters
in item The item whose selection state is to be changed
in val The new selection state (1=select, 0=de-select)
in docallbacks If 1, invokes widget callback if item changed.
If 0, doesn’t do callback (default).

Returns
1 if state was changed, 0 if not.

int Fl Browser ::select only ( void ∗ item, int docallbacks = 0 )


Selects item and returns 1 if the state changed or 0 if it did not.
Any other items in the list are deselected.
350 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in item The item to select.
in docallbacks If 1, invokes widget callback if item changed.
If 0, doesn’t do callback (default).

void∗ Fl Browser ::selection ( ) const [inline], [protected]


Returns the item currently selected, or NULL if there is no selection.
For multiple selection browsers this call returns the currently focused item, even if it is not selected. To
find all selected items, call Fl Multi Browser::selected() for every item in question.

void Fl Browser ::sort ( int flags = 0 )


Sort the items in the browser based on flags.
item swap(void∗, void∗) and item text(void∗) must be implemented for this call.
Parameters
in flags FL SORT ASCENDING – sort in ascending order
FL SORT DESCENDING – sort in descending order
Values other than the above will cause undefined behavior
Other flags may appear in the future.

Todo Add a flag to ignore case

void Fl Browser ::swapping ( void ∗ a, void ∗ b ) [protected]


This method should be used when two items a and b are being swapped.
It allows the Fl Browser to update its cache data as needed, schedules a redraw for the two items, and
tries to maintain the current selection. This method does not actually swap items, but handles the follow
up bookkeeping after items have been swapped.
Parameters
in a,b Items being swapped.

Fl Font Fl Browser ::textfont ( ) const [inline]


Gets the default text font for the lines in the browser.
See Also
textfont(), textsize(), textcolor()

31.8.5 Member Data Documentation


Fl Scrollbar Fl Browser ::hscrollbar
Horizontal scrollbar.
Public, so that it can be accessed directly.

Fl Scrollbar Fl Browser ::scrollbar


Vertical scrollbar.
Public, so that it can be accessed directly.
The documentation for this class was generated from the following files:
31.9. FL BUTTON CLASS REFERENCE 351

• Fl Browser .H
• Fl Browser .cxx

31.9 Fl Button Class Reference


Buttons generate callbacks when they are clicked by the user.
#include <Fl Button.H>
Inheritance diagram for Fl Button:

Fl_Widget

Fl_Button

Fl_Light_Button Fl_Radio_Button Fl_Repeat_Button Fl_Return_Button Fl_Toggle_Button

Fl_Check_Button Fl_Radio_Light_Button Fl_Round_Button

Fl_Radio_Round_Button

Public Member Functions


• int clear ()
Same as value(0).
• Fl Boxtype down box () const
Returns the current down box type, which is drawn when value() is non-zero.
• void down box (Fl Boxtype b)
Sets the down box type.
• Fl Color down color () const
(for backwards compatibility)
• void down color (unsigned c)
(for backwards compatibility)
• Fl Button (int X, int Y, int W, int H, const char ∗L=0)
The constructor creates the button using the given position, size, and label.
• virtual int handle (int)
Handles the specified event.
• int set ()
Same as value(1).
• void setonly ()
Turns on this button and turns off all other radio buttons in the group (calling value(1) or set() does
not do this).
• int shortcut () const
Returns the current shortcut key for the button.
• void shortcut (int s)
Sets the shortcut key to s.
• void shortcut (const char ∗s)
(for backwards compatibility)
• int value (int v)
Sets the current value of the button.
• char value () const
Returns the current value of the button (0 or 1).
352 CHAPTER 31. CLASS DOCUMENTATION

Protected Member Functions


• virtual void draw ()
Draws the widget.
• void simulate key action ()

Static Protected Member Functions


• static void key release timeout (void ∗)

Static Protected Attributes


• static Fl Widget Tracker ∗ key release tracker = 0

Additional Inherited Members


31.9.1 Detailed Description
Buttons generate callbacks when they are clicked by the user.
You control exactly when and how by changing the values for type() and when(). Buttons can also
generate callbacks in response to FL SHORTCUT events. The button can either have an explicit shortcut(int
s) value or a letter shortcut can be indicated in the label() with an ’&’ character before it. For the label
shortcut it does not matter if Alt is held down, but if you have an input field in the same window, the user
will have to hold down the Alt key so that the input field does not eat the event first as an FL KEYBOARD
event.
Todo Refactor the doxygen comments for Fl Button type() documentation.
For an Fl Button object, the type() call returns one of:
• FL NORMAL BUTTON (0): value() remains unchanged after button press.
• FL TOGGLE BUTTON: value() is inverted after button press.
• FL RADIO BUTTON: value() is set to 1 after button press, and all other buttons in the current group
with type() == FL RADIO BUTTON are set to zero.
Todo Refactor the doxygen comments for Fl Button when() documentation.
For an Fl Button object, the following when() values are useful, the default being FL WHEN RELEA-
SE:
• 0: The callback is not done, instead changed() is turned on.
• FL WHEN RELEASE: The callback is done after the user successfully clicks the button, or when a
shortcut is typed.
• FL WHEN CHANGED: The callback is done each time the value() changes (when the user pushes
and releases the button, and as the mouse is dragged around in and out of the button).

31.9.2 Constructor & Destructor Documentation


Fl Button::Fl Button ( int X, int Y, int W, int H, const char ∗ L = 0 )
The constructor creates the button using the given position, size, and label.
The default box type is box(FL UP BOX).
You can control how the button is drawn when ON by setting down box(). The default is FL NO BOX
(0) which will select an appropriate box type using the normal (OFF) box type by using fl down(box()).
Derived classes may handle this differently.
31.9. FL BUTTON CLASS REFERENCE 353

Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

31.9.3 Member Function Documentation


int Fl Button::clear ( ) [inline]
Same as value(0).
See Also
value(int v)

Fl Boxtype Fl Button::down box ( ) const [inline]


Returns the current down box type, which is drawn when value() is non-zero.
Return values
Fl Boxtype

void Fl Button::down box ( Fl Boxtype b ) [inline]


Sets the down box type.
The default value of 0 causes FLTK to figure out the correct matching down version of box().
Some derived classes (e.g. Fl Round Button and Fl Light Button use down box() for special purposes.
See docs of these classes.
Parameters
in b down box type

void Fl Button::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.
Reimplemented in Fl Light Button, and Fl Return Button.

int Fl Button::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
354 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.


Reimplemented in Fl Light Button, Fl Return Button, and Fl Repeat Button.

int Fl Button::set ( ) [inline]


Same as value(1).
See Also
value(int v)

int Fl Button::shortcut ( ) const [inline]


Returns the current shortcut key for the button.
Return values
int

void Fl Button::shortcut ( int s ) [inline]


Sets the shortcut key to s.
Setting this overrides the use of ’&’ in the label(). The value is a bitwise OR of a key and a set of shift
flags, for example: FL ALT | ’a’, or FL ALT | (FL F + 10), or just ’a’. A value of 0 disables the
shortcut.
The key can be any value returned by Fl::event key(), but will usually be an ASCII letter. Use a lower-
case letter unless you require the shift key to be held down.
The shift flags can be any set of values accepted by Fl::event state(). If the bit is on, that shift key must
be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in the shift flags (zero for the other bits
indicates a ”don’t care” setting).
Parameters
in s bitwise OR of key and shift flags

int Fl Button::value ( int v )


Sets the current value of the button.
A non-zero value sets the button to 1 (ON), and zero sets it to 0 (OFF).
Parameters
31.10. FL CAIRO STATE CLASS REFERENCE 355

in v button value.

See Also
set(), clear()

The documentation for this class was generated from the following files:

• Fl Button.H
• Fl Button.cxx

31.10 Fl Cairo State Class Reference


Contains all the necessary info on the current cairo context.
#include <Fl Cairo.H>

Public Member Functions


• bool autolink () const
Gets the autolink option. See Fl::cairo autolink context(bool)
• void autolink (bool b)
Sets the autolink option, only available with –enable-cairoext.
• cairo t ∗ cc () const
Gets the current cairo context.
• void cc (cairo t ∗c, bool own=true)
Sets the current cairo context, own indicates cc deletion is handle externally by user.
• void gc (void ∗c)
Sets the gc c to keep track on.
• void ∗ gc () const
Gets the last gc attached to a cc.
• void window (void ∗w)
Sets the window w to keep track on.
• void ∗ window () const
Gets the last window attached to a cc.

31.10.1 Detailed Description


Contains all the necessary info on the current cairo context.
A private internal & unique corresponding object is created to permit cairo context state handling while
keeping it opaque. For internal use only.

Note
Only available when configure has the –enable-cairo option

The documentation for this class was generated from the following files:

• Fl Cairo.H
• Fl Cairo.cxx
356 CHAPTER 31. CLASS DOCUMENTATION

31.11 Fl Cairo Window Class Reference


This defines a pre-configured cairo fltk window.
#include <Fl Cairo Window.H>
Inheritance diagram for Fl Cairo Window:

Fl_Widget

Fl_Group

Fl_Window

Fl_Double_Window

Fl_Cairo_Window

Public Types
• typedef void(∗ cairo draw cb )(Fl Cairo Window ∗self, cairo t ∗def)
This defines the cairo draw callback prototype that you must further.

Public Member Functions


• Fl Cairo Window (int w, int h)
• void set draw cb (cairo draw cb cb)
You must provide a draw callback which will implement your cairo rendering.

Protected Member Functions


• void draw ()
Overloaded to provide cairo callback support.

Additional Inherited Members


31.11.1 Detailed Description
This defines a pre-configured cairo fltk window.
This class overloads the virtual draw() method for you, so that the only thing you have to do is to
provide your cairo code. All cairo context handling is achieved transparently.

Note
You can alternatively define your custom cairo fltk window, and thus at least override the draw()
method to provide custom cairo support. In this case you will probably use Fl::cairo make current(-
Fl Window∗) to attach a context to your window. You should do it only when your window is the
current window.

See Also
Fl Window::current()
31.12. FL CHART CLASS REFERENCE 357

31.11.2 Member Function Documentation


void Fl Cairo Window::set draw cb ( cairo draw cb cb ) [inline]
You must provide a draw callback which will implement your cairo rendering.
This method will permit you to set your cairo callback to cb.
The documentation for this class was generated from the following file:
• Fl Cairo Window.H

31.12 Fl Chart Class Reference


Fl Chart displays simple charts.
#include <Fl Chart.H>
Inheritance diagram for Fl Chart:

Fl_Widget

Fl_Chart

Public Member Functions


• void add (double val, const char ∗str=0, unsigned col=0)
Add the data value val with optional label str and color col to the chart.
• uchar autosize () const
Get whether the chart will automatically adjust the bounds of the chart.
• void autosize (uchar n)
Set whether the chart will automatically adjust the bounds of the chart.
• void bounds (double ∗a, double ∗b) const
Gets the lower and upper bounds of the chart values.
• void bounds (double a, double b)
Sets the lower and upper bounds of the chart values.
• void clear ()
Removes all values from the chart.
• Fl Chart (int X, int Y, int W, int H, const char ∗L=0)
Create a new Fl Chart widget using the given position, size and label string.
• void insert (int ind, double val, const char ∗str=0, unsigned col=0)
Inserts a data value val at the given position ind.
• int maxsize () const
Gets the maximum number of data values for a chart.
• void maxsize (int m)
Set the maximum number of data values for a chart.
• void replace (int ind, double val, const char ∗str=0, unsigned col=0)
Replace a data value val at the given position ind.
• int size () const
Returns the number of data values in the chart.
• void size (int W, int H)
• Fl Color textcolor () const
358 CHAPTER 31. CLASS DOCUMENTATION

Gets the chart’s text color.


• void textcolor (Fl Color n)
gets the chart’s text color to n.
• Fl Font textfont () const
Gets the chart’s text font.
• void textfont (Fl Font s)
Sets the chart’s text font to s.
• Fl Fontsize textsize () const
Gets the chart’s text size.
• void textsize (Fl Fontsize s)
gets the chart’s text size to s.
• ∼Fl Chart ()
Destroys the Fl Chart widget and all of its data.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.12.1 Detailed Description
Fl Chart displays simple charts.
It is provided for Forms compatibility.

Figure 31.2: Fl Chart

Todo Refactor Fl Chart::type() information.

The type of an Fl Chart object can be set using type(uchar t) to:


• FL BAR CHART: Each sample value is drawn as a vertical bar.
• FL FILLED CHART: The chart is filled from the bottom of the graph to the sample values.
• FL HORBAR CHART: Each sample value is drawn as a horizontal bar.
• FL LINE CHART: The chart is drawn as a polyline with vertices at each sample value.
• FL PIE CHART: A pie chart is drawn with each sample value being drawn as a proportionate slice
in the circle.
31.12. FL CHART CLASS REFERENCE 359

• FL SPECIALPIE CHART: Like FL PIE CHART, but the first slice is separated from the pie.
• FL SPIKE CHART: Each sample value is drawn as a vertical line.

31.12.2 Constructor & Destructor Documentation


Fl Chart::Fl Chart ( int X, int Y, int W, int H, const char ∗ L = 0 )
Create a new Fl Chart widget using the given position, size and label string.
The default boxstyle is FL NO BOX.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

31.12.3 Member Function Documentation


void Fl Chart::add ( double val, const char ∗ str = 0, unsigned col = 0 )
Add the data value val with optional label str and color col to the chart.
Parameters
in val data value
in str optional data label
in col optional data color

uchar Fl Chart::autosize ( ) const [inline]


Get whether the chart will automatically adjust the bounds of the chart.
Returns
non-zero if auto-sizing is enabled and zero if disabled.

void Fl Chart::autosize ( uchar n ) [inline]


Set whether the chart will automatically adjust the bounds of the chart.
Parameters
in n non-zero to enable automatic resizing, zero to disable.

void Fl Chart::bounds ( double ∗ a, double ∗ b ) const [inline]


Gets the lower and upper bounds of the chart values.
Parameters
out a,b are set to lower, upper

void Fl Chart::bounds ( double a, double b )


Sets the lower and upper bounds of the chart values.
360 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in a,b are used to set lower, upper

void Fl Chart::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

void Fl Chart::insert ( int ind, double val, const char ∗ str = 0, unsigned col = 0 )
Inserts a data value val at the given position ind.
Position 1 is the first data value.
Parameters
in ind insertion position
in val data value
in str optional data label
in col optional data color

void Fl Chart::maxsize ( int m )


Set the maximum number of data values for a chart.
If you do not call this method then the chart will be allowed to grow to any size depending on available
memory.
Parameters
in m maximum number of data values allowed.

void Fl Chart::replace ( int ind, double val, const char ∗ str = 0, unsigned col = 0 )
Replace a data value val at the given position ind.
Position 1 is the first data value.
Parameters
in ind insertion position
in val data value
in str optional data label
in col optional data color

void Fl Chart::textcolor ( Fl Color n ) [inline]


gets the chart’s text color to n.

void Fl Chart::textfont ( Fl Font s ) [inline]


Sets the chart’s text font to s.
31.13. FL CHART ENTRY STRUCT REFERENCE 361

void Fl Chart::textsize ( Fl Fontsize s ) [inline]

gets the chart’s text size to s.


The documentation for this class was generated from the following files:

• Fl Chart.H
• Fl Chart.cxx

31.13 FL CHART ENTRY Struct Reference


For internal use only.
#include <Fl Chart.H>

Public Attributes
• unsigned col
For internal use only.
• char str [FL CHART LABEL MAX+1]
For internal use only.
• float val
For internal use only.

31.13.1 Detailed Description


For internal use only.

31.13.2 Member Data Documentation


unsigned FL CHART ENTRY::col

For internal use only.

char FL CHART ENTRY::str[FL CHART LABEL MAX+1]

For internal use only.

float FL CHART ENTRY::val

For internal use only.


The documentation for this struct was generated from the following file:

• Fl Chart.H

31.14 Fl Check Browser Class Reference


The Fl Check Browser widget displays a scrolling list of text lines that may be selected and/or checked by
the user.
#include <Fl Check Browser.H>
Inheritance diagram for Fl Check Browser:
362 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Group

Fl_Browser_

Fl_Check_Browser

Public Member Functions


• int add (char ∗s)
Add a new unchecked line to the end of the browser.
• int add (char ∗s, int b)
Add a new line to the end of the browser.
• int add (const char ∗s)
See int Fl Check Browser::add(char ∗s)
• int add (const char ∗s, int b)
See int Fl Check Browser::add(char ∗s)
• void check all ()
Sets all the items checked.
• void check none ()
Sets all the items unchecked.
• int checked (int item) const
Gets the current status of item item.
• void checked (int item, int b)
Sets the check status of item item to b.
• void clear ()
Remove every item from the browser.
• Fl Check Browser (int x, int y, int w, int h, const char ∗l=0)
The constructor makes an empty browser.
• int nchecked () const
Returns how many items are currently checked.
• int nitems () const
Returns how many lines are in the browser.
• int remove (int item)
Remove line n and make the browser one line shorter.
• void set checked (int item)
Equivalent to Fl Check Browser::checked(item, 1).
• char ∗ text (int item) const
Return a pointer to an internal buffer holding item item’s text.
• int value () const
Returns the index of the currently selected item.
• ∼Fl Check Browser ()
The destructor deletes all list items and destroys the browser.
31.14. FL CHECK BROWSER CLASS REFERENCE 363

Protected Member Functions


• int handle (int)
Handles the event within the normal widget bounding box.

Additional Inherited Members


31.14.1 Detailed Description
The Fl Check Browser widget displays a scrolling list of text lines that may be selected and/or checked by
the user.

31.14.2 Constructor & Destructor Documentation


Fl Check Browser::Fl Check Browser ( int X, int Y, int W, int H, const char ∗ l = 0 )
The constructor makes an empty browser.

Fl Check Browser::∼Fl Check Browser ( ) [inline]


The destructor deletes all list items and destroys the browser.

31.14.3 Member Function Documentation


int Fl Check Browser::add ( char ∗ s )
Add a new unchecked line to the end of the browser.
See Also
add(char ∗s, int b)

int Fl Check Browser::add ( char ∗ s, int b )


Add a new line to the end of the browser.
The text is copied using the strdup() function. It may also be NULL to make a blank line. It can set the
item checked if b is not 0.

void Fl Check Browser::check all ( )


Sets all the items checked.

void Fl Check Browser::check none ( )


Sets all the items unchecked.

int Fl Check Browser::checked ( int i ) const


Gets the current status of item item.

void Fl Check Browser::checked ( int i, int b )


Sets the check status of item item to b.

void Fl Check Browser::clear ( )


Remove every item from the browser.
364 CHAPTER 31. CLASS DOCUMENTATION

int Fl Check Browser::handle ( int event ) [protected], [virtual]


Handles the event within the normal widget bounding box.
31.15. FL CHECK BUTTON CLASS REFERENCE 365

Parameters
in event The event to process.

Returns
1 if event was processed, 0 if not.

Reimplemented from Fl Browser .

int Fl Check Browser::nchecked ( ) const [inline]


Returns how many items are currently checked.

int Fl Check Browser::nitems ( ) const [inline]


Returns how many lines are in the browser.
The last line number is equal to this.

int Fl Check Browser::remove ( int item )


Remove line n and make the browser one line shorter.
Returns the number of lines left in the browser.

void Fl Check Browser::set checked ( int item ) [inline]


Equivalent to Fl Check Browser::checked(item, 1).

char ∗ Fl Check Browser::text ( int i ) const


Return a pointer to an internal buffer holding item item’s text.

int Fl Check Browser::value ( ) const


Returns the index of the currently selected item.
The documentation for this class was generated from the following files:

• Fl Check Browser.H
• Fl Check Browser.cxx

31.15 Fl Check Button Class Reference


A button with a ”checkmark” to show its status.
Inheritance diagram for Fl Check Button:

Fl_Widget

Fl_Button

Fl_Light_Button

Fl_Check_Button
366 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• Fl Check Button (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Check Button widget using the given position, size, and label string.

Additional Inherited Members


31.15.1 Detailed Description
A button with a ”checkmark” to show its status.

Figure 31.3: Fl Check Button

Buttons generate callbacks when they are clicked by the user. You control exactly when and how by
changing the values for type() and when().
The Fl Check Button subclass displays its ”ON” state by showing a ”checkmark” rather than drawing
itself pushed in.

31.15.2 Constructor & Destructor Documentation


Fl Check Button::Fl Check Button ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Check Button widget using the given position, size, and label string.
The default box type is FL NO BOX, which draws the label w/o a box right of the checkmark.
The selection color() sets the color of the checkmark. Default is FL FOREGROUND COLOR (usually
black).
You can use down box() to change the box type of the checkmark. Default is FL DOWN BOX.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label
The documentation for this class was generated from the following files:

• Fl Check Button.H
• Fl Check Button.cxx

31.16 Fl Choice Class Reference


A button that is used to pop up a menu.
#include <Fl Choice.H>
Inheritance diagram for Fl Choice:

Fl_Widget

Fl_Menu_

Fl_Choice
31.16. FL CHOICE CLASS REFERENCE 367

Public Member Functions


• Fl Choice (int X, int Y, int W, int H, const char ∗L=0)
Create a new Fl Choice widget using the given position, size and label string.
• int handle (int)
Handles the specified event.
• int value () const
Gets the index of the last item chosen by the user.
• int value (int v)
Sets the currently selected value using the index into the menu item array.
• int value (const Fl Menu Item ∗v)
Sets the currently selected value using a pointer to menu item.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.16.1 Detailed Description
A button that is used to pop up a menu.
This is a button that, when pushed, pops up a menu (or hierarchy of menus) defined by an array of
Fl Menu Item objects. Motif calls this an OptionButton.
The only difference between this and a Fl Menu Button is that the name of the most recent chosen menu
item is displayed inside the box, while the label is displayed outside the box. However, since the use of this
is most often to control a single variable rather than do individual callbacks, some of the Fl Menu Button
methods are redescribed here in those terms.
When the user picks an item off the menu the value() is set to that item and then the item’s callback
is done with the menu button as the Fl Widget∗ argument. If the item does not have a callback the
menu button’s callback is done instead.
All three mouse buttons pop up the menu. The Forms behavior of the first two buttons to incre-
ment/decrement the choice is not implemented. This could be added with a subclass, however.
The menu will also pop up in response to shortcuts indicated by putting a ’&’ character in the label().
See Fl Button::shortcut(int s) for a description of this.
Typing the shortcut() of any of the items will do exactly the same as when you pick the item with the
mouse. The ’&’ character in item names are only looked at when the menu is popped up, however.

Figure 31.4: Fl Choice


368 CHAPTER 31. CLASS DOCUMENTATION

Todo Refactor the doxygen comments for Fl Choice changed() documentation.

• int Fl Widget::changed() const This value is true the user picks a different value. It is
turned off by value() and just before doing a callback (the callback can turn it back on if desired).
• void Fl Widget::set changed() This method sets the changed() flag.

• void Fl Widget::clear changed() This method clears the changed() flag.


• Fl Boxtype Fl Choice::down box() const Gets the current down box, which is used
when the menu is popped up. The default down box type is FL DOWN BOX.
• void Fl Choice::down box(Fl Boxtype b) Sets the current down box type to b.

31.16.2 Constructor & Destructor Documentation


Fl Choice::Fl Choice ( int X, int Y, int W, int H, const char ∗ L = 0 )
Create a new Fl Choice widget using the given position, size and label string.
The default boxtype is FL UP BOX.
The constructor sets menu() to NULL. See Fl Menu for the methods to set or change the menu.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

31.16.3 Member Function Documentation


void Fl Choice::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Choice::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
31.17. FL CLOCK CLASS REFERENCE 369

in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.

int Fl Choice::value ( ) const [inline]

Gets the index of the last item chosen by the user.


The index is zero initially.

int Fl Choice::value ( int v )

Sets the currently selected value using the index into the menu item array.
Changing the selected value causes a redraw().
Parameters
in v index of value in the menu item array.

Returns
non-zero if the new value is different to the old one.

int Fl Choice::value ( const Fl Menu Item ∗ v )

Sets the currently selected value using a pointer to menu item.


Changing the selected value causes a redraw().
Parameters
in v pointer to menu item in the menu item array.

Returns
non-zero if the new value is different to the old one.

The documentation for this class was generated from the following files:

• Fl Choice.H
• Fl Choice.cxx

31.17 Fl Clock Class Reference


This widget provides a round analog clock display.
#include <Fl Clock.H>
Inheritance diagram for Fl Clock:
370 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Clock_Output

Fl_Clock

Fl_Round_Clock

Public Member Functions

• Fl Clock (int X, int Y, int W, int H, const char ∗L=0)

Create an Fl Clock widget using the given position, size, and label string.

• Fl Clock (uchar t, int X, int Y, int W, int H, const char ∗L)

Create an Fl Clock widget using the given boxtype, position, size, and label string.

• int handle (int)

Handles the specified event.

• ∼Fl Clock ()

The destructor removes the clock.

Additional Inherited Members

31.17.1 Detailed Description

This widget provides a round analog clock display.


Fl Clock is provided for Forms compatibility. It installs a 1-second timeout callback using Fl::add -
timeout(). You can choose the rounded or square type of the clock with type(), see below.

Figure 31.5: FL SQUARE CLOCK type


31.17. FL CLOCK CLASS REFERENCE 371

Figure 31.6: FL ROUND CLOCK type

31.17.2 Constructor & Destructor Documentation


Fl Clock::Fl Clock ( int X, int Y, int W, int H, const char ∗ L = 0 )
Create an Fl Clock widget using the given position, size, and label string.
The default boxtype is FL NO BOX.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

Fl Clock::Fl Clock ( uchar t, int X, int Y, int W, int H, const char ∗ L )


Create an Fl Clock widget using the given boxtype, position, size, and label string.
Parameters
in t boxtype
in X,Y,W,H position and size of the widget
in L widget label, default is no label

31.17.3 Member Function Documentation


int Fl Clock::handle ( int event ) [virtual]
Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
372 CHAPTER 31. CLASS DOCUMENTATION

1 if the event was used and can be deleted

See Also
Fl Event
Reimplemented from Fl Widget.
The documentation for this class was generated from the following files:
• Fl Clock.H
• Fl Clock.cxx

31.18 Fl Clock Output Class Reference


This widget can be used to display a program-supplied time.
#include <Fl Clock.H>
Inheritance diagram for Fl Clock Output:

Fl_Widget

Fl_Clock_Output

Fl_Clock

Fl_Round_Clock

Public Member Functions


• Fl Clock Output (int X, int Y, int W, int H, const char ∗L=0)
Create a new Fl Clock Output widget with the given position, size and label.
• int hour () const
Returns the displayed hour (0 to 23).
• int minute () const
Returns the displayed minute (0 to 59).
• int second () const
Returns the displayed second (0 to 60, 60=leap second).
• void value (ulong v)
Set the displayed time.
• void value (int H, int m, int s)
Set the displayed time.
• ulong value () const
Returns the displayed time.

Protected Member Functions


• void draw ()
Draw clock with current position and size.
• void draw (int X, int Y, int W, int H)
Draw clock with the given position and size.
31.18. FL CLOCK OUTPUT CLASS REFERENCE 373

Additional Inherited Members


31.18.1 Detailed Description
This widget can be used to display a program-supplied time.
The time shown on the clock is not updated. To display the current time, use Fl Clock instead.

Figure 31.7: FL SQUARE CLOCK type

Figure 31.8: FL ROUND CLOCK type

31.18.2 Constructor & Destructor Documentation


Fl Clock Output::Fl Clock Output ( int X, int Y, int W, int H, const char ∗ L = 0 )
Create a new Fl Clock Output widget with the given position, size and label.
The default boxtype is FL NO BOX.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

31.18.3 Member Function Documentation


void Fl Clock Output::draw ( int X, int Y, int W, int H ) [protected]
Draw clock with the given position and size.
374 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in X,Y,W,H position and size

int Fl Clock Output::hour ( ) const [inline]


Returns the displayed hour (0 to 23).

See Also
value(), minute(), second()

int Fl Clock Output::minute ( ) const [inline]


Returns the displayed minute (0 to 59).

See Also
value(), hour(), second()

int Fl Clock Output::second ( ) const [inline]


Returns the displayed second (0 to 60, 60=leap second).

See Also
value(), hour(), minute()

void Fl Clock Output::value ( ulong v )


Set the displayed time.
Set the time in seconds since the UNIX epoch (January 1, 1970).
Parameters
in v seconds since epoch

See Also
value()

void Fl Clock Output::value ( int H, int m, int s )


Set the displayed time.
Set the time in hours, minutes, and seconds.
Parameters
in H,m,s displayed time

See Also
hour(), minute(), second()
31.19. FL COLOR CHOOSER CLASS REFERENCE 375

ulong Fl Clock Output::value ( ) const [inline]


Returns the displayed time.
Returns the time in seconds since the UNIX epoch (January 1, 1970).
See Also
value(ulong)
The documentation for this class was generated from the following files:
• Fl Clock.H
• Fl Clock.cxx

31.19 Fl Color Chooser Class Reference


The Fl Color Chooser widget provides a standard RGB color chooser.
#include <Fl Color Chooser.H>
Inheritance diagram for Fl Color Chooser:

Fl_Widget

Fl_Group

Fl_Color_Chooser

Public Member Functions


• double b () const
Returns the current blue value.
• Fl Color Chooser (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Color Chooser widget using the given position, size, and label string.
• double g () const
Returns the current green value.
• int hsv (double H, double S, double V)
Set the hsv values.
• double hue () const
Returns the current hue.
• int mode ()
Returns which Fl Color Chooser variant is currently active.
• void mode (int newMode)
Set which Fl Color Chooser variant is currently active.
• double r () const
Returns the current red value.
• int rgb (double R, double G, double B)
Sets the current rgb color values.
• double saturation () const
Returns the saturation.
• double value () const
Returns the value/brightness.
376 CHAPTER 31. CLASS DOCUMENTATION

Static Public Member Functions


• static void hsv2rgb (double H, double S, double V, double &R, double &G, double &B)
This static method converts HSV colors to RGB colorspace.
• static void rgb2hsv (double R, double G, double B, double &H, double &S, double &V)
This static method converts RGB colors to HSV colorspace.

Related Functions
(Note that these are not member functions.)

• int fl color chooser (const char ∗name, double &r, double &g, double &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.
• int fl color chooser (const char ∗name, uchar &r, uchar &g, uchar &b, int cmode)
Pops up a window to let the user pick an arbitrary RGB color.

Additional Inherited Members


31.19.1 Detailed Description
The Fl Color Chooser widget provides a standard RGB color chooser.

Figure 31.9: fl color chooser()

You can place any number of the widgets into a panel of your own design. The diagram shows the
widget as part of a color chooser dialog created by the fl color chooser() function. The Fl Color Chooser
widget contains the hue box, value slider, and rgb input fields from the above diagram (it does not have the
color chips or the Cancel or OK buttons). The callback is done every time the user changes the rgb value. It
is not done if they move the hue control in a way that produces the same rgb value, such as when saturation
or value is zero.
The fl color chooser() function pops up a window to let the user pick an arbitrary RGB color. They can
pick the hue and saturation in the ”hue box” on the left (hold down CTRL to just change the saturation),
and the brightness using the vertical slider. Or they can type the 8-bit numbers into the RGB Fl Value Input
fields, or drag the mouse across them to adjust them. The pull-down menu lets the user set the input fields
to show RGB, HSV, or 8-bit RGB (0 to 255).
fl color chooser() returns non-zero if the user picks ok, and updates the RGB values. If the user picks
cancel or closes the window this returns zero and leaves RGB unchanged.
If you use the color chooser on an 8-bit screen, it will allocate all the available colors, leaving you no
space to exactly represent the color the user picks! You can however use fl rectf() to fill a region with a
simulated color using dithering.
31.19. FL COLOR CHOOSER CLASS REFERENCE 377

31.19.2 Constructor & Destructor Documentation


Fl Color Chooser::Fl Color Chooser ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Color Chooser widget using the given position, size, and label string.
The recommended dimensions are 200x95. The color is initialized to black.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

31.19.3 Member Function Documentation


double Fl Color Chooser::b ( ) const [inline]
Returns the current blue value.
0 <= b <= 1.

double Fl Color Chooser::g ( ) const [inline]


Returns the current green value.
0 <= g <= 1.

int Fl Color Chooser::hsv ( double H, double S, double V )


Set the hsv values.
The passed values are clamped (or for hue, modulus 6 is used) to get legal values. Does not do the
callback.
Parameters
in H,S,V color components.

Returns
1 if a new hsv value was set, 0 if the hsv value was the previous one.

void Fl Color Chooser::hsv2rgb ( double H, double S, double V, double & R, double & G, double
& B ) [static]
This static method converts HSV colors to RGB colorspace.
Parameters
in H,S,V color components
out R,G,B color components

double Fl Color Chooser::hue ( ) const [inline]


Returns the current hue.
0 <= hue < 6. Zero is red, one is yellow, two is green, etc. This value is convenient for the internal
calculations - some other systems consider hue to run from zero to one, or from 0 to 360.

int Fl Color Chooser::mode ( ) [inline]


Returns which Fl Color Chooser variant is currently active.
378 CHAPTER 31. CLASS DOCUMENTATION

Returns
color modes are rgb(0), byte(1), hex(2), or hsv(3)

void Fl Color Chooser::mode ( int newMode )

Set which Fl Color Chooser variant is currently active.


Parameters
in newMode color modes are rgb(0), byte(1), hex(2), or hsv(3)

double Fl Color Chooser::r ( ) const [inline]

Returns the current red value.


0 <= r <= 1.

int Fl Color Chooser::rgb ( double R, double G, double B )

Sets the current rgb color values.


Does not do the callback. Does not clamp (but out of range values will produce psychedelic effects in
the hue selector).
Parameters
in R,G,B color components.

Returns
1 if a new rgb value was set, 0 if the rgb value was the previous one.

void Fl Color Chooser::rgb2hsv ( double R, double G, double B, double & H, double & S, double
& V ) [static]

This static method converts RGB colors to HSV colorspace.


Parameters
in R,G,B color components
out H,S,V color components

double Fl Color Chooser::saturation ( ) const [inline]

Returns the saturation.


0 <= saturation <= 1.

double Fl Color Chooser::value ( ) const [inline]

Returns the value/brightness.


0 <= value <= 1.
The documentation for this class was generated from the following files:

• Fl Color Chooser.H
• Fl Color Chooser.cxx
31.20. FL COPY SURFACE CLASS REFERENCE 379

31.20 Fl Copy Surface Class Reference


Supports copying of graphical data to the clipboard.
#include <Fl Copy Surface.H>
Inheritance diagram for Fl Copy Surface:

Fl_Device

Fl_Surface_Device

Fl_Copy_Surface

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void draw (Fl Widget ∗widget, int delta x=0, int delta y=0)
Copies a widget in the clipboard.
• Fl Copy Surface (int w, int h)
Constructor.
• void set current ()
Use this drawing surface for future graphics requests.
• ∼Fl Copy Surface ()
Destructor.

Static Public Attributes


• static const char ∗ class id = ”Fl Copy Surface”

Additional Inherited Members


31.20.1 Detailed Description
Supports copying of graphical data to the clipboard.
After creation of an Fl Copy Surface object, call set current() on it, and all subsequent graphics re-
quests will be recorded in the clipboard. It’s possible to draw widgets (using Fl Copy Surface::draw() ) or
to use any of the Drawing functions or the Color & Font functions. Finally, delete the Fl Copy Surface
object to load the clipboard with the graphical data.
Fl GL Window ’s can be copied to the clipboard as well.
Usage example:
Fl Widget *g = ...; // a widget you want to copy to the clipboard
Fl Copy Surface *copy surf = new Fl Copy Surface(g->
w(), g->h()); // create an Fl Copy Surface object
copy surf->set current(); // direct graphics requests to the clipboard
fl color(FL WHITE); fl rectf(0, 0, g->w(), g->h()); // draw a white background
copy surf->draw(g); // draw the g widget in the clipboard
delete copy surf; // after this, the clipboard is loaded
Fl Display Device::display device()->
set current(); // direct graphics requests back to the display

Platform details:
380 CHAPTER 31. CLASS DOCUMENTATION

• MSWindows: Transparent RGB images copy without transparency. The graphical data is copied to
the clipboard as an ’enhanced metafile’.

• Mac OS: The graphical data is copied to the clipboard (a.k.a. pasteboard) in 2 ’flavors’: 1) in vectorial
form as PDF data; 2) in bitmap form as a TIFF image (or PICT for Mac OS 10.3). Applications to
which the clipboard content is pasted can use the flavor that suits them best.

• X11: the graphical data is copied to the clipboard as an image in BMP format.

31.20.2 Constructor & Destructor Documentation


Fl Copy Surface::Fl Copy Surface ( int w, int h )
Constructor.
Parameters
w and
h are the width and height of the clipboard surface in pixels where drawing will occur.

31.20.3 Member Function Documentation


const char∗ Fl Copy Surface::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Device.

void Fl Copy Surface::draw ( Fl Widget ∗ widget, int delta x = 0, int delta y = 0 )


Copies a widget in the clipboard.
Parameters
widget any FLTK widget (e.g., standard, custom, window, GL view) to copy
delta x and
delta y give the position in the clipboard of the top-left corner of the widget

void Fl Copy Surface::set current ( void ) [virtual]


Use this drawing surface for future graphics requests.
Reimplemented from Fl Surface Device.
The documentation for this class was generated from the following files:

• Fl Copy Surface.H
• Fl Copy Surface.cxx

31.21 Fl Counter Class Reference


Controls a single floating point value with button (or keyboard) arrows.
#include <Fl Counter.H>
Inheritance diagram for Fl Counter:
31.21. FL COUNTER CLASS REFERENCE 381

Fl_Widget

Fl_Valuator

Fl_Counter

Fl_Simple_Counter

Public Member Functions


• Fl Counter (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Counter widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
• void lstep (double a)
Sets the increment for the large step buttons.
• void step (double a, double b)
Sets the increments for the normal and large step buttons.
• void step (double a)
Sets the increment for the normal step buttons.
• double step () const
Returns the increment for normal step buttons.
• Fl Color textcolor () const
Gets the font color.
• void textcolor (Fl Color s)
Sets the font color to s.
• Fl Font textfont () const
Gets the text font.
• void textfont (Fl Font s)
Sets the text font to s.
• Fl Fontsize textsize () const
Gets the font size.
• void textsize (Fl Fontsize s)
Sets the font size to s.
• ∼Fl Counter ()
Destroys the valuator.

Protected Member Functions


• void draw ()
Draws the widget.
382 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.21.1 Detailed Description
Controls a single floating point value with button (or keyboard) arrows.
Double arrows buttons achieve larger steps than simple arrows.

See Also
Fl Spinner for value input with vertical step arrows.

Figure 31.10: Fl Counter

Todo Refactor the doxygen comments for Fl Counter type() documentation.

The type of an Fl Counter object can be set using type(uchar t) to:

• FL NORMAL COUNTER: Displays a counter with 4 arrow buttons.

• FL SIMPLE COUNTER: Displays a counter with only 2 arrow buttons.

31.21.2 Constructor & Destructor Documentation


Fl Counter::Fl Counter ( int X, int Y, int W, int H, const char ∗ L = 0 )

Creates a new Fl Counter widget using the given position, size, and label string.
The default type is FL NORMAL COUNTER.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

31.21.3 Member Function Documentation


void Fl Counter::draw ( ) [protected], [virtual]

Draws the widget.


Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:

Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar


s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.
31.22. FL DEVICE CLASS REFERENCE 383

int Fl Counter::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.

void Fl Counter::lstep ( double a ) [inline]


Sets the increment for the large step buttons.
The default value is 1.0.
Parameters
in a large step increment.

void Fl Counter::step ( double a, double b ) [inline]


Sets the increments for the normal and large step buttons.
Parameters
in a,b normal and large step increments.

void Fl Counter::step ( double a ) [inline]


Sets the increment for the normal step buttons.
Parameters
in a normal step increment.
The documentation for this class was generated from the following files:

• Fl Counter.H
• Fl Counter.cxx

31.22 Fl Device Class Reference


All graphical output devices and all graphics systems.
#include <Fl Device.H>
Inheritance diagram for Fl Device:
384 CHAPTER 31. CLASS DOCUMENTATION

Fl_Device

Fl_Graphics_Driver Fl_Surface_Device

Fl_GDI_Graphics_Driver Fl_Copy_Surface

Fl_PostScript_Graphics_Driver Fl_Display_Device

Fl_Quartz_Graphics_Driver Fl_Image_Surface

Fl_Xlib_Graphics_Driver Fl_Paged_Device

Public Member Functions


• virtual const char ∗ class name ()
Returns the name of the class of this object.
• virtual ∼Fl Device ()
Virtual destructor.

Static Public Attributes


• static const char ∗ class id = ”Fl Device”
A string that identifies each subclass of Fl Device.

31.22.1 Detailed Description


All graphical output devices and all graphics systems.

31.22.2 Constructor & Destructor Documentation


virtual Fl Device::∼Fl Device ( ) [inline], [virtual]

Virtual destructor.
The destructor of Fl Device must be virtual to make the destructors of derived classes being called
correctly on destruction.

31.22.3 Member Function Documentation


virtual const char∗ Fl Device::class name ( ) [inline], [virtual]

Returns the name of the class of this object.


Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:

if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented in Fl Display Device, Fl Surface Device, Fl Xlib Graphics Driver, Fl GDI Printer -
Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, Fl Graphics Driver, Fl PostScript-
File Device, Fl Printer, Fl Paged Device, Fl PostScript Printer, Fl Copy Surface, Fl System Printer, Fl-
Image Surface, and Fl PostScript Graphics Driver.
31.23. FL DEVICE PLUGIN CLASS REFERENCE 385

31.22.4 Member Data Documentation


const char ∗ Fl Device::class id = ”Fl Device” [static]
A string that identifies each subclass of Fl Device.
Function class name() applied to a device of this class returns this string.
The documentation for this class was generated from the following files:
• Fl Device.H
• Fl Device.cxx

31.23 Fl Device Plugin Class Reference


This plugin socket allows the integration of new device drivers for special window or screen types.
#include <Fl Device.H>
Inheritance diagram for Fl Device Plugin:

Fl_Plugin

Fl_Device_Plugin

Public Member Functions


• Fl Device Plugin (const char ∗pluginName)
The constructor.
• virtual const char ∗ klass ()
Returns the class name.
• virtual const char ∗ name ()=0
Returns the plugin name.
• virtual int print (Fl Widget ∗w, int x, int y, int height)=0
Prints a widget.

31.23.1 Detailed Description


This plugin socket allows the integration of new device drivers for special window or screen types.
It is currently used to provide an automated printing service for OpenGL windows, if linked with fltk gl.

31.23.2 Member Function Documentation


virtual int Fl Device Plugin::print ( Fl Widget ∗ w, int x, int y, int height ) [pure virtual]
Prints a widget.
Parameters
w the widget
x,y offsets where to print relatively to coordinates origin
386 CHAPTER 31. CLASS DOCUMENTATION

height height of the current drawing area


The documentation for this class was generated from the following file:

• Fl Device.H

31.24 Fl Dial Class Reference


The Fl Dial widget provides a circular dial to control a single floating point value.
#include <Fl Dial.H>
Inheritance diagram for Fl Dial:

Fl_Widget

Fl_Valuator

Fl_Dial

Fl_Fill_Dial Fl_Line_Dial

Public Member Functions


• short angle1 () const
Sets Or gets the angles used for the minimum and maximum values.
• void angle1 (short a)
See short angle1() const.
• short angle2 () const
See short angle1() const.
• void angle2 (short a)
See short angle1() const.
• void angles (short a, short b)
See short angle1() const.
• Fl Dial (int x, int y, int w, int h, const char ∗l=0)
Creates a new Fl Dial widget using the given position, size, and label string.
• int handle (int)
Allow subclasses to handle event based on current position and size.

Protected Member Functions


• void draw (int X, int Y, int W, int H)
Draws dial at given position and size.
• void draw ()
Draws dial at current position and size.
• int handle (int event, int X, int Y, int W, int H)
Allows subclasses to handle event based on given position and size.
31.24. FL DIAL CLASS REFERENCE 387

Additional Inherited Members


31.24.1 Detailed Description
The Fl Dial widget provides a circular dial to control a single floating point value.

Figure 31.11: Fl Dial

Use type() to set the type of the dial to:

• FL NORMAL DIAL - Draws a normal dial with a knob.

• FL LINE DIAL - Draws a dial with a line.

• FL FILL DIAL - Draws a dial with a filled arc.

31.24.2 Constructor & Destructor Documentation


Fl Dial::Fl Dial ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Dial widget using the given position, size, and label string.
The default type is FL NORMAL DIAL.

31.24.3 Member Function Documentation


short Fl Dial::angle1 ( ) const [inline]
Sets Or gets the angles used for the minimum and maximum values.
The default values are 45 and 315 (0 degrees is straight down and the angles progress clockwise).
Normally angle1 is less than angle2, but if you reverse them the dial moves counter-clockwise.

void Fl Dial::draw ( int X, int Y, int W, int H ) [protected]


Draws dial at given position and size.
Parameters
in X,Y,W,H position and size

int Fl Dial::handle ( int event, int X, int Y, int W, int H ) [protected]


Allows subclasses to handle event based on given position and size.
Parameters
in event,X,Y,W,H event to handle, related position and size.
The documentation for this class was generated from the following files:

• Fl Dial.H
• Fl Dial.cxx
388 CHAPTER 31. CLASS DOCUMENTATION

31.25 Fl Display Device Class Reference


A display to which the computer can draw.
#include <Fl Device.H>
Inheritance diagram for Fl Display Device:

Fl_Device

Fl_Surface_Device

Fl_Display_Device

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• Fl Display Device (Fl Graphics Driver ∗graphics driver)
A constructor that sets the graphics driver used by the display.

Static Public Member Functions


• static Fl Display Device ∗ display device ()
Returns the platform display device.

Static Public Attributes


• static const char ∗ class id = ”Fl Display Device”

Additional Inherited Members


31.25.1 Detailed Description
A display to which the computer can draw.

31.25.2 Member Function Documentation


const char∗ Fl Display Device::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Surface Device.

static Fl Display Device∗ Fl Display Device::display device ( ) [inline], [static]


Returns the platform display device.
The documentation for this class was generated from the following files:
• Fl Device.H
• Fl Device.cxx
31.26. FL DOUBLE WINDOW CLASS REFERENCE 389

31.26 Fl Double Window Class Reference


The Fl Double Window provides a double-buffered window.
#include <Fl Double Window.H>
Inheritance diagram for Fl Double Window:

Fl_Widget

Fl_Group

Fl_Window

Fl_Double_Window

Fl_Cairo_Window Fl_Overlay_Window

Public Member Functions


• Fl Double Window (int W, int H, const char ∗l=0)
Creates a new Fl Double Window widget using the given position, size, and label (title) string.
• Fl Double Window (int X, int Y, int W, int H, const char ∗l=0)
See Fl Double Window::Fl Double Window(int w, int h, const char ∗label = 0)
• void flush ()
Forces the window to be redrawn.
• void hide ()
Removes the window from the screen.
• void resize (int, int, int, int)
Changes the size and position of the window.
• void show ()
Puts the window on the screen.
• void show (int a, char ∗∗b)
• ∼Fl Double Window ()
The destructor also deletes all the children.

Protected Member Functions


• void flush (int eraseoverlay)
Forces the window to be redrawn.

Protected Attributes
• char force doublebuffering
Force double buffering, even if the OS already buffers windows (overlays need that on MacOS and Win-
dows2000)
390 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.26.1 Detailed Description
The Fl Double Window provides a double-buffered window.
If possible this will use the X double buffering extension (Xdbe). If not, it will draw the window data
into an off-screen pixmap, and then copy it to the on-screen window.
It is highly recommended that you put the following code before the first show() of any window in your
program:

Fl::visual(FL DOUBLE|FL INDEX)

This makes sure you can use Xdbe on servers where double buffering does not exist for every visual.

31.26.2 Constructor & Destructor Documentation


Fl Double Window::∼Fl Double Window ( )

The destructor also deletes all the children.


This allows a whole tree to be deleted at once, without having to keep a pointer to all the children in
the user code.

31.26.3 Member Function Documentation


void Fl Double Window::flush ( int eraseoverlay ) [protected]

Forces the window to be redrawn.


Parameters
in eraseoverlay non-zero to erase overlay, zero to ignore
Fl Overlay Window relies on flush(1) copying the back buffer to the front everywhere, even if damage()
== 0, thus erasing the overlay, and leaving the clip region set to the entire window.

void Fl Double Window::hide ( ) [virtual]

Removes the window from the screen.


If the window is already hidden or has not been shown then this does nothing and is harmless.
Reimplemented from Fl Window.
Reimplemented in Fl Overlay Window.

void Fl Double Window::resize ( int X, int Y, int W, int H ) [virtual]

Changes the size and position of the window.


If shown() is true, these changes are communicated to the window server (which may refuse that size
and cause a further resize). If shown() is false, the size and position are used when show() is called. See
Fl Group for the effect of resizing on the child widgets.
You can also call the Fl Widget methods size(x,y) and position(w,h), which are inline wrappers for this
virtual function.
A top-level window can not force, but merely suggest a position and size to the operating system. The
window manager may not be willing or able to display a window at the desired position or with the given
dimensions. It is up to the application developer to verify window parameters after the resize request.
Reimplemented from Fl Window.
Reimplemented in Fl Overlay Window.
31.27. FL END CLASS REFERENCE 391

void Fl Double Window::show ( ) [virtual]


Puts the window on the screen.
Usually (on X) this has the side effect of opening the display.
If the window is already shown then it is restored and raised to the top. This is really convenient
because your program can call show() at any time, even if the window is already up. It also means that
show() serves the purpose of raise() in other toolkits.
Fl Window::show(int argc, char ∗∗argv) is used for top-level windows and allows standard arguments
to be parsed from the command-line.

See Also
Fl Window::show(int argc, char ∗∗argv)

Reimplemented from Fl Window.


Reimplemented in Fl Overlay Window.
The documentation for this class was generated from the following files:

• Fl Double Window.H
• Fl Double Window.cxx

31.27 Fl End Class Reference


This is a dummy class that allows you to end a Fl Group in a constructor list of a class:
#include <Fl Group.H>

Public Member Functions


• Fl End ()
All it does is calling Fl Group::current()->end()

31.27.1 Detailed Description


This is a dummy class that allows you to end a Fl Group in a constructor list of a class:
class MyClass {
Fl Group group;
Fl Button button in group;
Fl End end;
Fl Button button outside group;
MyClass();
};
MyClass::MyClass() :
group(10,10,100,100),
button in group(20,20,60,30),
end(),
button outside group(10,120,60,30)
{}

The documentation for this class was generated from the following file:

• Fl Group.H

31.28 Fl File Browser Class Reference


The Fl File Browser widget displays a list of filenames, optionally with file-specific icons.
#include <Fl File Browser.H>
Inheritance diagram for Fl File Browser:
392 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Group

Fl_Browser_

Fl_Browser

Fl_File_Browser

Public Types
• enum { FILES, DIRECTORIES }

Public Member Functions


• int filetype () const
Sets or gets the file browser type, FILES or DIRECTORIES.
• void filetype (int t)
Sets or gets the file browser type, FILES or DIRECTORIES.
• void filter (const char ∗pattern)
Sets or gets the filename filter.
• const char ∗ filter () const
Sets or gets the filename filter.
• Fl File Browser (int, int, int, int, const char ∗=0)
The constructor creates the Fl File Browser widget at the specified position and size.
• uchar iconsize () const
Sets or gets the size of the icons.
• void iconsize (uchar s)
Sets or gets the size of the icons.
• int load (const char ∗directory, Fl File Sort F ∗sort=fl numericsort)
Loads the specified directory into the browser.
• Fl Fontsize textsize () const
• void textsize (Fl Fontsize s)

Additional Inherited Members


31.28.1 Detailed Description
The Fl File Browser widget displays a list of filenames, optionally with file-specific icons.

31.28.2 Constructor & Destructor Documentation


Fl File Browser::Fl File Browser ( int X, int Y, int W, int H, const char ∗ l = 0 )
The constructor creates the Fl File Browser widget at the specified position and size.
The destructor destroys the widget and frees all memory that has been allocated.
31.29. FL FILE CHOOSER CLASS REFERENCE 393

31.28.3 Member Function Documentation


int Fl File Browser::filetype ( ) const [inline]

Sets or gets the file browser type, FILES or DIRECTORIES.


When set to FILES, both files and directories are shown. Otherwise only directories are shown.

void Fl File Browser::filetype ( int t ) [inline]

Sets or gets the file browser type, FILES or DIRECTORIES.


When set to FILES, both files and directories are shown. Otherwise only directories are shown.

void Fl File Browser::filter ( const char ∗ pattern )

Sets or gets the filename filter.


The pattern matching uses the fl filename match() function in FLTK.

const char∗ Fl File Browser::filter ( ) const [inline]

Sets or gets the filename filter.


The pattern matching uses the fl filename match() function in FLTK.

uchar Fl File Browser::iconsize ( ) const [inline]

Sets or gets the size of the icons.


The default size is 20 pixels.

void Fl File Browser::iconsize ( uchar s ) [inline]

Sets or gets the size of the icons.


The default size is 20 pixels.

int Fl File Browser::load ( const char ∗ directory, Fl File Sort F ∗ sort = fl numericsort )

Loads the specified directory into the browser.


If icons have been loaded then the correct icon is associated with each file in the list.
The sort argument specifies a sort function to be used with fl filename list().
The documentation for this class was generated from the following files:

• Fl File Browser.H
• Fl File Browser.cxx

31.29 Fl File Chooser Class Reference


The Fl File Chooser widget displays a standard file selection dialog that supports various selection modes.

Public Types
• enum { SINGLE = 0, MULTI = 1, CREATE = 2, DIRECTORY = 4 }
394 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• Fl Widget ∗ add extra (Fl Widget ∗gr)
Adds extra widget at the bottom of Fl File Chooser window.
• void callback (void(∗cb)(Fl File Chooser ∗, void ∗), void ∗d=0)
Sets the file chooser callback cb and associated data d.
• void color (Fl Color c)
Sets the background color of the Fl File Browser list.
• Fl Color color ()
Gets the background color of the Fl File Browser list.
• int count ()
Returns the number of selected files.
• void directory (const char ∗d)
Sets the current directory.
• char ∗ directory ()
Gets the current directory.
• void filter (const char ∗p)
Sets or gets the current filename filter patterns.
• const char ∗ filter ()
See void filter(const char ∗pattern)
• int filter value ()
Gets the current filename filter selection.
• void filter value (int f)
Sets the current filename filter selection.
• Fl File Chooser (const char ∗d, const char ∗p, int t, const char ∗title)
The constructor creates the Fl File Chooser dialog shown.
• void hide ()
Hides the Fl File Chooser window.
• void iconsize (uchar s)
Sets the size of the icons in the Fl File Browser.
• uchar iconsize ()
Gets the size of the icons in the Fl File Browser.
• void label (const char ∗l)
Sets the title bar text for the Fl File Chooser.
• const char ∗ label ()
Gets the title bar text for the Fl File Chooser.
• void ok label (const char ∗l)
Sets the label for the ”ok” button in the Fl File Chooser.
• const char ∗ ok label ()
Gets the label for the ”ok” button in the Fl File Chooser.
• void preview (int e)
Enable or disable the preview tile.
• int preview () const
Returns the current state of the preview box.
• void rescan ()
Reloads the current directory in the Fl File Browser.
• void rescan keep filename ()
31.29. FL FILE CHOOSER CLASS REFERENCE 395

Rescan the current directory without clearing the filename, then select the file if it is in the list.
• void show ()
Shows the Fl File Chooser window.
• int shown ()
Returns non-zero if the file chooser main window show() has been called (but not hide() see Fl Window-
::shown()
• void textcolor (Fl Color c)
Sets the current Fl File Browser text color.
• Fl Color textcolor ()
Gets the current Fl File Browser text color.
• void textfont (Fl Font f)
Sets the current Fl File Browser text font.
• Fl Font textfont ()
Gets the current Fl File Browser text font.
• void textsize (Fl Fontsize s)
Sets the current Fl File Browser text size.
• Fl Fontsize textsize ()
Gets the current Fl File Browser text size.
• void type (int t)
Sets the current type of Fl File Chooser.
• int type ()
Gets the current type of Fl File Chooser.
• void ∗ user data () const
Gets the file chooser user data.
• void user data (void ∗d)
Sets the file chooser user data d.
• const char ∗ value (int f=1)
Gets the current value of the selected file(s).
• void value (const char ∗filename)
Sets the current value of the selected file.
• int visible ()
Returns 1 if the Fl File Chooser window is visible.
• ∼Fl File Chooser ()
Destroys the widget and frees all memory used by it.

Public Attributes
• Fl Button ∗ newButton
The ”new directory” button is exported so that application developers can control the appearance and use.
• Fl Check Button ∗ previewButton
The ”preview” button is exported so that application developers can control the appearance and use.
• Fl Check Button ∗ showHiddenButton
When checked, hidden files (i.e., filename begins with dot) are displayed.
396 CHAPTER 31. CLASS DOCUMENTATION

Static Public Attributes


• static const char ∗ add favorites label = ”Add to Favorites”
[standard text may be customized at run-time]
• static const char ∗ all files label = ”All Files (∗)”
[standard text may be customized at run-time]
• static const char ∗ custom filter label = ”Custom Filter”
[standard text may be customized at run-time]
• static const char ∗ existing file label = ”Please choose an existing file!”
[standard text may be customized at run-time]
• static const char ∗ favorites label = ”Favorites”
[standard text may be customized at run-time]
• static const char ∗ filename label = ”Filename:”
[standard text may be customized at run-time]
• static const char ∗ filesystems label = ”File Systems”
[standard text may be customized at run-time]
• static const char ∗ hidden label = ”Show hidden files”
[standard text may be customized at run-time]
• static const char ∗ manage favorites label = ”Manage Favorites”
[standard text may be customized at run-time]
• static const char ∗ new directory label = ”New Directory?”
[standard text may be customized at run-time]
• static const char ∗ new directory tooltip = ”Create a new directory.”
[standard text may be customized at run-time]
• static const char ∗ preview label = ”Preview”
[standard text may be customized at run-time]
• static const char ∗ save label = ”Save”
[standard text may be customized at run-time]
• static const char ∗ show label = ”Show:”
[standard text may be customized at run-time]
• static Fl File Sort F ∗ sort = fl numericsort
the sort function that is used when loading the contents of a directory.

Related Functions
(Note that these are not member functions.)

• char ∗ fl dir chooser (const char ∗message, const char ∗fname, int relative)
Shows a file chooser dialog and gets a directory.
• char ∗ fl file chooser (const char ∗message, const char ∗pat, const char ∗fname, int relative)
Shows a file chooser dialog and gets a filename.
• void fl file chooser callback (void(∗cb)(const char ∗))
Set the file chooser callback.
• void fl file chooser ok label (const char ∗l)
Set the ”OK” button label.
31.29. FL FILE CHOOSER CLASS REFERENCE 397

31.29.1 Detailed Description


The Fl File Chooser widget displays a standard file selection dialog that supports various selection modes.

Figure 31.12: Fl File Chooser

The Fl File Chooser widget transmits UTF-8 encoded filenames to its user. It is recommended to open
files that may have non-ASCII names with the fl fopen() or fl open() utility functions that handle these
names in a cross-platform way (whereas the standard fopen()/open() functions fail on the MSWindows
platform to open files with a non-ASCII name).
The Fl File Chooser class also exports several static values that may be used to localize or customize
the appearance of all file chooser dialogs:

Member Default value


add favorites label ”Add to Favorites”
all files label ”All Files (∗)”
custom filter label ”Custom Filter”
existing file label ”Please choose an existing file!”
favorites label ”Favorites”
filename label ”Filename:”
filesystems label ”My Computer” (WIN32)
”File Systems” (all others)
hidden label ”Show hidden files:”
manage favorites label ”Manage Favorites”
new directory label ”New Directory?”
398 CHAPTER 31. CLASS DOCUMENTATION

new directory tooltip ”Create a new directory.”


preview label ”Preview”
save label ”Save”
show label ”Show:”
sort fl numericsort

The Fl File Chooser::sort member specifies the sort function that is used when loading the contents of
a directory and can be customized at run-time.
The Fl File Chooser class also exports the Fl File Chooser::newButton and Fl File Chooser::preview-
Button widgets so that application developers can control their appearance and use. For more complex
customization, consider copying the FLTK file chooser code and changing it accordingly.

31.29.2 Constructor & Destructor Documentation


Fl File Chooser::Fl File Chooser ( const char ∗ pathname, const char ∗ pattern, int type, const
char ∗ title )
The constructor creates the Fl File Chooser dialog shown.
The pathname argument can be a directory name or a complete file name (in which case the corre-
sponding file is highlighted in the list and in the filename input field.)
The pattern argument can be a NULL string or ”∗” to list all files, or it can be a series of descriptions
and filter strings separated by tab characters (\t). The format of filters is either ”Description text (patterns)”
or just ”patterns”. A file chooser that provides filters for HTML and image files might look like:
"HTML Files (*.html)\tImage Files (*.{bmp,gif,jpg,png})"

The file chooser will automatically add the ”All Files (∗)” pattern to the end of the string you pass if
you do not provide one. The first filter in the string is the default filter.
See the FLTK documentation on fl filename match() for the kinds of pattern strings that are supported.
The type argument can be one of the following:

• SINGLE - allows the user to select a single, existing file.

• MULTI - allows the user to select one or more existing files.

• CREATE - allows the user to select a single, existing file or specify a new filename.

• DIRECTORY - allows the user to select a single, existing directory.

The title argument is used to set the title bar text for the Fl File Chooser window.

Fl File Chooser::∼Fl File Chooser ( )


Destroys the widget and frees all memory used by it.

31.29.3 Member Function Documentation


Fl Widget ∗ Fl File Chooser::add extra ( Fl Widget ∗ gr )
Adds extra widget at the bottom of Fl File Chooser window.
Returns pointer for previous extra widget or NULL if not set previously. If argument is NULL only
remove previous extra widget.

Note
Fl File Chooser does not delete extra widget in destructor! To prevent memory leakage, don’t forget
to delete unused extra widgets
31.29. FL FILE CHOOSER CLASS REFERENCE 399

void Fl File Chooser::color ( Fl Color c )


Sets the background color of the Fl File Browser list.

Fl Color Fl File Chooser::color ( )


Gets the background color of the Fl File Browser list.

int Fl File Chooser::count ( )


Returns the number of selected files.

void Fl File Chooser::directory ( const char ∗ pathname )


Sets the current directory.

const char ∗ Fl File Chooser::directory ( )


Gets the current directory.

void Fl File Chooser::filter ( const char ∗ pattern )


Sets or gets the current filename filter patterns.
The filter patterns use fl filename match(). Multiple patterns can be used by separating them with
tabs, like "∗.jpg\t∗.png\t∗.gif\t∗". In addition, you can provide human-readable labels with the
patterns inside parenthesis, like "JPEG Files (∗.jpg)\tPNG Files (∗.png)\tGIF Files
(∗.gif)\tAll Files (∗)" .
Use filter(NULL) to show all files.

int Fl File Chooser::filter value ( )


Gets the current filename filter selection.

void Fl File Chooser::filter value ( int f )


Sets the current filename filter selection.

void Fl File Chooser::hide ( )


Hides the Fl File Chooser window.

void Fl File Chooser::iconsize ( uchar s )


Sets the size of the icons in the Fl File Browser.
By default the icon size is set to 1.5 times the textsize().

uchar Fl File Chooser::iconsize ( )


Gets the size of the icons in the Fl File Browser.
By default the icon size is set to 1.5 times the textsize().

void Fl File Chooser::label ( const char ∗ l )


Sets the title bar text for the Fl File Chooser.
400 CHAPTER 31. CLASS DOCUMENTATION

const char ∗ Fl File Chooser::label ( )

Gets the title bar text for the Fl File Chooser.

void Fl File Chooser::preview ( int e )

Enable or disable the preview tile.


1 = enable preview, 0 = disable preview.

int Fl File Chooser::preview ( ) const [inline]

Returns the current state of the preview box.

void Fl File Chooser::rescan ( )

Reloads the current directory in the Fl File Browser.

void Fl File Chooser::show ( )

Shows the Fl File Chooser window.

void Fl File Chooser::textcolor ( Fl Color c )

Sets the current Fl File Browser text color.

Fl Color Fl File Chooser::textcolor ( )

Gets the current Fl File Browser text color.

void Fl File Chooser::textfont ( Fl Font f )

Sets the current Fl File Browser text font.

Fl Font Fl File Chooser::textfont ( )

Gets the current Fl File Browser text font.

void Fl File Chooser::textsize ( Fl Fontsize s )

Sets the current Fl File Browser text size.

Fl Fontsize Fl File Chooser::textsize ( )

Gets the current Fl File Browser text size.

void Fl File Chooser::type ( int t )

Sets the current type of Fl File Chooser.

int Fl File Chooser::type ( )

Gets the current type of Fl File Chooser.


31.30. FL FILE ICON CLASS REFERENCE 401

const char ∗ Fl File Chooser::value ( int f = 1 )


Gets the current value of the selected file(s).
f is a 1-based index into a list of file names. The number of selected files is returned by Fl File -
Chooser::count().
This sample code loops through all selected files:
// Get list of filenames user selected from a MULTI chooser
for ( int t=1; t<=chooser->count(); t++ ) {
const char *filename = chooser->value(t);
...
}

int Fl File Chooser::visible ( )


Returns 1 if the Fl File Chooser window is visible.

31.29.4 Member Data Documentation


Fl File Chooser::showHiddenButton
When checked, hidden files (i.e., filename begins with dot) are displayed.
The ”showHiddenButton” button is exported so that application developers can control its appearance.
The documentation for this class was generated from the following files:

• Fl File Chooser.H
• Fl File Chooser.cxx
• Fl File Chooser2.cxx
• fl file dir.cxx

31.30 Fl File Icon Class Reference


The Fl File Icon class manages icon images that can be used as labels in other widgets and as icons in the
FileBrowser widget.
#include <Fl File Icon.H>

Public Types
• enum {
ANY, PLAIN, FIFO, DEVICE,
LINK, DIRECTORY }
• enum {
END, COLOR, LINE, CLOSEDLINE,
POLYGON, OUTLINEPOLYGON, VERTEX }

Public Member Functions


• short ∗ add (short d)
Adds a keyword value to the icon array, returning a pointer to it.
• short ∗ add color (Fl Color c)
Adds a color value to the icon array, returning a pointer to it.
• short ∗ add vertex (int x, int y)
Adds a vertex value to the icon array, returning a pointer to it.
• short ∗ add vertex (float x, float y)
402 CHAPTER 31. CLASS DOCUMENTATION

Adds a vertex value to the icon array, returning a pointer to it.


• void clear ()
Clears all icon data from the icon.
• void draw (int x, int y, int w, int h, Fl Color ic, int active=1)
Draws an icon in the indicated area.
• Fl File Icon (const char ∗p, int t, int nd=0, short ∗d=0)
Creates a new Fl File Icon with the specified information.
• void label (Fl Widget ∗w)
Applies the icon to the widget, registering the Fl File Icon label type as needed.
• void load (const char ∗f)
Loads the specified icon image.
• int load fti (const char ∗fti)
Loads an SGI icon file.
• int load image (const char ∗i)
Load an image icon file from an image filename.
• Fl File Icon ∗ next ()
Returns next file icon object.
• const char ∗ pattern ()
Returns the filename matching pattern for the icon.
• int size ()
Returns the number of words of data used by the icon.
• int type ()
Returns the filetype associated with the icon, which can be one of the following:
• short ∗ value ()
Returns the data array for the icon.
• ∼Fl File Icon ()
The destructor destroys the icon and frees all memory that has been allocated for it.

Static Public Member Functions


• static Fl File Icon ∗ find (const char ∗filename, int filetype=ANY)
Finds an icon that matches the given filename and file type.
• static Fl File Icon ∗ first ()
Returns a pointer to the first icon in the list.
• static void labeltype (const Fl Label ∗o, int x, int y, int w, int h, Fl Align a)
Draw the icon label.
• static void load system icons (void)
Loads all system-defined icons.

31.30.1 Detailed Description


The Fl File Icon class manages icon images that can be used as labels in other widgets and as icons in the
FileBrowser widget.

31.30.2 Constructor & Destructor Documentation


Fl File Icon::Fl File Icon ( const char ∗ p, int t, int nd = 0, short ∗ d = 0 )
Creates a new Fl File Icon with the specified information.
31.30. FL FILE ICON CLASS REFERENCE 403

Parameters
in p filename pattern
in t file type
in nd number of data values
in d data values

31.30.3 Member Function Documentation


short ∗ Fl File Icon::add ( short d )
Adds a keyword value to the icon array, returning a pointer to it.
Parameters
in d data value

short∗ Fl File Icon::add color ( Fl Color c ) [inline]


Adds a color value to the icon array, returning a pointer to it.
Parameters
in c color value

short∗ Fl File Icon::add vertex ( int x, int y ) [inline]


Adds a vertex value to the icon array, returning a pointer to it.
The integer version accepts coordinates from 0 to 10000. The origin (0.0) is in the lower-lefthand
corner of the icon.
Parameters
in x,y vertex coordinates

short∗ Fl File Icon::add vertex ( float x, float y ) [inline]


Adds a vertex value to the icon array, returning a pointer to it.
The floating point version goes from 0.0 to 1.0. The origin (0.0) is in the lower-lefthand corner of the
icon.
Parameters
in x,y vertex coordinates

void Fl File Icon::clear ( ) [inline]


Clears all icon data from the icon.

void Fl File Icon::draw ( int x, int y, int w, int h, Fl Color ic, int active = 1 )
Draws an icon in the indicated area.
Parameters
404 CHAPTER 31. CLASS DOCUMENTATION

in x,y,w,h position and size


in ic icon color
in active status, default is active [non-zero]

Fl File Icon ∗ Fl File Icon::find ( const char ∗ filename, int filetype = ANY ) [static]
Finds an icon that matches the given filename and file type.
Parameters
in filename name of file
in filetype enumerated file type

Returns
matching file icon or NULL

static Fl File Icon∗ Fl File Icon::first ( ) [inline], [static]


Returns a pointer to the first icon in the list.

void Fl File Icon::label ( Fl Widget ∗ w )


Applies the icon to the widget, registering the Fl File Icon label type as needed.
Parameters
in w widget for which this icon will become the label

void Fl File Icon::labeltype ( const Fl Label ∗ o, int x, int y, int w, int h, Fl Align a ) [static]
Draw the icon label.
Parameters
in o label data
in x,y,w,h position and size of label
in a label alignment [not used]

void Fl File Icon::load ( const char ∗ f )


Loads the specified icon image.
The format is deduced from the filename.
Parameters
in f filename

int Fl File Icon::load fti ( const char ∗ fti )


Loads an SGI icon file.
Parameters
31.30. FL FILE ICON CLASS REFERENCE 405

in fti icon filename

Returns
0 on success, non-zero on error

int Fl File Icon::load image ( const char ∗ ifile )


Load an image icon file from an image filename.
Parameters
in ifile image filename

Returns
0 on success, non-zero on error

void Fl File Icon::load system icons ( void ) [static]


Loads all system-defined icons.
This call is useful when using the FileChooser widget and should be used when the application starts:
Fl File Icon::load system icons();

Fl File Icon∗ Fl File Icon::next ( ) [inline]


Returns next file icon object.
See Fl File Icon::first()

const char∗ Fl File Icon::pattern ( ) [inline]


Returns the filename matching pattern for the icon.

int Fl File Icon::size ( ) [inline]


Returns the number of words of data used by the icon.

int Fl File Icon::type ( ) [inline]


Returns the filetype associated with the icon, which can be one of the following:

• Fl File Icon::ANY, any kind of file.

• Fl File Icon::PLAIN, plain files.

• Fl File Icon::FIFO, named pipes.

• Fl File Icon::DEVICE, character and block devices.

• Fl File Icon::LINK, symbolic links.

• Fl File Icon::DIRECTORY, directories.


406 CHAPTER 31. CLASS DOCUMENTATION

short∗ Fl File Icon::value ( ) [inline]

Returns the data array for the icon.


The documentation for this class was generated from the following files:

• Fl File Icon.H
• Fl File Icon.cxx
• Fl File Icon2.cxx

31.31 Fl File Input Class Reference


This widget displays a pathname in a text input field.
#include <Fl File Input.H>
Inheritance diagram for Fl File Input:

Fl_Widget

Fl_Input_

Fl_Input

Fl_File_Input

Public Member Functions


• Fl Boxtype down box () const
Gets the box type used for the navigation bar.
• void down box (Fl Boxtype b)
Sets the box type to use for the navigation bar.
• Fl Color errorcolor () const
Gets the current error color.
• void errorcolor (Fl Color c)
Sets the current error color to c.
• Fl File Input (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl File Input widget using the given position, size, and label string.
• virtual int handle (int event)
Handle events in the widget.
• int value (const char ∗str)
Sets the value of the widget given a new string value.
• int value (const char ∗str, int len)
Sets the value of the widget given a new string value and its length.
• const char ∗ value ()
Returns the current value, which is a pointer to an internal buffer and is valid only until the next event is
handled.
31.31. FL FILE INPUT CLASS REFERENCE 407

Protected Member Functions


• virtual void draw ()
Draws the file input widget.

Additional Inherited Members


31.31.1 Detailed Description
This widget displays a pathname in a text input field.
A navigation bar located above the input field allows the user to navigate upward in the directory tree.
You may want to handle FL WHEN CHANGED events for tracking text changes and also FL WHEN R-
ELEASE for button release when changing to parent dir. FL WHEN RELEASE callback won’t be called
if the directory clicked is the same as the current one.

Figure 31.13: Fl File Input

Note
As all Fl Input derived objects, Fl File Input may call its callback when losing focus (see FL UN-
FOCUS) to update its state like its cursor shape. One resulting side effect is that you should call
clear changed() early in your callback to avoid reentrant calls if you plan to show another window or
dialog box in the callback.

31.31.2 Constructor & Destructor Documentation


Fl File Input::Fl File Input ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl File Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

31.31.3 Member Function Documentation


Fl Boxtype Fl File Input::down box ( ) const [inline]
Gets the box type used for the navigation bar.

void Fl File Input::down box ( Fl Boxtype b ) [inline]


Sets the box type to use for the navigation bar.

Fl Color Fl File Input::errorcolor ( ) const [inline]


Gets the current error color.

Todo Better docs for Fl File Input::errorcolor() - is it even used?


408 CHAPTER 31. CLASS DOCUMENTATION

int Fl File Input::handle ( int event ) [virtual]

Handle events in the widget.


Return non zero if event is handled.
Parameters
in event
Reimplemented from Fl Widget.

int Fl File Input::value ( const char ∗ str )

Sets the value of the widget given a new string value.


Returns non 0 on success.
Parameters
in str new string value

int Fl File Input::value ( const char ∗ str, int len )

Sets the value of the widget given a new string value and its length.
Returns non 0 on success.
Parameters
in str new string value
in len lengh of value
The documentation for this class was generated from the following files:

• Fl File Input.H
• Fl File Input.cxx

31.32 Fl Fill Dial Class Reference


Draws a dial with a filled arc.
#include <Fl Fill Dial.H>
Inheritance diagram for Fl Fill Dial:

Fl_Widget

Fl_Valuator

Fl_Dial

Fl_Fill_Dial

Public Member Functions


• Fl Fill Dial (int X, int Y, int W, int H, const char ∗L)
Creates a filled dial, also setting its type to FL FILL DIAL.
31.33. FL FILL SLIDER CLASS REFERENCE 409

Additional Inherited Members


31.32.1 Detailed Description
Draws a dial with a filled arc.

31.32.2 Constructor & Destructor Documentation


Fl Fill Dial::Fl Fill Dial ( int X, int Y, int W, int H, const char ∗ L )
Creates a filled dial, also setting its type to FL FILL DIAL.
The documentation for this class was generated from the following files:

• Fl Fill Dial.H
• Fl Dial.cxx

31.33 Fl Fill Slider Class Reference


Widget that draws a filled horizontal slider, useful as a progress or value meter.
#include <Fl Fill Slider.H>
Inheritance diagram for Fl Fill Slider:

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Fill_Slider

Public Member Functions


• Fl Fill Slider (int X, int Y, int W, int H, const char ∗L=0)
Creates the slider from its position,size and optional title.

Additional Inherited Members


31.33.1 Detailed Description
Widget that draws a filled horizontal slider, useful as a progress or value meter.

31.33.2 Constructor & Destructor Documentation


Fl Fill Slider::Fl Fill Slider ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates the slider from its position,size and optional title.
The documentation for this class was generated from the following files:

• Fl Fill Slider.H
• Fl Slider.cxx
410 CHAPTER 31. CLASS DOCUMENTATION

31.34 Fl Float Input Class Reference


The Fl Float Input class is a subclass of Fl Input that only allows the user to type floating point numbers
(sign, digits, decimal point, more digits, ’E’ or ’e’, sign, digits).
#include <Fl Float Input.H>
Inheritance diagram for Fl Float Input:

Fl_Widget

Fl_Input_

Fl_Input

Fl_Float_Input

Public Member Functions


• Fl Float Input (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Float Input widget using the given position, size, and label string.

Additional Inherited Members


31.34.1 Detailed Description
The Fl Float Input class is a subclass of Fl Input that only allows the user to type floating point numbers
(sign, digits, decimal point, more digits, ’E’ or ’e’, sign, digits).

31.34.2 Constructor & Destructor Documentation


Fl Float Input::Fl Float Input ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Float Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.
The documentation for this class was generated from the following files:

• Fl Float Input.H
• Fl Input.cxx

31.35 Fl FLTK File Chooser Class Reference


Inheritance diagram for Fl FLTK File Chooser:

Fl_FLTK_File_Chooser

Fl_GTK_File_Chooser
31.35. FL FLTK FILE CHOOSER CLASS REFERENCE 411

Protected Member Functions


• virtual int count () const
• void directory (const char ∗val)
• const char ∗ directory () const
• void errmsg (const char ∗msg)
• const char ∗ errmsg () const
• int exist dialog ()
• virtual const char ∗ filename () const
• virtual const char ∗ filename (int i) const
• const char ∗ filter () const
• void filter (const char ∗)
• void filter value (int i)
• int filter value () const
• int filters () const
• Fl FLTK File Chooser (int val)
• void options (int)
• int options () const
• void parse filter ()
• void preset file (const char ∗)
• const char ∗ preset file () const
• virtual int show ()
• virtual void title (const char ∗)
• virtual const char ∗ title () const
• virtual void type (int)
• int type () const
• int type fl file (int)

Protected Attributes
• int btype
• char ∗ directory
• char ∗ errmsg
• Fl File Chooser ∗ file chooser
• char ∗ filter
• int filtvalue
• int nfilters
• int options
• char ∗ parsedfilt
• char ∗ preset file
• char ∗ prevvalue

Friends
• class Fl Native File Chooser

The documentation for this class was generated from the following files:

• Fl Native File Chooser.H


• Fl Native File Chooser FLTK.cxx
412 CHAPTER 31. CLASS DOCUMENTATION

31.36 Fl Font Descriptor Class Reference


This a structure for an actual system font, with junk to help choose it and info on character sizes.
#include <Fl Font.H>

Public Attributes
• Fl Font Descriptor ∗ next
linked list for this Fl Fontdesc
• Fl Fontsize size
font size

31.36.1 Detailed Description


This a structure for an actual system font, with junk to help choose it and info on character sizes.
Each Fl Fontdesc has a linked list of these. These are created the first time each system font/size
combination is used.
The documentation for this class was generated from the following file:

• Fl Font.H

31.37 Fl Fontdesc Struct Reference


Public Attributes
• Fl Font Descriptor ∗ first
• char fontname [128]
• int n
• const char ∗ name
• char ∗∗ xlist

The documentation for this struct was generated from the following file:

• Fl Font.H

31.38 Fl FormsBitmap Class Reference


Forms compatibility Bitmap Image Widget.
#include <Fl FormsBitmap.H>
Inheritance diagram for Fl FormsBitmap:

Fl_Widget

Fl_FormsBitmap
31.39. FL FORMSPIXMAP CLASS REFERENCE 413

Public Member Functions


• void bitmap (Fl Bitmap ∗B)
Sets a new bitmap.
• Fl Bitmap ∗ bitmap () const
Gets a the current associated Fl Bitmap objects.
• Fl FormsBitmap (Fl Boxtype, int, int, int, int, const char ∗=0)
Creates a bitmap widget from a box type, position, size and optional label specification.
• void set (int W, int H, const uchar ∗bits)
Sets a new bitmap bits with size W,H.

Protected Member Functions


• void draw ()
Draws the bitmap and its associated box.

Additional Inherited Members


31.38.1 Detailed Description
Forms compatibility Bitmap Image Widget.

31.38.2 Member Function Documentation


void Fl FormsBitmap::bitmap ( Fl Bitmap ∗ B ) [inline]
Sets a new bitmap.

Fl Bitmap∗ Fl FormsBitmap::bitmap ( ) const [inline]


Gets a the current associated Fl Bitmap objects.

void Fl FormsBitmap::draw ( void ) [protected], [virtual]


Draws the bitmap and its associated box.
Implements Fl Widget.

void Fl FormsBitmap::set ( int W, int H, const uchar ∗ bits )


Sets a new bitmap bits with size W,H.
Deletes the previous one.
The documentation for this class was generated from the following files:

• Fl FormsBitmap.H
• forms bitmap.cxx

31.39 Fl FormsPixmap Class Reference


Forms pixmap drawing routines.
#include <Fl FormsPixmap.H>
Inheritance diagram for Fl FormsPixmap:
414 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_FormsPixmap

Public Member Functions


• Fl FormsPixmap (Fl Boxtype t, int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl FormsPixmap widget using the given box type, position, size and label string.
• void Pixmap (Fl Pixmap ∗B)
Set the internal pixmap pointer to an existing pixmap.
• Fl Pixmap ∗ Pixmap () const
Get the internal pixmap pointer.
• void set (char ∗const ∗bits)
Set/create the internal pixmap using raw data.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.39.1 Detailed Description
Forms pixmap drawing routines.

31.39.2 Constructor & Destructor Documentation


Fl FormsPixmap::Fl FormsPixmap ( Fl Boxtype t, int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl FormsPixmap widget using the given box type, position, size and label string.
Parameters
in t box type
in X,Y,W,H position and size
in L widget label, default is no label

31.39.3 Member Function Documentation


void Fl FormsPixmap::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.
31.39. FL FORMSPIXMAP CLASS REFERENCE 415

void Fl FormsPixmap::Pixmap ( Fl Pixmap ∗ B ) [inline]


Set the internal pixmap pointer to an existing pixmap.
416 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in B existing pixmap

Fl Pixmap∗ Fl FormsPixmap::Pixmap ( ) const [inline]


Get the internal pixmap pointer.

void Fl FormsPixmap::set ( char ∗const ∗ bits )


Set/create the internal pixmap using raw data.
Parameters
in bits raw data
The documentation for this class was generated from the following files:

• Fl FormsPixmap.H
• forms pixmap.cxx

31.40 Fl FormsText Class Reference


Inheritance diagram for Fl FormsText:

Fl_Widget

Fl_FormsText

Public Member Functions


• Fl FormsText (Fl Boxtype b, int X, int Y, int W, int H, const char ∗l=0)

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.40.1 Member Function Documentation
void Fl FormsText::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()
31.41. FL FREE CLASS REFERENCE 417

Implements Fl Widget.
The documentation for this class was generated from the following file:
• forms.H

31.41 Fl Free Class Reference


Emulation of the Forms ”free” widget.
#include <Fl Free.H>
Inheritance diagram for Fl Free:

Fl_Widget

Fl_Free

Public Member Functions


• Fl Free (uchar t, int X, int Y, int W, int H, const char ∗L, FL HANDLEPTR hdl)
Create a new Fl Free widget with type, position, size, label and handler.
• int handle (int e)
Handles the specified event.
• ∼Fl Free ()
The destructor will call the handle function with the event FL FREE MEM.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.41.1 Detailed Description
Emulation of the Forms ”free” widget.
This emulation allows the free demo to run, and appears to be useful for porting programs written in
Forms which use the free widget or make subclasses of the Forms widgets.
There are five types of free, which determine when the handle function is called:
• FL NORMAL FREE normal event handling.
• FL SLEEPING FREE deactivates event handling (widget is inactive).
• FL INPUT FREE accepts FL FOCUS events.
• FL CONTINUOUS FREE sets a timeout callback 100 times a second and provides an FL STEP
event. This has obvious detrimental effects on machine performance.
• FL ALL FREE same as FL INPUT FREE and FL CONTINUOUS FREE.

31.41.2 Constructor & Destructor Documentation


Fl Free::Fl Free ( uchar t, int X, int Y, int W, int H, const char ∗ L, FL HANDLEPTR hdl )
Create a new Fl Free widget with type, position, size, label and handler.
418 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in t type
in X,Y,W,H position and size
in L widget label
in hdl handler function
The constructor takes both the type and the handle function. The handle function should be declared as
follows:
int handle function(Fl Widget *w,
int event,
float event x,
float event y,
char key)

This function is called from the handle() method in response to most events, and is called by the draw()
method.
The event argument contains the event type:
// old event names for compatibility:
#define FL MOUSE FL DRAG
#define FL DRAW 0
#define FL STEP 9
#define FL FREEMEM 12
#define FL FREEZE FL UNMAP
#define FL THAW FL MAP

31.41.3 Member Function Documentation


void Fl Free::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Free::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
31.42. FL GDI GRAPHICS DRIVER CLASS REFERENCE 419

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.


The documentation for this class was generated from the following files:

• Fl Free.H
• forms free.cxx

31.42 Fl GDI Graphics Driver Class Reference


The MSWindows-specific graphics class.
#include <Fl Device.H>
Inheritance diagram for Fl GDI Graphics Driver:

Fl_Device

Fl_Graphics_Driver

Fl_GDI_Graphics_Driver

Fl_GDI_Printer_Graphics_Driver

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void color (Fl Color c)
see fl color(Fl Color c).
• void color (uchar r, uchar g, uchar b)
see fl color(uchar r, uchar g, uchar b).
• void copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
• int descent ()
see fl descent().
• void draw (const char ∗str, int n, int x, int y)
see fl draw(const char ∗str, int n, int x, int y).
• void draw (int angle, const char ∗str, int n, int x, int y)
see fl draw(int angle, const char ∗str, int n, int x, int y).
• void draw (Fl Pixmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Pixmap object to the device.
• void draw (Fl Bitmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Bitmap object to the device.
420 CHAPTER 31. CLASS DOCUMENTATION

• void draw (Fl RGB Image ∗img, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl RGB Image object to the device.
• void draw image (const uchar ∗buf, int X, int Y, int W, int H, int D=3, int L=0)
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=3)
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D=1, int L=0)
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=1)
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void font (Fl Font face, Fl Fontsize size)
see fl font(Fl Font face, Fl Fontsize size).
• int height ()
see fl height().
• void rtl draw (const char ∗str, int n, int x, int y)
see fl rtl draw(const char ∗str, int n, int x, int y).
• void text extents (const char ∗, int n, int &dx, int &dy, int &w, int &h)
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
• double width (const char ∗str, int n)
see fl width(const char ∗str, int n).
• double width (unsigned int c)
see fl width(unsigned int n).

Static Public Attributes


• static const char ∗ class id = ”Fl GDI Graphics Driver”

Additional Inherited Members


31.42.1 Detailed Description
The MSWindows-specific graphics class.
This class is implemented only on the MSWindows platform.

31.42.2 Member Function Documentation


const char∗ Fl GDI Graphics Driver::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Graphics Driver.


Reimplemented in Fl GDI Printer Graphics Driver.

void Fl GDI Graphics Driver::color ( Fl Color c ) [virtual]


see fl color(Fl Color c).
Reimplemented from Fl Graphics Driver.
31.42. FL GDI GRAPHICS DRIVER CLASS REFERENCE 421

void Fl GDI Graphics Driver::color ( uchar r, uchar g, uchar b ) [virtual]

see fl color(uchar r, uchar g, uchar b).


Reimplemented from Fl Graphics Driver.

int Fl GDI Graphics Driver::descent ( ) [virtual]

see fl descent().
Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [virtual]

see fl draw(const char ∗str, int n, int x, int y).


Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y ) [virtual]

see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int cx, int
cy ) [virtual]

Draws an Fl Pixmap object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.
Reimplemented in Fl GDI Printer Graphics Driver.

void Fl GDI Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int cx, int
cy ) [virtual]

Draws an Fl Bitmap object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.
Reimplemented in Fl GDI Printer Graphics Driver.

void Fl GDI Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP, int cx,
int cy ) [virtual]

Draws an Fl RGB Image object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D =
3, int L = 0 ) [virtual]

see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.
422 CHAPTER 31. CLASS DOCUMENTATION

void Fl GDI Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int
W, int H, int D = 3 ) [virtual]
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 1, int L = 0 ) [virtual]
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X, int
Y, int W, int H, int D = 1 ) [virtual]
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::font ( Fl Font face, Fl Fontsize fsize ) [virtual]


see fl font(Fl Font face, Fl Fontsize size).
Reimplemented from Fl Graphics Driver.

int Fl GDI Graphics Driver::height ( ) [virtual]


see fl height().
Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl rtl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.

void Fl GDI Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int & w, int
& h ) [virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented from Fl Graphics Driver.

double Fl GDI Graphics Driver::width ( const char ∗ str, int n ) [virtual]


see fl width(const char ∗str, int n).
Reimplemented from Fl Graphics Driver.

double Fl GDI Graphics Driver::width ( unsigned int c ) [virtual]


see fl width(unsigned int n).
Reimplemented from Fl Graphics Driver.
The documentation for this class was generated from the following files:

• Fl Device.H
• fl color win32.cxx
• Fl Device.cxx
• fl draw image win32.cxx
31.43. FL GDI PRINTER GRAPHICS DRIVER CLASS REFERENCE 423

31.43 Fl GDI Printer Graphics Driver Class Reference


The graphics driver used when printing on MSWindows.
#include <Fl Device.H>
Inheritance diagram for Fl GDI Printer Graphics Driver:

Fl_Device

Fl_Graphics_Driver

Fl_GDI_Graphics_Driver

Fl_GDI_Printer_Graphics_Driver

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void draw (Fl Pixmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Pixmap object to the device.
• void draw (Fl Bitmap ∗bm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Bitmap object to the device.

Static Public Attributes


• static const char ∗ class id = ”Fl GDI Printer Graphics Driver”

Additional Inherited Members


31.43.1 Detailed Description
The graphics driver used when printing on MSWindows.
This class is implemented only on the MSWindows platform. It ’s extremely similar to Fl GDI -
Graphics Driver.

31.43.2 Member Function Documentation


const char∗ Fl GDI Printer Graphics Driver::class name ( ) [inline], [virtual]

Returns the name of the class of this object.


Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:

if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl GDI Graphics Driver.


424 CHAPTER 31. CLASS DOCUMENTATION

void Fl GDI Printer Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP,
int cx, int cy ) [virtual]
Draws an Fl Pixmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl GDI Graphics Driver.

void Fl GDI Printer Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int
cx, int cy ) [virtual]
Draws an Fl Bitmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl GDI Graphics Driver.
The documentation for this class was generated from the following files:

• Fl Device.H
• Fl Device.cxx

31.44 Fl GIF Image Class Reference


The Fl GIF Image class supports loading, caching, and drawing of Compuserve GIFSM images.
#include <Fl GIF Image.H>
Inheritance diagram for Fl GIF Image:

Fl_Image

Fl_Pixmap

Fl_GIF_Image

Public Member Functions


• Fl GIF Image (const char ∗filename)
The constructor loads the named GIF image.

Additional Inherited Members


31.44.1 Detailed Description
The Fl GIF Image class supports loading, caching, and drawing of Compuserve GIFSM images.
The class loads the first image and supports transparency.

31.44.2 Constructor & Destructor Documentation


Fl GIF Image::Fl GIF Image ( const char ∗ infname )
The constructor loads the named GIF image.
The inherited destructor free all memory and server resources that are used by the image.
The documentation for this class was generated from the following files:
31.45. FL GL CHOICE CLASS REFERENCE 425

• Fl GIF Image.H
• Fl GIF Image.cxx

31.45 Fl Gl Choice Class Reference


Static Public Member Functions
• static Fl Gl Choice ∗ find (int mode, const int ∗)

Public Attributes
• Colormap colormap
• XVisualInfo ∗ vis

The documentation for this class was generated from the following files:
• Fl Gl Choice.H
• Fl Gl Choice.cxx

31.46 Fl Gl Window Class Reference


The Fl Gl Window widget sets things up so OpenGL works.
#include <Fl Gl Window.H>
Inheritance diagram for Fl Gl Window:

Fl_Widget

Fl_Group

Fl_Window

Fl_Gl_Window

Fl_Glut_Window

Public Member Functions


• virtual Fl Gl Window ∗ as gl window ()
Returns an Fl Gl Window pointer if this widget is an Fl Gl Window.
• int can do ()
Returns non-zero if the hardware supports the given or current OpenGL mode.
• int can do overlay ()
Returns true if the hardware overlay is possible.
• void ∗ context () const
void See void context(void∗ v, int destroy flag)
• void context (void ∗, int destroy flag=0)
Returns or sets a pointer to the GLContext that this window is using.
• char context valid () const
426 CHAPTER 31. CLASS DOCUMENTATION

Will only be set if the OpenGL context is created or recreated.


• void context valid (char v)
See char Fl Gl Window::context valid() const.
• Fl Gl Window (int W, int H, const char ∗l=0)
Creates a new Fl Gl Window widget using the given size, and label string.
• Fl Gl Window (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Gl Window widget using the given position, size, and label string.
• void flush ()
Forces the window to be drawn, this window is also made current and calls draw().
• int handle (int)
Handle some FLTK events as needed.
• void hide ()
Hides the window and destroys the OpenGL context.
• void hide overlay ()
Hides the window if it is not this window, does nothing in WIN32.
• void invalidate ()
The invalidate() method turns off valid() and is equivalent to calling value(0).
• void make current ()
The make current() method selects the OpenGL context for the widget.
• void make overlay current ()
The make overlay current() method selects the OpenGL context for the widget’s overlay.
• Fl Mode mode () const
Set or change the OpenGL capabilites of the window.
• int mode (int a)
See Fl Mode mode() const.
• int mode (const int ∗a)
See Fl Mode mode() const.
• void ortho ()
Sets the projection so 0,0 is in the lower left of the window and each pixel is 1 unit wide/tall.
• void redraw overlay ()
This method causes draw overlay() to be called at a later time.
• void resize (int, int, int, int)
Changes the size and position of the window.
• void show ()
Puts the window on the screen.
• void show (int a, char ∗∗b)
• void swap buffers ()
The swap buffers() method swaps the back and front buffers.
• char valid () const
Is turned off when FLTK creates a new context for this window or when the window resizes, and is turned
on after draw() is called.
• void valid (char v)
See char Fl Gl Window::valid() const.
• ∼Fl Gl Window ()
The destructor removes the widget and destroys the OpenGL context associated with it.
31.46. FL GL WINDOW CLASS REFERENCE 427

Static Public Member Functions


• static int can do (int m)
Returns non-zero if the hardware supports the given or current OpenGL mode.
• static int can do (const int ∗m)
Returns non-zero if the hardware supports the given or current OpenGL mode.

Protected Member Functions


• virtual void draw ()
Draws the Fl Gl Window.

Friends
• class Fl Gl Overlay

Additional Inherited Members


31.46.1 Detailed Description
The Fl Gl Window widget sets things up so OpenGL works.
It also keeps an OpenGL ”context” for that window, so that changes to the lighting and projection may
be reused between redraws. Fl Gl Window also flushes the OpenGL streams and swaps buffers after draw()
returns.
OpenGL hardware typically provides some overlay bit planes, which are very useful for drawing UI
controls atop your 3D graphics. If the overlay hardware is not provided, FLTK tries to simulate the overlay.
This works pretty well if your graphics are double buffered, but not very well for single-buffered.
Please note that the FLTK drawing and clipping functions will not work inside an Fl Gl Window. All
drawing should be done using OpenGL calls exclusively. Even though Fl Gl Window is derived from Fl-
Group, it is not useful to add other FLTK Widgets as children, unless those widgets are modified to draw
using OpenGL calls.

31.46.2 Constructor & Destructor Documentation


Fl Gl Window::Fl Gl Window ( int W, int H, const char ∗ l = 0 ) [inline]
Creates a new Fl Gl Window widget using the given size, and label string.
The default boxtype is FL NO BOX. The default mode is FL RGB|FL DOUBLE|FL DEPTH.

Fl Gl Window::Fl Gl Window ( int X, int Y, int W, int H, const char ∗ l = 0 ) [inline]


Creates a new Fl Gl Window widget using the given position, size, and label string.
The default boxtype is FL NO BOX. The default mode is FL RGB|FL DOUBLE|FL DEPTH.

31.46.3 Member Function Documentation


virtual Fl Gl Window∗ Fl Gl Window::as gl window ( ) [inline], [virtual]
Returns an Fl Gl Window pointer if this widget is an Fl Gl Window.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from
Fl Gl Window. If it returns non-NULL, then the widget in question is derived from Fl Gl Window.
428 CHAPTER 31. CLASS DOCUMENTATION

Return values
NULL if this widget is not derived from Fl Gl Window.

Note
This method is provided to avoid dynamic cast.

See Also
Fl Widget::as group(), Fl Widget::as window()

Reimplemented from Fl Widget.

static int Fl Gl Window::can do ( int m ) [inline], [static]


Returns non-zero if the hardware supports the given or current OpenGL mode.

static int Fl Gl Window::can do ( const int ∗ m ) [inline], [static]


Returns non-zero if the hardware supports the given or current OpenGL mode.

int Fl Gl Window::can do ( ) [inline]


Returns non-zero if the hardware supports the given or current OpenGL mode.

int Fl Gl Window::can do overlay ( )


Returns true if the hardware overlay is possible.
If this is false, FLTK will try to simulate the overlay, with significant loss of update speed. Calling this
will cause FLTK to open the display.

void Fl Gl Window::context ( void ∗ v, int destroy flag = 0 )


Returns or sets a pointer to the GLContext that this window is using.
This is a system-dependent structure, but it is portable to copy the context from one window to another.
You can also set it to NULL, which will force FLTK to recreate the context the next time make current()
is called, this is useful for getting around bugs in OpenGL implementations.
If destroy flag is true the context will be destroyed by fltk when the window is destroyed, or when the
mode() is changed, or the next time context(x) is called.

char Fl Gl Window::context valid ( ) const [inline]


Will only be set if the OpenGL context is created or recreated.
It differs from Fl Gl Window::valid() which is also set whenever the context changes size.

void Fl Gl Window::draw ( void ) [protected], [virtual]


Draws the Fl Gl Window.
You must subclass Fl Gl Window and provide an implementation for draw().
You must override the draw() method.
You may also provide an implementation of draw overlay() if you want to draw into the overlay planes.
You can avoid reinitializing the viewport and lights and other things by checking valid() at the start of
draw() and only doing the initialization if it is false.
The draw() method can only use OpenGL calls. Do not attempt to call X, any of the functions in
<FL/fl draw.H>, or glX directly. Do not call gl start() or gl finish().
31.46. FL GL WINDOW CLASS REFERENCE 429

If double-buffering is enabled in the window, the back and front buffers are swapped after this function
is completed.
Reimplemented from Fl Window.
Reimplemented in Fl Glut Window.

void Fl Gl Window::flush ( ) [virtual]


Forces the window to be drawn, this window is also made current and calls draw().
Reimplemented from Fl Window.

void Fl Gl Window::hide overlay ( )


Hides the window if it is not this window, does nothing in WIN32.

void Fl Gl Window::make current ( )


The make current() method selects the OpenGL context for the widget.
It is called automatically prior to the draw() method being called and can also be used to implement
feedback and/or selection within the handle() method.

void Fl Gl Window::make overlay current ( )


The make overlay current() method selects the OpenGL context for the widget’s overlay.
It is called automatically prior to the draw overlay() method being called and can also be used to
implement feedback and/or selection within the handle() method.

Fl Mode Fl Gl Window::mode ( ) const [inline]


Set or change the OpenGL capabilites of the window.
The value can be any of the following OR’d together:
• FL RGB - RGB color (not indexed)
• FL RGB8 - RGB color with at least 8 bits of each color
• FL INDEX - Indexed mode
• FL SINGLE - not double buffered
• FL DOUBLE - double buffered
• FL ACCUM - accumulation buffer
• FL ALPHA - alpha channel in color
• FL DEPTH - depth buffer
• FL STENCIL - stencil buffer
• FL MULTISAMPLE - multisample antialiasing
FL RGB and FL SINGLE have a value of zero, so they are ”on” unless you give FL INDEX or FL D-
OUBLE.
If the desired combination cannot be done, FLTK will try turning off FL MULTISAMPLE. If this also
fails the show() will call Fl::error() and not show the window.
You can change the mode while the window is displayed. This is most useful for turning double-
buffering on and off. Under X this will cause the old X window to be destroyed and a new one to be
created. If this is a top-level window this will unfortunately also cause the window to blink, raise to the
top, and be de-iconized, and the xid() will change, possibly breaking other code. It is best to make the GL
window a child of another window if you wish to do this!
mode() must not be called within draw() since it changes the current context.
430 CHAPTER 31. CLASS DOCUMENTATION

void Fl Gl Window::ortho ( )
Sets the projection so 0,0 is in the lower left of the window and each pixel is 1 unit wide/tall.
If you are drawing 2D images, your draw() method may want to call this if valid() is false.

void Fl Gl Window::redraw overlay ( )


This method causes draw overlay() to be called at a later time.
Initially the overlay is clear. If you want the window to display something in the overlay when it first
appears, you must call this immediately after you show() your window.

void Fl Gl Window::resize ( int X, int Y, int W, int H ) [virtual]


Changes the size and position of the window.
If shown() is true, these changes are communicated to the window server (which may refuse that size
and cause a further resize). If shown() is false, the size and position are used when show() is called. See
Fl Group for the effect of resizing on the child widgets.
You can also call the Fl Widget methods size(x,y) and position(w,h), which are inline wrappers for this
virtual function.
A top-level window can not force, but merely suggest a position and size to the operating system. The
window manager may not be willing or able to display a window at the desired position or with the given
dimensions. It is up to the application developer to verify window parameters after the resize request.
Reimplemented from Fl Window.

void Fl Gl Window::show ( ) [virtual]


Puts the window on the screen.
Usually (on X) this has the side effect of opening the display.
If the window is already shown then it is restored and raised to the top. This is really convenient
because your program can call show() at any time, even if the window is already up. It also means that
show() serves the purpose of raise() in other toolkits.
Fl Window::show(int argc, char ∗∗argv) is used for top-level windows and allows standard arguments
to be parsed from the command-line.

See Also
Fl Window::show(int argc, char ∗∗argv)

Reimplemented from Fl Window.

void Fl Gl Window::swap buffers ( )


The swap buffers() method swaps the back and front buffers.
It is called automatically after the draw() method is called.

char Fl Gl Window::valid ( ) const [inline]


Is turned off when FLTK creates a new context for this window or when the window resizes, and is turned
on after draw() is called.
You can use this inside your draw() method to avoid unnecessarily initializing the OpenGL context.
Just do this:
void mywindow::draw() {
if (!valid()) {
glViewport(0,0,w(),h());
glFrustum(...);
...other initialization...
}
if (!context valid()) {
31.47. FL GLUT BITMAP FONT STRUCT REFERENCE 431

...load textures, etc. ...


}
... draw your geometry here ...
}

You can turn valid() on by calling valid(1). You should only do this after fixing the transformation
inside a draw() or after make current(). This is done automatically after draw() returns.
The documentation for this class was generated from the following files:

• Fl Gl Window.H
• Fl Gl Overlay.cxx
• Fl Gl Window.cxx

31.47 Fl Glut Bitmap Font Struct Reference


fltk glut font/size attributes used in the glutXXX functions
#include <glut.H>

Public Attributes
• Fl Font font
• Fl Fontsize size

31.47.1 Detailed Description


fltk glut font/size attributes used in the glutXXX functions
The documentation for this struct was generated from the following file:

• glut.H

31.48 Fl Glut StrokeChar Struct Reference


Public Attributes
• int Number
• GLfloat Right
• const Fl Glut StrokeStrip ∗ Strips

The documentation for this struct was generated from the following file:

• glut.H

31.49 Fl Glut StrokeFont Struct Reference


Public Attributes
• const Fl Glut StrokeChar ∗∗ Characters
• GLfloat Height
• char ∗ Name
• int Quantity

The documentation for this struct was generated from the following file:

• glut.H
432 CHAPTER 31. CLASS DOCUMENTATION

31.50 Fl Glut StrokeStrip Struct Reference


Public Attributes
• int Number
• const Fl Glut StrokeVertex ∗ Vertices

The documentation for this struct was generated from the following file:

• glut.H

31.51 Fl Glut StrokeVertex Struct Reference


Public Attributes
• GLfloat X
• GLfloat Y

The documentation for this struct was generated from the following file:

• glut.H

31.52 Fl Glut Window Class Reference


GLUT is emulated using this window class and these static variables (plus several more static variables
hidden in glut compatability.cxx):
#include <glut.H>
Inheritance diagram for Fl Glut Window:

Fl_Widget

Fl_Group

Fl_Window

Fl_Gl_Window

Fl_Glut_Window

Public Member Functions


• Fl Glut Window (int w, int h, const char ∗)
Creates a glut window, registers to the glut windows list.
• Fl Glut Window (int x, int y, int w, int h, const char ∗)
Creates a glut window, registers to the glut windows list.
• void make current ()
• ∼Fl Glut Window ()
Destroys the glut window, first unregister it from the glut windows list.
31.52. FL GLUT WINDOW CLASS REFERENCE 433

Public Attributes
• void(∗ display )()
• void(∗ entry )(int)
• void(∗ keyboard )(uchar, int x, int y)
• int menu [3]
• void(∗ motion )(int x, int y)
• void(∗ mouse )(int b, int state, int x, int y)
• int number
• void(∗ overlaydisplay )()
• void(∗ passivemotion )(int x, int y)
• void(∗ reshape )(int w, int h)
• void(∗ special )(int, int x, int y)
• void(∗ visibility )(int)

Protected Member Functions


• void draw ()
Draws the Fl Gl Window.
• void draw overlay ()
You must implement this virtual function if you want to draw into the overlay.
• int handle (int)
Handle some FLTK events as needed.

Additional Inherited Members


31.52.1 Detailed Description
GLUT is emulated using this window class and these static variables (plus several more static variables
hidden in glut compatability.cxx):

31.52.2 Constructor & Destructor Documentation


Fl Glut Window::Fl Glut Window ( int W, int H, const char ∗ t )
Creates a glut window, registers to the glut windows list.

Fl Glut Window::Fl Glut Window ( int X, int Y, int W, int H, const char ∗ t )
Creates a glut window, registers to the glut windows list.

31.52.3 Member Function Documentation


void Fl Glut Window::draw ( void ) [protected], [virtual]
Draws the Fl Gl Window.
You must subclass Fl Gl Window and provide an implementation for draw().
You must override the draw() method.
You may also provide an implementation of draw overlay() if you want to draw into the overlay planes.
You can avoid reinitializing the viewport and lights and other things by checking valid() at the start of
draw() and only doing the initialization if it is false.
The draw() method can only use OpenGL calls. Do not attempt to call X, any of the functions in
<FL/fl draw.H>, or glX directly. Do not call gl start() or gl finish().
434 CHAPTER 31. CLASS DOCUMENTATION

If double-buffering is enabled in the window, the back and front buffers are swapped after this function
is completed.
Reimplemented from Fl Gl Window.

void Fl Glut Window::draw overlay ( ) [protected], [virtual]


You must implement this virtual function if you want to draw into the overlay.
The overlay is cleared before this is called. You should draw anything that is not clear using OpenGL.
You must use gl color(i) to choose colors (it allocates them from the colormap using system-specific calls),
and remember that you are in an indexed OpenGL mode and drawing anything other than flat-shaded will
probably not work.
Both this function and Fl Gl Window::draw() should check Fl Gl Window::valid() and set the same
transformation. If you don’t your code may not work on other systems. Depending on the OS, and on
whether overlays are real or simulated, the OpenGL context may be the same or different between the
overlay and main window.
Reimplemented from Fl Gl Window.
The documentation for this class was generated from the following files:

• glut.H
• glut compatability.cxx

31.53 Fl Graphics Driver Class Reference


A virtual class subclassed for each graphics driver FLTK uses.
#include <Fl Device.H>
Inheritance diagram for Fl Graphics Driver:

Fl_Device

Fl_Graphics_Driver

Fl_GDI_Graphics_Driver Fl_PostScript_Graphics_Driver Fl_Quartz_Graphics_Driver Fl_Xlib_Graphics_Driver

Fl_GDI_Printer_Graphics_Driver

Classes
• struct matrix
A 2D coordinate transformation matrix.

Public Member Functions


• virtual const char ∗ class name ()
Returns the name of the class of this object.
• Fl Color color ()
see fl color(void).
• virtual int descent ()
see fl descent().
• virtual void font (Fl Font face, Fl Fontsize fsize)
see fl font(Fl Font face, Fl Fontsize size).
• Fl Font font ()
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 435

see fl font(void).
• Fl Font Descriptor ∗ font descriptor ()
Returns a pointer to the current Fl Font Descriptor for the graphics driver.
• void font descriptor (Fl Font Descriptor ∗d)
Sets the current Fl Font Descriptor for the graphics driver.
• virtual int height ()
see fl height().
• Fl Fontsize size ()
see fl size().
• virtual void text extents (const char ∗, int n, int &dx, int &dy, int &w, int &h)
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
• virtual double width (const char ∗str, int n)
see fl width(const char ∗str, int n).
• virtual double width (unsigned int c)
see fl width(unsigned int n).
• virtual ∼Fl Graphics Driver ()
The destructor.

Static Public Attributes


• static const char ∗ class id = ”Fl Graphics Driver”

Protected Member Functions


• virtual void arc (double x, double y, double r, double start, double end)
see fl arc(double x, double y, double r, double start, double end).
• virtual void arc (int x, int y, int w, int h, double a1, double a2)
see fl arc(int x, int y, int w, int h, double a1, double a2).
• virtual void begin complex polygon ()
see fl begin complex polygon().
• virtual void begin line ()
see fl begin line().
• virtual void begin loop ()
see fl begin loop().
• virtual void begin points ()
see fl begin points().
• virtual void begin polygon ()
see fl begin polygon().
• virtual void circle (double x, double y, double r)
see fl circle(double x, double y, double r).
• virtual int clip box (int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
see fl clip box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
• Fl Region clip region ()
see fl clip region().
• void clip region (Fl Region r)
see fl clip region(Fl Region r).
• virtual void color (Fl Color c)
see fl color(Fl Color c).
436 CHAPTER 31. CLASS DOCUMENTATION

• virtual void color (uchar r, uchar g, uchar b)


see fl color(uchar r, uchar g, uchar b).
• void copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
see fl copy offscreen()
• virtual void curve (double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3)
see fl curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3).
• virtual void draw (const char ∗str, int n, int x, int y)
see fl draw(const char ∗str, int n, int x, int y).
• virtual void draw (int angle, const char ∗str, int n, int x, int y)
see fl draw(int angle, const char ∗str, int n, int x, int y).
• virtual void draw (Fl RGB Image ∗rgb, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl RGB Image object to the device.
• virtual void draw (Fl Pixmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Pixmap object to the device.
• virtual void draw (Fl Bitmap ∗bm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Bitmap object to the device.
• virtual void draw image (const uchar ∗buf, int X, int Y, int W, int H, int D=3, int L=0)
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• virtual void draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=3)
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• virtual void draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D=1, int L=0)
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• virtual void draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=1)
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• virtual void end complex polygon ()
see fl end complex polygon().
• virtual void end line ()
see fl end line().
• virtual void end loop ()
see fl end loop().
• virtual void end points ()
see fl end points().
• virtual void end polygon ()
see fl end polygon().
• Fl Graphics Driver ()
The constructor.
• virtual void gap ()
see fl gap().
• virtual void line (int x, int y, int x1, int y1)
see fl line(int x, int y, int x1, int y1).
• virtual void line (int x, int y, int x1, int y1, int x2, int y2)
see fl line(int x, int y, int x1, int y1, int x2, int y2).
• virtual void line style (int style, int width=0, char ∗dashes=0)
see fl line style(int style, int width, char∗ dashes).
• virtual void loop (int x0, int y0, int x1, int y1, int x2, int y2)
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2).
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 437

• virtual void loop (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
• void mult matrix (double a, double b, double c, double d, double x, double y)
see fl mult matrix(double a, double b, double c, double d, double x, double y).
• virtual int not clipped (int x, int y, int w, int h)
see fl not clipped(int x, int y, int w, int h).
• virtual void pie (int x, int y, int w, int h, double a1, double a2)
see fl pie(int x, int y, int w, int h, double a1, double a2).
• virtual void point (int x, int y)
see fl point(int x, int y).
• virtual void polygon (int x0, int y0, int x1, int y1, int x2, int y2)
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2).
• virtual void polygon (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
• virtual void pop clip ()
see fl pop clip().
• void pop matrix ()
see fl pop matrix().
• virtual void push clip (int x, int y, int w, int h)
see fl push clip(int x, int y, int w, int h).
• void push matrix ()
see fl push matrix().
• virtual void push no clip ()
see fl push no clip().
• virtual void rect (int x, int y, int w, int h)
see fl rect(int x, int y, int w, int h).
• virtual void rectf (int x, int y, int w, int h)
see fl rectf(int x, int y, int w, int h).
• void restore clip ()
see fl restore clip().
• void rotate (double d)
see fl rotate(double d).
• virtual void rtl draw (const char ∗str, int n, int x, int y)
see fl rtl draw(const char ∗str, int n, int x, int y).
• void scale (double x, double y)
see fl scale(double x, double y).
• void scale (double x)
see fl scale(double x).
• double transform dx (double x, double y)
see fl transform dx(double x, double y).
• double transform dy (double x, double y)
see fl transform dy(double x, double y).
• double transform x (double x, double y)
see fl transform x(double x, double y).
• double transform y (double x, double y)
see fl transform y(double x, double y).
438 CHAPTER 31. CLASS DOCUMENTATION

• virtual void transformed vertex (double xf, double yf)


see fl transformed vertex(double xf, double yf).
• void translate (double x, double y)
see fl translate(double x, double y).
• virtual void vertex (double x, double y)
see fl vertex(double x, double y).
• virtual void xyline (int x, int y, int x1)
see fl xyline(int x, int y, int x1).
• virtual void xyline (int x, int y, int x1, int y2)
see fl xyline(int x, int y, int x1, int y2).
• virtual void xyline (int x, int y, int x1, int y2, int x3)
see fl xyline(int x, int y, int x1, int y2, int x3).
• virtual void yxline (int x, int y, int y1)
see fl yxline(int x, int y, int y1).
• virtual void yxline (int x, int y, int y1, int x2)
see fl yxline(int x, int y, int y1, int x2).
• virtual void yxline (int x, int y, int y1, int x2, int y3)
see fl yxline(int x, int y, int y1, int x2, int y3).

Protected Attributes
• matrix ∗ fl matrix
Points to the current coordinate transformation matrix.

Friends
• void fl arc (double x, double y, double r, double start, double end)
Adds a series of points to the current path on the arc of a circle.
• void fl arc (int x, int y, int w, int h, double a1, double a2)
Draw ellipse sections using integer coordinates.
• void fl begin complex polygon ()
Starts drawing a complex filled polygon.
• void fl begin line ()
Starts drawing a list of lines.
• void fl begin loop ()
Starts drawing a closed sequence of lines.
• void fl begin points ()
Starts drawing a list of points.
• void fl begin polygon ()
Starts drawing a convex filled polygon.
• class Fl Bitmap
• void fl circle (double x, double y, double r)
fl circle() is equivalent to fl arc(x,y,r,0,360), but may be faster.
• int fl clip box (int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
Intersects the rectangle with the current clip region and returns the bounding box of the result.
• Fl Region fl clip region ()
Returns the current clipping region.
• void fl clip region (Fl Region r)
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 439

Replaces the top of the clipping stack with a clipping region of any shape.
• void fl color (Fl Color c)
Sets the color for all subsequent drawing operations.
• void fl color (uchar r, uchar g, uchar b)
Sets the color for all subsequent drawing operations.
• void fl copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
• void fl curve (double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3)
Adds a series of points on a Bezier curve to the path.
• void fl draw (const char ∗str, int n, int x, int y)
Draws starting at the given x, y location a UTF-8 string of length n bytes.
• void fl draw (int angle, const char ∗str, int n, int x, int y)
Draws at the given x, y location a UTF-8 string of length n bytes rotating angle degrees counter-
clockwise.
• void fl draw image (const uchar ∗buf, int X, int Y, int W, int H, int D, int L)
Draws an 8-bit per color RGB or luminance image.
• void fl draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D)
Draws an image using a callback function to generate image data.
• void fl draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D, int L)
Draws a gray-scale (1 channel) image.
• FL EXPORT void fl draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int
H, int D)
Draws a gray-scale image using a callback function to generate image data.
• void fl end complex polygon ()
Ends complex filled polygon, and draws.
• void fl end line ()
Ends list of lines, and draws.
• void fl end loop ()
Ends closed sequence of lines, and draws.
• void fl end points ()
Ends list of points, and draws.
• void fl end polygon ()
Ends convex filled polygon, and draws.
• void fl font (Fl Font face, Fl Fontsize size)
Sets the current font, which is then used in various drawing routines.
• void fl gap ()
Call fl gap() to separate loops of the path.
• void fl line (int x, int y, int x1, int y1)
Draws a line from (x,y) to (x1,y1)
• void fl line (int x, int y, int x1, int y1, int x2, int y2)
Draws a line from (x,y) to (x1,y1) and another from (x1,y1) to (x2,y2)
• void fl line style (int style, int width, char ∗dashes)
Sets how to draw lines (the ”pen”).
• void fl loop (int x0, int y0, int x1, int y1, int x2, int y2)
Outlines a 3-sided polygon with lines.
• void fl loop (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
440 CHAPTER 31. CLASS DOCUMENTATION

Outlines a 4-sided polygon with lines.


• void fl mult matrix (double a, double b, double c, double d, double x, double y)
Concatenates another transformation onto the current one.
• int fl not clipped (int x, int y, int w, int h)
Does the rectangle intersect the current clip region?
• void fl pie (int x, int y, int w, int h, double a1, double a2)
Draw filled ellipse sections using integer coordinates.
• class Fl Pixmap
• void fl point (int x, int y)
Draws a single pixel at the given coordinates.
• void fl polygon (int x0, int y0, int x1, int y1, int x2, int y2)
Fills a 3-sided polygon.
• void fl polygon (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
Fills a 4-sided polygon.
• void fl pop clip ()
Restores the previous clip region.
• void fl pop matrix ()
Restores the current transformation matrix from the stack.
• void fl push clip (int x, int y, int w, int h)
Intersects the current clip region with a rectangle and pushes this new region onto the stack.
• void fl push matrix ()
Saves the current transformation matrix on the stack.
• void fl push no clip ()
Pushes an empty clip region onto the stack so nothing will be clipped.
• void fl rect (int x, int y, int w, int h)
Draws a 1-pixel border inside the given bounding box.
• void fl rectf (int x, int y, int w, int h)
Colors with current color a rectangle that exactly fills the given bounding box.
• void fl restore clip ()
Undoes any clobbering of clip done by your program.
• class Fl RGB Image
• void fl rotate (double d)
Concatenates rotation transformation onto the current one.
• void fl rtl draw (const char ∗str, int n, int x, int y)
Draws a UTF-8 string of length n bytes right to left starting at the given x, y location.
• void fl scale (double x, double y)
Concatenates scaling transformation onto the current one.
• void fl scale (double x)
Concatenates scaling transformation onto the current one.
• double fl transform dx (double x, double y)
Transforms distance using current transformation matrix.
• double fl transform dy (double x, double y)
Transforms distance using current transformation matrix.
• double fl transform x (double x, double y)
Transforms coordinate using the current transformation matrix.
• double fl transform y (double x, double y)
Transforms coordinate using the current transformation matrix.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 441

• void fl transformed vertex (double xf, double yf)


Adds coordinate pair to the vertex list without further transformations.
• void fl translate (double x, double y)
Concatenates translation transformation onto the current one.
• void fl vertex (double x, double y)
Adds a single vertex to the current path.
• void fl xyline (int x, int y, int x1)
Draws a horizontal line from (x,y) to (x1,y)
• void fl xyline (int x, int y, int x1, int y2)
Draws a horizontal line from (x,y) to (x1,y), then vertical from (x1,y) to (x1,y2)
• void fl xyline (int x, int y, int x1, int y2, int x3)
Draws a horizontal line from (x,y) to (x1,y), then a vertical from (x1,y) to (x1,y2) and then another horizontal
from (x1,y2) to (x3,y2)
• void fl yxline (int x, int y, int y1)
Draws a vertical line from (x,y) to (x,y1)
• void fl yxline (int x, int y, int y1, int x2)
Draws a vertical line from (x,y) to (x,y1), then a horizontal from (x,y1) to (x2,y1)
• void fl yxline (int x, int y, int y1, int x2, int y3)
Draws a vertical line from (x,y) to (x,y1) then a horizontal from (x,y1) to (x2,y1), then another vertical from
(x2,y1) to (x2,y3)
• FL EXPORT void gl start ()
Creates an OpenGL context.

31.53.1 Detailed Description


A virtual class subclassed for each graphics driver FLTK uses.
The virtual methods of this class are those that a graphics driver should implement to support all of
FLTK drawing functions.
The public API for drawing operations is functionally presented in Drawing Things in FLTK and as
function lists in the Drawing functions and Color & Font functions modules.

31.53.2 Constructor & Destructor Documentation


Fl Graphics Driver::Fl Graphics Driver ( ) [protected]
The constructor.

31.53.3 Member Function Documentation


void Fl Graphics Driver::arc ( double x, double y, double r, double start, double end )
[protected], [virtual]
see fl arc(double x, double y, double r, double start, double end).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::arc ( int x, int y, int w, int h, double a1, double a2 ) [protected],
[virtual]
see fl arc(int x, int y, int w, int h, double a1, double a2).
Reimplemented in Fl PostScript Graphics Driver.
442 CHAPTER 31. CLASS DOCUMENTATION

void Fl Graphics Driver::begin complex polygon ( ) [protected], [virtual]


see fl begin complex polygon().
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::begin line ( ) [protected], [virtual]


see fl begin line().
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::begin loop ( ) [protected], [virtual]


see fl begin loop().
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::begin points ( ) [protected], [virtual]


see fl begin points().
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::begin polygon ( ) [protected], [virtual]


see fl begin polygon().
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::circle ( double x, double y, double r ) [protected], [virtual]


see fl circle(double x, double y, double r).
Reimplemented in Fl PostScript Graphics Driver.

virtual const char∗ Fl Graphics Driver::class name ( ) [inline], [virtual]


Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Device.


Reimplemented in Fl Xlib Graphics Driver, Fl GDI Printer Graphics Driver, Fl GDI Graphics Driver,
Fl Quartz Graphics Driver, and Fl PostScript Graphics Driver.

int Fl Graphics Driver::clip box ( int x, int y, int w, int h, int & X, int & Y, int & W, int & H )
[protected], [virtual]
see fl clip box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
Reimplemented in Fl PostScript Graphics Driver.

Fl Region Fl Graphics Driver::clip region ( ) [protected]


see fl clip region().

void Fl Graphics Driver::clip region ( Fl Region r ) [protected]


see fl clip region(Fl Region r).
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 443

virtual void Fl Graphics Driver::color ( Fl Color c ) [inline], [protected], [virtual]

see fl color(Fl Color c).


Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::color ( uchar r, uchar g, uchar b ) [inline], [protected],


[virtual]

see fl color(uchar r, uchar g, uchar b).


Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

Fl Color Fl Graphics Driver::color ( ) [inline]

see fl color(void).

void Fl Graphics Driver::curve ( double X0, double Y0, double X1, double Y1, double X2, double
Y2, double X3, double Y3 ) [protected], [virtual]

see fl curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3).
Reimplemented in Fl PostScript Graphics Driver.

virtual int Fl Graphics Driver::descent ( ) [inline], [virtual]

see fl descent().
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [inline],
[protected], [virtual]

see fl draw(const char ∗str, int n, int x, int y).


Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y )
[inline], [protected], [virtual]

see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP, int
cx, int cy ) [inline], [protected], [virtual]

Draws an Fl RGB Image object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
444 CHAPTER 31. CLASS DOCUMENTATION

virtual void Fl Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int cx,
int cy ) [inline], [protected], [virtual]
Draws an Fl Pixmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Printer Graphics Driver, Fl GDI Graphics Driver,
Fl Quartz Graphics Driver, and Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int cx,
int cy ) [inline], [protected], [virtual]
Draws an Fl Bitmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Printer Graphics Driver, Fl GDI Graphics Driver,
Fl Quartz Graphics Driver, and Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D
= 3, int L = 0 ) [inline], [protected], [virtual]
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y,
int W, int H, int D = 3 ) [inline], [protected], [virtual]
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 1, int L = 0 ) [inline], [protected], [virtual]
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X,
int Y, int W, int H, int D = 1 ) [inline], [protected], [virtual]
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

void Fl Graphics Driver::end complex polygon ( ) [protected], [virtual]


see fl end complex polygon().
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::end line ( ) [protected], [virtual]


see fl end line().
Reimplemented in Fl PostScript Graphics Driver.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 445

void Fl Graphics Driver::end loop ( ) [protected], [virtual]

see fl end loop().


Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::end points ( ) [protected], [virtual]

see fl end points().


Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::end polygon ( ) [protected], [virtual]

see fl end polygon().


Reimplemented in Fl PostScript Graphics Driver.

virtual void Fl Graphics Driver::font ( Fl Font face, Fl Fontsize fsize ) [inline], [virtual]

see fl font(Fl Font face, Fl Fontsize size).


Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

Fl Font Fl Graphics Driver::font ( ) [inline]

see fl font(void).

void Fl Graphics Driver::gap ( ) [protected], [virtual]

see fl gap().
Reimplemented in Fl PostScript Graphics Driver.

virtual int Fl Graphics Driver::height ( ) [inline], [virtual]

see fl height().
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

void Fl Graphics Driver::line ( int x, int y, int x1, int y1 ) [protected], [virtual]

see fl line(int x, int y, int x1, int y1).


Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::line ( int x, int y, int x1, int y1, int x2, int y2 ) [protected],
[virtual]

see fl line(int x, int y, int x1, int y1, int x2, int y2).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::line style ( int style, int width = 0, char ∗ dashes = 0 ) [protected],
[virtual]

see fl line style(int style, int width, char∗ dashes).


Reimplemented in Fl PostScript Graphics Driver.
446 CHAPTER 31. CLASS DOCUMENTATION

void Fl Graphics Driver::loop ( int x0, int y0, int x1, int y1, int x2, int y2 ) [protected],
[virtual]
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::loop ( int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3 )
[protected], [virtual]
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::mult matrix ( double a, double b, double c, double d, double x, double
y ) [protected]
see fl mult matrix(double a, double b, double c, double d, double x, double y).

int Fl Graphics Driver::not clipped ( int x, int y, int w, int h ) [protected], [virtual]
see fl not clipped(int x, int y, int w, int h).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::pie ( int x, int y, int w, int h, double a1, double a2 ) [protected],
[virtual]
see fl pie(int x, int y, int w, int h, double a1, double a2).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::point ( int x, int y ) [protected], [virtual]


see fl point(int x, int y).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::polygon ( int x0, int y0, int x1, int y1, int x2, int y2 ) [protected],
[virtual]
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::polygon ( int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3 )
[protected], [virtual]
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::pop clip ( ) [protected], [virtual]


see fl pop clip().
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::pop matrix ( ) [protected]


see fl pop matrix().
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 447

void Fl Graphics Driver::push clip ( int x, int y, int w, int h ) [protected], [virtual]
see fl push clip(int x, int y, int w, int h).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::push matrix ( ) [protected]


see fl push matrix().

void Fl Graphics Driver::push no clip ( ) [protected], [virtual]


see fl push no clip().
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::rect ( int x, int y, int w, int h ) [protected], [virtual]


see fl rect(int x, int y, int w, int h).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::rectf ( int x, int y, int w, int h ) [protected], [virtual]


see fl rectf(int x, int y, int w, int h).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::restore clip ( ) [protected]


see fl restore clip().

void Fl Graphics Driver::rotate ( double d ) [protected]


see fl rotate(double d).

virtual void Fl Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [inline],
[protected], [virtual]
see fl rtl draw(const char ∗str, int n, int x, int y).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

void Fl Graphics Driver::scale ( double x, double y ) [inline], [protected]


see fl scale(double x, double y).

void Fl Graphics Driver::scale ( double x ) [inline], [protected]


see fl scale(double x).

Fl Fontsize Fl Graphics Driver::size ( ) [inline]


see fl size().

void Fl Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int & w, int & h )
[virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.
448 CHAPTER 31. CLASS DOCUMENTATION

double Fl Graphics Driver::transform dx ( double x, double y ) [protected]


see fl transform dx(double x, double y).

double Fl Graphics Driver::transform dy ( double x, double y ) [protected]


see fl transform dy(double x, double y).

double Fl Graphics Driver::transform x ( double x, double y ) [protected]


see fl transform x(double x, double y).

double Fl Graphics Driver::transform y ( double x, double y ) [protected]


see fl transform y(double x, double y).

void Fl Graphics Driver::transformed vertex ( double xf, double yf ) [protected],


[virtual]
see fl transformed vertex(double xf, double yf).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::translate ( double x, double y ) [inline], [protected]


see fl translate(double x, double y).

void Fl Graphics Driver::vertex ( double x, double y ) [protected], [virtual]


see fl vertex(double x, double y).
Reimplemented in Fl PostScript Graphics Driver.

virtual double Fl Graphics Driver::width ( const char ∗ str, int n ) [inline], [virtual]
see fl width(const char ∗str, int n).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

virtual double Fl Graphics Driver::width ( unsigned int c ) [inline], [virtual]


see fl width(unsigned int n).
Reimplemented in Fl Xlib Graphics Driver, Fl GDI Graphics Driver, Fl Quartz Graphics Driver, and
Fl PostScript Graphics Driver.

void Fl Graphics Driver::xyline ( int x, int y, int x1 ) [protected], [virtual]


see fl xyline(int x, int y, int x1).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::xyline ( int x, int y, int x1, int y2 ) [protected], [virtual]
see fl xyline(int x, int y, int x1, int y2).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::xyline ( int x, int y, int x1, int y2, int x3 ) [protected], [virtual]
see fl xyline(int x, int y, int x1, int y2, int x3).
Reimplemented in Fl PostScript Graphics Driver.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 449

void Fl Graphics Driver::yxline ( int x, int y, int y1 ) [protected], [virtual]


see fl yxline(int x, int y, int y1).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::yxline ( int x, int y, int y1, int x2 ) [protected], [virtual]
see fl yxline(int x, int y, int y1, int x2).
Reimplemented in Fl PostScript Graphics Driver.

void Fl Graphics Driver::yxline ( int x, int y, int y1, int x2, int y3 ) [protected], [virtual]
see fl yxline(int x, int y, int y1, int x2, int y3).
Reimplemented in Fl PostScript Graphics Driver.

31.53.4 Friends And Related Function Documentation


void fl arc ( double x, double y, double r, double start, double end ) [friend]
Adds a series of points to the current path on the arc of a circle.
You can get elliptical paths by using scale and rotate before calling fl arc().
Parameters
in x,y,r center and radius of circular arc
in start,end angles of start and end of arc measured in degrees counter-clockwise
from 3 o’clock. If end is less than start then it draws the arc in a
clockwise direction.
Examples:
// Draw an arc of points
fl begin points();
fl arc(100.0, 100.0, 50.0, 0.0, 180.0);
fl end points();

// Draw arc with a line


fl begin line();
fl arc(200.0, 100.0, 50.0, 0.0, 180.0);
fl end line();

// Draw filled arc


fl begin polygon();
fl arc(300.0, 100.0, 50.0, 0.0, 180.0);
fl end polygon();

void fl arc ( int x, int y, int w, int h, double a1, double a2 ) [friend]
Draw ellipse sections using integer coordinates.
These functions match the rather limited circle drawing code provided by X and WIN32. The advantage
over using fl arc with floating point coordinates is that they are faster because they often use the hardware,
and they draw much nicer small circles, since the small sizes are often hard-coded bitmaps.
If a complete circle is drawn it will fit inside the passed bounding box. The two angles are measured
in degrees counter-clockwise from 3 o’clock and are the starting and ending angle of the arc, a2 must be
greater or equal to a1.
fl arc() draws a series of lines to approximate the arc. Notice that the integer version of fl arc() has
a different number of arguments than the double version fl arc(double x, double y, double r, double start,
double end)
450 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in x,y,w,h bounding box of complete circle
in a1,a2 start and end angles of arc measured in degrees counter-clockwise from
3 o’clock. a2 must be greater than or equal to a1.

void fl begin complex polygon ( ) [friend]


Starts drawing a complex filled polygon.
The polygon may be concave, may have holes in it, or may be several disconnected pieces. Call fl gap()
to separate loops of the path.
To outline the polygon, use fl begin loop() and replace each fl gap() with fl end loop();fl begin loop()
pairs.
Note
For portability, you should only draw polygons that appear the same whether ”even/odd” or ”non-
zero” winding rules are used to fill them. Holes should be drawn in the opposite direction to the
outside loop.

void fl begin points ( ) [friend]


Starts drawing a list of points.
Points are added to the list with fl vertex()

void fl circle ( double x, double y, double r ) [friend]


fl circle() is equivalent to fl arc(x,y,r,0,360), but may be faster.
It must be the only thing in the path: if you want a circle as part of a complex polygon you must use
fl arc()
Parameters
in x,y,r center and radius of circle

int fl clip box ( int x, int y, int w, int h, int & X, int & Y, int & W, int & H ) [friend]
Intersects the rectangle with the current clip region and returns the bounding box of the result.
Returns non-zero if the resulting rectangle is different to the original. This can be used to limit the
necessary drawing to a rectangle. W and H are set to zero if the rectangle is completely outside the region.
Parameters
in x,y,w,h position and size of rectangle
out X,Y,W,H position and size of resulting bounding box.

Returns
Non-zero if the resulting rectangle is different to the original.

void fl clip region ( Fl Region r ) [friend]


Replaces the top of the clipping stack with a clipping region of any shape.
Fl Region is an operating system specific type.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 451

Parameters
in r clipping region

void fl color ( Fl Color c ) [friend]


Sets the color for all subsequent drawing operations.
For colormapped displays, a color cell will be allocated out of fl colormap the first time you use a
color. If the colormap fills up then a least-squares algorithm is used to find the closest color. If no valid
graphical context (fl gc) is available, the foreground is not set for the current window.
Parameters
in c color

void fl color ( uchar r, uchar g, uchar b ) [friend]


Sets the color for all subsequent drawing operations.
The closest possible match to the RGB color is used. The RGB color is used directly on TrueColor
displays. For colormap visuals the nearest index in the gray ramp or color cube is used. If no valid
graphical context (fl gc) is available, the foreground is not set for the current window.
Parameters
in r,g,b color components

void fl copy offscreen ( int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy )
[friend]
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
Parameters
x,y position where to draw the copied rectangle
w,h size of the copied rectangle
pixmap offscreen buffer containing the rectangle to copy
srcx,srcy origin in offscreen buffer of rectangle to copy

void fl curve ( double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3 ) [friend]
Adds a series of points on a Bezier curve to the path.
The curve ends (and two of the points) are at X0,Y0 and X3,Y3.
Parameters
in X0,Y0 curve start point
in X1,Y1 curve control point
in X2,Y2 curve control point
in X3,Y3 curve end point

void fl draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D = 3, int L = 0 )
[friend]
Draws an 8-bit per color RGB or luminance image.
452 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in buf points at the ”r” data of the top-left pixel. Color data must be in r,g,b
order. Luminance data is only one gray byte.
in X,Y position where to put top-left corner of image
in W,H size of the image
in D delta to add to the pointer between pixels. It may be any value greater
than or equal to 1, or it can be negative to flip the image horizontally
in L delta to add to the pointer between lines (if 0 is passed it uses W ∗ D),
and may be larger than W ∗ D to crop data, or negative to flip the image
vertically
It is highly recommended that you put the following code before the first show() of any window in your
program to get rid of the dithering if possible:
Fl::visual(FL RGB);

Gray scale (1-channel) images may be drawn. This is done if abs(D) is less than 3, or by calling fl -
draw image mono(). Only one 8-bit sample is used for each pixel, and on screens with different numbers
of bits for red, green, and blue only gray colors are used. Setting D greater than 1 will let you display one
channel of a color image.
Note:
The X version does not support all possible visuals. If FLTK cannot draw the image in the current
visual it will abort. FLTK supports any visual of 8 bits or less, and all common TrueColor visuals up
to 32 bits.

void fl draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int W, int H, int D = 3 )
[friend]
Draws an image using a callback function to generate image data.
You can generate the image as it is being drawn, or do arbitrary decompression of stored data, provided
it can be decompressed to individual scan lines easily.
Parameters
in cb callback function to generate scan line data
in data user data passed to callback function
in X,Y screen position of top left pixel
in W,H image width and height
in D data size in bytes (must be greater than 0)

See Also
fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L)

The callback function cb is called with the void∗ data user data pointer to allow access to a structure
of information about the image, and the x, y, and w of the scan line desired from the image. 0,0 is the
upper-left corner of the image, not x, y. A pointer to a buffer to put the data into is passed. You must copy
w pixels from scanline y, starting at pixel x, to this buffer.
Due to cropping, less than the whole image may be requested. So x may be greater than zero, the first
y may be greater than zero, and w may be less than W. The buffer is long enough to store the entire W ∗ D
pixels, this is for convenience with some decompression schemes where you must decompress the entire
line at once: decompress it into the buffer, and then if x is not zero, copy the data over so the x’th pixel
is at the start of the buffer.
You can assume the y’s will be consecutive, except the first one may be greater than zero.
If D is 4 or more, you must fill in the unused bytes with zero.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 453

void fl draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H, int D = 1, int L = 0 )
[friend]
Draws a gray-scale (1 channel) image.
See Also
fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L)

FL EXPORT void fl draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int W,
int H, int D = 1 ) [friend]
Draws a gray-scale image using a callback function to generate image data.
See Also
fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D)

void fl font ( Fl Font face, Fl Fontsize size ) [friend]


Sets the current font, which is then used in various drawing routines.
You may call this outside a draw context if necessary to call fl width(), but on X this will open the
display.
The font is identified by a face and a size. The size of the font is measured in pixels and not
”points”. Lines should be spaced size pixels apart or more.

void fl gap ( ) [friend]


Call fl gap() to separate loops of the path.
It is unnecessary but harmless to call fl gap() before the first vertex, after the last vertex, or several
times in a row.

void fl line style ( int style, int width = 0, char ∗ dashes = 0 ) [friend]
Sets how to draw lines (the ”pen”).
If you change this it is your responsibility to set it back to the default using fl line style(0).
Parameters
in style A bitmask which is a bitwise-OR of a line style, a cap style, and a join
style. If you don’t specify a dash type you will get a solid line. If you
don’t specify a cap or join type you will get a system-defined default of
whatever value is fastest.
in width The thickness of the lines in pixels. Zero results in the system defined
default, which on both X and Windows is somewhat different and nicer
than 1.
in dashes A pointer to an array of dash lengths, measured in pixels. The first lo-
cation is how long to draw a solid portion, the next is how long to draw
the gap, then the solid, etc. It is terminated with a zero-length entry. A
NULL pointer or a zero-length array results in a solid line. Odd array
sizes are not supported and result in undefined behavior.

Note
Because of how line styles are implemented on Win32 systems, you must set the line style after
setting the drawing color. If you set the color after the line style you will lose the line style settings.
The dashes array does not work under Windows 95, 98 or Me, since those operating systems do
not support complex line styles.
454 CHAPTER 31. CLASS DOCUMENTATION

void fl mult matrix ( double a, double b, double c, double d, double x, double y ) [friend]
Concatenates another transformation onto the current one.
31.53. FL GRAPHICS DRIVER CLASS REFERENCE 455

Parameters
in a,b,c,d,x,y transformation matrix elements such that X’ = aX + cY + x and
Y’ = bX +dY + y

int fl not clipped ( int x, int y, int w, int h ) [friend]


Does the rectangle intersect the current clip region?
Parameters
in x,y,w,h position and size of rectangle

Returns
non-zero if any of the rectangle intersects the current clip region. If this returns 0 you don’t have to
draw the object.

Note
Under X this returns 2 if the rectangle is partially clipped, and 1 if it is entirely inside the clip region.

void fl pie ( int x, int y, int w, int h, double a1, double a2 ) [friend]
Draw filled ellipse sections using integer coordinates.
Like fl arc(), but fl pie() draws a filled-in pie slice. This slice may extend outside the line drawn by
fl arc(); to avoid this use w - 1 and h - 1.
Parameters
in x,y,w,h bounding box of complete circle
in a1,a2 start and end angles of arc measured in degrees counter-clockwise from
3 o’clock. a2 must be greater than or equal to a1.

void fl polygon ( int x0, int y0, int x1, int y1, int x2, int y2 ) [friend]
Fills a 3-sided polygon.
The polygon must be convex.

void fl polygon ( int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3 ) [friend]
Fills a 4-sided polygon.
The polygon must be convex.

void fl pop clip ( ) [friend]


Restores the previous clip region.
You must call fl pop clip() once for every time you call fl push clip(). Unpredictable results may occur
if the clip stack is not empty when you return to FLTK.

void fl push clip ( int x, int y, int w, int h ) [friend]


Intersects the current clip region with a rectangle and pushes this new region onto the stack.
456 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in x,y,w,h position and size

void fl push matrix ( ) [friend]


Saves the current transformation matrix on the stack.
The maximum depth of the stack is 32.

void fl rect ( int x, int y, int w, int h ) [friend]


Draws a 1-pixel border inside the given bounding box.
This function is meant for quick drawing of simple boxes. The behavior is undefined for line widths
that are not 1.

void fl rotate ( double d ) [friend]


Concatenates rotation transformation onto the current one.
Parameters
in d - rotation angle, counter-clockwise in degrees (not radians)

void fl scale ( double x, double y ) [friend]


Concatenates scaling transformation onto the current one.
Parameters
in x,y scale factors in x-direction and y-direction

void fl scale ( double x ) [friend]


Concatenates scaling transformation onto the current one.
Parameters
in x scale factor in both x-direction and y-direction

double fl transform dx ( double x, double y ) [friend]


Transforms distance using current transformation matrix.
Parameters
in x,y coordinate

double fl transform dy ( double x, double y ) [friend]


Transforms distance using current transformation matrix.
Parameters
in x,y coordinate

double fl transform x ( double x, double y ) [friend]


Transforms coordinate using the current transformation matrix.
31.54. FL GROUP CLASS REFERENCE 457

Parameters
in x,y coordinate

double fl transform y ( double x, double y ) [friend]

Transforms coordinate using the current transformation matrix.


Parameters
in x,y coordinate

void fl transformed vertex ( double xf, double yf ) [friend]

Adds coordinate pair to the vertex list without further transformations.


Parameters
in xf,yf transformed coordinate

void fl translate ( double x, double y ) [friend]

Concatenates translation transformation onto the current one.


Parameters
in x,y translation factor in x-direction and y-direction

void fl vertex ( double x, double y ) [friend]

Adds a single vertex to the current path.


Parameters
in x,y coordinate
The documentation for this class was generated from the following files:

• Fl Device.H
• fl arc.cxx
• fl arci.cxx
• fl curve.cxx
• Fl Device.cxx
• Fl Double Window.cxx
• fl line style.cxx
• fl rect.cxx
• fl vertex.cxx

31.54 Fl Group Class Reference


The Fl Group class is the FLTK container widget.
#include <Fl Group.H>
Inheritance diagram for Fl Group:
458 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Group

Fl_Browser_

Fl_Color_Chooser

Fl_Help_View

Fl_Input_Choice

Fl_Pack

Fl_Scroll

Fl_Spinner

Fl_Table

Fl_Tabs

Fl_Text_Display

Fl_Tile

Fl_Tree

Fl_Window

Fl_Wizard

Public Member Functions


• Fl Widget ∗& ddfdesign kludge ()
This is for forms compatibility only.
• void add (Fl Widget &)
The widget is removed from its current group (if any) and then added to the end of this group.
• void add (Fl Widget ∗o)
See void Fl Group::add(Fl Widget &w)
• void add resizable (Fl Widget &o)
Adds a widget to the group and makes it the resizable widget.
• Fl Widget ∗const ∗ array () const
Returns a pointer to the array of children.
• virtual Fl Group ∗ as group ()
Returns an Fl Group pointer if this widget is an Fl Group.
• void begin ()
Sets the current group so you can build the widget tree by just constructing the widgets.
• Fl Widget ∗ child (int n) const
Returns array()[n].
• int children () const
Returns how many child widgets the group has.
31.54. FL GROUP CLASS REFERENCE 459

• void clear ()
Deletes all child widgets from memory recursively.
• void clip children (int c)
Controls whether the group widget clips the drawing of child widgets to its bounding box.
• unsigned int clip children ()
Returns the current clipping mode.
• void end ()
Exactly the same as current(this->parent()).
• int find (const Fl Widget ∗) const
Searches the child array for the widget and returns the index.
• int find (const Fl Widget &o) const
See int Fl Group::find(const Fl Widget ∗w) const.
• Fl Group (int, int, int, int, const char ∗=0)
Creates a new Fl Group widget using the given position, size, and label string.
• void focus (Fl Widget ∗W)
• void forms end ()
This is for forms compatibility only.
• int handle (int)
Handles the specified event.
• void init sizes ()
Resets the internal array of widget sizes and positions.
• void insert (Fl Widget &, int i)
The widget is removed from its current group (if any) and then inserted into this group.
• void insert (Fl Widget &o, Fl Widget ∗before)
This does insert(w, find(before)).
• void remove (int index)
Removes the widget at index from the group but does not delete it.
• void remove (Fl Widget &)
Removes a widget from the group but does not delete it.
• void remove (Fl Widget ∗o)
Removes the widget o from the group.
• void resizable (Fl Widget &o)
See void Fl Group::resizable(Fl Widget ∗box)
• void resizable (Fl Widget ∗o)
The resizable widget defines the resizing box for the group.
• Fl Widget ∗ resizable () const
See void Fl Group::resizable(Fl Widget ∗box)
• void resize (int, int, int, int)
Resizes the Fl Group widget and all of its children.
• virtual ∼Fl Group ()
The destructor also deletes all the children.

Static Public Member Functions


• static Fl Group ∗ current ()
Returns the currently active group.
• static void current (Fl Group ∗g)
Sets the current group.
460 CHAPTER 31. CLASS DOCUMENTATION

Protected Member Functions


• void draw ()
Draws the widget.
• void draw child (Fl Widget &widget) const
Forces a child to redraw.
• void draw children ()
Draws all children of the group.
• void draw outside label (const Fl Widget &widget) const
Parents normally call this to draw outside labels of child widgets.
• int ∗ sizes ()
Returns the internal array of widget sizes and positions.
• void update child (Fl Widget &widget) const
Draws a child only if it needs it.

Additional Inherited Members


31.54.1 Detailed Description
The Fl Group class is the FLTK container widget.
It maintains an array of child widgets. These children can themselves be any widget including Fl-
Group. The most important subclass of Fl Group is Fl Window, however groups can also be used to
control radio buttons or to enforce resize behavior.
The tab and arrow keys are used to move the focus between widgets of this group, and to other groups.
The only modifier grabbed is shift (for shift-tab), so that ctrl-tab, alt-up, and such are free for the app to use
as shortcuts.

31.54.2 Constructor & Destructor Documentation


Fl Group::Fl Group ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Group widget using the given position, size, and label string.
The default boxtype is FL NO BOX.

Fl Group::∼Fl Group ( ) [virtual]


The destructor also deletes all the children.
This allows a whole tree to be deleted at once, without having to keep a pointer to all the children in
the user code.
It is allowed that the Fl Group and all of its children are automatic (local) variables, but you must
declare the Fl Group first, so that it is destroyed last.
If you add static or automatic (local) variables to an Fl Group, then it is your responsibility to remove
(or delete) all such static or automatic child widgets before destroying the group - otherwise the child
widgets’ destructors would be called twice!

31.54.3 Member Function Documentation


Fl Widget ∗const ∗ Fl Group::array ( ) const
Returns a pointer to the array of children.
This pointer is only valid until the next time a child is added or removed.
31.54. FL GROUP CLASS REFERENCE 461

virtual Fl Group∗ Fl Group::as group ( ) [inline], [virtual]


Returns an Fl Group pointer if this widget is an Fl Group.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from
Fl Group. If it returns non-NULL, then the widget in question is derived from Fl Group, and you can use
the returned pointer to access its children or other Fl Group-specific methods.
Example:
void my callback (Fl Widget *w, void *) {
Fl Group *g = w->as group();
if (g)
printf ("This group has %d children\n",g->children());
else
printf ("This widget is not a group!\n");
}

Return values
NULL if this widget is not derived from Fl Group.

Note
This method is provided to avoid dynamic cast.

See Also
Fl Widget::as window(), Fl Widget::as gl window()

Reimplemented from Fl Widget.

void Fl Group::begin ( )
Sets the current group so you can build the widget tree by just constructing the widgets.
begin() is automatically called by the constructor for Fl Group (and thus for Fl Window as well). be-
gin() is exactly the same as current(this). Don’t forget to end() the group or window!

Fl Widget∗ Fl Group::child ( int n ) const [inline]


Returns array()[n].
No range checking is done!

void Fl Group::clear ( )
Deletes all child widgets from memory recursively.
This method differs from the remove() method in that it affects all child widgets and deletes them from
memory.

void Fl Group::clip children ( int c ) [inline]


Controls whether the group widget clips the drawing of child widgets to its bounding box.
Set c to 1 if you want to clip the child widgets to the bounding box.
The default is to not clip (0) the drawing of child widgets.

unsigned int Fl Group::clip children ( ) [inline]


Returns the current clipping mode.
Returns
true, if clipping is enabled, false otherwise.
462 CHAPTER 31. CLASS DOCUMENTATION

See Also
void Fl Group::clip children(int c)

Fl Group ∗ Fl Group::current ( ) [static]


Returns the currently active group.
The Fl Widget constructor automatically does current()->add(widget) if this is not null. To prevent
new widgets from being added to a group, call Fl Group::current(0).

void Fl Group::current ( Fl Group ∗ g ) [static]


Sets the current group.

See Also
Fl Group::current()

void Fl Group::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.
Reimplemented in Fl Table, Fl Tree, Fl Text Display, Fl Tabs, Fl Window, Fl Scroll, Fl Pack, and
Fl Glut Window.

void Fl Group::draw child ( Fl Widget & widget ) const [protected]


Forces a child to redraw.
This draws a child widget, if it is not clipped. The damage bits are cleared after drawing.

void Fl Group::draw children ( ) [protected]


Draws all children of the group.
This is useful, if you derived a widget from Fl Group and want to draw a special border or background.
You can call draw children() from the derived draw() method after drawing the box, border, or background.

void Fl Group::draw outside label ( const Fl Widget & widget ) const [protected]
Parents normally call this to draw outside labels of child widgets.

void Fl Group::end ( )
Exactly the same as current(this->parent()).
Any new widgets added to the widget tree will be added to the parent of the group.
31.54. FL GROUP CLASS REFERENCE 463

int Fl Group::find ( const Fl Widget ∗ o ) const


Searches the child array for the widget and returns the index.
Returns children() if the widget is NULL or not found.

void Fl Group::focus ( Fl Widget ∗ W ) [inline]


Deprecated This is for backwards compatibility only. You should use W->take focus() instead.

See Also
Fl Widget::take focus();

int Fl Group::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.


Reimplemented in Fl Tree, Fl Table, Fl Window, Fl Tabs, Fl Text Display, Fl Scroll, Fl Spinner, Fl -
Table Row, Fl Text Editor, Fl Glut Window, and Fl Tile.

void Fl Group::init sizes ( )


Resets the internal array of widget sizes and positions.
The Fl Group widget keeps track of the original widget sizes and positions when resizing occurs so that
if you resize a window back to its original size the widgets will be in the correct places. If you rearrange
the widgets in your group, call this method to register the new arrangement with the Fl Group that contains
them.
If you add or remove widgets, this will be done automatically.

Note
The internal array of widget sizes and positions will be allocated and filled when the next resize()
occurs.

See Also
sizes()
464 CHAPTER 31. CLASS DOCUMENTATION

void Fl Group::insert ( Fl Widget & o, int index )

The widget is removed from its current group (if any) and then inserted into this group.
It is put at index n - or at the end, if n >= children(). This can also be used to rearrange the widgets
inside a group.

void Fl Group::insert ( Fl Widget & o, Fl Widget ∗ before ) [inline]

This does insert(w, find(before)).


This will append the widget if before is not in the group.

void Fl Group::remove ( int index )

Removes the widget at index from the group but does not delete it.
This method does nothing if index is out of bounds.
This method differs from the clear() method in that it only affects a single widget and does not delete it
from memory.

Since
FLTK 1.3.0

void Fl Group::remove ( Fl Widget & o )

Removes a widget from the group but does not delete it.
This method does nothing if the widget is not a child of the group.
This method differs from the clear() method in that it only affects a single widget and does not delete it
from memory.

Note
If you have the child’s index anyway, use remove(int index) instead, because this doesn’t need a child
lookup in the group’s table of children. This can be much faster, if there are lots of children.

void Fl Group::remove ( Fl Widget ∗ o ) [inline]

Removes the widget o from the group.

See Also
void remove(Fl Widget&)

void Fl Group::resizable ( Fl Widget ∗ o ) [inline]

The resizable widget defines the resizing box for the group.
When the group is resized it calculates a new size and position for all of its children. Widgets that are
horizontally or vertically inside the dimensions of the box are scaled to the new size. Widgets outside the
box are moved.
In these examples the gray area is the resizable:
31.54. FL GROUP CLASS REFERENCE 465

Figure 31.14: before resize

Figure 31.15: after resize

The resizable may be set to the group itself, in which case all the contents are resized. This is the
default value for Fl Group, although NULL is the default for Fl Window and Fl Pack.
If the resizable is NULL then all widgets remain a fixed size and distance from the top-left corner.
It is possible to achieve any type of resize behavior by using an invisible Fl Box as the resizable and/or
by using a hierarchy of child Fl Group’s.

void Fl Group::resize ( int X, int Y, int W, int H ) [virtual]


Resizes the Fl Group widget and all of its children.
The Fl Group widget first resizes itself, and then it moves and resizes all its children according to the
rules documented for Fl Group::resizable(Fl Widget∗)

See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)

Reimplemented from Fl Widget.


Reimplemented in Fl Table, Fl Tree, Fl Help View, Fl Text Display, Fl Window, Fl Input Choice,
Fl Spinner, Fl Scroll, Fl Overlay Window, and Fl Tile.

int ∗ Fl Group::sizes ( ) [protected]


Returns the internal array of widget sizes and positions.
466 CHAPTER 31. CLASS DOCUMENTATION

If the sizes() array does not exist, it will be allocated and filled with the current widget sizes and
positions.

Note
You should never need to use this method directly, unless you have special needs to rearrange the
children of a Fl Group. Fl Tile uses this to rearrange its widget positions.

See Also
init sizes()

Todo Should the internal representation of the sizes() array be documented?

void Fl Group::update child ( Fl Widget & widget ) const [protected]

Draws a child only if it needs it.


This draws a child widget, if it is not clipped and if any damage() bits are set. The damage bits are
cleared after drawing.

See Also
Fl Group::draw child(Fl Widget& widget) const

The documentation for this class was generated from the following files:

• Fl Group.H
• Fl Group.cxx
• forms compatability.cxx

31.55 Fl GTK File Chooser Class Reference


Inheritance diagram for Fl GTK File Chooser:

Fl_FLTK_File_Chooser

Fl_GTK_File_Chooser

Friends
• class Fl Native File Chooser

Additional Inherited Members


The documentation for this class was generated from the following files:

• Fl Native File Chooser.H


• Fl Native File Chooser GTK.cxx
31.56. FL HELP BLOCK STRUCT REFERENCE 467

31.56 Fl Help Block Struct Reference


Public Attributes
• Fl Color bgcolor
• uchar border
• const char ∗ end
• int h
• int line [32]
• const char ∗ start
• int w
• int x
• int y

The documentation for this struct was generated from the following file:
• Fl Help View.H

31.57 Fl Help Dialog Class Reference


The Fl Help Dialog widget displays a standard help dialog window using the Fl Help View widget.

Public Member Functions


• Fl Help Dialog ()
The constructor creates the dialog pictured above.
• int h ()
Returns the position and size of the help dialog.
• void hide ()
Hides the Fl Help Dialog window.
• void load (const char ∗f)
Loads the specified HTML file into the Fl Help View widget.
• void position (int xx, int yy)
Set the screen position of the dialog.
• void resize (int xx, int yy, int ww, int hh)
Change the position and size of the dialog.
• void show ()
Shows the Fl Help Dialog window.
• void show (int argc, char ∗∗argv)
Shows the main Help Dialog Window Delegates call to encapsulated window void Fl Window::show(int
argc, char ∗∗argv) instance method.
• void textsize (Fl Fontsize s)
Sets or gets the default text size for the help view.
• Fl Fontsize textsize ()
Sets or gets the default text size for the help view.
• void topline (const char ∗n)
Sets the top line in the Fl Help View widget to the named or numbered line.
• void topline (int n)
Sets the top line in the Fl Help View widget to the named or numbered line.
• void value (const char ∗f)
468 CHAPTER 31. CLASS DOCUMENTATION

The first form sets the current buffer to the string provided and reformats the text.
• const char ∗ value () const
The first form sets the current buffer to the string provided and reformats the text.
• int visible ()
Returns 1 if the Fl Help Dialog window is visible.
• int w ()
Returns the position and size of the help dialog.
• int x ()
Returns the position and size of the help dialog.
• int y ()
Returns the position and size of the help dialog.
• ∼Fl Help Dialog ()
The destructor destroys the widget and frees all memory that has been allocated for the current file.

31.57.1 Detailed Description


The Fl Help Dialog widget displays a standard help dialog window using the Fl Help View widget.

Figure 31.16: Fl Help Dialog

31.57.2 Constructor & Destructor Documentation


Fl Help Dialog::Fl Help Dialog ( )
The constructor creates the dialog pictured above.

31.57.3 Member Function Documentation


int Fl Help Dialog::h ( )
Returns the position and size of the help dialog.

void Fl Help Dialog::hide ( )


Hides the Fl Help Dialog window.
31.57. FL HELP DIALOG CLASS REFERENCE 469

void Fl Help Dialog::load ( const char ∗ f )

Loads the specified HTML file into the Fl Help View widget.
The filename can also contain a target name (”filename.html#target”).

void Fl Help Dialog::position ( int x, int y )

Set the screen position of the dialog.

void Fl Help Dialog::resize ( int xx, int yy, int ww, int hh )

Change the position and size of the dialog.

void Fl Help Dialog::show ( )

Shows the Fl Help Dialog window.


Shows the main Help Dialog Window Delegates call to encapsulated window void Fl Window::show()
method.

void Fl Help Dialog::textsize ( Fl Fontsize s )

Sets or gets the default text size for the help view.
Sets the internal Fl Help View instance text size.
Delegates call to encapsulated view void Fl Help View::textsize(Fl Fontsize s) instance method

uchar Fl Help Dialog::textsize ( )

Sets or gets the default text size for the help view.

void Fl Help Dialog::value ( const char ∗ v )

The first form sets the current buffer to the string provided and reformats the text.
It also clears the history of the ”back” and ”forward” buttons. The second form returns the current
buffer contents.

const char ∗ Fl Help Dialog::value ( ) const

The first form sets the current buffer to the string provided and reformats the text.
It also clears the history of the ”back” and ”forward” buttons. The second form returns the current
buffer contents.

int Fl Help Dialog::visible ( )

Returns 1 if the Fl Help Dialog window is visible.

int Fl Help Dialog::w ( )

Returns the position and size of the help dialog.

int Fl Help Dialog::x ( )

Returns the position and size of the help dialog.


470 CHAPTER 31. CLASS DOCUMENTATION

int Fl Help Dialog::y ( )


Returns the position and size of the help dialog.
The documentation for this class was generated from the following files:

• Fl Help Dialog.H
• Fl Help Dialog.cxx
• Fl Help Dialog Dox.cxx

31.58 Fl Help Font Stack Struct Reference


Public Member Functions
• size t count () const
Gets the current count of font style elements in the stack.
• Fl Help Font Stack ()
font stack construction, initialize attributes.
• void init (Fl Font f, Fl Fontsize s, Fl Color c)
• void pop (Fl Font &f, Fl Fontsize &s, Fl Color &c)
Pops from the stack the font style triplet and calls fl font() & fl color() adequately.
• void push (Fl Font f, Fl Fontsize s, Fl Color c)
Pushes the font style triplet on the stack, also calls fl font() & fl color() adequately.
• void top (Fl Font &f, Fl Fontsize &s, Fl Color &c)
Gets the top (current) element on the stack.

Protected Attributes
• Fl Help Font Style elts [100]
font elements
• size t nfonts
current number of fonts in stack

31.58.1 Constructor & Destructor Documentation


Fl Help Font Stack::Fl Help Font Stack ( ) [inline]
font stack construction, initialize attributes.

31.58.2 Member Function Documentation


size t Fl Help Font Stack::count ( ) const [inline]
Gets the current count of font style elements in the stack.

void Fl Help Font Stack::top ( Fl Font & f, Fl Fontsize & s, Fl Color & c ) [inline]
Gets the top (current) element on the stack.
The documentation for this struct was generated from the following file:

• Fl Help View.H
31.59. FL HELP FONT STYLE STRUCT REFERENCE 471

31.59 Fl Help Font Style Struct Reference


Fl Help View font stack element definition.
#include <Fl Help View.H>

Public Member Functions


• Fl Help Font Style (Fl Font afont, Fl Fontsize asize, Fl Color acolor)
• void get (Fl Font &afont, Fl Fontsize &asize, Fl Color &acolor)
Gets current font attributes.
• void set (Fl Font afont, Fl Fontsize asize, Fl Color acolor)
Sets current font attributes.

Public Attributes
• Fl Color c
Font Color.
• Fl Font f
Font.
• Fl Fontsize s
Font Size.

31.59.1 Detailed Description


Fl Help View font stack element definition.
The documentation for this struct was generated from the following file:

• Fl Help View.H

31.60 Fl Help Link Struct Reference


Definition of a link for the html viewer.
#include <Fl Help View.H>

Public Attributes
• char filename [192]
Reference filename.
• int h
Height of link text.
• char name [32]
Link target (blank if none)
• int w
Width of link text.
• int x
X offset of link text.
• int y
Y offset of link text.
472 CHAPTER 31. CLASS DOCUMENTATION

31.60.1 Detailed Description


Definition of a link for the html viewer.
The documentation for this struct was generated from the following file:
• Fl Help View.H

31.61 Fl Help Target Struct Reference


Fl Help Target structure.
#include <Fl Help View.H>

Public Attributes
• char name [32]
Target name.
• int y
Y offset of target.

31.61.1 Detailed Description


Fl Help Target structure.
The documentation for this struct was generated from the following file:
• Fl Help View.H

31.62 Fl Help View Class Reference


The Fl Help View widget displays HTML text.
#include <Fl Help View.H>
Inheritance diagram for Fl Help View:

Fl_Widget

Fl_Group

Fl_Help_View

Public Member Functions


• void clear selection ()
Removes the current text selection.
• const char ∗ directory () const
Returns the current directory for the text in the buffer.
• const char ∗ filename () const
Returns the current filename for the text in the buffer.
• int find (const char ∗s, int p=0)
Finds the specified string s at starting position p.
• Fl Help View (int xx, int yy, int ww, int hh, const char ∗l=0)
31.62. FL HELP VIEW CLASS REFERENCE 473

The constructor creates the Fl Help View widget at the specified position and size.
• void leftline (int)
Scrolls the text to the indicated position, given a pixel column.
• int leftline () const
Gets the left position in pixels.
• void link (Fl Help Func ∗fn)
This method assigns a callback function to use when a link is followed or a file is loaded (via Fl Help View-
::load()) that requires a different file or path.
• int load (const char ∗f)
Loads the specified file.
• void resize (int, int, int, int)
Resizes the help widget.
• int scrollbar size () const
Gets the current size of the scrollbars’ troughs, in pixels.
• void scrollbar size (int newSize)
Sets the pixel size of the scrollbars’ troughs to newSize, in pixels.
• void select all ()
Selects all the text in the view.
• int size () const
Gets the size of the help view.
• void size (int W, int H)
• void textcolor (Fl Color c)
Sets the default text color.
• Fl Color textcolor () const
Returns the current default text color.
• void textfont (Fl Font f)
Sets the default text font.
• Fl Font textfont () const
Returns the current default text font.
• void textsize (Fl Fontsize s)
Sets the default text size.
• Fl Fontsize textsize () const
Gets the default text size.
• const char ∗ title ()
Returns the current document title, or NULL if there is no title.
• void topline (const char ∗n)
Scrolls the text to the indicated position, given a named destination.
• void topline (int)
Scrolls the text to the indicated position, given a pixel line.
• int topline () const
Returns the current top line in pixels.
• void value (const char ∗val)
Sets the current help text buffer to the string provided and reformats the text.
• const char ∗ value () const
Returns the current buffer contents.
• ∼Fl Help View ()
Destroys the Fl Help View widget.
474 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.62.1 Detailed Description
The Fl Help View widget displays HTML text.
Most HTML 2.0 elements are supported, as well as a primitive implementation of tables. GIF, JPEG,
and PNG images are displayed inline.
Supported HTML tags:

• A: HREF/NAME

• B

• BODY: BGCOLOR/TEXT/LINK

• BR

• CENTER

• CODE

• DD

• DL

• DT

• EM

• FONT: COLOR/SIZE/FACE=(helvetica/arial/sans/times/serif/symbol/courier)

• H1/H2/H3/H4/H5/H6

• HEAD

• HR

• I

• IMG: SRC/WIDTH/HEIGHT/ALT

• KBD

• LI

• OL

• P

• PRE

• STRONG

• TABLE: TH/TD/TR/BORDER/BGCOLOR/COLSPAN/ALIGN=CENTER|RIGHT|LEFT

• TITLE

• TT

• U

• UL

• VAR
31.62. FL HELP VIEW CLASS REFERENCE 475

Supported color names:


• black,red,green,yellow,blue,magenta,fuchsia,cyan,aqua,white,gray,grey,lime,maroon,navy,olive,purple,silver,teal.
Supported urls:
• Internal: file:
• External: http: ftp: https: ipp: mailto: news:
Quoted char names:
• Aacute aacute Acirc acirc acute AElig aelig Agrave agrave amp Aring aring Atilde atilde Auml auml
• brvbar bull
• Ccedil ccedil cedil cent copy curren
• deg divide
• Eacute eacute Ecirc ecirc Egrave egrave ETH eth Euml euml euro
• frac12 frac14 frac34
• gt
• Iacute iacute Icirc icirc iexcl Igrave igrave iquest Iuml iuml
• laquo lt
• macr micro middot
• nbsp not Ntilde ntilde
• Oacute oacute Ocirc ocirc Ograve ograve ordf ordm Oslash oslash Otilde otilde Ouml ouml
• para premil plusmn pound
• quot
• raquo reg
• sect shy sup1 sup2 sup3 szlig
• THORN thorn times trade
• Uacute uacute Ucirc ucirc Ugrave ugrave uml Uuml uuml
• Yacute yacute
• yen Yuml yuml

31.62.2 Constructor & Destructor Documentation


Fl Help View::∼Fl Help View ( )
Destroys the Fl Help View widget.
The destructor destroys the widget and frees all memory that has been allocated for the current docu-
ment.

31.62.3 Member Function Documentation


void Fl Help View::clear selection ( )
Removes the current text selection.
476 CHAPTER 31. CLASS DOCUMENTATION

const char∗ Fl Help View::directory ( ) const [inline]


Returns the current directory for the text in the buffer.

const char∗ Fl Help View::filename ( ) const [inline]


Returns the current filename for the text in the buffer.

int Fl Help View::find ( const char ∗ s, int p = 0 )


Finds the specified string s at starting position p.

Returns
the matching position or -1 if not found

void Fl Help View::leftline ( int left )


Scrolls the text to the indicated position, given a pixel column.
If the given pixel value left is out of range, then the text is scrolled to the left or right side of the
document, resp.
Parameters
in left left column number in pixels (0 = left side)

int Fl Help View::leftline ( ) const [inline]


Gets the left position in pixels.

void Fl Help View::link ( Fl Help Func ∗ fn ) [inline]


This method assigns a callback function to use when a link is followed or a file is loaded (via Fl Help -
View::load()) that requires a different file or path.
The callback function receives a pointer to the Fl Help View widget and the URI or full pathname for
the file in question. It must return a pathname that can be opened as a local file or NULL:

const char *fn(Fl Widget *w, const char *uri);

The link function can be used to retrieve remote or virtual documents, returning a temporary file that
contains the actual data. If the link function returns NULL, the value of the Fl Help View widget will
remain unchanged.
If the link callback cannot handle the URI scheme, it should return the uri value unchanged or set the
value() of the widget before returning NULL.

int Fl Help View::load ( const char ∗ f )


Loads the specified file.
This method loads the specified file or URL.

void Fl Help View::resize ( int xx, int yy, int ww, int hh ) [virtual]
Resizes the help widget.
Reimplemented from Fl Group.
31.62. FL HELP VIEW CLASS REFERENCE 477

int Fl Help View::scrollbar size ( ) const [inline]


Gets the current size of the scrollbars’ troughs, in pixels.
If this value is zero (default), this widget will use the Fl::scrollbar size() value as the scrollbar’s width.

Returns
Scrollbar size in pixels, or 0 if the global Fl::scrollbar size() is being used.

See Also
Fl::scrollbar size(int)

void Fl Help View::scrollbar size ( int newSize ) [inline]


Sets the pixel size of the scrollbars’ troughs to newSize, in pixels.
Normally you should not need this method, and should use Fl::scrollbar size(int) instead to manage
the size of ALL your widgets’ scrollbars. This ensures your application has a consistent UI, is the default
behavior, and is normally what you want.
Only use THIS method if you really need to override the global scrollbar size. The need for this should
be rare.
Setting newSize to the special value of 0 causes the widget to track the global Fl::scrollbar size(),
which is the default.
Parameters
in newSize Sets the scrollbar size in pixels.
If 0 (default), scrollbar size tracks the global Fl::scrollbar size()

See Also
Fl::scrollbar size()

void Fl Help View::select all ( )


Selects all the text in the view.

int Fl Help View::size ( ) const [inline]


Gets the size of the help view.

void Fl Help View::textcolor ( Fl Color c ) [inline]


Sets the default text color.

Fl Color Fl Help View::textcolor ( ) const [inline]


Returns the current default text color.

void Fl Help View::textfont ( Fl Font f ) [inline]


Sets the default text font.

Fl Font Fl Help View::textfont ( ) const [inline]


Returns the current default text font.
478 CHAPTER 31. CLASS DOCUMENTATION

void Fl Help View::textsize ( Fl Fontsize s ) [inline]


Sets the default text size.

Fl Fontsize Fl Help View::textsize ( ) const [inline]


Gets the default text size.

const char∗ Fl Help View::title ( ) [inline]


Returns the current document title, or NULL if there is no title.

void Fl Help View::topline ( const char ∗ n )


Scrolls the text to the indicated position, given a named destination.
Parameters
in n target name

void Fl Help View::topline ( int top )


Scrolls the text to the indicated position, given a pixel line.
If the given pixel value top is out of range, then the text is scrolled to the top or bottom of the document,
resp.
Parameters
in top top line number in pixels (0 = start of document)

int Fl Help View::topline ( ) const [inline]


Returns the current top line in pixels.

void Fl Help View::value ( const char ∗ val )


Sets the current help text buffer to the string provided and reformats the text.
The provided character string val is copied internally and will be freed when value() is called again,
or when the widget is destroyed.
If val is NULL, then the widget is cleared.

const char∗ Fl Help View::value ( ) const [inline]


Returns the current buffer contents.
The documentation for this class was generated from the following files:

• Fl Help View.H
• Fl Help View.cxx

31.63 Fl Hold Browser Class Reference


The Fl Hold Browser is a subclass of Fl Browser which lets the user select a single item, or no items by
clicking on the empty space.
#include <Fl Hold Browser.H>
Inheritance diagram for Fl Hold Browser:
31.64. FL HOR FILL SLIDER CLASS REFERENCE 479

Fl_Widget

Fl_Group

Fl_Browser_

Fl_Browser

Fl_Hold_Browser

Public Member Functions


• Fl Hold Browser (int X, int Y, int W, int H, const char ∗L=0)

Creates a new Fl Hold Browser widget using the given position, size, and label string.

Additional Inherited Members

31.63.1 Detailed Description


The Fl Hold Browser is a subclass of Fl Browser which lets the user select a single item, or no items by
clicking on the empty space.
As long as the mouse button is held down the item pointed to by it is highlighted, and this highlighting
remains on when the mouse button is released. Normally the callback is done when the user releases the
mouse, but you can change this with when().
See Fl Browser for methods to add and remove lines from the browser.

31.63.2 Constructor & Destructor Documentation


Fl Hold Browser::Fl Hold Browser ( int X, int Y, int W, int H, const char ∗ L = 0 )

Creates a new Fl Hold Browser widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX. The constructor specializes Fl Browser() by setting the type
to FL HOLD BROWSER. The destructor destroys the widget and frees all memory that has been allocated.
The documentation for this class was generated from the following files:

• Fl Hold Browser.H
• Fl Browser.cxx

31.64 Fl Hor Fill Slider Class Reference


Inheritance diagram for Fl Hor Fill Slider:
480 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Hor_Fill_Slider

Public Member Functions


• Fl Hor Fill Slider (int X, int Y, int W, int H, const char ∗L=0)

Additional Inherited Members


The documentation for this class was generated from the following files:

• Fl Hor Fill Slider.H


• Fl Slider.cxx

31.65 Fl Hor Nice Slider Class Reference


Inheritance diagram for Fl Hor Nice Slider:

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Hor_Nice_Slider

Public Member Functions


• Fl Hor Nice Slider (int X, int Y, int W, int H, const char ∗L=0)

Additional Inherited Members


The documentation for this class was generated from the following files:

• Fl Hor Nice Slider.H


• Fl Slider.cxx

31.66 Fl Hor Slider Class Reference


Horizontal Slider class.
#include <Fl Hor Slider.H>
31.67. FL HOR VALUE SLIDER CLASS REFERENCE 481

Inheritance diagram for Fl Hor Slider:

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Hor_Slider

Public Member Functions


• Fl Hor Slider (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Hor Slider widget using the given position, size, and label string.

Additional Inherited Members


31.66.1 Detailed Description
Horizontal Slider class.
See Also
class Fl Slider.

The documentation for this class was generated from the following files:

• Fl Hor Slider.H
• Fl Slider.cxx

31.67 Fl Hor Value Slider Class Reference


Inheritance diagram for Fl Hor Value Slider:

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Value_Slider

Fl_Hor_Value_Slider

Public Member Functions


• Fl Hor Value Slider (int X, int Y, int W, int H, const char ∗l=0)
482 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


The documentation for this class was generated from the following files:

• Fl Hor Value Slider.H


• Fl Value Slider.cxx

31.68 Fl Image Class Reference


Fl Image is the base class used for caching and drawing all kinds of images in FLTK.
#include <Fl Image.H>
Inheritance diagram for Fl Image:

Fl_Image

Fl_Bitmap Fl_Pixmap Fl_RGB_Image Fl_Shared_Image Fl_Tiled_Image

Fl_XBM_Image Fl_GIF_Image Fl_XPM_Image Fl_BMP_Image Fl_JPEG_Image Fl_PNG_Image Fl_PNM_Image

Public Member Functions


• virtual void color average (Fl Color c, float i)
The color average() method averages the colors in the image with the FLTK color value c.
• virtual Fl Image ∗ copy (int W, int H)
The copy() method creates a copy of the specified image.
• Fl Image ∗ copy ()
The copy() method creates a copy of the specified image.
• int count () const
The count() method returns the number of data values associated with the image.
• int d () const
Returns the current image depth.
• const char ∗const ∗ data () const
Returns a pointer to the current image data array.
• virtual void desaturate ()
The desaturate() method converts an image to grayscale.
• virtual void draw (int X, int Y, int W, int H, int cx=0, int cy=0)
Draws the image with a bounding box.
• void draw (int X, int Y)
Draws the image.
• Fl Image (int W, int H, int D)
The constructor creates an empty image with the specified width, height, and depth.
• int h () const
Returns the current image height in pixels.
• void inactive ()
The inactive() method calls color average(FL BACKGROUND COLOR, 0.33f) to produce an image that
appears grayed out.
• virtual void label (Fl Widget ∗w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void label (Fl Menu Item ∗m)
31.68. FL IMAGE CLASS REFERENCE 483

The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• int ld () const
Returns the current line data size in bytes.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.
• int w () const
Returns the current image width in pixels.
• virtual ∼Fl Image ()
The destructor is a virtual method that frees all memory used by the image.

Static Public Member Functions


• static void RGB scaling (Fl RGB Scaling)
Sets the RGB image scaling method used for copy(int, int).
• static Fl RGB Scaling RGB scaling ()
Returns the currently used RGB image scaling method.

Protected Member Functions


• void d (int D)
Sets the current image depth.
• void data (const char ∗const ∗p, int c)
Sets the current array pointer and count of pointers in the array.
• void draw empty (int X, int Y)
The protected method draw empty() draws a box with an X in it.
• void h (int H)
Sets the current image height in pixels.
• void ld (int LD)
Sets the current line data size in bytes.
• void w (int W)
Sets the current image width in pixels.

Static Protected Member Functions


• static void labeltype (const Fl Label ∗lo, int lx, int ly, int lw, int lh, Fl Align la)
• static void measure (const Fl Label ∗lo, int &lw, int &lh)

31.68.1 Detailed Description


Fl Image is the base class used for caching and drawing all kinds of images in FLTK.
This class keeps track of common image data such as the pixels, colormap, width, height, and depth.
Virtual methods are used to provide type-specific image handling.
Since the Fl Image class does not support image drawing by itself, calling the draw() method results in
a box with an X in it being drawn instead.

31.68.2 Constructor & Destructor Documentation


Fl Image::Fl Image ( int W, int H, int D ) [inline]
The constructor creates an empty image with the specified width, height, and depth.
The width and height are in pixels. The depth is 0 for bitmaps, 1 for pixmap (colormap) images, and 1
to 4 for color images.
484 CHAPTER 31. CLASS DOCUMENTATION

31.68.3 Member Function Documentation


void Fl Image::color average ( Fl Color c, float i ) [virtual]
The color average() method averages the colors in the image with the FLTK color value c.
The i argument specifies the amount of the original image to combine with the color, so a value of 1.0
results in no color blend, and a value of 0.0 results in a constant image of the specified color. The original
image data is not altered by this method.
Reimplemented in Fl RGB Image, Fl Pixmap, Fl Shared Image, and Fl Tiled Image.

Fl Image ∗ Fl Image::copy ( int W, int H ) [virtual]


The copy() method creates a copy of the specified image.
If the width and height are provided, the image is resized to the specified size. The image should be
deleted (or in the case of Fl Shared Image, released) when you are done with it.
Reimplemented in Fl RGB Image, Fl Pixmap, Fl Shared Image, Fl Bitmap, and Fl Tiled Image.

Fl Image∗ Fl Image::copy ( ) [inline]


The copy() method creates a copy of the specified image.
If the width and height are provided, the image is resized to the specified size. The image should be
deleted (or in the case of Fl Shared Image, released) when you are done with it.

int Fl Image::count ( ) const [inline]


The count() method returns the number of data values associated with the image.
The value will be 0 for images with no associated data, 1 for bitmap and color images, and greater than
2 for pixmap images.

int Fl Image::d ( ) const [inline]


Returns the current image depth.
The return value will be 0 for bitmaps, 1 for pixmaps, and 1 to 4 for color images.

const char∗ const∗ Fl Image::data ( ) const [inline]


Returns a pointer to the current image data array.
Use the count() method to find the size of the data array.

void Fl Image::desaturate ( ) [virtual]


The desaturate() method converts an image to grayscale.
If the image contains an alpha channel (depth = 4), the alpha channel is preserved. This method does
not alter the original image data.
Reimplemented in Fl RGB Image, Fl Pixmap, Fl Shared Image, and Fl Tiled Image.

void Fl Image::draw ( int X, int Y, int W, int H, int cx = 0, int cy = 0 ) [virtual]


Draws the image with a bounding box.
This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image
offset by the cx and cy arguments.
Reimplemented in Fl RGB Image, Fl Pixmap, Fl Shared Image, Fl Bitmap, and Fl Tiled Image.

void Fl Image::draw ( int X, int Y ) [inline]


Draws the image.
This form specifies the upper-lefthand corner of the image.
31.69. FL IMAGE SURFACE CLASS REFERENCE 485

void Fl Image::draw empty ( int X, int Y ) [protected]


The protected method draw empty() draws a box with an X in it.
It can be used to draw any image that lacks image data.

void Fl Image::inactive ( ) [inline]


The inactive() method calls color average(FL BACKGROUND COLOR, 0.33f) to produce an image that
appears grayed out.
This method does not alter the original image data.

void Fl Image::label ( Fl Widget ∗ widget ) [virtual]


The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented in Fl RGB Image, Fl Pixmap, and Fl Bitmap.

void Fl Image::label ( Fl Menu Item ∗ m ) [virtual]


The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented in Fl RGB Image, Fl Pixmap, and Fl Bitmap.

int Fl Image::ld ( ) const [inline]


Returns the current line data size in bytes.
Line data is extra data that is included after each line of color image data and is normally not present.

void Fl Image::RGB scaling ( Fl RGB Scaling method ) [static]


Sets the RGB image scaling method used for copy(int, int).
Applies to all RGB images, defaults to FL RGB SCALING NEAREST.

Fl RGB Scaling Fl Image::RGB scaling ( ) [static]


Returns the currently used RGB image scaling method.

void Fl Image::uncache ( ) [virtual]


If the image has been cached for display, delete the cache data.
This allows you to change the data used for the image and then redraw it without recreating an image
object.
Reimplemented in Fl RGB Image, Fl Pixmap, Fl Shared Image, and Fl Bitmap.
The documentation for this class was generated from the following files:

• Fl Image.H
• Fl Image.cxx

31.69 Fl Image Surface Class Reference


Directs all graphics requests to an Fl Image.
#include <Fl Image Surface.H>
Inheritance diagram for Fl Image Surface:
486 CHAPTER 31. CLASS DOCUMENTATION

Fl_Device

Fl_Surface_Device

Fl_Image_Surface

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void draw (Fl Widget ∗, int delta x=0, int delta y=0)
Draws a widget in the image surface.
• Fl Image Surface (int w, int h)
The constructor.
• Fl RGB Image ∗ image ()
Returns an image made of all drawings sent to the Fl Image Surface object.
• void set current ()
Use this drawing surface for future graphics requests.
• ∼Fl Image Surface ()
The destructor.

Static Public Attributes


• static const char ∗ class id = ”Fl Image Surface”

Additional Inherited Members


31.69.1 Detailed Description
Directs all graphics requests to an Fl Image.
After creation of an Fl Image Surface object, call set current() on it, and all subsequent graphics re-
quests will be recorded in the image. It’s possible to draw widgets (using Fl Image Surface::draw()) or
to use any of the Drawing functions or the Color & Font functions. Finally, call image() on the object to
obtain a newly allocated Fl RGB Image object.
Fl GL Window objects can be drawn in the image as well.
Usage example:
Fl Widget *g = ...; // a widget you want to draw in an image
Fl Image Surface *img surf = new Fl Image Surface(g->
w(), g->h()); // create an Fl Image Surface object
img surf->set current(); // direct graphics requests to the image
fl color(FL WHITE); fl rectf(0, 0, g->w(), g->h()); // draw a white background
img surf->draw(g); // draw the g widget in the image
Fl RGB Image* image = img surf->image(); // get the resulting image
delete img surf; // delete the img surf object
Fl Display Device::display device()->
set current(); // direct graphics requests back to the display

31.69.2 Constructor & Destructor Documentation


Fl Image Surface::Fl Image Surface ( int w, int h )
The constructor.
31.70. FL INPUT CLASS REFERENCE 487

Parameters
w and
h give the size in pixels of the resulting image.

31.69.3 Member Function Documentation


const char∗ Fl Image Surface::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Surface Device.

void Fl Image Surface::draw ( Fl Widget ∗ widget, int delta x = 0, int delta y = 0 )


Draws a widget in the image surface.
Parameters
widget any FLTK widget (e.g., standard, custom, window, GL view) to draw in the image
delta x and
delta y give the position in the image of the top-left corner of the widget

Fl RGB Image ∗ Fl Image Surface::image ( )


Returns an image made of all drawings sent to the Fl Image Surface object.
The returned object contains its own copy of the RGB data.

void Fl Image Surface::set current ( void ) [virtual]


Use this drawing surface for future graphics requests.
Reimplemented from Fl Surface Device.
The documentation for this class was generated from the following files:
• Fl Image Surface.H
• Fl Image Surface.cxx

31.70 Fl Input Class Reference


This is the FLTK text input widget.
#include <Fl Input.H>
Inheritance diagram for Fl Input:

Fl_Widget

Fl_Input_

Fl_Input

Fl_File_Input Fl_Float_Input Fl_Int_Input Fl_Multiline_Input Fl_Output Fl_Secret_Input

Fl_Multiline_Output
488 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• Fl Input (int, int, int, int, const char ∗=0)
Creates a new Fl Input widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.70.1 Detailed Description
This is the FLTK text input widget.
It displays a single line of text and lets the user edit it. Normally it is drawn with an inset box and a
white background. The text may contain any characters, and will correctly display any UTF text, using ∧ X
notation for unprintable control characters. It assumes the font can draw any characters of the used scripts,
which is true for standard fonts under MSWindows and Mac OS X. Characters can be input using the
keyboard or the character palette/map. Character composition is done using dead keys and/or a compose
key as defined by the operating system.

Mouse button 1 Moves the cursor to this point. Drag selects


characters. Double click selects words. Triple
click selects all line. Shift+click extends the
selection. When you select text it is automatically
copied to the selection buffer.
Mouse button 2 Insert the selection buffer at the point clicked.
You can also select a region and replace it with
the selection buffer by selecting the region with
mouse button 2.
Mouse button 3 Currently acts like button 1.
Backspace Deletes one character to the left, or deletes the
selected region.
Delete Deletes one character to the right, or deletes the
selected region. Combine with Shift for
equivalent of ∧ X (copy+cut).
Enter May cause the callback, see when().

Table 31.1: Fl Input keyboard and mouse bindings.

31.70.2 Constructor & Destructor Documentation


Fl Input::Fl Input ( int X, int Y, int W, int H, const char ∗ l = 0 )

Creates a new Fl Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
31.71. FL INPUT CLASS REFERENCE 489

31.70.3 Member Function Documentation


void Fl Input::draw ( ) [protected], [virtual]

Draws the widget.


Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:

Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar


s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Input::handle ( int event ) [virtual]

Handles the specified event.


You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.


Reimplemented in Fl Secret Input.
The documentation for this class was generated from the following files:

• Fl Input.H
• Fl Input.cxx

31.71 Fl Input Class Reference


This class provides a low-overhead text input field.
#include <Fl Input .H>
Inheritance diagram for Fl Input :
490 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Input_

Fl_Input

Fl_File_Input Fl_Float_Input Fl_Int_Input Fl_Multiline_Input Fl_Output Fl_Secret_Input

Fl_Multiline_Output

Public Member Functions


• int copy (int clipboard)
Put the current selection into the clipboard.
• int copy cuts ()
Copies the yank buffer to the clipboard.
• Fl Color cursor color () const
Gets the color of the cursor.
• void cursor color (Fl Color n)
Sets the color of the cursor.
• int cut ()
Deletes the current selection.
• int cut (int n)
Deletes the next n bytes rounded to characters before or after the cursor.
• int cut (int a, int b)
Deletes all characters between index a and b.
• Fl Input (int, int, int, int, const char ∗=0)
Creates a new Fl Input widget.
• Fl Char index (int i) const
Returns the character at index i.
• int input type () const
Gets the input field type.
• void input type (int t)
Sets the input field type.
• int insert (const char ∗t, int l=0)
Inserts text at the cursor position.
• int mark () const
Gets the current selection mark.
• int mark (int m)
Sets the current selection mark.
• int maximum size () const
Gets the maximum length of the input field in characters.
• void maximum size (int m)
Sets the maximum length of the input field in characters.
• int position () const
Gets the position of the text cursor.
• int position (int p, int m)
Sets the index for the cursor and mark.
31.71. FL INPUT CLASS REFERENCE 491

• int position (int p)


Sets the cursor position and mark.
• int readonly () const
Gets the read-only state of the input field.
• void readonly (int b)
Sets the read-only state of the input field.
• int replace (int b, int e, const char ∗text, int ilen=0)
Deletes text from b to e and inserts the new string text.
• void resize (int, int, int, int)
Changes the size of the widget.
• int shortcut () const
Return the shortcut key associated with this widget.
• void shortcut (int s)
Sets the shortcut key associated with this widget.
• int size () const
Returns the number of bytes in value().
• void size (int W, int H)
Sets the width and height of this widget.
• int static value (const char ∗)
Changes the widget text.
• int static value (const char ∗, int)
Changes the widget text.
• void tab nav (int val)
Sets whether the Tab key does focus navigation, or inserts tab characters into Fl Multiline Input.
• int tab nav () const
Gets whether the Tab key causes focus navigation in multiline input fields or not.
• Fl Color textcolor () const
Gets the color of the text in the input field.
• void textcolor (Fl Color n)
Sets the color of the text in the input field.
• Fl Font textfont () const
Gets the font of the text in the input field.
• void textfont (Fl Font s)
Sets the font of the text in the input field.
• Fl Fontsize textsize () const
Gets the size of the text in the input field.
• void textsize (Fl Fontsize s)
Sets the size of the text in the input field.
• int undo ()
Undoes previous changes to the text buffer.
• int value (const char ∗)
Changes the widget text.
• int value (const char ∗, int)
Changes the widget text.
• const char ∗ value () const
Returns the text displayed in the widget.
492 CHAPTER 31. CLASS DOCUMENTATION

• int wrap () const


Gets the word wrapping state of the input field.
• void wrap (int b)
Sets the word wrapping state of the input field.
• ∼Fl Input ()
Destroys the widget.

Protected Member Functions


• void drawtext (int, int, int, int)
Draws the text in the passed bounding box.
• void handle mouse (int, int, int, int, int keepmark=0)
Handles mouse clicks and mouse moves.
• int handletext (int e, int, int, int, int)
Handles all kinds of text field related events.
• int line end (int i) const
Finds the end of a line.
• int line start (int i) const
Finds the start of a line.
• int linesPerPage ()
• void maybe do callback ()
• int up down position (int, int keepmark=0)
Moves the cursor to the column given by up down pos.
• int word end (int i) const
Finds the end of a word.
• int word start (int i) const
Finds the start of a word.
• int xscroll () const
• int yscroll () const
• void yscroll (int yOffset)

Additional Inherited Members


31.71.1 Detailed Description
This class provides a low-overhead text input field.
This is a virtual base class below Fl Input. It has all the same interfaces, but lacks the handle() and
draw() method. You may want to subclass it if you are one of those people who likes to change how the
editing keys work. It may also be useful for adding scrollbars to the input field.
This can act like any of the subclasses of Fl Input, by setting type() to one of the following values:
#define FL NORMAL INPUT 0
#define FL FLOAT INPUT 1
#define FL INT INPUT 2
#define FL MULTILINE INPUT 4
#define FL SECRET INPUT 5
#define FL INPUT TYPE 7
#define FL INPUT READONLY 8
#define FL NORMAL OUTPUT (FL NORMAL INPUT | FL INPUT READONLY)
#define FL MULTILINE OUTPUT (FL MULTILINE INPUT | FL INPUT READONLY)
#define FL INPUT WRAP 16
#define FL MULTILINE INPUT WRAP (FL MULTILINE INPUT | FL INPUT WRAP)
#define FL MULTILINE OUTPUT WRAP (FL MULTILINE INPUT | FL INPUT READONLY | FL INPUT WRAP)
31.71. FL INPUT CLASS REFERENCE 493

All variables that represent an index into a text buffer are byte-oriented, not character oriented, counting
from 0 (at or before the first character) to size() (at the end of the buffer, after the last byte). Since UTF-8
characters can be up to six bytes long, simply incrementing such an index will not reliably advance to the
next character in the text buffer.
Indices and pointers into the text buffer should always point at a 7 bit ASCII character or the beginning
of a UTF-8 character sequence. Behavior for false UTF-8 sequences and pointers into the middle of a
sequence are undefined.

See Also
Fl Text Display, Fl Text Editor for more powerful text handling widgets

31.71.2 Constructor & Destructor Documentation


Fl Input ::Fl Input ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Input widget.
This function creates a new Fl Input widget and adds it to the current Fl Group. The value() is set to
NULL. The default boxtype is FL DOWN BOX.
Parameters
X,Y,W,H the dimensions of the new widget
l an optional label text

Fl Input ::∼Fl Input ( )


Destroys the widget.
The destructor clears all allocated buffers and removes the widget from the parent Fl Group.

31.71.3 Member Function Documentation


int Fl Input ::copy ( int clipboard )
Put the current selection into the clipboard.
This function copies the current selection between mark() and position() into the specified clipboard.
This does not replace the old clipboard contents if position() and mark() are equal. Clipboard 0 maps to
the current text selection and clipboard 1 maps to the cut/paste clipboard.
Parameters
clipboard the clipboard destination 0 or 1

Returns
0 if no text is selected, 1 if the selection was copied

See Also
Fl::copy(const char ∗, int, int)

int Fl Input ::copy cuts ( )


Copies the yank buffer to the clipboard.
This method copies all the previous contiguous cuts from the undo information to the clipboard. This
function implements the ∧ K shortcut key.
494 CHAPTER 31. CLASS DOCUMENTATION

Returns
0 if the operation did not change the clipboard

See Also
copy(int), cut()

Fl Color Fl Input ::cursor color ( ) const [inline]


Gets the color of the cursor.
Returns
the current cursor color

void Fl Input ::cursor color ( Fl Color n ) [inline]


Sets the color of the cursor.
The default color for the cursor is FL BLACK.
Parameters
in n the new cursor color

int Fl Input ::cut ( ) [inline]


Deletes the current selection.
This function deletes the currently selected text without storing it in the clipboard. To use the clipboard,
you may call copy() first or copy cuts() after this call.
Returns
0 if no data was copied

int Fl Input ::cut ( int n ) [inline]


Deletes the next n bytes rounded to characters before or after the cursor.
This function deletes the currently selected text without storing it in the clipboard. To use the clipboard,
you may call copy() first or copy cuts() after this call.
Parameters
n number of bytes rounded to full characters and clamped to the buffer. A negative
number will cut characters to the left of the cursor.

Returns
0 if no data was copied

int Fl Input ::cut ( int a, int b ) [inline]


Deletes all characters between index a and b.
This function deletes the currently selected text without storing it in the clipboard. To use the clipboard,
you may call copy() first or copy cuts() after this call.
31.71. FL INPUT CLASS REFERENCE 495

Parameters
a,b range of bytes rounded to full characters and clamped to the buffer

Returns
0 if no data was copied

void Fl Input ::drawtext ( int X, int Y, int W, int H ) [protected]


Draws the text in the passed bounding box.
If damage() & FL DAMAGE ALL is true, this assumes the area has already been erased to color().
Otherwise it does minimal update and erases the area itself.
Parameters
X,Y,W,H area that must be redrawn

void Fl Input ::handle mouse ( int X, int Y, int , int , int drag = 0 ) [protected]
Handles mouse clicks and mouse moves.

Todo Add comment and parameters

int Fl Input ::handletext ( int event, int X, int Y, int W, int H ) [protected]
Handles all kinds of text field related events.
This is called by derived classes.
Todo Add comment and parameters

unsigned int Fl Input ::index ( int i ) const


Returns the character at index i.
This function returns the UTF-8 character at i as a ucs4 character code.
Parameters
in i index into the value field

Returns
the character at index i

int Fl Input ::input type ( ) const [inline]


Gets the input field type.
Returns
the current input type

void Fl Input ::input type ( int t ) [inline]


Sets the input field type.
A redraw() is required to reformat the input field.
496 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in t new input type

int Fl Input ::insert ( const char ∗ t, int l = 0 ) [inline]


Inserts text at the cursor position.
This function inserts the string in t at the cursor position() and moves the new position and mark to the
end of the inserted text.
Parameters
in t text that will be inserted
in l length of text, or 0 if the string is terminated by nul.

Returns
0 if no text was inserted

int Fl Input ::line end ( int i ) const [protected]


Finds the end of a line.
This call calculates the end of a line based on the given index i.
Parameters
in i starting index for the search

Returns
end of the line

int Fl Input ::line start ( int i ) const [protected]


Finds the start of a line.
This call calculates the start of a line based on the given index i.
Parameters
in i starting index for the search

Returns
start of the line

int Fl Input ::mark ( ) const [inline]


Gets the current selection mark.
Returns
index into the text

int Fl Input ::mark ( int m ) [inline]


Sets the current selection mark.
mark(n) is the same as position(position(),n).
31.71. FL INPUT CLASS REFERENCE 497

Parameters
m new index of the mark

Returns
0 if the mark did not change

See Also
position(), position(int, int)

int Fl Input ::maximum size ( ) const [inline]


Gets the maximum length of the input field in characters.
See Also
maximum size(int).

void Fl Input ::maximum size ( int m ) [inline]


Sets the maximum length of the input field in characters.
This limits the number of characters that can be inserted in the widget.
Since
FLTK 1.3 this is different than the buffer size, since one character can be more than one byte in
UTF-8 encoding. In FLTK 1.1 this was the same (one byte = one character).

int Fl Input ::position ( ) const [inline]


Gets the position of the text cursor.
Returns
the cursor position as an index in the range 0..size()

See Also
position(int, int)

int Fl Input ::position ( int p, int m )


Sets the index for the cursor and mark.
The input widget maintains two pointers into the string. The position (p) is where the cursor is. The
mark (m) is the other end of the selected text. If they are equal then there is no selection. Changing this
does not affect the clipboard (use copy() to do that).
Changing these values causes a redraw(). The new values are bounds checked.
Parameters
498 CHAPTER 31. CLASS DOCUMENTATION

p index for the cursor position


m index for the mark

Returns
0 if no positions changed

See Also
position(int), position(), mark(int)

int Fl Input ::position ( int p ) [inline]


Sets the cursor position and mark.
position(n) is the same as position(n, n).
Parameters
p new index for cursor and mark

Returns
0 if no positions changed

See Also
position(int, int), position(), mark(int)

int Fl Input ::readonly ( ) const [inline]


Gets the read-only state of the input field.

Returns
non-zero if this widget is read-only

void Fl Input ::readonly ( int b ) [inline]


Sets the read-only state of the input field.
Parameters
in b if b is 0, the text in this widget can be edited by the user

int Fl Input ::replace ( int b, int e, const char ∗ text, int ilen = 0 )
Deletes text from b to e and inserts the new string text.
All changes to the text buffer go through this function. It deletes the region between b and e (either
one may be less or equal to the other), and then inserts the string text at that point and moves the mark()
and position() to the end of the insertion. Does the callback if when() & FL WHEN CHANGED and there
is a change.
Set b and e equal to not delete anything. Set text to NULL to not insert anything.
ilen can be zero or strlen(text), which saves a tiny bit of time if you happen to already know
the length of the insertion, or can be used to insert a portion of a string. If ilen is zero, strlen(text)
is used instead.
31.71. FL INPUT CLASS REFERENCE 499

b and e are clamped to the 0..size() range, so it is safe to pass any values. b, e, and ilen are
used as numbers of bytes (not characters), where b and e count from 0 to size() (end of buffer).
If b and/or e don’t point to a valid UTF-8 character boundary, they are adjusted to the previous (b) or
the next (e) valid UTF-8 character boundary, resp..
If the current number of characters in the buffer minus deleted characters plus inserted characters in
text would overflow the number of allowed characters (maximum size()), then only the first characters
of the string are inserted, so that maximum size() is not exceeded.
cut() and insert() are just inline functions that call replace().
Parameters
in b beginning index of text to be deleted
in e ending index of text to be deleted and insertion position
in text string that will be inserted
in ilen length of text or 0 for nul terminated strings

Returns
0 if nothing changed

Note
If text does not point to a valid UTF-8 character or includes invalid UTF-8 sequences, the text is
inserted nevertheless (counting invalid UTF-8 bytes as one character each).

void Fl Input ::resize ( int X, int Y, int W, int H ) [virtual]


Changes the size of the widget.
This call updates the text layout so that the cursor is visible.
Parameters
in X,Y,W,H new size of the widget

See Also
Fl Widget::resize(int, int, int, int)

Reimplemented from Fl Widget.

int Fl Input ::shortcut ( ) const [inline]


Return the shortcut key associated with this widget.
Returns
shortcut keystroke

See Also
Fl Button::shortcut()

void Fl Input ::shortcut ( int s ) [inline]


Sets the shortcut key associated with this widget.
Pressing the shortcut key gives text editing focus to this widget.
500 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in s new shortcut keystroke

See Also
Fl Button::shortcut()

int Fl Input ::size ( ) const [inline]


Returns the number of bytes in value().
This may be greater than strlen(value()) if there are nul characters in the text.
Returns
number of bytes in the text

void Fl Input ::size ( int W, int H ) [inline]


Sets the width and height of this widget.
Parameters
in W,H new width and height

See Also
Fl Widget::size(int, int)

int Fl Input ::static value ( const char ∗ str )


Changes the widget text.
This function changes the text and sets the mark and the point to the end of it. The string is not copied.
If the user edits the string it is copied to the internal buffer then. This can save a great deal of time and
memory if your program is rapidly changing the values of text fields, but this will only work if the passed
string remains unchanged until either the Fl Input is destroyed or value() is called again.
Parameters
in str the new text

Returns
non-zero if the new value is different than the current one

int Fl Input ::static value ( const char ∗ str, int len )


Changes the widget text.
This function changes the text and sets the mark and the point to the end of it. The string is not copied.
If the user edits the string it is copied to the internal buffer then. This can save a great deal of time and
memory if your program is rapidly changing the values of text fields, but this will only work if the passed
string remains unchanged until either the Fl Input is destroyed or value() is called again.
You can use the len parameter to directly set the length if you know it already or want to put nul
characters in the text.
31.71. FL INPUT CLASS REFERENCE 501

Parameters
in str the new text
in len the length of the new text

Returns
non-zero if the new value is different than the current one

void Fl Input ::tab nav ( int val ) [inline]


Sets whether the Tab key does focus navigation, or inserts tab characters into Fl Multiline Input.
By default this flag is enabled to provide the ’normal’ behavior most users expect; Tab navigates focus
to the next widget. To inserting an actual Tab character, users can use Ctrl-I or copy/paste.
Disabling this flag gives the old FLTK behavior where Tab inserts a tab character into the text field, in
which case only the mouse can be used to navigate to the next field.
History: This flag was provided for backwards support of FLTK’s old 1.1.x behavior where Tab inserts
a tab character instead of navigating focus to the next widget. This behavior was unique to Fl Multiline -
Input. With the advent of Fl Text Editor, this old behavior has been deprecated.
Parameters
in val If val is 1, Tab advances focus (default).
If val is 0, Tab inserts a tab character (old FLTK behavior).

See Also
tab nav(), Fl::OPTION ARROW FOCUS.

int Fl Input ::tab nav ( ) const [inline]


Gets whether the Tab key causes focus navigation in multiline input fields or not.
If enabled (default), hitting Tab causes focus navigation to the next widget.
If disabled, hitting Tab inserts a tab character into the text field.
Returns
1 if Tab advances focus (default), 0 if Tab inserts tab characters.

See Also
tab nav(int), Fl::OPTION ARROW FOCUS.

Fl Color Fl Input ::textcolor ( ) const [inline]


Gets the color of the text in the input field.
Returns
the text color

See Also
textcolor(Fl Color)

void Fl Input ::textcolor ( Fl Color n ) [inline]


Sets the color of the text in the input field.
The text color defaults to FL FOREGROUND COLOR.
502 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in n new text color

See Also
textcolor()

Fl Font Fl Input ::textfont ( ) const [inline]


Gets the font of the text in the input field.
Returns
the current Fl Font index

void Fl Input ::textfont ( Fl Font s ) [inline]


Sets the font of the text in the input field.
The text font defaults to FL HELVETICA.
Parameters
in s the new text font

Fl Fontsize Fl Input ::textsize ( ) const [inline]


Gets the size of the text in the input field.
Returns
the text height in pixels

void Fl Input ::textsize ( Fl Fontsize s ) [inline]


Sets the size of the text in the input field.
The text height defaults to FL NORMAL SIZE.
Parameters
in s the new font height in pixel units

int Fl Input ::undo ( )


Undoes previous changes to the text buffer.
This call undoes a number of previous calls to replace().
Returns
non-zero if any change was made.

int Fl Input ::up down position ( int i, int keepmark = 0 ) [protected]


Moves the cursor to the column given by up down pos.
This function is helpful when implementing up and down cursor movement. It moves the cursor from
the beginning of a line to the column indicated by the global variable up down pos in pixel units.
31.71. FL INPUT CLASS REFERENCE 503

Parameters
in i index into the beginning of a line of text
in keepmark if set, move only the cursor, but not the mark

Returns
index to new cursor position

int Fl Input ::value ( const char ∗ str )


Changes the widget text.
This function changes the text and sets the mark and the point to the end of it. The string is copied to
the internal buffer. Passing NULL is the same as "".
Parameters
in str the new text

Returns
non-zero if the new value is different than the current one

See Also
Fl Input ::value(const char∗ str, int len), Fl Input ::value()

int Fl Input ::value ( const char ∗ str, int len )


Changes the widget text.
This function changes the text and sets the mark and the point to the end of it. The string is copied to
the internal buffer. Passing NULL is the same as ””.
You can use the length parameter to directly set the length if you know it already or want to put nul
characters in the text.
Parameters
in str the new text
in len the length of the new text

Returns
non-zero if the new value is different than the current one

See Also
Fl Input ::value(const char∗ str), Fl Input ::value()

const char∗ Fl Input ::value ( ) const [inline]


Returns the text displayed in the widget.
This function returns the current value, which is a pointer to the internal buffer and is valid only until
the next event is handled.
Returns
pointer to an internal buffer - do not free() this

See Also
Fl Input ::value(const char∗)
504 CHAPTER 31. CLASS DOCUMENTATION

int Fl Input ::word end ( int i ) const [protected]

Finds the end of a word.


Returns the index after the last byte of a word. If the index is already at the end of a word, it will find
the end of the following word, so if you call it repeatedly you will move forwards to the end of the text.
Note that this is inconsistent with line end().
Parameters
in i starting index for the search

Returns
end of the word

int Fl Input ::word start ( int i ) const [protected]

Finds the start of a word.


Returns the index of the first byte of a word. If the index is already at the beginning of a word, it
will find the beginning of the previous word, so if you call it repeatedly you will move backwards to the
beginning of the text.
Note that this is inconsistent with line start().
Parameters
in i starting index for the search

Returns
start of the word, or previous word

int Fl Input ::wrap ( ) const [inline]

Gets the word wrapping state of the input field.


Word wrap is only functional with multi-line input fields.

void Fl Input ::wrap ( int b ) [inline]

Sets the word wrapping state of the input field.


Word wrap is only functional with multi-line input fields.
The documentation for this class was generated from the following files:

• Fl Input .H
• Fl Input .cxx

31.72 Fl Input Choice Class Reference


A combination of the input widget and a menu button.
#include <Fl Input Choice.H>
Inheritance diagram for Fl Input Choice:
31.72. FL INPUT CHOICE CLASS REFERENCE 505

Fl_Widget

Fl_Group

Fl_Input_Choice

Public Member Functions


• void add (const char ∗s)
Adds an item to the menu.
• int changed () const
Returns the combined changed() state of the input and menu button widget.
• void clear ()
Removes all items from the menu.
• void clear changed ()
Clears the changed() state of both input and menu button widgets.
• Fl Boxtype down box () const
Gets the box type of the menu button.
• void down box (Fl Boxtype b)
Sets the box type of the menu button.
• Fl Input Choice (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Input Choice widget using the given position, size, and label string.
• Fl Input ∗ input ()
Returns a pointer to the internal Fl Input widget.
• const Fl Menu Item ∗ menu ()
Gets the Fl Menu Item array used for the menu.
• void menu (const Fl Menu Item ∗m)
Sets the Fl Menu Item array used for the menu.
• Fl Menu Button ∗ menubutton ()
Returns a pointer to the internal Fl Menu Button widget.
• void resize (int X, int Y, int W, int H)
Resizes the Fl Group widget and all of its children.
• void set changed ()
Sets the changed() state of both input and menu button widgets to the specfied value.
• Fl Color textcolor () const
Gets the Fl Input text field’s text color.
• void textcolor (Fl Color c)
Sets the Fl Input text field’s text color to c.
• Fl Font textfont () const
Gets the Fl Input text field’s font style.
• void textfont (Fl Font f)
Sets the Fl Input text field’s font style to f.
• Fl Fontsize textsize () const
Gets the Fl Input text field’s font size.
• void textsize (Fl Fontsize s)
506 CHAPTER 31. CLASS DOCUMENTATION

Sets the Fl Input text field’s font size to s.


• const char ∗ value () const
Returns the Fl Input text field’s current contents.
• void value (const char ∗val)
Sets the Fl Input text field’s contents to val.
• void value (int val)
Chooses item# val in the menu, and sets the Fl Input text field to that value.

Additional Inherited Members


31.72.1 Detailed Description
A combination of the input widget and a menu button.

Figure 31.17: Fl Input Choice widget

The user can either type into the input area, or use the menu button chooser on the right to choose an
item which loads the input area with the selected text.
The application can directly access both the internal Fl Input and Fl Menu Button widgets respectively
using the input() and menubutton() accessor methods.

31.72.2 Constructor & Destructor Documentation


Fl Input Choice::Fl Input Choice ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Input Choice widget using the given position, size, and label string.
Inherited destructor destroys the widget and any values associated with it.

31.72.3 Member Function Documentation


void Fl Input Choice::add ( const char ∗ s ) [inline]
Adds an item to the menu.
You can access the more complex Fl Menu Button::add() methods (setting callbacks, userdata, etc),
via menubutton(). Example:
Fl Input Choice *choice = new Fl Input Choice(100,10,120,25,"Fonts");
Fl Menu Button *mb = choice->menubutton(); // use Fl Input Choice’s
Fl Menu Button
mb->add("Helvetica", 0, MyFont CB, (void*)mydata); // use Fl Menu Button’s add() methods
mb->add("Courier", 0, MyFont CB, (void*)mydata);
mb->add("More..", 0, FontDialog CB, (void*)mydata);

int Fl Input Choice::changed ( ) const [inline]


Returns the combined changed() state of the input and menu button widget.
31.72. FL INPUT CHOICE CLASS REFERENCE 507

void Fl Input Choice::clear ( ) [inline]


Removes all items from the menu.

void Fl Input Choice::clear changed ( ) [inline]


Clears the changed() state of both input and menu button widgets.

Fl Input∗ Fl Input Choice::input ( ) [inline]


Returns a pointer to the internal Fl Input widget.
This can be used to directly access all of the Fl Input widget’s methods.

const Fl Menu Item∗ Fl Input Choice::menu ( ) [inline]


Gets the Fl Menu Item array used for the menu.

void Fl Input Choice::menu ( const Fl Menu Item ∗ m ) [inline]


Sets the Fl Menu Item array used for the menu.

Fl Menu Button∗ Fl Input Choice::menubutton ( ) [inline]


Returns a pointer to the internal Fl Menu Button widget.
This can be used to access any of the methods of the menu button, e.g.

Fl Input Choice *choice = new Fl Input Choice(100,10,120,25,"Choice:");


[..]
// Print all the items in the choice menu
for ( int t=0; t<choice->menubutton()->size(); t++ ) {
const Fl Menu Item &item = choice->menubutton()->menu()[t];
printf("item %d -- label=%s\n", t, item.label() ? item.label() : "(Null)");
}

void Fl Input Choice::resize ( int X, int Y, int W, int H ) [inline], [virtual]


Resizes the Fl Group widget and all of its children.
The Fl Group widget first resizes itself, and then it moves and resizes all its children according to the
rules documented for Fl Group::resizable(Fl Widget∗)

See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)

Reimplemented from Fl Group.

void Fl Input Choice::set changed ( ) [inline]


Sets the changed() state of both input and menu button widgets to the specfied value.

void Fl Input Choice::value ( const char ∗ val ) [inline]


Sets the Fl Input text field’s contents to val.
Does not affect the menu selection.
508 CHAPTER 31. CLASS DOCUMENTATION

void Fl Input Choice::value ( int val ) [inline]

Chooses item# val in the menu, and sets the Fl Input text field to that value.
Any previous text is cleared.
The documentation for this class was generated from the following files:

• Fl Input Choice.H
• Fl Group.cxx

31.73 Fl Int Input Class Reference


The Fl Int Input class is a subclass of Fl Input that only allows the user to type decimal digits (or hex
numbers of the form 0xaef).
#include <Fl Int Input.H>
Inheritance diagram for Fl Int Input:

Fl_Widget

Fl_Input_

Fl_Input

Fl_Int_Input

Public Member Functions


• Fl Int Input (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Int Input widget using the given position, size, and label string.

Additional Inherited Members


31.73.1 Detailed Description
The Fl Int Input class is a subclass of Fl Input that only allows the user to type decimal digits (or hex
numbers of the form 0xaef).

31.73.2 Constructor & Destructor Documentation


Fl Int Input::Fl Int Input ( int X, int Y, int W, int H, const char ∗ l = 0 )

Creates a new Fl Int Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.
The documentation for this class was generated from the following files:

• Fl Int Input.H
• Fl Input.cxx
31.74. FL JPEG IMAGE CLASS REFERENCE 509

31.74 Fl JPEG Image Class Reference


The Fl JPEG Image class supports loading, caching, and drawing of Joint Photographic Experts Group
(JPEG) File Interchange Format (JFIF) images.
#include <Fl JPEG Image.H>
Inheritance diagram for Fl JPEG Image:

Fl_Image

Fl_RGB_Image

Fl_JPEG_Image

Public Member Functions


• Fl JPEG Image (const char ∗filename)
The constructor loads the JPEG image from the given jpeg filename.
• Fl JPEG Image (const char ∗name, const unsigned char ∗data)
The constructor loads the JPEG image from memory.

Additional Inherited Members


31.74.1 Detailed Description
The Fl JPEG Image class supports loading, caching, and drawing of Joint Photographic Experts Group
(JPEG) File Interchange Format (JFIF) images.
The class supports grayscale and color (RGB) JPEG image files.

31.74.2 Constructor & Destructor Documentation


Fl JPEG Image::Fl JPEG Image ( const char ∗ filename )
The constructor loads the JPEG image from the given jpeg filename.
The inherited destructor frees all memory and server resources that are used by the image.
There is no error function in this class. If the image has loaded correctly, w(), h(), and d() should return
values greater zero.
Parameters
in filename a full path and name pointing to a valid jpeg file.

Fl JPEG Image::Fl JPEG Image ( const char ∗ name, const unsigned char ∗ data )
The constructor loads the JPEG image from memory.
Construct an image from a block of memory inside the application. Fluid offers ”binary Data” chunks
as a great way to add image data into the C++ source code. name png can be NULL. If a name is given,
the image is added to the list of shared images (see: Fl Shared Image) and will be available by that name.
The inherited destructor frees all memory and server resources that are used by the image.
There is no error function in this class. If the image has loaded correctly, w(), h(), and d() should return
values greater zero.
510 CHAPTER 31. CLASS DOCUMENTATION

Parameters
name A unique name or NULL
data A pointer to the memory location of the JPEG image
The documentation for this class was generated from the following files:

• Fl JPEG Image.H
• Fl JPEG Image.cxx

31.75 Fl Label Struct Reference


This struct stores all information for a text or mixed graphics label.
#include <Fl Widget.H>

Public Member Functions


• void draw (int, int, int, int, Fl Align) const
Draws the label aligned to the given box.
• void measure (int &w, int &h) const
Measures the size of the label.

Public Attributes
• Fl Align align
alignment of label
• Fl Color color
text color
• Fl Image ∗ deimage
optional image for a deactivated label
• Fl Font font
label font used in text
• Fl Image ∗ image
optional image for an active label
• Fl Fontsize size
size of label font
• uchar type
type of label.
• const char ∗ value
label text

31.75.1 Detailed Description


This struct stores all information for a text or mixed graphics label.

Todo For FLTK 1.3, the Fl Label type will become a widget by itself. That way we will be avoiding a
lot of code duplication by handling labels in a similar fashion to widgets containing text. We also
provide an easy interface for very complex labels, containing html or vector graphics.
31.75. FL LABEL STRUCT REFERENCE 511

31.75.2 Member Function Documentation


void Fl Label::draw ( int X, int Y, int W, int H, Fl Align align ) const
Draws the label aligned to the given box.
Draws a label with arbitrary alignment in an arbitrary box.

void Fl Label::measure ( int & W, int & H ) const


Measures the size of the label.
512 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in,out W,H : this is the requested size for the label text plus image; on return, this
will contain the size needed to fit the label

31.75.3 Member Data Documentation


uchar Fl Label::type

type of label.

See Also
Fl Labeltype

The documentation for this struct was generated from the following files:

• Fl Widget.H
• fl labeltype.cxx

31.76 Fl Light Button Class Reference


This subclass displays the ”on” state by turning on a light, rather than drawing pushed in.
#include <Fl Light Button.H>
Inheritance diagram for Fl Light Button:

Fl_Widget

Fl_Button

Fl_Light_Button

Fl_Check_Button Fl_Radio_Light_Button Fl_Round_Button

Fl_Radio_Round_Button

Public Member Functions


• Fl Light Button (int x, int y, int w, int h, const char ∗l=0)
Creates a new Fl Light Button widget using the given position, size, and label string.
• virtual int handle (int)
Handles the specified event.

Protected Member Functions


• virtual void draw ()
Draws the widget.
31.76. FL LIGHT BUTTON CLASS REFERENCE 513

Additional Inherited Members


31.76.1 Detailed Description
This subclass displays the ”on” state by turning on a light, rather than drawing pushed in.
The shape of the ”light” is initially set to FL DOWN BOX. The color of the light when on is controlled
with selection color(), which defaults to FL YELLOW.
Buttons generate callbacks when they are clicked by the user. You control exactly when and how by
changing the values for type() and when().

Figure 31.18: Fl Light Button

31.76.2 Constructor & Destructor Documentation


Fl Light Button::Fl Light Button ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Light Button widget using the given position, size, and label string.
The destructor deletes the check button.

31.76.3 Member Function Documentation


void Fl Light Button::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Button.

int Fl Light Button::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
514 CHAPTER 31. CLASS DOCUMENTATION

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Button.


The documentation for this class was generated from the following files:

• Fl Light Button.H
• Fl Light Button.cxx

31.77 Fl Line Dial Class Reference


Inheritance diagram for Fl Line Dial:

Fl_Widget

Fl_Valuator

Fl_Dial

Fl_Line_Dial

Public Member Functions


• Fl Line Dial (int X, int Y, int W, int H, const char ∗L=0)

Additional Inherited Members


The documentation for this class was generated from the following files:

• Fl Line Dial.H
• Fl Dial.cxx

31.78 Fl Mac App Menu Class Reference


Mac OS-specific class allowing to localize the application menu.
#include <x.H>

Static Public Attributes


• static const char ∗ about = ”About %@”
Localizable text for the ”About xxx” application menu item.
• static const char ∗ hide = ”Hide %@”
Localizable text for the ”Hide xxx” application menu item.
• static const char ∗ hide others = ”Hide Others”
31.79. FL MENU CLASS REFERENCE 515

Localizable text for the ”Hide Others” application menu item.


• static const char ∗ print = ”Print Front Window”
Localizable text for the ”Print Front Window” application menu item.
• static const char ∗ quit = ”Quit %@”
Localizable text for the ”Quit xxx” application menu item.
• static const char ∗ services = ”Services”
Localizable text for the ”Services” application menu item.
• static const char ∗ show = ”Show All”
Localizable text for the ”Show All” application menu item.

31.78.1 Detailed Description


Mac OS-specific class allowing to localize the application menu.
These character strings are used to build the application menu. They can be localized at run time to any
UTF-8 text by placing instructions such as this very early in the program:
Fl_Mac_App_Menu::print = "Imprimer la fenêtre";

31.78.2 Member Data Documentation


const char ∗ Fl Mac App Menu::print = ”Print Front Window” [static]
Localizable text for the ”Print Front Window” application menu item.
This menu item won’t be displayed if Fl Mac App Menu::print is set to an empty string.
The documentation for this class was generated from the following files:

• mac.H
• Fl.cxx

31.79 Fl Menu Class Reference


Base class of all widgets that have a menu in FLTK.
#include <Fl Menu .H>
Inheritance diagram for Fl Menu :

Fl_Widget

Fl_Menu_

Fl_Choice Fl_Menu_Bar Fl_Menu_Button

Fl_Sys_Menu_Bar

Public Member Functions


• int add (const char ∗, int shortcut, Fl Callback ∗, void ∗=0, int=0)
Adds a new menu item.
• int add (const char ∗a, const char ∗b, Fl Callback ∗c, void ∗d=0, int e=0)
See int Fl Menu ::add(const char∗ label, int shortcut, Fl Callback∗, void ∗user data=0, int flags=0)
516 CHAPTER 31. CLASS DOCUMENTATION

• int add (const char ∗)


This is a Forms (and SGI GL library) compatible add function, it adds many menu items, with ’|’ separating
the menu items, and tab separating the menu item names from an optional shortcut string.
• void clear ()
Same as menu(NULL), set the array pointer to null, indicating a zero-length menu.
• int clear submenu (int index)
Clears the specified submenu pointed to by index of all menu items.
• void copy (const Fl Menu Item ∗m, void ∗user data=0)
Sets the menu array pointer with a copy of m that will be automatically deleted.
• Fl Boxtype down box () const
This box type is used to surround the currently-selected items in the menus.
• void down box (Fl Boxtype b)
See Fl Boxtype Fl Menu ::down box() const.
• Fl Color down color () const
For back compatibility, same as selection color()
• void down color (unsigned c)
For back compatibility, same as selection color()
• int find index (const char ∗name) const
Find the menu item index for a given menu pathname, such as ”Edit/Copy”.
• int find index (const Fl Menu Item ∗item) const
Find the index the menu array for given item.
• int find index (Fl Callback ∗cb) const
Find the index into the menu array for a given callback cb.
• const Fl Menu Item ∗ find item (const char ∗name)
Find the menu item for a given menu pathname, such as ”Edit/Copy”.
• const Fl Menu Item ∗ find item (Fl Callback ∗)
Find the menu item for the given callback cb.
• Fl Menu (int, int, int, int, const char ∗=0)
Creates a new Fl Menu widget using the given position, size, and label string.
• void global ()
Make the shortcuts for this menu work no matter what window has the focus when you type it.
• int insert (int index, const char ∗, int shortcut, Fl Callback ∗, void ∗=0, int=0)
Inserts a new menu item at the specified index position.
• int insert (int index, const char ∗a, const char ∗b, Fl Callback ∗c, void ∗d=0, int e=0)
See int Fl Menu ::insert(const char∗ label, int shortcut, Fl Callback∗, void ∗user data=0, int flags=0)
• int item pathname (char ∗name, int namelen, const Fl Menu Item ∗finditem=0) const
Get the menu ’pathname’ for the specified menuitem.
• const Fl Menu Item ∗ menu () const
Returns a pointer to the array of Fl Menu Items.
• void menu (const Fl Menu Item ∗m)
Sets the menu array pointer directly.
• void mode (int i, int fl)
Sets the flags of item i.
• int mode (int i) const
Gets the flags of item i.
• const Fl Menu Item ∗ mvalue () const
Returns a pointer to the last menu item that was picked.
31.79. FL MENU CLASS REFERENCE 517

• const Fl Menu Item ∗ picked (const Fl Menu Item ∗)


When user picks a menu item, call this.
• void remove (int)
Deletes item i from the menu.
• void replace (int, const char ∗)
Changes the text of item i.
• void shortcut (int i, int s)
Changes the shortcut of item i to n.
• int size () const
This returns the number of Fl Menu Item structures that make up the menu, correctly counting submenus.
• void size (int W, int H)
• const Fl Menu Item ∗ test shortcut ()
Returns the menu item with the entered shortcut (key value).
• const char ∗ text () const
Returns the title of the last item chosen.
• const char ∗ text (int i) const
Returns the title of item i.
• Fl Color textcolor () const
Get the current color of menu item labels.
• void textcolor (Fl Color c)
Sets the current color of menu item labels.
• Fl Font textfont () const
Gets the current font of menu item labels.
• void textfont (Fl Font c)
Sets the current font of menu item labels.
• Fl Fontsize textsize () const
Gets the font size of menu item labels.
• void textsize (Fl Fontsize c)
Sets the font size of menu item labels.
• int value () const
Returns the index into menu() of the last item chosen by the user.
• int value (const Fl Menu Item ∗)
The value is the index into menu() of the last item chosen by the user.
• int value (int i)
The value is the index into menu() of the last item chosen by the user.

Protected Attributes
• uchar alloc
• uchar down box
• Fl Color textcolor
• Fl Font textfont
• Fl Fontsize textsize
518 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.79.1 Detailed Description
Base class of all widgets that have a menu in FLTK.
Currently FLTK provides you with Fl Menu Button, Fl Menu Bar, and Fl Choice.
The class contains a pointer to an array of structures of type Fl Menu Item. The array may either be
supplied directly by the user program, or it may be ”private”: a dynamically allocated array managed by
the Fl Menu .

31.79.2 Constructor & Destructor Documentation


Fl Menu ::Fl Menu ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Menu widget using the given position, size, and label string.
menu() is initialized to null.

31.79.3 Member Function Documentation


int Fl Menu ::add ( const char ∗ label, int shortcut, Fl Callback ∗ callback, void ∗ userdata = 0,
int flags = 0 )
Adds a new menu item.
Parameters
in label The text label for the menu item.
in shortcut Optional keyboard shortcut that can be an int or string; (FL CTRL+’a’)
or ”∧ a”. Default 0 if none.
in callback Optional callback invoked when user clicks the item. Default 0 if none.
in userdata Optional user data passed as an argument to the callback. Default 0 if
none.
in flags Optional flags that control the type of menu item; see below. Default is
0 for none.

Returns
The index into the menu() array, where the entry was added.
Description

If the menu array was directly set with menu(x), then copy() is done to make a private array.

Since this method can change the internal menu array, any menu item pointers or indecies the applica-
tion may have cached can become stale, and should be recalculated/refreshed.

A menu item’s callback must not add() items to its parent menu during the callback.

Detailed Description of Parameters


label
The menu item’s label. This option is required.

The characters ”&”, ”/”, ”\”, and ” ” are treated as special characters in the label string. The ”&”
character specifies that the following character is an accelerator and will be underlined. The ”\”
character is used to escape the next character in the string. Labels starting with the ” ” character cause
a divider to be placed after that menu item.
31.79. FL MENU CLASS REFERENCE 519

A label of the form ”File/Quit” will create the submenu ”File” with a menu item called ”Quit”. The
”/” character is ignored if it appears as the first character of the label string, e.g. ”/File/Quit”.

The label string is copied to new memory and can be freed. The other arguments (including the
shortcut) are copied into the menu item unchanged.

If an item exists already with that name then it is replaced with this new one. Otherwise this new one
is added to the end of the correct menu or submenu. The return value is the offset into the array that
the new entry was placed at.
shortcut
The keyboard shortcut for this menu item.

This parameter is optional, and defaults to 0 to indicate no shortcut.

The shortcut can either be a raw integer value (eg. FL CTRL+’A’) or a string (eg. ”∧ c” or ”∧ 97”).

Raw integer shortcuts can be a combination of keyboard chars (eg. ’A’) and optional keyboard mod-
ifiers (see Fl::event state(), e.g. FL SHIFT, etc). In addition, FL COMMAND can be used to denote
FL META under Mac OS X and FL CTRL under other platforms.

String shortcuts can be specified in one of two ways:

[#+ˆ]<ascii_value> e.g. "97", "ˆ97", "+97", "#97"


[#+ˆ]<ascii_char> e.g. "a", "ˆa", "+a", "#a"

..where <ascii value> is a decimal value representing an ascii character (eg. 97 is the ascii code for
’a’), and the optional prefixes enhance the value that follows. Multiple prefixes must appear in the
order below.

# - Alt
+ - Shift
ˆ - Control

Internally, the text shortcuts are converted to integer values using fl old shortcut(const char∗).
callback
The callback to invoke when this menu item is selected.

This parameter is optional, and defaults to 0 for no callback.


userdata
The callback’s ’user data’ that is passed to the callback.

This parameter is optional, and defaults to 0.


flags

These are bit flags to define what kind of menu item this is.
520 CHAPTER 31. CLASS DOCUMENTATION

This parameter is optional, and defaults to 0 to define a ’regular’ menu item.

These flags can be ’OR’ed together:


FL MENU INACTIVE // Deactivate menu item (gray out)
FL MENU TOGGLE // Item is a checkbox toggle (shows checkbox for on/off state)
FL MENU VALUE // The on/off state for checkbox/radio buttons (if set, state is ’on’)
FL MENU RADIO // Item is a radio button (one checkbox of many can be on)
FL MENU INVISIBLE // Item will not show up (shortcut will work)
FL SUBMENU POINTER // Indicates user data() is a pointer to another menu array
FL SUBMENU // This item is a submenu to other items
FL MENU DIVIDER // Creates divider line below this item. Also ends a group of radio buttons.

Todo Raw integer shortcut needs examples. Dependent on responses to http://fltk.org/newsgroups.-


php?gfltk.development+v:10086 and results of STR#2344

int Fl Menu ::add ( const char ∗ str )


This is a Forms (and SGI GL library) compatible add function, it adds many menu items, with ’|’ separating
the menu items, and tab separating the menu item names from an optional shortcut string.
The passed string is split at any ’|’ characters and then add(s,0,0,0,0) is done with each section. This
is often useful if you are just using the value, and is compatible with Forms and other GL programs. The
section strings use the same special characters as described for the long version of add().
No items must be added to a menu during a callback to the same menu.
Parameters
str string containing multiple menu labels as described above

Returns
the index into the menu() array, where the entry was added

void Fl Menu ::clear ( )


Same as menu(NULL), set the array pointer to null, indicating a zero-length menu.
Menus must not be cleared during a callback to the same menu.

int Fl Menu ::clear submenu ( int index )


Clears the specified submenu pointed to by index of all menu items.
This method is useful for clearing a submenu so that it can be re-populated with new items. Example:
a ”File/Recent Files/...” submenu that shows the last few files that have been opened.
The specified index must point to a submenu.
The submenu is cleared with remove(). If the menu array was directly set with menu(x), then copy() is
done to make a private array.
Warning

Since this method can change the internal menu array, any menu item pointers or indecies the appli-
cation may have cached can become stale, and should be recalculated/refreshed.

Example:
int index = menubar->find index("File/Recent"); // get index of "File/Recent" submenu
if ( index != -1 ) menubar->clear submenu(index); // clear the submenu
menubar->add("File/Recent/Aaa");
menubar->add("File/Recent/Bbb");
[..]
31.79. FL MENU CLASS REFERENCE 521

Parameters
index The index of the submenu to be cleared

Returns
0 on success, -1 if the index is out of range or not a submenu

See Also
remove(int)

void Fl Menu ::copy ( const Fl Menu Item ∗ m, void ∗ ud = 0 )


Sets the menu array pointer with a copy of m that will be automatically deleted.
If userdata ud is not NULL, then all user data pointers are changed in the menus as well. See void
Fl Menu ::menu(const Fl Menu Item∗ m).

Fl Boxtype Fl Menu ::down box ( ) const [inline]


This box type is used to surround the currently-selected items in the menus.
If this is FL NO BOX then it acts like FL THIN UP BOX and selection color() acts like FL WHITE,
for back compatibility.

int Fl Menu ::find index ( const char ∗ pathname ) const


Find the menu item index for a given menu pathname, such as ”Edit/Copy”.
This method finds a menu item’s index position for the given menu pathname, also traversing submenus,
but not submenu pointers.
To get the menu item pointer for a pathname, use find item()
Parameters
pathname The path and name of the menu item index to find

Returns
The index of the matching item, or -1 if not found.

See Also
item pathname()

int Fl Menu ::find index ( const Fl Menu Item ∗ item ) const


Find the index the menu array for given item.
A way to convert a menu item pointer into an index.
Current implementation is fast and not expensive.
// Convert an index-to-item
int index = 12;
const Fl Menu Item *item = mymenu->menu() + index;

// Convert an item-to-index
int index = mymenu->find index(item);
if ( index == -1 ) { ..error.. }
522 CHAPTER 31. CLASS DOCUMENTATION

Parameters
item The ∗item to be found

Returns
The index of the item, or -1 if not found.

See Also
menu()

int Fl Menu ::find index ( Fl Callback ∗ cb ) const


Find the index into the menu array for a given callback cb.
This method finds a menu item’s index position, also traversing submenus, but not submenu pointers.
This is useful if an application uses internationalisation and a menu item can not be found using its label.
This search is also much faster.
Parameters
cb Find the first item with this callback

Returns
The index of the item with the specific callback, or -1 if not found

See Also
find index(const char∗)

const Fl Menu Item ∗ Fl Menu ::find item ( const char ∗ pathname )


Find the menu item for a given menu pathname, such as ”Edit/Copy”.
This method finds a menu item in the menu array, also traversing submenus, but not submenu pointers.
To get the menu item’s index, use find index(const char∗)
Example:
Fl Menu Bar *menubar = new Fl Menu Bar(..);
menubar->add("File/&Open");
menubar->add("File/&Save");
menubar->add("Edit/&Copy");
// [..]
Fl Menu Item *item;
if ( ( item = (Fl Menu Item*)menubar->find item("File/&Open") ) != NULL ) {
item->labelcolor(FL RED);
}
if ( ( item = (Fl Menu Item*)menubar->find item("Edit/&Copy") ) != NULL ) {
item->labelcolor(FL GREEN);
}

Parameters
pathname The path and name of the menu item

Returns
The item found, or NULL if not found

See Also
find index(const char∗), find item(Fl Callback∗), item pathname()
31.79. FL MENU CLASS REFERENCE 523

const Fl Menu Item ∗ Fl Menu ::find item ( Fl Callback ∗ cb )


Find the menu item for the given callback cb.
This method finds a menu item in a menu array, also traversing submenus, but not submenu pointers.
This is useful if an application uses internationalisation and a menu item can not be found using its label.
This search is also much faster.
Parameters
cb find the first item with this callback

Returns
The item found, or NULL if not found

See Also
find item(const char∗)

void Fl Menu ::global ( )


Make the shortcuts for this menu work no matter what window has the focus when you type it.
This is done by using Fl::add handler(). This Fl Menu widget does not have to be visible (ie the
window it is in can be hidden, or it does not have to be put in a window at all).
Currently there can be only one global()menu. Setting a new one will replace the old one. There is no
way to remove the global() setting (so don’t destroy the widget!)

int Fl Menu ::insert ( int index, const char ∗ label, int shortcut, Fl Callback ∗ callback, void ∗
userdata = 0, int flags = 0 )
Inserts a new menu item at the specified index position.
If index is -1, the menu item is appended; same behavior as add().
To properly insert a menu item, label must be the name of the item (eg. ”Quit”), and not a ’menu
pathname’ (eg. ”File/Quit”). If a menu pathname is specified, the value of index is ignored, the new
item’s position defined by the pathname.
For more details, see add(). Except for the index parameter, add() has more detailed information on
parameters and behavior, and is functionally equivalent.
Parameters
in index The menu array’s index position where the new item is inserted. If -1,
behavior is the same as add().
in label The text label for the menu item. If the label is a menu pathname, index
is ignored, and the pathname indicates the position of the new item.
in shortcut Optional keyboard shortcut. Can be an int (FL CTRL+’a’) or a string
(”∧ a”). Default is 0.
in callback Optional callback invoked when user clicks the item. Default 0 if none.
in userdata Optional user data passed as an argument to the callback. Default 0 if
none.
in flags Optional flags that control the type of menu item; see add() for more
info. Default is 0 for none.

Returns
The index into the menu() array, where the entry was added.

See Also
add()
524 CHAPTER 31. CLASS DOCUMENTATION

int Fl Menu ::item pathname ( char ∗ name, int namelen, const Fl Menu Item ∗ finditem = 0 )
const
Get the menu ’pathname’ for the specified menuitem.
If finditem==NULL, mvalue() is used (the most recently picked menuitem).
Example:

Fl Menu Bar *menubar = 0;


void my menu callback(Fl Widget*,void*) {
char name[80];
if ( menubar->item pathname(name, sizeof(name)-1) == 0 ) { // recently picked item
if ( strcmp(name, "File/&Open") == 0 ) { .. } // open invoked
if ( strcmp(name, "File/&Save") == 0 ) { .. } // save invoked
if ( strcmp(name, "Edit/&Copy") == 0 ) { .. } // copy invoked
}
}
int main() {
[..]
menubar = new Fl Menu Bar(..);
menubar->add("File/&Open", 0, my menu callback);
menubar->add("File/&Save", 0, my menu callback);
menubar->add("Edit/&Copy", 0, my menu callback);
[..]
}

Returns
• 0 : OK (name has menuitem’s pathname)
• -1 : item not found (name=””)
• -2 : ’name’ not large enough (name=””)

See Also
find item()

const Fl Menu Item∗ Fl Menu ::menu ( ) const [inline]


Returns a pointer to the array of Fl Menu Items.
This will either be the value passed to menu(value) or the private copy.

See Also
size() – returns the size of the Fl Menu Item array.

Example: How to walk the array:

for ( int t=0; t<menubar->size(); t++ ) { // walk array of items


const Fl Menu Item &item = menubar->menu()[t]; // get each item
fprintf(stderr, "item #%d -- label=%s, value=%s type=%s\n",
t,
item.label() ? item.label() : "(Null)", // menu terminators have NULL labels
(item.flags & FL MENU VALUE) ? "set" : "clear", // value of toggle or radio items
(item.flags & FL SUBMENU) ? "Submenu" : "Item"); // see if item is a submenu or actual item
}

void Fl Menu ::menu ( const Fl Menu Item ∗ m )


Sets the menu array pointer directly.
If the old menu is private it is deleted. NULL is allowed and acts the same as a zero-length menu. If
you try to modify the array (with add(), replace(), or remove()) a private copy is automatically done.
31.79. FL MENU CLASS REFERENCE 525

void Fl Menu ::mode ( int i, int fl ) [inline]


Sets the flags of item i.
For a list of the flags, see Fl Menu Item.

int Fl Menu ::mode ( int i ) const [inline]


Gets the flags of item i.
For a list of the flags, see Fl Menu Item.

const Fl Menu Item∗ Fl Menu ::mvalue ( ) const [inline]


Returns a pointer to the last menu item that was picked.

const Fl Menu Item ∗ Fl Menu ::picked ( const Fl Menu Item ∗ v )


When user picks a menu item, call this.
It will do the callback. Unfortunately this also casts away const for the checkboxes, but this was
necessary so non-checkbox menus can really be declared const...

void Fl Menu ::remove ( int i )


Deletes item i from the menu.
If the menu array was directly set with menu(x) then copy() is done to make a private array.
No items must be removed from a menu during a callback to the same menu.
Parameters
i index into menu array

void Fl Menu ::replace ( int i, const char ∗ str )


Changes the text of item i.
This is the only way to get slash into an add()’ed menu item. If the menu array was directly set with
menu(x) then copy() is done to make a private array.
Parameters
i index into menu array
str new label for menu item at index i

void Fl Menu ::shortcut ( int i, int s ) [inline]


Changes the shortcut of item i to n.

int Fl Menu ::size ( ) const


This returns the number of Fl Menu Item structures that make up the menu, correctly counting submenus.
This includes the ”terminator” item at the end. To copy a menu array you need to copy size()∗sizeof(Fl-
Menu Item) bytes. If the menu is NULL this returns zero (an empty menu will return 1).

const Fl Menu Item∗ Fl Menu ::test shortcut ( ) [inline]


Returns the menu item with the entered shortcut (key value).
This searches the complete menu() for a shortcut that matches the entered key value. It must be called
for a FL KEYBOARD or FL SHORTCUT event.
If a match is found, the menu’s callback will be called.
526 CHAPTER 31. CLASS DOCUMENTATION

Returns
matched Fl Menu Item or NULL.

const char∗ Fl Menu ::text ( ) const [inline]


Returns the title of the last item chosen.

const char∗ Fl Menu ::text ( int i ) const [inline]


Returns the title of item i.

Fl Color Fl Menu ::textcolor ( ) const [inline]


Get the current color of menu item labels.

void Fl Menu ::textcolor ( Fl Color c ) [inline]


Sets the current color of menu item labels.

Fl Font Fl Menu ::textfont ( ) const [inline]


Gets the current font of menu item labels.

void Fl Menu ::textfont ( Fl Font c ) [inline]


Sets the current font of menu item labels.

Fl Fontsize Fl Menu ::textsize ( ) const [inline]


Gets the font size of menu item labels.

void Fl Menu ::textsize ( Fl Fontsize c ) [inline]


Sets the font size of menu item labels.

int Fl Menu ::value ( ) const [inline]


Returns the index into menu() of the last item chosen by the user.
It is zero initially.

int Fl Menu ::value ( const Fl Menu Item ∗ m )


The value is the index into menu() of the last item chosen by the user.
It is zero initially. You can set it as an integer, or set it with a pointer to a menu item. The set routines
return non-zero if the new value is different than the old one.

int Fl Menu ::value ( int i ) [inline]


The value is the index into menu() of the last item chosen by the user.
It is zero initially. You can set it as an integer, or set it with a pointer to a menu item. The set routines
return non-zero if the new value is different than the old one.
The documentation for this class was generated from the following files:
• Fl Menu .H
• Fl Menu .cxx
• Fl Menu add.cxx
• Fl Menu global.cxx
31.80. FL MENU BAR CLASS REFERENCE 527

31.80 Fl Menu Bar Class Reference


This widget provides a standard menubar interface.
#include <Fl Menu Bar.H>
Inheritance diagram for Fl Menu Bar:

Fl_Widget

Fl_Menu_

Fl_Menu_Bar

Fl_Sys_Menu_Bar

Public Member Functions


• Fl Menu Bar (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Menu Bar widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.80.1 Detailed Description
This widget provides a standard menubar interface.
Usually you will put this widget along the top edge of your window. The height of the widget should
be 30 for the menu titles to draw correctly with the default font.
The items on the bar and the menus they bring up are defined by a single Fl Menu Item array. Because
a Fl Menu Item array defines a hierarchy, the top level menu defines the items in the menubar, while the
submenus define the pull-down menus. Sub-sub menus and lower pop up to the right of the submenus.

Figure 31.19: menubar

If there is an item in the top menu that is not a title of a submenu, then it acts like a ”button” in the
menubar. Clicking on it will pick it.
When the user picks an item off the menu, the item’s callback is done with the menubar as the Fl -
Widget∗ argument. If the item does not have a callback the menubar’s callback is done instead.
528 CHAPTER 31. CLASS DOCUMENTATION

Submenus will also pop up in response to shortcuts indicated by putting a ’&’ character in the name
field of the menu item. If you put a ’&’ character in a top-level ”button” then the shortcut picks it. The ’&’
character in submenus is ignored until the menu is popped up.
Typing the shortcut() of any of the menu items will cause callbacks exactly the same as when you pick
the item with the mouse.

31.80.2 Constructor & Destructor Documentation


Fl Menu Bar::Fl Menu Bar ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Menu Bar widget using the given position, size, and label string.
The default boxtype is FL UP BOX.
The constructor sets menu() to NULL. See Fl Menu for the methods to set or change the menu.
labelsize(), labelfont(), and labelcolor() are used to control how the menubar items are drawn. They are
initialized from the Fl Menu static variables, but you can change them if desired.
label() is ignored unless you change align() to put it outside the menubar.
The destructor removes the Fl Menu Bar widget and all of its menu items.

31.80.3 Member Function Documentation


void Fl Menu Bar::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:

Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar


s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.
Reimplemented in Fl Sys Menu Bar.

int Fl Menu Bar::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted
31.81. FL MENU BUTTON CLASS REFERENCE 529

See Also
Fl Event

Reimplemented from Fl Widget.


The documentation for this class was generated from the following files:

• Fl Menu Bar.H
• Fl Menu Bar.cxx

31.81 Fl Menu Button Class Reference


This is a button that when pushed pops up a menu (or hierarchy of menus) defined by an array of Fl Menu-
Item objects.
#include <Fl Menu Button.H>
Inheritance diagram for Fl Menu Button:

Fl_Widget

Fl_Menu_

Fl_Menu_Button

Public Types
• enum popup buttons {
POPUP1 = 1, POPUP2, POPUP12, POPUP3,
POPUP13, POPUP23, POPUP123 }
indicate what mouse buttons pop up the menu.

Public Member Functions


• Fl Menu Button (int, int, int, int, const char ∗=0)
Creates a new Fl Menu Button widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
• const Fl Menu Item ∗ popup ()
Act exactly as though the user clicked the button or typed the shortcut key.

Protected Member Functions


• void draw ()
Draws the widget.
530 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.81.1 Detailed Description
This is a button that when pushed pops up a menu (or hierarchy of menus) defined by an array of Fl Menu-
Item objects.

Figure 31.20: menu button

Normally any mouse button will pop up a menu and it is lined up below the button as shown in the
picture. However an Fl Menu Button may also control a pop-up menu. This is done by setting the type().
If type() is zero a normal menu button is produced. If it is nonzero then this is a pop-up menu. The bits in
type() indicate what mouse buttons pop up the menu (see Fl Menu Button::popup buttons).
The menu will also pop up in response to shortcuts indicated by putting a ’&’ character in the label().
Typing the shortcut() of any of the menu items will cause callbacks exactly the same as when you pick
the item with the mouse. The ’&’ character in menu item names are only looked at when the menu is
popped up, however.
When the user picks an item off the menu, the item’s callback is done with the menu button as the
Fl Widget∗ argument. If the item does not have a callback the menu button’s callback is done instead.

31.81.2 Member Enumeration Documentation


enum Fl Menu Button::popup buttons
indicate what mouse buttons pop up the menu.
Values for type() used to indicate what mouse buttons pop up the menu. Fl Menu Button::POPUP3 is
usually what you want.
Enumerator
POPUP1 pops up with the mouse 1st button.
POPUP2 pops up with the mouse 2nd button.
POPUP12 pops up with the mouse 1st or 2nd buttons.
POPUP3 pops up with the mouse 3rd button.
POPUP13 pops up with the mouse 1st or 3rd buttons.
POPUP23 pops up with the mouse 2nd or 3rd buttons.
31.81. FL MENU BUTTON CLASS REFERENCE 531

POPUP123 pops up with any mouse button.

31.81.3 Constructor & Destructor Documentation


Fl Menu Button::Fl Menu Button ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Menu Button widget using the given position, size, and label string.
The default boxtype is FL UP BOX.
The constructor sets menu() to NULL. See Fl Menu for the methods to set or change the menu.

31.81.4 Member Function Documentation


void Fl Menu Button::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Menu Button::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event
Reimplemented from Fl Widget.

const Fl Menu Item ∗ Fl Menu Button::popup ( )


Act exactly as though the user clicked the button or typed the shortcut key.
The menu appears, it waits for the user to pick an item, and if they pick one it sets value() and does the
callback or sets changed() as described above. The menu item is returned or NULL if the user dismisses
the menu.
The documentation for this class was generated from the following files:
• Fl Menu Button.H
• Fl Menu Button.cxx
532 CHAPTER 31. CLASS DOCUMENTATION

31.82 Fl Menu Item Struct Reference


The Fl Menu Item structure defines a single menu item that is used by the Fl Menu class.
#include <Fl Menu Item.H>

Public Member Functions


• void activate ()
Allows a menu item to be picked.
• int active () const
Gets whether or not the item can be picked.
• int activevisible () const
Returns non 0 if FL INACTIVE and FL INVISIBLE are cleared, 0 otherwise.
• int add (const char ∗, int shortcut, Fl Callback ∗, void ∗=0, int=0)
Adds an item.
• int add (const char ∗a, const char ∗b, Fl Callback ∗c, void ∗d=0, int e=0)
See int add(const char∗, int shortcut, Fl Callback∗, void∗, int)
• long argument () const
Gets the user data() argument that is sent to the callback function.
• void argument (long v)
Sets the user data() argument that is sent to the callback function.
• Fl Callback p callback () const
Returns the callback function that is set for the menu item.
• void callback (Fl Callback ∗c, void ∗p)
Sets the menu item’s callback function and userdata() argument.
• void callback (Fl Callback ∗c)
Sets the menu item’s callback function.
• void callback (Fl Callback0 ∗c)
Sets the menu item’s callback function.
• void callback (Fl Callback1 ∗c, long p=0)
Sets the menu item’s callback function and userdata() argument.
• void check ()
back compatibility only
• int checkbox () const
Returns true if a checkbox will be drawn next to this item.
• int checked () const
back compatibility only
• void clear ()
Turns the check or radio item ”off” for the menu item.
• void deactivate ()
Prevents a menu item from being picked.
• void do callback (Fl Widget ∗o) const
Calls the Fl Menu Item item’s callback, and provides the Fl Widget argument.
• void do callback (Fl Widget ∗o, void ∗arg) const
Calls the Fl Menu Item item’s callback, and provides the Fl Widget argument.
• void do callback (Fl Widget ∗o, long arg) const
Calls the Fl Menu Item item’s callback, and provides the Fl Widget argument.
• void draw (int x, int y, int w, int h, const Fl Menu ∗, int t=0) const
31.82. FL MENU ITEM STRUCT REFERENCE 533

Draws the menu item in bounding box x,y,w,h, optionally selects the item.
• const Fl Menu Item ∗ find shortcut (int ∗ip=0, const bool require alt=false) const
Search only the top level menu for a shortcut.
• const Fl Menu Item ∗ first () const
Returns the first menu item, same as next(0).
• Fl Menu Item ∗ first ()
Returns the first menu item, same as next(0).
• void hide ()
Hides an item in the menu.
• void image (Fl Image ∗a)
compatibility api for FLUID, same as a->label(this)
• void image (Fl Image &a)
compatibility api for FLUID, same as a.label(this)
• int insert (int, const char ∗, int, Fl Callback ∗, void ∗=0, int=0)
Inserts an item at position index.
• const char ∗ label () const
Returns the title of the item.
• void label (const char ∗a)
See const char∗ Fl Menu Item::label() const.
• void label (Fl Labeltype a, const char ∗b)
See const char∗ Fl Menu Item::label() const.
• Fl Color labelcolor () const
Gets the menu item’s label color.
• void labelcolor (Fl Color a)
Sets the menu item’s label color.
• Fl Font labelfont () const
Gets the menu item’s label font.
• void labelfont (Fl Font a)
Sets the menu item’s label font.
• Fl Fontsize labelsize () const
Gets the label font pixel size/height.
• void labelsize (Fl Fontsize a)
Sets the label font pixel size/height.
• Fl Labeltype labeltype () const
Returns the menu item’s labeltype.
• void labeltype (Fl Labeltype a)
Sets the menu item’s labeltype.
• int measure (int ∗h, const Fl Menu ∗) const
Measures width of label, including effect of & characters.
• const Fl Menu Item ∗ next (int=1) const
Advance a pointer by n items through a menu array, skipping the contents of submenus and invisible items.
• Fl Menu Item ∗ next (int i=1)
Advances a pointer by n items through a menu array, skipping the contents of submenus and invisible items.
• const Fl Menu Item ∗ popup (int X, int Y, const char ∗title=0, const Fl Menu Item ∗picked=0, const
Fl Menu ∗=0) const
This method is called by widgets that want to display menus.
534 CHAPTER 31. CLASS DOCUMENTATION

• const Fl Menu Item ∗ pulldown (int X, int Y, int W, int H, const Fl Menu Item ∗picked=0, const
Fl Menu ∗=0, const Fl Menu Item ∗title=0, int menubar=0) const
Pulldown() is similar to popup(), but a rectangle is provided to position the menu.
• int radio () const
Returns true if this item is a radio item.
• void set ()
Turns the check or radio item ”on” for the menu item.
• void setonly ()
Turns the radio item ”on” for the menu item and turns off adjacent radio items set.
• int shortcut () const
Gets what key combination shortcut will trigger the menu item.
• void shortcut (int s)
Sets exactly what key combination will trigger the menu item.
• void show ()
Makes an item visible in the menu.
• int size () const
Size of the menu starting from this menu item.
• int submenu () const
Returns true if either FL SUBMENU or FL SUBMENU POINTER is on in the flags.
• const Fl Menu Item ∗ test shortcut () const
This is designed to be called by a widgets handle() method in response to a FL SHORTCUT event.
• void uncheck ()
back compatibility only
• void ∗ user data () const
Gets the user data() argument that is sent to the callback function.
• void user data (void ∗v)
Sets the user data() argument that is sent to the callback function.
• int value () const
Returns the current value of the check or radio item.
• int visible () const
Gets the visibility of an item.

Public Attributes
• Fl Callback ∗ callback
menu item callback
• int flags
menu item flags like FL MENU TOGGLE, FL MENU RADIO
• Fl Color labelcolor
menu item text color
• Fl Font labelfont
which font for this menu item text
• Fl Fontsize labelsize
size of menu item text
• uchar labeltype
how the menu item text looks like
• int shortcut
31.82. FL MENU ITEM STRUCT REFERENCE 535

menu item shortcut

• const char ∗ text

menu item text, returned by label()

• void ∗ user data

menu item user data for the menu’s callback

31.82.1 Detailed Description

The Fl Menu Item structure defines a single menu item that is used by the Fl Menu class.

struct Fl Menu Item {


const char* text; // label()
ulong shortcut ;
Fl Callback* callback ;
void* user data ;
int flags;
uchar labeltype ;
uchar labelfont ;
uchar labelsize ;
uchar labelcolor ;
};

enum { // values for flags:


FL MENU INACTIVE = 1, // Deactivate menu item (gray out)
FL MENU TOGGLE = 2, // Item is a checkbox toggle (shows checkbox for on/off state)
FL MENU VALUE = 4, // The on/off state for checkbox/radio buttons (if set, state is ’on’)
FL MENU RADIO = 8, // Item is a radio button (one checkbox of many can be on)
FL MENU INVISIBLE = 0x10, // Item will not show up (shortcut will work)
FL SUBMENU POINTER = 0x20, // Indicates user data() is a pointer to another menu array
FL SUBMENU = 0x40, // This item is a submenu to other items
FL MENU DIVIDER = 0x80, // Creates divider line below this item. Also ends a group of radio
buttons.
FL MENU HORIZONTAL = 0x100 // ??? -- reserved
};

Typically menu items are statically defined; for example:

Fl Menu Item popup[] = {


{"&alpha", FL ALT+’a’, the cb, (void*)1},
{"&beta", FL ALT+’b’, the cb, (void*)2},
{"gamma", FL ALT+’c’, the cb, (void*)3, FL MENU DIVIDER},
{"&strange", 0, strange cb},
{"&charm", 0, charm cb},
{"&truth", 0, truth cb},
{"b&eauty", 0, beauty cb},
{"sub&menu", 0, 0, 0, FL SUBMENU},
{"one"},
{"two"},
{"three"},
{0},
{"inactive", FL ALT+’i’, 0, 0, FL MENU INACTIVE|FL MENU DIVIDER},
{"invisible",FL ALT+’i’, 0, 0, FL MENU INVISIBLE},
{"check", FL ALT+’i’, 0, 0, FL MENU TOGGLE|FL MENU VALUE},
{"box", FL ALT+’i’, 0, 0, FL MENU TOGGLE},
{0}};

produces:
536 CHAPTER 31. CLASS DOCUMENTATION

Figure 31.21: menu

A submenu title is identified by the bit FL SUBMENU in the flags field, and ends with a label() that is
NULL. You can nest menus to any depth. A pointer to the first item in the submenu can be treated as an
Fl Menu array itself. It is also possible to make separate submenu arrays with FL SUBMENU POINTER
flags.
You should use the method functions to access structure members and not access them directly to avoid
compatibility problems with future releases of FLTK.

31.82.2 Member Function Documentation


void Fl Menu Item::activate ( ) [inline]

Allows a menu item to be picked.

int Fl Menu Item::active ( ) const [inline]

Gets whether or not the item can be picked.

int Fl Menu Item::activevisible ( ) const [inline]

Returns non 0 if FL INACTIVE and FL INVISIBLE are cleared, 0 otherwise.


31.82. FL MENU ITEM STRUCT REFERENCE 537

int Fl Menu Item::add ( const char ∗ mytext, int sc, Fl Callback ∗ cb, void ∗ data = 0, int myflags
=0 )
Adds an item.
The text is split at ’/’ characters to automatically produce submenus (actually a totally unnecessary
feature as you can now add submenu titles directly by setting SUBMENU in the flags):

long Fl Menu Item::argument ( ) const [inline]


Gets the user data() argument that is sent to the callback function.
For convenience you can also define the callback as taking a long argument. This method casts the
stored userdata() argument to long and returns it as a long value.

void Fl Menu Item::argument ( long v ) [inline]


Sets the user data() argument that is sent to the callback function.
For convenience you can also define the callback as taking a long argument. This method casts the
given argument v to void∗ and stores it in the menu item’s userdata() member. This may not be portable to
some machines.

Fl Callback p Fl Menu Item::callback ( ) const [inline]


Returns the callback function that is set for the menu item.
Each item has space for a callback function and an argument for that function. Due to back compatibil-
ity, the Fl Menu Item itself is not passed to the callback, instead you have to get it by calling ((Fl Menu -
∗)w)->mvalue() where w is the widget argument.

void Fl Menu Item::callback ( Fl Callback ∗ c, void ∗ p ) [inline]


Sets the menu item’s callback function and userdata() argument.

See Also
Fl Callback p Fl MenuItem::callback() const

void Fl Menu Item::callback ( Fl Callback ∗ c ) [inline]


Sets the menu item’s callback function.
This method does not set the userdata() argument.

See Also
Fl Callback p Fl MenuItem::callback() const

void Fl Menu Item::callback ( Fl Callback0 ∗ c ) [inline]


Sets the menu item’s callback function.
This method does not set the userdata() argument.

See Also
Fl Callback p Fl MenuItem::callback() const
538 CHAPTER 31. CLASS DOCUMENTATION

void Fl Menu Item::callback ( Fl Callback1 ∗ c, long p = 0 ) [inline]


Sets the menu item’s callback function and userdata() argument.
This method does not set the userdata() argument. The argument is cast to void∗ and stored as the
userdata() for the menu item’s callback function.

See Also
Fl Callback p Fl MenuItem::callback() const

void Fl Menu Item::check ( ) [inline]


back compatibility only

Deprecated .

int Fl Menu Item::checkbox ( ) const [inline]


Returns true if a checkbox will be drawn next to this item.
This is true if FL MENU TOGGLE or FL MENU RADIO is set in the flags.

int Fl Menu Item::checked ( ) const [inline]


back compatibility only

Deprecated .

void Fl Menu Item::clear ( ) [inline]


Turns the check or radio item ”off” for the menu item.

void Fl Menu Item::deactivate ( ) [inline]


Prevents a menu item from being picked.
Note that this will also cause the menu item to appear grayed-out.

void Fl Menu Item::do callback ( Fl Widget ∗ o ) const [inline]


Calls the Fl Menu Item item’s callback, and provides the Fl Widget argument.
The callback is called with the stored user data() as its second argument. You must first check that
callback() is non-zero before calling this.

void Fl Menu Item::do callback ( Fl Widget ∗ o, void ∗ arg ) const [inline]


Calls the Fl Menu Item item’s callback, and provides the Fl Widget argument.
This call overrides the callback’s second argument with the given value arg. You must first check that
callback() is non-zero before calling this.

void Fl Menu Item::do callback ( Fl Widget ∗ o, long arg ) const [inline]


Calls the Fl Menu Item item’s callback, and provides the Fl Widget argument.
This call overrides the callback’s second argument with the given value arg. long arg is cast to void∗
when calling the callback. You must first check that callback() is non-zero before calling this.
31.82. FL MENU ITEM STRUCT REFERENCE 539

void Fl Menu Item::draw ( int x, int y, int w, int h, const Fl Menu ∗ m, int selected = 0 ) const
Draws the menu item in bounding box x,y,w,h, optionally selects the item.

const Fl Menu Item ∗ Fl Menu Item::find shortcut ( int ∗ ip = 0, const bool require alt = false )
const
Search only the top level menu for a shortcut.
Either &x in the label or the shortcut fields are used.
This tests the current event, which must be an FL KEYBOARD or FL SHORTCUT, against a shortcut
value.
Parameters
ip returns the index of the item, if ip is not NULL.
require alt if true: match only if Alt key is pressed.

Returns
found Fl Menu Item or NULL

const Fl Menu Item∗ Fl Menu Item::first ( ) const [inline]


Returns the first menu item, same as next(0).

Fl Menu Item∗ Fl Menu Item::first ( ) [inline]


Returns the first menu item, same as next(0).

void Fl Menu Item::hide ( ) [inline]


Hides an item in the menu.

int Fl Menu Item::insert ( int index, const char ∗ mytext, int sc, Fl Callback ∗ cb, void ∗ data = 0,
int myflags = 0 )
Inserts an item at position index.
If index is -1, the item is added the same way as Fl Menu Item::add().
If ’mytext’ contains any un-escaped front slashes (/), it’s assumed a menu pathname is being specified,
and the value of index will be ignored.
In all other aspects, the behavior of insert() is the same as add().
Parameters
index insert new items here
mytext new label string, details see above
sc keyboard shortcut for new item
cb callback function for new item
data user data for new item
myflags menu flags as described in FL Menu Item

Returns
the index into the menu() array, where the entry was added
540 CHAPTER 31. CLASS DOCUMENTATION

const char∗ Fl Menu Item::label ( ) const [inline]


Returns the title of the item.
A NULL here indicates the end of the menu (or of a submenu). A ’&’ in the item will print an under-
score under the next letter, and if the menu is popped up that letter will be a ”shortcut” to pick that item.
To get a real ’&’ put two in a row.

Fl Color Fl Menu Item::labelcolor ( ) const [inline]


Gets the menu item’s label color.
This color is passed to the labeltype routine, and is typically the color of the label text. This defaults to
FL BLACK. If this color is not black fltk will not use overlay bitplanes to draw the menu - this is so that
images put in the menu draw correctly.

void Fl Menu Item::labelcolor ( Fl Color a ) [inline]


Sets the menu item’s label color.
See Also
Fl Color Fl Menu Item::labelcolor() const

Fl Font Fl Menu Item::labelfont ( ) const [inline]


Gets the menu item’s label font.
Fonts are identified by small 8-bit indexes into a table. See the enumeration list for predefined fonts.
The default value is a Helvetica font. The function Fl::set font() can define new fonts.

void Fl Menu Item::labelfont ( Fl Font a ) [inline]


Sets the menu item’s label font.
Fonts are identified by small 8-bit indexes into a table. See the enumeration list for predefined fonts.
The default value is a Helvetica font. The function Fl::set font() can define new fonts.

Fl Fontsize Fl Menu Item::labelsize ( ) const [inline]


Gets the label font pixel size/height.

void Fl Menu Item::labelsize ( Fl Fontsize a ) [inline]


Sets the label font pixel size/height.

Fl Labeltype Fl Menu Item::labeltype ( ) const [inline]


Returns the menu item’s labeltype.
A labeltype identifies a routine that draws the label of the widget. This can be used for special effects
such as emboss, or to use the label() pointer as another form of data such as a bitmap. The value FL NO-
RMAL LABEL prints the label as text.

void Fl Menu Item::labeltype ( Fl Labeltype a ) [inline]


Sets the menu item’s labeltype.
A labeltype identifies a routine that draws the label of the widget. This can be used for special effects
such as emboss, or to use the label() pointer as another form of data such as a bitmap. The value FL NO-
RMAL LABEL prints the label as text.
31.82. FL MENU ITEM STRUCT REFERENCE 541

int Fl Menu Item::measure ( int ∗ hp, const Fl Menu ∗ m ) const


Measures width of label, including effect of & characters.
Optionally, can get height if hp is not NULL.

const Fl Menu Item ∗ Fl Menu Item::next ( int n = 1 ) const


Advance a pointer by n items through a menu array, skipping the contents of submenus and invisible items.
There are two calls so that you can advance through const and non-const data.

Fl Menu Item∗ Fl Menu Item::next ( int i = 1 ) [inline]


Advances a pointer by n items through a menu array, skipping the contents of submenus and invisible items.
There are two calls so that you can advance through const and non-const data.

const Fl Menu Item ∗ Fl Menu Item::popup ( int X, int Y, const char ∗ title = 0, const
Fl Menu Item ∗ picked = 0, const Fl Menu ∗ button = 0 ) const
This method is called by widgets that want to display menus.
The menu stays up until the user picks an item or dismisses it. The selected item (or NULL if none) is
returned. This does not do the callbacks or change the state of check or radio items.
X,Y is the position of the mouse cursor, relative to the window that got the most recent event (usually
you can pass Fl::event x() and Fl::event y() unchanged here).
title is a character string title for the menu. If non-zero a small box appears above the menu with
the title in it.
The menu is positioned so the cursor is centered over the item picked. This will work even if picked
is in a submenu. If picked is zero or not in the menu item table the menu is positioned with the cursor in
the top-left corner.
button is a pointer to an Fl Menu from which the color and boxtypes for the menu are pulled. If
NULL then defaults are used.

const Fl Menu Item ∗ Fl Menu Item::pulldown ( int X, int Y, int W, int H, const Fl Menu Item ∗
initial item = 0, const Fl Menu ∗ pbutton = 0, const Fl Menu Item ∗ t = 0, int menubar = 0 ) const
Pulldown() is similar to popup(), but a rectangle is provided to position the menu.
The menu is made at least W wide, and the picked item is centered over the rectangle (like Fl Choice
uses). If picked is zero or not found, the menu is aligned just below the rectangle (like a pulldown menu).
The title and menubar arguments are used internally by the Fl Menu Bar widget.

int Fl Menu Item::radio ( ) const [inline]


Returns true if this item is a radio item.
When a radio button is selected all ”adjacent” radio buttons are turned off. A set of radio items is
delimited by an item that has radio() false, or by an item with FL MENU DIVIDER turned on.

void Fl Menu Item::set ( ) [inline]


Turns the check or radio item ”on” for the menu item.
Note that this does not turn off any adjacent radio items like set only() does.

void Fl Menu Item::setonly ( )


Turns the radio item ”on” for the menu item and turns off adjacent radio items set.
542 CHAPTER 31. CLASS DOCUMENTATION

int Fl Menu Item::shortcut ( ) const [inline]

Gets what key combination shortcut will trigger the menu item.

void Fl Menu Item::shortcut ( int s ) [inline]

Sets exactly what key combination will trigger the menu item.
The value is a logical ’or’ of a key and a set of shift flags, for instance FL ALT+’a’ or FL ALT+FL -
F+10 or just ’a’. A value of zero disables the shortcut.
The key can be any value returned by Fl::event key(), but will usually be an ASCII letter. Use a lower-
case letter unless you require the shift key to be held down.
The shift flags can be any set of values accepted by Fl::event state(). If the bit is on that shift key must
be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in the shift flags (zero for the other bits
indicates a ”don’t care” setting).

void Fl Menu Item::show ( ) [inline]

Makes an item visible in the menu.

int Fl Menu Item::submenu ( ) const [inline]

Returns true if either FL SUBMENU or FL SUBMENU POINTER is on in the flags.


FL SUBMENU indicates an embedded submenu that goes from the next item through the next one
with a NULL label(). FL SUBMENU POINTER indicates that user data() is a pointer to another menu
array.

const Fl Menu Item ∗ Fl Menu Item::test shortcut ( ) const

This is designed to be called by a widgets handle() method in response to a FL SHORTCUT event.


If the current event matches one of the items shortcut, that item is returned. If the keystroke does not
match any shortcuts then NULL is returned. This only matches the shortcut() fields, not the letters in the
title preceeded by ’

void Fl Menu Item::uncheck ( ) [inline]

back compatibility only

Deprecated .

int Fl Menu Item::value ( ) const [inline]

Returns the current value of the check or radio item.


This is zero (0) if the menu item is not checked and non-zero otherwise. You should not rely on a
particular value, only zero or non-zero.

Note
The returned value for a checked menu item as of FLTK 1.3.2 is FL MENU VALUE (4), but may
be 1 in a future version.
31.83. FL MENU WINDOW CLASS REFERENCE 543

int Fl Menu Item::visible ( ) const [inline]


Gets the visibility of an item.
The documentation for this struct was generated from the following files:
• Fl Menu Item.H
• Fl Menu.cxx
• Fl Menu .cxx
• Fl Menu add.cxx

31.83 Fl Menu Window Class Reference


The Fl Menu Window widget is a window type used for menus.
#include <Fl Menu Window.H>
Inheritance diagram for Fl Menu Window:

Fl_Widget

Fl_Group

Fl_Window

Fl_Single_Window

Fl_Menu_Window

Public Member Functions


• void clear overlay ()
Tells FLTK to use normal drawing planes instead of overlay planes.
• void erase ()
Erases the window, does nothing if HAVE OVERLAY is not defined config.h.
• Fl Menu Window (int W, int H, const char ∗l=0)
Creates a new Fl Menu Window widget using the given size, and label string.
• Fl Menu Window (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Menu Window widget using the given position, size, and label string.
• void flush ()
Forces the window to be drawn, this window is also made current and calls draw().
• void hide ()
Removes the window from the screen.
• unsigned int overlay ()
Tells if hardware overlay mode is set.
• void set overlay ()
Tells FLTK to use hardware overlay planes if they are available.
• void show ()
Puts the window on the screen.
• ∼Fl Menu Window ()
Destroys the window and all of its children.
544 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.83.1 Detailed Description
The Fl Menu Window widget is a window type used for menus.
By default the window is drawn in the hardware overlay planes if they are available so that the menu
don’t force the rest of the window to redraw.

31.83.2 Constructor & Destructor Documentation


Fl Menu Window::∼Fl Menu Window ( )
Destroys the window and all of its children.

Fl Menu Window::Fl Menu Window ( int W, int H, const char ∗ l = 0 )


Creates a new Fl Menu Window widget using the given size, and label string.

Fl Menu Window::Fl Menu Window ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Menu Window widget using the given position, size, and label string.

31.83.3 Member Function Documentation


void Fl Menu Window::clear overlay ( ) [inline]
Tells FLTK to use normal drawing planes instead of overlay planes.
This is usually necessary if your menu contains multi-color pixmaps.

void Fl Menu Window::flush ( ) [virtual]


Forces the window to be drawn, this window is also made current and calls draw().
Reimplemented from Fl Window.

void Fl Menu Window::hide ( ) [virtual]


Removes the window from the screen.
If the window is already hidden or has not been shown then this does nothing and is harmless.
Reimplemented from Fl Window.

void Fl Menu Window::set overlay ( ) [inline]


Tells FLTK to use hardware overlay planes if they are available.

void Fl Menu Window::show ( ) [virtual]


Puts the window on the screen.
Usually (on X) this has the side effect of opening the display.
If the window is already shown then it is restored and raised to the top. This is really convenient
because your program can call show() at any time, even if the window is already up. It also means that
show() serves the purpose of raise() in other toolkits.
Fl Window::show(int argc, char ∗∗argv) is used for top-level windows and allows standard arguments
to be parsed from the command-line.
31.84. FL MULTI BROWSER CLASS REFERENCE 545

See Also
Fl Window::show(int argc, char ∗∗argv)

Reimplemented from Fl Window.


The documentation for this class was generated from the following files:

• Fl Menu Window.H
• Fl Menu Window.cxx

31.84 Fl Multi Browser Class Reference


The Fl Multi Browser class is a subclass of Fl Browser which lets the user select any set of the lines.
#include <Fl Multi Browser.H>
Inheritance diagram for Fl Multi Browser:

Fl_Widget

Fl_Group

Fl_Browser_

Fl_Browser

Fl_Multi_Browser

Public Member Functions


• Fl Multi Browser (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Multi Browser widget using the given position, size, and label string.

Additional Inherited Members


31.84.1 Detailed Description
The Fl Multi Browser class is a subclass of Fl Browser which lets the user select any set of the lines.
The user interface is Macintosh style: clicking an item turns off all the others and selects that one,
dragging selects all the items the mouse moves over, and shift + click toggles the items. This is different
then how forms did it. Normally the callback is done when the user releases the mouse, but you can change
this with when().
See Fl Browser for methods to add and remove lines from the browser.

31.84.2 Constructor & Destructor Documentation


Fl Multi Browser::Fl Multi Browser ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Multi Browser widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX. The constructor specializes Fl Browser() by setting the type
to FL MULTI BROWSER. The destructor destroys the widget and frees all memory that has been allo-
cated.
The documentation for this class was generated from the following files:
546 CHAPTER 31. CLASS DOCUMENTATION

• Fl Multi Browser.H
• Fl Browser.cxx

31.85 Fl Multi Label Struct Reference


Public Member Functions
• void label (Fl Widget ∗)
• void label (Fl Menu Item ∗)

Public Attributes
• const char ∗ labela
• const char ∗ labelb
• uchar typea
• uchar typeb

The documentation for this struct was generated from the following files:

• Fl Multi Label.H
• Fl Multi Label.cxx

31.86 Fl Multiline Input Class Reference


This input field displays ’\n’ characters as new lines rather than ∧ J, and accepts the Return, Tab, and up
and down arrow keys.
#include <Fl Multiline Input.H>
Inheritance diagram for Fl Multiline Input:

Fl_Widget

Fl_Input_

Fl_Input

Fl_Multiline_Input

Public Member Functions


• Fl Multiline Input (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Multiline Input widget using the given position, size, and label string.

Additional Inherited Members


31.86.1 Detailed Description
This input field displays ’\n’ characters as new lines rather than ∧ J, and accepts the Return, Tab, and up
and down arrow keys.
This is for editing multiline text.
31.87. FL MULTILINE OUTPUT CLASS REFERENCE 547

This is far from the nirvana of text editors, and is probably only good for small bits of text, 10 lines at
most. Note that this widget does not support scrollbars or per-character color control.
If you are presenting large amounts of text and need scrollbars or full color control of characters, you
probably want Fl Text Editor instead.
In FLTK 1.3.x, the default behavior of the ’Tab’ key was changed to support consistent focus naviga-
tion. To get the older FLTK 1.1.x behavior, set Fl Input ::tab nav() to 0. Newer programs should consider
using Fl Text Editor.

31.86.2 Constructor & Destructor Documentation


Fl Multiline Input::Fl Multiline Input ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Multiline Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.
The documentation for this class was generated from the following files:

• Fl Multiline Input.H
• Fl Input.cxx

31.87 Fl Multiline Output Class Reference


This widget is a subclass of Fl Output that displays multiple lines of text.
#include <Fl Multiline Output.H>
Inheritance diagram for Fl Multiline Output:

Fl_Widget

Fl_Input_

Fl_Input

Fl_Output

Fl_Multiline_Output

Public Member Functions


• Fl Multiline Output (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Multiline Output widget using the given position, size, and label string.

Additional Inherited Members


31.87.1 Detailed Description
This widget is a subclass of Fl Output that displays multiple lines of text.
It also displays tab characters as whitespace to the next column.
Note that this widget does not support scrollbars, or per-character color control.
If you are presenting large amounts of read-only text and need scrollbars, or full color control of char-
acters, then use Fl Text Display. If you want to display HTML text, use Fl Help View.
548 CHAPTER 31. CLASS DOCUMENTATION

31.87.2 Constructor & Destructor Documentation


Fl Multiline Output::Fl Multiline Output ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Multiline Output widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.
The documentation for this class was generated from the following files:

• Fl Multiline Output.H
• Fl Input.cxx

31.88 Fl Native File Chooser Class Reference


This class lets an FLTK application easily and consistently access the operating system’s native file chooser.
#include <Fl Native File Chooser.H>

Public Types
• enum Option {
NO OPTIONS = 0x0000, SAVEAS CONFIRM = 0x0001, NEW FOLDER = 0x0002, PREVIEW
= 0x0004,
USE FILTER EXT = 0x0008 }
• enum Type {
BROWSE FILE = 0, BROWSE DIRECTORY, BROWSE MULTI FILE, BROWSE MULTI DI-
RECTORY,
BROWSE SAVE FILE, BROWSE SAVE DIRECTORY }

Public Member Functions


• int count () const
Returns the number of filenames (or directory names) the user selected.
• void directory (const char ∗val)
Preset the directory the browser will show when opened.
• const char ∗ directory () const
Returns the current preset directory() value.
• const char ∗ errmsg () const
Returns a system dependent error message for the last method that failed.
• const char ∗ filename () const
Return the filename the user chose.
• const char ∗ filename (int i) const
Return one of the filenames the user selected.
• const char ∗ filter () const
Returns the filter string last set.
• void filter (const char ∗f)
Sets the filename filters used for browsing.
• void filter value (int i)
Sets which filter will be initially selected.
• int filter value () const
Returns which filter value was last selected by the user.
• int filters () const
31.88. FL NATIVE FILE CHOOSER CLASS REFERENCE 549

Gets how many filters were available, not including ”All Files”.
• Fl Native File Chooser (int val=BROWSE FILE)
The constructor.
• void options (int o)
Sets the platform specific chooser options to val.
• int options () const
Gets the platform specific Fl Native File Chooser::Option flags.
• void preset file (const char ∗f)
Sets the default filename for the chooser.
• const char ∗ preset file () const
Get the preset filename.
• int show ()
Post the chooser’s dialog.
• void title (const char ∗t)
Set the title of the file chooser’s dialog window.
• const char ∗ title () const
Get the title of the file chooser’s dialog window.
• void type (int t)
Sets the current Fl Native File Chooser::Type of browser.
• int type () const
Gets the current Fl Native File Chooser::Type of browser.
• ∼Fl Native File Chooser ()
Destructor.

Static Public Attributes


• static const char ∗ file exists message = ”File exists. Are you sure you want to overwrite?”
Localizable message.

31.88.1 Detailed Description


This class lets an FLTK application easily and consistently access the operating system’s native file chooser.
Some operating systems have very complex and specific file choosers that many users want access to
specifically, instead of FLTK’s default file chooser(s).
In cases where there is no native file browser, FLTK’s own file browser is used instead.
To use this widget, use the following include in your code:
#include <FL/Fl Native File Chooser.H>

The following example shows how to pick a single file:


// Create and post the local native file chooser
#include <FL/Fl Native File Chooser.H>
[..]
Fl Native File Chooser fnfc;
fnfc.title("Pick a file");
fnfc.type(Fl Native File Chooser::BROWSE FILE);
fnfc.filter("Text\t*.txt\n"
"C Files\t*.{cxx,h,c}");
fnfc.directory("/var/tmp"); // default directory to use
// Show native chooser
switch ( fnfc.show() ) {
case -1: printf("ERROR: %s\n", fnfc.errmsg()); break; // ERROR
case 1: printf("CANCEL\n"); break; // CANCEL
default: printf("PICKED: %s\n", fnfc.filename()); break; // FILE CHOSEN
}
550 CHAPTER 31. CLASS DOCUMENTATION

The Fl Native File Chooser widget transmits UTF-8 encoded filenames to its user. It is recommended
to open files that may have non-ASCII names with the fl fopen() or fl open() utility functions that han-
dle these names in a cross-platform way (whereas the standard fopen()/open() functions fail on the MS-
Windows platform to open files with a non-ASCII name).
Platform Specific Caveats

• Under X windows, and if Fl::OPTION FNFC USES GTK has not been switched off, the widget
attempts to use standard GTK file chooser dialogs if they are available at run-time on the platform,
and falls back to use FLTK’s Fl File Chooser if they are not. In the latter case, it’s best if you
call Fl File Icon::load system icons() at the start of main(), to enable the nicer looking file browser
widgets. Use the static public attributes of class Fl File Chooser to localize the browser.

• Some operating systems support certain OS specific options; see Fl Native File Chooser::options()
for a list.

Figure 31.22: The Fl Native File Chooser on different platforms

31.88.2 Member Enumeration Documentation


enum Fl Native File Chooser::Option
Enumerator
NO OPTIONS no options enabled
SAVEAS CONFIRM Show native ’Save As’ overwrite confirm dialog.
NEW FOLDER Show ’New Folder’ icon (if supported)
31.88. FL NATIVE FILE CHOOSER CLASS REFERENCE 551

PREVIEW enable preview mode (if supported)


USE FILTER EXT Chooser filter pilots the output file extension (if supported)

enum Fl Native File Chooser::Type


Enumerator
BROWSE FILE browse files (lets user choose one file)
BROWSE DIRECTORY browse directories (lets user choose one directory)
BROWSE MULTI FILE browse files (lets user choose multiple files)
BROWSE MULTI DIRECTORY browse directories (lets user choose multiple directories)
BROWSE SAVE FILE browse to save a file
BROWSE SAVE DIRECTORY browse to save a directory

31.88.3 Constructor & Destructor Documentation


Fl Native File Chooser::Fl Native File Chooser ( int val = BROWSE FILE )
The constructor.
Internally allocates the native widgets. Optional val presets the type of browser this will be, which
can also be changed with type().

Fl Native File Chooser::∼Fl Native File Chooser ( )


Destructor.
Deallocates any resources allocated to this widget.

31.88.4 Member Function Documentation


int Fl Native File Chooser::count ( ) const
Returns the number of filenames (or directory names) the user selected.
Example:

if ( fnfc->show() == 0 ) {
// Print all filenames user selected
for (int n=0; n<fnfc->count(); n++ ) {
printf("%d) ’%s’\n", n, fnfc->filename(n));
}
}

void Fl Native File Chooser::directory ( const char ∗ val )


Preset the directory the browser will show when opened.
If val is NULL, or no directory is specified, the chooser will attempt to use the last non-cancelled
folder.

const char ∗ Fl Native File Chooser::errmsg ( ) const


Returns a system dependent error message for the last method that failed.
This message should at least be flagged to the user in a dialog box, or to some kind of error log.
Contents will be valid only for methods that document errmsg() will have info on failures.
552 CHAPTER 31. CLASS DOCUMENTATION

const char ∗ Fl Native File Chooser::filename ( ) const

Return the filename the user chose.


Use this if only expecting a single filename. If more than one filename is expected, use filename(int)
instead. Return value may be ”” if no filename was chosen (eg. user cancelled).

const char ∗ Fl Native File Chooser::filename ( int i ) const

Return one of the filenames the user selected.


Use count() to determine how many filenames the user selected.
Example:

if ( fnfc->show() == 0 ) {
// Print all filenames user selected
for (int n=0; n<fnfc->count(); n++ ) {
printf("%d) ’%s’\n", n, fnfc->filename(n));
}
}

const char ∗ Fl Native File Chooser::filter ( ) const

Returns the filter string last set.


Can be NULL if no filter was set.

void Fl Native File Chooser::filter ( const char ∗ f )

Sets the filename filters used for browsing.


The default is NULL, which browses all files.
The filter string can be any of:

• A single wildcard (eg. ”∗.txt”)

• Multiple wildcards (eg. ”∗.{cxx,h,H}”)

• A descriptive name followed by a ”\t” and a wildcard (eg. ”Text Files\t∗.txt”)

• A list of separate wildcards with a ”\n” between each (eg. ”∗.{cxx,H}\n∗.txt”)

• A list of descriptive names and wildcards (eg. ”C++ Files\t∗.{cxx,H}\nTxt Files\t∗.txt”)

The format of each filter is a wildcard, or an optional user description followed by ’\t’ and the wildcard.
On most platforms, each filter is available to the user via a pulldown menu in the file chooser. The ’All
Files’ option is always available to the user.

void Fl Native File Chooser::filter value ( int i )

Sets which filter will be initially selected.


The first filter is indexed as 0. If filter value()==filters(), then ”All Files” was chosen. If filter value()
> filters(), then a custom filter was set.

int Fl Native File Chooser::filter value ( ) const

Returns which filter value was last selected by the user.


This is only valid if the chooser returns success.
31.89. FL NICE SLIDER CLASS REFERENCE 553

void Fl Native File Chooser::options ( int o )

Sets the platform specific chooser options to val.


val is expected to be one or more Fl Native File Chooser::Option flags ORed together. Some plat-
forms have OS-specific functions that can be enabled/disabled via this method.

Flag Description Win Mac Other


-------------- ----------------------------------------------- ------- ------- -------
NEW FOLDER Shows the ’New Folder’ button. Ignored Used Used
PREVIEW Enables the ’Preview’ mode by default. Ignored Ignored Used
SAVEAS CONFIRM Confirm dialog if BROWSE SAVE FILE file exists. Used
Used Used
USE FILTER EXT Chooser filter pilots the output file extension. Ignored Used
Ignored

void Fl Native File Chooser::preset file ( const char ∗ f )

Sets the default filename for the chooser.


Use directory() to set the default directory. Mainly used to preset the filename for save dialogs, and on
most platforms can be used for opening files as well.

int Fl Native File Chooser::show ( )

Post the chooser’s dialog.


Blocks until dialog has been completed or cancelled.

Returns
• 0 – user picked a file
• 1 – user cancelled
• -1 – failed; errmsg() has reason

void Fl Native File Chooser::title ( const char ∗ t )

Set the title of the file chooser’s dialog window.


Can be NULL if no title desired. The default title varies according to the platform, so you are advised
to set the title explicitly.

const char ∗ Fl Native File Chooser::title ( ) const

Get the title of the file chooser’s dialog window.


Return value may be NULL if no title was set.
The documentation for this class was generated from the following files:

• Fl Native File Chooser.H


• Fl Native File Chooser.cxx
• Fl Native File Chooser FLTK.cxx

31.89 Fl Nice Slider Class Reference


Inheritance diagram for Fl Nice Slider:
554 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Nice_Slider

Public Member Functions


• Fl Nice Slider (int X, int Y, int W, int H, const char ∗L=0)

Additional Inherited Members


The documentation for this class was generated from the following files:

• Fl Nice Slider.H
• Fl Slider.cxx

31.90 Fl Output Class Reference


This widget displays a piece of text.
#include <Fl Output.H>
Inheritance diagram for Fl Output:

Fl_Widget

Fl_Input_

Fl_Input

Fl_Output

Fl_Multiline_Output

Public Member Functions


• Fl Output (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Output widget using the given position, size, and label string.

Additional Inherited Members


31.90.1 Detailed Description
This widget displays a piece of text.
31.91. FL OVERLAY WINDOW CLASS REFERENCE 555

When you set the value() , Fl Output does a strcpy() to its own storage, which is useful for program-
generated values. The user may select portions of the text using the mouse and paste the contents into other
fields or programs.

Figure 31.23: Fl Output

There is a single subclass, Fl Multiline Output, which allows you to display multiple lines of text.
Fl Multiline Output does not provide scroll bars. If a more complete text editing widget is needed, use
Fl Text Display instead.
The text may contain any characters except \0, and will correctly display anything, using ∧ X notation
for unprintable control characters and \nnn notation for unprintable characters with the high bit set. It
assumes the font can draw any characters in the ISO-Latin1 character set.

31.90.2 Constructor & Destructor Documentation


Fl Output::Fl Output ( int X, int Y, int W, int H, const char ∗ l = 0 )

Creates a new Fl Output widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.
The documentation for this class was generated from the following files:

• Fl Output.H
• Fl Input.cxx

31.91 Fl Overlay Window Class Reference


This window provides double buffering and also the ability to draw the ”overlay” which is another picture
placed on top of the main image.
#include <Fl Overlay Window.H>
Inheritance diagram for Fl Overlay Window:
556 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Group

Fl_Window

Fl_Double_Window

Fl_Overlay_Window

Public Member Functions


• int can do overlay ()
Returns non-zero if there’s hardware overlay support.
• void flush ()
Forces the window to be redrawn.
• void hide ()
Removes the window from the screen.
• void redraw overlay ()
Call this to indicate that the overlay data has changed and needs to be redrawn.
• void resize (int, int, int, int)
Changes the size and position of the window.
• void show ()
Puts the window on the screen.
• void show (int a, char ∗∗b)
• ∼Fl Overlay Window ()
Destroys the window and all child widgets.

Protected Member Functions


• virtual void draw overlay ()=0
You must subclass Fl Overlay Window and provide this method.
• Fl Overlay Window (int W, int H, const char ∗l=0)
See Fl Overlay Window::Fl Overlay Window(int X, int Y, int W, int H, const char ∗l=0)
• Fl Overlay Window (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Overlay Window widget using the given position, size, and label (title) string.

Additional Inherited Members


31.91.1 Detailed Description
This window provides double buffering and also the ability to draw the ”overlay” which is another picture
placed on top of the main image.
The overlay is designed to be a rapidly-changing but simple graphic such as a mouse selection box.
Fl Overlay Window uses the overlay planes provided by your graphics hardware if they are available.
If no hardware support is found the overlay is simulated by drawing directly into the on-screen copy of
the double-buffered window, and ”erased” by copying the backbuffer over it again. This means the overlay
will blink if you change the image in the window.
31.91. FL OVERLAY WINDOW CLASS REFERENCE 557

31.91.2 Constructor & Destructor Documentation


Fl Overlay Window::Fl Overlay Window ( int X, int Y, int W, int H, const char ∗ l = 0 )
[protected]

Creates a new Fl Overlay Window widget using the given position, size, and label (title) string.
If the positions (x,y) are not given, then the window manager will choose them.

31.91.3 Member Function Documentation


virtual void Fl Overlay Window::draw overlay ( ) [protected], [pure virtual]

You must subclass Fl Overlay Window and provide this method.


It is just like a draw() method, except it draws the overlay. The overlay will have already been ”cleared”
when this is called. You can use any of the routines described in <FL/fl draw.H>.

void Fl Overlay Window::hide ( ) [virtual]

Removes the window from the screen.


If the window is already hidden or has not been shown then this does nothing and is harmless.
Reimplemented from Fl Double Window.

void Fl Overlay Window::redraw overlay ( )

Call this to indicate that the overlay data has changed and needs to be redrawn.
The overlay will be clear until the first time this is called, so if you want an initial display you must call
this after calling show().

void Fl Overlay Window::resize ( int X, int Y, int W, int H ) [virtual]

Changes the size and position of the window.


If shown() is true, these changes are communicated to the window server (which may refuse that size
and cause a further resize). If shown() is false, the size and position are used when show() is called. See
Fl Group for the effect of resizing on the child widgets.
You can also call the Fl Widget methods size(x,y) and position(w,h), which are inline wrappers for this
virtual function.
A top-level window can not force, but merely suggest a position and size to the operating system. The
window manager may not be willing or able to display a window at the desired position or with the given
dimensions. It is up to the application developer to verify window parameters after the resize request.
Reimplemented from Fl Double Window.

void Fl Overlay Window::show ( ) [virtual]

Puts the window on the screen.


Usually (on X) this has the side effect of opening the display.
If the window is already shown then it is restored and raised to the top. This is really convenient
because your program can call show() at any time, even if the window is already up. It also means that
show() serves the purpose of raise() in other toolkits.
Fl Window::show(int argc, char ∗∗argv) is used for top-level windows and allows standard arguments
to be parsed from the command-line.
558 CHAPTER 31. CLASS DOCUMENTATION

See Also
Fl Window::show(int argc, char ∗∗argv)

Reimplemented from Fl Double Window.


The documentation for this class was generated from the following files:

• Fl Overlay Window.H
• Fl Double Window.cxx
• Fl Overlay Window.cxx

31.92 Fl Pack Class Reference


This widget was designed to add the functionality of compressing and aligning widgets.
#include <Fl Pack.H>
Inheritance diagram for Fl Pack:

Fl_Widget

Fl_Group

Fl_Pack

Public Types
• enum { VERTICAL = 0, HORIZONTAL = 1 }

Public Member Functions


• Fl Pack (int x, int y, int w, int h, const char ∗l=0)
Creates a new Fl Pack widget using the given position, size, and label string.
• uchar horizontal () const
Same as Fl Group::type()
• int spacing () const
Gets the number of extra pixels of blank space that are added between the children.
• void spacing (int i)
Sets the number of extra pixels of blank space that are added between the children.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.92.1 Detailed Description
This widget was designed to add the functionality of compressing and aligning widgets.
If type() is Fl Pack::HORIZONTAL all the children are resized to the height of the Fl Pack, and are
moved next to each other horizontally. If type() is not Fl Pack::HORIZONTAL then the children are
31.93. FL PAGED DEVICE CLASS REFERENCE 559

resized to the width and are stacked below each other. Then the Fl Pack resizes itself to surround the child
widgets.
This widget is needed for the Fl Tabs. In addition you may want to put the Fl Pack inside an Fl Scroll.
The resizable for Fl Pack is set to NULL by default.
See also: Fl Group::resizable()

31.92.2 Constructor & Destructor Documentation


Fl Pack::Fl Pack ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Pack widget using the given position, size, and label string.
The default boxtype is FL NO BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without
having to keep a pointer to all the children in the user code. A kludge has been done so the Fl Pack and
all of it’s children can be automatic (local) variables, but you must declare the Fl Packfirst, so that it is
destroyed last.

31.92.3 Member Function Documentation


void Fl Pack::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Group.


The documentation for this class was generated from the following files:
• Fl Pack.H
• Fl Pack.cxx

31.93 Fl Paged Device Class Reference


Represents page-structured drawing surfaces.
#include <Fl Paged Device.H>
Inheritance diagram for Fl Paged Device:

Fl_Device

Fl_Surface_Device

Fl_Paged_Device

Fl_PostScript_File_Device Fl_Printer Fl_System_Printer

Fl_PostScript_Printer
560 CHAPTER 31. CLASS DOCUMENTATION

Classes
• struct page format
width, height and name of a page format

Public Types
• enum Page Format {
A0 = 0, A1, A2, A3,
A4, A5, A6, A7,
A8, A9, B0, B1,
B2, B3, B4, B5,
B6, B7, B8, B9,
B10, C5E, DLE, EXECUTIVE,
FOLIO, LEDGER, LEGAL, LETTER,
TABLOID, ENVELOPE, MEDIA = 0x1000 }
Possible page formats.
• enum Page Layout { PORTRAIT = 0, LANDSCAPE = 0x100, REVERSED = 0x200, ORIENTAT-
ION = 0x300 }
Possible page layouts.

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• virtual void end job (void)
To be called at the end of a print job.
• virtual int end page (void)
To be called at the end of each page.
• virtual void margins (int ∗left, int ∗top, int ∗right, int ∗bottom)
Computes the dimensions of margins that lie between the printable page area and the full page.
• virtual void origin (int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
• virtual void origin (int ∗x, int ∗y)
Computes the page coordinates of the current origin of graphics functions.
• virtual void print widget (Fl Widget ∗widget, int delta x=0, int delta y=0)
Draws the widget on the printed page.
• void print window (Fl Window ∗win, int x offset=0, int y offset=0)
Prints a window with its title bar and frame if any.
• virtual void print window part (Fl Window ∗win, int x, int y, int w, int h, int delta x=0, int delta y=0)
Prints a rectangular part of an on-screen window.
• virtual int printable rect (int ∗w, int ∗h)
Computes the width and height of the printable area of the page.
• virtual void rotate (float angle)
Rotates the graphics operations relatively to paper.
• virtual void scale (float scale x, float scale y=0.)
Changes the scaling of page coordinates.
• virtual int start job (int pagecount, int ∗frompage=NULL, int ∗topage=NULL)
Starts a print job.
31.93. FL PAGED DEVICE CLASS REFERENCE 561

• virtual int start page (void)


Starts a new printed page.
• virtual void translate (int x, int y)
Translates the current graphics origin accounting for the current rotation.
• virtual void untranslate (void)
Undoes the effect of a previous translate() call.

Static Public Attributes


• static const char ∗ class id = ”Fl Paged Device”
• static const page format page formats [NO PAGE FORMATS]
width, height and name of all elements of the enum Page Format.

Protected Member Functions


• Fl Paged Device ()
The constructor.
• virtual ∼Fl Paged Device ()
The destructor.

Protected Attributes
• int x offset
horizontal offset to the origin of graphics coordinates
• int y offset
vertical offset to the origin of graphics coordinates

Additional Inherited Members


31.93.1 Detailed Description
Represents page-structured drawing surfaces.
This class has no public constructor: don’t instantiate it; use Fl Printer or Fl PostScript File Device
instead.

31.93.2 Member Enumeration Documentation


enum Fl Paged Device::Page Format

Possible page formats.


All paper formats with pre-defined width and height.

Enumerator
A0 A0 format.
A4 A4 format.
LETTER Letter format.
562 CHAPTER 31. CLASS DOCUMENTATION

enum Fl Paged Device::Page Layout


Possible page layouts.
Enumerator
PORTRAIT Portrait orientation.
LANDSCAPE Landscape orientation.
REVERSED Reversed orientation.
ORIENTATION orientation

31.93.3 Member Function Documentation


const char∗ Fl Paged Device::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Surface Device.


Reimplemented in Fl PostScript File Device, Fl Printer, Fl PostScript Printer, and Fl System Printer.

int Fl Paged Device::end page ( void ) [virtual]


To be called at the end of each page.
Returns
0 if OK, non-zero if any error.

Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.

void Fl Paged Device::margins ( int ∗ left, int ∗ top, int ∗ right, int ∗ bottom ) [virtual]
Computes the dimensions of margins that lie between the printable page area and the full page.
Values are in the same unit as that used by FLTK drawing functions. They are changed by scale() calls.
Parameters
out left If non-null, ∗left is set to the left margin size.
out top If non-null, ∗top is set to the top margin size.
out right If non-null, ∗right is set to the right margin size.
out bottom If non-null, ∗bottom is set to the bottom margin size.
Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.

void Fl Paged Device::origin ( int x, int y ) [virtual]


Sets the position in page coordinates of the origin of graphics functions.
Arguments should be expressed relatively to the result of a previous printable rect() call. That is,
printable rect(&w, &h); origin(w/2, 0); sets the graphics origin at the top center of the
page printable area. Origin() calls are not affected by rotate() calls. Successive origin() calls don’t combine
their effects.
31.93. FL PAGED DEVICE CLASS REFERENCE 563

Parameters
in x Horizontal position in page coordinates of the desired origin of graphics
functions.
in y Same as above, vertically.
Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.

void Fl Paged Device::origin ( int ∗ x, int ∗ y ) [virtual]


Computes the page coordinates of the current origin of graphics functions.
Parameters
out x If non-null, ∗x is set to the horizontal page offset of graphics origin.
out y Same as above, vertically.
Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.

void Fl Paged Device::print widget ( Fl Widget ∗ widget, int delta x = 0, int delta y = 0 )
[virtual]
Draws the widget on the printed page.
The widget’s position on the printed page is determined by the last call to origin() and by the optional
delta x and delta y arguments. Its dimensions are in points unless there was a previous call to scale().
Parameters
in widget Any FLTK widget (e.g., standard, custom, window).
in delta x Optional horizontal offset for positioning the widget relatively to the cur-
rent origin of graphics functions.
in delta y Same as above, vertically.
Reimplemented in Fl Printer.

void Fl Paged Device::print window ( Fl Window ∗ win, int x offset = 0, int y offset = 0 )
Prints a window with its title bar and frame if any.
x offset and y offset are optional coordinates of where to position the window top left. Equiv-
alent to print widget() if win is a subwindow or has no border. Use Fl Window::decorated w() and Fl -
Window::decorated h() to get the size of the printed window.

void Fl Paged Device::print window part ( Fl Window ∗ win, int x, int y, int w, int h, int delta x
= 0, int delta y = 0 ) [virtual]
Prints a rectangular part of an on-screen window.
Parameters
win The window from where to capture.
x The rectangle left
y The rectangle top
w The rectangle width
h The rectangle height
delta x Optional horizontal offset from current graphics origin where to print the captured
rectangle.
564 CHAPTER 31. CLASS DOCUMENTATION

delta y As above, vertically.


Reimplemented in Fl Printer.

int Fl Paged Device::printable rect ( int ∗ w, int ∗ h ) [virtual]

Computes the width and height of the printable area of the page.
Values are in the same unit as that used by FLTK drawing functions, are unchanged by calls to origin(),
but are changed by scale() calls. Values account for the user-selected paper type and print orientation.

Returns
0 if OK, non-zero if any error

Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.

void Fl Paged Device::rotate ( float angle ) [virtual]

Rotates the graphics operations relatively to paper.


The rotation is centered on the current graphics origin. Successive rotate() calls don’t combine their
effects.
Parameters
angle Rotation angle in counter-clockwise degrees.
Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.

void Fl Paged Device::scale ( float scale x, float scale y = 0. ) [virtual]

Changes the scaling of page coordinates.


This function also resets the origin of graphics functions at top left of printable page area. After a
scale() call, do a printable rect() call to get the new dimensions of the printable page area. Successive
scale() calls don’t combine their effects.
Parameters
scale x Horizontal dimensions of plot are multiplied by this quantity.
scale y Same as above, vertically. The value 0. is equivalent to setting scale y = scale x.
Thus, scale(factor); is equivalent to scale(factor, factor);
Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.

int Fl Paged Device::start job ( int pagecount, int ∗ frompage = NULL, int ∗ topage = NULL )
[virtual]

Starts a print job.


Parameters
in pagecount the total number of pages of the job
out frompage if non-null, ∗frompage is set to the first page the user wants printed
out topage if non-null, ∗topage is set to the last page the user wants printed

Returns
0 if OK, non-zero if any error

Reimplemented in Fl PostScript File Device, Fl Printer, Fl PostScript Printer, and Fl System Printer.
31.94. FL PIXMAP CLASS REFERENCE 565

int Fl Paged Device::start page ( void ) [virtual]


Starts a new printed page.
The page coordinates are initially in points, i.e., 1/72 inch, and with origin at the top left of the printable
page area.

Returns
0 if OK, non-zero if any error

Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.

void Fl Paged Device::translate ( int x, int y ) [virtual]


Translates the current graphics origin accounting for the current rotation.
This function is only useful after a rotate() call. Each translate() call must be matched by an untrans-
late() call. Successive translate() calls add up their effects.
Reimplemented in Fl PostScript File Device, Fl Printer, and Fl System Printer.
The documentation for this class was generated from the following files:

• Fl Paged Device.H
• Fl Paged Device.cxx

31.94 Fl Pixmap Class Reference


The Fl Pixmap class supports caching and drawing of colormap (pixmap) images, including transparency.
#include <Fl Pixmap.H>
Inheritance diagram for Fl Pixmap:

Fl_Image

Fl_Pixmap

Fl_GIF_Image Fl_XPM_Image

Public Member Functions


• virtual void color average (Fl Color c, float i)
The color average() method averages the colors in the image with the FLTK color value c.
• virtual Fl Image ∗ copy (int W, int H)
The copy() method creates a copy of the specified image.
• Fl Image ∗ copy ()
• virtual void desaturate ()
The desaturate() method converts an image to grayscale.
• virtual void draw (int X, int Y, int W, int H, int cx=0, int cy=0)
Draws the image with a bounding box.
• void draw (int X, int Y)
• Fl Pixmap (char ∗const ∗D)
The constructors create a new pixmap from the specified XPM data.
• Fl Pixmap (uchar ∗const ∗D)
566 CHAPTER 31. CLASS DOCUMENTATION

The constructors create a new pixmap from the specified XPM data.
• Fl Pixmap (const char ∗const ∗D)
The constructors create a new pixmap from the specified XPM data.
• Fl Pixmap (const uchar ∗const ∗D)
The constructors create a new pixmap from the specified XPM data.
• virtual void label (Fl Widget ∗w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void label (Fl Menu Item ∗m)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.
• virtual ∼Fl Pixmap ()
The destructor free all memory and server resources that are used by the pixmap.

Public Attributes
• int alloc data

Protected Member Functions


• void measure ()

Friends
• class Fl GDI Graphics Driver
• class Fl GDI Printer Graphics Driver
• class Fl Quartz Graphics Driver
• class Fl Xlib Graphics Driver

Additional Inherited Members


31.94.1 Detailed Description
The Fl Pixmap class supports caching and drawing of colormap (pixmap) images, including transparency.

31.94.2 Constructor & Destructor Documentation


Fl Pixmap::Fl Pixmap ( char ∗const ∗ D ) [inline], [explicit]
The constructors create a new pixmap from the specified XPM data.

Fl Pixmap::Fl Pixmap ( uchar ∗const ∗ D ) [inline], [explicit]


The constructors create a new pixmap from the specified XPM data.

Fl Pixmap::Fl Pixmap ( const char ∗const ∗ D ) [inline], [explicit]


The constructors create a new pixmap from the specified XPM data.

Fl Pixmap::Fl Pixmap ( const uchar ∗const ∗ D ) [inline], [explicit]


The constructors create a new pixmap from the specified XPM data.
31.94. FL PIXMAP CLASS REFERENCE 567

31.94.3 Member Function Documentation


void Fl Pixmap::color average ( Fl Color c, float i ) [virtual]
The color average() method averages the colors in the image with the FLTK color value c.
The i argument specifies the amount of the original image to combine with the color, so a value of 1.0
results in no color blend, and a value of 0.0 results in a constant image of the specified color. The original
image data is not altered by this method.
Reimplemented from Fl Image.

Fl Image ∗ Fl Pixmap::copy ( int W, int H ) [virtual]


The copy() method creates a copy of the specified image.
If the width and height are provided, the image is resized to the specified size. The image should be
deleted (or in the case of Fl Shared Image, released) when you are done with it.
Reimplemented from Fl Image.

void Fl Pixmap::desaturate ( ) [virtual]


The desaturate() method converts an image to grayscale.
If the image contains an alpha channel (depth = 4), the alpha channel is preserved. This method does
not alter the original image data.
Reimplemented from Fl Image.

void Fl Pixmap::draw ( int X, int Y, int W, int H, int cx = 0, int cy = 0 ) [virtual]


Draws the image with a bounding box.
This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image
offset by the cx and cy arguments.
Reimplemented from Fl Image.

void Fl Pixmap::label ( Fl Widget ∗ widget ) [virtual]


The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented from Fl Image.

void Fl Pixmap::label ( Fl Menu Item ∗ m ) [virtual]


The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented from Fl Image.

void Fl Pixmap::uncache ( ) [virtual]


If the image has been cached for display, delete the cache data.
This allows you to change the data used for the image and then redraw it without recreating an image
object.
Reimplemented from Fl Image.
The documentation for this class was generated from the following files:

• Fl Pixmap.H
• Fl Pixmap.cxx
568 CHAPTER 31. CLASS DOCUMENTATION

31.95 Fl Plugin Class Reference


Fl Plugin allows link-time and run-time integration of binary modules.
#include <Fl Plugin.H>
Inheritance diagram for Fl Plugin:

Fl_Plugin

Fl_Device_Plugin

Public Member Functions


• Fl Plugin (const char ∗klass, const char ∗name)
Create a plugin.
• virtual ∼Fl Plugin ()
Clear the plugin and remove it from the database.

31.95.1 Detailed Description


Fl Plugin allows link-time and run-time integration of binary modules.
Fl Plugin and Fl Plugin Manager provide a small and simple solution for linking C++ classes at run-
time, or optionally linking modules at compile time without the need to change the main application.
Fl Plugin Manager uses static initialisation to create the plugin interface early during startup. Plugins
are stored in a temporary database, organized in classes.
Plugins should derive a new class from Fl Plugin as a base:
class My Plugin : public Fl Plugin {
public:
My Plugin() : Fl Plugin("effects", "blur") { }
void do something(...);
};
My Plugin blur plugin();

Plugins can be put into modules and either linked before distribution, or loaded from dynamically
linkable files. An Fl Plugin Manager is used to list and access all currently loaded plugins.
Fl Plugin Manager mgr("effects");
int i, n = mgr.plugins();
for (i=0; i<n; i++) {
My Plugin *pin = (My Plugin*)mgr.plugin(i);
pin->do something();
}

31.95.2 Constructor & Destructor Documentation


Fl Plugin::Fl Plugin ( const char ∗ klass, const char ∗ name )
Create a plugin.
Parameters
in klass plugins are grouped in classes
31.96. FL PLUGIN MANAGER CLASS REFERENCE 569

in name every plugin should have a unique name


The documentation for this class was generated from the following files:
• Fl Plugin.H
• Fl Preferences.cxx

31.96 Fl Plugin Manager Class Reference


Fl Plugin Manager manages link-time and run-time plugin binaries.
#include <Fl Plugin.H>
Inheritance diagram for Fl Plugin Manager:

Fl_Preferences

Fl_Plugin_Manager

Public Member Functions


• Fl Preferences::ID addPlugin (const char ∗name, Fl Plugin ∗plugin)
This function adds a new plugin to the database.
• Fl Plugin Manager (const char ∗klass)
Manage all plugins belonging to one class.
• Fl Plugin ∗ plugin (int index)
Return the address of a plugin by index.
• Fl Plugin ∗ plugin (const char ∗name)
Return the address of a plugin by name.
• int plugins ()
Return the number of plugins in the klass.
• ∼Fl Plugin Manager ()
Remove the plugin manager.

Static Public Member Functions


• static int load (const char ∗filename)
Load a module from disk.
• static int loadAll (const char ∗filepath, const char ∗pattern=0)
Use this function to load a whole directory full of modules.
• static void removePlugin (Fl Preferences::ID id)
Remove any plugin.

Additional Inherited Members


31.96.1 Detailed Description
Fl Plugin Manager manages link-time and run-time plugin binaries.
See Also
Fl Plugin
570 CHAPTER 31. CLASS DOCUMENTATION

31.96.2 Constructor & Destructor Documentation


Fl Plugin Manager::∼Fl Plugin Manager ( )
Remove the plugin manager.
Calling this does not remove the database itself or any plugins. It just removes the reference to the
database.

31.96.3 Member Function Documentation


Fl Preferences::ID Fl Plugin Manager::addPlugin ( const char ∗ name, Fl Plugin ∗ plugin )
This function adds a new plugin to the database.
There is no need to call this function explicitly. Every Fl Plugin constructor will call this function at
initialization time.

int Fl Plugin Manager::load ( const char ∗ filename ) [static]


Load a module from disk.
A module must be a dynamically linkable file for the given operating system. When loading a module,
its +init function will be called which in turn calls the constructor of all statically initialized Fl Plugin
classes and adds them to the database.

void Fl Plugin Manager::removePlugin ( Fl Preferences::ID id ) [static]


Remove any plugin.
There is no need to call this function explicitly. Every Fl Plugin destructor will call this function at
destruction time.
The documentation for this class was generated from the following files:
• Fl Plugin.H
• Fl Preferences.cxx

31.97 Fl PNG Image Class Reference


The Fl PNG Image class supports loading, caching, and drawing of Portable Network Graphics (PNG)
image files.
#include <Fl PNG Image.H>
Inheritance diagram for Fl PNG Image:

Fl_Image

Fl_RGB_Image

Fl_PNG_Image

Public Member Functions


• Fl PNG Image (const char ∗filename)
The constructor loads the named PNG image from the given png filename.
• Fl PNG Image (const char ∗name png, const unsigned char ∗buffer, int datasize)
Constructor that reads a PNG image from memory.
31.98. FL PNM IMAGE CLASS REFERENCE 571

Additional Inherited Members


31.97.1 Detailed Description
The Fl PNG Image class supports loading, caching, and drawing of Portable Network Graphics (PNG)
image files.
The class loads colormapped and full-color images and handles color- and alpha-based transparency.

31.97.2 Constructor & Destructor Documentation


Fl PNG Image::Fl PNG Image ( const char ∗ filename )
The constructor loads the named PNG image from the given png filename.
The destructor frees all memory and server resources that are used by the image.
Parameters
in filename Name of PNG file to read

Fl PNG Image::Fl PNG Image ( const char ∗ name png, const unsigned char ∗ buffer, int maxsize
)
Constructor that reads a PNG image from memory.
Construct an image from a block of memory inside the application. Fluid offers ”binary Data” chunks
as a great way to add image data into the C++ source code. name png can be NULL. If a name is given,
the image is added to the list of shared images (see: Fl Shared Image) and will be available by that name.
Parameters
name png A name given to this image or NULL
buffer Pointer to the start of the PNG image in memory
maxsize Size in bytes of the memory buffer containing the PNG image
The documentation for this class was generated from the following files:
• Fl PNG Image.H
• Fl PNG Image.cxx

31.98 Fl PNM Image Class Reference


The Fl PNM Image class supports loading, caching, and drawing of Portable Anymap (PNM, PBM, PGM,
PPM) image files.
#include <Fl PNM Image.H>
Inheritance diagram for Fl PNM Image:

Fl_Image

Fl_RGB_Image

Fl_PNM_Image

Public Member Functions


• Fl PNM Image (const char ∗filename)
The constructor loads the named PNM image.
572 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.98.1 Detailed Description
The Fl PNM Image class supports loading, caching, and drawing of Portable Anymap (PNM, PBM, PGM,
PPM) image files.
The class loads bitmap, grayscale, and full-color images in both ASCII and binary formats.

31.98.2 Constructor & Destructor Documentation


Fl PNM Image::Fl PNM Image ( const char ∗ name )
The constructor loads the named PNM image.
The inherited destructor free all memory and server resources that are used by the image.
The documentation for this class was generated from the following files:
• Fl PNM Image.H
• Fl PNM Image.cxx

31.99 Fl Positioner Class Reference


This class is provided for Forms compatibility.
#include <Fl Positioner.H>
Inheritance diagram for Fl Positioner:

Fl_Widget

Fl_Positioner

Public Member Functions


• Fl Positioner (int x, int y, int w, int h, const char ∗l=0)
Creates a new Fl Positioner widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
• int value (double, double)
Returns the current position in x and y.
• void xbounds (double, double)
Sets the X axis bounds.
• double xmaximum () const
Gets the X axis maximum.
• void xmaximum (double a)
Same as xbounds(xminimum(), a)
• double xminimum () const
Gets the X axis minimum.
• void xminimum (double a)
Same as xbounds(a, xmaximum())
• void xstep (double a)
Sets the stepping value for the X axis.
31.99. FL POSITIONER CLASS REFERENCE 573

• double xvalue () const


Gets the X axis coordinate.
• int xvalue (double)
Sets the X axis coordinate.
• void ybounds (double, double)
Sets the Y axis bounds.
• double ymaximum () const
Gets the Y axis maximum.
• void ymaximum (double a)
Same as ybounds(ymininimum(), a)
• double yminimum () const
Gets the Y axis minimum.
• void yminimum (double a)
Same as ybounds(a, ymaximum())
• void ystep (double a)
Sets the stepping value for the Y axis.
• double yvalue () const
Gets the Y axis coordinate.
• int yvalue (double)
Sets the Y axis coordinate.

Protected Member Functions


• void draw (int, int, int, int)
• void draw ()
Draws the widget.
• int handle (int, int, int, int, int)

Additional Inherited Members


31.99.1 Detailed Description
This class is provided for Forms compatibility.
It provides 2D input. It would be useful if this could be put atop another widget so that the crosshairs
are on top, but this is not implemented. The color of the crosshairs is selection color().

Figure 31.24: Fl Positioner

31.99.2 Constructor & Destructor Documentation


Fl Positioner::Fl Positioner ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Positioner widget using the given position, size, and label string.
The default boxtype is FL NO BOX.
574 CHAPTER 31. CLASS DOCUMENTATION

31.99.3 Member Function Documentation


void Fl Positioner::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Positioner::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.

int Fl Positioner::value ( double X, double Y )


Returns the current position in x and y.

void Fl Positioner::xbounds ( double a, double b )


Sets the X axis bounds.

void Fl Positioner::xstep ( double a ) [inline]


Sets the stepping value for the X axis.

double Fl Positioner::xvalue ( ) const [inline]


Gets the X axis coordinate.

int Fl Positioner::xvalue ( double X )


Sets the X axis coordinate.
31.100. FL POSTSCRIPT FILE DEVICE CLASS REFERENCE 575

void Fl Positioner::ybounds ( double a, double b )


Sets the Y axis bounds.

void Fl Positioner::ystep ( double a ) [inline]


Sets the stepping value for the Y axis.

double Fl Positioner::yvalue ( ) const [inline]


Gets the Y axis coordinate.

int Fl Positioner::yvalue ( double Y )


Sets the Y axis coordinate.
The documentation for this class was generated from the following files:

• Fl Positioner.H
• Fl Positioner.cxx

31.100 Fl PostScript File Device Class Reference


To send graphical output to a PostScript file.
#include <Fl PostScript.H>
Inheritance diagram for Fl PostScript File Device:

Fl_Device

Fl_Surface_Device

Fl_Paged_Device

Fl_PostScript_File_Device

Fl_PostScript_Printer

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void end job (void)
To be called at the end of a print job.
• int end page (void)
To be called at the end of each page.
• Fl PostScript File Device ()
The constructor.
• void margins (int ∗left, int ∗top, int ∗right, int ∗bottom)
Computes the dimensions of margins that lie between the printable page area and the full page.
• void origin (int ∗x, int ∗y)
576 CHAPTER 31. CLASS DOCUMENTATION

Computes the page coordinates of the current origin of graphics functions.


• void origin (int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
• int printable rect (int ∗w, int ∗h)
Computes the width and height of the printable area of the page.
• void rotate (float angle)
Rotates the graphics operations relatively to paper.
• void scale (float scale x, float scale y=0.)
Changes the scaling of page coordinates.
• int start job (int pagecount, int ∗from, int ∗to)
Don’t use with this class.
• int start job (int pagecount, enum Fl Paged Device::Page Format format=Fl Paged Device::A4, enum
Fl Paged Device::Page Layout layout=Fl Paged Device::PORTRAIT)
Begins the session where all graphics requests will go to a local PostScript file.
• int start job (FILE ∗ps output, int pagecount, enum Fl Paged Device::Page Format format=Fl Paged-
Device::A4, enum Fl Paged Device::Page Layout layout=Fl Paged Device::PORTRAIT)
Begins the session where all graphics requests will go to FILE pointer.
• int start page (void)
Starts a new printed page.
• void translate (int x, int y)
Translates the current graphics origin accounting for the current rotation.
• void untranslate (void)
Undoes the effect of a previous translate() call.
• ∼Fl PostScript File Device ()
The destructor.

Static Public Attributes


• static const char ∗ class id = ”Fl PostScript File Device”
• static const char ∗ file chooser title = ”Select a .ps file”
Label of the PostScript file chooser window.

Protected Member Functions


• Fl PostScript Graphics Driver ∗ driver ()
Returns the PostScript driver of this drawing surface.

Additional Inherited Members


31.100.1 Detailed Description
To send graphical output to a PostScript file.
31.100. FL POSTSCRIPT FILE DEVICE CLASS REFERENCE 577

31.100.2 Member Function Documentation


const char∗ Fl PostScript File Device::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Paged Device.


Reimplemented in Fl PostScript Printer.

int Fl PostScript File Device::end page ( void ) [virtual]


To be called at the end of each page.
Returns
0 if OK, non-zero if any error.

Reimplemented from Fl Paged Device.

void Fl PostScript File Device::margins ( int ∗ left, int ∗ top, int ∗ right, int ∗ bottom )
[virtual]
Computes the dimensions of margins that lie between the printable page area and the full page.
Values are in the same unit as that used by FLTK drawing functions. They are changed by scale() calls.
Parameters
out left If non-null, ∗left is set to the left margin size.
out top If non-null, ∗top is set to the top margin size.
out right If non-null, ∗right is set to the right margin size.
out bottom If non-null, ∗bottom is set to the bottom margin size.
Reimplemented from Fl Paged Device.

void Fl PostScript File Device::origin ( int ∗ x, int ∗ y ) [virtual]


Computes the page coordinates of the current origin of graphics functions.
Parameters
out x If non-null, ∗x is set to the horizontal page offset of graphics origin.
out y Same as above, vertically.
Reimplemented from Fl Paged Device.

void Fl PostScript File Device::origin ( int x, int y ) [virtual]


Sets the position in page coordinates of the origin of graphics functions.
Arguments should be expressed relatively to the result of a previous printable rect() call. That is,
printable rect(&w, &h); origin(w/2, 0); sets the graphics origin at the top center of the
page printable area. Origin() calls are not affected by rotate() calls. Successive origin() calls don’t combine
their effects.
578 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in x Horizontal position in page coordinates of the desired origin of graphics
functions.
in y Same as above, vertically.
Reimplemented from Fl Paged Device.

int Fl PostScript File Device::printable rect ( int ∗ w, int ∗ h ) [virtual]


Computes the width and height of the printable area of the page.
Values are in the same unit as that used by FLTK drawing functions, are unchanged by calls to origin(),
but are changed by scale() calls. Values account for the user-selected paper type and print orientation.
Returns
0 if OK, non-zero if any error

Reimplemented from Fl Paged Device.

void Fl PostScript File Device::rotate ( float angle ) [virtual]


Rotates the graphics operations relatively to paper.
The rotation is centered on the current graphics origin. Successive rotate() calls don’t combine their
effects.
Parameters
angle Rotation angle in counter-clockwise degrees.
Reimplemented from Fl Paged Device.

void Fl PostScript File Device::scale ( float scale x, float scale y = 0. ) [virtual]


Changes the scaling of page coordinates.
This function also resets the origin of graphics functions at top left of printable page area. After a
scale() call, do a printable rect() call to get the new dimensions of the printable page area. Successive
scale() calls don’t combine their effects.
Parameters
scale x Horizontal dimensions of plot are multiplied by this quantity.
scale y Same as above, vertically. The value 0. is equivalent to setting scale y = scale x.
Thus, scale(factor); is equivalent to scale(factor, factor);
Reimplemented from Fl Paged Device.

int Fl PostScript File Device::start job ( int pagecount, int ∗ from, int ∗ to ) [virtual]
Don’t use with this class.
Reimplemented from Fl Paged Device.
Reimplemented in Fl PostScript Printer.

int Fl PostScript File Device::start job ( int pagecount, enum Fl Paged Device::Page Format
format = Fl Paged Device::A4, enum Fl Paged Device::Page Layout layout =
Fl Paged Device::PORTRAIT )
Begins the session where all graphics requests will go to a local PostScript file.
Opens a file dialog entitled with Fl PostScript File Device::file chooser title to select an output Post-
Script file.
31.100. FL POSTSCRIPT FILE DEVICE CLASS REFERENCE 579

Parameters
pagecount The total number of pages to be created. Use 0 if this number is unknown when this
function is called.
format Desired page format.
layout Desired page layout.

Returns
0 if OK, 1 if user cancelled the file dialog, 2 if fopen failed on user-selected output file.

int Fl PostScript File Device::start job ( FILE ∗ ps output, int pagecount, enum Fl Paged Device-
::Page Format format = Fl Paged Device::A4, enum Fl Paged Device::Page Layout layout =
Fl Paged Device::PORTRAIT )

Begins the session where all graphics requests will go to FILE pointer.
Parameters
ps output A writable FILE pointer that will receive PostScript output and that should not be
closed until after end job() has been called.
pagecount The total number of pages to be created. Use 0 if this number is unknown when this
function is called.
format Desired page format.
layout Desired page layout.

Returns
always 0.

int Fl PostScript File Device::start page ( void ) [virtual]

Starts a new printed page.


The page coordinates are initially in points, i.e., 1/72 inch, and with origin at the top left of the printable
page area.

Returns
0 if OK, non-zero if any error

Reimplemented from Fl Paged Device.

void Fl PostScript File Device::translate ( int x, int y ) [virtual]

Translates the current graphics origin accounting for the current rotation.
This function is only useful after a rotate() call. Each translate() call must be matched by an untrans-
late() call. Successive translate() calls add up their effects.
Reimplemented from Fl Paged Device.
The documentation for this class was generated from the following files:

• Fl PostScript.H
• Fl PostScript.cxx
580 CHAPTER 31. CLASS DOCUMENTATION

31.101 Fl PostScript Graphics Driver Class Reference


Inheritance diagram for Fl PostScript Graphics Driver:

Fl_Device

Fl_Graphics_Driver

Fl_PostScript_Graphics_Driver

Public Member Functions


• void arc (double x, double y, double r, double start, double a)
see fl arc(double x, double y, double r, double start, double end).
• void arc (int x, int y, int w, int h, double a1, double a2)
see fl arc(int x, int y, int w, int h, double a1, double a2).
• void begin complex polygon ()
see fl begin complex polygon().
• void begin line ()
see fl begin line().
• void begin loop ()
see fl begin loop().
• void begin points ()
see fl begin points().
• void begin polygon ()
see fl begin polygon().
• void circle (double x, double y, double r)
see fl circle(double x, double y, double r).
• const char ∗ class name ()
Returns the name of the class of this object.
• int clip box (int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
see fl clip box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
• int clocale printf (const char ∗format,...)
Shields output PostScript data from modifications of the current locale.
• void color (Fl Color c)
see fl color(Fl Color c).
• void color (uchar r, uchar g, uchar b)
see fl color(uchar r, uchar g, uchar b).
• void curve (double x, double y, double x1, double y1, double x2, double y2, double x3, double y3)
see fl curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3).
• int descent ()
see fl descent().
• void draw (const char ∗s, int nBytes, int x, int y)
see fl draw(const char ∗str, int n, int x, int y).
• void draw (int angle, const char ∗str, int n, int x, int y)
31.101. FL POSTSCRIPT GRAPHICS DRIVER CLASS REFERENCE 581

see fl draw(int angle, const char ∗str, int n, int x, int y).
• void draw (Fl Pixmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Pixmap object to the device.
• void draw (Fl Bitmap ∗bitmap, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Bitmap object to the device.
• void draw (Fl RGB Image ∗rgb, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl RGB Image object to the device.
• void draw image (const uchar ∗d, int x, int y, int w, int h, int delta=3, int ldelta=0)
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image (Fl Draw Image Cb call, void ∗data, int x, int y, int w, int h, int delta=3)
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void draw image mono (const uchar ∗d, int x, int y, int w, int h, int delta=1, int ld=0)
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image mono (Fl Draw Image Cb call, void ∗data, int x, int y, int w, int h, int delta=1)
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void end complex polygon ()
see fl end complex polygon().
• void end line ()
see fl end line().
• void end loop ()
see fl end loop().
• void end points ()
see fl end points().
• void end polygon ()
see fl end polygon().
• Fl PostScript Graphics Driver ()
The constructor.
• void font (int face, int size)
see fl font(Fl Font face, Fl Fontsize size).
• void gap ()
see fl gap().
• int height ()
see fl height().
• void line (int x1, int y1, int x2, int y2)
see fl line(int x, int y, int x1, int y1).
• void line (int x1, int y1, int x2, int y2, int x3, int y3)
see fl line(int x, int y, int x1, int y1, int x2, int y2).
• void line style (int style, int width=0, char ∗dashes=0)
see fl line style(int style, int width, char∗ dashes).
• void loop (int x0, int y0, int x1, int y1, int x2, int y2)
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2).
• void loop (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
• int not clipped (int x, int y, int w, int h)
see fl not clipped(int x, int y, int w, int h).
• void pie (int x, int y, int w, int h, double a1, double a2)
582 CHAPTER 31. CLASS DOCUMENTATION

see fl pie(int x, int y, int w, int h, double a1, double a2).


• void point (int x, int y)
see fl point(int x, int y).
• void polygon (int x0, int y0, int x1, int y1, int x2, int y2)
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2).
• void polygon (int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
• void pop clip ()
see fl pop clip().
• void push clip (int x, int y, int w, int h)
see fl push clip(int x, int y, int w, int h).
• void push no clip ()
see fl push no clip().
• void rect (int x, int y, int w, int h)
see fl rect(int x, int y, int w, int h).
• void rectf (int x, int y, int w, int h)
see fl rectf(int x, int y, int w, int h).
• void rtl draw (const char ∗s, int n, int x, int y)
see fl rtl draw(const char ∗str, int n, int x, int y).
• void text extents (const char ∗c, int n, int &dx, int &dy, int &w, int &h)
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
• void transformed vertex (double x, double y)
see fl transformed vertex(double xf, double yf).
• void vertex (double x, double y)
see fl vertex(double x, double y).
• double width (const char ∗, int)
see fl width(const char ∗str, int n).
• double width (unsigned int u)
see fl width(unsigned int n).
• void xyline (int x, int y, int x1)
see fl xyline(int x, int y, int x1).
• void xyline (int x, int y, int x1, int y2)
see fl xyline(int x, int y, int x1, int y2).
• void xyline (int x, int y, int x1, int y2, int x3)
see fl xyline(int x, int y, int x1, int y2, int x3).
• void yxline (int x, int y, int y1)
see fl yxline(int x, int y, int y1).
• void yxline (int x, int y, int y1, int x2)
see fl yxline(int x, int y, int y1, int x2).
• void yxline (int x, int y, int y1, int x2, int y3)
see fl yxline(int x, int y, int y1, int x2, int y3).
• ∼Fl PostScript Graphics Driver ()
The destructor.

Static Public Attributes


• static const char ∗ class id = ”Fl PostScript Graphics Driver”
31.101. FL POSTSCRIPT GRAPHICS DRIVER CLASS REFERENCE 583

Additional Inherited Members


31.101.1 Constructor & Destructor Documentation
Fl PostScript Graphics Driver::∼Fl PostScript Graphics Driver ( )

The destructor.

31.101.2 Member Function Documentation


void Fl PostScript Graphics Driver::arc ( double x, double y, double r, double start, double end )
[virtual]

see fl arc(double x, double y, double r, double start, double end).


Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::arc ( int x, int y, int w, int h, double a1, double a2 )
[virtual]

see fl arc(int x, int y, int w, int h, double a1, double a2).


Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::begin complex polygon ( ) [inline], [virtual]

see fl begin complex polygon().


Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::begin line ( ) [virtual]

see fl begin line().


Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::begin loop ( ) [virtual]

see fl begin loop().


Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::begin points ( ) [virtual]

see fl begin points().


Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::begin polygon ( ) [virtual]

see fl begin polygon().


Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::circle ( double x, double y, double r ) [virtual]

see fl circle(double x, double y, double r).


Reimplemented from Fl Graphics Driver.
584 CHAPTER 31. CLASS DOCUMENTATION

const char∗ Fl PostScript Graphics Driver::class name ( ) [inline], [virtual]


Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Graphics Driver.

int Fl PostScript Graphics Driver::clip box ( int x, int y, int w, int h, int & X, int & Y, int & W,
int & H ) [virtual]
see fl clip box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H).
Reimplemented from Fl Graphics Driver.

int Fl PostScript Graphics Driver::clocale printf ( const char ∗ format, ... )


Shields output PostScript data from modifications of the current locale.
It typically avoids PostScript errors caused if the current locale uses comma instead of dot as ”decimal
point”.
Parameters
format directives controlling output PostScript data

Returns
value returned by vfprintf() call

void Fl PostScript Graphics Driver::color ( Fl Color c ) [virtual]


see fl color(Fl Color c).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::color ( uchar r, uchar g, uchar b ) [virtual]


see fl color(uchar r, uchar g, uchar b).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::curve ( double X0, double Y0, double X1, double Y1, double
X2, double Y2, double X3, double Y3 ) [virtual]
see fl curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3).
Reimplemented from Fl Graphics Driver.

int Fl PostScript Graphics Driver::descent ( ) [virtual]


see fl descent().
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [inline],
[virtual]
see fl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
31.101. FL POSTSCRIPT GRAPHICS DRIVER CLASS REFERENCE 585

void Fl PostScript Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y )
[virtual]
see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int
cx, int cy ) [virtual]
Draws an Fl Pixmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int
cx, int cy ) [virtual]
Draws an Fl Bitmap object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP,
int cx, int cy ) [virtual]
Draws an Fl RGB Image object to the device.
Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 3, int L = 0 ) [virtual]
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int
Y, int W, int H, int D = 3 ) [virtual]
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int
H, int D = 1, int L = 0 ) [virtual]
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int
X, int Y, int W, int H, int D = 1 ) [virtual]
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.
586 CHAPTER 31. CLASS DOCUMENTATION

void Fl PostScript Graphics Driver::end complex polygon ( ) [inline], [virtual]


see fl end complex polygon().
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::end line ( ) [virtual]


see fl end line().
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::end loop ( ) [virtual]


see fl end loop().
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::end points ( ) [virtual]


see fl end points().
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::end polygon ( ) [virtual]


see fl end polygon().
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::font ( int face, int fsize ) [virtual]


see fl font(Fl Font face, Fl Fontsize size).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::gap ( ) [inline], [virtual]


see fl gap().
Reimplemented from Fl Graphics Driver.

int Fl PostScript Graphics Driver::height ( ) [virtual]


see fl height().
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::line ( int x, int y, int x1, int y1 ) [virtual]
see fl line(int x, int y, int x1, int y1).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::line ( int x, int y, int x1, int y1, int x2, int y2 ) [virtual]
see fl line(int x, int y, int x1, int y1, int x2, int y2).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::line style ( int style, int width = 0, char ∗ dashes = 0 )
[virtual]
see fl line style(int style, int width, char∗ dashes).
Reimplemented from Fl Graphics Driver.
31.101. FL POSTSCRIPT GRAPHICS DRIVER CLASS REFERENCE 587

void Fl PostScript Graphics Driver::loop ( int x0, int y0, int x1, int y1, int x2, int y2 )
[virtual]
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::loop ( int x0, int y0, int x1, int y1, int x2, int y2, int x3, int
y3 ) [virtual]
see fl loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
Reimplemented from Fl Graphics Driver.

int Fl PostScript Graphics Driver::not clipped ( int x, int y, int w, int h ) [virtual]
see fl not clipped(int x, int y, int w, int h).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::pie ( int x, int y, int w, int h, double a1, double a2 )
[virtual]
see fl pie(int x, int y, int w, int h, double a1, double a2).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::point ( int x, int y ) [virtual]


see fl point(int x, int y).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::polygon ( int x0, int y0, int x1, int y1, int x2, int y2 )
[virtual]
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::polygon ( int x0, int y0, int x1, int y1, int x2, int y2, int x3,
int y3 ) [virtual]
see fl polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::pop clip ( ) [virtual]


see fl pop clip().
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::push clip ( int x, int y, int w, int h ) [virtual]
see fl push clip(int x, int y, int w, int h).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::push no clip ( ) [virtual]


see fl push no clip().
Reimplemented from Fl Graphics Driver.
588 CHAPTER 31. CLASS DOCUMENTATION

void Fl PostScript Graphics Driver::rect ( int x, int y, int w, int h ) [virtual]


see fl rect(int x, int y, int w, int h).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::rectf ( int x, int y, int w, int h ) [virtual]


see fl rectf(int x, int y, int w, int h).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl rtl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int &
w, int & h ) [virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::transformed vertex ( double xf, double yf ) [virtual]


see fl transformed vertex(double xf, double yf).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::vertex ( double x, double y ) [virtual]


see fl vertex(double x, double y).
Reimplemented from Fl Graphics Driver.

double Fl PostScript Graphics Driver::width ( const char ∗ str, int n ) [virtual]


see fl width(const char ∗str, int n).
Reimplemented from Fl Graphics Driver.

double Fl PostScript Graphics Driver::width ( unsigned int c ) [virtual]


see fl width(unsigned int n).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::xyline ( int x, int y, int x1 ) [virtual]


see fl xyline(int x, int y, int x1).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::xyline ( int x, int y, int x1, int y2 ) [virtual]
see fl xyline(int x, int y, int x1, int y2).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::xyline ( int x, int y, int x1, int y2, int x3 ) [virtual]
see fl xyline(int x, int y, int x1, int y2, int x3).
Reimplemented from Fl Graphics Driver.
31.102. FL POSTSCRIPT PRINTER CLASS REFERENCE 589

void Fl PostScript Graphics Driver::yxline ( int x, int y, int y1 ) [virtual]


see fl yxline(int x, int y, int y1).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::yxline ( int x, int y, int y1, int x2 ) [virtual]
see fl yxline(int x, int y, int y1, int x2).
Reimplemented from Fl Graphics Driver.

void Fl PostScript Graphics Driver::yxline ( int x, int y, int y1, int x2, int y3 ) [virtual]
see fl yxline(int x, int y, int y1, int x2, int y3).
Reimplemented from Fl Graphics Driver.
The documentation for this class was generated from the following files:
• Fl PostScript.H
• Fl PostScript.cxx

31.102 Fl PostScript Printer Class Reference


Print support under Unix/Linux.
#include <Fl Printer.H>
Inheritance diagram for Fl PostScript Printer:

Fl_Device

Fl_Surface_Device

Fl_Paged_Device

Fl_PostScript_File_Device

Fl_PostScript_Printer

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• int start job (int pages, int ∗firstpage=NULL, int ∗lastpage=NULL)
Don’t use with this class.

Static Public Attributes


• static const char ∗ class id = Fl Printer::class id

Protected Member Functions


• Fl PostScript Printer (void)
The constructor.
590 CHAPTER 31. CLASS DOCUMENTATION

Friends
• class Fl Printer

Additional Inherited Members


31.102.1 Detailed Description
Print support under Unix/Linux.
Class Fl PostScript Printer is implemented only on the Unix/Linux platform. It has no public construc-
tor. Use Fl Printer instead that is cross-platform and has the same API.

31.102.2 Member Function Documentation


const char∗ Fl PostScript Printer::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl PostScript File Device.

int Fl PostScript Printer::start job ( int pagecount, int ∗ from = NULL, int ∗ to = NULL )
[virtual]
Don’t use with this class.
Reimplemented from Fl PostScript File Device.
The documentation for this class was generated from the following files:

• Fl Printer.H
• Fl Printer.cxx

31.103 Fl Preferences Class Reference


Fl Preferences provides methods to store user settings between application starts.
#include <Fl Preferences.H>
Inheritance diagram for Fl Preferences:

Fl_Preferences

Fl_Plugin_Manager

Classes
• struct Entry
• class Name
’Name’ provides a simple method to create numerical or more complex procedural names for entries and
groups on the fly.
• class Node
• class RootNode
31.103. FL PREFERENCES CLASS REFERENCE 591

Public Types
• typedef void ∗ ID
Every Fl Preferences-Group has a uniqe ID.
• enum Root { SYSTEM =0, USER }
Define the scope of the preferences.

Public Member Functions


• char clear ()
Delete all groups and all entries.
• char deleteAllEntries ()
Delete all entries.
• char deleteAllGroups ()
Delete all groups.
• char deleteEntry (const char ∗entry)
Deletes a single name/value pair.
• char deleteGroup (const char ∗group)
Deletes a group.
• int entries ()
Returns the number of entries (name/value pairs) in a group.
• const char ∗ entry (int index)
Returns the name of an entry.
• char entryExists (const char ∗key)
Returns non-zero if an entry with this name exists.
• Fl Preferences (Root root, const char ∗vendor, const char ∗application)
The constructor creates a group that manages name/value pairs and child groups.
• Fl Preferences (const char ∗path, const char ∗vendor, const char ∗application)
Use this constructor to create or read a preferences file at an arbitrary position in the file system.
• Fl Preferences (Fl Preferences &parent, const char ∗group)
Generate or read a new group of entries within another group.
• Fl Preferences (Fl Preferences ∗parent, const char ∗group)
Create or access a group of preferences using a name.
• Fl Preferences (Fl Preferences &parent, int groupIndex)
Open a child group using a given index.
• Fl Preferences (Fl Preferences ∗parent, int groupIndex)
• Fl Preferences (const Fl Preferences &)
Create another reference to a Preferences group.
• Fl Preferences (ID id)
Create a new dataset access point using a dataset ID.
• void flush ()
Writes all preferences to disk.
• char get (const char ∗entry, int &value, int defaultValue)
Reads an entry from the group.
• char get (const char ∗entry, float &value, float defaultValue)
Reads an entry from the group.
• char get (const char ∗entry, double &value, double defaultValue)
Reads an entry from the group.
592 CHAPTER 31. CLASS DOCUMENTATION

• char get (const char ∗entry, char ∗&value, const char ∗defaultValue)
Reads an entry from the group.
• char get (const char ∗entry, char ∗value, const char ∗defaultValue, int maxSize)
Reads an entry from the group.
• char get (const char ∗entry, void ∗&value, const void ∗defaultValue, int defaultSize)
Reads an entry from the group.
• char get (const char ∗entry, void ∗value, const void ∗defaultValue, int defaultSize, int maxSize)
Reads an entry from the group.
• char getUserdataPath (char ∗path, int pathlen)
Creates a path that is related to the preferences file and that is usable for additional application data.
• const char ∗ group (int num group)
Returns the name of the Nth (num group) group.
• char groupExists (const char ∗key)
Returns non-zero if a group with this name exists.
• int groups ()
Returns the number of groups that are contained within a group.
• ID id ()
Return an ID that can later be reused to open more references to this dataset.
• const char ∗ name ()
Return the name of this entry.
• const char ∗ path ()
Return the full path to this entry.
• char set (const char ∗entry, int value)
Sets an entry (name/value pair).
• char set (const char ∗entry, float value)
Sets an entry (name/value pair).
• char set (const char ∗entry, float value, int precision)
Sets an entry (name/value pair).
• char set (const char ∗entry, double value)
Sets an entry (name/value pair).
• char set (const char ∗entry, double value, int precision)
Sets an entry (name/value pair).
• char set (const char ∗entry, const char ∗value)
Sets an entry (name/value pair).
• char set (const char ∗entry, const void ∗value, int size)
Sets an entry (name/value pair).
• int size (const char ∗entry)
Returns the size of the value part of an entry.
• virtual ∼Fl Preferences ()
The destructor removes allocated resources.

Static Public Member Functions


• static const char ∗ newUUID ()
Returns a UUID as generated by the system.
• static char remove (ID id )
Remove the group with this ID from a database.
31.103. FL PREFERENCES CLASS REFERENCE 593

Protected Attributes
• Node ∗ node
• RootNode ∗ rootNode

Friends
• class Node
• class RootNode

31.103.1 Detailed Description


Fl Preferences provides methods to store user settings between application starts.
It is similar to the Registry on WIN32 and Preferences on MacOS, and provides a simple configuration
mechanism for UNIX.
Fl Preferences uses a hierarchy to store data. It bundles similar data into groups and manages entries
into those groups as name/value pairs.
Preferences are stored in text files that can be edited manually. The file format is easy to read and
relatively forgiving. Preferences files are the same on all platforms. User comments in preference files are
preserved. Filenames are unique for each application by using a vendor/application naming scheme. The
user must provide default values for all entries to ensure proper operation should preferences be corrupted
or not yet exist.
Entries can be of any length. However, the size of each preferences file should be kept small for
performance reasons. One application can have multiple preferences files. Extensive binary data however
should be stored in separate files: see getUserdataPath().

Note
Starting with FLTK 1.3, preference databases are expected to be in UTF-8 encoding. Previous
databases were stored in the current character set or code page which renders them incompatible
for text entries using international characters.

31.103.2 Member Typedef Documentation


typedef void∗ Fl Preferences::ID

Every Fl Preferences-Group has a uniqe ID.


ID’s can be retrieved from an Fl Preferences-Group and can then be used to create more Fl Preference
references to the same data set, as long as the database remains open.

31.103.3 Member Enumeration Documentation


enum Fl Preferences::Root

Define the scope of the preferences.

Enumerator
SYSTEM Preferences are used system-wide.
USER Preferences apply only to the current user.
594 CHAPTER 31. CLASS DOCUMENTATION

31.103.4 Constructor & Destructor Documentation


Fl Preferences::Fl Preferences ( Root root, const char ∗ vendor, const char ∗ application )
The constructor creates a group that manages name/value pairs and child groups.
Groups are ready for reading and writing at any time. The root argument is either Fl Preferences::USER
or Fl Preferences::SYSTEM.
This constructor creates the base instance for all following entries and reads existing databases into
memory. The vendor argument is a unique text string identifying the development team or vendor of an
application. A domain name or an EMail address are great unique names, e.g. ”researchATmatthiasm.-
com” or ”fltk.org”. The application argument can be the working title or final name of your application.
Both vendor and application must be valid relative UNIX pathnames and may contain ’/’s to create deeper
file structures.
A set of Preferences marked ”run-time” exists exactly one per application and only as long as the
application runs. It can be used as a database for volatile information. FLTK uses it to register plugins at
run-time.
Parameters
in root can be USER or SYSTEM for user specific or system wide preferences
in vendor unique text describing the company or author of this file
in application unique text describing the application

Fl Preferences::Fl Preferences ( const char ∗ path, const char ∗ vendor, const char ∗ application )
Use this constructor to create or read a preferences file at an arbitrary position in the file system.
The file name is generated in the form path/application.prefs. If application is NULL,
path must contain the full file name.
Parameters
in path path to the directory that contains the preferences file
in vendor unique text describing the company or author of this file
in application unique text describing the application

Fl Preferences::Fl Preferences ( Fl Preferences & parent, const char ∗ group )


Generate or read a new group of entries within another group.
Use the group argument to name the group that you would like to access. Group can also contain a
path to a group further down the hierarchy by separating group names with a forward slash ’/’.
Parameters
in parent reference object for the new group
in group name of the group to access (may contain ’/’s)

Fl Preferences::Fl Preferences ( Fl Preferences ∗ parent, const char ∗ group )


Create or access a group of preferences using a name.
Parameters
in parent the parameter parent is a pointer to the parent group. Parent may be
NULL. It then refers to an application internal database which exists only
once, and remains in RAM only until the application quits. This database
is used to manage plugins and other data indexes by strings.
in group a group name that is used as a key into the database
31.103. FL PREFERENCES CLASS REFERENCE 595

See Also
Fl Preferences( Fl Preferences&, const char ∗group )

Fl Preferences::Fl Preferences ( Fl Preferences & parent, int groupIndex )


Open a child group using a given index.
Use the groupIndex argument to find the group that you would like to access. If the given index is
invalid (negative or too high), a new group is created with a UUID as a name.
The index needs to be fixed. It is currently backward. Index 0 points to the last member in the ’list’ of
preferences.
Parameters
in parent reference object for the new group
in groupIndex zero based index into child groups

Fl Preferences::Fl Preferences ( Fl Preferences ∗ parent, int groupIndex )


See Also
Fl Preferences( Fl Preferences&, int groupIndex )

Fl Preferences::Fl Preferences ( Fl Preferences::ID id )


Create a new dataset access point using a dataset ID.
ID’s are a great way to remember shortcuts to database entries that are deeply nested in a preferences
database, as long as the database root is not deleted. An ID can be retrieved from any Fl Preferences
dataset, and can then be used to create multiple new references to the same dataset.
ID’s can be very helpful when put into the user data() field of widget callbacks.

Fl Preferences::∼Fl Preferences ( ) [virtual]


The destructor removes allocated resources.
When used on the base preferences group, the destructor flushes all changes to the preferences file and
deletes all internal databases.
The destructor does not remove any data from the database. It merely deletes your reference to the
database.

31.103.5 Member Function Documentation


char Fl Preferences::deleteEntry ( const char ∗ key )
Deletes a single name/value pair.
This function removes the entry key from the database.
Parameters
in key name of entry to delete

Returns
0 if deleting the entry failed

char Fl Preferences::deleteGroup ( const char ∗ group )


Deletes a group.
Removes a group and all keys and groups within that group from the database.
596 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in group name of the group to delete

Returns
0 if call failed

int Fl Preferences::entries ( )
Returns the number of entries (name/value pairs) in a group.
Returns
number of entries

const char ∗ Fl Preferences::entry ( int index )


Returns the name of an entry.
There is no guaranteed order of entry names. The index must be within the range given by entries().
Parameters
in index number indexing the requested entry

Returns
pointer to value cstring

char Fl Preferences::entryExists ( const char ∗ key )


Returns non-zero if an entry with this name exists.
Parameters
in key name of entry that is searched for

Returns
0 if entry was not found

void Fl Preferences::flush ( )
Writes all preferences to disk.
This function works only with the base preferences group. This function is rarely used as deleting the
base preferences flushes automatically.

char Fl Preferences::get ( const char ∗ key, int & value, int defaultValue )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0).
31.103. FL PREFERENCES CLASS REFERENCE 597

Parameters
in key name of entry
out value returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set

Returns
0 if the default value was used

char Fl Preferences::get ( const char ∗ key, float & value, float defaultValue )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0).
Parameters
in key name of entry
out value returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set

Returns
0 if the default value was used

char Fl Preferences::get ( const char ∗ key, double & value, double defaultValue )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0).
Parameters
in key name of entry
out value returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set

Returns
0 if the default value was used

char Fl Preferences::get ( const char ∗ key, char ∗& text, const char ∗ defaultValue )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0). get() allocates memory of sufficient size to hold the value. The buffer must be
free’d by the developer using ’free(value)’.
Parameters
in key name of entry
out text returned from preferences or default value if none was set
598 CHAPTER 31. CLASS DOCUMENTATION

in defaultValue default value to be used if no preference was set

Returns
0 if the default value was used

char Fl Preferences::get ( const char ∗ key, char ∗ text, const char ∗ defaultValue, int maxSize )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0). ’maxSize’ is the maximum length of text that will be read. The text buffer must
allow for one additional byte for a trailing zero.
Parameters
in key name of entry
out text returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set
in maxSize maximum length of value plus one byte for a trailing zero

Returns
0 if the default value was used

char Fl Preferences::get ( const char ∗ key, void ∗& data, const void ∗ defaultValue, int defaultSize
)
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0). get() allocates memory of sufficient size to hold the value. The buffer must be
free’d by the developer using ’free(value)’.
Parameters
in key name of entry
out data returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set
in defaultSize size of default value array

Returns
0 if the default value was used

char Fl Preferences::get ( const char ∗ key, void ∗ data, const void ∗ defaultValue, int defaultSize,
int maxSize )
Reads an entry from the group.
A default value must be supplied. The return value indicates if the value was available (non-zero) or
the default was used (0). ’maxSize’ is the maximum length of text that will be read.
Parameters
31.103. FL PREFERENCES CLASS REFERENCE 599

in key name of entry


out data value returned from preferences or default value if none was set
in defaultValue default value to be used if no preference was set
in defaultSize size of default value array
in maxSize maximum length of value

Returns
0 if the default value was used

Todo maxSize should receive the number of bytes that were read.

char Fl Preferences::getUserdataPath ( char ∗ path, int pathlen )


Creates a path that is related to the preferences file and that is usable for additional application data.
This function creates a directory that is named after the preferences database without the .prefs exten-
sion and located in the same directory. It then fills the given buffer with the complete path name.
Exmaple:
Fl Preferences prefs( USER, "matthiasm.com", "test" );
char path[FL PATH MAX];
prefs.getUserdataPath( path );

creates the preferences database in (MS Windows):


c:/Documents and Settings/matt/Application Data/matthiasm.com/test.prefs

and returns the userdata path:


c:/Documents and Settings/matt/Application Data/matthiasm.com/test/

Parameters
out path buffer for user data path
in pathlen size of path buffer (should be at least FL PATH MAX)

Returns
0 if path was not created or pathname can’t fit into buffer

const char ∗ Fl Preferences::group ( int num group )


Returns the name of the Nth (num group) group.
There is no guaranteed order of group names. The index must be within the range given by groups().
Parameters
in num group number indexing the requested group

Returns
’C’ string pointer to the group name

char Fl Preferences::groupExists ( const char ∗ key )


Returns non-zero if a group with this name exists.
Group names are relative to the Preferences node and can contain a path. ”.” describes the current node,
”./” describes the topmost node. By preceding a groupname with a ”./”, its path becomes relative to the
topmost node.
600 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in key name of group that is searched for

Returns
0 if no group by that name was found

int Fl Preferences::groups ( )
Returns the number of groups that are contained within a group.
Returns
0 for no groups at all

const char ∗ Fl Preferences::newUUID ( ) [static]


Returns a UUID as generated by the system.
A UUID is a ”universally unique identifier” which is commonly used in configuration files to create
identities. A UUID in ASCII looks like this: 937C4900-51AA-4C11-8DD3-7AB59944F03E. It has
always 36 bytes plus a trailing zero.
Returns
a pointer to a static buffer containing the new UUID in ASCII format. The buffer is overwritten
during every call to this function!

char Fl Preferences::set ( const char ∗ key, int value )


Sets an entry (name/value pair).
The return value indicates if there was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences file.
Parameters
in key name of entry
in value set this entry to value

Returns
0 if setting the value failed

char Fl Preferences::set ( const char ∗ key, float value )


Sets an entry (name/value pair).
The return value indicates if there was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences file.
Parameters
in key name of entry
31.103. FL PREFERENCES CLASS REFERENCE 601

in value set this entry to value

Returns
0 if setting the value failed

char Fl Preferences::set ( const char ∗ key, float value, int precision )


Sets an entry (name/value pair).
The return value indicates if there was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences file.
Parameters
in key name of entry
in value set this entry to value
in precision number of decimal digits to represent value

Returns
0 if setting the value failed

char Fl Preferences::set ( const char ∗ key, double value )


Sets an entry (name/value pair).
The return value indicates if there was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences file.
Parameters
in key name of entry
in value set this entry to value

Returns
0 if setting the value failed

char Fl Preferences::set ( const char ∗ key, double value, int precision )


Sets an entry (name/value pair).
The return value indicates if there was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences file.
Parameters
in key name of entry
in value set this entry to value
in precision number of decimal digits to represent value

Returns
0 if setting the value failed

char Fl Preferences::set ( const char ∗ key, const char ∗ text )


Sets an entry (name/value pair).
The return value indicates if there was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences file.
602 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in key name of entry
in text set this entry to value

Returns
0 if setting the value failed

char Fl Preferences::set ( const char ∗ key, const void ∗ data, int dsize )
Sets an entry (name/value pair).
The return value indicates if there was a problem storing the data in memory. However it does not
reflect if the value was actually stored in the preferences file.
Parameters
in key name of entry
in data set this entry to value
in dsize size of data array

Returns
0 if setting the value failed

int Fl Preferences::size ( const char ∗ key )


Returns the size of the value part of an entry.
Parameters
in key name of entry

Returns
size of value
The documentation for this class was generated from the following files:
• Fl Preferences.H
• Fl Preferences.cxx

31.104 Fl Printer Class Reference


OS-independent print support.
#include <Fl Printer.H>
Inheritance diagram for Fl Printer:

Fl_Device

Fl_Surface_Device

Fl_Paged_Device

Fl_Printer
31.104. FL PRINTER CLASS REFERENCE 603

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• Fl Graphics Driver ∗ driver (void)
• void end job (void)
To be called at the end of a print job.
• int end page (void)
To be called at the end of each page.
• Fl Printer (void)
The constructor.
• void margins (int ∗left, int ∗top, int ∗right, int ∗bottom)
Computes the dimensions of margins that lie between the printable page area and the full page.
• void origin (int ∗x, int ∗y)
Computes the page coordinates of the current origin of graphics functions.
• void origin (int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
• void print widget (Fl Widget ∗widget, int delta x=0, int delta y=0)
Draws the widget on the printed page.
• void print window part (Fl Window ∗win, int x, int y, int w, int h, int delta x=0, int delta y=0)
Prints a rectangular part of an on-screen window.
• int printable rect (int ∗w, int ∗h)
Computes the width and height of the printable area of the page.
• void rotate (float angle)
Rotates the graphics operations relatively to paper.
• void scale (float scale x, float scale y=0.)
Changes the scaling of page coordinates.
• void set current (void)
Use this drawing surface for future graphics requests.
• int start job (int pagecount, int ∗frompage=NULL, int ∗topage=NULL)
Starts a print job.
• int start page (void)
Starts a new printed page.
• void translate (int x, int y)
Translates the current graphics origin accounting for the current rotation.
• void untranslate (void)
Undoes the effect of a previous translate() call.
• ∼Fl Printer (void)
The destructor.

Static Public Attributes


• static const char ∗ class id = ”Fl Printer”

These attributes are effective under the Xlib platform only.

• static const char ∗ dialog title = ”Print”


[this text may be customized at run-time]
• static const char ∗ dialog printer = ”Printer:”
604 CHAPTER 31. CLASS DOCUMENTATION

[this text may be customized at run-time]


• static const char ∗ dialog range = ”Print Range”
[this text may be customized at run-time]
• static const char ∗ dialog copies = ”Copies”
[this text may be customized at run-time]
• static const char ∗ dialog all = ”All”
[this text may be customized at run-time]
• static const char ∗ dialog pages = ”Pages”
[this text may be customized at run-time]
• static const char ∗ dialog from = ”From:”
[this text may be customized at run-time]
• static const char ∗ dialog to = ”To:”
[this text may be customized at run-time]
• static const char ∗ dialog properties = ”Properties...”
[this text may be customized at run-time]
• static const char ∗ dialog copyNo = ”# Copies:”
[this text may be customized at run-time]
• static const char ∗ dialog print button = ”Print”
[this text may be customized at run-time]
• static const char ∗ dialog cancel button = ”Cancel”
[this text may be customized at run-time]
• static const char ∗ dialog print to file = ”Print To File”
[this text may be customized at run-time]
• static const char ∗ property title = ”Printer Properties”
[this text may be customized at run-time]
• static const char ∗ property pagesize = ”Page Size:”
[this text may be customized at run-time]
• static const char ∗ property mode = ”Output Mode:”
[this text may be customized at run-time]
• static const char ∗ property use = ”Use”
[this text may be customized at run-time]
• static const char ∗ property save = ”Save”
[this text may be customized at run-time]
• static const char ∗ property cancel = ”Cancel”
[this text may be customized at run-time]

Additional Inherited Members


31.104.1 Detailed Description
OS-independent print support.
Fl Printer allows to use all FLTK drawing, color, text, and clip functions, and to have them operate on
printed page(s). There are two main, non exclusive, ways to use it.
• Print any widget (standard, custom, Fl Window, Fl Gl Window) as it appears on screen, with op-
tional translation, scaling and rotation. This is done by calling print widget(), print window() or
print window part().
• Use a series of FLTK graphics commands (e.g., font, text, lines, colors, clip, image) to compose a
page appropriately shaped for printing.
In both cases, begin by start job(), start page(), printable rect() and origin() calls and finish by end page()
and end job() calls.
Platform specifics
31.104. FL PRINTER CLASS REFERENCE 605

• Unix/Linux platforms: Class Fl RGB Image prints but loses its transparency if it has one. See class
Fl PostScript Graphics Driver for a description of how UTF-8 strings appear in print. Use the static
public attributes of this class to set the print dialog to other languages than English. For example, the
”Printer:” dialog item Fl Printer::dialog printer can be set to French with:

Fl Printer::dialog printer = "Imprimante:";

before creation of the Fl Printer object. Use Fl PostScript File Device::file chooser title to cus-
tomize the title of the file chooser dialog that opens when using the ”Print To File” option of the print
dialog.
• MSWindows platform: Transparent Fl RGB Image ’s don’t print with exact transparency on most
printers. Fl RGB Image ’s don’t rotate() well. A workaround is to use the print window part() call.
• Mac OS X platform: all graphics requests print as on display.

31.104.2 Member Function Documentation


const char∗ Fl Printer::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Paged Device.

int Fl Printer::end page ( void ) [virtual]


To be called at the end of each page.
Returns
0 if OK, non-zero if any error.

Reimplemented from Fl Paged Device.

void Fl Printer::margins ( int ∗ left, int ∗ top, int ∗ right, int ∗ bottom ) [virtual]
Computes the dimensions of margins that lie between the printable page area and the full page.
Values are in the same unit as that used by FLTK drawing functions. They are changed by scale() calls.
Parameters
out left If non-null, ∗left is set to the left margin size.
out top If non-null, ∗top is set to the top margin size.
out right If non-null, ∗right is set to the right margin size.
out bottom If non-null, ∗bottom is set to the bottom margin size.
Reimplemented from Fl Paged Device.

void Fl Printer::origin ( int ∗ x, int ∗ y ) [virtual]


Computes the page coordinates of the current origin of graphics functions.
606 CHAPTER 31. CLASS DOCUMENTATION

Parameters
out x If non-null, ∗x is set to the horizontal page offset of graphics origin.
out y Same as above, vertically.
Reimplemented from Fl Paged Device.

void Fl Printer::origin ( int x, int y ) [virtual]


Sets the position in page coordinates of the origin of graphics functions.
Arguments should be expressed relatively to the result of a previous printable rect() call. That is,
printable rect(&w, &h); origin(w/2, 0); sets the graphics origin at the top center of the
page printable area. Origin() calls are not affected by rotate() calls. Successive origin() calls don’t combine
their effects.
Parameters
in x Horizontal position in page coordinates of the desired origin of graphics
functions.
in y Same as above, vertically.
Reimplemented from Fl Paged Device.

void Fl Printer::print widget ( Fl Widget ∗ widget, int delta x = 0, int delta y = 0 ) [virtual]
Draws the widget on the printed page.
The widget’s position on the printed page is determined by the last call to origin() and by the optional
delta x and delta y arguments. Its dimensions are in points unless there was a previous call to scale().
Parameters
in widget Any FLTK widget (e.g., standard, custom, window).
in delta x Optional horizontal offset for positioning the widget relatively to the cur-
rent origin of graphics functions.
in delta y Same as above, vertically.
Reimplemented from Fl Paged Device.

void Fl Printer::print window part ( Fl Window ∗ win, int x, int y, int w, int h, int delta x = 0,
int delta y = 0 ) [virtual]
Prints a rectangular part of an on-screen window.
Parameters
win The window from where to capture.
x The rectangle left
y The rectangle top
w The rectangle width
h The rectangle height
delta x Optional horizontal offset from current graphics origin where to print the captured
rectangle.
delta y As above, vertically.
Reimplemented from Fl Paged Device.

int Fl Printer::printable rect ( int ∗ w, int ∗ h ) [virtual]


Computes the width and height of the printable area of the page.
Values are in the same unit as that used by FLTK drawing functions, are unchanged by calls to origin(),
but are changed by scale() calls. Values account for the user-selected paper type and print orientation.
31.104. FL PRINTER CLASS REFERENCE 607

Returns
0 if OK, non-zero if any error

Reimplemented from Fl Paged Device.

void Fl Printer::rotate ( float angle ) [virtual]


Rotates the graphics operations relatively to paper.
The rotation is centered on the current graphics origin. Successive rotate() calls don’t combine their
effects.
Parameters
angle Rotation angle in counter-clockwise degrees.
Reimplemented from Fl Paged Device.

void Fl Printer::scale ( float scale x, float scale y = 0. ) [virtual]


Changes the scaling of page coordinates.
This function also resets the origin of graphics functions at top left of printable page area. After a
scale() call, do a printable rect() call to get the new dimensions of the printable page area. Successive
scale() calls don’t combine their effects.
Parameters
scale x Horizontal dimensions of plot are multiplied by this quantity.
scale y Same as above, vertically. The value 0. is equivalent to setting scale y = scale x.
Thus, scale(factor); is equivalent to scale(factor, factor);
Reimplemented from Fl Paged Device.

void Fl Printer::set current ( void ) [virtual]


Use this drawing surface for future graphics requests.
Reimplemented from Fl Surface Device.

int Fl Printer::start job ( int pagecount, int ∗ frompage = NULL, int ∗ topage = NULL )
[virtual]
Starts a print job.
Parameters
in pagecount the total number of pages of the job
out frompage if non-null, ∗frompage is set to the first page the user wants printed
out topage if non-null, ∗topage is set to the last page the user wants printed

Returns
0 if OK, non-zero if any error

Reimplemented from Fl Paged Device.

int Fl Printer::start page ( void ) [virtual]


Starts a new printed page.
The page coordinates are initially in points, i.e., 1/72 inch, and with origin at the top left of the printable
page area.
608 CHAPTER 31. CLASS DOCUMENTATION

Returns
0 if OK, non-zero if any error

Reimplemented from Fl Paged Device.

void Fl Printer::translate ( int x, int y ) [virtual]


Translates the current graphics origin accounting for the current rotation.
This function is only useful after a rotate() call. Each translate() call must be matched by an untrans-
late() call. Successive translate() calls add up their effects.
Reimplemented from Fl Paged Device.
The documentation for this class was generated from the following files:

• Fl Printer.H
• Fl Printer.cxx

31.105 Fl Progress Class Reference


Displays a progress bar for the user.
#include <Fl Progress.H>
Inheritance diagram for Fl Progress:

Fl_Widget

Fl_Progress

Public Member Functions


• Fl Progress (int x, int y, int w, int h, const char ∗l=0)
The constructor creates the progress bar using the position, size, and label.
• void maximum (float v)
Sets the maximum value in the progress widget.
• float maximum () const
Gets the maximum value in the progress widget.
• void minimum (float v)
Sets the minimum value in the progress widget.
• float minimum () const
Gets the minimum value in the progress widget.
• void value (float v)
Sets the current value in the progress widget.
• float value () const
Gets the current value in the progress widget.

Protected Member Functions


• virtual void draw ()
Draws the progress bar.
31.105. FL PROGRESS CLASS REFERENCE 609

Additional Inherited Members


31.105.1 Detailed Description
Displays a progress bar for the user.

31.105.2 Constructor & Destructor Documentation


Fl Progress::Fl Progress ( int X, int Y, int W, int H, const char ∗ L = 0 )

The constructor creates the progress bar using the position, size, and label.
You can set the background color with color() and the progress bar color with selection color(), or you
can set both colors together with color(unsigned bg, unsigned sel).
The default colors are FL BACKGROUND2 COLOR and FL YELLOW, resp.

31.105.3 Member Function Documentation


void Fl Progress::draw ( void ) [protected], [virtual]

Draws the progress bar.


Implements Fl Widget.

void Fl Progress::maximum ( float v ) [inline]

Sets the maximum value in the progress widget.

float Fl Progress::maximum ( ) const [inline]

Gets the maximum value in the progress widget.

void Fl Progress::minimum ( float v ) [inline]

Sets the minimum value in the progress widget.

float Fl Progress::minimum ( ) const [inline]

Gets the minimum value in the progress widget.

void Fl Progress::value ( float v ) [inline]

Sets the current value in the progress widget.

float Fl Progress::value ( ) const [inline]

Gets the current value in the progress widget.


The documentation for this class was generated from the following files:

• Fl Progress.H
• Fl Progress.cxx
610 CHAPTER 31. CLASS DOCUMENTATION

31.106 Fl Quartz Graphics Driver Class Reference


The Mac OS X-specific graphics class.
#include <Fl Device.H>
Inheritance diagram for Fl Quartz Graphics Driver:

Fl_Device

Fl_Graphics_Driver

Fl_Quartz_Graphics_Driver

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void color (Fl Color c)
see fl color(Fl Color c).
• void color (uchar r, uchar g, uchar b)
see fl color(uchar r, uchar g, uchar b).
• void copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
• int descent ()
see fl descent().
• void draw (const char ∗str, int n, int x, int y)
see fl draw(const char ∗str, int n, int x, int y).
• void draw (int angle, const char ∗str, int n, int x, int y)
see fl draw(int angle, const char ∗str, int n, int x, int y).
• void draw (Fl Pixmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Pixmap object to the device.
• void draw (Fl Bitmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Bitmap object to the device.
• void draw (Fl RGB Image ∗img, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl RGB Image object to the device.
• void draw image (const uchar ∗buf, int X, int Y, int W, int H, int D=3, int L=0)
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=3)
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D=1, int L=0)
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=1)
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void font (Fl Font face, Fl Fontsize size)
see fl font(Fl Font face, Fl Fontsize size).
• int height ()
see fl height().
• void rtl draw (const char ∗str, int n, int x, int y)
31.106. FL QUARTZ GRAPHICS DRIVER CLASS REFERENCE 611

see fl rtl draw(const char ∗str, int n, int x, int y).


• void text extents (const char ∗, int n, int &dx, int &dy, int &w, int &h)
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
• double width (const char ∗str, int n)
see fl width(const char ∗str, int n).
• double width (unsigned int c)
see fl width(unsigned int n).

Static Public Attributes


• static const char ∗ class id = ”Fl Quartz Graphics Driver”

Additional Inherited Members


31.106.1 Detailed Description
The Mac OS X-specific graphics class.
This class is implemented only on the Mac OS X platform.

31.106.2 Member Function Documentation


const char∗ Fl Quartz Graphics Driver::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::color ( Fl Color c ) [virtual]


see fl color(Fl Color c).
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::color ( uchar r, uchar g, uchar b ) [virtual]


see fl color(uchar r, uchar g, uchar b).
Reimplemented from Fl Graphics Driver.

int Fl Quartz Graphics Driver::descent ( ) [virtual]


see fl descent().
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y )
[virtual]
see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
612 CHAPTER 31. CLASS DOCUMENTATION

void Fl Quartz Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int cx,
int cy ) [virtual]

Draws an Fl Pixmap object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int cx,
int cy ) [virtual]

Draws an Fl Bitmap object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP, int
cx, int cy ) [virtual]

Draws an Fl RGB Image object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D
= 3, int L = 0 ) [virtual]

see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y,
int W, int H, int D = 3 ) [virtual]

see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 1, int L = 0 ) [virtual]

see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X,
int Y, int W, int H, int D = 1 ) [virtual]

see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::font ( Fl Font face, Fl Fontsize fsize ) [virtual]

see fl font(Fl Font face, Fl Fontsize size).


Reimplemented from Fl Graphics Driver.
31.107. FL RADIO BUTTON CLASS REFERENCE 613

int Fl Quartz Graphics Driver::height ( ) [virtual]

see fl height().
Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [virtual]

see fl rtl draw(const char ∗str, int n, int x, int y).


Reimplemented from Fl Graphics Driver.

void Fl Quartz Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int & w,
int & h ) [virtual]

see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented from Fl Graphics Driver.

double Fl Quartz Graphics Driver::width ( const char ∗ str, int n ) [virtual]

see fl width(const char ∗str, int n).


Reimplemented from Fl Graphics Driver.

double Fl Quartz Graphics Driver::width ( unsigned int c ) [virtual]

see fl width(unsigned int n).


Reimplemented from Fl Graphics Driver.
The documentation for this class was generated from the following files:

• Fl Device.H
• fl color mac.cxx
• Fl Device.cxx
• Fl Double Window.cxx
• fl draw image mac.cxx

31.107 Fl Radio Button Class Reference


Inheritance diagram for Fl Radio Button:

Fl_Widget

Fl_Button

Fl_Radio_Button

Public Member Functions


• Fl Radio Button (int X, int Y, int W, int H, const char ∗L=0)
The constructor creates the button using the given position, size, and label.
614 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members

31.107.1 Constructor & Destructor Documentation


Fl Radio Button::Fl Radio Button ( int X, int Y, int W, int H, const char ∗ L = 0 )

The constructor creates the button using the given position, size, and label.
The Button type() is set to FL RADIO BUTTON.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label

The documentation for this class was generated from the following files:

• Fl Radio Button.H
• Fl Button.cxx

31.108 Fl Radio Light Button Class Reference


Inheritance diagram for Fl Radio Light Button:

Fl_Widget

Fl_Button

Fl_Light_Button

Fl_Radio_Light_Button

Public Member Functions


• Fl Radio Light Button (int X, int Y, int W, int H, const char ∗l=0)

Additional Inherited Members


The documentation for this class was generated from the following files:

• Fl Radio Light Button.H


• Fl Light Button.cxx

31.109 Fl Radio Round Button Class Reference


Inheritance diagram for Fl Radio Round Button:
31.110. FL SCROLL::SCROLLINFO::FL REGION LRTB STRUCT REFERENCE 615

Fl_Widget

Fl_Button

Fl_Light_Button

Fl_Round_Button

Fl_Radio_Round_Button

Public Member Functions


• Fl Radio Round Button (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Radio Button widget using the given position, size, and label string.

Additional Inherited Members


31.109.1 Constructor & Destructor Documentation
Fl Radio Round Button::Fl Radio Round Button ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Radio Button widget using the given position, size, and label string.
The button type() is set to FL RADIO BUTTON.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label
The documentation for this class was generated from the following files:

• Fl Radio Round Button.H


• Fl Round Button.cxx

31.110 Fl Scroll::ScrollInfo::Fl Region LRTB Struct Reference


A local struct to manage a region defined by left/right/top/bottom.
#include <Fl Scroll.H>

Public Attributes
• int b
(b)ottom ”y” position, aka y2
• int l
(l)eft ”x” position, aka x1
• int r
(r)ight ”x” position, aka x2
• int t
(t)op ”y” position, aka y1
616 CHAPTER 31. CLASS DOCUMENTATION

31.110.1 Detailed Description


A local struct to manage a region defined by left/right/top/bottom.
The documentation for this struct was generated from the following file:

• Fl Scroll.H

31.111 Fl Scroll::ScrollInfo::Fl Region XYWH Struct Reference


A local struct to manage a region defined by xywh.
#include <Fl Scroll.H>

Public Attributes
• int h
• int w
• int x
• int y

31.111.1 Detailed Description


A local struct to manage a region defined by xywh.
The documentation for this struct was generated from the following file:

• Fl Scroll.H

31.112 Fl Repeat Button Class Reference


The Fl Repeat Button is a subclass of Fl Button that generates a callback when it is pressed and then
repeatedly generates callbacks as long as it is held down.
#include <Fl Repeat Button.H>
Inheritance diagram for Fl Repeat Button:

Fl_Widget

Fl_Button

Fl_Repeat_Button

Public Member Functions


• void deactivate ()
• Fl Repeat Button (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Repeat Button widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
31.113. FL RETURN BUTTON CLASS REFERENCE 617

Additional Inherited Members


31.112.1 Detailed Description
The Fl Repeat Button is a subclass of Fl Button that generates a callback when it is pressed and then
repeatedly generates callbacks as long as it is held down.
The speed of the repeat is fixed and depends on the implementation.

31.112.2 Constructor & Destructor Documentation


Fl Repeat Button::Fl Repeat Button ( int X, int Y, int W, int H, const char ∗ l = 0 )

Creates a new Fl Repeat Button widget using the given position, size, and label string.
The default boxtype is FL UP BOX. Deletes the button.

31.112.3 Member Function Documentation


int Fl Repeat Button::handle ( int event ) [virtual]

Handles the specified event.


You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Button.


The documentation for this class was generated from the following files:

• Fl Repeat Button.H
• Fl Repeat Button.cxx

31.113 Fl Return Button Class Reference


The Fl Return Button is a subclass of Fl Button that generates a callback when it is pressed or when the
user presses the Enter key.
#include <Fl Return Button.H>
Inheritance diagram for Fl Return Button:
618 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Button

Fl_Return_Button

Public Member Functions


• Fl Return Button (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Return Button widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.113.1 Detailed Description
The Fl Return Button is a subclass of Fl Button that generates a callback when it is pressed or when the
user presses the Enter key.
A carriage-return symbol is drawn next to the button label.

Figure 31.25: Fl Return Button

31.113.2 Constructor & Destructor Documentation


Fl Return Button::Fl Return Button ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Return Button widget using the given position, size, and label string.
The default boxtype is FL UP BOX.
The inherited destructor deletes the button.

31.113.3 Member Function Documentation


void Fl Return Button::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
31.114. FL RGB IMAGE CLASS REFERENCE 619

Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar


s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Button.

int Fl Return Button::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Button.


The documentation for this class was generated from the following files:

• Fl Return Button.H
• Fl Return Button.cxx

31.114 Fl RGB Image Class Reference


The Fl RGB Image class supports caching and drawing of full-color images with 1 to 4 channels of color
information.
#include <Fl Image.H>
Inheritance diagram for Fl RGB Image:

Fl_Image

Fl_RGB_Image

Fl_BMP_Image Fl_JPEG_Image Fl_PNG_Image Fl_PNM_Image

Public Member Functions


• virtual void color average (Fl Color c, float i)
The color average() method averages the colors in the image with the FLTK color value c.
• virtual Fl Image ∗ copy (int W, int H)
The copy() method creates a copy of the specified image.
620 CHAPTER 31. CLASS DOCUMENTATION

• Fl Image ∗ copy ()
• virtual void desaturate ()
The desaturate() method converts an image to grayscale.
• virtual void draw (int X, int Y, int W, int H, int cx=0, int cy=0)
Draws the image with a bounding box.
• void draw (int X, int Y)
• Fl RGB Image (const uchar ∗bits, int W, int H, int D=3, int LD=0)
The constructor creates a new image from the specified data.
• Fl RGB Image (const Fl Pixmap ∗pxm, Fl Color bg=FL GRAY)
The constructor creates a new RGBA image from the specified Fl Pixmap.
• virtual void label (Fl Widget ∗w)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void label (Fl Menu Item ∗m)
The label() methods are an obsolete way to set the image attribute of a widget or menu item.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.
• virtual ∼Fl RGB Image ()
The destructor frees all memory and server resources that are used by the image.

Static Public Member Functions


• static void max size (size t size)
Sets the maximum allowed image size in bytes when creating an Fl RGB Image object.
• static size t max size ()
Returns the maximum allowed image size in bytes when creating an Fl RGB Image object.

Public Attributes
• int alloc array
• const uchar ∗ array

Friends
• class Fl GDI Graphics Driver
• class Fl Quartz Graphics Driver
• class Fl Xlib Graphics Driver

Additional Inherited Members


31.114.1 Detailed Description
The Fl RGB Image class supports caching and drawing of full-color images with 1 to 4 channels of color
information.
Images with an even number of channels are assumed to contain alpha information, which is used to
blend the image with the contents of the screen.
Fl RGB Image is defined in <FL/Fl Image.H>, however for compatibility reasons <FL/Fl RGB -
Image.H> should be included.
31.114. FL RGB IMAGE CLASS REFERENCE 621

31.114.2 Constructor & Destructor Documentation


Fl RGB Image::Fl RGB Image ( const uchar ∗ bits, int W, int H, int D = 3, int LD = 0 )
[inline]
The constructor creates a new image from the specified data.
622 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in bits The image data array.
in W The width of the image in pixels
in H The height of the image in pixels
in D The image depth, or ’number of channels’. Default=3
If D=1, each uchar in bits[] is a grayscale pixel value.
If D=2, each uchar pair in bits[] is a grayscale + alpha pixel value.
If D=3, each uchar triplet in bits[] is an R/G/B pixel value
If D=4, each uchar quad in bits[] is an R/G/B/A pixel value.
in LD Line data size (default=0).
Line data is extra data that is included after each line of color image data
and is normally not present.

See Also
Fl Image::data(), Fl Image::w(), Fl Image::h(), Fl Image::d(), Fl Image::ld()

Fl RGB Image::Fl RGB Image ( const Fl Pixmap ∗ pxm, Fl Color bg = FL GRAY )


The constructor creates a new RGBA image from the specified Fl Pixmap.
The RGBA image is built fully opaque except for the transparent area of the pixmap that is assigned
the
bg color with full transparency

Fl RGB Image::∼Fl RGB Image ( ) [virtual]


The destructor frees all memory and server resources that are used by the image.

31.114.3 Member Function Documentation


void Fl RGB Image::color average ( Fl Color c, float i ) [virtual]
The color average() method averages the colors in the image with the FLTK color value c.
The i argument specifies the amount of the original image to combine with the color, so a value of 1.0
results in no color blend, and a value of 0.0 results in a constant image of the specified color. The original
image data is not altered by this method.
Reimplemented from Fl Image.

Fl Image ∗ Fl RGB Image::copy ( int W, int H ) [virtual]


The copy() method creates a copy of the specified image.
If the width and height are provided, the image is resized to the specified size. The image should be
deleted (or in the case of Fl Shared Image, released) when you are done with it.
Reimplemented from Fl Image.

void Fl RGB Image::desaturate ( ) [virtual]


The desaturate() method converts an image to grayscale.
If the image contains an alpha channel (depth = 4), the alpha channel is preserved. This method does
not alter the original image data.
Reimplemented from Fl Image.
31.115. FL ROLLER CLASS REFERENCE 623

void Fl RGB Image::draw ( int X, int Y, int W, int H, int cx = 0, int cy = 0 ) [virtual]

Draws the image with a bounding box.


This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image
offset by the cx and cy arguments.
Reimplemented from Fl Image.

void Fl RGB Image::label ( Fl Widget ∗ widget ) [virtual]

The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented from Fl Image.

void Fl RGB Image::label ( Fl Menu Item ∗ m ) [virtual]

The label() methods are an obsolete way to set the image attribute of a widget or menu item.
Use the image() or deimage() methods of the Fl Widget and Fl Menu Item classes instead.
Reimplemented from Fl Image.

static void Fl RGB Image::max size ( size t size ) [inline], [static]

Sets the maximum allowed image size in bytes when creating an Fl RGB Image object.
The image size in bytes of an Fl RGB Image object is the value of the product w() ∗ h() ∗ d(). If
this product exceeds size, the created object of a derived class of Fl RGB Image won’t be loaded with the
image data. This does not apply to direct RGB image creation with Fl RGB Image::Fl RGB Image(const
uchar ∗bits, int W, int H, int D, int LD). The default max size() value is essentially infinite.

static size t Fl RGB Image::max size ( ) [inline], [static]

Returns the maximum allowed image size in bytes when creating an Fl RGB Image object.

See Also
void Fl RGB Image::max size(size t)

void Fl RGB Image::uncache ( ) [virtual]

If the image has been cached for display, delete the cache data.
This allows you to change the data used for the image and then redraw it without recreating an image
object.
Reimplemented from Fl Image.
The documentation for this class was generated from the following files:

• Fl Image.H
• Fl Image.cxx

31.115 Fl Roller Class Reference


The Fl Roller widget is a ”dolly” control commonly used to move 3D objects.
#include <Fl Roller.H>
Inheritance diagram for Fl Roller:
624 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Valuator

Fl_Roller

Public Member Functions


• Fl Roller (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Roller widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.115.1 Detailed Description
The Fl Roller widget is a ”dolly” control commonly used to move 3D objects.

Figure 31.26: Fl Roller

31.115.2 Constructor & Destructor Documentation


Fl Roller::Fl Roller ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Roller widget using the given position, size, and label string.
The default boxtype is FL NO BOX.
Inherited destructor destroys the valuator.

31.115.3 Member Function Documentation


void Fl Roller::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
31.116. FL ROUND BUTTON CLASS REFERENCE 625

Override this function to draw your own widgets.


If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Roller::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.


The documentation for this class was generated from the following files:

• Fl Roller.H
• Fl Roller.cxx

31.116 Fl Round Button Class Reference


Buttons generate callbacks when they are clicked by the user.
#include <Fl Round Button.H>
Inheritance diagram for Fl Round Button:

Fl_Widget

Fl_Button

Fl_Light_Button

Fl_Round_Button

Fl_Radio_Round_Button
626 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• Fl Round Button (int x, int y, int w, int h, const char ∗l=0)
Creates a new Fl Round Button widget using the given position, size, and label string.

Additional Inherited Members


31.116.1 Detailed Description
Buttons generate callbacks when they are clicked by the user.
You control exactly when and how by changing the values for type() and when().

Figure 31.27: Fl Round Button

The Fl Round Button subclass display the ”on” state by turning on a light, rather than drawing pushed
in. The shape of the ”light” is initially set to FL ROUND DOWN BOX. The color of the light when on is
controlled with selection color(), which defaults to FL FOREGROUND COLOR.

31.116.2 Constructor & Destructor Documentation


Fl Round Button::Fl Round Button ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Round Button widget using the given position, size, and label string.

Figure 31.28: Fl Round Button

The Fl Round Button subclass displays the ”ON” state by turning on a light, rather than drawing pushed
in.
The default box type is FL NO BOX, which draws the label w/o a box right of the checkmark.
The shape of the ”light” is set with down box() and its default value is FL ROUND DOWN BOX.
The color of the light when on is controlled with selection color(), which defaults to FL FOREGRO-
UND COLOR (usually black).
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label
The documentation for this class was generated from the following files:

• Fl Round Button.H
• Fl Round Button.cxx

31.117 Fl Round Clock Class Reference


A clock widget of type FL ROUND CLOCK.
#include <Fl Round Clock.H>
Inheritance diagram for Fl Round Clock:
31.118. FL SCROLL CLASS REFERENCE 627

Fl_Widget

Fl_Clock_Output

Fl_Clock

Fl_Round_Clock

Public Member Functions


• Fl Round Clock (int X, int Y, int W, int H, const char ∗L=0)
Creates the clock widget, setting his type and box.

Additional Inherited Members


31.117.1 Detailed Description
A clock widget of type FL ROUND CLOCK.
Has no box.

31.117.2 Constructor & Destructor Documentation


Fl Round Clock::Fl Round Clock ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates the clock widget, setting his type and box.
The documentation for this class was generated from the following files:

• Fl Round Clock.H
• Fl Clock.cxx

31.118 Fl Scroll Class Reference


This container widget lets you maneuver around a set of widgets much larger than your window.
#include <Fl Scroll.H>
Inheritance diagram for Fl Scroll:

Fl_Widget

Fl_Group

Fl_Scroll

Public Types
• enum {
HORIZONTAL = 1, VERTICAL = 2, BOTH = 3, ALWAYS ON = 4,
HORIZONTAL ALWAYS = 5, VERTICAL ALWAYS = 6, BOTH ALWAYS = 7 }
628 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• void clear ()
Clear all but the scrollbars...
• Fl Scroll (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Scroll widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
• void resize (int, int, int, int)
Resizes the Fl Group widget and all of its children.
• void scroll to (int, int)
Moves the contents of the scroll group to a new position.
• int scrollbar size () const
Gets the current size of the scrollbars’ troughs, in pixels.
• void scrollbar size (int newSize)
Sets the pixel size of the scrollbars’ troughs to newSize, in pixels.
• int xposition () const
Gets the current horizontal scrolling position.
• int yposition () const
Gets the current vertical scrolling position.

Public Attributes
• Fl Scrollbar hscrollbar
• Fl Scrollbar scrollbar

Protected Member Functions


• void bbox (int &, int &, int &, int &)
Returns the bounding box for the interior of the scrolling area, inside the scrollbars.
• void draw ()
Draws the widget.

Additional Inherited Members


31.118.1 Detailed Description
This container widget lets you maneuver around a set of widgets much larger than your window.
If the child widgets are larger than the size of this object then scrollbars will appear so that you can
scroll over to them:

Figure 31.29: Fl Scroll


31.118. FL SCROLL CLASS REFERENCE 629

If all of the child widgets are packed together into a solid rectangle then you want to set box() to FL -
NO BOX or one of the FRAME types. This will result in the best output. However, if the child widgets
are a sparse arrangement you must set box() to a real BOX type. This can result in some blinking during
redrawing, but that can be solved by using a Fl Double Window.
By default you can scroll in both directions, and the scrollbars disappear if the data will fit in the area
of the scroll.
Use Fl Scroll::type() to change this as follows :

• 0 - No scrollbars

• Fl Scroll::HORIZONTAL - Only a horizontal scrollbar.

• Fl Scroll::VERTICAL - Only a vertical scrollbar.

• Fl Scroll::BOTH - The default is both scrollbars.

• Fl Scroll::HORIZONTAL ALWAYS - Horizontal scrollbar always on, vertical always off.

• Fl Scroll::VERTICAL ALWAYS - Vertical scrollbar always on, horizontal always off.

• Fl Scroll::BOTH ALWAYS - Both always on.

Use scrollbar.align(int) ( see void Fl Widget::align(Fl Align) ) : to change what side the scrollbars
are drawn on.
If the FL ALIGN LEFT bit is on, the vertical scrollbar is on the left. If the FL ALIGN TOP bit is on,
the horizontal scrollbar is on the top. Note that only the alignment flags in scrollbar are considered. The
flags in hscrollbar however are ignored.
This widget can also be used to pan around a single child widget ”canvas”. This child widget should be
of your own class, with a draw() method that draws the contents. The scrolling is done by changing the x()
and y() of the widget, so this child must use the x() and y() to position its drawing. To speed up drawing it
should test fl push clip().
Another very useful child is a single Fl Pack, which is itself a group that packs its children together and
changes size to surround them. Filling the Fl Pack with Fl Tabs groups (and then putting normal widgets
inside those) gives you a very powerful scrolling list of individually-openable panels.
Fluid lets you create these, but you can only lay out objects that fit inside the Fl Scroll without scrolling.
Be sure to leave space for the scrollbars, as Fluid won’t show these either.
You cannot use Fl Window as a child of this since the clipping is not conveyed to it when drawn, and it
will draw over the scrollbars and neighboring objects.

31.118.2 Constructor & Destructor Documentation


Fl Scroll::Fl Scroll ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Scroll widget using the given position, size, and label string.
The default boxtype is FL NO BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without
having to keep a pointer to all the children in the user code. A kludge has been done so the Fl Scroll and
all of its children can be automatic (local) variables, but you must declare the Fl Scroll first, so that it is
destroyed last.

31.118.3 Member Function Documentation


void Fl Scroll::bbox ( int & X, int & Y, int & W, int & H ) [protected]
Returns the bounding box for the interior of the scrolling area, inside the scrollbars.
Currently this is only reliable after draw(), and before any resizing of the Fl Scroll or any child widgets
occur.
630 CHAPTER 31. CLASS DOCUMENTATION

Todo The visibility of the scrollbars ought to be checked/calculated outside of the draw() method (STR
#1895).

void Fl Scroll::clear ( )
Clear all but the scrollbars...

void Fl Scroll::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Group.

int Fl Scroll::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Group.

void Fl Scroll::resize ( int X, int Y, int W, int H ) [virtual]


Resizes the Fl Group widget and all of its children.
The Fl Group widget first resizes itself, and then it moves and resizes all its children according to the
rules documented for Fl Group::resizable(Fl Widget∗)
See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)

Reimplemented from Fl Group.


31.119. FL SCROLLBAR CLASS REFERENCE 631

void Fl Scroll::scroll to ( int X, int Y )


Moves the contents of the scroll group to a new position.

int Fl Scroll::scrollbar size ( ) const [inline]


Gets the current size of the scrollbars’ troughs, in pixels.
If this value is zero (default), this widget will use the Fl::scrollbar size() value as the scrollbar’s width.

Returns
Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used.

See Also
Fl::scrollbar size(int)

void Fl Scroll::scrollbar size ( int newSize ) [inline]


Sets the pixel size of the scrollbars’ troughs to newSize, in pixels.
Normally you should not need this method, and should use Fl::scrollbar size(int) instead to manage
the size of ALL your widgets’ scrollbars. This ensures your application has a consistent UI, is the default
behavior, and is normally what you want.
Only use THIS method if you really need to override the global scrollbar size. The need for this should
be rare.
Setting newSize to the special value of 0 causes the widget to track the global Fl::scrollbar size(),
which is the default.
Parameters
in newSize Sets the scrollbar size in pixels.
If 0 (default), scrollbar size tracks the global Fl::scrollbar size()

See Also
Fl::scrollbar size()

int Fl Scroll::xposition ( ) const [inline]


Gets the current horizontal scrolling position.

int Fl Scroll::yposition ( ) const [inline]


Gets the current vertical scrolling position.
The documentation for this class was generated from the following files:

• Fl Scroll.H
• Fl Scroll.cxx

31.119 Fl Scrollbar Class Reference


The Fl Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
#include <Fl Scrollbar.H>
Inheritance diagram for Fl Scrollbar:
632 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Scrollbar

Public Member Functions


• Fl Scrollbar (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Scrollbar widget with given position, size, and label.
• int handle (int)
Handles the specified event.
• int linesize () const
Get the size of step, in lines, that the arror keys move.
• void linesize (int i)
This number controls how big the steps are that the arrow keys do.
• int value () const
Gets the integer value (position) of the slider in the scrollbar.
• int value (int p)
Sets the value (position) of the slider in the scrollbar.
• int value (int pos, int windowSize, int first, int total)
Sets the position, size and range of the slider in the scrollbar.
• ∼Fl Scrollbar ()
Destroys the Scrollbar.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.119.1 Detailed Description
The Fl Scrollbar widget displays a slider with arrow buttons at the ends of the scrollbar.
Clicking on the arrows move up/left and down/right by linesize(). Scrollbars also accept FL SHORT-
CUT events: the arrows move by linesize(), and vertical scrollbars take Page Up/Down (they move by the
page size minus linesize()) and Home/End (they jump to the top or bottom).
Scrollbars have step(1) preset (they always return integers). If desired you can set the step() to non-
integer values. You will then have to use casts to get at the floating-point versions of value() from Fl Slider.
31.119. FL SCROLLBAR CLASS REFERENCE 633

Figure 31.30: Fl Scrollbar

31.119.2 Constructor & Destructor Documentation


Fl Scrollbar::Fl Scrollbar ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Scrollbar widget with given position, size, and label.
You need to do type(FL HORIZONTAL) if you want a horizontal scrollbar.

Fl Scrollbar::∼Fl Scrollbar ( )
Destroys the Scrollbar.

31.119.3 Member Function Documentation


void Fl Scrollbar::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Scrollbar::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
634 CHAPTER 31. CLASS DOCUMENTATION

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.

void Fl Scrollbar::linesize ( int i ) [inline]


This number controls how big the steps are that the arrow keys do.
In addition page up/down move by the size last sent to value() minus one linesize(). The default is 16.

int Fl Scrollbar::value ( ) const [inline]


Gets the integer value (position) of the slider in the scrollbar.
You can get the floating point value with Fl Slider::value().
See Also
Fl Scrollbar::value(int p)
Fl Scrollbar::value(int pos, int size, int first, int total)

int Fl Scrollbar::value ( int p ) [inline]


Sets the value (position) of the slider in the scrollbar.
See Also
Fl Scrollbar::value()
Fl Scrollbar::value(int pos, int size, int first, int total)

int Fl Scrollbar::value ( int pos, int windowSize, int first, int total ) [inline]
Sets the position, size and range of the slider in the scrollbar.
Parameters
in pos position, first line displayed
in windowSize number of lines displayed
in first number of first line
in total total number of lines
You should call this every time your window changes size, your data changes size, or your scroll position
changes (even if in response to a callback from this scrollbar). All necessary calls to redraw() are done.
Calls Fl Slider::scrollvalue(int pos, int size, int first, int total).
The documentation for this class was generated from the following files:
• Fl Scrollbar.H
• Fl Scrollbar.cxx

31.120 Fl Scroll::ScrollInfo::Fl Scrollbar Data Struct Reference


A local struct to manage a scrollbar’s xywh region and tab values.
#include <Fl Scroll.H>
31.121. FL SECRET INPUT CLASS REFERENCE 635

Public Attributes
• int first
scrollbar tab’s ”number of first line”
• int h
• int pos
scrollbar tab’s ”position of first line displayed”
• int size
scrollbar tab’s ”size of window in lines”
• int total
scrollbar tab’s ”total number of lines”
• int w
• int x
• int y

31.120.1 Detailed Description


A local struct to manage a scrollbar’s xywh region and tab values.
The documentation for this struct was generated from the following file:

• Fl Scroll.H

31.121 Fl Secret Input Class Reference


The Fl Secret Input class is a subclass of Fl Input that displays its input as a string of placeholders.
#include <Fl Secret Input.H>
Inheritance diagram for Fl Secret Input:

Fl_Widget

Fl_Input_

Fl_Input

Fl_Secret_Input

Public Member Functions


• Fl Secret Input (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Secret Input widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
636 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.121.1 Detailed Description
The Fl Secret Input class is a subclass of Fl Input that displays its input as a string of placeholders.
Depending on the platform this placeholder is either the asterisk (’∗’) or the Unicode bullet character
(U+2022).
This subclass is usually used to receive passwords and other ”secret” information.

31.121.2 Constructor & Destructor Documentation


Fl Secret Input::Fl Secret Input ( int X, int Y, int W, int H, const char ∗ l = 0 )

Creates a new Fl Secret Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.
Inherited destructor destroys the widget and any value associated with it.

31.121.3 Member Function Documentation


int Fl Secret Input::handle ( int event ) [virtual]

Handles the specified event.


You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Input.


The documentation for this class was generated from the following files:

• Fl Secret Input.H
• Fl Input.cxx

31.122 Fl Select Browser Class Reference


The class is a subclass of Fl Browser which lets the user select a single item, or no items by clicking on the
empty space.
#include <Fl Select Browser.H>
Inheritance diagram for Fl Select Browser:
31.123. FL SHARED IMAGE CLASS REFERENCE 637

Fl_Widget

Fl_Group

Fl_Browser_

Fl_Browser

Fl_Select_Browser

Public Member Functions


• Fl Select Browser (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Select Browser widget using the given position, size, and label string.

Additional Inherited Members


31.122.1 Detailed Description
The class is a subclass of Fl Browser which lets the user select a single item, or no items by clicking on the
empty space.
As long as the mouse button is held down on an unselected item it is highlighted. Normally the callback
is done when the user presses the mouse, but you can change this with when().
See Fl Browser for methods to add and remove lines from the browser.

31.122.2 Constructor & Destructor Documentation


Fl Select Browser::Fl Select Browser ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Select Browser widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX. The constructor specializes Fl Browser() by setting the type
to FL SELECT BROWSER. The destructor destroys the widget and frees all memory that has been allo-
cated.
The documentation for this class was generated from the following files:

• Fl Select Browser.H
• Fl Browser.cxx

31.123 Fl Shared Image Class Reference


This class supports caching, loading, and drawing of image files.
#include <Fl Shared Image.H>
Inheritance diagram for Fl Shared Image:

Fl_Image

Fl_Shared_Image
638 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• virtual void color average (Fl Color c, float i)
The color average() method averages the colors in the image with the FLTK color value c.
• virtual Fl Image ∗ copy (int W, int H)
The copy() method creates a copy of the specified image.
• Fl Image ∗ copy ()
• virtual void desaturate ()
The desaturate() method converts an image to grayscale.
• virtual void draw (int X, int Y, int W, int H, int cx, int cy)
Draws the image with a bounding box.
• void draw (int X, int Y)
• const char ∗ name ()
Returns the filename of the shared image.
• int refcount ()
Returns the number of references of this shared image.
• void release ()
Releases and possibly destroys (if refcount <=0) a shared image.
• void reload ()
Reloads the shared image from disk.
• virtual void uncache ()
If the image has been cached for display, delete the cache data.

Static Public Member Functions


• static void add handler (Fl Shared Handler f)
Adds a shared image handler, which is basically a test function for adding new formats.
• static Fl Shared Image ∗ find (const char ∗n, int W=0, int H=0)
Finds a shared image from its named and size specifications.
• static Fl Shared Image ∗ get (const char ∗n, int W=0, int H=0)
Find or load an image that can be shared by multiple widgets.
• static Fl Shared Image ∗∗ images ()
Returns the Fl Shared Image∗ array.
• static int num images ()
Returns the total number of shared images in the array.
• static void remove handler (Fl Shared Handler f)
Removes a shared image handler.

Protected Member Functions


• void add ()
• Fl Shared Image ()
Creates an empty shared image.
• Fl Shared Image (const char ∗n, Fl Image ∗img=0)
Creates a shared image from its filename and its corresponding Fl Image∗ img.
• void update ()
• virtual ∼Fl Shared Image ()
The destructor free all memory and server resources that are used by the image.
31.123. FL SHARED IMAGE CLASS REFERENCE 639

Static Protected Member Functions


• static int compare (Fl Shared Image ∗∗i0, Fl Shared Image ∗∗i1)

Protected Attributes
• int alloc image
• Fl Image ∗ image
• const char ∗ name
• int original
• int refcount

Static Protected Attributes


• static int alloc handlers = 0
• static int alloc images = 0
• static Fl Shared Handler ∗ handlers = 0
• static Fl Shared Image ∗∗ images = 0
• static int num handlers = 0
• static int num images = 0

Friends
• class Fl JPEG Image
• class Fl PNG Image

31.123.1 Detailed Description


This class supports caching, loading, and drawing of image files.
Most applications will also want to link against the fltk images library and call the fl register images()
function to support standard image formats such as BMP, GIF, JPEG, and PNG.

31.123.2 Constructor & Destructor Documentation


Fl Shared Image::Fl Shared Image ( ) [protected]
Creates an empty shared image.
The constructors create a new shared image record in the image cache.
The constructors are protected and cannot be used directly from a program. Use the get() method
instead.

Fl Shared Image::Fl Shared Image ( const char ∗ n, Fl Image ∗ img = 0 ) [protected]


Creates a shared image from its filename and its corresponding Fl Image∗ img.
The constructors create a new shared image record in the image cache.
The constructors are protected and cannot be used directly from a program. Use the get() method
instead.

Fl Shared Image::∼Fl Shared Image ( ) [protected], [virtual]


The destructor free all memory and server resources that are used by the image.
The destructor is protected and cannot be used directly from a program. Use the Fl Shared Image-
::release() method instead.
640 CHAPTER 31. CLASS DOCUMENTATION

31.123.3 Member Function Documentation


void Fl Shared Image::color average ( Fl Color c, float i ) [virtual]
The color average() method averages the colors in the image with the FLTK color value c.
The i argument specifies the amount of the original image to combine with the color, so a value of 1.0
results in no color blend, and a value of 0.0 results in a constant image of the specified color. The original
image data is not altered by this method.
Reimplemented from Fl Image.

Fl Image ∗ Fl Shared Image::copy ( int W, int H ) [virtual]


The copy() method creates a copy of the specified image.
If the width and height are provided, the image is resized to the specified size. The image should be
deleted (or in the case of Fl Shared Image, released) when you are done with it.
Reimplemented from Fl Image.

void Fl Shared Image::desaturate ( ) [virtual]


The desaturate() method converts an image to grayscale.
If the image contains an alpha channel (depth = 4), the alpha channel is preserved. This method does
not alter the original image data.
Reimplemented from Fl Image.

void Fl Shared Image::draw ( int X, int Y, int W, int H, int cx, int cy ) [virtual]
Draws the image with a bounding box.
This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image
offset by the cx and cy arguments.
Reimplemented from Fl Image.

Fl Shared Image ∗ Fl Shared Image::get ( const char ∗ n, int W = 0, int H = 0 ) [static]


Find or load an image that can be shared by multiple widgets.
Gets a shared image, if it exists already ; it will return it. If it does not exist or if it exist but with other
size, then the existing image is deleted and replaced by a new image from the n filename of the proper
dimension. If n is not a valid image filename, then get() will return NULL.
Shared JPEG and PNG images can also be created from memory by using their named memory access
constructor.
Parameters
n name of the image
W,H desired size

See Also
Fl Shared Image::find(const char ∗n, int W, int H)
Fl Shared Image::release()
Fl JPEG Image::Fl JPEG Image(const char ∗name, const unsigned char ∗data)
Fl PNG Image::Fl PNG Image (const char ∗name png, const unsigned char ∗buffer, int maxsize)

int Fl Shared Image::num images ( ) [static]


Returns the total number of shared images in the array.
31.124. FL SIMPLE COUNTER CLASS REFERENCE 641

int Fl Shared Image::refcount ( ) [inline]

Returns the number of references of this shared image.


When reference is below 1, the image is deleted.

void Fl Shared Image::release ( )

Releases and possibly destroys (if refcount <=0) a shared image.


In the latter case, it will reorganize the shared image array so that no hole will occur.

void Fl Shared Image::uncache ( ) [virtual]

If the image has been cached for display, delete the cache data.
This allows you to change the data used for the image and then redraw it without recreating an image
object.
Reimplemented from Fl Image.
The documentation for this class was generated from the following files:

• Fl Shared Image.H
• Fl Shared Image.cxx

31.124 Fl Simple Counter Class Reference


This widget creates a counter with only 2 arrow buttons.
#include <Fl Simple Counter.H>
Inheritance diagram for Fl Simple Counter:

Fl_Widget

Fl_Valuator

Fl_Counter

Fl_Simple_Counter

Public Member Functions


• Fl Simple Counter (int X, int Y, int W, int H, const char ∗L=0)

Additional Inherited Members


31.124.1 Detailed Description
This widget creates a counter with only 2 arrow buttons.
642 CHAPTER 31. CLASS DOCUMENTATION

Figure 31.31: Fl Simple Counter

The documentation for this class was generated from the following files:

• Fl Simple Counter.H
• Fl Counter.cxx

31.125 Fl Single Window Class Reference


This is the same as Fl Window.
#include <Fl Single Window.H>
Inheritance diagram for Fl Single Window:

Fl_Widget

Fl_Group

Fl_Window

Fl_Single_Window

Fl_Menu_Window

Public Member Functions


• Fl Single Window (int W, int H, const char ∗l=0)
Creates a new Fl Single Window widget using the given size, and label (title) string.
• Fl Single Window (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Single Window widget using the given position, size, and label (title) string.
• void flush ()
Forces the window to be drawn, this window is also made current and calls draw().
• int make current ()
• void show ()
Puts the window on the screen.
• void show (int a, char ∗∗b)

Additional Inherited Members


31.125.1 Detailed Description
This is the same as Fl Window.
31.126. FL SLIDER CLASS REFERENCE 643

However, it is possible that some implementations will provide double-buffered windows by default.
This subcan be used to force single-buffering. This may be useful for modifying existing programs that use
incremental update, or for some types of image data, such as a movie flipbook.

31.125.2 Member Function Documentation


void Fl Single Window::flush ( ) [virtual]
Forces the window to be drawn, this window is also made current and calls draw().
Reimplemented from Fl Window.

void Fl Single Window::show ( ) [virtual]


Puts the window on the screen.
Usually (on X) this has the side effect of opening the display.
If the window is already shown then it is restored and raised to the top. This is really convenient
because your program can call show() at any time, even if the window is already up. It also means that
show() serves the purpose of raise() in other toolkits.
Fl Window::show(int argc, char ∗∗argv) is used for top-level windows and allows standard arguments
to be parsed from the command-line.

See Also
Fl Window::show(int argc, char ∗∗argv)

Reimplemented from Fl Window.


The documentation for this class was generated from the following files:

• Fl Single Window.H
• Fl Single Window.cxx

31.126 Fl Slider Class Reference


The Fl Slider widget contains a sliding knob inside a box.
#include <Fl Slider.H>
Inheritance diagram for Fl Slider:

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Fill_Slider Fl_Hor_Fill_Slider Fl_Hor_Nice_Slider Fl_Hor_Slider Fl_Nice_Slider Fl_Scrollbar Fl_Value_Slider

Fl_Hor_Value_Slider

Public Member Functions


• void bounds (double a, double b)
Sets the minimum (a) and maximum (b) values for the valuator widget.
• Fl Slider (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Slider widget using the given position, size, and label string.
• Fl Slider (uchar t, int X, int Y, int W, int H, const char ∗L)
Creates a new Fl Slider widget using the given type, position, size, and label string.
644 CHAPTER 31. CLASS DOCUMENTATION

• int handle (int)


Handles the specified event.
• int scrollvalue (int pos, int size, int first, int total)
Sets the size and position of the sliding knob in the box.
• Fl Boxtype slider () const
Gets the slider box type.
• void slider (Fl Boxtype c)
Sets the slider box type.
• float slider size () const
Get the dimensions of the moving piece of slider.
• void slider size (double v)
Set the dimensions of the moving piece of slider.

Protected Member Functions


• void draw (int, int, int, int)
• void draw ()
Draws the widget.
• int handle (int, int, int, int, int)

Additional Inherited Members


31.126.1 Detailed Description
The Fl Slider widget contains a sliding knob inside a box.
It is often used as a scrollbar. Moving the box all the way to the top/left sets it to the minimum(), and
to the bottom/right to the maximum(). The minimum() may be greater than the maximum() to reverse the
slider direction.
Use void Fl Widget::type(int) to set how the slider is drawn, which can be one of the following:

• FL VERTICAL - Draws a vertical slider (this is the default).

• FL HORIZONTAL - Draws a horizontal slider.

• FL VERT FILL SLIDER - Draws a filled vertical slider, useful as a progress or value meter.

• FL HOR FILL SLIDER - Draws a filled horizontal slider, useful as a progress or value meter.

• FL VERT NICE SLIDER - Draws a vertical slider with a nice looking control knob.

• FL HOR NICE SLIDER - Draws a horizontal slider with a nice looking control knob.

Figure 31.32: Fl Slider


31.126. FL SLIDER CLASS REFERENCE 645

31.126.2 Constructor & Destructor Documentation


Fl Slider::Fl Slider ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Slider widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.

31.126.3 Member Function Documentation


void Fl Slider::bounds ( double a, double b )
Sets the minimum (a) and maximum (b) values for the valuator widget.
if at least one of the values is changed, a partial redraw is asked.

void Fl Slider::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.
Reimplemented in Fl Value Slider.

int Fl Slider::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.


Reimplemented in Fl Value Slider.

int Fl Slider::scrollvalue ( int pos, int size, int first, int total )
Sets the size and position of the sliding knob in the box.
646 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in pos position of first line displayed
in size size of window in lines
in first number of first line
in total total number of lines Returns Fl Valuator::value(p)

Fl Boxtype Fl Slider::slider ( ) const [inline]


Gets the slider box type.

void Fl Slider::slider ( Fl Boxtype c ) [inline]


Sets the slider box type.

void Fl Slider::slider size ( double v )


Set the dimensions of the moving piece of slider.
This is the fraction of the size of the entire widget. If you set this to 1 then the slider cannot move. The
default value is .08.
For the ”fill” sliders this is the size of the area around the end that causes a drag effect rather than
causing the slider to jump to the mouse.
The documentation for this class was generated from the following files:

• Fl Slider.H
• Fl Slider.cxx

31.127 Fl Spinner Class Reference


This widget is a combination of the input widget and repeat buttons.
#include <Fl Spinner.H>
Inheritance diagram for Fl Spinner:

Fl_Widget

Fl_Group

Fl_Spinner

Public Member Functions


• void color (Fl Color v)
Change the background color of the spinner widget’s input field.
• Fl Color color () const
Return the background color of the spinner widget’s input field.
• Fl Spinner (int X, int Y, int W, int H, const char ∗L=0)
Creates a new Fl Spinner widget using the given position, size, and label string.
• const char ∗ format ()
Sets or returns the format string for the value.
31.127. FL SPINNER CLASS REFERENCE 647

• void format (const char ∗f)


Sets or returns the format string for the value.
• int handle (int event)
Handles the specified event.
• double maximum () const
Gets the maximum value of the widget.
• void maximum (double m)
Sets the maximum value of the widget.
• double maxinum () const
Speling mistakes retained for source compatibility.
• double minimum () const
Gets the minimum value of the widget.
• void minimum (double m)
Sets the minimum value of the widget.
• double mininum () const
Speling mistakes retained for source compatibility.
• void range (double a, double b)
Sets the minimum and maximum values for the widget.
• void resize (int X, int Y, int W, int H)
Resizes the Fl Group widget and all of its children.
• void selection color (Fl Color val)
Change the selection color of the spinner widget’s input field.
• Fl Color selection color () const
Return the selection color of the spinner widget’s input field.
• double step () const
Sets or returns the amount to change the value when the user clicks a button.
• void step (double s)
See double Fl Spinner::step() const.
• Fl Color textcolor () const
Gets the color of the text in the input field.
• void textcolor (Fl Color c)
Sets the color of the text in the input field.
• Fl Font textfont () const
Gets the font of the text in the input field.
• void textfont (Fl Font f)
Sets the font of the text in the input field.
• Fl Fontsize textsize () const
Gets the size of the text in the input field.
• void textsize (Fl Fontsize s)
Sets the size of the text in the input field.
• uchar type () const
Gets the numeric representation in the input field.
• void type (uchar v)
Sets the numeric representation in the input field.
• double value () const
Gets the current value of the widget.
• void value (double v)
Sets the current value of the widget.
648 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.127.1 Detailed Description
This widget is a combination of the input widget and repeat buttons.
The user can either type into the input area or use the buttons to change the value.

Figure 31.33: Fl Spinner widget

31.127.2 Constructor & Destructor Documentation


Fl Spinner::Fl Spinner ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Spinner widget using the given position, size, and label string.
Inherited destructor Destroys the widget and any value associated with it.

31.127.3 Member Function Documentation


const char∗ Fl Spinner::format ( ) [inline]
Sets or returns the format string for the value.

void Fl Spinner::format ( const char ∗ f ) [inline]


Sets or returns the format string for the value.

int Fl Spinner::handle ( int event ) [inline], [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
31.127. FL SPINNER CLASS REFERENCE 649

1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Group.

double Fl Spinner::maximum ( ) const [inline]


Gets the maximum value of the widget.

void Fl Spinner::maximum ( double m ) [inline]


Sets the maximum value of the widget.

double Fl Spinner::maxinum ( ) const [inline]


Speling mistakes retained for source compatibility.

Deprecated

double Fl Spinner::minimum ( ) const [inline]


Gets the minimum value of the widget.

void Fl Spinner::minimum ( double m ) [inline]


Sets the minimum value of the widget.

double Fl Spinner::mininum ( ) const [inline]


Speling mistakes retained for source compatibility.

Deprecated

void Fl Spinner::range ( double a, double b ) [inline]


Sets the minimum and maximum values for the widget.

void Fl Spinner::resize ( int X, int Y, int W, int H ) [inline], [virtual]


Resizes the Fl Group widget and all of its children.
The Fl Group widget first resizes itself, and then it moves and resizes all its children according to the
rules documented for Fl Group::resizable(Fl Widget∗)

See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)

Reimplemented from Fl Group.


650 CHAPTER 31. CLASS DOCUMENTATION

double Fl Spinner::step ( ) const [inline]


Sets or returns the amount to change the value when the user clicks a button.
Before setting step to a non-integer value, the spinner type() should be changed to floating point.

Fl Color Fl Spinner::textcolor ( ) const [inline]


Gets the color of the text in the input field.

void Fl Spinner::textcolor ( Fl Color c ) [inline]


Sets the color of the text in the input field.

Fl Font Fl Spinner::textfont ( ) const [inline]


Gets the font of the text in the input field.

void Fl Spinner::textfont ( Fl Font f ) [inline]


Sets the font of the text in the input field.

Fl Fontsize Fl Spinner::textsize ( ) const [inline]


Gets the size of the text in the input field.

void Fl Spinner::textsize ( Fl Fontsize s ) [inline]


Sets the size of the text in the input field.

uchar Fl Spinner::type ( ) const [inline]


Gets the numeric representation in the input field.
See Also
Fl Spinner::type(uchar)

void Fl Spinner::type ( uchar v ) [inline]


Sets the numeric representation in the input field.
Valid values are FL INT INPUT and FL FLOAT INPUT. Also changes the format() template. Setting
a new spinner type via a superclass pointer will not work.
Note
type is not a virtual function.

double Fl Spinner::value ( ) const [inline]


Gets the current value of the widget.

void Fl Spinner::value ( double v ) [inline]


Sets the current value of the widget.
Before setting value to a non-integer value, the spinner type() should be changed to floating point.
The documentation for this class was generated from the following files:
• Fl Spinner.H
• Fl Group.cxx
31.128. FL SURFACE DEVICE CLASS REFERENCE 651

31.128 Fl Surface Device Class Reference


A surface that’s susceptible to receive graphical output.
#include <Fl Device.H>
Inheritance diagram for Fl Surface Device:

Fl_Device

Fl_Surface_Device

Fl_Copy_Surface Fl_Display_Device Fl_Image_Surface Fl_Paged_Device

Fl_PostScript_File_Device Fl_Printer Fl_System_Printer

Fl_PostScript_Printer

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void driver (Fl Graphics Driver ∗graphics driver)
Sets the graphics driver of this drawing surface.
• Fl Graphics Driver ∗ driver ()
Returns the graphics driver of this drawing surface.
• virtual void set current (void)
Use this drawing surface for future graphics requests.
• virtual ∼Fl Surface Device ()
The destructor.

Static Public Member Functions


• static Fl Surface Device ∗ surface ()
the surface that currently receives graphics output

Static Public Attributes


• static const char ∗ class id = ”Fl Surface Device”

Protected Member Functions


• Fl Surface Device (Fl Graphics Driver ∗graphics driver)
Constructor that sets the graphics driver to use for the created surface.

31.128.1 Detailed Description


A surface that’s susceptible to receive graphical output.

31.128.2 Constructor & Destructor Documentation


Fl Surface Device::Fl Surface Device ( Fl Graphics Driver ∗ graphics driver ) [inline],
[protected]
Constructor that sets the graphics driver to use for the created surface.
652 CHAPTER 31. CLASS DOCUMENTATION

virtual Fl Surface Device::∼Fl Surface Device ( ) [inline], [virtual]


The destructor.

31.128.3 Member Function Documentation


const char∗ Fl Surface Device::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:

if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Device.


Reimplemented in Fl Display Device, Fl PostScript File Device, Fl Printer, Fl Paged Device, Fl -
PostScript Printer, Fl System Printer, and Fl Image Surface.

void Fl Surface Device::driver ( Fl Graphics Driver ∗ graphics driver ) [inline]


Sets the graphics driver of this drawing surface.

Fl Graphics Driver∗ Fl Surface Device::driver ( void ) [inline]


Returns the graphics driver of this drawing surface.

void Fl Surface Device::set current ( void ) [virtual]


Use this drawing surface for future graphics requests.
Reimplemented in Fl Printer, Fl Copy Surface, and Fl Image Surface.
The documentation for this class was generated from the following files:

• Fl Device.H
• Fl Device.cxx

31.129 Fl Sys Menu Bar Class Reference


A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the
screen.
#include <Fl Sys Menu Bar.H>
Inheritance diagram for Fl Sys Menu Bar:

Fl_Widget

Fl_Menu_

Fl_Menu_Bar

Fl_Sys_Menu_Bar
31.129. FL SYS MENU BAR CLASS REFERENCE 653

Public Member Functions


• int add (const char ∗label, int shortcut, Fl Callback ∗, void ∗user data=0, int flags=0)
add to the system menu bar a new menu item
• int add (const char ∗label, const char ∗shortcut, Fl Callback ∗cb, void ∗user data=0, int flags=0)
Adds a new menu item.
• int add (const char ∗str)
Forms-compatible procedure to add items to the system menu bar.
• void clear ()
Set the Fl Menu Item array pointer to null, indicating a zero-length menu.
• int clear submenu (int index)
Clears the specified submenu pointed to by index of all menu items.
• Fl Sys Menu Bar (int x, int y, int w, int h, const char ∗l=0)
The constructor.
• void global ()
Make the shortcuts for this menu work no matter what window has the focus when you type it.
• int insert (int index, const char ∗label, int shortcut, Fl Callback ∗cb, void ∗user data=0, int flags=0)
insert in the system menu bar a new menu item
• int insert (int index, const char ∗label, const char ∗shortcut, Fl Callback ∗cb, void ∗user data=0, int
flags=0)
Insert a new menu item.
• const Fl Menu Item ∗ menu () const
Return the system menu’s array of Fl Menu Item’s.
• void menu (const Fl Menu Item ∗m)
create a system menu bar using the given list of menu structs
• void mode (int i, int fl)
Sets the flags of item i.
• int mode (int i) const
Gets the flags of item i.
• void remove (int n)
remove an item from the system menu bar
• void replace (int rank, const char ∗name)
rename an item from the system menu bar
• void shortcut (int i, int s)
Changes the shortcut of item i to n.
• ∼Fl Sys Menu Bar ()
The destructor.

Protected Member Functions


• void draw ()
Draws the widget.
• void update ()
Updates the system menu after any change to its items.
654 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.129.1 Detailed Description
A class to create, modify and delete menus that appear on Mac OS X in the menu bar at the top of the
screen.
On other than Mac OS X platforms, Fl Sys Menu Bar is a synonym of class Fl Menu Bar.
To use this class, just replace Fl Menu Bar by Fl Sys Menu Bar, and, on the Mac platform, a system
menu at the top of the screen will be available. This menu will match an array of Fl Menu Item’s exactly
as with standard FLTK menus.
A few FLTK features are not supported by the Mac System menu:

• no symbolic labels

• no embossed labels

• no font sizes

You can configure a callback for the ’About’ menu item to invoke your own code with fl mac set about().

31.129.2 Constructor & Destructor Documentation


Fl Sys Menu Bar::Fl Sys Menu Bar ( int x, int y, int w, int h, const char ∗ l = 0 )
The constructor.
On Mac OS X, all arguments are unused. On other platforms they are used as by Fl Menu Bar::Fl -
Menu Bar().

31.129.3 Member Function Documentation


int Fl Sys Menu Bar::add ( const char ∗ label, int shortcut, Fl Callback ∗ cb, void ∗ user data = 0,
int flags = 0 )
add to the system menu bar a new menu item
add to the system menu bar a new menu item, with a title string, shortcut int, callback, argument to the
callback, and flags.

See Also
Fl Menu ::add(const char∗ label, int shortcut, Fl Callback ∗cb, void ∗user data, int flags)

int Fl Sys Menu Bar::add ( const char ∗ label, const char ∗ shortcut, Fl Callback ∗ cb, void ∗
user data = 0, int flags = 0 ) [inline]
Adds a new menu item.
See Also
Fl Menu ::add(const char∗ label, int shortcut, Fl Callback∗, void ∗user data=0, int flags=0)

int Fl Sys Menu Bar::add ( const char ∗ str )


Forms-compatible procedure to add items to the system menu bar.

See Also
Fl Menu ::add(const char∗ str)
31.129. FL SYS MENU BAR CLASS REFERENCE 655

void Fl Sys Menu Bar::clear ( )


Set the Fl Menu Item array pointer to null, indicating a zero-length menu.
See Also
Fl Menu ::clear()

int Fl Sys Menu Bar::clear submenu ( int index )


Clears the specified submenu pointed to by index of all menu items.
See Also
Fl Menu ::clear submenu(int index)

void Fl Sys Menu Bar::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Menu Bar.

int Fl Sys Menu Bar::insert ( int index, const char ∗ label, int shortcut, Fl Callback ∗ cb, void ∗
user data = 0, int flags = 0 )
insert in the system menu bar a new menu item
insert in the system menu bar a new menu item, with a title string, shortcut int, callback, argument to
the callback, and flags.
See Also
Fl Menu ::insert(int index, const char∗ label, int shortcut, Fl Callback ∗cb, void ∗user data, int flags)

int Fl Sys Menu Bar::insert ( int index, const char ∗ label, const char ∗ shortcut, Fl Callback ∗ cb,
void ∗ user data = 0, int flags = 0 ) [inline]
Insert a new menu item.
See Also
Fl Menu ::insert(int index, const char∗ label, const char∗ shortcut, Fl Callback ∗cb, void ∗user -
data=0, int flags=0)

void Fl Sys Menu Bar::menu ( const Fl Menu Item ∗ m )


create a system menu bar using the given list of menu structs
Author
Matthias Melcher
656 CHAPTER 31. CLASS DOCUMENTATION

Parameters
m list of Fl Menu Item

void Fl Sys Menu Bar::mode ( int i, int fl ) [inline]


Sets the flags of item i.
See Also
Fl Menu ::mode(int i, int fl)

void Fl Sys Menu Bar::remove ( int rank )


remove an item from the system menu bar
Parameters
rank the rank of the item to remove

void Fl Sys Menu Bar::replace ( int rank, const char ∗ name )


rename an item from the system menu bar
Parameters
rank the rank of the item to rename
name the new item name as a UTF8 string
The documentation for this class was generated from the following files:
• Fl Sys Menu Bar.H
• Fl Sys Menu Bar.mm

31.130 Fl System Printer Class Reference


Print support under MSWindows and Mac OS.
#include <Fl Printer.H>
Inheritance diagram for Fl System Printer:

Fl_Device

Fl_Surface_Device

Fl_Paged_Device

Fl_System_Printer

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void end job (void)
31.130. FL SYSTEM PRINTER CLASS REFERENCE 657

To be called at the end of a print job.


• int end page (void)
To be called at the end of each page.
• void margins (int ∗left, int ∗top, int ∗right, int ∗bottom)
Computes the dimensions of margins that lie between the printable page area and the full page.
• void origin (int ∗x, int ∗y)
Computes the page coordinates of the current origin of graphics functions.
• void origin (int x, int y)
Sets the position in page coordinates of the origin of graphics functions.
• int printable rect (int ∗w, int ∗h)
Computes the width and height of the printable area of the page.
• void rotate (float angle)
Rotates the graphics operations relatively to paper.
• void scale (float scale x, float scale y=0.)
Changes the scaling of page coordinates.
• int start job (int pagecount, int ∗frompage=NULL, int ∗topage=NULL)
Starts a print job.
• int start page (void)
Starts a new printed page.
• void translate (int x, int y)
Translates the current graphics origin accounting for the current rotation.
• void untranslate (void)
Undoes the effect of a previous translate() call.
• ∼Fl System Printer (void)
The destructor.

Static Public Attributes


• static const char ∗ class id = Fl Printer::class id

Protected Member Functions


• Fl System Printer (void)
The constructor.

Friends
• class Fl Printer

Additional Inherited Members


31.130.1 Detailed Description
Print support under MSWindows and Mac OS.
Class Fl System Printer is implemented only on the MSWindows and Mac OS platforms. It has no
public constructor. Use Fl Printer instead that is cross-platform and has the same API.
658 CHAPTER 31. CLASS DOCUMENTATION

31.130.2 Member Function Documentation


const char∗ Fl System Printer::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Paged Device.

int Fl System Printer::end page ( void ) [virtual]


To be called at the end of each page.
Returns
0 if OK, non-zero if any error.

Reimplemented from Fl Paged Device.

void Fl System Printer::margins ( int ∗ left, int ∗ top, int ∗ right, int ∗ bottom ) [virtual]
Computes the dimensions of margins that lie between the printable page area and the full page.
Values are in the same unit as that used by FLTK drawing functions. They are changed by scale() calls.
Parameters
out left If non-null, ∗left is set to the left margin size.
out top If non-null, ∗top is set to the top margin size.
out right If non-null, ∗right is set to the right margin size.
out bottom If non-null, ∗bottom is set to the bottom margin size.
Reimplemented from Fl Paged Device.

void Fl System Printer::origin ( int ∗ x, int ∗ y ) [virtual]


Computes the page coordinates of the current origin of graphics functions.
Parameters
out x If non-null, ∗x is set to the horizontal page offset of graphics origin.
out y Same as above, vertically.
Reimplemented from Fl Paged Device.

void Fl System Printer::origin ( int x, int y ) [virtual]


Sets the position in page coordinates of the origin of graphics functions.
Arguments should be expressed relatively to the result of a previous printable rect() call. That is,
printable rect(&w, &h); origin(w/2, 0); sets the graphics origin at the top center of the
page printable area. Origin() calls are not affected by rotate() calls. Successive origin() calls don’t combine
their effects.
Parameters
in x Horizontal position in page coordinates of the desired origin of graphics
functions.
31.130. FL SYSTEM PRINTER CLASS REFERENCE 659

in y Same as above, vertically.


Reimplemented from Fl Paged Device.

int Fl System Printer::printable rect ( int ∗ w, int ∗ h ) [virtual]

Computes the width and height of the printable area of the page.
Values are in the same unit as that used by FLTK drawing functions, are unchanged by calls to origin(),
but are changed by scale() calls. Values account for the user-selected paper type and print orientation.

Returns
0 if OK, non-zero if any error

Reimplemented from Fl Paged Device.

void Fl System Printer::rotate ( float angle ) [virtual]

Rotates the graphics operations relatively to paper.


The rotation is centered on the current graphics origin. Successive rotate() calls don’t combine their
effects.
Parameters
angle Rotation angle in counter-clockwise degrees.
Reimplemented from Fl Paged Device.

void Fl System Printer::scale ( float scale x, float scale y = 0. ) [virtual]

Changes the scaling of page coordinates.


This function also resets the origin of graphics functions at top left of printable page area. After a
scale() call, do a printable rect() call to get the new dimensions of the printable page area. Successive
scale() calls don’t combine their effects.
Parameters
scale x Horizontal dimensions of plot are multiplied by this quantity.
scale y Same as above, vertically. The value 0. is equivalent to setting scale y = scale x.
Thus, scale(factor); is equivalent to scale(factor, factor);
Reimplemented from Fl Paged Device.

int Fl System Printer::start job ( int pagecount, int ∗ frompage = NULL, int ∗ topage = NULL )
[virtual]

Starts a print job.


Parameters
in pagecount the total number of pages of the job
out frompage if non-null, ∗frompage is set to the first page the user wants printed
out topage if non-null, ∗topage is set to the last page the user wants printed

Returns
0 if OK, non-zero if any error

Reimplemented from Fl Paged Device.


660 CHAPTER 31. CLASS DOCUMENTATION

int Fl System Printer::start page ( void ) [virtual]


Starts a new printed page.
The page coordinates are initially in points, i.e., 1/72 inch, and with origin at the top left of the printable
page area.

Returns
0 if OK, non-zero if any error

Reimplemented from Fl Paged Device.

void Fl System Printer::translate ( int x, int y ) [virtual]


Translates the current graphics origin accounting for the current rotation.
This function is only useful after a rotate() call. Each translate() call must be matched by an untrans-
late() call. Successive translate() calls add up their effects.
Reimplemented from Fl Paged Device.
The documentation for this class was generated from the following files:

• Fl Printer.H
• Fl Printer.cxx

31.131 Fl Table Class Reference


A table of widgets or other content.
#include <Fl Table.H>
Inheritance diagram for Fl Table:

Fl_Widget

Fl_Group

Fl_Table

Fl_Table_Row

Public Types
• enum TableContext {
CONTEXT NONE = 0, CONTEXT STARTPAGE = 0x01, CONTEXT ENDPAGE = 0x02, CON-
TEXT ROW HEADER = 0x04,
CONTEXT COL HEADER = 0x08, CONTEXT CELL = 0x10, CONTEXT TABLE = 0x20, CO-
NTEXT RC RESIZE = 0x40 }
The context bit flags for Fl Table related callbacks (eg.

Public Member Functions


• void add (Fl Widget &wgt)
• void add (Fl Widget ∗wgt)
• Fl Widget ∗const ∗ array ()
31.131. FL TABLE CLASS REFERENCE 661

• void begin ()
• void callback (Fl Widget ∗, void ∗)
Callbacks will be called depending on the setting of Fl Widget::when().
• int callback col ()
Returns the current column the event occurred on.
• TableContext callback context ()
Returns the current ’table context’.
• int callback row ()
Returns the current row the event occurred on.
• Fl Widget ∗ child (int n) const
Returns the child widget by an index.
• int children () const
Returns the number of children in the table.
• virtual void clear ()
Clears the table to zero rows (rows(0)), zero columns (cols(0)), and clears any widgets (table->clear()) that
were added with begin()/end() or add()/insert()/etc.
• int col header ()
Returns if column headers are enabled or not.
• void col header (int flag)
Enable or disable column headers.
• void col header color (Fl Color val)
Sets the color for column headers and redraws the table.
• Fl Color col header color ()
Gets the color for column headers.
• void col header height (int height)
Sets the height in pixels for column headers and redraws the table.
• int col header height ()
Gets the column header height.
• void col position (int col)
Sets the column scroll position to column ’col’, and causes the screen to redraw.
• int col position ()
Returns the current column scroll position as a column number.
• int col resize ()
Returns the current value of this flag.
• void col resize (int flag)
Allows/disallows column resizing by the user.
• int col resize min ()
Sets the current column minimum resize value.
• void col resize min (int val)
Returns the current column minimum resize value.
• void col width (int col, int width)
Sets the width of the specified column in pixels, and the table is redrawn.
• int col width (int col)
Returns the current width of the specified column in pixels.
• void col width all (int width)
Convenience method to set the width of all columns to the same value, in pixels.
• virtual void cols (int val)
662 CHAPTER 31. CLASS DOCUMENTATION

Set the number of columns in the table and redraw.


• int cols ()
Get the number of columns in the table.
• void do callback (TableContext context, int row, int col)
• void draw (void)
Draws the widget.
• void end ()
• int find (const Fl Widget ∗wgt) const
• int find (const Fl Widget &wgt) const
• Fl Table (int X, int Y, int W, int H, const char ∗l=0)
The constructor for the Fl Table.
• void get selection (int &row top, int &col left, int &row bot, int &col right)
Gets the region of cells selected (highlighted).
• void init sizes ()
• void insert (Fl Widget &wgt, int n)
• void insert (Fl Widget &wgt, Fl Widget ∗w2)
• int is interactive resize ()
Returns 1 if someone is interactively resizing a row or column.
• int is selected (int r, int c)
See if the cell at row r and column c is selected.
• int move cursor (int R, int C, int shiftselect)
• int move cursor (int R, int C)
• void remove (Fl Widget &wgt)
• void resize (int X, int Y, int W, int H)
Changes the size of the Fl Table, causing it to redraw.
• int row header ()
Returns the value of this flag.
• void row header (int flag)
Enables/disables showing the row headers.
• void row header color (Fl Color val)
Sets the row header color and causes the screen to redraw.
• Fl Color row header color ()
Returns the current row header color.
• void row header width (int width)
Sets the row header width to n and causes the screen to redraw.
• int row header width ()
Returns the current row header width (in pixels).
• void row height (int row, int height)
Sets the height of the specified row in pixels, and the table is redrawn.
• int row height (int row)
Returns the current height of the specified row as a value in pixels.
• void row height all (int height)
Convenience method to set the height of all rows to the same value, in pixels.
• void row position (int row)
Sets the row scroll position to ’row’, and causes the screen to redraw.
• int row position ()
Returns the current row scroll position as a row number.
31.131. FL TABLE CLASS REFERENCE 663

• int row resize ()


Returns the current value of this flag.
• void row resize (int flag)
Allows/disallows row resizing by the user.
• int row resize min ()
Returns the current row minimum resize value.
• void row resize min (int val)
Sets the current row minimum resize value.
• virtual void rows (int val)
Sets the number of rows in the table, and the table is redrawn.
• int rows ()
Returns the number of rows in the table.
• void set selection (int row top, int col left, int row bot, int col right)
Sets the region of cells to be selected (highlighted).
• void table box (Fl Boxtype val)
Sets the kind of box drawn around the data table, the default being FL NO BOX.
• Fl Boxtype table box (void)
Returns the current box type used for the data table.
• void top row (int row)
Sets which row should be at the top of the table, scrolling as necessary, and the table is redrawn.
• int top row ()
Returns the current top row shown in the table.
• void visible cells (int &r1, int &r2, int &c1, int &c2)
Returns the range of row and column numbers for all visible and partially visible cells in the table.
• void when (Fl When flags)
The Fl Widget::when() function is used to set a group of flags, determining when the widget callback is
called:
• ∼Fl Table ()
The destructor for the Fl Table.

Protected Types
• enum ResizeFlag {
RESIZE NONE = 0, RESIZE COL LEFT = 1, RESIZE COL RIGHT = 2, RESIZE ROW A-
BOVE = 3,
RESIZE ROW BELOW = 4 }

Protected Member Functions


• void change cursor (Fl Cursor newcursor)
• long col scroll position (int col)
• TableContext cursor2rowcol (int &R, int &C, ResizeFlag &resizeflag)
• void damage zone (int r1, int c1, int r2, int c2, int r3=0, int c3=0)
• virtual void draw cell (TableContext context, int R=0, int C=0, int X=0, int Y=0, int W=0, int H=0)
Subclass should override this method to handle drawing the cells.
• int find cell (TableContext context, int R, int C, int &X, int &Y, int &W, int &H)
• void get bounds (TableContext context, int &X, int &Y, int &W, int &H)
• int handle (int e)
Handles the specified event.
664 CHAPTER 31. CLASS DOCUMENTATION

• int is fltk container ()


• void recalc dimensions ()
• void redraw range (int topRow, int botRow, int leftCol, int rightCol)
• int row col clamp (TableContext context, int &R, int &C)
• long row scroll position (int row)
• void table resized ()
• void table scrolled ()

Static Protected Member Functions


• static void scroll cb (Fl Widget ∗, void ∗)

Protected Attributes
• int botrow
• int current col
• int current row
• Fl Scrollbar ∗ hscrollbar
• int leftcol
• int leftcol scrollpos
• int rightcol
• int select col
• int select row
• Fl Scroll ∗ table
• int table h
• int table w
• int tih
• int tiw
• int tix
• int tiy
• int toh
• int toprow
• int toprow scrollpos
• int tow
• int tox
• int toy
• Fl Scrollbar ∗ vscrollbar
• int wih
• int wiw
• int wix
• int wiy

Additional Inherited Members


31.131.1 Detailed Description
A table of widgets or other content.
This is the base class for table widgets.
To be useful it must be subclassed and several virtual functions defined. Normally applications use
widgets derived from this widget, and do not use this widget directly; this widget is usually too low level
to be used directly by applications.
This widget does not handle the data in the table. The draw cell() method must be overridden by a
subclass to manage drawing the contents of the cells.
This widget can be used in several ways:
31.131. FL TABLE CLASS REFERENCE 665

• As a custom widget; see examples/table-simple.cxx and test/table.cxx. Very optimal for even ex-
tremely large tables.

• As a table made up of a single FLTK widget instanced all over the table, simulating a numeric spread-
sheet. See examples/table-spreadsheet.cxx and examples/table-spreadsheet-with-keyboard-nav.cxx.
Optimal for large tables.

• As a regular container of FLTK widgets, one widget per cell. See examples/table-as-container.cxx.
Not recommended for large tables.

Figure 31.34: table-simple example

Figure 31.35: table-as-container example

When acting as part of a custom widget, events on the cells and/or headings generate callbacks when
they are clicked by the user. You control when events are generated based on the setting for Fl Table-
::when().
When acting as a container for FLTK widgets, the FLTK widgets maintain themselves. Although
the draw cell() method must be overridden, its contents can be very simple. See the draw cell() code in
examples/table-simple.cxx.
The following variables are available to classes deriving from Fl Table:
666 CHAPTER 31. CLASS DOCUMENTATION

Figure 31.36: Fl Table Dimensions

x()/y()/w()/h() Fl Table widget’s outer dimension. The outer


edge of the border of the Fl Table. (Red in the
diagram above)

wix/wiy/wiw/wih Fl Table widget’s inner dimension. The inner


edge of the border of the Fl Table. eg. if the
Fl Table’s box() is FL NO BOX, these values are
the same as x()/y()/w()/h(). (Yellow in the
diagram above)

tox/toy/tow/toh The table’s outer dimension. The outer edge of


the border around the cells, but inside the row/col
headings and scrollbars. (Green in the diagram
above)

tix/tiy/tiw/tih The table’s inner dimension. The inner edge of


the border around the cells, but inside the row/col
headings and scrollbars. AKA the table’s clip
region. eg. if the table box() is FL NO BOX,
these values are the same as tox/toyy/tow/toh.
(Blue in the diagram above)
CORE DEVELOPERS

• Greg Ercolano : 12/16/2002 - initial implementation 12/16/02. Fl Table, Fl Table Row, docs.
• Jean-Marc Lienher : 02/22/2004 - added keyboard nav + mouse selection, and ported Fl Table into
fltk-utf8-1.1.4

OTHER CONTRIBUTORS

• Inspired by the Feb 2000 version of FLVW’s Flvw Table widget. Mucho thanks to those folks.
• Mister Satan : 04/07/2003 - MinGW porting mods, and singleinput.cxx; a cool Fl Input oriented
spreadsheet example
• Marek Paliwoda : 01/08/2003 - Porting mods for Borland
31.131. FL TABLE CLASS REFERENCE 667

• Ori Berger : 03/16/2006 - Optimizations for >500k rows/cols

LICENSE
Greg added the following license to the original distribution of Fl Table. He kindly gave his permission
to integrate Fl Table and Fl Table Row into FLTK, allowing FLTK license to apply while his widgets are
part of the library.
If used on its own, this is the license that applies:
Fl_Table License
December 16, 2002

The Fl_Table library and included programs are provided under the terms
of the GNU Library General Public License (LGPL) with the following
exceptions:

1. Modifications to the Fl_Table configure script, config


header file, and makefiles by themselves to support
a specific platform do not constitute a modified or
derivative work.

The authors do request that such modifications be


contributed to the Fl_Table project - send all
contributions to "erco at seriss dot com".

2. Widgets that are subclassed from Fl_Table widgets do not


constitute a derivative work.

3. Static linking of applications and widgets to the


Fl_Table library does not constitute a derivative work
and does not require the author to provide source
code for the application or widget, use the shared
Fl_Table libraries, or link their applications or
widgets against a user-supplied version of Fl_Table.

If you link the application or widget to a modified


version of Fl_Table, then the changes to Fl_Table must be
provided under the terms of the LGPL in sections
1, 2, and 4.

4. You do not have to provide a copy of the Fl_Table license


with programs that are linked to the Fl_Table library, nor
do you have to identify the Fl_Table license in your
program or documentation as required by section 6
of the LGPL.

However, programs must still identify their use of Fl_Table.


The following example statement can be included in user
documentation to satisfy this requirement:

[program/widget] is based in part on the work of


the Fl_Table project http://seriss.com/people/erco/fltk/Fl_Table/

31.131.2 Member Enumeration Documentation


enum Fl Table::TableContext
The context bit flags for Fl Table related callbacks (eg.
draw cell(), callback(), etc)
Enumerator
CONTEXT NONE no known context
CONTEXT STARTPAGE before a page is redrawn
CONTEXT ENDPAGE after a page is redrawn
668 CHAPTER 31. CLASS DOCUMENTATION

CONTEXT ROW HEADER in the row header


CONTEXT COL HEADER in the col header
CONTEXT CELL in one of the cells
CONTEXT TABLE in a dead zone of table
CONTEXT RC RESIZE column or row being resized

31.131.3 Constructor & Destructor Documentation


Fl Table::Fl Table ( int X, int Y, int W, int H, const char ∗ l = 0 )
The constructor for the Fl Table.
This creates an empty table with no rows or columns, with headers and row/column resize behavior
disabled.

Fl Table::∼Fl Table ( )
The destructor for the Fl Table.
Destroys the table and its associated widgets.

31.131.4 Member Function Documentation


void Fl Table::callback ( Fl Widget ∗ , void ∗ )
Callbacks will be called depending on the setting of Fl Widget::when().
Callback functions should use the following functions to determine the context/row/column:
Fl Table::callback row() returns current row Fl Table::callback col() returns current column Fl Table-
::callback context() returns current table context
callback row() and callback col() will be set to the row and column number the event occurred on. If
someone clicked on a row header, col will be 0. If someone clicked on a column header, row will be 0.
callback context() will return one of the following:
Fl Table::CONTEXT ROW HEADER Someone clicked on a row header. Excludes
resizing.
Fl Table::CONTEXT COL HEADER Someone clicked on a column header. Excludes
resizing.
Fl Table::CONTEXT CELL Someone clicked on a cell.
To receive callbacks for FL RELEASE events,
you must set when(FL WHEN RELEASE).
Fl Table::CONTEXT RC RESIZE Someone is resizing rows/columns either
interactively, or via the col width() or
row height() API.
Use is interactive resize() to determine
interactive resizing.
If resizing a column, R=0 and C=column being
resized.
If resizing a row, C=0 and R=row being resized.
NOTE: To receive resize events, you must set
when(FL WHEN CHANGED).
class MyTable : public Fl Table {
[..]
private:
// Handle events that happen on the table
void event callback2() {
int R = callback row(), // row where event occurred
C = callback col(); // column where event occurred
TableContext context = callback context(); // which part of table
fprintf(stderr, "callback: Row=%d Col=%d Context=%d Event=%d\n",
31.131. FL TABLE CLASS REFERENCE 669

R, C, (int)context, (int)Fl::event());
}

// Actual static callback


static void event callback(Fl Widget*, void* data) {
MyTable *o = (MyTable*)data;
o-&gt;event callback2();
}

public:
// Constructor
MyTable() {
[..]
table.callback(&event callback, (void*)this); // setup callback
table.when(FL WHEN CHANGED|FL WHEN RELEASE); // when to call it
}
};

int Fl Table::callback col ( ) [inline]

Returns the current column the event occurred on.


This function should only be used from within the user’s callback function

TableContext Fl Table::callback context ( ) [inline]

Returns the current ’table context’.


This function should only be used from within the user’s callback function

int Fl Table::callback row ( ) [inline]

Returns the current row the event occurred on.


This function should only be used from within the user’s callback function

Fl Widget∗ Fl Table::child ( int n ) const [inline]

Returns the child widget by an index.


When using the Fl Table as a container for FLTK widgets, this method returns the widget pointer from
the internal array of widgets in the container.
Typically used in loops, eg:

for ( int i=0; i<children(); i++ ) {


Fl Widget *w = child(i);
[..]
}

int Fl Table::children ( ) const [inline]

Returns the number of children in the table.


When using the Fl Table as a container for FLTK widgets, this method returns how many child widgets
the table has.

See Also
child(int)
670 CHAPTER 31. CLASS DOCUMENTATION

virtual void Fl Table::clear ( ) [inline], [virtual]

Clears the table to zero rows (rows(0)), zero columns (cols(0)), and clears any widgets (table->clear()) that
were added with begin()/end() or add()/insert()/etc.

See Also
rows(int), cols(int)

Reimplemented in Fl Table Row.

void Fl Table::col header ( int flag ) [inline]

Enable or disable column headers.


If changed, the table is redrawn.

void Fl Table::col resize ( int flag ) [inline]

Allows/disallows column resizing by the user.


1=allow interactive resizing, 0=disallow interactive resizing. Since interactive resizing is done via the
column headers, col header() must also be enabled to allow resizing.

int Fl Table::col resize min ( ) [inline]

Sets the current column minimum resize value.


This is used to prevent the user from interactively resizing any column to be smaller than ’pixels’. Must
be a value >=1.

void Fl Table::col width ( int col, int width )

Sets the width of the specified column in pixels, and the table is redrawn.
callback() will be invoked with CONTEXT RC RESIZE if the column’s width was actually changed,
and when() is FL WHEN CHANGED.

void Fl Table::col width all ( int width ) [inline]

Convenience method to set the width of all columns to the same value, in pixels.
The screen is redrawn.

void Fl Table::draw ( void ) [virtual]

Draws the widget.


Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:

Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar


s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Group.


31.131. FL TABLE CLASS REFERENCE 671

virtual void Fl Table::draw cell ( TableContext context, int R = 0, int C = 0, int X = 0, int Y = 0,
int W = 0, int H = 0 ) [inline], [protected], [virtual]
Subclass should override this method to handle drawing the cells.
This method will be called whenever the table is redrawn, once per cell.
Only cells that are completely (or partially) visible will be told to draw.
context will be one of the following:
672 CHAPTER 31. CLASS DOCUMENTATION

Fl Table::CONTEXT STARTPAGE When table, or parts of the table, are about to be


redrawn.
Use to initialize static data, such as font
selections.
R/C will be zero,
X/Y/W/H will be the dimensions of the table’s
entire data area.
(Useful for locking a database before accessing;
see also visible cells())
Fl Table::CONTEXT ENDPAGE When table has completed being redrawn.
R/C will be zero, X/Y/W/H dimensions of table’s
data area.
(Useful for unlocking a database after accessing)
Fl Table::CONTEXT ROW HEADER Whenever a row header cell needs to be drawn.
R will be the row number of the header being
redrawn,
C will be zero,
X/Y/W/H will be the fltk drawing area of the row
header in the window
Fl Table::CONTEXT COL HEADER Whenever a column header cell needs to be
drawn.
R will be zero,
C will be the column number of the header being
redrawn,
X/Y/W/H will be the fltk drawing area of the
column header in the window
Fl Table::CONTEXT CELL Whenever a data cell in the table needs to be
drawn.
R/C will be the row/column of the cell to be
drawn,
X/Y/W/H will be the fltk drawing area of the cell
in the window
Fl Table::CONTEXT RC RESIZE Whenever table or row/column is resized or
scrolled, either interactively or via col width() or
row height().
R/C/X/Y/W/H will all be zero.
Useful for fltk containers that need to resize or
move the child fltk widgets.
row and col will be set to the row and column number of the cell being drawn. In the case of row
headers, col will be 0. In the case of column headers, row will be 0.
x/y/w/h will be the position and dimensions of where the cell should be drawn.
In the case of custom widgets, a minimal draw cell() override might look like the following. With cus-
tom widgets it is up to the caller to handle drawing everything within the dimensions of the cell, including
handling the selection color. Note all clipping must be handled as well; this allows drawing outside the
dimensions of the cell if so desired for ’custom effects’.

// This is called whenever Fl Table wants you to draw a cell


void MyTable::draw cell(TableContext context, int R=0, int C=0, int X=0, int Y=0, int W=0, int
H=0) {
static char s[40];
sprintf(s, "%d/%d", R, C); // text for each cell
switch ( context ) {
case CONTEXT STARTPAGE: // Fl Table telling us its starting to draw
page
fl font(FL HELVETICA, 16);
return;

case CONTEXT ROW HEADER: // Fl Table telling us it’s draw row/col


31.131. FL TABLE CLASS REFERENCE 673

headers
case CONTEXT COL HEADER:
fl push clip(X, Y, W, H);
{
fl draw box(FL THIN UP BOX, X, Y, W, H,
color());
fl color(FL BLACK);
fl draw(s, X, Y, W, H, FL ALIGN CENTER);
}
fl pop clip();
return;

case CONTEXT CELL: // Fl Table telling us to draw cells


fl push clip(X, Y, W, H);
{
// BG COLOR
fl color( row selected(R) ? selection color() : FL WHITE);
fl rectf(X, Y, W, H);

// TEXT
fl color(FL BLACK);
fl draw(s, X, Y, W, H, FL ALIGN CENTER);

// BORDER
fl color(FL LIGHT2);
fl rect(X, Y, W, H);
}
fl pop clip();
return;

default:
return;
}
//NOTREACHED
}

void Fl Table::get selection ( int & row top, int & col left, int & row bot, int & col right )
Gets the region of cells selected (highlighted).
Parameters
in row top Returns the top row of selection area
in col left Returns the left column of selection area
in row bot Returns the bottom row of selection area
in col right Returns the right column of selection area

int Fl Table::handle ( int event ) [protected], [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
674 CHAPTER 31. CLASS DOCUMENTATION

0 if the event was not used or understood


1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Group.


Reimplemented in Fl Table Row.

int Fl Table::is interactive resize ( ) [inline]


Returns 1 if someone is interactively resizing a row or column.
You can currently call this only from within your callback().

int Fl Table::is selected ( int r, int c )


See if the cell at row r and column c is selected.
Returns
1 if the cell is selected, 0 if not.

void Fl Table::row header ( int flag ) [inline]


Enables/disables showing the row headers.
1=enabled, 0=disabled. If changed, the table is redrawn.

void Fl Table::row height ( int row, int height )


Sets the height of the specified row in pixels, and the table is redrawn.
callback() will be invoked with CONTEXT RC RESIZE if the row’s height was actually changed, and
when() is FL WHEN CHANGED.

void Fl Table::row height all ( int height ) [inline]


Convenience method to set the height of all rows to the same value, in pixels.
The screen is redrawn.

void Fl Table::row resize ( int flag ) [inline]


Allows/disallows row resizing by the user.
1=allow interactive resizing, 0=disallow interactive resizing. Since interactive resizing is done via the
row headers, row header() must also be enabled to allow resizing.

void Fl Table::row resize min ( int val ) [inline]


Sets the current row minimum resize value.
This is used to prevent the user from interactively resizing any row to be smaller than ’pixels’. Must be
a value >=1.

void Fl Table::set selection ( int row top, int col left, int row bot, int col right )
Sets the region of cells to be selected (highlighted).
So for instance, set selection(0,0,0,0) selects the top/left cell in the table. And set selection(0,0,1,1)
selects the four cells in rows 0 and 1, column 0 and 1.
31.131. FL TABLE CLASS REFERENCE 675

Parameters
in row top Top row of selection area
in col left Left column of selection area
in row bot Bottom row of selection area
in col right Right column of selection area

void Fl Table::table box ( Fl Boxtype val ) [inline]

Sets the kind of box drawn around the data table, the default being FL NO BOX.
Changing this value will cause the table to redraw.

void Fl Table::top row ( int row ) [inline]

Sets which row should be at the top of the table, scrolling as necessary, and the table is redrawn.
If the table cannot be scrolled that far, it is scrolled as far as possible.

int Fl Table::top row ( ) [inline]

Returns the current top row shown in the table.


This row may be partially obscured.

void Fl Table::visible cells ( int & r1, int & r2, int & c1, int & c2 ) [inline]

Returns the range of row and column numbers for all visible and partially visible cells in the table.
These values can be used e.g. by your draw cell() routine during CONTEXT STARTPAGE to figure
out what cells are about to be redrawn for the purposes of locking the data from a database before it’s
drawn.

leftcol rightcol
: :
toprow .. .-------------------.
| |
| V I S I B L E |
| |
| T A B L E |
| |
botrow .. ’-------------------‘

e.g. in a table where the visible rows are 5-20, and the visible columns are 100-120, then those variables
would be:

• toprow = 5

• botrow = 20

• leftcol = 100

• rightcol = 120

void Fl Table::when ( Fl When flags )

The Fl Widget::when() function is used to set a group of flags, determining when the widget callback is
called:
676 CHAPTER 31. CLASS DOCUMENTATION

FL WHEN CHANGED callback() will be called when rows or columns


are resized (interactively or via col width() or
row height()), passing CONTEXT RC RESIZE
via callback context().
FL WHEN RELEASE callback() will be called during FL RELEASE
events, such as when someone releases a mouse
button somewhere on the table.
The callback() routine is sent a TableContext that indicates the context the event occurred in, such as in
a cell, in a header, or elsewhere on the table. When an event occurs in a cell or header, callback row() and
callback col() can be used to determine the row and column. The callback can also look at the regular fltk
event values (ie. Fl::event() and Fl::button()) to determine what kind of event is occurring.
The documentation for this class was generated from the following files:

• Fl Table.H
• Fl Table.cxx

31.132 Fl Table Row Class Reference


A table with row selection capabilities.
#include <Fl Table Row.H>
Inheritance diagram for Fl Table Row:

Fl_Widget

Fl_Group

Fl_Table

Fl_Table_Row

Public Types
• enum TableRowSelectMode { SELECT NONE, SELECT SINGLE, SELECT MULTI }

Public Member Functions


• void clear ()
Clears the table to zero rows (rows(0)), zero columns (cols(0)), and clears any widgets (table->clear()) that
were added with begin()/end() or add()/insert()/etc.
• Fl Table Row (int X, int Y, int W, int H, const char ∗l=0)
The constructor for the Fl Table Row.
• int row selected (int row)
Checks to see if ’row’ is selected.
• void rows (int val)
Sets the number of rows in the table, and the table is redrawn.
• int rows ()
• void select all rows (int flag=1)
This convenience function changes the selection state for all rows based on ’flag’.
31.132. FL TABLE ROW CLASS REFERENCE 677

• int select row (int row, int flag=1)


Changes the selection state for ’row’, depending on the value of ’flag’.
• void type (TableRowSelectMode val)
Sets the table selection mode.
• TableRowSelectMode type () const
• ∼Fl Table Row ()
The destructor for the Fl Table Row.

Protected Member Functions


• int find cell (TableContext context, int R, int C, int &X, int &Y, int &W, int &H)
• int handle (int event)
Handles the specified event.

Additional Inherited Members


31.132.1 Detailed Description
A table with row selection capabilities.
This class implements a simple table with the ability to select rows. This widget is similar to an
Fl Browser with columns. Most methods of importance will be found in the Fl Table widget, such as
Fl Table::rows() and Fl Table::cols().
To be useful it must be subclassed and at minimum the draw cell() method must be overridden to
provide the content of the cells. This widget does not manage the cell’s data content; it is up to the parent
class’s draw cell() method override to provide this.
Events on the cells and/or headings generate callbacks when they are clicked by the user. You control
when events are generated based on the values you supply for Fl Table::when().

31.132.2 Constructor & Destructor Documentation


Fl Table Row::Fl Table Row ( int X, int Y, int W, int H, const char ∗ l = 0 ) [inline]
The constructor for the Fl Table Row.
This creates an empty table with no rows or columns, with headers and row/column resize behavior
disabled.

Fl Table Row::∼Fl Table Row ( ) [inline]


The destructor for the Fl Table Row.
Destroys the table and its associated widgets.

31.132.3 Member Function Documentation


void Fl Table Row::clear ( ) [inline], [virtual]
Clears the table to zero rows (rows(0)), zero columns (cols(0)), and clears any widgets (table->clear()) that
were added with begin()/end() or add()/insert()/etc.

See Also
rows(int), cols(int)

Reimplemented from Fl Table.


678 CHAPTER 31. CLASS DOCUMENTATION

int Fl Table Row::handle ( int event ) [protected], [virtual]

Handles the specified event.


You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Table.

int Fl Table Row::row selected ( int row )

Checks to see if ’row’ is selected.


Returns 1 if selected, 0 if not. You can change the selection of a row by clicking on it, or by using
select row(row, flag)

void Fl Table Row::select all rows ( int flag = 1 )

This convenience function changes the selection state for all rows based on ’flag’.
0=deselect, 1=select, 2=toggle existing state.

int Fl Table Row::select row ( int row, int flag = 1 )

Changes the selection state for ’row’, depending on the value of ’flag’.
0=deselected, 1=select, 2=toggle existing state.

void Fl Table Row::type ( TableRowSelectMode val )

Sets the table selection mode.

• Fl Table Row::SELECT NONE - No selection allowed

• Fl Table Row::SELECT SINGLE - Only single rows can be selected

• Fl Table Row::SELECT MULTI - Multiple rows can be selected

The documentation for this class was generated from the following files:

• Fl Table Row.H
• Fl Table Row.cxx
31.133. FL TABS CLASS REFERENCE 679

31.133 Fl Tabs Class Reference


The Fl Tabs widget is the ”file card tabs” interface that allows you to put lots and lots of buttons and
switches in a panel, as popularized by many toolkits.
#include <Fl Tabs.H>
Inheritance diagram for Fl Tabs:

Fl_Widget

Fl_Group

Fl_Tabs

Public Member Functions


• void client area (int &rx, int &ry, int &rw, int &rh, int tabh=0)
Returns the position and size available to be used by its children.
• Fl Tabs (int, int, int, int, const char ∗=0)
Creates a new Fl Tabs widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
• Fl Widget ∗ push () const
Returns the tab group for the tab the user has currently down-clicked on and remains over until FL RELE-
ASE.
• int push (Fl Widget ∗)
This is called by the tab widget’s handle() method to set the tab group widget the user last FL PUSH’ed on.
• Fl Widget ∗ value ()
Gets the currently visible widget/tab.
• int value (Fl Widget ∗)
Sets the widget to become the current visible widget/tab.
• Fl Widget ∗ which (int event x, int event y)
Return the widget of the tab the user clicked on at event x / event y.

Protected Member Functions


• void draw ()
Draws the widget.
• void redraw tabs ()

Additional Inherited Members


31.133.1 Detailed Description
The Fl Tabs widget is the ”file card tabs” interface that allows you to put lots and lots of buttons and
switches in a panel, as popularized by many toolkits.
680 CHAPTER 31. CLASS DOCUMENTATION

Figure 31.37: Fl Tabs

Clicking the tab makes a child visible() by calling show() on it, and all other children are made in-
visible by calling hide() on them. Usually the children are Fl Group widgets containing several widgets
themselves.
Each child makes a card, and its label() is printed on the card tab, including the label font and style. The
selection color of that child is used to color the tab, while the color of the child determines the background
color of the pane.
The size of the tabs is controlled by the bounding box of the children (there should be some space
between the children and the edge of the Fl Tabs), and the tabs may be placed ”inverted” on the bottom
- this is determined by which gap is larger. It is easiest to lay this out in fluid, using the fluid browser to
select each child group and resize them until the tabs look the way you want them to.
The background area behind and to the right of the tabs is ”transparent”, exposing the background
detail of the parent. The value of Fl Tabs::box() does not affect this area. So if Fl Tabs is resized by itself
without the parent, force the appropriate parent (visible behind the tabs) to redraw() to prevent artifacts.
See ”Resizing Caveats” below on how to keep tab heights constant. See ”Callback’s Use Of when()”
on how to control the details of how clicks invoke the callback().
A typical use of the Fl Tabs widget:

// Typical use of Fl Tabs


Fl Tabs *tabs = new Fl Tabs(10,10,300,200);
{
Fl Group *grp1 = new Fl Group(20,30,280,170,"Tab1");
{
..widgets that go in tab#1..
}
grp1->end();
Fl Group *grp2 = new Fl Group(20,30,280,170,"Tab2");
{
..widgets that go in tab#2..
}
grp2->end();
}
tabs->end();

Default Appearance
The appearance of each ”tab” is taken from the label() and color() of the child group corresponding to
that ”tab” and panel. Where the ”tabs” appear depends on the position and size of the child groups that
make up the panels within the Fl Tab, i.e. whether there is more space above or below them. The height of
the ”tabs” depends on how much free space is available.
31.133. FL TABS CLASS REFERENCE 681

Figure 31.38: Fl Tabs Default Appearance

Highlighting The Selected Tab


The selected ”tab” can be highlighted further by setting the selection color() of the Fl Tab itself, e.g.

..
tabs = new Fl Tabs(..);
tabs->selection color(FL DARK3);
..

The result of the above looks like:

Figure 31.39: Highlighting the selected tab

Uniform Tab and Panel Appearance


In order to have uniform tab and panel appearance, not only must the color() and selection color() for
each child group be set, but also the selection color() of the Fl Tab itself any time a new ”tab” is selected.
This can be achieved within the Fl Tab callback, e.g.

void MyTabCallback(Fl Widget *w, void*) {


Fl Tabs *tabs = (Fl Tabs*)w;
// When tab changed, make sure it has same color as its group
tabs->selection color( (tab->value())->color() );
}
..
int main(..) {
// Define tabs widget
tabs = new Fl Tabs(..);
tabs->callback(MyTabCallback);

// Create three tabs each colored differently


grp1 = new Fl Group(.. "One");
grp1->color(9);
grp1->selection color(9);
grp1->end();

grp2 = new Fl Group(.. "Two");


grp2->color(10);
grp2->selection color(10);
grp2->end();

grp3 = new Fl Group(.. "Three");


grp3->color(14);
grp3->selection color(14);
grp3->end();
..
// Make sure default tab has same color as its group
tabs->selection color( (tab->value())->color() );
682 CHAPTER 31. CLASS DOCUMENTATION

..
return Fl::run();
}

The result of the above looks like:

Figure 31.40: Fl Tabs with uniform colors

Resizing Caveats
When Fl Tabs is resized vertically, the default behavior scales the tab’s height as well as its children.
To keep the tab height constant during resizing, set the tab widget’s resizable() to one of the tab’s child
groups, i.e.

tabs = new Fl Tabs(..);


grp1 = new Fl Group(..);
..
grp2 = new Fl Group(..);
..
tabs->end();
tabs->resizable(grp1); // keeps tab height constant

Callback’s Use Of when()

As of FLTK 1.3.3, Fl Tabs() supports the following flags for when():


• FL WHEN NEVER – callback never invoked (all flags off)
• FL WHEN CHANGED – if flag set, invokes callback when a tab has been changed (on click or
keyboard navigation)
• FL WHEN NOT CHANGED – if flag set, invokes callback when the tabs remain unchanged (on
click or keyboard navigation)
• FL WHEN RELEASE – if flag set, invokes callback on RELEASE of mouse button or keyboard
navigation
Notes:
1. The above flags can be logically OR-ed (|) or added (+) to combine behaviors.
2. The default value for when() is FL WHEN RELEASE (inherited from Fl Widget).
3. If FL WHEN RELEASE is the only flag specified, the behavior will be as if (FL WHEN RELEAS-
E|FL WHEN CHANGED) was specified.
4. The value of changed() will be valid during the callback.
5. If both FL WHEN CHANGED and FL WHEN NOT CHANGED are specified, the callback is in-
voked whether the tab has been changed or not. The changed() method can be used to determine the
cause.
6. FL WHEN NOT CHANGED can happen if someone clicks on an already selected tab, or if a key-
board navigation attempt results in no change to the tabs, such as using the arrow keys while at the
left or right end of the tabs.
31.133. FL TABS CLASS REFERENCE 683

31.133.2 Constructor & Destructor Documentation


Fl Tabs::Fl Tabs ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Tabs widget using the given position, size, and label string.
The default boxtype is FL THIN UP BOX.
Use add(Fl Widget∗) to add each child, which are usually Fl Group widgets. The children should be
sized to stay away from the top or bottom edge of the Fl Tabs widget, which is where the tabs will be
drawn.
All children of Fl Tabs should have the same size and exactly fit on top of each other. They should only
leave space above or below where that tabs will go, but not on the sides. If the first child of Fl Tabs is set
to ”resizable()”, the riders will not resize when the tabs are resized.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without
having to keep a pointer to all the children in the user code. A kludge has been done so the Fl Tabs and all
of its children can be automatic (local) variables, but you must declare the Fl Tabs widget first so that it is
destroyed last.

31.133.3 Member Function Documentation


void Fl Tabs::client area ( int & rx, int & ry, int & rw, int & rh, int tabh = 0 )
Returns the position and size available to be used by its children.
If there isn’t any child yet the tabh parameter will be used to calculate the return values. This assumes
that the children’s labelsize is the same as the Fl Tabs’ labelsize and adds a small border.
If there are already children, the values of child(0) are returned, and tabh is ignored.
Note
Children should always use the same positions and sizes.
tabh can be one of
• 0: calculate label size, tabs on top
• -1: calculate label size, tabs on bottom
• > 0: use given tabh value, tabs on top (height = tabh)
• < -1: use given tabh value, tabs on bottom (height = -tabh)
Parameters
in tabh position and optional height of tabs (see above)
out rx,ry,rw,rh (x,y,w,h) of client area for children

Since
FLTK 1.3.0

void Fl Tabs::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Group.


684 CHAPTER 31. CLASS DOCUMENTATION

int Fl Tabs::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Group.

Fl Widget∗ Fl Tabs::push ( ) const [inline]


Returns the tab group for the tab the user has currently down-clicked on and remains over until FL RELE-
ASE.
Otherwise, returns NULL.
While the user is down-clicked on a tab, the return value is the tab group for that tab. But as soon as
the user releases, or drags off the tab with the button still down, the return value will be NULL.

See Also
push(Fl Widget∗).

int Fl Tabs::push ( Fl Widget ∗ o )


This is called by the tab widget’s handle() method to set the tab group widget the user last FL PUSH’ed
on.
Set back to zero on FL RELEASE.
As of this writing, the value is mainly used by draw tab() to determine whether or not to draw a ’down’
box for the tab when it’s clicked, and to turn it off if the user drags off it.

See Also
push().

Fl Widget ∗ Fl Tabs::value ( )
Gets the currently visible widget/tab.
The value() is the first visible child (or the last child if none are visible) and this also hides any other
children. This allows the tabs to be deleted, moved to other groups, and show()/hide() called without it
screwing up.
31.134. FL TEXT BUFFER CLASS REFERENCE 685

int Fl Tabs::value ( Fl Widget ∗ newvalue )


Sets the widget to become the current visible widget/tab.
Setting the value hides all other children, and makes this one visible, if it is really a child.

Returns
1 if there was a change (new value different from previous),
0 if there was no change (new value already set)

Fl Widget ∗ Fl Tabs::which ( int event x, int event y )


Return the widget of the tab the user clicked on at event x / event y.
This is used for event handling (clicks) and by fluid to pick tabs.

Returns
The child widget of the tab the user clicked on, or
0 if there are no children or if the event is outside of the tabs area.

The documentation for this class was generated from the following files:

• Fl Tabs.H
• Fl Tabs.cxx

31.134 Fl Text Buffer Class Reference


This class manages unicode displayed in one or more Fl Text Display widgets.
#include <Fl Text Buffer.H>

Public Member Functions


• void add modify callback (Fl Text Modify Cb bufModifiedCB, void ∗cbArg)
Adds a callback function that is called whenever the text buffer is modified.
• void add predelete callback (Fl Text Predelete Cb bufPredelCB, void ∗cbArg)
Adds a callback routine to be called before text is deleted from the buffer.
• const char ∗ address (int pos) const
Convert a byte offset in buffer into a memory address.
• char ∗ address (int pos)
Convert a byte offset in buffer into a memory address.
• void append (const char ∗t)
Appends the text string to the end of the buffer.
• int appendfile (const char ∗file, int buflen=128 ∗1024)
Appends the named file to the end of the buffer.
• char byte at (int pos) const
Returns the raw byte at the specified position pos in the buffer.
• void call modify callbacks ()
Calls all modify callbacks that have been registered using the add modify callback() method.
• void call predelete callbacks ()
Calls the stored pre-delete callback procedure(s) for this buffer to update the changed area(s) on the screen
and any other listeners.
• void canUndo (char flag=1)
686 CHAPTER 31. CLASS DOCUMENTATION

Lets the undo system know if we can undo changes.


• unsigned int char at (int pos) const
Returns the character at the specified position pos in the buffer.
• void copy (Fl Text Buffer ∗fromBuf, int fromStart, int fromEnd, int toPos)
Copies text from one buffer to this one.
• int count displayed characters (int lineStartPos, int targetPos) const
Count the number of displayed characters between buffer position lineStartPos and targetPos.
• int count lines (int startPos, int endPos) const
Counts the number of newlines between startPos and endPos in buffer.
• int findchar backward (int startPos, unsigned int searchChar, int ∗foundPos) const
Search backwards in buffer buf for character searchChar, starting with the character BEFORE start-
Pos, returning the result in foundPos returns 1 if found, 0 if not.
• int findchar forward (int startPos, unsigned searchChar, int ∗foundPos) const
Finds the next occurrence of the specified character.
• Fl Text Buffer (int requestedSize=0, int preferredGapSize=1024)
Create an empty text buffer of a pre-determined size.
• void highlight (int start, int end)
Highlights the specified text within the buffer.
• int highlight ()
Returns the highlighted text.
• int highlight position (int ∗start, int ∗end)
Highlights the specified text between start and end within the buffer.
• const Fl Text Selection ∗ highlight selection () const
Returns the current highlight selection.
• char ∗ highlight text ()
Returns the highlighted text.
• void insert (int pos, const char ∗text)
Inserts null-terminated string text at position pos.
• int insertfile (const char ∗file, int pos, int buflen=128 ∗1024)
Inserts a file at the specified position.
• int length () const
Returns the number of bytes in the buffer.
• int line end (int pos) const
Finds and returns the position of the end of the line containing position pos (which is either a pointer to
the newline character ending the line, or a pointer to one character beyond the end of the buffer)
• int line start (int pos) const
Returns the position of the start of the line containing position pos.
• char ∗ line text (int pos) const
Returns the text from the entire line containing the specified character position.
• int loadfile (const char ∗file, int buflen=128 ∗1024)
Loads a text file into the buffer.
• int next char (int ix) const
Returns the index of the next character.
• int next char clipped (int ix) const
• int outputfile (const char ∗file, int start, int end, int buflen=128 ∗1024)
Writes the specified portions of the file to a file.
• int prev char (int ix) const
31.134. FL TEXT BUFFER CLASS REFERENCE 687

Returns the index of the previous character.


• int prev char clipped (int ix) const
• const Fl Text Selection ∗ primary selection () const
Returns the primary selection.
• Fl Text Selection ∗ primary selection ()
Returns the primary selection.
• void remove (int start, int end)
Deletes a range of characters in the buffer.
• void remove modify callback (Fl Text Modify Cb bufModifiedCB, void ∗cbArg)
Removes a modify callback.
• void remove predelete callback (Fl Text Predelete Cb predelCB, void ∗cbArg)
Removes a callback routine bufPreDeleteCB associated with argument cbArg to be called before text
is deleted from the buffer.
• void remove secondary selection ()
Removes the text from the buffer corresponding to the secondary text selection object.
• void remove selection ()
Removes the text in the primary selection.
• void replace (int start, int end, const char ∗text)
Deletes the characters between start and end, and inserts the null-terminated string text in their place
in the buffer.
• void replace secondary selection (const char ∗text)
Replaces the text from the buffer corresponding to the secondary text selection object with the new string
text.
• void replace selection (const char ∗text)
Replaces the text in the primary selection.
• int rewind lines (int startPos, int nLines)
Finds and returns the position of the first character of the line nLines backwards from startPos (not
counting the character pointed to by startpos if that is a newline) in the buffer.
• int savefile (const char ∗file, int buflen=128 ∗1024)
Saves a text file from the current buffer.
• int search backward (int startPos, const char ∗searchString, int ∗foundPos, int matchCase=0) const
Search backwards in buffer for string searchCharssearchString, starting with the character BEFORE start-
Pos, returning the result in foundPos returns 1 if found, 0 if not.
• int search forward (int startPos, const char ∗searchString, int ∗foundPos, int matchCase=0) const
Search forwards in buffer for string searchString, starting with the character startPos, and return-
ing the result in foundPos returns 1 if found, 0 if not.
• void secondary select (int start, int end)
Selects a range of characters in the secondary selection.
• int secondary selected ()
Returns a non 0 value if text has been selected in the secondary text selection, 0 otherwise.
• const Fl Text Selection ∗ secondary selection () const
Returns the secondary selection.
• int secondary selection position (int ∗start, int ∗end)
Returns the current selection in the secondary text selection object.
• char ∗ secondary selection text ()
Returns the text in the secondary selection.
• void secondary unselect ()
Clears any selection in the secondary text selection object.
688 CHAPTER 31. CLASS DOCUMENTATION

• void select (int start, int end)


Selects a range of characters in the buffer.
• int selected () const
Returns a non 0 value if text has been selected, 0 otherwise.
• int selection position (int ∗start, int ∗end)
Gets the selection position.
• char ∗ selection text ()
Returns the currently selected text.
• int skip displayed characters (int lineStartPos, int nChars)
Count forward from buffer position startPos in displayed characters (displayed characters are the char-
acters shown on the screen to represent characters in the buffer, where tabs and control characters are
expanded)
• int skip lines (int startPos, int nLines)
Finds the first character of the line nLines forward from startPos in the buffer and returns its position.
• int tab distance () const
Gets the tab width.
• void tab distance (int tabDist)
Set the hardware tab distance (width) used by all displays for this buffer, and used in computing offsets for
rectangular selection operations.
• char ∗ text () const
Get a copy of the entire contents of the text buffer.
• void text (const char ∗text)
Replaces the entire contents of the text buffer.
• char ∗ text range (int start, int end) const
Get a copy of a part of the text buffer.
• int undo (int ∗cp=0)
Undo text modification according to the undo variables or insert text from the undo buffer.
• void unhighlight ()
Unhighlights text in the buffer.
• void unselect ()
Cancels any previous selection on the primary text selection object.
• int utf8 align (int) const
Align an index into the buffer to the current or previous utf8 boundary.
• int word end (int pos) const
Returns the position corresponding to the end of the word.
• int word start (int pos) const
Returns the position corresponding to the start of the word.
• ∼Fl Text Buffer ()
Frees a text buffer.

Public Attributes
• int input file was transcoded
true iff the loaded file has been transcoded to UTF-8
• void(∗ transcoding warning action )(Fl Text Buffer ∗)
Pointer to a function called after reading a non UTF-8 encoded file.
31.134. FL TEXT BUFFER CLASS REFERENCE 689

Static Public Attributes


• static const char ∗ file encoding warning message
This message may be displayed using the fl alert() function when a file which was not UTF-8 encoded is
input.

Protected Member Functions


• void call modify callbacks (int pos, int nDeleted, int nInserted, int nRestyled, const char ∗deleted-
Text) const
Calls the stored modify callback procedure(s) for this buffer to update the changed area(s) on the screen
and any other listeners.
• void call predelete callbacks (int pos, int nDeleted) const
Calls the stored pre-delete callback procedure(s) for this buffer to update the changed area(s) on the screen
and any other listeners.
• int insert (int pos, const char ∗text)
Internal (non-redisplaying) version of BufInsert.
• void move gap (int pos)
Move the gap to start at a new position.
• void reallocate with gap (int newGapStart, int newGapLen)
Reallocates the text storage in the buffer to have a gap starting at newGapStart and a gap size of new-
GapLen, preserving the buffer’s current contents.
• void redisplay selection (Fl Text Selection ∗oldSelection, Fl Text Selection ∗newSelection) const
Calls the stored redisplay procedure(s) for this buffer to update the screen for a change in a selection.
• void remove (int start, int end)
Internal (non-redisplaying) version of BufRemove.
• void remove selection (Fl Text Selection ∗sel)
Removes the text from the buffer corresponding to sel.
• void replace selection (Fl Text Selection ∗sel, const char ∗text)
Replaces the text in selection sel.
• char ∗ selection text (Fl Text Selection ∗sel) const
• void update selections (int pos, int nDeleted, int nInserted)
Updates all of the selections in the buffer for changes in the buffer’s text.

Protected Attributes
• char ∗ mBuf
allocated memory where the text is stored
• char mCanUndo
if this buffer is used for attributes, it must not do any undo calls
• void ∗∗ mCbArgs
caller arguments for modifyProcs above
• int mCursorPosHint
hint for reasonable cursor position after a buffer modification operation
• int mGapEnd
points to the first char after the gap
• int mGapStart
points to the first character of the gap
• Fl Text Selection mHighlight
690 CHAPTER 31. CLASS DOCUMENTATION

highlighted areas
• int mLength
length of the text in the buffer (the length of the buffer itself must be calculated: gapEnd - gapStart + length)
• Fl Text Modify Cb ∗ mModifyProcs
procedures to call when buffer is modified to redisplay contents
• int mNModifyProcs
number of modify-redisplay procs attached
• int mNPredeleteProcs
number of pre-delete procs attached
• void ∗∗ mPredeleteCbArgs
caller argument for pre-delete proc above
• Fl Text Predelete Cb ∗ mPredeleteProcs
procedure to call before text is deleted from the buffer; at most one is supported.
• int mPreferredGapSize
the default allocation for the text gap is 1024 bytes and should only be increased if frequent and large
changes in buffer size are expected
• Fl Text Selection mPrimary
highlighted areas
• Fl Text Selection mSecondary
highlighted areas
• int mTabDist
equiv.

31.134.1 Detailed Description


This class manages unicode displayed in one or more Fl Text Display widgets.
All text in Fl Text Buffermust be encoded in UTF-8. All indices used in the function calls must be
aligned to the start of a UTF-8 sequence. All indices and pointers returned will be aligned. All functions
that return a single character will return that in an unsiged int in UCS-4 encoding.
The Fl Text Buffer class is used by the Fl Text Display and Fl Text Editor to manage complex text
data and is based upon the excellent NEdit text editor engine - see http://www.nedit.org/.

31.134.2 Constructor & Destructor Documentation


Fl Text Buffer::Fl Text Buffer ( int requestedSize = 0, int preferredGapSize = 1024 )
Create an empty text buffer of a pre-determined size.
Parameters
requestedSize use this to avoid unnecessary re-allocation if you know exactly how much the buffer
will need to hold
preferredGap- Initial size for the buffer gap (empty space in the buffer where text might be inserted
Size if the user is typing sequential chars)

31.134.3 Member Function Documentation


void Fl Text Buffer::add modify callback ( Fl Text Modify Cb bufModifiedCB, void ∗ cbArg )
Adds a callback function that is called whenever the text buffer is modified.
The callback function is declared as follows:
typedef void (*Fl Text Modify Cb)(int pos, int nInserted, int nDeleted,
int nRestyled, const char* deletedText,
void* cbArg);
31.134. FL TEXT BUFFER CLASS REFERENCE 691

const char∗ Fl Text Buffer::address ( int pos ) const [inline]


Convert a byte offset in buffer into a memory address.
692 CHAPTER 31. CLASS DOCUMENTATION

Parameters
pos byte offset into buffer

Returns
byte offset converted to a memory address

char∗ Fl Text Buffer::address ( int pos ) [inline]


Convert a byte offset in buffer into a memory address.
Parameters
pos byte offset into buffer

Returns
byte offset converted to a memory address

void Fl Text Buffer::append ( const char ∗ t ) [inline]


Appends the text string to the end of the buffer.
Parameters
t utf-8 encoded and nul terminated text

int Fl Text Buffer::appendfile ( const char ∗ file, int buflen = 128∗1024 ) [inline]
Appends the named file to the end of the buffer.
See also insertfile().

char Fl Text Buffer::byte at ( int pos ) const


Returns the raw byte at the specified position pos in the buffer.
Positions start at 0
Parameters
pos byte offset into buffer

Returns
unencoded raw byte

unsigned int Fl Text Buffer::char at ( int pos ) const


Returns the character at the specified position pos in the buffer.
Positions start at 0
Parameters
pos byte offset into buffer, pos must be at a character boundary

Returns
Unicode UCS-4 encoded character

void Fl Text Buffer::copy ( Fl Text Buffer ∗ fromBuf, int fromStart, int fromEnd, int toPos )
Copies text from one buffer to this one.
31.134. FL TEXT BUFFER CLASS REFERENCE 693

Parameters
fromBuf source text buffer may be the same as this
fromStart byte offset into buffer
fromEnd byte offset into buffer
toPos destination byte offset into buffer

int Fl Text Buffer::count displayed characters ( int lineStartPos, int targetPos ) const
Count the number of displayed characters between buffer position lineStartPos and targetPos.
(displayed characters are the characters shown on the screen to represent characters in the buffer, where
tabs and control characters are expanded)

int Fl Text Buffer::count lines ( int startPos, int endPos ) const


Counts the number of newlines between startPos and endPos in buffer.
The character at position endPos is not counted.

int Fl Text Buffer::findchar backward ( int startPos, unsigned int searchChar, int ∗ foundPos )
const
Search backwards in buffer buf for character searchChar, starting with the character BEFORE start-
Pos, returning the result in foundPos returns 1 if found, 0 if not.
(The difference between this and BufSearchBackward is that it’s optimized for single characters. The
overall performance of the text widget is dependent on its ability to count lines quickly, hence searching
for a single character: newline)
Parameters
startPos byte offset to start position
searchChar UCS-4 character that we want to find
foundPos byte offset where the character was found

Returns
1 if found, 0 if not

int Fl Text Buffer::findchar forward ( int startPos, unsigned searchChar, int ∗ foundPos ) const
Finds the next occurrence of the specified character.
Search forwards in buffer for character searchChar, starting with the character startPos, and
returning the result in foundPos returns 1 if found, 0 if not. (The difference between this and BufSearch-
Forward is that it’s optimized for single characters. The overall performance of the text widget is dependent
on its ability to count lines quickly, hence searching for a single character: newline)
Parameters
startPos byte offset to start position
searchChar UCS-4 character that we want to find
foundPos byte offset where the character was found

Returns
1 if found, 0 if not
694 CHAPTER 31. CLASS DOCUMENTATION

int Fl Text Buffer::highlight ( ) [inline]


Returns the highlighted text.
When you are done with the text, free it using the free() function.

char ∗ Fl Text Buffer::highlight text ( )


Returns the highlighted text.
When you are done with the text, free it using the free() function.

void Fl Text Buffer::insert ( int pos, const char ∗ text )


Inserts null-terminated string text at position pos.
Parameters
pos insertion position as byte offset (must be utf-8 character aligned)
text utf-8 encoded and nul terminated text

int Fl Text Buffer::insert ( int pos, const char ∗ text ) [protected]


Internal (non-redisplaying) version of BufInsert.
Returns the length of text inserted (this is just strlen(text), however this calculation can be expen-
sive and the length will be required by any caller who will continue on to call redisplay). pos must be
contiguous with the existing text in the buffer (i.e. not past the end).
Returns
the number of bytes inserted

int Fl Text Buffer::insertfile ( const char ∗ file, int pos, int buflen = 128∗1024 )
Inserts a file at the specified position.
Returns 0 on success, non-zero on error (strerror() contains reason). 1 indicates open for read failed (no
data loaded). 2 indicates error occurred while reading data (data was partially loaded). File can be UTF-8
or CP1252-encoded. If the input file is not UTF-8-encoded, the Fl Text Buffer widget will contain UTF-
8-transcoded data. By default, the message Fl Text Buffer::file encoding warning message will warn the
user about this.
See Also
input file was transcoded and transcoding warning action.

int Fl Text Buffer::length ( ) const [inline]


Returns the number of bytes in the buffer.
Returns
size of text in bytes

int Fl Text Buffer::line end ( int pos ) const


Finds and returns the position of the end of the line containing position pos (which is either a pointer to
the newline character ending the line, or a pointer to one character beyond the end of the buffer)
31.134. FL TEXT BUFFER CLASS REFERENCE 695

Parameters
pos byte index into buffer

Returns
byte offset to line end

int Fl Text Buffer::line start ( int pos ) const


Returns the position of the start of the line containing position pos.
Parameters
pos byte index into buffer

Returns
byte offset to line start

char ∗ Fl Text Buffer::line text ( int pos ) const


Returns the text from the entire line containing the specified character position.
When you are done with the text, free it using the free() function.
Parameters
pos byte index into buffer

Returns
copy of utf8 text, must be free’d

int Fl Text Buffer::loadfile ( const char ∗ file, int buflen = 128∗1024 ) [inline]
Loads a text file into the buffer.
See also insertfile().

int Fl Text Buffer::next char ( int ix ) const


Returns the index of the next character.
Parameters
ix index to the current char

int Fl Text Buffer::outputfile ( const char ∗ file, int start, int end, int buflen = 128∗1024 )
Writes the specified portions of the file to a file.
Returns 0 on success, non-zero on error (strerror() contains reason). 1 indicates open for write failed
(no data saved). 2 indicates error occurred while writing data (data was partially saved).

int Fl Text Buffer::prev char ( int ix ) const


Returns the index of the previous character.
696 CHAPTER 31. CLASS DOCUMENTATION

Parameters
ix index to the current char

void Fl Text Buffer::remove ( int start, int end )


Deletes a range of characters in the buffer.
Parameters
start byte offset to first character to be removed
end byte offset to charcatre after last character to be removed

void Fl Text Buffer::remove ( int start, int end ) [protected]


Internal (non-redisplaying) version of BufRemove.
Removes the contents of the buffer between start and end (and moves the gap to the site of the delete).

void Fl Text Buffer::replace ( int start, int end, const char ∗ text )
Deletes the characters between start and end, and inserts the null-terminated string text in their place
in the buffer.
Parameters
start byte offset to first character to be removed and new insert position
end byte offset to charcatre after last character to be removed
text utf-8 encoded and nul terminated text

int Fl Text Buffer::rewind lines ( int startPos, int nLines )


Finds and returns the position of the first character of the line nLines backwards from startPos (not
counting the character pointed to by startpos if that is a newline) in the buffer.
nLines == 0 means find the beginning of the line

int Fl Text Buffer::search backward ( int startPos, const char ∗ searchString, int ∗ foundPos, int
matchCase = 0 ) const
Search backwards in buffer for string searchCharssearchString, starting with the character BEFORE start-
Pos, returning the result in foundPos returns 1 if found, 0 if not.
Parameters
startPos byte offset to start position
searchString utf8 string that we want to find
foundPos byte offset where the string was found
matchCase if set, match character case

Returns
1 if found, 0 if not

int Fl Text Buffer::search forward ( int startPos, const char ∗ searchString, int ∗ foundPos, int
matchCase = 0 ) const
Search forwards in buffer for string searchString, starting with the character startPos, and return-
ing the result in foundPos returns 1 if found, 0 if not.
31.134. FL TEXT BUFFER CLASS REFERENCE 697

Parameters
startPos byte offset to start position
searchString utf8 string that we want to find
foundPos byte offset where the string was found
matchCase if set, match character case

Returns
1 if found, 0 if not

char ∗ Fl Text Buffer::secondary selection text ( )


Returns the text in the secondary selection.
When you are done with the text, free it using the free() function.

char ∗ Fl Text Buffer::selection text ( )


Returns the currently selected text.
When you are done with the text, free it using the free() function.

int Fl Text Buffer::skip displayed characters ( int lineStartPos, int nChars )


Count forward from buffer position startPos in displayed characters (displayed characters are the char-
acters shown on the screen to represent characters in the buffer, where tabs and control characters are
expanded)
Parameters
lineStartPos byte offset into buffer
nChars number of bytes that are sent to the display

Returns
byte offset in input after all output bytes are sent

char ∗ Fl Text Buffer::text ( ) const


Get a copy of the entire contents of the text buffer.
Memory is allocated to contain the returned string, which the caller must free.
Returns
newly allocated text buffer - must be free’d, text is utf8

void Fl Text Buffer::text ( const char ∗ text )


Replaces the entire contents of the text buffer.
Parameters
text Text must be valid utf8. if null an empty string is substituted.

char ∗ Fl Text Buffer::text range ( int start, int end ) const


Get a copy of a part of the text buffer.
Return a copy of the text between start and end character positions from text buffer buf. Positions
start at 0, and the range does not include the character pointed to by end. When you are done with the text,
free it using the free() function.
698 CHAPTER 31. CLASS DOCUMENTATION

Parameters
start byte offset to first character
end byte offset after last character in range

Returns
newly allocated text buffer - must be free’d, text is utf8

int Fl Text Buffer::word end ( int pos ) const

Returns the position corresponding to the end of the word.


Parameters
pos byte index into buffer

Returns
byte offset to word end

int Fl Text Buffer::word start ( int pos ) const

Returns the position corresponding to the start of the word.


Parameters
pos byte index into buffer

Returns
byte offset to word start

31.134.4 Member Data Documentation


const char ∗ Fl Text Buffer::file encoding warning message [static]

Initial value:

=
"Displayed text contains the UTF-8 transcoding\n"
"of the input file which was not UTF-8 encoded.\n"
"Some changes may have occurred."

This message may be displayed using the fl alert() function when a file which was not UTF-8 encoded
is input.

Fl Text Predelete Cb∗ Fl Text Buffer::mPredeleteProcs [protected]

procedure to call before text is deleted from the buffer; at most one is supported.

int Fl Text Buffer::mTabDist [protected]

equiv.
number of characters in a tab
31.135. FL TEXT DISPLAY CLASS REFERENCE 699

void(∗ Fl Text Buffer::transcoding warning action)(Fl Text Buffer ∗)


Pointer to a function called after reading a non UTF-8 encoded file.
This function is called after reading a file if the file content was transcoded to UTF-8. Its default
implementation calls fl alert() with the text of file encoding warning message. No warning message is
displayed if this pointer is set to NULL. Use input file was transcoded to be informed if file input required
transcoding to UTF-8.
The documentation for this class was generated from the following files:

• Fl Text Buffer.H
• Fl Text Buffer.cxx

31.135 Fl Text Display Class Reference


Rich text display widget.
#include <Fl Text Display.H>
Inheritance diagram for Fl Text Display:

Fl_Widget

Fl_Group

Fl_Text_Display

Fl_Text_Editor

Classes
• struct Style Table Entry
This structure associates the color, font, andsize of a string to draw with an attribute mask matching attr.

Public Types
• enum {
NORMAL CURSOR, CARET CURSOR, DIM CURSOR, BLOCK CURSOR,
HEAVY CURSOR, SIMPLE CURSOR }
text display cursor shapes enumeration
• enum { CURSOR POS, CHARACTER POS }
the character position is the left edge of a character, whereas the cursor is thought to be between the centers
of two consecutive characters.
• enum {
DRAG NONE = -2, DRAG START DND = -1, DRAG CHAR = 0, DRAG WORD = 1,
DRAG LINE = 2 }
drag types - they match Fl::event clicks() so that single clicking to start a collection selects by character,
double clicking selects by word and triple clicking selects by line.
• enum { WRAP NONE, WRAP AT COLUMN, WRAP AT PIXEL, WRAP AT BOUNDS }
wrap types - used in wrap mode()
• typedef void(∗ Unfinished Style Cb )(int, void ∗)
700 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• void buffer (Fl Text Buffer ∗buf)
Attach a text buffer to display, replacing the current buffer (if any)
• void buffer (Fl Text Buffer &buf)
Sets the current text buffer associated with the text widget.
• Fl Text Buffer ∗ buffer () const
Gets the current text buffer associated with the text widget.
• double col to x (double col) const
Convert a column number into an x pixel position.
• int count lines (int start, int end, bool start pos is line start) const
Count the number of lines between two positions.
• Fl Color cursor color () const
Gets the text cursor color.
• void cursor color (Fl Color n)
Sets the text cursor color.
• void cursor style (int style)
Sets the text cursor style.
• Fl Text Display (int X, int Y, int W, int H, const char ∗l=0)
Creates a new text display widget.
• virtual int handle (int e)
Event handling.
• void hide cursor ()
Hides the text cursor.
• void highlight data (Fl Text Buffer ∗styleBuffer, const Style Table Entry ∗styleTable, int nStyles,
char unfinishedStyle, Unfinished Style Cb unfinishedHighlightCB, void ∗cbArg)
Attach (or remove) highlight information in text display and redisplay.
• int in selection (int x, int y) const
Check if a pixel position is within the primary selection.
• void insert (const char ∗text)
Inserts ”text” at the current cursor location.
• void insert position (int newPos)
Sets the position of the text insertion cursor for text display.
• int insert position () const
Gets the position of the text insertion cursor for text display.
• int line end (int startPos, bool startPosIsLineStart) const
Returns the end of a line.
• int line start (int pos) const
Return the beginning of a line.
• void linenumber align (Fl Align val)
Set alignment for line numbers (if enabled).
• Fl Align linenumber align () const
Returns the alignment used for line numbers (if enabled).
• void linenumber bgcolor (Fl Color val)
Set the background color used for line numbers (if enabled).
• Fl Color linenumber bgcolor () const
Returns the background color used for line numbers (if enabled).
31.135. FL TEXT DISPLAY CLASS REFERENCE 701

• void linenumber fgcolor (Fl Color val)


Set the foreground color used for line numbers (if enabled).
• Fl Color linenumber fgcolor () const
Return the foreground color used for line numbers (if enabled).
• void linenumber font (Fl Font val)
Set the font used for line numbers (if enabled).
• Fl Font linenumber font () const
Return the font used for line numbers (if enabled).
• void linenumber format (const char ∗val)
Sets the printf() style format string used for line numbers.
• const char ∗ linenumber format () const
Returns the line number printf() format string.
• void linenumber size (Fl Fontsize val)
Set the font size used for line numbers (if enabled).
• Fl Fontsize linenumber size () const
Return the font size used for line numbers (if enabled).
• void linenumber width (int width)
Set width of screen area for line numbers.
• int linenumber width () const
Return the screen area width provided for line numbers.
• int move down ()
Moves the current insert position down one line.
• int move left ()
Moves the current insert position left one character.
• int move right ()
Moves the current insert position right one character.
• int move up ()
Moves the current insert position up one line.
• void next word (void)
Moves the current insert position right one word.
• void overstrike (const char ∗text)
Replaces text at the current insert position.
• int position style (int lineStartPos, int lineLen, int lineIndex) const
Find the correct style for a character.
• int position to xy (int pos, int ∗x, int ∗y) const
Convert a character index into a pixel position.
• void previous word (void)
Moves the current insert position left one word.
• void redisplay range (int start, int end)
Marks text from start to end as needing a redraw.
• virtual void resize (int X, int Y, int W, int H)
Change the size of the displayed text area.
• int rewind lines (int startPos, int nLines)
Skip a number of lines back.
• void scroll (int topLineNum, int horizOffset)
Scrolls the current buffer to start at the specified line and column.
702 CHAPTER 31. CLASS DOCUMENTATION

• Fl Align scrollbar align () const


Gets the scrollbar alignment type.
• void scrollbar align (Fl Align a)
Sets the scrollbar alignment type.
• int scrollbar width () const
Gets the width/height of the scrollbars.
• void scrollbar width (int W)
Sets the width/height of the scrollbars.
• int shortcut () const
• void shortcut (int s)
• void show cursor (int b=1)
Shows the text cursor.
• void show insert position ()
Scrolls the text buffer to show the current insert position.
• int skip lines (int startPos, int nLines, bool startPosIsLineStart)
Skip a number of lines forward.
• Fl Color textcolor () const
Gets the default color of text in the widget.
• void textcolor (Fl Color n)
Sets the default color of text in the widget.
• Fl Font textfont () const
Gets the default font used when drawing text in the widget.
• void textfont (Fl Font s)
Sets the default font used when drawing text in the widget.
• Fl Fontsize textsize () const
Gets the default size of text in the widget.
• void textsize (Fl Fontsize s)
Sets the default size of text in the widget.
• int word end (int pos) const
Moves the insert position to the end of the current word.
• int word start (int pos) const
Moves the insert position to the beginning of the current word.
• void wrap mode (int wrap, int wrap margin)
Set the new text wrap mode.
• int wrapped column (int row, int column) const
Nobody knows what this function does.
• int wrapped row (int row) const
Nobody knows what this function does.
• double x to col (double x) const
Convert an x pixel position into a column number.
• ∼Fl Text Display ()
Free a text display and release its associated memory.

Protected Types
• enum { DRAW LINE, FIND INDEX, FIND INDEX FROM ZERO, GET WIDTH }
31.135. FL TEXT DISPLAY CLASS REFERENCE 703

Protected Member Functions


• void absolute top line number (int oldFirstChar)
Line numbering stuff, currently unused.
• void calc last char ()
Update last display character index.
• void calc line starts (int startLine, int endLine)
Update the line start arrays.
• void clear rect (int style, int x, int y, int width, int height) const
Clear a rectangle with the appropriate background color for style.
• void display insert ()
Scroll the display to bring insertion cursor into view.
• virtual void draw ()
Draw the widget.
• void draw cursor (int, int)
Draw a cursor with top center at X, Y.
• void draw line numbers (bool clearAll)
Refresh the line number area.
• void draw range (int start, int end)
Draw a range of text.
• void draw string (int style, int x, int y, int toX, const char ∗string, int nChars) const
Draw a text segment in a single style.
• void draw text (int X, int Y, int W, int H)
Refresh a rectangle of the text display.
• void draw vline (int visLineNum, int leftClip, int rightClip, int leftCharIndex, int rightCharIndex)
Draw a single line of text.
• int empty vlines () const
Return true if there are lines visible with no corresponding buffer text.
• void extend range for styles (int ∗start, int ∗end)
I don’t know what this does!
• void find line end (int pos, bool start pos is line start, int ∗lineEnd, int ∗nextLineStart) const
Finds both the end of the current line and the start of the next line.
• void find wrap range (const char ∗deletedText, int pos, int nInserted, int nDeleted, int ∗modRange-
Start, int ∗modRangeEnd, int ∗linesInserted, int ∗linesDeleted)
Wrapping calculations.
• int find x (const char ∗s, int len, int style, int x) const
Find the index of the character that lies at the given x position.
• int get absolute top line number () const
Line numbering stuff, currently unused.
• int handle vline (int mode, int lineStart, int lineLen, int leftChar, int rightChar, int topClip, int
bottomClip, int leftClip, int rightClip) const
Universal pixel machine.
• int longest vline () const
Find the longest line of all visible lines.
• void maintain absolute top line number (int state)
Line numbering stuff, currently unused.
• int maintaining absolute top line number () const
704 CHAPTER 31. CLASS DOCUMENTATION

Line numbering stuff, currently unused.


• void measure deleted lines (int pos, int nDeleted)
Wrapping calculations.
• double measure proportional character (const char ∗s, int colNum, int pos) const
Wrapping calculations.
• int measure vline (int visLineNum) const
Returns the width in pixels of the displayed line pointed to by ”visLineNum”.
• void offset line starts (int newTopLineNum)
Offset line start counters for a new vertical scroll position.
• int position to line (int pos, int ∗lineNum) const
Convert a position index into a line number offset.
• int position to linecol (int pos, int ∗lineNum, int ∗column) const
Find the line and column number of position pos.
• void reset absolute top line number ()
Line numbering stuff, probably unused.
• int scroll (int topLineNum, int horizOffset)
Scrolls the current buffer to start at the specified line and column.
• double string width (const char ∗string, int length, int style) const
Find the width of a string in the font of a particular style.
• void update h scrollbar ()
Update vertical scrollbar.
• void update line starts (int pos, int charsInserted, int charsDeleted, int linesInserted, int linesDeleted,
int ∗scrolled)
Update line start arrays and variables.
• void update v scrollbar ()
Update vertical scrollbar.
• int vline length (int visLineNum) const
Count number of bytes in a visible line.
• int wrap uses character (int lineEndPos) const
Check if the line break is caused by a \n or by line wrapping.
• void wrapped line counter (Fl Text Buffer ∗buf, int startPos, int maxPos, int maxLines, bool start-
PosIsLineStart, int styleBufOffset, int ∗retPos, int ∗retLines, int ∗retLineStart, int ∗retLineEnd, bool
countLastLineMissingNewLine=true) const
Wrapping calculations.
• int xy to position (int x, int y, int PosType=CHARACTER POS) const
Translate a pixel position into a character index.
• void xy to rowcol (int x, int y, int ∗row, int ∗column, int PosType=CHARACTER POS) const
Translate pixel coordinates into row and column.

Static Protected Member Functions


• static void buffer modified cb (int pos, int nInserted, int nDeleted, int nRestyled, const char ∗deleted-
Text, void ∗cbArg)
This is called whenever the buffer is modified.
• static void buffer predelete cb (int pos, int nDeleted, void ∗cbArg)
This is called before any characters are deleted.
• static void h scrollbar cb (Fl Scrollbar ∗w, Fl Text Display ∗d)
Callbacks for drag or valueChanged on scrollbars.
31.135. FL TEXT DISPLAY CLASS REFERENCE 705

• static void scroll timer cb (void ∗)


Timer callback for scroll events.
• static void v scrollbar cb (Fl Scrollbar ∗w, Fl Text Display ∗d)
Callbacks for drag or valueChanged on scrollbars.

Protected Attributes
• int damage range1 end
• int damage range1 start
• int damage range2 end
• int damage range2 start
• int display insert position hint
• int dragging
• int dragPos
• int dragType
• int mAbsTopLineNum
• Fl Text Buffer ∗ mBuffer
• double mColumnScale
• int mContinuousWrap
• Fl Color mCursor color
• int mCursorOldY
• int mCursorOn
• int mCursorPos
• int mCursorPreferredXPos
• int mCursorStyle
• int mCursorToHint
• int mFirstChar
• void ∗ mHighlightCBArg
• int mHorizOffset
• int mHorizOffsetHint
• Fl Scrollbar ∗ mHScrollBar
• int mLastChar
• int mLineNumLeft
• int mLineNumWidth
• int ∗ mLineStarts
• int mMaxsize
• int mModifyingTabDistance
• int mNBufferLines
• int mNeedAbsTopLineNum
• int mNLinesDeleted
• int mNStyles
• int mNVisibleLines
• Fl Text Buffer ∗ mStyleBuffer
• const Style Table Entry ∗ mStyleTable
• int mSuppressResync
• int mTopLineNum
• int mTopLineNumHint
• Unfinished Style Cb mUnfinishedHighlightCB
• char mUnfinishedStyle
• Fl Scrollbar ∗ mVScrollBar
706 CHAPTER 31. CLASS DOCUMENTATION

• int mWrapMarginPix
• Fl Align scrollbar align
• int scrollbar width
• int shortcut

• Fl Color textcolor
Fl Font textfont
Fl Fontsize textsize

Friends
• void fl text drag me (int pos, Fl Text Display ∗d)

Additional Inherited Members


31.135.1 Detailed Description
Rich text display widget.
This is the FLTK text display widget. It allows the user to view multiple lines of text and supports
highlighting, word wrap, mixes of font faces and colors, line numbers and scrolling. The buffer that is
displayed in the widget is managed by the Fl Text Buffer class. A single Text Buffer can be displayed by
multiple Text Displays.

Figure 31.41: Fl Text Display widget

Figure 31.42: Fl Text Display widget with line numbers enabled


31.135. FL TEXT DISPLAY CLASS REFERENCE 707

Example Use
#include <FL/FL Text Display.H>
..
int main() {
..
Fl Text Buffer *buff = new Fl Text Buffer();
Fl Text Display *disp = new Fl Text Display(10, 10, 640, 480);
disp->buffer(buff); // attach text buffer to display widget
buff->text("line one\nline two"); // add some text to buffer
..
}

Features
• Word wrap: wrap mode(), wrapped column(), wrapped row()
• Font control: textfont(), textsize(), textcolor()
• Font styling: highlight data()
• Cursor: cursor style(), show cursor(), hide cursor(), cursor color()
• Line numbers: linenumber width(), linenumber font(), linenumber size(), linenumber fgcolor(), linenumber-
bgcolor(), linenumber align(), linenumber format()
Note that other features may be available via Fl Text Editor and Fl Text Buffer classes.
Note
Line numbers were added in 1.3.3. To avoid breaking ABI, many of its options are read only. To
adjust these features in 1.3.x, you must build FLTK with FLTK ABI VERSION set to 10303 or
higher.

31.135.2 Member Enumeration Documentation


anonymous enum
text display cursor shapes enumeration
Enumerator
NORMAL CURSOR I-beam.
CARET CURSOR caret under the text
DIM CURSOR dim I-beam
BLOCK CURSOR unfille box under the current character
HEAVY CURSOR thick I-beam
SIMPLE CURSOR as cursor as Fl Input cursor

anonymous enum
wrap types - used in wrap mode()
Enumerator
WRAP NONE don’t wrap text at all
WRAP AT COLUMN wrap text at the given text column
WRAP AT PIXEL wrap text at a pixel position
WRAP AT BOUNDS wrap text so that it fits into the widget width

31.135.3 Constructor & Destructor Documentation


Fl Text Display::Fl Text Display ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new text display widget.
708 CHAPTER 31. CLASS DOCUMENTATION

Parameters
X,Y,W,H position and size of widget
l label text, defaults to none

Fl Text Display::∼Fl Text Display ( )

Free a text display and release its associated memory.


Note, the text BUFFER that the text display displays is a separate entity and is not freed, nor are the
style buffer or style table.

31.135.4 Member Function Documentation


void Fl Text Display::absolute top line number ( int oldFirstChar ) [protected]

Line numbering stuff, currently unused.


Re-calculate absolute top line number for a change in scroll position.

void Fl Text Display::buffer ( Fl Text Buffer ∗ buf )

Attach a text buffer to display, replacing the current buffer (if any)
Parameters
buf attach this text buffer

void Fl Text Display::buffer ( Fl Text Buffer & buf ) [inline]

Sets the current text buffer associated with the text widget.
Multiple text widgets can be associated with the same text buffer.
Parameters
buf new text buffer

Fl Text Buffer∗ Fl Text Display::buffer ( ) const [inline]

Gets the current text buffer associated with the text widget.
Multiple text widgets can be associated with the same text buffer.

Returns
current text buffer

void Fl Text Display::buffer modified cb ( int pos, int nInserted, int nDeleted, int nRestyled, const
char ∗ deletedText, void ∗ cbArg ) [static], [protected]

This is called whenever the buffer is modified.


Callback attached to the text buffer to receive modification information
This callback can be used to adjust the display or update other setting. It is not advisable to change any
buffers or text in this callback, or line counting may get out of sync.
31.135. FL TEXT DISPLAY CLASS REFERENCE 709

Parameters
pos starting index of modification
nInserted number of bytes we inserted (must be UTF-8 aligned!)
nDeleted number of bytes deleted (must be UTF-8 aligned!)
nRestyled ??
deletedText this is what was removed, must not be NULL if nDeleted is set
cbArg ”this” pointer for static callback function

void Fl Text Display::buffer predelete cb ( int pos, int nDeleted, void ∗ cbArg ) [static],
[protected]

This is called before any characters are deleted.


Callback attached to the text buffer to receive delete information before the modifications are actually
made.
This callback can be used to adjust the display or update other setting. It is not advisable to change any
buffers or text in this callback, or line counting may get out of sync.
Parameters
pos starting index of deletion
nDeleted number of bytes we will delete (must be UTF-8 aligned!)
cbArg ”this” pointer for static callback function

void Fl Text Display::calc last char ( ) [protected]

Update last display character index.


Given a Fl Text Display with a complete, up-to-date lineStarts array, update the lastChar entry to point
to the last buffer position displayed.

void Fl Text Display::calc line starts ( int startLine, int endLine ) [protected]

Update the line start arrays.


Scan through the text in the ”textD”’s buffer and recalculate the line starts array values beginning
at index ”startLine” and continuing through (including) ”endLine”. It assumes that the line starts entry
preceding ”startLine” (or mFirstChar if startLine is 0) is good, and re-counts newlines to fill in the requested
entries. Out of range values for ”startLine” and ”endLine” are acceptable.
Parameters
startLine,end- range of lines to scan as line numbers
Line

void Fl Text Display::clear rect ( int style, int X, int Y, int width, int height ) const
[protected]

Clear a rectangle with the appropriate background color for style.


Parameters
style index into style table
size and position of background area
X,Y,width,height
710 CHAPTER 31. CLASS DOCUMENTATION

double Fl Text Display::col to x ( double col ) const


Convert a column number into an x pixel position.
31.135. FL TEXT DISPLAY CLASS REFERENCE 711

Parameters
col an approximate column number based on the main font

Returns
number of pixels from the left margin to the left of an average sized character

int Fl Text Display::count lines ( int startPos, int endPos, bool startPosIsLineStart ) const
Count the number of lines between two positions.
Same as BufCountLines, but takes into account wrapping if wrapping is turned on. If the caller knows
that startPos is at a line start, it can pass startPosIsLineStart as True to make the call more
efficient by avoiding the additional step of scanning back to the last newline.
Parameters
startPos index to first character
endPos index after last character
startPosIsLine- avoid scanning back to the line start
Start

Returns
number of lines

Fl Color Fl Text Display::cursor color ( ) const [inline]


Gets the text cursor color.
Returns
cursor color

void Fl Text Display::cursor color ( Fl Color n ) [inline]


Sets the text cursor color.
Parameters
n new cursor color

void Fl Text Display::cursor style ( int style )


Sets the text cursor style.
Sets the text cursor style to one of the following:

• Fl Text Display::NORMAL CURSOR - Shows an I beam.


• Fl Text Display::CARET CURSOR - Shows a caret under the text.
• Fl Text Display::DIM CURSOR - Shows a dimmed I beam.
• Fl Text Display::BLOCK CURSOR - Shows an unfilled box around the current character.

• Fl Text Display::HEAVY CURSOR - Shows a thick I beam.

This call also switches the cursor on and may trigger a redraw.
712 CHAPTER 31. CLASS DOCUMENTATION

Parameters
style new cursor style

void Fl Text Display::display insert ( ) [protected]


Scroll the display to bring insertion cursor into view.
Note: it would be nice to be able to do this without counting lines twice (scroll () counts them too)
and/or to count from the most efficient starting point, but the efficiency of this routine is not as important
to the overall performance of the text display.

Todo Unicode?

void Fl Text Display::draw ( void ) [protected], [virtual]


Draw the widget.
This function tries to limit drawing to smaller areas if possible.
Reimplemented from Fl Group.

void Fl Text Display::draw cursor ( int X, int Y ) [protected]


Draw a cursor with top center at X, Y.
Parameters
X,Y cursor position in pixels

void Fl Text Display::draw line numbers ( bool clearAll ) [protected]


Refresh the line number area.
Parameters
clearAll – (currently unused) If False, only draws the line number text, does not clear the area
behind it. If True, clears the area and redraws the text. Use False to avoid a ’flash’ for
single buffered windows.

void Fl Text Display::draw range ( int startpos, int endpos ) [protected]


Draw a range of text.
Refresh all of the text between buffer positions startpos and endpos not including the character at
the position endpos.
If endpos points beyond the end of the buffer, refresh the whole display after startpos, including
blank lines which are not technically part of any range of characters.
Parameters
startpos index of first character to draw
endpos index after last character to draw

void Fl Text Display::draw string ( int style, int X, int Y, int toX, const char ∗ string, int nChars )
const [protected]
Draw a text segment in a single style.
Draw a string or blank area according to parameter style, using the appropriate colors and drawing
method for that style, with top left corner at X, Y. If style says to draw text, use string as source of
31.135. FL TEXT DISPLAY CLASS REFERENCE 713

characters, and draw nChars, if style is FILL, erase rectangle where text would have drawn from X to
toX and from Y to the maximum y extent of the current font(s).
714 CHAPTER 31. CLASS DOCUMENTATION

Parameters
style index into style lookup table
X,Y drawing origin
toX rightmost position if this is a fill operation
string text if this is a drawing operation
nChars number of characters to draw

void Fl Text Display::draw text ( int left, int top, int width, int height ) [protected]
Refresh a rectangle of the text display.
Parameters
left,top are in coordinates of the text drawing window.
width,height size in pixels

void Fl Text Display::draw vline ( int visLineNum, int leftClip, int rightClip, int leftCharIndex,
int rightCharIndex ) [protected]
Draw a single line of text.
Draw the text on a single line represented by visLineNum (the number of lines down from the top
of the display), limited by leftClip and rightClip window coordinates and leftCharIndex and
rightCharIndex character positions (not including the character at position rightCharIndex).
Parameters
visLineNum index of line in the visible line number lookup
leftClip,right- pixel position of clipped area
Clip
leftChar- index into line of segment that we want to draw
Index,right-
CharIndex

int Fl Text Display::empty vlines ( ) const [protected]


Return true if there are lines visible with no corresponding buffer text.

Returns
1 if there are empty lines

void Fl Text Display::extend range for styles ( int ∗ startpos, int ∗ endpos ) [protected]
I don’t know what this does!
Extend the range of a redraw request (from ∗start to ∗end) with additional redraw requests resulting
from changes to the attached style buffer (which contains auxiliary information for coloring or styling
text).
Parameters
startpos ??
endpos ??

Todo Unicode?
31.135. FL TEXT DISPLAY CLASS REFERENCE 715

void Fl Text Display::find line end ( int startPos, bool startPosIsLineStart, int ∗ lineEnd, int ∗
nextLineStart ) const [protected]

Finds both the end of the current line and the start of the next line.
Why? In continuous wrap mode, if you need to know both, figuring out one from the other can be
expensive or error prone. The problem comes when there’s a trailing space or tab just before the end of
the buffer. To translate an end of line value to or from the next lines start value, you need to know whether
the trailing space or tab is being used as a line break or just a normal character, and to find that out would
otherwise require counting all the way back to the beginning of the line.
Parameters
startPos
startPosIsLine-
Start
out lineEnd
out nextLineStart

void Fl Text Display::find wrap range ( const char ∗ deletedText, int pos, int nInserted, int
nDeleted, int ∗ modRangeStart, int ∗ modRangeEnd, int ∗ linesInserted, int ∗ linesDeleted )
[protected]

Wrapping calculations.
When continuous wrap is on, and the user inserts or deletes characters, wrapping can happen before
and beyond the changed position. This routine finds the extent of the changes, and counts the deleted
and inserted lines over that range. It also attempts to minimize the size of the range to what has to be
counted and re-displayed, so the results can be useful both for delimiting where the line starts need to be
recalculated, and for deciding what part of the text to redisplay.
Parameters
deletedText
pos
nInserted
nDeleted
modRangeStart
modRangeEnd
linesInserted
linesDeleted

int Fl Text Display::find x ( const char ∗ s, int len, int style, int x ) const [protected]

Find the index of the character that lies at the given x position.
Parameters
s UTF-8 text string
len length of string
style index into style lookup table
x position in pixels

Returns
index into buffer
716 CHAPTER 31. CLASS DOCUMENTATION

int Fl Text Display::get absolute top line number ( ) const [protected]


Line numbering stuff, currently unused.
Returns the absolute (non-wrapped) line number of the first line displayed. Returns 0 if the absolute
top line number is not being maintained.

int Fl Text Display::handle vline ( int mode, int lineStartPos, int lineLen, int leftChar, int
rightChar, int Y, int bottomClip, int leftClip, int rightClip ) const [protected]
Universal pixel machine.
We use a single function that handles all line layout, measuring, and drawing
• draw a text range

• return the width of a text range in pixels


• return the index of a character that is at a pixel position
Parameters
in mode DRAW LINE, GET WIDTH, FIND INDEX
in lineStartPos index of first character
in lineLen size of string in bytes
in leftChar,right-
Char
in Y drawing position
in bottomClip,left- stop work when we reach the clipped area. rightClip is the X position
Clip,rightClip that we search in FIND INDEX.
Return values
DRAW LINE index of last drawn character
GET WIDTH width in pixels of text segment if we would draw it
FIND INDEX index of character at given x position in window coordinates
FIND INDEX FROM Z- index of character at given x position without scrolling and widget offsets
ERO

Todo we need to handle hidden hyphens and tabs here!


we handle all styles and selections
we must provide code to get pixel positions of the middle of a character as well

void Fl Text Display::highlight data ( Fl Text Buffer ∗ styleBuffer, const Style Table Entry ∗
styleTable, int nStyles, char unfinishedStyle, Unfinished Style Cb unfinishedHighlightCB, void ∗
cbArg )
Attach (or remove) highlight information in text display and redisplay.
Highlighting information consists of a style buffer which parallels the normal text buffer, but codes font
and color information for the display; a style table which translates style buffer codes (indexed by buffer
character - ’A’) into fonts and colors; and a callback mechanism for as-needed highlighting, triggered by a
style buffer entry of ”unfinishedStyle”. Style buffer can trigger additional redisplay during a normal buffer
modification if the buffer contains a primary Fl Text Selection (see extendRangeForStyleMods for more
information on this protocol).
Style buffers, tables and their associated memory are managed by the caller.
Styles are ranged from 65 (’A’) to 126.
31.135. FL TEXT DISPLAY CLASS REFERENCE 717

Parameters
styleBuffer this buffer works in parallel to the text buffer. For every character in the text buffer,
the stye buffer has a byte at the same offset that contains an index into an array of
possible styles.
styleTable a list of styles indexed by the style buffer
nStyles number of styles in the style table
unfinishedStyle if this style is found, the callback below is called
unfinished- if a character with an unfinished style is found, this callback will be called
HighlightCB
cbArg and optional argument for the callback above, usually a pointer to the Text Display.

int Fl Text Display::in selection ( int X, int Y ) const


Check if a pixel position is within the primary selection.
Parameters
X,Y pixel position to test

Returns
1 if position (X, Y) is inside of the primary Fl Text Selection

void Fl Text Display::insert ( const char ∗ text )


Inserts ”text” at the current cursor location.
This has the same effect as inserting the text into the buffer using BufInsert and then moving the insert
position after the newly inserted text, except that it’s optimized to do less redrawing.
Parameters
text new text in UTF-8 encoding.

void Fl Text Display::insert position ( int newPos )


Sets the position of the text insertion cursor for text display.
Move the insertion cursor in front of the character at newPos. This function may trigger a redraw.
Parameters
newPos new caret position

int Fl Text Display::insert position ( ) const [inline]


Gets the position of the text insertion cursor for text display.
Returns
insert position index into text buffer

int Fl Text Display::line end ( int startPos, bool startPosIsLineStart ) const


Returns the end of a line.
Same as BufEndOfLine, but takes into account line breaks when wrapping is turned on. If the caller
knows that startPos is at a line start, it can pass ”startPosIsLineStart” as True to make the call more
efficient by avoiding the additional step of scanning back to the last newline.
718 CHAPTER 31. CLASS DOCUMENTATION

Note that the definition of the end of a line is less clear when continuous wrap is on. With continuous
wrap off, it’s just a pointer to the newline that ends the line. When it’s on, it’s the character beyond the last
displayable character on the line, where a whitespace character which has been ”converted” to a newline
for wrapping is not considered displayable. Also note that a line can be wrapped at a non-whitespace
character if the line had no whitespace. In this case, this routine returns a pointer to the start of the next
line. This is also consistent with the model used by visLineLength.
Parameters
startPos index to starting character
startPosIsLine- avoid scanning back to the line start
Start

Returns
new position as index

int Fl Text Display::line start ( int pos ) const


Return the beginning of a line.
Same as BufStartOfLine, but returns the character after last wrap point rather than the last newline.
Parameters
pos index to starting character

Returns
new position as index

void Fl Text Display::linenumber align ( Fl Align val )


Set alignment for line numbers (if enabled).
Valid values are FL ALIGN LEFT, FL ALIGN CENTER or FL ALIGN RIGHT.

Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)

void Fl Text Display::linenumber bgcolor ( Fl Color val )


Set the background color used for line numbers (if enabled).

Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)

void Fl Text Display::linenumber fgcolor ( Fl Color val )


Set the foreground color used for line numbers (if enabled).

Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)
31.135. FL TEXT DISPLAY CLASS REFERENCE 719

void Fl Text Display::linenumber font ( Fl Font val )


Set the font used for line numbers (if enabled).
Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)

void Fl Text Display::linenumber format ( const char ∗ val )


Sets the printf() style format string used for line numbers.
Default is ”%d” for normal unpadded decimal integers.
An internal copy of val is allocated and managed; it is automatically freed whenever a new value is
assigned, or when the widget is destroyed.
The value of val must not be NULL.
Example values:
- "%d" -- For normal line numbers without padding (Default)
- "%03d" -- For 000 padding
- "%x" -- For hexadecimal line numbers
- "%o" -- For octal line numbers

Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)

void Fl Text Display::linenumber size ( Fl Fontsize val )


Set the font size used for line numbers (if enabled).
Version
1.3.3 ABI feature (ignored in 1.3.x unless FLTK ABI VERSION is 10303 or higher)

void Fl Text Display::linenumber width ( int width )


Set width of screen area for line numbers.
Use to also enable/disable line numbers. A value of 0 disables line numbering, values >0 enables them.
Parameters
width The new width of the area for line numbers to appear, in pixels. 0 disables line numbers
(default)

int Fl Text Display::longest vline ( ) const [protected]


Find the longest line of all visible lines.
Returns
the width of the longest visible line in pixels

void Fl Text Display::maintain absolute top line number ( int state ) [protected]
Line numbering stuff, currently unused.
In continuous wrap mode, internal line numbers are calculated after wrapping. A separate non-wrapped
line count is maintained when line numbering is turned on. There is some performance cost to maintaining
this line count, so normally absolute line numbers are not tracked if line numbering is off. This routine
allows callers to specify that they still want this line count maintained (for use via TextDPosToLineAnd-
Col). More specifically, this allows the line number reported in the statistics line to be calibrated in absolute
lines, rather than post-wrapped lines.
720 CHAPTER 31. CLASS DOCUMENTATION

int Fl Text Display::maintaining absolute top line number ( ) const [protected]


Line numbering stuff, currently unused.
Return true if a separate absolute top line number is being maintained (for displaying line numbers or
showing in the statistics line).

void Fl Text Display::measure deleted lines ( int pos, int nDeleted ) [protected]
Wrapping calculations.
This is a stripped-down version of the findWrapRange() function above, intended to be used to calculate
the number of ”deleted” lines during a buffer modification. It is called before the modification takes place.
This function should only be called in continuous wrap mode with a non-fixed font width. In that
case, it is impossible to calculate the number of deleted lines, because the necessary style information is
no longer available after the modification. In other cases, we can still perform the calculation afterwards
(possibly even more efficiently).
Parameters
pos
nDeleted

double Fl Text Display::measure proportional character ( const char ∗ s, int xPix, int pos ) const
[protected]
Wrapping calculations.
Measure the width in pixels of the first character of string ”s” at a particular column ”colNum” and
buffer position ”pos”. This is for measuring characters in proportional or mixed-width highlighting fonts.
A note about proportional and mixed-width fonts: the mixed width and proportional font code in nedit
does not get much use in general editing, because nedit doesn’t allow per-language-mode fonts, and editing
programs in a proportional font is usually a bad idea, so very few users would choose a proportional font as a
default. There are still probably mixed- width syntax highlighting cases where things don’t redraw properly
for insertion/deletion, though static display and wrapping and resizing should now be solid because they
are now used for online help display.
Parameters
s text string
xPix x pixel position needed for calculating tab widths
pos offset within string

Returns
width of character in pixels

int Fl Text Display::measure vline ( int visLineNum ) const [protected]


Returns the width in pixels of the displayed line pointed to by ”visLineNum”.
Parameters
visLineNum index into visible lines array

Returns
width of line in pixels
31.135. FL TEXT DISPLAY CLASS REFERENCE 721

int Fl Text Display::move down ( )


Moves the current insert position down one line.

Returns
1 if the cursor moved, 0 if the beginning of the text was reached

int Fl Text Display::move left ( )


Moves the current insert position left one character.

Returns
1 if the cursor moved, 0 if the beginning of the text was reached

int Fl Text Display::move right ( )


Moves the current insert position right one character.

Returns
1 if the cursor moved, 0 if the end of the text was reached

int Fl Text Display::move up ( )


Moves the current insert position up one line.

Returns
1 if the cursor moved, 0 if the beginning of the text was reached

void Fl Text Display::offset line starts ( int newTopLineNum ) [protected]


Offset line start counters for a new vertical scroll position.
Offset the line starts array, mTopLineNum, mFirstChar and lastChar, for a new vertical scroll position
given by newTopLineNum. If any currently displayed lines will still be visible, salvage the line starts
values, otherwise, count lines from the nearest known line start (start or end of buffer, or the closest value
in the mLineStarts array)
Parameters
newTopLine- index into buffer
Num

void Fl Text Display::overstrike ( const char ∗ text )


Replaces text at the current insert position.
Parameters
text new text in UTF-8 encoding

Todo Unicode? Find out exactly what we do here and simplify.


722 CHAPTER 31. CLASS DOCUMENTATION

int Fl Text Display::position style ( int lineStartPos, int lineLen, int lineIndex ) const
Find the correct style for a character.
Determine the drawing method to use to draw a specific character from ”buf”. lineStartPos gives
the character index where the line begins, lineIndex, the number of characters past the beginning of
the line, and lineIndex the number of displayed characters past the beginning of the line. Passing
lineStartPos of -1 returns the drawing style for ”no text”.
Why not just: position style(pos)? Because style applies to blank areas of the window beyond the
text boundaries, and because this routine must also decide whether a position is inside of a rectangular
Fl Text Selection, and do so efficiently, without re-counting character positions from the start of the line.
Note that style is a somewhat incorrect name, drawing method would be more appropriate.
Parameters
lineStartPos beginning of this line
lineLen number of bytes in line
lineIndex position of character within line

Returns
style for the given character

int Fl Text Display::position to line ( int pos, int ∗ lineNum ) const [protected]
Convert a position index into a line number offset.
Find the line number of position pos relative to the first line of displayed text. Returns 0 if the line is
not displayed.
Parameters
pos ??
out lineNum ??

Returns
??
Todo What does this do?

int Fl Text Display::position to linecol ( int pos, int ∗ lineNum, int ∗ column ) const
[protected]
Find the line and column number of position pos.
This only works for displayed lines. If the line is not displayed, the function returns 0 (without the
mLineStarts array it could turn in to very long calculation involving scanning large amounts of text in the
buffer). If continuous wrap mode is on, returns the absolute line number (as opposed to the wrapped line
number which is used for scrolling).
Parameters
pos character index
out lineNum absolute (unwrapped) line number
out column character offset to the beginning of the line

Returns
0 if pos is off screen, line number otherwise
Todo a column number makes little sense in the UTF-8/variable font width environment. We will have
to further define what exactly we want to return. Please check the functions that call this particular
function.
31.135. FL TEXT DISPLAY CLASS REFERENCE 723

int Fl Text Display::position to xy ( int pos, int ∗ X, int ∗ Y ) const


Convert a character index into a pixel position.
Translate a buffer text position to the XY location where the top left of the cursor would be positioned
to point to that character. Returns 0 if the position is not displayed because it is vertically out of view. If the
position is horizontally out of view, returns the X coordinate where the position would be if it were visible.
Parameters
pos character index
out X,Y pixel position of character on screen

Returns
0 if character vertically out of view, X & Y positions otherwise

void Fl Text Display::redisplay range ( int startpos, int endpos )


Marks text from start to end as needing a redraw.
This function will trigger a damage event and later a redraw of parts of the widget.
Parameters
startpos index of first character needing redraw
endpos index after last character needing redraw

void Fl Text Display::reset absolute top line number ( ) [protected]


Line numbering stuff, probably unused.
Count lines from the beginning of the buffer to reestablish the absolute (non-wrapped) top line number.
If mode is not continuous wrap, or the number is not being maintained, does nothing.

void Fl Text Display::resize ( int X, int Y, int W, int H ) [virtual]


Change the size of the displayed text area.
Calling this function will trigger a recalculation of all lines visible and of all scrollbar sizes.
Parameters
X,Y,W,H new position and size of this widget
Reimplemented from Fl Group.

int Fl Text Display::rewind lines ( int startPos, int nLines )


Skip a number of lines back.
Same as BufCountBackwardNLines, but takes into account line breaks when wrapping is turned on.
Parameters
startPos index to starting character
nLines number of lines to skip back

Returns
new position as index

void Fl Text Display::scroll ( int topLineNum, int horizOffset )


Scrolls the current buffer to start at the specified line and column.
724 CHAPTER 31. CLASS DOCUMENTATION

Parameters
topLineNum top line number
horizOffset column number

Todo Column numbers make little sense here.

int Fl Text Display::scroll ( int topLineNum, int horizOffset ) [protected]


Scrolls the current buffer to start at the specified line and column.
Parameters
topLineNum top line number
horizOffset in pixels

Returns
0 if nothing changed, 1 if we scrolled

void Fl Text Display::scroll timer cb ( void ∗ user data ) [static], [protected]


Timer callback for scroll events.
This timer event scrolls the text view proportionally to how far the mouse pointer has left the text area.
This allows for smooth scrolling without ”wiggeling” the mouse.

Fl Align Fl Text Display::scrollbar align ( ) const [inline]


Gets the scrollbar alignment type.

Returns
scrollbar alignment

void Fl Text Display::scrollbar align ( Fl Align a ) [inline]


Sets the scrollbar alignment type.
Parameters
a new scrollbar alignment

int Fl Text Display::scrollbar width ( ) const [inline]


Gets the width/height of the scrollbars.
/return width of scrollbars

void Fl Text Display::scrollbar width ( int W ) [inline]


Sets the width/height of the scrollbars.
Parameters
W width of scrollbars
31.135. FL TEXT DISPLAY CLASS REFERENCE 725

int Fl Text Display::shortcut ( ) const [inline]


Todo FIXME : get set methods pointing on shortcut have no effects as shortcut is unused in this class
and derived!
Returns
the current shortcut key

void Fl Text Display::shortcut ( int s ) [inline]


Todo FIXME : get set methods pointing on shortcut have no effects as shortcut is unused in this class
and derived!
Parameters
s the new shortcut key

void Fl Text Display::show cursor ( int b = 1 )


Shows the text cursor.
This function may trigger a redraw.
Parameters
b show(1) or hide(0) the text cursor (caret).

void Fl Text Display::show insert position ( )


Scrolls the text buffer to show the current insert position.
This function triggers a complete recalculation, ending in a call to Fl Text Display::display insert()

int Fl Text Display::skip lines ( int startPos, int nLines, bool startPosIsLineStart )
Skip a number of lines forward.
Same as BufCountForwardNLines, but takes into account line breaks when wrapping is turned on. If
the caller knows that startPos is at a line start, it can pass ”startPosIsLineStart” as True to make the call
more efficient by avoiding the additional step of scanning back to the last newline.
Parameters
startPos index to starting character
nLines number of lines to skip ahead
startPosIsLine- avoid scanning back to the line start
Start

Returns
new position as index

double Fl Text Display::string width ( const char ∗ string, int length, int style ) const
[protected]
Find the width of a string in the font of a particular style.
726 CHAPTER 31. CLASS DOCUMENTATION

Parameters
string the text
length number of bytes in string
style index into style table

Returns
width of text segment in pixels

Fl Color Fl Text Display::textcolor ( ) const [inline]


Gets the default color of text in the widget.
Returns
text color unless overridden by a style

void Fl Text Display::textcolor ( Fl Color n ) [inline]


Sets the default color of text in the widget.
Parameters
n new text color

Fl Font Fl Text Display::textfont ( ) const [inline]


Gets the default font used when drawing text in the widget.
Returns
current text font face unless overridden by a style

void Fl Text Display::textfont ( Fl Font s ) [inline]


Sets the default font used when drawing text in the widget.
Parameters
s default text font face

Fl Fontsize Fl Text Display::textsize ( ) const [inline]


Gets the default size of text in the widget.
Returns
current text height unless overridden by a style

void Fl Text Display::textsize ( Fl Fontsize s ) [inline]


Sets the default size of text in the widget.
31.135. FL TEXT DISPLAY CLASS REFERENCE 727

Parameters
s new text size

void Fl Text Display::update h scrollbar ( ) [protected]


Update vertical scrollbar.
Update the minimum, maximum, slider size, page increment, and value for the horizontal scrollbar.

void Fl Text Display::update line starts ( int pos, int charsInserted, int charsDeleted, int
linesInserted, int linesDeleted, int ∗ scrolled ) [protected]
Update line start arrays and variables.
Update the line starts array, mTopLineNum, mFirstChar and lastChar for this text display after a modi-
fication to the text buffer, given by the position pos where the change began, and the numbers of characters
and lines inserted and deleted.
Parameters
pos index into buffer of recent changes
charsInserted number of bytes(!) inserted
charsDeleted number of bytes(!) deleted
linesInserted number of lines
linesDeleted number of lines
out scrolled set to 1 if the text display needs to be scrolled

void Fl Text Display::update v scrollbar ( ) [protected]


Update vertical scrollbar.
Update the minimum, maximum, slider size, page increment, and value for vertical scrollbar.

int Fl Text Display::vline length ( int visLineNum ) const [protected]


Count number of bytes in a visible line.
Return the length of a line (number of bytes) by examining entries in the line starts array rather than by
scanning for newlines.
Parameters
visLineNum index of line in visible line array

Returns
number of bytes in this line

int Fl Text Display::word end ( int pos ) const [inline]


Moves the insert position to the end of the current word.
Parameters
pos start calculation at this index

Returns
index of first character after the end of the word
728 CHAPTER 31. CLASS DOCUMENTATION

int Fl Text Display::word start ( int pos ) const [inline]


Moves the insert position to the beginning of the current word.
31.135. FL TEXT DISPLAY CLASS REFERENCE 729

Parameters
pos start calculation at this index

Returns
beginning of the words

void Fl Text Display::wrap mode ( int wrap, int wrapMargin )


Set the new text wrap mode.
If wrap mode is not zero, this call enables automatic word wrapping at column wrapMargin. Word-
wrapping does not change the text buffer itself, only the way the text is displayed. Different Text Displays
can have different wrap modes, even if they share the same Text Buffer.
Parameters
wrap new wrap mode is WRAP NONE (don’t wrap text at all), WRAP AT COLUMN
(wrap text at the given text column), WRAP AT PIXEL (wrap text at a pixel posi-
tion), or WRAP AT BOUNDS (wrap text so that it fits into the widget width)
wrapMargin in WRAP AT COLUMN mode, text will wrap at the n’th character. For variable
width fonts, an average character width is calculated. The column width is calculated
using the current textfont or the first style when this function is called. If the font size
changes, this function must be called again. In WRAP AT PIXEL mode, this is the
pixel position.

Todo we need new wrap modes to wrap at the window edge and based on pixel width or average character
width.

int Fl Text Display::wrap uses character ( int lineEndPos ) const [protected]


Check if the line break is caused by a \n or by line wrapping.
Line breaks in continuous wrap mode usually happen at newlines or whitespace. This line-terminating
character is not included in line width measurements and has a special status as a non-visible character.
However, lines with no whitespace are wrapped without the benefit of a line terminating character, and this
distinction causes endless trouble with all of the text display code which was originally written without
continuous wrap mode and always expects to wrap at a newline character.
Given the position of the end of the line, as returned by TextDEndOfLine or BufEndOfLine, this returns
true if there is a line terminating character, and false if there’s not. On the last character in the buffer, this
function can’t tell for certain whether a trailing space was used as a wrap point, and just guesses that it
wasn’t. So if an exact accounting is necessary, don’t use this function.
Parameters
lineEndPos index of character where the line wraps

Returns
1 if a \n character causes the line wrap

int Fl Text Display::wrapped column ( int row, int column ) const


Nobody knows what this function does.
Correct a column number based on an unconstrained position (as returned by TextDXYToUnconstrained-
Position) to be relative to the last actual newline in the buffer before the row and column position given,
rather than the last line start created by line wrapping. This is an adapter for rectangular selections and code
written before continuous wrap mode, which thinks that the unconstrained column is the number of char-
acters from the last newline. Obviously this is time consuming, because it invloves character re-counting.
730 CHAPTER 31. CLASS DOCUMENTATION

Parameters
row
column

Returns
something unknown

Todo What does this do and how is it useful? Column numbers mean little in this context. Which functions
depend on this one?

Todo Unicode?

void Fl Text Display::wrapped line counter ( Fl Text Buffer ∗ buf, int startPos, int maxPos, int
maxLines, bool startPosIsLineStart, int styleBufOffset, int ∗ retPos, int ∗ retLines, int ∗ retLineStart,
int ∗ retLineEnd, bool countLastLineMissingNewLine = true ) const [protected]
Wrapping calculations.
Count forward from startPos to either maxPos or maxLines (whichever is reached first), and return all
relevant positions and line count. The provided textBuffer may differ from the actual text buffer of the
widget. In that case it must be a (partial) copy of the actual text buffer and the styleBufOffset argument
must indicate the starting position of the copy, to take into account the correct style information.
Parameters
in buf The text buffer to operate on
in startPos Starting index position into the buffer
in maxPos Maximum index position into the buffer we’ll reach
in maxLines Maximum number of lines we’ll reach
in startPosIsLine- Flag indicating if startPos is start of line. (If set, prevents our having to
Start find the line start)
in styleBufOffset Offset index position into style buffer.
out retPos Position where counting ended. When counting lines, the position re-
turned is the start of the line ”maxLines” lines beyond ”startPos”.
out retLines Number of line breaks counted
out retLineStart Start of the line where counting ended
out retLineEnd End position of the last line traversed
out countLastLine-
MissingNew-
Line

int Fl Text Display::wrapped row ( int row ) const


Nobody knows what this function does.
Correct a row number from an unconstrained position (as returned by TextDXYToUnconstrained-
Position) to a straight number of newlines from the top line of the display. Because rectangular selections
are based on newlines, rather than display wrapping, and anywhere a rectangular selection needs a row, it
needs it in terms of un-wrapped lines.
Parameters
31.135. FL TEXT DISPLAY CLASS REFERENCE 731

row

Returns
something unknown

Todo What does this do and how is it useful? Column numbers mean little in this context. Which functions
depend on this one?

double Fl Text Display::x to col ( double x ) const


Convert an x pixel position into a column number.
Parameters
x number of pixels from the left margin

Returns
an approximate column number based on the main font

int Fl Text Display::xy to position ( int X, int Y, int posType = CHARACTER POS ) const
[protected]
Translate a pixel position into a character index.
Translate window coordinates to the nearest (insert cursor or character cell) text position. The parameter
posType specifies how to interpret the position: CURSOR POS means translate the coordinates to the
nearest cursor position, and CHARACTER POS means return the position of the character closest to (X,
Y).
Parameters
X,Y pixel position
posType CURSOR POS or CHARACTER POS

Returns
index into text buffer

void Fl Text Display::xy to rowcol ( int X, int Y, int ∗ row, int ∗ column, int posType =
CHARACTER POS ) const [protected]
Translate pixel coordinates into row and column.
Translate window coordinates to the nearest row and column number for positioning the cursor. This, of
course, makes no sense when the font is proportional, since there are no absolute columns. The parameter
posType specifies how to interpret the position: CURSOR POS means translate the coordinates to the
nearest position between characters, and CHARACTER POS means translate the position to the nearest
character cell.
Parameters
X,Y pixel coordinates
732 CHAPTER 31. CLASS DOCUMENTATION

out row,column neares row and column


posType CURSOR POS or CHARACTER POS
The documentation for this class was generated from the following files:
• Fl Text Display.H
• Fl Text Display.cxx

31.136 Fl Text Editor Class Reference


This is the FLTK text editor widget.
#include <Fl Text Editor.H>
Inheritance diagram for Fl Text Editor:

Fl_Widget

Fl_Group

Fl_Text_Display

Fl_Text_Editor

Classes
• struct Key Binding
Simple linked list associating a key/state to a function.

Public Types
• typedef int(∗ Key Func )(int key, Fl Text Editor ∗editor)
Key function binding callback type.

Public Member Functions


• void add default key bindings (Key Binding ∗∗list)
Adds all of the default editor key bindings to the specified key binding list.
• void add key binding (int key, int state, Key Func f, Key Binding ∗∗list)
Adds a key of state ”state” with the function ”function”.
• void add key binding (int key, int state, Key Func f)
Adds a key of state ”state” with the function ”function”.
• Key Func bound key function (int key, int state, Key Binding ∗list)
Returns the function associated with a key binding.
• Key Func bound key function (int key, int state)
Returns the function associated with a key binding.
• void default key function (Key Func f)
Sets the default key function for unassigned keys.
• Fl Text Editor (int X, int Y, int W, int H, const char ∗l=0)
The constructor creates a new text editor widget.
31.136. FL TEXT EDITOR CLASS REFERENCE 733

• virtual int handle (int e)


Event handling.
• void insert mode (int b)
Sets the current insert mode; if non-zero, new text is inserted before the current cursor position.
• int insert mode ()
Gets the current insert mode; if non-zero, new text is inserted before the current cursor position.
• void remove all key bindings (Key Binding ∗∗list)
Removes all of the key bindings associated with the text editor or list.
• void remove all key bindings ()
Removes all of the key bindings associated with the text editor or list.
• void remove key binding (int key, int state, Key Binding ∗∗list)
Removes the key binding associated with the key ”key” of state ”state”.
• void remove key binding (int key, int state)
Removes the key binding associated with the key ”key” of state ”state”.

Static Public Member Functions


• static int kf backspace (int c, Fl Text Editor ∗e)
Does a backspace in the current buffer.
• static int kf c s move (int c, Fl Text Editor ∗e)
Extends the current selection in the direction indicated by control key c.
• static int kf copy (int c, Fl Text Editor ∗e)
Does a copy of selected text or the current character in the current buffer.
• static int kf ctrl move (int c, Fl Text Editor ∗e)
Moves the current text cursor in the direction indicated by control key.
• static int kf cut (int c, Fl Text Editor ∗e)
Does a cut of selected text in the current buffer.
• static int kf default (int c, Fl Text Editor ∗e)
Inserts the text associated with the key.
• static int kf delete (int c, Fl Text Editor ∗e)
Does a delete of selected text or the current character in the current buffer.
• static int kf down (int c, Fl Text Editor ∗e)
Moves the text cursor one line down.
• static int kf end (int c, Fl Text Editor ∗e)
Moves the text cursor to the end of the current line.
• static int kf enter (int c, Fl Text Editor ∗e)
Inserts a newline at the current cursor position.
• static int kf home (int, Fl Text Editor ∗e)
Moves the text cursor to the beginning of the current line.
• static int kf ignore (int c, Fl Text Editor ∗e)
Ignores the keypress.
• static int kf insert (int c, Fl Text Editor ∗e)
Toggles the insert mode in the text editor.
• static int kf left (int c, Fl Text Editor ∗e)
Moves the text cursor one character to the left.
• static int kf m s move (int c, Fl Text Editor ∗e)
Extends the current selection in the direction indicated by meta key c.
734 CHAPTER 31. CLASS DOCUMENTATION

• static int kf meta move (int c, Fl Text Editor ∗e)


Moves the current text cursor in the direction indicated by meta key.
• static int kf move (int c, Fl Text Editor ∗e)
Moves the text cursor in the direction indicated by key c.
• static int kf page down (int c, Fl Text Editor ∗e)
Moves the text cursor down one page.
• static int kf page up (int c, Fl Text Editor ∗e)
Moves the text cursor up one page.
• static int kf paste (int c, Fl Text Editor ∗e)
Does a paste of selected text in the current buffer.
• static int kf right (int c, Fl Text Editor ∗e)
Moves the text cursor one character to the right.
• static int kf select all (int c, Fl Text Editor ∗e)
Selects all text in the current buffer.
• static int kf shift move (int c, Fl Text Editor ∗e)
Extends the current selection in the direction of key c.
• static int kf undo (int c, Fl Text Editor ∗e)
Undo last edit in the current buffer.
• static int kf up (int c, Fl Text Editor ∗e)
Moves the text cursor one line up.

Protected Member Functions


• int handle key ()
Handles a key press in the editor.
• void maybe do callback ()
does or does not a callback according to changed() and when() settings

Additional Inherited Members


31.136.1 Detailed Description
This is the FLTK text editor widget.
It allows the user to edit multiple lines of text and supports highlighting and scrolling. The buffer that
is displayed in the widget is managed by the Fl Text Buffer class.

31.136.2 Constructor & Destructor Documentation


Fl Text Editor::Fl Text Editor ( int X, int Y, int W, int H, const char ∗ l = 0 )
The constructor creates a new text editor widget.

31.136.3 Member Function Documentation


void Fl Text Editor::add default key bindings ( Key Binding ∗∗ list )
Adds all of the default editor key bindings to the specified key binding list.

Fl Text Editor::Key Func Fl Text Editor::bound key function ( int key, int state, Key Binding ∗
list )
Returns the function associated with a key binding.
31.136. FL TEXT EDITOR CLASS REFERENCE 735

Key Func Fl Text Editor::bound key function ( int key, int state ) [inline]
Returns the function associated with a key binding.

void Fl Text Editor::default key function ( Key Func f ) [inline]


Sets the default key function for unassigned keys.

void Fl Text Editor::insert mode ( int b ) [inline]


Sets the current insert mode; if non-zero, new text is inserted before the current cursor position.
Otherwise, new text replaces text at the current cursor position.

int Fl Text Editor::insert mode ( ) [inline]


Gets the current insert mode; if non-zero, new text is inserted before the current cursor position.
Otherwise, new text replaces text at the current cursor position.

int Fl Text Editor::kf backspace ( int c, Fl Text Editor ∗ e ) [static]


Does a backspace in the current buffer.

int Fl Text Editor::kf c s move ( int c, Fl Text Editor ∗ e ) [static]


Extends the current selection in the direction indicated by control key c.

int Fl Text Editor::kf copy ( int c, Fl Text Editor ∗ e ) [static]


Does a copy of selected text or the current character in the current buffer.

int Fl Text Editor::kf cut ( int c, Fl Text Editor ∗ e ) [static]


Does a cut of selected text in the current buffer.

int Fl Text Editor::kf delete ( int c, Fl Text Editor ∗ e ) [static]


Does a delete of selected text or the current character in the current buffer.

int Fl Text Editor::kf down ( int c, Fl Text Editor ∗ e ) [static]


Moves the text cursor one line down.

int Fl Text Editor::kf end ( int c, Fl Text Editor ∗ e ) [static]


Moves the text cursor to the end of the current line.

int Fl Text Editor::kf home ( int , Fl Text Editor ∗ e ) [static]


Moves the text cursor to the beginning of the current line.

int Fl Text Editor::kf insert ( int c, Fl Text Editor ∗ e ) [static]


Toggles the insert mode in the text editor.

int Fl Text Editor::kf left ( int c, Fl Text Editor ∗ e ) [static]


Moves the text cursor one character to the left.
736 CHAPTER 31. CLASS DOCUMENTATION

int Fl Text Editor::kf m s move ( int c, Fl Text Editor ∗ e ) [static]


Extends the current selection in the direction indicated by meta key c.

int Fl Text Editor::kf move ( int c, Fl Text Editor ∗ e ) [static]


Moves the text cursor in the direction indicated by key c.

int Fl Text Editor::kf page down ( int c, Fl Text Editor ∗ e ) [static]


Moves the text cursor down one page.

int Fl Text Editor::kf page up ( int c, Fl Text Editor ∗ e ) [static]


Moves the text cursor up one page.

int Fl Text Editor::kf paste ( int c, Fl Text Editor ∗ e ) [static]


Does a paste of selected text in the current buffer.

int Fl Text Editor::kf right ( int c, Fl Text Editor ∗ e ) [static]


Moves the text cursor one character to the right.

int Fl Text Editor::kf select all ( int c, Fl Text Editor ∗ e ) [static]


Selects all text in the current buffer.

int Fl Text Editor::kf shift move ( int c, Fl Text Editor ∗ e ) [static]


Extends the current selection in the direction of key c.

int Fl Text Editor::kf undo ( int c, Fl Text Editor ∗ e ) [static]


Undo last edit in the current buffer.
Also deselect previous selection.

int Fl Text Editor::kf up ( int c, Fl Text Editor ∗ e ) [static]


Moves the text cursor one line up.

void Fl Text Editor::remove all key bindings ( Key Binding ∗∗ list )


Removes all of the key bindings associated with the text editor or list.

void Fl Text Editor::remove all key bindings ( ) [inline]


Removes all of the key bindings associated with the text editor or list.

void Fl Text Editor::remove key binding ( int key, int state ) [inline]
Removes the key binding associated with the key ”key” of state ”state”.
The documentation for this class was generated from the following files:

• Fl Text Editor.H
• Fl Text Editor.cxx
31.137. FL TEXT SELECTION CLASS REFERENCE 737

31.137 Fl Text Selection Class Reference


This is an internal class for Fl Text Buffer to manage text selections.
#include <Fl Text Buffer.H>

Public Member Functions


• int end () const
Return the byte ofsset to the character after the last selected character.
• int includes (int pos) const
Return true if position pos with indentation dispIndex is in the Fl Text Selection.
• int position (int ∗start, int ∗end) const
Return the positions of this selection.
• bool selected () const
Returns true if any text is selected.
• void selected (bool b)
Modify the ’selected’ flag.
• void set (int start, int end)
Set the selection range.
• int start () const
Return the byte offset to the first selected character.
• void update (int pos, int nDeleted, int nInserted)
Updates a selection afer text was modified.

Protected Attributes
• int mEnd
byte offset to the character after the last selected character
• bool mSelected
this flag is set if any text is selected
• int mStart
byte offset to the first selected character

Friends
• class Fl Text Buffer

31.137.1 Detailed Description


This is an internal class for Fl Text Buffer to manage text selections.
This class works correctly with utf-8 strings assuming that the parameters for all calls are on character
boundaries.

31.137.2 Member Function Documentation


int Fl Text Selection::end ( ) const [inline]
Return the byte ofsset to the character after the last selected character.
Returns
byte offset
738 CHAPTER 31. CLASS DOCUMENTATION

int Fl Text Selection::position ( int ∗ start, int ∗ end ) const


Return the positions of this selection.
31.137. FL TEXT SELECTION CLASS REFERENCE 739

Parameters
start retrun byte offset to first selected character
end retrun byte offset pointing after last selected character

Returns
true if selected

bool Fl Text Selection::selected ( ) const [inline]


Returns true if any text is selected.

Returns
a non-zero number if any text has been selected, or 0 if no text is selected.

void Fl Text Selection::selected ( bool b ) [inline]


Modify the ’selected’ flag.
Parameters
b new flag

void Fl Text Selection::set ( int start, int end )


Set the selection range.
Parameters
start byte offset to first selected character
end byte offset pointing after last selected character

int Fl Text Selection::start ( ) const [inline]


Return the byte offset to the first selected character.

Returns
byte offset

void Fl Text Selection::update ( int pos, int nDeleted, int nInserted )


Updates a selection afer text was modified.
Updates an individual selection for changes in the corresponding text
Parameters
pos byte offset into text buffer at which the change occured
nDeleted number of bytes deleted from the buffer
nInserted number of bytes inserted into the buffer
The documentation for this class was generated from the following files:

• Fl Text Buffer.H
• Fl Text Buffer.cxx
740 CHAPTER 31. CLASS DOCUMENTATION

31.138 Fl Tile Class Reference


The Fl Tile class lets you resize its children by dragging the border between them.
Inheritance diagram for Fl Tile:

Fl_Widget

Fl_Group

Fl_Tile

Public Member Functions


• Fl Tile (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Tile widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
• void position (int, int, int, int)
Drags the intersection at (oldx,oldy) to (newx,newy).
• void resize (int, int, int, int)
Resizes the Fl Tile widget and its children.

Additional Inherited Members


31.138.1 Detailed Description
The Fl Tile class lets you resize its children by dragging the border between them.

Figure 31.43: Fl Tile

For the tiling to work correctly, the children of an Fl Tile must cover the entire area of the widget, but
not overlap. This means that all children must touch each other at their edges, and no gaps can be left inside
the Fl Tile.
Fl Tile does not normally draw any graphics of its own. The ”borders” which can be seen in the
snapshot above are actually part of the children. Their boxtypes have been set to FL DOWN BOX creating
31.138. FL TILE CLASS REFERENCE 741

the impression of ”ridges” where the boxes touch. What you see are actually two adjacent FL DOWN B-
OX’s drawn next to each other. All neighboring widgets share the same edge - the widget’s thick borders
make it appear as though the widgets aren’t actually touching, but they are. If the edges of adjacent widgets
do not touch, then it will be impossible to drag the corresponding edges.
Fl Tile allows objects to be resized to zero dimensions. To prevent this you can use the resizable() to
limit where corners can be dragged to. For more information see note below.
Even though objects can be resized to zero sizes, they must initially have non-zero sizes so the Fl Tile
can figure out their layout. If desired, call position() after creating the children but before displaying the
window to set the borders where you want.
Note on resizable(Fl Widget &w): The ”resizable” child widget (which should be invisible) limits
where the borders can be dragged to. All dragging will be limited inside the resizable widget’s borders.
If you don’t set it, it will be possible to drag the borders right to the edges of the Fl Tile widget, and thus
resize objects on the edges to zero width or height. When the entire Fl Tile widget is resized, the resizable()
widget will keep its border distance to all borders the same (this is normal resize behavior), so that you can
effectively set a border width that will never change.
Note: You can still resize widgets inside the resizable() to zero width and/or height, i.e. box 2b above
to zero width and box 3a to zero height.
See Also
void Fl Group::resizable(Fl Widget &w)

Example for resizable with 20 pixel border distance:


int dx = 20, dy = dx;
Fl Tile tile(50,50,300,300);
// ... create widgets inside tile (see test/tile.cxx) ...
// create resizable() box
Fl Box r(tile.x()+dx,tile.y()+dy,tile.w()-2*dx,tile.h()-2*dy);
tile.resizable(r);
tile.end();

See also the complete example program in test/tile.cxx.

31.138.2 Constructor & Destructor Documentation


Fl Tile::Fl Tile ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Tile widget using the given position, size, and label string.
The default boxtype is FL NO BOX.
The destructor also deletes all the children. This allows a whole tree to be deleted at once, without
having to keep a pointer to all the children in the user code. A kludge has been done so the Fl Tile and
all of its children can be automatic (local) variables, but you must declare the Fl Tile first, so that it is
destroyed last.
See Also
class Fl Group

31.138.3 Member Function Documentation


int Fl Tile::handle ( int event ) [virtual]
Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
742 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Group.

void Fl Tile::position ( int oldx, int oldy, int newx, int newy )
Drags the intersection at (oldx,oldy) to (newx,newy).
This redraws all the necessary children.
Pass zero as oldx or oldy to disable drag in that direction.

void Fl Tile::resize ( int X, int Y, int W, int H ) [virtual]


Resizes the Fl Tile widget and its children.
Fl Tile implements its own resize() method. It does not use Fl Group::resize() to resize itself and its
children.
Enlarging works by just moving the lower-right corner and resizing the bottom and right border widgets
accordingly.
Shrinking the Fl Tile works in the opposite way by shrinking the bottom and right border widgets,
unless they are reduced to zero width or height, resp. or to their minimal sizes defined by the resizable()
widget. In this case other widgets will be shrunk as well.
See the Fl Tile class documentation about how the resizable() works.
Reimplemented from Fl Group.
The documentation for this class was generated from the following files:
• Fl Tile.H
• Fl Tile.cxx

31.139 Fl Tiled Image Class Reference


This class supports tiling of images over a specified area.
#include <Fl Tiled Image.H>
Inheritance diagram for Fl Tiled Image:

Fl_Image

Fl_Tiled_Image

Public Member Functions


• virtual void color average (Fl Color c, float i)
The color average() method averages the colors in the image with the FLTK color value c.
• virtual Fl Image ∗ copy (int W, int H)
31.139. FL TILED IMAGE CLASS REFERENCE 743

The copy() method creates a copy of the specified image.


• Fl Image ∗ copy ()
• virtual void desaturate ()
The desaturate() method converts an image to grayscale.
• virtual void draw (int X, int Y, int W, int H, int cx, int cy)
Draws the image with a bounding box.
• void draw (int X, int Y)
• Fl Tiled Image (Fl Image ∗i, int W=0, int H=0)
The constructors create a new tiled image containing the specified image.
• Fl Image ∗ image ()
Gets The image that is shared.
• virtual ∼Fl Tiled Image ()
The destructor frees all memory and server resources that are used by the tiled image.

Protected Attributes
• int alloc image
• Fl Image ∗ image

Additional Inherited Members


31.139.1 Detailed Description
This class supports tiling of images over a specified area.
The source (tile) image is not copied unless you call the color average(), desaturate(), or inactive()
methods.

31.139.2 Constructor & Destructor Documentation


Fl Tiled Image::Fl Tiled Image ( Fl Image ∗ i, int W = 0, int H = 0 )
The constructors create a new tiled image containing the specified image.
Use a width and height of 0 to tile the whole window/widget.

31.139.3 Member Function Documentation


void Fl Tiled Image::color average ( Fl Color c, float i ) [virtual]
The color average() method averages the colors in the image with the FLTK color value c.
The i argument specifies the amount of the original image to combine with the color, so a value of 1.0
results in no color blend, and a value of 0.0 results in a constant image of the specified color. The original
image data is not altered by this method.
Reimplemented from Fl Image.

Fl Image ∗ Fl Tiled Image::copy ( int W, int H ) [virtual]


The copy() method creates a copy of the specified image.
If the width and height are provided, the image is resized to the specified size. The image should be
deleted (or in the case of Fl Shared Image, released) when you are done with it.
Reimplemented from Fl Image.
744 CHAPTER 31. CLASS DOCUMENTATION

void Fl Tiled Image::desaturate ( ) [virtual]


The desaturate() method converts an image to grayscale.
If the image contains an alpha channel (depth = 4), the alpha channel is preserved. This method does
not alter the original image data.
Reimplemented from Fl Image.

void Fl Tiled Image::draw ( int X, int Y, int W, int H, int cx, int cy ) [virtual]
Draws the image with a bounding box.
This form specifies a bounding box for the image, with the origin (upper-lefthand corner) of the image
offset by the cx and cy arguments.
Reimplemented from Fl Image.
The documentation for this class was generated from the following files:

• Fl Tiled Image.H
• Fl Tiled Image.cxx

31.140 Fl Timer Class Reference


This is provided only to emulate the Forms Timer widget.
#include <Fl Timer.H>
Inheritance diagram for Fl Timer:

Fl_Widget

Fl_Timer

Public Member Functions


• char direction () const
Gets or sets the direction of the timer.
• void direction (char d)
Gets or sets the direction of the timer.
• Fl Timer (uchar t, int x, int y, int w, int h, const char ∗l)
Creates a new Fl Timer widget using the given type, position, size, and label string.
• int handle (int)
Handles the specified event.
• char suspended () const
Gets or sets whether the timer is suspended.
• void suspended (char d)
Gets or sets whether the timer is suspended.
• void value (double)
Sets the current timer value.
• double value () const
See void Fl Timer::value(double)
• ∼Fl Timer ()
Destroys the timer and removes the timeout.
31.140. FL TIMER CLASS REFERENCE 745

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.140.1 Detailed Description
This is provided only to emulate the Forms Timer widget.
It works by making a timeout callback every 1/5 second. This is wasteful and inaccurate if you just
want something to happen a fixed time in the future. You should directly call Fl::add timeout() instead.

31.140.2 Constructor & Destructor Documentation


Fl Timer::Fl Timer ( uchar t, int X, int Y, int W, int H, const char ∗ l )
Creates a new Fl Timer widget using the given type, position, size, and label string.
The type parameter can be any of the following symbolic constants:

• FL NORMAL TIMER - The timer just does the callback and displays the string ”Timer” in the
widget.

• FL VALUE TIMER - The timer does the callback and displays the current timer value in the widget.

• FL HIDDEN TIMER - The timer just does the callback and does not display anything.

31.140.3 Member Function Documentation


char Fl Timer::direction ( ) const [inline]
Gets or sets the direction of the timer.
If the direction is zero then the timer will count up, otherwise it will count down from the initial value().

void Fl Timer::direction ( char d ) [inline]


Gets or sets the direction of the timer.
If the direction is zero then the timer will count up, otherwise it will count down from the initial value().

void Fl Timer::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:

Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar


s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.
746 CHAPTER 31. CLASS DOCUMENTATION

int Fl Timer::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.

char Fl Timer::suspended ( ) const [inline]


Gets or sets whether the timer is suspended.

void Fl Timer::suspended ( char d )


Gets or sets whether the timer is suspended.
The documentation for this class was generated from the following files:
• Fl Timer.H
• forms timer.cxx

31.141 Fl Toggle Button Class Reference


The toggle button is a push button that needs to be clicked once to toggle on, and one more time to toggle
off.
#include <Fl Toggle Button.H>
Inheritance diagram for Fl Toggle Button:

Fl_Widget

Fl_Button

Fl_Toggle_Button

Public Member Functions


• Fl Toggle Button (int X, int Y, int W, int H, const char ∗l=0)
Creates a new Fl Toggle Button widget using the given position, size, and label string.
31.142. FL TOOLTIP CLASS REFERENCE 747

Additional Inherited Members


31.141.1 Detailed Description
The toggle button is a push button that needs to be clicked once to toggle on, and one more time to toggle
off.
The Fl Toggle Button subclass displays the ”on” state by drawing a pushed-in button.
Buttons generate callbacks when they are clicked by the user. You control exactly when and how by
changing the values for type() and when().

31.141.2 Constructor & Destructor Documentation


Fl Toggle Button::Fl Toggle Button ( int X, int Y, int W, int H, const char ∗ L = 0 )
Creates a new Fl Toggle Button widget using the given position, size, and label string.
The constructor creates the button using the given position, size, and label.
The inherited destructor deletes the toggle button.
The Button type() is set to FL TOGGLE BUTTON.
Parameters
in X,Y,W,H position and size of the widget
in L widget label, default is no label
The documentation for this class was generated from the following files:
• Fl Toggle Button.H
• Fl Button.cxx

31.142 Fl Tooltip Class Reference


The Fl Tooltip class provides tooltip support for all FLTK widgets.
#include <Fl Tooltip.H>

Static Public Member Functions


• static Fl Color color ()
Gets the background color for tooltips.
• static void color (Fl Color c)
Sets the background color for tooltips.
• static Fl Widget ∗ current ()
Gets the current widget target.
• static void current (Fl Widget ∗)
Sets the current widget target.
• static float delay ()
Gets the tooltip delay.
• static void delay (float f)
Sets the tooltip delay.
• static void disable ()
Same as enable(0), disables tooltips on all widgets.
• static void enable (int b=1)
Enables tooltips on all widgets (or disables if b is false).
• static int enabled ()
Returns non-zero if tooltips are enabled.
748 CHAPTER 31. CLASS DOCUMENTATION

• static void enter area (Fl Widget ∗w, int X, int Y, int W, int H, const char ∗tip)
You may be able to use this to provide tooltips for internal pieces of your widget.
• static Fl Font font ()
Gets the typeface for the tooltip text.
• static void font (Fl Font i)
Sets the typeface for the tooltip text.
• static float hoverdelay ()
Gets the tooltip hover delay, the delay between tooltips.
• static void hoverdelay (float f)
Sets the tooltip hover delay, the delay between tooltips.
• static int margin height ()
• static int margin width ()
• static Fl Fontsize size ()
Gets the size of the tooltip text.
• static void size (Fl Fontsize s)
Sets the size of the tooltip text.
• static Fl Color textcolor ()
Gets the color of the text in the tooltip.
• static void textcolor (Fl Color c)
Sets the color of the text in the tooltip.
• static int wrap width ()

Static Public Attributes


• static void(∗ enter )(Fl Widget ∗w) = nothing
• static void(∗ exit )(Fl Widget ∗w) = nothing

Friends
• void Fl Widget::copy tooltip (const char ∗)
• void Fl Widget::tooltip (const char ∗)

31.142.1 Detailed Description


The Fl Tooltip class provides tooltip support for all FLTK widgets.
It contains only static methods.

Figure 31.44: Fl Tooltip Options


31.142. FL TOOLTIP CLASS REFERENCE 749

31.142.2 Member Function Documentation


static Fl Color Fl Tooltip::color ( ) [inline], [static]
Gets the background color for tooltips.
The default background color is a pale yellow.

static void Fl Tooltip::color ( Fl Color c ) [inline], [static]


Sets the background color for tooltips.
The default background color is a pale yellow.

void Fl Tooltip::current ( Fl Widget ∗ w ) [static]


Sets the current widget target.
Acts as though enter(widget) was done but does not pop up a tooltip. This is useful to prevent a tooltip
from reappearing when a modal overlapping window is deleted. FLTK does this automatically when you
click the mouse button.

static float Fl Tooltip::delay ( ) [inline], [static]


Gets the tooltip delay.
The default delay is 1.0 seconds.

static void Fl Tooltip::delay ( float f ) [inline], [static]


Sets the tooltip delay.
The default delay is 1.0 seconds.

static void Fl Tooltip::disable ( ) [inline], [static]


Same as enable(0), disables tooltips on all widgets.

static void Fl Tooltip::enable ( int b = 1 ) [inline], [static]


Enables tooltips on all widgets (or disables if b is false).

static int Fl Tooltip::enabled ( ) [inline], [static]


Returns non-zero if tooltips are enabled.

void Fl Tooltip::enter area ( Fl Widget ∗ wid, int x, int y, int w, int h, const char ∗ t )
[static]
You may be able to use this to provide tooltips for internal pieces of your widget.
Call this after setting Fl::belowmouse() to your widget (because that calls the above enter() method).
Then figure out what thing the mouse is pointing at, and call this with the widget (this pointer is used to
remove the tooltip if the widget is deleted or hidden, and to locate the tooltip), the rectangle surrounding
the area, relative to the top-left corner of the widget (used to calculate where to put the tooltip), and the text
of the tooltip (which must be a pointer to static data as it is not copied).

static Fl Font Fl Tooltip::font ( ) [inline], [static]


Gets the typeface for the tooltip text.
750 CHAPTER 31. CLASS DOCUMENTATION

static void Fl Tooltip::font ( Fl Font i ) [inline], [static]

Sets the typeface for the tooltip text.

static float Fl Tooltip::hoverdelay ( ) [inline], [static]

Gets the tooltip hover delay, the delay between tooltips.


The default delay is 0.2 seconds.

static void Fl Tooltip::hoverdelay ( float f ) [inline], [static]

Sets the tooltip hover delay, the delay between tooltips.


The default delay is 0.2 seconds.

static Fl Fontsize Fl Tooltip::size ( ) [inline], [static]

Gets the size of the tooltip text.

static void Fl Tooltip::size ( Fl Fontsize s ) [inline], [static]

Sets the size of the tooltip text.

static Fl Color Fl Tooltip::textcolor ( ) [inline], [static]

Gets the color of the text in the tooltip.


The default is black.

static void Fl Tooltip::textcolor ( Fl Color c ) [inline], [static]

Sets the color of the text in the tooltip.


The default is black.
The documentation for this class was generated from the following files:

• Fl Tooltip.H
• Fl.cxx
• Fl Tooltip.cxx

31.143 Fl Tree Class Reference


Tree widget.
#include <Fl Tree.H>
Inheritance diagram for Fl Tree:

Fl_Widget

Fl_Group

Fl_Tree
31.143. FL TREE CLASS REFERENCE 751

Public Member Functions


• Fl Tree Item ∗ add (const char ∗path)
Adds a new item given a menu style ’path’.
• Fl Tree Item ∗ add (const char ∗path, Fl Tree Item ∗newitem)
Adds a new item, given a menu style ’path’.
• Fl Tree Item ∗ add (Fl Tree Item ∗parent item, const char ∗name)
Add a new child item labeled ’name’ to the specified ’parent item’.
• void callback item (Fl Tree Item ∗item)
Sets the item that was changed for this callback.
• Fl Tree Item ∗ callback item ()
Gets the item that caused the callback.
• void callback reason (Fl Tree Reason reason)
Sets the reason for this callback.
• Fl Tree Reason callback reason () const
Gets the reason for this callback.
• void clear ()
Clear the entire tree’s children, including the root.
• void clear children (Fl Tree Item ∗item)
Clear all the children for ’item’.
• int close (Fl Tree Item ∗item, int docallback=1)
Closes the specified ’item’.
• int close (const char ∗path, int docallback=1)
Closes the item specified by ’path’.
• Fl Image ∗ closeicon () const
Returns the icon to be used as the ’close’ icon.
• void closeicon (Fl Image ∗val)
Sets the icon to be used as the ’close’ icon.
• Fl Color connectorcolor () const
Get the connector color used for tree connection lines.
• void connectorcolor (Fl Color val)
Set the connector color used for tree connection lines.
• Fl Tree Connector connectorstyle () const
Returns the line drawing style for inter-connecting items.
• void connectorstyle (Fl Tree Connector val)
Sets the line drawing style for inter-connecting items.
• int connectorwidth () const
Gets the width of the horizontal connection lines (in pixels) that appear to the left of each tree item’s label.
• void connectorwidth (int val)
Sets the width of the horizontal connection lines (in pixels) that appear to the left of each tree item’s label.
• int deselect (Fl Tree Item ∗item, int docallback=1)
De-select the specified item.
• int deselect (const char ∗path, int docallback=1)
Deselect an item specified by ’path’.
• int deselect all (Fl Tree Item ∗item=0, int docallback=1)
Deselect ’item’ and all its children.
• void display (Fl Tree Item ∗item)
752 CHAPTER 31. CLASS DOCUMENTATION

Displays ’item’, scrolling the tree as necessary.


• int displayed (Fl Tree Item ∗item)
See if ’item’ is currently displayed on-screen (visible within the widget).
• void draw ()
Standard FLTK draw() method, handles drawing the tree widget.
• int extend selection dir (Fl Tree Item ∗from, Fl Tree Item ∗to, int dir, int val, bool visible)
Extend the selection between and including ’from’ and ’to’ depending on direction ’dir’, ’val’,
and ’visible’.
• const Fl Tree Item ∗ find clicked () const
Find the item that was last clicked on.
• Fl Tree Item ∗ find clicked ()
Non-const version of Fl Tree::find clicked() const.
• Fl Tree Item ∗ find item (const char ∗path)
Non-const version of Fl Tree::find item(const char ∗path) const.
• const Fl Tree Item ∗ find item (const char ∗path) const
Find the item, given a menu style path, e.g.
• Fl Tree Item ∗ first ()
Returns the first item in the tree, or 0 if none.
• Fl Tree Item ∗ first selected item ()
Returns the first selected item in the tree.
• Fl Tree Item ∗ first visible ()
Returns the first open(), visible item in the tree, or 0 if none.
• Fl Tree Item ∗ first visible item ()
Returns the first open(), visible item in the tree, or 0 if none.
• Fl Tree (int X, int Y, int W, int H, const char ∗L=0)
Constructor.
• Fl Tree Item ∗ get item focus () const
Get the item that currently has keyboard focus.
• int handle (int e)
Standard FLTK event handler for this widget.
• int hposition () const
Returns the horizontal scroll position as a pixel offset.
• void hposition (int pos)
Sets the horizontal scroll offset to position ’pos’.
• Fl Tree Item ∗ insert (Fl Tree Item ∗item, const char ∗name, int pos)
Insert a new item ’name’ into ’item’s children at position ’pos’.
• Fl Tree Item ∗ insert above (Fl Tree Item ∗above, const char ∗name)
Inserts a new item ’name’ above the specified Fl Tree Item ’above’.
• int is close (Fl Tree Item ∗item) const
See if the specified ’item’ is closed.
• int is close (const char ∗path) const
See if item specified by ’path’ is closed.
• int is hscroll visible () const
See if the horizontal scrollbar is currently visible.
• int is open (Fl Tree Item ∗item) const
See if ’item’ is open.
• int is open (const char ∗path) const
31.143. FL TREE CLASS REFERENCE 753

See if item specified by ’path’ is open.


• int is scrollbar (Fl Widget ∗w)
See if widget ’w’ is one of the Fl Tree widget’s scrollbars.
• int is selected (Fl Tree Item ∗item) const
See if the specified ’item’ is selected.
• int is selected (const char ∗path)
See if item specified by ’path’ is selected.
• int is vscroll visible () const
See if the vertical scrollbar is currently visible.
• Fl Tree Item ∗ item clicked ()
Return the item that was last clicked.
• Fl Color item labelbgcolor (void) const
Get the default label background color used for creating new items.
• void item labelbgcolor (Fl Color val)
Set the default label background color used for creating new items.
• Fl Color item labelfgcolor (void) const
Get the default label foreground color used for creating new items.
• void item labelfgcolor (Fl Color val)
Set the default label foreground color used for creating new items.
• Fl Font item labelfont () const
Get the default font face used for creating new items.
• void item labelfont (Fl Font val)
Set the default font face used for creating new items.
• Fl Fontsize item labelsize () const
Get the default label fontsize used for creating new items.
• void item labelsize (Fl Fontsize val)
Set the default label font size used for creating new items.
• int item pathname (char ∗pathname, int pathnamelen, const Fl Tree Item ∗item) const
Return ’pathname’ of size ’pathnamelen’ for the specified ’item’.
• int labelmarginleft () const
Get the amount of white space (in pixels) that should appear to the left of the label text.
• void labelmarginleft (int val)
Set the amount of white space (in pixels) that should appear to the left of the label text.
• Fl Tree Item ∗ last ()
Returns the last item in the tree.
• Fl Tree Item ∗ last selected item ()
Returns the last selected item in the tree.
• Fl Tree Item ∗ last visible ()
Returns the last open(), visible item in the tree.
• Fl Tree Item ∗ last visible item ()
Returns the last open(), visible item in the tree.
• int linespacing () const
Get the amount of white space (in pixels) that should appear between items in the tree.
• void linespacing (int val)
Sets the amount of white space (in pixels) that should appear between items in the tree.
• void load (class Fl Preferences &)
754 CHAPTER 31. CLASS DOCUMENTATION

Load FLTK preferences.


• int marginleft () const
Get the amount of white space (in pixels) that should appear between the widget’s left border and the tree’s
contents.
• void marginleft (int val)
Set the amount of white space (in pixels) that should appear between the widget’s left border and the left
side of the tree’s contents.
• int margintop () const
Get the amount of white space (in pixels) that should appear between the widget’s top border and the top of
the tree’s contents.
• void margintop (int val)
Sets the amount of white space (in pixels) that should appear between the widget’s top border and the top
of the tree’s contents.
• Fl Tree Item ∗ next (Fl Tree Item ∗item=0)
Return the next item after ’item’, or 0 if no more items.
• Fl Tree Item ∗ next item (Fl Tree Item ∗item, int dir=FL Down, bool visible=false)
Returns next item after ’item’ in direction ’dir’ depending on ’visible’.
• Fl Tree Item ∗ next selected item (Fl Tree Item ∗item=0)
Returns the next selected item after ’item’.
• Fl Tree Item ∗ next selected item (Fl Tree Item ∗item, int dir)
Returns the next selected item above or below ’item’, depending on ’dir’.
• int open (Fl Tree Item ∗item, int docallback=1)
Open the specified ’item’.
• int open (const char ∗path, int docallback=1)
Opens the item specified by ’path’.
• void open toggle (Fl Tree Item ∗item, int docallback=1)
Toggle the open state of ’item’.
• int openchild marginbottom () const
Get the amount of white space (in pixels) that should appear below an open child tree’s contents.
• void openchild marginbottom (int val)
Set the amount of white space (in pixels) that should appear below an open child tree’s contents.
• Fl Image ∗ openicon () const
Returns the icon to be used as the ’open’ icon.
• void openicon (Fl Image ∗val)
Sets the icon to be used as the ’open’ icon.
• const Fl Tree Prefs & prefs () const
• Fl Tree Item ∗ prev (Fl Tree Item ∗item=0)
Return the previous item before ’item’, or 0 if no more items.
• void recalc tree ()
Schedule tree to recalc the entire tree size.
• int remove (Fl Tree Item ∗item)
Remove the specified ’item’ from the tree.
• void resize (int, int, int, int)
Resizes the Fl Group widget and all of its children.
• Fl Tree Item ∗ root ()
Returns the root item.
• void root (Fl Tree Item ∗newitem)
31.143. FL TREE CLASS REFERENCE 755

Sets the root item to ’newitem’.


• void root label (const char ∗new label)
Set the label for the root item to ’new label’.
• int scrollbar size () const
Gets the default size of scrollbars’ troughs for this widget in pixels.
• void scrollbar size (int size)
Sets the pixel size of the scrollbars’ troughs to ’size’ for this widget, in pixels.
• int select (Fl Tree Item ∗item, int docallback=1)
Select the specified ’item’.
• int select (const char ∗path, int docallback=1)
Select the item specified by ’path’.
• int select all (Fl Tree Item ∗item=0, int docallback=1)
Select ’item’ and all its children.
• int select only (Fl Tree Item ∗selitem, int docallback=1)
Select only the specified ’item’, deselecting all others that might be selected.
• void select toggle (Fl Tree Item ∗item, int docallback=1)
Toggle the select state of the specified ’item’.
• Fl Boxtype selectbox () const
Sets the style of box used to draw selected items.
• void selectbox (Fl Boxtype val)
Gets the style of box used to draw selected items.
• Fl Tree Select selectmode () const
Gets the tree’s current selection mode.
• void selectmode (Fl Tree Select val)
Sets the tree’s selection mode.
• void set item focus (Fl Tree Item ∗item)
Set the item that currently should have keyboard focus.
• void show item (Fl Tree Item ∗item, int yoff)
Adjust the vertical scroll bar so that ’item’ is visible ’yoff’ pixels from the top of the Fl Tree widget’s
display.
• void show item (Fl Tree Item ∗item)
Adjust the vertical scroll bar to show ’item’ at the top of the display IF it is currently off-screen (e.g.
• void show item bottom (Fl Tree Item ∗item)
Adjust the vertical scrollbar so that ’item’ is at the bottom of the display.
• void show item middle (Fl Tree Item ∗item)
Adjust the vertical scrollbar so that ’item’ is in the middle of the display.
• void show item top (Fl Tree Item ∗item)
Adjust the vertical scrollbar so that ’item’ is at the top of the display.
• void show self ()
Print the tree as ’ascii art’ to stdout.
• int showcollapse () const
Returns 1 if the collapse icon is enabled, 0 if not.
• void showcollapse (int val)
Set if we should show the collapse icon or not.
• int showroot () const
Returns 1 if the root item is to be shown, or 0 if not.
• void showroot (int val)
756 CHAPTER 31. CLASS DOCUMENTATION

Set if the root item should be shown or not.


• Fl Tree Sort sortorder () const
Set the default sort order used when items are added to the tree.
• void sortorder (Fl Tree Sort val)
Gets the sort order used to add items to the tree.
• Fl Image ∗ usericon () const
Returns the Fl Image being used as the default user icon for all newly created items.
• void usericon (Fl Image ∗val)
Sets the Fl Image to be used as the default user icon for all newly created items.
• int usericonmarginleft () const
Get the amount of white space (in pixels) that should appear to the left of the usericon.
• void usericonmarginleft (int val)
Set the amount of white space (in pixels) that should appear to the left of the usericon.
• int vposition () const
Returns the vertical scroll position as a pixel offset.
• void vposition (int pos)
Sets the vertical scroll offset to position ’pos’.
• ∼Fl Tree ()
Destructor.

Protected Member Functions


• void do callback for item (Fl Tree Item ∗item, Fl Tree Reason reason)
Do the callback for the specified ’item’ using ’reason’, setting the callback item() and callback -
reason().
• int draw tree ()
• void extend selection (Fl Tree Item ∗from, Fl Tree Item ∗to)
Extend a selection between ’from’ and ’to’.
• void item clicked (Fl Tree Item ∗val)
Set the item that was last clicked.
• Fl Tree Item ∗ next visible item (Fl Tree Item ∗start, int dir)
Returns next open(), visible item above (dir==FL Up) or below (dir==FL Down) the specified ’item’,
or 0 if no more items.

Protected Attributes
• Fl Scrollbar ∗ vscroll
Vertical scrollbar.

Friends
• class Fl Tree Item
31.143. FL TREE CLASS REFERENCE 757

Additional Inherited Members


31.143.1 Detailed Description
Tree widget.

Figure 31.45: Fl Tree example program

Fl Tree // Top level widget


|--- Fl Tree Item // Items in the tree
|--- Fl Tree Prefs // Preferences for the tree
|--- Fl Tree Connector (enum) // Connection modes
|--- Fl Tree Select (enum) // Selection modes
|--- Fl Tree Sort (enum) // Sort behavior

Similar to Fl_Browser, Fl_Tree is a browser of Fl_Tree_Item’s arranged


in a parented hierarchy, or ’tree’. Subtrees can be expanded or closed.
Items can be added, deleted, inserted, sorted and re-ordered.

The tree items may also contain other FLTK widgets, like buttons, input fields,
or even "custom" widgets.

The callback() is invoked depending on the value of when():

- FL_WHEN_RELEASE -- callback invoked when left mouse button is released on an item


- FL_WHEN_CHANGED -- callback invoked when left mouse changes selection state

The simple way to define a tree:

#include <FL/Fl Tree.H>


[..]
Fl Tree tree(X,Y,W,H);
tree.begin();
tree.add("Flintstones/Fred");
tree.add("Flintstones/Wilma");
tree.add("Flintstones/Pebbles");
tree.add("Simpsons/Homer");
tree.add("Simpsons/Marge");
tree.add("Simpsons/Bart");
tree.add("Simpsons/Lisa");
tree.end();

FEATURES
Items can be added with add(),
removed with remove(),
completely cleared with clear(),
inserted with insert() and insert above(),
selected/deselected with select() and deselect(),
open/closed with open() and close(),
758 CHAPTER 31. CLASS DOCUMENTATION

positioned on the screen with show item top(), show item middle() and show item bottom(),
item children can be swapped around with Fl Tree Item::swap children(),
sorting can be controlled when items are add()ed via sortorder().
You can walk the entire tree with first() and next().
You can walk visible items with first visible item() and next visible item().
You can walk selected items with first selected item() and next selected item().
Items can be found by their pathname using find item(const char∗), and an item’s pathname can be
found with item pathname().
The selected items’ colors are controlled by selection color() (inherited from Fl Widget).
A hook is provided to allow you to redefine how item’s labels are drawn via Fl Tree::item draw -
callback().
SELECTION OF ITEMS
The tree can have different selection behaviors controlled by selectmode(). The background color
used for selected items is the Fl Tree::selection color(). The foreground color for selected items is
controlled internally with fl contrast().
CHILD WIDGETS
FLTK widgets (including custom widgets) can be assigned to tree items via Fl Tree Item::widget().

When an Fl Tree Item::widget() is defined, the default behavior is for the widget() to be shown in
place of the item’s label (if it has one). Only the widget()’s width will be used; the widget()’s x() and
y() position will be managed by the tree, and the h() will track the item’s height. This default behavior
can be altered (ABI 1.3.1): Setting Fl Tree::item draw mode()’s FL TREE ITEM DRAW LABEL-
AND WIDGET flag causes the label + widget to be displayed together in that order, and adding
the FL TREE ITEM HEIGHT FROM WIDGET flag causes widget’s height to define the widget()’s
height.
ICONS
The tree’s open/close icons can be redefined with Fl Tree::openicon(), Fl Tree::closeicon(). User icons
can either be changed globally with Fl Tree::usericon(), or on a per-item basis with Fl Tree Item-
::usericon().

Various default preferences can be globally manipulated via Fl Tree Prefs, including colors, margins,
icons, connection lines, etc.
FONTS AND COLORS
When adding new items to the tree, the new items get the defaults for fonts and colors from:

• Fl Tree::item labelfont() – The default item label font (default: FL HELVETICA)


• Fl Tree::item labelsize() – The default item label size (default: FL NORMAL SIZE)
• Fl Tree::item labelfgcolor() – The default item label foreground color (default: FL FOREGRO-
UND COLOR)
• Fl Tree::item labelbgcolor() – The default item label background color (default: 0xffffffff, which
tree uses as ’transparent’)

Each item (Fl Tree Item) inherits a copy of these font/color attributes when created, and each item
has its own methods to let the app change these values on a per-item basis using methods of the same
name:

• Fl Tree Item::labelfont() – The item’s label font (default: FL HELVETICA)


31.143. FL TREE CLASS REFERENCE 759

• Fl Tree Item::labelsize() – The item’s label size (default: FL NORMAL SIZE)


• Fl Tree Item::labelfgcolor() – The item’s label foreground color (default: FL FOREGROUND-
COLOR)
• Fl Tree Item::labelbgcolor() – The item’s label background color (default: 0xffffffff, which uses
the tree’s own bg color)
CALLBACKS
The tree’s callback() will be invoked when items change state or are open/closed. when() controls
when mouse/keyboard events invoke the callback. callback item() and callback reason() can be used
to determine the cause of the callback. e.g.

void MyTreeCallback(Fl Widget *w, void *data) {


Fl Tree *tree = (Fl Tree*)w;
Fl Tree Item *item = (Fl Tree Item*)tree->
callback item(); // get selected item
switch ( tree->callback reason() ) {
case FL TREE REASON SELECTED: [..]
case FL TREE REASON DESELECTED: [..]
case FL TREE REASON RESELECTED: [..]
case FL TREE REASON OPENED: [..]
case FL TREE REASON CLOSED: [..]
}

SIMPLE EXAMPLES
To find all the selected items:
for ( Fl Tree Item *i=first selected item(); i; i=
next selected item(i) )
printf("Item %s is selected\n", i->label());

To get an item’s full menu pathname, use Fl Tree::item pathname(), e.g.


char pathname[256] = "???";
tree->item pathname(pathname, sizeof(pathname), item); // eg.
"Parent/Child/Item"

To walk all the items of the tree from top to bottom:


// Walk all the items in the tree, and print their labels
for ( Fl Tree Item *item = tree->first(); item; item = tree->
next(item) ) {
printf("Item: %s\n", item->label());
}

To recursively walk all the children of a particular item, define a function that uses recursion:
// Find all of the item’s children and print an indented report of their labels
void my print all children(Fl Tree Item *item, int indent=0) {
for ( int t=0; t<item->children(); t++ ) {
printf("%*s Item: %s\n", indent, "", item->child(t)->label());
my print all children(item->child(t), indent+4); // recurse
}
}

To change the default label font and color when creating new items:
tree = new Fl Tree(..);
tree->item labelfont(FL COURIER); // Use Courier font for all new items
tree->item labelfgcolor(FL RED); // Use red color for labels of all new items
[..]
// Now create the items in the tree using the above defaults.
tree->add("Aaa");
tree->add("Bbb");
[..]
760 CHAPTER 31. CLASS DOCUMENTATION

To change the font and color of all existing items in the tree:
// Change the font and color of all items currently in the tree
for ( Fl Tree Item *item = tree->first(); item; item = tree->
next(item) ) {
item->labelfont(FL COURIER);
item->labelcolor(FL RED);
}

DISPLAY DESCRIPTION
The following image shows the tree’s various visual elements and the methods that control them:

Figure 31.46: Fl Tree elements

The following shows the protected ’tree inner’ (tix..) and ’tree outer’ (tox..) dimension variables:

Figure 31.47: Fl Tree inner/outer dimensions

KEYBOARD BINDINGS
The following table lists keyboard bindings for navigating the tree:

31.143.2 Member Function Documentation


Fl Tree Item ∗ Fl Tree::add ( const char ∗ path )
Adds a new item given a menu style ’path’.
Same as calling add(path, NULL);
31.143. FL TREE CLASS REFERENCE 761

Parameters
in path The path to the item to be created, e.g. ”Flintsone/Fred”.

Returns
The new item added, or 0 on error.

See Also
add(const char∗,Fl Tree Item∗)

Version
1.3.0 release

Fl Tree Item ∗ Fl Tree::add ( const char ∗ path, Fl Tree Item ∗ item )


Adds a new item, given a menu style ’path’.
Any parent nodes that don’t already exist are created automatically. Adds the item based on the value
of sortorder(). If ’item’ is NULL, a new item is created.
To specify items or submenus that contain slashes (’/’ or ’\’) use an escape character to protect them,
e.g.
tree->add("/Holidays/Photos/12\\/25\\2010"); // Adds item "12/25/2010"
tree->add("/Pathnames/c:\\\\Program Files\\\\MyApp"); // Adds item "c:\Program Files\MyApp"

Parameters
in path The path to the item, e.g. ”Flintsone/Fred”.
in item The new item to be added. If NULL, a new item is created with a name
that is the last element in ’path’.

Returns
The new item added, or 0 on error.

Version
1.3.3

Fl Tree Item ∗ Fl Tree::add ( Fl Tree Item ∗ parent item, const char ∗ name )
Add a new child item labeled ’name’ to the specified ’parent item’.
Parameters
in parent item The parent item the new child item will be added to. Must not be NULL.
in name The label for the new item

Returns
The new item added.

Version
1.3.0 release
762 CHAPTER 31. CLASS DOCUMENTATION

void Fl Tree::callback item ( Fl Tree Item ∗ item )


Sets the item that was changed for this callback.
Used internally to pass the item that invoked the callback.

Fl Tree Item ∗ Fl Tree::callback item ( )


Gets the item that caused the callback.
The callback() can use this value to see which item changed.

void Fl Tree::callback reason ( Fl Tree Reason reason )


Sets the reason for this callback.
Used internally to pass the reason the callback was invoked.

Fl Tree Reason Fl Tree::callback reason ( ) const


Gets the reason for this callback.
The callback() can use this value to see why it was called. Example:
void MyTreeCallback(Fl Widget *w, void *userdata) {
Fl Tree *tree = (Fl Tree*)w;
Fl Tree Item *item = tree->callback item(); // the item changed (can be
NULL if more than one item was changed!)
switch ( tree->callback reason() ) { // reason callback was invoked
case FL TREE REASON OPENED: ..item was opened..
case FL TREE REASON CLOSED: ..item was closed..
case FL TREE REASON SELECTED: ..item was selected..
case FL TREE REASON RESELECTED: ..item was reselected (double-clicked, etc)..
case FL TREE REASON DESELECTED: ..item was deselected..
}
}

See Also
item reselect mode() – enables FL TREE REASON RESELECTED events

void Fl Tree::clear ( )
Clear the entire tree’s children, including the root.
The tree will be left completely empty.

void Fl Tree::clear children ( Fl Tree Item ∗ item )


Clear all the children for ’item’.
Item may not be NULL.

int Fl Tree::close ( Fl Tree Item ∗ item, int docallback = 1 )


Closes the specified ’item’.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
31.143. FL TREE CLASS REFERENCE 763

Parameters
in item – the item to be closed. Must not be NULL.
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - callback() is not invoked


• 1 - callback() is invoked if item changed (default), callback -
reason() will be FL TREE REASON CLOSED

Returns
• 1 – item was closed
• 0 – item was already closed, no change

See Also
open(), close(), is open(), is close(), callback item(), callback reason()

int Fl Tree::close ( const char ∗ path, int docallback = 1 )


Closes the item specified by ’path’.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
Items or submenus that themselves contain slashes (’/’ or ’\’) should be escaped, e.g. close(”Holidays/12\\/25\//2010”).
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)
in docallback – A flag that determines if the callback() is invoked or not:
• 0 - callback() is not invoked
• 1 - callback() is invoked if item changed (default), callback -
reason() will be FL TREE REASON CLOSED

Returns
• 1 – OK: item closed
• 0 – OK: item was already closed, no change
• -1 – ERROR: item was not found

See Also
open(), close(), is open(), is close(), callback item(), callback reason()

Fl Image ∗ Fl Tree::closeicon ( ) const


Returns the icon to be used as the ’close’ icon.
If none was set, the internal default is returned, a simple ’[-]’ icon.

void Fl Tree::closeicon ( Fl Image ∗ val )


Sets the icon to be used as the ’close’ icon.
This overrides the built in default ’[-]’ icon.
764 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in val – The new image, or zero to use the default [-] icon.

void Fl Tree::connectorstyle ( Fl Tree Connector val )


Sets the line drawing style for inter-connecting items.
See Fl Tree Connector for possible values.

int Fl Tree::deselect ( Fl Tree Item ∗ item, int docallback = 1 )


De-select the specified item.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in item – the item to be selected. Must not be NULL.
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - the callback() is not invoked


• 1 - the callback() is invoked if item changed state (default),
callback reason() will be FL TREE REASON DESELECTED

Returns
• 0 - item was already deselected, no change was made
• 1 - item’s state was changed

int Fl Tree::deselect ( const char ∗ path, int docallback = 1 )


Deselect an item specified by ’path’.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
Items or submenus that themselves contain slashes (’/’ or ’\’) should be escaped, e.g. deselect(”-
Holidays/12\\/25\//2010”).
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - the callback() is not invoked


• 1 - the callback() is invoked if item changed state (default),
callback reason() will be FL TREE REASON DESELECTED

Returns
• 1 - OK: item’s state was changed
• 0 - OK: item was already deselected, no change was made
• -1 - ERROR: item was not found
31.143. FL TREE CLASS REFERENCE 765

int Fl Tree::deselect all ( Fl Tree Item ∗ item = 0, int docallback = 1 )


Deselect ’item’ and all its children.
If item is NULL, first() is used.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in item The item that will be deselected (along with all its children). If NULL,
first() is used.
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - the callback() is not invoked


• 1 - the callback() is invoked for each item that changed state (de-
fault), callback reason() will be FL TREE REASON DESELEC-
TED

Returns
Count of how many items were actually changed to the deselected state.

void Fl Tree::display ( Fl Tree Item ∗ item )


Displays ’item’, scrolling the tree as necessary.
Parameters
in item The item to be displayed. If NULL, first() is used.

int Fl Tree::displayed ( Fl Tree Item ∗ item )


See if ’item’ is currently displayed on-screen (visible within the widget).
This can be used to detect if the item is scrolled off-screen. Checks to see if the item’s vertical position
is within the top and bottom edges of the display window. This does NOT take into account the hide() /
show() or open() / close() status of the item.
Parameters
in item The item to be checked. If NULL, first() is used.

Returns
1 if displayed, 0 if scrolled off screen or no items are in tree.

void Fl Tree::extend selection ( Fl Tree Item ∗ from, Fl Tree Item ∗ to ) [protected]


Extend a selection between ’from’ and ’to’.
Extends selection for items and all children, visible (’open’) or not. Walks entire tree from top to
bottom looking for ’from’ and ’to’.

Version
1.3.0
766 CHAPTER 31. CLASS DOCUMENTATION

int Fl Tree::extend selection dir ( Fl Tree Item ∗ from, Fl Tree Item ∗ to, int dir, int val, bool
visible )
Extend the selection between and including ’from’ and ’to’ depending on direction ’dir’, ’val’,
and ’visible’.
Efficient: does not walk entire tree; starts with ’from’ and stops at ’to’ while moving in direction
’dir’. Dir must be specified though. Handles calling redraw() if anything changed.
Parameters
in from Starting item
in to Ending item
in dir Direction to extend selection (FL Up or FL Down)
in val 0=deselect, 1=select, 2=toggle
in visible true=affect only open(), visible items,
false=affect open or closed items (default)

Returns
The number of items whose selection states were changed, if any.

Version
1.3.3

const Fl Tree Item ∗ Fl Tree::find clicked ( ) const


Find the item that was last clicked on.
You should use callback item() instead, which is fast, and is meant to be used within a callback to
determine the item clicked.
This method walks the entire tree looking for the first item that is under the mouse, i.e. at Fl::event x()
/ Fl::event y().
Use this method /only/ if you’ve subclassed Fl Tree, and are receiving events before Fl Tree has been
able to process and update callback item().
Returns
The item clicked, or NULL if no item was under the current event.
Version
1.3.0

Fl Tree Item ∗ Fl Tree::find clicked ( )


Non-const version of Fl Tree::find clicked() const.
Version
1.3.0

const Fl Tree Item ∗ Fl Tree::find item ( const char ∗ path ) const


Find the item, given a menu style path, e.g.
”/Parent/Child/item”. There is both a const and non-const version of this method. Const version allows
pure const methods to use this method to do lookups without causing compiler errors.
To specify items or submenus that contain slashes (’/’ or ’\’) use an escape character to protect them,
e.g.
tree->add("/Holidays/Photos/12\\/25\\2010"); // Adds item "12/25/2010"
tree->add("/Pathnames/c:\\\\Program Files\\\\MyApp"); // Adds item "c:\Program Files\MyApp"
31.143. FL TREE CLASS REFERENCE 767

Parameters
in path – the tree item’s pathname to be found (e.g. ”Flintstones/Fred”)

Returns
The item, or NULL if not found.

See Also
item pathname()

Fl Tree Item ∗ Fl Tree::first ( )


Returns the first item in the tree, or 0 if none.
Use this to walk the tree in the forward direction, e.g.

for ( Fl Tree Item *item = tree->first(); item; item = tree->


next(item) )
printf("Item: %s\n", item->label());

Returns
First item in tree, or 0 if none (tree empty).

See Also
first(), next(), last(), prev()

Fl Tree Item ∗ Fl Tree::first selected item ( )


Returns the first selected item in the tree.
Use this to walk the tree from top to bottom looking for all the selected items, e.g.

// Walk tree forward, from top to bottom


for ( Fl Tree Item *i=tree->first selected item(); i; i=tree->
next selected item(i) )
printf("Selected item: %s\n", i->label());

Returns
The first selected item, or 0 if none.

See Also
first selected item(), last selected item(), next selected item()

Fl Tree Item ∗ Fl Tree::first visible ( )


Returns the first open(), visible item in the tree, or 0 if none.

Deprecated in 1.3.3 ABI – use first visible item() instead.


768 CHAPTER 31. CLASS DOCUMENTATION

Fl Tree Item ∗ Fl Tree::first visible item ( )


Returns the first open(), visible item in the tree, or 0 if none.
Returns
First visible item in tree, or 0 if none.

See Also
first visible item(), last visible item(), next visible item()

Version
1.3.3

int Fl Tree::handle ( int e ) [virtual]


Standard FLTK event handler for this widget.
Todo add Fl Widget Tracker (see Fl Browser .cxx::handle())
Reimplemented from Fl Group.

int Fl Tree::hposition ( ) const


Returns the horizontal scroll position as a pixel offset.
The position returned is how many pixels of the tree are scrolled off the left edge of the screen.
See Also
vposition(), hposition()

Note
Must be using FLTK ABI 1.3.3 or higher for this to be effective.

void Fl Tree::hposition ( int pos )


Sets the horizontal scroll offset to position ’pos’.
The position is how many pixels of the tree are scrolled off the left edge of the screen.
Parameters
in pos The vertical position (in pixels) to scroll the browser to.

Note
Must be using FLTK ABI 1.3.3 or higher for this to be effective.

Fl Tree Item ∗ Fl Tree::insert ( Fl Tree Item ∗ item, const char ∗ name, int pos )
Insert a new item ’name’ into ’item’s children at position ’pos’.
Example:
tree->add("Aaa/000"); // "000" is index 0 in Aaa’s children
tree->add("Aaa/111"); // "111" is index 1 in Aaa’s children
tree->add("Aaa/222"); // "222" is index 2 in Aaa’s children
..
// How to use insert() to insert a new item between Aaa/111 + Aaa/222
Fl Tree Item *item = tree->find item("Aaa"); // get parent item Aaa
if (item) tree->insert(item, "New item", 2); // insert as a child of Aaa at index #2
31.143. FL TREE CLASS REFERENCE 769

Parameters
in item The existing item to insert new child into. Must not be NULL.
in name The label for the new item
in pos The position of the new item in the child list

Returns
The new item added.

See Also
insert above()

Fl Tree Item ∗ Fl Tree::insert above ( Fl Tree Item ∗ above, const char ∗ name )
Inserts a new item ’name’ above the specified Fl Tree Item ’above’.
Example:
tree->add("Aaa/000"); // "000" is index 0 in Aaa’s children
tree->add("Aaa/111"); // "111" is index 1 in Aaa’s children
tree->add("Aaa/222"); // "222" is index 2 in Aaa’s children
..
// How to use insert above() to insert a new item above Aaa/222
Fl Tree Item *item = tree->find item("Aaa/222"); // get item Aaa/222
if (item) tree->insert above(item, "New item"); // insert new item above it

Parameters
in above – the item above which to insert the new item. Must not be NULL.
in name – the name of the new item

Returns
The new item added, or 0 if ’above’ could not be found.

See Also
insert()

int Fl Tree::is close ( Fl Tree Item ∗ item ) const


See if the specified ’item’ is closed.
Parameters
in item – the item to be tested. Must not be NULL.

Returns
• 1 : item is open
• 0 : item is closed

int Fl Tree::is close ( const char ∗ path ) const


See if item specified by ’path’ is closed.
Items or submenus that themselves contain slashes (’/’ or ’\’) should be escaped, e.g. is close(”-
Holidays/12\\/25\//2010”).
770 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)

Returns
• 1 - OK: item is closed
• 0 - OK: item is open
• -1 - ERROR: item was not found

int Fl Tree::is hscroll visible ( ) const


See if the horizontal scrollbar is currently visible.
Returns
1 if scrollbar visible, 0 if not.

Note
Must be using FLTK ABI 1.3.3 or higher for this to be effective.

int Fl Tree::is open ( Fl Tree Item ∗ item ) const


See if ’item’ is open.
Items that are ’open’ are themselves not necessarily visible; one of the item’s parents might be closed.
Parameters
in item – the item to be tested. Must not be NULL.

Returns
• 1 : item is open
• 0 : item is closed

int Fl Tree::is open ( const char ∗ path ) const


See if item specified by ’path’ is open.
Items or submenus that themselves contain slashes (’/’ or ’\’) should be escaped, e.g. is open(”-
Holidays/12\\/25\//2010”).
Items that are ’open’ are themselves not necessarily visible; one of the item’s parents might be closed.
Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)

Returns
• 1 - OK: item is open
• 0 - OK: item is closed
• -1 - ERROR: item was not found

See Also
Fl Tree Item::visible r()
31.143. FL TREE CLASS REFERENCE 771

int Fl Tree::is scrollbar ( Fl Widget ∗ w )


See if widget ’w’ is one of the Fl Tree widget’s scrollbars.
Use this to skip over the scrollbars when walking the child() array. Example:
for ( int i=0; i<tree->children(); i++ ) { // walk children
Fl Widget *w= tree->child(i);
if ( brow->is scrollbar(w) ) continue; // skip scrollbars
..do work here..
}

Parameters
in w Widget to test

Returns
1 if w is a scrollbar, 0 if not.

Todo should be const

int Fl Tree::is selected ( Fl Tree Item ∗ item ) const


See if the specified ’item’ is selected.
Parameters
in item – the item to be tested. Must not be NULL.

Returns
• 1 : item selected
• 0 : item deselected

int Fl Tree::is selected ( const char ∗ path )


See if item specified by ’path’ is selected.
Items or submenus that themselves contain slashes (’/’ or ’\’) should be escaped, e.g. is selected(”-
Holidays/12\\/25\//2010”).
Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)

Returns
• 1 : item selected
• 0 : item deselected
• -1 : item was not found

int Fl Tree::is vscroll visible ( ) const


See if the vertical scrollbar is currently visible.

Returns
1 if scrollbar visible, 0 if not.
772 CHAPTER 31. CLASS DOCUMENTATION

void Fl Tree::item clicked ( Fl Tree Item ∗ item ) [protected]


Set the item that was last clicked.
Should only be used by subclasses needing to change this value. Normally Fl Tree manages this value.

Deprecated in 1.3.3 ABI – use callback item() instead.

Fl Tree Item ∗ Fl Tree::item clicked ( )


Return the item that was last clicked.
Valid only from within the callback().
Returns
The item clicked, or 0 if none. 0 may also be used to indicate several items were clicked/changed.

Deprecated in 1.3.3 ABI – use callback item() instead.

Fl Color Fl Tree::item labelbgcolor ( void ) const


Get the default label background color used for creating new items.
If the color is 0xffffffff, it is ’transparent’.

void Fl Tree::item labelbgcolor ( Fl Color val )


Set the default label background color used for creating new items.
A special case is made for color 0xffffffff (default) which is treated as ’transparent’. To change the
background color on a per-item basis, use Fl Tree Item::labelbgcolor(Fl Color)

void Fl Tree::item labelfgcolor ( Fl Color val )


Set the default label foreground color used for creating new items.
To change the foreground color on a per-item basis, use Fl Tree Item::labelfgcolor(Fl Color)

void Fl Tree::item labelfont ( Fl Font val )


Set the default font face used for creating new items.
To change the font face on a per-item basis, use Fl Tree Item::labelfont(Fl Font)

void Fl Tree::item labelsize ( Fl Fontsize val )


Set the default label font size used for creating new items.
To change the font size on a per-item basis, use Fl Tree Item::labelsize(Fl Fontsize)

int Fl Tree::item pathname ( char ∗ pathname, int pathnamelen, const Fl Tree Item ∗ item ) const
Return ’pathname’ of size ’pathnamelen’ for the specified ’item’.
If ’item’ is NULL, root() is used.
The tree’s root will be included in the pathname of showroot() is on.
Menu items or submenus that contain slashes (’/’ or ’\’) in their names will be escaped with a backslash.
This is symmetrical with the add() function which uses the same escape pattern to set names.
31.143. FL TREE CLASS REFERENCE 773

Parameters
out pathname The string to use to return the pathname
in pathnamelen The maximum length of the string (including NULL). Must not be zero.
in item The item whose pathname is to be returned.

Returns
• 0 : OK (pathname returns the item’s pathname)
• -1 : item not found (pathname=””)
• -2 : pathname not large enough (pathname=””)

See Also
find item()

int Fl Tree::labelmarginleft ( ) const


Get the amount of white space (in pixels) that should appear to the left of the label text.

void Fl Tree::labelmarginleft ( int val )


Set the amount of white space (in pixels) that should appear to the left of the label text.

Fl Tree Item ∗ Fl Tree::last ( )


Returns the last item in the tree.
This can be used to walk the tree in reverse, e.g.
for ( Fl Tree Item *item = tree->last(); item; item = tree->prev() )
printf("Item: %s\n", item->label());

Returns
Last item in the tree, or 0 if none (tree empty).

See Also
first(), next(), last(), prev()

Fl Tree Item ∗ Fl Tree::last selected item ( )


Returns the last selected item in the tree.
Use this to walk the tree in reverse from bottom to top looking for all the selected items, e.g.
// Walk tree in reverse, from bottom to top
for ( Fl Tree Item *i=tree->last selected item(); i; i=tree->
next selected item(i, FL Up) )
printf("Selected item: %s\n", i->label());

Returns
The last selected item, or 0 if none.

See Also
first selected item(), last selected item(), next selected item()

Version
1.3.3
774 CHAPTER 31. CLASS DOCUMENTATION

Fl Tree Item ∗ Fl Tree::last visible ( )


Returns the last open(), visible item in the tree.

Deprecated in 1.3.3 – use last visible item() instead.

Fl Tree Item ∗ Fl Tree::last visible item ( )


Returns the last open(), visible item in the tree.

Returns
Last visible item in the tree, or 0 if none.

See Also
first visible item(), last visible item(), next visible item()

Version
1.3.3

void Fl Tree::load ( class Fl Preferences & prefs )


Load FLTK preferences.
Read a preferences database into the tree widget.
A preferences database is a hierarchical collection of data which can be directly loaded into the tree
view for inspection.
Parameters
in prefs the Fl Preferences database

Fl Tree Item ∗ Fl Tree::next ( Fl Tree Item ∗ item = 0 )


Return the next item after ’item’, or 0 if no more items.
Use this code to walk the entire tree:

for ( Fl Tree Item *i = tree->first(); i; i = tree->next(i) )


printf("Item: %s\n", i->label());

Parameters
in item The item to use to find the next item. If NULL, returns 0.

Returns
Next item in tree, or 0 if at last item.

See Also
first(), next(), last(), prev()
31.143. FL TREE CLASS REFERENCE 775

Fl Tree Item ∗ Fl Tree::next item ( Fl Tree Item ∗ item, int dir = FL Down, bool visible = false )
Returns next item after ’item’ in direction ’dir’ depending on ’visible’.
Next item will be above (if dir==FL Up) or below (if dir==FL Down). If ’visible’ is true, only
items whose parents are open() will be returned. If ’visible’ is false, even items whose parents are
close()ed will be returned.
If item is 0, the return value will be the result of this truth table:
visible=true visible=false
------------------- -------------
dir=Fl Up: last visible item() last()
dir=Fl Down: first visible item() first()
Example use:

// Walk down the tree showing open(), visible items


for ( Fl Tree Item *i=tree->first visible item(); i; i=tree->
next item(i, FL Down, true) )
printf("Item: %s\n", i->label());

// Walk up the tree showing open(), visible items


for ( Fl Tree Item *i=tree->last visible item(); i; i=tree->
next item(i, FL Up, true) )
printf("Item: %s\n", i->label());

// Walk down the tree showing all items (open or closed)


for ( Fl Tree Item *i=tree->first(); i; i=tree->next item(i,
FL Down, false) )
printf("Item: %s\n", i->label());

// Walk up the tree showing all items (open or closed)


for ( Fl Tree Item *i=tree->last(); i; i=tree->next item(i,
FL Up, false) )
printf("Item: %s\n", i->label());

Parameters
in item The item to use to find the next item. If NULL, returns 0.
in dir Can be FL Up or FL Down (default=FL Down or ’next’)
in visible true=return only open(), visible items,
false=return open or closed items (default)

Returns
Next item in tree in the direction and visibility specified, or 0 if no more items of specified visibility
in that direction.
See Also
first(), last(), next(),
first visible item(), last visible item(), next visible item(),
first selected item(), last selected item(), next selected item()
Version
1.3.3

Fl Tree Item ∗ Fl Tree::next selected item ( Fl Tree Item ∗ item = 0 )


Returns the next selected item after ’item’.
If item is 0, search starts at the first item (root).
This is a convenience method; equivalent to next selected item(item, FL Down);
Use this to walk the tree forward (downward) looking for all the selected items, e.g.
for ( Fl Tree Item *i = tree->first selected item(); i; i = tree->
next selected item(i) )
printf("Selected item: %s\n", i->label());
776 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in item The item to use to find the next selected item. If NULL, first() is used.

Returns
The next selected item, or 0 if there are no more selected items.

See Also
first selected item(), last selected item(), next selected item()

Fl Tree Item ∗ Fl Tree::next selected item ( Fl Tree Item ∗ item, int dir )
Returns the next selected item above or below ’item’, depending on ’dir’.
If ’item’ is 0, search starts at either first() or last(), depending on ’dir’: first() if ’dir’ is FL -
Down (default), last() if ’dir’ is FL Up.
Use this to walk the tree looking for all the selected items, e.g.
// Walk down the tree (forwards)
for ( Fl Tree Item *i=tree->first selected item(); i; i=tree->
next selected item(i, FL Down) )
printf("Item: %s\n", i->label());

// Walk up the tree (backwards)


for ( Fl Tree Item *i=tree->last selected item(); i; i=tree->
next selected item(i, FL Up) )
printf("Item: %s\n", i->label());

Parameters
in item The item above or below which we’ll find the next selected item. If
NULL, first() is used if FL Down, last() if FL Up. (default=NULL)
in dir The direction to go. FL Up for moving up the tree, FL Down for down
the tree (default)

Returns
The next selected item, or 0 if there are no more selected items.

See Also
first selected item(), last selected item(), next selected item()

Version
1.3.3

Fl Tree Item ∗ Fl Tree::next visible item ( Fl Tree Item ∗ item, int dir ) [protected]
Returns next open(), visible item above (dir==FL Up) or below (dir==FL Down) the specified ’item’,
or 0 if no more items.
If ’item’ is 0, returns first() if ’dir’ is FL Up, or last() if dir is FL Down.
// Walk down the tree (forwards)
for ( Fl Tree Item *i=tree->first visible item(); i; i=tree->
next visible item(i, FL Down) )
printf("Item: %s\n", i->label());

// Walk up the tree (backwards)


for ( Fl Tree Item *i=tree->last visible item(); i; i=tree->
next visible item(i, FL Up) )
printf("Item: %s\n", i->label());
31.143. FL TREE CLASS REFERENCE 777

Parameters
in item The item above/below which we’ll find the next visible item
in dir The direction to search. Can be FL Up or FL Down.

Returns
The item found, or 0 if there’s no visible items above/below the specified item.

Version
1.3.3

int Fl Tree::open ( Fl Tree Item ∗ item, int docallback = 1 )


Open the specified ’item’.
This causes the item’s children (if any) to be shown.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in item – the item to be opened. Must not be NULL.
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - callback() is not invoked


• 1 - callback() is invoked if item changed, (default) callback -
reason() will be FL TREE REASON OPENED

Returns
• 1 – item was opened
• 0 – item was already open, no change

See Also
open(), close(), is open(), is close(), callback item(), callback reason()

int Fl Tree::open ( const char ∗ path, int docallback = 1 )


Opens the item specified by ’path’.
This causes the item’s children (if any) to be shown.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
Items or submenus that themselves contain slashes (’/’ or ’\’) should be escaped, e.g. open(”Holidays/12\\/25\//2010”).
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
778 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - callback() is not invoked


• 1 - callback() is invoked if item changed (default), callback -
reason() will be FL TREE REASON OPENED

Returns
• 1 – OK: item opened
• 0 – OK: item was already open, no change
• -1 – ERROR: item was not found

See Also
open(), close(), is open(), is close(), callback item(), callback reason()

void Fl Tree::open toggle ( Fl Tree Item ∗ item, int docallback = 1 )


Toggle the open state of ’item’.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in item – the item whose open state is to be toggled. Must not be NULL.
in docallback – A flag that determines if the callback() is invoked or not:
• 0 - callback() is not invoked

• 1 - callback() is invoked (default), callback reason() will be either


FL TREE REASON OPENED or FL TREE REASON CLOSE-
D

See Also
open(), close(), is open(), is close(), callback item(), callback reason()

Fl Image ∗ Fl Tree::openicon ( ) const


Returns the icon to be used as the ’open’ icon.
If none was set, the internal default is returned, a simple ’[+]’ icon.

void Fl Tree::openicon ( Fl Image ∗ val )


Sets the icon to be used as the ’open’ icon.
This overrides the built in default ’[+]’ icon.
31.143. FL TREE CLASS REFERENCE 779

Parameters
in val – The new image, or zero to use the default [+] icon.

Fl Tree Item ∗ Fl Tree::prev ( Fl Tree Item ∗ item = 0 )


Return the previous item before ’item’, or 0 if no more items.
This can be used to walk the tree in reverse, e.g.
for ( Fl Tree Item *item = tree->first(); item; item = tree->
prev(item) )
printf("Item: %s\n", item->label());

Parameters
in item The item to use to find the previous item. If NULL, returns 0.

Returns
Previous item in tree, or 0 if at first item.

See Also
first(), next(), last(), prev()

void Fl Tree::recalc tree ( )


Schedule tree to recalc the entire tree size.
Note
Must be using FLTK ABI 1.3.3 or higher for this to be effective.

int Fl Tree::remove ( Fl Tree Item ∗ item )


Remove the specified ’item’ from the tree.
item may not be NULL. If it has children, all those are removed too. If item being removed has focus,
no item will have focus.
Returns
0 if done, -1 if ’item’ not found.

void Fl Tree::resize ( int X, int Y, int W, int H ) [virtual]


Resizes the Fl Group widget and all of its children.
The Fl Group widget first resizes itself, and then it moves and resizes all its children according to the
rules documented for Fl Group::resizable(Fl Widget∗)

See Also
Fl Group::resizable(Fl Widget∗)
Fl Group::resizable()
Fl Widget::resize(int,int,int,int)

Reimplemented from Fl Group.


780 CHAPTER 31. CLASS DOCUMENTATION

void Fl Tree::root ( Fl Tree Item ∗ newitem )


Sets the root item to ’newitem’.
If a root item already exists, clear() is first to clear it before replacing it with newitem.
Version
1.3.3

void Fl Tree::root label ( const char ∗ new label )


Set the label for the root item to ’new label’.
Makes an internally managed copy of ’new label’.

int Fl Tree::scrollbar size ( ) const


Gets the default size of scrollbars’ troughs for this widget in pixels.
If this value is zero (default), this widget will use the global Fl::scrollbar size() value as the scrollbar’s
width.
Returns
Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used.

See Also
Fl::scrollbar size(int)

void Fl Tree::scrollbar size ( int size )


Sets the pixel size of the scrollbars’ troughs to ’size’ for this widget, in pixels.
Normally you should not need this method, and should use the global Fl::scrollbar size(int) instead to
manage the size of ALL your widgets’ scrollbars. This ensures your application has a consistent UI, and is
the default behavior. Normally this is what you want.
Only use this method if you really need to override just THIS instance of the widget’s scrollbar size.
(This need should be rare.)
Setting size to the special value of 0 causes the widget to track the global Fl::scrollbar size(), which
is the default.
Parameters
in size Sets the scrollbar size in pixels.
If 0 (default), scrollbar size tracks the global Fl::scrollbar size()

See Also
Fl::scrollbar size()

int Fl Tree::select ( Fl Tree Item ∗ item, int docallback = 1 )


Select the specified ’item’.
Use ’deselect()’ to de-select it.
Invokes the callback depending on the value of optional parameter docallback.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
31.143. FL TREE CLASS REFERENCE 781

Parameters
in item – the item to be selected. Must not be NULL.
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - the callback() is not invoked


• 1 - the callback() is invoked if item changed state, callback -
reason() will be FL TREE REASON SELECTED

Returns
• 1 - item’s state was changed
• 0 - item was already selected, no change was made

int Fl Tree::select ( const char ∗ path, int docallback = 1 )


Select the item specified by ’path’.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
Items or submenus that themselves contain slashes (’/’ or ’\’) should be escaped, e.g. select(”Holidays/12\\/25\//2010”).
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in path – the tree item’s pathname (e.g. ”Flintstones/Fred”)
in docallback – A flag that determines if the callback() is invoked or not:
• 0 - the callback() is not invoked
• 1 - the callback() is invoked if item changed state (default),
callback reason() will be FL TREE REASON SELECTED

Returns
• 1 : OK: item’s state was changed
• 0 : OK: item was already selected, no change was made
• -1 : ERROR: item was not found

int Fl Tree::select all ( Fl Tree Item ∗ item = 0, int docallback = 1 )


Select ’item’ and all its children.
If item is NULL, first() is used.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
782 CHAPTER 31. CLASS DOCUMENTATION

in item The item that will be selected (along with all its children). If NULL,
first() is used.
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - the callback() is not invoked


• 1 - the callback() is invoked for each item that changed state (de-
fault), callback reason() will be FL TREE REASON SELECTE-
D

Returns
Count of how many items were actually changed to the selected state.

int Fl Tree::select only ( Fl Tree Item ∗ selitem, int docallback = 1 )


Select only the specified ’item’, deselecting all others that might be selected.
If item is 0, first() is used.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in selitem The item to be selected. If NULL, first() is used.
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - the callback() is not invoked


• 1 - the callback() is invoked for each item that changed state (de-
fault), callback reason() will be either FL TREE REASON SEL-
ECTED or FL TREE REASON DESELECTED

Returns
The number of items whose selection states were changed, if any.

void Fl Tree::select toggle ( Fl Tree Item ∗ item, int docallback = 1 )


Toggle the select state of the specified ’item’.
Invokes the callback depending on the value of optional parameter ’docallback’.
Handles calling redraw() if anything changed.
The callback can use callback item() and callback reason() respectively to determine the item changed
and the reason the callback was called.
Parameters
in item – the item to be selected. Must not be NULL.
in docallback – A flag that determines if the callback() is invoked or not:

• 0 - the callback() is not invoked


• 1 - the callback() is invoked (default), callback reason() will be
either FL TREE REASON SELECTED or FL TREE REASON-
DESELECTED
31.143. FL TREE CLASS REFERENCE 783

Fl Boxtype Fl Tree::selectbox ( ) const


Sets the style of box used to draw selected items.
This is an fltk Fl Boxtype. The default is influenced by FLTK’s current Fl::scheme()

void Fl Tree::selectbox ( Fl Boxtype val )


Gets the style of box used to draw selected items.
This is an fltk Fl Boxtype. The default is influenced by FLTK’s current Fl::scheme()

void Fl Tree::selectmode ( Fl Tree Select val )


Sets the tree’s selection mode.
See Fl Tree Select for possible values.

void Fl Tree::set item focus ( Fl Tree Item ∗ item )


Set the item that currently should have keyboard focus.
Handles calling redraw() to update the focus box (if it is visible).
Parameters
in item The item that should take focus. If NULL, none will have focus.

void Fl Tree::show item ( Fl Tree Item ∗ item, int yoff )


Adjust the vertical scroll bar so that ’item’ is visible ’yoff’ pixels from the top of the Fl Tree widget’s
display.
For instance, yoff=0 will position the item at the top.
If yoff is larger than the vertical scrollbar’s limit, the value will be clipped. So if yoff=100, but scroll-
bar’s max is 50, then 50 will be used.
Parameters
in item The item to be shown. If NULL, first() is used.
in yoff The pixel offset from the top for the displayed position.

See Also
show item top(), show item middle(), show item bottom()

void Fl Tree::show item ( Fl Tree Item ∗ item )


Adjust the vertical scroll bar to show ’item’ at the top of the display IF it is currently off-screen (e.g.
show item top()). If it is already on-screen, no change is made.
Parameters
in item The item to be shown. If NULL, first() is used.

See Also
show item top(), show item middle(), show item bottom()

void Fl Tree::show item bottom ( Fl Tree Item ∗ item )


Adjust the vertical scrollbar so that ’item’ is at the bottom of the display.
784 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in item The item to be shown. If NULL, first() is used.

void Fl Tree::show item middle ( Fl Tree Item ∗ item )


Adjust the vertical scrollbar so that ’item’ is in the middle of the display.
Parameters
in item The item to be shown. If NULL, first() is used.

void Fl Tree::show item top ( Fl Tree Item ∗ item )


Adjust the vertical scrollbar so that ’item’ is at the top of the display.
Parameters
in item The item to be shown. If NULL, first() is used.

void Fl Tree::show self ( )


Print the tree as ’ascii art’ to stdout.
Used mainly for debugging.

Todo should be const

Version
1.3.0

void Fl Tree::showcollapse ( int val )


Set if we should show the collapse icon or not.
If collapse icons are disabled, the user will not be able to interactively collapse items in the tree, unless
the application provides some other means via open() and close().
Parameters
in val 1: shows collapse icons (default),
0: hides collapse icons.

void Fl Tree::showroot ( int val )


Set if the root item should be shown or not.
Parameters
in val 1 – show the root item (default)
0 – hide the root item.

Fl Tree Sort Fl Tree::sortorder ( ) const


Set the default sort order used when items are added to the tree.
See Fl Tree Sort for possible values.
31.144. FL TREE ITEM CLASS REFERENCE 785

Fl Image ∗ Fl Tree::usericon ( ) const


Returns the Fl Image being used as the default user icon for all newly created items.
Returns zero if no icon has been set, which is the default.

void Fl Tree::usericon ( Fl Image ∗ val )


Sets the Fl Image to be used as the default user icon for all newly created items.
If you want to specify user icons on a per-item basis, use Fl Tree Item::usericon() instead.
Parameters
in val – The new image to be used, or zero to disable user icons.

int Fl Tree::usericonmarginleft ( ) const


Get the amount of white space (in pixels) that should appear to the left of the usericon.

void Fl Tree::usericonmarginleft ( int val )


Set the amount of white space (in pixels) that should appear to the left of the usericon.

int Fl Tree::vposition ( ) const


Returns the vertical scroll position as a pixel offset.
The position returned is how many pixels of the tree are scrolled off the top edge of the screen.

See Also
vposition(), hposition()

void Fl Tree::vposition ( int pos )


Sets the vertical scroll offset to position ’pos’.
The position is how many pixels of the tree are scrolled off the top edge of the screen.
Parameters
in pos The vertical position (in pixels) to scroll the browser to.
The documentation for this class was generated from the following files:

• Fl Tree.H
• Fl Tree.cxx

31.144 Fl Tree Item Class Reference


Tree widget item.
#include <Fl Tree Item.H>

Public Member Functions


• void activate (int val=1)
Change the item’s activation state to the optionally specified ’val’.
• Fl Tree Item ∗ add (const Fl Tree Prefs &prefs, const char ∗new label, Fl Tree Item ∗newitem)
Add ’item’ as immediate child with ’new label’ and defaults from ’prefs’.
• Fl Tree Item ∗ add (const Fl Tree Prefs &prefs, const char ∗new label)
786 CHAPTER 31. CLASS DOCUMENTATION

Add a new child to this item with the name ’new label’ and defaults from ’prefs’.
• Fl Tree Item ∗ add (const Fl Tree Prefs &prefs, char ∗∗arr, Fl Tree Item ∗newitem)
Descend into path specified by ’arr’ and add ’newitem’ there.
• Fl Tree Item ∗ add (const Fl Tree Prefs &prefs, char ∗∗arr)
Descend into the path specified by ’arr’, and add a new child there.
• Fl Tree Item ∗ child (int index)
Return the child item for the given ’index’.
• const Fl Tree Item ∗ child (int t) const
Return the const child item for the given ’index’.
• int children () const
Return the number of children this item has.
• void clear children ()
Clear all the children for this item.
• void close ()
Close this item and all its children.
• void deactivate ()
Deactivate the item; the callback() won’t be invoked when clicked.
• Fl Tree Item ∗ deparent (int index)
Deparent child at index position ’pos’.
• int depth () const
Returns how many levels deep this item is in the hierarchy.
• void deselect ()
Disable the item’s selection state.
• int deselect all ()
Deselect item and all its children.
• void draw (int X, int &Y, int W, Fl Widget ∗tree, Fl Tree Item ∗itemfocus, const Fl Tree Prefs
&prefs, int lastchild=1)
Draw this item and its children.
• int event on collapse icon (const Fl Tree Prefs &prefs) const
Was the event on the ’collapse’ button of this item?
• int event on label (const Fl Tree Prefs &prefs) const
Was event on the label() of this item?
• int find child (const char ∗name)
Return the index of the immediate child of this item that has the label ’name’.
• int find child (Fl Tree Item ∗item)
Find the index number for the specified ’item’ in the current item’s list of children.
• const Fl Tree Item ∗ find child item (const char ∗name) const
Return the /immediate/ child of current item that has the label ’name’.
• Fl Tree Item ∗ find child item (const char ∗name)
Non-const version of Fl Tree Item::find child item(const char ∗name) const.
• const Fl Tree Item ∗ find child item (char ∗∗arr) const
Find child item by descending array ’arr’ of names.
• Fl Tree Item ∗ find child item (char ∗∗arr)
Non-const version of Fl Tree Item::find child item(char ∗∗arr) const.
• const Fl Tree Item ∗ find clicked (const Fl Tree Prefs &prefs) const
Find the item that the last event was over.
• Fl Tree Item ∗ find clicked (const Fl Tree Prefs &prefs)
31.144. FL TREE ITEM CLASS REFERENCE 787

Non-const version of Fl Tree Item::find clicked(const Fl Tree Prefs&) const.


• const Fl Tree Item ∗ find item (char ∗∗arr) const
Find item by descending array of ’names’.
• Fl Tree Item ∗ find item (char ∗∗arr)
Non-const version of Fl Tree Item::find item(char ∗∗names) const.
• Fl Tree Item (const Fl Tree Prefs &prefs)
Constructor.
• Fl Tree Item (const Fl Tree Item ∗o)
Copy constructor.
• int h () const
The item’s height.
• int has children () const
See if this item has children.
• Fl Tree Item ∗ insert (const Fl Tree Prefs &prefs, const char ∗new label, int pos=0)
Insert a new item named ’new label’ into current item’s children at a specified position ’pos’.
• Fl Tree Item ∗ insert above (const Fl Tree Prefs &prefs, const char ∗new label)
Insert a new item named ’new label’ above this item.
• char is activated () const
See if the item is activated.
• char is active () const
See if the item is activated. Alias for is activated().
• int is close () const
See if the item is ’closed’.
• int is open () const
See if the item is ’open’.
• int is root () const
Is this item the root of the tree?
• char is selected () const
See if the item is selected.
• int is visible () const
See if the item is visible.
• void label (const char ∗val)
Set the label to ’name’.
• const char ∗ label () const
Return the label.
• int label h () const
The item’s label height.
• int label w () const
The item’s maximum label width to right edge of Fl Tree’s inner width within scrollbars.
• int label x () const
The item’s label x position relative to the window.
• int label y () const
The item’s label y position relative to the window.
• void labelbgcolor (Fl Color val)
Set item’s label background color.
• Fl Color labelbgcolor () const
788 CHAPTER 31. CLASS DOCUMENTATION

Return item’s label background text color.


• void labelcolor (Fl Color val)
Set item’s label text color. Alias for labelfgcolor(Fl Color)).
• Fl Color labelcolor () const
Return item’s label text color. Alias for labelfgcolor() const).
• void labelfgcolor (Fl Color val)
Set item’s label foreground text color.
• Fl Color labelfgcolor () const
Return item’s label foreground text color.
• void labelfont (Fl Font val)
Set item’s label font face.
• Fl Font labelfont () const
Get item’s label font face.
• void labelsize (Fl Fontsize val)
Set item’s label font size.
• Fl Fontsize labelsize () const
Get item’s label font size.
• int move (int to, int from)
Move the item ’to’ to sibling position of ’from’.
• int move (Fl Tree Item ∗item, int op=0, int pos=0)
Move the current item above/below/into the specified ’item’, where ’op’ determines the type of move:
• int move above (Fl Tree Item ∗item)
Move the current item above the specified ’item’.
• int move below (Fl Tree Item ∗item)
Move the current item below the specified ’item’.
• int move into (Fl Tree Item ∗item, int pos=0)
Parent the current item as a child of the specified ’item’.
• Fl Tree Item ∗ next ()
Return the next item in the tree.
• Fl Tree Item ∗ next displayed (Fl Tree Prefs &prefs)
Same as next visible().
• Fl Tree Item ∗ next sibling ()
Return this item’s next sibling.
• Fl Tree Item ∗ next visible (Fl Tree Prefs &prefs)
Return the next open(), visible() item.
• void open ()
Open this item and all its children.
• void open toggle ()
Toggle the item’s open/closed state.
• Fl Tree Item ∗ parent ()
Return the parent for this item. Returns NULL if we are the root.
• const Fl Tree Item ∗ parent () const
Return the const parent for this item. Returns NULL if we are the root.
• void parent (Fl Tree Item ∗val)
Set the parent for this item.
• Fl Tree Item ∗ prev ()
31.144. FL TREE ITEM CLASS REFERENCE 789

Return the previous item in the tree.


• Fl Tree Item ∗ prev displayed (Fl Tree Prefs &prefs)
Same as prev visible().
• Fl Tree Item ∗ prev sibling ()
Return this item’s previous sibling.
• Fl Tree Item ∗ prev visible (Fl Tree Prefs &prefs)
Return the previous open(), visible() item.
• int remove child (Fl Tree Item ∗item)
Remove ’item’ from the current item’s children.
• int remove child (const char ∗new label)
Remove immediate child (and its children) by its label ’name’.
• int reparent (Fl Tree Item ∗newchild, int index)
Reparent specified item as a child of ourself at position ’pos’.
• void select (int val=1)
Change the item’s selection state to the optionally specified ’val’.
• int select all ()
Select item and all its children.
• void select toggle ()
Toggle the item’s selection state.
• void show self (const char ∗indent=””) const
Print the tree as ’ascii art’ to stdout.
• void swap children (int ax, int bx)
Swap two of our children, given two child index values ’ax’ and ’bx’.
• int swap children (Fl Tree Item ∗a, Fl Tree Item ∗b)
Swap two of our immediate children, given item pointers.
• void update prev next (int index)
Update our prev sibling and next sibling pointers to point to neighbors given index as being our current
position in the parent’s item array.
• void user data (void ∗data)
Set a user-data value for the item.
• void ∗ user data () const
Retrieve the user-data value that has been assigned to the item.
• void usericon (Fl Image ∗val)
Set the item’s user icon to an Fl Image. ’0’ will disable.
• Fl Image ∗ usericon () const
Get the item’s user icon as an Fl Image. Returns ’0’ if disabled.
• int visible () const
See if the item is visible. Alias for is visible().
• int visible r () const
See if item and all its parents are open() and visible().
• int w () const
The entire item’s width to right edge of Fl Tree’s inner width within scrollbars.
• void widget (Fl Widget ∗val)
Assign an FLTK widget to this item.
• Fl Widget ∗ widget () const
Return FLTK widget assigned to this item.
• int x () const
790 CHAPTER 31. CLASS DOCUMENTATION

The item’s x position relative to the window.


• int y () const
The item’s y position relative to the window.

Protected Member Functions


• void Init (const Fl Tree Prefs &prefs, Fl Tree ∗tree)
• int calc item height (const Fl Tree Prefs &prefs) const
Return the item’s ’visible’ height.
• void draw horizontal connector (int x1, int x2, int y, const Fl Tree Prefs &prefs)
Internal: Horizontal connector line based on preference settings.
• void draw vertical connector (int x, int y1, int y2, const Fl Tree Prefs &prefs)
Internal: Vertical connector line based on preference settings.
• void hide widgets ()
Internal: Hide the FLTK widget() for this item and all children.
• int is flag (unsigned short flag) const
See if flag set. Returns 0 or 1.
• void recalc tree ()
Call this when our geometry is changed.
• void set flag (unsigned short flag, int val)
Set a flag to an on or off value. val is 0 or 1.
• void show widgets ()
Internal: Show the FLTK widget() for this item and all children.

31.144.1 Detailed Description


Tree widget item.
This class is a single tree item, and manages all of the item’s attributes. Fl Tree Item is used by Fl Tree,
which is comprised of many instances of Fl Tree Item.
Fl Tree Item is hierarchical; it dynamically manages an Fl Tree Item Array of children that are them-
selves instances of Fl Tree Item. Each item can have zero or more children. When an item has children,
close() and open() can be used to hide or show them.
Items have their own attributes; font size, face, color. Items maintain their own hierarchy of children.
When you make changes to items, you’ll need to tell the tree to redraw() for the changes to show up.
New 1.3.3 ABI feature: You can define custom items by either adding a custom widget to the item with
Fl Tree Item::widget(), or override the draw item content() method if you want to just redefine how the
label is drawn.
The following shows the Fl Tree Item’s dimensions, useful when overriding the draw item content()
method:

\image html Fl_Tree_Item-dimensions.png "Fl_Tree_Item’s internal dimensions." width=6cm


\image latex Fl_Tree_Item-dimensions.png "Fl_Tree_Item’s internal dimensions." width=6cm

31.144.2 Constructor & Destructor Documentation


Fl Tree Item::Fl Tree Item ( const Fl Tree Prefs & prefs )
Constructor.
Makes a new instance of Fl Tree Item using defaults from ’prefs’.
31.144. FL TREE ITEM CLASS REFERENCE 791

31.144.3 Member Function Documentation


void Fl Tree Item::activate ( int val = 1 ) [inline]

Change the item’s activation state to the optionally specified ’val’.


When deactivated, the item will be ’grayed out’; the callback() won’t be invoked if the user clicks on
the label. If a widget() is associated with the item, its activation state will be changed as well.
If ’val’ is not specified, the item will be activated.

Fl Tree Item ∗ Fl Tree Item::add ( const Fl Tree Prefs & prefs, const char ∗ new label,
Fl Tree Item ∗ item )

Add ’item’ as immediate child with ’new label’ and defaults from ’prefs’.
If ’item’ is NULL, a new item is created. An internally managed copy is made of the label string.
Adds the item based on the value of prefs.sortorder().

Returns
the item added

Version
1.3.3

Fl Tree Item ∗ Fl Tree Item::add ( const Fl Tree Prefs & prefs, const char ∗ new label )

Add a new child to this item with the name ’new label’ and defaults from ’prefs’.
An internally managed copy is made of the label string. Adds the item based on the value of prefs.-
sortorder().

Returns
the item added

Version
1.3.0 release

Fl Tree Item ∗ Fl Tree Item::add ( const Fl Tree Prefs & prefs, char ∗∗ arr, Fl Tree Item ∗
newitem )

Descend into path specified by ’arr’ and add ’newitem’ there.


Should be used only by Fl Tree’s internals. If item is NULL, a new item is created. Adds the item
based on the value of prefs.sortorder().

Returns
the item added.

Version
1.3.3 ABI feature
792 CHAPTER 31. CLASS DOCUMENTATION

Fl Tree Item ∗ Fl Tree Item::add ( const Fl Tree Prefs & prefs, char ∗∗ arr )
Descend into the path specified by ’arr’, and add a new child there.
Should be used only by Fl Tree’s internals. Adds the item based on the value of prefs.sortorder().
Returns
the item added.

Version
1.3.0 release

int Fl Tree Item::calc item height ( const Fl Tree Prefs & prefs ) const [protected]
Return the item’s ’visible’ height.
Takes into account the item’s:
• visibility (if !is visible(), returns 0)
• labelfont() height: if label() != NULL
• widget() height: if widget() != NULL
• openicon() height (if not NULL)
• usericon() height (if not NULL) Does NOT include Fl Tree::linespacing();
Returns
maximum pixel height

const Fl Tree Item ∗ Fl Tree Item::child ( int t ) const


Return the const child item for the given ’index’.
Return const child item for the specified ’index’.

void Fl Tree Item::deactivate ( ) [inline]


Deactivate the item; the callback() won’t be invoked when clicked.
Same as activate(0)

Fl Tree Item ∗ Fl Tree Item::deparent ( int pos )


Deparent child at index position ’pos’.
This creates an ”orphaned” item that is still allocated, but has no parent or siblings. Normally the caller
would want to immediately reparent the orphan elsewhere.
A successfully orphaned item will have its parent() and prev sibling()/next sibling() set to NULL.
Returns
• pointer to orphaned item on success
• NULL on error (could not deparent the item)

int Fl Tree Item::depth ( ) const


Returns how many levels deep this item is in the hierarchy.
For instance; root has a depth of zero, and its immediate children would have a depth of 1, and so on.
Use e.g. for determining the horizontal indent of this item during drawing.
31.144. FL TREE ITEM CLASS REFERENCE 793

int Fl Tree Item::deselect all ( ) [inline]


Deselect item and all its children.
Returns count of how many items were in the ’selected’ state, ie. how many items were ”changed”.

void Fl Tree Item::draw ( int X, int & Y, int W, Fl Widget ∗ tree, Fl Tree Item ∗ itemfocus, const
Fl Tree Prefs & prefs, int lastchild = 1 )
Draw this item and its children.
Parameters
in X Horizontal position for item being drawn
in,out Y Vertical position for item being drawn, returns new position for next item
in W Recommended width of item
in tree The parent tree
in itemfocus The tree’s current focus item (if any)
in prefs The tree’s preferences
in lastchild Is this item the last child in a subtree?

Version
1.3.0 release, removed 1.3.3 ABI

void Fl Tree Item::draw horizontal connector ( int x1, int x2, int y, const Fl Tree Prefs & prefs )
[protected]
Internal: Horizontal connector line based on preference settings.
Parameters
in x1 The left hand X position of the horizontal connector
in x2 The right hand X position of the horizontal connector
in y The vertical position of the horizontal connector
in prefs The Fl Tree prefs

void Fl Tree Item::draw vertical connector ( int x, int y1, int y2, const Fl Tree Prefs & prefs )
[protected]
Internal: Vertical connector line based on preference settings.
Parameters
in x The x position of the vertical connector
in y1 The top of the vertical connector
in y2 The bottom of the vertical connector
in prefs The Fl Tree prefs

int Fl Tree Item::find child ( const char ∗ name )


Return the index of the immediate child of this item that has the label ’name’.
Returns
index of found item, or -1 if not found.

Version
1.3.0 release
794 CHAPTER 31. CLASS DOCUMENTATION

int Fl Tree Item::find child ( Fl Tree Item ∗ item )


Find the index number for the specified ’item’ in the current item’s list of children.
Returns
the index, or -1 if not found.

const Fl Tree Item ∗ Fl Tree Item::find child item ( const char ∗ name ) const
Return the /immediate/ child of current item that has the label ’name’.
Returns
const found item, or 0 if not found.

Version
1.3.3

const Fl Tree Item ∗ Fl Tree Item::find child item ( char ∗∗ arr ) const
Find child item by descending array ’arr’ of names.
Does not include self in search. Only Fl Tree should need this method.
Returns
item, or 0 if not found

Version
1.3.0 release

const Fl Tree Item ∗ Fl Tree Item::find clicked ( const Fl Tree Prefs & prefs ) const
Find the item that the last event was over.
Parameters
in prefs The parent tree’s Fl Tree Prefs

Returns
pointer to clicked item, or NULL if none found

Version
1.3.0

const Fl Tree Item ∗ Fl Tree Item::find item ( char ∗∗ names ) const


Find item by descending array of ’names’.
Includes self in search. Only Fl Tree should need this method. Use Fl Tree::find item() instead.
Returns
const item, or 0 if not found
31.144. FL TREE ITEM CLASS REFERENCE 795

void Fl Tree Item::hide widgets ( ) [protected]


Internal: Hide the FLTK widget() for this item and all children.
Used by close() to hide widgets.

Fl Tree Item ∗ Fl Tree Item::insert ( const Fl Tree Prefs & prefs, const char ∗ new label, int pos =
0 )
Insert a new item named ’new label’ into current item’s children at a specified position ’pos’.
Returns
the new item inserted.

Fl Tree Item ∗ Fl Tree Item::insert above ( const Fl Tree Prefs & prefs, const char ∗ new label )
Insert a new item named ’new label’ above this item.
Returns
the new item inserted, or 0 if an error occurred.

void Fl Tree Item::label ( const char ∗ name )


Set the label to ’name’.
Makes and manages an internal copy of ’name’.

int Fl Tree Item::label h ( ) const [inline]


The item’s label height.
Version
1.3.3

int Fl Tree Item::label w ( ) const [inline]


The item’s maximum label width to right edge of Fl Tree’s inner width within scrollbars.
Version
1.3.3

int Fl Tree Item::label x ( ) const [inline]


The item’s label x position relative to the window.
Version
1.3.3

int Fl Tree Item::label y ( ) const [inline]


The item’s label y position relative to the window.
Version
1.3.3
796 CHAPTER 31. CLASS DOCUMENTATION

void Fl Tree Item::labelbgcolor ( Fl Color val ) [inline]


Set item’s label background color.
A special case is made for color 0xffffffff which uses the parent tree’s bg color.

Fl Color Fl Tree Item::labelbgcolor ( ) const [inline]


Return item’s label background text color.
If the color is 0xffffffff, the default behavior is the parent tree’s bg color will be used. (An overloaded
draw item content() can override this behavior.)

int Fl Tree Item::move ( int to, int from )


Move the item ’to’ to sibling position of ’from’.

Returns
• 0: Success
• -1: range error (e.g. if ’to’ or ’from’ out of range).
• (Other return values reserved for future use)

int Fl Tree Item::move ( Fl Tree Item ∗ item, int op = 0, int pos = 0 )


Move the current item above/below/into the specified ’item’, where ’op’ determines the type of move:

• 0: move above ’item’ (’pos’ ignored)

• 1: move below ’item’ (’pos’ ignored)

• 2: move into ’item’ as a child (at optional position ’pos’)

Returns
0 on success. a negative number on error:
• -1: one of the items has no parent
• -2: item’s index could not be determined
• -3: bad ’op’
• -4: index range error
• -5: could not deparent
• -6: could not reparent at ’pos’
• (Other return values reserved for future use.)

int Fl Tree Item::move above ( Fl Tree Item ∗ item )


Move the current item above the specified ’item’.
This is the equivalent of calling move(item,0,0).

Returns
0 on success.
On error returns a negative value; see move(Fl Tree Item∗,int,int) for possible error codes.
31.144. FL TREE ITEM CLASS REFERENCE 797

int Fl Tree Item::move below ( Fl Tree Item ∗ item )


Move the current item below the specified ’item’.
This is the equivalent of calling move(item,1,0).
Returns
0 on success.
On error returns a negative value; see move(Fl Tree Item∗,int,int) for possible error codes.

int Fl Tree Item::move into ( Fl Tree Item ∗ item, int pos = 0 )


Parent the current item as a child of the specified ’item’.
This is the equivalent of calling move(item,2,pos).
Returns
0 on success.
On error returns a negative value; see move(Fl Tree Item∗,int,int) for possible error codes.

Fl Tree Item ∗ Fl Tree Item::next ( )


Return the next item in the tree.
This method can be used to walk the tree forward. For an example of how to use this method, see
Fl Tree::first().
Returns
the next item in the tree, or 0 if there’s no more items.

Fl Tree Item ∗ Fl Tree Item::next displayed ( Fl Tree Prefs & prefs )


Same as next visible().
Deprecated in 1.3.3 for confusing name, use next visible() instead

Fl Tree Item ∗ Fl Tree Item::next sibling ( )


Return this item’s next sibling.
Moves to the next item below us at the same level (sibling). Use this to move down the tree without
changing depth(). effectively skipping over this item’s children/descendents.
Returns
item’s next sibling, or 0 if none.

Fl Tree Item ∗ Fl Tree Item::next visible ( Fl Tree Prefs & prefs )


Return the next open(), visible() item.
(If this item has children and is closed, children are skipped)
This method can be used to walk the tree forward, skipping items that are not currently open/visible to
the user.
Returns
the next open() visible() item below us, or 0 if there’s no more items.

Version
1.3.3
798 CHAPTER 31. CLASS DOCUMENTATION

void Fl Tree Item::parent ( Fl Tree Item ∗ val ) [inline]


Set the parent for this item.
Should only be used by Fl Tree’s internals.

Fl Tree Item ∗ Fl Tree Item::prev ( )


Return the previous item in the tree.
This method can be used to walk the tree backwards. For an example of how to use this method, see
Fl Tree::last().

Returns
the previous item in the tree, or 0 if there’s no item above this one (hit the root).

Fl Tree Item ∗ Fl Tree Item::prev displayed ( Fl Tree Prefs & prefs )


Same as prev visible().

Deprecated in 1.3.3 for confusing name, use prev visible()

Fl Tree Item ∗ Fl Tree Item::prev sibling ( )


Return this item’s previous sibling.
Moves to the previous item above us at the same level (sibling). Use this to move up the tree without
changing depth().

Returns
This item’s previous sibling, or 0 if none.

Fl Tree Item ∗ Fl Tree Item::prev visible ( Fl Tree Prefs & prefs )


Return the previous open(), visible() item.
(If this item above us has children and is closed, its children are skipped)
This method can be used to walk the tree backward, skipping items that are not currently open/visible
to the user.

Returns
the previous open() visible() item above us, or 0 if there’s no more items.

void Fl Tree Item::recalc tree ( ) [protected]


Call this when our geometry is changed.
(Font size, label contents, etc) Schedules tree to recalculate itself, as changes to us may affect tree
widget’s scrollbar visibility and tab sizes.

Version
1.3.3 ABI
31.144. FL TREE ITEM CLASS REFERENCE 799

int Fl Tree Item::remove child ( Fl Tree Item ∗ item )


Remove ’item’ from the current item’s children.
Returns
0 if removed, -1 if item not an immediate child.

int Fl Tree Item::remove child ( const char ∗ name )


Remove immediate child (and its children) by its label ’name’.
If more than one item matches ’name’, only the first matching item is removed.
Parameters
in name The label name of the immediate child to remove

Returns
0 if removed, -1 if not found.

Version
1.3.3

int Fl Tree Item::reparent ( Fl Tree Item ∗ newchild, int pos )


Reparent specified item as a child of ourself at position ’pos’.
Typically ’newchild’ was recently orphaned with deparent().

Returns
• 0: on success
• -1: on error (e.g. if ’pos’ out of range)

void Fl Tree Item::select ( int val = 1 ) [inline]


Change the item’s selection state to the optionally specified ’val’.
If ’val’ is not specified, the item will be selected.

int Fl Tree Item::select all ( ) [inline]


Select item and all its children.
Returns count of how many items were in the ’deselected’ state, ie. how many items were ”changed”.

void Fl Tree Item::show self ( const char ∗ indent = "" ) const


Print the tree as ’ascii art’ to stdout.
Used mainly for debugging.

void Fl Tree Item::show widgets ( ) [protected]


Internal: Show the FLTK widget() for this item and all children.
Used by open() to re-show widgets that were hidden by a previous close()
800 CHAPTER 31. CLASS DOCUMENTATION

void Fl Tree Item::swap children ( int ax, int bx )


Swap two of our children, given two child index values ’ax’ and ’bx’.
Use e.g. for sorting.
This method is FAST, and does not involve lookups.
No range checking is done on either index value.
31.145. FL TREE ITEM ARRAY CLASS REFERENCE 801

Parameters
in ax,bx the index of the items to swap

int Fl Tree Item::swap children ( Fl Tree Item ∗ a, Fl Tree Item ∗ b )


Swap two of our immediate children, given item pointers.
Use e.g. for sorting.
This method is SLOW because it involves linear lookups.
For speed, use swap children(int,int) instead.
Parameters
in a,b The item ptrs of the two items to swap. Both must be immediate children
of the current item.

Returns
• 0 : OK
• -1 : failed: item ’a’ or ’b’ is not our child.

void Fl Tree Item::update prev next ( int index )


Update our prev sibling and next sibling pointers to point to neighbors given index as being our current
position in the parent’s item array.
Call this whenever items in the array are added/removed/moved/swapped/etc.
Parameters
in index Our index# in the parent.
Special case if index=-1: become an orphan; null out all parent/sibling
associations.

int Fl Tree Item::visible r ( ) const


See if item and all its parents are open() and visible().

Returns
1 – item and its parents are open() and visible() 0 – item (or one of its parents) are invisible or
close()ed.

int Fl Tree Item::w ( ) const [inline]


The entire item’s width to right edge of Fl Tree’s inner width within scrollbars.
The documentation for this class was generated from the following files:

• Fl Tree Item.H
• Fl Tree Item.cxx

31.145 Fl Tree Item Array Class Reference


Manages an array of Fl Tree Item pointers.
#include <Fl Tree Item Array.H>
802 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• void add (Fl Tree Item ∗val)
Add an item∗ to the end of the array.
• void clear ()
Clear the entire array.
• int deparent (int pos)
Deparent item at ’pos’ from our list of children.
• Fl Tree Item Array (int new chunksize=10)
Constructor; creates an empty array.
• Fl Tree Item Array (const Fl Tree Item Array ∗o)
Copy constructor. Makes new copy of array, with new instances of each item.
• void insert (int pos, Fl Tree Item ∗new item)
Insert an item at index position pos.
• int move (int to, int from)
Move item at ’from’ to new position ’to’ in the array.
• Fl Tree Item ∗ operator[ ] (int i)
Return the item and index i.
• const Fl Tree Item ∗ operator[ ] (int i) const
Const version of operator[ ](int i)
• void remove (int index)
Remove the item at.
• int remove (Fl Tree Item ∗item)
Remove the item from the array.
• int reparent (Fl Tree Item ∗item, Fl Tree Item ∗newparent, int pos)
Reparent specified item as a child of ourself.
• void replace (int pos, Fl Tree Item ∗new item)
Replace the item at index with newitem.
• void swap (int ax, int bx)
Swap the two items at index positions ax and bx.
• int total () const
Return the total items in the array, or 0 if empty.
• ∼Fl Tree Item Array ()
Destructor. Calls each item’s destructor, destroys internal items array.

31.145.1 Detailed Description


Manages an array of Fl Tree Item pointers.
Because FLTK 1.x.x. has mandated that templates and STL not be used, we use this class to dynami-
cally manage the arrays.
None of the methods do range checking on index values; the caller must be sure that index values are
within the range 0<index<total() (unless otherwise noted).

31.145.2 Constructor & Destructor Documentation


Fl Tree Item Array::Fl Tree Item Array ( int new chunksize = 10 )
Constructor; creates an empty array.
The optional ’chunksize’ can be specified to optimize memory allocation for potentially large arrays.
Default chunksize is 10.
31.145. FL TREE ITEM ARRAY CLASS REFERENCE 803

31.145.3 Member Function Documentation


void Fl Tree Item Array::add ( Fl Tree Item ∗ val )
Add an item∗ to the end of the array.
Assumes the item was created with ’new’, and will remain allocated.. Fl Tree Item Array will handle
calling the item’s destructor when the array is cleared or the item remove()’ed.

void Fl Tree Item Array::clear ( )


Clear the entire array.
Each item will be deleted (destructors will be called), and the array will be cleared. total() will return
0.

int Fl Tree Item Array::deparent ( int pos )


Deparent item at ’pos’ from our list of children.
Similar to a remove() without the destruction of the item. This creates an orphaned item (still allocated,
has no parent) which soon after is typically reparented elsewhere.
\returns 0 on success, -1 on error (e.g. if \p ’pos’ out of range)

void Fl Tree Item Array::insert ( int pos, Fl Tree Item ∗ new item )
Insert an item at index position pos.
Handles enlarging array if needed, total increased by 1. If pos == total(), an empty item is appended
to the array.

int Fl Tree Item Array::move ( int to, int from )


Move item at ’from’ to new position ’to’ in the array.
Due to how the moving an item shuffles the array around, a positional ’move’ implies things that may
not be obvious:

• When ’from’ moved lower in tree, appears BELOW item that was at ’to’.

• When ’from’ moved higher in tree, appears ABOVE item that was at ’to’.

Returns
0 on success, -1 on range error (e.g. if ’to’ or ’from’ out of range)

void Fl Tree Item Array::remove ( int index )


Remove the item at.
Parameters
in index from the array.
The item will be delete’d (if non-NULL), so its destructor will be called.

int Fl Tree Item Array::remove ( Fl Tree Item ∗ item )


Remove the item from the array.
Returns
0 if removed, or -1 if the item was not in the array.
804 CHAPTER 31. CLASS DOCUMENTATION

int Fl Tree Item Array::reparent ( Fl Tree Item ∗ item, Fl Tree Item ∗ newparent, int pos )
Reparent specified item as a child of ourself.
Typically ’newchild’ was recently orphaned with deparent().
\returns 0 on success, -1 on error (e.g. if \p ’pos’ out of range)

void Fl Tree Item Array::replace ( int index, Fl Tree Item ∗ newitem )


Replace the item at index with newitem.
Old item at index position will be destroyed, and the new item will take it’s place, and stitched into the
linked list.
The documentation for this class was generated from the following files:
• Fl Tree Item Array.H
• Fl Tree Item Array.cxx

31.146 Fl Tree Prefs Class Reference


Tree widget’s preferences.
#include <Fl Tree Prefs.H>

Public Member Functions


• Fl Image ∗ closeicon () const
Gets the default ’close’ icon Returns the Fl Image∗ of the icon, or 0 if none.
• void closeicon (Fl Image ∗val)
Sets the icon to be used as the ’close’ icon.
• Fl Color connectorcolor () const
Get the connector color used for tree connection lines.
• void connectorcolor (Fl Color val)
Set the connector color used for tree connection lines.
• Fl Tree Connector connectorstyle () const
Get the connector style.
• void connectorstyle (Fl Tree Connector val)
Set the connector style.
• void connectorstyle (int val)
Set the connector style [integer].
• int connectorwidth () const
Get the tree connection line’s width.
• void connectorwidth (int val)
Set the tree connection line’s width.
• Fl Tree Prefs ()
Fl Tree Prefs constructor.
• Fl Color item labelbgcolor () const
Get the default label background color.
• void item labelbgcolor (Fl Color val)
Set the default label background color.
• Fl Color item labelfgcolor () const
Get the default label foreground color.
31.146. FL TREE PREFS CLASS REFERENCE 805

• void item labelfgcolor (Fl Color val)


Set the default label foreground color.
• Fl Font item labelfont () const
Return the label’s font.
• void item labelfont (Fl Font val)
Set the label’s font to val.
• Fl Fontsize item labelsize () const
Return the label’s size in pixels.
• void item labelsize (Fl Fontsize val)
Set the label’s size in pixels to val.
• Fl Color labelbgcolor () const
Obsolete: Get the default label background color. Please use item labelbgcolor() instead.
• void labelbgcolor (Fl Color val)
Obsolete: Set the default label background color. Please use item labelbgcolor(Fl Color) instead.
• Fl Color labelfgcolor () const
Obsolete: Get the default label foreground color. Please use item labelfgcolor() instead.
• void labelfgcolor (Fl Color val)
Obsolete: Set the default label foreground color. Please use item labelfgcolor(Fl Color) instead.
• Fl Font labelfont () const
Obsolete: Return the label’s font. Please use item labelfont() instead.
• void labelfont (Fl Font val)
Obsolete: Set the label’s font to val. Please use item labelfont(Fl Font) instead.
• int labelmarginleft () const
Get the label’s left margin value in pixels.
• void labelmarginleft (int val)
Set the label’s left margin value in pixels.
• Fl Fontsize labelsize () const
Obsolete: Return the label’s size in pixels. Please use item labelsize() instead.
• void labelsize (Fl Fontsize val)
Obsolete: Set the label’s size in pixels to val. Please use item labelsize(Fl Fontsize) instead.
• int linespacing () const
Get the line spacing value in pixels.
• void linespacing (int val)
Set the line spacing value in pixels.
• int marginleft () const
Get the left margin’s value in pixels.
• void marginleft (int val)
Set the left margin’s value in pixels.
• int margintop () const
Get the top margin’s value in pixels.
• void margintop (int val)
Set the top margin’s value in pixels.
• int openchild marginbottom () const
Get the margin below an open child in pixels.
• void openchild marginbottom (int val)
Set the margin below an open child in pixels.
806 CHAPTER 31. CLASS DOCUMENTATION

• Fl Image ∗ openicon () const


Get the current default ’open’ icon.
• void openicon (Fl Image ∗val)
Sets the default icon to be used as the ’open’ icon when items are add()ed to the tree.
• Fl Boxtype selectbox () const
Get the default selection box’s box drawing style as an Fl Boxtype.
• void selectbox (Fl Boxtype val)
Set the default selection box’s box drawing style to val.
• Fl Tree Select selectmode () const
Get the selection mode used for the tree.
• void selectmode (Fl Tree Select val)
Set the selection mode used for the tree to val.
• char showcollapse () const
Returns 1 if the collapse icon is enabled, 0 if not.
• void showcollapse (int val)
Set if we should show the collapse icon or not.
• int showroot () const
Returns 1 if the root item is to be shown, or 0 if not.
• void showroot (int val)
Set if the root item should be shown or not.
• Fl Tree Sort sortorder () const
Get the default sort order value.
• void sortorder (Fl Tree Sort val)
Set the default sort order value.
• Fl Image ∗ usericon () const
Gets the default ’user icon’ (default is 0)
• void usericon (Fl Image ∗val)
Sets the default ’user icon’ Returns the Fl Image∗ of the icon, or 0 if none (default).
• int usericonmarginleft () const
Get the user icon’s left margin value in pixels.
• void usericonmarginleft (int val)
Set the user icon’s left margin value in pixels.

31.146.1 Detailed Description


Tree widget’s preferences.
Fl Tree’s Preferences class.
This class manages the Fl Tree’s defaults. You should probably be using the methods in Fl Tree instead
of trying to accessing tree’s preferences settings directly.

31.146.2 Member Function Documentation


void Fl Tree Prefs::closeicon ( Fl Image ∗ val )
Sets the icon to be used as the ’close’ icon.
This overrides the built in default ’[-]’ icon.
31.146. FL TREE PREFS CLASS REFERENCE 807

Parameters
in val – The new image, or zero to use the default [-] icon.

Fl Image∗ Fl Tree Prefs::openicon ( ) const [inline]

Get the current default ’open’ icon.


Returns the Fl Image∗ of the icon, or 0 if none.

void Fl Tree Prefs::openicon ( Fl Image ∗ val )

Sets the default icon to be used as the ’open’ icon when items are add()ed to the tree.
This overrides the built in default ’[+]’ icon.
Parameters
in val – The new image, or zero to use the default [+] icon.

void Fl Tree Prefs::selectmode ( Fl Tree Select val ) [inline]

Set the selection mode used for the tree to val.


This affects how items in the tree are selected when clicked on and dragged over by the mouse. See
Fl Tree Select for possible values.

void Fl Tree Prefs::showcollapse ( int val ) [inline]

Set if we should show the collapse icon or not.


If collapse icons are disabled, the user will not be able to interactively collapse items in the tree, unless
the application provides some other means via open() and close().
Parameters
in val 1: shows collapse icons (default),
0: hides collapse icons.

void Fl Tree Prefs::showroot ( int val ) [inline]

Set if the root item should be shown or not.


Parameters
in val 1 – show the root item (default)
0 – hide the root item.

void Fl Tree Prefs::sortorder ( Fl Tree Sort val ) [inline]

Set the default sort order value.


Defines the order new items appear when add()ed to the tree. See Fl Tree Sort for possible values.
The documentation for this class was generated from the following files:

• Fl Tree Prefs.H
• Fl Tree Prefs.cxx
808 CHAPTER 31. CLASS DOCUMENTATION

31.147 Fl Valuator Class Reference


The Fl Valuator class controls a single floating-point value and provides a consistent interface to set the
value, range, and step, and insures that callbacks are done the same for every object.
#include <Fl Valuator.H>
Inheritance diagram for Fl Valuator:

Fl_Widget

Fl_Valuator

Fl_Adjuster Fl_Counter Fl_Dial Fl_Roller Fl_Slider Fl_Value_Input Fl_Value_Output

Fl_Simple_Counter Fl_Fill_Dial Fl_Fill_Slider

Fl_Line_Dial Fl_Hor_Fill_Slider

Fl_Hor_Nice_Slider

Fl_Hor_Slider

Fl_Nice_Slider

Fl_Scrollbar

Fl_Value_Slider

Public Member Functions


• void bounds (double a, double b)
Sets the minimum (a) and maximum (b) values for the valuator widget.
• double clamp (double)
Clamps the passed value to the valuator range.
• virtual int format (char ∗)
Uses internal rules to format the fields numerical value into the character array pointed to by the passed
parameter.
• double increment (double, int)
Adds n times the step value to the passed value.
• double maximum () const
Gets the maximum value for the valuator.
• void maximum (double a)
Sets the maximum value for the valuator.
• double minimum () const
Gets the minimum value for the valuator.
• void minimum (double a)
Sets the minimum value for the valuator.
• void precision (int)
Sets the step value to 1/10digits .
• void range (double a, double b)
Sets the minimum and maximum values for the valuator.
• double round (double)
Round the passed value to the nearest step increment.
• void step (int a)
See double Fl Valuator::step() const.
31.147. FL VALUATOR CLASS REFERENCE 809

• void step (double a, int b)


See double Fl Valuator::step() const.
• void step (double s)
See double Fl Valuator::step() const.
• double step () const
Gets or sets the step value.
• double value () const
Gets the floating point(double) value.
• int value (double)
Sets the current value.

Protected Member Functions


• Fl Valuator (int X, int Y, int W, int H, const char ∗L)
Creates a new Fl Valuator widget using the given position, size, and label string.
• void handle drag (double newvalue)
Called during a drag operation, after an FL WHEN CHANGED event is received and before the callback.
• void handle push ()
Stores the current value in the previous value.
• void handle release ()
Called after an FL WHEN RELEASE event is received and before the callback.
• int horizontal () const
Tells if the valuator is an FL HORIZONTAL one.
• double previous value () const
Gets the previous floating point value before an event changed it.
• void set value (double v)
Sets the current floating point value.
• double softclamp (double)
Clamps the value, but accepts v if the previous value is not already out of range.
• virtual void value damage ()
Asks for partial redraw.

Additional Inherited Members

31.147.1 Detailed Description


The Fl Valuator class controls a single floating-point value and provides a consistent interface to set the
value, range, and step, and insures that callbacks are done the same for every object.
There are probably more of these classes in FLTK than any others:
810 CHAPTER 31. CLASS DOCUMENTATION

Figure 31.48: Valuators derived from Fl Valuators

In the above diagram each box surrounds an actual subclass. These are further differentiated by setting
the type() of the widget t o the symbolic value labeling the widget. The ones labelled ”0” are the default
versions with a type(0). For consistency the symbol FL VERTICAL is defined as zero.

31.147.2 Constructor & Destructor Documentation


Fl Valuator::Fl Valuator ( int X, int Y, int W, int H, const char ∗ L ) [protected]
Creates a new Fl Valuator widget using the given position, size, and label string.
The default boxtype is FL NO BOX.

31.147.3 Member Function Documentation


void Fl Valuator::bounds ( double a, double b ) [inline]
Sets the minimum (a) and maximum (b) values for the valuator widget.

double Fl Valuator::clamp ( double v )


Clamps the passed value to the valuator range.

int Fl Valuator::format ( char ∗ buffer ) [virtual]


Uses internal rules to format the fields numerical value into the character array pointed to by the passed
parameter.
The actual format used depends on the current step value. If the step value has been set to zero then a
g format is used. If the step value is non-zero, then a %.∗f format is used, where the precision is calculated
to show sufficient digits for the current step value. An integer step value, such as 1 or 1.0, gives a precision
of 0, so the formatted value will appear as an integer.
31.147. FL VALUATOR CLASS REFERENCE 811

This method is used by the Fl Value ... group of widgets to format the current value into a text string.
The return value is the length of the formatted text. The formatted value is written into in buffer. buffer
should have space for at least 128 bytes.
You may override this function to create your own text formatting.

void Fl Valuator::handle drag ( double v ) [protected]


Called during a drag operation, after an FL WHEN CHANGED event is received and before the callback.

void Fl Valuator::handle release ( ) [protected]


Called after an FL WHEN RELEASE event is received and before the callback.

double Fl Valuator::increment ( double v, int n )


Adds n times the step value to the passed value.
If step was set to zero it uses fabs(maximum() - minimum()) / 100.

double Fl Valuator::maximum ( ) const [inline]


Gets the maximum value for the valuator.

void Fl Valuator::maximum ( double a ) [inline]


Sets the maximum value for the valuator.

double Fl Valuator::minimum ( ) const [inline]


Gets the minimum value for the valuator.

void Fl Valuator::minimum ( double a ) [inline]


Sets the minimum value for the valuator.

void Fl Valuator::precision ( int p )

Sets the step value to 1/10digits .

void Fl Valuator::range ( double a, double b ) [inline]


Sets the minimum and maximum values for the valuator.
When the user manipulates the widget, the value is limited to this range. This clamping is done after
rounding to the step value (this makes a difference if the range is not a multiple of the step).
The minimum may be greater than the maximum. This has the effect of ”reversing” the object so the
larger values are in the opposite direction. This also switches which end of the filled sliders is filled.
Some widgets consider this a ”soft” range. This means they will stop at the range, but if the user
releases and grabs the control again and tries to move it further, it is allowed.
The range may affect the display. You must redraw() the widget after changing the range.

double Fl Valuator::round ( double v )


Round the passed value to the nearest step increment.
Does nothing if step is zero.
812 CHAPTER 31. CLASS DOCUMENTATION

void Fl Valuator::set value ( double v ) [inline], [protected]


Sets the current floating point value.

double Fl Valuator::step ( ) const [inline]


Gets or sets the step value.
As the user moves the mouse the value is rounded to the nearest multiple of the step value. This is done
before clamping it to the range. For most widgets the default step is zero.
For precision the step is stored as the ratio of two integers, A/B. You can set these integers directly.
Currently setting a floating point value sets the nearest A/1 or 1/B value possible.

double Fl Valuator::value ( ) const [inline]


Gets the floating point(double) value.
See int value(double)

int Fl Valuator::value ( double v )


Sets the current value.
The new value is not clamped or otherwise changed before storing it. Use clamp() or round() to modify
the value before calling value(). The widget is redrawn if the new value is different than the current one.
The initial value is zero.
changed() will return true if the user has moved the slider, but it will be turned off by value(x) and just
before doing a callback (the callback can turn it back on if desired).
The documentation for this class was generated from the following files:

• Fl Valuator.H
• Fl Valuator.cxx

31.148 Fl Value Input Class Reference


The Fl Value Input widget displays a numeric value.
#include <Fl Value Input.H>
Inheritance diagram for Fl Value Input:

Fl_Widget

Fl_Valuator

Fl_Value_Input

Public Member Functions


• Fl Color cursor color () const
Gets the color of the text cursor.
• void cursor color (Fl Color n)
Sets the color of the text cursor.
• Fl Value Input (int x, int y, int w, int h, const char ∗l=0)
Creates a new Fl Value Input widget using the given position, size, and label string.
31.148. FL VALUE INPUT CLASS REFERENCE 813

• int handle (int)


Handles the specified event.
• void resize (int, int, int, int)
Changes the size or position of the widget.
• int shortcut () const
Returns the current shortcut key for the Input.
• void shortcut (int s)
Sets the shortcut key to s.
• void soft (char s)
See void Fl Value Input::soft(char s)
• char soft () const
If ”soft” is turned on, the user is allowed to drag the value outside the range.
• Fl Color textcolor () const
Gets the color of the text in the value box.
• void textcolor (Fl Color n)
Sets the color of the text in the value box.
• Fl Font textfont () const
Gets the typeface of the text in the value box.
• void textfont (Fl Font s)
Sets the typeface of the text in the value box.
• Fl Fontsize textsize () const
Gets the size of the text in the value box.
• void textsize (Fl Fontsize s)
Sets the size of the text in the value box.

Public Attributes
• Fl Input input

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.148.1 Detailed Description
The Fl Value Input widget displays a numeric value.
The user can click in the text field and edit it - there is in fact a hidden Fl Input widget with type(FL-
FLOAT INPUT) or type(FL INT INPUT) in there - and when they hit return or tab the value updates to
what they typed and the callback is done.
If step() is non-zero and integral, then the range of numbers is limited to integers instead of floating
point numbers. As well as displaying the value as an integer, typed input is also limited to integer values,
even if the hidden Fl Input widget is of type(FL FLOAT INPUT).
If step() is non-zero, the user can also drag the mouse across the object and thus slide the value. The
left button moves one step() per pixel, the middle by 10 step(), and the right button by 100 ∗ step(). It
is therefore impossible to select text by dragging across it, although clicking can still move the insertion
cursor.
814 CHAPTER 31. CLASS DOCUMENTATION

If step() is non-zero and integral, then the range of numbers are limited to integers instead of floating
point values.

Figure 31.49: Fl Value Input

31.148.2 Constructor & Destructor Documentation


Fl Value Input::Fl Value Input ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Value Input widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.

31.148.3 Member Function Documentation


Fl Color Fl Value Input::cursor color ( ) const [inline]
Gets the color of the text cursor.
The text cursor is black by default.

void Fl Value Input::cursor color ( Fl Color n ) [inline]


Sets the color of the text cursor.
The text cursor is black by default.

void Fl Value Input::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Value Input::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
31.148. FL VALUE INPUT CLASS REFERENCE 815

Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.

void Fl Value Input::resize ( int x, int y, int w, int h ) [virtual]

Changes the size or position of the widget.


This is a virtual function so that the widget may implement its own handling of resizing. The default
version does not call the redraw() method, but instead relies on the parent widget to do so because the
parent may know a faster way to update the display, such as scrolling from the old position.
Some window managers under X11 call resize() a lot more often than needed. Please verify that the
position or size of a widget did actually change before doing any extensive calculations.
position(X, Y) is a shortcut for resize(X, Y, w(), h()), and size(W, H) is a shortcut for resize(x(), y(), W,
H).
Parameters
in x,y new position relative to the parent window
in w,h new size

See Also
position(int,int), size(int,int)

Reimplemented from Fl Widget.

int Fl Value Input::shortcut ( ) const [inline]

Returns the current shortcut key for the Input.

See Also
Fl Value Input::shortcut(int)

void Fl Value Input::shortcut ( int s ) [inline]

Sets the shortcut key to s.


Setting this overrides the use of ’&’ in the label(). The value is a bitwise OR of a key and a set of shift
flags, for example FL ALT | ’a’ , FL ALT | (FL F + 10), or just ’a’. A value of 0 disables the shortcut.
The key can be any value returned by Fl::event key(), but will usually be an ASCII letter. Use a lower-
case letter unless you require the shift key to be held down.
The shift flags can be any set of values accepted by Fl::event state(). If the bit is on that shift key must
be pushed. Meta, Alt, Ctrl, and Shift must be off if they are not in the shift flags (zero for the other bits
indicates a ”don’t care” setting).
816 CHAPTER 31. CLASS DOCUMENTATION

char Fl Value Input::soft ( ) const [inline]

If ”soft” is turned on, the user is allowed to drag the value outside the range.
If they drag the value to one of the ends, let go, then grab again and continue to drag, they can get to
any value. The default is true.

Fl Color Fl Value Input::textcolor ( ) const [inline]

Gets the color of the text in the value box.

void Fl Value Input::textcolor ( Fl Color n ) [inline]

Sets the color of the text in the value box.

Fl Font Fl Value Input::textfont ( ) const [inline]

Gets the typeface of the text in the value box.

void Fl Value Input::textfont ( Fl Font s ) [inline]

Sets the typeface of the text in the value box.

Fl Fontsize Fl Value Input::textsize ( ) const [inline]

Gets the size of the text in the value box.

void Fl Value Input::textsize ( Fl Fontsize s ) [inline]

Sets the size of the text in the value box.


The documentation for this class was generated from the following files:

• Fl Value Input.H
• Fl Value Input.cxx

31.149 Fl Value Output Class Reference


The Fl Value Output widget displays a floating point value.
#include <Fl Value Output.H>
Inheritance diagram for Fl Value Output:

Fl_Widget

Fl_Valuator

Fl_Value_Output
31.149. FL VALUE OUTPUT CLASS REFERENCE 817

Public Member Functions


• Fl Value Output (int x, int y, int w, int h, const char ∗l=0)
Creates a new Fl Value Output widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
• void soft (uchar s)
If ”soft” is turned on, the user is allowed to drag the value outside the range.
• uchar soft () const
If ”soft” is turned on, the user is allowed to drag the value outside the range.
• Fl Color textcolor () const
Sets the color of the text in the value box.
• void textcolor (Fl Color s)
Gets the color of the text in the value box.
• Fl Font textfont () const
Gets the typeface of the text in the value box.
• void textfont (Fl Font s)
Sets the typeface of the text in the value box.
• Fl Fontsize textsize () const
Gets the size of the text in the value box.
• void textsize (Fl Fontsize s)

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.149.1 Detailed Description
The Fl Value Output widget displays a floating point value.
If step() is not zero, the user can adjust the value by dragging the mouse left and right. The left button
moves one step() per pixel, the middle by 10 ∗ step(), and the right button by 100 ∗ step().
This is much lighter-weight than Fl Value Input because it contains no text editing code or character
buffer.

Figure 31.50: Fl Value Output

31.149.2 Constructor & Destructor Documentation


Fl Value Output::Fl Value Output ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Value Output widget using the given position, size, and label string.
The default boxtype is FL NO BOX.
Inherited destructor destroys the Valuator.
818 CHAPTER 31. CLASS DOCUMENTATION

31.149.3 Member Function Documentation


void Fl Value Output::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Implements Fl Widget.

int Fl Value Output::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Widget.

void Fl Value Output::soft ( uchar s ) [inline]


If ”soft” is turned on, the user is allowed to drag the value outside the range.
If they drag the value to one of the ends, let go, then grab again and continue to drag, they can get to
any value. Default is one.

uchar Fl Value Output::soft ( ) const [inline]


If ”soft” is turned on, the user is allowed to drag the value outside the range.
If they drag the value to one of the ends, let go, then grab again and continue to drag, they can get to
any value. Default is one.

Fl Color Fl Value Output::textcolor ( ) const [inline]


Sets the color of the text in the value box.

void Fl Value Output::textcolor ( Fl Color s ) [inline]


Gets the color of the text in the value box.
31.150. FL VALUE SLIDER CLASS REFERENCE 819

Fl Font Fl Value Output::textfont ( ) const [inline]


Gets the typeface of the text in the value box.

void Fl Value Output::textfont ( Fl Font s ) [inline]


Sets the typeface of the text in the value box.

Fl Fontsize Fl Value Output::textsize ( ) const [inline]


Gets the size of the text in the value box.
The documentation for this class was generated from the following files:

• Fl Value Output.H
• Fl Value Output.cxx

31.150 Fl Value Slider Class Reference


The Fl Value Slider widget is a Fl Slider widget with a box displaying the current value.
#include <Fl Value Slider.H>
Inheritance diagram for Fl Value Slider:

Fl_Widget

Fl_Valuator

Fl_Slider

Fl_Value_Slider

Fl_Hor_Value_Slider

Public Member Functions


• Fl Value Slider (int x, int y, int w, int h, const char ∗l=0)
Creates a new Fl Value Slider widget using the given position, size, and label string.
• int handle (int)
Handles the specified event.
• Fl Color textcolor () const
Gets the color of the text in the value box.
• void textcolor (Fl Color s)
Sets the color of the text in the value box.
• Fl Font textfont () const
Gets the typeface of the text in the value box.
• void textfont (Fl Font s)
Sets the typeface of the text in the value box.
• Fl Fontsize textsize () const
Gets the size of the text in the value box.
820 CHAPTER 31. CLASS DOCUMENTATION

• void textsize (Fl Fontsize s)


Sets the size of the text in the value box.

Protected Member Functions


• void draw ()
Draws the widget.

Additional Inherited Members


31.150.1 Detailed Description
The Fl Value Slider widget is a Fl Slider widget with a box displaying the current value.

Figure 31.51: Fl Value Slider

31.150.2 Constructor & Destructor Documentation


Fl Value Slider::Fl Value Slider ( int X, int Y, int W, int H, const char ∗ l = 0 )
Creates a new Fl Value Slider widget using the given position, size, and label string.
The default boxtype is FL DOWN BOX.

31.150.3 Member Function Documentation


void Fl Value Slider::draw ( ) [protected], [virtual]
Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Slider.

int Fl Value Slider::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
31.151. FL WIDGET CLASS REFERENCE 821

Parameters
in event the kind of event received

Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented from Fl Slider.

Fl Color Fl Value Slider::textcolor ( ) const [inline]

Gets the color of the text in the value box.

void Fl Value Slider::textcolor ( Fl Color s ) [inline]

Sets the color of the text in the value box.

Fl Font Fl Value Slider::textfont ( ) const [inline]

Gets the typeface of the text in the value box.

void Fl Value Slider::textfont ( Fl Font s ) [inline]

Sets the typeface of the text in the value box.

Fl Fontsize Fl Value Slider::textsize ( ) const [inline]

Gets the size of the text in the value box.

void Fl Value Slider::textsize ( Fl Fontsize s ) [inline]

Sets the size of the text in the value box.


The documentation for this class was generated from the following files:

• Fl Value Slider.H
• Fl Value Slider.cxx

31.151 Fl Widget Class Reference


Fl Widget is the base class for all widgets in FLTK.
#include <Fl Widget.H>
Inheritance diagram for Fl Widget:
822 CHAPTER 31. CLASS DOCUMENTATION

Fl_Widget

Fl_Box

Fl_Button

Fl_Chart

Fl_Clock_Output

Fl_FormsBitmap

Fl_FormsPixmap

Fl_FormsText

Fl_Free

Fl_Group

Fl_Input_

Fl_Menu_

Fl_Positioner

Fl_Progress

Fl_Timer

Fl_Valuator

Public Member Functions


• void clear fullscreen ()
• void set fullscreen ()
• void activate ()
Activates the widget.
• unsigned int active () const
Returns whether the widget is active.
• int active r () const
Returns whether the widget and all of its parents are active.
• Fl Align align () const
Gets the label alignment.
• void align (Fl Align alignment)
Sets the label alignment.
• long argument () const
Gets the current user data (long) argument that is passed to the callback function.
• void argument (long v)
Sets the current user data (long) argument that is passed to the callback function.
• virtual class Fl Gl Window ∗ as gl window ()
Returns an Fl Gl Window pointer if this widget is an Fl Gl Window.
• virtual Fl Group ∗ as group ()
31.151. FL WIDGET CLASS REFERENCE 823

Returns an Fl Group pointer if this widget is an Fl Group.


• virtual Fl Window ∗ as window ()
Returns an Fl Window pointer if this widget is an Fl Window.
• Fl Boxtype box () const
Gets the box type of the widget.
• void box (Fl Boxtype new box)
Sets the box type for the widget.
• Fl Callback p callback () const
Gets the current callback function for the widget.
• void callback (Fl Callback ∗cb, void ∗p)
Sets the current callback function for the widget.
• void callback (Fl Callback ∗cb)
Sets the current callback function for the widget.
• void callback (Fl Callback0 ∗cb)
Sets the current callback function for the widget.
• void callback (Fl Callback1 ∗cb, long p=0)
Sets the current callback function for the widget.
• unsigned int changed () const
Checks if the widget value changed since the last callback.
• void clear active ()
Marks the widget as inactive without sending events or changing focus.
• void clear changed ()
Marks the value of the widget as unchanged.
• void clear damage (uchar c=0)
Clears or sets the damage flags.
• void clear output ()
Sets a widget to accept input.
• void clear visible ()
Hides the widget.
• void clear visible focus ()
Disables keyboard focus navigation with this widget.
• Fl Color color () const
Gets the background color of the widget.
• void color (Fl Color bg)
Sets the background color of the widget.
• void color (Fl Color bg, Fl Color sel)
Sets the background and selection color of the widget.
• Fl Color color2 () const
For back compatibility only.
• void color2 (unsigned a)
For back compatibility only.
• int contains (const Fl Widget ∗w) const
Checks if w is a child of this widget.
• void copy label (const char ∗new label)
Sets the current label.
• void copy tooltip (const char ∗text)
824 CHAPTER 31. CLASS DOCUMENTATION

Sets the current tooltip text.


• uchar damage () const
Returns non-zero if draw() needs to be called.
• void damage (uchar c)
Sets the damage bits for the widget.
• void damage (uchar c, int x, int y, int w, int h)
Sets the damage bits for an area inside the widget.
• int damage resize (int, int, int, int)
Internal use only.
• void deactivate ()
Deactivates the widget.
• Fl Image ∗ deimage ()
Gets the image that is used as part of the widget label.
• const Fl Image ∗ deimage () const
• void deimage (Fl Image ∗img)
Sets the image to use as part of the widget label.
• void deimage (Fl Image &img)
Sets the image to use as part of the widget label.
• void do callback ()
Calls the widget callback.
• void do callback (Fl Widget ∗o, long arg)
Calls the widget callback.
• void do callback (Fl Widget ∗o, void ∗arg=0)
Calls the widget callback.
• virtual void draw ()=0
Draws the widget.
• void draw label (int, int, int, int, Fl Align) const
Draws the label in an arbitrary bounding box with an arbitrary alignment.
• int h () const
Gets the widget height.
• virtual int handle (int event)
Handles the specified event.
• virtual void hide ()
Makes a widget invisible.
• Fl Image ∗ image ()
Gets the image that is used as part of the widget label.
• const Fl Image ∗ image () const
• void image (Fl Image ∗img)
Sets the image to use as part of the widget label.
• void image (Fl Image &img)
Sets the image to use as part of the widget label.
• int inside (const Fl Widget ∗wgt) const
Checks if this widget is a child of wgt.
• const char ∗ label () const
Gets the current label text.
• void label (const char ∗text)
Sets the current label pointer.
31.151. FL WIDGET CLASS REFERENCE 825

• void label (Fl Labeltype a, const char ∗b)


Shortcut to set the label text and type in one call.
• Fl Color labelcolor () const
Gets the label color.
• void labelcolor (Fl Color c)
Sets the label color.
• Fl Font labelfont () const
Gets the font to use.
• void labelfont (Fl Font f)
Sets the font to use.
• Fl Fontsize labelsize () const
Gets the font size in pixels.
• void labelsize (Fl Fontsize pix)
Sets the font size in pixels.
• Fl Labeltype labeltype () const
Gets the label type.
• void labeltype (Fl Labeltype a)
Sets the label type.
• void measure label (int &ww, int &hh) const
Sets width ww and height hh accordingly with the label size.
• unsigned int output () const
Returns if a widget is used for output only.
• Fl Group ∗ parent () const
Returns a pointer to the parent widget.
• void parent (Fl Group ∗p)
Internal use only - ”for hacks only”.
• void position (int X, int Y)
Repositions the window or widget.
• void redraw ()
Schedules the drawing of the widget.
• void redraw label ()
Schedules the drawing of the label.
• virtual void resize (int x, int y, int w, int h)
Changes the size or position of the widget.
• Fl Color selection color () const
Gets the selection color.
• void selection color (Fl Color a)
Sets the selection color.
• void set active ()
Marks the widget as active without sending events or changing focus.
• void set changed ()
Marks the value of the widget as changed.
• void set output ()
Sets a widget to output only.
• void set visible ()
Makes the widget visible.
826 CHAPTER 31. CLASS DOCUMENTATION

• void set visible focus ()


Enables keyboard focus navigation with this widget.
• virtual void show ()
Makes a widget visible.
• void size (int W, int H)
Changes the size of the widget.
• int take focus ()
Gives the widget the keyboard focus.
• unsigned int takesevents () const
Returns if the widget is able to take events.
• int test shortcut ()
Returns true if the widget’s label contains the entered ’&x’ shortcut.
• const char ∗ tooltip () const
Gets the current tooltip text.
• void tooltip (const char ∗text)
Sets the current tooltip text.
• Fl Window ∗ top window () const
Returns a pointer to the top-level window for the widget.
• Fl Window ∗ top window offset (int &xoff, int &yoff) const
Finds the x/y offset of the current widget relative to the top-level window.
• uchar type () const
Gets the widget type.
• void type (uchar t)
Sets the widget type.
• int use accents menu ()
Returns non zero if MAC USE ACCENTS MENU flag is set, 0 otherwise.
• void ∗ user data () const
Gets the user data for this widget.
• void user data (void ∗v)
Sets the user data for this widget.
• unsigned int visible () const
Returns whether a widget is visible.
• void visible focus (int v)
Modifies keyboard focus navigation.
• unsigned int visible focus ()
Checks whether this widget has a visible focus.
• int visible r () const
Returns whether a widget and all its parents are visible.
• int w () const
Gets the widget width.
• Fl When when () const
Returns the conditions under which the callback is called.
• void when (uchar i)
Sets the flags used to decide when a callback is called.
• Fl Window ∗ window () const
Returns a pointer to the nearest parent window up the widget hierarchy.
31.151. FL WIDGET CLASS REFERENCE 827

• int x () const
Gets the widget position in its window.
• int y () const
Gets the widget position in its window.
• virtual ∼Fl Widget ()
Destroys the widget.

Static Public Member Functions


• static void default callback (Fl Widget ∗cb, void ∗d)
Sets the default callback for all widgets.
• static unsigned int label shortcut (const char ∗t)
Returns the Unicode value of the ’&x’ shortcut in a given text.
• static int test shortcut (const char ∗, const bool require alt=false)
Returns true if the given text t contains the entered ’&x’ shortcut.

Protected Types
• enum {
INACTIVE = 1<<0, INVISIBLE = 1<<1, OUTPUT = 1<<2, NOBORDER = 1<<3,
FORCE POSITION = 1<<4, NON MODAL = 1<<5, SHORTCUT LABEL = 1<<6, CHANGE-
D = 1<<7,
OVERRIDE = 1<<8, VISIBLE FOCUS = 1<<9, COPIED LABEL = 1<<10, CLIP CHILDREN
= 1<<11,
MENU WINDOW = 1<<12, TOOLTIP WINDOW = 1<<13, MODAL = 1<<14, NO OVERL-
AY = 1<<15,
GROUP RELATIVE = 1<<16, COPIED TOOLTIP = 1<<17, FULLSCREEN = 1<<18, MAC -
USE ACCENTS MENU = 1<<19,
USERFLAG3 = 1<<29, USERFLAG2 = 1<<30, USERFLAG1 = 1<<31 }
flags possible values enumeration.

Protected Member Functions


• void clear flag (unsigned int c)
Clears a flag in the flags mask.
• void draw backdrop () const
If FL ALIGN IMAGE BACKDROP is set, the image or deimage will be drawn.
• void draw box () const
Draws the widget box according its box style.
• void draw box (Fl Boxtype t, Fl Color c) const
Draws a box of type t, of color c at the widget’s position and size.
• void draw box (Fl Boxtype t, int x, int y, int w, int h, Fl Color c) const
Draws a box of type t, of color c at the position X,Y and size W,H.
• void draw focus ()
draws a focus rectangle around the widget
• void draw focus (Fl Boxtype t, int x, int y, int w, int h) const
Draws a focus box for the widget at the given position and size.
• void draw label () const
Draws the widget’s label at the defined label position.
828 CHAPTER 31. CLASS DOCUMENTATION

• void draw label (int, int, int, int) const


Draws the label in an arbitrary bounding box.
• Fl Widget (int x, int y, int w, int h, const char ∗label=0L)
Creates a widget at the given position and size.
• unsigned int flags () const
Gets the widget flags mask.
• void h (int v)
Internal use only.
• void set flag (unsigned int c)
Sets a flag in the flags mask.
• void w (int v)
Internal use only.
• void x (int v)
Internal use only.
• void y (int v)
Internal use only.

Friends
• class Fl Group

31.151.1 Detailed Description


Fl Widget is the base class for all widgets in FLTK.
You can’t create one of these because the constructor is not public. However you can subclass it.
All ”property” accessing methods, such as color(), parent(), or argument() are implemented as trivial
inline functions and thus are as fast and small as accessing fields in a structure. Unless otherwise noted, the
property setting methods such as color(n) or label(s) are also trivial inline functions, even if they change
the widget’s appearance. It is up to the user code to call redraw() after these.

31.151.2 Member Enumeration Documentation


anonymous enum [protected]
flags possible values enumeration.
See activate(), output(), visible(), changed(), set visible focus()
Enumerator
INACTIVE the widget can’t receive focus, and is disabled but potentially visible
INVISIBLE the widget is not drawn, but can receive a few special events
OUTPUT for output only
NOBORDER don’t draw a decoration (Fl Window)
FORCE POSITION don’t let the window manager position the window (Fl Window)
NON MODAL this is a hovering toolbar window (Fl Window)
SHORTCUT LABEL the label contains a shortcut we need to draw
CHANGED the widget value changed
OVERRIDE position window on top (Fl Window)
VISIBLE FOCUS accepts keyboard focus navigation if the widget can have the focus
COPIED LABEL the widget label is internally copied, its destruction is handled by the widget
31.151. FL WIDGET CLASS REFERENCE 829

CLIP CHILDREN all drawing within this widget will be clipped (Fl Group)
MENU WINDOW a temporary popup window, dismissed by clicking outside (Fl Window)
TOOLTIP WINDOW a temporary popup, transparent to events, and dismissed easily (Fl Window)
MODAL a window blocking input to all other winows (Fl Window)
NO OVERLAY window not using a hardware overlay plane (Fl Menu Window)
GROUP RELATIVE position this widget relative to the parent group, not to the window
COPIED TOOLTIP the widget tooltip is internally copied, its destruction is handled by the widget
FULLSCREEN a fullscreen window (Fl Window)
MAC USE ACCENTS MENU On the Mac OS platform, pressing and holding a key on the keyboard
opens an accented-character menu window (Fl Input , Fl Text Editor)
USERFLAG3 reserved for 3rd party extensions
USERFLAG2 reserved for 3rd party extensions
USERFLAG1 reserved for 3rd party extensions

31.151.3 Constructor & Destructor Documentation


Fl Widget::Fl Widget ( int x, int y, int w, int h, const char ∗ label = 0L ) [protected]
Creates a widget at the given position and size.
The Fl Widget is a protected constructor, but all derived widgets have a matching public constructor. It
takes a value for x(), y(), w(), h(), and an optional value for label().
Parameters
in x,y the position of the widget relative to the enclosing window
in w,h size of the widget in pixels
in label optional text for the widget label

Fl Widget::∼Fl Widget ( ) [virtual]


Destroys the widget.
Destroys the widget, taking care of throwing focus before if any.
Destroying single widgets is not very common. You almost always want to destroy the parent group
instead, which will destroy all of the child widgets and groups in that group.
Since
FLTK 1.3, the widget’s destructor removes the widget from its parent group, if it is member of a
group.

Destruction removes the widget from any parent group! And groups when destroyed destroy all their
children. This is convenient and fast.

31.151.4 Member Function Documentation


void Fl Widget::activate ( )
Activates the widget.
Changing this value will send FL ACTIVATE to the widget if active r() is true.
See Also
active(), active r(), deactivate()
830 CHAPTER 31. CLASS DOCUMENTATION

unsigned int Fl Widget::active ( ) const [inline]


Returns whether the widget is active.
31.151. FL WIDGET CLASS REFERENCE 831

Return values
0 if the widget is inactive

See Also
active r(), activate(), deactivate()

int Fl Widget::active r ( ) const


Returns whether the widget and all of its parents are active.
Return values
0 if this or any of the parent widgets are inactive

See Also
active(), activate(), deactivate()

Fl Align Fl Widget::align ( ) const [inline]


Gets the label alignment.
Returns
label alignment

See Also
label(), align(Fl Align), Fl Align

void Fl Widget::align ( Fl Align alignment ) [inline]


Sets the label alignment.
This controls how the label is displayed next to or inside the widget. The default value is FL ALIGN -
CENTER, which centers the label inside the widget.
Parameters
in alignment new label alignment

See Also
align(), Fl Align

void Fl Widget::argument ( long v ) [inline]


Sets the current user data (long) argument that is passed to the callback function.

Todo The user data value must be implemented using intptr t or similar to avoid 64-bit machine incom-
patibilities.

virtual class Fl Gl Window∗ Fl Widget::as gl window ( ) [inline], [virtual]


Returns an Fl Gl Window pointer if this widget is an Fl Gl Window.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from
Fl Gl Window. If it returns non-NULL, then the widget in question is derived from Fl Gl Window.
832 CHAPTER 31. CLASS DOCUMENTATION

Return values
NULL if this widget is not derived from Fl Gl Window.

Note
This method is provided to avoid dynamic cast.

See Also
Fl Widget::as group(), Fl Widget::as window()
Reimplemented in Fl Gl Window.

virtual Fl Group∗ Fl Widget::as group ( ) [inline], [virtual]


Returns an Fl Group pointer if this widget is an Fl Group.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from
Fl Group. If it returns non-NULL, then the widget in question is derived from Fl Group, and you can use
the returned pointer to access its children or other Fl Group-specific methods.
Example:
void my callback (Fl Widget *w, void *) {
Fl Group *g = w->as group();
if (g)
printf ("This group has %d children\n",g->children());
else
printf ("This widget is not a group!\n");
}

Return values
NULL if this widget is not derived from Fl Group.

Note
This method is provided to avoid dynamic cast.

See Also
Fl Widget::as window(), Fl Widget::as gl window()
Reimplemented in Fl Group.

virtual Fl Window∗ Fl Widget::as window ( ) [inline], [virtual]


Returns an Fl Window pointer if this widget is an Fl Window.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from
Fl Window. If it returns non-NULL, then the widget in question is derived from Fl Window, and you can
use the returned pointer to access its children or other Fl Window-specific methods.
Return values
NULL if this widget is not derived from Fl Window.

Note
This method is provided to avoid dynamic cast.

See Also
Fl Widget::as group(), Fl Widget::as gl window()
Reimplemented in Fl Window.
31.151. FL WIDGET CLASS REFERENCE 833

Fl Boxtype Fl Widget::box ( ) const [inline]


Gets the box type of the widget.
Returns
the current box type

See Also
box(Fl Boxtype), Fl Boxtype

void Fl Widget::box ( Fl Boxtype new box ) [inline]


Sets the box type for the widget.
This identifies a routine that draws the background of the widget. See Fl Boxtype for the available
types. The default depends on the widget, but is usually FL NO BOX or FL UP BOX.
Parameters
in new box the new box type

See Also
box(), Fl Boxtype

Fl Callback p Fl Widget::callback ( ) const [inline]


Gets the current callback function for the widget.
Each widget has a single callback.
Returns
current callback

void Fl Widget::callback ( Fl Callback ∗ cb, void ∗ p ) [inline]


Sets the current callback function for the widget.
Each widget has a single callback.
Parameters
in cb new callback
in p user data

void Fl Widget::callback ( Fl Callback ∗ cb ) [inline]


Sets the current callback function for the widget.
Each widget has a single callback.
Parameters
in cb new callback

void Fl Widget::callback ( Fl Callback0 ∗ cb ) [inline]


Sets the current callback function for the widget.
Each widget has a single callback.
834 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in cb new callback

void Fl Widget::callback ( Fl Callback1 ∗ cb, long p = 0 ) [inline]


Sets the current callback function for the widget.
Each widget has a single callback.
Parameters
in cb new callback
in p user data

unsigned int Fl Widget::changed ( ) const [inline]


Checks if the widget value changed since the last callback.
”Changed” is a flag that is turned on when the user changes the value stored in the widget. This is
only used by subclasses of Fl Widget that store values, but is in the base class so it is easier to scan all the
widgets in a panel and do callback() on the changed ones in response to an ”OK” button.
Most widgets turn this flag off when they do the callback, and when the program sets the stored value.
Return values
0 if the value did not change

See Also
set changed(), clear changed()

void Fl Widget::clear active ( ) [inline]


Marks the widget as inactive without sending events or changing focus.
This is mainly for specialized use, for normal cases you want deactivate().
See Also
deactivate()

void Fl Widget::clear changed ( ) [inline]


Marks the value of the widget as unchanged.
See Also
changed(), set changed()

void Fl Widget::clear damage ( uchar c = 0 ) [inline]


Clears or sets the damage flags.
Damage flags are cleared when parts of the widget drawing is repaired.
The optional argument c specifies the bits that are set after the call (default: 0) and not the bits that are
cleared!
Note
Therefore it is possible to set damage bits with this method, but this should be avoided. Use dam-
age(uchar) instead.
31.151. FL WIDGET CLASS REFERENCE 835

Parameters
in c new bitmask of damage flags (default: 0)

See Also
damage(uchar), damage()

void Fl Widget::clear output ( ) [inline]


Sets a widget to accept input.
See Also
set output(), output()

void Fl Widget::clear visible ( ) [inline]


Hides the widget.
You must still redraw the parent to see a change in the window. Normally you want to use the hide()
method instead.

void Fl Widget::clear visible focus ( ) [inline]


Disables keyboard focus navigation with this widget.
Normally, all widgets participate in keyboard focus navigation.
See Also
set visible focus(), visible focus(), visible focus(int)

Fl Color Fl Widget::color ( ) const [inline]


Gets the background color of the widget.
Returns
current background color

See Also
color(Fl Color), color(Fl Color, Fl Color)

void Fl Widget::color ( Fl Color bg ) [inline]


Sets the background color of the widget.
The color is passed to the box routine. The color is either an index into an internal table of RGB colors
or an RGB color value generated using fl rgb color().
The default for most widgets is FL BACKGROUND COLOR. Use Fl::set color() to redefine colors in
the color map.
836 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in bg background color

See Also
color(), color(Fl Color, Fl Color), selection color(Fl Color)

void Fl Widget::color ( Fl Color bg, Fl Color sel ) [inline]


Sets the background and selection color of the widget.
The two color form sets both the background and selection colors.
Parameters
in bg background color
in sel selection color

See Also
color(unsigned), selection color(unsigned)

Fl Color Fl Widget::color2 ( ) const [inline]


For back compatibility only.

Deprecated Use selection color() instead.

void Fl Widget::color2 ( unsigned a ) [inline]


For back compatibility only.

Deprecated Use selection color(unsigned) instead.

int Fl Widget::contains ( const Fl Widget ∗ w ) const


Checks if w is a child of this widget.
Parameters
in w potential child widget

Returns
Returns 1 if w is a child of this widget, or is equal to this widget. Returns 0 if w is NULL.

void Fl Widget::copy label ( const char ∗ new label )


Sets the current label.
Unlike label(), this method allocates a copy of the label string instead of using the original string pointer.
The internal copy will automatically be freed whenever you assign a new label or when the widget is
destroyed.
31.151. FL WIDGET CLASS REFERENCE 837

Parameters
in new label the new label text

See Also
label()

void Fl Widget::copy tooltip ( const char ∗ text )


Sets the current tooltip text.
Unlike tooltip(), this method allocates a copy of the tooltip string instead of using the original string
pointer.
The internal copy will automatically be freed whenever you assign a new tooltip or when the widget is
destroyed.
If no tooltip is set, the tooltip of the parent is inherited. Setting a tooltip for a group and setting no
tooltip for a child will show the group’s tooltip instead. To avoid this behavior, you can set the child’s
tooltip to an empty string (””).
Parameters
in text New tooltip text (an internal copy is made and managed)

See Also
tooltip(const char∗), tooltip()

uchar Fl Widget::damage ( ) const [inline]


Returns non-zero if draw() needs to be called.
The damage value is actually a bit field that the widget subclass can use to figure out what parts to draw.
Returns
a bitmap of flags describing the kind of damage to the widget

See Also
damage(uchar), clear damage(uchar)

void Fl Widget::damage ( uchar c )


Sets the damage bits for the widget.
Setting damage bits will schedule the widget for the next redraw.
Parameters
in c bitmask of flags to set

See Also
damage(), clear damage(uchar)

void Fl Widget::damage ( uchar c, int x, int y, int w, int h )


Sets the damage bits for an area inside the widget.
Setting damage bits will schedule the widget for the next redraw.
838 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in c bitmask of flags to set
in x,y,w,h size of damaged area

See Also
damage(), clear damage(uchar)

int Fl Widget::damage resize ( int X, int Y, int W, int H )


Internal use only.

void Fl Widget::deactivate ( )
Deactivates the widget.
Inactive widgets will be drawn ”grayed out”, e.g. with less contrast than the active widget. Inactive
widgets will not receive any keyboard or mouse button events. Other events (including FL ENTER, FL -
MOVE, FL LEAVE, FL SHORTCUT, and others) will still be sent. A widget is only active if active() is
true on it and all of its parents.
Changing this value will send FL DEACTIVATE to the widget if active r() is true.
Currently you cannot deactivate Fl Window widgets.
See Also
activate(), active(), active r()

void Fl Widget::default callback ( Fl Widget ∗ cb, void ∗ d ) [static]


Sets the default callback for all widgets.
Sets the default callback, which puts a pointer to the widget on the queue returned by Fl::readqueue().
You may want to call this from your own callback.
Parameters
in cb the new callback
in d user data associated with that callback

See Also
callback(), do callback(), Fl::readqueue()

Fl Image∗ Fl Widget::deimage ( ) [inline]


Gets the image that is used as part of the widget label.
This image is used when drawing the widget in the inactive state.
Returns
the current image for the deactivated widget

void Fl Widget::deimage ( Fl Image ∗ img ) [inline]


Sets the image to use as part of the widget label.
This image is used when drawing the widget in the inactive state.
31.151. FL WIDGET CLASS REFERENCE 839

Parameters
in img the new image for the deactivated widget

void Fl Widget::deimage ( Fl Image & img ) [inline]


Sets the image to use as part of the widget label.
This image is used when drawing the widget in the inactive state.
Parameters
in img the new image for the deactivated widget

void Fl Widget::do callback ( ) [inline]


Calls the widget callback.
Causes a widget to invoke its callback function with default arguments.
See Also
callback()

void Fl Widget::do callback ( Fl Widget ∗ o, long arg ) [inline]


Calls the widget callback.
Causes a widget to invoke its callback function with arbitrary arguments.
Parameters
in o call the callback with o as the widget argument
in arg call the callback with arg as the user data argument

See Also
callback()

void Fl Widget::do callback ( Fl Widget ∗ o, void ∗ arg = 0 )


Calls the widget callback.
Causes a widget to invoke its callback function with arbitrary arguments.
Parameters
in o call the callback with o as the widget argument
in arg use arg as the user data argument

See Also
callback()

virtual void Fl Widget::draw ( ) [pure virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
840 CHAPTER 31. CLASS DOCUMENTATION

Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar


s->draw(); // calls Fl Scrollbar::draw()

Implemented in Fl Table, Fl FormsText, Fl Tree, Fl Text Display, Fl Input, Fl Gl Window, Fl Tabs,


Fl Browser , Fl Window, Fl Scroll, Fl Button, Fl Chart, Fl Choice, Fl Slider, Fl Value Input, Fl File -
Input, Fl Counter, Fl Free, Fl Clock Output, Fl Group, Fl Dial, Fl Cairo Window, Fl Menu Bar, Fl Pack,
Fl Menu Button, Fl Scrollbar, Fl Positioner, Fl Adjuster, Fl Timer, Fl Value Output, Fl Glut Window,
Fl Progress, Fl Sys Menu Bar, Fl Light Button, Fl Value Slider, Fl Roller, Fl Box, Fl Return Button, Fl-
FormsPixmap, and Fl FormsBitmap.

void Fl Widget::draw box ( Fl Boxtype t, Fl Color c ) const [protected]


Draws a box of type t, of color c at the widget’s position and size.

void Fl Widget::draw box ( Fl Boxtype t, int X, int Y, int W, int H, Fl Color c ) const
[protected]
Draws a box of type t, of color c at the position X,Y and size W,H.

void Fl Widget::draw label ( ) const [protected]


Draws the widget’s label at the defined label position.
This is the normal call for a widget’s draw() method.

void Fl Widget::draw label ( int X, int Y, int W, int H ) const [protected]


Draws the label in an arbitrary bounding box.
draw() can use this instead of draw label(void) to change the bounding box

void Fl Widget::draw label ( int X, int Y, int W, int H, Fl Align a ) const


Draws the label in an arbitrary bounding box with an arbitrary alignment.
Anybody can call this to force the label to draw anywhere.

void Fl Widget::h ( int v ) [inline], [protected]


Internal use only.
Use position(int,int), size(int,int) or resize(int,int,int,int) instead.

int Fl Widget::h ( ) const [inline]


Gets the widget height.
Returns
the height of the widget in pixels.

int Fl Widget::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
31.151. FL WIDGET CLASS REFERENCE 841

Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event

Reimplemented in Fl Tree, Fl Table, Fl Input, Fl Window, Fl Browser , Fl Tabs, Fl Text Display, Fl-
Scroll, Fl Spinner, Fl Table Row, Fl Clock, Fl Check Browser, Fl Button, Fl Gl Window, Fl Choice, Fl-
Slider, Fl Menu Button, Fl Group, Fl Value Input, Fl Counter, Fl File Input, Fl Free, Fl Dial, Fl Menu-
Bar, Fl Scrollbar, Fl Text Editor, Fl Positioner, Fl Box, Fl Value Output, Fl Timer, Fl Glut Window,
Fl Adjuster, Fl Secret Input, Fl Light Button, Fl Value Slider, Fl Roller, Fl Return Button, Fl Repeat -
Button, and Fl Tile.

void Fl Widget::hide ( ) [virtual]


Makes a widget invisible.
See Also
show(), visible(), visible r()

Reimplemented in Fl Window, Fl Browser, Fl Gl Window, Fl Overlay Window, Fl Double Window,


and Fl Menu Window.

Fl Image∗ Fl Widget::image ( ) [inline]


Gets the image that is used as part of the widget label.
This image is used when drawing the widget in the active state.
Returns
the current image

void Fl Widget::image ( Fl Image ∗ img ) [inline]


Sets the image to use as part of the widget label.
This image is used when drawing the widget in the active state.
Parameters
in img the new image for the label

void Fl Widget::image ( Fl Image & img ) [inline]


Sets the image to use as part of the widget label.
This image is used when drawing the widget in the active state.
842 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in img the new image for the label

int Fl Widget::inside ( const Fl Widget ∗ wgt ) const [inline]


Checks if this widget is a child of wgt.
Returns 1 if this widget is a child of wgt, or is equal to wgt. Returns 0 if wgt is NULL.
Parameters
in wgt the possible parent widget.

See Also
contains()

const char∗ Fl Widget::label ( ) const [inline]


Gets the current label text.
Returns
a pointer to the current label text

See Also
label(const char ∗), copy label(const char ∗)

void Fl Widget::label ( const char ∗ text )


Sets the current label pointer.
The label is shown somewhere on or next to the widget. The passed pointer is stored unchanged in
the widget (the string is not copied), so if you need to set the label to a formatted value, make sure the
buffer is static, global, or allocated. The copy label() method can be used to make a copy of the label string
automatically.
Parameters
in text pointer to new label text

See Also
copy label()

void Fl Widget::label ( Fl Labeltype a, const char ∗ b ) [inline]


Shortcut to set the label text and type in one call.
See Also
label(const char ∗), labeltype(Fl Labeltype)

unsigned int Fl Widget::label shortcut ( const char ∗ t ) [static]


Returns the Unicode value of the ’&x’ shortcut in a given text.
The given text t (usually a widget’s label or a menu text) is searched for a ’&x’ shortcut label, and if
found, the Unicode value (code point) of the ’&x’ shortcut is returned.
31.151. FL WIDGET CLASS REFERENCE 843

Parameters
t text or label to search for ’&x’ shortcut.

Returns
Unicode (UCS-4) value of shortcut in t or 0.

Note
Internal use only.

Fl Color Fl Widget::labelcolor ( ) const [inline]


Gets the label color.
The default color is FL FOREGROUND COLOR.
Returns
the current label color

void Fl Widget::labelcolor ( Fl Color c ) [inline]


Sets the label color.
The default color is FL FOREGROUND COLOR.
Parameters
in c the new label color

Fl Font Fl Widget::labelfont ( ) const [inline]


Gets the font to use.
Fonts are identified by indexes into a table. The default value uses a Helvetica typeface (Arial for
Microsoft® Windows®). The function Fl::set font() can define new typefaces.
Returns
current font used by the label

See Also
Fl Font

void Fl Widget::labelfont ( Fl Font f ) [inline]


Sets the font to use.
Fonts are identified by indexes into a table. The default value uses a Helvetica typeface (Arial for
Microsoft® Windows®). The function Fl::set font() can define new typefaces.
Parameters
844 CHAPTER 31. CLASS DOCUMENTATION

in f the new font for the label

See Also
Fl Font

Fl Fontsize Fl Widget::labelsize ( ) const [inline]


Gets the font size in pixels.
The default size is 14 pixels.

Returns
the current font size

void Fl Widget::labelsize ( Fl Fontsize pix ) [inline]


Sets the font size in pixels.
Parameters
in pix the new font size

See Also
Fl Fontsize labelsize()

Fl Labeltype Fl Widget::labeltype ( ) const [inline]


Gets the label type.

Returns
the current label type.

See Also
Fl Labeltype

void Fl Widget::labeltype ( Fl Labeltype a ) [inline]


Sets the label type.
The label type identifies the function that draws the label of the widget. This is generally used for
special effects such as embossing or for using the label() pointer as another form of data such as an icon.
The value FL NORMAL LABEL prints the label as plain text.
Parameters
in a new label type

See Also
Fl Labeltype
31.151. FL WIDGET CLASS REFERENCE 845

void Fl Widget::measure label ( int & ww, int & hh ) const [inline]
Sets width ww and height hh accordingly with the label size.
Labels with images will return w() and h() of the image.
This calls fl measure() internally. For more information about the arguments ww and hh and word
wrapping
See Also
fl measure(const char∗, int&, int&, int)

unsigned int Fl Widget::output ( ) const [inline]


Returns if a widget is used for output only.
output() means the same as !active() except it does not change how the widget is drawn. The widget
will not receive any events. This is useful for making scrollbars or buttons that work as displays rather than
input devices.
Return values
0 if the widget is used for input and output

See Also
set output(), clear output()

Fl Group∗ Fl Widget::parent ( ) const [inline]


Returns a pointer to the parent widget.
Usually this is a Fl Group or Fl Window.
Return values
NULL if the widget has no parent

See Also
Fl Group::add(Fl Widget∗)

void Fl Widget::parent ( Fl Group ∗ p ) [inline]


Internal use only - ”for hacks only”.
It is STRONGLY recommended not to use this method, because it short-circuits Fl Group’s normal
widget adding and removing methods, if the widget is already a child widget of another Fl Group.
Use Fl Group::add(Fl Widget∗) and/or Fl Group::remove(Fl Widget∗) instead.

void Fl Widget::position ( int X, int Y ) [inline]


Repositions the window or widget.
position(X, Y) is a shortcut for resize(X, Y, w(), h()).
Parameters
in X,Y new position relative to the parent window

See Also
resize(int,int,int,int), size(int,int)
846 CHAPTER 31. CLASS DOCUMENTATION

void Fl Widget::redraw ( )
Schedules the drawing of the widget.
Marks the widget as needing its draw() routine called.

void Fl Widget::redraw label ( )


Schedules the drawing of the label.
Marks the widget or the parent as needing a redraw for the label area of a widget.

void Fl Widget::resize ( int x, int y, int w, int h ) [virtual]


Changes the size or position of the widget.
This is a virtual function so that the widget may implement its own handling of resizing. The default
version does not call the redraw() method, but instead relies on the parent widget to do so because the
parent may know a faster way to update the display, such as scrolling from the old position.
Some window managers under X11 call resize() a lot more often than needed. Please verify that the
position or size of a widget did actually change before doing any extensive calculations.
position(X, Y) is a shortcut for resize(X, Y, w(), h()), and size(W, H) is a shortcut for resize(x(), y(), W,
H).
Parameters
in x,y new position relative to the parent window
in w,h new size

See Also
position(int,int), size(int,int)

Reimplemented in Fl Table, Fl Tree, Fl Help View, Fl Text Display, Fl Window, Fl Browser , Fl-
Input , Fl Input Choice, Fl Spinner, Fl Scroll, Fl Group, Fl Gl Window, Fl Value Input, Fl Overlay -
Window, Fl Double Window, and Fl Tile.

Fl Color Fl Widget::selection color ( ) const [inline]


Gets the selection color.
Returns
the current selection color

See Also
selection color(Fl Color), color(Fl Color, Fl Color)

void Fl Widget::selection color ( Fl Color a ) [inline]


Sets the selection color.
The selection color is defined for Forms compatibility and is usually used to color the widget when it
is selected, although some widgets use this color for other purposes. You can set both colors at once with
color(Fl Color bg, Fl Color sel).
31.151. FL WIDGET CLASS REFERENCE 847

Parameters
in a the new selection color

See Also
selection color(), color(Fl Color, Fl Color)

void Fl Widget::set active ( ) [inline]

Marks the widget as active without sending events or changing focus.


This is mainly for specialized use, for normal cases you want activate().

See Also
activate()

void Fl Widget::set changed ( ) [inline]

Marks the value of the widget as changed.

See Also
changed(), clear changed()

void Fl Widget::set output ( ) [inline]

Sets a widget to output only.

See Also
output(), clear output()

void Fl Widget::set visible ( ) [inline]

Makes the widget visible.


You must still redraw the parent widget to see a change in the window. Normally you want to use the
show() method instead.

void Fl Widget::set visible focus ( ) [inline]

Enables keyboard focus navigation with this widget.


Note, however, that this will not necessarily mean that the widget will accept focus, but for widgets that
can accept focus, this method enables it if it has been disabled.

See Also
visible focus(), clear visible focus(), visible focus(int)
848 CHAPTER 31. CLASS DOCUMENTATION

void Fl Widget::show ( ) [virtual]


Makes a widget visible.
An invisible widget never gets redrawn and does not get keyboard or mouse events, but can receive a
few other events like FL SHOW.
The visible() method returns true if the widget is set to be visible. The visible r() method returns true
if the widget and all of its parents are visible. A widget is only visible if visible() is true on it and all of its
parents.
Changing it will send FL SHOW or FL HIDE events to the widget. Do not change it if the parent is not
visible, as this will send false FL SHOW or FL HIDE events to the widget. redraw() is called if necessary
on this or the parent.
See Also
hide(), visible(), visible r()
Reimplemented in Fl Window, Fl Browser, Fl Gl Window, Fl Overlay Window, Fl Double Window,
Fl Single Window, and Fl Menu Window.

void Fl Widget::size ( int W, int H ) [inline]


Changes the size of the widget.
size(W, H) is a shortcut for resize(x(), y(), W, H).
Parameters
in W,H new size

See Also
position(int,int), resize(int,int,int,int)

int Fl Widget::take focus ( )


Gives the widget the keyboard focus.
Tries to make this widget be the Fl::focus() widget, by first sending it an FL FOCUS event, and if it
returns non-zero, setting Fl::focus() to this widget. You should use this method to assign the focus to a
widget.
Returns
true if the widget accepted the focus.

unsigned int Fl Widget::takesevents ( ) const [inline]


Returns if the widget is able to take events.
This is the same as (active() && !output() && visible()) but is faster.
Return values
0 if the widget takes no events

int Fl Widget::test shortcut ( )


Returns true if the widget’s label contains the entered ’&x’ shortcut.
This method must only be called in handle() methods or callbacks after a keypress event (usually FL -
KEYDOWN or FL SHORTCUT). The widget’s label is searched for a ’&x’ shortcut, and if found, this is
compared with the entered key value.
Fl::event text() is used to get the entered key value.
31.151. FL WIDGET CLASS REFERENCE 849

Returns
true, if the entered text matches the widget’s’&x’ shortcut, false (0) otherwise.

Note
Internal use only.

int Fl Widget::test shortcut ( const char ∗ t, const bool require alt = false ) [static]
Returns true if the given text t contains the entered ’&x’ shortcut.
This method must only be called in handle() methods or callbacks after a keypress event (usually FL -
KEYDOWN or FL SHORTCUT). The given text t (usually a widget’s label or menu text) is searched for
a ’&x’ shortcut, and if found, this is compared with the entered key value.
Fl::event text() is used to get the entered key value. Fl::event state() is used to get the Alt modifier, if
require alt is true.
Parameters
t text or label to search for ’&x’ shortcut.
require alt if true: match only if Alt key is pressed.

Returns
true, if the entered text matches the ’&x’ shortcut in t false (0) otherwise.

Note
Internal use only.

const char∗ Fl Widget::tooltip ( ) const [inline]


Gets the current tooltip text.
Returns
a pointer to the tooltip text or NULL

See Also
tooltip(const char∗), copy tooltip(const char∗)

void Fl Widget::tooltip ( const char ∗ text )


Sets the current tooltip text.
Sets a string of text to display in a popup tooltip window when the user hovers the mouse over the
widget. The string is not copied, so make sure any formatted string is stored in a static, global, or allocated
buffer. If you want a copy made and managed for you, use the copy tooltip() method, which will manage
the tooltip string automatically.
If no tooltip is set, the tooltip of the parent is inherited. Setting a tooltip for a group and setting no
tooltip for a child will show the group’s tooltip instead. To avoid this behavior, you can set the child’s
tooltip to an empty string (””).
850 CHAPTER 31. CLASS DOCUMENTATION

Parameters
in text New tooltip text (no copy is made)

See Also
copy tooltip(const char∗), tooltip()

Fl Window ∗ Fl Widget::top window ( ) const


Returns a pointer to the top-level window for the widget.
In other words, the ’window manager window’ that contains this widget. This method differs from
window() in that it won’t return sub-windows (if there are any).
Returns
the top-level window, or NULL if no top-level window is associated with this widget.

See Also
window()

Fl Window ∗ Fl Widget::top window offset ( int & xoff, int & yoff ) const
Finds the x/y offset of the current widget relative to the top-level window.
Parameters
out xoff,yoff Returns the x/y offset

Returns
the top-level window (or NULL for a widget that’s not in any window)

uchar Fl Widget::type ( ) const [inline]


Gets the widget type.
Returns the widget type value, which is used for Forms compatibility and to simulate RTTI.
Todo Explain ”simulate RTTI” (currently only used to decide if a widget is a window, i.e. type()>=FL -
WINDOW ?). Is type() really used in a way that ensures ”Forms compatibility” ?

void Fl Widget::type ( uchar t ) [inline]


Sets the widget type.
This is used for Forms compatibility.

void∗ Fl Widget::user data ( ) const [inline]


Gets the user data for this widget.
Gets the current user data (void ∗) argument that is passed to the callback function.
Returns
user data as a pointer

void Fl Widget::user data ( void ∗ v ) [inline]


Sets the user data for this widget.
Sets the new user data (void ∗) argument that is passed to the callback function.
31.151. FL WIDGET CLASS REFERENCE 851

Parameters
in v new user data

unsigned int Fl Widget::visible ( ) const [inline]


Returns whether a widget is visible.
Return values
0 if the widget is not drawn and hence invisible.

See Also
show(), hide(), visible r()

void Fl Widget::visible focus ( int v ) [inline]


Modifies keyboard focus navigation.
Parameters
in v set or clear visible focus

See Also
set visible focus(), clear visible focus(), visible focus()

unsigned int Fl Widget::visible focus ( ) [inline]


Checks whether this widget has a visible focus.
Return values
0 if this widget has no visible focus.

See Also
visible focus(int), set visible focus(), clear visible focus()

int Fl Widget::visible r ( ) const


Returns whether a widget and all its parents are visible.
Return values
0 if the widget or any of its parents are invisible.

See Also
show(), hide(), visible()

void Fl Widget::w ( int v ) [inline], [protected]


Internal use only.
Use position(int,int), size(int,int) or resize(int,int,int,int) instead.
852 CHAPTER 31. CLASS DOCUMENTATION

int Fl Widget::w ( ) const [inline]


Gets the widget width.
Returns
the width of the widget in pixels.

Fl When Fl Widget::when ( ) const [inline]


Returns the conditions under which the callback is called.
You can set the flags with when(uchar), the default value is FL WHEN RELEASE.
Returns
set of flags

See Also
when(uchar)

void Fl Widget::when ( uchar i ) [inline]


Sets the flags used to decide when a callback is called.
This controls when callbacks are done. The following values are useful, the default value is FL WHE-
N RELEASE:
• 0: The callback is not done, but changed() is turned on.
• FL WHEN CHANGED: The callback is done each time the text is changed by the user.
• FL WHEN RELEASE: The callback will be done when this widget loses the focus, including when
the window is unmapped. This is a useful value for text fields in a panel where doing the callback
on every change is wasteful. However the callback will also happen if the mouse is moved out of the
window, which means it should not do anything visible (like pop up an error message). You might
do better setting this to zero, and scanning all the items for changed() when the OK button on a panel
is pressed.
• FL WHEN ENTER KEY: If the user types the Enter key, the entire text is selected, and the callback
is done if the text has changed. Normally the Enter key will navigate to the next field (or insert a
newline for a Fl Multiline Input) - this changes the behavior.
• FL WHEN ENTER KEY|FL WHEN NOT CHANGED: The Enter key will do the callback even if
the text has not changed. Useful for command fields. Fl Widget::when() is a set of bitflags used by
subclasses of Fl Widget to decide when to do the callback.
If the value is zero then the callback is never done. Other values are described in the individual widgets.
This field is in the base class so that you can scan a panel and do callback() on all the ones that don’t do
their own callbacks in response to an ”OK” button.
Parameters
in i set of flags

Fl Window ∗ Fl Widget::window ( ) const


Returns a pointer to the nearest parent window up the widget hierarchy.
This will return sub-windows if there are any, or the parent window if there’s no sub-windows. If this
widget IS the top-level window, NULL is returned.
31.152. FL WIDGET TRACKER CLASS REFERENCE 853

Return values
NULL if no window is associated with this widget.

Note
for an Fl Window widget, this returns its parent window (if any), not this window.

See Also
top window()

void Fl Widget::x ( int v ) [inline], [protected]


Internal use only.
Use position(int,int), size(int,int) or resize(int,int,int,int) instead.

int Fl Widget::x ( ) const [inline]


Gets the widget position in its window.

Returns
the x position relative to the window

void Fl Widget::y ( int v ) [inline], [protected]


Internal use only.
Use position(int,int), size(int,int) or resize(int,int,int,int) instead.

int Fl Widget::y ( ) const [inline]


Gets the widget position in its window.

Returns
the y position relative to the window

The documentation for this class was generated from the following files:

• Fl Widget.H
• Fl.cxx
• fl boxtype.cxx
• fl labeltype.cxx
• fl shortcut.cxx
• Fl Tooltip.cxx
• Fl Widget.cxx
• Fl Window.cxx

31.152 Fl Widget Tracker Class Reference


This class should be used to control safe widget deletion.
#include <Fl.H>
854 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• int deleted ()
Returns 1, if the watched widget has been deleted.
• int exists ()
Returns 1, if the watched widget exists (has not been deleted).
• Fl Widget Tracker (Fl Widget ∗wi)
The constructor adds a widget to the watch list.
• Fl Widget ∗ widget ()
Returns a pointer to the watched widget.
• ∼Fl Widget Tracker ()
The destructor removes a widget from the watch list.

31.152.1 Detailed Description


This class should be used to control safe widget deletion.
You can use an Fl Widget Tracker object to watch another widget, if you need to know, if this widget
has been deleted during a callback.
This simplifies the use of the ”safe widget deletion” methods Fl::watch widget pointer() and Fl::release-
widget pointer() and makes their use more reliable, because the destructor autmatically releases the widget
pointer from the widget watch list.
It is intended to be used as an automatic (local/stack) variable, such that the automatic destructor is
called when the object’s scope is left. This ensures that no stale widget pointers are left in the widget watch
list (see example below).
You can also create Fl Widget Tracker objects with new, but then it is your responsibility to delete the
object (and thus remove the widget pointer from the watch list) when it is not needed any more.
Example:
int MyClass::handle (int event) {

if (...) {
Fl Widget Tracker wp(this); // watch myself
do callback(); // call the callback

if (wp.deleted()) return 1; // exit, if deleted

// Now we are sure that the widget has not been deleted.
// It is safe to access the widget

clear changed(); // access the widget


}
}

31.152.2 Member Function Documentation


int Fl Widget Tracker::deleted ( ) [inline]
Returns 1, if the watched widget has been deleted.
This is a convenience method. You can also use something like
if (wp.widget() == 0) // ...
where wp is an Fl Widget Tracker object.

int Fl Widget Tracker::exists ( ) [inline]


Returns 1, if the watched widget exists (has not been deleted).
This is a convenience method. You can also use something like
if (wp.widget() != 0) // ...
where wp is an Fl Widget Tracker object.
31.153. FL WINDOW CLASS REFERENCE 855

Fl Widget∗ Fl Widget Tracker::widget ( ) [inline]


Returns a pointer to the watched widget.
This pointer is NULL, if the widget has been deleted.
The documentation for this class was generated from the following files:

• Fl.H
• Fl.cxx

31.153 Fl Window Class Reference


This widget produces an actual window.
#include <Fl Window.H>
Inheritance diagram for Fl Window:

Fl_Widget

Fl_Group

Fl_Window

Fl_Double_Window Fl_Gl_Window Fl_Single_Window

Fl_Cairo_Window Fl_Overlay_Window Fl_Glut_Window Fl_Menu_Window

Classes
• struct shape data type
Data supporting a non-rectangular window shape.

Public Member Functions


• virtual Fl Window ∗ as window ()
Returns an Fl Window pointer if this widget is an Fl Window.
• void border (int b)
Sets whether or not the window manager border is around the window.
• unsigned int border () const
See void Fl Window::border(int)
• void clear border ()
Fast inline function to turn the window manager border off.
• void clear modal states ()
Clears the ”modal” flags and converts a ”modal” or ”non-modal” window back into a ”normal” window.
• void copy label (const char ∗a)
Sets the window titlebar label to a copy of a character string.
• void cursor (Fl Cursor)
Changes the cursor for this window.
• void cursor (const Fl RGB Image ∗, int, int)
856 CHAPTER 31. CLASS DOCUMENTATION

Changes the cursor for this window.


• void cursor (Fl Cursor c, Fl Color, Fl Color=FL WHITE)
For back compatibility only.
• int decorated h ()
Returns the window height including any window title bar and any frame added by the window manager.
• int decorated w ()
Returns the window width including any frame added by the window manager.
• void default cursor (Fl Cursor)
Sets the default window cursor.
• void default cursor (Fl Cursor c, Fl Color, Fl Color=FL WHITE)
For back compatibility only.
• Fl Window (int w, int h, const char ∗title=0)
Creates a window from the given size and title.
• Fl Window (int x, int y, int w, int h, const char ∗title=0)
Creates a window from the given position, size and title.
• void free position ()
Undoes the effect of a previous resize() or show() so that the next time show() is called the window manager
is free to position the window.
• void fullscreen ()
Makes the window completely fill one or more screens, without any window manager border visible.
• unsigned int fullscreen active () const
Returns non zero if FULLSCREEN flag is set, 0 otherwise.
• void fullscreen off ()
Turns off any side effects of fullscreen()
• void fullscreen off (int X, int Y, int W, int H)
Turns off any side effects of fullscreen() and does resize(x,y,w,h).
• void fullscreen screens (int top, int bottom, int left, int right)
Sets which screens should be used when this window is in fullscreen mode.
• virtual int handle (int)
Handles the specified event.
• virtual void hide ()
Removes the window from the screen.
• void hotspot (int x, int y, int offscreen=0)
Positions the window so that the mouse is pointing at the given position, or at the center of the given widget,
which may be the window itself.
• void hotspot (const Fl Widget ∗, int offscreen=0)
See void Fl Window::hotspot(int x, int y, int offscreen = 0)
• void hotspot (const Fl Widget &p, int offscreen=0)
See void Fl Window::hotspot(int x, int y, int offscreen = 0)
• void icon (const Fl RGB Image ∗)
Sets a single window icon.
• const void ∗ icon () const
Gets the current icon window target dependent data.
• void icon (const void ∗ic)
Sets the current icon window target dependent data.
• void iconize ()
Iconifies the window.
31.153. FL WINDOW CLASS REFERENCE 857

• const char ∗ iconlabel () const


See void Fl Window::iconlabel(const char∗)
• void iconlabel (const char ∗)
Sets the icon label.
• void icons (const Fl RGB Image ∗[ ], int)
Sets the window icons.
• const char ∗ label () const
See void Fl Window::label(const char∗)
• void label (const char ∗)
Sets the window title bar label.
• void label (const char ∗label, const char ∗iconlabel)
Sets the icon label.
• void make current ()
Sets things up so that the drawing functions in <FL/fl draw.H> will go into this window.
• unsigned int menu window () const
Returns true if this window is a menu window.
• unsigned int modal () const
Returns true if this window is modal.
• unsigned int non modal () const
Returns true if this window is modal or non-modal.
• unsigned int override () const
Returns non zero if FL OVERRIDE flag is set, 0 otherwise.
• virtual void resize (int X, int Y, int W, int H)
Changes the size and position of the window.
• void set menu window ()
Marks the window as a menu window.
• void set modal ()
A ”modal” window, when shown(), will prevent any events from being delivered to other windows in the
same program, and will also remain on top of the other windows (if the X window manager supports the
”transient for” property).
• void set non modal ()
A ”non-modal” window (terminology borrowed from Microsoft Windows) acts like a modal() one in that it
remains on top, but it has no effect on event delivery.
• void set override ()
Activates the flags NOBORDER|FL OVERRIDE.
• void set tooltip window ()
Marks the window as a tooltip window.
• void shape (const Fl Image ∗img)
Assigns a non-rectangular shape to the window.
• void shape (const Fl Image &b)
Set the window’s shape with an Fl Image.
• virtual void show ()
Puts the window on the screen.
• void show (int argc, char ∗∗argv)
Puts the window on the screen and parses command-line arguments.
• int shown ()
Returns non-zero if show() has been called (but not hide() ).
858 CHAPTER 31. CLASS DOCUMENTATION

• void size range (int minw, int minh, int maxw=0, int maxh=0, int dw=0, int dh=0, int aspect=0)
Sets the allowable range the user can resize this window to.
• unsigned int tooltip window () const
Returns true if this window is a tooltip window.
• void wait for expose ()
Waits for the window to be fully displayed after calling show().
• int x root () const
Gets the x position of the window on the screen.
• const char ∗ xclass () const
Returns the xclass for this window, or a default.
• void xclass (const char ∗c)
Sets the xclass for this window.
• int y root () const
Gets the y position of the window on the screen.
• virtual ∼Fl Window ()
The destructor also deletes all the children.

Static Public Member Functions


• static Fl Window ∗ current ()
Returns the last window that was made current.
• static void default callback (Fl Window ∗, void ∗v)
Back compatibility: Sets the default callback v for win to call on close event.
• static void default icon (const Fl RGB Image ∗)
Sets a single default window icon.
• static void default icons (const Fl RGB Image ∗[ ], int)
Sets the default window icons.
• static void default xclass (const char ∗)
Sets the default window xclass.
• static const char ∗ default xclass ()
Returns the default xclass.

Protected Member Functions


• virtual void draw ()
Draws the widget.
• virtual void flush ()
Forces the window to be drawn, this window is also made current and calls draw().
• void force position (int force)
Sets an internal flag that tells FLTK and the window manager to honor position requests.
• int force position () const
Returns the internal state of the window’s FORCE POSITION flag.
• void free icons ()
Deletes all icons previously attached to the window.

Protected Attributes
• shape data type ∗ shape data
non-null means the window has a non-rectangular shape
31.153. FL WINDOW CLASS REFERENCE 859

Static Protected Attributes


• static Fl Window ∗ current
Stores the last window that was made current.

Friends
• class Fl X

Additional Inherited Members


31.153.1 Detailed Description
This widget produces an actual window.
This can either be a main window, with a border and title and all the window management controls, or
a ”subwindow” inside a window. This is controlled by whether or not the window has a parent().
Once you create a window, you usually add children Fl Widget ’s to it by using window->add(child)
for each new widget. See Fl Group for more information on how to add and remove children.
There are several subclasses of Fl Window that provide double-buffering, overlay, menu, and OpenGL
support.
The window’s callback is done if the user tries to close a window using the window manager and
Fl::modal() is zero or equal to the window. Fl Window has a default callback that calls Fl Window::hide().

31.153.2 Constructor & Destructor Documentation


Fl Window::Fl Window ( int w, int h, const char ∗ title = 0 )

Creates a window from the given size and title.


If Fl Group::current() is not NULL, the window is created as a subwindow of the parent window.
The (w,h) form of the constructor creates a top-level window and asks the window manager to position
the window. The (x,y,w,h) form of the constructor either creates a subwindow or a top-level window at
the specified location (x,y) , subject to window manager configuration. If you do not specify the position
of the window, the window manager will pick a place to show the window or allow the user to pick a
location. Use position(x,y) or hotspot() before calling show() to request a position on the screen. See
Fl Window::resize() for some more details on positioning windows.
Top-level windows initially have visible() set to 0 and parent() set to NULL. Subwindows initially have
visible() set to 1 and parent() set to the parent window pointer.
Fl Widget::box() defaults to FL FLAT BOX. If you plan to completely fill the window with children
widgets you should change this to FL NO BOX. If you turn the window border off you may want to change
this to FL UP BOX.

See Also
Fl Window(int x, int y, int w, int h, const char∗ title)

Fl Window::Fl Window ( int x, int y, int w, int h, const char ∗ title = 0 )

Creates a window from the given position, size and title.

See Also
Fl Window(int w, int h, const char ∗title)
860 CHAPTER 31. CLASS DOCUMENTATION

Fl Window::∼Fl Window ( ) [virtual]


The destructor also deletes all the children.
This allows a whole tree to be deleted at once, without having to keep a pointer to all the children in
the user code. A kludge has been done so the Fl Window and all of its children can be automatic (local)
variables, but you must declare the Fl Window first so that it is destroyed last.

31.153.3 Member Function Documentation


virtual Fl Window∗ Fl Window::as window ( ) [inline], [virtual]
Returns an Fl Window pointer if this widget is an Fl Window.
Use this method if you have a widget (pointer) and need to know whether this widget is derived from
Fl Window. If it returns non-NULL, then the widget in question is derived from Fl Window, and you can
use the returned pointer to access its children or other Fl Window-specific methods.
Return values
NULL if this widget is not derived from Fl Window.

Note
This method is provided to avoid dynamic cast.

See Also
Fl Widget::as group(), Fl Widget::as gl window()

Reimplemented from Fl Widget.

void Fl Window::border ( int b )


Sets whether or not the window manager border is around the window.
The default value is true. void border(int) can be used to turn the border on and off. Under most X
window managers this does not work after show() has been called, although SGI’s 4DWM does work.

void Fl Window::clear border ( ) [inline]


Fast inline function to turn the window manager border off.
It only works before show() is called.

void Fl Window::clear modal states ( ) [inline]


Clears the ”modal” flags and converts a ”modal” or ”non-modal” window back into a ”normal” window.
Note that there are three states for a window: modal, non-modal, and normal.
You can not change the ”modality” of a window whilst it is shown, so it is necessary to first hide() the
window, change its ”modality” as required, then re-show the window for the new state to take effect.
This method can also be used to change a ”modal” window into a ”non-modal” one. On several sup-
ported platforms, the ”modal” state over-rides the ”non-modal” state, so the ”modal” state must be cleared
before the window can be set into the ”non-modal” state. In general, the following sequence should work:
win->hide();
win->clear modal states();
//Set win to new state as desired, or leave "normal", e.g...
win->set non modal();
win->show();
31.153. FL WINDOW CLASS REFERENCE 861

Note
Under some window managers, the sequence of hiding the window and changing its modality will
often cause it to be re-displayed at a different position when it is subsequently shown. This is an
irritating feature but appears to be unavoidable at present. As a result we would advise to use this
method only when absolutely necessary.

See Also
void set modal(), void set non modal()

Fl Window ∗ Fl Window::current ( ) [static]


Returns the last window that was made current.
See Also
Fl Window::make current()

void Fl Window::cursor ( Fl Cursor c )


Changes the cursor for this window.
This always calls the system, if you are changing the cursor a lot you may want to keep track of how
you set it in a static variable and call this only if the new cursor is different.
The type Fl Cursor is an enumeration defined in <FL/Enumerations.H>.

See Also
cursor(const Fl RGB Image∗, int, int), default cursor()

void Fl Window::cursor ( const Fl RGB Image ∗ image, int hotx, int hoty )
Changes the cursor for this window.
This always calls the system, if you are changing the cursor a lot you may want to keep track of how
you set it in a static variable and call this only if the new cursor is different.
The default cursor will be used if the provided image cannot be used as a cursor.

See Also
cursor(Fl Cursor), default cursor()

void Fl Window::cursor ( Fl Cursor c, Fl Color , Fl Color = FL WHITE )


For back compatibility only.
Same as Fl Window::cursor(Fl Cursor)

int Fl Window::decorated h ( )
Returns the window height including any window title bar and any frame added by the window manager.
Same as h() if applied to a subwindow.

int Fl Window::decorated w ( )
Returns the window width including any frame added by the window manager.
Same as w() if applied to a subwindow.
862 CHAPTER 31. CLASS DOCUMENTATION

void Fl Window::default cursor ( Fl Cursor c )


Sets the default window cursor.
This is the cursor that will be used after the mouse pointer leaves a widget with a custom cursor set.
See Also
cursor(const Fl RGB Image∗, int, int), default cursor()

void Fl Window::default cursor ( Fl Cursor c, Fl Color , Fl Color = FL WHITE )


For back compatibility only.
same as Fl Window::default cursor(Fl Cursor)

void Fl Window::default icon ( const Fl RGB Image ∗ icon ) [static]


Sets a single default window icon.
Parameters
in icon default icon for all windows subsequently created

See Also
Fl Window::default icons(const Fl RGB Image ∗[ ], int)
Fl Window::icon(const Fl RGB Image ∗)
Fl Window::icons(const Fl RGB Image ∗[ ], int)

void Fl Window::default icons ( const Fl RGB Image ∗ icons[ ], int count ) [static]
Sets the default window icons.
The default icons are used for all windows that don’t have their own icons set before show() is called.
You can change the default icons whenever you want, but this only affects windows that are created (and
shown) after this call.
The given images in icons are copied. You can use a local variable or free the images immediately
after this call.
Parameters
in icons default icons for all windows subsequently created
in count number of images in icons. set to 0 to remove the current default icons

See Also
Fl Window::default icon(const Fl RGB Image ∗)
Fl Window::icon(const Fl RGB Image ∗)
Fl Window::icons(const Fl RGB Image ∗[ ], int)

void Fl Window::default xclass ( const char ∗ xc ) [static]


Sets the default window xclass.
The default xclass is used for all windows that don’t have their own xclass set before show() is called.
You can change the default xclass whenever you want, but this only affects windows that are created (and
shown) after this call.
The given string xc is copied. You can use a local variable or free the string immediately after this call.
If you don’t call this, the default xclass for all windows will be ”FLTK”. You can reset the default
xclass by specifying NULL for xc.
If you call Fl Window::xclass(const char ∗) for any window, then this also sets the default xclass, unless
it has been set before.
31.153. FL WINDOW CLASS REFERENCE 863

Parameters
in xc default xclass for all windows subsequently created

See Also
Fl Window::xclass(const char ∗)

const char ∗ Fl Window::default xclass ( ) [static]


Returns the default xclass.
See Also
Fl Window::default xclass(const char ∗)

void Fl Window::draw ( ) [protected], [virtual]


Draws the widget.
Never call this function directly. FLTK will schedule redrawing whenever needed. If your widget must
be redrawn as soon as possible, call redraw() instead.
Override this function to draw your own widgets.
If you ever need to call another widget’s draw method from within your own draw() method, e.g. for an
embedded scrollbar, you can do it (because draw() is virtual) like this:
Fl Widget *s = &scroll; // scroll is an embedded Fl Scrollbar
s->draw(); // calls Fl Scrollbar::draw()

Reimplemented from Fl Group.


Reimplemented in Fl Gl Window, Fl Cairo Window, and Fl Glut Window.

void Fl Window::flush ( ) [protected], [virtual]


Forces the window to be drawn, this window is also made current and calls draw().
Reimplemented in Fl Gl Window, Fl Overlay Window, Fl Double Window, Fl Single Window, and
Fl Menu Window.

void Fl Window::force position ( int force ) [inline], [protected]


Sets an internal flag that tells FLTK and the window manager to honor position requests.
This is used internally and should not be needed by user code.
Parameters
in force 1 to set the FORCE POSITION flag, 0 to clear it

int Fl Window::force position ( ) const [inline], [protected]


Returns the internal state of the window’s FORCE POSITION flag.
Return values
1 if flag is set
864 CHAPTER 31. CLASS DOCUMENTATION

0 otherwise

See Also
force position(int)

void Fl Window::free icons ( ) [protected]


Deletes all icons previously attached to the window.
See Also
Fl Window::icons(const Fl RGB Image ∗icons[ ], int count)

void Fl Window::free position ( ) [inline]


Undoes the effect of a previous resize() or show() so that the next time show() is called the window manager
is free to position the window.
This is for Forms compatibility only.
Deprecated please use force position(0) instead

void Fl Window::fullscreen ( )
Makes the window completely fill one or more screens, without any window manager border visible.
You must use fullscreen off() to undo this.
Note
On some platforms, this can result in the keyboard being grabbed. The window may also be recreated,
meaning hide() and show() will be called.

See Also
void Fl Window::fullscreen screens()

void Fl Window::fullscreen screens ( int top, int bottom, int left, int right )
Sets which screens should be used when this window is in fullscreen mode.
The window will be resized to the top of the screen with index top, the bottom of the screen with index
bottom, etc.
If this method is never called, or if any argument is < 0, then the window will be resized to fill the
screen it is currently on.
See Also
void Fl Window::fullscreen()

int Fl Window::handle ( int event ) [virtual]


Handles the specified event.
You normally don’t call this method directly, but instead let FLTK do it when the user interacts with
the widget.
When implemented in a widget, this function must return 0 if the widget does not use the event or 1
otherwise.
Most of the time, you want to call the inherited handle() method in your overridden method so that you
don’t short-circuit events that you don’t handle. In this last case you should return the callee retval.
31.153. FL WINDOW CLASS REFERENCE 865

Parameters
in event the kind of event received
Return values
0 if the event was not used or understood
1 if the event was used and can be deleted

See Also
Fl Event
Reimplemented from Fl Group.
Reimplemented in Fl Gl Window, and Fl Glut Window.

void Fl Window::hide ( ) [virtual]


Removes the window from the screen.
If the window is already hidden or has not been shown then this does nothing and is harmless.
Reimplemented from Fl Widget.
Reimplemented in Fl Gl Window, Fl Overlay Window, Fl Double Window, and Fl Menu Window.

void Fl Window::hotspot ( int x, int y, int offscreen = 0 )


Positions the window so that the mouse is pointing at the given position, or at the center of the given widget,
which may be the window itself.
If the optional offscreen parameter is non-zero, then the window is allowed to extend off the screen
(this does not work with some X window managers).
See Also
position()

void Fl Window::icon ( const Fl RGB Image ∗ icon )


Sets a single window icon.
Parameters
in icon icon for this window

See Also
Fl Window::default icon(const Fl RGB Image ∗)
Fl Window::default icons(const Fl RGB Image ∗[ ], int)
Fl Window::icons(const Fl RGB Image ∗[ ], int)

const void ∗ Fl Window::icon ( ) const


Gets the current icon window target dependent data.
Deprecated in 1.3.3

void Fl Window::icon ( const void ∗ ic )


Sets the current icon window target dependent data.
Deprecated in 1.3.3
866 CHAPTER 31. CLASS DOCUMENTATION

void Fl Window::iconize ( )
Iconifies the window.
If you call this when shown() is false it will show() it as an icon. If the window is already iconified this
does nothing.
Call show() to restore the window.
When a window is iconified/restored (either by these calls or by the user) the handle() method is called
with FL HIDE and FL SHOW events and visible() is turned on and off.
There is no way to control what is drawn in the icon except with the string passed to Fl Window-
::xclass(). You should not rely on window managers displaying the icons.

void Fl Window::iconlabel ( const char ∗ iname )


Sets the icon label.

void Fl Window::icons ( const Fl RGB Image ∗ icons[ ], int count )


Sets the window icons.
The given images in icons are copied. You can use a local variable or free the images immediately
after this call.
Parameters
in icons icons for this window
in count number of images in icons. set to 0 to remove the current icons

See Also
Fl Window::default icon(const Fl RGB Image ∗)
Fl Window::default icons(const Fl RGB Image ∗[ ], int)
Fl Window::icon(const Fl RGB Image ∗)

void Fl Window::label ( const char ∗ name )


Sets the window title bar label.

void Fl Window::label ( const char ∗ label, const char ∗ iconlabel )


Sets the icon label.

void Fl Window::make current ( )


Sets things up so that the drawing functions in <FL/fl draw.H> will go into this window.
This is useful for incremental update of windows, such as in an idle callback, which will make your
program behave much better if it draws a slow graphic. Danger: incremental update is very hard to
debug and maintain!
This method only works for the Fl Window and Fl Gl Window derived classes.

unsigned int Fl Window::menu window ( ) const [inline]


Returns true if this window is a menu window.

unsigned int Fl Window::modal ( ) const [inline]


Returns true if this window is modal.
31.153. FL WINDOW CLASS REFERENCE 867

unsigned int Fl Window::non modal ( ) const [inline]


Returns true if this window is modal or non-modal.

unsigned int Fl Window::override ( ) const [inline]


Returns non zero if FL OVERRIDE flag is set, 0 otherwise.

virtual void Fl Window::resize ( int X, int Y, int W, int H ) [virtual]


Changes the size and position of the window.
If shown() is true, these changes are communicated to the window server (which may refuse that size
and cause a further resize). If shown() is false, the size and position are used when show() is called. See
Fl Group for the effect of resizing on the child widgets.
You can also call the Fl Widget methods size(x,y) and position(w,h), which are inline wrappers for this
virtual function.
A top-level window can not force, but merely suggest a position and size to the operating system. The
window manager may not be willing or able to display a window at the desired position or with the given
dimensions. It is up to the application developer to verify window parameters after the resize request.
Reimplemented from Fl Group.
Reimplemented in Fl Gl Window, Fl Overlay Window, and Fl Double Window.

void Fl Window::set menu window ( ) [inline]


Marks the window as a menu window.
This is intended for internal use, but it can also be used if you write your own menu handling. However,
this is not recommended.
This flag is used for correct ”parenting” of windows in communication with the windowing system.
Modern X window managers can use different flags to distinguish menu and tooltip windows from normal
windows.
This must be called before the window is shown and cannot be changed later.

void Fl Window::set modal ( ) [inline]


A ”modal” window, when shown(), will prevent any events from being delivered to other windows in the
same program, and will also remain on top of the other windows (if the X window manager supports the
”transient for” property).
Several modal windows may be shown at once, in which case only the last one shown gets events. You
can see which window (if any) is modal by calling Fl::modal().

void Fl Window::set non modal ( ) [inline]


A ”non-modal” window (terminology borrowed from Microsoft Windows) acts like a modal() one in that
it remains on top, but it has no effect on event delivery.
There are three states for a window: modal, non-modal, and normal.

void Fl Window::set tooltip window ( ) [inline]


Marks the window as a tooltip window.
This is intended for internal use, but it can also be used if you write your own tooltip handling. However,
this is not recommended.
This flag is used for correct ”parenting” of windows in communication with the windowing system.
Modern X window managers can use different flags to distinguish menu and tooltip windows from normal
windows.
This must be called before the window is shown and cannot be changed later.
868 CHAPTER 31. CLASS DOCUMENTATION

Note
Since Fl Tooltip Window is derived from Fl Menu Window, this also clears the menu window()
state.

void Fl Window::shape ( const Fl Image ∗ img )

Assigns a non-rectangular shape to the window.


This function gives an arbitrary shape (not just a rectangular region) to an Fl Window. An Fl Image of
any dimension can be used as mask; it is rescaled to the window’s dimension as needed.
The layout and widgets inside are unaware of the mask shape, and most will act as though the window’s
rectangular bounding box is available to them. It is up to you to make sure they adhere to the bounds of
their masking shape.
The img argument can be an Fl Bitmap, Fl Pixmap or Fl RGB Image:

• With Fl Bitmap or Fl Pixmap, the shaped window covers the image part where bitmap bits equal
one, or where the pixmap is not fully transparent.

• With an Fl RGB Image with an alpha channel (depths 2 or 4), the shaped window covers the image
part that is not fully transparent.

• With an Fl RGB Image of depth 1 (gray-scale) or 3 (RGB), the shaped window covers the non-black
image part.

Platform details:

• On the unix/linux platform, the SHAPE extension of the X server is required. This function does
control the shape of Fl Gl Window instances.

• On the MSWindows platform, this function does nothing with class Fl Gl Window.

• On the Mac platform, OS version 10.4 or above is required. An 8-bit shape-mask is used when img
is an Fl RGB Image: with depths 2 or 4, the image alpha channel becomes the shape mask such that
areas with alpha = 0 are out of the shaped window; with depths 1 or 3, white and black are in and out
of the shaped window, respectively, and other colors give intermediate masking scores. This function
does nothing with class Fl Gl Window.

The window borders and caption created by the window system are turned off by default. They can be
re-enabled by calling Fl Window::border(1).
A usage example is found at example/shapedwindow.cxx.

Version
1.3.3 (and requires compilation with -DFLTK ABI VERSION = 10303)

void Fl Window::shape ( const Fl Image & b ) [inline]

Set the window’s shape with an Fl Image.

See Also
void shape(const Fl Image∗ img)
31.153. FL WINDOW CLASS REFERENCE 869

virtual void Fl Window::show ( ) [virtual]


Puts the window on the screen.
Usually (on X) this has the side effect of opening the display.
If the window is already shown then it is restored and raised to the top. This is really convenient
because your program can call show() at any time, even if the window is already up. It also means that
show() serves the purpose of raise() in other toolkits.
Fl Window::show(int argc, char ∗∗argv) is used for top-level windows and allows standard arguments
to be parsed from the command-line.
See Also
Fl Window::show(int argc, char ∗∗argv)

Reimplemented from Fl Widget.


Reimplemented in Fl Gl Window, Fl Overlay Window, Fl Double Window, Fl Single Window, and
Fl Menu Window.

void Fl Window::show ( int argc, char ∗∗ argv )


Puts the window on the screen and parses command-line arguments.
Usually (on X) this has the side effect of opening the display.
This form should be used for top-level windows, at least for the first (main) window. It allows standard
arguments to be parsed from the command-line. You can use argc and argv from main(int argc, char
∗∗argv) for this call.
The first call also sets up some system-specific internal variables like the system colors.

Todo explain which system parameters are set up.

Parameters
argc command-line argument count, usually from main()
argv command-line argument vector, usually from main()

See Also
virtual void Fl Window::show()

int Fl Window::shown ( ) [inline]


Returns non-zero if show() has been called (but not hide() ).
You can tell if a window is iconified with (w->shown() && !w->visible()).

void Fl Window::size range ( int minw, int minh, int maxw = 0, int maxh = 0, int dw = 0, int dh =
0, int aspect = 0 ) [inline]
Sets the allowable range the user can resize this window to.
This only works for top-level windows.
• minw and minh are the smallest the window can be. Either value must be greater than 0.
• maxw and maxh are the largest the window can be. If either is equal to the minimum then you
cannot resize in that direction. If either is zero then FLTK picks a maximum size in that direction
such that the window will fill the screen.
• dw and dh are size increments. The window will be constrained to widths of minw + N ∗ dw, where
N is any non-negative integer. If these are less or equal to 1 they are ignored (this is ignored on
WIN32).
870 CHAPTER 31. CLASS DOCUMENTATION

• aspect is a flag that indicates that the window should preserve its aspect ratio. This only works
if both the maximum and minimum have the same aspect ratio (ignored on WIN32 and by many X
window managers).
If this function is not called, FLTK tries to figure out the range from the setting of resizable():
• If resizable() is NULL (this is the default) then the window cannot be resized and the resize border
and max-size control will not be displayed for the window.
• If either dimension of resizable() is less than 100, then that is considered the minimum size. Other-
wise the resizable() has a minimum size of 100.
• If either dimension of resizable() is zero, then that is also the maximum size (so the window cannot
resize in that direction).
It is undefined what happens if the current size does not fit in the constraints passed to size range().

unsigned int Fl Window::tooltip window ( ) const [inline]


Returns true if this window is a tooltip window.

void Fl Window::wait for expose ( )


Waits for the window to be fully displayed after calling show().
Fl Window::show() is not guaranteed to show and draw the window on all platforms immediately.
Instead this is done in the background; particularly on X11 this will take a few messages (client server
roundtrips) to display the window.
Usually this small delay doesn’t matter, but in some cases you may want to have the window instantiated
and displayed synchronously.
Currently (as of FLTK 1.3.3) this method only has an effect on X11. On Windows and Mac OS
X show() is always synchronous. If you want to write portable code and need this synchronous show()
feature, add win->wait for expose() on all platforms, FLTK will just do the right thing.
This method can be used for displaying splash screens before calling Fl::run() or for having exact
control over which window has focus after calling show().
If the window is not shown(), this method does nothing.
See Also
virtual void Fl Window::show()
Example code for displaying a window before calling Fl::run()
Fl Double Window win = new Fl Double Window(...);

// do more window initialization here ...

win->show(); // show window


win->wait for expose(); // wait, until displayed
Fl::flush(); // make sure everything gets drawn

// do more initialization work that needs some time here ...

Fl::run(); // start FLTK event loop

Note that the window will not be responsive until the event loop is started with Fl::run().

const char ∗ Fl Window::xclass ( ) const


Returns the xclass for this window, or a default.
See Also
Fl Window::default xclass(const char ∗)
Fl Window::xclass(const char ∗)
31.154. FL WIZARD CLASS REFERENCE 871

void Fl Window::xclass ( const char ∗ xc )


Sets the xclass for this window.
A string used to tell the system what type of window this is. Mostly this identifies the picture to draw
in the icon. This only works if called before calling show().
Under X, this is turned into a XA WM CLASS pair by truncating at the first non-alphanumeric char-
acter and capitalizing the first character, and the second one if the first is ’x’. Thus ”foo” turns into ”foo,
Foo”, and ”xprog.1” turns into ”xprog, XProg”.
Under Microsoft Windows, this string is used as the name of the WNDCLASS structure, though it is
not clear if this can have any visible effect.
Since
FLTK 1.3 the passed string is copied. You can use a local variable or free the string immediately after
this call. Note that FLTK 1.1 stores the pointer without copying the string.

If the default xclass has not yet been set, this also sets the default xclass for all windows created subse-
quently.
See Also
Fl Window::default xclass(const char ∗)

31.153.4 Member Data Documentation


Fl Window∗ Fl Window::current [static], [protected]
Stores the last window that was made current.
See current() const
The documentation for this class was generated from the following files:
• Fl Window.H
• Fl.cxx
• Fl arg.cxx
• fl cursor.cxx
• Fl Window.cxx
• Fl Window fullscreen.cxx
• Fl Window hotspot.cxx
• Fl Window iconize.cxx
• Fl Window shape.cxx

31.154 Fl Wizard Class Reference


This widget is based off the Fl Tabs widget, but instead of displaying tabs it only changes ”tabs” under
program control.
#include <Fl Wizard.H>
Inheritance diagram for Fl Wizard:

Fl_Widget

Fl_Group

Fl_Wizard
872 CHAPTER 31. CLASS DOCUMENTATION

Public Member Functions


• Fl Wizard (int, int, int, int, const char ∗=0)
The constructor creates the Fl Wizard widget at the specified position and size.
• void next ()
This method shows the next child of the wizard.
• void prev ()
Shows the previous child.
• Fl Widget ∗ value ()
Gets the current visible child widget.
• void value (Fl Widget ∗)
Sets the child widget that is visible.

Additional Inherited Members


31.154.1 Detailed Description
This widget is based off the Fl Tabs widget, but instead of displaying tabs it only changes ”tabs” under
program control.
Its primary purpose is to support ”wizards” that step a user through configuration or troubleshooting
tasks.
As with Fl Tabs, wizard panes are composed of child (usually Fl Group) widgets. Navigation buttons
must be added separately.

31.154.2 Constructor & Destructor Documentation


Fl Wizard::Fl Wizard ( int xx, int yy, int ww, int hh, const char ∗ l = 0 )
The constructor creates the Fl Wizard widget at the specified position and size.
The inherited destructor destroys the widget and its children.

31.154.3 Member Function Documentation


void Fl Wizard::next ( )
This method shows the next child of the wizard.
If the last child is already visible, this function does nothing.

void Fl Wizard::prev ( )
Shows the previous child.

Fl Widget ∗ Fl Wizard::value ( )
Gets the current visible child widget.

void Fl Wizard::value ( Fl Widget ∗ kid )


Sets the child widget that is visible.
The documentation for this class was generated from the following files:

• Fl Wizard.H
• Fl Wizard.cxx
31.155. FL XBM IMAGE CLASS REFERENCE 873

31.155 Fl XBM Image Class Reference


The Fl XBM Image class supports loading, caching, and drawing of X Bitmap (XBM) bitmap files.
#include <Fl XBM Image.H>
Inheritance diagram for Fl XBM Image:

Fl_Image

Fl_Bitmap

Fl_XBM_Image

Public Member Functions


• Fl XBM Image (const char ∗filename)
The constructor loads the named XBM file from the given name filename.

Additional Inherited Members


31.155.1 Detailed Description
The Fl XBM Image class supports loading, caching, and drawing of X Bitmap (XBM) bitmap files.

31.155.2 Constructor & Destructor Documentation


Fl XBM Image::Fl XBM Image ( const char ∗ name )

The constructor loads the named XBM file from the given name filename.
The destructor free all memory and server resources that are used by the image.
The documentation for this class was generated from the following files:

• Fl XBM Image.H
• Fl XBM Image.cxx

31.156 Fl XColor Struct Reference


Public Attributes
• unsigned char b
• unsigned char g
• unsigned char mapped
• unsigned long pixel
• unsigned char r

The documentation for this struct was generated from the following file:

• Fl XColor.H
874 CHAPTER 31. CLASS DOCUMENTATION

31.157 Fl Xlib Graphics Driver Class Reference


The Xlib-specific graphics class.
#include <Fl Device.H>
Inheritance diagram for Fl Xlib Graphics Driver:

Fl_Device

Fl_Graphics_Driver

Fl_Xlib_Graphics_Driver

Public Member Functions


• const char ∗ class name ()
Returns the name of the class of this object.
• void color (Fl Color c)
see fl color(Fl Color c).
• void color (uchar r, uchar g, uchar b)
see fl color(uchar r, uchar g, uchar b).
• void copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
• int descent ()
see fl descent().
• void draw (const char ∗str, int n, int x, int y)
see fl draw(const char ∗str, int n, int x, int y).
• void draw (int angle, const char ∗str, int n, int x, int y)
see fl draw(int angle, const char ∗str, int n, int x, int y).
• void draw (Fl Pixmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Pixmap object to the device.
• void draw (Fl Bitmap ∗pxm, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl Bitmap object to the device.
• void draw (Fl RGB Image ∗img, int XP, int YP, int WP, int HP, int cx, int cy)
Draws an Fl RGB Image object to the device.
• void draw image (const uchar ∗buf, int X, int Y, int W, int H, int D=3, int L=0)
see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=3)
see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D=1, int L=0)
see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
• void draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=1)
see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
• void font (Fl Font face, Fl Fontsize size)
see fl font(Fl Font face, Fl Fontsize size).
• int height ()
see fl height().
• void rtl draw (const char ∗str, int n, int x, int y)
31.157. FL XLIB GRAPHICS DRIVER CLASS REFERENCE 875

see fl rtl draw(const char ∗str, int n, int x, int y).


• void text extents (const char ∗, int n, int &dx, int &dy, int &w, int &h)
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
• double width (const char ∗str, int n)
see fl width(const char ∗str, int n).
• double width (unsigned int c)
see fl width(unsigned int n).

Static Public Attributes


• static const char ∗ class id = ”Fl Xlib Graphics Driver”

Additional Inherited Members


31.157.1 Detailed Description
The Xlib-specific graphics class.
This class is implemented only on the Xlib platform.

31.157.2 Member Function Documentation


const char∗ Fl Xlib Graphics Driver::class name ( ) [inline], [virtual]
Returns the name of the class of this object.
Use of the class name() function is discouraged because it will be removed from future FLTK versions.
The class of an instance of an Fl Device subclass can be checked with code such as:
if ( instance->class name() == Fl Printer::class id ) { ... }

Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::color ( Fl Color c ) [virtual]


see fl color(Fl Color c).
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::color ( uchar r, uchar g, uchar b ) [virtual]


see fl color(uchar r, uchar g, uchar b).
Reimplemented from Fl Graphics Driver.

int Fl Xlib Graphics Driver::descent ( ) [virtual]


see fl descent().
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::draw ( int angle, const char ∗ str, int n, int x, int y ) [virtual]
see fl draw(int angle, const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.
876 CHAPTER 31. CLASS DOCUMENTATION

void Fl Xlib Graphics Driver::draw ( Fl Pixmap ∗ pxm, int XP, int YP, int WP, int HP, int cx, int
cy ) [virtual]

Draws an Fl Pixmap object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::draw ( Fl Bitmap ∗ bm, int XP, int YP, int WP, int HP, int cx, int
cy ) [virtual]

Draws an Fl Bitmap object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::draw ( Fl RGB Image ∗ rgb, int XP, int YP, int WP, int HP, int cx,
int cy ) [virtual]

Draws an Fl RGB Image object to the device.


Specifies a bounding box for the image, with the origin (upper left-hand corner) of the image offset by
the cx and cy arguments.
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::draw image ( const uchar ∗ buf, int X, int Y, int W, int H, int D =
3, int L = 0 ) [virtual]

see fl draw image(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::draw image ( Fl Draw Image Cb cb, void ∗ data, int X, int Y, int
W, int H, int D = 3 ) [virtual]

see fl draw image(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::draw image mono ( const uchar ∗ buf, int X, int Y, int W, int H,
int D = 1, int L = 0 ) [virtual]

see fl draw image mono(const uchar∗ buf, int X,int Y,int W,int H, int D, int L).
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::draw image mono ( Fl Draw Image Cb cb, void ∗ data, int X, int
Y, int W, int H, int D = 1 ) [virtual]

see fl draw image mono(Fl Draw Image Cb cb, void∗ data, int X,int Y,int W,int H, int D).
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::font ( Fl Font face, Fl Fontsize fsize ) [virtual]

see fl font(Fl Font face, Fl Fontsize size).


Reimplemented from Fl Graphics Driver.
31.158. FL XPM IMAGE CLASS REFERENCE 877

int Fl Xlib Graphics Driver::height ( ) [virtual]


see fl height().
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::rtl draw ( const char ∗ str, int n, int x, int y ) [virtual]
see fl rtl draw(const char ∗str, int n, int x, int y).
Reimplemented from Fl Graphics Driver.

void Fl Xlib Graphics Driver::text extents ( const char ∗ t, int n, int & dx, int & dy, int & w, int
& h ) [virtual]
see fl text extents(const char∗, int n, int& dx, int& dy, int& w, int& h).
Reimplemented from Fl Graphics Driver.

double Fl Xlib Graphics Driver::width ( const char ∗ str, int n ) [virtual]


see fl width(const char ∗str, int n).
Reimplemented from Fl Graphics Driver.

double Fl Xlib Graphics Driver::width ( unsigned int c ) [virtual]


see fl width(unsigned int n).
Reimplemented from Fl Graphics Driver.
The documentation for this class was generated from the following files:
• Fl Device.H
• Fl Bitmap.cxx
• fl color.cxx
• Fl Device.cxx
• fl draw image.cxx
• Fl Image.cxx
• Fl Pixmap.cxx

31.158 Fl XPM Image Class Reference


The Fl XPM Image class supports loading, caching, and drawing of X Pixmap (XPM) images, including
transparency.
#include <Fl XPM Image.H>
Inheritance diagram for Fl XPM Image:

Fl_Image

Fl_Pixmap

Fl_XPM_Image

Public Member Functions


• Fl XPM Image (const char ∗filename)
The constructor loads the XPM image from the name filename.
878 CHAPTER 31. CLASS DOCUMENTATION

Additional Inherited Members


31.158.1 Detailed Description
The Fl XPM Image class supports loading, caching, and drawing of X Pixmap (XPM) images, including
transparency.

31.158.2 Constructor & Destructor Documentation


Fl XPM Image::Fl XPM Image ( const char ∗ name )
The constructor loads the XPM image from the name filename.
The destructor free all memory and server resources that are used by the image.
The documentation for this class was generated from the following files:
• Fl XPM Image.H
• Fl XPM Image.cxx

31.159 Fl Text Editor::Key Binding Struct Reference


Simple linked list associating a key/state to a function.
#include <Fl Text Editor.H>

Public Attributes
• Key Func function
associated function
• int key
the key pressed
• Key Binding ∗ next
next key binding in the list
• int state
the state of key modifiers

31.159.1 Detailed Description


Simple linked list associating a key/state to a function.
The documentation for this struct was generated from the following file:
• Fl Text Editor.H

31.160 Fl Graphics Driver::matrix Struct Reference


A 2D coordinate transformation matrix.
#include <Fl Device.H>

Public Attributes
• double a
• double b
• double c
• double d
• double x
• double y
31.161. FL PREFERENCES::NAME CLASS REFERENCE 879

31.160.1 Detailed Description


A 2D coordinate transformation matrix.
The documentation for this struct was generated from the following file:
• Fl Device.H

31.161 Fl Preferences::Name Class Reference


’Name’ provides a simple method to create numerical or more complex procedural names for entries and
groups on the fly.
#include <Fl Preferences.H>

Public Member Functions


• Name (unsigned int n)
Creates a group name or entry name on the fly.
• Name (const char ∗format,...)
Creates a group name or entry name on the fly.
• operator const char ∗ ()
Return the Name as a ”C” string.

31.161.1 Detailed Description


’Name’ provides a simple method to create numerical or more complex procedural names for entries and
groups on the fly.
Example: prefs.set(Fl Preferences::Name(”File%d”,i),file[i]);.
See test/preferences.cxx as a sample for writing arrays into preferences.
’Name’ is actually implemented as a class inside Fl Preferences. It casts into const char∗ and gets
automatically destroyed after the enclosing call ends.

31.161.2 Constructor & Destructor Documentation


Fl Preferences::Name::Name ( unsigned int n )
Creates a group name or entry name on the fly.
This version creates a simple unsigned integer as an entry name.
int n, i;
Fl Preferences prev( appPrefs, "PreviousFiles" );
prev.get( "n", 0 );
for ( i=0; i<n; i++ )
prev.get( Fl Preferences::Name(i), prevFile[i], "" );

Fl Preferences::Name::Name ( const char ∗ format, ... )


Creates a group name or entry name on the fly.
This version creates entry names as in ’printf’.
int n, i;
Fl Preferences prefs( USER, "matthiasm.com", "test" );
prev.get( "nFiles", 0 );
for ( i=0; i<n; i++ )
prev.get( Fl Preferences::Name( "File%d", i ), prevFile[i], "" );

The documentation for this class was generated from the following files:
• Fl Preferences.H
• Fl Preferences.cxx
880 CHAPTER 31. CLASS DOCUMENTATION

31.162 Fl Preferences::Node Class Reference


Public Member Functions
• void add (const char ∗line)
• Node ∗ addChild (const char ∗path)
• const char ∗ child (int ix)
• Node ∗ childNode (int ix)
• void deleteAllChildren ()
• void deleteAllEntries ()
• char deleteEntry (const char ∗name)
• char dirty ()
• Entry & entry (int i)
• Node ∗ find (const char ∗path)
• RootNode ∗ findRoot ()
• const char ∗ get (const char ∗name)
• int getEntry (const char ∗name)
• const char ∗ name ()
• int nChildren ()
• int nEntry ()
• Node (const char ∗path)
• Node ∗ parent ()
• const char ∗ path ()
• char remove ()
• Node ∗ search (const char ∗path, int offset=0)
• void set (const char ∗name, const char ∗value)
• void set (const char ∗line)
• void setParent (Node ∗parent)
• void setRoot (RootNode ∗r)
• int write (FILE ∗f)

Static Public Attributes


• static int lastEntrySet = -1
The documentation for this class was generated from the following files:
• Fl Preferences.H
• Fl Preferences.cxx

31.163 Fl Paged Device::page format Struct Reference


width, height and name of a page format
#include <Fl Paged Device.H>

Public Attributes
• int height
height in points
• const char ∗ name
format name
• int width
width in points
31.164. FL PREFERENCES::ROOTNODE CLASS REFERENCE 881

31.163.1 Detailed Description


width, height and name of a page format
The documentation for this struct was generated from the following file:

• Fl Paged Device.H

31.164 Fl Preferences::RootNode Class Reference


Public Member Functions
• char getPath (char ∗path, int pathlen)
• int read ()
• RootNode (Fl Preferences ∗, Root root, const char ∗vendor, const char ∗application)
• RootNode (Fl Preferences ∗, const char ∗path, const char ∗vendor, const char ∗application)
• RootNode (Fl Preferences ∗)
• int write ()

The documentation for this class was generated from the following files:

• Fl Preferences.H
• Fl Preferences.cxx

31.165 Fl Window::shape data type Struct Reference


Data supporting a non-rectangular window shape.
#include <Fl Window.H>

Public Attributes
• int lh
height of shape image
• int lw
width of shape image
• Fl Image ∗ shape
shape image
• Fl Bitmap ∗ todelete
auxiliary bitmap image

31.165.1 Detailed Description


Data supporting a non-rectangular window shape.
The documentation for this struct was generated from the following file:

• Fl Window.H

31.166 Fl Text Display::Style Table Entry Struct Reference


This structure associates the color, font, andsize of a string to draw with an attribute mask matching attr.
#include <Fl Text Display.H>
882 CHAPTER 31. CLASS DOCUMENTATION

Public Attributes
• unsigned attr
• Fl Color color
• Fl Font font
• Fl Fontsize size

31.166.1 Detailed Description


This structure associates the color, font, andsize of a string to draw with an attribute mask matching attr.
The documentation for this struct was generated from the following file:

• Fl Text Display.H
31.166. FL TEXT DISPLAY::STYLE TABLE ENTRY STRUCT REFERENCE 883

Windows/Linux Mac Function


A Command-A Selects all text in the widget.


C Command-C Copy the current selection to
the clipboard.

∧ ∧
I I Insert a tab.

∧ ∧
J J Insert a Line Feed.
(Similar to literal ’Enter’
character)

∧ ∧
L L Insert a Form Feed.

∧ ∧
M M Insert a Carriage Return.


V, Command-V Paste the clipboard.
Shift-Insert (Macs keyboards don’t have
”Insert” keys, but if they did,
Shift-Insert would work)


X, Command-X, Cut.
Shift-Delete Shift-Delete Copy the selection to the
clipboard and delete it. (If
there’s no selection,
Shift-Delete acts like Delete)


Z Command-Z Undo.
This is a single-level undo
mechanism, but all adjacent
deletions and insertions are
concatenated into a single
”undo”. Often this will undo a
lot more than you expected.

Shift-∧ Z Shift-Command-Z Redo.


Currently same behavior as ∧ Z.
Reserved for future multilevel
undo/redo.

Arrow Keys Arrow Keys Standard cursor movement.


Can be combined with Shift to
extend selection.

Home Command-Up, Move to start of line.


Command-Left Can be combined with Shift to
extend selection.

End Command-Down, Move to end of line.


Command-Right Can be combined with Shift to
extend selection.

Ctrl-Home Command-Up, Move to top of


Command-PgUp, document/field.
Ctrl-Left In single line input, moves to
start of line. In multiline input,
moves to start of top line. Can
be combined with Shift to
extend selection.
884 CHAPTER 31. CLASS DOCUMENTATION

Keyboard FL TREE SELECT - FL TREE SELECT - FL TREE SELECT -


MULTI SINGLE NONE

Ctrl-A Select all items. N/A N/A


(Linux/Windows)
Command-A (Mac)
Space Selects item. Selects item. N/A

Ctrl-Space Toggle item. Toggle item. N/A

Shift-Space Extends selection Selects item. N/A


from last item.
Enter, Toggles open/close Toggles open/close Toggles open/close
Ctrl-Enter,
Shift-Enter
Right / Left Open/Close item. Open/Close item. Open/Close item.

Up / Down Move focus box Move focus box N/A


up/down. up/down.
Shift-Up / Shift-Down Extend selection Move focus up/down. N/A
up/down.
Home / End Move to top/bottom of Move to top/bottom of Move to top/bottom of
tree. tree. tree.

PageUp / PageDown Page up/down. Page up/down. Page up/down.

Table 31.3: Fl Tree keyboard bindings.


Chapter 32

File Documentation

32.1 Enumerations.H File Reference


This file contains type definitions and general enumerations.
#include "Fl Export.H"
#include "fl types.h"

Macros
• #define FL IMAGE WITH ALPHA 0x40000000

Version Numbers
FLTK defines some constants to help the programmer to find out, for which FLTK version a program is
compiled.
The following constants are defined:
• #define FL MAJOR VERSION 1
The major release version of this FLTK library.
• #define FL MINOR VERSION 3
The minor release version for this library.
• #define FL PATCH VERSION 3
The patch version for this library.
• #define FL VERSION
The FLTK version number as a double.

Mouse and Keyboard Events

This and the following constants define the non-ASCII keys on the
keyboard for FL_KEYBOARD and FL_SHORTCUT events.

Todo FL Button and FL key... constants could be structured better (use an enum or some doxygen
grouping ?)

\sa Fl::event_key() and Fl::get_key(int) (use ascii letters for all other keys):

• #define FL Button 0xfee8


A mouse button; use Fl Button + n for mouse button n.
• #define FL BackSpace 0xff08
The backspace key.

885
886 CHAPTER 32. FILE DOCUMENTATION

• #define FL Tab 0xff09


The tab key.
• #define FL Iso Key 0xff0c
The additional key of ISO keyboards.
• #define FL Enter 0xff0d
The enter key.
• #define FL Pause 0xff13
The pause key.
• #define FL Scroll Lock 0xff14
The scroll lock key.
• #define FL Escape 0xff1b
The escape key.
• #define FL Kana 0xff2e
The Kana key of JIS keyboards.
• #define FL Eisu 0xff2f
The Eisu key of JIS keyboards.
• #define FL Yen 0xff30
The Yen key of JIS keyboards.
• #define FL JIS Underscore 0xff31
The underscore key of JIS keyboards.
• #define FL Home 0xff50
The home key.
• #define FL Left 0xff51
The left arrow key.
• #define FL Up 0xff52
The up arrow key.
• #define FL Right 0xff53
The right arrow key.
• #define FL Down 0xff54
The down arrow key.
• #define FL Page Up 0xff55
The page-up key.
• #define FL Page Down 0xff56
The page-down key.
• #define FL End 0xff57
The end key.
• #define FL Print 0xff61
The print (or print-screen) key.
• #define FL Insert 0xff63
The insert key.
• #define FL Menu 0xff67
The menu key.
• #define FL Help 0xff68
The ’help’ key on Mac keyboards.
• #define FL Num Lock 0xff7f
The num lock key.
• #define FL KP 0xff80
One of the keypad numbers; use FL KP + ’n’ for digit n.
• #define FL KP Enter 0xff8d
The enter key on the keypad, same as Fl KP+’\r’.
• #define FL KP Last 0xffbd
32.1. ENUMERATIONS.H FILE REFERENCE 887

The last keypad key; use to range-check keypad.


• #define FL F 0xffbd
One of the function keys; use FL F + n for function key n.
• #define FL F Last 0xffe0
The last function key; use to range-check function keys.
• #define FL Shift L 0xffe1
The lefthand shift key.
• #define FL Shift R 0xffe2
The righthand shift key.
• #define FL Control L 0xffe3
The lefthand control key.
• #define FL Control R 0xffe4
The righthand control key.
• #define FL Caps Lock 0xffe5
The caps lock key.
• #define FL Meta L 0xffe7
The left meta/Windows key.
• #define FL Meta R 0xffe8
The right meta/Windows key.
• #define FL Alt L 0xffe9
The left alt key.
• #define FL Alt R 0xffea
The right alt key.
• #define FL Delete 0xffff
The delete key.
• #define FL Volume Down 0xEF11 /∗ Volume control down ∗/
• #define FL Volume Mute 0xEF12 /∗ Mute sound from the system ∗/
• #define FL Volume Up 0xEF13 /∗ Volume control up ∗/
• #define FL Media Play 0xEF14 /∗ Start playing of audio ∗/
• #define FL Media Stop 0xEF15 /∗ Stop playing audio ∗/
• #define FL Media Prev 0xEF16 /∗ Previous track ∗/
• #define FL Media Next 0xEF17 /∗ Next track ∗/
• #define FL Home Page 0xEF18 /∗ Display user’s home page ∗/
• #define FL Mail 0xEF19 /∗ Invoke user’s mail program ∗/
• #define FL Search 0xEF1B /∗ Search ∗/
• #define FL Back 0xEF26 /∗ Like back on a browser ∗/
• #define FL Forward 0xEF27 /∗ Like forward on a browser ∗/
• #define FL Stop 0xEF28 /∗ Stop current operation ∗/
• #define FL Refresh 0xEF29 /∗ Refresh the page ∗/
• #define FL Sleep 0xEF2F /∗ Put system to sleep ∗/
• #define FL Favorites 0xEF30 /∗ Show favorite locations ∗/

Mouse Buttons

These constants define the button numbers for FL_PUSH and FL_RELEASE events.

See Also
Fl::event button()

• #define FL LEFT MOUSE 1


The left mouse button.
• #define FL MIDDLE MOUSE 2
The middle mouse button.
888 CHAPTER 32. FILE DOCUMENTATION

• #define FL RIGHT MOUSE 3


The right mouse button.

Event States

The following constants define bits in the Fl::event_state() value.

• #define FL SHIFT 0x00010000


One of the shift keys is down.
• #define FL CAPS LOCK 0x00020000
The caps lock is on.
• #define FL CTRL 0x00040000
One of the ctrl keys is down.
• #define FL ALT 0x00080000
One of the alt keys is down.
• #define FL NUM LOCK 0x00100000
The num lock is on.
• #define FL META 0x00400000
One of the meta/Windows keys is down.
• #define FL SCROLL LOCK 0x00800000
The scroll lock is on.
• #define FL BUTTON1 0x01000000
Mouse button 1 is pushed.
• #define FL BUTTON2 0x02000000
Mouse button 2 is pushed.
• #define FL BUTTON3 0x04000000
Mouse button 3 is pushed.
• #define FL BUTTONS 0x7f000000
Any mouse button is pushed.
• #define FL BUTTON(n) (0x00800000<<(n))
Mouse button n (n > 0) is pushed.
• #define FL KEY MASK 0x0000ffff
All keys are 16 bit for now.
• #define FL COMMAND FL CTRL
An alias for FL CTRL on WIN32 and X11, or FL META on MacOS X.
• #define FL CONTROL FL META
An alias for FL META on WIN32 and X11, or FL CTRL on MacOS X.

Typedefs
• typedef int Fl Fontsize
Size of a font in pixels.

Enumerations
• enum { FL READ = 1, FL WRITE = 4, FL EXCEPT = 8 }
FD ”when” conditions.
• enum Fl Damage {
FL DAMAGE CHILD = 0x01, FL DAMAGE EXPOSE = 0x02, FL DAMAGE SCROLL = 0x04,
FL DAMAGE OVERLAY = 0x08,
FL DAMAGE USER1 = 0x10, FL DAMAGE USER2 = 0x20, FL DAMAGE ALL = 0x80 }
Damage masks.
32.1. ENUMERATIONS.H FILE REFERENCE 889

• enum Fl Event {
FL NO EVENT = 0, FL PUSH = 1, FL RELEASE = 2, FL ENTER = 3,
FL LEAVE = 4, FL DRAG = 5, FL FOCUS = 6, FL UNFOCUS = 7,
FL KEYDOWN = 8, FL KEYBOARD = 8, FL KEYUP = 9, FL CLOSE = 10,
FL MOVE = 11, FL SHORTCUT = 12, FL DEACTIVATE = 13, FL ACTIVATE = 14,
FL HIDE = 15, FL SHOW = 16, FL PASTE = 17, FL SELECTIONCLEAR = 18,
FL MOUSEWHEEL = 19, FL DND ENTER = 20, FL DND DRAG = 21, FL DND LEAVE = 22,
FL DND RELEASE = 23, FL SCREEN CONFIGURATION CHANGED = 24, FL FULLSCRE-
EN = 25 }
Every time a user moves the mouse pointer, clicks a button, or presses a key, an event is generated and sent
to your application.
• enum Fl Labeltype {
FL NORMAL LABEL = 0, FL NO LABEL, FL SHADOW LABEL, FL ENGRAVED LABEL,
FL EMBOSSED LABEL, FL MULTI LABEL, FL ICON LABEL, FL IMAGE LABEL,
FL FREE LABELTYPE }
The labeltype() method sets the type of the label.
• enum Fl Mode {
FL RGB = 0, FL INDEX = 1, FL SINGLE = 0, FL DOUBLE = 2,
FL ACCUM = 4, FL ALPHA = 8, FL DEPTH = 16, FL STENCIL = 32,
FL RGB8 = 64, FL MULTISAMPLE = 128, FL STEREO = 256, FL FAKE SINGLE = 512 }
visual types and Fl Gl Window::mode() (values match Glut)

When Conditions

• enum Fl When {
FL WHEN NEVER = 0, FL WHEN CHANGED = 1, FL WHEN NOT CHANGED = 2, FL -
WHEN RELEASE = 4,
FL WHEN RELEASE ALWAYS = 6, FL WHEN ENTER KEY = 8, FL WHEN ENTER KE-
Y ALWAYS =10, FL WHEN ENTER KEY CHANGED =11 }
These constants determine when a callback is performed.

Cursors

• enum Fl Cursor {
FL CURSOR DEFAULT = 0, FL CURSOR ARROW = 35, FL CURSOR CROSS = 66, FL C-
URSOR WAIT = 76,
FL CURSOR INSERT = 77, FL CURSOR HAND = 31, FL CURSOR HELP = 47, FL CURS-
OR MOVE = 27,
FL CURSOR NS = 78, FL CURSOR WE = 79, FL CURSOR NWSE = 80, FL CURSOR NE-
SW = 81,
FL CURSOR N = 70, FL CURSOR NE = 69, FL CURSOR E = 49, FL CURSOR SE = 8,
FL CURSOR S = 9, FL CURSOR SW = 7, FL CURSOR W = 36, FL CURSOR NW = 68,
FL CURSOR NONE =255 }
The following constants define the mouse cursors that are available in FLTK.

Variables
• FL EXPORT Fl Fontsize FL NORMAL SIZE
normal font size
890 CHAPTER 32. FILE DOCUMENTATION

Box Types
FLTK standard box types
This enum defines the standard box types included with FLTK.
FL NO BOX means nothing is drawn at all, so whatever is already on the screen remains. The FL ... -
FRAME types only draw their edges, leaving the interior unchanged. The blue color in Figure 1 is the area
that is not drawn by the frame types.

Figure 32.1: FLTK standard box types

Todo Description of boxtypes is incomplete. See below for the defined enum Fl Boxtype.

See Also
src/Fl get system colors.cxx

• #define FL ROUND UP BOX fl define FL ROUND UP BOX()


• #define FL ROUND DOWN BOX (Fl Boxtype)(fl define FL ROUND UP BOX()+1)
• #define FL SHADOW BOX fl define FL SHADOW BOX()
• #define FL SHADOW FRAME (Fl Boxtype)(fl define FL SHADOW BOX()+2)
• #define FL ROUNDED BOX fl define FL ROUNDED BOX()
• #define FL ROUNDED FRAME (Fl Boxtype)(fl define FL ROUNDED BOX()+2)
• #define FL RFLAT BOX fl define FL RFLAT BOX()
• #define FL RSHADOW BOX fl define FL RSHADOW BOX()
• #define FL DIAMOND UP BOX fl define FL DIAMOND BOX()
• #define FL DIAMOND DOWN BOX (Fl Boxtype)(fl define FL DIAMOND BOX()+1)
• #define FL OVAL BOX fl define FL OVAL BOX()
• #define FL OSHADOW BOX (Fl Boxtype)(fl define FL OVAL BOX()+1)
• #define FL OVAL FRAME (Fl Boxtype)(fl define FL OVAL BOX()+2)
• #define FL OFLAT BOX (Fl Boxtype)(fl define FL OVAL BOX()+3)
• #define FL PLASTIC UP BOX fl define FL PLASTIC UP BOX()
• #define FL PLASTIC DOWN BOX (Fl Boxtype)(fl define FL PLASTIC UP BOX()+1)
• #define FL PLASTIC UP FRAME (Fl Boxtype)(fl define FL PLASTIC UP BOX()+2)
• #define FL PLASTIC DOWN FRAME (Fl Boxtype)(fl define FL PLASTIC UP BOX()+3)
32.1. ENUMERATIONS.H FILE REFERENCE 891

• #define FL PLASTIC THIN UP BOX (Fl Boxtype)(fl define FL PLASTIC UP BOX()+4)


• #define FL PLASTIC THIN DOWN BOX (Fl Boxtype)(fl define FL PLASTIC UP BOX()+5)
• #define FL PLASTIC ROUND UP BOX (Fl Boxtype)(fl define FL PLASTIC UP BOX()+6)
• #define FL PLASTIC ROUND DOWN BOX (Fl Boxtype)(fl define FL PLASTIC UP BOX()+7)
• #define FL GTK UP BOX fl define FL GTK UP BOX()
• #define FL GTK DOWN BOX (Fl Boxtype)(fl define FL GTK UP BOX()+1)
• #define FL GTK UP FRAME (Fl Boxtype)(fl define FL GTK UP BOX()+2)
• #define FL GTK DOWN FRAME (Fl Boxtype)(fl define FL GTK UP BOX()+3)
• #define FL GTK THIN UP BOX (Fl Boxtype)(fl define FL GTK UP BOX()+4)
• #define FL GTK THIN DOWN BOX (Fl Boxtype)(fl define FL GTK UP BOX()+5)
• #define FL GTK THIN UP FRAME (Fl Boxtype)(fl define FL GTK UP BOX()+6)
• #define FL GTK THIN DOWN FRAME (Fl Boxtype)(fl define FL GTK UP BOX()+7)
• #define FL GTK ROUND UP BOX (Fl Boxtype)(fl define FL GTK UP BOX()+8)
• #define FL GTK ROUND DOWN BOX (Fl Boxtype)(fl define FL GTK UP BOX()+9)
• #define FL GLEAM UP BOX fl define FL GLEAM UP BOX()
• #define FL GLEAM DOWN BOX (Fl Boxtype)(fl define FL GLEAM UP BOX()+1)
• #define FL GLEAM UP FRAME (Fl Boxtype)(fl define FL GLEAM UP BOX()+2)
• #define FL GLEAM DOWN FRAME (Fl Boxtype)(fl define FL GLEAM UP BOX()+3)
• #define FL GLEAM THIN UP BOX (Fl Boxtype)(fl define FL GLEAM UP BOX()+4)
• #define FL GLEAM THIN DOWN BOX (Fl Boxtype)(fl define FL GLEAM UP BOX()+5)
• #define FL GLEAM ROUND UP BOX (Fl Boxtype)(fl define FL GLEAM UP BOX()+6)
• #define FL GLEAM ROUND DOWN BOX (Fl Boxtype)(fl define FL GLEAM UP BOX()+7)
• #define FL FRAME FL ENGRAVED FRAME
• #define FL FRAME BOX FL ENGRAVED BOX
• #define FL CIRCLE BOX FL ROUND DOWN BOX
• #define FL DIAMOND BOX FL DIAMOND DOWN BOX
• enum Fl Boxtype {
FL NO BOX = 0, FL FLAT BOX, FL UP BOX, FL DOWN BOX,
FL UP FRAME, FL DOWN FRAME, FL THIN UP BOX, FL THIN DOWN BOX,
FL THIN UP FRAME, FL THIN DOWN FRAME, FL ENGRAVED BOX, FL EMBOSSED B-
OX,
FL ENGRAVED FRAME, FL EMBOSSED FRAME, FL BORDER BOX, FL SHADOW BOX,
FL BORDER FRAME, FL SHADOW FRAME, FL ROUNDED BOX, FL RSHADOW BOX,
FL ROUNDED FRAME, FL RFLAT BOX, FL ROUND UP BOX, FL ROUND DOWN B-
OX,
FL DIAMOND UP BOX, FL DIAMOND DOWN BOX, FL OVAL BOX, FL OSHADOW -
BOX,
FL OVAL FRAME, FL OFLAT BOX, FL PLASTIC UP BOX, FL PLASTIC DOWN BOX,
FL PLASTIC UP FRAME, FL PLASTIC DOWN FRAME, FL PLASTIC THIN UP BOX, -
FL PLASTIC THIN DOWN BOX,
FL PLASTIC ROUND UP BOX, FL PLASTIC ROUND DOWN BOX, FL GTK UP BOX, -
FL GTK DOWN BOX,
FL GTK UP FRAME, FL GTK DOWN FRAME, FL GTK THIN UP BOX, FL GTK THIN-
DOWN BOX,
FL GTK THIN UP FRAME, FL GTK THIN DOWN FRAME, FL GTK ROUND UP BOX, -
FL GTK ROUND DOWN BOX,
FL GLEAM UP BOX, FL GLEAM DOWN BOX, FL GLEAM UP FRAME, FL GLEAM -
DOWN FRAME,
FL GLEAM THIN UP BOX, FL GLEAM THIN DOWN BOX, FL GLEAM ROUND UP B-
OX, FL GLEAM ROUND DOWN BOX,
FL FREE BOXTYPE }
• FL EXPORT Fl Boxtype fl define FL ROUND UP BOX ()
892 CHAPTER 32. FILE DOCUMENTATION

• FL EXPORT Fl Boxtype fl define FL SHADOW BOX ()


• FL EXPORT Fl Boxtype fl define FL ROUNDED BOX ()
• FL EXPORT Fl Boxtype fl define FL RFLAT BOX ()
• FL EXPORT Fl Boxtype fl define FL RSHADOW BOX ()
• FL EXPORT Fl Boxtype fl define FL DIAMOND BOX ()
• FL EXPORT Fl Boxtype fl define FL OVAL BOX ()
• FL EXPORT Fl Boxtype fl define FL PLASTIC UP BOX ()
• FL EXPORT Fl Boxtype fl define FL GTK UP BOX ()
• FL EXPORT Fl Boxtype fl define FL GLEAM UP BOX ()
• Fl Boxtype fl box (Fl Boxtype b)
Get the filled version of a frame.
• Fl Boxtype fl down (Fl Boxtype b)
Get the ”pressed” or ”down” version of a box.
• Fl Boxtype fl frame (Fl Boxtype b)
Get the unfilled, frame only version of a box.

• #define FL SYMBOL LABEL FL NORMAL LABEL


Sets the current label type and return its corresponding Fl Labeltype value.
• #define FL SHADOW LABEL fl define FL SHADOW LABEL()
• #define FL ENGRAVED LABEL fl define FL ENGRAVED LABEL()
• #define FL EMBOSSED LABEL fl define FL EMBOSSED LABEL()
• Fl Labeltype FL EXPORT fl define FL SHADOW LABEL ()
• Fl Labeltype FL EXPORT fl define FL ENGRAVED LABEL ()
• Fl Labeltype FL EXPORT fl define FL EMBOSSED LABEL ()

Alignment Flags
Flags to control the label alignment.
This controls how the label is displayed next to or inside the widget. The default value is FL ALIGN -
CENTER for most widgets, which centers the label inside the widget.
Flags can be or’d to achieve a combination of alignments.
Outside alignments:
TOP LEFT TOP TOP RIGHT
LEFT TOP+---------------------------------+RIGHT TOP
| |
LEFT| |RIGHT
| |
LEFT BOTTOM+---------------------------------+RIGHT BOTTOM
BOTTOM RIGHT BOTTOM BOTTOM LEFT

Inside alignments:
+---------------------------------+
|TOP LEFT TOP TOP RIGHT|
| |
|LEFT RIGHT|
| |
|BOTTOM RIGHT BOTTOM BOTTOM LEFT|
+---------------------------------+

See Also
FL ALIGN CENTER, etc.

• typedef unsigned Fl Align


FLTK type for alignment control.
• const Fl Align FL ALIGN CENTER = (Fl Align)0
Align the label horizontally in the middle.
32.1. ENUMERATIONS.H FILE REFERENCE 893

• const Fl Align FL ALIGN TOP = (Fl Align)1


Align the label at the top of the widget.
• const Fl Align FL ALIGN BOTTOM = (Fl Align)2
Align the label at the bottom of the widget.
• const Fl Align FL ALIGN LEFT = (Fl Align)4
Align the label at the left of the widget.
• const Fl Align FL ALIGN RIGHT = (Fl Align)8
Align the label to the right of the widget.
• const Fl Align FL ALIGN INSIDE = (Fl Align)16
Draw the label inside of the widget.
• const Fl Align FL ALIGN TEXT OVER IMAGE = (Fl Align)0x0020
If the label contains an image, draw the text on top of the image.
• const Fl Align FL ALIGN IMAGE OVER TEXT = (Fl Align)0x0000
If the label contains an image, draw the text below the image.
• const Fl Align FL ALIGN CLIP = (Fl Align)64
All parts of the label that are lager than the widget will not be drawn .
• const Fl Align FL ALIGN WRAP = (Fl Align)128
Wrap text that does not fit the width of the widget.
• const Fl Align FL ALIGN IMAGE NEXT TO TEXT = (Fl Align)0x0100
If the label contains an image, draw the text to the right of the image.
• const Fl Align FL ALIGN TEXT NEXT TO IMAGE = (Fl Align)0x0120
If the label contains an image, draw the text to the left of the image.
• const Fl Align FL ALIGN IMAGE BACKDROP = (Fl Align)0x0200
If the label contains an image, draw the image or deimage in the background.
• const Fl Align FL ALIGN TOP LEFT = FL ALIGN TOP | FL ALIGN LEFT
• const Fl Align FL ALIGN TOP RIGHT = FL ALIGN TOP | FL ALIGN RIGHT
• const Fl Align FL ALIGN BOTTOM LEFT = FL ALIGN BOTTOM | FL ALIGN LEFT
• const Fl Align FL ALIGN BOTTOM RIGHT = FL ALIGN BOTTOM | FL ALIGN RIGHT
• const Fl Align FL ALIGN LEFT TOP = 0x0007
• const Fl Align FL ALIGN RIGHT TOP = 0x000b
• const Fl Align FL ALIGN LEFT BOTTOM = 0x000d
• const Fl Align FL ALIGN RIGHT BOTTOM = 0x000e
• const Fl Align FL ALIGN NOWRAP = (Fl Align)0
• const Fl Align FL ALIGN POSITION MASK = 0x000f
• const Fl Align FL ALIGN IMAGE MASK = 0x0320

Font Numbers
The following constants define the standard FLTK fonts:

• typedef int Fl Font


A font number is an index into the internal font table.
• const Fl Font FL HELVETICA = 0
Helvetica (or Arial) normal (0)
• const Fl Font FL HELVETICA BOLD = 1
Helvetica (or Arial) bold.
• const Fl Font FL HELVETICA ITALIC = 2
Helvetica (or Arial) oblique.
894 CHAPTER 32. FILE DOCUMENTATION

• const Fl Font FL HELVETICA BOLD ITALIC = 3


Helvetica (or Arial) bold-oblique.
• const Fl Font FL COURIER = 4
Courier normal.
• const Fl Font FL COURIER BOLD = 5
Courier bold.
• const Fl Font FL COURIER ITALIC = 6
Courier italic.
• const Fl Font FL COURIER BOLD ITALIC = 7
Courier bold-italic.
• const Fl Font FL TIMES = 8
Times roman.
• const Fl Font FL TIMES BOLD = 9
Times roman bold.
• const Fl Font FL TIMES ITALIC = 10
Times roman italic.
• const Fl Font FL TIMES BOLD ITALIC = 11
Times roman bold-italic.
• const Fl Font FL SYMBOL = 12
Standard symbol font.
• const Fl Font FL SCREEN = 13
Default monospaced screen font.
• const Fl Font FL SCREEN BOLD = 14
Default monospaced bold screen font.
• const Fl Font FL ZAPF DINGBATS = 15
Zapf-dingbats font.
• const Fl Font FL FREE FONT = 16
first one to allocate
• const Fl Font FL BOLD = 1
add this to helvetica, courier, or times
• const Fl Font FL ITALIC = 2
add this to helvetica, courier, or times
• const Fl Font FL BOLD ITALIC = 3
add this to helvetica, courier, or times

Colors
The Fl Color type holds an FLTK color value.
Colors are either 8-bit indexes into a virtual colormap or 24-bit RGB color values. (See Colors for the
default FLTK colormap)
Color indices occupy the lower 8 bits of the value, while RGB colors occupy the upper 24 bits, for a
byte organization of RGBI.
Fl Color => 0xrrggbbii
| | | |
| | | +--- index between 0 and 255
| | +----- blue color component (8 bit)
| +------- green component (8 bit)
+--------- red component (8 bit)
32.1. ENUMERATIONS.H FILE REFERENCE 895

A color can have either an index or an rgb value. Colors with rgb set and an index >0 are reserved for
special use.

• #define FL FREE COLOR (Fl Color)16


• #define FL NUM FREE COLOR 16
• #define FL GRAY RAMP (Fl Color)32
• #define FL NUM GRAY 24
• #define FL GRAY FL BACKGROUND COLOR
• #define FL COLOR CUBE (Fl Color)56
• #define FL NUM RED 5
• #define FL NUM GREEN 8
• #define FL NUM BLUE 5
• typedef unsigned int Fl Color
An FLTK color value; see also Colors.
• const Fl Color FL FOREGROUND COLOR = 0
the default foreground color (0) used for labels and text
• const Fl Color FL BACKGROUND2 COLOR = 7
the default background color for text, list, and valuator widgets
• const Fl Color FL INACTIVE COLOR = 8
the inactive foreground color
• const Fl Color FL SELECTION COLOR = 15
the default selection/highlight color
• const Fl Color FL GRAY0 = 32
• const Fl Color FL DARK3 = 39
• const Fl Color FL DARK2 = 45
• const Fl Color FL DARK1 = 47
• const Fl Color FL BACKGROUND COLOR = 49
• const Fl Color FL LIGHT1 = 50
• const Fl Color FL LIGHT2 = 52
• const Fl Color FL LIGHT3 = 54
• const Fl Color FL BLACK = 56
• const Fl Color FL RED = 88
• const Fl Color FL GREEN = 63
• const Fl Color FL YELLOW = 95
• const Fl Color FL BLUE = 216
• const Fl Color FL MAGENTA = 248
• const Fl Color FL CYAN = 223
• const Fl Color FL DARK RED = 72
• const Fl Color FL DARK GREEN = 60
• const Fl Color FL DARK YELLOW = 76
• const Fl Color FL DARK BLUE = 136
• const Fl Color FL DARK MAGENTA = 152
• const Fl Color FL DARK CYAN = 140
• const Fl Color FL WHITE = 255
• FL EXPORT Fl Color fl inactive (Fl Color c)
Returns the inactive, dimmed version of the given color.
• FL EXPORT Fl Color fl contrast (Fl Color fg, Fl Color bg)
Returns a color that contrasts with the background color.
• FL EXPORT Fl Color fl color average (Fl Color c1, Fl Color c2, float weight)
896 CHAPTER 32. FILE DOCUMENTATION

Returns the weighted average color between the two given colors.
• Fl Color fl lighter (Fl Color c)
Returns a lighter version of the specified color.
• Fl Color fl darker (Fl Color c)
Returns a darker version of the specified color.
• Fl Color fl rgb color (uchar r, uchar g, uchar b)
Returns the 24-bit color value closest to r, g, b.
• Fl Color fl rgb color (uchar g)
Returns the 24-bit color value closest to g (grayscale).
• Fl Color fl gray ramp (int i)
Returns a gray color value from black (i == 0) to white (i == FL NUM GRAY - 1).
• Fl Color fl color cube (int r, int g, int b)
Returns a color out of the color cube.

32.1.1 Detailed Description


This file contains type definitions and general enumerations.

32.1.2 Macro Definition Documentation


#define FL MAJOR VERSION 1
The major release version of this FLTK library.

See Also
FL VERSION

#define FL MINOR VERSION 3


The minor release version for this library.
FLTK remains mostly source-code compatible between minor version changes.

#define FL PATCH VERSION 3


The patch version for this library.
FLTK remains binary compatible between patches.

#define FL VERSION
Value:

((double)FL MAJOR VERSION + \


(double)FL MINOR VERSION * 0.01 + \
(double)FL PATCH VERSION * 0.0001)

The FLTK version number as a double.


FL VERSION is a double that describes the major and minor version numbers. Version 1.1 is actually
stored as 1.01 to allow for more than 9 minor releases.
The FL MAJOR VERSION, FL MINOR VERSION, and FL PATCH VERSION constants give the
integral values for the major, minor, and patch releases respectively.
32.1. ENUMERATIONS.H FILE REFERENCE 897

32.1.3 Typedef Documentation


typedef int Fl Font
A font number is an index into the internal font table.

typedef int Fl Fontsize


Size of a font in pixels.
This is the approximate height of a font in pixels.

32.1.4 Enumeration Type Documentation


anonymous enum
FD ”when” conditions.
Enumerator
FL READ Call the callback when there is data to be read.
FL WRITE Call the callback when data can be written without blocking.
FL EXCEPT Call the callback if an exception occurs on the file.

enum Fl Boxtype
Enumerator
FL NO BOX nothing is drawn at all, this box is invisible
FL FLAT BOX a flat box
FL UP BOX see figure 1
FL DOWN BOX see figure 1
FL UP FRAME see figure 1
FL DOWN FRAME see figure 1
FL THIN UP BOX see figure 1
FL THIN DOWN BOX see figure 1
FL THIN UP FRAME see figure 1
FL THIN DOWN FRAME see figure 1
FL ENGRAVED BOX see figure 1
FL EMBOSSED BOX see figure 1
FL ENGRAVED FRAME see figure 1
FL EMBOSSED FRAME see figure 1
FL BORDER BOX see figure 1
FL SHADOW BOX see figure 1
FL BORDER FRAME see figure 1
FL SHADOW FRAME see figure 1
FL ROUNDED BOX see figure 1
FL RSHADOW BOX see figure 1
FL ROUNDED FRAME see figure 1
FL RFLAT BOX see figure 1
898 CHAPTER 32. FILE DOCUMENTATION

FL ROUND UP BOX see figure 1


FL ROUND DOWN BOX see figure 1
FL DIAMOND UP BOX see figure 1
FL DIAMOND DOWN BOX see figure 1
FL OVAL BOX see figure 1
FL OSHADOW BOX see figure 1
FL OVAL FRAME see figure 1
FL OFLAT BOX see figure 1
FL PLASTIC UP BOX plastic version of FL UP BOX
FL PLASTIC DOWN BOX plastic version of FL DOWN BOX
FL PLASTIC UP FRAME plastic version of FL UP FRAME
FL PLASTIC DOWN FRAME plastic version of FL DOWN FRAME
FL PLASTIC THIN UP BOX plastic version of FL THIN UP BOX
FL PLASTIC THIN DOWN BOX plastic version of FL THIN DOWN BOX
FL PLASTIC ROUND UP BOX plastic version of FL ROUND UP BOX
FL PLASTIC ROUND DOWN BOX plastic version of FL ROUND DOWN BOX
FL GTK UP BOX gtk+ version of FL UP BOX
FL GTK DOWN BOX gtk+ version of FL DOWN BOX
FL GTK UP FRAME gtk+ version of FL UP FRAME
FL GTK DOWN FRAME gtk+ version of FL DOWN RAME
FL GTK THIN UP BOX gtk+ version of FL THIN UP BOX
FL GTK THIN DOWN BOX gtk+ version of FL THIN DOWN BOX
FL GTK THIN UP FRAME gtk+ version of FL UP FRAME
FL GTK THIN DOWN FRAME gtk+ version of FL THIN DOWN FRAME
FL GTK ROUND UP BOX gtk+ version of FL ROUND UP BOX
FL GTK ROUND DOWN BOX gtk+ version of FL ROUND DOWN BOX
FL GLEAM UP BOX gleam version of FL GLEAM UP BOX
FL GLEAM DOWN BOX gleam version of FL GLEAM DOWN BOX
FL GLEAM UP FRAME gleam version of FL GLEAM UP FRAME
FL GLEAM DOWN FRAME gleam version of FL GLEAM DOWN FRAME
FL GLEAM THIN UP BOX gleam version of FL GLEAM THIN UP BOX
FL GLEAM THIN DOWN BOX gleam version of FL GLEAM THIN DOWN BOX
FL GLEAM ROUND UP BOX gleam version of FL GLEAM ROUND UP BOX
FL GLEAM ROUND DOWN BOX gleam version of FL GLEAM ROUND DOWN BOX
FL FREE BOXTYPE the first free box type for creation of new box types
32.1. ENUMERATIONS.H FILE REFERENCE 899

enum Fl Cursor
The following constants define the mouse cursors that are available in FLTK.
Cursors are provided by the system when available, or bitmaps built into FLTK as a fallback.

Todo enum Fl Cursor needs maybe an image.

Enumerator
FL CURSOR DEFAULT the default cursor, usually an arrow.
FL CURSOR ARROW an arrow pointer.
FL CURSOR CROSS crosshair.
FL CURSOR WAIT busy indicator (e.g. hourglass).
FL CURSOR INSERT I-beam.
FL CURSOR HAND pointing hand.
FL CURSOR HELP question mark pointer.
FL CURSOR MOVE 4-pointed arrow or hand.
FL CURSOR NS up/down resize.
FL CURSOR WE left/right resize.
FL CURSOR NWSE diagonal resize.
FL CURSOR NESW diagonal resize.
FL CURSOR N upwards resize.
FL CURSOR NE upwards, right resize.
FL CURSOR E rightwards resize.
FL CURSOR SE downwards, right resize.
FL CURSOR S downwards resize.
FL CURSOR SW downwards, left resize.
FL CURSOR W leftwards resize.
FL CURSOR NW upwards, left resize.
FL CURSOR NONE invisible.

enum Fl Damage
Damage masks.

Enumerator
FL DAMAGE CHILD A child needs to be redrawn.
FL DAMAGE EXPOSE The window was exposed.
FL DAMAGE SCROLL The Fl Scroll widget was scrolled.
FL DAMAGE OVERLAY The overlay planes need to be redrawn.
FL DAMAGE USER1 First user-defined damage bit.
FL DAMAGE USER2 Second user-defined damage bit.
FL DAMAGE ALL Everything needs to be redrawn.
900 CHAPTER 32. FILE DOCUMENTATION

enum Fl Event
Every time a user moves the mouse pointer, clicks a button, or presses a key, an event is generated and sent
to your application.
Events can also come from other programs like the window manager.
Events are identified by the integer argument passed to 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. This static information remains valid until the next event is read from the window system, so it
is ok to look at it outside of the handle() method.

See Also
Fl::event text(), Fl::event key(), class Fl::

Enumerator
FL NO EVENT No event.
FL PUSH A mouse button has gone down with the mouse pointing at this widget. You can find out
what button by calling Fl::event button(). You find out the mouse position by calling Fl::event x()
and Fl::event y().
A widget indicates that it ”wants” the mouse click by returning non-zero from its Fl Widget-
::handle() method. It will then become the Fl::pushed() widget and will get FL DRAG and the
matching FL RELEASE events. If Fl Widget::handle() returns zero then FLTK will try sending
the FL PUSH to another widget.
FL RELEASE A mouse button has been released. You can find out what button by calling Fl::event-
button().
In order to receive the FL RELEASE event, the widget must return non-zero when handling
FL PUSH.
FL ENTER The mouse has been moved to point at this widget. This can be used for highlighting
feedback. If a widget wants to highlight or otherwise track the mouse, it indicates this by return-
ing non-zero from its handle() method. It then becomes the Fl::belowmouse() widget and will
receive FL MOVE and FL LEAVE events.
FL LEAVE The mouse has moved out of the widget. In order to receive the FL LEAVE event, the
widget must return non-zero when handling FL ENTER.
FL DRAG The mouse has moved with a button held down. The current button state is in Fl::event -
state(). The mouse position is in Fl::event x() and Fl::event y().
In order to receive FL DRAG events, the widget must return non-zero when handling FL PUSH.

FL FOCUS This indicates an attempt to give a widget the keyboard focus. If a widget wants the
focus, it should change itself to display the fact that it has the focus, and return non-zero from its
handle() method. It then becomes the Fl::focus() widget and gets FL KEYDOWN, FL KEYUP,
and FL UNFOCUS events.
The focus will change either because the window manager changed which window gets the focus,
or because the user tried to navigate using tab, arrows, or other keys. You can check Fl::event-
key() to figure out why it moved. For navigation it will be the key pressed and for interaction
with the window manager it will be zero.
FL UNFOCUS This event is sent to the previous Fl::focus() widget when another widget gets the
focus or the window loses focus.
FL KEYDOWN A key was pressed (FL KEYDOWN) or released (FL KEYUP). Fl KEYBOARD
is a synonym for FL KEYDOWN. The key can be found in Fl::event key(). The text that the key
should insert can be found with Fl::event text() and its length is in Fl::event length(). If you use
the key handle() should return 1. If you return zero then FLTK assumes you ignored the key and
32.1. ENUMERATIONS.H FILE REFERENCE 901

will then attempt to send it to a parent widget. If none of them want it, it will change the event
into a FL SHORTCUT event.
To receive FL KEYBOARD events you must also respond to the FL FOCUS and FL UNFOCUS
events.
If you are writing a text-editing widget you may also want to call the Fl::compose() function to
translate individual keystrokes into non-ASCII characters.
FL KEYUP events are sent to the widget that currently has focus. This is not necessarily the same
widget that received the corresponding FL KEYDOWN event because focus may have changed
between events.
FL KEYBOARD Equivalent to FL KEYDOWN.
See Also
FL KEYDOWN
FL KEYUP Key release event.
See Also
FL KEYDOWN
FL CLOSE The user clicked the close button of a window. This event is used internally only to trig-
ger the callback of Fl Window derived classed. The default callback closes the window calling
Fl Window::hide().
FL MOVE The mouse has moved without any mouse buttons held down. This event is sent to the
Fl::belowmouse() widget.
In order to receive FL MOVE events, the widget must return non-zero when handling FL ENT-
ER.
FL SHORTCUT If the Fl::focus() widget is zero or ignores an FL KEYBOARD event then FLTK
tries sending this event to every widget it can, until one of them returns non-zero. FL SHORT-
CUT is first sent to the Fl::belowmouse() widget, then its parents and siblings, and eventually to
every widget in the window, trying to find an object that returns non-zero. FLTK tries really hard
to not to ignore any keystrokes!
You can also make ”global” shortcuts by using Fl::add handler(). A global shortcut will work no
matter what windows are displayed or which one has the focus.
FL DEACTIVATE This widget is no longer active, due to Fl Widget::deactivate() being called on it
or one of its parents. Fl Widget::active() may still be true after this, the widget is only active if
Fl Widget::active() is true on it and all its parents (use Fl Widget::active r() to check this).
FL ACTIVATE This widget is now active, due to Fl Widget::activate() being called on it or one of
its parents.
FL HIDE This widget is no longer visible, due to Fl Widget::hide() being called on it or one of its
parents, or due to a parent window being minimized. Fl Widget::visible() may still be true after
this, but the widget is visible only if visible() is true for it and all its parents (use Fl Widget-
::visible r() to check this).
FL SHOW This widget is visible again, due to Fl Widget::show() being called on it or one of its
parents, or due to a parent window being restored. Child Fl Windows respond to this by actually
creating the window if not done already, so if you subclass a window, be sure to pass FL SHOW
to the base class Fl Widget::handle() method!
FL PASTE You should get this event some time after you call Fl::paste(). The contents of Fl::event-
text() is the text to insert and the number of characters is in Fl::event length().
FL SELECTIONCLEAR The Fl::selection owner() will get this event before the selection is moved
to another widget. This indicates that some other widget or program has claimed the selection.
Motif programs used this to clear the selection indication. Most modern programs ignore this.
902 CHAPTER 32. FILE DOCUMENTATION

FL MOUSEWHEEL The user has moved the mouse wheel. The Fl::event dx() and Fl::event dy()
methods can be used to find the amount to scroll horizontally and vertically.
FL DND ENTER The mouse has been moved to point at this widget. A widget that is interested
in receiving drag’n’drop data must return 1 to receive FL DND DRAG, FL DND LEAVE and
FL DND RELEASE events.
FL DND DRAG The mouse has been moved inside a widget while dragging data. A widget that is
interested in receiving drag’n’drop data should indicate the possible drop position.
FL DND LEAVE The mouse has moved out of the widget.
FL DND RELEASE The user has released the mouse button dropping data into the widget. If the
widget returns 1, it will receive the data in the immediately following FL PASTE event.
FL SCREEN CONFIGURATION CHANGED The screen configuration (number, positions) was
changed. Use Fl::add handler() to be notified of this event.
FL FULLSCREEN The fullscreen state of the window has changed.

enum Fl Labeltype
The labeltype() method sets the type of the label.
The following standard label types are included:

Todo The doxygen comments are incomplete, and some labeltypes are starting with an underscore. Also,
there are three external functions undocumented (yet):
• fl define FL SHADOW LABEL()
• fl define FL ENGRAVED LABEL()
• fl define FL EMBOSSED LABEL()
Enumerator
FL NORMAL LABEL draws the text (0)
FL NO LABEL does nothing
FL SHADOW LABEL draws a drop shadow under the text
FL ENGRAVED LABEL draws edges as though the text is engraved
FL EMBOSSED LABEL draws edges as though the text is raised
FL MULTI LABEL ?
FL ICON LABEL draws the icon associated with the text
FL IMAGE LABEL ?
FL FREE LABELTYPE first free labeltype to use for creating own labeltypes

enum Fl When
These constants determine when a callback is performed.
See Also
Fl Widget::when();

Todo doxygen comments for values are incomplete and maybe wrong or unclear
Enumerator
FL WHEN NEVER Never call the callback.
32.1. ENUMERATIONS.H FILE REFERENCE 903

FL WHEN CHANGED Do the callback only when the widget value changes.
FL WHEN NOT CHANGED Do the callback whenever the user interacts with the widget.
FL WHEN RELEASE Do the callback when the button or key is released and the value changes.
FL WHEN RELEASE ALWAYS Do the callback when the button or key is released, even if the
value doesn’t change.
FL WHEN ENTER KEY Do the callback when the user presses the ENTER key and the value
changes.
FL WHEN ENTER KEY ALWAYS Do the callback when the user presses the ENTER key, even if
the value doesn’t change.
FL WHEN ENTER KEY CHANGED ?

32.1.5 Function Documentation


Fl Boxtype fl box ( Fl Boxtype b ) [inline]
Get the filled version of a frame.
If no filled version of a given frame exists, the behavior of this function is undefined and some random
box or frame is returned.

Fl Color fl color cube ( int r, int g, int b ) [inline]


Returns a color out of the color cube.
r must be in the range 0 to FL NUM RED (5) minus 1, g must be in the range 0 to FL NUM GREEN
(8) minus 1, b must be in the range 0 to FL NUM BLUE (5) minus 1.
To get the closest color to a 8-bit set of R,G,B values use:
fl color cube(R * (FL NUM RED - 1) / 255,
G * (FL NUM GREEN - 1) / 255,
B * (FL NUM BLUE - 1) / 255);

Fl Color fl darker ( Fl Color c ) [inline]


Returns a darker version of the specified color.

Fl Boxtype fl down ( Fl Boxtype b ) [inline]


Get the ”pressed” or ”down” version of a box.
If no ”down” version of a given box exists, the behavior of this function is undefined and some random
box or frame is returned.

Fl Boxtype fl frame ( Fl Boxtype b ) [inline]


Get the unfilled, frame only version of a box.
If no frame version of a given box exists, the behavior of this function is undefined and some random
box or frame is returned.

Fl Color fl gray ramp ( int i ) [inline]


Returns a gray color value from black (i == 0) to white (i == FL NUM GRAY - 1).
FL NUM GRAY is defined to be 24 in the current FLTK release. To get the closest FLTK gray value
to an 8-bit grayscale color ’I’ use:
fl gray ramp(I * (FL NUM GRAY - 1) / 255)
904 CHAPTER 32. FILE DOCUMENTATION

Fl Color fl lighter ( Fl Color c ) [inline]


Returns a lighter version of the specified color.

Fl Color fl rgb color ( uchar r, uchar g, uchar b ) [inline]


Returns the 24-bit color value closest to r, g, b.

Fl Color fl rgb color ( uchar g ) [inline]


Returns the 24-bit color value closest to g (grayscale).

32.1.6 Variable Documentation


const Fl Align FL ALIGN BOTTOM = (Fl Align)2
Align the label at the bottom of the widget.

const Fl Align FL ALIGN CENTER = (Fl Align)0


Align the label horizontally in the middle.

const Fl Align FL ALIGN CLIP = (Fl Align)64


All parts of the label that are lager than the widget will not be drawn .

const Fl Align FL ALIGN IMAGE BACKDROP = (Fl Align)0x0200


If the label contains an image, draw the image or deimage in the background.

const Fl Align FL ALIGN IMAGE NEXT TO TEXT = (Fl Align)0x0100


If the label contains an image, draw the text to the right of the image.

const Fl Align FL ALIGN IMAGE OVER TEXT = (Fl Align)0x0000


If the label contains an image, draw the text below the image.

const Fl Align FL ALIGN INSIDE = (Fl Align)16


Draw the label inside of the widget.

const Fl Align FL ALIGN LEFT = (Fl Align)4


Align the label at the left of the widget.
Inside labels appear left-justified starting at the left side of the widget, outside labels are right-justified
and drawn to the left of the widget.

const Fl Align FL ALIGN RIGHT = (Fl Align)8


Align the label to the right of the widget.

const Fl Align FL ALIGN TEXT NEXT TO IMAGE = (Fl Align)0x0120


If the label contains an image, draw the text to the left of the image.
32.2. FILENAME.H FILE REFERENCE 905

const Fl Align FL ALIGN TEXT OVER IMAGE = (Fl Align)0x0020


If the label contains an image, draw the text on top of the image.

const Fl Align FL ALIGN TOP = (Fl Align)1


Align the label at the top of the widget.
Inside labels appear below the top, outside labels are drawn on top of the widget.

const Fl Align FL ALIGN WRAP = (Fl Align)128


Wrap text that does not fit the width of the widget.

FL EXPORT Fl Fontsize FL NORMAL SIZE


normal font size
normal font size

32.2 filename.H File Reference


File names and URI utility functions.
#include "Fl Export.H"
#include <sys/types.h>
#include <dirent.h>

Macros
• #define fl dirent h cyclic include
• #define FL FILENAME H
• #define FL PATH MAX 2048
all path buffers should use this length

Typedefs
• typedef int( Fl File Sort F )(struct dirent ∗∗, struct dirent ∗∗)
File sorting function.

Functions
• FL EXPORT void fl decode uri (char ∗uri)
Decodes a URL-encoded string.
• FL EXPORT int fl filename absolute (char ∗to, int tolen, const char ∗from)
Makes a filename absolute from a relative filename.
• FL EXPORT int fl filename expand (char ∗to, int tolen, const char ∗from)
Expands a filename containing shell variables and tilde (∼).
• FL EXPORT const char ∗ fl filename ext (const char ∗buf)
Gets the extensions of a filename.
• FL EXPORT void fl filename free list (struct dirent ∗∗∗l, int n)
Free the list of filenames that is generated by fl filename list().
• FL EXPORT int fl filename isdir (const char ∗name)
Determines if a file exists and is a directory from its filename.
906 CHAPTER 32. FILE DOCUMENTATION

• FL EXPORT int fl filename list (const char ∗d, struct dirent ∗∗∗l, Fl File Sort F ∗s=fl numericsort)
Portable and const-correct wrapper for the scandir() function.
• FL EXPORT int fl filename match (const char ∗name, const char ∗pattern)
Checks if a string s matches a pattern p.
• FL EXPORT const char ∗ fl filename name (const char ∗filename)
Gets the file name from a path.
• FL EXPORT int fl filename relative (char ∗to, int tolen, const char ∗from)
Makes a filename relative to the current working directory.
• FL EXPORT char ∗ fl filename setext (char ∗to, int tolen, const char ∗ext)
Replaces the extension in buf of max.
• FL EXPORT int fl open uri (const char ∗uri, char ∗msg, int msglen)
Opens the specified Uniform Resource Identifier (URI).

32.2.1 Detailed Description


File names and URI utility functions.

32.3 Fl.H File Reference


Fl static class.
#include <FL/Fl Cairo.H>
#include "fl utf8.h"
#include "Enumerations.H"

Classes
• class Fl
The Fl is the FLTK global (static) class containing state information and global methods for the current
application.
• class Fl Widget Tracker
This class should be used to control safe widget deletion.

Macros
• #define Fl Object Fl Widget
for back compatibility - use Fl Widget!
• #define FL SOCKET int

Typedefs
• typedef void(∗ Fl Abort Handler )(const char ∗format,...)
Signature of set abort functions passed as parameters.
• typedef int(∗ Fl Args Handler )(int argc, char ∗∗argv, int &i)
Signature of args functions passed as parameters.
• typedef void(∗ Fl Atclose Handler )(Fl Window ∗window, void ∗data)
Signature of set atclose functions passed as parameters.
• typedef void(∗ Fl Awake Handler )(void ∗data)
Signature of some wakeup callback functions passed as parameters.
32.4. FL ARC.CXX FILE REFERENCE 907

• typedef void( Fl Box Draw F )(int x, int y, int w, int h, Fl Color color)
Signature of some box drawing functions passed as parameters.
• typedef void(∗ Fl Clipboard Notify Handler )(int source, void ∗data)
Signature of add clipboard notify functions passed as parameters.
• typedef int(∗ Fl Event Dispatch )(int event, Fl Window ∗w)
Signature of event dispatch functions passed as parameters.
• typedef int(∗ Fl Event Handler )(int event)
Signature of add handler functions passed as parameters.
• typedef void(∗ Fl FD Handler )(FL SOCKET fd, void ∗data)
Signature of add fd functions passed as parameters.
• typedef void(∗ Fl Idle Handler )(void ∗data)
Signature of add idle callback functions passed as parameters.
• typedef void( Fl Label Draw F )(const Fl Label ∗label, int x, int y, int w, int h, Fl Align align)
Signature of some label drawing functions passed as parameters.
• typedef void( Fl Label Measure F )(const Fl Label ∗label, int &width, int &height)
Signature of some label measurement functions passed as parameters.
• typedef void(∗ Fl Old Idle Handler )()
Signature of set idle callback functions passed as parameters.
• typedef int(∗ Fl System Handler )(void ∗event, void ∗data)
Signature of add system handler functions passed as parameters.
• typedef void(∗ Fl Timeout Handler )(void ∗data)
Signature of some timeout callback functions passed as parameters.

32.3.1 Detailed Description


Fl static class.

32.4 fl arc.cxx File Reference


Utility functions for drawing arcs and circles.
#include <FL/fl draw.H>
#include <FL/math.h>

32.4.1 Detailed Description


Utility functions for drawing arcs and circles.

32.5 fl arci.cxx File Reference


Utility functions for drawing circles using integers.
#include <FL/fl draw.H>
#include <FL/x.H>
#include <config.h>

32.5.1 Detailed Description


Utility functions for drawing circles using integers.
908 CHAPTER 32. FILE DOCUMENTATION

32.6 fl ask.cxx File Reference


Utility functions for common dialogs.
#include <stdio.h>
#include <stdarg.h>
#include "flstring.h"
#include <FL/Fl.H>
#include <FL/fl ask.H>
#include <FL/Fl Box.H>
#include <FL/Fl Button.H>
#include <FL/Fl Return Button.H>
#include <FL/Fl Window.H>
#include <FL/Fl Input.H>
#include <FL/Fl Secret Input.H>
#include <FL/x.H>
#include <FL/fl draw.H>

Functions
• void fl alert (const char ∗fmt,...)
Shows an alert message dialog box.
• int fl ask (const char ∗fmt,...)
Shows a dialog displaying the fmt message, this dialog features 2 yes/no buttons.
• void fl beep (int type)
Emits a system beep message.
• int fl choice (const char ∗fmt, const char ∗b0, const char ∗b1, const char ∗b2,...)
Shows a dialog displaying the fmt message, this dialog features up to 3 customizable choice buttons.
• const char ∗ fl input (const char ∗fmt, const char ∗defstr,...)
Shows an input dialog displaying the fmt message.
• void fl message (const char ∗fmt,...)
Shows an information message dialog box.
• void fl message hotspot (int enable)
Sets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• int fl message hotspot (void)
Gets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• Fl Widget ∗ fl message icon ()
Gets the Fl Box icon container of the current default dialog used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password()
• void fl message title (const char ∗title)
Sets the title of the dialog window used in many common dialogs.
• void fl message title default (const char ∗title)
Sets the default title of the dialog window used in many common dialogs.
• const char ∗ fl password (const char ∗fmt, const char ∗defstr,...)
Shows an input dialog displaying the fmt message.
32.7. FL ASK.H FILE REFERENCE 909

Variables
• const char ∗ fl cancel = ”Cancel”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl close = ”Close”
string pointer used in common dialogs, you can change it to another language
• Fl Font fl message font = FL HELVETICA
• Fl Fontsize fl message size = -1
• const char ∗ fl no = ”No”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl ok = ”OK”
string pointer used in common dialogs, you can change it to another language
• const char ∗ fl yes = ”Yes”
string pointer used in common dialogs, you can change it to another language

32.6.1 Detailed Description


Utility functions for common dialogs.

32.7 fl ask.H File Reference


API for common dialogs.
#include "Enumerations.H"

Macros
• #define fl attr(x)

Enumerations
• enum Fl Beep {
FL BEEP DEFAULT = 0, FL BEEP MESSAGE, FL BEEP ERROR, FL BEEP QUESTION,
FL BEEP PASSWORD, FL BEEP NOTIFICATION }
Different system beeps available.

Functions
• FL EXPORT void FL EXPORT void fl alert (const char ∗,...) fl attr(( format ( printf
• FL EXPORT void FL EXPORT void
FL EXPORT int fl ask (const char ∗,...) fl attr(( format ( printf
• FL EXPORT void fl beep (int type=FL BEEP DEFAULT)
Emits a system beep message.
• FL EXPORT int fl choice (const char ∗q, const char ∗b0, const char ∗b1, const char ∗b2,...) fl -
attr(( format ( printf
• FL EXPORT int FL EXPORT const
char ∗ fl input (const char ∗label, const char ∗deflt=0,...) fl attr(( format ( printf
• FL EXPORT void fl message (const char ∗,...) fl attr(( format ( printf
• void fl message font (Fl Font f, Fl Fontsize s)
• FL EXPORT void fl message hotspot (int enable)
910 CHAPTER 32. FILE DOCUMENTATION

Sets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• FL EXPORT int fl message hotspot (void)
Gets whether or not to move the common message box used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password() to follow the mouse pointer.
• FL EXPORT int FL EXPORT const
char FL EXPORT const char
FL EXPORT Fl Widget ∗ fl message icon ()
Gets the Fl Box icon container of the current default dialog used in many common dialogs like fl message(),
fl alert(), fl ask(), fl choice(), fl input(), fl password()
• FL EXPORT void fl message title (const char ∗title)
Sets the title of the dialog window used in many common dialogs.
• FL EXPORT void fl message title default (const char ∗title)
Sets the default title of the dialog window used in many common dialogs.
• FL EXPORT int FL EXPORT const
char FL EXPORT const char ∗ fl password (const char ∗label, const char ∗deflt=0,...) fl attr(( -
format ( printf

Variables
• FL EXPORT void FL EXPORT void
FL EXPORT int deprecated
• FL EXPORT const char ∗ fl cancel
string pointer used in common dialogs, you can change it to another language
• FL EXPORT const char ∗ fl close
string pointer used in common dialogs, you can change it to another language
• FL EXPORT Fl Font fl message font
• FL EXPORT Fl Fontsize fl message size
• FL EXPORT const char ∗ fl no
string pointer used in common dialogs, you can change it to another language
• FL EXPORT const char ∗ fl ok
string pointer used in common dialogs, you can change it to another language
• FL EXPORT const char ∗ fl yes
string pointer used in common dialogs, you can change it to another language

32.7.1 Detailed Description


API for common dialogs.

32.7.2 Enumeration Type Documentation


enum Fl Beep

Different system beeps available.


32.8. FL BOXTYPE.CXX FILE REFERENCE 911

See Also
fl beep(int)
Enumerator
FL BEEP DEFAULT Default beep.
FL BEEP MESSAGE Message beep.
FL BEEP ERROR Error beep.
FL BEEP QUESTION Question beep.
FL BEEP PASSWORD Password beep.
FL BEEP NOTIFICATION Notification beep.

32.8 fl boxtype.cxx File Reference


drawing code for common box types.
#include <FL/Fl.H>
#include <FL/Fl Widget.H>
#include <FL/fl draw.H>
#include <config.h>

Macros
• #define D1 BORDER WIDTH
• #define D2 (BORDER WIDTH+BORDER WIDTH)
• #define fl border box fl rectbound
allow consistent naming

Functions
• void fl border frame (int x, int y, int w, int h, Fl Color c)
Draws a frame of type FL BORDER FRAME.
• void fl down box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL DOWN BOX.
• void fl down frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL DOWN FRAME.
• void fl draw box (Fl Boxtype t, int x, int y, int w, int h, Fl Color c)
Draws a box using given type, position, size and color.
• void fl embossed box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL EMBOSSED BOX.
• void fl embossed frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL EMBOSSED FRAME.
• void fl engraved box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL ENGRAVED BOX.
• void fl engraved frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL ENGRAVED FRAME.
• void fl frame (const char ∗s, int x, int y, int w, int h)
Draws a series of line segments around the given box.
• void fl frame2 (const char ∗s, int x, int y, int w, int h)
912 CHAPTER 32. FILE DOCUMENTATION

Draws a series of line segments around the given box.


• const uchar ∗ fl gray ramp ()
• void fl internal boxtype (Fl Boxtype t, Fl Box Draw F ∗f)
Sets the drawing function for a given box type.
• void fl no box (int, int, int, int, Fl Color)
Draws a box of type FL NO BOX.
• void fl rectbound (int x, int y, int w, int h, Fl Color bgcolor)
Draws a bounded rectangle with a given position, size and color.
• void fl thin down box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL THIN DOWN BOX.
• void fl thin down frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL THIN DOWN FRAME.
• void fl thin up box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL THIN UP BOX.
• void fl thin up frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL THIN UP FRAME.
• void fl up box (int x, int y, int w, int h, Fl Color c)
Draws a box of type FL UP BOX.
• void fl up frame (int x, int y, int w, int h, Fl Color)
Draws a frame of type FL UP FRAME.

32.8.1 Detailed Description


drawing code for common box types.

32.8.2 Function Documentation


void fl internal boxtype ( Fl Boxtype t, Fl Box Draw F ∗ f )
Sets the drawing function for a given box type.
Parameters
in t box type
in f box drawing function

void fl rectbound ( int x, int y, int w, int h, Fl Color bgcolor )


Draws a bounded rectangle with a given position, size and color.
Equivalent to drawing a box of type FL BORDER BOX.

32.9 fl color.cxx File Reference


Color handling.
#include "Fl XColor.H"
#include <FL/Fl.H>
#include <FL/x.H>
#include <FL/fl draw.H>
#include "fl cmap.h"
32.10. FL COLOR CHOOSER.H FILE REFERENCE 913

Macros
• #define fl overlay 0
HAVE OVERLAY determines whether fl overlay is variable or defined as 0.

Functions
• Fl Color fl color average (Fl Color color1, Fl Color color2, float weight)
Returns the weighted average color between the two given colors.
• Fl Color fl contrast (Fl Color fg, Fl Color bg)
Returns a color that contrasts with the background color.
• Fl Color fl inactive (Fl Color c)
Returns the inactive, dimmed version of the given color.
• ulong fl xpixel (uchar r, uchar g, uchar b)
Returns the X pixel number used to draw the given rgb color.
• ulong fl xpixel (Fl Color i)
Returns the X pixel number used to draw the given FLTK color index.

Variables
• uchar fl bluemask
color mask used in current color map handling
• int fl blueshift
color shift used in current color map handling
• int fl extrashift
color shift used in current color map handling
• uchar fl greenmask
color mask used in current color map handling
• int fl greenshift
color shift used in current color map handling
• uchar fl redmask
color mask used in current color map handling
• int fl redshift
color shift used in current color map handling
• Fl XColor fl xmap [1][256]
HAVE OVERLAY determines whether fl xmap is one or two planes.

32.9.1 Detailed Description


Color handling.

32.10 Fl Color Chooser.H File Reference


Fl Color Chooser widget .
#include <FL/Fl Group.H>
#include <FL/Fl Box.H>
#include <FL/Fl Return Button.H>
#include <FL/Fl Choice.H>
#include <FL/Fl Value Input.H>
914 CHAPTER 32. FILE DOCUMENTATION

Classes
• class Fl Color Chooser
The Fl Color Chooser widget provides a standard RGB color chooser.

32.10.1 Detailed Description


Fl Color Chooser widget .

32.11 Fl compose.cxx File Reference


Utility functions to support text input.
#include <FL/Fl.H>
#include <FL/x.H>

Variables
• XIC fl xim ic

32.11.1 Detailed Description


Utility functions to support text input.

32.12 fl curve.cxx File Reference


Utility for drawing Bezier curves, adding the points to the current fl begin/fl vertex/fl end path.
#include <FL/fl draw.H>
#include <math.h>

32.12.1 Detailed Description


Utility for drawing Bezier curves, adding the points to the current fl begin/fl vertex/fl end path. Incremen-
tal math implementation: I very much doubt this is optimal! From Foley/vanDam page 511. If anybody
has a better algorithm, please send it!

32.13 Fl Device.H File Reference


declaration of classes Fl Device, Fl Graphics Driver, Fl Surface Device, Fl Display Device, Fl Device -
Plugin.
#include <FL/x.H>
#include <FL/Fl Plugin.H>
#include <FL/Fl Image.H>
#include <FL/Fl Bitmap.H>
#include <FL/Fl Pixmap.H>
#include <FL/Fl RGB Image.H>
#include <stdlib.h>
32.13. FL DEVICE.H FILE REFERENCE 915

Classes
• class Fl Device
All graphical output devices and all graphics systems.
• class Fl Device Plugin
This plugin socket allows the integration of new device drivers for special window or screen types.
• class Fl Display Device
A display to which the computer can draw.
• class Fl GDI Graphics Driver
The MSWindows-specific graphics class.
• class Fl GDI Printer Graphics Driver
The graphics driver used when printing on MSWindows.
• class Fl Graphics Driver
A virtual class subclassed for each graphics driver FLTK uses.
• class Fl Quartz Graphics Driver
The Mac OS X-specific graphics class.
• class Fl Surface Device
A surface that’s susceptible to receive graphical output.
• class Fl Xlib Graphics Driver
The Xlib-specific graphics class.
• struct Fl Graphics Driver::matrix
A 2D coordinate transformation matrix.

Macros
• #define FL MATRIX STACK SIZE 32
• #define FL REGION STACK SIZE 10
• #define XPOINT XPoint

Typedefs
• typedef short COORD T
• typedef void(∗ Fl Draw Image Cb )(void ∗data, int x, int y, int w, uchar ∗buf)
signature of image generation callback function.

Variables
• FL EXPORT Fl Graphics Driver ∗ fl graphics driver
Points to the driver that currently receives all graphics requests.

32.13.1 Detailed Description


declaration of classes Fl Device, Fl Graphics Driver, Fl Surface Device, Fl Display Device, Fl Device -
Plugin.

32.13.2 Typedef Documentation


typedef void(∗ Fl Draw Image Cb)(void ∗data, int x, int y, int w, uchar ∗buf)
signature of image generation callback function.
916 CHAPTER 32. FILE DOCUMENTATION

Parameters
in data user data passed to function
in x,y,w position and width of scan line in image
out buf buffer for generated image data. You must copy w pixels from scanline
y, starting at pixel x to this buffer.

32.14 Fl Double Window.cxx File Reference


Fl Double Window implementation.
#include <config.h>
#include <FL/Fl.H>
#include <FL/Fl Double Window.H>
#include <FL/Fl Overlay Window.H>
#include <FL/Fl Printer.H>
#include <FL/x.H>
#include <FL/fl draw.H>

Functions
• void fl begin offscreen (Fl Offscreen ctx)
Send all subsequent drawing commands to this offscreen buffer.
• char fl can do alpha blending ()
Checks whether platform supports true alpha blending for RGBA images.
• void fl copy offscreen (int x, int y, int w, int h, Fl Offscreen pixmap, int srcx, int srcy)
Copy a rectangular area of the given offscreen buffer into the current drawing destination.
• Fl Offscreen fl create offscreen (int w, int h)
Creation of an offscreen graphics buffer.
• void fl delete offscreen (Fl Offscreen ctx)
Deletion of an offscreen graphics buffer.
• void fl end offscreen ()
Quit sending drawing commands to the current offscreen buffer.

Variables
• const int stack max = 16

32.14.1 Detailed Description


Fl Double Window implementation.

32.15 fl draw.H File Reference


utility header to pull drawing functions together
#include <FL/x.H>
#include <FL/Enumerations.H>
#include <FL/Fl Window.H>
#include <FL/Fl Device.H>
32.15. FL DRAW.H FILE REFERENCE 917

Macros
• #define fl clip fl push clip
Intersects the current clip region with a rectangle and pushes this new region onto the stack (deprecated).

Enumerations
• enum {
FL SOLID = 0, FL DASH = 1, FL DOT = 2, FL DASHDOT = 3,
FL DASHDOTDOT = 4, FL CAP FLAT = 0x100, FL CAP ROUND = 0x200, FL CAP SQUARE
= 0x300,
FL JOIN MITER = 0x1000, FL JOIN ROUND = 0x2000, FL JOIN BEVEL = 0x3000 }

Functions
• FL EXPORT int fl add symbol (const char ∗name, void(∗drawit)(Fl Color), int scalable)
Adds a symbol to the system.
• void fl arc (int x, int y, int w, int h, double a1, double a2)
Draw ellipse sections using integer coordinates.
• void fl arc (double x, double y, double r, double start, double end)
Adds a series of points to the current path on the arc of a circle.
• void fl begin complex polygon ()
Starts drawing a complex filled polygon.
• void fl begin line ()
Starts drawing a list of lines.
• void fl begin loop ()
Starts drawing a closed sequence of lines.
• void fl begin points ()
Starts drawing a list of points.
• void fl begin polygon ()
Starts drawing a convex filled polygon.
• FL EXPORT char fl can do alpha blending ()
Checks whether platform supports true alpha blending for RGBA images.
• FL EXPORT void fl chord (int x, int y, int w, int h, double a1, double a2)
fl chord declaration is a place holder - the function does not yet exist
• void fl circle (double x, double y, double r)
fl circle() is equivalent to fl arc(x,y,r,0,360), but may be faster.
• int fl clip box (int x, int y, int w, int h, int &X, int &Y, int &W, int &H)
Intersects the rectangle with the current clip region and returns the bounding box of the result.
• void fl clip region (Fl Region r)
Replaces the top of the clipping stack with a clipping region of any shape.
• Fl Region fl clip region ()
Returns the current clipping region.
• void fl color (Fl Color c)
Sets the color for all subsequent drawing operations.
• void fl color (int c)
for back compatibility - use fl color(Fl Color c) instead
• void fl color (uchar r, uchar g, uchar b)
Sets the color for all subsequent drawing operations.
918 CHAPTER 32. FILE DOCUMENTATION

• Fl Color fl color ()
Returns the last fl color() that was set.
• FL EXPORT void fl cursor (Fl Cursor)
Sets the cursor for the current window to the specified shape and colors.
• FL EXPORT void fl cursor (Fl Cursor, Fl Color fg, Fl Color bg=FL WHITE)
• void fl curve (double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3,
double Y3)
Adds a series of points on a Bezier curve to the path.
• int fl descent ()
Returns the recommended distance above the bottom of a fl height() tall box to draw the text at so it looks
centered vertically in that box.
• FL EXPORT void fl draw (const char ∗str, int x, int y)
Draws a nul-terminated UTF-8 string starting at the given x, y location.
• FL EXPORT void fl draw (int angle, const char ∗str, int x, int y)
Draws a nul-terminated UTF-8 string starting at the given x, y location and rotating angle degrees
counter-clockwise.
• void fl draw (const char ∗str, int n, int x, int y)
Draws starting at the given x, y location a UTF-8 string of length n bytes.
• void fl draw (int angle, const char ∗str, int n, int x, int y)
Draws at the given x, y location a UTF-8 string of length n bytes rotating angle degrees counter-
clockwise.
• FL EXPORT void fl draw (const char ∗str, int x, int y, int w, int h, Fl Align align, Fl Image ∗img=0,
int draw symbols=1)
Fancy string drawing function which is used to draw all the labels.
• FL EXPORT void fl draw (const char ∗str, int x, int y, int w, int h, Fl Align align, void(∗callthis)(const
char ∗, int, int, int), Fl Image ∗img=0, int draw symbols=1)
The same as fl draw(const char∗,int,int,int,int,Fl Align,Fl Image∗,int) with the addition of the callthis
parameter, which is a pointer to a text drawing function such as fl draw(const char∗, int, int, int) to do the
real work.
• FL EXPORT void fl draw box (Fl Boxtype, int x, int y, int w, int h, Fl Color)
Draws a box using given type, position, size and color.
• void fl draw image (const uchar ∗buf, int X, int Y, int W, int H, int D=3, int L=0)
Draws an 8-bit per color RGB or luminance image.
• void fl draw image (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=3)
Draws an image using a callback function to generate image data.
• void fl draw image mono (const uchar ∗buf, int X, int Y, int W, int H, int D=1, int L=0)
Draws a gray-scale (1 channel) image.
• void fl draw image mono (Fl Draw Image Cb cb, void ∗data, int X, int Y, int W, int H, int D=1)
Draws a gray-scale image using a callback function to generate image data.
• FL EXPORT int fl draw pixmap (char ∗const ∗data, int x, int y, Fl Color=FL GRAY)
Draw XPM image data, with the top-left corner at the given position.
• FL EXPORT int fl draw pixmap (const char ∗const ∗cdata, int x, int y, Fl Color=FL GRAY)
Draw XPM image data, with the top-left corner at the given position.
• FL EXPORT int fl draw symbol (const char ∗label, int x, int y, int w, int h, Fl Color)
Draw the named symbol in the given rectangle using the given color.
• void fl end complex polygon ()
Ends complex filled polygon, and draws.
• void fl end line ()
32.15. FL DRAW.H FILE REFERENCE 919

Ends list of lines, and draws.


• void fl end loop ()
Ends closed sequence of lines, and draws.
• void fl end points ()
Ends list of points, and draws.
• void fl end polygon ()
Ends convex filled polygon, and draws.
• FL EXPORT const char ∗ fl expand text (const char ∗from, char ∗buf, int maxbuf, double maxw, int
&n, double &width, int wrap, int draw symbols=0)
Copy from to buf, replacing control characters with ∧ X.
• void fl font (Fl Font face, Fl Fontsize fsize)
Sets the current font, which is then used in various drawing routines.
• Fl Font fl font ()
Returns the face set by the most recent call to fl font().
• FL EXPORT void fl frame (const char ∗s, int x, int y, int w, int h)
Draws a series of line segments around the given box.
• FL EXPORT void fl frame2 (const char ∗s, int x, int y, int w, int h)
Draws a series of line segments around the given box.
• void fl gap ()
Call fl gap() to separate loops of the path.
• int fl height ()
Returns the recommended minimum line spacing for the current font.
• FL EXPORT int fl height (int font, int size)
This function returns the actual height of the specified font and size.
• FL EXPORT const char ∗ fl latin1 to local (const char ∗t, int n=-1)
Converts text from Windows/X11 latin1 character set to local encoding.
• void fl line (int x, int y, int x1, int y1)
Draws a line from (x,y) to (x1,y1)
• void fl line (int x, int y, int x1, int y1, int x2, int y2)
Draws a line from (x,y) to (x1,y1) and another from (x1,y1) to (x2,y2)
• void fl line style (int style, int width=0, char ∗dashes=0)
Sets how to draw lines (the ”pen”).
• FL EXPORT const char ∗ fl local to latin1 (const char ∗t, int n=-1)
Converts text from local encoding to Windowx/X11 latin1 character set.
• FL EXPORT const char ∗ fl local to mac roman (const char ∗t, int n=-1)
Converts text from local encoding to Mac Roman character set.
• void fl loop (int x, int y, int x1, int y1, int x2, int y2)
Outlines a 3-sided polygon with lines.
• void fl loop (int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
Outlines a 4-sided polygon with lines.
• FL EXPORT const char ∗ fl mac roman to local (const char ∗t, int n=-1)
Converts text from Mac Roman character set to local encoding.
• FL EXPORT void fl measure (const char ∗str, int &x, int &y, int draw symbols=1)
Measure how wide and tall the string will be when printed by the fl draw() function with align parameter.
• FL EXPORT int fl measure pixmap (char ∗const ∗data, int &w, int &h)
Get the dimensions of a pixmap.
• FL EXPORT int fl measure pixmap (const char ∗const ∗cdata, int &w, int &h)
920 CHAPTER 32. FILE DOCUMENTATION

Get the dimensions of a pixmap.


• void fl mult matrix (double a, double b, double c, double d, double x, double y)
Concatenates another transformation onto the current one.
• int fl not clipped (int x, int y, int w, int h)
Does the rectangle intersect the current clip region?
• FL EXPORT unsigned int fl old shortcut (const char ∗s)
Emulation of XForms named shortcuts.
• FL EXPORT void fl overlay clear ()
Erase a selection rectangle without drawing a new one.
• FL EXPORT void fl overlay rect (int x, int y, int w, int h)
Draws a selection rectangle, erasing a previous one by XOR’ing it first.
• void fl pie (int x, int y, int w, int h, double a1, double a2)
Draw filled ellipse sections using integer coordinates.
• void fl point (int x, int y)
Draws a single pixel at the given coordinates.
• void fl polygon (int x, int y, int x1, int y1, int x2, int y2)
Fills a 3-sided polygon.
• void fl polygon (int x, int y, int x1, int y1, int x2, int y2, int x3, int y3)
Fills a 4-sided polygon.
• void fl pop clip ()
Restores the previous clip region.
• void fl pop matrix ()
Restores the current transformation matrix from the stack.
• void fl push clip (int x, int y, int w, int h)
Intersects the current clip region with a rectangle and pushes this new region onto the stack.
• void fl push matrix ()
Saves the current transformation matrix on the stack.
• void fl push no clip ()
Pushes an empty clip region onto the stack so nothing will be clipped.
• FL EXPORT uchar ∗ fl read image (uchar ∗p, int X, int Y, int W, int H, int alpha=0)
Reads an RGB(A) image from the current window or off-screen buffer.
• void fl rect (int x, int y, int w, int h)
Draws a 1-pixel border inside the given bounding box.
• void fl rect (int x, int y, int w, int h, Fl Color c)
Draws with passed color a 1-pixel border inside the given bounding box.
• void fl rectf (int x, int y, int w, int h)
Colors with current color a rectangle that exactly fills the given bounding box.
• void fl rectf (int x, int y, int w, int h, Fl Color c)
Colors with passed color a rectangle that exactly fills the given bounding box.
• FL EXPORT void fl rectf (int x, int y, int w, int h, uchar r, uchar g, uchar b)
Colors a rectangle with ”exactly” the passed r,g,b color.
• FL EXPORT void fl reset spot (void)
• void fl restore clip ()
Undoes any clobbering of clip done by your program.
• void fl rotate (double d)
Concatenates rotation transformation onto the current one.
• void fl rtl draw (const char ∗str, int n, int x, int y)
32.15. FL DRAW.H FILE REFERENCE 921

Draws a UTF-8 string of length n bytes right to left starting at the given x, y location.
• void fl scale (double x, double y)
Concatenates scaling transformation onto the current one.
• void fl scale (double x)
Concatenates scaling transformation onto the current one.
• FL EXPORT void fl scroll (int X, int Y, int W, int H, int dx, int dy, void(∗draw area)(void ∗, int, int,
int, int), void ∗data)
Scroll a rectangle and draw the newly exposed portions.
• FL EXPORT void fl set spot (int font, int size, int X, int Y, int W, int H, Fl Window ∗win=0)
• FL EXPORT void fl set status (int X, int Y, int W, int H)
• FL EXPORT const char ∗ fl shortcut label (unsigned int shortcut)
Get a human-readable string from a shortcut value.
• FL EXPORT const char ∗ fl shortcut label (unsigned int shortcut, const char ∗∗eom)
Get a human-readable string from a shortcut value.
• Fl Fontsize fl size ()
Returns the size set by the most recent call to fl font().
• FL EXPORT void fl text extents (const char ∗, int &dx, int &dy, int &w, int &h)
Determines the minimum pixel dimensions of a nul-terminated string.
• void fl text extents (const char ∗t, int n, int &dx, int &dy, int &w, int &h)
Determines the minimum pixel dimensions of a sequence of n characters.
• double fl transform dx (double x, double y)
Transforms distance using current transformation matrix.
• double fl transform dy (double x, double y)
Transforms distance using current transformation matrix.
• double fl transform x (double x, double y)
Transforms coordinate using the current transformation matrix.
• double fl transform y (double x, double y)
Transforms coordinate using the current transformation matrix.
• void fl transformed vertex (double xf, double yf)
Adds coordinate pair to the vertex list without further transformations.
• void fl translate (double x, double y)
Concatenates translation transformation onto the current one.
• void fl vertex (double x, double y)
Adds a single vertex to the current path.
• FL EXPORT double fl width (const char ∗txt)
Returns the typographical width of a nul-terminated string using the current font face and size.
• double fl width (const char ∗txt, int n)
Returns the typographical width of a sequence of n characters using the current font face and size.
• double fl width (unsigned int c)
Returns the typographical width of a single character using the current font face and size.
• void fl xyline (int x, int y, int x1)
Draws a horizontal line from (x,y) to (x1,y)
• void fl xyline (int x, int y, int x1, int y2)
Draws a horizontal line from (x,y) to (x1,y), then vertical from (x1,y) to (x1,y2)
• void fl xyline (int x, int y, int x1, int y2, int x3)
Draws a horizontal line from (x,y) to (x1,y), then a vertical from (x1,y) to (x1,y2) and then another horizontal
from (x1,y2) to (x3,y2)
922 CHAPTER 32. FILE DOCUMENTATION

• void fl yxline (int x, int y, int y1)


Draws a vertical line from (x,y) to (x,y1)
• void fl yxline (int x, int y, int y1, int x2)
Draws a vertical line from (x,y) to (x,y1), then a horizontal from (x,y1) to (x2,y1)
• void fl yxline (int x, int y, int y1, int x2, int y3)
Draws a vertical line from (x,y) to (x,y1) then a horizontal from (x,y1) to (x2,y1), then another vertical from
(x2,y1) to (x2,y3)

Variables
• FL EXPORT char fl draw shortcut

32.15.1 Detailed Description


utility header to pull drawing functions together

32.16 Fl Image.H File Reference


Fl Image, Fl RGB Image classes.
#include "Enumerations.H"
#include <stdlib.h>

Classes
• class Fl Image
Fl Image is the base class used for caching and drawing all kinds of images in FLTK.
• class Fl RGB Image
The Fl RGB Image class supports caching and drawing of full-color images with 1 to 4 channels of color
information.

Enumerations
• enum Fl RGB Scaling { FL RGB SCALING NEAREST = 0, FL RGB SCALING BILINEAR }
The scaling algorithm to use for RGB images.

32.16.1 Detailed Description


Fl Image, Fl RGB Image classes.

32.16.2 Enumeration Type Documentation


enum Fl RGB Scaling
The scaling algorithm to use for RGB images.

Enumerator
FL RGB SCALING NEAREST default RGB image scaling algorithm
FL RGB SCALING BILINEAR more accurate, but slower RGB image scaling algorithm
32.17. FL LINE STYLE.CXX FILE REFERENCE 923

32.17 fl line style.cxx File Reference


Line style drawing utility hiding different platforms.
#include <FL/Fl.H>
#include <FL/fl draw.H>
#include <FL/x.H>
#include <FL/Fl Printer.H>
#include "flstring.h"
#include <stdio.h>

Variables
• int fl line width = 0

32.17.1 Detailed Description


Line style drawing utility hiding different platforms.

32.18 Fl Native File Chooser.H File Reference


Fl Native File Chooser widget.
#include <FL/Fl File Chooser.H>
#include <unistd.h>

Classes
• class Fl FLTK File Chooser
• class Fl GTK File Chooser
• class Fl Native File Chooser
This class lets an FLTK application easily and consistently access the operating system’s native file chooser.

32.18.1 Detailed Description


Fl Native File Chooser widget.

32.19 Fl Paged Device.cxx File Reference


implementation of class Fl Paged Device.
#include <FL/Fl Paged Device.H>
#include <FL/Fl.H>
#include <FL/fl draw.H>

32.19.1 Detailed Description


implementation of class Fl Paged Device.
924 CHAPTER 32. FILE DOCUMENTATION

32.20 Fl Paged Device.H File Reference


declaration of class Fl Paged Device.
#include <FL/Fl Device.H>
#include <FL/Fl Window.H>

Classes
• class Fl Paged Device
Represents page-structured drawing surfaces.
• struct Fl Paged Device::page format
width, height and name of a page format

Macros
• #define NO PAGE FORMATS 30 /∗ MSVC6 compilation fix ∗/
Number of elements in enum Page Format.

32.20.1 Detailed Description


declaration of class Fl Paged Device.

32.21 Fl PostScript.H File Reference


declaration of classes Fl PostScript Graphics Driver, Fl PostScript File Device.
#include <FL/Fl Paged Device.H>
#include <FL/fl draw.H>
#include <stdarg.h>

Classes
• class Fl PostScript File Device
To send graphical output to a PostScript file.
• class Fl PostScript Graphics Driver

Typedefs
• typedef int( Fl PostScript Close Command )(FILE ∗)
PostScript graphical backend.

32.21.1 Detailed Description


declaration of classes Fl PostScript Graphics Driver, Fl PostScript File Device.
32.21. FL POSTSCRIPT.H FILE REFERENCE 925

32.21.2 Typedef Documentation


typedef int( Fl PostScript Close Command)(FILE ∗)
PostScript graphical backend.
PostScript text uses vectorial fonts when using the FLTK standard fonts and the latin alphabet or a
few other characters listed in the following table. The latin alphabet means all unicode characters between
U+0020 and U+017F, or, in other words, the ASCII, Latin-1 Supplement and Latin Extended-A charts.
926 CHAPTER 32. FILE DOCUMENTATION

Char Code- Name Char Code- Name Char Code- Name


point point point
ƒ U+0192 florin U+201- ™ U+2122 trade-
A quotesinglbase mark
ˆ U+02C6 circum- “ U+201C quoted- U+2202 partiald-
flex blleft iff
ˇ U+02C7 caron ” U+201- quoted- U+2206 Delta
D blright
˘ U+02- breve U+201E quoted- U+2211 summa-
D8 blbase tion
U+02- dotac- † U+2020 dagger U+221- radical
D9 cent A
U+02D- ring ‡ U+2021 dag- U+221E infinity
A gerdbl
U+02D- ogonek • U+2022 bullet U+2260 notequal
B
˜ U+02D- tilde ... U+2026 ellipsis U+2264 lesse-
C qual
´´ U+02D- hun- ‰ U+2030 perthou- U+2265
D garum- sand greaterequal
laut
– U+2013 endash U+2039 guils- U+25C- lozenge
inglleft A
— U+2014 emdash U+203- guils- U+F- fi
A inglright B01
‘ U+2018 / U+2044 fraction U+F- fl
quoteleft B02
’ U+2019 quo- C U+20A- Euro U+F8FF apple
teright C (Mac
OS
only)
All other unicode characters or all other fonts (FL FREE FONT and above) are output as a bitmap.
FLTK standard fonts are output using the corresponding PostScript standard fonts.Signature of Fl Post-
Script::close command() functions passed as parameters.

32.22 Fl Printer.H File Reference


declaration of classes Fl Printer, Fl System Printer and Fl PostScript Printer.
#include <FL/x.H>
#include <FL/Fl Paged Device.H>
#include <FL/fl draw.H>
#include <FL/Fl Pixmap.H>
#include <FL/Fl RGB Image.H>
#include <FL/Fl Bitmap.H>
#include <stdio.h>
#include <FL/Fl PostScript.H>

Classes
• class Fl PostScript Printer
Print support under Unix/Linux.
• class Fl Printer
32.23. FL RECT.CXX FILE REFERENCE 927

OS-independent print support.


• class Fl System Printer
Print support under MSWindows and Mac OS.

32.22.1 Detailed Description


declaration of classes Fl Printer, Fl System Printer and Fl PostScript Printer.

32.23 fl rect.cxx File Reference


Drawing and clipping routines for rectangles.
#include <config.h>
#include <FL/Fl.H>
#include <FL/Fl Widget.H>
#include <FL/Fl Printer.H>
#include <FL/fl draw.H>
#include <FL/x.H>

Functions
• Fl Region XRectangleRegion (int x, int y, int w, int h)

Variables
• int fl line width

32.23.1 Detailed Description


Drawing and clipping routines for rectangles.

32.24 Fl Shared Image.H File Reference


Fl Shared Image class.
#include "Fl Image.H"

Classes
• class Fl Shared Image
This class supports caching, loading, and drawing of image files.

Typedefs
• typedef Fl Image ∗(∗ Fl Shared Handler )(const char ∗name, uchar ∗header, int headerlen)

Functions
• FL EXPORT void fl register images ()
Register the image formats.
928 CHAPTER 32. FILE DOCUMENTATION

32.24.1 Detailed Description


Fl Shared Image class.

32.24.2 Function Documentation


FL EXPORT void fl register images ( )
Register the image formats.
This function is provided in the fltk images library and registers all of the ”extra” image file formats
that are not part of the core FLTK library.

32.25 fl show colormap.H File Reference


The fl show colormap() function hides the implementation classes used to provide the popup window and
color selection mechanism.

Functions
• FL EXPORT Fl Color fl show colormap (Fl Color oldcol)
Pops up a window to let the user pick a colormap entry.

32.25.1 Detailed Description


The fl show colormap() function hides the implementation classes used to provide the popup window and
color selection mechanism.

32.26 Fl Tree.H File Reference


This file contains the definitions of the Fl Tree class.
#include <FL/Fl.H>
#include <FL/Fl Group.H>
#include <FL/Fl Scrollbar.H>
#include <FL/fl draw.H>
#include <FL/Fl Tree Item.H>
#include <FL/Fl Tree Prefs.H>

Classes
• class Fl Tree
Tree widget.

Enumerations
• enum Fl Tree Reason {
FL TREE REASON NONE =0, FL TREE REASON SELECTED, FL TREE REASON DESEL-
ECTED, FL TREE REASON OPENED,
FL TREE REASON CLOSED, FL TREE REASON DRAGGED }
The reason the callback was invoked.
32.27. FL TREE ITEM.H FILE REFERENCE 929

32.26.1 Detailed Description


This file contains the definitions of the Fl Tree class.

32.26.2 Enumeration Type Documentation


enum Fl Tree Reason
The reason the callback was invoked.
Enumerator
FL TREE REASON NONE unknown reason
FL TREE REASON SELECTED an item was selected
FL TREE REASON DESELECTED an item was de-selected
FL TREE REASON OPENED an item was opened
FL TREE REASON CLOSED an item was closed
FL TREE REASON DRAGGED an item was dragged into a new place

32.27 Fl Tree Item.H File Reference


This file contains the definitions for Fl Tree Item.
#include <FL/Fl.H>
#include <FL/Fl Widget.H>
#include <FL/Fl Image.H>
#include <FL/fl draw.H>
#include <FL/Fl Tree Item Array.H>
#include <FL/Fl Tree Prefs.H>

Classes
• class Fl Tree Item
Tree widget item.

32.27.1 Detailed Description


This file contains the definitions for Fl Tree Item.

32.28 Fl Tree Item Array.H File Reference


This file defines a class that manages an array of Fl Tree Item pointers.
#include <FL/Fl.H>
#include "Fl Export.H"

Classes
• class Fl Tree Item Array
Manages an array of Fl Tree Item pointers.
930 CHAPTER 32. FILE DOCUMENTATION

Variables
• class FL EXPORT Fl Tree Item

32.28.1 Detailed Description


This file defines a class that manages an array of Fl Tree Item pointers.

32.29 Fl Tree Prefs.H File Reference


This file contains the definitions for Fl Tree’s preferences.
#include <FL/Fl.H>

Classes
• class Fl Tree Prefs
Tree widget’s preferences.

Enumerations
• enum Fl Tree Connector { FL TREE CONNECTOR NONE =0, FL TREE CONNECTOR DOT-
TED =1, FL TREE CONNECTOR SOLID =2 }
Defines the style of connection lines between items.
• enum Fl Tree Select { FL TREE SELECT NONE =0, FL TREE SELECT SINGLE =1, FL TRE-
E SELECT MULTI =2, FL TREE SELECT SINGLE DRAGGABLE =3 }
Tree selection style.
• enum Fl Tree Sort { FL TREE SORT NONE =0, FL TREE SORT ASCENDING =1, FL TREE -
SORT DESCENDING =2 }
Sort order options for items added to the tree.

32.29.1 Detailed Description


This file contains the definitions for Fl Tree’s preferences.
Fl Tree Prefs
:
.....:.......
: :
Fl Tree :
| Fl Tree Item

32.29.2 Enumeration Type Documentation


enum Fl Tree Connector
Defines the style of connection lines between items.

Enumerator
FL TREE CONNECTOR NONE Use no lines connecting items.
FL TREE CONNECTOR DOTTED Use dotted lines connecting items (default)
FL TREE CONNECTOR SOLID Use solid lines connecting items.
32.30. FL TYPES.H FILE REFERENCE 931

enum Fl Tree Select


Tree selection style.
Enumerator
FL TREE SELECT NONE Nothing selected when items are clicked.
FL TREE SELECT SINGLE Single item selected when item is clicked (default)
FL TREE SELECT MULTI Multiple items can be selected by clicking with SHIFT, CTRL or mouse
drags.
FL TREE SELECT SINGLE DRAGGABLE Single items may be selected, and they may be. re-
ordered by mouse drag.

enum Fl Tree Sort


Sort order options for items added to the tree.
Enumerator
FL TREE SORT NONE No sorting; items are added in the order defined (default).
FL TREE SORT ASCENDING Add items in ascending sort order.
FL TREE SORT DESCENDING Add items in descending sort order.

32.30 fl types.h File Reference


This file contains simple ”C”-style type definitions.

Typedefs
Miscellaneous
• typedef unsigned char uchar
unsigned char
• typedef unsigned long ulong
unsigned long
• typedef char ∗ Fl String
Flexible length utf8 Unicode text.
• typedef const char ∗ Fl CString
Flexible length utf8 Unicode read-only string.
• typedef unsigned int Fl Shortcut
24-bit Unicode character + 8-bit indicator for keyboard flags
• typedef unsigned int Fl Char
24-bit Unicode character - upper 8-bits are unused

32.30.1 Detailed Description


This file contains simple ”C”-style type definitions.

32.30.2 Typedef Documentation


typedef const char∗ Fl CString
Flexible length utf8 Unicode read-only string.
See Also
Fl String
932 CHAPTER 32. FILE DOCUMENTATION

typedef char∗ Fl String


Flexible length utf8 Unicode text.

Todo FIXME: temporary (?) typedef to mark UTF8 and Unicode conversions

32.31 fl utf8.h File Reference


header for Unicode and UTF8 chracter handling
#include "Fl Export.H"
#include "fl types.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <X11/Xlocale.h>
#include <X11/Xlib.h>
#include <locale.h>

Macros
• #define xchar unsigned short

Functions
• FL EXPORT int fl access (const char ∗f, int mode)
• FL EXPORT int fl chmod (const char ∗f, int mode)
• FL EXPORT int fl execvp (const char ∗file, char ∗const ∗argv)
• FL EXPORT FILE ∗ fl fopen (const char ∗f, const char ∗mode)
Cross-platform function to open files with a UTF-8 encoded name.
• FL EXPORT char ∗ fl getcwd (char ∗buf, int maxlen)
• FL EXPORT char ∗ fl getenv (const char ∗name)
• FL EXPORT char fl make path (const char ∗path)
• FL EXPORT void fl make path for file (const char ∗path)
• FL EXPORT int fl mkdir (const char ∗f, int mode)
• FL EXPORT unsigned int fl nonspacing (unsigned int ucs)
returns true if the character is non-spacing.
• FL EXPORT int fl open (const char ∗f, int oflags,...)
Cross-platform function to open files with a UTF-8 encoded name.
• FL EXPORT int fl rename (const char ∗f, const char ∗t)
• FL EXPORT int fl rmdir (const char ∗f)
• FL EXPORT int fl stat (const char ∗path, struct stat ∗buffer)
• FL EXPORT int fl system (const char ∗f)
• FL EXPORT int fl tolower (unsigned int ucs)
return the Unicode lower case value of ucs
• FL EXPORT int fl toupper (unsigned int ucs)
return the Unicode upper case value of ucs
• FL EXPORT unsigned fl ucs to Utf16 (const unsigned ucs, unsigned short ∗dst, const unsigned
dstlen)
32.31. FL UTF8.H FILE REFERENCE 933

• FL EXPORT int fl unlink (const char ∗f)


• FL EXPORT char ∗ fl utf2mbcs (const char ∗s)
converts UTF8 to a local multi-byte character string.
• FL EXPORT const char ∗ fl utf8back (const char ∗p, const char ∗start, const char ∗end)
• FL EXPORT int fl utf8bytes (unsigned ucs)
Return the number of bytes needed to encode the given UCS4 character in UTF8.
• FL EXPORT unsigned fl utf8decode (const char ∗p, const char ∗end, int ∗len)
• FL EXPORT int fl utf8encode (unsigned ucs, char ∗buf)
• FL EXPORT unsigned fl utf8from mb (char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen)
• FL EXPORT unsigned fl utf8froma (char ∗dst, unsigned dstlen, const char ∗src, unsigned srclen)
• FL EXPORT unsigned fl utf8fromwc (char ∗dst, unsigned dstlen, const wchar t ∗src, unsigned sr-
clen)
• FL EXPORT const char ∗ fl utf8fwd (const char ∗p, const char ∗start, const char ∗end)
• FL EXPORT int fl utf8len (char c)
return the byte length of the UTF-8 sequence with first byte c, or -1 if c is not valid.
• FL EXPORT int fl utf8len1 (char c)
Return the byte length of the UTF-8 sequence with first byte c, or 1 if c is not valid.
• FL EXPORT int fl utf8locale ()
• FL EXPORT int fl utf8test (const char ∗src, unsigned len)
• FL EXPORT unsigned fl utf8to mb (const char ∗src, unsigned srclen, char ∗dst, unsigned dstlen)
• FL EXPORT unsigned fl utf8toa (const char ∗src, unsigned srclen, char ∗dst, unsigned dstlen)
• FL EXPORT unsigned fl utf8toUtf16 (const char ∗src, unsigned srclen, unsigned short ∗dst, un-
signed dstlen)
• FL EXPORT unsigned fl utf8towc (const char ∗src, unsigned srclen, wchar t ∗dst, unsigned dstlen)
Converts a UTF-8 string into a wide character string.
• FL EXPORT int fl utf nb char (const unsigned char ∗buf, int len)
returns the number of Unicode chars in the UTF-8 string
• FL EXPORT int fl utf strcasecmp (const char ∗s1, const char ∗s2)
UTF-8 aware strcasecmp - converts to Unicode and tests.
• FL EXPORT int fl utf strncasecmp (const char ∗s1, const char ∗s2, int n)
UTF-8 aware strncasecmp - converts to lower case Unicode and tests.
• FL EXPORT int fl utf tolower (const unsigned char ∗str, int len, char ∗buf)
converts the str string to the lower case equivalent into buf.
• FL EXPORT int fl utf toupper (const unsigned char ∗str, int len, char ∗buf)
converts the str string to the upper case equivalent into buf.
• FL EXPORT int fl wcwidth (const char ∗src)
extended wrapper around fl wcwidth (unsigned int ucs) function.
• FL EXPORT int fl wcwidth (unsigned int ucs)
wrapper to adapt Markus Kuhn’s implementation of wcwidth() for FLTK

32.31.1 Detailed Description


header for Unicode and UTF8 chracter handling
934 CHAPTER 32. FILE DOCUMENTATION

32.32 fl vertex.cxx File Reference


Portable drawing code for drawing arbitrary shapes with simple 2D transformations.
#include <config.h>
#include <FL/fl draw.H>
#include <FL/x.H>
#include <FL/Fl.H>
#include <FL/math.h>
#include <stdlib.h>

32.32.1 Detailed Description


Portable drawing code for drawing arbitrary shapes with simple 2D transformations.

32.33 Fl Widget.H File Reference


Fl Widget, Fl Label classes .
#include "Enumerations.H"

Classes
• struct Fl Label
This struct stores all information for a text or mixed graphics label.
• class Fl Widget
Fl Widget is the base class for all widgets in FLTK.

Macros
• #define FL RESERVED TYPE 100
Reserved type numbers (necessary for my cheapo RTTI) start here.

Typedefs
• typedef void( Fl Callback )(Fl Widget ∗, void ∗)
Default callback type definition for all fltk widgets (by far the most used)
• typedef void( Fl Callback0 )(Fl Widget ∗)
One parameter callback type definition passing only the widget.
• typedef void( Fl Callback1 )(Fl Widget ∗, long)
Callback type definition passing the widget and a long data value.
• typedef Fl Callback ∗ Fl Callback p
Default callback type pointer definition for all fltk widgets.
• typedef long fl intptr t
• typedef unsigned long fl uintptr t

32.33.1 Detailed Description


Fl Widget, Fl Label classes .
32.34. FL WINDOW.H FILE REFERENCE 935

32.33.2 Macro Definition Documentation


#define FL RESERVED TYPE 100
Reserved type numbers (necessary for my cheapo RTTI) start here.
Grep the header files for ”RESERVED TYPE” to find the next available number.

32.33.3 Typedef Documentation


typedef long fl intptr t
Todo typedef’s fl intptr t and fl uintptr t should be documented.

32.34 Fl Window.H File Reference


Fl Window widget .
#include "Fl Group.H"
#include "Fl Bitmap.H"
#include <stdlib.h>

Classes
• class Fl Window
This widget produces an actual window.
• struct Fl Window::shape data type
Data supporting a non-rectangular window shape.

Macros
• #define FL DOUBLE WINDOW 0xF1
double window type id
• #define FL WINDOW 0xF0
window type id all subclasses have type() >= this

32.34.1 Detailed Description


Fl Window widget .

32.35 gl.h File Reference


This file defines wrapper functions for OpenGL in FLTK.
#include "Enumerations.H"
#include <GL/gl.h>

Functions
• FL EXPORT void gl color (Fl Color i)
Sets the curent OpenGL color to an FLTK color.
• void gl color (int c)
back compatibility
936 CHAPTER 32. FILE DOCUMENTATION

• FL EXPORT int gl descent ()


Returns the current font’s descent.
• FL EXPORT void gl draw (const char ∗)
Draws a nul-terminated string in the current font at the current position.
• FL EXPORT void gl draw (const char ∗, int n)
Draws an array of n characters of the string in the current font at the current position.
• FL EXPORT void gl draw (const char ∗, int x, int y)
Draws a nul-terminated string in the current font at the given position.
• FL EXPORT void gl draw (const char ∗, float x, float y)
Draws a nul-terminated string in the current font at the given position.
• FL EXPORT void gl draw (const char ∗, int n, int x, int y)
Draws n characters of the string in the current font at the given position.
• FL EXPORT void gl draw (const char ∗, int n, float x, float y)
Draws n characters of the string in the current font at the given position.
• FL EXPORT void gl draw (const char ∗, int x, int y, int w, int h, Fl Align)
Draws a string formatted into a box, with newlines and tabs expanded, other control characters changed to

X.
• FL EXPORT void gl draw image (const uchar ∗, int x, int y, int w, int h, int d=3, int ld=0)
• FL EXPORT void gl finish ()
Releases an OpenGL context.
• FL EXPORT void gl font (int fontid, int size)
Sets the current OpenGL font to the same font as calling fl font()
• FL EXPORT int gl height ()
Returns the current font’s height.
• FL EXPORT void gl measure (const char ∗, int &x, int &y)
Measure how wide and tall the string will be when drawn by the gl draw() function.
• FL EXPORT void gl rect (int x, int y, int w, int h)
Outlines the given rectangle with the current color.
• void gl rectf (int x, int y, int w, int h)
Fills the given rectangle with the current color.
• FL EXPORT void gl start ()
Creates an OpenGL context.
• FL EXPORT double gl width (const char ∗)
Returns the width of the string in the current fnt.
• FL EXPORT double gl width (const char ∗, int n)
Returns the width of n characters of the string in the current font.
• FL EXPORT double gl width (uchar)
Returns the width of the character in the current font.

32.35.1 Detailed Description


This file defines wrapper functions for OpenGL in FLTK. To use OpenGL from within an FLTK application
you MUST use gl visual() to select the default visual before doing show() on any windows. Mesa will crash
if yoy try to use a visual not returned by glxChooseVidual.
This does not work with Fl Double Window’s! It will try to draw into the front buffer. Depending on
the system this will either crash or do nothing (when pixmaps are being used as back buffer and GL is
being done by hardware), work correctly (when GL is done with software, such as Mesa), or draw into the
front buffer and be erased when the buffers are swapped (when double buffer hardware is being used)
32.35. GL.H FILE REFERENCE 937

32.35.2 Function Documentation


FL EXPORT void gl color ( Fl Color i )
Sets the curent OpenGL color to an FLTK color.
For color-index modes it will use fl xpixel(c), which is only right if the window uses the default col-
ormap!

FL EXPORT void gl draw ( const char ∗ str )


Draws a nul-terminated string in the current font at the current position.

See Also
On the Mac OS X platform, see gl texture pile height(int)

FL EXPORT void gl draw ( const char ∗ str, int n )


Draws an array of n characters of the string in the current font at the current position.

See Also
On the Mac OS X platform, see gl texture pile height(int)

FL EXPORT void gl draw ( const char ∗ str, int x, int y )


Draws a nul-terminated string in the current font at the given position.

See Also
On the Mac OS X platform, see gl texture pile height(int)

FL EXPORT void gl draw ( const char ∗ str, float x, float y )


Draws a nul-terminated string in the current font at the given position.

See Also
On the Mac OS X platform, see gl texture pile height(int)

FL EXPORT void gl draw ( const char ∗ str, int n, int x, int y )


Draws n characters of the string in the current font at the given position.

See Also
On the Mac OS X platform, see gl texture pile height(int)

FL EXPORT void gl draw ( const char ∗ str, int n, float x, float y )


Draws n characters of the string in the current font at the given position.

See Also
On the Mac OS X platform, see gl texture pile height(int)
938 CHAPTER 32. FILE DOCUMENTATION

FL EXPORT void gl draw ( const char ∗ str, int x, int y, int w, int h, Fl Align align )
Draws a string formatted into a box, with newlines and tabs expanded, other control characters changed to

X.
and aligned with the edges or center. Exactly the same output as fl draw().

FL EXPORT void gl rect ( int x, int y, int w, int h )


Outlines the given rectangle with the current color.
If Fl Gl Window::ortho() has been called, then the rectangle will exactly fill the given pixel rectangle.

void gl rectf ( int x, int y, int w, int h ) [inline]


Fills the given rectangle with the current color.
See Also
gl rect(int x, int y, int w, int h)

32.36 mac.H File Reference


Mac OS X-specific symbols.

Classes
• class Fl Mac App Menu
Mac OS-specific class allowing to localize the application menu.

Functions
• void fl mac set about (Fl Callback ∗cb, void ∗user data, int shortcut=0)
Attaches a callback to the ”About myprog” item of the system application menu.
• void fl open callback (void(∗cb)(const char ∗))
Register a function called for each file dropped onto an application icon.

Variables
• int fl mac os version
The version number of the running Mac OS X (e.g., 100604 for 10.6.4)
• class Fl Sys Menu Bar ∗ fl sys menu bar
The system menu bar.

32.36.1 Detailed Description


Mac OS X-specific symbols.
Index

∼Fl Check Browser Enumerations.H, 902


Fl Check Browser, 365 FL EMBOSSED LABEL
∼Fl Device Enumerations.H, 906
Fl Device, 386 FL ENGRAVED LABEL
∼Fl Double Window Enumerations.H, 906
Fl Double Window, 392 FL GLEAM DOWN BOX
∼Fl File Chooser Enumerations.H, 902
Fl File Chooser, 400 FL GLEAM DOWN FRAME
∼Fl Group Enumerations.H, 902
Fl Group, 461 FL GLEAM ROUND DOWN BOX
∼Fl Help View Enumerations.H, 902
Fl Help View, 476 FL GLEAM ROUND UP BOX
∼Fl Input Enumerations.H, 902
Fl Input , 494 FL GLEAM THIN DOWN BOX
∼Fl Menu Window Enumerations.H, 902
Fl Menu Window, 545 FL GLEAM THIN UP BOX
∼Fl Native File Chooser Enumerations.H, 902
Fl Native File Chooser, 552 FL GLEAM UP BOX
∼Fl Plugin Manager Enumerations.H, 902
Fl Plugin Manager, 571 FL GLEAM UP FRAME
∼Fl PostScript Graphics Driver Enumerations.H, 902
Fl PostScript Graphics Driver, 584 FL GTK DOWN BOX
∼Fl Preferences Enumerations.H, 902
Fl Preferences, 596 FL GTK DOWN FRAME
∼Fl RGB Image Enumerations.H, 902
Fl RGB Image, 623 FL GTK ROUND DOWN BOX
∼Fl Scrollbar Enumerations.H, 902
Fl Scrollbar, 634 FL GTK ROUND UP BOX
∼Fl Shared Image Enumerations.H, 902
Fl Shared Image, 640 FL GTK THIN DOWN BOX
∼Fl Surface Device Enumerations.H, 902
Fl Surface Device, 652 FL GTK THIN DOWN FRAME
∼Fl Table Enumerations.H, 902
Fl Table, 669 FL GTK THIN UP BOX
∼Fl Table Row Enumerations.H, 902
Fl Table Row, 678 FL GTK THIN UP FRAME
∼Fl Text Display Enumerations.H, 902
Fl Text Display, 709 FL GTK UP BOX
∼Fl Widget Enumerations.H, 902
Fl Widget, 831 FL GTK UP FRAME
∼Fl Window Enumerations.H, 902
Fl Window, 863 FL ICON LABEL
FL DIAMOND DOWN BOX Enumerations.H, 906
Enumerations.H, 902 FL IMAGE LABEL
FL DIAMOND UP BOX Enumerations.H, 906

939
940 INDEX

FL MULTI LABEL Fl Text Display, 709


Enumerations.H, 906 activate
FL OFLAT BOX Fl Menu Item, 537
Enumerations.H, 902 Fl Tree Item, 793
FL OSHADOW BOX Fl Widget, 831
Enumerations.H, 902 active
FL OVAL BOX Fl Menu Item, 537
Enumerations.H, 902 Fl Widget, 831
FL OVAL FRAME active r
Enumerations.H, 902 Fl Widget, 833
FL PLASTIC DOWN BOX activevisible
Enumerations.H, 902 Fl Menu Item, 537
FL PLASTIC DOWN FRAME add
Enumerations.H, 902 Fl Browser, 323
FL PLASTIC ROUND DOWN BOX Fl Chart, 361
Enumerations.H, 902 Fl Check Browser, 365
FL PLASTIC ROUND UP BOX Fl File Icon, 405
Enumerations.H, 902 Fl Input Choice, 507
FL PLASTIC THIN DOWN BOX Fl Menu , 519, 521
Enumerations.H, 902 Fl Menu Item, 537
FL PLASTIC THIN UP BOX Fl Sys Menu Bar, 655
Enumerations.H, 902 Fl Tree, 762
FL PLASTIC UP BOX Fl Tree Item, 793
Enumerations.H, 902 Fl Tree Item Array, 805
FL PLASTIC UP FRAME add awake handler
Enumerations.H, 902 Fl, 300
FL RFLAT BOX add check
Enumerations.H, 901 Fl, 300
FL ROUNDED BOX add clipboard notify
Enumerations.H, 901 Selection & Clipboard functions, 221
FL ROUNDED FRAME add color
Enumerations.H, 901 Fl File Icon, 405
FL ROUND DOWN BOX add default key bindings
Enumerations.H, 902 Fl Text Editor, 735
FL ROUND UP BOX add extra
Enumerations.H, 901 Fl File Chooser, 400
FL RSHADOW BOX add fd
Enumerations.H, 901 Fl, 301
FL SHADOW BOX add handler
Enumerations.H, 901 Events handling functions, 209
FL SHADOW FRAME add idle
Enumerations.H, 901 Fl, 301
FL SHADOW LABEL add modify callback
Enumerations.H, 906 Fl Text Buffer, 691
remove add system handler
Fl Browser, 323 Events handling functions, 210
add timeout
A0 Fl, 301
Fl Paged Device, 562 add vertex
A4 Fl File Icon, 405
Fl Paged Device, 562 addPlugin
ALWAYS ON Fl Plugin Manager, 571
Fl Browser , 342 address
absolute top line number Fl Text Buffer, 691, 693
INDEX 941

align BROWSE SAVE FILE


Fl Widget, 833 Fl Native File Chooser, 552
angle1 background
Fl Dial, 389 Fl, 303
append background2
Fl Text Buffer, 693 Fl, 303
appendfile bbox
Fl Text Buffer, 693 Fl Browser , 343
arc Fl Scroll, 630
Fl Graphics Driver, 443 begin
Fl PostScript Graphics Driver, 584 Fl Group, 462
arg begin complex polygon
Fl, 301 Fl Graphics Driver, 443
args Fl PostScript Graphics Driver, 584
Fl, 302, 303 begin line
argument Fl Graphics Driver, 444
Fl Menu Item, 538 Fl PostScript Graphics Driver, 584
Fl Widget, 833 begin loop
array Fl Graphics Driver, 444
Fl Group, 462 Fl PostScript Graphics Driver, 584
as gl window begin points
Fl Gl Window, 429 Fl Graphics Driver, 444
Fl Widget, 833 Fl PostScript Graphics Driver, 584
as group begin polygon
Fl Group, 462 Fl Graphics Driver, 444
Fl Widget, 834 Fl PostScript Graphics Driver, 584
as window belowmouse
Fl Widget, 834 Events handling functions, 210
Fl Window, 863 bitmap
atclose Fl FormsBitmap, 415
Windows handling functions, 206 border
autosize Fl Window, 863
Fl Chart, 361 bottomline
awake Fl Browser, 324
Multithreading support functions, 255 bound key function
Fl Text Editor, 735
b bounds
Fl Color Chooser, 379 Fl Chart, 361
BLOCK CURSOR Fl Slider, 646
Fl Text Display, 708 Fl Valuator, 812
BOTH box
Fl Browser , 342 Fl Widget, 834, 835
BOTH ALWAYS box dh
Fl Browser , 342 Fl, 303
BROWSE DIRECTORY box dw
Fl Native File Chooser, 552 Fl, 304
BROWSE FILE box dx
Fl Native File Chooser, 552 Fl, 304
BROWSE MULTI DIRECTORY box dy
Fl Native File Chooser, 552 Fl, 304
BROWSE MULTI FILE buffer
Fl Native File Chooser, 552 Fl Text Display, 709
BROWSE SAVE DIRECTORY buffer modified cb
Fl Native File Chooser, 552 Fl Text Display, 710
942 INDEX

buffer predelete cb Fl Table, 670


Fl Text Display, 710 callback context
byte at Fl Table, 670
Fl Text Buffer, 693 callback item
Fl Tree, 763
CARET CURSOR callback reason
Fl Text Display, 708 Fl Tree, 763
CHANGED callback row
Fl Widget, 830 Fl Table, 670
CLIP CHILDREN can do
Fl Widget, 830 Fl Gl Window, 430
CONTEXT CELL can do overlay
Fl Table, 669 Fl Gl Window, 430
CONTEXT COL HEADER changed
Fl Table, 669 Fl Input Choice, 507
CONTEXT ENDPAGE Fl Widget, 836
Fl Table, 668 char at
CONTEXT NONE Fl Text Buffer, 693
Fl Table, 668 check
CONTEXT RC RESIZE Fl, 304
Fl Table, 669 Fl Menu Item, 539
CONTEXT ROW HEADER check all
Fl Table, 668 Fl Check Browser, 365
CONTEXT STARTPAGE check none
Fl Table, 668 Fl Check Browser, 365
CONTEXT TABLE checkbox
Fl Table, 669 Fl Menu Item, 539
COPIED LABEL checked
Fl Widget, 830 Fl Check Browser, 365
COPIED TOOLTIP Fl Menu Item, 539
Fl Widget, 831 child
Cairo support functions and classes, 260 Fl Group, 462
cairo autolink context, 260 Fl Table, 670
cairo cc, 261 Fl Tree Item, 794
cairo make current, 261 children
cairo autolink context Fl Table, 670
Cairo support functions and classes, 260 circle
cairo cc Fl Graphics Driver, 444
Cairo support functions and classes, 261 Fl PostScript Graphics Driver, 584
cairo make current clamp
Cairo support functions and classes, 261 Fl Valuator, 812
calc item height class id
Fl Tree Item, 794 Fl Device, 387
calc last char class name
Fl Text Display, 710 Fl Copy Surface, 382
calc line starts Fl Device, 386
Fl Text Display, 710 Fl Display Device, 390
callback Fl GDI Graphics Driver, 422
Fl Menu Item, 538 Fl GDI Printer Graphics Driver, 425
Fl Table, 669 Fl Graphics Driver, 444
Fl Widget, 835, 836 Fl Image Surface, 488
Callback function typedefs, 203 Fl Paged Device, 563
Fl Event Dispatch, 204 Fl PostScript File Device, 578
callback col Fl PostScript Graphics Driver, 584
INDEX 943

Fl PostScript Printer, 591 Fl Graphics Driver, 444


Fl Printer, 606 Fl PostScript Graphics Driver, 585
Fl Quartz Graphics Driver, 612 clip children
Fl Surface Device, 653 Fl Group, 462
Fl System Printer, 659 clip region
Fl Xlib Graphics Driver, 878 Fl Graphics Driver, 444
clear clipboard contains
Fl Browser, 324 Selection & Clipboard functions, 222
Fl Button, 355 clocale printf
Fl Check Browser, 365 Fl PostScript Graphics Driver, 585
Fl File Icon, 405 close
Fl Group, 462 Fl Tree, 763, 764
Fl Input Choice, 507 closeicon
Fl Menu , 521 Fl Tree, 765
Fl Menu Item, 539 Fl Tree Prefs, 808
Fl Scroll, 631 col
Fl Sys Menu Bar, 655 FL CHART ENTRY, 363
Fl Table, 670 col header
Fl Table Row, 678 Fl Table, 671
Fl Tree, 763 col resize
Fl Tree Item Array, 805 Fl Table, 671
clear active col resize min
Fl Widget, 836 Fl Table, 671
clear border col to x
Fl Window, 863 Fl Text Display, 711
clear changed col width
Fl Input Choice, 508 Fl Table, 671
Fl Widget, 836 col width all
clear children Fl Table, 671
Fl Tree, 763 color
clear damage Fl File Chooser, 400, 401
Fl Widget, 836 Fl GDI Graphics Driver, 422
clear modal states Fl Graphics Driver, 444, 445
Fl Window, 863 Fl PostScript Graphics Driver, 585
clear output Fl Quartz Graphics Driver, 612
Fl Widget, 837 Fl Tooltip, 750
clear overlay Fl Widget, 837, 839
Fl Menu Window, 545 Fl Xlib Graphics Driver, 878
clear rect Color & Font functions, 228
Fl Text Display, 711 fl color, 229, 230
clear selection fl color average, 230
Fl Help View, 476 fl contrast, 230
clear submenu fl font, 230
Fl Menu , 521 fl height, 231
Fl Sys Menu Bar, 656 fl latin1 to local, 231
clear visible fl local to latin1, 231
Fl Widget, 837 fl local to mac roman, 231
clear visible focus fl mac roman to local, 232
Fl Widget, 837 fl show colormap, 232
clear widget pointer fl size, 233
Safe widget deletion support functions, 258 fl text extents, 233
client area fl width, 233
Fl Tabs, 684 fl xpixel, 233, 234
clip box free color, 234
944 INDEX

get color, 234 Fl Input , 494


get font, 234 Fl Menu , 522
get font name, 234 Fl Pixmap, 568
get font sizes, 234 Fl RGB Image, 623
set color, 235 Fl Shared Image, 641
set font, 235 Fl Text Buffer, 694
set fonts, 235 Fl Tiled Image, 744
color2 Selection & Clipboard functions, 222
Fl Widget, 839 copy cuts
color average Fl Input , 494
Fl Image, 485 copy label
Fl Pixmap, 568 Fl Widget, 839
Fl RGB Image, 623 copy tooltip
Fl Shared Image, 641 Fl Widget, 840
Fl Tiled Image, 744 count
column char Fl File Chooser, 401
Fl Browser, 324 Fl Help Font Stack, 471
column widths Fl Image, 485
Fl Browser, 324, 325 Fl Native File Chooser, 552
Common Dialogs classes and functions, 273 count displayed characters
error, 281 Fl Text Buffer, 694
fatal, 281 count lines
fl alert, 274 Fl Text Buffer, 694
fl ask, 274 Fl Text Display, 711
fl beep, 275 current
fl choice, 275 Fl Group, 463
fl color chooser, 275, 276 Fl Tooltip, 750
fl dir chooser, 277 Fl Window, 864
fl file chooser, 277 current
fl file chooser callback, 278 Fl Window, 874
fl file chooser ok label, 278 cursor
fl input, 279 Fl Window, 864
fl message, 279 cursor color
fl message hotspot, 279, 280 Fl Input , 495
fl message icon, 280 Fl Text Display, 711
fl message title, 280 Fl Value Input, 816
fl message title default, 280 cursor style
fl password, 281 Fl Text Display, 712
warning, 281 curve
compose Fl Graphics Driver, 445
Events handling functions, 210 Fl PostScript Graphics Driver, 585
compose reset cut
Events handling functions, 211 Fl Input , 495
connectorstyle
Fl Tree, 765 d
contains Fl Image, 485
Fl Widget, 839 DIM CURSOR
context Fl Text Display, 708
Fl Gl Window, 430 damage
context valid Fl, 304
Fl Gl Window, 430 Fl Widget, 840
copy damage resize
Fl Bitmap, 316 Fl Widget, 841
Fl Image, 485 data
INDEX 945

Fl Browser, 325 Fl Xlib Graphics Driver, 878


Fl Image, 485 deselect
deactivate Fl Browser , 343
Fl Menu Item, 539 Fl Tree, 765, 766
Fl Tree Item, 794 deselect all
Fl Widget, 841 Fl Tree, 766
decorated h Fl Tree Item, 794
Fl Window, 864 direction
decorated w Fl Timer, 746
Fl Window, 864 directory
default atclose Fl File Chooser, 401
Windows handling functions, 205 Fl Help View, 476
default callback Fl Native File Chooser, 552
Fl Widget, 841 disable
default cursor Fl Tooltip, 750
Fl Window, 864, 865 disable im
default icon Events handling functions, 211
Fl Window, 865 display
default icons Fl, 304
Fl Window, 865 Fl Browser, 326
default key function Fl Browser , 343
Fl Text Editor, 736 Fl Tree, 767
default xclass display device
Fl Window, 865, 866 Fl Display Device, 390
deimage display insert
Fl Widget, 841, 842 Fl Text Display, 712
delay displayed
Fl Tooltip, 750 Fl Browser, 326
delete widget Fl Browser , 343
Safe widget deletion support functions, 258 Fl Tree, 767
deleteEntry dnd
Fl Preferences, 596 Selection & Clipboard functions, 222
deleteGroup dnd text ops
Fl Preferences, 596 Fl, 305
deleted do callback
Fl Widget Tracker, 857 Fl Menu Item, 539
deleting Fl Widget, 842
Fl Browser , 343 do widget deletion
deparent Safe widget deletion support functions, 258
Fl Tree Item, 794 down box
Fl Tree Item Array, 805 Fl Button, 355
depth Fl File Input, 409
Fl Tree Item, 794 Fl Menu , 522
desaturate draw
Fl Image, 485 Fl Adjuster, 313
Fl Pixmap, 568 Fl Bitmap, 316
Fl RGB Image, 623 Fl Box, 319
Fl Shared Image, 641 Fl Button, 355
Fl Tiled Image, 745 Fl Chart, 362
descent Fl Choice, 370
Fl GDI Graphics Driver, 423 Fl Clock Output, 375
Fl Graphics Driver, 445 Fl Copy Surface, 382
Fl PostScript Graphics Driver, 585 Fl Counter, 384
Fl Quartz Graphics Driver, 612 Fl Dial, 389
946 INDEX

Fl File Icon, 405 Fl Group, 463


Fl FormsBitmap, 415 draw cursor
Fl FormsPixmap, 416 Fl Text Display, 712
Fl FormsText, 418 draw empty
Fl Free, 420 Fl Image, 485
Fl GDI Graphics Driver, 423 draw horizontal connector
Fl GDI Printer Graphics Driver, 425, 426 Fl Tree Item, 795
Fl Gl Window, 430 draw image
Fl Glut Window, 435 Fl GDI Graphics Driver, 423
Fl Graphics Driver, 445, 446 Fl Graphics Driver, 446
Fl Group, 463 Fl PostScript Graphics Driver, 586
Fl Image, 485 Fl Quartz Graphics Driver, 613
Fl Image Surface, 488 Fl Xlib Graphics Driver, 879
Fl Input, 490 draw image mono
Fl Label, 512 Fl GDI Graphics Driver, 424
Fl Light Button, 514 Fl Graphics Driver, 446
Fl Menu Bar, 529 Fl PostScript Graphics Driver, 586
Fl Menu Button, 532 Fl Quartz Graphics Driver, 613
Fl Menu Item, 539 Fl Xlib Graphics Driver, 879
Fl Pack, 560 draw label
Fl Pixmap, 568 Fl Widget, 843
Fl Positioner, 575 draw line numbers
Fl PostScript Graphics Driver, 585, 586 Fl Text Display, 712
Fl Progress, 610 draw outside label
Fl Quartz Graphics Driver, 612, 613 Fl Group, 463
Fl Return Button, 619 draw overlay
Fl RGB Image, 623 Fl Glut Window, 436
Fl Roller, 625 Fl Overlay Window, 558
Fl Scroll, 631 draw range
Fl Scrollbar, 634 Fl Text Display, 713
Fl Shared Image, 641 draw string
Fl Slider, 646 Fl Text Display, 713
Fl Sys Menu Bar, 656 draw text
Fl Table, 671 Fl Text Display, 713
Fl Tabs, 684 draw vertical connector
Fl Text Display, 712 Fl Tree Item, 795
Fl Tiled Image, 745 draw vline
Fl Timer, 746 Fl Text Display, 713
Fl Tree Item, 795 Drawing functions, 236
Fl Value Input, 816 FL CAP FLAT, 241
Fl Value Output, 820 FL CAP ROUND, 241
Fl Value Slider, 822 FL CAP SQUARE, 241
Fl Widget, 842 FL DASH, 241
Fl Window, 866 FL DASHDOT, 241
Fl Xlib Graphics Driver, 878, 879 FL DASHDOTDOT, 241
draw box FL DOT, 241
Fl Widget, 843 FL JOIN BEVEL, 241
draw box active FL JOIN MITER, 241
Fl, 305 FL JOIN ROUND, 241
draw cell FL SOLID, 241
Fl Table, 671 fl add symbol, 241
draw child fl arc, 241, 242
Fl Group, 463 fl begin complex polygon, 242
draw children fl begin offscreen, 242
INDEX 947

fl begin points, 242 ERRORS TO CP1252


fl can do alpha blending, 242 Unicode and UTF-8 functions, 263
fl circle, 243 ERRORS TO ISO8859 1
fl clip, 240 Unicode and UTF-8 functions, 263
fl clip box, 243 empty vlines
fl clip region, 243 Fl Text Display, 714
fl copy offscreen, 243 enable
fl create offscreen, 244 Fl Tooltip, 750
fl cursor, 244 enable im
fl curve, 244 Events handling functions, 211
fl delete offscreen, 244 enabled
fl draw, 244 Fl Tooltip, 750
fl draw box, 245 end
fl draw image, 245 Fl Group, 463
fl draw image mono, 246 Fl Text Selection, 738
fl draw pixmap, 246, 247 end complex polygon
fl draw symbol, 247 Fl Graphics Driver, 446
fl expand text, 247 Fl PostScript Graphics Driver, 586
fl frame, 247 end line
fl frame2, 247 Fl Graphics Driver, 446
fl gap, 248 Fl PostScript Graphics Driver, 587
fl line style, 248 end loop
Fl Graphics Driver, 446
fl measure, 248
Fl PostScript Graphics Driver, 587
fl measure pixmap, 249
end page
fl mult matrix, 249
Fl Paged Device, 563
fl not clipped, 249
Fl PostScript File Device, 578
fl old shortcut, 249
Fl Printer, 606
fl pie, 250
Fl System Printer, 659
fl polygon, 251
end points
fl pop clip, 251
Fl Graphics Driver, 447
fl push clip, 251
Fl PostScript Graphics Driver, 587
fl push matrix, 251 end polygon
fl read image, 251 Fl Graphics Driver, 447
fl rect, 251 Fl PostScript Graphics Driver, 587
fl rectf, 252 enter area
fl reset spot, 252 Fl Tooltip, 750
fl rotate, 252 entries
fl scale, 252 Fl Preferences, 597
fl scroll, 252 entry
fl set spot, 253 Fl Preferences, 597
fl set status, 253 entryExists
fl shortcut label, 253 Fl Preferences, 597
fl transform dx, 253 Enumerations.H
fl transform dy, 254 FL DIAMOND DOWN BOX, 902
fl transform x, 254 FL DIAMOND UP BOX, 902
fl transform y, 254 FL EMBOSSED LABEL, 906
fl transformed vertex, 254 FL ENGRAVED LABEL, 906
fl translate, 254 FL GLEAM DOWN BOX, 902
fl vertex, 254 FL GLEAM DOWN FRAME, 902
drawtext FL GLEAM ROUND DOWN BOX, 902
Fl Input , 496 FL GLEAM ROUND UP BOX, 902
driver FL GLEAM THIN DOWN BOX, 902
Fl Surface Device, 653 FL GLEAM THIN UP BOX, 902
948 INDEX

FL GLEAM UP BOX, 902 FL CURSOR NWSE, 903


FL GLEAM UP FRAME, 902 FL CURSOR S, 903
FL GTK DOWN BOX, 902 FL CURSOR SE, 903
FL GTK DOWN FRAME, 902 FL CURSOR SW, 903
FL GTK ROUND DOWN BOX, 902 FL CURSOR W, 903
FL GTK ROUND UP BOX, 902 FL CURSOR WAIT, 903
FL GTK THIN DOWN BOX, 902 FL CURSOR WE, 903
FL GTK THIN DOWN FRAME, 902 FL DAMAGE ALL, 903
FL GTK THIN UP BOX, 902 FL DAMAGE CHILD, 903
FL GTK THIN UP FRAME, 902 FL DAMAGE EXPOSE, 903
FL GTK UP BOX, 902 FL DAMAGE OVERLAY, 903
FL GTK UP FRAME, 902 FL DAMAGE SCROLL, 903
FL ICON LABEL, 906 FL DAMAGE USER1, 903
FL IMAGE LABEL, 906 FL DAMAGE USER2, 903
FL MULTI LABEL, 906 FL DEACTIVATE, 905
FL OFLAT BOX, 902 FL DND DRAG, 906
FL OSHADOW BOX, 902 FL DND ENTER, 906
FL OVAL BOX, 902 FL DND LEAVE, 906
FL OVAL FRAME, 902 FL DND RELEASE, 906
FL PLASTIC DOWN BOX, 902 FL DOWN BOX, 901
FL PLASTIC DOWN FRAME, 902 FL DOWN FRAME, 901
FL PLASTIC ROUND DOWN BOX, 902 FL DRAG, 904
FL PLASTIC ROUND UP BOX, 902 FL EMBOSSED BOX, 901
FL PLASTIC THIN DOWN BOX, 902 FL EMBOSSED FRAME, 901
FL PLASTIC THIN UP BOX, 902 FL ENGRAVED BOX, 901
FL PLASTIC UP BOX, 902 FL ENGRAVED FRAME, 901
FL PLASTIC UP FRAME, 902 FL ENTER, 904
FL RFLAT BOX, 901 FL EXCEPT, 901
FL ROUNDED BOX, 901 FL FLAT BOX, 901
FL ROUNDED FRAME, 901 FL FOCUS, 904
FL ROUND DOWN BOX, 902 FL FREE BOXTYPE, 902
FL ROUND UP BOX, 901 FL FREE LABELTYPE, 906
FL RSHADOW BOX, 901 FL FULLSCREEN, 906
FL SHADOW BOX, 901 FL HIDE, 905
FL SHADOW FRAME, 901 FL KEYBOARD, 905
FL SHADOW LABEL, 906 FL KEYDOWN, 904
FL ACTIVATE, 905 FL KEYUP, 905
FL BORDER BOX, 901 FL LEAVE, 904
FL BORDER FRAME, 901 FL MOUSEWHEEL, 905
FL CLOSE, 905 FL MOVE, 905
FL CURSOR ARROW, 903 FL NO BOX, 901
FL CURSOR CROSS, 903 FL NO EVENT, 904
FL CURSOR DEFAULT, 903 FL NO LABEL, 906
FL CURSOR E, 903 FL NORMAL LABEL, 906
FL CURSOR HAND, 903 FL PASTE, 905
FL CURSOR HELP, 903 FL PUSH, 904
FL CURSOR INSERT, 903 FL READ, 901
FL CURSOR MOVE, 903 FL RELEASE, 904
FL CURSOR N, 903 FL SCREEN CONFIGURATION CHANGE-
FL CURSOR NE, 903 D, 906
FL CURSOR NESW, 903 FL SELECTIONCLEAR, 905
FL CURSOR NONE, 903 FL SHORTCUT, 905
FL CURSOR NS, 903 FL SHOW, 905
FL CURSOR NW, 903 FL THIN DOWN BOX, 901
INDEX 949

FL THIN DOWN FRAME, 901 Events handling functions, 211


FL THIN UP BOX, 901 event button
FL THIN UP FRAME, 901 Events handling functions, 211
FL UNFOCUS, 904 event button1
FL UP BOX, 901 Events handling functions, 212
FL UP FRAME, 901 event button2
FL WHEN CHANGED, 906 Events handling functions, 212
FL WHEN ENTER KEY, 907 event button3
FL WHEN ENTER KEY ALWAYS, 907 Events handling functions, 212
FL WHEN ENTER KEY CHANGED, 907 event buttons
FL WHEN NEVER, 906 Events handling functions, 212
FL WHEN NOT CHANGED, 907 event clicks
FL WHEN RELEASE, 907 Events handling functions, 212
FL WHEN RELEASE ALWAYS, 907 event clipboard
FL WRITE, 901 Events handling functions, 213
Enumerations.H, 889 event clipboard type
FL ALIGN BOTTOM, 908 Events handling functions, 213
FL ALIGN CENTER, 908 event command
FL ALIGN CLIP, 908 Events handling functions, 213
FL ALIGN INSIDE, 908 event ctrl
FL ALIGN LEFT, 908 Events handling functions, 213
FL ALIGN RIGHT, 908 event dispatch
FL ALIGN TOP, 909 Events handling functions, 213
FL ALIGN WRAP, 909 event dx
FL MAJOR VERSION, 900 Events handling functions, 213
FL MINOR VERSION, 900 event dy
FL NORMAL SIZE, 909 Events handling functions, 214
FL PATCH VERSION, 900 event inside
FL VERSION, 900 Events handling functions, 214
Fl Boxtype, 901 event is click
Fl Cursor, 902 Events handling functions, 215
Fl Damage, 903 event key
Fl Event, 903 Events handling functions, 215
Fl Font, 901 event length
Fl Fontsize, 901 Events handling functions, 216
Fl Labeltype, 906 event original key
Fl When, 906 Events handling functions, 216
fl box, 907 event shift
fl color cube, 907 Events handling functions, 216
fl darker, 907 event state
fl down, 907 Events handling functions, 216
fl frame, 907 event text
fl gray ramp, 907 Events handling functions, 216
fl lighter, 907 event x root
fl rgb color, 908 Events handling functions, 217
errmsg event y root
Fl Native File Chooser, 552 Events handling functions, 217
error Events handling functions, 207
Common Dialogs classes and functions, 281 add handler, 209
errorcolor add system handler, 210
Fl File Input, 409 belowmouse, 210
event compose, 210
Events handling functions, 211 compose reset, 211
event alt disable im, 211
950 INDEX

enable im, 211 FL BEEP NOTIFICATION


event, 211 fl ask.H, 915
event alt, 211 FL BEEP PASSWORD
event button, 211 fl ask.H, 915
event button1, 212 FL BEEP QUESTION
event button2, 212 fl ask.H, 915
event button3, 212 FL BORDER BOX
event buttons, 212 Enumerations.H, 901
event clicks, 212 FL BORDER FRAME
event clipboard, 213 Enumerations.H, 901
event clipboard type, 213 FL CAP FLAT
event command, 213 Drawing functions, 241
event ctrl, 213 FL CAP ROUND
event dispatch, 213 Drawing functions, 241
event dx, 213 FL CAP SQUARE
event dy, 214 Drawing functions, 241
event inside, 214 FL CLOSE
event is click, 215 Enumerations.H, 905
event key, 215 FL CURSOR ARROW
event length, 216 Enumerations.H, 903
event original key, 216 FL CURSOR CROSS
event shift, 216 Enumerations.H, 903
event state, 216 FL CURSOR DEFAULT
event text, 216 Enumerations.H, 903
event x root, 217 FL CURSOR E
event y root, 217 Enumerations.H, 903
fl eventnames, 219 FL CURSOR HAND
fl fontnames, 220 Enumerations.H, 903
focus, 217 FL CURSOR HELP
get key, 217 Enumerations.H, 903
get mouse, 217 FL CURSOR INSERT
handle, 218 Enumerations.H, 903
handle , 218 FL CURSOR MOVE
pushed, 218 Enumerations.H, 903
remove handler, 219 FL CURSOR N
remove system handler, 219 Enumerations.H, 903
test shortcut, 219 FL CURSOR NE
exists Enumerations.H, 903
Fl Widget Tracker, 857 FL CURSOR NESW
extend range for styles Enumerations.H, 903
Fl Text Display, 714 FL CURSOR NONE
extend selection Enumerations.H, 903
Fl Tree, 767 FL CURSOR NS
extend selection dir Enumerations.H, 903
Fl Tree, 767 FL CURSOR NW
Enumerations.H, 903
FL ACTIVATE FL CURSOR NWSE
Enumerations.H, 905 Enumerations.H, 903
FL BEEP DEFAULT FL CURSOR S
fl ask.H, 915 Enumerations.H, 903
FL BEEP ERROR FL CURSOR SE
fl ask.H, 915 Enumerations.H, 903
FL BEEP MESSAGE FL CURSOR SW
fl ask.H, 915 Enumerations.H, 903
INDEX 951

FL CURSOR W FL EXCEPT
Enumerations.H, 903 Enumerations.H, 901
FL CURSOR WAIT FL FLAT BOX
Enumerations.H, 903 Enumerations.H, 901
FL CURSOR WE FL FOCUS
Enumerations.H, 903 Enumerations.H, 904
FL DAMAGE ALL FL FREE BOXTYPE
Enumerations.H, 903 Enumerations.H, 902
FL DAMAGE CHILD FL FREE LABELTYPE
Enumerations.H, 903 Enumerations.H, 906
FL DAMAGE EXPOSE FL FULLSCREEN
Enumerations.H, 903 Enumerations.H, 906
FL DAMAGE OVERLAY FL HIDE
Enumerations.H, 903 Enumerations.H, 905
FL DAMAGE SCROLL FL JOIN BEVEL
Enumerations.H, 903 Drawing functions, 241
FL DAMAGE USER1 FL JOIN MITER
Enumerations.H, 903 Drawing functions, 241
FL DAMAGE USER2 FL JOIN ROUND
Enumerations.H, 903 Drawing functions, 241
FL DASH FL KEYBOARD
Drawing functions, 241 Enumerations.H, 905
FL DASHDOT FL KEYDOWN
Drawing functions, 241 Enumerations.H, 904
FL DASHDOTDOT FL KEYUP
Drawing functions, 241 Enumerations.H, 905
FL DEACTIVATE FL LEAVE
Enumerations.H, 905 Enumerations.H, 904
FL DND DRAG FL MOUSEWHEEL
Enumerations.H, 906 Enumerations.H, 905
FL DND ENTER FL MOVE
Enumerations.H, 906 Enumerations.H, 905
FL DND LEAVE FL NO BOX
Enumerations.H, 906 Enumerations.H, 901
FL DND RELEASE FL NO EVENT
Enumerations.H, 906 Enumerations.H, 904
FL DOT FL NO LABEL
Drawing functions, 241 Enumerations.H, 906
FL DOWN BOX FL NORMAL LABEL
Enumerations.H, 901 Enumerations.H, 906
FL DOWN FRAME FL PASTE
Enumerations.H, 901 Enumerations.H, 905
FL DRAG FL PUSH
Enumerations.H, 904 Enumerations.H, 904
FL EMBOSSED BOX FL READ
Enumerations.H, 901 Enumerations.H, 901
FL EMBOSSED FRAME FL RELEASE
Enumerations.H, 901 Enumerations.H, 904
FL ENGRAVED BOX FL RGB SCALING BILINEAR
Enumerations.H, 901 Fl Image.H, 926
FL ENGRAVED FRAME FL RGB SCALING NEAREST
Enumerations.H, 901 Fl Image.H, 926
FL ENTER FL SCREEN CONFIGURATION CHANGED
Enumerations.H, 904 Enumerations.H, 906
952 INDEX

FL SELECTIONCLEAR FL WHEN CHANGED


Enumerations.H, 905 Enumerations.H, 906
FL SHORTCUT FL WHEN ENTER KEY
Enumerations.H, 905 Enumerations.H, 907
FL SHOW FL WHEN ENTER KEY ALWAYS
Enumerations.H, 905 Enumerations.H, 907
FL SOLID FL WHEN ENTER KEY CHANGED
Drawing functions, 241 Enumerations.H, 907
FL THIN DOWN BOX FL WHEN NEVER
Enumerations.H, 901 Enumerations.H, 906
FL THIN DOWN FRAME FL WHEN NOT CHANGED
Enumerations.H, 901 Enumerations.H, 907
FL THIN UP BOX FL WHEN RELEASE
Enumerations.H, 901 Enumerations.H, 907
FL THIN UP FRAME FL WHEN RELEASE ALWAYS
Enumerations.H, 901 Enumerations.H, 907
FL TREE CONNECTOR DOTTED FL WRITE
Fl Tree Prefs.H, 934 Enumerations.H, 901
FL TREE CONNECTOR NONE FORCE POSITION
Fl Tree Prefs.H, 934 Fl Widget, 830
FL TREE CONNECTOR SOLID FULLSCREEN
Fl Tree Prefs.H, 934 Fl Widget, 831
FL TREE REASON CLOSED FL ALIGN BOTTOM
Fl Tree.H, 933 Enumerations.H, 908
FL TREE REASON DESELECTED FL ALIGN CENTER
Fl Tree.H, 933 Enumerations.H, 908
FL TREE REASON DRAGGED FL ALIGN CLIP
Fl Tree.H, 933 Enumerations.H, 908
FL TREE REASON NONE FL ALIGN INSIDE
Fl Tree.H, 933 Enumerations.H, 908
FL TREE REASON OPENED FL ALIGN LEFT
Fl Tree.H, 933 Enumerations.H, 908
FL TREE REASON SELECTED FL ALIGN RIGHT
Fl Tree.H, 933 Enumerations.H, 908
FL TREE SELECT MULTI FL ALIGN TOP
Fl Tree Prefs.H, 935 Enumerations.H, 909
FL TREE SELECT NONE FL ALIGN WRAP
Fl Tree Prefs.H, 935 Enumerations.H, 909
FL TREE SELECT SINGLE FL CHART ENTRY, 363
Fl Tree Prefs.H, 935 col, 363
FL TREE SELECT SINGLE DRAGGABLE str, 363
Fl Tree Prefs.H, 935 val, 363
FL TREE SORT ASCENDING FL MAJOR VERSION
Fl Tree Prefs.H, 935 Enumerations.H, 900
FL TREE SORT DESCENDING FL MINOR VERSION
Fl Tree Prefs.H, 935 Enumerations.H, 900
FL TREE SORT NONE FL NORMAL SIZE
Fl Tree Prefs.H, 935 Enumerations.H, 909
FL UNFOCUS FL PATCH VERSION
Enumerations.H, 904 Enumerations.H, 900
FL UP BOX FL RESERVED TYPE
Enumerations.H, 901 Fl Widget.H, 939
FL UP FRAME FL VERSION
Enumerations.H, 901 Enumerations.H, 900
INDEX 953

fatal Fl Menu Item, 540


Common Dialogs classes and functions, 281 find wrap range
File names and URI utility functions, 283 Fl Text Display, 714
Fl File Sort F, 284 find x
fl decode uri, 284 Fl Text Display, 716
fl filename absolute, 284 findchar backward
fl filename expand, 284 Fl Text Buffer, 694
fl filename ext, 285 findchar forward
fl filename free list, 285 Fl Text Buffer, 694
fl filename isdir, 285 first
fl filename list, 285 Fl File Icon, 406
fl filename match, 287 Fl Menu Item, 540
fl filename name, 287 Fl Tree, 768
fl filename relative, 287 first selected item
fl filename setext, 288 Fl Tree, 769
fl open uri, 288 first visible
file encoding warning message Fl Tree, 769
Fl Text Buffer, 700 first visible item
filename Fl Tree, 769
Fl Help View, 477 first window
Fl Native File Chooser, 552, 553 Windows handling functions, 205
filename.H, 909 Fl, 291
filetype add awake handler , 300
Fl File Browser, 395 add check, 300
filter add fd, 301
Fl File Browser, 395 add idle, 301
Fl File Chooser, 401 add timeout, 301
Fl Native File Chooser, 553 arg, 301
filter value args, 302, 303
Fl File Chooser, 401 background, 303
Fl Native File Chooser, 553 background2, 303
find box dh, 303
Fl File Icon, 406 box dw, 304
Fl Group, 464 box dx, 304
Fl Help View, 477 box dy, 304
find child check, 304
Fl Tree Item, 795 damage, 304
find child item display, 304
Fl Tree Item, 796 dnd text ops, 305
find clicked draw box active, 305
Fl Tree, 768 Fl Option, 300
Fl Tree Item, 796 flush, 305
find index foreground, 305
Fl Menu , 522, 523 get awake handler , 305
find item get boxtype, 305
Fl Browser , 344 get system colors, 305
Fl Menu , 523 gl visual, 305
Fl Tree, 768 help, 311
Fl Tree Item, 796 idle, 311
find line is scheme, 306
Fl Browser, 326 OPTION ARROW FOCUS, 300
find line end OPTION DND TEXT, 300
Fl Text Display, 714 OPTION FNFC USES GTK, 300
find shortcut OPTION LAST, 300
954 INDEX

OPTION SHOW TOOLTIPS, 300 A0, 562


OPTION VISIBLE FOCUS, 300 A4, 562
option, 306, 307 LANDSCAPE, 563
own colormap, 307 LETTER, 562
ready, 307 ORIENTATION, 563
release, 307 PORTRAIT, 563
reload scheme, 308 REVERSED, 563
remove check, 308 Fl Preferences
remove fd, 308 SYSTEM, 594
remove timeout, 308 USER, 594
repeat timeout, 308 Fl Table
run, 308 CONTEXT CELL, 669
scheme, 308 CONTEXT COL HEADER, 669
scrollbar size, 309 CONTEXT ENDPAGE, 668
set boxtype, 309 CONTEXT NONE, 668
set idle, 309 CONTEXT RC RESIZE, 669
set labeltype, 309 CONTEXT ROW HEADER, 668
version, 310 CONTEXT STARTPAGE, 668
visible focus, 310 CONTEXT TABLE, 669
visual, 310 Fl Text Display
wait, 310 BLOCK CURSOR, 708
Fl.H, 910 CARET CURSOR, 708
Fl Browser DIM CURSOR, 708
ALWAYS ON, 342 HEAVY CURSOR, 708
BOTH, 342 NORMAL CURSOR, 708
BOTH ALWAYS, 342 SIMPLE CURSOR, 708
HORIZONTAL, 342 WRAP AT BOUNDS, 709
HORIZONTAL ALWAYS, 342 WRAP AT COLUMN, 709
VERTICAL, 342 WRAP AT PIXEL, 709
VERTICAL ALWAYS, 342 WRAP NONE, 709
Fl Image.H Fl Tree.H
FL RGB SCALING BILINEAR, 926 FL TREE REASON CLOSED, 933
FL RGB SCALING NEAREST, 926 FL TREE REASON DESELECTED, 933
Fl Menu Button FL TREE REASON DRAGGED, 933
POPUP1, 531 FL TREE REASON NONE, 933
POPUP12, 531 FL TREE REASON OPENED, 933
POPUP123, 531 FL TREE REASON SELECTED, 933
POPUP13, 531 Fl Tree Prefs.H
POPUP2, 531 FL TREE CONNECTOR DOTTED, 934
POPUP23, 531 FL TREE CONNECTOR NONE, 934
POPUP3, 531 FL TREE CONNECTOR SOLID, 934
Fl Native File Chooser FL TREE SELECT MULTI, 935
BROWSE DIRECTORY, 552 FL TREE SELECT NONE, 935
BROWSE FILE, 552 FL TREE SELECT SINGLE, 935
BROWSE MULTI DIRECTORY, 552 FL TREE SELECT SINGLE DRAGGABLE,
BROWSE MULTI FILE, 552 935
BROWSE SAVE DIRECTORY, 552 FL TREE SORT ASCENDING, 935
BROWSE SAVE FILE, 552 FL TREE SORT DESCENDING, 935
NEW FOLDER, 551 FL TREE SORT NONE, 935
NO OPTIONS, 551 Fl Widget
PREVIEW, 551 CHANGED, 830
SAVEAS CONFIRM, 551 CLIP CHILDREN, 830
USE FILTER EXT, 552 COPIED LABEL, 830
Fl Paged Device COPIED TOOLTIP, 831
INDEX 955

FORCE POSITION, 830 bottomline, 324


FULLSCREEN, 831 clear, 324
GROUP RELATIVE, 831 column char, 324
INACTIVE, 830 column widths, 324, 325
INVISIBLE, 830 data, 325
MAC USE ACCENTS MENU, 831 display, 326
MENU WINDOW, 831 displayed, 326
MODAL, 831 find line, 326
NO OVERLAY, 831 Fl Browser, 323
NOBORDER, 830 Fl Browser, 323
NON MODAL, 830 format char, 326, 327
OUTPUT, 830 full height, 327
OVERRIDE, 830 hide, 327, 328
SHORTCUT LABEL, 830 icon, 328
TOOLTIP WINDOW, 831 incr height, 328
USERFLAG1, 831 insert, 328, 329
USERFLAG2, 831 item at, 329
USERFLAG3, 831 item draw, 329
VISIBLE FOCUS, 830 item first, 329
fl ask.H item height, 330
FL BEEP DEFAULT, 915 item last, 330
FL BEEP ERROR, 915 item next, 330
FL BEEP MESSAGE, 915 item prev, 331
FL BEEP NOTIFICATION, 915 item select, 331
FL BEEP PASSWORD, 915 item selected, 331
FL BEEP QUESTION, 915 item swap, 331
Fl Adjuster, 312 item text, 333
draw, 313 item width, 333
Fl Adjuster, 313 lineno, 333
Fl Adjuster, 313 lineposition, 333
handle, 313 load, 334
soft, 315 make visible, 334
Fl BMP Image, 317 middleline, 334
Fl BMP Image, 318 move, 334
Fl BMP Image, 318 remove, 335
Fl Beep remove icon, 335
fl ask.H, 914 replace, 335
Fl Bitmap, 315 select, 335
copy, 316 selected, 335
draw, 316 show, 336
Fl Bitmap, 316 size, 336
Fl Bitmap, 316 swap, 336
label, 317 text, 337
uncache, 317 topline, 337
Fl Box, 318 value, 337, 338
draw, 319 visible, 338
Fl Box, 318 Fl Browser , 338
Fl Box, 318 bbox, 343
handle, 319 deleting, 343
Fl Boxtype deselect, 343
Enumerations.H, 901 display, 343
Fl Browser, 319 displayed, 343
remove, 323 find item, 344
add, 323 Fl Browser , 342
956 INDEX

Fl Browser , 342 Fl Chart, 359


full height, 344 add, 361
full width, 344 autosize, 361
handle, 344 bounds, 361
has scrollbar, 345 draw, 362
hposition, 345 Fl Chart, 361
hscrollbar, 352 Fl Chart, 361
incr height, 345 insert, 362
inserting, 345 maxsize, 362
item at, 346 replace, 362
item first, 346 textcolor, 362
item height, 346 textfont, 362
item last, 346 textsize, 362
item next, 346 Fl Check Browser, 363
item prev, 347 ∼Fl Check Browser, 365
item quick height, 347 add, 365
item select, 347 check all, 365
item selected, 347 check none, 365
item swap, 348 checked, 365
item text, 348 clear, 365
item width, 348 Fl Check Browser, 365
leftedge, 348 Fl Check Browser, 365
new list, 348 handle, 365
position, 349 nchecked, 367
redraw line, 349 nitems, 367
redraw lines, 349 remove, 367
replacing, 349 set checked, 367
resize, 350 text, 367
scrollbar, 352 value, 367
scrollbar left, 350 Fl Check Button, 367
scrollbar right, 350 Fl Check Button, 368
scrollbar size, 350 Fl Check Button, 368
scrollbar width, 351 Fl Choice, 368
select, 351 draw, 370
select only, 351 Fl Choice, 370
selection, 352 Fl Choice, 370
sort, 352 handle, 370
swapping, 352 value, 371
textfont, 352 Fl Clock, 371
Fl Button, 353 Fl Clock, 373
clear, 355 Fl Clock, 373
down box, 355 handle, 373
draw, 355 Fl Clock Output, 374
Fl Button, 354 draw, 375
Fl Button, 354 Fl Clock Output, 375
handle, 355 Fl Clock Output, 375
set, 356 hour, 376
shortcut, 356 minute, 376
value, 356 second, 376
Fl CString value, 376
fl types.h, 935 Fl Color Chooser, 377
Fl Cairo State, 357 b, 379
Fl Cairo Window, 358 Fl Color Chooser, 379
set draw cb, 359 Fl Color Chooser, 379
INDEX 957

g, 379 Fl End, 393


hsv, 379 Fl Event
hsv2rgb, 379 Enumerations.H, 903
hue, 379 Fl Event Dispatch
mode, 379, 380 Callback function typedefs, 204
r, 380 Fl FLTK File Chooser, 412
rgb, 380 Fl File Browser, 393
rgb2hsv, 380 filetype, 395
saturation, 380 filter, 395
value, 380 Fl File Browser, 394
Fl Color Chooser.H, 917 Fl File Browser, 394
Fl Copy Surface, 381 iconsize, 395
class name, 382 load, 395
draw, 382 Fl File Chooser, 395
Fl Copy Surface, 382 ∼Fl File Chooser, 400
Fl Copy Surface, 382 add extra, 400
set current, 382 color, 400, 401
Fl Counter, 382 count, 401
draw, 384 directory, 401
Fl Counter, 384 filter, 401
Fl Counter, 384 filter value, 401
handle, 384 Fl File Chooser, 400
lstep, 385 Fl File Chooser, 400
step, 385 hide, 401
Fl Cursor iconsize, 401
Enumerations.H, 902 label, 401
Fl Damage preview, 402
Enumerations.H, 903 rescan, 402
Fl Device, 385 show, 402
∼Fl Device, 386 showHiddenButton, 403
class id, 387 textcolor, 402
class name, 386 textfont, 402
Fl Device.H, 918 textsize, 402
Fl Draw Image Cb, 919 type, 402
Fl Device Plugin, 387 value, 402
print, 387 visible, 403
Fl Dial, 388 Fl File Icon, 403
angle1, 389 add, 405
draw, 389 add color, 405
Fl Dial, 389 add vertex, 405
Fl Dial, 389 clear, 405
handle, 389 draw, 405
Fl Display Device, 390 find, 406
class name, 390 first, 406
display device, 390 Fl File Icon, 404
Fl Double Window, 391 Fl File Icon, 404
∼Fl Double Window, 392 label, 406
flush, 392 labeltype, 406
hide, 392 load, 406
resize, 392 load fti, 406
show, 392 load image, 407
Fl Double Window.cxx, 920 load system icons, 407
Fl Draw Image Cb next, 407
Fl Device.H, 919 pattern, 407
958 INDEX

size, 407 text extents, 424


type, 407 width, 424
value, 407 Fl GDI Printer Graphics Driver, 425
Fl File Input, 408 class name, 425
down box, 409 draw, 425, 426
errorcolor, 409 Fl GIF Image, 426
Fl File Input, 409 Fl GIF Image, 426
Fl File Input, 409 Fl GIF Image, 426
handle, 409 Fl GTK File Chooser, 467
value, 410 Fl Gl Choice, 427
Fl File Sort F Fl Gl Window, 427
File names and URI utility functions, 284 as gl window, 429
Fl Fill Dial, 410 can do, 430
Fl Fill Dial, 411 can do overlay, 430
Fl Fill Dial, 411 context, 430
Fl Fill Slider, 411 context valid, 430
Fl Fill Slider, 411 draw, 430
Fl Fill Slider, 411 Fl Gl Window, 429
Fl Float Input, 412 Fl Gl Window, 429
Fl Float Input, 412 flush, 431
Fl Float Input, 412 hide overlay, 431
Fl Font make current, 431
Enumerations.H, 901 make overlay current, 431
Fl Font Descriptor, 414 mode, 431
Fl Fontdesc, 414 ortho, 431
Fl Fontsize redraw overlay, 432
Enumerations.H, 901 resize, 432
Fl FormsBitmap, 414 show, 432
bitmap, 415 swap buffers, 432
draw, 415 valid, 432
set, 415 Fl Glut Bitmap Font, 433
Fl FormsPixmap, 415 Fl Glut StrokeChar, 433
draw, 416 Fl Glut StrokeFont, 433
Fl FormsPixmap, 416 Fl Glut StrokeStrip, 434
Fl FormsPixmap, 416 Fl Glut StrokeVertex, 434
Pixmap, 416, 418 Fl Glut Window, 434
set, 418 draw, 435
Fl FormsText, 418 draw overlay, 436
draw, 418 Fl Glut Window, 435
Fl Free, 419 Fl Glut Window, 435
draw, 420 Fl Graphics Driver, 436
Fl Free, 419 arc, 443
Fl Free, 419 begin complex polygon, 443
handle, 420 begin line, 444
Fl GDI Graphics Driver, 421 begin loop, 444
class name, 422 begin points, 444
color, 422 begin polygon, 444
descent, 423 circle, 444
draw, 423 class name, 444
draw image, 423 clip box, 444
draw image mono, 424 clip region, 444
font, 424 color, 444, 445
height, 424 curve, 445
rtl draw, 424 descent, 445
INDEX 959

draw, 445, 446 push clip, 448


draw image, 446 push matrix, 449
draw image mono, 446 push no clip, 449
end complex polygon, 446 rect, 449
end line, 446 rectf, 449
end loop, 446 restore clip, 449
end points, 447 rotate, 449
end polygon, 447 rtl draw, 449
Fl Graphics Driver, 443 scale, 449
fl arc, 451 size, 449
fl begin complex polygon, 452 text extents, 449
fl begin points, 452 transform dx, 449
fl circle, 452 transform dy, 450
fl clip box, 452 transform x, 450
fl clip region, 452 transform y, 450
fl color, 453 transformed vertex, 450
fl copy offscreen, 453 translate, 450
fl curve, 453 vertex, 450
fl draw image, 453, 454 width, 450
fl draw image mono, 454, 455 xyline, 450
fl font, 455 yxline, 450, 451
fl gap, 455 Fl Graphics Driver::matrix, 881
fl line style, 455 Fl Group, 459
fl mult matrix, 456 ∼Fl Group, 461
fl not clipped, 456 array, 462
fl pie, 456 as group, 462
fl polygon, 456 begin, 462
fl pop clip, 456 child, 462
fl push clip, 457 clear, 462
fl push matrix, 457 clip children, 462
fl rect, 457 current, 463
fl rotate, 457 draw, 463
fl scale, 457 draw child, 463
fl transform dx, 457 draw children, 463
fl transform dy, 458 draw outside label, 463
fl transform x, 458 end, 463
fl transform y, 458 find, 464
fl transformed vertex, 458 Fl Group, 461
fl translate, 458 Fl Group, 461
fl vertex, 458 focus, 464
Fl Graphics Driver, 443 handle, 464
font, 447 init sizes, 464
gap, 447 insert, 465
height, 447 remove, 465
line, 447 resizable, 465
line style, 447 resize, 466
loop, 447, 448 sizes, 466
mult matrix, 448 update child, 467
not clipped, 448 Fl Help Block, 468
pie, 448 Fl Help Dialog, 468
point, 448 Fl Help Dialog, 469
polygon, 448 Fl Help Dialog, 469
pop clip, 448 h, 469
pop matrix, 448 hide, 469
960 INDEX

load, 469 Fl Image, 484


position, 470 inactive, 486
resize, 470 label, 486
show, 470 ld, 486
textsize, 470 RGB scaling, 486
value, 470 uncache, 486
visible, 470 Fl Image.H, 926
w, 470 Fl RGB Scaling, 926
x, 470 Fl Image Surface, 486
y, 470 class name, 488
Fl Help Font Stack, 471 draw, 488
count, 471 Fl Image Surface, 487
Fl Help Font Stack, 471 Fl Image Surface, 487
Fl Help Font Stack, 471 image, 488
top, 471 set current, 488
Fl Help Font Style, 472 Fl Input, 488
Fl Help Link, 472 draw, 490
Fl Help Target, 473 Fl Input, 489
Fl Help View, 473 Fl Input, 489
∼Fl Help View, 476 handle, 490
clear selection, 476 Fl Input , 490
directory, 476 ∼Fl Input , 494
filename, 477 copy, 494
find, 477 copy cuts, 494
leftline, 477 cursor color, 495
link, 477 cut, 495
load, 477 drawtext, 496
resize, 477 Fl Input , 494
scrollbar size, 477, 478 Fl Input , 494
select all, 478 handle mouse, 496
size, 478 handletext, 496
textcolor, 478 index, 496
textfont, 478 input type, 496
textsize, 478, 479 insert, 497
title, 479 line end, 497
topline, 479 line start, 497
value, 479 mark, 497
Fl Hold Browser, 479 maximum size, 498
Fl Hold Browser, 480 position, 498, 499
Fl Hold Browser, 480 readonly, 499
Fl Hor Fill Slider, 480 replace, 499
Fl Hor Nice Slider, 481 resize, 500
Fl Hor Slider, 481 shortcut, 500
Fl Hor Value Slider, 482 size, 501
Fl Image, 483 static value, 501
color average, 485 tab nav, 502
copy, 485 textcolor, 502
count, 485 textfont, 503
d, 485 textsize, 503
data, 485 undo, 503
desaturate, 485 up down position, 503
draw, 485 value, 504
draw empty, 485 word end, 504
Fl Image, 484 word start, 505
INDEX 961

wrap, 505 size, 526


Fl Input Choice, 505 test shortcut, 526
add, 507 text, 527
changed, 507 textcolor, 527
clear, 507 textfont, 527
clear changed, 508 textsize, 527
Fl Input Choice, 507 value, 527
Fl Input Choice, 507 Fl Menu Bar, 528
input, 508 draw, 529
menu, 508 Fl Menu Bar, 529
menubutton, 508 Fl Menu Bar, 529
resize, 508 handle, 529
set changed, 508 Fl Menu Button, 530
value, 508 draw, 532
Fl Int Input, 509 Fl Menu Button, 532
Fl Int Input, 509 Fl Menu Button, 532
Fl Int Input, 509 handle, 532
Fl JPEG Image, 510 popup, 532
Fl JPEG Image, 510 popup buttons, 531
Fl JPEG Image, 510 Fl Menu Item, 533
Fl Label, 511 activate, 537
draw, 512 active, 537
measure, 512 activevisible, 537
type, 513 add, 537
Fl Labeltype argument, 538
Enumerations.H, 906 callback, 538
Fl Light Button, 513 check, 539
draw, 514 checkbox, 539
Fl Light Button, 514 checked, 539
Fl Light Button, 514 clear, 539
handle, 514 deactivate, 539
Fl Line Dial, 515 do callback, 539
Fl Mac App Menu, 515 draw, 539
print, 516 find shortcut, 540
Fl Menu , 516 first, 540
add, 519, 521 hide, 540
clear, 521 insert, 540
clear submenu, 521 label, 540
copy, 522 labelcolor, 541
down box, 522 labelfont, 541
find index, 522, 523 labelsize, 541
find item, 523 labeltype, 541
Fl Menu , 519 measure, 541
Fl Menu , 519 next, 542
global, 524 popup, 542
insert, 524 pulldown, 542
item pathname, 525 radio, 542
menu, 525 set, 542
mode, 526 setonly, 542
mvalue, 526 shortcut, 542, 543
picked, 526 show, 543
remove, 526 submenu, 543
replace, 526 test shortcut, 543
shortcut, 526 uncheck, 543
962 INDEX

value, 543 Fl PNG Image, 572


visible, 543 Fl PNM Image, 572
Fl Menu Window, 544 Fl PNM Image, 573
∼Fl Menu Window, 545 Fl PNM Image, 573
clear overlay, 545 Fl Pack, 559
Fl Menu Window, 545 draw, 560
Fl Menu Window, 545 Fl Pack, 560
flush, 545 Fl Pack, 560
hide, 545 Fl Paged Device, 560
set overlay, 545 class name, 563
show, 545 end page, 563
Fl Multi Browser, 546 margins, 563
Fl Multi Browser, 546 origin, 563, 564
Fl Multi Browser, 546 Page Format, 562
Fl Multi Label, 547 Page Layout, 562
Fl Multiline Input, 547 print widget, 564
Fl Multiline Input, 548 print window, 564
Fl Multiline Input, 548 print window part, 564
Fl Multiline Output, 548 printable rect, 565
Fl Multiline Output, 549 rotate, 565
Fl Multiline Output, 549 scale, 565
Fl Native File Chooser, 549 start job, 565
∼Fl Native File Chooser, 552 start page, 565
count, 552 translate, 566
directory, 552 Fl Paged Device.cxx, 927
errmsg, 552 Fl Paged Device.H, 928
filename, 552, 553 Fl Paged Device::page format, 883
filter, 553 Fl Pixmap, 566
filter value, 553 color average, 568
Fl Native File Chooser, 552 copy, 568
Fl Native File Chooser, 552 desaturate, 568
Option, 551 draw, 568
options, 553 Fl Pixmap, 567
preset file, 554 Fl Pixmap, 567
show, 554 label, 568
title, 554 uncache, 568
Type, 552 Fl Plugin, 569
Fl Native File Chooser.H, 927 Fl Plugin, 569
Fl Nice Slider, 554 Fl Plugin, 569
Fl Option Fl Plugin Manager, 570
Fl, 300 ∼Fl Plugin Manager, 571
Fl Output, 555 addPlugin, 571
Fl Output, 556 load, 571
Fl Output, 556 removePlugin, 571
Fl Overlay Window, 556 Fl Positioner, 573
draw overlay, 558 draw, 575
Fl Overlay Window, 558 Fl Positioner, 574
Fl Overlay Window, 558 Fl Positioner, 574
hide, 558 handle, 575
redraw overlay, 558 value, 575
resize, 558 xbounds, 575
show, 558 xstep, 575
Fl PNG Image, 571 xvalue, 575
Fl PNG Image, 572 ybounds, 575
INDEX 963

ystep, 576 rtl draw, 589


yvalue, 576 text extents, 589
Fl PostScript.H, 928 transformed vertex, 589
Fl PostScript Close Command, 929 vertex, 589
Fl PostScript Close Command width, 589
Fl PostScript.H, 929 xyline, 589
Fl PostScript File Device, 576 yxline, 589, 590
class name, 578 Fl PostScript Printer, 590
end page, 578 class name, 591
margins, 578 start job, 591
origin, 578 Fl Preferences, 591
printable rect, 579 ∼Fl Preferences, 596
rotate, 579 deleteEntry, 596
scale, 579 deleteGroup, 596
start job, 579, 580 entries, 597
start page, 580 entry, 597
translate, 580 entryExists, 597
Fl PostScript Graphics Driver, 581 Fl Preferences, 595, 596
arc, 584 Fl Preferences, 595, 596
begin complex polygon, 584 flush, 597
begin line, 584 get, 597–599
begin loop, 584 getUserdataPath, 600
begin points, 584 group, 600
begin polygon, 584 groupExists, 600
circle, 584 groups, 601
class name, 584 ID, 594
clip box, 585 newUUID, 601
clocale printf, 585 Root, 594
color, 585 set, 601–603
curve, 585 size, 603
descent, 585 Fl Preferences::Entry, 291
draw, 585, 586 Fl Preferences::Name, 882
draw image, 586 Name, 882
draw image mono, 586 Fl Preferences::Node, 883
end complex polygon, 586 Fl Preferences::RootNode, 884
end line, 587 Fl Printer, 603
end loop, 587 class name, 606
end points, 587 end page, 606
end polygon, 587 margins, 606
font, 587 origin, 606, 607
gap, 587 print widget, 607
height, 587 print window part, 607
line, 587 printable rect, 607
line style, 587 rotate, 608
loop, 587, 588 scale, 608
not clipped, 588 set current, 608
pie, 588 start job, 608
point, 588 start page, 608
polygon, 588 translate, 609
pop clip, 588 Fl Printer.H, 930
push clip, 588 Fl Progress, 609
push no clip, 588 draw, 610
rect, 588 Fl Progress, 610
rectf, 589 Fl Progress, 610
964 INDEX

maximum, 610 Fl Round Clock, 628


minimum, 610 Fl Scroll, 628
value, 610 bbox, 630
Fl Quartz Graphics Driver, 611 clear, 631
class name, 612 draw, 631
color, 612 Fl Scroll, 630
descent, 612 Fl Scroll, 630
draw, 612, 613 handle, 631
draw image, 613 resize, 631
draw image mono, 613 scroll to, 631
font, 613 scrollbar size, 632
height, 613 xposition, 632
rtl draw, 614 yposition, 632
text extents, 614 Fl Scroll::ScrollInfo::Fl Region LRTB, 616
width, 614 Fl Scroll::ScrollInfo::Fl Region XYWH, 617
Fl RGB Image, 620 Fl Scroll::ScrollInfo::Fl Scrollbar Data, 635
∼Fl RGB Image, 623 Fl Scrollbar, 632
color average, 623 ∼Fl Scrollbar, 634
copy, 623 draw, 634
desaturate, 623 Fl Scrollbar, 634
draw, 623 Fl Scrollbar, 634
Fl RGB Image, 622, 623 handle, 634
Fl RGB Image, 622, 623 linesize, 635
label, 624 value, 635
max size, 624 Fl Secret Input, 636
uncache, 624 Fl Secret Input, 637
Fl RGB Scaling Fl Secret Input, 637
Fl Image.H, 926 handle, 637
Fl Radio Button, 614 Fl Select Browser, 637
Fl Radio Button, 615 Fl Select Browser, 638
Fl Radio Button, 615 Fl Select Browser, 638
Fl Radio Light Button, 615 Fl Shared Image, 638
Fl Radio Round Button, 615 ∼Fl Shared Image, 640
Fl Radio Round Button, 616 color average, 641
Fl Radio Round Button, 616 copy, 641
Fl Repeat Button, 617 desaturate, 641
Fl Repeat Button, 618 draw, 641
Fl Repeat Button, 618 Fl Shared Image, 640
handle, 618 Fl Shared Image, 640
Fl Return Button, 618 get, 641
draw, 619 num images, 641
Fl Return Button, 619 refcount, 641
Fl Return Button, 619 release, 642
handle, 620 uncache, 642
Fl Roller, 624 Fl Shared Image.H, 931
draw, 625 fl register images, 932
Fl Roller, 625 Fl Simple Counter, 642
Fl Roller, 625 Fl Single Window, 643
handle, 626 flush, 644
Fl Round Button, 626 show, 644
Fl Round Button, 627 Fl Slider, 644
Fl Round Button, 627 bounds, 646
Fl Round Clock, 627 draw, 646
Fl Round Clock, 628 Fl Slider, 646
INDEX 965

Fl Slider, 646 Fl Table, 661


handle, 646 ∼Fl Table, 669
scrollvalue, 646 callback, 669
slider, 647 callback col, 670
slider size, 647 callback context, 670
Fl Spinner, 647 callback row, 670
Fl Spinner, 649 child, 670
Fl Spinner, 649 children, 670
format, 649 clear, 670
handle, 649 col header, 671
maximum, 650 col resize, 671
maxinum, 650 col resize min, 671
minimum, 650 col width, 671
mininum, 650 col width all, 671
range, 650 draw, 671
resize, 650 draw cell, 671
step, 650 Fl Table, 669
textcolor, 651 Fl Table, 669
textfont, 651 get selection, 674
textsize, 651 handle, 674
type, 651 is interactive resize, 675
value, 651 is selected, 675
Fl String row header, 675
fl types.h, 935 row height, 675
Fl Surface Device, 652 row height all, 675
∼Fl Surface Device, 652 row resize, 675
class name, 653 row resize min, 675
driver, 653 set selection, 675
Fl Surface Device, 652 table box, 676
Fl Surface Device, 652 TableContext, 668
set current, 653 top row, 676
Fl Sys Menu Bar, 653 visible cells, 676
add, 655 when, 676
clear, 655 Fl Table Row, 677
clear submenu, 656 ∼Fl Table Row, 678
draw, 656 clear, 678
Fl Sys Menu Bar, 655 Fl Table Row, 678
Fl Sys Menu Bar, 655 Fl Table Row, 678
insert, 656 handle, 678
menu, 656 row selected, 679
mode, 657 select all rows, 679
remove, 657 select row, 679
replace, 657 type, 679
Fl System Printer, 657 Fl Tabs, 680
class name, 659 client area, 684
end page, 659 draw, 684
margins, 659 Fl Tabs, 684
origin, 659 Fl Tabs, 684
printable rect, 660 handle, 684
rotate, 660 push, 685
scale, 660 value, 685
start job, 660 which, 686
start page, 660 Fl Text Buffer, 686
translate, 661 add modify callback, 691
966 INDEX

address, 691, 693 cursor style, 712


append, 693 display insert, 712
appendfile, 693 draw, 712
byte at, 693 draw cursor, 712
char at, 693 draw line numbers, 712
copy, 694 draw range, 713
count displayed characters, 694 draw string, 713
count lines, 694 draw text, 713
file encoding warning message, 700 draw vline, 713
findchar backward, 694 empty vlines, 714
findchar forward, 694 extend range for styles, 714
Fl Text Buffer, 691 find line end, 714
Fl Text Buffer, 691 find wrap range, 714
highlight, 695 find x, 716
highlight text, 695 Fl Text Display, 709
insert, 695 Fl Text Display, 709
insert , 695 get absolute top line number, 716
insertfile, 695 handle vline, 716
length, 695 highlight data, 717
line end, 696 in selection, 717
line start, 696 insert, 717
line text, 696 insert position, 718
loadfile, 696 line end, 718
mPredeleteProcs, 700 line start, 718
mTabDist, 700 linenumber align, 719
next char, 696 linenumber bgcolor, 719
outputfile, 697 linenumber fgcolor, 719
prev char, 697 linenumber font, 719
remove, 697 linenumber format, 719
remove , 697 linenumber size, 719
replace, 697 linenumber width, 720
rewind lines, 697 longest vline, 720
search backward, 697 maintain absolute top line number, 720
search forward, 698 maintaining absolute top line number, 720
secondary selection text, 698 measure deleted lines, 720
selection text, 698 measure proportional character, 721
skip displayed characters, 698 measure vline, 721
text, 698, 699 move down, 721
text range, 699 move left, 721
transcoding warning action, 700 move right, 721
word end, 699 move up, 722
word start, 699 offset line starts, 722
Fl Text Display, 700 overstrike, 722
∼Fl Text Display, 709 position style, 722
absolute top line number, 709 position to line, 723
buffer, 709 position to linecol, 723
buffer modified cb, 710 position to xy, 723
buffer predelete cb, 710 redisplay range, 724
calc last char, 710 reset absolute top line number, 724
calc line starts, 710 resize, 724
clear rect, 711 rewind lines, 724
col to x, 711 scroll, 724
count lines, 711 scroll , 725
cursor color, 711 scroll timer cb, 725
INDEX 967

scrollbar align, 725 Fl Text Editor::Key Binding, 881


scrollbar width, 725 Fl Text Selection, 738
shortcut, 726 end, 738
show cursor, 726 position, 738
show insert position, 726 selected, 740
skip lines, 726 set, 740
string width, 726 start, 740
textcolor, 727 update, 740
textfont, 727 Fl Tile, 741
textsize, 727 Fl Tile, 742
update h scrollbar, 728 Fl Tile, 742
update line starts, 728 handle, 742
update v scrollbar, 728 position, 743
vline length, 728 resize, 743
word end, 728 Fl Tiled Image, 743
word start, 728 color average, 744
wrap mode, 730 copy, 744
wrap uses character, 730 desaturate, 745
wrapped column, 730 draw, 745
wrapped line counter, 731 Fl Tiled Image, 744
wrapped row, 731 Fl Tiled Image, 744
x to col, 732 Fl Timer, 745
xy to position, 732 direction, 746
xy to rowcol, 732 draw, 746
Fl Text Display::Style Table Entry, 884 Fl Timer, 746
Fl Text Editor, 733 Fl Timer, 746
add default key bindings, 735 handle, 747
bound key function, 735 suspended, 747
default key function, 736 Fl Toggle Button, 747
Fl Text Editor, 735 Fl Toggle Button, 748
Fl Text Editor, 735 Fl Toggle Button, 748
insert mode, 736 Fl Tooltip, 748
kf backspace, 736 color, 750
kf c s move, 736 current, 750
kf copy, 736 delay, 750
kf cut, 736 disable, 750
kf delete, 736 enable, 750
kf down, 736 enabled, 750
kf end, 736 enter area, 750
kf home, 736 font, 751
kf insert, 736 hoverdelay, 751
kf left, 736 size, 751
kf m s move, 736 textcolor, 751
kf move, 737 Fl Tree, 752
kf page down, 737 add, 762
kf page up, 737 callback item, 763
kf paste, 737 callback reason, 763
kf right, 737 clear, 763
kf select all, 737 clear children, 763
kf shift move, 737 close, 763, 764
kf undo, 737 closeicon, 765
kf up, 737 connectorstyle, 765
remove all key bindings, 737 deselect, 765, 766
remove key binding, 737 deselect all, 766
968 INDEX

display, 767 show item bottom, 785


displayed, 767 show item middle, 786
extend selection, 767 show item top, 786
extend selection dir, 767 show self, 786
find clicked, 768 showcollapse, 786
find item, 768 showroot, 786
first, 768 sortorder, 786
first selected item, 769 usericon, 786, 787
first visible, 769 usericonmarginleft, 787
first visible item, 769 vposition, 787
handle, 769 Fl Tree.H, 932
hposition, 770 Fl Tree Reason, 933
insert, 770 Fl Tree Connector
insert above, 770 Fl Tree Prefs.H, 934
is close, 771 Fl Tree Item, 787
is hscroll visible, 771 activate, 793
is open, 772 add, 793
is scrollbar, 772 calc item height, 794
is selected, 773 child, 794
is vscroll visible, 773 deactivate, 794
item clicked, 773 deparent, 794
item labelbgcolor, 774 depth, 794
item labelfgcolor, 774 deselect all, 794
item labelfont, 774 draw, 795
item labelsize, 774 draw horizontal connector, 795
item pathname, 774 draw vertical connector, 795
labelmarginleft, 775 find child, 795
last, 775 find child item, 796
last selected item, 775 find clicked, 796
last visible, 775 find item, 796
last visible item, 775 Fl Tree Item, 792
load, 776 Fl Tree Item, 792
next, 776 hide widgets, 796
next item, 776 insert, 797
next selected item, 777, 778 insert above, 797
next visible item, 778 label, 797
open, 779 label h, 797
open toggle, 780 label w, 797
openicon, 780 label x, 797
prev, 781 label y, 797
recalc tree, 781 labelbgcolor, 797, 798
remove, 781 move, 798
resize, 781 move above, 798
root, 781 move below, 798
root label, 782 move into, 799
scrollbar size, 782 next, 799
select, 782, 783 next displayed, 799
select all, 783 next sibling, 799
select only, 784 next visible, 799
select toggle, 784 parent, 799
selectbox, 784, 785 prev, 800
selectmode, 785 prev displayed, 800
set item focus, 785 prev sibling, 800
show item, 785 prev visible, 800
INDEX 969

recalc tree, 800 round, 813


remove child, 800, 801 set value, 813
reparent, 801 step, 814
select, 801 value, 814
select all, 801 Fl Value Input, 814
show self, 801 cursor color, 816
show widgets, 801 draw, 816
swap children, 801, 803 Fl Value Input, 816
update prev next, 803 Fl Value Input, 816
visible r, 803 handle, 816
w, 803 resize, 817
Fl Tree Item.H, 933 shortcut, 817
Fl Tree Item Array, 803 soft, 817
add, 805 textcolor, 818
clear, 805 textfont, 818
deparent, 805 textsize, 818
Fl Tree Item Array, 804 Fl Value Output, 818
Fl Tree Item Array, 804 draw, 820
insert, 805 Fl Value Output, 819
move, 805 Fl Value Output, 819
remove, 805 handle, 820
reparent, 805 soft, 820
replace, 806 textcolor, 820
Fl Tree Item Array.H, 933 textfont, 820, 821
Fl Tree Prefs, 806 textsize, 821
closeicon, 808 Fl Value Slider, 821
openicon, 809 draw, 822
selectmode, 809 Fl Value Slider, 822
showcollapse, 809 Fl Value Slider, 822
showroot, 809 handle, 822
sortorder, 809 textcolor, 823
Fl Tree Prefs.H, 934 textfont, 823
Fl Tree Connector, 934 textsize, 823
Fl Tree Select, 934 Fl When
Fl Tree Sort, 935 Enumerations.H, 906
Fl Tree Reason Fl Widget, 823
Fl Tree.H, 933 ∼Fl Widget, 831
Fl Tree Select activate, 831
Fl Tree Prefs.H, 934 active, 831
Fl Tree Sort active r, 833
Fl Tree Prefs.H, 935 align, 833
Fl Valuator, 810 argument, 833
bounds, 812 as gl window, 833
clamp, 812 as group, 834
Fl Valuator, 812 as window, 834
Fl Valuator, 812 box, 834, 835
format, 812 callback, 835, 836
handle drag, 813 changed, 836
handle release, 813 clear active, 836
increment, 813 clear changed, 836
maximum, 813 clear damage, 836
minimum, 813 clear output, 837
precision, 813 clear visible, 837
range, 813 clear visible focus, 837
970 INDEX

color, 837, 839 when, 855


color2, 839 window, 856
contains, 839 x, 856
copy label, 839 y, 856
copy tooltip, 840 Fl Widget.H, 938
damage, 840 FL RESERVED TYPE, 939
damage resize, 841 fl intptr t, 939
deactivate, 841 Fl Widget Tracker, 857
default callback, 841 deleted, 857
deimage, 841, 842 exists, 857
do callback, 842 widget, 858
draw, 842 Fl Window, 858
draw box, 843 ∼Fl Window, 863
draw label, 843 as window, 863
Fl Widget, 831 border, 863
Fl Widget, 831 clear border, 863
h, 843 clear modal states, 863
handle, 843 current, 864
hide, 844 current , 874
image, 844 cursor, 864
inside, 845 decorated h, 864
label, 845 decorated w, 864
label shortcut, 845 default cursor, 864, 865
labelcolor, 846 default icon, 865
labelfont, 846 default icons, 865
labelsize, 847 default xclass, 865, 866
labeltype, 847 draw, 866
measure label, 847 Fl Window, 862
output, 848 Fl Window, 862
parent, 848 flush, 866
position, 848 force position, 866
redraw, 849 free icons, 867
redraw label, 849 free position, 867
resize, 849 fullscreen, 867
selection color, 849 fullscreen screens, 867
set active, 850 handle, 867
set changed, 850 hide, 868
set output, 850 hotspot, 868
set visible, 850 icon, 868
set visible focus, 850 iconize, 868
show, 850 iconlabel, 869
size, 851 icons, 869
take focus, 851 label, 869
takesevents, 851 make current, 869
test shortcut, 851, 852 menu window, 869
tooltip, 852 modal, 869
top window, 853 non modal, 869
top window offset, 853 override, 870
type, 853 resize, 870
user data, 853 set menu window, 870
visible, 854 set modal, 870
visible focus, 854 set non modal, 870
visible r, 854 set tooltip window, 870
w, 854 shape, 871
INDEX 971

show, 871, 872 fl begin points


shown, 872 Drawing functions, 242
size range, 872 Fl Graphics Driver, 452
tooltip window, 873 fl box
wait for expose, 873 Enumerations.H, 907
xclass, 873 fl boxtype.cxx, 915
Fl Window.H, 939 fl internal boxtype, 916
Fl Window::shape data type, 884 fl rectbound, 916
Fl Wizard, 874 fl can do alpha blending
Fl Wizard, 875 Drawing functions, 242
Fl Wizard, 875 fl choice
next, 875 Common Dialogs classes and functions, 275
prev, 875 fl circle
value, 875 Drawing functions, 243
Fl XBM Image, 876 Fl Graphics Driver, 452
Fl XBM Image, 876 fl clip
Fl XBM Image, 876 Drawing functions, 240
Fl XColor, 876 fl clip box
Fl XPM Image, 880 Drawing functions, 243
Fl XPM Image, 881 Fl Graphics Driver, 452
Fl XPM Image, 881 fl clip region
Fl Xlib Graphics Driver, 877 Drawing functions, 243
class name, 878 Fl Graphics Driver, 452
color, 878 fl color
descent, 878 Color & Font functions, 229, 230
draw, 878, 879 Fl Graphics Driver, 453
draw image, 879 fl color.cxx, 916
draw image mono, 879 fl color average
font, 879 Color & Font functions, 230
height, 879 fl color chooser
rtl draw, 880 Common Dialogs classes and functions, 275,
text extents, 880 276
width, 880 fl color cube
fl add symbol Enumerations.H, 907
Drawing functions, 241 Fl compose.cxx, 918
fl alert fl contrast
Common Dialogs classes and functions, 274 Color & Font functions, 230
fl arc fl copy offscreen
Drawing functions, 241, 242 Drawing functions, 243
Fl Graphics Driver, 451 Fl Graphics Driver, 453
fl arc.cxx, 911 fl create offscreen
fl arci.cxx, 911 Drawing functions, 244
fl ask fl cursor
Common Dialogs classes and functions, 274 Drawing functions, 244
fl ask.cxx, 912 fl curve
fl ask.H, 913 Drawing functions, 244
Fl Beep, 914 Fl Graphics Driver, 453
fl beep fl curve.cxx, 918
Common Dialogs classes and functions, 275 fl darker
fl begin complex polygon Enumerations.H, 907
Drawing functions, 242 fl decode uri
Fl Graphics Driver, 452 File names and URI utility functions, 284
fl begin offscreen fl delete offscreen
Drawing functions, 242 Drawing functions, 244
972 INDEX

fl dir chooser fl fopen


Common Dialogs classes and functions, 277 Unicode and UTF-8 functions, 264
fl down fl frame
Enumerations.H, 907 Drawing functions, 247
fl draw Enumerations.H, 907
Drawing functions, 244 fl frame2
fl draw.H, 920 Drawing functions, 247
fl draw box fl gap
Drawing functions, 245 Drawing functions, 248
fl draw image Fl Graphics Driver, 455
Drawing functions, 245 fl gray ramp
Fl Graphics Driver, 453, 454 Enumerations.H, 907
fl draw image mono fl height
Drawing functions, 246 Color & Font functions, 231
Fl Graphics Driver, 454, 455 fl input
fl draw pixmap Common Dialogs classes and functions, 279
Drawing functions, 246, 247 fl internal boxtype
fl draw symbol fl boxtype.cxx, 916
Drawing functions, 247 fl intptr t
fl eventnames Fl Widget.H, 939
Events handling functions, 219 fl latin1 to local
fl expand text Color & Font functions, 231
Drawing functions, 247 fl lighter
fl file chooser Enumerations.H, 907
Common Dialogs classes and functions, 277 fl line style
fl file chooser callback Drawing functions, 248
Common Dialogs classes and functions, 278 Fl Graphics Driver, 455
fl file chooser ok label fl line style.cxx, 927
Common Dialogs classes and functions, 278 fl local to latin1
fl filename absolute Color & Font functions, 231
File names and URI utility functions, 284 fl local to mac roman
fl filename expand Color & Font functions, 231
File names and URI utility functions, 284 fl mac roman to local
fl filename ext Color & Font functions, 232
File names and URI utility functions, 285 fl mac set about
fl filename free list Mac OS X-specific symbols, 271
File names and URI utility functions, 285 fl measure
fl filename isdir Drawing functions, 248
File names and URI utility functions, 285 fl measure pixmap
fl filename list Drawing functions, 249
File names and URI utility functions, 285 fl message
fl filename match Common Dialogs classes and functions, 279
File names and URI utility functions, 287 fl message hotspot
fl filename name Common Dialogs classes and functions, 279,
File names and URI utility functions, 287 280
fl filename relative fl message icon
File names and URI utility functions, 287 Common Dialogs classes and functions, 280
fl filename setext fl message title
File names and URI utility functions, 288 Common Dialogs classes and functions, 280
fl font fl message title default
Color & Font functions, 230 Common Dialogs classes and functions, 280
Fl Graphics Driver, 455 fl mult matrix
fl fontnames Drawing functions, 249
Events handling functions, 220 Fl Graphics Driver, 456
INDEX 973

fl nonspacing fl set spot


Unicode and UTF-8 functions, 264 Drawing functions, 253
fl not clipped fl set status
Drawing functions, 249 Drawing functions, 253
Fl Graphics Driver, 456 fl shortcut label
fl old shortcut Drawing functions, 253
Drawing functions, 249 fl show colormap
fl open Color & Font functions, 232
Unicode and UTF-8 functions, 264 fl show colormap.H, 932
fl open callback fl size
Mac OS X-specific symbols, 271 Color & Font functions, 233
fl open uri fl text extents
File names and URI utility functions, 288 Color & Font functions, 233
fl password fl transform dx
Common Dialogs classes and functions, 281 Drawing functions, 253
fl pie Fl Graphics Driver, 457
Drawing functions, 250 fl transform dy
Fl Graphics Driver, 456 Drawing functions, 254
fl polygon Fl Graphics Driver, 458
Drawing functions, 251 fl transform x
Fl Graphics Driver, 456 Drawing functions, 254
fl pop clip Fl Graphics Driver, 458
Drawing functions, 251 fl transform y
Fl Graphics Driver, 456 Drawing functions, 254
fl push clip Fl Graphics Driver, 458
Drawing functions, 251 fl transformed vertex
Fl Graphics Driver, 457 Drawing functions, 254
fl push matrix Fl Graphics Driver, 458
Drawing functions, 251 fl translate
Fl Graphics Driver, 457 Drawing functions, 254
fl read image Fl Graphics Driver, 458
Drawing functions, 251 fl types.h, 935
fl rect Fl CString, 935
Drawing functions, 251 Fl String, 935
Fl Graphics Driver, 457 fl ucs to Utf16
fl rect.cxx, 931 Unicode and UTF-8 functions, 264
fl rectbound fl utf8.h, 936
fl boxtype.cxx, 916 fl utf8back
fl rectf Unicode and UTF-8 functions, 265
Drawing functions, 252 fl utf8bytes
fl register images Unicode and UTF-8 functions, 265
Fl Shared Image.H, 932 fl utf8decode
fl reset spot Unicode and UTF-8 functions, 265
Drawing functions, 252 fl utf8encode
fl rgb color Unicode and UTF-8 functions, 265
Enumerations.H, 908 fl utf8from mb
fl rotate Unicode and UTF-8 functions, 266
Drawing functions, 252 fl utf8froma
Fl Graphics Driver, 457 Unicode and UTF-8 functions, 266
fl scale fl utf8fromwc
Drawing functions, 252 Unicode and UTF-8 functions, 266
Fl Graphics Driver, 457 fl utf8fwd
fl scroll Unicode and UTF-8 functions, 266
Drawing functions, 252 fl utf8len
974 INDEX

Unicode and UTF-8 functions, 267 Fl Window, 866


fl utf8len1 foreground
Unicode and UTF-8 functions, 267 Fl, 305
fl utf8locale format
Unicode and UTF-8 functions, 267 Fl Spinner, 649
fl utf8test Fl Valuator, 812
Unicode and UTF-8 functions, 267 format char
fl utf8to mb Fl Browser, 326, 327
Unicode and UTF-8 functions, 267 free color
fl utf8toUtf16 Color & Font functions, 234
Unicode and UTF-8 functions, 268 free icons
fl utf8toa Fl Window, 867
Unicode and UTF-8 functions, 268 free position
fl utf8towc Fl Window, 867
Unicode and UTF-8 functions, 268 full height
fl utf strcasecmp Fl Browser, 327
Unicode and UTF-8 functions, 269 Fl Browser , 344
fl utf strncasecmp full width
Unicode and UTF-8 functions, 269 Fl Browser , 344
fl utf tolower fullscreen
Unicode and UTF-8 functions, 269 Fl Window, 867
fl utf toupper fullscreen screens
Unicode and UTF-8 functions, 269 Fl Window, 867
fl vertex
Drawing functions, 254 g
Fl Graphics Driver, 458 Fl Color Chooser, 379
fl vertex.cxx, 938 GROUP RELATIVE
fl wcwidth Fl Widget, 831
Unicode and UTF-8 functions, 269 gap
fl wcwidth Fl Graphics Driver, 447
Unicode and UTF-8 functions, 269 Fl PostScript Graphics Driver, 587
fl width get
Color & Font functions, 233 Fl Preferences, 597–599
fl xpixel Fl Shared Image, 641
Color & Font functions, 233, 234 get absolute top line number
flush Fl Text Display, 716
Fl, 305 get awake handler
Fl Double Window, 392 Fl, 305
Fl Gl Window, 431 get boxtype
Fl Menu Window, 545 Fl, 305
Fl Preferences, 597 get color
Fl Single Window, 644 Color & Font functions, 234
Fl Window, 866 get font
focus Color & Font functions, 234
Events handling functions, 217 get font name
Fl Group, 464 Color & Font functions, 234
font get font sizes
Fl GDI Graphics Driver, 424 Color & Font functions, 234
Fl Graphics Driver, 447 get key
Fl PostScript Graphics Driver, 587 Events handling functions, 217
Fl Quartz Graphics Driver, 613 get mouse
Fl Tooltip, 751 Events handling functions, 217
Fl Xlib Graphics Driver, 879 get selection
force position Fl Table, 674
INDEX 975

get system colors Fl Free, 420


Fl, 305 Fl Group, 464
getUserdataPath Fl Input, 490
Fl Preferences, 600 Fl Light Button, 514
gl.h, 939 Fl Menu Bar, 529
gl color, 941 Fl Menu Button, 532
gl draw, 941 Fl Positioner, 575
gl rect, 942 Fl Repeat Button, 618
gl rectf, 942 Fl Return Button, 620
gl color Fl Roller, 626
gl.h, 941 Fl Scroll, 631
gl draw Fl Scrollbar, 634
gl.h, 941 Fl Secret Input, 637
gl rect Fl Slider, 646
gl.h, 942 Fl Spinner, 649
gl rectf Fl Table, 674
gl.h, 942 Fl Table Row, 678
gl texture pile height Fl Tabs, 684
Mac OS X-specific symbols, 271, 272 Fl Tile, 742
gl visual Fl Timer, 747
Fl, 305 Fl Tree, 769
global Fl Value Input, 816
Fl Menu , 524 Fl Value Output, 820
grab Fl Value Slider, 822
Windows handling functions, 205, 206 Fl Widget, 843
group Fl Window, 867
Fl Preferences, 600 handle
groupExists Events handling functions, 218
Fl Preferences, 600 handle drag
groups Fl Valuator, 813
Fl Preferences, 601 handle mouse
Fl Input , 496
h handle release
Fl Help Dialog, 469 Fl Valuator, 813
Fl Widget, 843 handle vline
Screen functions, 224 Fl Text Display, 716
HEAVY CURSOR handletext
Fl Text Display, 708 Fl Input , 496
HORIZONTAL has scrollbar
Fl Browser , 342 Fl Browser , 345
HORIZONTAL ALWAYS height
Fl Browser , 342 Fl GDI Graphics Driver, 424
handle Fl Graphics Driver, 447
Events handling functions, 218 Fl PostScript Graphics Driver, 587
Fl Adjuster, 313 Fl Quartz Graphics Driver, 613
Fl Box, 319 Fl Xlib Graphics Driver, 879
Fl Browser , 344 help
Fl Button, 355 Fl, 311
Fl Check Browser, 365 hide
Fl Choice, 370 Fl Browser, 327, 328
Fl Clock, 373 Fl Double Window, 392
Fl Counter, 384 Fl File Chooser, 401
Fl Dial, 389 Fl Help Dialog, 469
Fl File Input, 409 Fl Menu Item, 540
976 INDEX

Fl Menu Window, 545 Fl Widget, 844


Fl Overlay Window, 558 in selection
Fl Widget, 844 Fl Text Display, 717
Fl Window, 868 inactive
hide overlay Fl Image, 486
Fl Gl Window, 431 incr height
hide widgets Fl Browser, 328
Fl Tree Item, 796 Fl Browser , 345
highlight increment
Fl Text Buffer, 695 Fl Valuator, 813
highlight data index
Fl Text Display, 717 Fl Input , 496
highlight text init sizes
Fl Text Buffer, 695 Fl Group, 464
hotspot input
Fl Window, 868 Fl Input Choice, 508
hour input type
Fl Clock Output, 376 Fl Input , 496
hoverdelay insert
Fl Tooltip, 751 Fl Browser, 328, 329
hposition Fl Chart, 362
Fl Browser , 345 Fl Group, 465
Fl Tree, 770 Fl Input , 497
hscrollbar Fl Menu , 524
Fl Browser , 352 Fl Menu Item, 540
hsv Fl Sys Menu Bar, 656
Fl Color Chooser, 379 Fl Text Buffer, 695
hsv2rgb Fl Text Display, 717
Fl Color Chooser, 379 Fl Tree, 770
hue Fl Tree Item, 797
Fl Color Chooser, 379 Fl Tree Item Array, 805
insert
INACTIVE Fl Text Buffer, 695
Fl Widget, 830 insert above
INVISIBLE Fl Tree, 770
Fl Widget, 830 Fl Tree Item, 797
ID insert mode
Fl Preferences, 594 Fl Text Editor, 736
icon insert position
Fl Browser, 328 Fl Text Display, 718
Fl Window, 868 insertfile
iconize Fl Text Buffer, 695
Fl Window, 868 inserting
iconlabel Fl Browser , 345
Fl Window, 869 inside
icons Fl Widget, 845
Fl Window, 869 is close
iconsize Fl Tree, 771
Fl File Browser, 395 is hscroll visible
Fl File Chooser, 401 Fl Tree, 771
idle is interactive resize
Fl, 311 Fl Table, 675
image is open
Fl Image Surface, 488 Fl Tree, 772
INDEX 977

is scheme Fl Browser, 333


Fl, 306 Fl Browser , 348
is scrollbar item width
Fl Tree, 772 Fl Browser, 333
is selected Fl Browser , 348
Fl Table, 675
Fl Tree, 773 kf backspace
is vscroll visible Fl Text Editor, 736
Fl Tree, 773 kf c s move
item at Fl Text Editor, 736
Fl Browser, 329 kf copy
Fl Browser , 346 Fl Text Editor, 736
item clicked kf cut
Fl Tree, 773 Fl Text Editor, 736
item draw kf delete
Fl Browser, 329 Fl Text Editor, 736
item first kf down
Fl Browser, 329 Fl Text Editor, 736
Fl Browser , 346 kf end
item height Fl Text Editor, 736
Fl Browser, 330 kf home
Fl Browser , 346 Fl Text Editor, 736
item labelbgcolor kf insert
Fl Tree, 774 Fl Text Editor, 736
item labelfgcolor kf left
Fl Tree, 774 Fl Text Editor, 736
item labelfont kf m s move
Fl Tree, 774 Fl Text Editor, 736
item labelsize kf move
Fl Tree, 774 Fl Text Editor, 737
item last kf page down
Fl Browser, 330 Fl Text Editor, 737
Fl Browser , 346 kf page up
item next Fl Text Editor, 737
Fl Browser, 330 kf paste
Fl Browser , 346 Fl Text Editor, 737
item pathname kf right
Fl Menu , 525 Fl Text Editor, 737
Fl Tree, 774 kf select all
item prev Fl Text Editor, 737
Fl Browser, 331 kf shift move
Fl Browser , 347 Fl Text Editor, 737
item quick height kf undo
Fl Browser , 347 Fl Text Editor, 737
item select kf up
Fl Browser, 331 Fl Text Editor, 737
Fl Browser , 347
item selected LANDSCAPE
Fl Browser, 331 Fl Paged Device, 563
Fl Browser , 347 LETTER
item swap Fl Paged Device, 562
Fl Browser, 331 label
Fl Browser , 348 Fl Bitmap, 317
item text Fl File Chooser, 401
978 INDEX

Fl File Icon, 406 line end


Fl Image, 486 Fl Input , 497
Fl Menu Item, 540 Fl Text Buffer, 696
Fl Pixmap, 568 Fl Text Display, 718
Fl RGB Image, 624 line start
Fl Tree Item, 797 Fl Input , 497
Fl Widget, 845 Fl Text Buffer, 696
Fl Window, 869 Fl Text Display, 718
label h line style
Fl Tree Item, 797 Fl Graphics Driver, 447
label shortcut Fl PostScript Graphics Driver, 587
Fl Widget, 845 line text
label w Fl Text Buffer, 696
Fl Tree Item, 797 lineno
label x Fl Browser, 333
Fl Tree Item, 797 linenumber align
label y Fl Text Display, 719
Fl Tree Item, 797 linenumber bgcolor
labelbgcolor Fl Text Display, 719
Fl Tree Item, 797, 798 linenumber fgcolor
labelcolor Fl Text Display, 719
Fl Menu Item, 541 linenumber font
Fl Widget, 846 Fl Text Display, 719
labelfont linenumber format
Fl Menu Item, 541 Fl Text Display, 719
Fl Widget, 846 linenumber size
labelmarginleft Fl Text Display, 719
Fl Tree, 775 linenumber width
labelsize Fl Text Display, 720
Fl Menu Item, 541 lineposition
Fl Widget, 847 Fl Browser, 333
labeltype linesize
Fl File Icon, 406 Fl Scrollbar, 635
Fl Menu Item, 541 link
Fl Widget, 847 Fl Help View, 477
last load
Fl Tree, 775 Fl Browser, 334
last selected item Fl File Browser, 395
Fl Tree, 775 Fl File Icon, 406
last visible Fl Help Dialog, 469
Fl Tree, 775 Fl Help View, 477
last visible item Fl Plugin Manager, 571
Fl Tree, 775 Fl Tree, 776
ld load fti
Fl Image, 486 Fl File Icon, 406
leftedge load image
Fl Browser , 348 Fl File Icon, 407
leftline load system icons
Fl Help View, 477 Fl File Icon, 407
length loadfile
Fl Text Buffer, 695 Fl Text Buffer, 696
line lock
Fl Graphics Driver, 447 Multithreading support functions, 255
Fl PostScript Graphics Driver, 587 longest vline
INDEX 979

Fl Text Display, 720 Fl Menu Item, 541


loop measure deleted lines
Fl Graphics Driver, 447, 448 Fl Text Display, 720
Fl PostScript Graphics Driver, 587, 588 measure label
lstep Fl Widget, 847
Fl Counter, 385 measure proportional character
Fl Text Display, 721
MAC USE ACCENTS MENU measure vline
Fl Widget, 831 Fl Text Display, 721
MENU WINDOW menu
Fl Widget, 831 Fl Input Choice, 508
MODAL Fl Menu , 525
Fl Widget, 831 Fl Sys Menu Bar, 656
mPredeleteProcs menu window
Fl Text Buffer, 700 Fl Window, 869
mTabDist menubutton
Fl Text Buffer, 700 Fl Input Choice, 508
Mac OS X-specific symbols, 271 middleline
fl mac set about, 271 Fl Browser, 334
fl open callback, 271 minimum
gl texture pile height, 271, 272 Fl Progress, 610
mac.H, 942 Fl Spinner, 650
maintain absolute top line number Fl Valuator, 813
Fl Text Display, 720 mininum
maintaining absolute top line number Fl Spinner, 650
Fl Text Display, 720 minute
make current Fl Clock Output, 376
Fl Gl Window, 431 modal
Fl Window, 869 Fl Window, 869
make overlay current Windows handling functions, 206
Fl Gl Window, 431 mode
make visible Fl Color Chooser, 379, 380
Fl Browser, 334 Fl Gl Window, 431
margins Fl Menu , 526
Fl Paged Device, 563 Fl Sys Menu Bar, 657
Fl PostScript File Device, 578 move
Fl Printer, 606 Fl Browser, 334
Fl System Printer, 659 Fl Tree Item, 798
mark Fl Tree Item Array, 805
Fl Input , 497 move above
max size Fl Tree Item, 798
Fl RGB Image, 624 move below
maximum Fl Tree Item, 798
Fl Progress, 610 move down
Fl Spinner, 650 Fl Text Display, 721
Fl Valuator, 813 move into
maximum size Fl Tree Item, 799
Fl Input , 498 move left
maxinum Fl Text Display, 721
Fl Spinner, 650 move right
maxsize Fl Text Display, 721
Fl Chart, 362 move up
measure Fl Text Display, 722
Fl Label, 512 mult matrix
980 INDEX

Fl Graphics Driver, 448 Fl Window, 869


Multithreading support functions, 255 not clipped
awake, 255 Fl Graphics Driver, 448
lock, 255 Fl PostScript Graphics Driver, 588
thread message, 256 num images
unlock, 256 Fl Shared Image, 641
mvalue
Fl Menu , 526 OPTION ARROW FOCUS
Fl, 300
NEW FOLDER OPTION DND TEXT
Fl Native File Chooser, 551 Fl, 300
NO OPTIONS OPTION FNFC USES GTK
Fl Native File Chooser, 551 Fl, 300
NO OVERLAY OPTION LAST
Fl Widget, 831 Fl, 300
NOBORDER OPTION SHOW TOOLTIPS
Fl Widget, 830 Fl, 300
NON MODAL OPTION VISIBLE FOCUS
Fl Widget, 830 Fl, 300
NORMAL CURSOR ORIENTATION
Fl Text Display, 708 Fl Paged Device, 563
Name OUTPUT
Fl Preferences::Name, 882 Fl Widget, 830
nchecked OVERRIDE
Fl Check Browser, 367 Fl Widget, 830
new list offset line starts
Fl Browser , 348 Fl Text Display, 722
newUUID open
Fl Preferences, 601 Fl Tree, 779
next open toggle
Fl File Icon, 407 Fl Tree, 780
Fl Menu Item, 542 openicon
Fl Tree, 776 Fl Tree, 780
Fl Tree Item, 799 Fl Tree Prefs, 809
Fl Wizard, 875 Option
next char Fl Native File Chooser, 551
Fl Text Buffer, 696 option
next displayed Fl, 306, 307
Fl Tree Item, 799 options
next item Fl Native File Chooser, 553
Fl Tree, 776 origin
next selected item Fl Paged Device, 563, 564
Fl Tree, 777, 778 Fl PostScript File Device, 578
next sibling Fl Printer, 606, 607
Fl Tree Item, 799 Fl System Printer, 659
next visible ortho
Fl Tree Item, 799 Fl Gl Window, 431
next visible item output
Fl Tree, 778 Fl Widget, 848
next window outputfile
Windows handling functions, 206 Fl Text Buffer, 697
nitems override
Fl Check Browser, 367 Fl Window, 870
non modal overstrike
INDEX 981

Fl Text Display, 722 popup buttons


own colormap Fl Menu Button, 531
Fl, 307 position
Fl Browser , 349
POPUP1 Fl Help Dialog, 470
Fl Menu Button, 531 Fl Input , 498, 499
POPUP12 Fl Text Selection, 738
Fl Menu Button, 531 Fl Tile, 743
POPUP123 Fl Widget, 848
Fl Menu Button, 531 position style
POPUP13 Fl Text Display, 722
Fl Menu Button, 531 position to line
POPUP2 Fl Text Display, 723
Fl Menu Button, 531 position to linecol
POPUP23 Fl Text Display, 723
Fl Menu Button, 531 position to xy
POPUP3 Fl Text Display, 723
Fl Menu Button, 531 precision
PORTRAIT Fl Valuator, 813
Fl Paged Device, 563 preset file
PREVIEW Fl Native File Chooser, 554
Fl Native File Chooser, 551 prev
Page Format Fl Tree, 781
Fl Paged Device, 562 Fl Tree Item, 800
Page Layout Fl Wizard, 875
Fl Paged Device, 562 prev char
parent Fl Text Buffer, 697
Fl Tree Item, 799 prev displayed
Fl Widget, 848 Fl Tree Item, 800
paste prev sibling
Selection & Clipboard functions, 222, 223 Fl Tree Item, 800
pattern prev visible
Fl File Icon, 407 Fl Tree Item, 800
picked preview
Fl Menu , 526 Fl File Chooser, 402
pie print
Fl Graphics Driver, 448 Fl Device Plugin, 387
Fl PostScript Graphics Driver, 588 Fl Mac App Menu, 516
Pixmap print widget
Fl FormsPixmap, 416, 418 Fl Paged Device, 564
point Fl Printer, 607
Fl Graphics Driver, 448 print window
Fl PostScript Graphics Driver, 588 Fl Paged Device, 564
polygon print window part
Fl Graphics Driver, 448 Fl Paged Device, 564
Fl PostScript Graphics Driver, 588 Fl Printer, 607
pop clip printable rect
Fl Graphics Driver, 448 Fl Paged Device, 565
Fl PostScript Graphics Driver, 588 Fl PostScript File Device, 579
pop matrix Fl Printer, 607
Fl Graphics Driver, 448 Fl System Printer, 660
popup pulldown
Fl Menu Button, 532 Fl Menu Item, 542
Fl Menu Item, 542 push
982 INDEX

Fl Tabs, 685 release widget pointer


push clip Safe widget deletion support functions, 258
Fl Graphics Driver, 448 reload scheme
Fl PostScript Graphics Driver, 588 Fl, 308
push matrix remove
Fl Graphics Driver, 449 Fl Browser, 335
push no clip Fl Check Browser, 367
Fl Graphics Driver, 449 Fl Group, 465
Fl PostScript Graphics Driver, 588 Fl Menu , 526
pushed Fl Sys Menu Bar, 657
Events handling functions, 218 Fl Text Buffer, 697
Fl Tree, 781
r Fl Tree Item Array, 805
Fl Color Chooser, 380 remove
REVERSED Fl Text Buffer, 697
Fl Paged Device, 563 remove all key bindings
RGB scaling Fl Text Editor, 737
Fl Image, 486 remove check
radio Fl, 308
Fl Menu Item, 542 remove child
range Fl Tree Item, 800, 801
Fl Spinner, 650 remove fd
Fl Valuator, 813 Fl, 308
readonly remove handler
Fl Input , 499 Events handling functions, 219
ready remove icon
Fl, 307 Fl Browser, 335
recalc tree remove key binding
Fl Tree, 781 Fl Text Editor, 737
Fl Tree Item, 800 remove system handler
rect Events handling functions, 219
Fl Graphics Driver, 449 remove timeout
Fl PostScript Graphics Driver, 588 Fl, 308
rectf removePlugin
Fl Graphics Driver, 449 Fl Plugin Manager, 571
Fl PostScript Graphics Driver, 589 reparent
redisplay range Fl Tree Item, 801
Fl Text Display, 724 Fl Tree Item Array, 805
redraw repeat timeout
Fl Widget, 849 Fl, 308
redraw label replace
Fl Widget, 849 Fl Browser, 335
redraw line Fl Chart, 362
Fl Browser , 349 Fl Input , 499
redraw lines Fl Menu , 526
Fl Browser , 349 Fl Sys Menu Bar, 657
redraw overlay Fl Text Buffer, 697
Fl Gl Window, 432 Fl Tree Item Array, 806
Fl Overlay Window, 558 replacing
refcount Fl Browser , 349
Fl Shared Image, 641 rescan
release Fl File Chooser, 402
Fl, 307 reset absolute top line number
Fl Shared Image, 642 Fl Text Display, 724
INDEX 983

resizable Fl Table Row, 679


Fl Group, 465 rtl draw
resize Fl GDI Graphics Driver, 424
Fl Browser , 350 Fl Graphics Driver, 449
Fl Double Window, 392 Fl PostScript Graphics Driver, 589
Fl Gl Window, 432 Fl Quartz Graphics Driver, 614
Fl Group, 466 Fl Xlib Graphics Driver, 880
Fl Help Dialog, 470 run
Fl Help View, 477 Fl, 308
Fl Input , 500
Fl Input Choice, 508 SAVEAS CONFIRM
Fl Overlay Window, 558 Fl Native File Chooser, 551
Fl Scroll, 631 SHORTCUT LABEL
Fl Spinner, 650 Fl Widget, 830
Fl Text Display, 724 SIMPLE CURSOR
Fl Tile, 743 Fl Text Display, 708
Fl Tree, 781 SYSTEM
Fl Value Input, 817 Fl Preferences, 594
Fl Widget, 849 STRICT RFC3629
Fl Window, 870 Unicode and UTF-8 functions, 263
restore clip Safe widget deletion support functions, 257
Fl Graphics Driver, 449 clear widget pointer, 258
rewind lines delete widget, 258
Fl Text Buffer, 697 do widget deletion, 258
Fl Text Display, 724 release widget pointer, 258
rgb watch widget pointer, 259
Fl Color Chooser, 380 saturation
rgb2hsv Fl Color Chooser, 380
Fl Color Chooser, 380 scale
Root Fl Graphics Driver, 449
Fl Preferences, 594 Fl Paged Device, 565
root Fl PostScript File Device, 579
Fl Tree, 781 Fl Printer, 608
root label Fl System Printer, 660
Fl Tree, 782 scheme
rotate Fl, 308
Fl Graphics Driver, 449 Screen functions, 224
Fl Paged Device, 565 h, 224
Fl PostScript File Device, 579 screen dpi, 224
Fl Printer, 608 screen num, 225
Fl System Printer, 660 screen work area, 225
round screen xywh, 226
Fl Valuator, 813 w, 226
row header x, 226
Fl Table, 675 y, 227
row height screen dpi
Fl Table, 675 Screen functions, 224
row height all screen num
Fl Table, 675 Screen functions, 225
row resize screen work area
Fl Table, 675 Screen functions, 225
row resize min screen xywh
Fl Table, 675 Screen functions, 226
row selected scroll
984 INDEX

Fl Text Display, 724 selected


scroll Fl Browser, 335
Fl Text Display, 725 Fl Text Selection, 740
scroll timer cb selection
Fl Text Display, 725 Fl Browser , 352
scroll to Selection & Clipboard functions, 223
Fl Scroll, 631 Selection & Clipboard functions, 221
scrollbar add clipboard notify, 221
Fl Browser , 352 clipboard contains, 222
scrollbar align copy, 222
Fl Text Display, 725 dnd, 222
scrollbar left paste, 222, 223
Fl Browser , 350 selection, 223
scrollbar right selection owner, 223
Fl Browser , 350 selection color
scrollbar size Fl Widget, 849
Fl, 309 selection owner
Fl Browser , 350 Selection & Clipboard functions, 223
Fl Help View, 477, 478 selection text
Fl Scroll, 632 Fl Text Buffer, 698
Fl Tree, 782 selectmode
scrollbar width Fl Tree, 785
Fl Browser , 351 Fl Tree Prefs, 809
Fl Text Display, 725 set
scrollvalue Fl Button, 356
Fl Slider, 646 Fl FormsBitmap, 415
search backward Fl FormsPixmap, 418
Fl Text Buffer, 697 Fl Menu Item, 542
search forward Fl Preferences, 601–603
Fl Text Buffer, 698 Fl Text Selection, 740
second set active
Fl Clock Output, 376 Fl Widget, 850
secondary selection text set atclose
Fl Text Buffer, 698 Windows handling functions, 206
select set boxtype
Fl Browser, 335 Fl, 309
Fl Browser , 351 set changed
Fl Tree, 782, 783 Fl Input Choice, 508
Fl Tree Item, 801 Fl Widget, 850
select all set checked
Fl Help View, 478 Fl Check Browser, 367
Fl Tree, 783 set color
Fl Tree Item, 801 Color & Font functions, 235
select all rows set current
Fl Table Row, 679 Fl Copy Surface, 382
select only Fl Image Surface, 488
Fl Browser , 351 Fl Printer, 608
Fl Tree, 784 Fl Surface Device, 653
select row set draw cb
Fl Table Row, 679 Fl Cairo Window, 359
select toggle set font
Fl Tree, 784 Color & Font functions, 235
selectbox set fonts
Fl Tree, 784, 785 Color & Font functions, 235
INDEX 985

set idle show item


Fl, 309 Fl Tree, 785
set item focus show item bottom
Fl Tree, 785 Fl Tree, 785
set labeltype show item middle
Fl, 309 Fl Tree, 786
set menu window show item top
Fl Window, 870 Fl Tree, 786
set modal show self
Fl Window, 870 Fl Tree, 786
set non modal Fl Tree Item, 801
Fl Window, 870 show widgets
set output Fl Tree Item, 801
Fl Widget, 850 showHiddenButton
set overlay Fl File Chooser, 403
Fl Menu Window, 545 showcollapse
set selection Fl Tree, 786
Fl Table, 675 Fl Tree Prefs, 809
set tooltip window shown
Fl Window, 870 Fl Window, 872
set value showroot
Fl Valuator, 813 Fl Tree, 786
set visible Fl Tree Prefs, 809
Fl Widget, 850 size
set visible focus Fl Browser, 336
Fl Widget, 850 Fl File Icon, 407
setonly Fl Graphics Driver, 449
Fl Menu Item, 542 Fl Help View, 478
shape Fl Input , 501
Fl Window, 871 Fl Menu , 526
shortcut Fl Preferences, 603
Fl Button, 356 Fl Tooltip, 751
Fl Input , 500 Fl Widget, 851
Fl Menu , 526 size range
Fl Menu Item, 542, 543 Fl Window, 872
Fl Text Display, 726 sizes
Fl Value Input, 817 Fl Group, 466
show skip displayed characters
Fl Browser, 336 Fl Text Buffer, 698
Fl Double Window, 392 skip lines
Fl File Chooser, 402 Fl Text Display, 726
Fl Gl Window, 432 slider
Fl Help Dialog, 470 Fl Slider, 647
Fl Menu Item, 543 slider size
Fl Menu Window, 545 Fl Slider, 647
Fl Native File Chooser, 554 soft
Fl Overlay Window, 558 Fl Adjuster, 315
Fl Single Window, 644 Fl Value Input, 817
Fl Widget, 850 Fl Value Output, 820
Fl Window, 871, 872 sort
show cursor Fl Browser , 352
Fl Text Display, 726 sortorder
show insert position Fl Tree, 786
Fl Text Display, 726 Fl Tree Prefs, 809
986 INDEX

start Fl Browser, 337


Fl Text Selection, 740 Fl Check Browser, 367
start job Fl Menu , 527
Fl Paged Device, 565 Fl Text Buffer, 698, 699
Fl PostScript File Device, 579, 580 text extents
Fl PostScript Printer, 591 Fl GDI Graphics Driver, 424
Fl Printer, 608 Fl Graphics Driver, 449
Fl System Printer, 660 Fl PostScript Graphics Driver, 589
start page Fl Quartz Graphics Driver, 614
Fl Paged Device, 565 Fl Xlib Graphics Driver, 880
Fl PostScript File Device, 580 text range
Fl Printer, 608 Fl Text Buffer, 699
Fl System Printer, 660 textcolor
static value Fl Chart, 362
Fl Input , 501 Fl File Chooser, 402
step Fl Help View, 478
Fl Counter, 385 Fl Input , 502
Fl Spinner, 650 Fl Menu , 527
Fl Valuator, 814 Fl Spinner, 651
str Fl Text Display, 727
FL CHART ENTRY, 363 Fl Tooltip, 751
string width Fl Value Input, 818
Fl Text Display, 726 Fl Value Output, 820
submenu Fl Value Slider, 823
Fl Menu Item, 543 textfont
suspended Fl Browser , 352
Fl Timer, 747 Fl Chart, 362
swap Fl File Chooser, 402
Fl Browser, 336 Fl Help View, 478
swap buffers Fl Input , 503
Fl Gl Window, 432 Fl Menu , 527
swap children Fl Spinner, 651
Fl Tree Item, 801, 803 Fl Text Display, 727
swapping Fl Value Input, 818
Fl Browser , 352 Fl Value Output, 820, 821
Fl Value Slider, 823
TOOLTIP WINDOW textsize
Fl Widget, 831 Fl Chart, 362
tab nav Fl File Chooser, 402
Fl Input , 502 Fl Help Dialog, 470
table box Fl Help View, 478, 479
Fl Table, 676 Fl Input , 503
TableContext Fl Menu , 527
Fl Table, 668 Fl Spinner, 651
take focus Fl Text Display, 727
Fl Widget, 851 Fl Value Input, 818
takesevents Fl Value Output, 821
Fl Widget, 851 Fl Value Slider, 823
test shortcut thread message
Events handling functions, 219 Multithreading support functions, 256
Fl Menu , 526 title
Fl Menu Item, 543 Fl Help View, 479
Fl Widget, 851, 852 Fl Native File Chooser, 554
text tooltip
INDEX 987

Fl Widget, 852 Fl Bitmap, 317


tooltip window Fl Image, 486
Fl Window, 873 Fl Pixmap, 568
top Fl RGB Image, 624
Fl Help Font Stack, 471 Fl Shared Image, 642
top row uncheck
Fl Table, 676 Fl Menu Item, 543
top window undo
Fl Widget, 853 Fl Input , 503
top window offset Unicode and UTF-8 functions, 262
Fl Widget, 853 ERRORS TO CP1252, 263
topline ERRORS TO ISO8859 1, 263
Fl Browser, 337 fl fopen, 264
Fl Help View, 479 fl nonspacing, 264
transcoding warning action fl open, 264
Fl Text Buffer, 700 fl ucs to Utf16, 264
transform dx fl utf8back, 265
Fl Graphics Driver, 449 fl utf8bytes, 265
transform dy fl utf8decode, 265
Fl Graphics Driver, 450 fl utf8encode, 265
transform x fl utf8from mb, 266
Fl Graphics Driver, 450 fl utf8froma, 266
transform y fl utf8fromwc, 266
Fl Graphics Driver, 450 fl utf8fwd, 266
transformed vertex fl utf8len, 267
Fl Graphics Driver, 450 fl utf8len1, 267
Fl PostScript Graphics Driver, 589 fl utf8locale, 267
translate fl utf8test, 267
Fl Graphics Driver, 450 fl utf8to mb, 267
Fl Paged Device, 566 fl utf8toUtf16, 268
Fl PostScript File Device, 580 fl utf8toa, 268
Fl Printer, 609 fl utf8towc, 268
Fl System Printer, 661 fl utf strcasecmp, 269
Type fl utf strncasecmp, 269
Fl Native File Chooser, 552 fl utf tolower, 269
type fl utf toupper, 269
Fl File Chooser, 402 fl wcwidth, 269
Fl File Icon, 407 fl wcwidth , 269
Fl Label, 513 STRICT RFC3629, 263
Fl Spinner, 651 unlock
Fl Table Row, 679 Multithreading support functions, 256
Fl Widget, 853 up down position
Fl Input , 503
USE FILTER EXT update
Fl Native File Chooser, 552 Fl Text Selection, 740
USER update child
Fl Preferences, 594 Fl Group, 467
USERFLAG1 update h scrollbar
Fl Widget, 831 Fl Text Display, 728
USERFLAG2 update line starts
Fl Widget, 831 Fl Text Display, 728
USERFLAG3 update prev next
Fl Widget, 831 Fl Tree Item, 803
uncache update v scrollbar
988 INDEX

Fl Text Display, 728 visible focus


user data Fl, 310
Fl Widget, 853 Fl Widget, 854
usericon visible r
Fl Tree, 786, 787 Fl Tree Item, 803
usericonmarginleft Fl Widget, 854
Fl Tree, 787 visual
Fl, 310
VERTICAL vline length
Fl Browser , 342 Fl Text Display, 728
VERTICAL ALWAYS vposition
Fl Browser , 342 Fl Tree, 787
VISIBLE FOCUS
Fl Widget, 830 w
val Fl Help Dialog, 470
FL CHART ENTRY, 363 Fl Tree Item, 803
valid Fl Widget, 854
Fl Gl Window, 432 Screen functions, 226
value WRAP AT BOUNDS
Fl Browser, 337, 338 Fl Text Display, 709
Fl Button, 356 WRAP AT COLUMN
Fl Check Browser, 367 Fl Text Display, 709
Fl Choice, 371 WRAP AT PIXEL
Fl Clock Output, 376 Fl Text Display, 709
Fl Color Chooser, 380 WRAP NONE
Fl File Chooser, 402 Fl Text Display, 709
Fl File Icon, 407 wait
Fl File Input, 410 Fl, 310
Fl Help Dialog, 470 wait for expose
Fl Help View, 479 Fl Window, 873
Fl Input , 504 warning
Fl Input Choice, 508 Common Dialogs classes and functions, 281
Fl Menu , 527 watch widget pointer
Fl Menu Item, 543 Safe widget deletion support functions, 259
Fl Positioner, 575 when
Fl Progress, 610 Fl Table, 676
Fl Scrollbar, 635 Fl Widget, 855
Fl Spinner, 651 which
Fl Tabs, 685 Fl Tabs, 686
Fl Valuator, 814 widget
Fl Wizard, 875 Fl Widget Tracker, 858
version width
Fl, 310 Fl GDI Graphics Driver, 424
vertex Fl Graphics Driver, 450
Fl Graphics Driver, 450 Fl PostScript Graphics Driver, 589
Fl PostScript Graphics Driver, 589 Fl Quartz Graphics Driver, 614
visible Fl Xlib Graphics Driver, 880
Fl Browser, 338 window
Fl File Chooser, 403 Fl Widget, 856
Fl Help Dialog, 470 Windows handling functions, 205
Fl Menu Item, 543 atclose, 206
Fl Widget, 854 default atclose, 205
visible cells first window, 205
Fl Table, 676 grab, 205, 206
INDEX 989

modal, 206 yposition


next window, 206 Fl Scroll, 632
set atclose, 206 ystep
word end Fl Positioner, 576
Fl Input , 504 yvalue
Fl Text Buffer, 699 Fl Positioner, 576
Fl Text Display, 728 yxline
word start Fl Graphics Driver, 450, 451
Fl Input , 505 Fl PostScript Graphics Driver, 589, 590
Fl Text Buffer, 699
Fl Text Display, 728
wrap
Fl Input , 505
wrap mode
Fl Text Display, 730
wrap uses character
Fl Text Display, 730
wrapped column
Fl Text Display, 730
wrapped line counter
Fl Text Display, 731
wrapped row
Fl Text Display, 731

x
Fl Help Dialog, 470
Fl Widget, 856
Screen functions, 226
x to col
Fl Text Display, 732
xbounds
Fl Positioner, 575
xclass
Fl Window, 873
xposition
Fl Scroll, 632
xstep
Fl Positioner, 575
xvalue
Fl Positioner, 575
xy to position
Fl Text Display, 732
xy to rowcol
Fl Text Display, 732
xyline
Fl Graphics Driver, 450
Fl PostScript Graphics Driver, 589

y
Fl Help Dialog, 470
Fl Widget, 856
Screen functions, 227
ybounds
Fl Positioner, 575

You might also like