/**
* @file XTPControlPopup.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(__XTPCONTROLPOPUP_H__)
# define __XTPCONTROLPOPUP_H__
/** @endcond */
# if _MSC_VER >= 1000
# pragma once
# endif // _MSC_VER >= 1000
# include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h"
class CXTPCommandBar;
class CXTPControls;
/**
* @brief
* CXTPControlPopup is a CXTPControl derived class.
* It represents a pop-upable control.
*/
class _XTP_EXT_CLASS CXTPControlPopup : public CXTPControlButton
{
public:
/**
* @brief
* Constructs a CXTPControlPopup object.
*/
CXTPControlPopup();
/**
* @brief
* Destroys a CXTPControlPopup object, handles cleanup and deallocation.
*/
virtual ~CXTPControlPopup();
public:
/**
* @brief
* Creates a CXTPControlPopup object with the specified type.
* @param controlType XTPControlType type of pop-up control. Can be any of the
* values listed in the Remarks section.
* @details
* Pop-up type can be one of the following:
* xtpControlPopup: Pop-up type.
* xtpControlButtonPopup: Button pop-up.
* xtpControlSplitButtonPopup: Split button pop-up.
* @return
* A pointer to a CXTPControlPopup object.
*/
static CXTPControlPopup* AFX_CDECL CreateControlPopup(XTPControlType controlType);
public:
/**
* @brief
* Call this member to set the child command bar.
* @param pMenu The menu to be loaded as a child.
*/
void SetCommandBar(CMenu* pMenu);
/**
* @brief
* Call this member to set the child command bar.
* @param pBar The child command bar.
*/
void SetCommandBar(CXTPCommandBar* pBar);
/**
* @brief
* Call this member to get the child command bar.
* @return
* A pointer to the child command bar.
*/
CXTPCommandBar* GetCommandBar() const;
/**
* @brief
* Call this member to get the control's pop-up state.
* @return
* TRUE if the control is a pop-up, otherwise FALSE.
*/
BOOL GetPopuped() const;
/**
* @brief
* Call this member to get the control's caption.
* @return
* The caption of the control.
*/
virtual CString GetCaption() const;
/**
* @brief
* Either reads this object from or writes this object to an archive.
* @param pPX A CXTPPropExchange object to serialize to or from.
*/
void DoPropExchange(CXTPPropExchange* pPX);
/**
* @brief
* Updates rectangle to set the position where the child pop-up bar becomes visible.
* @param rc CRect object specifying the size of the area.
* @param bVertical TRUE if the control is located vertically in its parent.
*/
virtual void AdjustExcludeRect(CRect& rc, BOOL bVertical);
/**
* @brief
* This method is called to copy the control.
* @param pControl Pointer to a source CXTPControl object.
* @param bRecursive TRUE to copy recursively.
*/
void Copy(CXTPControl* pControl, BOOL bRecursive = FALSE);
/**
* @brief
* This method is called when the user activates a control using its underline.
*/
virtual void OnUnderlineActivate();
protected:
/**
* @brief
* This method is called to check if pControlPopup contains in
* the control recursively.
* @param pControlPopup Pointer to a CXTPControlPopup object to check.
* @return
* TRUE if contains; otherwise returns FALSE
*/
BOOL ContainsPopup(CXTPControlPopup* pControlPopup);
/** @cond */
_XTP_DEPRECATED_IN_FAVOR(ContainsPopup)
BOOL IsContainPopup(CXTPControlPopup* pControlPopup)
{
return ContainsPopup(pControlPopup);
}
/** @endcond */
/**
* @brief
* Call this member to expand the parent pop-up bar.
*/
void ExpandCommandBar();
/**
* @brief
* This method is called when the control becomes selected.
* @param bSelected TRUE if the control becomes selected.
* @return
* TRUE if successful, otherwise FALSE.
*/
BOOL OnSetSelected(int bSelected);
/**
* @brief
* This method is called when the user clicks the control.
* @param bKeyboard TRUE if the control is selected using the keyboard.
* @param pt Mouse cursor position.
*/
void OnClick(BOOL bKeyboard = FALSE, CPoint pt = CPoint(0, 0));
/**
* @brief
* This method is called after the mouse hovers over the control.
*/
void OnMouseHover();
/**
* @brief
* This member is called when the mouse cursor moves.
* @param point Specifies the x- and y- coordinates of the cursor.
*/
virtual void OnMouseMove(CPoint point);
/**
* @brief
* This method is called to pop-up the control.
* @param bPopup TRUE to set pop-up.
* @return
* TRUE if successful, otherwise FALSE.
*/
virtual BOOL OnSetPopup(BOOL bPopup);
/**
* @brief
* This member is called when the user releases the left mouse
* button.
* @param point Specifies the x- and y- coordinates of the cursor.
*/
virtual void OnLButtonUp(CPoint point);
/**
* @brief
* This member is called when the user double-clicks the left mouse
* button.
* @param point Specifies the x- and y- coordinates of the cursor.
* @return
* TRUE if successful, otherwise FALSE.
*/
virtual BOOL OnLButtonDblClk(CPoint point);
/**
* @brief
* This method is called when the user moves the mouse over the
* control.
* @param pDataObject Pointer to a CXTPControl object.
* @param point Mouse position.
* @param dropEffect DROPEFFECT enumerator.
*/
void OnCustomizeDragOver(CXTPControl* pDataObject, CPoint point, DROPEFFECT& dropEffect);
/**
* @brief
* The implementation may implement a custom drag over handling logic in this method.
* @param pCommandBar Pointer to a CXTPCommandBar object.
* @param point Mouse position.
* @param dropEffect DROPEFFECT enumerator.
* @return
* TRUE if custom implementation handles drag over, otherwise FALSE.
*/
virtual BOOL DoCustomDragOver(CXTPCommandBar* pCommandBar, CPoint point,
DROPEFFECT& dropEffect);
/**
* @brief
* Call this member to compare controls.
* @param pOther The control to compare with.
* @return
* TRUE if the controls are identical, otherwise FALSE.
*/
virtual BOOL Compare(CXTPControl* pOther);
/**
* @brief
* Call this member to update the shadow of the control.
*/
virtual void UpdateShadow();
protected:
/**
* @brief
* This method is called from LoadCommandBars to restore
* controls and its child command bars.
* @param pCommandBarList Command bars collection that contains all the
* command bars to be restored.
*/
virtual void RestoreCommandBarList(CXTPCommandBarList* pCommandBarList);
protected:
BOOL m_bPopup; /**< TRUE if pop-up'ed. */
CXTPCommandBar* m_pCommandBar; /**< Child pop-up bar. */
DWORD m_dwCommandBarID; /**< Child pop-up ID. */
BOOL m_bShowShadow; /**< TRUE to show shadow. */
public:
# ifdef _XTP_COMMANDBARS_ACTIVEX
/** @cond */
DECLARE_DISPATCH_MAP()
DECLARE_INTERFACE_MAP()
DECLARE_OLETYPELIB_EX(CXTPControlPopup);
afx_msg LPDISPATCH OleGetCommandBar();
afx_msg void OleSetCommandBar(LPDISPATCH lpCommandBar);
enum
{
dispidCommandBar = 50L,
dispidStyle = 51L,
};
/** @endcond */
# endif
DECLARE_XTP_CONTROL(CXTPControlPopup)
friend class CXTPControls;
friend class CXTPPopupBar;
friend class CXTPCommandBar;
};
//////////////////////////////////////////////////////////////////////////
AFX_INLINE CXTPCommandBar* CXTPControlPopup::GetCommandBar() const
{
return m_pCommandBar;
}
AFX_INLINE BOOL CXTPControlPopup::GetPopuped() const
{
return m_bPopup;
}
/** @cond */
# include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h"
#endif //#if !defined(__XTPCONTROLPOPUP_H__)
/** @endcond */