home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / uidemo / bigstrvw / bigstrv.h < prev    next >
C/C++ Source or Header  |  1995-02-25  |  2KB  |  55 lines

  1.  
  2. #ifndef _bigstrv_h_
  3. #define _bigstrv_h_
  4.  
  5.  
  6.  
  7. // A BigStringView is a StringView that can display large numbers of
  8. // strings. It uses a StringSequence as its model, and the latter can hold
  9. // millions of strings.
  10. //
  11. // The BigStringView class is provided to illustrate how the graphic
  12. // capabilities can be used for building custom widgets. It simulates a
  13. // normal StringView  by drawing a view area and the strings in it, and
  14. // managing the scroll bar appropriately.
  15.  
  16.  
  17. #include "ui/scrolbar.h"
  18. #include "ui/vobjcoll.h"
  19. #include "base/strgseq.h"
  20.  
  21. class BigStringView: public UI_VObjCollection {
  22.  
  23. public:
  24.     BigStringView (UI_VObjCollection* parent, const UI_Rectangle& shape,
  25.                    CL_StringSequence& model, UI_ViewID id = -1);
  26.  
  27.     CL_Object& Model() {return _modelSeq;};
  28.  
  29.     long Selection () {return _selection; };
  30.     
  31. protected:
  32.     UI_VScrollBar*       _scrollBar;
  33.     CL_StringSequence&   _modelSeq;
  34.     short                _visibleCount;  // Number of visible strings
  35.     long                 _selection;     // Index of selected string in
  36.                                          // model sequence; -1 if no selection
  37.  
  38.     bool MakeVisualElement () {return UI_VObjCollection::MakeVisualElement();}
  39.     void Initialize ();
  40.     bool Paint ();
  41.     bool ButtonDown (const UI_Point& position, UI_MouseButton btn,
  42.                      bool shiftKey, bool ctrlKey); 
  43. private:
  44.     bool _Scroll (CL_Object&, long);
  45.     // Called when the scroll bar is scrolled
  46.  
  47.     bool _ModelChanged (CL_Object&, long);
  48.     bool _DrawClientArea ();
  49.  
  50.     void _SetupScrollBar ();
  51.     
  52. };
  53.  
  54. #endif /* _bigstrv_h_ */
  55.