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
00047 #ifndef WINSTL_INCL_WINSTL_CONTROLS_HPP_COMMCTRL_FUNCTIONALS
00048 #define WINSTL_INCL_WINSTL_CONTROLS_HPP_COMMCTRL_FUNCTIONALS
00049
00050 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00051 # define WINSTL_VER_WINSTL_CONTROLS_HPP_COMMCTRL_FUNCTIONALS_MAJOR 4
00052 # define WINSTL_VER_WINSTL_CONTROLS_HPP_COMMCTRL_FUNCTIONALS_MINOR 1
00053 # define WINSTL_VER_WINSTL_CONTROLS_HPP_COMMCTRL_FUNCTIONALS_REVISION 4
00054 # define WINSTL_VER_WINSTL_CONTROLS_HPP_COMMCTRL_FUNCTIONALS_EDIT 75
00055 #endif
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072 #ifndef WINSTL_INCL_WINSTL_H_WINSTL
00073 # include <winstl/winstl.h>
00074 #endif
00075
00076 #if defined(STLSOFT_COMPILER_IS_GCC) && \
00077 __GNUC__ < 3
00078 # error winstl_commctrl_functionals.h is not compatible with GNU C++ prior to 3.0
00079 #endif
00080
00081 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00082 # include <stlsoft/shims/access/string.hpp>
00083 #endif
00084 #ifndef STLSOFT_INCL_STLSOFT_ITERATORS_HPP_UNARY_FUNCTION_OUTPUT_ITERATOR_ADAPTOR
00085 # include <stlsoft/iterators/unary_function_output_iterator_adaptor.hpp>
00086 #endif
00087 #ifndef WINSTL_INCL_WINSTL_SHIMS_ACCESS_HPP_STRING
00088 # include <winstl/shims/access/string.hpp>
00089 #endif
00090
00091 #ifndef STLSOFT_INCL_H_COMMCTRL
00092 # define STLSOFT_INCL_H_COMMCTRL
00093 # include <commctrl.h>
00094 #endif
00095
00096
00097
00098
00099
00100 #ifndef _WINSTL_NO_NAMESPACE
00101 # if defined(_STLSOFT_NO_NAMESPACE) || \
00102 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00103
00104 namespace winstl
00105 {
00106 # else
00107
00108
00109 namespace stlsoft
00110 {
00111
00112 namespace winstl_project
00113 {
00114
00115 # endif
00116 #endif
00117
00118
00119
00120
00121
00122 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00123 template <ws_bool_t BACK>
00124 struct listview_inserter;
00125 #endif
00126
00132 template <ws_bool_t BACK = true>
00133
00134 struct listview_inserter
00135 #if !defined(STLSOFT_COMPILER_IS_DMC) || \
00136 __DMC__ > 0x0850
00137 : public stlsoft_ns_qual(unary_function_output_iterator_adaptor)<listview_inserter<BACK> >
00138 #endif
00139 {
00140 public:
00142 typedef listview_inserter class_type;
00143
00144 enum
00145 {
00146 #ifdef I_IMAGENONE
00147 image_none = I_IMAGENONE
00148 #else
00149 image_none = -2
00150 #endif
00151 };
00152
00153 public:
00155 ss_explicit_k listview_inserter(HWND hwndListview, ws_int_t iImage = image_none)
00156 : m_hwndListview(hwndListview)
00157 , m_iImage(iImage)
00158 {}
00159
00160 listview_inserter(class_type const& rhs)
00161 : m_hwndListview(rhs.m_hwndListview)
00162 , m_iImage(rhs.m_iImage)
00163 {}
00164
00165 #ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00167 template <ss_typename_param_k S>
00168 ws_int_t operator ()(S const& s)
00169 {
00170 return insert_item(stlsoft_ns_qual(c_str_ptr)(s));
00171 }
00172 #endif // STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
00174 ws_int_t operator ()(ws_char_a_t const* s)
00175 {
00176 return insert_item(s);
00177 }
00179 ws_int_t operator ()(ws_char_w_t const* s)
00180 {
00181 return insert_item(s);
00182 }
00183
00184 private:
00185 ws_int_t insert_index() const;
00186
00187 ws_int_t insert_item(ws_char_a_t const* s)
00188 {
00189 LV_ITEMA item;
00190
00191 item.mask = LVIF_TEXT;
00192 item.pszText = const_cast<ws_char_a_t *>(s);
00193 item.iItem = insert_index();
00194 item.iSubItem = 0;
00195
00196 if(image_none != m_iImage)
00197 {
00198 item.mask |= LVIF_IMAGE;
00199 item.iImage = m_iImage;
00200 }
00201
00202 return (int)::SendMessage(m_hwndListview, LVM_INSERTITEMA, 0, reinterpret_cast<LPARAM>(&item));
00203 }
00204
00205 ws_int_t insert_item(ws_char_w_t const* s)
00206 {
00207 LV_ITEMW item;
00208
00209 item.mask = LVIF_TEXT;
00210 item.pszText = const_cast<ws_char_w_t *>(s);
00211 item.iItem = insert_index();
00212 item.iSubItem = 0;
00213
00214 if(image_none != m_iImage)
00215 {
00216 item.mask |= LVIF_IMAGE;
00217 item.iImage = m_iImage;
00218 }
00219
00220 return (int)::SendMessage(m_hwndListview, LVM_INSERTITEMW, 0, reinterpret_cast<LPARAM>(&item));
00221 }
00222
00223 private:
00224 HWND m_hwndListview;
00225 ws_int_t m_iImage;
00226 };
00227
00228 STLSOFT_TEMPLATE_SPECIALISATION
00229 inline ws_int_t listview_inserter<false>::insert_index() const
00230 {
00231 return 0;
00232 }
00233
00234 STLSOFT_TEMPLATE_SPECIALISATION
00235 inline ws_int_t listview_inserter<true>::insert_index() const
00236 {
00237 return static_cast<ws_int_t>(::SendMessage(m_hwndListview, LVM_GETITEMCOUNT, 0, 0L));
00238 }
00239
00244 typedef listview_inserter<false> listview_front_inserter;
00249 typedef listview_inserter<true> listview_back_inserter;
00250
00251
00256
00257 struct treeview_inserter
00258 #if !defined(STLSOFT_COMPILER_IS_DMC) || \
00259 __DMC__ > 0x0850
00260 : public stlsoft_ns_qual(unary_function_output_iterator_adaptor)<treeview_inserter>
00261 #endif
00262 {
00263 enum
00264 {
00265 #ifdef I_IMAGENONE
00266 image_none = I_IMAGENONE
00267 #else
00268 image_none = -2
00269 #endif
00270 };
00271
00272 public:
00273 typedef void argument_type;
00274 typedef HTREEITEM result_type;
00275
00276 public:
00277 ss_explicit_k treeview_inserter(HWND hwndTree, HTREEITEM hParent)
00278 : m_hwndTree(hwndTree)
00279 , m_hParent(hParent)
00280 , m_hInsertAfter(TVI_LAST)
00281 , m_iImage(image_none)
00282 {}
00283 ss_explicit_k treeview_inserter(HWND hwndTree, HTREEITEM hParent, HTREEITEM hInsertAfter)
00284 : m_hwndTree(hwndTree)
00285 , m_hParent(hParent)
00286 , m_hInsertAfter(hInsertAfter)
00287 , m_iImage(image_none)
00288 {}
00289 ss_explicit_k treeview_inserter(HWND hwndTree, HTREEITEM hParent, int iImage)
00290 : m_hwndTree(hwndTree)
00291 , m_hParent(hParent)
00292 , m_hInsertAfter(TVI_LAST)
00293 , m_iImage(iImage)
00294 {}
00295
00296 public:
00297 template <ss_typename_param_k S>
00298 HTREEITEM operator () (S const& s)
00299 {
00300 return insert_item(stlsoft_ns_qual(c_str_ptr)(s));
00301 }
00302
00303 HTREEITEM operator () (char const* s)
00304 {
00305 return insert_item(stlsoft_ns_qual(c_str_ptr)(s));
00306 }
00307
00308 HTREEITEM operator () (wchar_t const* s)
00309 {
00310 return insert_item(stlsoft_ns_qual(c_str_ptr)(s));
00311 }
00312
00313 private:
00314 HTREEITEM insert_item(char const* s)
00315 {
00316 TV_INSERTSTRUCTA tvis;
00317
00318 tvis.hParent = m_hParent;
00319 tvis.hInsertAfter = m_hInsertAfter;
00320
00321 tvis.item.mask = TVIF_TEXT;
00322 tvis.item.pszText = const_cast<char*>(s);
00323
00324 if(image_none != m_iImage)
00325 {
00326 tvis.item.mask |= TVIF_IMAGE;
00327 tvis.item.iImage = m_iImage;
00328 }
00329
00330 return (HTREEITEM)::SendMessage(m_hwndTree, TVM_INSERTITEMA, 0, (LPARAM)&tvis);
00331 }
00332
00333 HTREEITEM insert_item(wchar_t const* s)
00334 {
00335 TV_INSERTSTRUCTW tvis;
00336
00337 tvis.hParent = m_hParent;
00338 tvis.hInsertAfter = m_hInsertAfter;
00339
00340 tvis.item.mask = TVIF_TEXT;
00341 tvis.item.pszText = const_cast<wchar_t*>(s);
00342
00343 if(image_none != m_iImage)
00344 {
00345 tvis.item.mask |= TVIF_IMAGE;
00346 tvis.item.iImage = m_iImage;
00347 }
00348
00349 return (HTREEITEM)::SendMessage(m_hwndTree, TVM_INSERTITEMW, 0, (LPARAM)&tvis);
00350 }
00351
00352 private:
00353 HWND m_hwndTree;
00354 HTREEITEM m_hParent;
00355 HTREEITEM m_hInsertAfter;
00356 int m_iImage;
00357 };
00358
00360
00361
00362 #ifdef STLSOFT_UNITTEST
00363 # include "./unittest/commctrl_functionals_unittest_.h"
00364 #endif
00365
00366
00367
00368 #ifndef _WINSTL_NO_NAMESPACE
00369 # if defined(_STLSOFT_NO_NAMESPACE) || \
00370 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00371 }
00372 # else
00373 }
00374 }
00375 # endif
00376 #endif
00377
00378
00379
00380 #endif
00381
00382