home *** CD-ROM | disk | FTP | other *** search
/ Xentax forum attachments archive / xentax.7z / 8090 / ModelEdit.7z / ltwintreeitem.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-03-08  |  3.6 KB  |  129 lines

  1. ////////////////////////////////////////////////////////////////
  2. //
  3. // ltwintreeitem.h
  4. //
  5. // This is the item class used by CLTWinTreeMgr. They form the
  6. // basis for a tree data structure. This class is meant to be
  7. // derived from by user data types, and then used within the
  8. // tree. Through GetType, numerous item types can be used in a
  9. // single tree. To access the tree, iterators are used, for more
  10. // information, see ltwintreeitemiter.h
  11. //
  12. // Author: John O'Rorke
  13. // Created: 7/21/00
  14. // Modification History:
  15. //
  16. ////////////////////////////////////////////////////////////////
  17. #ifndef __LTWINTREEITEM_H__
  18. #define __LTWINTREEITEM_H__
  19.  
  20. #ifndef __LTWINTREEICON_H__
  21. #    include "ltwintreeicon.h"
  22. #endif
  23.  
  24. #include "stdafx.h"
  25.  
  26. //forward reference so that we can declare it a friend
  27. class CLTWinTreeMgr;
  28.  
  29. //forward reference the iterator class
  30. class CLTWinTreeItemIter;
  31.  
  32. class CLTWinTreeItem
  33. {
  34. public:
  35.  
  36.     //unique identifier for this item
  37.     enum    {    BASE_ITEM    = 0xff    };
  38.  
  39.     //default constructor
  40.     CLTWinTreeItem(const char* pszText, CLTWinTreeIcon nIcon = DEFAULTICON);
  41.  
  42.     //deault destructor
  43.     virtual ~CLTWinTreeItem();
  44.  
  45.     //creates an iterator that iterates through all the siblings, starting
  46.     //with this current tree item. NOTE: the callee is responsible for
  47.     //deleting the iterator
  48.     CLTWinTreeItemIter*        CreateSiblingIter();
  49.  
  50.     //crates an iterator that iterates through all the children, starting
  51.     //with the first child. NOTE: the callee is responsible for
  52.     //deleting the iterator
  53.     CLTWinTreeItemIter*        CreateChildIter();
  54.  
  55.     //used for finding equal items
  56.     virtual BOOL operator==(const CLTWinTreeItem& rhs) const;
  57.  
  58.     //gets the unique identifier for the type of item this is
  59.     virtual DWORD    GetType() const;
  60.  
  61.     //determines if this item is selected or not
  62.     BOOL IsSelected() const;
  63.  
  64.     //gets the text associated with the item
  65.     const char* GetText() const;
  66.     
  67.     //returns the index to the icon associated with this item
  68.     CLTWinTreeIcon    GetIcon() const;
  69.  
  70.     //determines if this is a valid drop target for the passed
  71.     //in item
  72.     virtual BOOL    IsDropTarget(const CLTWinTreeItem* pItem) const;
  73.  
  74.     //determines if the text can be modified by the user
  75.     BOOL            IsTextEditable() const;
  76.  
  77.     //sets whether or not the text is modifiable
  78.     void            SetTextEditable(BOOL bEditable);
  79.  
  80.     //determines if this object is, or contains the object as a child
  81.     BOOL            ContainsObject(const CLTWinTreeItem* pItem);
  82.  
  83. private:
  84.  
  85.     //make the tree manager a friend so it can handle list management
  86.     friend class CLTWinTreeMgr;
  87.  
  88.     // make the iterator class a friend so it can look at the next
  89.     // sibling
  90.     friend class CLTWinTreeItemIter;
  91.  
  92.     //don't allow copying of these items
  93.     CLTWinTreeItem(const CLTWinTreeItem& rhs)    {}
  94.  
  95.     //handle to the tree item in the actual tree control
  96.     //note: This is UI dependent, and when porting to other
  97.     //UIs, this should be changed
  98.     HTREEITEM            m_hTreeItem;
  99.  
  100.     //Pointer to the next sibling in the list
  101.     CLTWinTreeItem*        m_pNextSibling;
  102.  
  103.     //pointer to the previous sibling in the list
  104.     CLTWinTreeItem*        m_pPrevSibling;
  105.  
  106.     //pointer to the first child
  107.     CLTWinTreeItem*        m_pFirstChild;
  108.  
  109.     //pointer to the parent item
  110.     CLTWinTreeItem*        m_pParent;
  111.  
  112.     //boolean to determine if this item is selected
  113.     BOOL                m_bSelected;
  114.  
  115.     //the index for the icon of this item
  116.     CLTWinTreeIcon        m_Icon;
  117.  
  118.     //the text for the item. This is private and can only
  119.     //be set by the constructor so that the text on the item
  120.     //doesn't get out of sync with the tree control. The manager
  121.     //can also set the text
  122.     CString                m_sText;
  123.  
  124.     //determines if the user can modify the name of this item
  125.     BOOL                m_bEditText;
  126. };
  127.  
  128. #endif
  129.