00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef CATTreeCtrl_H_
00017 #define CATTreeCtrl_H_
00018
00019 #include "CATControlWnd.h"
00020 #include <commctrl.h>
00021
00022
00023 struct CATTREEINFO
00024 {
00025 CATString DisplayText;
00026 void* DataPtr;
00027 struct CATTREEINFO* Parent;
00028 std::vector<CATTREEINFO*> Children;
00029 CATInt32 ItemHandle;
00030 CATInt32 ImageNumber;
00031 };
00032
00033
00034
00035
00036
00037 class CATTreeCtrl : public CATControlWnd
00038 {
00039 public:
00040 CATTreeCtrl( const CATString& element,
00041 const CATString& rootDir);
00042
00043 virtual ~CATTreeCtrl();
00044
00045 virtual bool OnControlEvent( const CATEvent& event, CATInt32& result);
00046 virtual CATResult OnEvent(const CATEvent& event, CATInt32& retVal);
00047
00048
00049 virtual void SetFocused(bool focused);
00050
00051
00052 virtual void OnEscapeChange();
00053
00054 virtual void OnParentCreate();
00055 virtual void OnParentDestroy();
00056
00057 virtual CATTREEINFO* GetCurItem();
00058 virtual CATTREEINFO* GetRootItem(CATUInt32 index);
00059 virtual CATUInt32 GetNumRootItems();
00060 virtual CATResult SetCurItem(CATTREEINFO* item, bool sendCommand = true);
00061
00062 virtual CATResult SetItemText(CATTREEINFO* item, const CATString& text);
00063 virtual CATResult ExpandItem(CATTREEINFO* item, bool expand);
00064
00065 virtual CATResult Insert( const CATString& displayText,
00066 CATTREEINFO* parent,
00067 CATTREEINFO*& newItemRef,
00068 void* dataPtr,
00069 CATUInt32 index = -1,
00070 CATUInt32 imageNumber = -1);
00071
00072 virtual CATTREEINFO* GetItemFromDataPtr( void* dataPtr, CATTREEINFO* rootItem = 0);
00073
00074 virtual CATResult Remove( CATTREEINFO*& item);
00075
00076 virtual CATResult Clear();
00077
00078 virtual CATString GetHint() const;
00079
00080 virtual CATCommand GetCommand() const ;
00081
00082 virtual CATString GetString () const;
00083
00084 virtual void SetEnabled(bool enabled);
00085
00086 virtual CATResult UseImageList( CATUInt32 imageListId, CATUInt32 width, const CATColor& transparent );
00087
00088 virtual void ExpandRoot();
00089
00090 protected:
00091 #ifdef _WIN32
00092 HIMAGELIST fImageList;
00093 #endif
00094 void ClearTreeItem(CATTREEINFO* item);
00095 void OSClearTree ();
00096 CATResult OSAddItem ( const CATString& displayText, CATTREEINFO* treeItem, CATUInt32 index);
00097 CATResult OSRemoveItem ( CATTREEINFO* treeItem);
00098 CATTREEINFO* OSGetCurSel ();
00099 CATResult OSSetCurSel ( CATTREEINFO* newSel );
00100 CATResult OSUpdateText ( CATTREEINFO* treeItem);
00101 CATResult OSEvent (const CATEvent& event, CATInt32& retVal);
00102 void OSRebuildTree(std::vector<CATTREEINFO*>* curList);
00103 void OSUpdateTreeColors();
00104
00105 protected:
00106 CATTREEINFO* fCurSel;
00107 std::vector<CATTREEINFO*> fRootList;
00108 CATFONT fFont;
00109 bool fRespondSelect;
00110 };
00111
00112 #endif // CATTreeCtrl_H_
00113
00114