/** * @file XTPPropertyGridItemExt.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ /** @cond */ #if !defined(__XTPPROPERTYGRIDITEMEXT_H__) # define __XTPPROPERTYGRIDITEMEXT_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" class CXTPPropertyGridItemDate; /** * @brief * Month calendar pop-up used for CXTPPropertyGridItemDate item. */ class _XTP_EXT_CLASS CXTPPropertyGridInplaceMonthCal : public CWnd { public: /** * @brief * Constructs a CXTPPropertyGridInplaceMonthCal object. * @param pItem Pointer to the parent item. */ CXTPPropertyGridInplaceMonthCal(CXTPPropertyGridItemDate* pItem) { m_pItem = pItem; } /** * @brief * Gets the minimal size required to display one month. * @param pRect Pointer to a RECT structure to receive the minimal * size required to display one month. This parameter * must be a valid address and cannot be NULL. * @details * This member function implements the behavior of the * CMonthCalCtrl::GetMinReqRect function. * @return * Nonzero if successful, otherwise 0. */ BOOL GetMinReqRect(RECT* pRect) const; protected: /** * @brief * This method is called if the user hits the Enter/Return key * while an in-place calendar is displayed or if an item in the * in-place calendar is selected. * @see * OnCancel */ void OnAccept(); /** * @brief * This method is called if the user hits the Escape Key or clicks * either another part of the property grid or another application * while the in-place calendar is displayed. * @see * OnAccept */ void OnCancel(); /** @cond */ virtual void PostNcDestroy(); virtual BOOL OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult); afx_msg void OnSelect(NMHDR* pNMHDR, LRESULT* pResult); DECLARE_MESSAGE_MAP() /** @endcond */ protected: CXTPPropertyGridItemDate* m_pItem; /**< Parent item. */ }; /** * @brief * CXTPPropertyGridItemDate is a CXTPPropertyGridItem derived class. * It is used to create a Date item in a Property Grid control. * * @details * When the in-place button for a date item is pressed, * a CXTPPropertyGridInplaceMonthCal object is created, which * is a User Interface that allows the user to easily select a date. * * Example: * This sample illustrates how to add an item of type Date to your grid: *
* CXTPPropertyGridItem* pStandard = m_wndPropertyGrid.AddCategory(_T("Appointments"));
*
* //Create a Date object with the date 12/26/2004. Note that no time information is entered
* //because this information is ignored.
* COleDateTime dates(2004, 12, 26, 0, 0, 0);
*
* //Adds a date item to the property grid and set the date to the value stored in dates
* CXTPPropertyGridItemDate* pDate = (CXTPPropertyGridItemDate*)(pStandard->AddChildItem(new
* CXTPPropertyGridItemDate(_T("Date item"), dates)));
*
* //Set the date format to MM/DD/YYYY
* pDate->SetDateFormat("\%m/\%d/\%Y");
*
* //Changes the date to 3/22/2001
* COleDateTime newDate(2003, 5, 12, 0, 0, 0);
*
* //Changes the date of the Date item.
* pDate->SetDate(newDate);
*
* //Gets the currently set date
* TRACE(_T("Current Date= \%d/\%d/\%d\n"), pDate->GetMonth(), pDate->GetDay(), pDate->GetYear());
*
* @see
* SetDate, GetMonth, GetDay, GetYear, SetDateFormat
*/
class _XTP_EXT_CLASS CXTPPropertyGridItemDate : public CXTPPropertyGridItem
{
public:
/**
* @brief
* Constructs a CXTPPropertyGridItemDate object.
* @param strCaption Caption of the item.
* @param oleDate Reference to a COleDateTime object containing
* the initial date value of the item.
* @param pBindDate If not NULL, then the value of the item
* is bound the value of this variable.
*/
CXTPPropertyGridItemDate(LPCTSTR strCaption, const COleDateTime& oleDate,
COleDateTime* pBindDate = NULL);
/**
* @brief
* Constructs a CXTPPropertyGridItemDate object.
* @param nID Identifier of the item.
* @param oleDate Reference to a COleDateTime object containing
* the initial date value of the item.
* @param pBindDate If not NULL, then the value of the item
* is bound the value of this variable.
*/
CXTPPropertyGridItemDate(UINT nID, const COleDateTime& oleDate, COleDateTime* pBindDate = NULL);
public:
/**
* @brief
* Sets the date value for the item.
* @param oleDate Reference to a COleDateTime object containing
* the date value. This value must include the
* month, day, and year and all time information
* should be set to zero.
*
* Example:
* This sample illustrates how to set the currently selected
* date in and item of type CXTPPropertyGridItemDate:
*
* CXTPPropertyGridItem* pStandard = m_wndPropertyGrid.AddCategory(_T("Appointments"));
*
* //Create a Date object with the date 12/26/2004. Note that no time information is entered
* //because this information is ignored.
* COleDateTime dates(2004, 12, 26, 0, 0, 0);
*
* //Adds a date item to the property grid and set the date to the value stored in dates
* CXTPPropertyGridItemDate* pDate = (CXTPPropertyGridItemDate*)(pStandard->AddChildItem(new
* CXTPPropertyGridItemDate(_T("Date item"), dates)));
*
* //Set the date format to MM/DD/YYYY
* pDate->SetDateFormat("\%m/\%d/\%Y");
*
* //Changes the date to 3/22/2001
* COleDateTime newDate(2003, 5, 12, 0, 0, 0);
*
* //Changes the date of the Date item.
* pDate->SetDate(newDate);
*
* //Gets the currently set date
* TRACE(_T("Current Date= \%d/\%d/\%d\n"), pDate->GetMonth(), pDate->GetDay(),
* pDate->GetYear());
*
*/
virtual void SetDate(const COleDateTime& oleDate);
/**
* @brief
* Converts the time in the COleDateTime object to be represented
* as a SYSTEMTIME data structure. The resulting time will be
* stored in the SYSTEMTIME data structure specified by sysTime.
* @param sysTime Reference to a SYSTEMTIME data structure to
* receive the resulting time.
* @details
* The SYSTEMTIME data structure initialized by this method
* will have its wMilliseconds member set to zero.
* @return
* TRUE if the time in the COleDateTime object was successfully
* stored in the SYSTEMTIME data structure specified by sysTime.
*
* Example:
* This sample code illustrates how to use the GetAsSystemTime member:
*
* CXTPPropertyGridItem* pStandard = m_wndPropertyGrid.AddCategory(_T("Appointments"));
*
* //Create a Date object with the date 12/26/2004. Note that no time information is entered
* //because this information is ignored.
* COleDateTime dates(2004, 12, 26, 0, 0, 0);
*
* //Adds a date item to the property grid and set the date to the value stored in dates
* CXTPPropertyGridItemDate* pDate = (CXTPPropertyGridItemDate*)(pStandard->AddChildItem(new
* CXTPPropertyGridItemDate(_T("Date item"), dates)));
*
* //Creates a SYSTEMTIME object
* SYSTEMTIME sysTime;
*
* //Stores the day, month, and year into the SYSTEMTIME structure, all other members will be 0.
* if (pDate->GetAsSystemTime(sysTime))
* TRACE(_T("SysTime Current Date= \%d/\%d/\%d\n"), sysTime.wMonth, sysTime.wDay,
* sysTime.wYear);
*
*/
virtual BOOL GetAsSystemTime(SYSTEMTIME& sysTime);
/**
* @brief
* Gets the date value of the item.
* @return
* A reference to a COleDateTime object containing the date value.
*/
virtual const COleDateTime& GetDate() const;
/**
* @brief
* Gets the day of the date value of the item.
* @return
* The day of the date value of the item.
*/
virtual long GetDay();
/**
* @brief
* Sets the day for the date value of the item.
* @param nDay Day to be set.
*/
virtual void SetDay(long nDay);
/**
* @brief
* Gets the month of the date value of the item.
* @return
* The month of the date value of the item.
*/
virtual long GetMonth();
/**
* @brief
* Sets the month for the date value of the item.
* @param nMonth Month to be set.
*/
virtual void SetMonth(long nMonth);
/**
* @brief
* Gets the year of the date value of the item.
* @return
* The year of the date value of the item.
*/
virtual long GetYear();
/**
* @brief
* Sets the year for the date value of the item.
* @param nYear Year to be set.
*/
virtual void SetYear(long nYear);
/**
* @brief
* Parses the month, day, and year from a specified COleDateTime object.
* @param dt Reference to a COleDateTime object containing
* the month, day, and year.
* @param strValue The date format:
* \%m Month as decimal number (01 12).
* \%d Day of month as decimal number (01 31).
* \%Y Year with century, as decimal number.
* Format string for 05/22/2004 is "%m%d%Y".
* @return
* TRUE if a valid date was extracted,
* FALSE if either an invalid or a NULL date was extracted.
*/
virtual BOOL ParseDateTime(COleDateTime& dt, LPCTSTR strValue);
/**
* @brief
* Changes the date format.
* @param strFormat The date format:
* \%m Month as decimal number (01 12).
* \%d Day of month as decimal number (01 31).
* \%Y Year with century, as decimal number.
* Format string for 05/22/2004 is "\%m\%d\%Y".
*
* Example:
* This sample code illustrates how to change the date format of
* of type CXTPPropertyGridItemDate:
*
* CXTPPropertyGridItem* pStandard = m_wndPropertyGrid.AddCategory(_T("Appointments"));
*
* //Create a Date object with the date 12/26/2004. Note that no time information is entered
* //because this information is ignored.
* COleDateTime dates(2004, 12, 26, 0, 0, 0);
*
* //Adds a date item to the property grid and set the date to the value stored in dates
* CXTPPropertyGridItemDate* pDate = (CXTPPropertyGridItemDate*)(pStandard->AddChildItem(new
* CXTPPropertyGridItemDate(_T("Date item"), dates)));
*
* //Set the date format to MM/DD/YYYY
* pDate->SetDateFormat("\%m/\%d/\%Y");
*
*/
virtual void SetDateFormat(LPCTSTR strFormat);
/**
* @brief
* Sets the displayed text for a NULL date.
* @param lpszNullValue Text to be set.
*/
void AllowNullDate(LPCTSTR lpszNullValue);
/**
* @brief
* Gets the displayed text for a NULL date.
* @return
* The displayed text for a NULL date.
*/
CString GetAllowNullDateString() const;
/**
* @brief
* Binds the item to a specified COleDateTime object.
* @param pBindDate Pointer to a COleDateTime object.
* @details
* Variables can be bound to an item in two ways, the first is
* to pass in a variable at the time of creation, the second allows
* variables to be bound to an item after creation with the
* BindToDate member.
*
* Bound variables store the values of the property grid items
* and can be accessed without using the property grid methods
* and properties. Bound variables allow the property grid to
* store data in variables. When the value of a PropertyGridItem
* is changed, the value of the bound variable will be changed to
* the PropertyGridItem value. The advantage of binding is that
* the variable can be used and manipulated without using
* PropertyGridItem methods and properties.
*
* NOTE: If the value of the variable is changed without using
* the PropertyGrid, the PropertyGridItem value will not be
* updated until you call CXTPPropertyGrid::Refresh.
*/
void BindToDate(COleDateTime* pBindDate);
protected:
/**
* @param oleDate Reference to the COleDateTime object to be formatted.
* @return Formats a specified COleDateTime object
*/
virtual CString Format(const COleDateTime& oleDate);
/**
* @brief
* This method is called when the user presses the in-place button.
* Override this method to show an item-specific dialog.
* @param pButton Pointer to the button that was pressed.
* @details
* The in-place button is the button that the user presses to
* display the date picker dialog.
*/
virtual void OnInplaceButtonDown(CXTPPropertyGridInplaceButton* pButton);
/**
* @brief
* Sets the value of the item.
* Override this method to add new functionality. You should call
* the base class version of this function from your override.
* @param strValue Value to be set.
*/
virtual void SetValue(CString strValue);
/**
* @brief
* This method is called when the value of the item is changed.
* Override this method if needed.
* @param strValue New value of the item.
*/
void OnValueChanged(CString strValue);
/**
* @brief
* This method is called before the item becomes visible in the
* property grid.
* @details
* Before the item is inserted, it is first checked to see if it
* is bound to a variable. If it is, then the value of the item
* is updated with the value stored in the bound variable.
*
* OnBeforeInsert is called when an item is inserted,
* when a category is inserted, when a category or item is expanded,
* and when the sort property has changed.
*/
virtual void OnBeforeInsert();
private:
void Init(const COleDateTime& oleDate);
protected:
COleDateTime m_oleDate; /**< Currently selected date. Only Month, Day, and Year are used. */
CString m_strNullValue; /**< String value to be displayed for the Date item when the current
date is NULL. */
COleDateTime* m_pBindDate; /**< Pointer to the variable bound to this item. */
# ifdef _XTP_ACTIVEX
/** @cond */
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
DECLARE_OLETYPELIB_EX(CXTPPropertyGridItemDate)
void OleSetValue(const VARIANT* varValue);
const VARIANT OleGetValue();
void BindDispatch();
afx_msg void OleSetDateFormat(LPCTSTR pcszFormat);
/** @endcond */
# endif
friend class CXTPPropertyGridInplaceMonthCal;
DECLARE_DYNAMIC(CXTPPropertyGridItemDate)
};
AFX_INLINE const COleDateTime& CXTPPropertyGridItemDate::GetDate() const
{
return m_oleDate;
}
# ifdef __AFXCTL_H__
/** @cond */
/**
* @brief
* Picture item of ActiveX PropertyGrid
*/
class _XTP_EXT_CLASS CXTPPropertyGridItemPicture : public CXTPPropertyGridItem
{
public:
/**
* @brief
* Constructs a XTPPropertyGridItemPicture object.
* @param strCaption Text caption of this item.
* This is the text displayed in the left column of
* the property grid.
*/
CXTPPropertyGridItemPicture(LPCTSTR strCaption);
public:
virtual CPictureHolder& GetPicture();
virtual void SetPicturePath(LPCTSTR lpszPath);
protected:
/**
* @brief
* This method is called when the user presses the in-place button.
* Override the method to show an item-specific dialog.
* @details
* The in-place button is the button that the user presses to
* display browse folder dialog so they can select a picture.
* @see XTPPropertyGridItemFlags, CXTPPropertyGridItem::SetFlags
*/
virtual void OnInplaceButtonDown(CXTPPropertyGridInplaceButton* pButton);
/**
* @brief
* This method is called when an item is drawn. Override this function if
* needed.
* @param dc Reference to the device context to be used for rendering an image
* of the item.
* @param rcValue Bounding rectangle of the item.
* @return
* TRUE if item is self-drawn.
*/
virtual BOOL OnDrawItemValue(CDC& dc, CRect rcValue);
protected:
CPictureHolder m_olePicture;
CString m_strPicturePath;
int m_nPreviewWidth;
# ifdef _XTP_ACTIVEX
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
DECLARE_OLETYPELIB_EX(CXTPPropertyGridItemPicture)
afx_msg void OleSetValue(const VARIANT* varValue);
afx_msg const VARIANT OleGetValue();
BSTR OleGetPicturePath();
# endif
};
AFX_INLINE CPictureHolder& CXTPPropertyGridItemPicture::GetPicture()
{
return m_olePicture;
}
/** @endcond */
# endif
/**
* @brief
* CXTPPropertyGridItemMultilineString is a CXTPPropertyGridItem derived class.
* It is used to create an item with an in-place multi-line edit box.
*/
class _XTP_EXT_CLASS CXTPPropertyGridItemMultilineString : public CXTPPropertyGridItem
{
public:
/**
* @brief
* Constructs a CXTPPropertyGridItemMultilineString object.
* @param lpszCaption Caption of the item.
* @param strValue Initial value of the item.
* @param pBindString If not NULL, then the value of the item
* is bound the value of this variable.
*/
CXTPPropertyGridItemMultilineString(LPCTSTR lpszCaption, LPCTSTR strValue = NULL,
CString* pBindString = NULL);
/**
* @brief
* Constructs a CXTPPropertyGridItemMultilineString object.
* @param nID Identifier of the item.
* @param strValue Initial value of the item.
* @param pBindString If not NULL, then the value of the item
* is bound the value of this variable.
*/
CXTPPropertyGridItemMultilineString(UINT nID, LPCTSTR strValue = NULL,
CString* pBindString = NULL);
protected:
/**
* @brief
* This method is called when the user presses the in-place button.
* Override this method to show an item-specific dialog.
* @param pButton Pointer to the button that was pressed.
* @details
* The in-place button is the button that the user presses to
* display the date picker dialog.
*/
virtual void OnInplaceButtonDown(CXTPPropertyGridInplaceButton* pButton);
};
AFX_INLINE BOOL CXTPPropertyGridInplaceMonthCal::GetMinReqRect(RECT* pRect) const
{
_ASSERTE(::IsWindow(m_hWnd));
return (BOOL)::SendMessage(m_hWnd, MCM_GETMINREQRECT, 0, (LPARAM)pRect);
}
/** @cond */
# include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"
#endif // #if !defined(__XTPPROPERTYGRIDITEMEXT_H__)
/** @endcond */