home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / cnr / uidate / developr.cpp next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  4.0 KB  |  131 lines

  1. //************************************************************
  2. // Container Control - Dates and Times as IDate/ITime
  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 <iframe.hpp>
  9. #include <ictlevt.hpp>
  10. #include <stddef.h>
  11. #include <iexcept.hpp>
  12. #include "developr.h"
  13. #include "developr.hpp"
  14.  
  15. DeveloperList :: DeveloperList ( const char* title)
  16.                    : IFrameWindow (title, DEVELOPER_WINDOW),
  17.                      cnrctl( DEVELOPER_CONTAINER, this, this)
  18.  
  19. {
  20.  
  21. // Put the container in the client area.
  22. setClient(&container());
  23.  
  24. Developer::createAllColumnsFor(cnrctl);
  25.  
  26. // Create and add the objects to the container.
  27. Developer* developer;
  28.  
  29. developer = new Developer("Joe Programmer",
  30.                           ID_DEVELOPER,
  31.                           "12345,6789",
  32.                           "38");
  33. container().addObject(developer);
  34. container().enableDataUpdate(developer);
  35.  
  36. container().setDeleteObjectsOnClose();
  37. container().showSplitBar();
  38. }
  39.  
  40.  
  41. IContainerControl& DeveloperList :: container( ) { 
  42.   return cnrctl;
  43. }
  44.  
  45.  
  46. void Developer::createAllColumnsFor ( IContainerControl&  container)
  47. {
  48.  IContainerColumn* newColumn;
  49.  
  50.  newColumn = createAndOrphanColumnFor( container, Developer::kIconColumn);
  51.  newColumn = createAndOrphanColumnFor( container, Developer::kNameColumn);
  52.  container.setDetailsViewSplit(newColumn, 125);
  53.  newColumn = createAndOrphanColumnFor( container, Developer::kCompuServeIdColumn);
  54.  newColumn = createAndOrphanColumnFor( container, Developer::kAgeColumn);
  55.  newColumn = createAndOrphanColumnFor( container, Developer::kBirthDateColumn);
  56.  newColumn = createAndOrphanColumnFor( container, Developer::kQuittingTimeColumn);
  57.  
  58.  container.setDeleteColumnsOnClose();
  59. }
  60.  
  61.  
  62. IContainerColumn* Developer::createAndOrphanColumnFor ( 
  63.                              IContainerControl& container,
  64.                              Column             columnType)
  65. {
  66.   // Set up a default column.
  67.   IContainerColumn* newColumn = 0;
  68.   IString headingText;
  69.   Boolean editable = false;
  70.   const unsigned long invalidOffset = (unsigned long)-1;
  71.   unsigned long offset = invalidOffset;
  72.   IContainerColumn::HeadingStyle headingStyle = IContainerColumn::defaultHeadingStyle();
  73.   IContainerColumn::DataStyle dataStyle = IContainerColumn::defaultDataStyle();
  74.  
  75.   if (columnType == Developer::kNameColumn)
  76.   {
  77.     newColumn = new IContainerColumn(IContainerColumn::isIconViewText,
  78.                                      headingStyle,
  79.                                      dataStyle);
  80.     headingText = "Name";
  81.     editable = true;
  82.   }
  83.   else if (columnType == Developer::kIconColumn)
  84.   {
  85.     newColumn = new IContainerColumn(IContainerColumn::isIcon,
  86.                                      headingStyle,
  87.                                      dataStyle);
  88.     headingText = "Role";
  89.   }
  90.   else if (columnType == Developer::kCompuServeIdColumn)
  91.   {
  92.     offset = offsetof(Developer, fCompuServeId);
  93.     headingText = "CompuServe Id";
  94.     editable = true;
  95.   }
  96.   else if (columnType == Developer::kAgeColumn)
  97.   {
  98.     offset = offsetof(Developer, fAge);
  99.     headingText = "Age";
  100.     editable = true;
  101.   }
  102.   else if (columnType == Developer::kBirthDateColumn)
  103.   {
  104.     offset = offsetof(Developer, fBirthDate);
  105.     headingText = "Birth Date";
  106.   }
  107.   else if (columnType == Developer::kQuittingTimeColumn)
  108.   {
  109.     offset = offsetof(Developer, fQuittingTime);
  110.     headingText = "Quitting Time";
  111.   }
  112.   
  113.   if (newColumn == 0 && offset < invalidOffset )
  114.     newColumn = new IContainerColumn(offset,
  115.                                      headingStyle,
  116.                                      dataStyle);
  117.  
  118.   // Ensure that a new column has been created.
  119.   IASSERTSTATE(newColumn != 0)
  120.  
  121.   newColumn->setHeadingText(headingText);
  122.  
  123.   if (editable == true) 
  124.     newColumn->enableDataUpdate();
  125.  
  126.   // Add the column to the container.
  127.   container.addColumn( newColumn);
  128.  
  129.   return newColumn;
  130. }
  131.