ebook img

Palm OS Programming PDF

569 Pages·2002·3.004 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Palm OS Programming

www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page i Glenn Bachmann Palm OS Programming 201 West 103rd Street, Indianapolis, Indiana 46290 www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page ii Palm OS Programming Associate Publisher Michael Stephens Copyright2003 by Sams Publishing Acquisitions Editor All rights reserved. No part of this book shall be reproduced, stored Michelle Newcomb in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without Development Editor written permission from the publisher. No patent liability is Mark Renfrow assumed with respect to the use of the information contained herein. Although every precaution has been taken in the prepara- Managing Editor tion of this book, the publisher and author assume no responsibil- Charlotte Clapp ity for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein. Project Editor Matthew Purcell International Standard Book Number: 0-672-32413-X Copy Editor Library of Congress Catalog Card Number: 2002100932 Kezia Endsley Printed in the United States of America Indexer First Printing: October 2002 Larry Sweazy 05 04 03 02 4 3 Proofreader 2 1 Abby Vanhuss Suzanne Thomas Trademarks Technical Editor All terms mentioned in this book that are known to be trademarks Jeff Pajor or service marks have been appropriately capitalized. Sams Team Coordinator Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity Lynne Williams of any trademark or service mark. Interior Designer Gary Adair Warning and Disclaimer Cover Designer Every effort has been made to make this book as complete and as Alan Clements accurate as possible, but no warranty or fitness is implied. The information provided is on an “as is” basis. The authors and the Page Layout publisher shall have neither liability nor responsibility to any Michelle Mitchell person or entity with respect to any loss or damages arising from the information contained in this book. Graphics Steve Adams Tammy Graham Oliver Jackson Laura Robbins www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page iii Contents at a Glance Introduction.................................................................................................1 Part I Getting Started with Palm Programming 5 1 Introduction to Palm Programming and CodeWarrior..........................7 2 Anatomy of a Palm Application......................................................17 3 Rapid Development Using POSE, the Palm OS Emulator.....................43 4 Debugging Techniques for Palm Applications....................................55 5 Creating and Managing Resources...................................................67 Part II Programming the Palm User Interface 75 6 Interacting with the User: Forms.....................................................77 7 Form Elements ............................................................................97 8 Button Controls.........................................................................103 9 Labels and Fields........................................................................121 10 Giving the Users a Choice: Lists and Pop-up Triggers........................131 11 Tables.......................................................................................153 12 Menus......................................................................................177 13 Drawing Graphics.......................................................................193 14 Handling Pen Events...................................................................213 15 Adding Color to Palm Applications...............................................225 Part III Memory, Databases, and Files 237 16 Palm OS Memory Management.....................................................239 17 Understanding Palm OS Databases................................................245 18 Palm Databases and Record Management.......................................255 19 Categories.................................................................................273 20 Expansion Memory Cards and the Virtual File System......................299 Part IV Communications 329 21 Serial Communications...............................................................331 22 Infrared Communications: OBEX and Exchange Manager.................349 23 Using the Infrared Library............................................................365 www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page iv 24 A Survey of Wireless Options for Palm Developers...........................377 25 Palm.NET and Web Clipping........................................................387 26 Using TCP/IP and Net.lib.............................................................403 Part V Advanced Topics 423 27 Overview of Conduits.................................................................425 28 Programming Palm OS Conduits...................................................431 29 Shared Libraries: Extending the Palm OS........................................461 30 Other Advanced Project Types: Multi-Segment and Static Libraries......481 31 Saving Program State: Application Preferences.................................489 32 Palm OS 5 and ARM: Looking into the Future.................................495 Index.......................................................................................503 www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page v Table of Contents Introduction 1 Part I Getting Started with Palm Programming 5 1 Introduction to Palm Programming and CodeWarrior 7 The Palm Computing Platform.........................................................9 What Is a Palm Application?..........................................................10 How Are Palm Applications Written?...............................................11 CodeWarrior and Development Tool Choices....................................12 PRC-Tools...........................................................................12 Falch.net.............................................................................13 AppForge............................................................................13 NS Basic..............................................................................13 Satellite Forms.....................................................................13 What Tool Is Best for You?.............................................................13 Tools Used in This Book................................................................14 The Palm SDK.............................................................................15 Summary....................................................................................15 2 Anatomy of a Palm Application 17 PilotMain and the Smallest Palm Program Ever.................................17 Launch Codes......................................................................18 Checking the Palm OS Version...............................................19 The Main Form............................................................................21 Events................................................................................22 The Main Form Handler........................................................25 Hello Palm!.................................................................................26 The Source Code..........................................................................27 Creating a CodeWarrior Project for “Hello Palm”...............................37 Creating a GCC Project for “Hello Palm”.........................................39 Building and Running “Hello Palm”................................................40 Summary....................................................................................41 www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page vi vi Palm OS Programming 3 Rapid Development Using POSE, the Palm OS Emulator 43 Where to Get POSE......................................................................44 ROM Images................................................................................44 Where to Get ROMs..............................................................45 The Different Kinds of ROMs..................................................46 Skins..........................................................................................46 Creating, Loading, and Saving POSE Sessions....................................47 Installing Applications and Databases..............................................49 Taking Screenshots.......................................................................49 Creating a Bound Copy of POSE.....................................................50 Advanced POSE Techniques...........................................................50 POSE Warnings and Error Messages.........................................51 Logging..............................................................................51 Profiling.............................................................................52 TCP/IP and Serial Communications Support.............................52 Gremlins.............................................................................52 The OS 5 Simulator......................................................................53 Summary....................................................................................54 4 Debugging Techniques for Palm Applications 55 Why Palm Debugging Is Different...................................................56 Defensive Programming................................................................56 Effective Debugging Techniques for the Palm....................................57 The Palm Error Manager........................................................57 FrmCustomAlert...................................................................58 Logging..............................................................................59 The CodeWarrior Debugger............................................................60 A Debugging Session.............................................................60 Setting Breakpoints...............................................................61 Stepping Through Code.........................................................62 Debugging to a Palm Device...................................................62 Other Debugging Tools.................................................................63 Using Gremlins to Find Problems....................................................63 Summary....................................................................................64 5 Creating and Managing Resources 67 What Is a Palm Resource?..............................................................68 Why Use Constructor?..................................................................68 Why Use PilRC?...........................................................................68 www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page vii Contents vii Creating a Resource Project File......................................................69 Creating Resources in Constructor...........................................69 What’s a Resource Fork?........................................................70 Version-Control Considerations in Constructor.........................71 A Constructor Example: “Hello Palm” Revisited.........................71 A PilRC Example: “Hello Palm” Revisited.................................72 Summary....................................................................................74 Part II Programming the Palm User Interface 75 6 Interacting with the User: Forms 77 The Palm User Interface................................................................78 What Is a Form?..........................................................................79 Examples of Forms in the Built-in Palm Applications..................79 Programming with Forms..............................................................80 Alerts.................................................................................81 Custom Forms.....................................................................86 Using Forms to Capture User Input.................................................90 More Complex Forms: Event Handlers.............................................92 Summary....................................................................................95 7 Form Elements 97 What Kinds of Form Elements Are Available?....................................98 Buttons...............................................................................98 Input Fields.........................................................................99 Labels.................................................................................99 Lists...................................................................................99 Triggers.............................................................................100 Tables...............................................................................101 Custom Gadgets.........................................................................101 Summary..................................................................................102 8 Button Controls 103 What Is a Control Object?...........................................................103 Types of Control Objects......................................................104 What Is a Button?.......................................................................105 Types of Buttons.................................................................105 Guidelines for the Use of Buttons..................................................107 General Guidelines on Buttons.....................................................108 www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page viii Using Buttons in Your Application................................................108 A Simple Survey Application........................................................108 Grouped Push Buttons.........................................................109 Repeating Buttons and the Arrow Increment...........................109 Initializing the Form...........................................................118 Trapping Control Events......................................................119 Summary..................................................................................120 9 Labels and Fields 121 Form Labels...............................................................................122 Input Fields...............................................................................122 Using Constructor to Create Labels and Fields.................................123 Using Labels and Fields in Your Application....................................125 Just What the Doctor Ordered......................................................126 Summary..................................................................................130 10 Giving the Users a Choice: Lists and Pop-up Triggers 131 Lists in the Palm Environment.....................................................132 Examples of Lists in Action on the Palm.................................132 Pop-up Lists.......................................................................132 Guidelines for Using Lists in an Application....................................133 Creating List Resources................................................................133 Usable ..............................................................................134 Visible Items......................................................................134 List Items..........................................................................134 Creating Pop-up List Resources.....................................................135 Adding List and Pop-up List Handling to Your Application................136 More Complex Handling—Drawing Your Own List...................137 More Complex Handling—Trapping List Events.......................138 Pop-up List Handling..........................................................138 A Shopping List Revisited.............................................................138 Summary..................................................................................151 11 Tables 153 What Is a Table?.........................................................................153 Table Functionality.....................................................................154 When to Use Tables Instead of Lists...............................................154 Adding Tables to Your Program.....................................................155 Table Initialization..............................................................156 Table View Management......................................................157 www.it-ebooks.info 00 413x fm 10/2/02 4:10 PM Page ix Table Data Mapping............................................................159 Table Drawing....................................................................161 Putting It All Together: FishTable..................................................164 Tables and Databases...................................................................175 Summary..................................................................................176 12 Menus 177 What Is a Menu?........................................................................178 Menus in Action on the Palm...............................................178 Menu Nomenclature...........................................................179 Guidelines for Menu Usage..........................................................180 Using Constructor to Create Menus...............................................181 Handling Menu Events in Your Application....................................183 Summary..................................................................................191 13 Drawing Graphics 193 The Palm Display.......................................................................193 Screen Sizes.......................................................................194 Color and Grayscale............................................................194 Palm OS Graphics Primitives........................................................195 Lines................................................................................195 Fill Patterns.......................................................................196 Rectangles.........................................................................196 Drawing Text.....................................................................197 Bitmaps.............................................................................197 The Palm OS Window Model........................................................197 What Is a Window?.............................................................197 Creating a Window.............................................................198 Multiple Windows..............................................................199 PalmDraw: A Graphics-Drawing Demonstration Program..................199 Setting Up for Multiple Windows..........................................207 The Line-Drawing and Rectangle-Drawing Windows.................208 The Text-Drawing Window...................................................209 The Bitmap-Drawing Window...............................................210 Summary..................................................................................211 14 Handling Pen Events 213 What Is a Pen Event?..................................................................214 How Pen Events and Control Events Coexist...................................214 Pen Events and Graffiti................................................................214 www.it-ebooks.info

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.