home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / tplab009.zip / tl_main.cpp < prev    next >
C/C++ Source or Header  |  1996-05-05  |  3KB  |  144 lines

  1. /* 
  2.  
  3.  
  4.     tl_main.cpp (emx+gcc) 
  5.     Tape Label Editor Version 0.09
  6.  
  7.     1995 1996 Giovanni Iachello
  8.     This is freeware software. You can use or modify it as you wish,
  9.     provided that the part of code that I wrote remains freeware.
  10.     Freeware means that the source code must be available on request 
  11.     to anyone.
  12.     You must also include this notice in all files derived from this
  13.     file.
  14.  
  15.  
  16. */
  17.  
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include <stdlib.h>
  21. #include <time.h>
  22. #include "tapelab.h"
  23. #include "pmstdres.h"
  24. #include "pmhelp.h"
  25.  
  26. PMApp* App;
  27.  
  28. PMHelpWin *helpwin;
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. //
  32. // this help hook services requests of help from message boxes.
  33. //
  34. //
  35.  
  36. BOOL helpHook ( HAB habAnchor, SHORT sMode, USHORT usTopic, USHORT usSubTopic, PRECTL prclPos )
  37. {
  38.     if ( (sMode == HLPM_WINDOW ) && 
  39.          helpwin && 
  40.          ( usTopic>=PMHLP_DLG_ERRMSG && usTopic<=PMHLP_DLG_ASSERTFAIL)
  41.        ) {
  42.         helpwin->sendMsg(HM_DISPLAY_HELP, 
  43.             MPFROMLONG (MAKELONG (usTopic, 0)), MPFROMSHORT( HM_RESOURCEID) );
  44.         return TRUE;
  45.     } 
  46.     return FALSE;
  47. }
  48.  
  49. ////////////////////////////////////////////////////////////////////////////
  50.  
  51. BOOL InfoDlg::command(USHORT id,USHORT cmddev) {
  52.     switch (id) {
  53.         case DINFO_PB_CURRDATE1:
  54.         case DINFO_PB_CURRDATE2:
  55.             char buf[64];
  56.             time_t t;
  57.             t=time(NULL);
  58.             strftime(buf,64,"%D",localtime(&t));
  59.             if (id == DINFO_PB_CURRDATE1) controlFromID(DINFO_EF_DATE1)->setText(buf);
  60.             else controlFromID(DINFO_EF_DATE2)->setText(buf);
  61.                  return TRUE;
  62.     } 
  63.     return PMModalDialog::command(id,cmddev);
  64. }
  65.  
  66. BOOL InfoDlg::initdlg()
  67. {
  68.     PMSpinButton* sp;
  69.     sp=(PMSpinButton*)controlFromID(DINFO_SB_SOURCE1);
  70.     sp->setArray(apchSources,5); sp->set();
  71.  
  72.     sp=(PMSpinButton*)controlFromID(DINFO_SB_SOURCE2);
  73.     sp->setArray(apchSources,5); sp->set();
  74.  
  75.     sp=(PMSpinButton*)controlFromID(DINFO_SB_NR1);
  76.     sp->setArray(apchNR,6); sp->set();
  77.  
  78.     sp=(PMSpinButton*)controlFromID(DINFO_SB_NR2);
  79.     sp->setArray(apchNR,6); sp->set();
  80.  
  81.     return TRUE;
  82. }
  83.  
  84. BOOL SizeDlg::initdlg()
  85. {
  86.     PMSpinButton* sp=(PMSpinButton*)controlFromID(DSIZE_SB_FLAPS);
  87.     sp->setLimits(4,2);
  88.     sp->set();
  89.     return TRUE;
  90. }
  91.  
  92. //////////////////////////////////////////////////////////////////////////////
  93.  
  94. void PMPrintLabelThread::main(void* arg=NULL) 
  95. {
  96.     PMPrinterDC printer(hab);
  97.     printer.open();
  98.     printer.startDoc(buf);
  99.  
  100.     PMPresSpace *prnps=new PMPresSpace(&printer,0,0,PU_LOMETRIC|GPIF_DEFAULT|GPIT_NORMAL|GPIA_ASSOC,hab);
  101.  
  102.     tl->paintlabel(*prnps);
  103.     delete prnps;
  104.     printer.endDoc(buf);
  105. }
  106.  
  107.  
  108. //////////////////////////////////////////////////////////////////////////////
  109.  
  110.  
  111. int main (int argc,char* argv[])
  112. {
  113.     char* file=NULL;
  114.     if (argc>1) file=argv[1];
  115.     
  116.     PMAnchorBlock ab;
  117.     PMMessageQueue mq;
  118.     ab.init();
  119.     mq.create(ab);
  120.     
  121.     App=new PMApp(ab,mq,argc,argv);
  122.  
  123.     helpwin=new PMHelpWin("Tape Label Editor Help","tapelab.hlp",ID_TAPELAB,ab);
  124.     helpwin->createWin();
  125.  
  126.     TapeLab * tl=new TapeLab(ab,file); // load also a file specified on the command line
  127.     tl->createWin();
  128.     
  129.     ab.setHook(mq,HK_HELP,(PFN)helpHook,NULLHANDLE);
  130.  
  131.     App->run();
  132.  
  133.     ab.releaseHook(mq,HK_HELP,(PFN)helpHook,NULLHANDLE);
  134.  
  135.     tl->destroyWin();
  136.  
  137.     mq.destroy();
  138.     ab.uninit();
  139.  
  140.     return (0);
  141. }
  142.  
  143.  
  144.