summaryrefslogtreecommitdiffstats
path: root/languages/cpp/app_templates/prc-tool/palmhello.c
diff options
context:
space:
mode:
Diffstat (limited to 'languages/cpp/app_templates/prc-tool/palmhello.c')
-rw-r--r--languages/cpp/app_templates/prc-tool/palmhello.c117
1 files changed, 117 insertions, 0 deletions
diff --git a/languages/cpp/app_templates/prc-tool/palmhello.c b/languages/cpp/app_templates/prc-tool/palmhello.c
new file mode 100644
index 00000000..0a34b6c4
--- /dev/null
+++ b/languages/cpp/app_templates/prc-tool/palmhello.c
@@ -0,0 +1,117 @@
+
+/* Main code for PalmHello */
+
+#include <PalmOS.h>
+#include <PalmCompatibility.h>
+#include "callback.h"
+
+#include "palmhelloRsc.h"
+
+static Boolean MainFormHandleEvent (EventPtr e)
+{
+ Boolean handled = false;
+ FormPtr frm;
+
+ CALLBACK_PROLOGUE
+
+ switch (e->eType) {
+ case frmOpenEvent:
+ frm = FrmGetActiveForm();
+ FrmDrawForm(frm);
+ handled = true;
+ break;
+
+ case menuEvent:
+ MenuEraseStatus(NULL);
+
+ switch(e->data.menu.itemID) {
+ }
+
+ handled = true;
+ break;
+
+ case ctlSelectEvent:
+ switch(e->data.ctlSelect.controlID) {
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ CALLBACK_EPILOGUE
+
+ return handled;
+}
+
+static Boolean ApplicationHandleEvent(EventPtr e)
+{
+ FormPtr frm;
+ Word formId;
+ Boolean handled = false;
+
+ if (e->eType == frmLoadEvent) {
+ formId = e->data.frmLoad.formID;
+ frm = FrmInitForm(formId);
+ FrmSetActiveForm(frm);
+
+ switch(formId) {
+ case MainForm:
+ FrmSetEventHandler(frm, MainFormHandleEvent);
+ break;
+ }
+ handled = true;
+ }
+
+ return handled;
+}
+
+/* Get preferences, open (or create) app database */
+static Word StartApplication(void)
+{
+ FrmGotoForm(MainForm);
+ return 0;
+}
+
+/* Save preferences, close forms, close app database */
+static void StopApplication(void)
+{
+ FrmSaveAllForms();
+ FrmCloseAllForms();
+}
+
+/* The main event loop */
+static void EventLoop(void)
+{
+ Word err;
+ EventType e;
+
+ do {
+ EvtGetEvent(&e, evtWaitForever);
+ if (! SysHandleEvent (&e))
+ if (! MenuHandleEvent (NULL, &e, &err))
+ if (! ApplicationHandleEvent (&e))
+ FrmDispatchEvent (&e);
+ } while (e.eType != appStopEvent);
+}
+
+/* Main entry point; it is unlikely you will need to change this except to
+ handle other launch command codes */
+DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
+{
+ Word err;
+
+ if (cmd == sysAppLaunchCmdNormalLaunch) {
+
+ err = StartApplication();
+ if (err) return err;
+
+ EventLoop();
+ StopApplication();
+
+ } else {
+ return sysErrParamErr;
+ }
+
+ return 0;
+}