Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

206 lines
5.0 KiB

  1. //+------------------------------------------------------------------
  2. //
  3. // Microsoft IEPEERS
  4. // Copyright (C) Microsoft Corporation, 1999.
  5. //
  6. // File: iextags\utbutton.hxx
  7. //
  8. // Contents: The UtilityButton control.
  9. //
  10. // Classes: CUtilityeButton
  11. //
  12. // Interfaces: IUtilityButton
  13. //
  14. //-------------------------------------------------------------------
  15. #ifndef __UTBUTTON_HXX_
  16. #define __UTBUTTON_HXX_
  17. #include "basectl.hxx"
  18. #include "resource.h" // main symbols
  19. /////////////////////////////////////////////////////////////////////////////
  20. //
  21. // CUtilityButton
  22. //
  23. /////////////////////////////////////////////////////////////////////////////
  24. typedef HRESULT (CBaseCtl::*PFN_PRESSED) (CUtilityButton *pButton);
  25. typedef HRESULT (CBaseCtl::*PFN_MOVED) (CUtilityButton *pButton, long &x, long &y);
  26. #define IS_PRESSABLE(flag) (flag & BUTTON_PRESSABLE)
  27. #define IS_MOVEABLE(flag) (IS_MOVEABLE_X(flag) | IS_MOVEABLE_Y(flag))
  28. #define IS_MOVEABLE_X(flag) (flag & BUTTON_MOVEABLE_X)
  29. #define IS_MOVEABLE_Y(flag) (flag & BUTTON_MOVEABLE_Y)
  30. enum { // Abilities
  31. BUTTON_PRESSABLE = 0x0001,
  32. BUTTON_MOVEABLE_X = 0x0002,
  33. BUTTON_MOVEABLE_Y = 0x0004
  34. };
  35. enum { // Arrow Style
  36. BUTTON_ARROW_UP = 0,
  37. BUTTON_ARROW_DOWN,
  38. BUTTON_ARROW_LEFT,
  39. BUTTON_ARROW_RIGHT
  40. };
  41. //
  42. //
  43. //
  44. // CUtilityButton
  45. //
  46. //
  47. //
  48. class CUtilityButton :
  49. public CBaseCtl,
  50. public CComCoClass<CUtilityButton, &CLSID_CUtilityButton>,
  51. public IDispatchImpl<IUtilityButton, &IID_IUtilityButton, &LIBID_IEXTagLib>
  52. {
  53. public:
  54. //
  55. // Factory constructor
  56. //
  57. static HRESULT Create(CBaseCtl *pOwnerCtl, IHTMLElement *pOwner, CComObject<CUtilityButton> ** ppButton);
  58. ~CUtilityButton ();
  59. protected:
  60. //
  61. // Protected constructor; build using static Create
  62. //
  63. CUtilityButton ();
  64. //
  65. // CBaseCtl overrides
  66. //
  67. HRESULT Init(CBaseCtl *pOwnerCtl, IHTMLElement *pOwner);
  68. HRESULT RegisterEvents();
  69. protected:
  70. //
  71. // Events
  72. //
  73. virtual HRESULT OnClick(CEventObjectAccess *pEvent);
  74. virtual HRESULT OnMouseDown(CEventObjectAccess *pEvent);
  75. virtual HRESULT OnMouseMove(CEventObjectAccess *pEvent);
  76. virtual HRESULT OnMouseUp(CEventObjectAccess *pEvent);
  77. virtual HRESULT OnMouseOver(CEventObjectAccess *pEvent);
  78. virtual HRESULT OnMouseOut(CEventObjectAccess *pEvent);
  79. virtual HRESULT OnSelectStart(CEventObjectAccess *pEvent);
  80. public:
  81. //
  82. // Connection Point Severance
  83. //
  84. HRESULT Unload();
  85. //
  86. // Internal Properties
  87. //
  88. HRESULT SetHeight(long height);
  89. HRESULT SetWidth(long width);
  90. HRESULT SetHorizontalOffset(long pixelOffset);
  91. HRESULT SetVerticalOffset(long pixelOffset);
  92. HRESULT SetArrowStyle(unsigned style);
  93. HRESULT SetArrowColor(VARIANT color);
  94. HRESULT SetFaceColor(VARIANT color);
  95. HRESULT Set3DLightColor(VARIANT color);
  96. HRESULT SetDarkShadowColor(VARIANT color);
  97. HRESULT SetShadowColor(VARIANT color);
  98. HRESULT SetHighlightColor(VARIANT color);
  99. HRESULT SetAbilities(unsigned abilities);
  100. //
  101. // Interigators
  102. //
  103. inline bool IsPressing() { return _pressing; }
  104. inline bool IsRaised() { return _raised; }
  105. inline bool IsMoving() { return _moving; }
  106. //
  107. // Callbacks
  108. //
  109. HRESULT SetPressedCallback(PFN_PRESSED pPressedFunc);
  110. HRESULT SetMovedCallback(PFN_MOVED pMovedFunc);
  111. DECLARE_PROPDESC_MEMBERS(1);
  112. DECLARE_REGISTRY_RESOURCEID(IDR_UTILITYBUTTON)
  113. DECLARE_NOT_AGGREGATABLE(CUtilityButton)
  114. BEGIN_COM_MAP(CUtilityButton)
  115. COM_INTERFACE_ENTRY2(IDispatch,IUtilityButton)
  116. COM_INTERFACE_ENTRY(IAccessible)
  117. COM_INTERFACE_ENTRY(IElementBehavior)
  118. COM_INTERFACE_ENTRY(IUtilityButton)
  119. COM_INTERFACE_ENTRY(IPersistPropertyBag2)
  120. END_COM_MAP()
  121. private:
  122. //
  123. // CUtilityButton
  124. //
  125. HRESULT BuildButton();
  126. HRESULT ShowDepressed();
  127. HRESULT ShowRaised();
  128. HRESULT ShowDisabled();
  129. HRESULT BuildArrow();
  130. HRESULT SetArrowSize();
  131. private:
  132. long _tx;
  133. long _ty;
  134. bool _moving;
  135. bool _pressing;
  136. bool _raised;
  137. unsigned _abilities : 4;
  138. CBaseCtl *_pOwnerCtl;
  139. VARIANT _vFaceColor;
  140. VARIANT _vArrowColor;
  141. VARIANT _v3dLightColor;
  142. VARIANT _vDarkShadowColor;
  143. VARIANT _vShadowColor;
  144. VARIANT _vHighlightColor;
  145. IHTMLElement *_pOwner; // the owner element
  146. IHTMLElement *_pElement; // the button outline element
  147. IHTMLElement *_pFace;
  148. IHTMLElement *_pArrow; // the font element containing arrow text
  149. IHTMLStyle *_pFaceStyle;
  150. IHTMLStyle *_pStyle;
  151. PFN_PRESSED _pfnPressed;
  152. PFN_MOVED _pfnMoved;
  153. };
  154. #endif // __BUTTON_HXX_