📄 treepropsheetbase.h
字号:
an empty page, when the sheet is in tree view mode
This default implementation simply returns lpszEmptyPageMessage
with the optional "%s" placeholder replaced by lpszCaption.
@param lpszEmptyPageMessage
The string, set by SetEmptyPageMessage(). This string may contain
a "%s" placeholder.
@param lpszCaption
The title of the empty page.
*/
virtual CString GenerateEmptyPageMessage(LPCTSTR lpszEmptyPageMessage, LPCTSTR lpszCaption);
/**
Will be called during creation process, to create the CTreeCtrl
object (the object, not the window!).
Allows you to inject your own CTreeCtrl-derived classes.
This default implementation simply creates a CTreeCtrl with new
and returns it.
*/
virtual CTreeCtrl* CreatePageTreeObject();
/**
Will be called during creation process, to create the object, that
is responsible for drawing the frame around the pages, drawing the
empty page message and the caption.
Allows you to inject your own CPropPageFrame-derived classes.
This default implementation simply creates a CPropPageFrameTab with
new and returns it.
*/
virtual CPropPageFrame* CreatePageFrame();
/**
Method called for each tree item from RefreshPageTree. The default implementation
only refreshes the text color of the item based on the enabled status of the
associated property page. Override this method if you want expand the behavior -
for instance refreshing the text itself.
@param hItem Item to be refreshed. */
virtual void RefreshTreeItem(HTREEITEM hItem);
// Implementation helpers
protected:
/**
Moves all children by the specified amount of pixels.
@param nDx
Pixels to move the children in horizontal direction (can be
negative).
@param nDy
Pixels to move the children in vertical direction (can be
negative).
*/
void MoveChildWindows(int nDx, int nDy);
/**
Refills the tree that contains the entries for the several pages.
During this operation, the tree is not redrawn and it is refreshed
once all the removal and insertion has been performed.
*/
void RefillPageTree();
/**
Refreshes the tree control. This is called during enabling and
disabling a property page. This method calls RefreshTreeItem for
each item in the tree.
@param hItem The specified item and its children to be refreshed.
@param bRedraw Invalidate the tree upon exiting the method.
*/
void RefreshPageTree(HTREEITEM hItem = TVI_ROOT, const bool bRedraw = true);
/**
Creates the specified path in the page tree and returns the handle
of the most child item created.
@param lpszPath
Path of the item to create (see description of this class).
@param hParent
Handle of the item under which the path should be created or
TVI_ROOT to start from the root.
*/
HTREEITEM CreatePageTreeItem(LPCTSTR lpszPath, HTREEITEM hParent = TVI_ROOT);
/**
Splits the given path into the topmost item and the rest. See
description of this class for detailed path information.
I.e. when given the string "Appearance::Toolbars::Customize", the
method will return "Appearance" and after the call strRest will
be "Toolbars::Customize".
*/
CString SplitPageTreePath(CString &strRest);
/**
Tries to deactivate the current page, and hides it if successful,
so that an empty page becomes visible.
@return
TRUE if the current page has been deactivated successfully,
FALSE if the currently active page prevents a page change.
*/
BOOL KillActiveCurrentPage();
/**
Returns the page tree item, that represents the specified page
or NULL, if no such item exists.
@param nPage
Zero based page index, for which the item to retrieve.
@param hRoot
Item to start the search at or TVI_ROOT to search the whole
tree.
*/
HTREEITEM GetPageTreeItem(int nPage, HTREEITEM hRoot = TVI_ROOT);
/**
Selects and shows the item, representing the specified page.
@param nPage
Zero based page index.
@return
TRUE on success, FALSE if no item does exist for the specified
page.
*/
BOOL SelectPageTreeItem(int nPage);
/**
Selects and shows the tree item for the currently active page.
@return
TRUE on success, FALSE if no item exists for the currently active
page or if it was not possible to get information about the
currently active page.
*/
BOOL SelectCurrentPageTreeItem();
/**
Updates the caption for the currently selected page (if the caption
is enabled).
*/
void UpdateCaption();
/**
Activates the previous page in the page order or the last one, if
the current one is the first. The method takes into account the
setting indicating if blank pages should be skipped.
This method does never fail.
*/
void ActivatePreviousPage();
/**
Activates the page located before the page designated by the provided
tree item. This call might be recursive. The method takes into account
the setting indicating if blank pages should be skipped.
This method does never fail.
*/
void ActivatePreviousPage(HTREEITEM hItem);
/**
Activates the next page in the page order or the first one, if the
current one is the last. The method takes into account the
setting indicating if blank pages should be skipped.
This method does never fail.
*/
void ActivateNextPage();
/**
Activates the page located after the page designated by the provided
tree item. This call might be recursive. The method takes into account
the setting indicating if blank pages should be skipped.
This method does never fail.
*/
void ActivateNextPage(HTREEITEM hItem);
/** Helper method indicating if the sheet is in wizard mode.
@return True if in wizard mode, false otherwise (in tab or
tree view mode). */
bool IsWizardMode() const;
/** Given a tree item, returns the index of the page representing
the next property page. The search is performed depth first.
If there is no valid page, 0 is returned.
@param hTreeItem Tree item where the search should start.
@return Index of the next valid page or 0 if none. */
int GetNextValidPageIndex(HTREEITEM hTreeItem) const;
/** Returns the next tree item, searching first for children then
sibling.
@param hItem ITem where the search starts.
@return Next tree item or NULL if none. */
HTREEITEM GetNextItem(HTREEITEM hItem) const;
/** Given a tree item, returns the tree item representing the next
property page. The search is performed depth first. If there
is no valid page, NULL is returned.
@param hTreeItem Tree item where the search should start.
@return Tree item of the next valid page. */
HTREEITEM GetNextValidPageTreeItem(HTREEITEM hTreeItem) const;
/** Helper indicating if the provided tree item has a valid property
page associated with it or an empty page. This is done by
retrieving the data item and if it is different from
kNoPageAssociated, the tree item has a property page associated.
@param hItem Tree item to check.
@return True if the tree item has a property page associated with it. */
bool HasValidPropertyPageAssociated(HTREEITEM hItem) const;
/** Helper indicating if the page associated with the item is enabled
or disabled.
@param hItem Tree item to check.
@return True if the tree item has not page or a page that is enabled,
false if the page is disabled. */
bool IsAssociatedPropertyPageEnabled(HTREEITEM hItem) const;
/** Helper indicating if the provided item is expanded or collapsed.
@param hItem Tree item to check.
@return True if the item is expanded, false if not (or if it does not
have any children. */
bool IsItemExpanded(HTREEITEM hItem) const;
/** Helper indicating if the specified tree item is displayable. This takes
into account the following:
- check if item without property page should be displayed,
- check if item with disabled property pages should be displayed.
This is introduces so that if behavior is changed by introducing new checks,
only this method should need updating.
@param hItem Tree item to check
@return True if the item is associated with a displayable page. */
bool IsTreeItemDisplayable(const HTREEITEM hItem) const;
/** Helper initializing members. */
void Init();
// Overridings
protected:
//{{AFX_VIRTUAL(CTreePropSheetBase)
public:
virtual BOOL OnInitDialog();
virtual BOOL PreTranslateMessage(MSG* pMsg);
//}}AFX_VIRTUAL
// Message handlers
protected:
//{{AFX_MSG(CTreePropSheetBase)
afx_msg void OnDestroy();
//}}AFX_MSG
afx_msg LRESULT OnAddPage(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnRemovePage(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetCurSel(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetCurSelId(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnIsDialogMessage(WPARAM wParam, LPARAM lParam);
afx_msg void OnPageTreeSelChanging(NMHDR *pNotifyStruct, LRESULT *plResult);
afx_msg void OnPageTreeSelChanged(NMHDR *pNotifyStruct, LRESULT *plResult);
afx_msg LRESULT OnEnablePage(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
// Inner class
private:
/*! \brief Class containing extra information regarding each property pages. */
class CPageInformation
{
// Construction/Destruction
public:
CPageInformation()
: m_bEnabled(true)
{
}
// Properties
bool IsEnabled() const {return m_bEnabled; }
void SetIsEnabled(const bool bEnabled) { m_bEnabled = bEnabled; }
// Members
private:
/*! Flag indicating page enabled status. */
bool m_bEnabled;
};
/*! Typedef for container of page information. */
typedef std::map<const CPropertyPage* const, CPageInformation> tMapPageInformation;
// Properties
private:
/** TRUE if we should use the tree control instead of the tab ctrl. */
BOOL m_bTreeViewMode;
/** The tree control */
CTreeCtrl *m_pwndPageTree;
/** The frame around the pages */
CPropPageFrame *m_pFrame;
/** TRUE if a page caption should be displayed, FALSE otherwise. */
BOOL m_bPageCaption;
/** TRUE if images should be displayed in the tree. */
BOOL m_bTreeImages;
/** Images to be displayed in the tree control. */
CImageList m_Images;
/** Default images. */
CImageList m_DefaultImages;
/**
Message to be displayed on empty pages. May contain a "%s"
placeholder which will be replaced by the caption of the empty
page.
*/
CString m_strEmptyPageMessage;
/*! Value indicating that active page should not be set from the tree during
tree content initialization. When the value is different from 0,
OnPageTreeSelChanging does not process new selection. This is set when
the tree is filled (in RefillPageTree).
*/
int m_nRefillingPageTreeContent;
protected:
/** The width of the page tree control in pixels. */
int m_nPageTreeWidth;
/** Separator width. */
int m_nSeparatorWidth;
/*! Skip empty pages. */
bool m_bSkipEmptyPages;
/*! Tree in auto-expand mode. */
bool m_bAutoExpandTree;
/*! Map keep extra page information. */
tMapPageInformation m_mapPageInformation;
/*! Flag indicating if disabled pages should be skipped. */
bool m_bSkipDisabledPages;
// Static Properties
private:
/** The id of the tree view control, that shows the pages. */
static const UINT s_unPageTreeId;
};
} //namespace TreePropSheet
//#pragma warning(pop)
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
#endif // _TREEPROPSHEET_TREEPROPSHEETBASE_H__INCLUDED_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -