home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / test / vtcmdwin.cpp < prev    next >
C/C++ Source or Header  |  1999-01-07  |  43KB  |  1,384 lines

  1. //=======================================================================
  2. //  vtcmdwin.cxx - testCmdWindow class
  3. //  Copyright (C) 1995,1996, 1997, 1998  Bruce E. Wampler
  4. //
  5. //  This program is part of the V C++ GUI Framework example programs.
  6. //
  7. //  This program is free software; you can redistribute it and/or gmodify
  8. //  it under the terms of the GNU General Public License as published by
  9. //  the Free Software Foundation; either version 2 of the License, or
  10. //  (at your option) any later version.
  11. //
  12. //  This program is distributed in the hope that it will be useful,
  13. //  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. //  GNU General Public License for more details.
  16. //
  17. //  You should have received a copy of the GNU General Public License
  18. //  (see COPYING) along with this program; if not, write to the Free
  19. //  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20. //=======================================================================
  21.  
  22. //#define ALLTESTS    // for ugly list-in-a-command-bar test
  23.  
  24. #include <v/vcanvas.h>  // for Cursors
  25. #include <v/vcolor.h>
  26. #include <v/vicon.h>
  27. #include <v/vutil.h>
  28. #include <v/vfontsel.h>
  29. #include <v/vfont.h>
  30. #include <v/vprinter.h>
  31.  
  32. #include <v/vmemdc.h>
  33. #include <v/vkeys.h>
  34.  
  35. #include "vtcmdwin.h"
  36. #include "vtcw2.h"
  37.  
  38.     static char mess[] = "[A] Is this a good test of text?\n";
  39.     static char newMenu[] = "[A] test very much bigger menu width";
  40.     static int filterIndex = 0;
  41.     static char* filter[] =
  42.       {
  43.         "*",
  44.         "*.txt",
  45.         "*.c;*.cpp;*.cxx;*.h",
  46.         0
  47.       };
  48.  
  49. //vbm1
  50. #define copy_depth 1
  51. #define copy_width 28
  52. #define copy_height 12
  53. static unsigned char copy_bits[] = {
  54.  0xff,0xff,0xff,0xff,0x03,0x00,0xff,0xfd,0xfb,0x0f,0x09,0xfd,0x0b,0x08,0x19,
  55.  0xfd,0xcb,0xff,0x3f,0xfd,0xcb,0xff,0x7f,0xfd,0xcb,0xff,0x3f,0xfd,0x0b,0x08,
  56.  0x19,0xfd,0x0b,0x08,0x89,0xfd,0x0b,0x0c,0xff,0xfc,0xfb,0x07,0x00,0xfc,0xff,
  57.  0xff,0xff,0xff};
  58.  
  59.     static vIcon copyIcon(©_bits[0], copy_height, copy_width);
  60.  
  61. #define DRAW_BRUCE
  62. #ifdef DRAW_BRUCE
  63. #include "bruce.vbm"    // bruce picture bitmap
  64.     static vIcon bruceIcon(&bruce_bits[0], bruce_height, bruce_width,8);
  65. #endif
  66. #define color_width 16
  67. #define color_height 24
  68. static unsigned char color_bits[] = {
  69.         2,              // 3 colors (offset by 1)
  70.         255,0,0,        // 0 -> red
  71.         0,255,0,        // 1 -> green
  72.         0,0,255,        // 2 -> blue
  73.         // a rgb "flag", 3 16x8 rows of each color
  74.         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,        // RRRRRRRRRRRRRRRR
  75.         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,        // RRRRRRRRRRRRRRRR
  76.         0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,        // RRRRRRRRRRBBBBBR
  77.         0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,        // RRRRRRRRRRBBBBBR
  78.         0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,        // RRRRRRRRRRBBBBBR
  79.         0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,        // RRRRRRRRRRBBBBBR
  80.         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,        // RRRRRRRRRRRRRRRR
  81.         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,        // RRRRRRRRRRRRRRRR
  82.         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,        // GGGGGGGGGGGGGGGG
  83.         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,        // GGGGGGGGGGGGGGGG
  84.         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,        // GGGGGGGGGGGGGGGG
  85.         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,        // GGGGGGGGGGGGGGGG
  86.         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,        // GGGGGGGGGGGGGGGG
  87.         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,        // GGGGGGGGGGGGGGGG
  88.         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,        // GGGGGGGGGGGGGGGG
  89.         1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,        // GGGGGGGGGGGGGGGG
  90.         2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,        // BBBBBBBBBBBBBBBB
  91.         2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,        // BBBBBBBBBBBBBBBB
  92.         2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,        // BBBBBBBBBBBBBBBB
  93.         2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,        // BBBBBBBBBBBBBBBB
  94.         2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,        // BBBBBBBBBBBBBBBB
  95.         2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,        // BBBBBBBBBBBBBBBB
  96.         2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,        // BBBBBBBBBBBBBBBB
  97.         2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2         // BBBBBBBBBBBBBBBB
  98.       };
  99.  
  100.     static vIcon colorIcon(&color_bits[0], color_height, color_width,8);
  101.  
  102. #define c24_height 15
  103. #define c24_width 8
  104.     static unsigned char c24_bits[] = {
  105.      255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, //RRRRRRRR
  106.      255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0,255,0,0,255,0, //RRRRRRGG
  107.      255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0,255,0,0,255,0, //RRRRRRGG
  108.      255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,0,255,0,0,255,0, //RRRRRRGG
  109.      255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0, //RRRRRRRR
  110.      0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0, //GGGGGGGG
  111.      0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0, //GGGGGGGG
  112.      0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0, //GGGGGGGG
  113.      0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0, //GGGGGGGG
  114.      0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0, //GGGGGGGG
  115.      0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, //BBBBBBBB
  116.      0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, //BBBBBBBB
  117.      0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, //BBBBBBBB
  118.      0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, //BBBBBBBB
  119.      0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255, //BBBBBBBB
  120.      0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255,0,0,255  //BBBBBBBB
  121.      };
  122.     static vIcon c24Icon(&c24_bits[0], c24_height, c24_width,24);
  123.  
  124.     int copy_sens = 0;
  125.  
  126.  
  127. //#########################################################################
  128.  
  129.     static char sub[] = "SubA";
  130.     static char title[] = "A Title(Σσ)";
  131.     static char blabel[] = "A Label(Σσ)";
  132.  
  133.   enum {
  134.  
  135.     M_SimpleWin = 10,
  136.     M_YNDialog,
  137.     M_Dialog,
  138.     M_CheckMe,
  139.     M_CopySens,
  140.     M_ShowList,
  141.     M_ChangeButton,
  142.     M_ModalDialog,
  143.     M_TextIn,
  144.     M_List,
  145.     M_Message,
  146.     m_new2,
  147.     M_ChgTitle,
  148.     M_ChgAppTitle,
  149.     M_Reply,
  150.     M_AttrMessage,
  151.     M_RevMessage,
  152.     M_CenterCursor,
  153.     M_SubMenu,
  154.     M_HideCursor,
  155.     M_ShowCursor,
  156.     m_ChangeCursor,
  157.     m_Hon,
  158.     m_Hoff,
  159.     m_Von,
  160.     m_Voff,
  161.     m_ScrollSub,
  162.     m_HideStat,
  163.     m_ShowStat,
  164.     m_HideCmd,
  165.     m_ShowCmd,
  166.     m_HideCnv,
  167.     m_ShowCnv,
  168.     m_font,
  169.     m_printTest,
  170.         m_printTestScaled,
  171.     M_DrawIcon,
  172.     M_Mem2Canvas,
  173.     M_ColorTest,
  174.     M_PointTest,
  175.     m_CopyAreaTest,
  176.     m_grow,
  177.     m_maketiny,
  178.     m_setBG,
  179.         m_changeMenu,
  180.         m_AngleText,
  181.  
  182.     M_Toggle,
  183.     m_togbtn,
  184.     m_togdlg,
  185.  
  186.     m_Timer,
  187.     m_CurTime,
  188.     m_Beep,
  189.     LAST_ENUM_CMD
  190.       };
  191.  
  192. //      Sample Menu Item Definition
  193. //      {"x", M_x, isSens, notChk, noKeyLbl, noKey, noSub},
  194.  
  195.     vMenu WindowSubMenu[] =
  196.       {
  197.         {"Center Cursor", M_CenterCursor,isSens, notChk, noKeyLbl, noKey, noSub},
  198.         {"Change Cursor", m_ChangeCursor,isSens, notChk, noKeyLbl, noKey, noSub},
  199.         {"Change Title", M_ChgTitle, isSens, notChk, noKeyLbl, noKey, noSub},
  200.         {"Change App Title", M_ChgAppTitle, isSens, notChk, noKeyLbl, noKey, noSub},
  201.         {"CheckMe", M_CheckMe, isSens, notChk, noKeyLbl, noKey, noSub},
  202.         {"Copy Sensitive", M_CopySens, isSens, notChk, noKeyLbl, noKey, noSub},
  203.         {"Hide Cursor", M_HideCursor,isSens, notChk, noKeyLbl, noKey, noSub},
  204.         {"Draw Icon",M_DrawIcon,isSens,notChk,noKeyLbl,noKey,noSub},
  205.         {"MemDC Point Test",M_PointTest,isSens,notChk,noKeyLbl,noKey,noSub},
  206.         {"MemDC to canvas",M_Mem2Canvas,isSens,notChk,noKeyLbl,noKey,noSub},
  207.         {"MemDC CopyArea test",m_CopyAreaTest,isSens,notChk,noKeyLbl,noKey,noSub},
  208.         {"Notice from vApp", 901, isSens, notChk, noKeyLbl, noKey, noSub},
  209.         {"Set BG color", m_setBG, isSens, notChk, "Ctrl-B", 'B'-'@', noSub},
  210.         {"Show Cursor", M_ShowCursor,isSens, notChk, noKeyLbl, noKey, noSub},
  211.         {"Show Window List", M_ShowList, isSens, notChk, noKeyLbl, noKey, noSub},
  212.         {"Shift Window",903, isSens, notChk, noKeyLbl, noKey, noSub},
  213.         {"Grow Canvas",m_grow,isSens, notChk, noKeyLbl, noKey, noSub},
  214.         {"Tiny Canvas",m_maketiny,isSens, notChk, noKeyLbl, noKey, noSub},
  215.         {"vWindow", M_SimpleWin, isSens, notChk, noKeyLbl, noKey, noSub},
  216.         {"Raise First Window", 902, isSens, notChk, noKeyLbl, noKey, noSub},
  217.         {"Timers off", 909, isSens, notChk, noKeyLbl, noKey, noSub},
  218.         {"Beep", m_Beep, isSens, notChk, noKeyLbl, noKey, noSub},
  219.     
  220.         {NULL}
  221.       };
  222.  
  223.     vMenu ScrollMenu[] =
  224.       {
  225.         {"Show HScroll", m_Hon, isSens, notChk, noKeyLbl, noKey, noSub},
  226.         {"Hide HScroll", m_Hoff, isSens, notChk, noKeyLbl, noKey, noSub},
  227.         {"Show VScroll", m_Von, isSens, notChk, noKeyLbl, noKey, noSub},
  228.         {"Hide VScroll", m_Voff, isSens, notChk, noKeyLbl, noKey, noSub},
  229.         {"Hide Status", m_HideStat, isSens, notChk, noKeyLbl, noKey, noSub},
  230.         {"Show Status", m_ShowStat, isSens, notChk, noKeyLbl, noKey, noSub},
  231.         {"Hide CmdBar", m_HideCmd, isSens, notChk, noKeyLbl, noKey, noSub},
  232.         {"Show CmdBar", m_ShowCmd, isSens, notChk, noKeyLbl, noKey, noSub},
  233.         {"Hide Canvas", m_HideCnv, isSens, notChk, noKeyLbl, noKey, noSub},
  234.         {"Show Canvas", m_ShowCnv, isSens, notChk, noKeyLbl, noKey, noSub},
  235.         {NULL}
  236.       };
  237.  
  238.     vMenu TestMenu[] =
  239.       {
  240.         {"Misc Tests", M_SubMenu, isSens, notChk, noKeyLbl, noKey, WindowSubMenu},
  241.         {"Hide/Show",m_ScrollSub, isSens,notChk,noKeyLbl,noKey, ScrollMenu},
  242.         {"Change menu",m_changeMenu, isSens,notChk,noKeyLbl,noKey, noSub},
  243.     {"&Dialog", M_Dialog, isSens, notChk, "Ctrl-D", 'D'-'@', noSub},
  244.     {"&Toggle Dialog", m_togdlg, isSens, notChk, noKeyLbl, noKey, noSub},
  245.         {"List", M_List, isSens, notChk, noKeyLbl, noKey, noSub},
  246.         {"Modal Dialog", M_ModalDialog, isSens, notChk, noKeyLbl, noKey, noSub},
  247.         {"Set Font", m_font, isSens, notChk,noKeyLbl, noKey, noSub},
  248.         {"Print Test", m_printTest, isSens, notChk, noKeyLbl, noKey, noSub},
  249.         {"Print Test Scaled", m_printTestScaled, isSens, notChk, noKeyLbl, noKey, noSub},
  250.         {"Text In", M_TextIn, isSens, notChk, noKeyLbl, noKey, noSub},
  251.         {"Reply", M_Reply, isSens, notChk, noKeyLbl, noKey, noSub},
  252.         {"YN Dialog", M_YNDialog, isSens, notChk, noKeyLbl, noKey, noSub},
  253.         {"CheckMe", M_CheckMe, isSens, notChk, noKeyLbl, noKey, noSub},
  254.         {"Test vCanvasPane", m_new2, isSens, notChk, noKeyLbl, noKey, noSub},
  255.         {NULL}
  256.       };
  257.  
  258.     vMenu FileMenu[] =
  259.       {
  260.         {"&New", M_New, isSens, notChk, noKeyLbl, noKey, noSub},
  261.         {"&Open", M_Open, isSens, notChk, noKeyLbl, noKey, noSub},
  262.         {"&Save", M_Save, notSens, notChk, noKeyLbl, noKey, noSub},
  263.     {"Save &As", M_SaveAs, isSens, notChk, noKeyLbl, noKey, noSub},
  264. #ifdef vDEBUG
  265.         {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  266.         {"&Debug", M_SetDebug, isSens, notChk, noKeyLbl, noKey, noSub},
  267. #endif
  268.         {"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
  269.         {"&Close",M_Close, isSens, notChk, noKeyLbl, noKey, noSub},
  270.         {"E&xit", M_Exit, isSens, notChk, noKeyLbl, noKey, noSub},
  271.         {NULL}
  272.       };
  273.  
  274.     vMenu EditMenu[] =
  275.       {
  276.         {"Cut", M_Cut, isSens, notChk, "Ctrl-X", noKey, noSub},
  277.         {"Copy", M_Copy, notSens, notChk, "Ctrl-C", noKey, noSub},
  278.         {"Paste", M_Paste, notSens, notChk, "Ctrl-V", noKey, noSub},
  279.         {NULL}
  280.       };
  281.  
  282.     vMenu StandardMenu[] =
  283.       {
  284.         {"&File", M_File, isSens, notUsed, notUsed, noKey, &FileMenu[0]},
  285.                 // the File menu
  286.         {"&Edit", M_Edit, isSens, notUsed, notUsed, noKey, &EditMenu[0]},
  287.                 // the Edit menu
  288.         {"&Test", M_Test, isSens, notUsed, notUsed, noKey, &TestMenu[0]},
  289.                 // the Test menu
  290.         {NULL}
  291.       };
  292.  
  293.       char* testl[] =
  294.       {
  295.     "Test A",
  296.         "Item B",
  297.         "Item C",
  298.         "Item D",
  299.         "Item E",
  300.         "Item F",
  301.     "Item G",
  302. //    "Item H",
  303. //    "Item I",
  304. //    "Item J",
  305. //    "Item K",
  306.         0
  307.       };
  308.  
  309.   
  310. #define vC_Size 8
  311.  
  312.     CommandObject CommandBar[] =
  313.       {
  314.         {C_Button, M_Copy, M_Copy, "Copy", NoList,CA_None,notSens,NoFrame, 0, 0, 0,
  315.         "Copy Highlight"},
  316.     {C_ToggleIconButton,M_Toggle , 1, "tog", ©Icon,CA_None,isSens,NoFrame, 0, 0, 0,
  317.         "Toggle Icon Test"},
  318.     {C_ToggleButton,m_togbtn , 1, "+/-", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  319.         "Toggle Text Test"},
  320.         {C_Button, M_Clear, M_Clear, "Clr", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  321.         "Clear screen"},
  322.     {C_Button, M_Message, M_Message, "Msg", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  323.         "Show message in canvas"},
  324.         {C_Button, M_RevMessage, M_RevMessage, "RevMsg", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  325.         "Reverse message in canvas"},
  326.  
  327. #include <v/vcb2x4.h>
  328.  
  329.     {C_ColorButton, M_Exit, M_Exit, "Exit", &vStdColors[vC_Red],CA_None,isSens,NoFrame, 0, 0, 0,
  330.         "Exit Test"},
  331. #ifdef ALLTESTS
  332.     {C_List, 4200, 0, "A List", (void*)testl,
  333.          CA_None,isSens,NoFrame,0,0},
  334. #endif
  335.     {C_ComboBox,4201,0,"ComboBox",(void*)testl,
  336.          CA_Simple,isSens,NoFrame,0,0,0, "Combo Box test"},
  337.         {C_TextIn,4202,0,"Test Text In", NoList,
  338.                 CA_None,isSens,NoFrame,0,0,0, "Test Text In"},
  339.         {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  340.       };
  341.  
  342.     CommandObject CommandBar2[] =
  343.       {
  344.         {C_Button, M_New, M_New, "New", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  345.         "New Command Window"},
  346.         {C_Button, M_Close, M_Close, "Close", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  347.         "Close this window"},
  348.         {C_Button, M_AttrMessage, 0, "Attr Message", NoList,CA_None,isSens,NoFrame,0,0,0,
  349.         "Message with attributes"},
  350.         {C_Button, M_ChangeButton, M_ChangeButton, "Change Me", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  351.         "Change text in this button"},
  352.         {C_IconButton, M_DrawIcon, M_DrawIcon, "", &colorIcon,CA_None,isSens,NoFrame, 0, 0, 0,
  353.         "Draw Icon on canvas"},
  354.        //       {C_Blank,887,0," ",CA_None,isSens,NoFrame, 0, 0},
  355.         {C_Button, M_ColorTest, 0, "Color Test", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  356.         "Draw colors"},
  357.         {C_Slider, 888, 4, "",NoList,CA_Horizontal ,isSens,NoFrame, 0, 0, 0,
  358.         "Slider Test"},
  359.         {C_Text, 889, 4, "", " 04",CA_None,isSens,NoFrame, 0, 0},
  360.         {C_Button, M_Dialog, 0, "Dialog", NoList,CA_None,isSens,NoFrame, 0, 0, 0,
  361.         "Show Dialog Test"},
  362.         {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  363.       };
  364.  
  365.     vStatus StatBar[] =
  366.       {
  367.         {" Time: ", 305, CA_NoBorder, isSens, 0},
  368.     {" 00:00:00 AM  dd mmm yyyy ",306, CA_None, isSens, 0},
  369.     {"00000",307, CA_None, isSens, 0},
  370.         {"Color:", 302, CA_NoBorder, isSens, 0 },
  371.     {" Black ", 304, CA_None, isSens, 70},
  372.     {"+",311,CA_NoBorder,isSens,0},
  373.     {" 20",313,CA_NoBorder,isSens,0},
  374.     {"/",314,CA_NoBorder,isSens,0},
  375.         {" 50",315,CA_NoBorder,isSens,0},
  376.         {NULL,0,0,0,0}
  377.       };
  378.  
  379.     char text_buff[256];        // big buffer for text
  380.  
  381.     CommandObject textInList[] =
  382.       {
  383.         {C_Label, 1, 1, "TI",NoList,
  384.                 CA_MainMsg,isSens,NoFrame, 0,0},
  385.         {C_TextIn, 2, 2, "Default Test Text", NoList,
  386.                 CA_None,isSens,NoFrame,0,1},
  387.         {C_TextIn, 3, 3, "12345", NoList,
  388.                 CA_None,isSens,NoFrame,0,2,5},
  389.         {C_TextIn, 4, 4, "",NoList,CA_Password,isSens,NoFrame,3,2},
  390.         {C_Button, M_OK, M_OK, " OK ", NoList,CA_DefaultButton,
  391.                 isSens,NoFrame,0,3},
  392.         {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  393.       };
  394.  
  395.     CommandObject ModalList[] =
  396.       {
  397.         {C_Label, 10, 10, "YND",
  398.                  NoList, CA_MainMsg, isSens, NoFrame, 0,0},
  399.         {C_Label, 99, 0, "Sample Label", NoList, CA_None,isSens,NoFrame, 10,0},
  400.  
  401.  
  402.         {C_Blank, 11, 0, "     ", NoList, CA_None,isSens,NoFrame, 0,10},
  403.         {C_Button, M_OK, M_OK, " OK ", NoList,
  404.                 CA_DefaultButton, isSens, NoFrame, 11, 10},
  405.         {C_Button, 14, M_No, " No ", NoList,CA_None,isSens,NoFrame, M_OK, 10},
  406.         {C_Button, M_Cancel, M_Cancel, " Cancel ", NoList,
  407.         CA_None,isSens,NoFrame,14, 10},
  408.  
  409.         {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  410.       };
  411.  
  412.     static VCursor curCursor = VC_IBar;
  413.  
  414.     static vFont gfont(vfDefaultFixed);
  415.     static long lp_lim = 0;
  416.     static int memdcValid = 0;
  417.     static int sliceOn = 0;
  418.  
  419.  
  420. //====================>>> myTimer::TimerTick <<<====================
  421.   void myTimer::TimerTick()
  422.   {
  423.  
  424.    cmdw->WindowCommand(m_CurTime, m_CurTime, C_Button);                 // update clock
  425.   }
  426.  
  427. //====================>>> testCmdWindow::testCmdWindow <<<====================
  428.   testCmdWindow::testCmdWindow(char* name, int width, int height) :
  429.     vCmdWindow(name, width, height)
  430.   {
  431.  
  432.     UserDebug3(Constructor,"testCmdWindow::testCmdWindow(%s,%d,%d) Constructor\n",name,width,height)
  433.  
  434.     nextWin = 0;
  435.     nextCmdWin = 0;
  436.     curDialog = 0;
  437.     curTogDialog = 0;
  438.     curListDialog = 0;
  439.     _workCounter = 0;
  440.  
  441.     // The "Standard" window will consist of a menubar, a canvas,
  442.     // an optional button bar, and an optional status bar.
  443.  
  444.     // First, create and add the proper panes to the CmdWindow
  445.     // Note: there must be a correspondint delete in the destructor
  446.  
  447.     // The Menu Bar
  448.     myMenu = new vMenuPane(StandardMenu);       // the standard menu
  449.     AddPane(myMenu);                            // add pane to window
  450.  
  451.     // The command pane
  452.     myCmdPane = new vCommandPane(CommandBar);
  453.     AddPane(myCmdPane);
  454.  
  455.     // The command pane
  456.     myCmdPane2 = new vCommandPane(CommandBar2);
  457.     AddPane(myCmdPane2);
  458.  
  459.     // The Canvas
  460.     myCanvas = new testTextCanvasPane(this);              // a new canvas pane
  461.     AddPane(myCanvas);                          // add the pane to window
  462.  
  463.     // The Status Bar
  464.     myStatus = new vStatusPane(StatBar);        // a new status bar
  465.     AddPane(myStatus);                          // add pane to window
  466.  
  467.     // the timer
  468.     _timer = new myTimer(this);
  469.     _timer->TimerSet(1000); // 2 second intervals
  470.  
  471.     myMemDC = new vMemoryDC(256,256);           // a memory dc
  472.  
  473.     ShowWindow();
  474.  
  475.     myCanvas->ShowVScroll(1); myCanvas->SetVScroll(20,50);
  476.  
  477.     WindowCommand(m_CurTime, m_CurTime, C_Button);      // update clock
  478.  
  479.     theApp->EnableWorkSlice(50); sliceOn = 1;
  480.  
  481.   }
  482.  
  483. //====================>>> testCmdWindow::~testCmdWindow <<<====================
  484.   testCmdWindow::~testCmdWindow()
  485.   {
  486.     UserDebug(Destructor,"testCmdWindow::~testCmdWindow() destructor\n")
  487.  
  488.     _timer->TimerStop();
  489.     delete _timer;
  490.     delete myMenu;
  491.     delete myCanvas;
  492.     delete myCmdPane;
  493.     delete myCmdPane2;
  494.     delete myStatus;
  495.     if (curDialog)
  496.     delete curDialog;
  497.     if (curTogDialog)
  498.     delete curTogDialog;
  499.     if (curListDialog)
  500.     delete curListDialog;
  501.  
  502.   }
  503.  
  504. //====================>>> testCmdWindow::CloseWin <<<====================
  505.   void testCmdWindow::CloseWin()
  506.   {
  507.     vCmdWindow::CloseWin();
  508.   }
  509.   
  510.  
  511. //====================>>> testCmdWindow::SetShownTop <<<====================
  512.   void testCmdWindow::SetShownTop(int shown, int top)
  513.   {
  514.     char buff[20];
  515.     IntToStr(shown,buff);
  516.     SetString(313,buff);
  517.     IntToStr(top,buff);
  518.     SetString(315,buff);
  519.   }
  520.  
  521. //====================>>> testCmdWindow::WindowCommand <<<====================
  522.   void testCmdWindow::WindowCommand(ItemVal id, ItemVal val, CmdType cType)
  523.   {
  524.  
  525.     // route all commands through here - menus and buttons
  526.     char buff[20];
  527.  
  528.     switch (id)
  529.       {
  530.         case M_Cut:
  531.         case M_Copy:
  532.           {
  533.             theApp->ClipboardSetText("Greetings From the V Test Program\n");
  534.             break;
  535.           }
  536.  
  537.         case M_Paste:
  538.           {
  539.             char* pasteText = theApp->ClipboardGetText();
  540.             if (pasteText != 0)
  541.               {
  542.                 myCanvas->DrawText(pasteText);
  543.                 myCanvas->DrawText("\n");
  544.               }
  545.             break;
  546.           }
  547.  
  548.         case M_New:
  549.       {
  550.             // Create and register a new window
  551.             if (theApp->simSDI())
  552.                 break;
  553.             testCmdWindow* tmp = new testCmdWindow(sub,
  554.         theApp->DefaultWidth(), theApp->DefaultHeight());
  555.         theApp->NewAppWin(tmp, sub, 400, 100);
  556.         sub[3]++;
  557.             break;
  558.           }
  559.  
  560.         case m_new2:
  561.           {
  562.             // Create and register a new window
  563.         // This test is required to test the MDI model to
  564.         // be sure the menus and tool bars change.
  565.             if (theApp->simSDI())
  566.                 break;
  567.             testCmdWindow2* tmp2 = new testCmdWindow2("Simple Window",
  568.                 300, 250);
  569.         theApp->NewAppWin(tmp2, "Simple Window", 400, 300);
  570.             break;
  571.           }
  572.  
  573.     case M_Open:
  574.       {
  575.         static char name[100] = ""; // start out with null name
  576.         vFileSelect fsel(this);     // make an instance
  577.  
  578.         int oans = fsel.FileSelect("Open file",name,99,filter,filterIndex);
  579.  
  580.         vNoticeDialog fsnote(this); // make an instance
  581.  
  582.         if (oans && *name)
  583.           {
  584.         SetTitle(name);
  585.         (void)fsnote.Notice(name);
  586.           }
  587.         else
  588.         (void)fsnote.Notice("No file name input.");
  589.  
  590.         break;
  591.       }
  592.  
  593.     case M_SaveAs:
  594.       {
  595.         static char name[100] = "saveas.tmp"; // start out with null name
  596.         vFileSelect fsel(this);     // make an instance
  597.  
  598.         int oans = fsel.FileSelectSave("Save file",name,99,filter,filterIndex);
  599.  
  600.         vNoticeDialog fsnote(this); // make an instance
  601.  
  602.         if (oans && *name)
  603.           {
  604.         SetTitle(name);
  605.         (void)fsnote.Notice(name);
  606.           }
  607.         else
  608.         (void)fsnote.Notice("No file name input.");
  609.  
  610.         break;
  611.       }
  612.  
  613.         case M_Close:           // Close not via close button
  614.           {
  615.             theApp->CloseAppWin(this);
  616.             break;
  617.           }
  618.  
  619.         case M_Exit:
  620.           {
  621.             theApp->Exit();
  622.             break;
  623.           }
  624.  
  625.         case M_CheckMe:                 // check me
  626.           {
  627.             ItemVal curval = GetValue(id);
  628.             SetValue(M_CheckMe,!curval,Checked);
  629.             if (curval)
  630.                 SetString(M_CheckMe,"Check Me");
  631.             else
  632.                 SetString(M_CheckMe,"UnChk Me");
  633.             break;
  634.       }
  635.  
  636.         case m_changeMenu:        // change menu item
  637.           {
  638.             SetString(m_changeMenu,newMenu);
  639.             newMenu[1]++;
  640.             break;
  641.           }
  642.  
  643.     case m_togbtn:
  644.           {
  645.              ItemVal curval = GetValue(id);     // get current value
  646.              if (curval)
  647.                  SetString(311,"+");
  648.              else
  649.                  SetString(311,"-");
  650.              break;
  651.           }
  652.  
  653.         case M_CopySens:                        // Last
  654.           {
  655.             copy_sens = !copy_sens;
  656.             SetValue(M_Copy,copy_sens,Sensitive);
  657.             break;
  658.           }
  659.  
  660.  
  661.         case M_SimpleWin:
  662.           {
  663.             if (nextWin < MAX_WINDOWS)
  664.               {
  665.                 Wins[nextWin] = new vWindow(sub,50,30);
  666.                 sub[3]++;               // make a new name
  667.                 Wins[nextWin]->ShowWindow();
  668.                 ++nextWin;
  669.               }
  670.            break;
  671.           }
  672. #ifdef vDEBUG
  673.         case M_SetDebug:
  674.           {
  675.         vDebugDialog debug(this);
  676.             debug.SetDebug();
  677.             break;
  678.           }
  679. #endif
  680.  
  681.         case M_YNDialog:
  682.           {
  683.         vYNReplyDialog ynd(this);   // make an instance
  684.             int ans;
  685.             char ynmsg[] = "YN Dialog - try one.";
  686.  
  687.             ans = ynd.AskYN(ynmsg);
  688.          //   fprintf(stderr,"YN answer value: %d\n",ans);
  689.             break;
  690.           }
  691.  
  692.         case M_ChgTitle:
  693.           {
  694.             SetTitle(title);
  695.             ++title[0];
  696.             break;
  697.           }
  698.  
  699.         case M_ChgAppTitle:
  700.           {
  701.             theApp->SetAppTitle(title);
  702.             ++title[0];
  703.             break;
  704.           }
  705.  
  706.         case M_Reply:
  707.           {
  708.             vReplyDialog rp(this);      // make an instance
  709.             char out[120];
  710.             char r[100];                // a buffer for reply
  711.  
  712.             int rv = rp.Reply("Please enter some text.",r,99,"Edit this text");
  713.  
  714.             vNoticeDialog note(this);   // make an instance
  715.  
  716.             if (rv == M_Cancel)
  717.                 (void)note.Notice("Cancel pressed");
  718.             else if (*r)
  719.               {
  720.                 strcpy(out,"Text was: ");
  721.                 strcat(out,r);
  722.                 (void)note.Notice(out);
  723.               }
  724.             else
  725.                 (void)note.Notice("No text input.");
  726.  
  727.             break;
  728.           }
  729.  
  730.         case M_CenterCursor:            // test cursor motion
  731.           {
  732.             int r = myCanvas->GetRows();
  733.             int c = myCanvas->GetCols();
  734.  
  735.             myCanvas->GotoRC(r/2, c/2);
  736.             break;
  737.           }
  738.  
  739.         case M_HideCursor:
  740.           {
  741.             myCanvas->HideTextCursor();
  742.             break;
  743.           }
  744.  
  745.         case M_ShowCursor:
  746.           {
  747.             myCanvas->ShowTextCursor();
  748.             break;
  749.           }
  750.  
  751.         case m_ChangeCursor:            // change canvas cursor
  752.           {
  753.             if (curCursor >= VC_LAST)   // change module # of cursors
  754.                 curCursor = 1;
  755.             else
  756.                 ++curCursor;
  757.             myCanvas->SetCursor(curCursor);  // Set the cursor
  758.             break;
  759.           }
  760.  
  761.         case m_Hon:
  762.           {
  763.             myCanvas->ShowHScroll(1);  // show the h scroll
  764.         myCanvas->SetHScroll(80,20);
  765.             break;
  766.           }
  767.  
  768.         case m_Hoff:
  769.           {
  770.             myCanvas->ShowHScroll(0);  // hide the h scroll
  771.             break;
  772.           }
  773.  
  774.         case m_Von:
  775.           {
  776.             myCanvas->ShowVScroll(1);  // show the v scroll
  777.             break;
  778.           }
  779.  
  780.         case m_Voff:
  781.           {
  782.             myCanvas->ShowVScroll(0);  // hide the v scroll
  783.             break;
  784.           }
  785.  
  786.         case m_HideStat:
  787.           {
  788.             ShowPane(myStatus,0);
  789.             break;
  790.           }
  791.  
  792.         case m_ShowStat:
  793.           {
  794.             ShowPane(myStatus,1);
  795.             break;
  796.           }
  797.  
  798.         case m_HideCmd:
  799.           {
  800.         ShowPane(myCmdPane,0);
  801.         ShowPane(myCmdPane2,0);
  802.             break;
  803.           }
  804.  
  805.         case m_ShowCmd:
  806.           {
  807.         ShowPane(myCmdPane,1);
  808.         ShowPane(myCmdPane2,1);
  809.             break;
  810.           }
  811.  
  812.         case m_HideCnv:
  813.           {
  814.             ShowPane(myCanvas,0);
  815.             break;
  816.           }
  817.  
  818.         case m_ShowCnv:
  819.           {
  820.             ShowPane(myCanvas,1);
  821.             break;
  822.           }
  823.  
  824.     case M_Dialog:
  825.       {
  826.              char val[20];
  827.  
  828.          if (!curDialog)
  829.           {
  830.                 curDialog = new testDialog(this);
  831.           }
  832.  
  833.         curDialog->ShowDialog("This is a simple modeless dialog.");
  834.         int l,t,w,h;
  835.         GetPosition(l,t,w,h);    // get positon of main window
  836.             myCanvas->DrawText("Main Window l,t,w, h: ");
  837.             IntToStr(l,val); myCanvas->DrawText(val); myCanvas->DrawText(", ");
  838.             IntToStr(t,val); myCanvas->DrawText(val); myCanvas->DrawText(", ");
  839.             IntToStr(w,val); myCanvas->DrawText(val); myCanvas->DrawText(", ");
  840.             IntToStr(h,val); myCanvas->DrawText(val); myCanvas->DrawText(", \n");
  841.  
  842.  
  843.         curDialog->SetDialogPosition(l+10,t+h+5);
  844.             curDialog->GetDialogPosition(l,t,w,h);
  845.             myCanvas->DrawText("Dialog l,t,w, h: ");
  846.             IntToStr(l,val); myCanvas->DrawText(val); myCanvas->DrawText(", ");
  847.             IntToStr(t,val); myCanvas->DrawText(val); myCanvas->DrawText(", ");
  848.             IntToStr(w,val); myCanvas->DrawText(val); myCanvas->DrawText(", ");
  849.             IntToStr(h,val); myCanvas->DrawText(val); myCanvas->DrawText(", \n");
  850.  
  851.  
  852.         break;
  853.       }
  854.  
  855.     case m_togdlg:
  856.       {
  857.         if (!curTogDialog)
  858.           {
  859.         curTogDialog = new toggleDialog(this);
  860.           }
  861.  
  862.         int dummy;
  863.         curTogDialog->ShowModalDialog("Toggle Dialog.",dummy);
  864.         break;
  865.       }
  866.  
  867.         case M_List:
  868.           {
  869.         if (!curListDialog)
  870.           {
  871.         curListDialog = new listDialog(this);      // create dynamically
  872.           }
  873.             ItemVal lid, junk;
  874.             int lval, cval, vval, ival1, ival2;
  875.  
  876.             curListDialog->SetValue(200,8,Value);   // pre-select 8
  877.             curListDialog->ShowDialog("List Dialog Test.");
  878.             break;
  879.       }
  880.  
  881.     case 1353:
  882.       {
  883.         vNoticeDialog note(this);
  884.         note.Notice("Change Combo");
  885.         break;
  886.       }
  887.  
  888.         case M_Clear:                   // clear display
  889.           {
  890.             myCanvas->Clear();
  891.             lp_lim = 0;
  892.             break;
  893.           }
  894.  
  895.         case M_Message:
  896.           {
  897.             myCanvas->DrawText(mess);
  898.         myCanvas->DrawText("\nYes\n");    // @@
  899.             if (++mess[1] > 'Z')        // something new each time
  900.                 mess[1] = 'A';
  901.             break;
  902.           }
  903.  
  904.         case M_AttrMessage:
  905.           {
  906.             myCanvas->DrawAttrText("Red, ", ChRed);
  907.             myCanvas->DrawAttrText("Green, ", ChGreen);
  908.             myCanvas->DrawAttrText("RevGreen, ", ChGreen|ChReverse);
  909.             myCanvas->DrawAttrText("HiGreen, ", ChGreen|ChHighlight);
  910.             myCanvas->DrawAttrText("DimGreen, ", ChGreen|ChDimColor);
  911.             myCanvas->DrawAttrText("reversed, ",ChReverse);
  912.             myCanvas->DrawAttrText("and ", ChNormal);
  913.             myCanvas->DrawAttrText("Blue.\n", ChBlue);
  914.             break;
  915.           }
  916.  
  917.         case M_RevMessage:
  918.           {
  919.             myCanvas->DrawAttrText(mess, ChReverse);
  920.             if (++mess[1] > 'Z')        // something new each time
  921.                 mess[1] = 'A';
  922.             break;
  923.           }
  924.  
  925.         case M_ModalDialog:
  926.           {
  927.             vModalDialog md(this);      // try this one dynamically...
  928.             int id, val;
  929.  
  930.             md.AddDialogCmds(ModalList);
  931.             id = md.ShowModalDialog("This is a MODAL dialog.",val);
  932.             break;
  933.           }
  934.  
  935.         case M_ShowList:
  936.           {
  937.             theApp->ShowList();
  938.             break;
  939.           }
  940.  
  941.         case M_ChangeButton:
  942.           {
  943.             SetString(M_ChangeButton,blabel);
  944.             ++blabel[0];
  945.             break;
  946.           }
  947.  
  948.         case m_font:
  949.           {
  950.             vFontSelect fd(this);
  951.  
  952.             (void) fd.FontSelect(gfont);
  953.             myCanvas->SetFont(gfont);
  954.             myCanvas->Clear();
  955.             myCanvas->DrawText(mess);
  956.             if (++mess[1] > 'Z')        // something new each time
  957.                 mess[1] = 'A';
  958.             break;
  959.           }
  960.  
  961.         case m_printTest:
  962.           {
  963.             PrintTest(0);
  964.             break;
  965.           }
  966.  
  967.         case m_printTestScaled:
  968.           {
  969.             PrintTest(1);
  970.             break;
  971.           }
  972.  
  973.         case m_grow:
  974.           {
  975.         static int w = 200;
  976.         static int h = 100;
  977.             myCanvas->SetWidthHeight(w,h);
  978.         w += 50; h += 50;
  979.             break;
  980.           }
  981.     case m_maketiny:
  982.       {
  983.         myCanvas->SetWidthHeight(100,4);
  984.         break;
  985.       }
  986.  
  987.     case m_setBG:
  988.         {
  989.          vColor bgc = _pen.GetColor();
  990.         myCanvas->SetBackground(bgc);
  991.         break;
  992.       }
  993.  
  994.         case M_DrawIcon:
  995.           {
  996.         memdcValid = 1;
  997.             myMemDC->Clear();
  998.             myCanvas->DrawLine(5,30,20,30);
  999.             myMemDC->DrawLine(5,30,20,30);
  1000.             myCanvas->DrawIcon(20,30,copyIcon);
  1001.             myMemDC->DrawIcon(20,30,copyIcon);
  1002.             myCanvas->DrawIcon(80,30,c24Icon);
  1003.         myMemDC->DrawIcon(80,30,c24Icon);
  1004. #ifdef DRAW_BRUCE
  1005.         myCanvas->DrawIcon(120,2,bruceIcon);
  1006.             myMemDC->DrawIcon(120,2,bruceIcon);
  1007. #else
  1008.             myCanvas->DrawIcon(120,30,colorIcon);
  1009.             myMemDC->DrawIcon(120,30,colorIcon);
  1010. #endif
  1011.             break;
  1012.           }
  1013.  
  1014.         case M_Mem2Canvas:
  1015.           {
  1016.             if (!memdcValid)            // haven't done this yet
  1017.               {
  1018.                 myMemDC->Clear();
  1019.                 vBrush br;
  1020.                 br.SetColor(255,0,0);
  1021.                 myMemDC->SetBrush(br);
  1022.                 myMemDC->DrawRectangle(0,0,256,256);
  1023.                 memdcValid = 1;
  1024.               }
  1025.             myCanvas->CopyFromMemoryDC(myMemDC,10,20);
  1026.             break;
  1027.       }
  1028.  
  1029.     case m_CopyAreaTest:
  1030.           {
  1031.             if (!memdcValid)            // haven't done this yet
  1032.               {
  1033.                 myMemDC->Clear();
  1034.                 vBrush br;
  1035.                 br.SetColor(255,0,0);
  1036.                 myMemDC->SetBrush(br);
  1037.                 myMemDC->DrawRectangle(0,0,256,256);
  1038.                 memdcValid = 1;
  1039.           }
  1040.         
  1041. #ifdef DRAW_BRUCE
  1042.         myCanvas->CopyFromMemoryDC(myMemDC,10,30,120,2,bruce_width,bruce_height);
  1043. #else
  1044.         myCanvas->CopyFromMemoryDC(myMemDC,10,30,120,30,color_width,color_height);
  1045. #endif
  1046.             break;
  1047.       }
  1048.  
  1049.         // The following test attempts to see how fast we can draw
  1050.         case M_ColorTest:
  1051.           {
  1052.                     lp_lim = (long) GetValue(888);              // get value of slider
  1053.             vColor colorRow[256];
  1054.             // myMemDC->Clear();
  1055.             myCanvas->Clear();
  1056.  
  1057.             vBrush brush;
  1058.             vPen pen;
  1059.  
  1060.             for (long lps = 0 ; lps  < lp_lim ; ++lps)
  1061.               {
  1062.                 for (long bar = 0 ; bar < 16 ; ++ bar)
  1063.                   {
  1064.                     brush.SetColor(vStdColors[(bar+lps) & 0x0F]);
  1065.                     pen.SetColor(vStdColors[(bar+lps) & 0x0F]);
  1066.  
  1067.                    // myMemDC->SetBrush(brush);
  1068.                    // myMemDC->DrawRectangle(0,bar*16,256,16);
  1069.                     myCanvas->SetBrush(brush);
  1070.                     myCanvas->SetPen(pen);
  1071.                     myCanvas->DrawRectangle(0,bar*16,256,16);
  1072.                   }
  1073.                 theApp->CheckEvents();
  1074.               }
  1075.             break;
  1076.           }
  1077.  
  1078.         case M_PointTest:
  1079.           {
  1080.             memdcValid = 1;
  1081.             lp_lim = 8;    // get value of slider
  1082.             vColor colorRow[256];
  1083.             myMemDC->Clear();
  1084.             myCanvas->Clear();
  1085.  
  1086.             for (long lps = 0 ; lps  < lp_lim ; ++lps)
  1087.               {
  1088.                 for (long bar = 0 ; bar < 16 ; ++ bar)
  1089.                   {
  1090.                     for (int col = 0 ; col < 256 ; ++col) // fill in color row
  1091.                         colorRow[col] = vStdColors[(bar+lps) & 0x0F];
  1092.  
  1093.                     for (int row = bar * 16 ; row < (bar*16)+16 ; ++row)
  1094.                       {
  1095.                         myMemDC->DrawColorPoints(0,row,256,colorRow);
  1096. //                      myCanvas->DrawColorPoints(0,row,256,colorRow);
  1097.                       }
  1098.                   }
  1099.                 myCanvas->CopyFromMemoryDC(myMemDC,0,0);
  1100.                 theApp->CheckEvents();
  1101.               }
  1102.  
  1103.             break;
  1104.           }
  1105.  
  1106.  
  1107.         case 888:
  1108.           {
  1109.             char buff[10];
  1110.             IntToStr(val,buff);
  1111.             SetString(889,buff);
  1112.             break;
  1113.           }
  1114.  
  1115.         case M_TextIn:
  1116.           {
  1117.             vModalDialog md(this);      // try this one dynamically...
  1118.  
  1119.             vNoticeDialog txtin(this);
  1120.  
  1121.             int ans, val;
  1122.  
  1123.             md.AddDialogCmds(textInList);
  1124.  
  1125.             ans = md.ShowModalDialog("Enter text.", val);
  1126.  
  1127.             text_buff[0] = 0;
  1128.  
  1129.             (void) md.GetTextIn(2, text_buff, 254);
  1130.  
  1131.             txtin.Notice(text_buff);
  1132.             break;
  1133.           }
  1134.  
  1135.     case m_CurTime:
  1136.           {
  1137.             char buff[40];
  1138.             char date[30];
  1139.             vGetLocalTime(buff);
  1140.         vGetLocalDate(date);
  1141.         strcat(buff,"  ");
  1142.             strcat(buff,date);
  1143.         SetString(306,buff);
  1144.         if (_workCounter < 1000)
  1145.           {
  1146.         LongToStr(_workCounter,buff);
  1147.         SetString(307,buff);
  1148.           }
  1149.         else
  1150.           {
  1151.         if (sliceOn)
  1152.           theApp->EnableWorkSlice(0);
  1153.         sliceOn = 0;
  1154.           }
  1155.         break;
  1156.           }
  1157.  
  1158.  
  1159.     case m_Beep:
  1160.       {
  1161.         vBeep();
  1162.         break;
  1163.       }
  1164.  
  1165.     case 909:
  1166.       {
  1167.         _timer->TimerStop();
  1168.         theApp->EnableWorkSlice(0);
  1169.         sliceOn = 0;
  1170.         break;
  1171.       }
  1172.  
  1173.     default:
  1174.       {
  1175.             if (id >= M_Black && id <= M_White) // A color button
  1176.               {
  1177.                 _pen.SetColor(vStdColors[val]);
  1178.                 myCanvas->SetPen(_pen);
  1179.                 SetString(304,vColorNames[val]);
  1180.               }
  1181.             else
  1182.                 vCmdWindow::WindowCommand(id, val, cType);
  1183.             break;
  1184.           }
  1185.       }
  1186.   }
  1187.  
  1188. //====================>>> testCmdWindow::PrintTest <<<======================
  1189.   void testCmdWindow::PrintTest(int scaled)
  1190.   {
  1191.     // Test what the text will do
  1192.  
  1193.     vPrintDC pdc(scaled);               // create a printDC object
  1194.     vPrinter printer;
  1195.     vFont font;
  1196.     int x;
  1197.  
  1198.     if (!printer.Setup("test.ps"))      // setup the printer
  1199.         return;
  1200.  
  1201.     pdc.SetPrinter(printer);    // change to the printer we setup
  1202.  
  1203.     if (!pdc.BeginPrinting())   // print to test.ps
  1204.         return;
  1205.  
  1206.     int physW = pdc.GetPhysWidth();
  1207.     int physH = pdc.GetPhysHeight();
  1208.  
  1209.     // Assume 8.5" paper for this test. Calculate a logical inch in pixels.
  1210.     // The default gives about 72.
  1211.  
  1212.     int physInch = (int)((float)pdc.GetPhysWidth() / 8.5);  // a logical inch
  1213.     int logicalWidth = 612;
  1214.     int logicalHeight = 792;
  1215.  
  1216.     // Now, set the scale if in scaled mode.
  1217.  
  1218.     if (scaled)
  1219.         pdc.SetScale(physInch/4, 18);    // 1/72 = n/physInch
  1220.     else
  1221.       {
  1222.         logicalWidth = pdc.GetPhysWidth();
  1223.         logicalHeight = pdc.GetPhysHeight();
  1224.       }
  1225.  
  1226.     // Have a valid drawing canvas, so draw a box around paper edges
  1227. //    for (int pg = 1 ; pg < 3 ; ++pg)    // print 2 pages to test everyting
  1228.     for (int pg = 1 ; pg < 2 ; ++pg)
  1229.       {
  1230.  
  1231.         vBrush pbrush(0,0,0,vTransparent);      // a transparent brush
  1232.         pdc.SetBrush(pbrush);
  1233.         if (pg == 1)
  1234.           {
  1235.             // We want 36 to be about 1/2" on 8.5" paper, which happens automatically
  1236.             // in the default mode. If we are in scaled mode, then 36 should be
  1237.             // 1/17th of the page width. Thus, to get real value, we need
  1238.             // to find n, where 36*n == PhysicalWidth / 17, or n = PhysWid / 612.
  1239.  
  1240.             pdc.DrawRectangle(36, 36, logicalWidth - 72,
  1241.                 logicalHeight - 72);
  1242.             pdc.SetTranslate(0,36);     // and now leave 1/2 inch at top
  1243.           }
  1244.         // since we center the text, we don't
  1245.         // need the left margin
  1246.  
  1247.         // ----------- Here is the printing test.
  1248.  
  1249.         font.SetFontValues(vfDefaultFixed, 10, vfNormal, vfNormal, 0);
  1250.         pdc.SetFont(font);
  1251.         x = GetCenter( pdc, "Default Fixed, 10 point, Normal", scaled);
  1252.         pdc.DrawLine(x, 12, x, 2);
  1253.         pdc.DrawText(x+1,12,"Default Fixed, 10 point, Normal");
  1254.  
  1255.         font.SetFontValues(vfDefaultVariable, 10, vfNormal, vfNormal, 0);
  1256.         pdc.SetFont(font);
  1257.         x = GetCenter( pdc, "Default Variable, 10 point, Normal", scaled);
  1258.         pdc.DrawLine(x, 25, x, 15);
  1259.         pdc.DrawText(x+1,25,"Default Variable, 10 point, Normal");
  1260.  
  1261.         font.SetFontValues(vfFixed, 10, vfNormal, vfNormal, 0);
  1262.         pdc.SetFont(font);
  1263.         x = GetCenter( pdc, "Fixed, 10 point, Normal", scaled);
  1264.         pdc.DrawLine(x, 40, x, 30);
  1265.         pdc.DrawText(x+1,40,"Fixed, 10 point, Normal");
  1266.  
  1267.         font.SetFontValues(vfSerif, 10, vfNormal, vfNormal, 0);
  1268.         pdc.SetFont(font);
  1269.         x = GetCenter( pdc, "Serif, 10 point, Normal", scaled);
  1270.         pdc.DrawLine(x, 55, x, 45);
  1271.         pdc.DrawText(x+1,55,"Serif, 10 point, Normal");
  1272.  
  1273.         font.SetFontValues(vfSansSerif, 10, vfNormal, vfNormal, 0);
  1274.         pdc.SetFont(font);
  1275.         x = GetCenter( pdc, "SansSerif, 10 point, Normal", scaled);
  1276.         pdc.DrawLine(x, 70, x, 60);
  1277.         pdc.DrawText(x+1,70,"SansSerif, 10 point, Normal");
  1278.  
  1279.         font.SetFontValues(vfSerif, 10, vfItalic, vfNormal, 0);
  1280.         pdc.SetFont(font);
  1281.         x = GetCenter( pdc, "Serif, 10 point, Italic", scaled);
  1282.         pdc.DrawLine(x, 85, x, 75);
  1283.         pdc.DrawText(x+1,85,"Serif, 10 point, Italic");
  1284.  
  1285.         font.SetFontValues(vfSerif, 10, vfItalic, vfBold, 0);
  1286.         pdc.SetFont(font);
  1287.         x = GetCenter( pdc, "Serif, 10 point, BoldItalic", scaled);
  1288.         pdc.DrawLine(x, 100, x, 90);
  1289.         pdc.DrawText(x+1,100,"Serif, 10 point, BoldItalic");
  1290.  
  1291.         font.SetFontValues(vfSansSerif, 10, vfItalic, vfNormal, 0);
  1292.         pdc.SetFont(font);
  1293.         x = GetCenter( pdc, "SansSerif, 10 point, Italic", scaled);
  1294.         pdc.DrawLine(x, 115, x, 105);
  1295.         pdc.DrawText(x+1,115,"SansSerif, 10 point, Italic");
  1296.  
  1297.         font.SetFontValues(vfSansSerif, 10, vfItalic, vfBold, 0);
  1298.         pdc.SetFont(font);
  1299.         x = GetCenter( pdc, "SansSerif, 10 point, BoldItalic", scaled);
  1300.         pdc.DrawLine(x, 130, x, 120);
  1301.         pdc.DrawText(x+1,130,"SansSerif, 10 point, BoldItalic");
  1302.  
  1303.         font.SetFontValues(vfFixed, 10, vfItalic, vfNormal, 0);
  1304.         pdc.SetFont(font);
  1305.         x = GetCenter( pdc, "Fixed, 10 point, Italic", scaled);
  1306.         pdc.DrawLine(x, 145, x, 135);
  1307.         pdc.DrawText(x+1,145,"Fixed, 10 point, Italic");
  1308.  
  1309.         font.SetFontValues(vfFixed, 10, vfItalic, vfBold, 0);
  1310.         pdc.SetFont(font);
  1311.         x = GetCenter( pdc, "Fixed, 10 point, BoldItalic", scaled);
  1312.         pdc.DrawLine(x, 160, x, 150);
  1313.         pdc.DrawText(x+1,160,"Fixed, 10 point, BoldItalic");
  1314.  
  1315.         font.SetFontValues(vfFixed, 20, vfItalic, vfBold, 0);
  1316.         pdc.SetFont(font);
  1317.         x = GetCenter( pdc, "BIG Fixed, 20 point, BoldItalic", scaled);
  1318.         pdc.DrawLine(x, 180, x, 160);
  1319.         pdc.DrawText(x+1,180,"BIG Fixed, 20 point, BoldItalic");
  1320.  
  1321.         pdc.SetFont(gfont);
  1322.         x = GetCenter( pdc, "Current Screen Font", scaled);
  1323.         pdc.DrawText(x+1,210,"Current Screen Font");
  1324.  
  1325.         font.SetFontValues(vfSansSerif, 24, vfNormal, vfBold, 1);
  1326.         pdc.SetFont(font);
  1327.         x = GetCenter( pdc, "The End", scaled);
  1328.         pdc.DrawLine(x, 310, x, 290);
  1329.         pdc.DrawText(x+1,310,"The End");
  1330.  
  1331.         pdc.DrawLine(60,72,72,72);
  1332.         pdc.DrawIcon(72,72,copyIcon);
  1333.  
  1334.         pdc.DrawLine(100,350,110,350);
  1335.         pdc.DrawIcon(110,350,bruceIcon);
  1336.  
  1337.         pdc.DrawLine(300,350,310,350);
  1338.         pdc.DrawIcon(310,350,c24Icon);
  1339.  
  1340.         // Test DrawColorPoints
  1341.         vColor useColor, colors[50];
  1342.  
  1343.         for (int cy = 16 ; cy < 32 ; ++cy)      // 16 bands of 16 lines
  1344.           {
  1345.             useColor.ResetColor(cy*8,cy*8,cy*8);        // set to a gray shade
  1346.             for (int rc = 0 ; rc < 50 ; ++rc)
  1347.                 colors[rc] = useColor;          // set all to this color
  1348.             for (int ry = cy - 16 ; ry < 16 ; ++ry)     // the 16 lines
  1349.                 pdc.DrawColorPoints(350,ry + cy + 500,50,colors);
  1350.           }
  1351.  
  1352. //        if (pg == 1)
  1353. //          {
  1354. //            pdc.EndPage();
  1355. //            pdc.BeginPage();
  1356. //@@          }
  1357.     }
  1358.  
  1359.     pdc.EndPrinting();
  1360.   }
  1361.  
  1362. //====================>>> testCmdWindow::GetCenter <<<======================
  1363.   int testCmdWindow::GetCenter(vPrintDC& pdc, char* str, int scale)
  1364.   {
  1365.     // Determine where the X is to center the text str
  1366.     // on the page, given a PrintDC
  1367.  
  1368.     int width = pdc.TextWidth(str);             // Real Width of the text
  1369.     int paperW = pdc.GetPhysWidth();            // Real paper width
  1370.  
  1371.     int center = (paperW - width) / 2;          // the x start to center!
  1372.     // The REAL center. Need to unscale if scaled
  1373.  
  1374.     if (scale)
  1375.       {
  1376.         int mult, div;
  1377.         pdc.GetScale(mult, div);
  1378.         center = (center/mult) * div;
  1379.       }
  1380.     if (width > paperW)                         // be reasonable
  1381.         center = 0;
  1382.     return center;
  1383.   }
  1384.