Public Types | |
|
typedef std::vector< std::pair < long, TString > > | Container |
| Container that holds pairs of formatted and non-formatted values. | |
Public Member Functions | |
| CLongEnumFormat (const Container &container) | |
| Constructor. | |
| CLongEnumFormat (const CLongEnumFormat &fmt) | |
| Copy constructor. | |
| ~CLongEnumFormat () | |
| Virtual destructor. | |
| virtual TString | FormatStl (long val, const CDataObject *pDO) const |
| The function converts enumerated value to a corresponding string. | |
| virtual bool | ParseStl (const TString &str, long &val, const CDataObject *pDO) const |
| The function converts a formatted string to corresponding value in an enumeration. | |
| virtual CString | FormatMfc (long val, const CDataObject *pDO) const |
| The function converts non-formatted value of long type to the formatted MFC string. | |
| virtual bool | ParseMfc (const CString &str, long &val, const CDataObject *pDO) const |
| The function converts the formatted MFC string to the non-formatted long-type value. | |
| virtual CFormat * | Clone () const |
| Creates a deep copy of a format. | |
| virtual bool | IsEnum () const |
| Indicates whether a format presents an enumeration. | |
| virtual bool | GetItems (Container &items) const |
| Fills the container with pairs value-string, stored in this object. | |
| virtual bool | AddItem (long value, const TString &text) |
| Add a new pair value-string to the internal conversion table. | |
| virtual bool | RemoveItem (long value) |
| Remove the conversion pair from the internal table. | |
| virtual TString & | operator[] (long value) |
| Provides an access to elements in the conversion table. If the element does not exist - an empty string will be added to the table. | |
| virtual void | Serialize (CSerializer &serializer) |
| Serializes a format. | |
Static Public Member Functions | |
| static int | GetSerializeVertion () |
| Serialization version. | |
Classes | |
| struct | Item |
| Represents a pair of numeric value and a corresponding formatted string. More... | |
// This example demonstrates how to present a numeric value (enum) as text in the grid //MyClass.h file //Declaration of some C++ class class CMyClass : public Dapfor::Common::CDataObject { public: //It is better to use enumerations instead of long numeric values... //The grid can use the same identifiers to show values returned by functions of this class. enum { ... FidCity, }; // A list of numeric identifiers used by CLongEnumFormat. // A mapping table of these identifiers and strings // is declared in MyClass.cpp file enum City { London = 100, Paris, Totonto, NewYork, }; public: CMyClass(City city); virtual ~CMyClass(); //Public methods ... City GetCity() const {return m_City;} private: City m_City; //Declaration of map containing a list of functions that can be called by their identifiers. DF_DECLARE_FIELD_MAP(); }; //MyClass.cpp file // This declaration can be used to display numeric value (enum) as text in the grid Dapfor::Common::CLongEnumFormat::Item cities[] = { {CMyClass::London, "London"}, {CMyClass::Paris, "Paris"}, {CMyClass::Totonto, "Totonto"}, {CMyClass::NewYork, "New York"}, }; // Field map declaration. // To put an object of CMyClass into the grid it should declare a table // that supports calling specified functions by identifiers. // We can also customize a presentation using formats included in // Common library or custom formats. DF_BEGIN_FIELD_MAP(CMyClass) ... DF_ENUM_ID (FidCity, "City", &CMyClass::GetCity, 0, DF_ENUM_FORMAT(cities)) DF_END_FIELD_MAP() CMyClass::CMyClass(City city) : m_City(city) { } //Virtual destructor CMyClass::~CMyClass() { //The object ends the life cycle. We notify the remaining subscribers. NotifyDelete(); } //Using sample: //grid initialization ... Dapfor::GUI::CHeader* header = new Dapfor::GUI::CHeader(); ... header->Add(new Dapfor::GUI::CColumn(CMyClass::FidCity, "City", 100)); m_Grid.SetHeader(header); Dapfor::Common::CDataObject* pDO = new CMyClass(CMyClass::Paris); m_Grid.Add(pDO);
| CLongEnumFormat | ( | const Container & | container | ) |
Constructor.
| [in] | container | List that contains pairs of formatted and non-formatted values. |
| CLongEnumFormat | ( | const CLongEnumFormat & | format | ) |
Copy constructor.
| [in] | format | Format to be copied. |
| TString FormatStl | ( | long | val, | |
| const CDataObject * | pDO | |||
| ) | const [virtual] |
The function converts enumerated value to a corresponding string.
| [in] | val | value in an enumeration. |
| [in] | pDO | Pointer to CDataObject. This parameter is optional and may be zero. |
Reimplemented from CFormat.
| bool ParseStl | ( | const TString & | str, | |
| long & | val, | |||
| const CDataObject * | pDO | |||
| ) | const [virtual] |
The function converts a formatted string to corresponding value in an enumeration.
| [in] | str | Formatted string. |
| [in,out] | val | Value of long type that accepts a result of conversion. |
| [in] | pDO | Pointer to CDataObject. This parameter is optional and may be zero. |
Reimplemented from CFormat.
| CString FormatMfc | ( | long | val, | |
| const CDataObject * | pDO | |||
| ) | const [virtual] |
The function converts non-formatted value of long type to the formatted MFC string.
| [in] | val | Non-formatted MFC string to be formatted. |
| [in] | pDO | Pointer to CDataObject. This parameter is optional and may be zero. |
Reimplemented from CFormat.
| bool ParseMfc | ( | const CString & | str, | |
| long & | val, | |||
| const CDataObject * | pDO | |||
| ) | const [virtual] |
The function converts the formatted MFC string to the non-formatted long-type value.
| [in] | str | MFC string to be formatted. |
| [in,out] | val | A value of the long type that is a result of the parsing. |
| [in] | pDO | Pointer to CDataObject. This parameter is optional and may be zero. |
Reimplemented from CFormat.
| CFormat * Clone | ( | ) | const [virtual] |
| bool IsEnum | ( | ) | const [virtual] |
| bool GetItems | ( | Container & | items | ) | const [virtual] |
Fills the container with pairs value-string, stored in this object.
| on] | items Container to be filled. |
| bool AddItem | ( | long | value, | |
| const TString & | text | |||
| ) | [virtual] |
Add a new pair value-string to the internal conversion table.
| [in] | value | Non-formatted value (value stored by the data object) |
| [in] | text | Formatted value (Text displayed in the grid or edit in place control) |
| bool RemoveItem | ( | long | value | ) | [virtual] |
Remove the conversion pair from the internal table.
| [in] | value | Non-formatted value (value stored by the data object) |
| TString & operator[] | ( | long | value | ) | [virtual] |
Provides an access to elements in the conversion table. If the element does not exist - an empty string will be added to the table.
| [in] | value | Non-formatted value (value stored by the data object) |
| void Serialize | ( | CSerializer & | serializer | ) | [virtual] |
Serializes a format.
| [in] | serializer | Object, into which a format object is serialized. |
Reimplemented from CFormat.
| Copyright Dapfor 2007-2009 | Generated on Wed Jul 7 03:24:43 2010 for MFCGrid by 1.5.5 |