Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 5 Compiling with resources Rob Pooley

Slides:



Advertisements
Similar presentations
Introduction to Macromedia Director 8.5 – Lingo
Advertisements

Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
11-Jun-14 The assert statement. 2 About the assert statement The purpose of the assert statement is to give you a way to catch program errors early The.
Your Friend and Mine The Windows Registry. What is the Registry? ► Think of as a giant 411 switchboard ► Simple idea of centralized one-stop shopping.
R4 Dynamically loading processes. Overview R4 is closely related to R3, much of what you have written for R3 applies to R4 In R3, we executed procedures.
Building and Running Modules Sarah Diesburg COP 5641.
Introduction to Systems Programming (CS 0449) PalmOS Events Handling Events OS–AppEventLoop() – Event Handlers.
Homework Any Questions?. Statements / Blocks, Section 3.1 An expression becomes a statement when it is followed by a semicolon x = 0; Braces are used.
Copyright © 2008 Pearson Addison-Wesley. All rights reserved. Chapter 12 Separate Compilation Namespaces Simple Make Files (Ignore all class references.
CSE 466 – Spring 2000 – PalmOS - 1 Palm OS zInterface management ybasic user interface model yevent dispatch loop paradigm zSystem management yalarm and.
LAUNCHXL2-RM57L – Project 0
C++ Functions. 2 Agenda What is a function? What is a function? Types of C++ functions: Types of C++ functions: Standard functions Standard functions.
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 12 Using the KToolbar Rob Pooley
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Copyright 2007, Information Builders. Slide 1 Maintain & JavaScript: Two Great Tools that Work Great Together Mark Derwin and Mark Rawls Information Builders.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 18 Exception Handling.
1 I-Logix Professional Services Specialist Rhapsody IDF (Interrupt Driven Framework) CPU External Code RTOS OXF Framework Rhapsody Generated.
Lecture 2 Event driven programming Mobile and Handheld Applications1 Programming of Handheld and Mobile Devices Lecture 2: Event driven programming concepts.
Automated Testing Tips Copyright © 2000 Compuware Corporation Mark Nesslar July 15, 2000.
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. C How To Program - 4th edition Deitels Class 05 University.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 6 Functions.
Programming of Mobile and Handheld Devices Lecture 7: Programming OXO for Palm OS Rob Pooley
Lecture 3Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 3 Palm conventions Rob Pooley
Programming of Mobile and Handheld Devices Lecture 9: Memory, databases and files on Palm OS Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 7 J2ME Rob Pooley
Introduction to Systems Programming (CS 0449) User Interface Elements (UIE) - Resources Palm OS resources ( Ch.4—PDA Programming in C Book & Ch.6,7 PalmOS.
Module 6: Debugging a Windows CE Image.  Overview Debug Zones IDE Debug Setup IDE Debug Commands Platform Builder Integrated Kernel Debugger Other Debugging.
Compilation & Linking Computer Organization I 1 November 2009 © McQuain, Feng & Ribbens The Preprocessor When a C compiler is invoked, the.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
GAM 200 Club. How to Game Engine GAM 200 Club Zachary Nawar.
Allegro CL Certification Program Lisp Programming Series Level I Session Basic Lisp Development in the IDE.
Writing a Run Time DLL The application loads the DLL using LoadLibrary() or LoadLibraryEx(). The standard search sequence is used by the operating system.
Programming of Mobile and Handheld Devices Lecture 5: Programming for Palm OS Rob Pooley
Week 2-3 Control flow (review) Conditional statements If, else, else if, switch-case, break Loop constructs for, while, do-while, break, continue, label--go;
McGraw-Hill/Irwin The Interactive Computing Series © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Microsoft Access 2002 Using Access Tools.
Lecture 4 OXO for PalmMobile and Handheld Applications1 Programming of Mobile and Handheld Devices Lecture 4: Programming OXO for Palm OS Rob Pooley
JavaScript, Fourth Edition
>> PHP: Insert Query & Form Processing. Insert Query Step 1: Define Form Variables Step 2: Make DB Connection Step 3: Error Handling Step 4: Define the.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
11/2: Math.random, more methods About DrawLine.java modifications –allow user input –draw a curve Method definitions Math.random()
Lecture 3 Programming on Palm OS Mobile and Handheld Applications1 Programming of Mobile and Handheld Devices Lecture 3: Programming for Palm OS Rob Pooley.
C++ / G4MICE Course Session 1 - Introduction Edit text files in a UNIX environment. Use the g++ compiler to compile a single C++ file. Understand the C++
Palm OS emulator.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Brief Edition Chapter 6 Functions.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
Lecture 7 Conditional Scripting and Importing/Exporting.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
PRACTICE OVERVIEW PL/SQL Part Your stored procedure, GET_BUDGET, has a logic problem and must be modified. The script that contains the procedure.
1 Introduction to J2ME Outline MIDP Building J2ME Apps- Tool J2ME Wireless Toolkit Demo MIDlet Programming -- MIDlet Transition States -- Midlet Skeleton.
© 2008, Renesas Technology America, Inc., All Rights Reserved 1 Introduction Purpose  This training course demonstrates the Project Generator function.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
Today… Preparation for doing Assignment 1. Invoking methods overview. Conditionals and Loops. Winter 2016CMPE212 - Prof. McLeod1.
Introduction to Systems Programming (CS 0449)
Chapter 1.2 Introduction to C++ Programming
Week 3-4 Control flow (review) Function definition Program Structures
PL/pgSQL
Mobile Application Development Chapter 5 [Persistent Data in Android]
Predefined Dialog Boxes
null, true, and false are also reserved.
Lecture Set 3 Introduction to Visual Basic Concepts
Lecture 5: For Loops Building Java Programs: A Back to Basics Approach
Homework Any Questions?.
Tonga Institute of Higher Education
2. Second Step for Learning C++ Programming • Data Type • Char • Float
Module 6: Debugging a Windows CE Image
Reports and Forms Second Term,
Presentation transcript:

Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 5 Compiling with resources Rob Pooley

Programming Handheld and Mobile devices 2 Standard Make In the standard make project wizards, Developer Suite provides a generic set of makefiles that you can modify and tailor for your specific application build. The standard make makefiles are user-defined and user-controlled. You have to manually update when you make changes to your project (adding files, removing files, changing the output, etc.). Developer Suite essentially invokes make to build the standard make projects. You also have the option of not using the Developer Suite supplied makefiles, but the you must modify your makefiles to meet certain Developer Suite requirements. Developer Suite requires that the following variables be defined in the makefile:

Programming Handheld and Mobile devices 3 AppStart() and AppStop() static Err AppStart(void) { return errNone; } static void AppStop(void) { FrmCloseAllForms(); }

Programming Handheld and Mobile devices 4 The event loop static void AppEventLoop(void) { Err error; EventType event; do { EvtGetEvent(&event, evtWaitForever); if (! SysHandleEvent(&event)) if (! MenuHandleEvent(0, &event, &error)) if (! AppHandleEvent(&event)) FrmDispatchEvent(&event); } while (event.eType != appStopEvent); }

Programming Handheld and Mobile devices 5 Event handler static Boolean AppHandleEvent(EventPtr event) { UInt16 formId; FormPtr form; if (event->eType == frmLoadEvent) { // Load the form resource. formId = event->data.frmLoad.formID; form = FrmInitForm(formId); ErrFatalDisplayIf(!form, "Can't initialize form"); FrmSetActiveForm(form); // Set the event handler for the form. The handler of the currently // active form is called by FrmHandleEvent each time is receives an // event. switch (formId) { case MainForm: FrmSetEventHandler(form, MainFormHandleEvent); break; case SecondForm: FrmSetEventHandler(form, SecondFormHandleEvent); break; default: ErrFatalDisplay("Invalid Form Load Event"); break; } return true; } else return false; }

Programming Handheld and Mobile devices 6 Header /* Copyright (c) , Neil Rhodes and Julie McKeehan All rights reserved. From the book "Palm Programming, the Developer's Guide, 2nd edition" by O'Reilly. Permission granted to use this file however you see fit. */ #define DO_NOT_ALLOW_ACCESS_TO_INTERNALS_OF_STRU CTS #include #ifdef DEBUG_BUILD #define ERROR_CHECK_LEVEL ERROR_CHECK_FULL #endif #include #include "ResourceDefines.h" #include "MainForm.h" #include "SecondForm.h" #include "Utils.h" #include "Constants.h" ResourceDefines.h #define RomIncompatibleAlert 1001 #define MainForm 2000 #define MainBeepButton 2001 #define MainGotoSecondFormButton 2002 #define SecondForm 3000 #define SecondGotoMainFormButton 3001

Programming Handheld and Mobile devices 7 Main form static void MainFormDeinit(FormPtr form) { #pragma unused(form) } Boolean MainFormHandleEvent(EventPtr event) { Boolean handled = false; FormPtr form; switch (event->eType) { case frmOpenEvent: form = FrmGetActiveForm(); MainFormInit(form); FrmDrawForm(form); // here's where you'd add a call to FrmSetFocus handled = true; break; case ctlSelectEvent: switch (event- >data.ctlSelect.controlID) { case MainBeepButton: SndPlaySystemSound(sndWarning); handled = true; break; case MainGotoSecondFormButton: FrmGotoForm(SecondForm); handled = true; break; } break; case frmCloseEvent: MainFormDeinit(FrmGetActiveForm()); handled = false; break; default: break; } return handled; }

Programming Handheld and Mobile devices 8 Second form static void SecondFormInit(FormPtr form) { #pragma unused(form) // warning-- don't do any drawing in this routine. // Also, don't call FrmSetFocus from here (it must be called *after* // FrmDrawForm) } static void SecondFormDeinit(FormPtr form) { #pragma unused(form) } Boolean SecondFormHandleEvent(EventPtr event) { Boolean handled = false; FormPtr form; switch (event->eType) { case frmOpenEvent: form = FrmGetActiveForm(); SecondFormInit(form); FrmDrawForm(form); // here's where you'd add a call to FrmSetFocus handled = true; break; case ctlSelectEvent: switch (event- >data.ctlSelect.controlID) { case SecondGotoMainFormButton: FrmGotoForm(MainForm); handled = true; break; } break; case frmCloseEvent: SecondFormDeinit(FrmGetActiveForm()); handled = false; break; default: break; } return handled; }

Programming Handheld and Mobile devices 9 Headers MainForm.h #ifndef MAINFORM_H #define MAINFORM_H Boolean MainFormHandleEvent(EventPtr eventP); #endif SecondForm.h #ifndef SECONDFORM_H #define SECONDFORM_H Boolean SecondFormHandleEvent(EventPtr eventP); #endif

Programming Handheld and Mobile devices 10 Defining the resources used Resources.rcp #include "ResourceDefines.h" APPLICATIONICONNAME 1000 "Starter" ALERT ID RomIncompatibleAlert CONFIRMATION BEGIN TITLE "System Incompatible" MESSAGE "System Version 3.0 or greater " \ "is required to run this application." BUTTONS "OK" END FORM ID MainForm AT ( ) USABLE BEGIN TITLE "OReilly Starter Main" BUTTON "Beep" ID MainBeepButton AT ( AUTO AUTO) BUTTON "Goto Second Form" ID MainGotoSecondFormButton AT (PrevLeft PrevBottom + 5 AUTO AUTO) END FORM ID SecondForm AT ( ) USABLE BEGIN TITLE "OReilly Starter Second" BUTTON "Goto Main Form" ID SecondGotoMainFormButton AT ( AUTO AUTO) END

Programming Handheld and Mobile devices 11 Palm’s simple example - PilotMain uint32_t PilotMain(uint16_t cmd, MemPtr cmdPBP, uint16_t launchFlags) { // OS6NEW: New error type status_t error = errNone; // OS6NEW: Get app database ref - needed for Form Mgr calls, resources. if ((error = SysGetModuleDatabase(SysGetRefNum(), NULL, &gAppDB)) < errNone) return error; // Handle launch code switch (cmd) { case sysAppLaunchCmdNormalLaunch: // Perform app initialization. error = AppStart(); if (error) return error; // OS6NEW: FrmGotoForm() now requires app db ref argument FrmGotoForm(gAppDB, MainForm); // Handle events until user switches to another app. AppEventLoop(); // Clean up before exit. AppStop(); break; default: break; } return errNone; }

Programming Handheld and Mobile devices 12 AppStart() static status_t AppStart(void) { #if 0 AppPrefsType prefs; // OS6NEW: PrefGetAppPreferences() size is now 32-bit uint32_tprefsSize; // Read the saved preferences / saved-state information. prefsSize = sizeof(AppPrefsType); if (PrefGetAppPreferences(kAppCreatorID, kAppPrefsID, &prefs, &prefsSize, kSyncedPrefsDB) != noPreferenceFound) { // Init globals, etc. } #endif return errNone; }

Programming Handheld and Mobile devices 13 AppEventLoop() static void AppEventLoop(void) { status_terror; EventTypeevent; do { EvtGetEvent(&event, evtWaitForever); if (SysHandleEvent(&event)) continue; //OS6NEW: error codes are now status_t (32 bit), not Err (16 bit) if (MenuHandleEvent(0, &event, &error)) continue; if (AppHandleEvent(&event)) continue; FrmDispatchEvent(&event); } while (event.eType != appStopEvent); }

Programming Handheld and Mobile devices 14 AppStop() static void AppStop(void) { #if 0 AppPrefsType prefs; // Write the saved preferences/saved-state information. This // data will be saved during a HotSync backup. PrefSetAppPreferences(kAppCreatorID,kAppPrefsID, kAppPrefsVersion, &prefs, sizeof(prefs), kSyncedPrefsDB); #endif // Close all the open forms. FrmCloseAllForms(); }

Programming Handheld and Mobile devices 15 AppHandleEvent() static Boolean AppHandleEvent(EventType* pEvent) { uint16_t formId; FormType* pForm; if (pEvent->eType == frmLoadEvent) { // Load the form resource. formId = pEvent->data.frmLoad.formID; // OS6NEW: FrmInitForm() needs app db ptr as first argument pForm = FrmInitForm(gAppDB, formId); FrmSetActiveForm(pForm); // Set the event handler for the form. The handler of the currently active form is called by FrmHandleEvent each time // is receives an event. switch (formId) { case MainForm: FrmSetEventHandler(pForm, MainFormHandleEvent); FrmInitLayout(pForm, gMainFormLayout); break; case Form2Form: FrmSetEventHandler(pForm, Form2FormHandleEvent); FrmInitLayout(pForm, gForm2FormLayout); break; default: ErrFatalDisplay("Invalid Form Load Event"); break; } return true; } return false; }

Programming Handheld and Mobile devices 16 Some references The O’Reilly example is available online at: –