home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / cnr / spreadsh / spreadsh.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  2.1 KB  |  80 lines

  1. //************************************************************
  2. // Container Control - Spreadsheet Behavior
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //************************************************************
  8. #include <iapp.hpp>
  9. #include <iframe.hpp>
  10. #include <ipoint.hpp>
  11. #include <icnrctl.hpp>
  12. #include <icnrcol.hpp>
  13. #include <icnrhdr.hpp>
  14. #include <icnrehdr.hpp>
  15. #include <new.h>
  16. #include "table.hpp"
  17. #include "sprdhdr.hpp"
  18.  
  19. void main()
  20. {
  21.  
  22. IFrameWindow cnrFrame("Container SpreadSheet View");
  23. cnrFrame.sizeTo(ISize(450,200));
  24.  
  25. IContainerControl cnr(0x101,
  26.                       &cnrFrame,
  27.                       &cnrFrame);
  28.  
  29. // Put container in client area
  30. cnrFrame.setClient(&cnr);
  31.  
  32.  
  33.  
  34. // Create a bunch of Table Objects with columnCount fields
  35. TableObject::setFieldCount(10);
  36. int obj, col;
  37. IString objectName;
  38. TableObject* pobject = 0;
  39. for (obj=0; obj<50;obj++ ) {
  40.   pobject = new TableObject;
  41.   cnr.addObject(pobject);
  42.   for (col=0; col<TableObject::fieldCount(); col++ ) {
  43.      pobject->setFieldText(IString("Obj: ") + IString(obj) +
  44.                 IString(" Col: ") + IString(col),col);
  45.      pobject->enableDataUpdate();
  46.      // Add the heading text when building the first object.
  47.      if (obj==0) 
  48.         pobject->setHeadingText(IString("Column ") + IString(col), col);
  49.   } /* endfor */
  50. } /* endfor */
  51.  
  52.  
  53. // Create the container columns for all fields.
  54. pobject->createAllColumnsFor(cnr);
  55.  
  56. cnr.setDeleteObjectsOnClose();
  57.  
  58. // Create Container EditHandler.
  59. // Create a Default Handler for the Container Edit Field
  60. // and energize it.
  61. ICnrEditHandler* pcnrEdit = new ICnrEditHandler();
  62. pcnrEdit->handleEventsFor(&cnr);
  63.  
  64. // Create the default ContainerHandler.
  65. ICnrHandler* pcnrHandler = new ICnrHandler();
  66. pcnrHandler->handleEventsFor(&cnr);
  67.  
  68. // Create Our Handler for Tabbing the Container.
  69. CnrSpreadSheetHandler* psprdHandler= new CnrSpreadSheetHandler(cnr);
  70. psprdHandler->handleEventsFor(&cnr);
  71.  
  72. // Show the details view.
  73. cnr.showDetailsView();
  74.  
  75. cnrFrame.show();
  76. cnrFrame.setFocus();
  77.  
  78. IApplication::current().run();
  79. }
  80.