FLTK 1.1.8 Programming Manual Revision 8
Total Page:16
File Type:pdf, Size:1020Kb
FLTK 1.1.8 Programming Manual Revision 8 Written by Michael Sweet, Craig P. Earls, Matthias Melcher, and Bill Spitzak Copyright 1998-2006 by Bill Spitzak and Others. FLTK 1.1.8 Programming Manual Table of Contents Preface..................................................................................................................................................................1 Organization.............................................................................................................................................1 Conventions.............................................................................................................................................2 Abbreviations...........................................................................................................................................2 Copyrights and Trademarks.....................................................................................................................2 1 - Introduction to FLTK...................................................................................................................................3 History of FLTK......................................................................................................................................3 Features....................................................................................................................................................4 Licensing..................................................................................................................................................5 What Does "FLTK" Mean?.....................................................................................................................5 Building and Installing FLTK Under UNIX and MacOS X....................................................................5 Building FLTK Under Microsoft Windows............................................................................................6 Building FLTK Under OS/2....................................................................................................................7 Internet Resources....................................................................................................................................7 Reporting Bugs........................................................................................................................................7 2 - FLTK Basics...................................................................................................................................................9 Writing Your First FLTK Program..........................................................................................................9 Compiling Programs with Standard Compilers.....................................................................................12 Compiling Programs with Microsoft Visual C++..................................................................................13 Naming...................................................................................................................................................13 Header Files...........................................................................................................................................14 3 - Common Widgets and Attributes..............................................................................................................15 Buttons...................................................................................................................................................15 Text........................................................................................................................................................16 Valuators................................................................................................................................................17 Groups....................................................................................................................................................18 Setting the Size and Position of Widgets...............................................................................................18 Colors.....................................................................................................................................................18 Box Types..............................................................................................................................................19 Labels and Label Types.........................................................................................................................21 Callbacks................................................................................................................................................23 Shortcuts................................................................................................................................................24 4 - Designing a Simple Text Editor..................................................................................................................27 Determining the Goals of the Text Editor..............................................................................................27 Designing the Main Window.................................................................................................................28 Variables................................................................................................................................................28 Menubars and Menus.............................................................................................................................28 Editing the Text.....................................................................................................................................29 The Replace Dialog................................................................................................................................29 Callbacks................................................................................................................................................30 Other Functions......................................................................................................................................34 The main() Function..............................................................................................................................36 Compiling the Editor.............................................................................................................................36 The Final Product...................................................................................................................................36 i FLTK 1.1.8 Programming Manual Table of Contents 4 - Designing a Simple Text Editor Advanced Features.................................................................................................................................37 5 - Drawing Things in FLTK...........................................................................................................................43 When Can You Draw Things in FLTK?................................................................................................43 FLTK Drawing Functions......................................................................................................................43 Drawing Images.....................................................................................................................................53 6 - Handling Events...........................................................................................................................................57 The FLTK Event Model.........................................................................................................................57 Mouse Events.........................................................................................................................................57 Focus Events..........................................................................................................................................58 Keyboard Events....................................................................................................................................59 Widget Events........................................................................................................................................59 Clipboard Events....................................................................................................................................60 Drag And Drop Events...........................................................................................................................60 Fl::event_*() methods............................................................................................................................61 Event Propagation..................................................................................................................................61 FLTK Compose-Character Sequences...................................................................................................62 7 - Adding and Extending Widgets..................................................................................................................63 Subclassing............................................................................................................................................63 Making a Subclass of Fl_Widget...........................................................................................................63