1
0

toolbar.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. #ifndef NULLSOFT_WINAMP_OMBROWSER_TOOLBAR_HEADER
  2. #define NULLSOFT_WINAMP_OMBROWSER_TOOLBAR_HEADER
  3. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  4. #pragma once
  5. #endif
  6. #include <wtypes.h>
  7. // registered classes
  8. #define TOOLCLS_STATIC "static"
  9. #define TOOLCLS_BUTTON "button"
  10. #define TOOLCLS_RATING "rating"
  11. #define TOOLCLS_PROGRESS "progress"
  12. #define TOOLCLS_ADDRESSBAR "addressbar"
  13. #define TOOLITEM_SEPARATOR "separator"
  14. #define TOOLITEM_SPACE "space"
  15. #define TOOLITEM_FLEXSPACE "spaceFlexible"
  16. #define TOOLITEM_CHEVRON "chevron"
  17. #define TOOLITEM_BUTTON_HOME (TOOLCLS_BUTTON "Home")
  18. #define TOOLITEM_BUTTON_BACK (TOOLCLS_BUTTON "Back")
  19. #define TOOLITEM_BUTTON_FORWARD (TOOLCLS_BUTTON "Forward")
  20. #define TOOLITEM_BUTTON_STOP (TOOLCLS_BUTTON "Stop")
  21. #define TOOLITEM_BUTTON_REFRESH (TOOLCLS_BUTTON "Refresh")
  22. #define TOOLITEM_BUTTON_HISTORY (TOOLCLS_BUTTON "History")
  23. #define TOOLITEM_CMDLINK_INFO (TOOLCLS_BUTTON "Info")
  24. #define TOOLITEM_CMDLINK_REPORT (TOOLCLS_BUTTON "Report")
  25. #define TOOLITEM_CMDLINK_UNSUBSCRIBE (TOOLCLS_BUTTON "Unsubscribe")
  26. #define TOOLITEM_USERRATING (TOOLCLS_RATING "User")
  27. #define TOOLITEM_DOWNLOADPROGRESS (TOOLCLS_PROGRESS "Download")
  28. #define TOOLITEM_ADDRESSBAR (TOOLCLS_ADDRESSBAR "Main")
  29. #define TOOLITEM_BUTTON_SCRIPTERROR (TOOLCLS_BUTTON "ScriptError")
  30. #define TOOLITEM_BUTTON_SECURECONNECTION (TOOLCLS_BUTTON "SecureConnection")
  31. #define NWC_ONLINEMEDIATOOLBAR L"Nullsoft_omBrowserToolbar"
  32. BOOL Toolbar_RegisterClass(HINSTANCE hInstance);
  33. #define ITEM_ERR ((INT)-1)
  34. // styles
  35. #define TBS_LOCKUPDATE 0x00000001 // do not reset directly use Toolbar_LockUpdate().
  36. #define TBS_AUTOHIDE 0x00000002
  37. #define TBS_BOTTOMDOCK 0x00000004
  38. #define TBS_TABSTOP 0x00000008
  39. #define TBS_SHOWADDRESS 0x00000010
  40. #define TBS_FORCEADDRESS 0x00000020
  41. #define TBS_FANCYADDRESS 0x00000040
  42. // item styles
  43. #define TBIS_HIDDEN 0x0001
  44. #define TBIS_DISABLED 0x0002
  45. #define TBIS_CHEVRONONLY 0x0004 // show item only in chevron
  46. #define TBIS_NOCHEVRON 0x0008 // show item in toolbar and ignore in chevron
  47. #define TBIS_POPUP 0x0010 // item only take space when visible
  48. // messages
  49. #define TBM_FIRST (WM_USER + 10)
  50. #define TBM_UPDATESKIN (TBM_FIRST + 0) //wParam = not used, lParam = (LPARAM)(BOOL)fRedraw.
  51. #define Toolbar_UpdateSkin(/*HWND*/ __hToolbar, /*BOOL*/ __fRedraw)\
  52. (SENDMSG(__hToolbar, TBM_UPDATESKIN, 0, (LPARAM)(__fRedraw)))
  53. #define TBM_GETIDEALHEIGHT (TBM_FIRST + 1)
  54. #define Toolbar_GetIdealHeight(/*HNWD*/__hToolbar)\
  55. ((INT)SendMessage((__hToolbar), TBM_GETIDEALHEIGHT, 0, 0L))
  56. #define TBM_GETICONSIZE (TBM_FIRST + 3)
  57. #define Toolbar_GetIconSize(/*HWND*/ __hToolbar, /*INT*/ __iconIndex, /*PSIZE*/ __sizeOut)\
  58. ((BOOL)SendMessage((__hToolbar), TBM_GETICONSIZE, (WPARAM)(__iconIndex), (LPARAM)(__sizeOut)))
  59. #define TBM_SENDCOMMAND (TBM_FIRST + 4)
  60. #define Toolbar_SendCommand(/*HWND*/ __hToolbar, /*INT*/ __commandId)\
  61. ((BOOL)SendMessage((__hToolbar), TBM_SENDCOMMAND, (WPARAM)(__commandId), 0L))
  62. typedef struct __TOOLBARDRAWICONPARAM
  63. {
  64. HDC hdcDst;
  65. INT iconIndex;
  66. INT x;
  67. INT y;
  68. INT cx;
  69. INT cy;
  70. UINT itemState;
  71. } TOOLBARDRAWICONPARAM;
  72. #define TBM_DRAWICON (TBM_FIRST + 5)
  73. #define Toolbar_DrawIcon(/*HWND*/ __hToolbar, /*TOOLBARDRAWICONPARAM* */ __toolbarDrawIconParam)\
  74. ((BOOL)SendMessage((__hToolbar), TBM_DRAWICON, 0, (LPARAM)(__toolbarDrawIconParam)))
  75. #define Toolbar_LockUpdate(/*HWND*/ __hToolbar, /*BOOL*/__fLock)\
  76. (SendMessage((__hToolbar), WM_SETREDRAW, (WPARAM)(0 == (__fLock)), 0L))
  77. #define TBM_GETITEMCOUNT (TBM_FIRST + 6)
  78. #define Toolbar_GetItemCount(/*HWND*/ __hToolbar)\
  79. ((INT)SendMessage((__hToolbar), TBM_GETITEMCOUNT, 0, 0L))
  80. #define TBM_CLEAR (TBM_FIRST + 7)
  81. #define Toolbar_Clear(/*HWND*/ __hToolbar)\
  82. ((BOOL)SendMessage((__hToolbar), TBM_CLEAR, 0, 0L))
  83. #define TBIP_FIRST 0x0000
  84. #define TBIP_LAST 0xFFFFFF
  85. typedef struct __TOOLBARINSERTITEM
  86. {
  87. INT cbSize;
  88. INT insertBefore; // you can use TBIP_XXX here
  89. LPCSTR pszName;
  90. UINT style;
  91. } TOOLBARINSERTITEM;
  92. #define TBM_INSERTITEM (TBM_FIRST + 8) // wParam - not used, lParam = (LPARAM)(TOOLBARINSERTITEM*)pInsertItem; Return item index or ITEM_ERR
  93. #define Toolbar_InsertItem(/*HWND*/ __hToolbar, /*TOOLBARINSERTITEM*/ __pInsertItem)\
  94. ((INT)SendMessage((__hToolbar), TBM_INSERTITEM, 0, (LPARAM)__pInsertItem))
  95. #define TBM_FINDITEM (TBM_FIRST + 9)
  96. #define Toolbar_FindItem(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName)\
  97. ((INT)SendMessage((__hToolbar), TBM_FINDITEM, 0, (LPARAM)(__pszItemName)))
  98. #define TBM_REMOVEITEM (TBM_FIRST + 10) // itemName can be INT index
  99. #define Toolbar_RemoveItem(/*HWND*/ __hToolbar, /*LPCSTR*/__pszItemName)\
  100. ((BOOL)SendMessage((__hToolbar), TBM_REMOVEITEM, 0, (LPARAM)(__pszItemName)))
  101. #define TBM_SETITEMINT (TBM_FIRST + 11) // itemName can be INT index
  102. #define Toolbar_SetItemInt(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*INT*/ __intValue)\
  103. ((BOOL)SendMessage((__hToolbar), TBM_SETITEMINT, (WPARAM)(__intValue), (LPARAM)(__pszItemName)))
  104. #define TBM_SETITEMSTRING (TBM_FIRST + 12) // itemName can be INT index
  105. #define Toolbar_SetItemString(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*LPCWSTR*/ __stringValue)\
  106. ((BOOL)SendMessage((__hToolbar), TBM_SETITEMSTRING, (WPARAM)(__stringValue), (LPARAM)(__pszItemName)))
  107. #define TBM_GETBKCOLOR (TBM_FIRST + 13)
  108. #define Toolbar_GetBkColor(/*HWND*/ __hToolbar)\
  109. ((COLORREF)SendMessage((__hToolbar), TBM_GETBKCOLOR, 0, 0L))
  110. #define TBM_GETFGCOLOR (TBM_FIRST + 14)
  111. #define Toolbar_GetFgColor(/*HWND*/ __hToolbar)\
  112. ((COLORREF)SendMessage((__hToolbar), TBM_GETFGCOLOR, 0, 0L))
  113. #define TBM_GETTEXTCOLOR (TBM_FIRST + 15)
  114. #define Toolbar_GetTextColor(/*HWND*/ __hToolbar)\
  115. ((COLORREF)SendMessage((__hToolbar), TBM_GETTEXTCOLOR, 0, 0L))
  116. #define TBM_GETHILITECOLOR (TBM_FIRST + 16)
  117. #define Toolbar_GetHiliteColor(/*HWND*/ __hToolbar)\
  118. ((COLORREF)SendMessage((__hToolbar), TBM_GETHILITECOLOR, 0, 0L))
  119. #define TBM_ENABLEITEM (TBM_FIRST + 17) // itemName can be INT index
  120. #define Toolbar_EnableItem(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*BOOL*/ __fEnable)\
  121. ((BOOL)SendMessage((__hToolbar), TBM_ENABLEITEM, (WPARAM)(__fEnable), (LPARAM)(__pszItemName)))
  122. #define TBM_SHOWITEM (TBM_FIRST + 18) // itemName can be INT index
  123. #define Toolbar_ShowItem(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*BOOL*/ __fShow)\
  124. ((BOOL)SendMessage((__hToolbar), TBM_SHOWITEM, (WPARAM)(__fShow), (LPARAM)(__pszItemName)))
  125. #define TBM_UPDATETIP (TBM_FIRST + 19)
  126. #define Toolbar_UpdateTip(/*HWND*/ __hToolbar)\
  127. ((BOOL)SendMessage((__hToolbar), TBM_UPDATETIP, 0, 0L))
  128. typedef struct __TOOLBARTEXTMETRIC
  129. {
  130. INT height;
  131. INT baseY;
  132. INT origY;
  133. INT aveCharWidth;
  134. INT overhang;
  135. } TOOLBARTEXTMETRIC;
  136. #define TBM_GETTEXTMETRICS (TBM_FIRST + 20)
  137. #define Toolbar_GetTextMetrics(/*HWND*/ __hToolbar, /*TOOLBARTEXTMETRIC* */ __textMetric)\
  138. ((BOOL)SendMessage((__hToolbar), TBM_GETTEXTMETRICS, 0, (LPARAM)__textMetric))
  139. #define TBM_GETBKBRUSH (TBM_FIRST + 21)
  140. #define Toolbar_GetBkBrush(/*HWND*/ __hToolbar)\
  141. ((HBRUSH)SendMessage((__hToolbar), TBM_GETBKBRUSH, 0, 0L))
  142. typedef struct __TOOLBARLAYOUT
  143. {
  144. const RECT *prcParent; // [in] - parent window rect
  145. HWND insertAfter; // [out] - toolar insert after
  146. RECT toolbarRect; // [out] - toolbar rect
  147. RECT clientRect; // [out] - new parent client rect
  148. } TOOLBARLAYOUT;
  149. #define TBM_LAYOUT (TBM_FIRST + 22)
  150. #define Toolbar_Layout(/*HWND*/ __hToolbar, /*TOOLBARLAYOUT* */ __pLayout)\
  151. ((BOOL)SendMessage((__hToolbar), TBM_LAYOUT, 0, (LPARAM)(__pLayout)))
  152. #define TBNS_NEXTITEM MAKEINTRESOURCEA(0)
  153. #define TBNS_PREVITEM MAKEINTRESOURCEA(1)
  154. #define TBM_NEXTITEM (TBM_FIRST + 23)
  155. #define Toolbar_NextItem(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*BOOL*/ __fUseName)\
  156. ((BOOL)SendMessage((__hToolbar), TBM_NEXTITEM, (WPARAM)(__fUseName), (LPARAM)(__pszItemName)))
  157. #define TBM_GETITEMSTYLE (TBM_FIRST + 24) // itemName can be INT index,
  158. #define Toolbar_GetItemStyle(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*UINT*/ __fMask)\
  159. ((UINT)SendMessage((__hToolbar), TBM_GETITEMSTYLE, (WPARAM)(__fMask), (LPARAM)(__pszItemName)))
  160. #define TBM_GETITEMCOMMAND (TBM_FIRST + 25) // itemName can be INT index,
  161. #define Toolbar_GetItemCommand(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName)\
  162. ((INT)SendMessage((__hToolbar), TBM_GETITEMCOMMAND, 0, (LPARAM)(__pszItemName)))
  163. #define TBM_SETITEMDESCRIPTION (TBM_FIRST + 26) // itemName can be INT index
  164. #define Toolbar_SetItemDescription(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*LPCWSTR*/__pszDescription)\
  165. ((BOOL)SendMessage((__hToolbar), TBM_SETITEMDESCRIPTION, (WPARAM)(__pszDescription), (LPARAM)(__pszItemName)))
  166. typedef struct __TBITEMINFO
  167. {
  168. INT commandId;
  169. UINT style;
  170. LPWSTR pszText;
  171. INT cchText;
  172. LPWSTR pszDescription;
  173. INT cchDescription;
  174. } TBITEMINFO;
  175. #define TBM_GETITEMINFO (TBM_FIRST + 27) // itemName can be INT index
  176. #define Toolbar_GetItemInfo(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*TBITEM* */__itemInfo)\
  177. ((BOOL)SendMessage((__hToolbar), TBM_GETITEMINFO, (WPARAM)(__itemInfo), (LPARAM)(__pszItemName)))
  178. #define TBPF_NORMAL 0x00000000
  179. #define TBPF_NOSERVICECOMMANDS 0x00000001
  180. #define TBPF_READONLYADDRESS 0x00000004
  181. #define TBM_AUTOPOPULATE (TBM_FIRST + 28) //wParam - (WPARAM)(UINT)populateFlags; lParam = (LPARAM)(ifc_omservice*)service; Return: number of buttons added.
  182. #define Toolbar_AutoPopulate(/*HWND*/ __hToolbar, /*ifc_omservice* */ __service, /*UINT*/__populateFlags)\
  183. ((UINT)SendMessage((__hToolbar), TBM_AUTOPOPULATE, (WPARAM)(__populateFlags), (LPARAM)(__service)))
  184. #define TBM_ENABLEBOTTOMDOCK (TBM_FIRST + 29) //wParam - not used; lParam = (LPARAM)(BOOL)fEnable; Return: previous state.
  185. #define Toolbar_EnableBottomDock(/*HWND*/ __hToolbar, /*BOOL*/ __fEnable)\
  186. ((BOOL)SendMessage((__hToolbar), TBM_ENABLEBOTTOMDOCK, 0, (LPARAM)(__fEnable)))
  187. #define TBM_ENABLEAUTOHIDE (TBM_FIRST + 30) //wParam - not used; lParam = (LPARAM)(BOOL)fEnable; Return: previous state.
  188. #define Toolbar_EnableAutoHide(/*HWND*/ __hToolbar, /*BOOL*/ __fEnable)\
  189. ((BOOL)SendMessage((__hToolbar), TBM_ENABLEAUTOHIDE, 0, (LPARAM)(__fEnable)))
  190. #define TBM_ENABLETABSTOP (TBM_FIRST + 31) //wParam - not used; lParam = (LPARAM)(BOOL)fEnable; Return: previous state.
  191. #define Toolbar_EnableTabStop(/*HWND*/ __hToolbar, /*BOOL*/ __fEnable)\
  192. ((BOOL)SendMessage((__hToolbar), TBM_ENABLETABSTOP, 0, (LPARAM)(__fEnable)))
  193. #define TBM_SETBROWSERHOST (TBM_FIRST + 32) //wParam = 0, lParam = (LPARAM)(HWND)hwndBrowserHost.
  194. #define Toolbar_SetBrowserHost(/*HWND*/ __hStatusbar, /*HWND*/ __hwndBrowserHost)\
  195. ((BOOL)SENDMSG(__hStatusbar, TBM_SETBROWSERHOST, 0, (LPARAM)(__hwndBrowserHost)))
  196. #define TBM_GETEDITCOLOR (TBM_FIRST + 33)
  197. #define Toolbar_GetEditColor(/*HWND*/ __hToolbar)\
  198. ((COLORREF)SendMessage((__hToolbar), TBM_GETEDITCOLOR, 0, 0L))
  199. #define TBM_GETEDITBKCOLOR (TBM_FIRST + 34)
  200. #define Toolbar_GetEditBkColor(/*HWND*/ __hToolbar)\
  201. ((COLORREF)SendMessage((__hToolbar), TBM_GETEDITBKCOLOR, 0, 0L))
  202. #define TBM_GETIMAGELISTHEIGHT (TBM_FIRST + 35)
  203. #define Toolbar_GetImageListHeight(/*HWND*/ __hToolbar)\
  204. ((INT)SendMessage((__hToolbar), TBM_GETIMAGELISTHEIGHT, 0, 0L))
  205. #define TBM_GETNEXTTABITEM (TBM_FIRST + 36)
  206. #define Toolbar_GetNextTabItem(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*BOOL*/ __fPrevious)\
  207. ((INT)SendMessage((__hToolbar), TBM_GETNEXTTABITEM, (BOOL)(__fPrevious), (LPARAM)(__pszItemName)))
  208. #define TBM_CHECKHIDE (TBM_FIRST + 37) // wParam - not used, lParam = (LPARAM)(BOOL)__fImmediate
  209. #define Toolbar_CheckHide(/*HWND*/ __hToolbar, /*BOOL*/ __fImmediate)\
  210. (SendMessage((__hToolbar), TBM_CHECKHIDE, 0, (BOOL)(__fImmediate)))
  211. #define TBM_ENABLEFORCEADDRESS (TBM_FIRST + 38) //wParam - not used; lParam = (LPARAM)(BOOL)fEnable; Return: previous state.
  212. #define Toolbar_EnableForceAddress(/*HWND*/ __hToolbar, /*BOOL*/ __fEnable)\
  213. ((BOOL)SendMessage((__hToolbar), TBM_ENABLEFORCEADDRESS, 0, (LPARAM)(__fEnable)))
  214. #define TBM_ENABLEFANCYADDRESS (TBM_FIRST + 39) //wParam - not used; lParam = (LPARAM)(BOOL)fEnable; Return: previous state.
  215. #define Toolbar_EnableFancyAddress(/*HWND*/ __hToolbar, /*BOOL*/ __fEnable)\
  216. ((BOOL)SendMessage((__hToolbar), TBM_ENABLEFANCYADDRESS, 0, (LPARAM)(__fEnable)))
  217. #define TBM_GETTEXTLENGTH (TBM_FIRST + 40) // wParam - (WPARAM)(size_t*)__textLengthOut, lParam - (LPARAM)(LPCSTR)(__itemName); Return TRUE if supported
  218. #define Toolbar_GetTextLength(/*HWND*/ __hToolbar, /*LPCSTR*/ __pszItemName, /*size_t* */ __textLengthOut)\
  219. ((BOOL)SendMessage((__hToolbar), TBM_GETTEXTLENGTH, (WPARAM)(__textLengthOut), (LPARAM)(__pszItemName)))
  220. // Nitifications (WM_COMMAND)
  221. #define TBN_DOCKCHANGED 1
  222. #define TBN_AUTOHIDECHANGED 2
  223. #define TBN_TABSTOPCHANGED 3
  224. #endif //NULLSOFT_WINAMP_OMBROWSER_TOOLBAR_HEADER