UICombo.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef __UICOMBO_H__
  2. #define __UICOMBO_H__
  3. #pragma once
  4. namespace DuiLib {
  5. /////////////////////////////////////////////////////////////////////////////////////
  6. //
  7. class CComboWnd;
  8. class UILIB_API CComboUI : public CContainerUI, public IListOwnerUI
  9. {
  10. DECLARE_DUICONTROL(CComboUI)
  11. friend class CComboWnd;
  12. public:
  13. CComboUI();
  14. ~CComboUI();
  15. LPCTSTR GetClass() const;
  16. LPVOID GetInterface(LPCTSTR pstrName);
  17. void DoInit();
  18. UINT GetControlFlags() const;
  19. CDuiString GetText() const;
  20. void SetEnabled(bool bEnable = true);
  21. void SetTextStyle(UINT uStyle);
  22. UINT GetTextStyle() const;
  23. void SetTextColor(DWORD dwTextColor);
  24. DWORD GetTextColor() const;
  25. void SetDisabledTextColor(DWORD dwTextColor);
  26. DWORD GetDisabledTextColor() const;
  27. void SetFont(int index);
  28. int GetFont() const;
  29. RECT GetTextPadding() const;
  30. void SetTextPadding(RECT rc);
  31. bool IsShowHtml();
  32. void SetShowHtml(bool bShowHtml = true);
  33. bool IsShowShadow();
  34. void SetShowShadow(bool bShow = true);
  35. CDuiString GetDropBoxAttributeList();
  36. void SetDropBoxAttributeList(LPCTSTR pstrList);
  37. SIZE GetDropBoxSize() const;
  38. void SetDropBoxSize(SIZE szDropBox);
  39. RECT GetDropBoxInset() const;
  40. void SetDropBoxInset(RECT szDropBox);
  41. UINT GetListType();
  42. TListInfoUI* GetListInfo();
  43. int GetCurSel() const;
  44. bool SelectItem(int iIndex, bool bTakeFocus = false);
  45. bool SelectMultiItem(int iIndex, bool bTakeFocus = false);
  46. bool UnSelectItem(int iIndex, bool bOthers = false);
  47. bool SetItemIndex(CControlUI* pControl, int iIndex);
  48. bool Add(CControlUI* pControl);
  49. bool AddAt(CControlUI* pControl, int iIndex);
  50. bool Remove(CControlUI* pControl);
  51. bool RemoveAt(int iIndex);
  52. void RemoveAll();
  53. bool Activate();
  54. LPCTSTR GetNormalImage() const;
  55. void SetNormalImage(LPCTSTR pStrImage);
  56. LPCTSTR GetHotImage() const;
  57. void SetHotImage(LPCTSTR pStrImage);
  58. LPCTSTR GetPushedImage() const;
  59. void SetPushedImage(LPCTSTR pStrImage);
  60. LPCTSTR GetFocusedImage() const;
  61. void SetFocusedImage(LPCTSTR pStrImage);
  62. LPCTSTR GetDisabledImage() const;
  63. void SetDisabledImage(LPCTSTR pStrImage);
  64. bool GetScrollSelect();
  65. void SetScrollSelect(bool bScrollSelect);
  66. void SetItemFont(int index);
  67. void SetItemTextStyle(UINT uStyle);
  68. RECT GetItemTextPadding() const;
  69. void SetItemTextPadding(RECT rc);
  70. DWORD GetItemTextColor() const;
  71. void SetItemTextColor(DWORD dwTextColor);
  72. DWORD GetItemBkColor() const;
  73. void SetItemBkColor(DWORD dwBkColor);
  74. LPCTSTR GetItemBkImage() const;
  75. void SetItemBkImage(LPCTSTR pStrImage);
  76. bool IsAlternateBk() const;
  77. void SetAlternateBk(bool bAlternateBk);
  78. DWORD GetSelectedItemTextColor() const;
  79. void SetSelectedItemTextColor(DWORD dwTextColor);
  80. DWORD GetSelectedItemBkColor() const;
  81. void SetSelectedItemBkColor(DWORD dwBkColor);
  82. LPCTSTR GetSelectedItemImage() const;
  83. void SetSelectedItemImage(LPCTSTR pStrImage);
  84. DWORD GetHotItemTextColor() const;
  85. void SetHotItemTextColor(DWORD dwTextColor);
  86. DWORD GetHotItemBkColor() const;
  87. void SetHotItemBkColor(DWORD dwBkColor);
  88. LPCTSTR GetHotItemImage() const;
  89. void SetHotItemImage(LPCTSTR pStrImage);
  90. DWORD GetDisabledItemTextColor() const;
  91. void SetDisabledItemTextColor(DWORD dwTextColor);
  92. DWORD GetDisabledItemBkColor() const;
  93. void SetDisabledItemBkColor(DWORD dwBkColor);
  94. LPCTSTR GetDisabledItemImage() const;
  95. void SetDisabledItemImage(LPCTSTR pStrImage);
  96. DWORD GetItemLineColor() const;
  97. void SetItemLineColor(DWORD dwLineColor);
  98. bool IsItemShowHtml();
  99. void SetItemShowHtml(bool bShowHtml = true);
  100. SIZE EstimateSize(SIZE szAvailable);
  101. void SetPos(RECT rc, bool bNeedInvalidate = true);
  102. void Move(SIZE szOffset, bool bNeedInvalidate = true);
  103. void DoEvent(TEventUI& event);
  104. void SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue);
  105. bool DoPaint(HDC hDC, const RECT& rcPaint, CControlUI* pStopControl);
  106. void PaintText(HDC hDC);
  107. void PaintStatusImage(HDC hDC);
  108. public:
  109. void SortItems();
  110. BOOL SortItems(PULVCompareFunc pfnCompare, UINT_PTR dwData);
  111. protected:
  112. static int __cdecl ItemComareFunc(void* pvlocale, const void* item1, const void* item2);
  113. int __cdecl ItemComareFunc(const void* item1, const void* item2);
  114. protected:
  115. PULVCompareFunc m_pCompareFunc;
  116. UINT_PTR m_compareData;
  117. protected:
  118. CComboWnd* m_pWindow;
  119. int m_iCurSel;
  120. DWORD m_dwTextColor;
  121. DWORD m_dwDisabledTextColor;
  122. int m_iFont;
  123. UINT m_uTextStyle;
  124. RECT m_rcTextPadding;
  125. bool m_bShowHtml;
  126. bool m_bShowShadow;
  127. CDuiString m_sDropBoxAttributes;
  128. SIZE m_szDropBox;
  129. RECT m_rcDropBox;
  130. UINT m_uButtonState;
  131. CDuiString m_sNormalImage;
  132. CDuiString m_sHotImage;
  133. CDuiString m_sPushedImage;
  134. CDuiString m_sFocusedImage;
  135. CDuiString m_sDisabledImage;
  136. bool m_bScrollSelect;
  137. TListInfoUI m_ListInfo;
  138. };
  139. } // namespace DuiLib
  140. #endif // __UICOMBO_H__