home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / listctls / drawlist / drawlist.cpp next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  4.1 KB  |  98 lines

  1. /************************************************************
  2. / List Controls - List Box Custom Drawing
  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 <iapp.hpp>
  10. #include <ilistbox.hpp>
  11. #include <istring.hpp>
  12. #include <icolor.hpp>
  13. #include <icconst.h>
  14. #include "listdhdr.hpp"
  15. #include "listitem.hpp"
  16.  
  17. void main()
  18. {
  19.   IFrameWindow frame("List box Custom Drawing");
  20.   DrawHandler listHandler;
  21.  
  22.   // Attach to the list box owner so that we get the
  23.   // setSize event during the creation of the list box.
  24.   listHandler.handleEventsFor(&frame);
  25.  
  26.   // Create a client area list box.
  27.   IListBox list(IC_FRAME_CLIENT_ID, &frame, &frame, IRectangle(),
  28.                 IListBox::defaultStyle() | IWindow::saveBits
  29.                  | IListBox::drawItem);
  30.  
  31.   // Make the background of the list box white.
  32.   list.setBackgroundColor(IColor::white);
  33.  
  34.   // Dummy up the data for each class in the
  35.   // hierarchy.
  36.   ListItem items[]
  37.      =  {ListItem("IBase",                  0, true,  false),
  38.         ListItem("IVBase",                  1, true,  false),
  39.         ListItem("INotifier",               2, true,  false),
  40.         ListItem("IStandardNotifier",       3, true,  true),
  41.         ListItem("IWindow",                 3, true,  false),
  42.         ListItem("IControl",                4, true,  false),
  43.         ListItem("IBaseListBox",            5, true,  false),
  44.         ListItem("ICollectionViewListBox",  6, false, false),
  45.         ListItem("IListBox",                6, false, false),
  46.         ListItem("IBaseSpinButton",         5, true,  false),
  47.         ListItem("INumericSpinButton",      6, false, false),
  48.         ListItem("ITextSpinButton",         6, false, false),
  49.         ListItem("ICanvas",                 5, true,  true),
  50.         ListItem("IContainerControl",       5, false, false),
  51.         ListItem("INotebook",               5, false, false),
  52.         ListItem("IScrollBar",              5, false, false),
  53.         ListItem("ITextControl",            5, true, false),
  54.         ListItem("IButton",                 6,true, false),
  55.         ListItem("IPushButton",             7,true, false),
  56.         ListItem("IGraphicPushButton",      8,false, false),
  57.         ListItem("ISettingButton",          7,true, false),
  58.         ListItem("I3StateCheckBox",         8,false, false),
  59.         ListItem("ICheckBox",               8,false, false),
  60.         ListItem("IRadioButton",            8,false, false),
  61.         ListItem("IEntryField",             6,true, false),
  62.         ListItem("IBaseComboBox",           7, true,  false),
  63.         ListItem("ICollectionViewComboBox", 8, false, false),
  64.         ListItem("IComboBox",               8, false, false),
  65.         ListItem("IGroupBox",               6,false, false),
  66.         ListItem("IMultiLineEdit",          6,false, false),
  67.         ListItem("IStaticText",             6,true, false),
  68.         ListItem("IBitmapControl",          7,false, true),
  69.         ListItem("IInfoArea",               7,false, false),
  70.         ListItem("ITitle",                  6,false, false),
  71.         ListItem("IFrameWindow",      4,true, false),
  72.         ListItem("IFileDialog",       5,false, false),
  73.         ListItem("IFontDialog",       5,false, false),
  74.         ListItem("IHelpWindow",       4,false, false),
  75.         ListItem("IMenu",             4,true, false),
  76.         ListItem("IMenuBar",          5,false, false),
  77.         ListItem("IPopUpMenu",        5,false, false),
  78.         ListItem("ISubmenu",          5,false, false),
  79.         ListItem("ISystemMenu",       5,false, false),
  80.         ListItem("IObjectWindow",     4,false, false)};
  81.  
  82.   // Add the items to the list box by creating an
  83.   // IString from the item data address.
  84.   for(int i=0; i< sizeof(items)/sizeof(ListItem); i++)
  85.   {
  86.     list.add(i, IString((unsigned long)&items[i]));
  87.   }
  88.  
  89.   // Put the list box in the client and show the application.
  90.   frame
  91.     .setClient(&list)
  92.     .setFocus()
  93.     .show();
  94.  
  95.   IApplication::current().run();
  96. }
  97.  
  98.