home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / vide / vrundlg.cpp < prev    next >
C/C++ Source or Header  |  1998-10-05  |  4KB  |  129 lines

  1. //===============================================================
  2. // vrundlg.cpp - vRunDialog class functions - 
  3. //
  4. // Copyright (C) 1998 Bruce E. Wampler
  5. //
  6. // This file is part of the V C++ GUI Framework, and is covered
  7. // under the terms of the GNU Library General Public License,
  8. // Version 2. This library has NO WARRANTY. See the source file
  9. // vapp.cxx for more complete information about license terms.
  10. //===============================================================
  11.  
  12. #include "vrundlg.h"           // our header
  13. #include <v/vos.h>
  14. #include <v/vicon.h>           // for icon
  15. #include <v/vfilesel.h>
  16.  
  17. // Define static data of the class
  18.  
  19. #define prompt_width 32
  20. #define prompt_height 32
  21. static unsigned char prompt_bits[] = {
  22.    0x00, 0x00, 0x00, 0x00, 0xf8, 0xff, 0xff, 0x1f, 0x04, 0x00, 0x00, 0x20,
  23.    0xe4, 0xff, 0xff, 0x27, 0x14, 0x00, 0x00, 0x28, 0x14, 0xc0, 0x01, 0x28,
  24.    0x14, 0xe0, 0x03, 0x28, 0x14, 0x30, 0x06, 0x28, 0x14, 0x30, 0x06, 0x28,
  25.    0x14, 0x00, 0x03, 0x28, 0x14, 0x80, 0x01, 0x28, 0x14, 0xc0, 0x00, 0x28,
  26.    0x14, 0xc0, 0x00, 0x28, 0x14, 0xc0, 0x00, 0x28, 0x14, 0xc0, 0x00, 0x28,
  27.    0x14, 0x00, 0x00, 0x28, 0x14, 0xc0, 0x00, 0x28, 0x14, 0x00, 0x00, 0x28,
  28.    0xe4, 0xff, 0xff, 0x27, 0x04, 0x00, 0x00, 0x20, 0xf8, 0xff, 0xff, 0x1f,
  29.    0xfe, 0xff, 0xff, 0x7f, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40,
  30.    0x02, 0x00, 0xe0, 0x47, 0x02, 0x00, 0x00, 0x40, 0xfa, 0xff, 0xff, 0x5f,
  31.    0xae, 0xaa, 0xaa, 0x6a, 0x56, 0x55, 0x55, 0x55, 0xaa, 0xaa, 0xaa, 0x6a,
  32.    0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
  33.  
  34.     static vIcon prompt(&prompt_bits[0], prompt_height, prompt_width);
  35.  
  36.     static CommandObject ReplyDialog[] =
  37.       {
  38.     // Modified: TEH Jan98
  39.     // Put icon + text in a frame so button is below frame.
  40.     // With many-line text displays, the button will always be below text.
  41.     // Also remove "Blanks" around buttons; not consistant with V look!
  42.     // Put OK button to left, and Cancel to right for proper style.
  43.     {C_Frame, 30, 0, "",
  44.         NoList, CA_NoSpace | CA_NoBorder, isSens, NoFrame, 0, 0},
  45.     {C_Icon,  10, 0, "Run?", (void*)&prompt, CA_None, isSens, 30, 0, 0},
  46.     {C_Label, 1, 1, "Enter name of program to run - ", NoList,
  47.         CA_None ,isSens, 30, 10,0},
  48.     {C_TextIn, 2, 2, "", NoList,
  49.         CA_Large, isSens, 30, 0, 10},
  50.         {C_Button, 3, 3, "Browse",
  51.         NoList, CA_None, isSens, NoFrame, 2, 10,0,"Use Dialog to select file"},
  52.     {C_Button, M_OK, M_OK, " OK ",
  53.         NoList, CA_DefaultButton, isSens, NoFrame, 0, 30},
  54.     {C_Button, M_Cancel, M_Cancel, " Cancel ",
  55.         NoList, CA_None, isSens, NoFrame, M_OK, 30},
  56.     {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  57.       };
  58.  
  59.     static int filterIndex = 0;
  60.     static char* filter[] =
  61.       {
  62.         "*",
  63.         0
  64.       };
  65.     static char runName[maxFileNameSize+2] = "";
  66.  
  67. //======================>>> vRunDialog::Run <<<=======================
  68.   int vRunDialog::Run(char *initialName)
  69.   {
  70.     //    Show a message, wait for a reply
  71.     //    no important return
  72.  
  73.     int ans;
  74.     char reply[maxFileNameSize+2];
  75.  
  76.     if (!added)
  77.       {
  78.     AddDialogCmds(ReplyDialog);        // Set up standard dialog
  79.     added = 1;
  80.       }
  81.  
  82.     if (!*runName && initialName && *initialName)
  83.     strcpy(runName,initialName);
  84.  
  85.     (void) ShowModalDialog("", ans);    // show and wait
  86.  
  87.     reply[0] = 0;
  88.  
  89.     if (ans != M_Cancel)
  90.       {
  91.     (void) GetTextIn(2, reply, maxFileNameSize);
  92.         vOS vos;
  93.         vos.vRunProcess(reply, 0, 0, 0);
  94.       }
  95.  
  96.     return ans;
  97.   }
  98.  
  99. //====================>>> vRunDialog::DialogDisplayed <<<=======================
  100.   void vRunDialog::DialogDisplayed()
  101.   {
  102.       SetString(2,runName);
  103.   }
  104.  
  105. //====================>>> vRunDialog::DialogCommand <<<=======================
  106.   void vRunDialog::DialogCommand(ItemVal id, ItemVal val, CmdType ctype)
  107.   {
  108.  
  109.     switch (id)
  110.       {
  111.         case 3:        // Browse
  112.           {
  113.             vFileSelect fsel(this);     // make an instance
  114.  
  115.             if (!fsel.FileSelect("Run Program",runName,maxFileNameSize,
  116.                      filter,filterIndex))
  117.               {
  118.                    return;
  119.               }
  120.             SetString(2,runName);
  121.             return;
  122.           }
  123.       }
  124.     vModalDialog::DialogCommand(id,val,ctype);
  125. //    if (id == M_OK || id == M_Cancel)
  126. //    CloseDialog();
  127.   }
  128. // --------------------------------------------------------------------- 
  129.