LazarusCompleteGuide:Content
Content
Foreword XI
Chapter 1: The Architecture of Lazarus 1 By Mattias Gärtner
1.1 The Source Code Editor ......................................5 1.1.1 Code tools ................................................6 1.1.2 Fast navigation through code ..............................6 1.2.3 Autocompletion ............................................9 1.2 Language Basics .............................................16 1.2.1 Basic types ...............................................19 1.2.2 Structure and operation of units ..........................24 1.2.3 Object orientation in Lazarus .............................27 1.2.4 Arrays in Free Pascal, compared to C ......................30 1.2.5 Compiler directives .......................................34 1.3 Projects ....................................................36 1.4 Components ..................................................39 1.5 Packages ....................................................40 1.5.1 C libraries in Free Pascal ................................41 1.5.2 Free Pascal Libraries in C ................................43 1.5.3 Installing new components in the IDE ......................44 1.5.4 Units in multiple projects ................................46 1.5.5 Virtual units .............................................47 1.5.6 Units for different platforms .............................47 1.5.7 Finding packages ..........................................49 1.5.8 Directories and search paths ..............................51 1.5.9 Dependencies and inheritance ..............................52 1.5.10 Compiling packages ........................................52 1.5.11 Translating packages ......................................53 1.6 Source code documentation ...................................55 1.7 Unicode .....................................................58
Chapter 2: Installing Lazarus 62 By Jörg Braun, Swen Heinig and Felipe Monteiro de Carvalho
2.1 Downloading from a Version Management System ................63 2.1.1 Installing TortoiseSVN ....................................64 2.1.2 The Subversion package ....................................65 2.1.3 SVN directories for Lazarus and FPC .......................69 2.1.4 Basic command-line operations .............................70 2.1.5 Checkout with TortoiseSVN .................................72 2.2 Installation on Windows .....................................75 2.2.1 64-bit Windows ............................................77 2.2.2 Removing Lazarus ..........................................77 2.3 Installation on Linux .......................................78 2.4 Installation on FreeBSD .....................................81 2.4.1 Installing from the ports .................................82 2.4.2 Manual installation .......................................84 2.5 Installation on MacOS X .....................................91
Chapter 3: The IDE 93 By Swen Heinig
3.1 The Lazarus Main Menu .......................................93 3.1.1 The File Menu .............................................94 3.1.2 The Edit Menu .............................................96 3.1.3 Searching .................................................104 3.1.4 The View Menu .............................................108 3.1.5 The Project Menu ..........................................118 3.1.6 Compiler options ..........................................125 3.1.7 The Run Menu ..............................................136 3.1.8 Packages ..................................................139 3.1.9 The Tools Menu ............................................153 3.1.10 The Environment Menu ......................................159 3.1.11 The Window Menu ...........................................205 3.1.12 The Help Menu .............................................205 3.2 Programming Tools available in the IDE ......................206 3.2.1 The Object Inspector ......................................206 3.2.2 The Source Code Editor ....................................211 3.2.3 Code Completion ...........................................217 3.2.4 Message Composer ..........................................220 3.2.5 The Debugger Settings .....................................221 3.3 Recompiling the IDE .........................................228
Chapter 4: Projects 233 By Felipe Monteiro de Carvalho
4.1 GUI Applications ............................................235 4.2 Console Applications ........................................240 4.2.1 Managed Console Applications ..............................242 4.3 DLLs And Shared Objects .....................................245 4.3.1 Dynamic Libraries .........................................246 4.3.2 Libraries in MacOS X ......................................252 4.3.3 Control Panel applications for Windows ....................253 4.4 Unit Testing ................................................261 4.5 Packages ....................................................263 4.5.1 Adding components .........................................267 4.5.2 Registering components ....................................267 4.5.3 Property editors ..........................................268 4.5.4 Component editors .........................................273 4.6 Services and Daemons ........................................276
Chapter 5: Target Platforms 279 By Felipe Monteiro de Carvalho
5.1 Platform Specifics ..........................................283 5.1.1 The Windows 32/64 API .....................................284 5.1.2 Windows CE, a special case ................................289 5.1.3 Linux, FreeBSD and other Unix-systems .....................301 5.1.4 The MacOS X APIs ..........................................307 5.1.5 32-bit and 64-bit 320 5.2 Configuration Files .........................................321 5.3 Resource Files ..............................................324
Chapter 6: The Class Libraries 328 By Michael Van Canneyt
6.1 The RTL (Free Pascal Run Time Library) ......................330 6.1.1 Streaming and RTTI ........................................331 6.1.2 TComponent and the naming of class instances ..............332 6.2 The FCL (Free Component Library) ............................333 6.3 The LCL (Lazarus Component Library) .........................337 6.3.1 The Application object ....................................339 6.3.2 Windows ...................................................352 6.3.3 Working with TForm ........................................354 6.3.4 The properties of TForm ...................................360 6.3.5 Special windows ...........................................371 6.3.6 The window environment ....................................378 6.3.7 Adding content to a form: Controls ........................380 6.3.8 Layout and design .........................................391 6.3.9 Actions ...................................................401 6.3.10 Drag and drop .............................................405 6.3.11 Drag-and-Dock .............................................416 6.4 An introduction to the component palette ....................425 6.4.1 The Standard Tab ..........................................429 6.4.2 The Additional Tab ........................................448 6.4.3 The Common Controls Tab ...................................460 6.4.4 The Dialogs Tab ...........................................481 6.4.5 The Misc Tab ..............................................486 6.4.6 The Data Controls Tab .....................................490 6.4.7 The Data Access Tab .......................................490 6.4.8 The System Tab ............................................491 6.4.9 The Synedit Tab ...........................................492
Chapter 7: Porting Delphi components 494 By Michael Van Canneyt
7.1 The Architecture of Lazarus Components ......................494 7.1.1 The LCL's platform-independent layer ......................495 7.1.2 Platform dependent layer ..................................498 7.2 The component model .........................................498 7.2.1 Components in Delphi ......................................499 7.2.2 Differences in architecture ...............................499 7.3 The Porting process .........................................506 7.3.1 Installing the components in Lazarus ......................511 7.3.2 The component palette .....................................512
Chapter 8: Files and Devices 514 By Felipe Monteiro de Carvalho and Jörg Braun
8.1 File Dialogs in Lazarus .....................................514 8.2 Working with files ..........................................522 8.2.1 Reading and writing files .................................524 8.2.2 Working with streams ......................................529 8.3 Searching in Directories ....................................539 8.4 Communication with Devices ..................................545 8.4.1 The parallel port .........................................546 8.4.2 Serial communication ......................................551 8.4.3 The printer ...............................................555
Chapter 9: Graphics Programming 560 By Felipe Monteiro de Carvlho
9.1 The Canvas ..................................................560 9.1.1 Colours ...................................................563 9.1.2 TPen ......................................................565 9.1.3 TBrush ....................................................568 9.1.4 Fonts .....................................................571 9.1.5 The most important graphics routines ......................574 9.2 Graphics components .........................................579 9.3 Graphics Formats ............................................584 9.3.1 TGraphic ..................................................584 9.3.2 TRasterImage ..............................................584 9.3.3 Bitmaps ...................................................587 9.3.4 TJpegImage ................................................589 9.3.5 Icons .....................................................590
Chapter 10: Processes and threads 595 By Felipe Monteiro de Carvalho
10.1 Processes ...................................................596 10.2 Threads .....................................................606 10.2.1 The TThread class .........................................608
Chapter 11: Network Programming 614 By Inoussa Ouedraogo
11.1 TCP/IP programming ..........................................614 11.1.1 The client program ........................................616 11.1.2 The server program ........................................619 11.2 Web services ................................................622 11.2.1 Programming the server ....................................624 11.2.2 Programming the client ....................................636 11.2.3 Logging server exchanged messages .........................644 11.2.4 Implementing Web Services object pooling ..................645 11.2.5 Service extensions ........................................648
Chapter 12: Database Access 651 By Michael Van Canneyt
12.1 Architecture ................................................651 12.1.1 Database Access ...........................................651 12.1.2 The case for database engines .............................653 12.1.3 The Data Desktop application ..............................656 12.2 The database access classes .................................657 12.2.1 TDataset ..................................................657 12.2.2 The data module ...........................................679 12.2.3 Data-aware visual controls ................................681 12.3 Available TDataset descendants ..............................682 12.4 The Lazarus Data Desktop ....................................699 12.4.1 Data dictionaries .........................................700 12.4.2 Exporting data ............................................705 12.4.3 Generating database code ..................................706 12.5 A crash course in SQL .......................................709 12.5.1 Creating a table in SQL ...................................709 12.5.2 Reading data from the database ............................710 12.5.3 Creating a new record in the table ........................711 12.5.4 Deleting a record from a table ............................712 12.5.5 Updating records in the database ..........................712 12.6 Reporting with Lazarus ......................................713 12.6.1 Creating a report .........................................715 12.6.2 The report designer .......................................717
INDEX 719