/** * @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