home *** CD-ROM | disk | FTP | other *** search
- //=============================================================================
- // $Id: nosecurity.c,v 1.1 1999/05/25 15:19:59 hofer Exp hofer $
- //=============================================================================
-
- /*
- Copyright (C) 1999 Remo Hofer <nucifera@geocities.com>
- For more information see http://www.geocities.com/SiliconValley/Cable/5206/
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 2
- of the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
-
- // include headers
- #include <Pilot.h>
- #include <System/Password.h>
- #include "callback.h"
- #include "resources.h"
-
- // global vaiables
- Char titlestr[80];
-
- //-----------------------------------------------------------------------------
- Boolean MainFormHandleEvent(EventPtr event) {
- FormPtr formPtr;
- VoidHand h;
- SWord x, y;
- Boolean handled = false;
-
- CALLBACK_PROLOGUE
-
- formPtr = FrmGetFormPtr(idMainForm);
-
- switch (event->eType) {
-
- case frmOpenEvent:
- // set form title and label to the application name
- h = DmGetResource(ainRsc, idAppName);
- StrCopy(titlestr, MemHandleLock(h));
- MemHandleUnlock(h);
- DmReleaseResource(h);
- FrmSetTitle(formPtr, titlestr);
- FrmCopyLabel(formPtr, idAppNameLabel, titlestr);
- // set form label to application version string
- h = DmGetResource(verRsc, idVersion);
- FrmCopyLabel(formPtr, idVersionLabel, MemHandleLock(h));
- MemHandleUnlock(h);
- DmReleaseResource(h);
- case frmUpdateEvent:
- // draw the form
- FrmDrawForm(formPtr);
- // get the coords of the button rect to draw into
- FrmGetObjectPosition(formPtr, FrmGetObjectIndex(formPtr, idIconRect),
- &x, &y);
- // get and draw the bitmap of the application icon
- h = DmGetResource(iconType, idAppIcon);
- WinDrawBitmap(MemHandleLock(h), x, y);
- MemHandleUnlock(h);
- DmReleaseResource(h);
- handled = true;
- break;
-
- case ctlSelectEvent:
- switch (event->data.ctlSelect.controlID) {
- case idAboutButton:
- // show about form
- FrmHelp(idAboutStr);
- handled = true;
- break;
- case idPasswordButton:
- if (PwdExists()) {
- // remove password
- PwdRemove();
- FrmAlert(idPasswordRemovedAlert);
- } else {
- // no password is assigned
- FrmAlert(idNoPasswordAlert);
- }
- handled = true;
- break;
- }
-
- }
-
- CALLBACK_EPILOGUE
- return(handled);
- }
-
- //-----------------------------------------------------------------------------
- static Boolean ApplicationHandleEvent(EventPtr event) {
- Word formId;
- FormPtr formPtr;
-
- if (event->eType == frmLoadEvent) {
-
- formId = event->data.frmLoad.formID;
-
- // load the form resource
- formPtr = FrmInitForm(formId);
- FrmSetActiveForm(formPtr);
-
- // set the event handler for the form
- FrmSetEventHandler (formPtr, MainFormHandleEvent);
-
- return(true);
-
- }
-
- return(false);
-
- }
-
- //-----------------------------------------------------------------------------
- static void EventLoop(void) {
- EventType event;
- Word error;
-
- do {
- EvtGetEvent(&event, evtWaitForever);
- if (! SysHandleEvent(&event)) {
- if (! MenuHandleEvent(NULL, &event, &error)) {
- if (! ApplicationHandleEvent(&event)) {
- FrmDispatchEvent(&event);
- }
- }
- }
- } while (event.eType != appStopEvent);
-
- }
-
- //-----------------------------------------------------------------------------
- DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags) {
-
- switch (cmd) {
-
- case sysAppLaunchCmdNormalLaunch:
- // display the initial form (usally called from StartApplication)
- FrmGotoForm(idMainForm);
- // enter the event loop
- EventLoop();
- // send a frmCloseEvent to active form handlers
- // (usally called from StopApplication)
- FrmCloseAllForms();
- break;
-
- }
-
- return(0);
- }
-
- //=============================================================================
-