Introduction to Systems Programming (CS 0449) PalmOS Events Handling Events OS–AppEventLoop() – Event Handlers.

Slides:



Advertisements
Similar presentations
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.
Advertisements

CS 450 Module R1. R1 Introduction In Module R1, you will implement a user interface (command handler). There are a couple of options: ▫Command Line: interface.
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
The Web Warrior Guide to Web Design Technologies
12-Jun-15 JavaScript Language Fundamentals I. 2 About JavaScript JavaScript is not Java, or even related to Java The original name for JavaScript was.
CSE 466 – Spring 2000 – PalmOS - 1 Palm OS zInterface management ybasic user interface model yevent dispatch loop paradigm zSystem management yalarm and.
Overview scope - determines when an identifier can be referenced in a program storage class - determines the period of time during which that identifier.
5.05 Apply Looping Structures
Ch 111 Chapter 11 Advanced Batch Files. Ch 112 Overview This chapter focuses on batch file commands that allow you to:  write sophisticated batch files.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
WORKING WITH MACROS CHAPTER 10 WORKING WITH MACROS.
Hello AP Computer Science!. What are some of the things that you have used computers for?
05/09/ Introducing Visual Basic Sequence Programming.
CPSC 252 Exception Handling Page 1 Exceptions and exception handling Client programmers can make errors using a class attempting to dequeue an item from.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Introduction to C++ Programming Introduction to C++ l C is a programming language developed in the 1970's alongside the UNIX operating system. l C provides.
Lecture 2 Event driven programming Mobile and Handheld Applications1 Programming of Handheld and Mobile Devices Lecture 2: Event driven programming concepts.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
PROGRAMMING IN VISUAL BASIC.NET VISUAL BASIC BUILDING BLOCKS Bilal Munir Mughal 1 Chapter-5.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
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,
PHP meets MySQL.
Ch 101 Chapter 10 Introduction to Batch Files. Ch 102 Overview A batch file is a text file that contains an ordered series of commands.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
The Java Programming Language
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 5 Compiling with resources Rob Pooley
Programming of Mobile and Handheld Devices Lecture 7: Programming OXO for Palm OS Rob Pooley
Programming Handheld and Mobile devices 1 Programming of Handheld and Mobile Devices Lecture 7 J2ME Rob Pooley
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
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.
CPS120: Introduction to Computer Science Decision Making in Programs.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
CNS 1410 Graphical User Interfaces. Obectives Students should understand the difference between a procedural program and an Event Driven Program. Students.
Chapter 15 Introduction to PL/SQL. Chapter Objectives  Explain the benefits of using PL/SQL blocks versus several SQL statements  Identify the sections.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Applications Development
Chapter 2: Variables, Functions, Objects, and Events JavaScript - Introductory.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
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
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 6 Functions.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Exceptions Chapter 16 This chapter explains: What as exception is Why they are useful Java exception facilities.
Lecture 3 Programming on Palm OS Mobile and Handheld Applications1 Programming of Mobile and Handheld Devices Lecture 3: Programming for Palm OS Rob Pooley.
Palm OS emulator.
Chapter Functions 6. Modular Programming 6.1 Modular Programming Modular programming: breaking a program up into smaller, manageable functions or modules.
Exceptions and Assertions Chapter 15 – CSCI 1302.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Brief Edition Chapter 6 Functions.
Manipulator example #include int main (void) { double x = ; streamsize prec = cout.precision(); cout
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
JavaScript Events Java 4 Understanding Events Events add interactivity between the web page and the user You can think of an event as a trigger that.
Introduction to Javascript. What is javascript?  The most popular web scripting language in the world  Used to produce rich thin client web applications.
JavaScript Events. Understanding Events Events add interactivity between the web page and the user Events add interactivity between the web page and the.
Today… Preparation for doing Assignment 1. Invoking methods overview. Conditionals and Loops. Winter 2016CMPE212 - Prof. McLeod1.
Introduction to Exceptions in Java CS201, SW Development Methods.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
3 Introduction to Classes and Objects.
Error Handling Summary of the next few pages: Error Handling Cursors.
Scripts & Functions Scripts and functions are contained in .m-files
Using Procedures and Exception Handling
Variables and Arithmetic Operations
Predefined Dialog Boxes
Govt. Polytechnic,Dhangar
CISC124 Labs start this week in JEFF 155. Fall 2018
Constructors, GUI’s(Using Swing) and ActionListner
IPC144 Introduction to Programming Using C Week 4 – Lesson 2
Presentation transcript:

Introduction to Systems Programming (CS 0449) PalmOS Events Handling Events OS–AppEventLoop() – Event Handlers

Palm OS - Handling Events UInt32 PilotMain (UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { //This function is the starting point for every palm program Error; switch (cmd) //cmd is the launch code for your program there are many launch { //codes that might be be sent to your program for different // reasons but here we will only cover one. case sysAppLaunchCmdNormalLaunch: //this is the launch code for a normal start error = AppStart(); //this function currently just returns that there is no error //but in other cases it might be used to initialize or retrieve data //if (error) this is just a little statement return error; //saying if something went wrong exit the program with //the reason FrmGotoForm(MainForm); //this puts an event in the event queue that tells it to open AppEventLoop(); //This function is a continuous loop that will direct events in //the event queue to the right event handler for your program AppStop(); //all this function does right now is close all the forms but in //other cases it might be used to do some cleanup for your program break; default: break; } return errNone; }

Palm OS - Handling Events PilotMain( ) AppStart ( ) AppEventLoop ( ) AppStop ( ) Event Queue Retrieve from AppLaunchCodeCmd AddRecord DisplayAlarm Find Goto NormalLaunch SystemReset Launch Codes

Palm OS – Processing AppEventLoop() Event Queue Event Event Loop OS EvtGetEvent

Palm OS–AppEventLoop() – Event Handlers Event Loop SysHandleEvent MenuHandleEvent AppHandleEvent FrmDispatchEvent -Handle System Event User pressing power button to turn off the handheld Battery low notification Global Find function Interrupts -Handle Menu Event User tapping menu silk-screened button. Selecting a displayed menu item. Taps inside a menu to activate a menu item (open). Taps outside a displayed menu (close)—remove menu from the screen. -Handle Application Event Programmer writes this function. To handle FrmLoadEvent. Loads and activates form resources. Application sets up a callback function to handle current active form. -Handle Form Dispatch Event Miniature AppEventLoop(). Passes events to active form’s event handler (which was set up in AppHandleEvent). Passes events to MainFormHandleEvent calback Function. On success, it returns execution to event loop.

PalmMain ( ) #include #include "helloRsc.h" UInt32 PilotMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags) { Err error; switch (cmd){ case sysAppLaunchCmdNormalLaunch: error = AppStart(); if (error) return error; FrmGotoForm(MainForm); AppEventLoop(); AppStop(); break; } return errNone; }

AppStart() and AppStop() static Err AppStart ( void ) { // This function is used to initialize databases and retrieve user preferences return errNone; } static void AppStop ( void ) { // Used for any cleanup that your program might need like closing // databases or saving preferences FrmCloseAllForms (); }

Application Main Event Loop AppEventLoop() static void AppEventLoop(void) { EventType event; Err error; do { EvtGetEvent(&event, evtWaitForever); if ( ! SysHandleEvent (&event) ) if ( ! MenuHandleEvent (0, &event, &error) ) if ( ! AppHandleEvent (&event)) FrmDispatchEvent (&event); } while ( event. eType != appStopEvent ); }

Event Driven Architecture PalmMain() AppEventLoop() AppHandleEvent() MainFormHandleEvent() FrmDispatchEvent() frmColseEvent FrmHandleEvent() Events frmLoadEvent FrmInitForm() FrmSetActiveForm() FrmSetEventHandler() frmOpenEvent FrmDrawForm()

Palm OS Event Driven Architecture PalmMain() AppStart()AppStop() AppEventLoop() AppHandleEvent() MainFormHandleEvent() FrmDispatchEvent() Events GUI event handling (Buttons, Fields,...) SysHandleEvent() MenuHandleEvent() MainMenuHandleEvent()

Application Event Handler static Boolean AppHandleEvent (EventType *event){ //Initializing resources and setting up event handlers for forms. FormType *form; UInt16 formID; Boolean handled = false; if (event -> eType == frmLoadEvent) { formID = event->data. frmLoad. formID; //these few lines form = FrmInitForm( formID ); //are getting some data FrmSetActiveForm( form ); //from the event structure switch (formID) { case MainForm: FrmSetEventHandler( form, MainFormHandleEvent ); break; } handled = true; } return handled; }

Form Event Handler static Boolean MainFormHandleEvent (EventType *event) { Boolean handled = false; FormType * form; switch (event -> eType) { case frmOpenEvent: form = FrmGetActiveForm (); FrmDrawForm (form); handled = true; break; default: break; } return handled; }

Handling Events on Selecting/Pressing Buttons (Palm OS Bible, Chapter 8, page 265) // Code from the form event handler procedure if( event -> eType == ctlSelectEvent ) { switch ( event -> data. ctlSelect. controlID ){ case MyOKButton : // OK was tapped... break; case MyCancelButton : // Cancel was tapped... break; }

Handling Alerts UInt16 tappedButton ; tappedButton = FrmAlert ( MyAlertID ); switch ( tappedButton ) case 0 : // the first button was tapped... break; case 1 : // the second button was tapped... break; } Resource file (.rcp) ALERT ID MyAlertID INFORMATION BEGIN TITLE "Hello, world" MESSAGE "Good day to you, ^1." BUTTONS "OK" END

FrmAlert ( ) -- Function Purpose Create a modal dialog from an alert resource and display it until the user selects a button in the dialog. Declared In Form.h Prototype UInt16 FrmAlert ( UInt16 alertId ) Parameters → alertId -- ID of the alert resource. Returns Returns the item number of the button the user selected. A button's item number is determined by its order in the alert dialog; the first button has the item number 0 (zero).

FrmCustomAlert( ) Function Purpose Create a modal dialog from an alert resource and display the dialog until the user taps a button in the alert dialog. Declared In Form.h Prototype UInt16 FrmCustomAlert (UInt16 alertId, const Char *s1, const Char *s2, const Char *s3 ) Parameters → alertId Resource ID of the alert. → s1, s2, s3 Strings to replace ^1, ^2, and ^3 (see Comments). Returns Returns the number of the button the user tapped (the first button is zero). Comments A button's item number is determined by its order in the alert template; the first button has the item number zero. Up to three strings can be passed to this routine. They are used to replace the variables ^1, ^2 and ^3 that are contained in the message string of the alert resource. If the variables ^1, ^2, and ^3 occur in the message string, do not pass NULL for the arguments s1, s2, and s3. If you want an argument to be ignored, pass the empty string (""). In Palm OS 2.0 or below, pass a string containing a space (" ") instead of the empty string.