listview.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. ** Copyright (C) 2003 Nullsoft, Inc.
  3. **
  4. ** This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held
  5. ** liable for any damages arising from the use of this software.
  6. **
  7. ** Permission is granted to anyone to use this software for any purpose, including commercial applications, and to
  8. ** alter it and redistribute it freely, subject to the following restrictions:
  9. **
  10. ** 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software.
  11. ** If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  12. **
  13. ** 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  14. **
  15. ** 3. This notice may not be removed or altered from any source distribution.
  16. **
  17. */
  18. #if 0
  19. #ifndef _LISTVIEW_H_
  20. #define _LISTVIEW_H_
  21. #include <windows.h>
  22. #include <windowsx.h>
  23. #include <commctrl.h>
  24. class W_ListView
  25. {
  26. public:
  27. W_ListView()
  28. {
  29. m_hwnd=NULL;
  30. m_col=0;
  31. m_allowfonts=1;
  32. m_font=NULL;
  33. #ifndef GEN_ML_EXPORTS
  34. m_libraryparent=NULL;
  35. #endif
  36. }
  37. W_ListView(HWND hwnd)
  38. {
  39. m_hwnd=NULL;
  40. m_col=0;
  41. m_allowfonts=1;
  42. m_font=NULL;
  43. #ifndef GEN_ML_EXPORTS
  44. m_libraryparent=NULL;
  45. #endif
  46. setwnd(hwnd);
  47. }
  48. ~W_ListView()
  49. {
  50. if (m_font) DeleteFont(m_font);
  51. m_font=0;
  52. }
  53. void refreshFont();
  54. #ifndef GEN_ML_EXPORTS
  55. void setLibraryParentWnd(HWND hwndParent)
  56. {
  57. m_libraryparent=hwndParent;
  58. }// for Winamp Font getting stuff
  59. #endif
  60. void setallowfonts(int allow=1);
  61. void setwnd(HWND hwnd);
  62. void AddCol(char *text, int w);
  63. int GetCount(void)
  64. {
  65. return ListView_GetItemCount(m_hwnd);
  66. }
  67. int GetParam(int p);
  68. void DeleteItem(int n)
  69. {
  70. ListView_DeleteItem(m_hwnd,n);
  71. }
  72. void Clear(void)
  73. {
  74. ListView_DeleteAllItems(m_hwnd);
  75. }
  76. int GetSelected(int x)
  77. {
  78. return(ListView_GetItemState(m_hwnd, x, LVIS_SELECTED) & LVIS_SELECTED)?1:0;
  79. }
  80. int GetSelectedCount()
  81. {
  82. return ListView_GetSelectedCount(m_hwnd);
  83. }
  84. int GetSelectionMark()
  85. {
  86. return ListView_GetSelectionMark(m_hwnd);
  87. }
  88. void SetSelected(int x)
  89. {
  90. ListView_SetItemState(m_hwnd,x,LVIS_SELECTED,LVIS_SELECTED);
  91. }
  92. int InsertItem(int p, char *text, int param);
  93. void GetItemRect(int i, RECT *r)
  94. {
  95. ListView_GetItemRect(m_hwnd, i, r, LVIR_BOUNDS);
  96. }
  97. void SetItemText(int p, int si, char *text);
  98. void SetItemParam(int p, int param);
  99. void GetText(int p, int si, char *text, int maxlen)
  100. {
  101. ListView_GetItemText(m_hwnd, p, si, text, maxlen);
  102. }
  103. int FindItemByParam(int param)
  104. {
  105. LVFINDINFO fi={LVFI_PARAM,0,param};
  106. return ListView_FindItem(m_hwnd,-1,&fi);
  107. }
  108. int FindItemByPoint(int x, int y)
  109. {
  110. int l=GetCount();
  111. for (int i=0;i<l;i++)
  112. {
  113. RECT r;
  114. GetItemRect(i, &r);
  115. if (r.left<=x && r.right>=x && r.top<=y && r.bottom>=y) return i;
  116. }
  117. return -1;
  118. }
  119. int GetColumnWidth(int col);
  120. HWND getwnd(void)
  121. {
  122. return m_hwnd;
  123. }
  124. protected:
  125. HWND m_hwnd;
  126. HFONT m_font;
  127. int m_col;
  128. int m_allowfonts;
  129. #ifndef GEN_ML_EXPORTS
  130. HWND m_libraryparent;
  131. #endif
  132. };
  133. #endif//_LISTVIEW_H_
  134. #endif