Merge pull request #13 from Tavisco/master
Add Handera SDK version 1.05
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.DS_Store
|
||||||
@ -10,4 +10,5 @@ Contributers
|
|||||||
- https://github.com/acesso[*@acesso*]: SDKs 1.0, 2.0, 3.1, 3.5, and 4.0
|
- https://github.com/acesso[*@acesso*]: SDKs 1.0, 2.0, 3.1, 3.5, and 4.0
|
||||||
- https://github.com/jichu4n[*@jichu4n*]: SDK 5.0r3
|
- https://github.com/jichu4n[*@jichu4n*]: SDK 5.0r3
|
||||||
- https://github.com/stevelittle[*@stevelittle*]: SDK 5.0r4
|
- https://github.com/stevelittle[*@stevelittle*]: SDK 5.0r4
|
||||||
|
- https://github.com/Tavisco[*@Tavisco*]: Handera SDK 1.05
|
||||||
|
|
||||||
|
|||||||
BIN
handera-105/doc/Companion/Programming_Companion.pdf
Normal file
BIN
handera-105/doc/Reference Manual/ReferenceManual.pdf
Normal file
BIN
handera-105/examples/ExampleA/ExampleA.mcp
Normal file
BIN
handera-105/examples/ExampleA/Rsc/Resource.frk/Starter.rsrc
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
0
handera-105/examples/ExampleA/Rsc/Starter.rsrc
Normal file
478
handera-105/examples/ExampleA/Src/starter.c
Normal file
@ -0,0 +1,478 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Starter.c
|
||||||
|
*
|
||||||
|
* Project : Example A
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Structures
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterPreferenceType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterAppInfoType;
|
||||||
|
|
||||||
|
typedef StarterAppInfoType* StarterAppInfoPtr;
|
||||||
|
|
||||||
|
FontID currentFont = stdFont;
|
||||||
|
Char helloStr[] = "Hello World";
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define appFileCreator 'Ex_A'
|
||||||
|
#define appVersionNum 0x01
|
||||||
|
#define appPrefID 0x00
|
||||||
|
#define appPrefVersionNum 0x01
|
||||||
|
|
||||||
|
// Define the minimum OS version we support (2.0 for now).
|
||||||
|
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: RomVersionCompatible
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine checks that a ROM version is meet your
|
||||||
|
* minimum requirement.
|
||||||
|
*
|
||||||
|
* PARAMETERS: requiredVersion - minimum rom version required
|
||||||
|
* (see sysFtrNumROMVersion in SystemMgr.h
|
||||||
|
* for format)
|
||||||
|
* launchFlags - flags that indicate if the application
|
||||||
|
* UI is initialized.
|
||||||
|
*
|
||||||
|
* RETURNED: error code or zero if rom is compatible
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
UInt32 romVersion;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* See if we're on in minimum required version of the ROM or later.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
|
||||||
|
if (romVersion < requiredVersion)
|
||||||
|
{
|
||||||
|
if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
|
||||||
|
(sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
|
||||||
|
{
|
||||||
|
FrmAlert (RomIncompatibleAlert);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Palm OS 1.0 will continuously relaunch this app unless we switch to
|
||||||
|
* another safe one.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (romVersion < ourMinVersion)
|
||||||
|
{
|
||||||
|
AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysErrRomIncompatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: GetObjectPtr
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine returns a pointer to an object in the current
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void * GetObjectPtr(UInt16 objectID)
|
||||||
|
{
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvSetHelloFont
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Sets the font and centers the field horizontally
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvCenterTextField(FormPtr frmP, FieldPtr fldP, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r, fr;
|
||||||
|
Int16 stringWidth;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* First get the width of the field string in pixels.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FntSetFont(FldGetFont(fldP));
|
||||||
|
stringWidth = FntCharsWidth(helloStr, StrLen(helloStr));
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Now center the field based on width of string in pixels.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &fr);
|
||||||
|
FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainHelloField), &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FldEraseField(fldP);
|
||||||
|
|
||||||
|
r.topLeft.x = (fr.extent.x/2) - (stringWidth/2);
|
||||||
|
FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainHelloField), &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FldDrawField(fldP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormInit
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine initializes the MainForm form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: frm - pointer to the MainForm form.
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormInit(FormPtr frmP)
|
||||||
|
{
|
||||||
|
FieldPtr fldP;
|
||||||
|
Char *tmp;
|
||||||
|
|
||||||
|
currentFont = stdFont;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Initialize the field to "Hello World" and set its font
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
fldP = (FieldPtr)GetObjectPtr(MainHelloField);
|
||||||
|
if ((tmp = FldGetTextPtr(fldP)) != NULL)
|
||||||
|
MemPtrFree(tmp);
|
||||||
|
tmp = (Char *)MemPtrNew(StrLen(helloStr) + 1);
|
||||||
|
StrCopy(tmp, helloStr);
|
||||||
|
FldSetTextPtr(fldP, tmp);
|
||||||
|
FldSetFont((FieldPtr)GetObjectPtr(MainHelloField), currentFont);
|
||||||
|
|
||||||
|
PrvCenterTextField(frmP, (FieldPtr)GetObjectPtr(MainHelloField), false);;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormDoCommand
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine performs the menu command specified.
|
||||||
|
*
|
||||||
|
* PARAMETERS: command - menu item id
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormDoCommand(UInt16 command)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
UInt16 formID;
|
||||||
|
FormPtr frmP, aboutFrmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
formID = FrmGetFormId (frmP);
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case MainOptionsAboutExampleA:
|
||||||
|
MenuEraseStatus(0);
|
||||||
|
aboutFrmP = FrmInitForm (AboutForm);
|
||||||
|
FrmDoDialog (aboutFrmP); // Display the About Box.
|
||||||
|
FrmDeleteForm (aboutFrmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainOptionsFont :
|
||||||
|
currentFont = FontSelect(currentFont);
|
||||||
|
FldSetFont((FieldPtr)GetObjectPtr(MainHelloField), currentFont);
|
||||||
|
PrvCenterTextField(frmP, (FieldPtr)GetObjectPtr(MainHelloField), true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event handler for the
|
||||||
|
* "MainForm" of this application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: eventP - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (eventP->eType)
|
||||||
|
{
|
||||||
|
case menuEvent:
|
||||||
|
return MainFormDoCommand(eventP->data.menu.itemID);
|
||||||
|
|
||||||
|
case frmOpenEvent:
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
MainFormInit(frmP);
|
||||||
|
FrmDrawForm (frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine loads form resources and set the event
|
||||||
|
* handler for the form loaded.
|
||||||
|
*
|
||||||
|
* PARAMETERS: event - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean AppHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
UInt16 formId;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
if (eventP->eType == frmLoadEvent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Load the form resource.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
formId = eventP->data.frmLoad.formID;
|
||||||
|
|
||||||
|
frmP = FrmInitForm(formId);
|
||||||
|
FrmSetActiveForm(frmP);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* 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(frmP, MainFormHandleEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrFatalDisplay("Invalid Form Load Event");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppEventLoop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event loop for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppEventLoop(void)
|
||||||
|
{
|
||||||
|
UInt16 error;
|
||||||
|
EventType event;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
EvtGetEvent(&event, evtWaitForever);
|
||||||
|
|
||||||
|
if (! SysHandleEvent(&event))
|
||||||
|
if (! MenuHandleEvent(0, &event, &error))
|
||||||
|
if (! AppHandleEvent(&event))
|
||||||
|
FrmDispatchEvent(&event);
|
||||||
|
|
||||||
|
} while (event.eType != appStopEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStart
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Get the current application's preferences.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: Err value 0 if nothing went wrong
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err AppStart(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
UInt16 prefsSize;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Read the saved preferences / saved-state information.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
prefsSize = sizeof(StarterPreferenceType);
|
||||||
|
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
|
||||||
|
noPreferenceFound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Save the current state of the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppStop(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Write the saved preferences / saved-state information. This data
|
||||||
|
* will be backed up during a HotSync.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
|
||||||
|
&prefs, sizeof (prefs), true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Close all the open forms.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmCloseAllForms ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: StarterPalmMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
*
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
Err error;
|
||||||
|
|
||||||
|
if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case sysAppLaunchCmdNormalLaunch:
|
||||||
|
if ((error = AppStart()) != errNone)
|
||||||
|
return(error);
|
||||||
|
|
||||||
|
FrmGotoForm(MainForm);
|
||||||
|
AppEventLoop();
|
||||||
|
AppStop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PilotMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
return StarterPalmMain(cmd, cmdPBP, launchFlags);
|
||||||
|
}
|
||||||
51
handera-105/examples/ExampleA/StarterRsc.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
// Header generated by Constructor for Palm OS¨ 1.6
|
||||||
|
//
|
||||||
|
// Generated at 4:45:12 PM on Wednesday, April 04, 2001
|
||||||
|
//
|
||||||
|
// Generated for file: T:\TRGProd\StarKist\sw\sdk\cw\examples\ExampleA\Rsc\Starter.rsrc
|
||||||
|
//
|
||||||
|
// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE FROM CONSTRUCTOR FOR PALM OS¨;
|
||||||
|
// - DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST
|
||||||
|
//
|
||||||
|
// Palm App Name: "ExampleA"
|
||||||
|
//
|
||||||
|
// Palm App Version: "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1000
|
||||||
|
#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0)
|
||||||
|
#define MainGlobeBitMap 1200 //(Left Origin = 50, Top Origin = 50, Bitmap Resource ID = 1200, Usable = 1)
|
||||||
|
#define MainHelloField 1002 //(Left Origin = 53, Top Origin = 138, Width = 80, Height = 20, Usable = 1, Editable = 0, Underline = 0, Single Line = 1, Dynamic Size = 0, Left Justified = 1, Max Characters = 80, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1100
|
||||||
|
#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
|
||||||
|
#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold)
|
||||||
|
#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: Talt 1001
|
||||||
|
#define RomIncompatibleAlert 1001
|
||||||
|
#define RomIncompatibleOK 0
|
||||||
|
|
||||||
|
// Resource: MBAR 1000
|
||||||
|
#define MainFormMenuBar 1000
|
||||||
|
|
||||||
|
// Resource: MENU 1000
|
||||||
|
#define MainOptionsMenu 1000
|
||||||
|
#define MainOptionsFont 1000
|
||||||
|
#define MainOptionsAboutExampleA 1001
|
||||||
|
|
||||||
|
// Resource: PICT 1200
|
||||||
|
#define GlobeBitmap 1200
|
||||||
|
// Resource: PICT 1100
|
||||||
|
#define SmallIconBitmap 1100
|
||||||
|
// Resource: PICT 1000
|
||||||
|
#define BigIconBitmap 1000
|
||||||
|
// Resource: taif 1001
|
||||||
|
#define SmallIconAppIconFamily 1001
|
||||||
|
|
||||||
|
// Resource: taif 1000
|
||||||
|
#define BigIconAppIconFamily 1000
|
||||||
BIN
handera-105/examples/ExampleB/ExampleB.mcp
Normal file
BIN
handera-105/examples/ExampleB/Rsc/Resource.frk/Starter.rsrc
Normal file
|
After Width: | Height: | Size: 18 KiB |
0
handera-105/examples/ExampleB/Rsc/Starter.rsrc
Normal file
478
handera-105/examples/ExampleB/Src/starter.c
Normal file
@ -0,0 +1,478 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Starter.c
|
||||||
|
*
|
||||||
|
* Project : Example B
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Structures
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterPreferenceType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterAppInfoType;
|
||||||
|
|
||||||
|
typedef StarterAppInfoType* StarterAppInfoPtr;
|
||||||
|
|
||||||
|
FontID currentFont = stdFont;
|
||||||
|
Char helloStr[] = "Hello World";
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define appFileCreator 'Ex_B'
|
||||||
|
#define appVersionNum 0x01
|
||||||
|
#define appPrefID 0x00
|
||||||
|
#define appPrefVersionNum 0x01
|
||||||
|
|
||||||
|
// Define the minimum OS version we support (2.0 for now).
|
||||||
|
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: RomVersionCompatible
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine checks that a ROM version is meet your
|
||||||
|
* minimum requirement.
|
||||||
|
*
|
||||||
|
* PARAMETERS: requiredVersion - minimum rom version required
|
||||||
|
* (see sysFtrNumROMVersion in SystemMgr.h
|
||||||
|
* for format)
|
||||||
|
* launchFlags - flags that indicate if the application
|
||||||
|
* UI is initialized.
|
||||||
|
*
|
||||||
|
* RETURNED: error code or zero if rom is compatible
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
UInt32 romVersion;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* See if we're on in minimum required version of the ROM or later.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
|
||||||
|
if (romVersion < requiredVersion)
|
||||||
|
{
|
||||||
|
if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
|
||||||
|
(sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
|
||||||
|
{
|
||||||
|
FrmAlert (RomIncompatibleAlert);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Palm OS 1.0 will continuously relaunch this app unless we switch to
|
||||||
|
* another safe one.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (romVersion < ourMinVersion)
|
||||||
|
{
|
||||||
|
AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysErrRomIncompatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: GetObjectPtr
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine returns a pointer to an object in the current
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void * GetObjectPtr(UInt16 objectID)
|
||||||
|
{
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvSetHelloFont
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Sets the font and centers the field horizontally
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvCenterTextField(FormPtr frmP, FieldPtr fldP, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r, fr;
|
||||||
|
Int16 stringWidth;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* First get the width of the field string in pixels.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FntSetFont(FldGetFont(fldP));
|
||||||
|
stringWidth = FntCharsWidth(helloStr, StrLen(helloStr));
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Now center the field based on width of string in pixels.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &fr);
|
||||||
|
FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainHelloField), &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FldEraseField(fldP);
|
||||||
|
|
||||||
|
r.topLeft.x = (fr.extent.x/2) - (stringWidth/2);
|
||||||
|
FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainHelloField), &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FldDrawField(fldP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormInit
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine initializes the MainForm form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: frm - pointer to the MainForm form.
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormInit(FormPtr frmP)
|
||||||
|
{
|
||||||
|
FieldPtr fldP;
|
||||||
|
Char *tmp;
|
||||||
|
|
||||||
|
currentFont = stdFont;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Initialize the field to "Hello World" and set its font
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
fldP = (FieldPtr)GetObjectPtr(MainHelloField);
|
||||||
|
if ((tmp = FldGetTextPtr(fldP)) != NULL)
|
||||||
|
MemPtrFree(tmp);
|
||||||
|
tmp = (Char *)MemPtrNew(StrLen(helloStr) + 1);
|
||||||
|
StrCopy(tmp, helloStr);
|
||||||
|
FldSetTextPtr(fldP, tmp);
|
||||||
|
FldSetFont((FieldPtr)GetObjectPtr(MainHelloField), currentFont);
|
||||||
|
|
||||||
|
PrvCenterTextField(frmP, (FieldPtr)GetObjectPtr(MainHelloField), false);;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormDoCommand
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine performs the menu command specified.
|
||||||
|
*
|
||||||
|
* PARAMETERS: command - menu item id
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormDoCommand(UInt16 command)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
UInt16 formID;
|
||||||
|
FormPtr frmP, aboutFrmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
formID = FrmGetFormId (frmP);
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case MainOptionsAboutExampleB :
|
||||||
|
MenuEraseStatus(0);
|
||||||
|
aboutFrmP = FrmInitForm (AboutForm);
|
||||||
|
FrmDoDialog (aboutFrmP); // Display the About Box.
|
||||||
|
FrmDeleteForm (aboutFrmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainOptionsFont :
|
||||||
|
currentFont = FontSelect(currentFont);
|
||||||
|
FldSetFont((FieldPtr)GetObjectPtr(MainHelloField), currentFont);
|
||||||
|
PrvCenterTextField(frmP, (FieldPtr)GetObjectPtr(MainHelloField), true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event handler for the
|
||||||
|
* "MainForm" of this application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: eventP - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (eventP->eType)
|
||||||
|
{
|
||||||
|
case menuEvent:
|
||||||
|
return MainFormDoCommand(eventP->data.menu.itemID);
|
||||||
|
|
||||||
|
case frmOpenEvent:
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
MainFormInit(frmP);
|
||||||
|
FrmDrawForm (frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine loads form resources and set the event
|
||||||
|
* handler for the form loaded.
|
||||||
|
*
|
||||||
|
* PARAMETERS: event - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean AppHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
UInt16 formId;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
if (eventP->eType == frmLoadEvent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Load the form resource.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
formId = eventP->data.frmLoad.formID;
|
||||||
|
|
||||||
|
frmP = FrmInitForm(formId);
|
||||||
|
FrmSetActiveForm(frmP);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* 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(frmP, MainFormHandleEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrFatalDisplay("Invalid Form Load Event");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppEventLoop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event loop for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppEventLoop(void)
|
||||||
|
{
|
||||||
|
UInt16 error;
|
||||||
|
EventType event;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
EvtGetEvent(&event, evtWaitForever);
|
||||||
|
|
||||||
|
if (! SysHandleEvent(&event))
|
||||||
|
if (! MenuHandleEvent(0, &event, &error))
|
||||||
|
if (! AppHandleEvent(&event))
|
||||||
|
FrmDispatchEvent(&event);
|
||||||
|
|
||||||
|
} while (event.eType != appStopEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStart
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Get the current application's preferences.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: Err value 0 if nothing went wrong
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err AppStart(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
UInt16 prefsSize;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Read the saved preferences / saved-state information.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
prefsSize = sizeof(StarterPreferenceType);
|
||||||
|
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
|
||||||
|
noPreferenceFound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Save the current state of the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppStop(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Write the saved preferences / saved-state information. This data
|
||||||
|
* will be backed up during a HotSync.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
|
||||||
|
&prefs, sizeof (prefs), true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Close all the open forms.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmCloseAllForms ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: StarterPalmMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
*
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
Err error;
|
||||||
|
|
||||||
|
if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case sysAppLaunchCmdNormalLaunch:
|
||||||
|
if ((error = AppStart()) != errNone)
|
||||||
|
return(error);
|
||||||
|
|
||||||
|
FrmGotoForm(MainForm);
|
||||||
|
AppEventLoop();
|
||||||
|
AppStop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PilotMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
return StarterPalmMain(cmd, cmdPBP, launchFlags);
|
||||||
|
}
|
||||||
68
handera-105/examples/ExampleB/StarterRsc.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// Header generated by Constructor for Palm OS¨ 1.6
|
||||||
|
//
|
||||||
|
// Generated at 4:45:36 PM on Wednesday, April 04, 2001
|
||||||
|
//
|
||||||
|
// Generated for file: T:\TRGProd\StarKist\sw\sdk\cw\examples\ExampleB\Rsc\Starter.rsrc
|
||||||
|
//
|
||||||
|
// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE FROM CONSTRUCTOR FOR PALM OS¨;
|
||||||
|
// - DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST
|
||||||
|
//
|
||||||
|
// Palm App Name: "ExampleB"
|
||||||
|
//
|
||||||
|
// Palm App Version: "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1000
|
||||||
|
#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0)
|
||||||
|
#define MainGlobeBitMap 1200 //(Left Origin = 50, Top Origin = 50, Bitmap Resource ID = 1200, Usable = 1)
|
||||||
|
#define MainHelloField 1002 //(Left Origin = 53, Top Origin = 138, Width = 80, Height = 20, Usable = 1, Editable = 0, Underline = 0, Single Line = 1, Dynamic Size = 0, Left Justified = 1, Max Characters = 80, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1100
|
||||||
|
#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
|
||||||
|
#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard)
|
||||||
|
#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold)
|
||||||
|
#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: Talt 1001
|
||||||
|
#define RomIncompatibleAlert 1001
|
||||||
|
#define RomIncompatibleOK 0
|
||||||
|
|
||||||
|
// Resource: MBAR 1000
|
||||||
|
#define MainFormMenuBar 1000
|
||||||
|
|
||||||
|
// Resource: MENU 1000
|
||||||
|
#define MainOptionsMenu 1000
|
||||||
|
#define MainOptionsFont 1000
|
||||||
|
#define MainOptionsAboutExampleB 1001
|
||||||
|
|
||||||
|
// Resource: PICT 1200
|
||||||
|
#define GlobeBitmap 1200
|
||||||
|
// Resource: PICT 1100
|
||||||
|
#define SmallIconBitmap 1100
|
||||||
|
// Resource: PICT 1000
|
||||||
|
#define BigIconBitmap 1000
|
||||||
|
// Resource: PICT 5296
|
||||||
|
#define VGAGlobeBitmap 5296
|
||||||
|
// Resource: PICT 1400
|
||||||
|
#define VGABigIconBitmap 1400
|
||||||
|
// Resource: PICT 1500
|
||||||
|
#define VGASmallIconBitmap 1500
|
||||||
|
// Resource: PICT 1600
|
||||||
|
#define VGABigIconInvertedBitmap 1600
|
||||||
|
// Resource: taif 2002
|
||||||
|
#define VGABigIconInvertedAppIconFamily 2002
|
||||||
|
|
||||||
|
// Resource: taif 2001
|
||||||
|
#define VGASmallIconAppIconFamily 2001
|
||||||
|
|
||||||
|
// Resource: taif 2000
|
||||||
|
#define VGABigIconAppIconFamily 2000
|
||||||
|
|
||||||
|
// Resource: taif 1001
|
||||||
|
#define SmallIconAppIconFamily 1001
|
||||||
|
|
||||||
|
// Resource: taif 1000
|
||||||
|
#define BigIconAppIconFamily 1000
|
||||||
BIN
handera-105/examples/ExampleC/ExampleC.mcp
Normal file
0
handera-105/examples/ExampleC/Rsc/ExampleC.rsrc
Normal file
BIN
handera-105/examples/ExampleC/Rsc/Resource.frk/ExampleC.rsrc
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
handera-105/examples/ExampleC/Rsc/Resource.frk/Starter.rsrc
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
0
handera-105/examples/ExampleC/Rsc/Starter.rsrc
Normal file
11
handera-105/examples/ExampleC/Src/Stub.c
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Stub.c
|
||||||
|
*
|
||||||
|
* Project: Example C
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
void __Startup__(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
546
handera-105/examples/ExampleC/Src/starter.c
Normal file
@ -0,0 +1,546 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Starter.c
|
||||||
|
*
|
||||||
|
* Project: Example C
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Entry Points
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Structures
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterPreferenceType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterAppInfoType;
|
||||||
|
|
||||||
|
typedef StarterAppInfoType* StarterAppInfoPtr;
|
||||||
|
|
||||||
|
FontID currentFont = stdFont;
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define appFileCreator 'Ex_5'
|
||||||
|
#define appVersionNum 0x01
|
||||||
|
#define appPrefID 0x00
|
||||||
|
#define appPrefVersionNum 0x01
|
||||||
|
|
||||||
|
// Define the minimum OS version we support (2.0 for now).
|
||||||
|
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: RomVersionCompatible
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine checks that a ROM version is meet your
|
||||||
|
* minimum requirement.
|
||||||
|
*
|
||||||
|
* PARAMETERS: requiredVersion - minimum rom version required
|
||||||
|
* (see sysFtrNumROMVersion in SystemMgr.h
|
||||||
|
* for format)
|
||||||
|
* launchFlags - flags that indicate if the application
|
||||||
|
* UI is initialized.
|
||||||
|
*
|
||||||
|
* RETURNED: error code or zero if rom is compatible
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
UInt32 romVersion;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* See if we're on in minimum required version of the ROM or later.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
|
||||||
|
if (romVersion < requiredVersion)
|
||||||
|
{
|
||||||
|
if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
|
||||||
|
(sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
|
||||||
|
{
|
||||||
|
FrmAlert (RomIncompatibleAlert);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Palm OS 1.0 will continuously relaunch this app unless we switch to
|
||||||
|
* another safe one.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (romVersion < ourMinVersion)
|
||||||
|
{
|
||||||
|
AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysErrRomIncompatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: GetObjectPtr
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine returns a pointer to an object in the current
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void * GetObjectPtr(UInt16 objectID)
|
||||||
|
{
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: DrawHelloWorld
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine prints "Hello World" to the center of the
|
||||||
|
* window.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void DrawHelloWorld(void)
|
||||||
|
{
|
||||||
|
MemHandle resH;
|
||||||
|
BitmapPtr resP;
|
||||||
|
char *str = "Hello World";
|
||||||
|
FontID savedFont;
|
||||||
|
Coord x, y, winWidth, winHeight;
|
||||||
|
|
||||||
|
resH = DmGetResource(bitmapRsc, GlobeBitmap);
|
||||||
|
ErrFatalDisplayIf(!resH, "Missing bitmap");
|
||||||
|
resP = MemHandleLock(resH);
|
||||||
|
|
||||||
|
WinGetWindowExtent(&winWidth, &winHeight);
|
||||||
|
savedFont = FntSetFont(currentFont);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Draw the globe graphic
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
x = (winWidth/2) - (resP->width/2);
|
||||||
|
y = (winHeight/2) - (resP->height/2);
|
||||||
|
WinDrawBitmap(resP, x, y);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Draw String below the globe
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
x = (winWidth/2) - (FntCharsWidth(str, StrLen(str))/2);
|
||||||
|
y = y + resP->height + FntCharHeight() + 10;
|
||||||
|
WinDrawChars(str, StrLen(str), x, y);
|
||||||
|
|
||||||
|
FntSetFont(savedFont);
|
||||||
|
MemPtrUnlock(resP);
|
||||||
|
DmReleaseResource(resH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: EraseHelloWorld
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine erases "Hello World" from the window.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void EraseHelloWorld(void)
|
||||||
|
{
|
||||||
|
MemHandle resH;
|
||||||
|
BitmapPtr resP;
|
||||||
|
char *str = "Hello World";
|
||||||
|
FontID savedFont;
|
||||||
|
Coord x, y, winWidth, winHeight;
|
||||||
|
|
||||||
|
resH = DmGetResource(bitmapRsc, GlobeBitmap);
|
||||||
|
ErrFatalDisplayIf(!resH, "Missing bitmap");
|
||||||
|
resP = MemHandleLock(resH);
|
||||||
|
|
||||||
|
WinGetWindowExtent(&winWidth, &winHeight);
|
||||||
|
savedFont = FntSetFont(currentFont);
|
||||||
|
|
||||||
|
x = (winWidth/2) - (FntCharsWidth(str, StrLen(str))/2);
|
||||||
|
y = (winHeight/2) - (resP->height/2);
|
||||||
|
y = y + resP->height + FntCharHeight() + 10;
|
||||||
|
WinEraseChars(str, StrLen(str), x, y);
|
||||||
|
|
||||||
|
FntSetFont(savedFont);
|
||||||
|
MemPtrUnlock(resP);
|
||||||
|
DmReleaseResource(resH);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormInit
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine initializes the MainForm form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: frm - pointer to the MainForm form.
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormInit(FormPtr /*frmP*/)
|
||||||
|
{
|
||||||
|
DrawHelloWorld();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormDoCommand
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine performs the menu command specified.
|
||||||
|
*
|
||||||
|
* PARAMETERS: command - menu item id
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormDoCommand(UInt16 command)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
UInt16 formID;
|
||||||
|
FormPtr frmP;
|
||||||
|
FontID newFont;
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case MainOptionsAboutExampleC:
|
||||||
|
MenuEraseStatus(0); // Clear the menu status from the display.
|
||||||
|
frmP = FrmInitForm (AboutForm);
|
||||||
|
FrmDoDialog (frmP); // Display the About Box.
|
||||||
|
FrmDeleteForm (frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainOptionsFont :
|
||||||
|
formID = (FrmGetFormId (FrmGetActiveForm ()));
|
||||||
|
newFont = FontSelect(currentFont);
|
||||||
|
EraseHelloWorld();
|
||||||
|
currentFont = newFont;
|
||||||
|
FrmUpdateForm (formID, frmRedrawUpdateCode);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event handler for the
|
||||||
|
* "MainForm" of this application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: eventP - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (eventP->eType)
|
||||||
|
{
|
||||||
|
case menuEvent:
|
||||||
|
return MainFormDoCommand(eventP->data.menu.itemID);
|
||||||
|
|
||||||
|
case frmOpenEvent:
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
MainFormInit( frmP);
|
||||||
|
FrmDrawForm ( frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case frmUpdateEvent :
|
||||||
|
DrawHelloWorld();
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine loads form resources and set the event
|
||||||
|
* handler for the form loaded.
|
||||||
|
*
|
||||||
|
* PARAMETERS: event - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean AppHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
UInt16 formId;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
if (eventP->eType == frmLoadEvent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Load the form resource.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
formId = eventP->data.frmLoad.formID;
|
||||||
|
frmP = FrmInitForm(formId);
|
||||||
|
FrmSetActiveForm(frmP);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* 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(frmP, MainFormHandleEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrFatalDisplay("Invalid Form Load Event");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppEventLoop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event loop for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppEventLoop(void)
|
||||||
|
{
|
||||||
|
UInt16 error;
|
||||||
|
EventType event;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
EvtGetEvent(&event, evtWaitForever);
|
||||||
|
|
||||||
|
if (! SysHandleEvent(&event))
|
||||||
|
if (! MenuHandleEvent(0, &event, &error))
|
||||||
|
if (! AppHandleEvent(&event))
|
||||||
|
FrmDispatchEvent(&event);
|
||||||
|
|
||||||
|
} while (event.eType != appStopEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStart
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Get the current application's preferences.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: Err value 0 if nothing went wrong
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err AppStart(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
UInt16 prefsSize;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Read the saved preferences / saved-state information.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
prefsSize = sizeof(StarterPreferenceType);
|
||||||
|
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
|
||||||
|
noPreferenceFound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Save the current state of the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppStop(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Write the saved preferences / saved-state information. This data
|
||||||
|
* will be backed up during a HotSync.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
|
||||||
|
&prefs, sizeof (prefs), true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Close all the open forms.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmCloseAllForms ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: StarterPalmMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
*
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
Err error;
|
||||||
|
|
||||||
|
if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case sysAppLaunchCmdNormalLaunch:
|
||||||
|
error = AppStart();
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
FrmGotoForm(MainForm);
|
||||||
|
AppEventLoop();
|
||||||
|
AppStop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PilotMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
return StarterPalmMain(cmd, cmdPBP, launchFlags);
|
||||||
|
}
|
||||||
|
|
||||||
50
handera-105/examples/ExampleC/StarterRsc.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
// Header generated by Constructor for Palm OS¨ 1.6
|
||||||
|
//
|
||||||
|
// Generated at 2:44:50 PM on Wednesday, March 21, 2001
|
||||||
|
//
|
||||||
|
// Generated for file: T:\TRGProd\StarKist\sw\sdk\dan\examples\ExampleC\Rsc\Starter.rsrc
|
||||||
|
//
|
||||||
|
// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE FROM CONSTRUCTOR FOR PALM OS¨;
|
||||||
|
// - DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST
|
||||||
|
//
|
||||||
|
// Palm App Name: "ExampleC"
|
||||||
|
//
|
||||||
|
// Palm App Version: "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1000
|
||||||
|
#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1100
|
||||||
|
#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
|
||||||
|
#define AboutTitleLabel 1102 //(Left Origin = 61, Top Origin = 23, Usable = 1, Font = Large)
|
||||||
|
#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard)
|
||||||
|
#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold)
|
||||||
|
#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: Talt 1001
|
||||||
|
#define RomIncompatibleAlert 1001
|
||||||
|
#define RomIncompatibleOK 0
|
||||||
|
|
||||||
|
// Resource: MBAR 1000
|
||||||
|
#define MainFormMenuBar 1000
|
||||||
|
|
||||||
|
// Resource: MENU 1000
|
||||||
|
#define MainOptionsMenu 1000
|
||||||
|
#define MainOptionsFont 1000
|
||||||
|
#define MainOptionsAboutExampleC 1001
|
||||||
|
|
||||||
|
// Resource: PICT 1200
|
||||||
|
#define GlobeBitmap 1200
|
||||||
|
// Resource: PICT 1100
|
||||||
|
#define SmallIconBitmap 1100
|
||||||
|
// Resource: PICT 1000
|
||||||
|
#define BigIconBitmap 1000
|
||||||
|
// Resource: taif 1001
|
||||||
|
#define SmallIconAppIconFamily 1001
|
||||||
|
|
||||||
|
// Resource: taif 1000
|
||||||
|
#define BigIconAppIconFamily 1000
|
||||||
BIN
handera-105/examples/ExampleD/ExampleD.mcp
Normal file
BIN
handera-105/examples/ExampleD/Rsc/Resource.frk/Starter.rsrc
Normal file
|
After Width: | Height: | Size: 18 KiB |
0
handera-105/examples/ExampleD/Rsc/Starter.rsrc
Normal file
643
handera-105/examples/ExampleD/Src/starter.c
Normal file
@ -0,0 +1,643 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Starter.c
|
||||||
|
*
|
||||||
|
* Project : Example D
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
#include "vga.h"
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Structures
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterPreferenceType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterAppInfoType;
|
||||||
|
|
||||||
|
typedef StarterAppInfoType* StarterAppInfoPtr;
|
||||||
|
|
||||||
|
FontID currentFont = stdFont;
|
||||||
|
Boolean vgaPresent = false;
|
||||||
|
Char helloStr[] = "Hello World";
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define appFileCreator 'Ex_D'
|
||||||
|
#define appVersionNum 0x01
|
||||||
|
#define appPrefID 0x00
|
||||||
|
#define appPrefVersionNum 0x01
|
||||||
|
|
||||||
|
// Define the minimum OS version we support (2.0 for now).
|
||||||
|
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
|
||||||
|
|
||||||
|
#define OptionsRotate 1500
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: RomVersionCompatible
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine checks that a ROM version is meet your
|
||||||
|
* minimum requirement.
|
||||||
|
*
|
||||||
|
* PARAMETERS: requiredVersion - minimum rom version required
|
||||||
|
* (see sysFtrNumROMVersion in SystemMgr.h
|
||||||
|
* for format)
|
||||||
|
* launchFlags - flags that indicate if the application
|
||||||
|
* UI is initialized.
|
||||||
|
*
|
||||||
|
* RETURNED: error code or zero if rom is compatible
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
UInt32 romVersion;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* See if we're on in minimum required version of the ROM or later.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
|
||||||
|
if (romVersion < requiredVersion)
|
||||||
|
{
|
||||||
|
if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
|
||||||
|
(sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
|
||||||
|
{
|
||||||
|
FrmAlert (RomIncompatibleAlert);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Palm OS 1.0 will continuously relaunch this app unless we switch to
|
||||||
|
* another safe one.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (romVersion < ourMinVersion)
|
||||||
|
{
|
||||||
|
AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysErrRomIncompatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: GetObjectPtr
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine returns a pointer to an object in the current
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void * GetObjectPtr(UInt16 objectID)
|
||||||
|
{
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvMoveObject
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine moves an object vertically within a form.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvMoveObject(FormPtr frmP, UInt16 objIndex, Coord y_diff, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r;
|
||||||
|
|
||||||
|
FrmGetObjectBounds(frmP, objIndex, &r);
|
||||||
|
if (draw)
|
||||||
|
{
|
||||||
|
RctInsetRectangle(&r, -2); //need to erase the frame as well
|
||||||
|
WinEraseRectangle(&r, 0);
|
||||||
|
RctInsetRectangle(&r, 2);
|
||||||
|
}
|
||||||
|
r.topLeft.y += y_diff;
|
||||||
|
FrmSetObjectBounds(frmP, objIndex, &r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvCenterObject
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine centers an object within a form.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvCenterObject(FormPtr frmP, UInt16 objIndex, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r, fr;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the frame and bitmap size
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &fr);
|
||||||
|
FrmGetObjectBounds(frmP, objIndex, &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
{
|
||||||
|
RctInsetRectangle(&r, -2); //need to erase the frame as well
|
||||||
|
WinEraseRectangle(&r, 0);
|
||||||
|
RctInsetRectangle(&r, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
r.topLeft.x = (fr.extent.x/2) - (r.extent.x/2);
|
||||||
|
r.topLeft.y = (fr.extent.y/2) - (r.extent.y/2);
|
||||||
|
|
||||||
|
FrmSetObjectBounds(frmP, objIndex, &r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvSetHelloFont
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Sets the font and centers the field horizontally
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvCenterTextField(FormPtr frmP, FieldPtr fldP, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r, fr;
|
||||||
|
Int16 stringWidth;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* First get the width of the field string in pixels.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FntSetFont(FldGetFont(fldP));
|
||||||
|
stringWidth = FntCharsWidth(helloStr, StrLen(helloStr));
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Now center the field based on width of string in pixels.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &fr);
|
||||||
|
FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainHelloField), &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FldEraseField(fldP);
|
||||||
|
|
||||||
|
r.topLeft.x = (fr.extent.x/2) - (stringWidth/2);
|
||||||
|
FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainHelloField), &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FldDrawField(fldP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormResize
|
||||||
|
*
|
||||||
|
* DESCRIPTION:
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED:
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormResize(FormPtr frmP, Boolean draw)
|
||||||
|
{
|
||||||
|
Coord x, y, y_diff;
|
||||||
|
RectangleType r;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the new extent
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
WinGetDisplayExtent(&x, &y);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the old extent
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &r);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Calculate change in form size.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
y_diff = y - (r.topLeft.y + r.extent.y);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Resize the form
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
r.extent.y = y;
|
||||||
|
r.extent.x = x;
|
||||||
|
WinSetWindowBounds(FrmGetWindowHandle(frmP), &r);
|
||||||
|
|
||||||
|
PrvCenterObject (frmP, FrmGetObjectIndex(frmP, MainGlobeBitMap), draw);
|
||||||
|
PrvCenterTextField(frmP, (FieldPtr)GetObjectPtr(MainHelloField), false);;
|
||||||
|
PrvMoveObject (frmP, FrmGetObjectIndex(frmP, MainHelloField), y_diff, draw);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FrmDrawForm(frmP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormInit
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine initializes the MainForm form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: frm - pointer to the MainForm form.
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormInit(FormPtr frmP)
|
||||||
|
{
|
||||||
|
FieldPtr fldP;
|
||||||
|
Char *tmp;
|
||||||
|
|
||||||
|
currentFont = stdFont;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Initialize the field to "Hello World" and set its font
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
fldP = (FieldPtr)GetObjectPtr(MainHelloField);
|
||||||
|
if ((tmp = FldGetTextPtr(fldP)) != NULL)
|
||||||
|
MemPtrFree(tmp);
|
||||||
|
tmp = (Char *)MemPtrNew(StrLen(helloStr) + 1);
|
||||||
|
StrCopy(tmp, helloStr);
|
||||||
|
FldSetTextPtr(fldP, tmp);
|
||||||
|
FldSetFont((FieldPtr)GetObjectPtr(MainHelloField), currentFont);
|
||||||
|
|
||||||
|
if (vgaPresent)
|
||||||
|
VgaFormModify(frmP, vgaFormModify160To240);
|
||||||
|
|
||||||
|
MainFormResize(frmP, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormDoCommand
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine performs the menu command specified.
|
||||||
|
*
|
||||||
|
* PARAMETERS: command - menu item id
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormDoCommand(UInt16 command)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
UInt16 formID;
|
||||||
|
FormPtr frmP, aboutFrmP;
|
||||||
|
VgaScreenModeType screenMode;
|
||||||
|
VgaRotateModeType rotateMode;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
formID = FrmGetFormId (frmP);
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case OptionsAboutExampleD:
|
||||||
|
MenuEraseStatus(0);
|
||||||
|
if (vgaPresent)
|
||||||
|
{
|
||||||
|
VgaGetScreenMode(&screenMode, &rotateMode);
|
||||||
|
VgaSetScreenMode(screenModeScaleToFit, rotateMode);
|
||||||
|
}
|
||||||
|
aboutFrmP = FrmInitForm (AboutForm);
|
||||||
|
FrmDoDialog (aboutFrmP); // Display the About Box.
|
||||||
|
FrmDeleteForm (aboutFrmP);
|
||||||
|
if (vgaPresent)
|
||||||
|
VgaSetScreenMode(screenMode, rotateMode);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OptionsFont :
|
||||||
|
currentFont = FontSelect(currentFont);
|
||||||
|
FldSetFont((FieldPtr)GetObjectPtr(MainHelloField), currentFont);
|
||||||
|
PrvCenterTextField(frmP, (FieldPtr)GetObjectPtr(MainHelloField), true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OptionsRotate :
|
||||||
|
VgaGetScreenMode(&screenMode, &rotateMode);
|
||||||
|
VgaSetScreenMode(screenMode1To1, VgaRotateSelect(rotateMode));
|
||||||
|
MainFormResize(FrmGetActiveForm(), true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event handler for the
|
||||||
|
* "MainForm" of this application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: eventP - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (eventP->eType)
|
||||||
|
{
|
||||||
|
case menuEvent:
|
||||||
|
return MainFormDoCommand(eventP->data.menu.itemID);
|
||||||
|
|
||||||
|
case frmOpenEvent:
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
MainFormInit(frmP);
|
||||||
|
FrmDrawForm (frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case menuOpenEvent :
|
||||||
|
if (vgaPresent)
|
||||||
|
MenuAddItem(OptionsFont, OptionsRotate, 0, "Rotate...");
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine loads form resources and set the event
|
||||||
|
* handler for the form loaded.
|
||||||
|
*
|
||||||
|
* PARAMETERS: event - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean AppHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
UInt16 formId;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
if (eventP->eType == frmLoadEvent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Load the form resource.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
formId = eventP->data.frmLoad.formID;
|
||||||
|
|
||||||
|
frmP = FrmInitForm(formId);
|
||||||
|
FrmSetActiveForm(frmP);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* 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(frmP, MainFormHandleEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrFatalDisplay("Invalid Form Load Event");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppEventLoop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event loop for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppEventLoop(void)
|
||||||
|
{
|
||||||
|
UInt16 error;
|
||||||
|
EventType event;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
EvtGetEvent(&event, evtWaitForever);
|
||||||
|
|
||||||
|
if (! SysHandleEvent(&event))
|
||||||
|
if (! MenuHandleEvent(0, &event, &error))
|
||||||
|
if (! AppHandleEvent(&event))
|
||||||
|
FrmDispatchEvent(&event);
|
||||||
|
|
||||||
|
} while (event.eType != appStopEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStart
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Get the current application's preferences.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: Err value 0 if nothing went wrong
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err AppStart(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
UInt16 prefsSize;
|
||||||
|
UInt32 version;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Read the saved preferences / saved-state information.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
prefsSize = sizeof(StarterPreferenceType);
|
||||||
|
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
|
||||||
|
noPreferenceFound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Check for VGA Extension
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (_TRGVGAFeaturePresent(&version))
|
||||||
|
vgaPresent = true;
|
||||||
|
else
|
||||||
|
vgaPresent = false;
|
||||||
|
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Save the current state of the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppStop(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Write the saved preferences / saved-state information. This data
|
||||||
|
* will be backed up during a HotSync.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
|
||||||
|
&prefs, sizeof (prefs), true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Close all the open forms.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmCloseAllForms ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: StarterPalmMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
*
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
Err error;
|
||||||
|
VgaScreenModeType screenMode;
|
||||||
|
VgaRotateModeType rotateMode;
|
||||||
|
|
||||||
|
if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case sysAppLaunchCmdNormalLaunch:
|
||||||
|
if ((error = AppStart()) != errNone)
|
||||||
|
return(error);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* You must set the screen mode before the form is loaded.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (vgaPresent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Call VgaGetScreenMode() to get the current rotation. We force the mode
|
||||||
|
* to 1to1 but want to keep the rotation.
|
||||||
|
*
|
||||||
|
* Note: If your app does not support screen rotation, simply call
|
||||||
|
*
|
||||||
|
* VgaSetScreenMode(screenMode1To1, rotateModeNone);
|
||||||
|
*
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
VgaGetScreenMode(&screenMode, &rotateMode);
|
||||||
|
VgaSetScreenMode(screenMode1To1, rotateMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
FrmGotoForm(MainForm);
|
||||||
|
AppEventLoop();
|
||||||
|
AppStop();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PilotMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
return StarterPalmMain(cmd, cmdPBP, launchFlags);
|
||||||
|
}
|
||||||
68
handera-105/examples/ExampleD/StarterRsc.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// Header generated by Constructor for Palm OS¨ 1.6
|
||||||
|
//
|
||||||
|
// Generated at 10:08:10 AM on Thursday, May 03, 2001
|
||||||
|
//
|
||||||
|
// Generated for file: T:\TRGProd\StarKist\sw\sdk\cw\examples\ExampleD\Rsc\Starter.rsrc
|
||||||
|
//
|
||||||
|
// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE FROM CONSTRUCTOR FOR PALM OS¨;
|
||||||
|
// - DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST
|
||||||
|
//
|
||||||
|
// Palm App Name: "ExampleD"
|
||||||
|
//
|
||||||
|
// Palm App Version: "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1000
|
||||||
|
#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0)
|
||||||
|
#define MainGlobeBitMap 1200 //(Left Origin = 46, Top Origin = 43, Bitmap Resource ID = 1200, Usable = 1)
|
||||||
|
#define MainHelloField 1002 //(Left Origin = 40, Top Origin = 145, Width = 80, Height = 12, Usable = 1, Editable = 0, Underline = 0, Single Line = 1, Dynamic Size = 0, Left Justified = 1, Max Characters = 80, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1100
|
||||||
|
#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
|
||||||
|
#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold)
|
||||||
|
#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
#define AboutText1Label 1103 //(Left Origin = 20, Top Origin = 54, Usable = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: Talt 1001
|
||||||
|
#define RomIncompatibleAlert 1001
|
||||||
|
#define RomIncompatibleOK 0
|
||||||
|
|
||||||
|
// Resource: MBAR 1000
|
||||||
|
#define MainMenuBar 1000
|
||||||
|
|
||||||
|
// Resource: MENU 1000
|
||||||
|
#define OptionsMenu 1000
|
||||||
|
#define OptionsFont 1000
|
||||||
|
#define OptionsAboutExampleD 1001
|
||||||
|
|
||||||
|
// Resource: PICT 1200
|
||||||
|
#define GlobeBitmap 1200
|
||||||
|
// Resource: PICT 1100
|
||||||
|
#define SmallIconBitmap 1100
|
||||||
|
// Resource: PICT 1000
|
||||||
|
#define BigIconBitmap 1000
|
||||||
|
// Resource: PICT 5296
|
||||||
|
#define VGAGlobeBitmap 5296
|
||||||
|
// Resource: PICT 1400
|
||||||
|
#define VGABigIconBitmap 1400
|
||||||
|
// Resource: PICT 1500
|
||||||
|
#define VGASmallIconBitmap 1500
|
||||||
|
// Resource: PICT 1600
|
||||||
|
#define VGABigIconInvertedBitmap 1600
|
||||||
|
// Resource: taif 2001
|
||||||
|
#define VGASmallIconAppIconFamily 2001
|
||||||
|
|
||||||
|
// Resource: taif 2000
|
||||||
|
#define VGABigIconAppIconFamily 2000
|
||||||
|
|
||||||
|
// Resource: taif 1001
|
||||||
|
#define SmallIconAppIconFamily 1001
|
||||||
|
|
||||||
|
// Resource: taif 1000
|
||||||
|
#define BigIconAppIconFamily 1000
|
||||||
|
|
||||||
|
// Resource: taif 2002
|
||||||
|
#define VGABigIconInvertedAppIconFamily 2002
|
||||||
BIN
handera-105/examples/ExampleE/ExampleE.mcp
Normal file
29
handera-105/examples/ExampleE/Rsc/HandEra.r
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999-2001, TRG, All Rights Reserved
|
||||||
|
*
|
||||||
|
* PROJECT: HandEra 330
|
||||||
|
*
|
||||||
|
* FILE: HandEra.r
|
||||||
|
*
|
||||||
|
* DESCRIPTION:
|
||||||
|
*
|
||||||
|
* AUTHOR: John Ehm
|
||||||
|
*
|
||||||
|
* DATE: 01/17/01
|
||||||
|
*
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
type 'sKst' {
|
||||||
|
//Currently no data is stored in resource, need dummy otherwise
|
||||||
|
//resource is not linked in
|
||||||
|
unsigned longint;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
resource 'sKst' (1000, "HandEra Aware")
|
||||||
|
{
|
||||||
|
0x00000000;
|
||||||
|
|
||||||
|
};
|
||||||
BIN
handera-105/examples/ExampleE/Rsc/Resource.frk/Starter.rsrc
Normal file
|
After Width: | Height: | Size: 18 KiB |
0
handera-105/examples/ExampleE/Rsc/Starter.rsrc
Normal file
648
handera-105/examples/ExampleE/Src/starter.c
Normal file
@ -0,0 +1,648 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Starter.c
|
||||||
|
*
|
||||||
|
* Project : Example E
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
#include "vga.h"
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Structures
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterPreferenceType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterAppInfoType;
|
||||||
|
|
||||||
|
typedef StarterAppInfoType* StarterAppInfoPtr;
|
||||||
|
|
||||||
|
FontID currentFont = stdFont;
|
||||||
|
Boolean vgaPresent = false;
|
||||||
|
Char helloStr[] = "Hello World";
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define appFileCreator 'Ex_E'
|
||||||
|
#define appVersionNum 0x01
|
||||||
|
#define appPrefID 0x00
|
||||||
|
#define appPrefVersionNum 0x01
|
||||||
|
|
||||||
|
// Define the minimum OS version we support (2.0 for now).
|
||||||
|
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
|
||||||
|
|
||||||
|
#define OptionsRotate 1500
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: RomVersionCompatible
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine checks that a ROM version is meet your
|
||||||
|
* minimum requirement.
|
||||||
|
*
|
||||||
|
* PARAMETERS: requiredVersion - minimum rom version required
|
||||||
|
* (see sysFtrNumROMVersion in SystemMgr.h
|
||||||
|
* for format)
|
||||||
|
* launchFlags - flags that indicate if the application
|
||||||
|
* UI is initialized.
|
||||||
|
*
|
||||||
|
* RETURNED: error code or zero if rom is compatible
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
UInt32 romVersion;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* See if we're on in minimum required version of the ROM or later.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
|
||||||
|
if (romVersion < requiredVersion)
|
||||||
|
{
|
||||||
|
if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
|
||||||
|
(sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
|
||||||
|
{
|
||||||
|
FrmAlert (RomIncompatibleAlert);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Palm OS 1.0 will continuously relaunch this app unless we switch to
|
||||||
|
* another safe one.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (romVersion < ourMinVersion)
|
||||||
|
{
|
||||||
|
AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysErrRomIncompatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: GetObjectPtr
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine returns a pointer to an object in the current
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void * GetObjectPtr(UInt16 objectID)
|
||||||
|
{
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvMoveObject
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine moves an object vertically within a form.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvMoveObject(FormPtr frmP, UInt16 objIndex, Coord y_diff, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r;
|
||||||
|
|
||||||
|
FrmGetObjectBounds(frmP, objIndex, &r);
|
||||||
|
if (draw)
|
||||||
|
{
|
||||||
|
RctInsetRectangle(&r, -2); //need to erase the frame as well
|
||||||
|
WinEraseRectangle(&r, 0);
|
||||||
|
RctInsetRectangle(&r, 2);
|
||||||
|
}
|
||||||
|
r.topLeft.y += y_diff;
|
||||||
|
FrmSetObjectBounds(frmP, objIndex, &r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvCenterObject
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine centers an object within a form.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvCenterObject(FormPtr frmP, UInt16 objIndex, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r, fr;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the frame and bitmap size
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &fr);
|
||||||
|
FrmGetObjectBounds(frmP, objIndex, &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
{
|
||||||
|
RctInsetRectangle(&r, -2); //need to erase the frame as well
|
||||||
|
WinEraseRectangle(&r, 0);
|
||||||
|
RctInsetRectangle(&r, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
r.topLeft.x = (fr.extent.x/2) - (r.extent.x/2);
|
||||||
|
r.topLeft.y = (fr.extent.y/2) - (r.extent.y/2);
|
||||||
|
|
||||||
|
FrmSetObjectBounds(frmP, objIndex, &r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvSetHelloFont
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Sets the font and centers the field horizontally
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvCenterTextField(FormPtr frmP, FieldPtr fldP, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r, fr;
|
||||||
|
Int16 stringWidth;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* First get the width of the field string in pixels.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FntSetFont(FldGetFont(fldP));
|
||||||
|
stringWidth = FntCharsWidth(helloStr, StrLen(helloStr));
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Now center the field based on width of string in pixels.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &fr);
|
||||||
|
FrmGetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainHelloField), &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FldEraseField(fldP);
|
||||||
|
|
||||||
|
r.topLeft.x = (fr.extent.x/2) - (stringWidth/2);
|
||||||
|
FrmSetObjectBounds(frmP, FrmGetObjectIndex(frmP, MainHelloField), &r);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FldDrawField(fldP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormResize
|
||||||
|
*
|
||||||
|
* DESCRIPTION:
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED:
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormResize(FormPtr frmP, Boolean draw)
|
||||||
|
{
|
||||||
|
Coord x, y, y_diff;
|
||||||
|
RectangleType r;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the new extent
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
WinGetDisplayExtent(&x, &y);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the old extent
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &r);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Calculate change in form size.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
y_diff = y - (r.topLeft.y + r.extent.y);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Resize the form
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
r.extent.y = y;
|
||||||
|
r.extent.x = x;
|
||||||
|
WinSetWindowBounds(FrmGetWindowHandle(frmP), &r);
|
||||||
|
|
||||||
|
PrvCenterObject (frmP, FrmGetObjectIndex(frmP, MainGlobeBitMap), draw);
|
||||||
|
PrvCenterTextField(frmP, (FieldPtr)GetObjectPtr(MainHelloField), false);;
|
||||||
|
PrvMoveObject (frmP, FrmGetObjectIndex(frmP, MainHelloField), y_diff, draw);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
FrmDrawForm(frmP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormInit
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine initializes the MainForm form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: frm - pointer to the MainForm form.
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormInit(FormPtr frmP)
|
||||||
|
{
|
||||||
|
FieldPtr fldP;
|
||||||
|
Char *tmp;
|
||||||
|
|
||||||
|
currentFont = stdFont;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Initialize the field to "Hello World" and set its font
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
fldP = (FieldPtr)GetObjectPtr(MainHelloField);
|
||||||
|
if ((tmp = FldGetTextPtr(fldP)) != NULL)
|
||||||
|
MemPtrFree(tmp);
|
||||||
|
tmp = (Char *)MemPtrNew(StrLen(helloStr) + 1);
|
||||||
|
StrCopy(tmp, helloStr);
|
||||||
|
FldSetTextPtr(fldP, tmp);
|
||||||
|
FldSetFont((FieldPtr)GetObjectPtr(MainHelloField), currentFont);
|
||||||
|
|
||||||
|
if (vgaPresent)
|
||||||
|
VgaFormModify(frmP, vgaFormModify160To240);
|
||||||
|
|
||||||
|
MainFormResize(frmP, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormDoCommand
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine performs the menu command specified.
|
||||||
|
*
|
||||||
|
* PARAMETERS: command - menu item id
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormDoCommand(UInt16 command)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
UInt16 formID;
|
||||||
|
FormPtr frmP, aboutFrmP;
|
||||||
|
VgaScreenModeType screenMode;
|
||||||
|
VgaRotateModeType rotateMode;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
formID = FrmGetFormId (frmP);
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case OptionsAboutExampleD:
|
||||||
|
MenuEraseStatus(0);
|
||||||
|
if (vgaPresent)
|
||||||
|
{
|
||||||
|
VgaGetScreenMode(&screenMode, &rotateMode);
|
||||||
|
VgaSetScreenMode(screenModeScaleToFit, rotateMode);
|
||||||
|
}
|
||||||
|
aboutFrmP = FrmInitForm (AboutForm);
|
||||||
|
FrmDoDialog (aboutFrmP); // Display the About Box.
|
||||||
|
FrmDeleteForm (aboutFrmP);
|
||||||
|
if (vgaPresent)
|
||||||
|
VgaSetScreenMode(screenMode, rotateMode);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OptionsFont :
|
||||||
|
currentFont = FontSelect(currentFont);
|
||||||
|
FldSetFont((FieldPtr)GetObjectPtr(MainHelloField), currentFont);
|
||||||
|
PrvCenterTextField(frmP, (FieldPtr)GetObjectPtr(MainHelloField), true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OptionsRotate :
|
||||||
|
VgaGetScreenMode(&screenMode, &rotateMode);
|
||||||
|
VgaSetScreenMode(screenMode1To1, VgaRotateSelect(rotateMode));
|
||||||
|
MainFormResize(FrmGetActiveForm(), true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event handler for the
|
||||||
|
* "MainForm" of this application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: eventP - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (eventP->eType)
|
||||||
|
{
|
||||||
|
case menuEvent:
|
||||||
|
return MainFormDoCommand(eventP->data.menu.itemID);
|
||||||
|
|
||||||
|
case frmOpenEvent:
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
MainFormInit(frmP);
|
||||||
|
FrmDrawForm (frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case displayExtentChangedEvent :
|
||||||
|
MainFormResize(FrmGetActiveForm(), true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case menuOpenEvent :
|
||||||
|
if (vgaPresent)
|
||||||
|
MenuAddItem(OptionsFont, OptionsRotate, 0, "Rotate...");
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine loads form resources and set the event
|
||||||
|
* handler for the form loaded.
|
||||||
|
*
|
||||||
|
* PARAMETERS: event - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean AppHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
UInt16 formId;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
if (eventP->eType == frmLoadEvent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Load the form resource.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
formId = eventP->data.frmLoad.formID;
|
||||||
|
|
||||||
|
frmP = FrmInitForm(formId);
|
||||||
|
FrmSetActiveForm(frmP);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* 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(frmP, MainFormHandleEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrFatalDisplay("Invalid Form Load Event");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppEventLoop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event loop for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppEventLoop(void)
|
||||||
|
{
|
||||||
|
UInt16 error;
|
||||||
|
EventType event;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
EvtGetEvent(&event, evtWaitForever);
|
||||||
|
|
||||||
|
if (! SysHandleEvent(&event))
|
||||||
|
if (! MenuHandleEvent(0, &event, &error))
|
||||||
|
if (! AppHandleEvent(&event))
|
||||||
|
FrmDispatchEvent(&event);
|
||||||
|
|
||||||
|
} while (event.eType != appStopEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStart
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Get the current application's preferences.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: Err value 0 if nothing went wrong
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err AppStart(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
UInt16 prefsSize;
|
||||||
|
UInt32 version;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Read the saved preferences / saved-state information.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
prefsSize = sizeof(StarterPreferenceType);
|
||||||
|
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
|
||||||
|
noPreferenceFound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Check for VGA Extension
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (_TRGVGAFeaturePresent(&version))
|
||||||
|
vgaPresent = true;
|
||||||
|
else
|
||||||
|
vgaPresent = false;
|
||||||
|
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Save the current state of the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppStop(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Write the saved preferences / saved-state information. This data
|
||||||
|
* will be backed up during a HotSync.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
|
||||||
|
&prefs, sizeof (prefs), true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Close all the open forms.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmCloseAllForms ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: StarterPalmMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
*
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
Err error;
|
||||||
|
VgaScreenModeType screenMode;
|
||||||
|
VgaRotateModeType rotateMode;
|
||||||
|
|
||||||
|
if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case sysAppLaunchCmdNormalLaunch:
|
||||||
|
if ((error = AppStart()) != errNone)
|
||||||
|
return(error);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* You must set the screen mode before the form is loaded.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (vgaPresent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Call VgaGetScreenMode() to get the current rotation. We force the mode
|
||||||
|
* to 1to1 but want to keep the rotation.
|
||||||
|
*
|
||||||
|
* Note: If your app does not support screen rotation, simply call
|
||||||
|
*
|
||||||
|
* VgaSetScreenMode(screenMode1To1, rotateModeNone);
|
||||||
|
*
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
VgaGetScreenMode(&screenMode, &rotateMode);
|
||||||
|
VgaSetScreenMode(screenMode1To1, rotateMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
FrmGotoForm(MainForm);
|
||||||
|
AppEventLoop();
|
||||||
|
AppStop();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PilotMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
return StarterPalmMain(cmd, cmdPBP, launchFlags);
|
||||||
|
}
|
||||||
68
handera-105/examples/ExampleE/StarterRsc.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// Header generated by Constructor for Palm OS¨ 1.6
|
||||||
|
//
|
||||||
|
// Generated at 10:11:42 AM on Thursday, May 03, 2001
|
||||||
|
//
|
||||||
|
// Generated for file: T:\TRGProd\StarKist\sw\sdk\cw\examples\ExampleE\Rsc\Starter.rsrc
|
||||||
|
//
|
||||||
|
// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE FROM CONSTRUCTOR FOR PALM OS¨;
|
||||||
|
// - DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST
|
||||||
|
//
|
||||||
|
// Palm App Name: "ExampleE"
|
||||||
|
//
|
||||||
|
// Palm App Version: "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1000
|
||||||
|
#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0)
|
||||||
|
#define MainGlobeBitMap 1200 //(Left Origin = 46, Top Origin = 43, Bitmap Resource ID = 1200, Usable = 1)
|
||||||
|
#define MainHelloField 1002 //(Left Origin = 40, Top Origin = 145, Width = 80, Height = 12, Usable = 1, Editable = 0, Underline = 0, Single Line = 1, Dynamic Size = 0, Left Justified = 1, Max Characters = 80, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1100
|
||||||
|
#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
|
||||||
|
#define AboutText1Label 1103 //(Left Origin = 20, Top Origin = 54, Usable = 1, Font = Standard)
|
||||||
|
#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold)
|
||||||
|
#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: Talt 1001
|
||||||
|
#define RomIncompatibleAlert 1001
|
||||||
|
#define RomIncompatibleOK 0
|
||||||
|
|
||||||
|
// Resource: MBAR 1000
|
||||||
|
#define MainMenuBar 1000
|
||||||
|
|
||||||
|
// Resource: MENU 1000
|
||||||
|
#define OptionsMenu 1000
|
||||||
|
#define OptionsFont 1000
|
||||||
|
#define OptionsAboutExampleD 1001
|
||||||
|
|
||||||
|
// Resource: PICT 1200
|
||||||
|
#define GlobeBitmap 1200
|
||||||
|
// Resource: PICT 1100
|
||||||
|
#define SmallIconBitmap 1100
|
||||||
|
// Resource: PICT 1000
|
||||||
|
#define BigIconBitmap 1000
|
||||||
|
// Resource: PICT 5296
|
||||||
|
#define VGAGlobeBitmap 5296
|
||||||
|
// Resource: PICT 1400
|
||||||
|
#define VGABigIconBitmap 1400
|
||||||
|
// Resource: PICT 1500
|
||||||
|
#define VGASmallIconBitmap 1500
|
||||||
|
// Resource: PICT 1600
|
||||||
|
#define VGABigIconInvertedBitmap 1600
|
||||||
|
// Resource: taif 2001
|
||||||
|
#define VGASmallIconAppIconFamily 2001
|
||||||
|
|
||||||
|
// Resource: taif 2000
|
||||||
|
#define VGABigIconAppIconFamily 2000
|
||||||
|
|
||||||
|
// Resource: taif 1001
|
||||||
|
#define SmallIconAppIconFamily 1001
|
||||||
|
|
||||||
|
// Resource: taif 1000
|
||||||
|
#define BigIconAppIconFamily 1000
|
||||||
|
|
||||||
|
// Resource: taif 2002
|
||||||
|
#define VGABigIconInvertedAppIconFamily 2002
|
||||||
BIN
handera-105/examples/ExampleF/ExampleF.mcp
Normal file
29
handera-105/examples/ExampleF/Rsc/HandEra.r
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999-2001, TRG, All Rights Reserved
|
||||||
|
*
|
||||||
|
* PROJECT: HandEra 330
|
||||||
|
*
|
||||||
|
* FILE: HandEra.r
|
||||||
|
*
|
||||||
|
* DESCRIPTION:
|
||||||
|
*
|
||||||
|
* AUTHOR: John Ehm
|
||||||
|
*
|
||||||
|
* DATE: 01/17/01
|
||||||
|
*
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
type 'sKst' {
|
||||||
|
//Currently no data is stored in resource, need dummy otherwise
|
||||||
|
//resource is not linked in
|
||||||
|
unsigned longint;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
resource 'sKst' (1000, "HandEra Aware")
|
||||||
|
{
|
||||||
|
0x00000000;
|
||||||
|
|
||||||
|
};
|
||||||
BIN
handera-105/examples/ExampleF/Rsc/Resource.frk/Starter.rsrc
Normal file
|
After Width: | Height: | Size: 15 KiB |
0
handera-105/examples/ExampleF/Rsc/Starter.rsrc
Normal file
527
handera-105/examples/ExampleF/Src/starter.c
Normal file
@ -0,0 +1,527 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Starter.c
|
||||||
|
*
|
||||||
|
* Project : ExampleF
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
#include "Silk.h"
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Entry Points
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Structures
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterPreferenceType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterAppInfoType;
|
||||||
|
|
||||||
|
typedef StarterAppInfoType* StarterAppInfoPtr;
|
||||||
|
|
||||||
|
Boolean silkExtensionPresent;
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define appFileCreator 'Ex_F'
|
||||||
|
#define appVersionNum 0x01
|
||||||
|
#define appPrefID 0x00
|
||||||
|
#define appPrefVersionNum 0x01
|
||||||
|
|
||||||
|
// Define the minimum OS version we support (2.0 for now).
|
||||||
|
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err DrawHelloWorld(void);
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: RomVersionCompatible
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine checks that a ROM version is meet your
|
||||||
|
* minimum requirement.
|
||||||
|
*
|
||||||
|
* PARAMETERS: requiredVersion - minimum rom version required
|
||||||
|
* (see sysFtrNumROMVersion in SystemMgr.h
|
||||||
|
* for format)
|
||||||
|
* launchFlags - flags that indicate if the application
|
||||||
|
* UI is initialized.
|
||||||
|
*
|
||||||
|
* RETURNED: error code or zero if rom is compatible
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
UInt32 romVersion;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* See if we're on in minimum required version of the ROM or later.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
|
||||||
|
if (romVersion < requiredVersion)
|
||||||
|
{
|
||||||
|
if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
|
||||||
|
(sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
|
||||||
|
{
|
||||||
|
FrmAlert (RomIncompatibleAlert);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Palm OS 1.0 will continuously relaunch this app unless we switch to
|
||||||
|
* another safe one.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (romVersion < ourMinVersion)
|
||||||
|
{
|
||||||
|
AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysErrRomIncompatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: GetObjectPtr
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine returns a pointer to an object in the current
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void * GetObjectPtr(UInt16 objectID)
|
||||||
|
{
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: DrawHelloWorld
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine prints "Hello World" to the center of the
|
||||||
|
* window.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err DrawHelloWorld(void)
|
||||||
|
{
|
||||||
|
WinHandle silkWindow, savedWindow;
|
||||||
|
MemHandle resH;
|
||||||
|
BitmapPtr resP;
|
||||||
|
Coord x, y, winWidth, winHeight;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the WinHandle to the silkscreen window
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if ((silkWindow = SilkGetWindow()) == NULL)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
savedWindow = WinSetDrawWindow(silkWindow);
|
||||||
|
|
||||||
|
if (SilkWindowMaximized())
|
||||||
|
{
|
||||||
|
resH = DmGetResource(bitmapRsc, GlobeBitmap);
|
||||||
|
ErrFatalDisplayIf(!resH, "Missing bitmap");
|
||||||
|
resP = MemHandleLock(resH);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Determine the size of the silkscreen area so we can center the globe.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
WinGetWindowExtent(&winWidth, &winHeight);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Draw the globe graphic
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
x = (winWidth/2) - (resP->width/2);
|
||||||
|
x -= 20; //OK, fudge a little so we don't erase the down arrow.
|
||||||
|
y = (winHeight/2) - (resP->height/2);
|
||||||
|
WinPaintBitmap(resP, x, y);
|
||||||
|
|
||||||
|
MemPtrUnlock(resP);
|
||||||
|
DmReleaseResource(resH);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FntSetFont(stdFont);
|
||||||
|
WinDrawChars("Hello World", 11, 50, 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
WinSetDrawWindow(savedWindow);
|
||||||
|
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormInit
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine initializes the MainForm form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: frm - pointer to the MainForm form.
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormInit(FormPtr /*frmP*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormDoCommand
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine performs the menu command specified.
|
||||||
|
*
|
||||||
|
* PARAMETERS: command - menu item id
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormDoCommand(UInt16 command)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case MainOptionsAboutExampleF:
|
||||||
|
MenuEraseStatus(0); // Clear the menu status from the display.
|
||||||
|
frmP = FrmInitForm (AboutForm);
|
||||||
|
FrmDoDialog (frmP); // Display the About Box.
|
||||||
|
FrmDeleteForm (frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event handler for the
|
||||||
|
* "MainForm" of this application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: eventP - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (eventP->eType)
|
||||||
|
{
|
||||||
|
case menuEvent:
|
||||||
|
return MainFormDoCommand(eventP->data.menu.itemID);
|
||||||
|
|
||||||
|
case ctlSelectEvent :
|
||||||
|
switch(eventP->data.ctlSelect.controlID)
|
||||||
|
{
|
||||||
|
case MainHelloWorldButton :
|
||||||
|
if (!silkExtensionPresent)
|
||||||
|
FrmAlert(SilkExtNotFoundAlert);
|
||||||
|
else
|
||||||
|
if (DrawHelloWorld() != errNone)
|
||||||
|
FrmAlert(SilkDrawErrorAlert);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case frmOpenEvent:
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
MainFormInit( frmP);
|
||||||
|
FrmDrawForm ( frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine loads form resources and set the event
|
||||||
|
* handler for the form loaded.
|
||||||
|
*
|
||||||
|
* PARAMETERS: event - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean AppHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
UInt16 formId;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
if (eventP->eType == frmLoadEvent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Load the form resource.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
formId = eventP->data.frmLoad.formID;
|
||||||
|
frmP = FrmInitForm(formId);
|
||||||
|
FrmSetActiveForm(frmP);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* 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(frmP, MainFormHandleEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrFatalDisplay("Invalid Form Load Event");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppEventLoop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event loop for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppEventLoop(void)
|
||||||
|
{
|
||||||
|
UInt16 error;
|
||||||
|
EventType event;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
EvtGetEvent(&event, evtWaitForever);
|
||||||
|
|
||||||
|
if (! SysHandleEvent(&event))
|
||||||
|
if (! MenuHandleEvent(0, &event, &error))
|
||||||
|
if (! AppHandleEvent(&event))
|
||||||
|
FrmDispatchEvent(&event);
|
||||||
|
|
||||||
|
} while (event.eType != appStopEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStart
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Get the current application's preferences.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: Err value 0 if nothing went wrong
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err AppStart(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
UInt16 prefsSize;
|
||||||
|
UInt32 version;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Read the saved preferences / saved-state information.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
prefsSize = sizeof(StarterPreferenceType);
|
||||||
|
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
|
||||||
|
noPreferenceFound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_TRGSilkFeaturePresent(&version))
|
||||||
|
silkExtensionPresent = true;
|
||||||
|
else
|
||||||
|
silkExtensionPresent = false;
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Save the current state of the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppStop(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Write the saved preferences / saved-state information. This data
|
||||||
|
* will be backed up during a HotSync.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
|
||||||
|
&prefs, sizeof (prefs), true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Close all the open forms.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmCloseAllForms ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: StarterPalmMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
*
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
Err error;
|
||||||
|
|
||||||
|
if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case sysAppLaunchCmdNormalLaunch:
|
||||||
|
error = AppStart();
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
FrmGotoForm(MainForm);
|
||||||
|
AppEventLoop();
|
||||||
|
AppStop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PilotMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
return StarterPalmMain(cmd, cmdPBP, launchFlags);
|
||||||
|
}
|
||||||
|
|
||||||
72
handera-105/examples/ExampleF/StarterRsc.h
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
// Header generated by Constructor for Palm OS¨ 1.6
|
||||||
|
//
|
||||||
|
// Generated at 6:29:08 PM on Friday, March 23, 2001
|
||||||
|
//
|
||||||
|
// Generated for file: T:\TRGProd\StarKist\sw\sdk\cw\examples\ExampleF\Rsc\Starter.rsrc
|
||||||
|
//
|
||||||
|
// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE FROM CONSTRUCTOR FOR PALM OS¨;
|
||||||
|
// - DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST
|
||||||
|
//
|
||||||
|
// Palm App Name: "ExampleF"
|
||||||
|
//
|
||||||
|
// Palm App Version: "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1000
|
||||||
|
#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0)
|
||||||
|
#define MainHelloWorldButton 1001 //(Left Origin = 50, Top Origin = 75, Width = 60, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1100
|
||||||
|
#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
|
||||||
|
#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard)
|
||||||
|
#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold)
|
||||||
|
#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: Talt 1001
|
||||||
|
#define RomIncompatibleAlert 1001
|
||||||
|
#define RomIncompatibleOK 0
|
||||||
|
|
||||||
|
// Resource: Talt 1000
|
||||||
|
#define SilkExtNotFoundAlert 1000
|
||||||
|
#define SilkExtNotFoundOK 0
|
||||||
|
|
||||||
|
// Resource: Talt 1100
|
||||||
|
#define SilkDrawErrorAlert 1100
|
||||||
|
#define SilkDrawErrorOK 0
|
||||||
|
|
||||||
|
// Resource: MBAR 1000
|
||||||
|
#define MainFormMenuBar 1000
|
||||||
|
|
||||||
|
// Resource: MENU 1000
|
||||||
|
#define MainOptionsMenu 1000
|
||||||
|
#define MainOptionsAboutExampleF 1000
|
||||||
|
|
||||||
|
// Resource: PICT 1100
|
||||||
|
#define SmallIconBitmap 1100
|
||||||
|
// Resource: PICT 1000
|
||||||
|
#define BigIconBitmap 1000
|
||||||
|
// Resource: PICT 1400
|
||||||
|
#define VGABigIconBitmap 1400
|
||||||
|
// Resource: PICT 1500
|
||||||
|
#define VGASmallIconBitmap 1500
|
||||||
|
// Resource: PICT 1200
|
||||||
|
#define GlobeBitmap 1200
|
||||||
|
// Resource: PICT 1600
|
||||||
|
#define VGABigIconInvertedBitmap 1600
|
||||||
|
// Resource: taif 2002
|
||||||
|
#define VGABigIconInvertedAppIconFamily 2002
|
||||||
|
|
||||||
|
// Resource: taif 2001
|
||||||
|
#define VGASmallIconAppIconFamily 2001
|
||||||
|
|
||||||
|
// Resource: taif 2000
|
||||||
|
#define VGABigIconAppIconFamily 2000
|
||||||
|
|
||||||
|
// Resource: taif 1001
|
||||||
|
#define SmallIconAppIconFamily 1001
|
||||||
|
|
||||||
|
// Resource: taif 1000
|
||||||
|
#define BigIconAppIconFamily 1000
|
||||||
BIN
handera-105/examples/ExampleG/Bitmaps/silk-1bit.bmp
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
handera-105/examples/ExampleG/Bitmaps/silk-2bit.bmp
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
handera-105/examples/ExampleG/Bitmaps/silk_inv-1bit.bmp
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
handera-105/examples/ExampleG/Bitmaps/silk_inv-2bit.bmp
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
handera-105/examples/ExampleG/ExampleG.mcp
Normal file
BIN
handera-105/examples/ExampleG/Rsc/Resource.frk/Starter.rsrc
Normal file
|
After Width: | Height: | Size: 36 KiB |
0
handera-105/examples/ExampleG/Rsc/Starter.rsrc
Normal file
743
handera-105/examples/ExampleG/Src/starter.c
Normal file
@ -0,0 +1,743 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Starter.c
|
||||||
|
*
|
||||||
|
* Project : ExampleG
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
#include "Silk.h"
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Entry Points
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Structures
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterPreferenceType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterAppInfoType;
|
||||||
|
|
||||||
|
typedef StarterAppInfoType* StarterAppInfoPtr;
|
||||||
|
|
||||||
|
Boolean silkPresent;
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define appFileCreator 'Ex_G'
|
||||||
|
#define appVersionNum 0x01
|
||||||
|
#define appPrefID 0x00
|
||||||
|
#define appPrefVersionNum 0x01
|
||||||
|
|
||||||
|
#define NUM_NEW_BUTTONS 11
|
||||||
|
|
||||||
|
#define KEYPAD_TOPX 141
|
||||||
|
#define KEYPAD_TOPY 21
|
||||||
|
#define BUTTON_WIDTH 14
|
||||||
|
#define BUTTON_HEIGHT 14
|
||||||
|
|
||||||
|
// Define the minimum OS version we support (2.0 for now).
|
||||||
|
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: RomVersionCompatible
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine checks that a ROM version is meet your
|
||||||
|
* minimum requirement.
|
||||||
|
*
|
||||||
|
* PARAMETERS: requiredVersion - minimum rom version required
|
||||||
|
* (see sysFtrNumROMVersion in SystemMgr.h
|
||||||
|
* for format)
|
||||||
|
* launchFlags - flags that indicate if the application
|
||||||
|
* UI is initialized.
|
||||||
|
*
|
||||||
|
* RETURNED: error code or zero if rom is compatible
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
UInt32 romVersion;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* See if we're on in minimum required version of the ROM or later.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
|
||||||
|
if (romVersion < requiredVersion)
|
||||||
|
{
|
||||||
|
if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
|
||||||
|
(sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
|
||||||
|
{
|
||||||
|
FrmAlert (RomIncompatibleAlert);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Palm OS 1.0 will continuously relaunch this app unless we switch to
|
||||||
|
* another safe one.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (romVersion < ourMinVersion)
|
||||||
|
{
|
||||||
|
AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysErrRomIncompatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: GetObjectPtr
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine returns a pointer to an object in the current
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void * GetObjectPtr(UInt16 objectID)
|
||||||
|
{
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: SetNewButtons
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Sets up the numeric keypad structure.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void SetNewButtons(PenBtnListType *buttonList)
|
||||||
|
{
|
||||||
|
UInt16 index, i;
|
||||||
|
|
||||||
|
index = buttonList->numButtons;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Look for the numeric keyboard button. Simply set the width to 0 for this
|
||||||
|
* example. A complete app would competely remove it.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
for (i = 0;i < index; i++)
|
||||||
|
{
|
||||||
|
if (buttonList->buttons[i].asciiCode == vchrKeyboardNumeric)
|
||||||
|
{
|
||||||
|
buttonList->buttons[i].boundsR.extent.x = 1;
|
||||||
|
buttonList->buttons[i].boundsR.extent.y = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '1'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+0].boundsR.topLeft.x = KEYPAD_TOPX ;
|
||||||
|
buttonList->buttons[index+0].boundsR.topLeft.y = KEYPAD_TOPY;
|
||||||
|
buttonList->buttons[index+0].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+0].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+0].asciiCode = '1';
|
||||||
|
buttonList->buttons[index+0].keyCode = 0;
|
||||||
|
buttonList->buttons[index+0].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '2'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+1].boundsR.topLeft.x = KEYPAD_TOPX + BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+1].boundsR.topLeft.y = KEYPAD_TOPY;
|
||||||
|
buttonList->buttons[index+1].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+1].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+1].asciiCode = '2';
|
||||||
|
buttonList->buttons[index+1].keyCode = 0;
|
||||||
|
buttonList->buttons[index+1].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '3'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+2].boundsR.topLeft.x = KEYPAD_TOPX + (BUTTON_WIDTH*2);
|
||||||
|
buttonList->buttons[index+2].boundsR.topLeft.y = KEYPAD_TOPY;
|
||||||
|
buttonList->buttons[index+2].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+2].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+2].asciiCode = '3';
|
||||||
|
buttonList->buttons[index+2].keyCode = 0;
|
||||||
|
buttonList->buttons[index+2].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '4'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+3].boundsR.topLeft.x = KEYPAD_TOPX;
|
||||||
|
buttonList->buttons[index+3].boundsR.topLeft.y = KEYPAD_TOPY + BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+3].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+3].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+3].asciiCode = '4';
|
||||||
|
buttonList->buttons[index+3].keyCode = 0;
|
||||||
|
buttonList->buttons[index+3].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '5'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+4].boundsR.topLeft.x = KEYPAD_TOPX + BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+4].boundsR.topLeft.y = KEYPAD_TOPY + BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+4].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+4].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+4].asciiCode = '5';
|
||||||
|
buttonList->buttons[index+4].keyCode = 0;
|
||||||
|
buttonList->buttons[index+4].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '6'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+5].boundsR.topLeft.x = KEYPAD_TOPX + (BUTTON_WIDTH*2);
|
||||||
|
buttonList->buttons[index+5].boundsR.topLeft.y = KEYPAD_TOPY + BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+5].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+5].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+5].asciiCode = '6';
|
||||||
|
buttonList->buttons[index+5].keyCode = 0;
|
||||||
|
buttonList->buttons[index+5].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '7'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+6].boundsR.topLeft.x = KEYPAD_TOPX;
|
||||||
|
buttonList->buttons[index+6].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*2);
|
||||||
|
buttonList->buttons[index+6].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+6].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+6].asciiCode = '7';
|
||||||
|
buttonList->buttons[index+6].keyCode = 0;
|
||||||
|
buttonList->buttons[index+6].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '8'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+7].boundsR.topLeft.x = KEYPAD_TOPX + BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+7].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*2);
|
||||||
|
buttonList->buttons[index+7].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+7].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+7].asciiCode = '8';
|
||||||
|
buttonList->buttons[index+7].keyCode = 0;
|
||||||
|
buttonList->buttons[index+7].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '9'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+8].boundsR.topLeft.x = KEYPAD_TOPX + (BUTTON_WIDTH*2);
|
||||||
|
buttonList->buttons[index+8].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*2);
|
||||||
|
buttonList->buttons[index+8].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+8].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+8].asciiCode = '9';
|
||||||
|
buttonList->buttons[index+8].keyCode = 0;
|
||||||
|
buttonList->buttons[index+8].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '0'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+9].boundsR.topLeft.x = KEYPAD_TOPX;
|
||||||
|
buttonList->buttons[index+9].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*3);
|
||||||
|
buttonList->buttons[index+9].boundsR.extent.x = BUTTON_WIDTH * 2;
|
||||||
|
buttonList->buttons[index+9].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+9].asciiCode = '0';
|
||||||
|
buttonList->buttons[index+9].keyCode = 0;
|
||||||
|
buttonList->buttons[index+9].modifiers = 0;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* '.'
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
buttonList->buttons[index+10].boundsR.topLeft.x = KEYPAD_TOPX + (BUTTON_WIDTH*2);
|
||||||
|
buttonList->buttons[index+10].boundsR.topLeft.y = KEYPAD_TOPY + (BUTTON_HEIGHT*3);
|
||||||
|
buttonList->buttons[index+10].boundsR.extent.x = BUTTON_WIDTH;
|
||||||
|
buttonList->buttons[index+10].boundsR.extent.y = BUTTON_HEIGHT;
|
||||||
|
buttonList->buttons[index+10].asciiCode = '.';
|
||||||
|
buttonList->buttons[index+10].keyCode = 0;
|
||||||
|
buttonList->buttons[index+10].modifiers = 0;
|
||||||
|
|
||||||
|
buttonList->numButtons += NUM_NEW_BUTTONS;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: SetTemplate
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine changes the template to our template
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void SetTemplate(void)
|
||||||
|
{
|
||||||
|
MemHandle normalH, invertedH;
|
||||||
|
BitmapPtr normal, inverted;
|
||||||
|
RectangleType alpha, numeric;
|
||||||
|
UInt16 numNewButtons;
|
||||||
|
PenBtnListType *currentPtr, *newPtr;
|
||||||
|
UInt16 currentSize, newSize;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* First draw the new silscreen template
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
normalH = DmGetResource(bitmapRsc, NormalSilkBitmapFamily);
|
||||||
|
ErrFatalDisplayIf(!normalH, "Missing normal bitmap");
|
||||||
|
normal = MemHandleLock(normalH);
|
||||||
|
|
||||||
|
invertedH = DmGetResource(bitmapRsc, InvertedSilkBitmapFamily);
|
||||||
|
ErrFatalDisplayIf(!invertedH, "Missing inverted bitmap");
|
||||||
|
inverted = MemHandleLock(invertedH);
|
||||||
|
|
||||||
|
SilkSetTemplateBitmaps(normal, inverted, NULL, NULL);
|
||||||
|
SilkMaximizeWindow();
|
||||||
|
|
||||||
|
MemPtrUnlock(normal);
|
||||||
|
DmReleaseResource(normalH);
|
||||||
|
MemPtrUnlock(inverted);
|
||||||
|
DmReleaseResource(invertedH);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* The numeric graffiti area can not be removed, so make its width 1, which
|
||||||
|
* will effectively remove it.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
SilkGetAreas(&alpha, &numeric);
|
||||||
|
numeric.extent.x = 1;
|
||||||
|
SilkSetAreas(&alpha, &numeric);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* First get the number of silk buttons so we know how much to allocate,
|
||||||
|
* with our additional buttons.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
currentSize = SilkGetButtonListSize(true);
|
||||||
|
|
||||||
|
if ((currentPtr = MemPtrNew(currentSize)) == NULL)
|
||||||
|
{
|
||||||
|
ErrFatalDisplay("Allcoate Errror");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SilkGetButtonList(currentPtr, true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Allocate space for new button list.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
numNewButtons = currentPtr->numButtons + NUM_NEW_BUTTONS;
|
||||||
|
newSize = sizeof(PenBtnListType) + (sizeof(PenBtnInfoType) * (numNewButtons - 1));
|
||||||
|
|
||||||
|
if ((newPtr = MemPtrNew(newSize)) == NULL)
|
||||||
|
{
|
||||||
|
MemPtrFree(currentPtr);
|
||||||
|
ErrFatalDisplay("Allcoate Errror");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MemMove(newPtr, currentPtr, currentSize);
|
||||||
|
|
||||||
|
SetNewButtons(newPtr);
|
||||||
|
SilkSetButtonList(newPtr, true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Since the button list is copied by the system, we can free our copy.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
MemPtrFree(currentPtr);
|
||||||
|
MemPtrFree(newPtr);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: ResetTemplate
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine restores the defaul template, areas and
|
||||||
|
* silk buttons.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void ResetTemplate(void)
|
||||||
|
{
|
||||||
|
SilkRestoreDefaultTemplates();
|
||||||
|
SilkMaximizeWindow();
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormInit
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine initializes the MainForm form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: frm - pointer to the MainForm form.
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormInit(FormPtr /*frmP*/)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormDoCommand
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine performs the menu command specified.
|
||||||
|
*
|
||||||
|
* PARAMETERS: command - menu item id
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormDoCommand(UInt16 command)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case MainOptionsAboutExampleG :
|
||||||
|
MenuEraseStatus(0); // Clear the menu status from the display.
|
||||||
|
frmP = FrmInitForm (AboutForm);
|
||||||
|
FrmDoDialog (frmP); // Display the About Box.
|
||||||
|
FrmDeleteForm (frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event handler for the
|
||||||
|
* "MainForm" of this application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: eventP - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
switch (eventP->eType)
|
||||||
|
{
|
||||||
|
case menuEvent:
|
||||||
|
return MainFormDoCommand(eventP->data.menu.itemID);
|
||||||
|
|
||||||
|
case ctlSelectEvent :
|
||||||
|
switch(eventP->data.ctlSelect.controlID)
|
||||||
|
{
|
||||||
|
case MainSetTemplateButton :
|
||||||
|
if (!silkPresent)
|
||||||
|
FrmAlert(SilkExtNotFoundAlert);
|
||||||
|
else
|
||||||
|
SetTemplate();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainResetTemplateButton :
|
||||||
|
if (!silkPresent)
|
||||||
|
FrmAlert(SilkExtNotFoundAlert);
|
||||||
|
else
|
||||||
|
ResetTemplate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case frmOpenEvent:
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
MainFormInit( frmP);
|
||||||
|
FrmDrawForm ( frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine loads form resources and set the event
|
||||||
|
* handler for the form loaded.
|
||||||
|
*
|
||||||
|
* PARAMETERS: event - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean AppHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
UInt16 formId;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
if (eventP->eType == frmLoadEvent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Load the form resource.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
formId = eventP->data.frmLoad.formID;
|
||||||
|
frmP = FrmInitForm(formId);
|
||||||
|
FrmSetActiveForm(frmP);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* 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(frmP, MainFormHandleEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrFatalDisplay("Invalid Form Load Event");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppEventLoop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event loop for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppEventLoop(void)
|
||||||
|
{
|
||||||
|
UInt16 error;
|
||||||
|
EventType event;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
EvtGetEvent(&event, evtWaitForever);
|
||||||
|
|
||||||
|
if (! SysHandleEvent(&event))
|
||||||
|
if (! MenuHandleEvent(0, &event, &error))
|
||||||
|
if (! AppHandleEvent(&event))
|
||||||
|
FrmDispatchEvent(&event);
|
||||||
|
|
||||||
|
} while (event.eType != appStopEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStart
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Get the current application's preferences.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: Err value 0 if nothing went wrong
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err AppStart(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
UInt16 prefsSize;
|
||||||
|
UInt32 version;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Read the saved preferences / saved-state information.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
prefsSize = sizeof(StarterPreferenceType);
|
||||||
|
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
|
||||||
|
noPreferenceFound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_TRGSilkFeaturePresent(&version))
|
||||||
|
silkPresent = true;
|
||||||
|
else
|
||||||
|
silkPresent = false;
|
||||||
|
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Save the current state of the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppStop(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Write the saved preferences / saved-state information. This data
|
||||||
|
* will be backed up during a HotSync.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
|
||||||
|
&prefs, sizeof (prefs), true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Close all the open forms.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmCloseAllForms ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: StarterPalmMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
*
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr /*cmdPBP*/, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
Err error;
|
||||||
|
|
||||||
|
if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case sysAppLaunchCmdNormalLaunch:
|
||||||
|
error = AppStart();
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
FrmGotoForm(MainForm);
|
||||||
|
AppEventLoop();
|
||||||
|
AppStop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PilotMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
* REVISION HISTORY:
|
||||||
|
*
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
return StarterPalmMain(cmd, cmdPBP, launchFlags);
|
||||||
|
}
|
||||||
|
|
||||||
81
handera-105/examples/ExampleG/StarterRsc.h
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
// Header generated by Constructor for Palm OS¨ 1.6
|
||||||
|
//
|
||||||
|
// Generated at 4:38:50 PM on Saturday, March 24, 2001
|
||||||
|
//
|
||||||
|
// Generated for file: T:\TRGProd\StarKist\sw\sdk\cw\examples\ExampleG\Rsc\Starter.rsrc
|
||||||
|
//
|
||||||
|
// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE FROM CONSTRUCTOR FOR PALM OS¨;
|
||||||
|
// - DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST
|
||||||
|
//
|
||||||
|
// Palm App Name: "ExampleG"
|
||||||
|
//
|
||||||
|
// Palm App Version: "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1000
|
||||||
|
#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0)
|
||||||
|
#define MainSetTemplateButton 1001 //(Left Origin = 50, Top Origin = 75, Width = 60, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
#define MainResetTemplateButton 1002 //(Left Origin = 40, Top Origin = 110, Width = 80, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1100
|
||||||
|
#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
|
||||||
|
#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 54, Usable = 1, Font = Standard)
|
||||||
|
#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold)
|
||||||
|
#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: Talt 1001
|
||||||
|
#define RomIncompatibleAlert 1001
|
||||||
|
#define RomIncompatibleOK 0
|
||||||
|
|
||||||
|
// Resource: Talt 1000
|
||||||
|
#define SilkExtNotFoundAlert 1000
|
||||||
|
#define SilkExtNotFoundOK 0
|
||||||
|
|
||||||
|
// Resource: MBAR 1000
|
||||||
|
#define MainFormMenuBar 1000
|
||||||
|
|
||||||
|
// Resource: MENU 1000
|
||||||
|
#define MainOptionsMenu 1000
|
||||||
|
#define MainOptionsAboutExampleG 1000
|
||||||
|
|
||||||
|
// Resource: PICT 1100
|
||||||
|
#define SmallIconBitmap 1100
|
||||||
|
// Resource: PICT 1000
|
||||||
|
#define BigIconBitmap 1000
|
||||||
|
// Resource: PICT 1400
|
||||||
|
#define VGABigIconBitmap 1400
|
||||||
|
// Resource: PICT 1500
|
||||||
|
#define VGASmallIconBitmap 1500
|
||||||
|
// Resource: PICT 1600
|
||||||
|
#define Silk1Bitmap 1600
|
||||||
|
// Resource: PICT 1700
|
||||||
|
#define Silk2Bitmap 1700
|
||||||
|
// Resource: PICT 1800
|
||||||
|
#define Silk3Bitmap 1800
|
||||||
|
// Resource: PICT 1900
|
||||||
|
#define Silk4Bitmap 1900
|
||||||
|
// Resource: PICT 2000
|
||||||
|
#define VGABigIconInvertedBitmap 2000
|
||||||
|
// Resource: tbmf 3000
|
||||||
|
#define InvertedSilkBitmapFamily 3000
|
||||||
|
|
||||||
|
// Resource: tbmf 3100
|
||||||
|
#define NormalSilkBitmapFamily 3100
|
||||||
|
|
||||||
|
// Resource: taif 2001
|
||||||
|
#define VGASmallIconAppIconFamily 2001
|
||||||
|
|
||||||
|
// Resource: taif 2000
|
||||||
|
#define VGABigIconAppIconFamily 2000
|
||||||
|
|
||||||
|
// Resource: taif 1001
|
||||||
|
#define SmallIconAppIconFamily 1001
|
||||||
|
|
||||||
|
// Resource: taif 1000
|
||||||
|
#define BigIconAppIconFamily 1000
|
||||||
|
|
||||||
|
// Resource: taif 2002
|
||||||
|
#define VGABigIconInvertedAppIconFamily 2002
|
||||||
BIN
handera-105/examples/ExampleH/ExampleH.mcp
Normal file
BIN
handera-105/examples/ExampleH/Rsc/Resource.frk/Starter.rsrc
Normal file
|
After Width: | Height: | Size: 3.1 KiB |
0
handera-105/examples/ExampleH/Rsc/Starter.rsrc
Normal file
17
handera-105/examples/ExampleH/Src/MainForm.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: MainForm.h
|
||||||
|
*
|
||||||
|
* Project : Example H
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
#ifndef _MAINFORM_H_
|
||||||
|
#define _MAINFORM_H_
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
|
||||||
|
Boolean MainFormHandleEvent (EventPtr eventP);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
707
handera-105/examples/ExampleH/Src/mainform.c
Normal file
@ -0,0 +1,707 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: MainForm.c
|
||||||
|
*
|
||||||
|
* Project : Example H
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include <vfsmgr.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
#include "Vga.h"
|
||||||
|
#include "Audio.h"
|
||||||
|
#include "MainForm.h"
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Local Types
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
extern Boolean vgaPresent;
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Local Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define maxTableItems 13
|
||||||
|
#define tblNameCol 0x00
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Local Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void *GetObjectPtr (UInt16 objectID);
|
||||||
|
static void PrvMoveObject (FormPtr frmP, UInt16 objIndex, Coord y_diff, Boolean draw);
|
||||||
|
static void PrvResizeObject (FormPtr frmP, UInt16 objIndex, Coord y_diff, Boolean draw);
|
||||||
|
static void TableDrawItem (void * tableP, Int16 row, Int16 column, RectanglePtr bounds);
|
||||||
|
static void MainFormScrollLines(Int16 lines, Boolean force_redraw);
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Local Variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static FontID currentFont;
|
||||||
|
static Int16 numTableItems;
|
||||||
|
static Int16 currentSelection;
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: GetObjectPtr
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine returns a pointer to an object in the current
|
||||||
|
* form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: formId - id of the form to display
|
||||||
|
*
|
||||||
|
* RETURNED: void *
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void * GetObjectPtr(UInt16 objectID)
|
||||||
|
{
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
return(FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvFrmGetGSI
|
||||||
|
*
|
||||||
|
* DESCRIPTION: FrmGetObjectIndex() does not work for the graffiti shift
|
||||||
|
* indicator. Therefore, we must do it ourselves.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED:
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt16 PrvFrmGetGSI(FormPtr frmP)
|
||||||
|
{
|
||||||
|
UInt16 i, numObjects;
|
||||||
|
|
||||||
|
numObjects = FrmGetNumberOfObjects(frmP);
|
||||||
|
|
||||||
|
for (i=0; i<numObjects; i++)
|
||||||
|
{
|
||||||
|
if (FrmGetObjectType(frmP, i) == frmGraffitiStateObj)
|
||||||
|
return(i);
|
||||||
|
}
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvMoveObject
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine moves an object vertically within a form.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvMoveObject(FormPtr frmP, UInt16 objIndex, Coord y_diff, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r;
|
||||||
|
|
||||||
|
FrmGetObjectBounds(frmP, objIndex, &r);
|
||||||
|
if (draw)
|
||||||
|
{
|
||||||
|
RctInsetRectangle(&r, -2); //need to erase the frame as well
|
||||||
|
WinEraseRectangle(&r, 0);
|
||||||
|
RctInsetRectangle(&r, 2);
|
||||||
|
}
|
||||||
|
r.topLeft.y += y_diff;
|
||||||
|
FrmSetObjectBounds(frmP, objIndex, &r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PrvResizeObject
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine moves an object vertically within a form.
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void PrvResizeObject(FormPtr frmP, UInt16 objIndex, Coord y_diff, Boolean draw)
|
||||||
|
{
|
||||||
|
RectangleType r;
|
||||||
|
|
||||||
|
FrmGetObjectBounds(frmP, objIndex, &r);
|
||||||
|
if (draw)
|
||||||
|
WinEraseRectangle(&r, 0);
|
||||||
|
r.extent.y += y_diff;
|
||||||
|
FrmSetObjectBounds(frmP, objIndex, &r);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FUNCTION: HandleSelectItem
|
||||||
|
* DESCRIPTION:
|
||||||
|
* PARAMETERS:
|
||||||
|
* RETURNED:
|
||||||
|
***********************************************************************/
|
||||||
|
static void HandleSelectItem(Int16 row)
|
||||||
|
{
|
||||||
|
Char buf[30];
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
Int16 valueP, minP, maxP, pageSizeP;
|
||||||
|
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
SclGetScrollBar(barP, &valueP, &minP, &maxP, &pageSizeP);
|
||||||
|
currentSelection = row;
|
||||||
|
StrPrintF(buf, "Line %d selected", currentSelection + valueP + 1);
|
||||||
|
FrmCustomAlert(LineNumberAlert, buf, NULL, NULL);
|
||||||
|
TblUnhighlightSelection(GetObjectPtr(MainAppTable));
|
||||||
|
TblSelectItem(GetObjectPtr(MainAppTable), currentSelection, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FUNCTION: HandlePrevKey
|
||||||
|
* DESCRIPTION:
|
||||||
|
* PARAMETERS:
|
||||||
|
* RETURNED:
|
||||||
|
***********************************************************************/
|
||||||
|
static void HandlePrevKey(void)
|
||||||
|
{
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
Int16 valueP, minP, maxP, pageSizeP;
|
||||||
|
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
SclGetScrollBar(barP, &valueP, &minP, &maxP, &pageSizeP);
|
||||||
|
|
||||||
|
if (currentSelection == -1)
|
||||||
|
currentSelection = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (currentSelection > 0)
|
||||||
|
currentSelection --;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (valueP > minP)
|
||||||
|
MainFormScrollLines(-1, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TblSelectItem(GetObjectPtr(MainAppTable), currentSelection, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FUNCTION: HandleNextKey
|
||||||
|
* DESCRIPTION:
|
||||||
|
* PARAMETERS:
|
||||||
|
* RETURNED:
|
||||||
|
***********************************************************************/
|
||||||
|
static void HandleNextKey(void)
|
||||||
|
{
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
Int16 valueP, minP, maxP, pageSizeP;
|
||||||
|
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
SclGetScrollBar(barP, &valueP, &minP, &maxP, &pageSizeP);
|
||||||
|
|
||||||
|
if (currentSelection == -1)
|
||||||
|
currentSelection = 0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (currentSelection < pageSizeP - 1)
|
||||||
|
currentSelection ++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (valueP < maxP)
|
||||||
|
MainFormScrollLines(1, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TblSelectItem(GetObjectPtr(MainAppTable), currentSelection, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FUNCTION: TableDrawItem
|
||||||
|
* DESCRIPTION:
|
||||||
|
* PARAMETERS:
|
||||||
|
* RETURNED:
|
||||||
|
***********************************************************************/
|
||||||
|
static void TableDrawItem(void * tableP, Int16 row, Int16 column, RectanglePtr bounds)
|
||||||
|
{
|
||||||
|
FontID saveID;
|
||||||
|
Int16 valueP, minP, maxP, pageSizeP;
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
Char buf[20];
|
||||||
|
|
||||||
|
WinEraseRectangle(bounds, 0);
|
||||||
|
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
SclGetScrollBar(barP, &valueP, &minP, &maxP, &pageSizeP);
|
||||||
|
row += valueP;
|
||||||
|
|
||||||
|
if(row < numTableItems)
|
||||||
|
{
|
||||||
|
StrPrintF(buf, "Line %d", row + 1);
|
||||||
|
|
||||||
|
saveID = FntSetFont(currentFont);
|
||||||
|
WinDrawTruncChars(buf, StrLen(buf), bounds->topLeft.x, bounds->topLeft.y, TblGetColumnWidth((TablePtr) tableP, column));
|
||||||
|
FntSetFont(saveID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FUNCTION: TableLoad
|
||||||
|
* DESCRIPTION:
|
||||||
|
* PARAMETERS:
|
||||||
|
* RETURNED:
|
||||||
|
***********************************************************************/
|
||||||
|
static void TableLoad(Int16 listOffset)
|
||||||
|
{
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
Int16 listItems = 0;
|
||||||
|
RectangleType rect;
|
||||||
|
Int16 running_total, row_height;
|
||||||
|
Int16 tblRows, row, visibleRows;
|
||||||
|
TablePtr tableP;
|
||||||
|
|
||||||
|
tableP = GetObjectPtr(MainAppTable);
|
||||||
|
tblRows = TblGetNumberOfRows(tableP);
|
||||||
|
|
||||||
|
TblSetColumnUsable (tableP, tblNameCol, true);
|
||||||
|
|
||||||
|
FntSetFont(currentFont);
|
||||||
|
row_height = FntLineHeight();
|
||||||
|
TblGetBounds(tableP, &rect);
|
||||||
|
running_total = 0;
|
||||||
|
visibleRows = 0;
|
||||||
|
|
||||||
|
for(row=0; row< tblRows; row++)
|
||||||
|
{
|
||||||
|
TblSetRowHeight(tableP, row, row_height);
|
||||||
|
|
||||||
|
running_total += row_height;
|
||||||
|
|
||||||
|
if(row < numTableItems)
|
||||||
|
TblSetRowUsable(tableP, row, running_total < rect.extent.y);
|
||||||
|
else
|
||||||
|
TblSetRowUsable(tableP, row, false);
|
||||||
|
|
||||||
|
if (running_total < rect.extent.y)
|
||||||
|
visibleRows++;
|
||||||
|
|
||||||
|
TblMarkRowInvalid(tableP, row);
|
||||||
|
}
|
||||||
|
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
if(numTableItems > visibleRows)
|
||||||
|
SclSetScrollBar(barP, listOffset, 0, numTableItems - visibleRows, visibleRows);
|
||||||
|
else
|
||||||
|
SclSetScrollBar(barP, 0, 0, 0, numTableItems);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FUNCTION: TableInit
|
||||||
|
* DESCRIPTION:
|
||||||
|
* PARAMETERS:
|
||||||
|
* RETURNED:
|
||||||
|
***********************************************************************/
|
||||||
|
static void TableInit(void)
|
||||||
|
{
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
Int16 tblRows, row, row_height;
|
||||||
|
TablePtr tableP;
|
||||||
|
|
||||||
|
currentSelection = -1;
|
||||||
|
|
||||||
|
tableP = GetObjectPtr(MainAppTable);
|
||||||
|
tblRows = TblGetNumberOfRows(tableP);
|
||||||
|
|
||||||
|
FntSetFont(currentFont);
|
||||||
|
|
||||||
|
row_height = FntLineHeight();
|
||||||
|
|
||||||
|
for(row=0; row< tblRows; row++)
|
||||||
|
{
|
||||||
|
TblSetItemStyle(tableP, row, tblNameCol, customTableItem);
|
||||||
|
TblSetRowHeight(tableP, row, row_height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Set the callback routine that draws the Name column.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
TblSetCustomDrawProcedure (tableP, tblNameCol, TableDrawItem);
|
||||||
|
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
SclSetScrollBar(barP, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FUNCTION:
|
||||||
|
* DESCRIPTION:
|
||||||
|
* PARAMETERS:
|
||||||
|
* RETURNED:
|
||||||
|
* REVISION HISTORY:
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormScroll(Int16 newValue, Int16 oldValue, Boolean force_redraw)
|
||||||
|
{
|
||||||
|
TablePtr tableP;
|
||||||
|
|
||||||
|
tableP = GetObjectPtr(MainAppTable);
|
||||||
|
|
||||||
|
TblUnhighlightSelection(tableP);
|
||||||
|
|
||||||
|
if(oldValue != newValue)
|
||||||
|
{
|
||||||
|
TableLoad(newValue);
|
||||||
|
|
||||||
|
if(force_redraw)
|
||||||
|
TblDrawTable(tableP);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
* FUNCTION:
|
||||||
|
* DESCRIPTION:
|
||||||
|
* PARAMETERS:
|
||||||
|
* RETURNED:
|
||||||
|
* REVISION HISTORY:
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormScrollLines(Int16 lines, Boolean force_redraw)
|
||||||
|
{
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
Int16 valueP, minP, maxP, pageSizeP;
|
||||||
|
Int16 newValue;
|
||||||
|
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
SclGetScrollBar(barP, &valueP, &minP, &maxP, &pageSizeP);
|
||||||
|
|
||||||
|
TblUnhighlightSelection(GetObjectPtr(MainAppTable));
|
||||||
|
|
||||||
|
//scroll up
|
||||||
|
if(lines < 0)
|
||||||
|
{
|
||||||
|
//we are at the start
|
||||||
|
if(valueP == minP)
|
||||||
|
return;
|
||||||
|
|
||||||
|
newValue = valueP + lines;
|
||||||
|
if(newValue < minP)
|
||||||
|
newValue = minP;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(valueP == maxP)
|
||||||
|
return;
|
||||||
|
|
||||||
|
newValue = valueP + lines;
|
||||||
|
if(newValue > maxP)
|
||||||
|
newValue = maxP;
|
||||||
|
}
|
||||||
|
|
||||||
|
SclSetScrollBar(barP, newValue, minP, maxP, pageSizeP);
|
||||||
|
MainFormScroll(newValue, valueP, force_redraw);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormResize
|
||||||
|
*
|
||||||
|
* DESCRIPTION:
|
||||||
|
*
|
||||||
|
* PARAMETERS:
|
||||||
|
*
|
||||||
|
* RETURNED:
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormResize(FormPtr frmP, Boolean draw)
|
||||||
|
{
|
||||||
|
Int16 valueP, minP, maxP, pageSizeP;
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
UInt16 objIdx;
|
||||||
|
Coord x, y;
|
||||||
|
Coord y_diff;
|
||||||
|
RectangleType r, erase_rect;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the new extent
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
WinGetDisplayExtent(&x, &y);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Get the old extent
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmGetFormBounds(frmP, &r);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Calculate change
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
y_diff = y - (r.topLeft.y + r.extent.y);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* If the silkscreen was maximized, erase the area under maxmized silkscreen
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (draw && (y_diff < 0))
|
||||||
|
{
|
||||||
|
erase_rect = r;
|
||||||
|
erase_rect.topLeft.y = r.extent.y + y_diff;
|
||||||
|
erase_rect.extent.y = -y_diff;
|
||||||
|
WinEraseRectangle(&erase_rect, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Resize the form
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
r.extent.y += y_diff;
|
||||||
|
WinSetWindowBounds(FrmGetWindowHandle(frmP), &r);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Move Bottom Controls Button
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrvMoveObject(frmP, FrmGetObjectIndex(frmP, MainHelpButton), y_diff, draw);
|
||||||
|
PrvMoveObject(frmP, FrmGetObjectIndex(frmP, MainTextField), y_diff, draw);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Move the GSI (graffiti shift indicator)
|
||||||
|
* Need to set the GSI's location as well as it's location on the form
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
objIdx = PrvFrmGetGSI(frmP);
|
||||||
|
PrvMoveObject (frmP, objIdx, y_diff, draw);
|
||||||
|
FrmGetObjectPosition(frmP, objIdx, &x, &y);
|
||||||
|
GsiSetLocation (x, y+y_diff);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Resize Scrollbar
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrvResizeObject(frmP, FrmGetObjectIndex(frmP, MainAppScrollBar), y_diff, draw);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Resize the table
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrvResizeObject(frmP, FrmGetObjectIndex(frmP, MainAppTable), y_diff, draw);
|
||||||
|
|
||||||
|
if (draw)
|
||||||
|
{
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
SclGetScrollBar(barP, &valueP, &minP, &maxP, &pageSizeP);
|
||||||
|
|
||||||
|
TableLoad(valueP);
|
||||||
|
FrmDrawForm(frmP);
|
||||||
|
|
||||||
|
currentSelection = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormInit
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine initializes the MainForm form.
|
||||||
|
*
|
||||||
|
* PARAMETERS: frm - pointer to the MainForm form.
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void MainFormInit(FormPtr frmP)
|
||||||
|
{
|
||||||
|
TableInit();
|
||||||
|
|
||||||
|
numTableItems = maxTableItems;
|
||||||
|
currentFont = stdFont;
|
||||||
|
|
||||||
|
if (vgaPresent)
|
||||||
|
{
|
||||||
|
currentFont = VgaBaseToVgaFont(currentFont);
|
||||||
|
VgaTableUseBaseFont((TablePtr)GetObjectPtr(MainAppTable), false);
|
||||||
|
VgaFormModify(frmP, vgaFormModify160To240);
|
||||||
|
MainFormResize(frmP, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
TableLoad(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormDoCommand
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine performs the menu command specified.
|
||||||
|
*
|
||||||
|
* PARAMETERS: command - menu item id
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean MainFormDoCommand(UInt16 command)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
UInt16 formID;
|
||||||
|
FontID newFont;
|
||||||
|
FormPtr frmP;
|
||||||
|
VgaScreenModeType screenMode;
|
||||||
|
VgaRotateModeType rotateMode;
|
||||||
|
|
||||||
|
formID = (FrmGetFormId (FrmGetActiveForm ()));
|
||||||
|
|
||||||
|
switch (command)
|
||||||
|
{
|
||||||
|
case MainOptionsAboutExampleH:
|
||||||
|
MenuEraseStatus(0);
|
||||||
|
if (vgaPresent)
|
||||||
|
{
|
||||||
|
VgaGetScreenMode(&screenMode, &rotateMode);
|
||||||
|
VgaSetScreenMode(screenModeScaleToFit, rotateMode);
|
||||||
|
}
|
||||||
|
frmP = FrmInitForm (AboutForm);
|
||||||
|
FrmDoDialog (frmP); // Display the About Box.
|
||||||
|
FrmDeleteForm (frmP);
|
||||||
|
if (vgaPresent)
|
||||||
|
VgaSetScreenMode(screenMode, rotateMode);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MainOptionsFont :
|
||||||
|
TblUnhighlightSelection(GetObjectPtr(MainAppTable));
|
||||||
|
currentSelection = -1;
|
||||||
|
newFont = FontSelect(currentFont);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Note: There is a bug in the OS which causes large Table Fonts to not
|
||||||
|
* highlight properly when selected. The work around is to implement
|
||||||
|
* the selection yourself. For simplicity sake, this example
|
||||||
|
* does not do this.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
currentFont = newFont;
|
||||||
|
if (vgaPresent)
|
||||||
|
{
|
||||||
|
if (VgaIsVgaFont(currentFont))
|
||||||
|
VgaTableUseBaseFont((TablePtr)GetObjectPtr(MainAppTable), false);
|
||||||
|
else
|
||||||
|
VgaTableUseBaseFont((TablePtr)GetObjectPtr(MainAppTable), true);
|
||||||
|
}
|
||||||
|
MainFormResize(FrmGetActiveForm(), true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: MainFormHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event handler for the
|
||||||
|
* "MainForm" of this application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: eventP - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
Boolean MainFormHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
Boolean handled = false;
|
||||||
|
FormPtr frmP;
|
||||||
|
ScrollBarPtr barP;
|
||||||
|
Int16 valueP, minP, maxP, pageSizeP;
|
||||||
|
|
||||||
|
|
||||||
|
switch (eventP->eType)
|
||||||
|
{
|
||||||
|
case menuEvent:
|
||||||
|
return MainFormDoCommand(eventP->data.menu.itemID);
|
||||||
|
|
||||||
|
case ctlSelectEvent :
|
||||||
|
switch(eventP->data.ctlSelect.controlID)
|
||||||
|
{
|
||||||
|
case MainHelpButton :
|
||||||
|
FrmHelp(HelpString);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case frmOpenEvent:
|
||||||
|
frmP = FrmGetActiveForm();
|
||||||
|
MainFormInit(frmP);
|
||||||
|
FrmDrawForm (frmP);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case displayExtentChangedEvent :
|
||||||
|
MainFormResize(FrmGetActiveForm(), true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case frmCloseEvent :
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case sclRepeatEvent:
|
||||||
|
currentSelection = -1;
|
||||||
|
MainFormScroll(eventP->data.sclRepeat.newValue, eventP->data.sclRepeat.value, true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case tblSelectEvent :
|
||||||
|
HandleSelectItem(eventP->data.tblSelect.row);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case keyDownEvent:
|
||||||
|
barP = GetObjectPtr(MainAppScrollBar);
|
||||||
|
SclGetScrollBar(barP, &valueP, &minP, &maxP, &pageSizeP);
|
||||||
|
|
||||||
|
switch (eventP->data.keyDown.chr)
|
||||||
|
{
|
||||||
|
case vchrPageUp :
|
||||||
|
currentSelection = -1;
|
||||||
|
MainFormScrollLines(-pageSizeP, true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
case vchrPageDown :
|
||||||
|
currentSelection = -1;
|
||||||
|
MainFormScrollLines(pageSizeP, true);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
case vchrPrevField :
|
||||||
|
HandlePrevKey();
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
case vchrNextField :
|
||||||
|
HandleNextKey();
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
case chrCarriageReturn :
|
||||||
|
if (currentSelection != -1)
|
||||||
|
HandleSelectItem(currentSelection);
|
||||||
|
handled = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return(handled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
306
handera-105/examples/ExampleH/Src/starter.c
Normal file
@ -0,0 +1,306 @@
|
|||||||
|
/******************************************************************************
|
||||||
|
*
|
||||||
|
* File: Starter.c
|
||||||
|
*
|
||||||
|
* Project : Example H
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <PalmOS.h>
|
||||||
|
#include <NotifyMgr.h>
|
||||||
|
#include "StarterRsc.h"
|
||||||
|
|
||||||
|
#include "Vga.h"
|
||||||
|
#include "MainForm.h"
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Structures
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterPreferenceType;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
UInt8 replaceme;
|
||||||
|
} StarterAppInfoType;
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Global variables
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
typedef StarterAppInfoType* StarterAppInfoPtr;
|
||||||
|
|
||||||
|
Boolean vgaPresent = false;
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Constants
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
#define appFileCreator 'Ex_H'
|
||||||
|
#define appVersionNum 0x01
|
||||||
|
#define appPrefID 0x00
|
||||||
|
#define appPrefVersionNum 0x01
|
||||||
|
|
||||||
|
// Define the minimum OS version we support (2.0 for now).
|
||||||
|
#define ourMinVersion sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Internal Functions
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: RomVersionCompatible
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine checks that a ROM version is meet your
|
||||||
|
* minimum requirement.
|
||||||
|
*
|
||||||
|
* PARAMETERS: requiredVersion - minimum rom version required
|
||||||
|
* (see sysFtrNumROMVersion in SystemMgr.h
|
||||||
|
* for format)
|
||||||
|
* launchFlags - flags that indicate if the application
|
||||||
|
* UI is initialized.
|
||||||
|
*
|
||||||
|
* RETURNED: error code or zero if rom is compatible
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err RomVersionCompatible(UInt32 requiredVersion, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
UInt32 romVersion;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* See if we're on in minimum required version of the ROM or later.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
|
||||||
|
if (romVersion < requiredVersion)
|
||||||
|
{
|
||||||
|
if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
|
||||||
|
(sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
|
||||||
|
{
|
||||||
|
FrmAlert (RomIncompatibleAlert);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Palm OS 1.0 will continuously relaunch this app unless we switch to
|
||||||
|
* another safe one.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (romVersion < ourMinVersion)
|
||||||
|
{
|
||||||
|
AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sysErrRomIncompatible;
|
||||||
|
}
|
||||||
|
|
||||||
|
return errNone;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppHandleEvent
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine loads form resources and set the event
|
||||||
|
* handler for the form loaded.
|
||||||
|
*
|
||||||
|
* PARAMETERS: event - a pointer to an EventType structure
|
||||||
|
*
|
||||||
|
* RETURNED: true if the event has handle and should not be passed
|
||||||
|
* to a higher level handler.
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Boolean AppHandleEvent(EventPtr eventP)
|
||||||
|
{
|
||||||
|
UInt16 formId;
|
||||||
|
FormPtr frmP;
|
||||||
|
|
||||||
|
if (eventP->eType == frmLoadEvent)
|
||||||
|
{
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Load the form resource.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
formId = eventP->data.frmLoad.formID;
|
||||||
|
frmP = FrmInitForm(formId);
|
||||||
|
FrmSetActiveForm(frmP);
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* 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(frmP, MainFormHandleEvent);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ErrFatalDisplay("Invalid Form Load Event");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppEventLoop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This routine is the event loop for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppEventLoop(void)
|
||||||
|
{
|
||||||
|
UInt16 error;
|
||||||
|
EventType event;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
EvtGetEvent(&event, evtWaitForever);
|
||||||
|
|
||||||
|
if (! SysHandleEvent(&event))
|
||||||
|
if (! MenuHandleEvent(0, &event, &error))
|
||||||
|
if (! AppHandleEvent(&event))
|
||||||
|
FrmDispatchEvent(&event);
|
||||||
|
|
||||||
|
} while (event.eType != appStopEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStart
|
||||||
|
*
|
||||||
|
* DESCRIPTION:
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: Err value 0 if nothing went wrong
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static Err AppStart(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
UInt16 prefsSize;
|
||||||
|
UInt32 version;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Read the saved preferences / saved-state information.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
prefsSize = sizeof(StarterPreferenceType);
|
||||||
|
if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) !=
|
||||||
|
noPreferenceFound)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Check to see if VGA extension present
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
if (_TRGVGAFeaturePresent(&version))
|
||||||
|
vgaPresent = true;
|
||||||
|
else
|
||||||
|
vgaPresent = false;
|
||||||
|
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: AppStop
|
||||||
|
*
|
||||||
|
* DESCRIPTION: Save the current state of the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: nothing
|
||||||
|
*
|
||||||
|
* RETURNED: nothing
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static void AppStop(void)
|
||||||
|
{
|
||||||
|
StarterPreferenceType prefs;
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Write the saved preferences / saved-state information. This data
|
||||||
|
* will be backed up during a HotSync.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum,
|
||||||
|
&prefs, sizeof (prefs), true);
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------
|
||||||
|
* Close all the open forms.
|
||||||
|
*----------------------------------------------------------------------*/
|
||||||
|
FrmCloseAllForms ();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: StarterPalmMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
*
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
static UInt32 StarterPalmMain(UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
Err error;
|
||||||
|
|
||||||
|
if ((error = RomVersionCompatible (ourMinVersion, launchFlags)) != 0)
|
||||||
|
return (error);
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case sysAppLaunchCmdNormalLaunch:
|
||||||
|
if ((error = AppStart()) != errNone)
|
||||||
|
return(error);
|
||||||
|
|
||||||
|
if (vgaPresent)
|
||||||
|
VgaSetScreenMode(screenMode1To1, rotateModeNone);
|
||||||
|
|
||||||
|
FrmGotoForm(MainForm);
|
||||||
|
AppEventLoop();
|
||||||
|
AppStop();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
return(errNone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* FUNCTION: PilotMain
|
||||||
|
*
|
||||||
|
* DESCRIPTION: This is the main entry point for the application.
|
||||||
|
*
|
||||||
|
* PARAMETERS: cmd - word value specifying the launch code.
|
||||||
|
* cmdPB - pointer to a structure that is associated with the launch code.
|
||||||
|
* launchFlags - word value providing extra information about the launch.
|
||||||
|
* RETURNED: Result of launch
|
||||||
|
*
|
||||||
|
***********************************************************************/
|
||||||
|
UInt32 PilotMain( UInt16 cmd, MemPtr cmdPBP, UInt16 launchFlags)
|
||||||
|
{
|
||||||
|
return StarterPalmMain(cmd, cmdPBP, launchFlags);
|
||||||
|
}
|
||||||
|
|
||||||
76
handera-105/examples/ExampleH/StarterRsc.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
// Header generated by Constructor for Palm OS¨ 1.6
|
||||||
|
//
|
||||||
|
// Generated at 4:46:29 PM on Wednesday, April 04, 2001
|
||||||
|
//
|
||||||
|
// Generated for file: T:\TRGProd\StarKist\sw\sdk\cw\examples\ExampleH\Rsc\Starter.rsrc
|
||||||
|
//
|
||||||
|
// THIS IS AN AUTOMATICALLY GENERATED HEADER FILE FROM CONSTRUCTOR FOR PALM OS¨;
|
||||||
|
// - DO NOT EDIT - CHANGES MADE TO THIS FILE WILL BE LOST
|
||||||
|
//
|
||||||
|
// Palm App Name: "ExampleH"
|
||||||
|
//
|
||||||
|
// Palm App Version: "1.0"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1000
|
||||||
|
#define MainForm 1000 //(Left Origin = 0, Top Origin = 0, Width = 160, Height = 160, Usable = 1, Modal = 0, Save Behind = 0, Help ID = 0, Menu Bar ID = 1000, Default Button ID = 0)
|
||||||
|
#define MainTextField 1001 //(Left Origin = 70, Top Origin = 146, Width = 60, Height = 12, Usable = 1, Editable = 1, Underline = 1, Single Line = 1, Dynamic Size = 0, Left Justified = 1, Max Characters = 80, Font = Standard, Auto Shift = 0, Has Scroll Bar = 0, Numeric = 0)
|
||||||
|
#define MainShiftGraffitiShift 1002 //(Left Origin = 140, Top Origin = 146)
|
||||||
|
#define MainAppLabel 1003 //(Left Origin = 4, Top Origin = 18, Usable = 1, Font = Bold)
|
||||||
|
#define MainAppTable 1005 //(Left Origin = 8, Top Origin = 30, Width = 141, Height = 110, Editable = 1, Rows = 20)
|
||||||
|
#define MainAppScrollBar 1006 //(Left Origin = 152, Top Origin = 29, Width = 7, Height = 112, Usable = 1, Value = 0, Minimum Value = 0, Maximum Value = 0, Page Size = 0)
|
||||||
|
#define MainAppGadget 1007 //(Left Origin = 4, Top Origin = 108, Width = 1, Height = 1, Usable = 1)
|
||||||
|
#define MainHelpButton 1008 //(Left Origin = 1, Top Origin = 146, Width = 36, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: tFRM 1100
|
||||||
|
#define AboutForm 1100 //(Left Origin = 2, Top Origin = 2, Width = 156, Height = 156, Usable = 1, Modal = 1, Save Behind = 1, Help ID = 0, Menu Bar ID = 0, Default Button ID = 0)
|
||||||
|
#define AboutText1Label 1103 //(Left Origin = 23, Top Origin = 61, Usable = 1, Font = Standard)
|
||||||
|
#define AboutText2Label 1104 //(Left Origin = 50, Top Origin = 104, Usable = 1, Font = Bold)
|
||||||
|
#define AboutOKButton 1105 //(Left Origin = 58, Top Origin = 133, Width = 40, Height = 12, Usable = 1, Anchor Left = 1, Frame = 1, Non-bold Frame = 1, Font = Standard)
|
||||||
|
|
||||||
|
|
||||||
|
// Resource: Talt 1001
|
||||||
|
#define RomIncompatibleAlert 1001
|
||||||
|
#define RomIncompatibleOK 0
|
||||||
|
|
||||||
|
// Resource: Talt 1000
|
||||||
|
#define LineNumberAlert 1000
|
||||||
|
#define LineNumberOK 0
|
||||||
|
|
||||||
|
// Resource: MBAR 1000
|
||||||
|
#define MainFormMenuBar 1000
|
||||||
|
|
||||||
|
// Resource: MENU 1000
|
||||||
|
#define MainOptionsMenu 1000
|
||||||
|
#define MainOptionsFont 1000
|
||||||
|
#define MainOptionsAboutExampleH 1001
|
||||||
|
|
||||||
|
// Resource: tSTR 1000
|
||||||
|
#define HelpString 1000 // "This is the help message for ExampleH."
|
||||||
|
|
||||||
|
// Resource: PICT 1100
|
||||||
|
#define SmallIconBitmap 1100
|
||||||
|
// Resource: PICT 1000
|
||||||
|
#define BigIconBitmap 1000
|
||||||
|
// Resource: PICT 1400
|
||||||
|
#define VGABigIconBitmap 1400
|
||||||
|
// Resource: PICT 1500
|
||||||
|
#define VGASmallIconBitmap 1500
|
||||||
|
// Resource: PICT 1600
|
||||||
|
#define VGABigIconInvertedBitmap 1600
|
||||||
|
// Resource: taif 2002
|
||||||
|
#define VGABigIconInvertedAppIconFamily 2002
|
||||||
|
|
||||||
|
// Resource: taif 2001
|
||||||
|
#define VGASmallIconAppIconFamily 2001
|
||||||
|
|
||||||
|
// Resource: taif 2000
|
||||||
|
#define VGABigIconAppIconFamily 2000
|
||||||
|
|
||||||
|
// Resource: taif 1001
|
||||||
|
#define SmallIconAppIconFamily 1001
|
||||||
|
|
||||||
|
// Resource: taif 1000
|
||||||
|
#define BigIconAppIconFamily 1000
|
||||||
BIN
handera-105/examples/ExampleI/Memo.mcp
Normal file
29
handera-105/examples/ExampleI/Rsc/HandEra.r
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/***********************************************************************
|
||||||
|
*
|
||||||
|
* Copyright (c) 1999-2001, TRG, All Rights Reserved
|
||||||
|
*
|
||||||
|
* PROJECT: HandEra 330
|
||||||
|
*
|
||||||
|
* FILE: HandEra.r
|
||||||
|
*
|
||||||
|
* DESCRIPTION:
|
||||||
|
*
|
||||||
|
* AUTHOR: John Ehm
|
||||||
|
*
|
||||||
|
* DATE: 01/17/01
|
||||||
|
*
|
||||||
|
**********************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
type 'sKst' {
|
||||||
|
//Currently no data is stored in resource, need dummy otherwise
|
||||||
|
//resource is not linked in
|
||||||
|
unsigned longint;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
resource 'sKst' (1000, "HandEra Aware")
|
||||||
|
{
|
||||||
|
0x00000001;
|
||||||
|
|
||||||
|
};
|
||||||
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 1003 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 894 B |
|
After Width: | Height: | Size: 767 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 1009 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 894 B |
|
After Width: | Height: | Size: 757 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.1 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 924 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 894 B |
|
After Width: | Height: | Size: 734 B |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.1 KiB |