/** * @file XTPPropertyGridItem.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(__XTPPROPERTYGRIDITEM_H__) # define __XTPPROPERTYGRIDITEM_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" // class forwards. class CXTPPropertyGridView; class CXTPPropertyGridItem; class CXTPPropertyGridItemMetrics; class CXTPImageManagerIcon; class CXTPPropertyGridInplaceButtons; class CXTPPropertyGridInplaceSlider; class CXTPPropertyGridInplaceSpinButton; class CXTPPropertyGridInplaceControls; class CXTPMarkupUIElement; class CXTPPropertyGridInplaceEdit; class CXTPPropertyGridInplaceList; class CXTPPropertyGridInplaceButton; /** * @brief * This constant is used to determine the "gutter" width of the * property grid. This is the area on the left side of the * grid that the expand buttons are drawn in. * @details * This is useful when drawing owner drawn controls such as buttons * and drop-down menus. * * Example: * The following example illustrates using XTP_PGI_EXPAND_BORDER: *
* void CDelphiGridPage::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
* {
* // code snip ...
*
* CRect rcText(rc);
* rcText.left = max(1, pItem->GetIndent()) * XTP_DPI_X(XTP_PGI_EXPAND_BORDER) + 3;
* rcText.right = rcCaption.right - 1;
* rcText.bottom -= 1;
* dc.DrawText(pItem->GetCaption(), rcText, DT_SINGLELINE | DT_VCENTER);
* }
*
*/
extern _XTP_EXT_CLASS const int XTP_PGI_EXPAND_BORDER;
const TCHAR XTP_PG_ITEMVALUE_TO_REPLACE_IN_MARKUP[] = _T("%value%");
/**
* @brief
* Flags that indicate which styles to set for the grid item.
*
* Example:
* pItem->SetFlags(xtpPropertyGridItemHasEdit | xtpPropertyGridItemHasComboButton);* @see * CXTPPropertyGridItem::SetFlags, OnInplaceButtonDown, * xtpPropertyGridItemHasEdit, xtpPropertyGridItemHasExpandButton, * xtpPropertyGridItemHasComboButton */ enum XTPPropertyGridItemFlags { xtpPropertyGridItemHasEdit = 1, /**< Item has an edit control. */ xtpPropertyGridItemHasExpandButton = 2, /**< Item has an expand button. */ xtpPropertyGridItemHasComboButton = 4 /**< Item has a combo button. */ }; /** @cond */ _XTP_DEPRECATED_IN_FAVOR(xtpPropertyGridItemHasEdit) const XTPPropertyGridItemFlags xtpGridItemHasEdit = xtpPropertyGridItemHasEdit; _XTP_DEPRECATED_IN_FAVOR(xtpGridItemHasExpandButton) const XTPPropertyGridItemFlags xtpGridItemHasExpandButton = xtpPropertyGridItemHasExpandButton; _XTP_DEPRECATED_IN_FAVOR(xtpGridItemHasComboButton) const XTPPropertyGridItemFlags xtpGridItemHasComboButton = xtpPropertyGridItemHasComboButton; /** @endcond */ /** * @brief * CXTPPropertyGridItems is a CList derived class. It represents the * items collection with some internal functionality. */ class _XTP_EXT_CLASS CXTPPropertyGridItems : public CXTPCmdTarget { public: /** * @brief * Retrieves an item by its identifier. * @param nID Indentifier of the item to retrieve. * @return * A pointer to the CXTPPropertyGridItem object if found, otherwise NULL. */ CXTPPropertyGridItem* FindItem(UINT nID) const; /** * @brief * Retrieves an item by its caption. * @param strCaption Caption of the item to retrieve. * @return * A pointer to the CXTPPropertyGridItem object if found, otherwise NULL. */ CXTPPropertyGridItem* FindItem(LPCTSTR strCaption) const; /** * @brief * Retrieves the index of a specified item within the collection of items. * @param pItem Pointer to the CXTPPropertyGridItem object * whose index must be retrieved. * @return * The index of the specified item within the collection of items * if found, otherwise a value of -1. */ int Find(CXTPPropertyGridItem* pItem) const; /** * @brief * Clears all items from the collection of items. */ void Clear(); /** * @brief * Gets the number of items within the collection of items. * @return * The number of items within the collection of items. */ long GetCount() const; /** * @brief * Determines if any items have been added to the property grid. * @return * TRUE if there are no items in the property grid, * FALSE if there is at least one item in the property grid. */ BOOL IsEmpty() const; /** * @brief * Retrieves the item at a specified index within the collection of items. * @param nIndex Index of the item to retrieve. * @return * A pointer to the CXTPPropertyGridItem object at the specified index * if successful, otherwise a value of 0. */ CXTPPropertyGridItem* GetAt(int nIndex) const; /** * @brief * Removes the item at a specified index within the collection of items. * @param nIndex Index of the item to remove. */ void RemoveAt(int nIndex); /** * @brief * Sorts the collection of items in alphabetical order. * @details * This method uses the Visual C++ run-time library (MSVCRT) * implementation of the quick-sort function, qsort, for sorting * stored CXTPPropertyGridItem objects. */ void Sort(); protected: /** * @brief * Constructs a CXTPPropertyGridItems object. */ CXTPPropertyGridItems(); /** * @brief * Adds an item/collection of items to the end (tail) of the * property grid's collection of items. * @param pItem Pointer to an item to add. * @details * Property grid's collection of items can be empty prior to calling this method. */ void AddTail(CXTPPropertyGridItem* pItem); /** * @brief * Adds an item/collection of items to the end (tail) of the * property grid's collection of items. * @param pItems Pointer to a collection of items to add. * @details * Property grid's collection of items can be empty prior to calling this method. */ void AddTail(CXTPPropertyGridItems* pItems); /** * @brief * Inserts a specified item at a specified index within the * property grid's collection of items. * @param nIndex Index to insert the item at. * @param pItem Pointer to the item to insert. */ void InsertAt(int nIndex, CXTPPropertyGridItem* pItem); private: static int AFX_CDECL CompareFunc(const CXTPPropertyGridItem** ppItem1, const CXTPPropertyGridItem** ppItem2); private: CArray
CXTPPropertyGridItemConstraints* pList = pItem->GetConstraints();* @see * CXTPPropertyGridItemConstraints::AddConstraint, OnConstraintsChanged */ CXTPPropertyGridItemConstraints* GetConstraints() const; /** * @brief * Enables/disables constraint editing mode. * @param bConstraintEdit TRUE to enable constraint editing mode, * FALSE to disable constraint editing mode. * @details * If constraint editing mode is enabled, then only values from * the constraint list can be input to the edit. */ void SetConstraintEdit(BOOL bConstraintEdit = TRUE); /** * @brief * Enables/disables auto-complete for the constraint list. * @param bAutoComplete TRUE to enable auto-complete, * FALSE to disable auto-complete. */ void SetAutoComplete(BOOL bAutoComplete = TRUE); /** * @brief * Determines if constraint editing mode is enabled/disabled. * @details * If constraint editing mode is enabled, then only values from * the constraint list can be input to the edit. * @return * TRUE if constraint editing mode is enabled, * FALSE if constraint editing mode is disabled. */ BOOL GetConstraintEdit() const; /** * @brief * Expands the item. */ void Expand(); /** * @brief * Collapses the item. */ void Collapse(); /** * @brief * Specifies if the item should be expandable by the user. * @param bExpandable TRUE to set the item to be expandable by the user, FALSE otherwise. */ void SetExpandable(BOOL bExpandable); /** * @brief * Determines if the item is expandable by the user. * @return * TRUE if the item is expandable by the user, otherwise FALSE. */ BOOL IsExpandable() const; /** * @brief * Selects the item. */ void Select(); /** * @brief * Gets the bounding rectangle of the item. * @return * The bounding rectangle of the item. */ CRect GetItemRect() const; /** * @brief * Gets the bounding rectangle of the item value's text. * Override this method to change it. * @return * The bounding rectangle of the item value's text. */ virtual CRect GetValueRect(); /** * @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 * Hides/shows the item. * @param bHidden TRUE to hide the item, FALSE to show the item. */ void SetHidden(BOOL bHidden); /** * @brief * Determines if the item is hidden/shown. * @return * TRUE if the item is hidden, FALSE if the item is shown. */ BOOL IsHidden() const; /** * @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. */ virtual void OnValueChanged(CString strValue); /** * @brief * This method is called when the markup text of the item is changed. * Override this method if needed. */ virtual void OnMarkupChanged(); /** * @brief * Gets the parent window. * @return * A pointer to the parent window. */ CXTPPropertyGridView* GetGrid() const; /** * @brief * Determines the visible state of the item. * @return * TRUE if the item is visible, otherwise FALSE. */ BOOL IsVisible() const; /** * @brief * Determines the expanded state of the item. * @return * TRUE if the item is expanded, otherwise FALSE. */ BOOL IsExpanded() const; /** * @brief * Gets the parent item of this item, if any. * @return * A pointer to the parent item of this item, if any, otherwise NULL. */ CXTPPropertyGridItem* GetParentItem() const; /** * @brief * Gets the indent of the item. * @return * The indent of the item. */ int GetIndent() const; /** * @brief * This method is called when an item is drawn. * Override this method 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 the item is self-drawn. */ virtual BOOL OnDrawItemValue(CDC& dc, CRect rcValue); /** * @brief * This method is called when a constraint in an in-place list is drawn. * Override this method if needed. * @param pDC Pointer to the device context to be used * for rendering an image of the item. * @param pConstraint Pointer to the constraint to be drawn. * @param rc Bounding rectangle of the constraint. * @param bSelected TRUE if the item is selected. */ virtual void OnDrawItemConstraint(CDC* pDC, CXTPPropertyGridItemConstraint* pConstraint, CRect rc, BOOL bSelected); /** * @brief * This method is called to get size of constraint in in-place list. * Override this function if needed. * @param pDC Reference to the device context to be used for rendering * an image of the item. * @param pConstraint Constraint to be drawn * @return Gets size of constraint in in-place list */ virtual CSize OnMergeItemConstraint(CDC* pDC, CXTPPropertyGridItemConstraint* pConstraint); /** * @brief * Override this method and fill in a specified MEASUREITEMSTRUCT structure * to inform Windows of the list-box dimensions. * @param lpMeasureItemStruct Long pointer to a MEASUREITEMSTRUCT structure. */ virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct); /** * @brief * Determines the selected stae of the item. * @return * TRUE if the item is selected, otherwise FALSE. */ BOOL IsSelected() const; /** * @brief * Binds the item to a specified CString object. * @param pBindString Pointer to a CString 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 * BindToString 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 BindToString(CString* pBindString); /** * @brief * Removes this item. */ void Remove(); /** * @brief * Applies a specified mask to a CXTPPropertyGridItem data field * to create a restrictive field for text entry. * @param strMask Mask of the item. * @param strLiteral Defines the prompt area of the mask where text entry * is allowed. This value should match the areas that * you have already defined as mask fields. By default, * the prompt character is '_'. * * Phone No: (___) ___-____ * * * @param chPrompt (Optional) This value is the prompt character used * in strLiteral to indicate a place holder. By default, * this parameter is the underscore '_' character. * @details * You can use any of these characters for defining your edit mask: *
* Mask Character Description
* --------------------- ------------------------
* 0 Numeric (0-9)
* 9 Numeric (0-9) or space (' ')
* # Numeric (0-9) or space (' ') or ('+') or ('-')
* L Alpha (a-Z)
* ? Alpha (a-Z) or space (' ')
* A Alpha numeric (0-9 and a-Z)
* a Alpha numeric (0-9 and a-Z) or space (' ')
* & All print character only
* H Uppercase hex digit (0-9 and A-F)
* h Lowercase hex digit (0-9 and a-f)
* X Uppercase hex digit (0-9 and A-F) and space (' ')
* x Lowercase hex digit (0-9 and a-f) and space (' ')
* > Forces characters to upper case (A-Z) or any Unicode character
* < Forces characters to lower case (a-z) or any Unicode character
* C Uppercase ASCII character
* c Lowercase ASCII character
*
*
* Any of these characters can be combined with additional
* characters to create a restrictive field for text entry.
* For example, if you wanted to display a prompt for a
* telephone number and wanted to restrict only numeric
* values, but wanted to display the area code inside of
* parentheses '(' and ')' then you could define your
* mask as:
*
* Phone No: (000) 000-0000
*
* @see
* GetMaskedText, SetMaskedText
*/
void SetMask(LPCTSTR strMask, LPCTSTR strLiteral, TCHAR chPrompt = _T('_'));
/**
* @brief
* Sets a password mask for the item.
* @param chMask Character to be used as the password mask; by default,
* this parameter is the asterisk (*) character.
* @details
* The password mask is the character used to replace the characters
* of the item's text when displayed.
* The actual text value of the item can be retrieved by using
* the GetMaskedText method.
* @see
* GetMaskedText
*/
void SetPasswordMask(TCHAR chMask = _T('*'));
/**
* @brief
* Gets the actual text value of the item without mask characters.
* @details
* Mask characters are added by methods such as SetMask.
* @return
* The actual text value of the item without mask characters.
* @see
* SetMaskedText, SetMask
*/
CString GetMaskedText() const;
/**
* @brief
* Determines if the value of the item was changed by the user.
* @details
* Call CXTPPropertyGrid::HighlightChangedItems to highlight
* all items with changed values.
* @return
* TRUE if the value of the item was changed by the user.
* @see
* CXTPPropertyGrid::HighlightChangedItems, ResetValue, SetDefaultValue
*/
virtual BOOL IsValueChanged() const;
/**
* @brief
* Resets the value of the item to its default value.
* @see
* SetDefaultValue, IsValueChanged
*/
virtual void ResetValue();
/**
* @brief
* Sets the default value for the item.
* @param lpszDefaultValue Value to be set.
* @see
* ResetValue, IsValueChanged
*/
void SetDefaultValue(LPCTSTR lpszDefaultValue);
/**
* @brief
* Sets the actual text value for the item without mask characters.
* @param lpszMaskedText Text string without mask.
* @details
* Mask characters are added by methods such as SetMask.
* If a mask is used, then the mask will be applied
* to the text string passed through lpszMaskedText.
* @see
* GetMaskedText, SetMask
*/
void SetMaskedText(LPCTSTR lpszMaskedText);
/**
* @brief
* Gets the value of the item that the user is currently viewing.
* @details
* The return value of this method includes the formatting used for
* the value of the item. For example, if a password mask is shown,
* then the return value of this method would be a CString filled
* with asterisks (*). Otherwise, if a password mask is not shown,
* the return value would be the same as the GetValue method.
* @return
* The value of the item that the user is currently viewing.
*/
virtual CString GetViewValue();
/**
* @brief
* Sets the 32-bit value associated with the item.
* @param dwData 32-bit value to associate with the item.
*/
void SetItemData(DWORD_PTR dwData);
/**
* @brief
* Gets the application-supplied, 32-bit value associated with the item.
* @return
* The 32-bit value associated with the item.
*/
DWORD_PTR GetItemData() const;
/**
* @brief
* Gets the in-place edit control of the item.
* @return
* A reference to the in-place edit control of the item.
*/
virtual CXTPPropertyGridInplaceEdit& GetInplaceEdit();
/**
* @brief
* Sets focus to the in-place control of the item.
*/
virtual void SetFocusToInplaceControl();
/**
* @brief
* Determines if a specified in-place button is visible.
* @param pButton Pointer to a CXTPPropertyGridInplaceButton object.
* @return
* TRUE if the specified in-place button is visible, otherwise FALSE.
* @see
* CXTPPropertyGrid::SetShowInplaceButtonsAlways
*/
virtual BOOL IsInplaceButtonVisible(CXTPPropertyGridInplaceButton* pButton) const;
/**
* @brief
* Gets the collection of in-place buttons of the item.
* @return
* A pointer to the collection of in-place buttons of the item.
*/
CXTPPropertyGridInplaceButtons* GetInplaceButtons() const;
/**
* @brief
* Gets the collection of in-place controls of the item.
* @return
* A pointer to the collection of in-place controls of the item.
*/
CXTPPropertyGridInplaceControls* GetInplaceControls() const;
/**
* @brief
* Adds a standard combo button.
*/
void AddComboButton();
/**
* @brief
* Adds a standard expand button.
*/
void AddExpandButton();
/**
* @brief
* Adds a slider control.
* @return
* A pointer to the newly added CXTPPropertyGridInplaceSlider object.
*/
CXTPPropertyGridInplaceSlider* AddSliderControl();
/**
* @brief
* Adds a spin button control.
* @return
* A pointer to the newly added CXTPPropertyGridInplaceSpinButton object.
*/
CXTPPropertyGridInplaceSpinButton* AddSpinButton();
/**
* @brief
* Gets the metrics of the value part.
* @return
* A pointer to a CXTPPropertyGridItemMetrics object containing
* the metrics (color, style) of the value part.
* @see
* CXTPPropertyGridItemMetrics, GetCaptionMetrics
*/
CXTPPropertyGridItemMetrics* GetValueMetrics() const;
/**
* @brief
* Gets the metrics of the caption part.
* @return
* A pointer to a CXTPPropertyGridItemMetrics object containing
* the metrics (color, style) of the caption part.
* @see
* CXTPPropertyGridItemMetrics, GetValueMetrics
*/
CXTPPropertyGridItemMetrics* GetCaptionMetrics() const;
/**
* @brief
* Gets the metrics of the value/caption part.
* @param bValueMetrics TRUE to get the metrics of the value part,
* FALSE to get the metrics of the caption part.
* @param bCreate TRUE to call the GetValueMetrics/GetCaptionMetrics method
* to get the metrics of the value/caption part.
* @return
* A pointer to a CXTPPropertyGridItemMetrics object containing
* the metrics (color, style) of the value/caption part.
* @see
* CXTPPropertyGridItemMetrics, GetValueMetrics
*/
CXTPPropertyGridItemMetrics* GetMetrics(BOOL bValueMetrics, BOOL bCreate = TRUE) const;
/**
* @brief
* Gets the variable height of the item.
* @return
* The height of the item, or a value of -1 if default values are used.
*/
int GetHeight() const;
/**
* @brief
* Sets the variable height of the item.
* @param nHeight Height to be set, or a value of -1 to use default values.
* @details
* Call CXTPPropertyGrid::SetVariableItemsHeight to use variable height items.
* @see
* CXTPPropertyGrid::SetVariableItemsHeight, SetMultiLinesCount
*/
void SetHeight(int nHeight);
/**
* @brief
* Determines if the item is multi-line (i.e. more than one line).
* @return
* TRUE if the item is multi-line, otherwise FALSE.
* @see
* SetMultiLinesCount
*/
BOOL IsMultiLine() const;
/**
* @brief
* Gets the number of lines of the item.
* @return
* The number of lines of the item.
*/
int GetMultiLinesCount() const;
/**
* @brief
* Sets the number of lines for the item.
* @param nLinesCount Number of lines to be set.
* @details
* Call CXTPPropertyGrid::SetVariableItemsHeight to use variable height items.
*/
void SetMultiLinesCount(int nLinesCount);
/**
* @brief
* Ensures that this item is visible.
*/
void EnsureVisible();
/**
* @brief
* This method is called before the user begins editing the item.
* @return
* TRUE to allow the user to edit the item, FALSE to disallow.
*/
virtual BOOL OnRequestEdit();
/**
* @brief
* This method is called before the user applies a new value to the item.
* @param strValue Value to be set.
* @return
* TRUE to allow the new item value, FALSE to disallow.
*/
virtual BOOL OnAfterEdit(CString& strValue);
/**
* @brief
* This method is called if the user cancels editing the item.
*/
virtual void OnCancelEdit();
/**
* @brief
* Sets the edit style for the item.
* @param dwEditStyle Edit style to be set.
*
* Example:
* pItem->SetEditStyle(ES_MULTILINE | ES_AUTOVSCROLL);*/ void SetEditStyle(DWORD dwEditStyle); /** * @brief * Sets the number of items in the dropdown list. * @param nDropDownItemCount Number of items to be set. */ void SetDropDownItemCount(int nDropDownItemCount); /** * @brief * Gets the number of items in the dropdown list. * @return * The number of items in the dropdown list. * @see * SetDropDownItemCount */ int GetDropDownItemCount() const; /** * @brief * This method is called to check the value from the in-place edit control. */ virtual void OnValidateEdit(); /** * @brief * Gets the CXTPMarkupUIElement object that renders * the caption of the item. * @return * A pointer to the CXTPMarkupUIElement object that renders * the caption of the item. */ CXTPMarkupUIElement* GetMarkupCaption() const; /** * @brief * Gets the CXTPMarkupUIElement object that renders * the description of the item in the Help pane. * @return * A pointer to the CXTPMarkupUIElement object that renders * the description of the item in the Help pane. */ CXTPMarkupUIElement* GetMarkupDescription() const; /** * @brief * Gets the CXTPMarkupUIElement object that renders * the value of the item in the property grid. * @return * A pointer to the CXTPMarkupUIElement object that renders * the value of the item in the property grid. */ CXTPMarkupUIElement* GetMarkupValue() const; /** * @brief * Gets the edit style of the item. * Override this method if you need a custom style. * @details * By default, this method returns WS_CHILD | ES_AUTOHSCROLL. * @return * The edit style of the item. */ virtual DWORD GetEditStyle() const; /** * @brief * Redraws the item. */ void RedrawItem(); protected: /** * @brief * Sets the visible state of the item. * @param bVisible TRUE to set the item to visible. */ virtual void SetVisible(BOOL bVisible); /** * @brief * This method is called when the index of the item is changed. */ virtual void OnIndexChanged(); /** * @brief * This method is called when an item is selected. */ virtual void OnSelect(); /** * @brief * This method is called when an item is de-selected. */ virtual void OnDeselect(); /** * @brief * This method is called when a key is pressed. * @param nChar Specifies the virtual-key code of the given key. * @return * TRUE if the key was processed, otherwise FALSE. */ virtual BOOL OnChar(UINT nChar); /** * @brief * This method is called when the user double-clicks the * left mouse button on the item. * @param nFlags Indicates whether various virtual keys are down * (see Visual C++ documentation). * @param point Specifies the x- and y- coordinates of the cursor. */ virtual void OnLButtonDblClk(UINT nFlags, CPoint point); /** * @brief * This method is called when the user presses the * right mouse button on the item. * @param nFlags Indicates whether various virtual keys are down * (see Visual C++ documentation). * @param point Specifies the x- and y- coordinates of the cursor. */ virtual void OnRButtonDown(UINT nFlags, CPoint point); /** * @brief * This method is called when the user presses the * left mouse button on the item. * @param nFlags Indicates whether various virtual keys are down * (see Visual C++ documentation). * @param point Specifies the x- and y- coordinates of the cursor. * @return * TRUE if the message was processed, otherwise FALSE. */ virtual BOOL OnLButtonDown(UINT nFlags, CPoint point); /** * @brief * This method is called when the user releases the * left mouse button on the item. * @param nFlags Indicates whether various virtual keys are down * (see Visual C++ documentation). * @param point Specifies the x- and y- coordinates of the cursor. */ virtual void OnLButtonUp(UINT nFlags, CPoint point); /** * @brief * This method is called when a non-system key is pressed. * @param nChar Specifies the virtual-key code of the given key. * @return * TRUE if the key was processed, otherwise FALSE. */ virtual BOOL OnKeyDown(UINT nChar); /** * @brief * This method is called when an item is added to the parent. */ virtual void OnAddChildItem(); /** * @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. */ virtual void OnInplaceButtonDown(CXTPPropertyGridInplaceButton* pButton); /** * @brief * Gets the in-place list control of the item. * @return * A reference to the in-place list control of the item. */ virtual CXTPPropertyGridInplaceList& GetInplaceList(); /** * @brief * Sets the text for the in-place edit control. * @param str Reference to the text to be set. */ virtual void SetEditText(const CString& str); /** * @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(); /** * @brief * This method is called when constraints are added to the item * (i.e. when CXTPPropertyGridItemConstraints::AddConstraint is called). * @see * CXTPPropertyGridItemConstraints::AddConstraint, GetConstraints */ virtual void OnConstraintsChanged(); /** * @brief * This method is called when the caption of the item is changed. */ virtual void OnCaptionChanged(); /** * @brief * This method is called by the property grid to set focus to * an in-place child window. * @param bForward TRUE if the user moves focus forward (with Tab), * FALSE if the user moves focus backword (with Shift+Tab). * @return * TRUE if successful, otherwise FALSE. */ virtual BOOL OnInpaceControlFocus(BOOL bForward); /** * @brief * Gets the text of the in-place edit control. * It is sometimes useful to override the default behavior of this method. * @return Gets the text of the in-place edit control */ virtual CString GetInPlacedEditValue() { return m_strValue; } /** * @brief * This method is called when the item's value is changed. * @see * CXTPPropertyGridItem::OnValueChanged */ void NotifyValueChanged(); protected: /** * @brief * Selects the next constraint in the list of constraints. * @return * TRUE if successful, otherwise FALSE. */ BOOL SelectNextConstraint(); /** * @brief * Determines if a specified point is within the value rectangle. * @param point Point to be tested. * @return * TRUE if the specified point is within the value rectangle, otherwise FALSE. */ BOOL PtInValueRect(CPoint point); protected: /** @cond */ // System accessibility Support virtual HRESULT GetAccessibleParent(IDispatch** ppdispParent); virtual HRESULT GetAccessibleDescription(VARIANT varChild, BSTR* pszDescription); virtual HRESULT GetAccessibleName(VARIANT varChild, BSTR* pszName); virtual HRESULT GetAccessibleRole(VARIANT varChild, VARIANT* pvarRole); virtual HRESULT AccessibleLocation(long* pxLeft, long* pyTop, long* pcxWidth, long* pcyHeight, VARIANT varChild); virtual HRESULT AccessibleHitTest(long xLeft, long yTop, VARIANT* pvarChild); virtual HRESULT GetAccessibleState(VARIANT varChild, VARIANT* pvarState); virtual CCmdTarget* GetAccessible(); virtual HRESULT AccessibleSelect(long flagsSelect, VARIANT varChild); virtual HRESULT GetAccessibleValue(VARIANT varChild, BSTR* pszValue); DECLARE_INTERFACE_MAP() /** @endcond */ protected: static int AFX_CDECL NextNumber(LPCTSTR& str); private: void Init(); void Refresh(BOOL bInvalidate = TRUE); void Clear(); CRect GetInplaceWindowsRect(); void SetIndent(int nIndent); void RefreshHeight(); protected: BOOL m_bConstraintEdit; /**< TRUE to constraint edit. */ int m_nIndex; /**< Index of the item. */ int m_nIndent; /**< Indent of the item. */ UINT m_nID; /**< Identifier of the item. */ UINT m_nFlags; /**< Item's flags. */ BOOL m_bReadOnly; /**< TRUE if the item state is set to read-only, FALSE if the item state is set to read/write. */ BOOL m_bVisible; /**< Visibility of the item. */ BOOL m_bCategory; /**< TRUE if the item is a category. */ BOOL m_bExpandable; /**< TRUE if the item can be expanded. */ BOOL m_bExpanded; /**< TRUE if the item is expanded. */ CString m_strValue; /**< Value of the item. */ CString m_strDefaultValue; /**< Default value of the item. */ CString m_strCaption; /**< Caption of the item. */ CString m_strDescription; /**< Description of the item. */ CString m_strTooltip; /**< Tooltip text. */ CXTPPropertyGridItem* m_pParent; /**< Parent item. */ CXTPPropertyGridView* m_pGrid; /**< Parent grid class. */ CXTPPropertyGridItems* m_pChilds; /**< Child items. */ CXTPPropertyGridItemConstraints* m_pConstraints; /**< Item's constraints. */ BOOL m_bAutoComplete; /**< TRUE to enable auto-complete for the item. */ mutable CXTPPropertyGridItemMetrics* m_pValueMetrics; /**< Value part metrics. */ mutable CXTPPropertyGridItemMetrics* m_pCaptionMetrics; /**< Caption part metrics. */ CXTPPropertyGridInplaceButtons* m_pInplaceButtons; /**< In-place buttons array. */ CXTPPropertyGridInplaceControls* m_pInplaceControls; /**< In-place controls array. */ int m_nDropDownItemCount; /**< Maximum drop down items. */ CString* m_pBindString; /**< Bound string. */ CString m_strFormat; /**< Format of the double value. */ CString m_strMask; /**< String to use as edit mask. */ CString m_strLiteral; /**< String to use as literal. This is the same as the edit mask, but all mask characters are replaced with m_chPrompt. */ CString m_strMarkupTemplate; /**< String that represents item's display when markup is on. Use XTP_PG_ITEMVALUE_TO_REPLACE_IN_MARKUP for item text value substitution. */ TCHAR m_chPrompt; /**< Character used as a space holder for a character. This is used in m_strLiteral. */ BOOL m_bUseMask; /**< TRUE to use an edit mask to display item data. */ BOOL m_bPassword; /**< TRUE to use a password mask. If TRUE, then each character will be replaced with an asterisk (*). */ DWORD_PTR m_dwData; /**< The 32-bit value associated with the item. */ BOOL m_bHidden; /**< TRUE if the item is hidden, FALSE if the item is shown. */ int m_nHeight; /**< Item's height; -1 to use the default. */ int m_nLinesCount; /**< Number of lines in a multi-line item. */ DWORD m_dwEditStyle; /**< Edit style. */ CXTPMarkupUIElement* m_pMarkupCaption; /**< Markup UIElement for item's caption. */ CXTPMarkupUIElement* m_pMarkupDescription; /**< Markup UIElement for item's description. */ CXTPMarkupUIElement* m_pMarkupValue; /**< Markup UIElement for item's value. */ friend class CXTPPropertyGridItems; friend class CXTPPropertyGridView; friend class CXTPPropertyGridInplaceEdit; friend class CXTPPropertyGridInplaceButton; DECLARE_DYNAMIC(CXTPPropertyGridItem) # ifdef _XTP_ACTIVEX /** @cond */ protected: DISPID m_dispidBinded; COleDispatchDriver m_dispDriverBinded; COleVariant m_oleTag; DECLARE_DISPATCH_MAP() DECLARE_OLETYPELIB_EX(CXTPPropertyGridItem) afx_msg LPDISPATCH OleInsertChildItem(int nIndex, long nType, LPCTSTR strTitle, const VARIANT* varValue); afx_msg LPDISPATCH OleAddChildItem(long nType, LPCTSTR strTitle, const VARIANT* varValue); afx_msg LPDISPATCH OleAddChildItemBinded(long nType, LPDISPATCH lpHandler, LPCTSTR lpzsProperty); afx_msg LPDISPATCH OleInsertChildItemBinded(long nIndex, long nType, LPDISPATCH lpHandler, LPCTSTR lpzsProperty); afx_msg BOOL OleGetExpanded(); afx_msg void OleSetExpanded(BOOL bExpanded); afx_msg BOOL OleGetSelected(); afx_msg BSTR OleGetDescription(); afx_msg void OleSetSelected(BOOL bSelected); afx_msg LPDISPATCH OleGetParent(); afx_msg LPDISPATCH OleGetChilds(); afx_msg LPDISPATCH OleGetConstraints(); afx_msg long OleGetType(); afx_msg BSTR OleGetMaskedText(); afx_msg virtual const VARIANT OleGetValue(); afx_msg virtual void OleSetValue(const VARIANT* varValue); afx_msg void OleSetMask(LPCTSTR strMask, LPCTSTR strLiteral, const VARIANT* pPrompt); afx_msg LPDISPATCH OleAddInplaceButton(UINT Id); afx_msg LPDISPATCH OleAddSliderControl(); afx_msg LPDISPATCH OleAddSpinButton(); afx_msg LPDISPATCH OleGetButtons(); afx_msg int OleGetHeight(); afx_msg int OleGetMultiLinesCount(); afx_msg void OleGetRect(long* pLeft, long* pTop, long* pRight, long* pBottom); afx_msg void OleStartEdit(); virtual void BindDispatch(); afx_msg LPDISPATCH OleGetValueMetrics(); afx_msg LPDISPATCH OleGetCaptionMetrics(); afx_msg BSTR OleGetCaption(); afx_msg void OleSetCaption(LPCTSTR lpszCaption); afx_msg BSTR OleGetMarkupTemplate(); afx_msg void OleSetMarkupTemplate(LPCTSTR lpszMarkupTemplate); long m_nType; enum { dispidValue = 0L, dispidExpanded = 1L, dispidReadOnly = 2L, dispidSelected = 3L, dispidCaption = 4L, dispidDescription = 5L, dispidTag = 6L, dispidFlags = 7L, dispidConstraintEdit = 8L, dispidFormat = 9L, dispidConstraints = 97L, dispidChilds = 98L, dispidParent = 99L, dispidAddChildItem = 100L, dispidType = 101L, dispidAddChildItemBinded = 102, dispidMarkupTemplate = 121 }; /** @endcond */ # endif friend class CXTPPropertyGridItemConstraints; friend class CXTPPropertyGrid; }; /** * @brief * CXTPPropertyGridItemCategory is a CXTPPropertyGridItem derived class. * Use it to add a sub-category to a property grid control. * Note: * The parent item for the category must also be a category. */ class _XTP_EXT_CLASS CXTPPropertyGridItemCategory : public CXTPPropertyGridItem { public: /** * @brief * Constructs a CXTPPropertyGridItemCategory object. * @param strCaption Caption of the item. * @details * Class CXTPPropertyGridItemCategory has no default constructor. * * When using the second constructor, the Identifier (nID) of the * second constructor can be linked with a STRINGTABLE resource * with the same ID in such form "Caption\\nDescription". */ CXTPPropertyGridItemCategory(LPCTSTR strCaption); /** * @brief * Constructs a CXTPPropertyGridItemCategory object. * @param nID Identifier of the item. * @details * Class CXTPPropertyGridItemCategory has no default constructor. * * When using the second constructor, the Identifier (nID) of the * second constructor can be linked with a STRINGTABLE resource * with the same ID in such form "Caption\\nDescription". */ CXTPPropertyGridItemCategory(UINT nID); }; ////////////////////////////////////////////////////////////////////// AFX_INLINE long CXTPPropertyGridItems::GetCount() const { return (long)m_arrItems.GetSize(); } AFX_INLINE BOOL CXTPPropertyGridItems::IsEmpty() const { return GetCount() == 0; } AFX_INLINE void CXTPPropertyGridItems::AddTail(CXTPPropertyGridItem* pItem) { m_arrItems.Add(pItem); } AFX_INLINE void CXTPPropertyGridItems::InsertAt(int nIndex, CXTPPropertyGridItem* pItem) { m_arrItems.InsertAt(nIndex, pItem); } AFX_INLINE BOOL CXTPPropertyGridItem::HasChilds() const { return !m_pChilds->IsEmpty(); } AFX_INLINE void CXTPPropertyGridItem::SetCaption(LPCTSTR lpszCaption) { CString strCaption(lpszCaption); if (m_strCaption != strCaption) { m_strCaption = strCaption; OnCaptionChanged(); } } AFX_INLINE CString CXTPPropertyGridItem::GetCaption() const { return m_strCaption; } AFX_INLINE CString CXTPPropertyGridItem::GetDescription() const { return m_strDescription; } AFX_INLINE CString CXTPPropertyGridItem::GetMarkupTemplate() const { return m_strMarkupTemplate; } AFX_INLINE BOOL CXTPPropertyGridItem::GetReadOnly() const { return m_bReadOnly; } AFX_INLINE void CXTPPropertyGridItem::SetID(UINT nID) { m_nID = nID; } AFX_INLINE UINT CXTPPropertyGridItem::GetID() const { return m_nID; } AFX_INLINE CString CXTPPropertyGridItem::GetValue() const { return m_strValue; } AFX_INLINE CString CXTPPropertyGridItem::GetDefaultValue() const { return m_strDefaultValue; } AFX_INLINE BOOL CXTPPropertyGridItem::IsCategory() const { return m_bCategory; } AFX_INLINE CXTPPropertyGridView* CXTPPropertyGridItem::GetGrid() const { return m_pGrid; } AFX_INLINE BOOL CXTPPropertyGridItem::OnDrawItemValue(CDC&, CRect) { return FALSE; } AFX_INLINE BOOL CXTPPropertyGridItem::IsVisible() const { return m_bVisible; } AFX_INLINE BOOL CXTPPropertyGridItem::IsExpanded() const { return m_bExpanded; } AFX_INLINE void CXTPPropertyGridItem::SetExpandable(BOOL bExpandable) { m_bExpandable = bExpandable; } AFX_INLINE BOOL CXTPPropertyGridItem::IsExpandable() const { return m_bExpandable; } AFX_INLINE CXTPPropertyGridItem* CXTPPropertyGridItem::GetParentItem() const { return m_pParent; } AFX_INLINE CXTPPropertyGridItems* CXTPPropertyGridItem::GetChilds() const { return m_pChilds; } AFX_INLINE int CXTPPropertyGridItem::GetIndent() const { return m_nIndent; } AFX_INLINE void CXTPPropertyGridItem::SetConstraintEdit(BOOL bConstraintEdit) { m_bConstraintEdit = bConstraintEdit; } AFX_INLINE BOOL CXTPPropertyGridItem::GetConstraintEdit() const { return m_bConstraintEdit; } AFX_INLINE void CXTPPropertyGridItem::SetPasswordMask(TCHAR chMask) { m_bPassword = TRUE; m_chPrompt = chMask; } AFX_INLINE void CXTPPropertyGridItem::OnRButtonDown(UINT, CPoint) { } AFX_INLINE void CXTPPropertyGridItem::OnConstraintsChanged() { } AFX_INLINE void CXTPPropertyGridItem::SetItemData(DWORD_PTR dwData) { m_dwData = dwData; } AFX_INLINE DWORD_PTR CXTPPropertyGridItem::GetItemData() const { return m_dwData; } AFX_INLINE void CXTPPropertyGridItem::SetVisible(BOOL bVisible) { m_bVisible = bVisible; } AFX_INLINE void CXTPPropertyGridItem::OnIndexChanged() { } AFX_INLINE CXTPPropertyGridItemConstraints* CXTPPropertyGridItem::GetConstraints() const { return m_pConstraints; } AFX_INLINE int CXTPPropertyGridItemConstraints::GetCount() const { return (int)m_arrConstraints.GetSize(); } AFX_INLINE BOOL CXTPPropertyGridItemConstraints::IsEmpty() const { return GetCount() == 0; } AFX_INLINE void CXTPPropertyGridItemConstraints::SetCurrent(int nIndex) { m_nCurrent = nIndex; } AFX_INLINE int CXTPPropertyGridItemConstraints::GetCurrent() const { return m_nCurrent; } AFX_INLINE int CXTPPropertyGridItemConstraint::GetIndex() const { return m_nIndex; } AFX_INLINE int CXTPPropertyGridItem::GetHeight() const { return m_nHeight; } AFX_INLINE BOOL CXTPPropertyGridItem::IsMultiLine() const { return m_nLinesCount > 1; } AFX_INLINE int CXTPPropertyGridItem::GetMultiLinesCount() const { return m_nLinesCount; } AFX_INLINE void CXTPPropertyGridItem::SetEditStyle(DWORD dwEditStyle) { m_dwEditStyle = dwEditStyle; } AFX_INLINE BOOL CXTPPropertyGridItem::OnKeyDown(UINT /*nChar*/) { return FALSE; } AFX_INLINE void CXTPPropertyGridItem::SetDropDownItemCount(int nDropDownItemCount) { m_nDropDownItemCount = nDropDownItemCount; } AFX_INLINE int CXTPPropertyGridItem::GetDropDownItemCount() const { return m_nDropDownItemCount; } AFX_INLINE void CXTPPropertyGridItem::SetAutoComplete(BOOL bAutoComplete) { m_bAutoComplete = bAutoComplete; } AFX_INLINE void CXTPPropertyGridItem::SetTooltip(LPCTSTR lpstrTooltip) { m_strTooltip = lpstrTooltip; } AFX_INLINE CString CXTPPropertyGridItem::GetTooltip() const { return m_strTooltip; } AFX_INLINE CXTPMarkupUIElement* CXTPPropertyGridItem::GetMarkupCaption() const { return m_pMarkupCaption; } AFX_INLINE CXTPMarkupUIElement* CXTPPropertyGridItem::GetMarkupDescription() const { return m_pMarkupDescription; } AFX_INLINE CXTPMarkupUIElement* CXTPPropertyGridItem::GetMarkupValue() const { return m_pMarkupValue; } /** @cond */ # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTPPROPERTYGRIDITEM_H__) /** @endcond */