home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional Developers Kit 1992 November / Disc01 / Disc01.mdf / cppbeta / clsam3j / win.cp_ / WIN.CPP
Encoding:
C/C++ Source or Header  |  1992-10-19  |  4.7 KB  |  127 lines

  1. /**************************************************************************/
  2. /* Sample Program for IBMCLASS - Main Window Class implementation         */
  3. /*                                                                        */
  4. /* Change History:                                                        */
  5. /* Rel Programmer        Stamp Date     Description                       */
  6. /* --- ----------------- ----- -------- --------------------------------- */
  7. /* 2.0 Kevin Leong       KKL   30/12/91 Creation                          */
  8. /* 3.0 Kevin Leong       KKL   01/08/92 Modify for V3.0 classes           */
  9. /* 3.1 Philippe Gregoire PHG   10/09/92 Add more stuff for demo           */
  10. /**************************************************************************/
  11.  
  12. /* include IBMCLASS headers */
  13. #include <iapp.hpp>           // IApplication
  14. #include <ireslib.hpp>        // IResourceLibrary/IResourceId
  15.  
  16. #include <itrace.hpp>         // ITrace
  17.  
  18. #include <idrgsrch.hpp>
  19.  
  20. /* include our classes definitions */
  21. #include "win.hpp"
  22.  
  23. /* include our symbols definitions */
  24. #include "win.h"
  25.  
  26.  
  27. /**************************************************************************/
  28. /* main                                                         KKL 01/08 */
  29. /*   Application entry point                                              */
  30. /**************************************************************************/
  31. void main()
  32. {
  33.  
  34.    // create our main window has child of the desktop
  35.    MyWindow myWin(WND_MAIN);
  36.  
  37.    // run the aplication
  38.    IApplication::current.run();
  39.  
  40. }/* end main */
  41.  
  42. /**************************************************************************/
  43. /* MyWindow::MyWindow                                           KKL 01/08 */
  44. /*   Constructor for our main window                                      */
  45. /**************************************************************************/
  46. MyWindow::MyWindow( unsigned long windowId)
  47.  : IFrameWindow(windowId)
  48. {
  49.    // set ourselves as event handler, since we multiple-inherit
  50.    addHandler((IHandler *)this);
  51.  
  52.    // set main menu
  53.    IActionBarMenu* pabmnMain=new IActionBarMenu(WND_MAIN,this);
  54.  
  55.    // Create client fill-box and set as client
  56.    pMyClient = new MyClientWindow(MY_CLIENT,this);
  57.    setClient(pMyClient);
  58.  
  59.    // Create static text status area
  60.    psttxtStatus = new IStaticText(ST_STATUS, this, this, IRectangle());
  61.    psttxtStatus->setText(STR_NOSTATUS);
  62.  
  63.    // set status line on top of client fill-box
  64.    addControl(psttxtStatus,
  65.               IFrCtlAttr::placeTop | IFrCtlAttr::splitBar,
  66.               pMyClient, None, 30);
  67.  
  68.    // Create titlebar icon
  69.    pbcTBIcon = new IBitmapControl(BM_TBICON, this, this, IRectangle(),
  70.                                   BM_TBICON);
  71.  
  72.    // set this one as extension, left of titlebar
  73.    addControl(pbcTBIcon,
  74.               IFrCtlAttr::placeLeft | IFrCtlAttr::thinSepLine,
  75.               0, Titlebar, 30);
  76.  
  77.    // Create D&D source handler for titlebar icon
  78.    psrchTBIcon=new IDragSourceHandler();
  79.    IDragItem* pdrgitmTBIcon= new IDragItem(pbcTBIcon,
  80.                                            0L,
  81.                                            "IBMICON", "<CUSTOMER,NONE>",
  82.                                            IDragItem::moveable);
  83.    pdrgitmTBIcon->setDragImage(new IDragImage(IResourceId(BM_TBICON),
  84.                                               ISize(0,0),ISize(0,0),
  85.                                               false));
  86.    psrchTBIcon->dragItemList().add(pdrgitmTBIcon);
  87.    pbcTBIcon->addHandler(psrchTBIcon);
  88.  
  89.    // Create list-box
  90.    plbCustList=new IListBox(LB_CUSTLIST, this, this, IRectangle());
  91.  
  92.    // set this one as extension, right of client, 1/3 size
  93.    addControl(plbCustList,
  94.               IFrCtlAttr::placeRight | IFrCtlAttr::splitBar,
  95.               pMyClient, 0, IPair(1,3));
  96.  
  97.    // size and show main frame window
  98.    sizeTo(ISize(400,300));
  99.    moveTo(ISize(100,100));
  100.    show();
  101.  
  102. }/* end MyWindow :: MyWindow(...) */
  103.  
  104.  
  105. /**************************************************************************/
  106. /* MyWindow :: command                                          PHG 10/09 */
  107. /*   Handle menu commands                                                 */
  108. /**************************************************************************/
  109. Boolean MyWindow :: command(ICommandEvent& cmdevt)
  110. {
  111.   switch(cmdevt.commandId()) {
  112.     case MI_NEXT:
  113.       psttxtStatus->setText(STR_LOADCUST);
  114.       psttxtStatus->setText(pMyClient->nextCustomer());
  115.       return(true);
  116.       break;
  117.  
  118.     case MI_PREVIOUS:
  119.       psttxtStatus->setText(STR_LOADCUST);
  120.       psttxtStatus->setText(pMyClient->previousCustomer());
  121.       return(true);
  122.       break;
  123.   }/* end switch */
  124.  
  125.   return(false);
  126. }/* end MyWindow :: command(...) */
  127.