home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 3.ddi / OWLINC.ZIP / LISTBOX.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  3.3 KB  |  117 lines

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