You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
7.3 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/controls/commctrl_functions.h
  3. *
  4. * Purpose: Various Windows common control functions.
  5. *
  6. * Created: 13th November 2002
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2002-2009, Matthew Wilson and Synesis Software
  12. * All rights reserved.
  13. *
  14. * Redistribution and use in source and binary forms, with or without
  15. * modification, are permitted provided that the following conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above copyright notice, this
  18. * list of conditions and the following disclaimer.
  19. * - Redistributions in binary form must reproduce the above copyright notice,
  20. * this list of conditions and the following disclaimer in the documentation
  21. * and/or other materials provided with the distribution.
  22. * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of
  23. * any contributors may be used to endorse or promote products derived from
  24. * this software without specific prior written permission.
  25. *
  26. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  27. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  28. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  29. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  30. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  32. * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  33. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  34. * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  35. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  36. * POSSIBILITY OF SUCH DAMAGE.
  37. *
  38. * ////////////////////////////////////////////////////////////////////// */
  39. /** \file winstl/controls/commctrl_functions.h
  40. *
  41. * \brief [C, C++] Various Windows common control functions
  42. * (\ref group__library__windows_controls "Windows Controls" Library).
  43. */
  44. #ifndef WINSTL_INCL_WINSTL_CONTROLS_H_COMMCTRL_FUNCTIONS
  45. #define WINSTL_INCL_WINSTL_CONTROLS_H_COMMCTRL_FUNCTIONS
  46. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  47. # define WINSTL_VER_WINSTL_CONTROLS_H_COMMCTRL_FUNCTIONS_MAJOR 4
  48. # define WINSTL_VER_WINSTL_CONTROLS_H_COMMCTRL_FUNCTIONS_MINOR 0
  49. # define WINSTL_VER_WINSTL_CONTROLS_H_COMMCTRL_FUNCTIONS_REVISION 3
  50. # define WINSTL_VER_WINSTL_CONTROLS_H_COMMCTRL_FUNCTIONS_EDIT 44
  51. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  52. /* /////////////////////////////////////////////////////////////////////////
  53. * Includes
  54. */
  55. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  56. # include <winstl/winstl.h>
  57. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  58. #ifndef WINSTL_INCL_WINSTL_WINDOW_H_MESSAGE_FUNCTIONS
  59. # include <winstl/window/message_functions.h>
  60. #endif /* !WINSTL_INCL_WINSTL_WINDOW_H_MESSAGE_FUNCTIONS */
  61. #ifndef STLSOFT_INCL_H_COMMCTRL
  62. # define STLSOFT_INCL_H_COMMCTRL
  63. # include <commctrl.h>
  64. #endif /* !STLSOFT_INCL_H_COMMCTRL */
  65. /* /////////////////////////////////////////////////////////////////////////
  66. * Namespace
  67. */
  68. #if !defined(_WINSTL_NO_NAMESPACE) && \
  69. !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  70. # if defined(_STLSOFT_NO_NAMESPACE)
  71. /* There is no stlsoft namespace, so must define ::winstl */
  72. namespace winstl
  73. {
  74. # else
  75. /* Define stlsoft::winstl_project */
  76. namespace stlsoft
  77. {
  78. namespace winstl_project
  79. {
  80. # endif /* _STLSOFT_NO_NAMESPACE */
  81. #endif /* !_WINSTL_NO_NAMESPACE */
  82. /* /////////////////////////////////////////////////////////////////////////
  83. * C functions
  84. */
  85. /** \brief Gets the next item in the tree view
  86. *
  87. * \ingroup group__library__windows_controls
  88. *
  89. * \param hwnd The tree view window handle
  90. * \param hitem The tree view item
  91. * \param flag One of the <b>TVGN_*</b> search flags
  92. */
  93. STLSOFT_INLINE HTREEITEM winstl__treeview_getnextitem(HWND hwnd, HTREEITEM hitem, UINT flag)
  94. {
  95. return stlsoft_reinterpret_cast(HTREEITEM, winstl__SendMessage(hwnd, TVM_GETNEXTITEM, stlsoft_static_cast(WPARAM, flag), stlsoft_reinterpret_cast(LPARAM, hitem)));
  96. }
  97. /** \brief Gets the tree view child item
  98. *
  99. * \ingroup group__library__windows_controls
  100. *
  101. * \param hwnd The tree view window handle
  102. * \param hitem The tree view item whose child is to be retrieved
  103. */
  104. STLSOFT_INLINE HTREEITEM winstl__treeview_getchilditem(HWND hwnd, HTREEITEM hitem)
  105. {
  106. return winstl__treeview_getnextitem(hwnd, hitem, TVGN_CHILD);
  107. }
  108. /** \brief Gets the tree view root item
  109. *
  110. * \ingroup group__library__windows_controls
  111. *
  112. * \param hwnd The tree view window handle
  113. */
  114. STLSOFT_INLINE HTREEITEM winstl__treeview_getrootitem(HWND hwnd)
  115. {
  116. return winstl__treeview_getnextitem(hwnd, 0, TVGN_ROOT);
  117. }
  118. /** \brief Gets the tree view caret item
  119. *
  120. * \ingroup group__library__windows_controls
  121. *
  122. * \param hwnd The tree view window handle
  123. */
  124. STLSOFT_INLINE HTREEITEM winstl__treeview_getcaretitem(HWND hwnd)
  125. {
  126. return winstl__treeview_getnextitem(hwnd, 0, TVGN_CARET);
  127. }
  128. /* /////////////////////////////////////////////////////////////////////////
  129. * Namespace
  130. */
  131. #ifdef STLSOFT_DOCUMENTATION_SKIP_SECTION
  132. namespace winstl
  133. {
  134. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  135. /* /////////////////////////////////////////////////////////////////////////
  136. * C++ functions
  137. */
  138. #ifdef __cplusplus
  139. /** \brief Gets the next item in the tree view
  140. *
  141. * \ingroup group__library__windows_controls
  142. *
  143. * \param hwnd The tree view window handle
  144. * \param hitem The tree view item
  145. * \param flag One of the <b>TVGN_*</b> search flags
  146. */
  147. inline HTREEITEM treeview_getnextitem(HWND hwnd, HTREEITEM hitem, UINT flag)
  148. {
  149. return winstl__treeview_getnextitem(hwnd, hitem, flag);
  150. }
  151. /** \brief Gets the tree view child item
  152. *
  153. * \ingroup group__library__windows_controls
  154. *
  155. * \param hwnd The tree view window handle
  156. * \param hitem The tree view item whose child is to be retrieved
  157. */
  158. inline HTREEITEM treeview_getchilditem(HWND hwnd, HTREEITEM hitem)
  159. {
  160. return winstl__treeview_getnextitem(hwnd, hitem, TVGN_CHILD);
  161. }
  162. /** \brief Gets the tree view root item
  163. *
  164. * \ingroup group__library__windows_controls
  165. *
  166. * \param hwnd The tree view window handle
  167. */
  168. inline HTREEITEM treeview_getrootitem(HWND hwnd)
  169. {
  170. return winstl__treeview_getnextitem(hwnd, 0, TVGN_ROOT);
  171. }
  172. /** \brief Gets the tree view caret item
  173. *
  174. * \ingroup group__library__windows_controls
  175. *
  176. * \param hwnd The tree view window handle
  177. */
  178. inline HTREEITEM treeview_getcaretitem(HWND hwnd)
  179. {
  180. return winstl__treeview_getnextitem(hwnd, 0, TVGN_CARET);
  181. }
  182. #endif /* __cplusplus */
  183. /* /////////////////////////////////////////////////////////////////////////
  184. * Unit-testing
  185. */
  186. #ifdef STLSOFT_UNITTEST
  187. # include "./unittest/commctrl_functions_unittest_.h"
  188. #endif /* STLSOFT_UNITTEST */
  189. /* ////////////////////////////////////////////////////////////////////// */
  190. #ifndef _WINSTL_NO_NAMESPACE
  191. # if defined(_STLSOFT_NO_NAMESPACE) || \
  192. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  193. } /* namespace winstl */
  194. # else
  195. } /* namespace winstl_project */
  196. } /* namespace stlsoft */
  197. # endif /* _STLSOFT_NO_NAMESPACE */
  198. #endif /* !_WINSTL_NO_NAMESPACE */
  199. /* ////////////////////////////////////////////////////////////////////// */
  200. #endif /* WINSTL_INCL_WINSTL_CONTROLS_H_COMMCTRL_FUNCTIONS */
  201. /* ///////////////////////////// end of file //////////////////////////// */