/** * @file XTPSearchOptionsCtrl.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(__XTPSEARCHOPTIONSCTRL_H__) # define __XTPSEARCHOPTIONSCTRL_H__ /** @endcond */ # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" /** * @brief * CXTPSearchOptionsCtrl is a CStatic derived class. CXTPSearchOptionsCtrl * is used to create a control similar to the Search Options item found * in the search pane of Windows Explorer as it is seen in Windows 2000 and * later. This class allows you to associate a group of controls to be * hidden or shown when the item is expanded and contracted and a set * of controls that need to move depending on the CXTPSearchOptionsCtrl state. * * Use with the CXTPSearchOptionsView form view class to create a pane * similar to the Windows Explorer search pane. To use the control, define * a set of controls that are to be hidden and moved depending on the * CXTPSearchOptionsCtrl state. * * Example: * The following example demonstrates how to use CXTPSearchOptionsCtrl. *
 * void CExpandTestView::OnInitialUpdate()
 * {
 *    CXTPSearchOptionsView::OnInitialUpdate();
 *
 *    m_expand.AddControl(&m_check1);
 *    m_expand.AddControl(&m_check2);
 *    m_expand.AddControl(&m_edit1);
 *    m_expand.AddControl(&m_edit2);
 *
 *    m_expand.MoveControl(&m_button1);
 *    m_expand.MoveControl(&m_button2);
 *    m_expand.MoveControl(&m_combo1);
 *
 *    m_expand.SetLabelText(
 *    _T("Search Options <<"), _T("Search Options >>"));
 * }
 * 
* * See the "SearchOptions" demo for a complete example. */ class _XTP_EXT_CLASS CXTPSearchOptionsCtrl : public CStatic { /** @cond */ DECLARE_DYNAMIC(CXTPSearchOptionsCtrl) /** @endcond */ public: /** * @brief * Constructs a CXTPSearchOptionsCtrl object. */ CXTPSearchOptionsCtrl(); /** * @brief * Destroys a CXTPSearchOptionsCtrl object, handles cleanup and deallocation. */ virtual ~CXTPSearchOptionsCtrl(); public: /** * @brief * Call this member function to determine if the search options * control has been expanded. * @return * true if expanded, otherwise false. */ bool IsExpanded() const; /** * @brief * Call this member function to add a control to the list of controls * that are displayed when the hide item control is expanded. * @param pWndCtrl Pointer to a valid CWnd object. */ void AddControl(CWnd* pWndCtrl); /** * @brief * Call this member function to add a control to the list of controls * that are moved when the hide item control is either expanded or contracted. * @param pWndCtrl Pointer to a valid CWnd object. */ void MoveControl(CWnd* pWndCtrl); /** * @brief * Call this member function to set the text that is displayed when the * hide item control is either expanded or contracted. * @param lpszExpand A NULL-terminated string that represents the text displayed * when the control is expanded. * @param lpszContract A NULL-terminated string that represents the text displayed * when the control is contracted. */ void SetLabelText(LPCTSTR lpszExpand, LPCTSTR lpszContract); /** * @brief * Call this member function to expand the hide item control and display * CWnd objects contained in the hide item list. Called by the control * whenever the user clicks on the expand label. */ void Expand(); /** * @brief * Call this member function to contract the hide item control and hide * CWnd objects contained in the hide item list. Called by the control * whenever the user clicks on the contract label. */ void Contract(); /** * @brief * Call this member function to return the minimum height of the hide * item control. * @return * An integer value that represents the height of the hide item control * when it is contracted. */ int GetMinSize(); /** * @brief * Call this member function to return the maximum height of the hide * item control. * @return * An integer value that represents the height of the hide item control * when it is expanded. */ int GetMaxSize(); /** * @brief * Call this member function to return the offset size for the * CXTPSearchOptionsCtrl object. This is the distance that the controls will * be moved to accommodate for the expansion and contraction of the control. * Also used by CXTPSearchOptionsView for adjusting scroll sizes. * @return * An integer value that represents the distance that the controls * will be moved. */ int GetOffsetSize(); protected: /** * @brief * This member function is called by the CXTPSearchOptionsCtrl class to * perform initialization when the window is created or sub-classed. * @return * TRUE if the window was successfully initialized, otherwise FALSE. */ virtual bool Init(); /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPSearchOptionsCtrl) virtual void PreSubclassWindow(); virtual BOOL PreCreateWindow(CREATESTRUCT& cs); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPSearchOptionsCtrl) afx_msg BOOL OnEraseBkgnd(CDC* pDC); afx_msg void OnPaint(); afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message); afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnWindowPosChanged(WINDOWPOS FAR* lpwndpos); afx_msg void OnEnable(BOOL bEnable); //}}AFX_MSG /** @endcond */ protected: int m_iMinSize; /**< Height of the control when contracted. */ int m_iMaxSize; /**< Height of the control when expanded. */ bool m_bExpanded; /**< true when the control is expanded. */ bool m_bPreSubclassInit; /**< true for initialization. */ CRect m_rcLabel; /**< Size of the label that is displayed. */ CString m_strExpandLabel; /**< Label to display when the control is expanded. */ CString m_strContractLabel; /**< Label to display when the control is contracted. */ CPtrArray m_arHideCtrls; /**< List of controls to show or hide. */ CPtrArray m_arMoveCtrls; /**< List of controls to move when expanded or contracted. */ }; ////////////////////////////////////////////////////////////////////// /** @cond */ AFX_INLINE int CXTPSearchOptionsCtrl::GetMinSize() { return m_iMinSize; } AFX_INLINE int CXTPSearchOptionsCtrl::GetMaxSize() { return m_iMaxSize; } AFX_INLINE int CXTPSearchOptionsCtrl::GetOffsetSize() { return GetMaxSize() - GetMinSize(); } AFX_INLINE bool CXTPSearchOptionsCtrl::IsExpanded() const { return m_bExpanded; } /** @endcond */ // forwards class CXTPSearchOptionsCtrl; /** * @brief * CXTPSearchOptionsView is a CFormView derived class. It is to * be used with a CXTPSearchOptionsCtrl object to paint the background * and control background color white. It is also used for resizing * and moving children of the form automatically. */ class _XTP_EXT_CLASS CXTPSearchOptionsView : public CFormView { /** @cond */ DECLARE_DYNAMIC(CXTPSearchOptionsView) /** @endcond */ private: // CResizeWnd - private helper class class CResizeWnd { public: CResizeWnd(CWnd* pWndParent, HWND hWndChild, const XTP_RESIZEPOINT& ptTopLeft, const XTP_RESIZEPOINT& ptTopRight); virtual ~CResizeWnd(); bool Resize(HDWP& hDWP, float iOffset); bool IsGroupBox(); HWND m_hWndChild; CWnd* m_pWndParent; CRect m_rcWindow; CRect m_rcParent; CXTPResizeRect m_rcSizing; }; private: // CResizeWndArray - private helper class typedef CList CResizeWndArray; protected: /** * @brief * When you create an object of a type derived from CXTPSearchOptionsView, * invoke one of the constructors to create the view object and identify the * dialog resource on which the view is based. You can identify the resource * either by name (pass a string as the argument to the constructor) or by * its ID (pass an unsigned integer as the argument). * @param nIDTemplate Contains the ID number of a dialog-template resource. * @details * The form-view window and child controls are not created until CWnd::Create * is called. CWnd::Create is called by the framework as part of the document * and view creation process, which is driven by the document template. */ CXTPSearchOptionsView(UINT nIDTemplate); /** * @brief * When you create an object of a type derived from CXTPSearchOptionsView, * invoke one of the constructors to create the view object and identify the * dialog resource on which the view is based. You can identify the resource * either by name (pass a string as the argument to the constructor) or by * its ID (pass an unsigned integer as the argument). * @param lpszTemplateName Contains a NULL-terminated string that is the name of * a dialog-template resource. * @details * The form-view window and child controls are not created until CWnd::Create * is called. CWnd::Create is called by the framework as part of the document * and view creation process, which is driven by the document template. */ CXTPSearchOptionsView(LPCTSTR lpszTemplateName); /** * @brief * Destroys a CXTPSearchOptionsView object, handles cleanup and deallocation. */ virtual ~CXTPSearchOptionsView(); protected: /** * @brief * The SetResize function specifies how much each side of a control will * move when the dialog is resized. If a control should be repositioned * (e.g. an OK button), then all four sides should move by the same amount * of pixels as the dialog is resized. If a control should be resized * just as much as the dialog (e.g. the list control in the file dialog), * then the left and top sides should not move, and the right and * bottom sides should move by the same amount of pixels as the dialog. * @param nID Specifies the control's ID. * @param ptTopLeft How much the top and left sides will move when the dialog * is resized. * @param ptTopRight How much the bottom and right sides will move when the dialog * is resized. */ void SetResize(int nID, const XTP_RESIZEPOINT& ptTopLeft, const XTP_RESIZEPOINT& ptTopRight); /** * @brief * Call this member function to adjust the scroll sizes for the form view. * @param pSOCtrl Pointer to the CXTPSearchOpetionsCtrl object to adjust the scroll * sizes for. * @param bAdd true to add the size, false to subtract the size. */ void AdjustScrollSizes(CXTPSearchOptionsCtrl* pSOCtrl, bool bAdd); public: virtual COLORREF GetBackColor() const; protected: /** @cond */ DECLARE_MESSAGE_MAP() //{{AFX_VIRTUAL(CXTPSearchOptionsView) protected: virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); virtual BOOL OnInitDialog(); //}}AFX_VIRTUAL //{{AFX_MSG(CXTPSearchOptionsView) afx_msg HBRUSH OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor); afx_msg void OnSize(UINT nType, int cx, int cy); //}}AFX_MSG /** @endcond */ protected: CXTPBrush m_xtpBrush; /**< Handle to the current background brush. */ XTP_SUBSTITUTE_GDI_MEMBER_WITH_CACHED_(HBRUSH, HBRUSH, HBRUSH, m_hBrush, m_xtpBrush, GetBrushHandle); COLORREF m_clrBrush; CRect m_rcWindow; /**< Original size of the window. */ CResizeWndArray m_arResizeWnd; /**< Array of children to move or resize. */ }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" /** @cond */ #endif // !defined(__XTPSEARCHOPTIONSCTRL_H__) /** @endcond */