home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / BCPPOWL1.ZIP / OWLINC.ZIP / LISTBOX.H < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-28  |  3.1 KB  |  107 lines

  1. // ObjectWindows - (C) Copyright 1991 by Borland International
  2.  
  3. #ifndef __LISTBOX_H
  4. #define __LISTBOX_H
  5.  
  6. #ifndef __CONTROL_H
  7. #include <control.h>
  8. #endif
  9.  
  10. #ifndef __ARRAY_H
  11. #include <array.h>
  12. #endif
  13.  
  14. #ifndef __STRNG_H
  15. #include <strng.h>
  16. #endif
  17.  
  18. _CLASSDEF(TListBox)
  19. _CLASSDEF(TListBoxData)
  20.  
  21. /* --------------------------------------------------------
  22.   TListBox object
  23.   -------------------------------------------------------- */
  24.  
  25. class _EXPORT TListBox : public TControl
  26. {
  27. public:
  28.     TListBox(PTWindowsObject AParent, int AnId, int X, int Y,
  29.              int W, int H, PTModule AModule = NULL);
  30.     TListBox(PTWindowsObject AParent, int ResourceId, PTModule AModule = NULL)
  31.              : TControl(AParent, ResourceId, AModule){};
  32.  
  33.     int AddString(LPSTR AString);
  34.     int InsertString(LPSTR AString, int Index);
  35.     int DeleteString(int Index);
  36.     void ClearList();
  37.     virtual WORD Transfer(Pvoid DataPtr, WORD TransferFlag);
  38.     int GetCount();
  39.     int FindString(LPSTR AString, int SearchIndex);
  40.     int FindExactString(LPSTR AString, int SearchIndex);
  41.     int GetString(LPSTR AString, int Index);
  42.     int GetStringLen(int Index);
  43.  
  44.     // next four functions only for single-selection
  45.     // list boxes (and combo boxes).
  46.     int GetSelString(LPSTR AString, int MaxChars);
  47.     int SetSelString(LPSTR AString, int SearchIndex);
  48.     int GetSelIndex();
  49.     int SetSelIndex(int Index);
  50.  
  51.     int GetSelCount();
  52.  
  53.     // next four functions only for multiple-selection list boxes.
  54.     int GetSelStrings(LPSTR *Strings, int MaxCount, int MaxChars);
  55.     int SetSelStrings(LPSTR *Prefixes, int NumSelections,
  56.                       BOOL ShouldSet);
  57.     int GetSelIndexes(Pint Indexes, int MaxCount);
  58.     int SetSelIndexes(Pint Indexes, int NumSelections,
  59.                       BOOL ShouldSet);
  60.  
  61.     static PTStreamable build();
  62.  
  63. protected:
  64.     virtual LPSTR GetClassName() 
  65.         { return "LISTBOX"; }
  66.     virtual WORD GetMsgID(WORD AMsg);
  67.  
  68.     TListBox(StreamableInit) : TControl(streamableInit) {};
  69.  
  70. private:
  71.     virtual const Pchar streamableName() const
  72.         { return "TListBox"; }
  73. };
  74.  
  75. inline Ripstream operator >> ( Ripstream is, RTListBox cl )
  76.     { return is >> (RTStreamable )cl; }
  77. inline Ripstream operator >> ( Ripstream is, RPTListBox cl )
  78.     { return is >> (RPvoid)cl; }
  79.  
  80. inline Ropstream operator << ( Ropstream os, RTListBox cl )
  81.     { return os << (RTStreamable )cl; }
  82. inline Ropstream operator << ( Ropstream os, PTListBox cl )
  83.     { return os << (PTStreamable )cl; }
  84.  
  85. enum msgname {MN_ADDSTRING,    MN_INSERTSTRING, MN_DELETESTRING,
  86.               MN_RESETCONTENT, MN_GETCOUNT,     MN_GETTEXT,
  87.               MN_GETTEXTLEN,   MN_SELECTSTRING, MN_SETCURSEL, 
  88.               MN_GETCURSEL,    MN_FINDSTRING };
  89.  
  90. class _EXPORT TListBoxData 
  91. {
  92. public:
  93.     PArray Strings;
  94.     PArray SelStrings;
  95.     int SelCount;
  96.  
  97.     TListBoxData();
  98.     ~TListBoxData();
  99.     void AddString(Pchar AString, BOOL IsSelected = FALSE);
  100.     void SelectString(LPSTR AString);
  101.     void ResetSelections();
  102.     int GetSelStringLength(int Index = 0);
  103.     void GetSelString(LPSTR Buffer, int BufferSize, int Index = 0);
  104. };
  105.  
  106. #endif
  107.