UICombo.h 4.7 KB

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