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

  1.  
  2.  
  3.  
  4.  
  5. #ifndef _vobjcoll_h_ /* Fri Nov 25 12:49:45 1994 */
  6. #define _vobjcoll_h_
  7.  
  8.  
  9.  
  10.  
  11.  
  12. /*
  13.  *
  14.  *          Copyright (C) 1994, M. A. Sridhar
  15.  *  
  16.  *
  17.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  18.  *     to copy, modify or distribute this software  as you see fit,
  19.  *     and to use  it  for  any  purpose, provided   this copyright
  20.  *     notice and the following   disclaimer are included  with all
  21.  *     copies.
  22.  *
  23.  *                        DISCLAIMER
  24.  *
  25.  *     The author makes no warranties, either expressed or implied,
  26.  *     with respect  to  this  software, its  quality, performance,
  27.  *     merchantability, or fitness for any particular purpose. This
  28.  *     software is distributed  AS IS.  The  user of this  software
  29.  *     assumes all risks  as to its quality  and performance. In no
  30.  *     event shall the author be liable for any direct, indirect or
  31.  *     consequential damages, even if the  author has been  advised
  32.  *     as to the possibility of such damages.
  33.  *
  34.  */
  35.  
  36.  
  37.  
  38. #if defined(__GNUC__)
  39. #pragma interface
  40. #endif
  41.  
  42.  
  43. #include "ui/visualob.h"
  44. #include "ui/viewdesc.h"
  45.  
  46. #include "base/iterator.h"
  47.  
  48.  
  49. class CL_EXPORT UI_VObjCollection: public UI_VisualObject {
  50.  
  51. public:
  52.     // ------------------- View-related methods ---------------
  53.     
  54.     virtual bool Enable ();
  55.     // Allow view to capture events. This overrides the inherited method;
  56.     // the overriding code enables all descendants.
  57.  
  58.     virtual bool Disable ();
  59.     // Prevent view from capturing events. This overrides the inherited
  60.     // method; the overriding code disables all descendants.
  61.  
  62.     virtual void MakeInvisible ();
  63.     // This overrides the inherited method with code that makes all
  64.     // descendants invisible.
  65.     
  66.     virtual void MakeVisible ();
  67.     // This overrides the inherited method with code that makes all
  68.     // descendants visible.
  69.  
  70.     virtual UI_VisualObject* operator [] (UI_ViewID id);
  71.     // Return a pointer to the child with the given ID. The return value
  72.     // is NULL if there is no such child.
  73.     
  74.     long ChildCount ();
  75.     // Return the number of children of this collection.
  76.  
  77.     bool Contains (UI_ViewID id);
  78.     // Test whether the object with ID 'id' is a child of this
  79.     // collection.
  80.  
  81.     virtual UI_WindowClass WindowClass () const;
  82.     
  83.  
  84.     const char* ClassName() const { return "UI_VObjCollection";};
  85.  
  86.  
  87.  
  88. protected:
  89.     
  90.     // ---------------------- Construction ----------------------------
  91.  
  92.     UI_VObjCollection (UI_VObjCollection* parent,
  93.                        const UI_Rectangle& shape, UI_ViewID id = -1);
  94.  
  95.     ~UI_VObjCollection ();
  96.  
  97.     virtual bool MakeVisualElement () = 0;
  98.     
  99.     // 
  100.     // Method for child event inspection:
  101.     // 
  102.  
  103.     virtual bool HandleChildEvent (const UI_Event& e) {return FALSE;};
  104.     // This is a hook for inspecting and processing any event originating
  105.     // in any of the contained objects that are passed up to this
  106.     // VObjCollection. The default implementation simply returns
  107.     // FALSE. It may be overridden in derived class for custom event handling.
  108.  
  109.     bool DestroyVisualElement ();
  110.  
  111.     bool _ModelChanged (CL_Object&, long);
  112.  
  113.     void _PrivateInitialize();
  114.  
  115.  
  116.     friend class UI_Controller;
  117.     friend class UI_VObjCollIterator;
  118.  
  119.     // 
  120.     // Instance Variables:
  121.     // 
  122.  
  123.     CL_IntPtrMap       _objMap;
  124.  
  125. public:
  126.     virtual void AddChild    (UI_VisualObject* child);
  127.     // [YACL internal use only]
  128.  
  129.     virtual UI_VisualObject* RemoveChild (UI_VisualObject* view);
  130.     // [YACL internal use only]
  131.  
  132.     bool SetFont (UI_Font* font);
  133.     // [YACL internal use only]
  134.  
  135. private:
  136.     bool _PrivateHandleChildEvent (UI_Event& e);
  137.     // The real child event gateway.
  138.     
  139. };
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146. // The VObjCollIterator is a means of iterating over all the children of a
  147. // VObjCollection. This object can only be created on a VObjCollection
  148. // {\it after\/} the latter is initialized and ready for display.
  149. //
  150. // Warning: do not add or remove children from a VObjCollection while an
  151. // iterator is active.
  152.  
  153.  
  154. class UI_VObjCollIterator {
  155.  
  156. public:
  157.     UI_VObjCollIterator (UI_VObjCollection& v);
  158.     // Construct an iterator on the VObjCollection v.
  159.  
  160.     void Reset ();
  161.     // Reset the iterator to the beginning.
  162.  
  163.     UI_VisualObject* Next ();
  164.     // Return a pointer to the next child of our collection. Return NULL if
  165.     // there are no more children.
  166.  
  167.     bool More ();
  168.     
  169. protected:
  170.     CL_IntPtrMapIterator _itr;
  171.  
  172. };
  173.  
  174.  
  175. #endif /* _vobjcoll_h_ */
  176.