home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / chip / tvgencpp / demo3cpp.exe / EXAMPLE / SOURCE / INSTAL.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-06  |  5.4 KB  |  226 lines

  1. #define Uses_TApplication
  2. #define Uses_TMenuBar
  3. #define Uses_TMenu
  4. #define Uses_TMenuItem
  5. #define Uses_TSubMenu
  6. #define Uses_TStatusLine
  7. #define Uses_THintStatusLine
  8. #define Uses_TStatusDef
  9. #define Uses_TStatusItem
  10. #define Uses_TKeys
  11. #define Uses_TEvent
  12. #define Uses_TDeskTop
  13. #define Uses_TCollection
  14. #define Uses_THint
  15. #define Uses_MsgBox
  16. #define Uses_TPalette
  17. #define Uses_fpstream
  18.  
  19. #if __BORLANDC__ < 0x452 && !defined(__WIN32__)
  20. #include <help.h>
  21. #else
  22. #include <tvision\help.h>
  23. #endif
  24.  
  25. #include <string.h>
  26.  
  27. #include "INSTAL_H.H"
  28. #include "INSTAL_C.H"
  29. #include "INSTAL_D.H"
  30.  
  31. #include "supply.h"
  32.  
  33. char **argv;
  34.  
  35.      class TMyApp : public TApplication
  36.        {
  37.         static THint *Hints[300];
  38.  
  39.         public:
  40.         TMyApp();
  41.         void additionalInit();
  42.         void additionalDone();
  43.         void handleEvent(TEvent &event);
  44.         static TStatusLine *initStatusLine(TRect r);
  45.         static TMenuBar *initMenuBar(TRect r);
  46.         void getEvent(TEvent &event);
  47.         TPalette &getPalette() const;
  48.         void CallInstaluj();
  49.         void CallAboutBox();
  50.       };
  51.  
  52. THint *TMyApp::Hints[300];
  53.  
  54.  
  55.  
  56. TStatusLine *TMyApp::initStatusLine(TRect r)
  57. {
  58.   r.a.y=r.b.y-1;
  59.  
  60.   TStatusDef &def1 = *new TStatusDef(hc_M_Instalace,hc_M_Instalace_Oproduktu)+
  61.    *new TStatusItem("~F1~ Pomoc",kbF1,cmHelp)+    
  62.    *new TStatusItem("~Alt-X~ Konec",kbAltX,cmQuit);
  63.  
  64.   TStatusDef &def2 = *new TStatusDef(hc_D_AboutBox,hc_D_Instaluj+99)+
  65.    *new TStatusItem("~F1~ Pomoc",kbF1,cmHelp);
  66.  
  67.   TStatusDef &def3 = *new TStatusDef(hcNoContext,hcNoContext)+
  68.    *new TStatusItem("~Alt-X~ Konec",kbAltX,cmQuit)+    
  69.    *new TStatusItem("~F10~ Menu",kbF10,cmMenu);
  70.  
  71.   TStatusDef &def4 = *new TStatusDef(hcHelpWindowActive,hcHelpWindowActive)+
  72.    *new TStatusItem("~ESC~ Zav⌐i",kbEsc,cmClose)+    
  73.    *new TStatusItem("",kbF5,cmZoom);
  74.  
  75.   TStatusDef &def5 = *new TStatusDef(hcDragging,hcDragging)+
  76.    *new TStatusItem("Objekt je p⌐esouván...",kbNoKey,cmResize);
  77.  
  78.   return (new THintStatusLine(r,
  79.      def1
  80.    + def2
  81.    + def3
  82.    + def4
  83.    + def5, Hints));     
  84. }
  85.  
  86.  
  87. TMenuBar *TMyApp::initMenuBar(TRect r)
  88. {
  89.   r.b.y=r.a.y+1;
  90.   TMenuItem *top1 = new TMenuItem("~I~nstalace",kbNoKey, new TMenu(
  91.       *new TMenuItem("~O~ produktu...",cmAbout,kbNoKey,hc_M_Instalace_Oproduktu)+  
  92.       *new TMenuItem("~I~nstaluj",cmInstaluj,kbNoKey,hc_M_Instalace_Instaluj)+  
  93.       newLine()+  
  94.       *new TMenuItem("~K~onec",cmQuit,kbAltX,hc_M_Instalace_Konec,"Alt-X")
  95.   ),hc_M_Instalace);
  96.  
  97.  
  98.   return (new TMenuBar(r, new TMenu(
  99.      *top1)));
  100. }
  101.  
  102.  
  103.  
  104. void TMyApp::additionalInit()
  105. {
  106. #include "INSTAL_N.INC"
  107.   Hints[20]=NULL;
  108.  
  109. }
  110.  
  111. void TMyApp::additionalDone()
  112. {
  113.   int loop=0;
  114.  
  115.   while (Hints[loop]!=NULL) delete Hints[loop++];
  116. }
  117.  
  118. void TMyApp::getEvent(TEvent &event)
  119. {
  120.   TApplication::getEvent(event);
  121.  
  122.   if (event.what==evCommand && event.message.command==cmHelp)
  123.   {
  124.     TWindow *w;
  125.     THelpFile *hFile;
  126.     fpstream *helpStrm;
  127.     static Boolean helpInUse = False;
  128.  
  129.     char HelpFile[128];
  130.     strcpy(HelpFile,argv[0]);
  131.     while(HelpFile[strlen(HelpFile)-1]!='\\') HelpFile[strlen(HelpFile)-1]='\0';
  132.     strcat(HelpFile,"INSTAL.HLP");
  133.  
  134.     if (helpInUse == False)
  135.     {
  136.       helpInUse = True;
  137.       helpStrm = new fpstream(HelpFile, ios::in|ios::binary|ios::nocreate);
  138.       hFile = new THelpFile(*helpStrm);
  139.       if (!helpStrm)
  140.       {
  141.         messageBox("Nemohu otevrit soubor s napovedou", mfError | mfOKButton);
  142.         delete hFile;
  143.       }
  144.       else
  145.       {
  146.         w = new THelpWindow(hFile, getHelpCtx());
  147.         TRect r=w->getBounds();
  148.         r.grow(8,1);
  149.         w->changeBounds(r);
  150.         strcpy((char *) w->title,"Napoveda");
  151.         w->flags &= ~wfGrow & ~wfZoom;
  152.         w->helpCtx=hcHelpWindowActive;
  153.         if (validView(w)!=0) execView(w);
  154.         destroy(w);
  155.       }
  156.       helpInUse = False;
  157.     }
  158.     clearEvent(event);
  159.   }
  160. }
  161.  
  162. TPalette &TMyApp::getPalette() const
  163. {
  164. #if _TV_VERSION < 0x0200
  165.   static TPalette newcolor ( cpColor cHelpColor, sizeof( cpColor cHelpColor )-1 );
  166.   static TPalette newblackwhite( cpBlackWhite cHelpBlackWhite, sizeof( cpBlackWhite cHelpBlackWhite)-1 );
  167.   static TPalette newmonochrome( cpMonochrome cHelpMonochrome, sizeof( cpMonochrome cHelpMonochrome)-1 );
  168.   static TPalette *palettes[] =  {&newcolor, &newblackwhite, &newmonochrome};
  169.  
  170.   return *(palettes[appPalette]);
  171. #else
  172.   return TApplication::getPalette();
  173. #endif
  174. }
  175.  
  176. TMyApp::TMyApp() : TProgInit(&TMyApp::initStatusLine,
  177.                                      &TMyApp::initMenuBar,
  178.                                      &TMyApp::initDeskTop)
  179. {
  180.   Result = AboutBox();
  181. }
  182.  
  183. void TMyApp::handleEvent(TEvent &event)
  184. {
  185.   TApplication::handleEvent(event);
  186.   if (event.what == evCommand) 
  187.     {
  188.       switch (event.message.command) 
  189.          {
  190.           case cmInstaluj                : CallInstaluj(); break;
  191.           case cmAbout                   : CallAboutBox(); break;
  192.           default : return;
  193.         }
  194.       }
  195.     clearEvent(event); 
  196. }
  197.  
  198.  
  199.  
  200.  
  201. void TMyApp::CallInstaluj()
  202. {
  203.     TInstalujData D;
  204.     ushort Result = Instaluj(D,False);
  205. }
  206.  
  207. void TMyApp::CallAboutBox()
  208. {
  209.     ushort Result = AboutBox();
  210. }
  211.  
  212. #pragma -wpar
  213.  
  214. void main(int argc, char *argv[])
  215. {
  216.   ::argv=argv;
  217.  
  218.   TMyApp AppInstance;
  219.  
  220.   AppInstance.additionalInit();
  221.   AppInstance.run();
  222.   AppInstance.additionalDone();
  223. }
  224.  
  225. // ************ Generated by TVGen 3.0 **************
  226.