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.

299 lines
10 KiB

  1. /* /////////////////////////////////////////////////////////////////////////
  2. * File: winstl/window/zorder_sequences.hpp
  3. *
  4. * Purpose: Collection of the peers of a given window.
  5. *
  6. * Created: 11th July 2005
  7. * Updated: 10th August 2009
  8. *
  9. * Home: http://stlsoft.org/
  10. *
  11. * Copyright (c) 2005-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/window/zorder_sequences.hpp
  40. *
  41. * \brief [C++ only] Definition of the winstl::child_window_sequence and
  42. * winstl::window_peer_sequence sequence classes
  43. * (\ref group__library__windows_window "Windows Window" Library).
  44. */
  45. #ifndef WINSTL_INCL_WINSTL_WINDOW_HPP_ZORDER_SEQUENCES
  46. #define WINSTL_INCL_WINSTL_WINDOW_HPP_ZORDER_SEQUENCES
  47. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  48. # define WINSTL_VER_WINSTL_WINDOW_HPP_ZORDER_SEQUENCES_MAJOR 2
  49. # define WINSTL_VER_WINSTL_WINDOW_HPP_ZORDER_SEQUENCES_MINOR 0
  50. # define WINSTL_VER_WINSTL_WINDOW_HPP_ZORDER_SEQUENCES_REVISION 3
  51. # define WINSTL_VER_WINSTL_WINDOW_HPP_ZORDER_SEQUENCES_EDIT 15
  52. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  53. /* /////////////////////////////////////////////////////////////////////////
  54. * Includes
  55. */
  56. #ifndef WINSTL_INCL_WINSTL_H_WINSTL
  57. # include <winstl/winstl.h>
  58. #endif /* !WINSTL_INCL_WINSTL_H_WINSTL */
  59. #ifndef WINSTL_INCL_WINSTL_WINDOW_HPP_ZORDER_ITERATOR
  60. # include <winstl/window/zorder_iterator.hpp>
  61. #endif /* !WINSTL_INCL_WINSTL_WINDOW_HPP_ZORDER_ITERATOR */
  62. #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
  63. # include <stlsoft/util/std/iterator_helper.hpp>
  64. #endif /* !STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER */
  65. #ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
  66. # include <stlsoft/collections/util/collections.hpp>
  67. #endif /* !STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS */
  68. /* /////////////////////////////////////////////////////////////////////////
  69. * Namespace
  70. */
  71. #ifndef _WINSTL_NO_NAMESPACE
  72. # if defined(_STLSOFT_NO_NAMESPACE) || \
  73. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  74. /* There is no stlsoft namespace, so must define ::winstl */
  75. namespace winstl
  76. {
  77. # else
  78. /* Define stlsoft::winstl_project */
  79. namespace stlsoft
  80. {
  81. namespace winstl_project
  82. {
  83. # endif /* _STLSOFT_NO_NAMESPACE */
  84. #endif /* !_WINSTL_NO_NAMESPACE */
  85. /* /////////////////////////////////////////////////////////////////////////
  86. * Classes
  87. */
  88. /** \brief Window peer sequence
  89. *
  90. * \ingroup group__library__windows_window
  91. */
  92. template< zorder_iterator_base::search B
  93. , zorder_iterator_base::search E
  94. >
  95. class zorder_sequence_base
  96. : public stlsoft_ns_qual(stl_collection_tag)
  97. {
  98. /// \name Member Types
  99. /// @{
  100. public:
  101. /// The mutating (non-const) iterator type
  102. typedef zorder_iterator iterator;
  103. /// The value type
  104. typedef iterator::value_type value_type;
  105. /// The size type
  106. typedef iterator::size_type size_type;
  107. /// The difference type
  108. typedef iterator::difference_type difference_type;
  109. /// The non-mutating (const) iterator type
  110. typedef zorder_iterator const_iterator;
  111. /// The mutating (non-const) reverse iterator type
  112. typedef iterator::base_iterator_type reverse_iterator;
  113. /// The non-mutating (const) reverse iterator type
  114. typedef const_iterator::base_iterator_type const_reverse_iterator;
  115. /// This class
  116. typedef zorder_sequence_base<B, E> class_type;
  117. /// @}
  118. /// \name Construction
  119. /// @{
  120. public:
  121. /// Constructs a sequence of peers of the given window
  122. ss_explicit_k zorder_sequence_base(HWND hwndRoot);
  123. /// @}
  124. /// \name Iteration
  125. /// @{
  126. public:
  127. iterator begin();
  128. iterator end();
  129. const_iterator begin() const;
  130. const_iterator end() const;
  131. reverse_iterator rbegin();
  132. reverse_iterator rend();
  133. const_reverse_iterator rbegin() const;
  134. const_reverse_iterator rend() const;
  135. /// @}
  136. /// \name State
  137. /// @{
  138. public:
  139. ws_bool_t empty() const;
  140. /// @}
  141. /// \name Members
  142. /// @{
  143. private:
  144. HWND m_hwnd;
  145. /// @}
  146. /// \name Not to be implemented
  147. /// @{
  148. private:
  149. zorder_sequence_base(class_type const&);
  150. class_type& operator =(class_type const&);
  151. /// @}
  152. };
  153. /* /////////////////////////////////////////////////////////////////////////
  154. * Typedefs
  155. */
  156. /** \brief Specialisation of \link winstl::zorder_sequence_base zorder_sequence_base\endlink
  157. * that searches the children of a given window.
  158. *
  159. * \ingroup group__library__windows_window
  160. */
  161. typedef zorder_sequence_base< zorder_iterator_base::fromFirstChild
  162. , zorder_iterator_base::atLastChild
  163. > child_window_sequence;
  164. /** \brief Specialisation of \link winstl::zorder_sequence_base zorder_sequence_base\endlink
  165. * that searches the peers of a given window.
  166. *
  167. * \ingroup group__library__windows_window
  168. */
  169. typedef zorder_sequence_base< zorder_iterator_base::fromFirstPeer
  170. , zorder_iterator_base::atLastPeer
  171. > window_peer_sequence;
  172. /* /////////////////////////////////////////////////////////////////////////
  173. * Implementation
  174. */
  175. #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
  176. template< zorder_iterator_base::search B
  177. , zorder_iterator_base::search E
  178. >
  179. inline /* ss_explicit_k */ zorder_sequence_base<B, E>::zorder_sequence_base(HWND hwndRoot)
  180. : m_hwnd(hwndRoot)
  181. {}
  182. template< zorder_iterator_base::search B
  183. , zorder_iterator_base::search E
  184. >
  185. inline ss_typename_type_ret_k zorder_sequence_base<B, E>::iterator zorder_sequence_base<B, E>::begin()
  186. {
  187. return iterator::create(m_hwnd, B);
  188. }
  189. template< zorder_iterator_base::search B
  190. , zorder_iterator_base::search E
  191. >
  192. inline ss_typename_type_ret_k zorder_sequence_base<B, E>::iterator zorder_sequence_base<B, E>::end()
  193. {
  194. return iterator::create(m_hwnd, E);
  195. }
  196. template< zorder_iterator_base::search B
  197. , zorder_iterator_base::search E
  198. >
  199. inline ss_typename_type_ret_k zorder_sequence_base<B, E>::const_iterator zorder_sequence_base<B, E>::begin() const
  200. {
  201. return const_iterator::create(m_hwnd, B);
  202. }
  203. template< zorder_iterator_base::search B
  204. , zorder_iterator_base::search E
  205. >
  206. inline ss_typename_type_ret_k zorder_sequence_base<B, E>::const_iterator zorder_sequence_base<B, E>::end() const
  207. {
  208. return const_iterator::create(m_hwnd, E);
  209. }
  210. template< zorder_iterator_base::search B
  211. , zorder_iterator_base::search E
  212. >
  213. inline ss_typename_type_ret_k zorder_sequence_base<B, E>::reverse_iterator zorder_sequence_base<B, E>::rbegin()
  214. {
  215. return reverse_iterator::create(m_hwnd, B);
  216. }
  217. template< zorder_iterator_base::search B
  218. , zorder_iterator_base::search E
  219. >
  220. inline ss_typename_type_ret_k zorder_sequence_base<B, E>::reverse_iterator zorder_sequence_base<B, E>::rend()
  221. {
  222. return reverse_iterator::create(m_hwnd, E);
  223. }
  224. template< zorder_iterator_base::search B
  225. , zorder_iterator_base::search E
  226. >
  227. inline ss_typename_type_ret_k zorder_sequence_base<B, E>::const_reverse_iterator zorder_sequence_base<B, E>::rbegin() const
  228. {
  229. return const_reverse_iterator::create(m_hwnd, B);
  230. }
  231. template< zorder_iterator_base::search B
  232. , zorder_iterator_base::search E
  233. >
  234. inline ss_typename_type_ret_k zorder_sequence_base<B, E>::const_reverse_iterator zorder_sequence_base<B, E>::rend() const
  235. {
  236. return const_reverse_iterator::create(m_hwnd, E);
  237. }
  238. template< zorder_iterator_base::search B
  239. , zorder_iterator_base::search E
  240. >
  241. inline ws_bool_t zorder_sequence_base<B, E>::empty() const
  242. {
  243. return end() == begin();
  244. }
  245. #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */
  246. /* /////////////////////////////////////////////////////////////////////////
  247. * Namespace
  248. */
  249. #ifndef _WINSTL_NO_NAMESPACE
  250. # if defined(_STLSOFT_NO_NAMESPACE) || \
  251. defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
  252. } // namespace winstl
  253. # else
  254. } // namespace winstl_project
  255. } // namespace stlsoft
  256. # endif /* _STLSOFT_NO_NAMESPACE */
  257. #endif /* !_WINSTL_NO_NAMESPACE */
  258. /* ////////////////////////////////////////////////////////////////////// */
  259. #endif /* WINSTL_INCL_WINSTL_WINDOW_HPP_ZORDER_SEQUENCES */
  260. /* ///////////////////////////// end of file //////////////////////////// */