navigation.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. #ifndef NULLOSFT_MEDIALIBRARY_NAVIGATION_HEADER
  2. #define NULLOSFT_MEDIALIBRARY_NAVIGATION_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <windows.h>
  7. #include "./config.h"
  8. #include "./ml_imagelist.h"
  9. typedef LPVOID HNAVCTRL;
  10. typedef LPVOID HNAVITEM;
  11. typedef struct _NAVITEM_I
  12. {
  13. UINT mask;
  14. INT id;
  15. LPWSTR pszText;
  16. INT cchTextMax;
  17. LPWSTR pszInvariant;
  18. INT cchInvariantMax;
  19. INT iImage;
  20. INT iSelectedImage;
  21. UINT state;
  22. UINT stateMask;
  23. UINT style;
  24. UINT styleMask;
  25. HFONT hFont;
  26. LPARAM lParam;
  27. } NAVITEM_I;
  28. typedef struct _NAVITEMDRAW_I
  29. {
  30. HDC hdc; //
  31. COLORREF clrText; //
  32. COLORREF clrTextBk; //
  33. HFONT hFont; //
  34. RECT *prc; //
  35. UINT itemState; // NIS_XXX
  36. UINT drawStage; // NIDS_XXX
  37. INT iLevel; // Zero-based level of the item being drawn.
  38. } NAVITEMDRAW_I;
  39. // navigation control styles
  40. #define NCS_NORMAL_I 0x0000
  41. #define NCS_FULLROWSELECT_I 0x0001
  42. #define NCS_SHOWICONS_I 0x0002
  43. // nav item draw stage
  44. #define NIDS_PREPAINT_I 0x0001
  45. #define NIDS_POSTPAINT_I 0x0002
  46. // item custom draw callback return values
  47. #define NICDRF_DODEFAULT_I 0x0001
  48. #define NICDRF_SKIPDEFAULT_I 0x0002
  49. #define NICDRF_NOTIFYPOSTPAINT_I 0x0004
  50. #define NICDRF_NEWFONT_I 0x0008
  51. // hit test flags
  52. #define NAVHT_NOWHERE_I 0x0001
  53. #define NAVHT_ONITEM_I 0x0002
  54. #define NAVHT_ONITEMBUTTON_I 0x0004 // only if item currently has children
  55. #define NAVHT_ONITEMINDENT_I 0x0010
  56. #define NAVHT_ONITEMRIGHT_I 0x0020
  57. #define NAVHT_ABOVE_I 0x0100
  58. #define NAVHT_BELOW_I 0x0200
  59. #define NAVHT_TORIGHT_I 0x0400
  60. #define NAVHT_TOLEFT_I 0x0800
  61. // navigation item masks
  62. #define NIMF_ITEMID_I 0x0001
  63. #define NIMF_TEXT_I 0x0002
  64. #define NIMF_TEXTINVARIANT_I 0x0004
  65. #define NIMF_IMAGE_I 0x0008
  66. #define NIMF_IMAGESEL_I 0x0010
  67. #define NIMF_STATE_I 0x0020
  68. #define NIMF_STYLE_I 0x0040
  69. #define NIMF_FONT_I 0x0080
  70. #define NIMF_PARAM_I 0x0100
  71. // states
  72. #define NIS_NORMAL_I 0x0000
  73. #define NIS_SELECTED_I 0x0001
  74. #define NIS_EXPANDED_I 0x0002
  75. #define NIS_DROPHILITED_I 0x0004
  76. #define NIS_FOCUSED_I 0x0008 // used with draw item
  77. // styles
  78. #define NIS_HASCHILDREN_I 0x0001 // item has children
  79. #define NIS_ALLOWCHILDMOVE_I 0x0002 // allow children to be moved (re-ordered)
  80. #define NIS_ALLOWEDIT_I 0x0004 // allow title edit
  81. #define NIS_ITALIC_I 0x0100 // when displaying item text draw it with italic style
  82. #define NIS_BOLD_I 0x0200 // when displaying item text draw it with bold style
  83. #define NIS_UNDERLINE_I 0x0400 // when displaying item text draw it with underline style
  84. #define NIS_CUSTOMDRAW_I 0x0010 // custom draw calback
  85. #define NIS_WANTSETCURSOR_I 0x0020 // item want to recive set cursor notification
  86. #define NIS_WANTHITTEST_I 0x0040 // item want to monitor/modify hittest results
  87. /// internal style - do not use
  88. #define NIS_WANTPOSTPAINT_I 0x8000 // custom draw calback
  89. // image types
  90. #define IMAGE_NORMAL_I 0x0000
  91. #define IMAGE_SELECTED_I 0x0001
  92. // item expand command flags
  93. #define NAVITEM_TOGGLE_I 0x0000
  94. #define NAVITEM_EXPAND_I 0x0001
  95. #define NAVITEM_COLLAPSE_I 0x0002
  96. // action codes
  97. #define ACTION_CLICKL_I 0x0000
  98. #define ACTION_CLICKR_I 0x0001
  99. #define ACTION_ENTER_I 0x0002
  100. #define ACTION_DBLCLICKL_I 0x0003
  101. #define ACTION_DBLCLICKR_I 0x0004
  102. // navigation callbacks ident
  103. #define CALLBACK_ONCLICK_I 0x0001
  104. #define CALLBACK_ONSELECTED_I 0x0002
  105. #define CALLBACK_ONKEYDOWN_I 0x0003
  106. #define CALLBACK_ONBEGINDRAG_I 0x0004
  107. #define CALLBACK_ONGETIMAGEINDEX_I 0x0005
  108. #define CALLBACK_ONBEGINTITLEEDIT_I 0x0006
  109. #define CALLBACK_ONENDTITLEEDIT_I 0x0007
  110. #define CALLBACK_ONITEMDELETE_I 0x0008
  111. #define CALLBACK_ONITEMDRAW_I 0x0009
  112. #define CALLBACK_ONSETCURSOR_I 0x000A
  113. #define CALLBACK_ONHITTEST_I 0x000B
  114. #define CALLBACK_ONDESTROY_I 0x000C
  115. typedef BOOL (CALLBACK *ONNAVITEMCLICK_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/, INT /*actionId*/); // return TRUE if you want to prevent further processing
  116. typedef void (CALLBACK *ONNAVITEMSELECTED_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItemOld*/, HNAVITEM /*hItemNew*/);
  117. typedef BOOL (CALLBACK *ONNAVCTRLKEYDOWN_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/, NMTVKEYDOWN* /*ptvkd*/);
  118. typedef void (CALLBACK *ONNAVCTRLBEGINDRAG_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/, POINT /*pt*/);
  119. typedef INT (CALLBACK *ONNAVITEMGETIMAGEINDEX_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/, INT /*imageType*/); // if item image index == -1 you can provide some some other index
  120. typedef BOOL (CALLBACK *ONNAVITEMBEGINTITLEEDIT_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/); // return TRUE to allow edit
  121. typedef BOOL (CALLBACK *ONNAVCTRLENDTITLEEDIT_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/, LPCWSTR /*pszNewTitle*/); // if pszNewTitle == NULL edit wa canceled. Return TRUE to accept new title
  122. typedef void (CALLBACK *ONNAVITEMDELETE_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/); //
  123. typedef UINT (CALLBACK *ONNAVITEMDRAW_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/, NAVITEMDRAW_I* /*pnicd*/, LPARAM /*lParam*/); // custom draw
  124. typedef BOOL (CALLBACK *ONNAVITEMSETCURSOR_I)(HNAVCTRL /*hNav*/, HNAVITEM /*hItem*/, LPARAM /*lParam*/); // set cursor
  125. typedef void (CALLBACK *ONNAVITEMHITTEST_I)(HNAVCTRL /*hNav*/, POINT /*pt*/, UINT* /*pFlags*/, HNAVITEM* /*phItem*/, LPARAM /*lParam*/);
  126. typedef void (CALLBACK *ONNAVCTRLDESTROY_I)(HNAVCTRL /*hNav*/);
  127. // name compare flags
  128. #define NICF_DISPLAY_I 0x0001 // compare display name (if specified in combination with othe flags will be used last)
  129. #define NICF_INVARIANT_I 0x0002 // compare invariant name (if specified in combination with other flags will be used after FULL and before DISPLAY
  130. #define NICF_IGNORECASE_I 0x0004 // ignore case (always used when comparing invariant names)
  131. // NavItemI_SetOrder flags
  132. #define NOF_MOVEONEBEFORE_I 0x00 // if order inded already used set order for this item and move old item on one position after until all items rearranged
  133. #define NOF_MOVEONEAFTER_I 0x01 //
  134. #define NOF_MOVEBEFORE_I 0x02 //
  135. #define NOF_MOVEAFTER_I 0x03 //
  136. // NavCtrlI_EnumItems callback
  137. typedef BOOL (CALLBACK *NAVENUMPROC_I)(HNAVITEM /*hItem*/, LPARAM /*lParam*/); // return FALSE to stop enumeration
  138. // Use this to in NavCtrlI_InertItem to create hInsertAfter
  139. #define MAKE_NAVITEMSORTORDER(o) ((HNAVITEM)((ULONG_PTR)((WORD)(o))))
  140. #define IS_NAVITEMSORTORDER(_i) ((((ULONG_PTR)(_i)) >> 16) == 0)
  141. #define NUF_LOCK_NONE_I 0x00
  142. #define NUF_LOCK_SELECTED_I 0x01 // try to remember selected position if no selected items in the view it will fallback to NUF_REMEMBER_TOP_I
  143. #define NUF_LOCK_TOP_I 0x02 // try to remeber top item...
  144. // insert item Insert after flags
  145. #define NCI_FIRST_I ((HNAVITEM)(ULONG_PTR)-0x0FFFF) // insert first item
  146. #define NCI_LAST_I ((HNAVITEM)(ULONG_PTR)-0x00000) // insert as last item
  147. // Navigation Control
  148. // NavCtrlI_Create - create new navigation manager
  149. HNAVCTRL NavCtrlI_Create(HWND hwndParent);
  150. BOOL NavCtrlI_SetRect(HNAVCTRL hNav, RECT *prc);
  151. BOOL NavCtrlI_Show(HNAVCTRL hNav, INT nCmdShow);
  152. BOOL NavCtrlI_Enable(HNAVCTRL hNav, BOOL fEnable);
  153. BOOL NavCtrlI_Destroy(HNAVCTRL hNav);
  154. BOOL NavCtrlI_Update(HNAVCTRL hNav); // calls UpdateWindow for the host;
  155. BOOL NavCtrlI_ProcessNotifications(HNAVCTRL hNav, LPNMHDR pnmh, LRESULT *pResult);
  156. C_Config *NavCtrlI_SetConfig(HNAVCTRL hNav, C_Config *pConfig);
  157. BOOL NavCtrlI_BeginUpdate(HNAVCTRL hNav, UINT fRememberPos); // call to prevent redraw (use NUF_REMEMBER_XXX)
  158. BOOL NavCtrlI_EndUpdate(HNAVCTRL hNav); // call to allow redraw
  159. BOOL NavCtrlI_DeleteItem(HNAVCTRL hNav, HNAVITEM hItem);
  160. BOOL NavCtrlI_DeleteAll(HNAVCTRL hNav);
  161. HNAVITEM NavCtrlI_FindItem(HNAVCTRL hNav, INT itemId);
  162. HNAVITEM NavCtrlI_FindItemByName(HNAVCTRL hNav, LCID Locale, UINT compFlags, LPCWSTR pszName, INT cchLength); // use one of the NICF_* flags
  163. HNAVITEM NavCtrlI_FindItemByFullName(HNAVCTRL hNav, LCID Locale, UINT compFlags, LPCWSTR pszName, INT cchLength, BOOL fAncestorOk); // use one of the NICF_* flags. if fAncestor is set and item with this name not exist - will fall back to closest ancestor
  164. HNAVITEM NavCtrlI_InsertItem(HNAVCTRL hNav, HNAVITEM hInsertAfter, HNAVITEM hParent, NAVITEM_I *pnis); // if hInsertAfter > 0xFFFF it is consider as an item otherwise it is sort order, Use MAKE_NAVITEMSORTORDER macro
  165. HNAVITEM NavCtrlI_GetRoot(HNAVCTRL hNav);
  166. HNAVITEM NavCtrlI_GetSelection(HNAVCTRL hNav);
  167. HNAVITEM NavCtrlI_GetFirstVisible(HNAVCTRL hNav);
  168. HNAVITEM NavCtrlI_GetLastVisible(HNAVCTRL hNav);
  169. BOOL NavCtrlI_UpdateLook(HNAVCTRL hNav);
  170. HMLIMGLST NavCtrlI_SetImageList(HNAVCTRL hNav, HMLIMGLST hmlil);
  171. HMLIMGLST NavCtrlI_GetImageList(HNAVCTRL hNav);
  172. HWND NavCtrlI_GetHWND(HNAVCTRL hNav);
  173. LPVOID NavCtrlI_RegisterCallback(HNAVCTRL hNav, LPVOID fnCallback, INT cbType);
  174. HNAVITEM NavCtrlI_HitTest(HNAVCTRL hNav, POINT *ppt, UINT *pFlags);
  175. BOOL NavCtrlI_SetInsertMark(HNAVCTRL hNav, HNAVITEM hItem, BOOL fAfter);
  176. BOOL NavCtrlI_EnumItems(HNAVCTRL hNav, NAVENUMPROC_I pEnumFunc, HNAVITEM hItemStart, LPARAM lParam);
  177. INT NavCtrlI_MapPointsTo(HNAVCTRL hNav, HWND hwndTo, POINT *ppt, UINT cPoints);
  178. INT NavCtrlI_MapPointsFrom(HNAVCTRL hNav, HWND hwndFrom, POINT *ppt, UINT cPoints);
  179. BOOL NavCtrlI_EndEditTitle(HNAVCTRL hNav, BOOL fCancel);
  180. INT NavCtrlI_GetIndent(HNAVCTRL hNav);
  181. DWORD NavCtrlI_GetStyle(HNAVCTRL hNav); // NCS_XXX
  182. // Navigation Item
  183. BOOL NavItemI_EditTitle(HNAVITEM hItem);
  184. HNAVITEM NavItemI_GetChild(HNAVITEM hItem);
  185. INT NavItemI_GetChildrenCount(HNAVITEM hItem);
  186. HFONT NavItemI_GetFont(HNAVITEM hItem);
  187. INT NavItemI_GetId(HNAVITEM hItem);
  188. INT NavItemI_GetImageIndex(HNAVITEM hItem, INT imageType);
  189. BOOL NavItemI_GetIndirect(HNAVITEM hItem, NAVITEM_I *pnis);
  190. BOOL NavItemI_GetText(HNAVITEM hItem, LPWSTR pszText, INT cchMaxLen);
  191. BOOL NavItemI_GetInvariantText(HNAVITEM hItem, LPWSTR pszText, INT cchMaxLen);
  192. HNAVITEM NavItemI_GetNext(HNAVITEM hItem);
  193. WORD NavItemI_GetOrder(HNAVITEM hItem);
  194. HNAVITEM NavItemI_GetParent(HNAVITEM hItem);
  195. HNAVITEM NavItemI_GetPrevious(HNAVITEM hItem);
  196. BOOL NavItemI_GetRect(HNAVITEM hItem, RECT *prc, BOOL fItemRect);
  197. HNAVITEM NavItemI_GetRoot(HNAVITEM hItem);
  198. UINT NavItemI_GetState(HNAVITEM hItem, UINT stateMask);
  199. UINT NavItemI_GetStyle(HNAVITEM hItem, UINT styleMask);
  200. INT NavItemI_GetFullName(HNAVITEM hItem, LPWSTR pszFullName, INT cchMaxLen);
  201. BOOL NavItemI_HasChildren(HNAVITEM hItem); // checks if item style for NIS_HASCHILDREN_I
  202. BOOL NavItemI_HasChildrenReal(HNAVITEM hItem); // cheks if item actually has at least one child
  203. BOOL NavItemI_IsSelected(HNAVITEM hItem);
  204. BOOL NavItemI_IsExpanded(HNAVITEM hItem);
  205. BOOL NavItemI_Expand(HNAVITEM hItem, UINT flag);
  206. BOOL NavItemI_Move(HNAVITEM hItem, HNAVITEM hItemDest, BOOL fAfter);
  207. HFONT NavItemI_SetFont(HNAVITEM hItem, HFONT hFont); // you stil own this font !!! (set hFont to NULL if you want to use treeview font). Returns previously set font.
  208. BOOL NavItemI_SetId(HNAVITEM hItem, INT itemId);
  209. BOOL NavItemI_SetImageIndex(HNAVITEM hItem, INT mlilIndex, INT imageType);
  210. BOOL NavItemI_SetIndirect(HNAVITEM hItem, NAVITEM_I *pnis);
  211. BOOL NavItemI_SetState(HNAVITEM hItem, UINT state, UINT stateMask);
  212. BOOL NavItemI_SetStyle(HNAVITEM hItem, UINT style, UINT mask);
  213. BOOL NavItemI_SetText(HNAVITEM hItem, LPCWSTR pszText);
  214. BOOL NavItemI_SetInvariantText(HNAVITEM hItem, LPCWSTR pszText);
  215. // Sets Item order and modifies all items oreder after it if required.
  216. // if oder == 0xFFFF order will be set to max + 1 for this group
  217. // returns new item order or 0xFFFF if error;
  218. // minimal order value 1.
  219. // flags one of the NOF_XXX
  220. WORD NavItemI_SetOrder(HNAVITEM hItem, WORD order, UINT flags);
  221. BOOL NavItemI_EnsureVisible(HNAVITEM hItem);
  222. BOOL NavItemI_Select(HNAVITEM hItem);
  223. HIMAGELIST NavItemI_CreateDragImage(HNAVITEM hItem, LPCWSTR pszTipText);
  224. BOOL NavItemI_Invalidate(HNAVITEM hItem, RECT *prc, BOOL fErase);
  225. #endif //NULLOSFT_MEDIALIBRARY_NAVIGATION_HEADER