00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00050 #ifndef WINSTL_INCL_WINSTL_CONTROLS_HPP_LISTBOX_SEQUENCE
00051 #define WINSTL_INCL_WINSTL_CONTROLS_HPP_LISTBOX_SEQUENCE
00052
00053 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00054 # define WINSTL_VER_WINSTL_CONTROLS_HPP_LISTBOX_SEQUENCE_MAJOR 4
00055 # define WINSTL_VER_WINSTL_CONTROLS_HPP_LISTBOX_SEQUENCE_MINOR 2
00056 # define WINSTL_VER_WINSTL_CONTROLS_HPP_LISTBOX_SEQUENCE_REVISION 2
00057 # define WINSTL_VER_WINSTL_CONTROLS_HPP_LISTBOX_SEQUENCE_EDIT 64
00058 #endif
00059
00060
00061
00062
00063
00064 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00065 # include <winstl/winstl.h>
00066 #endif
00067 #ifndef WINSTL_INCL_WINSTL_CONTROLS_HPP_LISTBOX_CONST_ITERATOR
00068 # include <winstl/controls/listbox_const_iterator.hpp>
00069 #endif
00070 #ifndef WINSTL_INCL_WINSTL_CONTROLS_H_FUNCTIONS
00071 # include <winstl/controls/functions.h>
00072 #endif
00073 #ifndef STLSOFT_INCL_STLSOFT_COLLECTIONS_UTIL_HPP_COLLECTIONS
00074 # include <stlsoft/collections/util/collections.hpp>
00075 #endif
00076 #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_HPP_ITERATOR_HELPER
00077 # include <stlsoft/util/std/iterator_helper.hpp>
00078 #endif
00079
00080
00081
00082
00083
00084 #ifndef _WINSTL_NO_NAMESPACE
00085 # if defined(_STLSOFT_NO_NAMESPACE) || \
00086 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00087
00088 namespace winstl
00089 {
00090 # else
00091
00092
00093 namespace stlsoft
00094 {
00095
00096 namespace winstl_project
00097 {
00098
00099 # endif
00100 #endif
00101
00102
00103
00104
00105
00106 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00107 struct listbox_sequence_traits
00108 {
00109 public:
00110 static ws_int_t err_constant()
00111 {
00112 return LB_ERR;
00113 }
00114 static ws_int_t get_count(HWND hwnd)
00115 {
00116 return listbox_getcount(hwnd);
00117 }
00118 static ws_int_t get_text_len(HWND hwnd, ws_int_t index)
00119 {
00120 return listbox_gettextlen(hwnd, index);
00121 }
00122 static ws_int_t get_text(HWND hwnd, ws_int_t index, ws_char_a_t *s)
00123 {
00124 return listbox_gettext_a(hwnd, index, s);
00125 }
00126 static ws_int_t get_text(HWND hwnd, ws_int_t index, ws_char_w_t *s)
00127 {
00128 return listbox_gettext_w(hwnd, index, s);
00129 }
00130 };
00131 #endif
00132
00141 template <ss_typename_param_k S>
00142 class listbox_sequence
00143 : public stlsoft_ns_qual(stl_collection_tag)
00144 {
00147 public:
00149 typedef listbox_sequence<S> class_type;
00151 typedef listbox_const_iterator<S, listbox_sequence_traits> const_iterator;
00153 typedef ss_typename_type_k const_iterator::char_type char_type;
00155 typedef ss_typename_type_k const_iterator::value_type value_type;
00157 typedef ss_typename_type_k const_iterator::const_reference const_reference;
00159 typedef ss_typename_type_k const_iterator::size_type size_type;
00161 typedef ss_typename_type_k const_iterator::difference_type difference_type;
00162 #if defined(STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00164 typedef ss_typename_type_k const_iterator::const_reverse_iterator_type const_reverse_iterator;
00165 #endif
00167 typedef ss_typename_type_k const_iterator::allocator_type allocator_type;
00168 private:
00169 typedef ss_typename_type_k const_iterator::buffer_type buffer_type;
00170 typedef listbox_sequence_traits control_traits_type;
00172
00175 public:
00177 ss_explicit_k listbox_sequence(HWND hwndListBox)
00178 : m_hwnd(hwndListBox)
00179 {}
00181
00184 public:
00186 size_type size() const
00187 {
00188 return static_cast<size_type>(control_traits_type::get_count(m_hwnd));
00189 }
00191 ws_bool_t empty() const
00192 {
00193 return 0 == size();
00194 }
00196 static size_type max_size()
00197 {
00198 return static_cast<size_type>(-1) / sizeof(LPCTSTR);
00199 }
00201
00204 public:
00208 const_iterator begin() const
00209 {
00210 return const_iterator(m_hwnd, 0);
00211 }
00215 const_iterator end() const
00216 {
00217 return const_iterator(m_hwnd, static_cast<int>(size()));
00218 }
00219
00220 #if defined(STLSOFT_LF_BIDIRECTIONAL_ITERATOR_SUPPORT)
00224 const_reverse_iterator rbegin() const
00225 {
00226 return const_reverse_iterator(end());
00227 }
00231 const_reverse_iterator rend() const
00232 {
00233 return const_reverse_iterator(begin());
00234 }
00235 #endif
00237
00240 public:
00242 value_type operator [](difference_type index) const
00243 {
00244 return const_iterator::get_value_at_(m_hwnd, index);
00245 }
00247
00250 private:
00251 HWND m_hwnd;
00253 };
00254
00256
00257
00258 #ifdef STLSOFT_UNITTEST
00259 # include "./unittest/listbox_sequence_unittest_.h"
00260 #endif
00261
00262
00263
00264 #ifndef _WINSTL_NO_NAMESPACE
00265 # if defined(_STLSOFT_NO_NAMESPACE) || \
00266 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00267 }
00268 # else
00269 }
00270 }
00271 # endif
00272 #endif
00273
00274
00275
00276 #endif
00277
00278