GME  13
ItemData.h
Go to the documentation of this file.
00001 // ItemData.h: interface for the CItemData class.
00002 //
00004 
00005 #if !defined(AFX_ITEMDATA_H__10E7D725_9DA8_4F76_A3E3_9FB83D386870__INCLUDED_)
00006 #define AFX_ITEMDATA_H__10E7D725_9DA8_4F76_A3E3_9FB83D386870__INCLUDED_
00007 
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011 
00012 #include "CompassData.h"
00013 
00014 void str_split( CString str, CStringArray &returnArray);
00015 
00016 enum itemdata_enum
00017 {
00018         ITEMDATA_NULL                   = 0,
00019         ITEMDATA_STRING                 = 1,
00020         ITEMDATA_INTEGER                = 2,
00021         ITEMDATA_DOUBLE                 = 3,
00022         ITEMDATA_BOOLEAN                = 4,
00023         ITEMDATA_FIXED_LIST             = 9,
00024         ITEMDATA_COLOR                  =10,
00025         ITEMDATA_COMPASS                =11,
00026         ITEMDATA_COMPASS_EXCL   =12
00027 
00028 };
00029 
00030 class CInPlaceManager;
00031 class CItemData  
00032 {
00033         friend class CListItem;
00034         friend class CInPlaceManager;
00035         friend class CInspectorList;
00036         void CommonInit();
00037 public:
00038         static const TCHAR * m_defFMTSTR;
00039         static CString      m_fmtStr;
00040         static void         getRealFmtString();
00041 
00042         void toString();
00043         bool toString(CString &)const;
00044         bool Validate();
00045 
00046         CItemData();
00047         virtual ~CItemData();
00048 
00049         // Constructors
00050         // Copy Const
00051         CItemData(CItemData&srcItemData);
00052 
00053 
00054         CItemData(int i){CommonInit();SetIntValue(i);};
00055         CItemData(double d){CommonInit();SetDoubleValue(d);};
00056         CItemData(bool b){CommonInit();SetBoolValue(b);};
00057         CItemData(COLORREF c){CommonInit();SetColorValue(c);};
00058         CItemData(UINT cmps){CommonInit();SetCompassValue(cmps);};
00059         CItemData(CStringArray& strArr, BYTE cDispLineNum){CommonInit();SetStringValue(strArr,cDispLineNum);};  
00060         CItemData(CString& str){SetStringValue(str);};
00061         CItemData(CStringArray& strArr,CStringArray& strArrNames, UINT nSelection){CommonInit();SetListValue(strArr, strArrNames,nSelection);}; 
00062         CItemData(CStringArray& strArr, UINT nSelection){CommonInit();SetListValue(strArr,nSelection);};
00063 
00064         // Set functions: set the value and the data type
00065         void SetIntValue(int i);
00066         void SetDoubleValue(double d);
00067         void SetBoolValue(bool b);
00068         void SetColorValue(COLORREF c);
00069         void SetCompassValue(UINT cmps);
00070         void SetCompassExclValue(UINT cmps);
00071         void SetStringValue(CStringArray& strArr,BYTE cDispLineNum);
00072         void SetStringValue(CString str);
00073         void SetListValue(CStringArray& strArr,CStringArray& strArrNames, UINT nSelection);
00074         void SetListValue(CStringArray& strArr, UINT nSelection);
00075         
00076         // Operator =
00077         void operator=(const CItemData& srcItemData);
00078 
00079         itemdata_enum dataType;
00080         
00081         CStringArray stringVal;
00082         
00083         // Intended access is read only
00084         union
00085         {
00086                 int                      intVal;
00087                 double           doubleVal;
00088                 bool             boolVal;
00089                 COLORREF     colorVal;
00090                 UINT             compassVal;
00091                 int                      listVal;       // Selected item for ITEMDATA_FIXED_LIST
00092                 BYTE             cLineNum;      // Line number of the edit box
00093         };
00094 
00095         CStringArray stringListNames; // Name Array for ITEMDATA_FIXED_LIST
00096 
00097 };
00098 
00099 
00100 class CListItem
00101 {
00102         friend class CInspectorList;
00103 public: 
00104         void CopyWithNoState(const CListItem& srcListItem);
00105         void SetDirty();
00106         CItemData Value;
00107         CItemData DefValue;
00108 
00109 
00110         CString strName;
00111         CString strToolTip;
00112         CString strContentType;
00113         bool bIsDefault;
00114         bool bIsReadOnly;
00115         bool bIsContainer;
00116         bool bIsContainerOpen;
00117 
00118         // Supporting multiple selections
00119         // If there is more than one object selected 
00120         // the value vcan be different
00121         bool bIsDifferentValue;
00122 
00123         // User data
00124         DWORD dwKeyValue;
00125         DWORD dwUserData;
00126 
00127         CListItem();
00128         CListItem(CListItem& srcListItem);
00129         void RestoreDefault();
00130 
00131         void operator =(const CListItem& srcListItem);
00132 
00133 private:
00134         // For containtment
00135         CArray<CListItem,CListItem&> m_ContainedListItemArray;
00136 };
00137 #endif // !defined(AFX_ITEMDATA_H__10E7D725_9DA8_4F76_A3E3_9FB83D386870__INCLUDED_)