home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / ilistbas.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  8.9 KB  |  292 lines

  1. #ifndef _ILISTBAS_
  2.   #define _ILISTBAS_
  3. /*******************************************************************************
  4. * FILE NAME: ilistbas.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IBaseListBox                                                             *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *******************************************************************************/
  18. #include <icontrol.hpp>
  19. #include <irect.hpp>
  20.  
  21. class IString;
  22. class IResourceId;
  23. class IBaseListBoxData;
  24. class IBaseListBoxCursorData;
  25.  
  26. #pragma pack(4)
  27.  
  28. class IBaseListBox : public IControl {
  29. typedef IControl
  30.   Inherited;
  31. public:
  32. class Style;
  33. class Cursor;
  34. /*------------------------------- Constructors -------------------------------*/
  35.   IBaseListBox   ( unsigned long        id,
  36.                    IWindow*             parent,
  37.                    IWindow*             owner,
  38.                    const IRectangle&    initial = IRectangle  ( ),
  39.                    const Style&         style   = defaultStyle( ) );
  40.  
  41.   IBaseListBox   ( unsigned long        id,
  42.                    IWindow*             parent );
  43.  
  44.   IBaseListBox   ( const IWindowHandle& handle );
  45.  
  46. virtual
  47.  ~IBaseListBox   ( );
  48.  
  49. /*---------------------------------- Styles ----------------------------------*/
  50. INESTEDBITFLAGCLASSDEF2(Style, IBaseListBox, IWindow, IControl);
  51.  
  52. static const Style
  53.   IC_IMPORTU classDefaultStyle,
  54.   IC_IMPORTU drawItem,
  55.   IC_IMPORTU horizontalScroll,
  56.   IC_IMPORTU multipleSelect,
  57.   IC_IMPORTU extendedSelect;
  58. static const Style
  59.   IC_IMPORTU noAdjustPosition;
  60. #ifndef IC_MOTIFPM_FLAGNOP
  61. static const Style
  62.   IC_IMPORTU border3D;
  63. #endif
  64.  
  65. static Style
  66.   defaultStyle            ( );
  67.  
  68. static void
  69.   setDefaultStyle         ( const Style&    style );
  70.  
  71. virtual unsigned long
  72.   convertToGUIStyle       ( const IBitFlag& style,
  73.                             Boolean         extendedOnly = false ) const;
  74.  
  75. Boolean
  76.   isDrawItem              ( ) const,
  77.   isHorizontalScroll      ( ) const,
  78.   isMultipleSelect        ( ) const,
  79.   isExtendedSelect        ( ) const;
  80. Boolean
  81.   isNoAdjustPosition      ( ) const;
  82.  
  83. virtual IBaseListBox
  84.  &enableDrawItem          ( Boolean enable = true ),
  85.  &disableDrawItem         ( );
  86.  
  87. #ifndef IC_WIN_FLAGNOP
  88. virtual IBaseListBox
  89.  &enableMultipleSelect    ( Boolean enable = true ),
  90.  &disableMultipleSelect   ( ),
  91.  &enableExtendedSelect    ( Boolean enable = true ),
  92.  &disableExtendedSelect   ( );
  93. #endif
  94.  
  95. virtual IBaseListBox
  96.  &enableNoAdjustPosition  ( Boolean enable = true ),
  97.  &disableNoAdjustPosition ( );
  98.  
  99. /*------------------------- Get and Change Items -----------------------------*/
  100. virtual IString
  101.   itemText                ( unsigned long      index ) const;
  102.  
  103. virtual IBaseListBox
  104.  &setItemText             ( unsigned long      index,
  105.                             const char*        string ),
  106.  &setItemText             ( unsigned long      index,
  107.                             const IResourceId& string );
  108.  
  109. virtual IString
  110.   elementAt               ( const Cursor&      cursor ) const;
  111.  
  112. /*------------------------- Selection ----------------------------------------*/
  113. virtual IBaseListBox
  114.  &select                  ( unsigned long index,
  115.                             Boolean       select = true ),
  116.  &deselect                ( unsigned long index ),
  117.  &selectAll               ( ),
  118.  &deselectAll             ( );
  119.  
  120. virtual Boolean
  121.   isSelected              ( unsigned long index ) const;
  122.  
  123. virtual unsigned long
  124.   numberOfSelections      ( ) const;
  125.  
  126. virtual long
  127.   selection               ( ) const;
  128.  
  129. /*------------------------ Scrolling Members ---------------------------------*/
  130. virtual IBaseListBox
  131.  &setTop                  ( unsigned long index );
  132.  
  133. virtual unsigned long
  134.   top                     ( ) const;
  135.  
  136. /*------------------------ Handle Members ------------------------------------*/
  137. virtual IBaseListBox
  138.  &setItemHandle           ( unsigned long index,
  139.                             unsigned long handle );
  140.  
  141. virtual unsigned long
  142.   itemHandle              ( unsigned long index ) const;
  143.  
  144. /*------------------------ Search List ---------------------------------------*/
  145. enum SearchType {
  146.   prefix,
  147.   substring,
  148.   exactMatch
  149. };
  150.  
  151. static const unsigned long
  152.   IC_IMPORTU notFound,
  153.   IC_IMPORTU first;
  154.  
  155. virtual unsigned long
  156.   locateText              ( const char*   searchString,
  157.                             Boolean       caseSensitive = true,
  158.                             SearchType    search        = exactMatch,
  159.                             unsigned long index         = first ) const;
  160.  
  161. /*------------------------- Content ------------------------------------------*/
  162. virtual unsigned long
  163.   count                   ( ) const;
  164.  
  165. virtual Boolean
  166.   isEmpty                 ( ) const;
  167.  
  168. /*------------------------- Item Height --------------------------------------*/
  169. virtual IBaseListBox
  170.  &setItemHeight           ( unsigned long newHeight );
  171.  
  172. unsigned long
  173.   itemHeight              ( ) const;
  174.  
  175.  
  176.  
  177. class Cursor : public IVBase {
  178. public:
  179. /*------------------------------ Filters --------------------------------*/
  180. enum Filter {
  181.   selectedItems,
  182.   allItems
  183. };
  184.  
  185. /*---------------------------- Constructors -----------------------------*/
  186.   Cursor                  ( const IBaseListBox& listbox,
  187.                             Filter              type = selectedItems );
  188.  
  189. virtual
  190.  ~Cursor                  ( );
  191.  
  192. /*--------------------------- Cursor Movement ---------------------------*/
  193. virtual Boolean
  194.   setToFirst              ( ),
  195.   setToNext               ( ),
  196.   setToPrevious           ( ),
  197.   setToLast               ( ),
  198.   setToIndex              ( unsigned long index );
  199.  
  200. /*-------------------------- Cursor Validation --------------------------*/
  201. virtual Boolean
  202.   isValid                 ( ) const;
  203.  
  204. virtual void
  205.   invalidate              ( );
  206.  
  207. virtual unsigned long
  208.   asIndex                 ( ) const;
  209.  
  210. private:
  211. /*-------------------------- Hidden Members -----------------------------*/
  212.   Cursor                  ( const Cursor& cursor );
  213. Cursor
  214.  &operator=               ( const Cursor& cursor );
  215.  
  216. /*------------------------------- Private -------------------------------*/
  217. const IBaseListBox
  218.  &rlbCl;
  219. unsigned long
  220.   lClCurrent;
  221. Filter
  222.   cursorTypeCl;
  223. unsigned long
  224.   sameValidation;
  225.  
  226. IBaseListBoxCursorData
  227.  *fCursorData;
  228. }; // IBaseListBox::Cursor
  229.  
  230. /*------------------------- Color --------------------------------------------*/
  231. virtual IColor
  232.   backgroundColor         ( ) const;
  233.  
  234. /*------------------------- Layout Support -----------------------------------*/
  235. virtual IBaseListBox
  236.  &setLayoutDistorted      ( unsigned long layoutAttributesOn,
  237.                             unsigned long layoutAttributesOff ),
  238.  &setMinimumCharacters    ( unsigned long minimumCharacters ),
  239.  &setMinimumRows          ( unsigned long minimumRows );
  240.  
  241. unsigned long
  242.   minimumCharacters       ( ) const,
  243.   minimumRows             ( ) const;
  244.  
  245. /*------------------------- Notification Members -----------------------------*/
  246. static INotificationId const
  247.   IC_IMPORTU enterId,
  248.   IC_IMPORTU selectId;
  249.  
  250. virtual IBaseListBox
  251.  &enableNotification      ( Boolean enable = true );
  252.  
  253. protected:
  254. /*------------------------- Layout Support -----------------------------------*/
  255. virtual ISize
  256.   calcMinimumSize         ( ) const;
  257.  
  258.  
  259. /*------------------------------- Item Changes -------------------------------*/
  260. unsigned long
  261.   changeCount             ( ) const;
  262.  
  263. void
  264.   incrementChangeCount    ( );
  265.  
  266. private:
  267. /*------------------------------ Hidden Members ------------------------------*/
  268.   IBaseListBox            ( const IBaseListBox& listBox );
  269. IBaseListBox
  270.  &operator=               ( const IBaseListBox& listBox );
  271.  
  272. /*--------------------------------- Private ----------------------------------*/
  273. friend class IBaseListBox::Cursor;
  274. friend class IBaseListHandler;
  275.  
  276.  
  277. static Style
  278.   currentDefaultStyle;
  279.  
  280. unsigned long
  281.   needValidation;
  282.  
  283. IBaseListBoxData
  284.  *fBaseListBoxData;
  285. }; // IBaseListBox
  286.  
  287. INESTEDBITFLAGCLASSFUNCS(Style, IBaseListBox);
  288.  
  289. #pragma pack()
  290.  
  291. #endif  /* _ILISTBAS_ */
  292.