home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / VFORM.ZIP / Source / VRowMorph.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-10  |  3.7 KB  |  95 lines

  1. // -------------------------------------------------------------------------
  2. // Copyright @ 1997 TCK Software, Incorporated
  3. // All Rights Reserved
  4. // -------------------------------------------------------------------------
  5. #ifndef __VROWMORPH_H__
  6. #define __VROWMORPH_H__
  7.  
  8. #include "VRow.h"
  9.  
  10. // #include "afxtempl.h"                // Already in VRow.h
  11.  
  12. // -------------------------------------------------------------------------
  13. // NOTES: Two possible ways to do a morphing row
  14. //
  15. //        1) Contain an array of actual rows in the Morphing row
  16. //            - reset the control pointer array as needed
  17. //            - delegate background drawing to active contained row
  18. //            - this requires using multiple virtual functions
  19. //            - also must ensure m_nRowId and m_pForm are set for contained rows
  20. //
  21. //        2) Morph row contains various "profiles", when one of these is set
  22. //            the control pointer array is set to that profile.
  23. //            - less problems this way, but developer must put all profiles in
  24. //              this one class.
  25. //
  26. // Also - at this time, for simplicity, we have decided to maintain a singular
  27. // row size for VForm.  If our customers inform us of a strong desire for
  28. // varying row sizes at the same time, that is something we could add.
  29. //
  30. // How to use:
  31. //        1) Derive a class from VRowMorph
  32. //        2) Include groups of controls in the class (one group for each row type)
  33. //        3) In the constructor, creat a profile for each group of controls
  34. //            - then add the controls to their respective profiles
  35. //        4) Finally, set the current profile
  36. //        5) In VForm::OnGetRow(), you must set which profile the row use
  37. //        6) Similarly, OnAddRow(), OnSaveRow(), etc. must all use the
  38. //            appropriate group/profile and the fields that go with it.
  39. //
  40. // By using VRowMorph, you can easily create a Tree control using VForm
  41. //   - you must combine the multiple row types with ResetNumRows() to
  42. //     expand and collapse rows
  43. //   - the tricky part is keeping track of the underlying data, and which
  44. //     row number corresponds to each data item.  This will vary depending
  45. //     on which rows are expanded or collapsed.
  46. //   - BUT... since VForm can be used completely virtually, you can
  47. //     achieve greater performance than on any control that you must load
  48. //     all the data.
  49. //
  50. // -------------------------------------------------------------------------
  51.  
  52. class VRowMorph;
  53.  
  54. // -------------------------------------------------------------------------
  55. // VMorphProfile Class - Helper for morphing VRow
  56. // -------------------------------------------------------------------------
  57. class AFX_EXT_CLASS VMorphProfile
  58. {
  59.     friend class VRowMorph;            // Let VRowMorph class use us
  60. protected:
  61.     VCtlPtrArray    m_ctl;                // Control Array
  62.     int                m_nCtls;            // Number of controls
  63. public:
  64.     VMorphProfile();                    // Constructor
  65.  
  66.     VMorphProfile&    operator =(VMorphProfile &x);
  67.     void    AddCtl(VCtl *xCtl);        // Adds a control to this profile
  68. };
  69.  
  70.  
  71. // typedef CArray<VRow *, VRow *> VRowPtrArray;
  72. typedef CArray<VMorphProfile, VMorphProfile&> VProfileArray; 
  73.  
  74. // -------------------------------------------------------------------------
  75. // VRowMorph Class - Morphing VRow class - row displayed depends on data
  76. // - derived from the normal VRow class
  77. // -------------------------------------------------------------------------
  78. class AFX_EXT_CLASS VRowMorph : public VRow
  79. {
  80. public:
  81.     VRowMorph();
  82.  
  83.     void    SetProfileIdx(int nIdx);
  84.     int        GetProfileIdx()                { return m_nProfileIdx; }
  85.     void    NewProfile(int nIdx);            // Adds/Clears a profile
  86.     VMorphProfile*    GetProfile(int nIdx=-1);
  87.  
  88.     virtual int        RowType()    { return m_nProfileIdx; }
  89.  
  90. protected:
  91.     int                m_nProfileIdx;            // Which Profile are we?
  92.     VProfileArray    m_profileArr;            // Array of profiles
  93. };
  94.  
  95. #endif