home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / test / vtcw2.cpp < prev    next >
C/C++ Source or Header  |  1998-07-03  |  5KB  |  144 lines

  1. //=======================================================================
  2. //  vtcmdwin2.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 modify
  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. #include <v/vcanvas.h>  // for Cursors
  23.  
  24. #include "vtcw2.h"
  25.  
  26.     // Define a different menu and different status bars from
  27.     // main cmdwindow to be sure things are updated correctly
  28.     // for the MDI model on Windows, and that we really do
  29.     // have independent menus and toolbars.
  30.  
  31.     static vMenu ShortFile[] =
  32.       {
  33.     {"Test Canvas", 200, isSens, notChk, noKeyLbl, noKey, noSub},
  34.         {"E&xit", M_Exit, isSens, notChk, noKeyLbl, noKey, noSub},
  35.         {NULL}
  36.       };
  37.  
  38.  
  39.     static CommandObject CommandBar[] =
  40.       {
  41.     {C_Button, 200,0,"Test Canvas", NoList,CA_None,isSens,NoFrame, 0, 0},
  42.         {C_Button, M_Close, M_Close, "Close", NoList,CA_None,isSens,NoFrame, 0, 0},
  43.         {C_EndOfList,0,0,0,0,CA_None,0,0,0}
  44.       };
  45.  
  46.     static vStatus StatBar[] =
  47.       {
  48.     {"vCanvasPane Test Window", 808, CA_NoBorder, isSens, 0 },
  49.         {NULL,0,0,0,0}
  50.       };
  51.  
  52.     static vMenu StandardMenu[] =
  53.       {
  54.     {"&File", M_File, isSens, notUsed, notUsed, noKey, &ShortFile[0]},
  55.     {NULL}
  56.       };
  57.  
  58.  
  59. //====================>>> testCmdWindow2::testCmdWindow2 <<<====================
  60.   testCmdWindow2::testCmdWindow2(char* name, int width, int height) :
  61.     vCmdWindow(name, width, height)
  62.   {
  63.  
  64.     // The "Standard" window will consist of a menubar, a canvas,
  65.     // an optional button bar, and an optional status bar.
  66.  
  67.     // First, create and add the proper panes to the CmdWindow
  68.     // Note: there must be a correspondint delete in the destructor
  69.  
  70.     // The Menu Bar
  71.     myMenu = new vMenuPane(StandardMenu);        // A short menu
  72.     AddPane(myMenu);                            // add pane to window
  73.  
  74.     // The command pane
  75.     myCmdPane = new vCommandPane(CommandBar);
  76.     AddPane(myCmdPane);
  77.  
  78.     // The Canvas
  79.     myCanvas = new vCanvasPane();              // a new canvas pane
  80.     AddPane(myCanvas);                          // add the pane to window
  81.  
  82.     // The Status Bar
  83.     myStatus = new vStatusPane(StatBar);        // a new status bar
  84.     AddPane(myStatus);                          // add pane to window
  85.  
  86.     ShowWindow();
  87.  
  88.   }
  89.  
  90. //====================>>> testCmdWindow::~testCmdWindow <<<====================
  91.   testCmdWindow2::~testCmdWindow2()
  92.   {
  93.     UserDebug(Destructor,"testCmdWindow2::~testCmdWindow2() destructor\n")
  94.  
  95.     delete myMenu;
  96.     delete myCanvas;
  97.     delete myCmdPane;
  98.     delete myStatus;
  99.  
  100.   }
  101.  
  102. //====================>>> testCmdWindow::WindowCommand <<<====================
  103.   void testCmdWindow2::WindowCommand(ItemVal id, ItemVal val, CmdType cType)
  104.   {
  105.  
  106.     // route all commands through here - menus and buttons
  107.     char buff[20];
  108.  
  109.     switch (id)
  110.       {
  111.     case 200:
  112.       {
  113.         myCanvas->Clear();
  114.             // The Ljyg is a visual pattern to line up lines with text
  115.         myCanvas->DrawText(20,40,"Ljyg: default font at 20,40");
  116.         myCanvas->DrawLine(20,10,20,40);
  117.         myCanvas->DrawLine(20,40,90,40);
  118.             vFont font0(vfSansSerif,10,vfNormal,vfNormal,0,0);
  119.             vFont font90(vfSansSerif,10,vfNormal,vfNormal,0,90);
  120.             vFont font180(vfSansSerif,10,vfNormal,vfNormal,0,180);
  121.             vFont font270(vfSansSerif,10,vfNormal,vfNormal,0,270);
  122.  
  123.             myCanvas->SetFont(font0);
  124.             myCanvas->DrawText(200,150,"Angled Text 0");
  125.             myCanvas->SetFont(font90);
  126.             myCanvas->DrawText(200,150,"Angled Text 90");
  127.             myCanvas->SetFont(font180);
  128.             myCanvas->DrawText(200,150,"Angled Text 180");
  129.             myCanvas->SetFont(font270);
  130.             myCanvas->DrawText(200,150,"Angled Text 270");
  131.  
  132.             myCanvas->SetFont(font0);
  133.  
  134.         break;
  135.       }
  136.  
  137.         case M_Close:           // Close not via close button
  138.           {
  139.             theApp->CloseAppWin(this);
  140.             break;
  141.           }
  142.       }
  143.   }
  144.