home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / pwrgu2.zip / POWERGU2.EXE / LISTCTLS / DRAWLIST / DRAWLIST.CPP next >
Text File  |  1995-07-25  |  3KB  |  89 lines

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