home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / tools / bachmann / bachmann.exe / CW / Samples / PS1999 / Src / ps1999.c next >
Encoding:
C/C++ Source or Header  |  2000-10-06  |  22.6 KB  |  818 lines

  1. /*************************************************************************
  2.  *
  3.  * PROJECT:  PS1999
  4.  * FILE:     Starter.c
  5.  * AUTHOR:   W.F. Ableson,  Bachmann Software and Services, LLC
  6.  *
  7.  * DECLARER: PS1999
  8.  *
  9.  * DESCRIPTION: Exercises Pentax Print Manager Functions
  10.  *      
  11.  *
  12.  **********************************************************************/
  13. #include <Pilot.h>
  14. #include <SysEvtMgr.h>
  15. #include <PrintMgr.h>
  16. #include "PS1999Rsc.h"
  17.  
  18.  
  19.  
  20. /***********************************************************************
  21.  *
  22.  *   Entry Points
  23.  *
  24.  ***********************************************************************/
  25.  
  26.  
  27. /***********************************************************************
  28.  *
  29.  *   Internal Structures
  30.  *
  31.  ***********************************************************************/
  32. typedef struct 
  33.     {
  34.     Byte replaceme;
  35.     } StarterPreferenceType;
  36.  
  37. typedef struct 
  38.     {
  39.     Byte replaceme;
  40.     } StarterAppInfoType;
  41.  
  42. typedef StarterAppInfoType* StarterAppInfoPtr;
  43.  
  44.  
  45. /***********************************************************************
  46.  *
  47.  *   Global variables
  48.  *
  49.  ***********************************************************************/
  50. //static Boolean HideSecretRecords;
  51.  
  52.  
  53. /***********************************************************************
  54.  *
  55.  *   Internal Constants
  56.  *
  57.  ***********************************************************************/
  58. #define appFileCreator                    'PS99'
  59. #define appVersionNum              0x01
  60. #define appPrefID                  0x00
  61. #define appPrefVersionNum          0x01
  62.  
  63.  
  64. // Define the minimum OS version we support
  65. #define ourMinVersion    sysMakeROMVersion(2,0,0,sysROMStageRelease,0)
  66.  
  67.  
  68. /***********************************************************************
  69.  *
  70.  *   Internal Functions
  71.  *
  72.  ***********************************************************************/
  73.  
  74. void DoPrintDemo(FormPtr formP);
  75.  
  76.  
  77. /***********************************************************************
  78.  *
  79.  * FUNCTION:    RomVersionCompatible
  80.  *
  81.  * DESCRIPTION: This routine checks that a ROM version is meet your
  82.  *              minimum requirement.
  83.  *
  84.  * PARAMETERS:  requiredVersion - minimum rom version required
  85.  *                                (see sysFtrNumROMVersion in SystemMgr.h 
  86.  *                                for format)
  87.  *              launchFlags     - flags that indicate if the application 
  88.  *                                UI is initialized.
  89.  *
  90.  * RETURNED:    error code or zero if rom is compatible
  91.  *
  92.  * REVISION HISTORY:
  93.  *
  94.  ***********************************************************************/
  95. static Err RomVersionCompatible(DWord requiredVersion, Word launchFlags)
  96. {
  97.     DWord romVersion;
  98.  
  99.     // See if we're on in minimum required version of the ROM or later.
  100.     FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion);
  101.     if (romVersion < requiredVersion)
  102.         {
  103.         if ((launchFlags & (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp)) ==
  104.             (sysAppLaunchFlagNewGlobals | sysAppLaunchFlagUIApp))
  105.             {
  106.             FrmAlert (RomIncompatibleAlert);
  107.         
  108.             // Pilot 1.0 will continuously relaunch this app unless we switch to 
  109.             // another safe one.
  110.             if (romVersion < sysMakeROMVersion(2,0,0,sysROMStageRelease,0))
  111.                 AppLaunchWithCommand(sysFileCDefaultApp, sysAppLaunchCmdNormalLaunch, NULL);
  112.             }
  113.         
  114.         return (sysErrRomIncompatible);
  115.         }
  116.  
  117.     return (0);
  118. }
  119.  
  120.  
  121. /***********************************************************************
  122.  *
  123.  * FUNCTION:    GetObjectPtr
  124.  *
  125.  * DESCRIPTION: This routine returns a pointer to an object in the current
  126.  *              form.
  127.  *
  128.  * PARAMETERS:  formId - id of the form to display
  129.  *
  130.  * RETURNED:    VoidPtr
  131.  *
  132.  * REVISION HISTORY:
  133.  *
  134.  *
  135.  ***********************************************************************/
  136. static VoidPtr GetObjectPtr(Word objectID)
  137.     {
  138.     FormPtr frmP;
  139.  
  140.  
  141.     frmP = FrmGetActiveForm();
  142.     return (FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID)));
  143. }
  144.  
  145.  
  146. /***********************************************************************
  147.  *
  148.  * FUNCTION:    MainFormInit
  149.  *
  150.  * DESCRIPTION: This routine initializes the MainForm form.
  151.  *
  152.  * PARAMETERS:  frm - pointer to the MainForm form.
  153.  *
  154.  * RETURNED:    nothing
  155.  *
  156.  * REVISION HISTORY:
  157.  *
  158.  *
  159.  ***********************************************************************/
  160. static void MainFormInit(FormPtr frmP)
  161. {
  162. }
  163.  
  164.  
  165. /***********************************************************************
  166.  *
  167.  * FUNCTION:    MainFormDoCommand
  168.  *
  169.  * DESCRIPTION: This routine performs the menu command specified.
  170.  *
  171.  * PARAMETERS:  command  - menu item id
  172.  *
  173.  * RETURNED:    nothing
  174.  *
  175.  * REVISION HISTORY:
  176.  *
  177.  *
  178.  ***********************************************************************/
  179. static Boolean MainFormDoCommand(Word command)
  180. {
  181.     Boolean handled = false;
  182.  
  183.     return handled;
  184. }
  185.  
  186.  
  187. /*
  188.    MainFormButtonHandler:
  189.    Handle a command sent to the main form.
  190.    Parms:   formP    - form handling event.
  191.             eventP   - event to be handled.
  192.    Return:  true  - handled (successfully or not)
  193.             false - not handled
  194. */
  195. Boolean
  196. MainFormButtonHandler (FormPtr formP, EventPtr eventP)
  197. {
  198.    Boolean handled = false;
  199.    switch (eventP->data.ctlEnter.controlID)
  200.    {
  201.       case MainGoButton:
  202.          DoPrintDemo(formP);
  203.          handled = true;
  204.          break;
  205.       default: 
  206.       {
  207.          handled = false;
  208.          break;
  209.       }
  210.    }
  211.    return handled;
  212. }
  213.  
  214.  
  215.  
  216.  
  217. /***********************************************************************
  218.  *
  219.  * FUNCTION:    MainFormHandleEvent
  220.  *
  221.  * DESCRIPTION: This routine is the event handler for the 
  222.  *              "MainForm" of this application.
  223.  *
  224.  * PARAMETERS:  eventP  - a pointer to an EventType structure
  225.  *
  226.  * RETURNED:    true if the event has handle and should not be passed
  227.  *              to a higher level handler.
  228.  *
  229.  * REVISION HISTORY:
  230.  *
  231.  *
  232.  ***********************************************************************/
  233. static Boolean MainFormHandleEvent(EventPtr eventP)
  234. {
  235.     Boolean handled = false;
  236.     FormPtr formP;
  237.  
  238.  
  239.     switch (eventP->eType) 
  240.         {
  241.         case menuEvent:
  242.             return MainFormDoCommand(eventP->data.menu.itemID);
  243.  
  244.       case ctlSelectEvent:
  245.          // A control button was tapped and released
  246.          formP = FrmGetActiveForm ();
  247.          handled = MainFormButtonHandler (formP, eventP);
  248.          break;
  249.  
  250.         case frmOpenEvent:
  251.             formP = FrmGetActiveForm();
  252.             MainFormInit( formP);
  253.             FrmDrawForm ( formP);
  254.             handled = true;
  255.             break;
  256.  
  257.         default:
  258.             break;
  259.         
  260.         }
  261.     
  262.     return handled;
  263. }
  264.  
  265.  
  266. /***********************************************************************
  267.  *
  268.  * FUNCTION:    AppHandleEvent
  269.  *
  270.  * DESCRIPTION: This routine loads form resources and set the event
  271.  *              handler for the form loaded.
  272.  *
  273.  * PARAMETERS:  event  - a pointer to an EventType structure
  274.  *
  275.  * RETURNED:    true if the event has handle and should not be passed
  276.  *              to a higher level handler.
  277.  *
  278.  * REVISION HISTORY:
  279.  *
  280.  *
  281.  ***********************************************************************/
  282. static Boolean AppHandleEvent( EventPtr eventP)
  283. {
  284.     Word formId;
  285.     FormPtr frmP;
  286.  
  287.  
  288.     if (eventP->eType == frmLoadEvent)
  289.         {
  290.         // Load the form resource.
  291.         formId = eventP->data.frmLoad.formID;
  292.         frmP = FrmInitForm(formId);
  293.         FrmSetActiveForm(frmP);
  294.  
  295.         // Set the event handler for the form.  The handler of the currently
  296.         // active form is called by FrmHandleEvent each time is receives an
  297.         // event.
  298.         switch (formId)
  299.             {
  300.             case MainForm:
  301.                 FrmSetEventHandler(frmP, MainFormHandleEvent);
  302.                 break;
  303.  
  304.             default:
  305. //                ErrFatalDisplay("Invalid Form Load Event");
  306.                 break;
  307.  
  308.             }
  309.         return true;
  310.         }
  311.     
  312.     return false;
  313. }
  314.  
  315.  
  316. /***********************************************************************
  317.  *
  318.  * FUNCTION:    AppEventLoop
  319.  *
  320.  * DESCRIPTION: This routine is the event loop for the application.  
  321.  *
  322.  * PARAMETERS:  nothing
  323.  *
  324.  * RETURNED:    nothing
  325.  *
  326.  * REVISION HISTORY:
  327.  *
  328.  *
  329.  ***********************************************************************/
  330. static void AppEventLoop(void)
  331. {
  332.     Word error;
  333.     EventType event;
  334.  
  335.  
  336.     do {
  337.         EvtGetEvent(&event, evtWaitForever);
  338.         
  339.         
  340.         if (! SysHandleEvent(&event))
  341.             if (! MenuHandleEvent(0, &event, &error))
  342.                 if (! AppHandleEvent(&event))
  343.                     FrmDispatchEvent(&event);
  344.  
  345.     } while (event.eType != appStopEvent);
  346. }
  347.  
  348.  
  349. /***********************************************************************
  350.  *
  351.  * FUNCTION:     AppStart
  352.  *
  353.  * DESCRIPTION:  Get the current application's preferences.
  354.  *
  355.  * PARAMETERS:   nothing
  356.  *
  357.  * RETURNED:     Err value 0 if nothing went wrong
  358.  *
  359.  * REVISION HISTORY:
  360.  *
  361.  *
  362.  ***********************************************************************/
  363. static Err AppStart(void)
  364. {
  365.     StarterPreferenceType prefs;
  366.     Word prefsSize;
  367.  
  368.  
  369.     // Read the saved preferences / saved-state information.
  370.     prefsSize = sizeof(StarterPreferenceType);
  371.     if (PrefGetAppPreferences(appFileCreator, appPrefID, &prefs, &prefsSize, true) != 
  372.         noPreferenceFound)
  373.         {
  374.         }
  375.     
  376.    return 0;
  377. }
  378.  
  379.  
  380. /***********************************************************************
  381.  *
  382.  * FUNCTION:    AppStop
  383.  *
  384.  * DESCRIPTION: Save the current state of the application.
  385.  *
  386.  * PARAMETERS:  nothing
  387.  *
  388.  * RETURNED:    nothing
  389.  *
  390.  * REVISION HISTORY:
  391.  *
  392.  *
  393.  ***********************************************************************/
  394. static void AppStop(void)
  395. {
  396.    StarterPreferenceType prefs;
  397.    
  398.    
  399.     // Write the saved preferences / saved-state information.  This data 
  400.     // will be backed up during a HotSync.
  401.     PrefSetAppPreferences (appFileCreator, appPrefID, appPrefVersionNum, 
  402.         &prefs, sizeof (prefs), true);
  403. }
  404.  
  405.  
  406.  
  407. /***********************************************************************
  408.  *
  409.  * FUNCTION:    StarterPilotMain
  410.  *
  411.  * DESCRIPTION: This is the main entry point for the application.
  412.  * PARAMETERS:  cmd - word value specifying the launch code. 
  413.  *              cmdPB - pointer to a structure that is associated with the launch code. 
  414.  *              launchFlags -  word value providing extra information about the launch.
  415.  *
  416.  * RETURNED:    Result of launch
  417.  *
  418.  * REVISION HISTORY:
  419.  *
  420.  *
  421.  ***********************************************************************/
  422. static DWord StarterPilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
  423. {
  424.     Err error;
  425.  
  426.  
  427.     error = RomVersionCompatible (ourMinVersion, launchFlags);
  428.     if (error) return (error);
  429.  
  430.  
  431.     switch (cmd)
  432.         {
  433.         case sysAppLaunchCmdNormalLaunch:
  434.             error = AppStart();
  435.             if (error) 
  436.                 return error;
  437.                 
  438.             FrmGotoForm(MainForm);
  439.             AppEventLoop();
  440.             AppStop();
  441.             break;
  442.  
  443.         default:
  444.             break;
  445.  
  446.         }
  447.     
  448.     return 0;
  449. }
  450.  
  451.  
  452. /***********************************************************************
  453.  *
  454.  * FUNCTION:    PilotMain
  455.  *
  456.  * DESCRIPTION: This is the main entry point for the application.
  457.  *
  458.  * PARAMETERS:  cmd - word value specifying the launch code. 
  459.  *              cmdPB - pointer to a structure that is associated with the launch code. 
  460.  *              launchFlags -  word value providing extra information about the launch.
  461.  * RETURNED:    Result of launch
  462.  *
  463.  * REVISION HISTORY:
  464.  *
  465.  *
  466.  ***********************************************************************/
  467. DWord PilotMain( Word cmd, Ptr cmdPBP, Word launchFlags)
  468. {
  469.     return StarterPilotMain(cmd, cmdPBP, launchFlags);
  470. }
  471.  
  472.  
  473. UInt refNum = 0;
  474.  
  475. void DoText(UInt refNum)
  476. {
  477.    Char buf[100];
  478.    VoidHand bitmapH;
  479.    BitmapPtr pbmp;
  480.    PrnFontType font;
  481.  
  482.  
  483.    StrCopy (font.typeface, "CourierNew10"); 
  484.    font.height = 10;
  485.    font.bold = true;
  486.    font.italics = false;
  487.    PrnSetFont (refNum, &font);
  488.  
  489.  
  490.    StrPrintF(buf,"What is Bachmann Print Manager?");
  491.    PrnDrawChars(refNum,buf,StrLen(buf),400,40); 
  492. //   font.bold = false;
  493. //   PrnSetFont (refNum, &font);
  494.    StrPrintF(buf,"Most computing platforms include printing support right out of the box.");
  495.    PrnDrawChars(refNum,buf,StrLen(buf),10,80); 
  496.    StrPrintF(buf,"But Palm Computing elected not to include a printing subsystem in their operating");
  497.    PrnDrawChars(refNum,buf,StrLen(buf),10,120); 
  498.    StrPrintF(buf,"system. So although Palm OS based devices include both a serial and infrared port");
  499.    PrnDrawChars(refNum,buf,StrLen(buf),10,160); 
  500.    StrPrintF(buf,"for communications, they cannot produce printed output. ");
  501.    PrnDrawChars(refNum,buf,StrLen(buf),10,200); 
  502.    StrPrintF(buf,"We designed Bachmann Print Manager as the \"missing\" printing subsystem that Palm");
  503.    PrnDrawChars(refNum,buf,StrLen(buf),10,270); 
  504.    StrPrintF(buf,"\"forgot\" to put in their product. Like the Palm's infrared library, serial");
  505.    PrnDrawChars(refNum,buf,StrLen(buf),10,320); 
  506.    StrPrintF(buf,"library and network library, Bachmann Print Manager is a standard Palm OS");
  507.    PrnDrawChars(refNum,buf,StrLen(buf),10,360); 
  508.    StrPrintF(buf,"Shared Library, so it is easily and tightly integrated with any Palm Pilot");
  509.    PrnDrawChars(refNum,buf,StrLen(buf),10,400); 
  510.    StrPrintF(buf,"application.  Bachmann Print Manager gives Palm Computing Platform application");
  511.    PrnDrawChars(refNum,buf,StrLen(buf),10,440); 
  512.    StrPrintF(buf,"developers the power to create stunning printed output directly from their Palm");
  513.    PrnDrawChars(refNum,buf,StrLen(buf),10,480); 
  514.    StrPrintF(buf,"Pilot application.");
  515.    PrnDrawChars(refNum,buf,StrLen(buf),10,520);
  516.    StrPrintF(buf,"Now, with Bachmann Print Manager, you can print any information from your Palm");
  517.    PrnDrawChars(refNum,buf,StrLen(buf),10,620); 
  518.    StrPrintF(buf,"Connected Organizer, using either a serial or infrared connection to popular");
  519.    PrnDrawChars(refNum,buf,StrLen(buf),10,660); 
  520.    StrPrintF(buf,"portable, standalone or networked printers.  There is no longer any need to");
  521.    PrnDrawChars(refNum,buf,StrLen(buf),10,700); 
  522.  
  523.    StrPrintF(buf,"synchronize data back to the desktop in order to create printed output that is");
  524.    PrnDrawChars(refNum,buf,StrLen(buf),10,740); 
  525.    StrPrintF(buf,"of the caliber you would expect from a Windows application.");
  526.    PrnDrawChars(refNum,buf,StrLen(buf),10,800); 
  527.  
  528. //   font.bold = true;
  529.    font.italics = true;
  530.    PrnSetFont (refNum, &font);
  531.  
  532.    StrPrintF(buf,"Visit us at Bachmannsoftware.com and PalmSource.");
  533.    PrnDrawChars(refNum,buf,StrLen(buf),10,1000); 
  534.  
  535.    bitmapH = DmGetResource(bitmapRsc,1600);
  536.    if (bitmapH != 0)
  537.    {
  538.       pbmp = (BitmapPtr) MemHandleLock(bitmapH);
  539.       if (pbmp != NULL)
  540.       {
  541.          PrnDrawBitmap(refNum,pbmp,1100,35);
  542.          MemHandleUnlock(bitmapH);
  543.       }
  544.       DmReleaseResource(bitmapH);
  545.    }
  546. }
  547.  
  548.  
  549. void DoPrintDemo(FormPtr formP)
  550. {
  551.    Word index = FrmGetObjectIndex (formP, MainDemoList);
  552.    ListPtr listP = (ListPtr) FrmGetObjectPtr (formP, index);
  553.    Word wDemo;
  554.    Err err;
  555.    Char buf[100];
  556.    RectangleType r;
  557.    VoidHand bitmapH;
  558.    BitmapPtr pbmp;
  559.    PrnFontType font;
  560.  
  561.    wDemo = LstGetSelection(listP);
  562.    if (wDemo == -1) return;
  563.  
  564.    err = SysLibLoad (printMgrTypeID, printMgrCreatorID, &refNum);
  565.    // Check result of loading library.
  566.    if (err)
  567.    {
  568.       // Print Manager failed to load successfully.
  569.       FrmCustomAlert(ErrorAlert,"Failed to Load PrintMgr.\nPlease Verify PrintMgr Installation.","","");
  570.       return;
  571.    }
  572.    
  573.  
  574.  
  575.    switch (wDemo)
  576.    {
  577.       case 0:
  578.          err = PrnOpen (refNum, "Pentax", "Serial");
  579.          if (err)
  580.          {
  581.             StrPrintF(buf,"Failed to Open PrintMgr (%d).",err);
  582.             FrmCustomAlert(ErrorAlert,buf,"","");
  583.             SysLibRemove (refNum);
  584.             return;
  585.          }
  586.  
  587.          // do graphics
  588.          PrnSetOrientation (refNum, prnOrientPortrait);
  589.  
  590.          StrCopy (font.typeface, "Courier New"); 
  591.          font.height = 10;
  592.          font.bold = true;
  593.          font.italics = false;
  594.          PrnSetFont (refNum, &font);
  595.          StrPrintF(buf,"Bachmann Print Manager");
  596.          PrnDrawChars(refNum,buf,StrLen(buf),200,40); 
  597.          PrnDrawChars(refNum,buf,StrLen(buf),900,40); 
  598.  
  599.          // draw some line - art !
  600.          r.topLeft.x = 120;
  601.          r.topLeft.y = 10;
  602.          r.extent.x = 590;
  603.          r.extent.y = 850;
  604.          PrnDrawRectangle(refNum,&r,0);
  605.          r.topLeft.x = 820;
  606.          PrnDrawRectangle(refNum,&r,0);
  607.  
  608.          r.topLeft.x = 200;
  609.          r.topLeft.y = 80;
  610.          r.extent.x = 425;
  611.          r.extent.y = 650;
  612.          PrnDrawRectangle(refNum,&r,0);
  613.          r.topLeft.x = 900;
  614.          PrnDrawRectangle(refNum,&r,0);
  615.  
  616.  
  617.          r.topLeft.x = 300;
  618.          r.topLeft.y = 575;
  619.          r.extent.x = 225;
  620.          r.extent.y = 153;
  621.          PrnDrawRectangle(refNum,&r,0);
  622.          r.topLeft.x = 1000;
  623.          PrnDrawRectangle(refNum,&r,0);
  624.  
  625.          r.topLeft.x = 200;
  626.          r.topLeft.y = 572;
  627.          r.extent.x = 425;
  628.          r.extent.y = 0;
  629.          PrnDrawRectangle(refNum,&r,0);
  630.          r.topLeft.x = 900;
  631.          PrnDrawRectangle(refNum,&r,0);
  632.  
  633.  
  634.  
  635.          bitmapH = DmGetResource(bitmapRsc,1000);
  636.          if (bitmapH != 0)
  637.          {
  638.             pbmp = (BitmapPtr) MemHandleLock(bitmapH);
  639.             if (pbmp != NULL)
  640.             {
  641.                PrnDrawBitmap(refNum,pbmp,230,610);
  642.                PrnDrawBitmap(refNum,pbmp,930,610);
  643.                PrnDrawBitmap(refNum,pbmp,230,665);
  644.                PrnDrawBitmap(refNum,pbmp,930,665);
  645.                PrnDrawBitmap(refNum,pbmp,550,610);
  646.                PrnDrawBitmap(refNum,pbmp,1250,610);
  647.                PrnDrawBitmap(refNum,pbmp,550,665);
  648.                PrnDrawBitmap(refNum,pbmp,1250,665);
  649.  
  650.                PrnDrawBitmap(refNum,pbmp,185,800);
  651.                PrnDrawBitmap(refNum,pbmp,885,800);
  652.                PrnDrawBitmap(refNum,pbmp,320,800);
  653.                PrnDrawBitmap(refNum,pbmp,1020,800);
  654.                PrnDrawBitmap(refNum,pbmp,455,800);
  655.                PrnDrawBitmap(refNum,pbmp,1155,800);
  656.                PrnDrawBitmap(refNum,pbmp,590,800);
  657.                PrnDrawBitmap(refNum,pbmp,1290,800);
  658.                MemHandleUnlock(bitmapH);
  659.             }
  660.             DmReleaseResource(bitmapH);
  661.          }
  662.  
  663.          bitmapH = DmGetResource(bitmapRsc,1600);
  664.          if (bitmapH != 0)
  665.          {
  666.             pbmp = (BitmapPtr) MemHandleLock(bitmapH);
  667.             if (pbmp != NULL)
  668.             {
  669.                PrnDrawBitmap(refNum,pbmp,210,100);
  670.                PrnDrawBitmap(refNum,pbmp,910,100);
  671.                PrnDrawBitmap(refNum,pbmp,210,200);
  672.                PrnDrawBitmap(refNum,pbmp,910,200);
  673.                PrnDrawBitmap(refNum,pbmp,210,300);
  674.                PrnDrawBitmap(refNum,pbmp,910,300);
  675.                PrnDrawBitmap(refNum,pbmp,210,400); 
  676.                PrnDrawBitmap(refNum,pbmp,910,400); 
  677.                PrnDrawBitmap(refNum,pbmp,210,500); 
  678.                PrnDrawBitmap(refNum,pbmp,910,500); 
  679.  
  680.  
  681.                PrnDrawBitmap(refNum,pbmp,540,100);
  682.                PrnDrawBitmap(refNum,pbmp,1240,100);
  683.                PrnDrawBitmap(refNum,pbmp,540,200);
  684.                PrnDrawBitmap(refNum,pbmp,1240,200);
  685.                PrnDrawBitmap(refNum,pbmp,540,300);
  686.                PrnDrawBitmap(refNum,pbmp,1240,300);
  687.                PrnDrawBitmap(refNum,pbmp,540,400); 
  688.                PrnDrawBitmap(refNum,pbmp,1240,400); 
  689.                PrnDrawBitmap(refNum,pbmp,540,500); 
  690.                PrnDrawBitmap(refNum,pbmp,1240,500); 
  691.  
  692.                MemHandleUnlock(bitmapH);
  693.             }
  694.             DmReleaseResource(bitmapH);
  695.          }
  696.  
  697.  
  698.          StrPrintF(buf,"www.bachmannsoftware.com");
  699.          PrnDrawChars(refNum,buf,StrLen(buf),185,915); 
  700.          PrnDrawChars(refNum,buf,StrLen(buf),885,915); 
  701.  
  702.          PrnNewPage(refNum);
  703. /*         FrmCustomAlert(ErrorAlert,"NewPage","","");
  704.          DoText(refNum);
  705.          PrnNewPage(refNum);
  706. */
  707.          break;
  708.       case 99:
  709.          err = PrnOpen (refNum, "Pentax", "Infrared");
  710.          if (err)
  711.          {
  712.             StrPrintF(buf,"Failed to Open PrintMgr (%d).",err);
  713.             FrmCustomAlert(ErrorAlert,buf,"","");
  714.             SysLibRemove (refNum);
  715.             return;
  716.          }
  717.  
  718.          // do graphics
  719.          PrnSetOrientation (refNum, prnOrientPortrait);
  720.  
  721.          StrCopy (font.typeface, "Courier New"); 
  722.          font.height = 10;
  723.          font.bold = true;
  724.          font.italics = false;
  725.          PrnSetFont (refNum, &font);
  726.          StrPrintF(buf,"Bachmann Print Manager");
  727.          PrnDrawChars(refNum,buf,StrLen(buf),500,40); 
  728.  
  729.          // draw some line - art !
  730.          r.topLeft.x = 420;
  731.          r.topLeft.y = 10;
  732.          r.extent.x = 590;
  733.          r.extent.y = 850;
  734.          PrnDrawRectangle(refNum,&r,0);
  735.  
  736.          r.topLeft.x = 500;
  737.          r.topLeft.y = 80;
  738.          r.extent.x = 425;
  739.          r.extent.y = 650;
  740.          PrnDrawRectangle(refNum,&r,0);
  741.  
  742.  
  743.          r.topLeft.x = 600;
  744.          r.topLeft.y = 575;
  745.          r.extent.x = 225;
  746.          r.extent.y = 153;
  747.          PrnDrawRectangle(refNum,&r,0);
  748.  
  749.          r.topLeft.x = 500;
  750.          r.topLeft.y = 572;
  751.          r.extent.x = 425;
  752.          r.extent.y = 0;
  753.          PrnDrawRectangle(refNum,&r,0);
  754.  
  755.  
  756.  
  757.          bitmapH = DmGetResource(bitmapRsc,1600);
  758.          if (bitmapH != 0)
  759.          {
  760.             pbmp = (BitmapPtr) MemHandleLock(bitmapH);
  761.             if (pbmp != NULL)
  762.             {
  763.                PrnDrawBitmap(refNum,pbmp,510,610);
  764.                PrnDrawBitmap(refNum,pbmp,510,665);
  765.                PrnDrawBitmap(refNum,pbmp,850,610);
  766.                PrnDrawBitmap(refNum,pbmp,850,665);
  767.  
  768.                PrnDrawBitmap(refNum,pbmp,485,800);
  769.                PrnDrawBitmap(refNum,pbmp,620,800);
  770.                PrnDrawBitmap(refNum,pbmp,755,800);
  771.                PrnDrawBitmap(refNum,pbmp,890,800);
  772.                MemHandleUnlock(bitmapH);
  773.             }
  774.             DmReleaseResource(bitmapH);
  775.          }
  776.  
  777.          StrPrintF(buf,"www.bachmannsoftware.com");
  778.          PrnDrawChars(refNum,buf,StrLen(buf),485,915); 
  779.          PrnNewPage(refNum);
  780.  
  781.  
  782.          break;
  783.       case 1:
  784.          err = PrnOpen (refNum, "Pentax", "Serial");
  785.          if (err)
  786.          {
  787.             StrPrintF(buf,"Failed to Open PrintMgr (%d).",err);
  788.             FrmCustomAlert(ErrorAlert,buf,"","");
  789.             SysLibRemove (refNum);
  790.             return;
  791.          }
  792.  
  793.          // portrait text
  794.          PrnSetOrientation (refNum, prnOrientPortrait);
  795.          DoText(refNum);
  796.          PrnNewPage(refNum);
  797.   
  798.         break;
  799.       case 2:
  800.          err = PrnOpen (refNum, "Pentax", "Serial");
  801.          if (err)
  802.          {
  803.             StrPrintF(buf,"Failed to Open PrintMgr (%d).",err);
  804.             FrmCustomAlert(ErrorAlert,buf,"","");
  805.             SysLibRemove (refNum);
  806.             return;
  807.          }
  808.          // landscape text
  809.          PrnSetOrientation (refNum, prnOrientLandscape);
  810.          DoText(refNum);
  811.          PrnNewPage(refNum);
  812.          break;
  813.    }
  814.    PrnClose(refNum);
  815.    SysLibRemove (refNum);
  816.    FrmCustomAlert(ErrorAlert,"Done.","","");
  817.    return;
  818. }