home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / strseq.h < prev    next >
C/C++ Source or Header  |  1995-04-09  |  3KB  |  123 lines

  1.  
  2.  
  3. #ifndef _strseq_h_
  4. #define _strseq_h_
  5.  
  6.  
  7.  
  8.  
  9.  
  10. /*
  11.  *
  12.  *          Copyright (C) 1994, M. A. Sridhar
  13.  *  
  14.  *
  15.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  16.  *     to copy, modify or distribute this software  as you see fit,
  17.  *     and to use  it  for  any  purpose, provided   this copyright
  18.  *     notice and the following   disclaimer are included  with all
  19.  *     copies.
  20.  *
  21.  *                        DISCLAIMER
  22.  *
  23.  *     The author makes no warranties, either expressed or implied,
  24.  *     with respect  to  this  software, its  quality, performance,
  25.  *     merchantability, or fitness for any particular purpose. This
  26.  *     software is distributed  AS IS.  The  user of this  software
  27.  *     assumes all risks  as to its quality  and performance. In no
  28.  *     event shall the author be liable for any direct, indirect or
  29.  *     consequential damages, even if the  author has been  advised
  30.  *     as to the possibility of such damages.
  31.  *
  32.  */
  33.  
  34.  
  35.  
  36.  
  37. #if defined(__GNUC__)
  38. #pragma interface
  39. #endif
  40.  
  41.  
  42.  
  43. #include "base/strgseq.h"
  44. #include "base/objset.h"
  45.  
  46.  
  47. // The class {\small\tt UI_StringSequence} serves as model for the
  48. // {\small\tt StringView} class. It adds methods to the base class
  49. // {\small\tt CL_StringSequence} so that it can be notified when one of
  50. // the contained strings is modified. Also provided in this class are
  51. // methods for adding and removing clients explicitly; these are useful to
  52. // allow multiple {\small\tt StringView} objects to share the same model.
  53.  
  54. class CL_EXPORT UI_StringView;
  55.  
  56. class CL_EXPORT UI_StringSequence: public CL_StringSequence {
  57.  
  58. public:
  59.  
  60.     void AddClient    (UI_StringView* );
  61.  
  62.     void RemoveClient (UI_StringView* );
  63.  
  64.     virtual bool Insert (const CL_String& s, long index = -1);
  65.     // Override the CL_StringSequence method to add dependency.
  66.  
  67.     virtual CL_String Remove (long index);
  68.  
  69.     virtual bool ShiftLeftAt  (long pos, long amount = 1);
  70.  
  71.     virtual bool ShiftRightAt (long pos, long amount = 1);
  72.  
  73.     CL_Sequence<CL_String>& operator= (const CL_Sequence<CL_String>&);
  74.  
  75.     void operator= (const CL_Object&);
  76.  
  77.     void MakeEmpty ();
  78.  
  79.     CL_Sequence<CL_String>& operator+= (const CL_Sequence<CL_String>& s);
  80.  
  81. #ifndef __GNUC__ // Temporarily disable these methods to work around
  82.                  // the GCC bug
  83.     void operator-= (const CL_IntegerSet& s);
  84.  
  85. #endif    // __GNUC__
  86.   
  87.     
  88.     
  89.     bool ChangeSize (long new_size);
  90.  
  91.     bool Sort (long pos, long len);
  92.     
  93. protected:
  94.  
  95.  
  96.     void _InsertionUpdate (long );
  97.  
  98.     void _RemovalUpdate   (long );
  99.  
  100.     void _ChangeUpdate    (long );
  101.  
  102.     void _ReassignCodes ();
  103.     
  104.     bool Update (CL_Object&, long);
  105.     // Invoked when the underlying array changes. Invokes Notify on its
  106.     // dependents, if any.
  107.  
  108.  
  109.  
  110.     CL_ObjectSet      _clientSet;
  111.     CL_String         _nullString;
  112. };
  113.  
  114.  
  115. inline void UI_StringSequence::operator= (const CL_Object& o)
  116. {
  117.     if (o.IsA (*this))
  118.         *this = (const CL_Sequence<CL_String>&) o;
  119. }
  120.  
  121. #endif
  122.  
  123.