FLTK 1.0.11 Programming Manual Revision 18
Total Page:16
File Type:pdf, Size:1020Kb
FLTK 1.0.11 Programming Manual Revision 18 Written by Michael Sweet, Craig P. Earls, and Bill Spitzak Copyright 1998−2001 by Bill Spitzak and Others. FLTK 1.0.11 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............................................................................................5 Building FLTK Under Microsoft Windows............................................................................................6 Building FLTK Under OS/2....................................................................................................................6 Internet Resources....................................................................................................................................7 Reporting Bugs........................................................................................................................................7 2 − FLTK Basics..................................................................................................................................................9 Naming.....................................................................................................................................................9 Header Files.............................................................................................................................................9 Compiling Programs with Standard Compilers.....................................................................................10 Compiling Programs with Microsoft Visual C++..................................................................................10 Writing Your First FLTK Program........................................................................................................10 3 − Common Widgets and Attributes..............................................................................................................13 Buttons...................................................................................................................................................13 Text........................................................................................................................................................14 Valuators................................................................................................................................................14 Groups....................................................................................................................................................15 Setting the Size and Position of Widgets...............................................................................................15 Colors.....................................................................................................................................................16 Box Types..............................................................................................................................................16 Labels and Label Types.........................................................................................................................18 Callbacks................................................................................................................................................20 Shortcuts................................................................................................................................................21 4 − Designing a Simple Text Editor.................................................................................................................23 Determining the Goals of the Text Editor..............................................................................................23 Designing the Main Window.................................................................................................................23 Variables................................................................................................................................................24 Menubars and Menus.............................................................................................................................24 Editing the Text.....................................................................................................................................25 The Replace Dialog................................................................................................................................25 Callbacks................................................................................................................................................25 Other Functions......................................................................................................................................30 Compiling the Editor.............................................................................................................................32 The Final Product...................................................................................................................................32 i FLTK 1.0.11 Programming Manual Table of Contents 5 − Drawing Things in FLTK..........................................................................................................................35 When Can You Draw Things in FLTK?................................................................................................35 FLTK Drawing Functions......................................................................................................................35 Images....................................................................................................................................................41 class Fl_Pixmap.....................................................................................................................................44 6 − Handling Events..........................................................................................................................................47 The FLTK Event Model.........................................................................................................................47 Mouse Events.........................................................................................................................................47 Focus Events..........................................................................................................................................48 Keyboard Events....................................................................................................................................49 Widget Events........................................................................................................................................49 Clipboard Events....................................................................................................................................50 Fl::event_*() methods............................................................................................................................50 Event Propagation..................................................................................................................................50 FLTK Compose−Character Sequences..................................................................................................51 7 − Adding and Extending Widgets.................................................................................................................53 Subclassing............................................................................................................................................53 Making a Subclass of Fl_Widget...........................................................................................................53 The Constructor.....................................................................................................................................54 Protected Methods of Fl_Widget...........................................................................................................54