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
00048 #ifndef MFCSTL_INCL_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND
00049 #define MFCSTL_INCL_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND
00050
00051 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00052 # define MFCSTL_VER_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND_MAJOR 4
00053 # define MFCSTL_VER_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND_MINOR 0
00054 # define MFCSTL_VER_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND_REVISION 5
00055 # define MFCSTL_VER_MFCSTL_SHIMS_ACCESS_STRING_HPP_CWND_EDIT 93
00056 #endif
00057
00058
00059
00060
00061
00062 #ifndef MFCSTL_INCL_MFCSTL_HPP_MFCSTL
00063 # include <mfcstl/mfcstl.hpp>
00064 #endif
00065 #ifndef STLSOFT_INCL_STLSOFT_SHIMS_ACCESS_HPP_STRING
00066 # include <stlsoft/shims/access/string.hpp>
00067 #endif
00068 #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_CONSTRAINTS
00069 # include <stlsoft/util/constraints.hpp>
00070 #endif
00071 #ifndef STLSOFT_INCL_STLSOFT_STRING_HPP_CSTRING_MAKER
00072 # include <stlsoft/string/cstring_maker.hpp>
00073 #endif
00074 #ifndef STLSOFT_INCL_STLSOFT_UTIL_STD_LIBRARY_DISCRIMINATOR
00075 # include <stlsoft/util/std/library_discriminator.hpp>
00076 #endif
00077
00078 #if defined(STLSOFT_COMPILER_IS_BORLAND)
00079 # pragma warn -8022
00080 # pragma warn -8084
00081 #endif
00082
00083 #ifndef STLSOFT_INCL_H_AFXWIN
00084 # define STLSOFT_INCL_H_AFXWIN
00085 # include <afxwin.h>
00086 #endif
00087 #if !defined(__AFXCMN_H__) && \
00088 !defined(MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCMN)
00089 # ifndef STLSOFT_INCL_H_AFXCMN
00090 # define STLSOFT_INCL_H_AFXCMN
00091 # include <afxcmn.h>
00092 # endif
00093 #endif
00094 #if !defined(__AFXCVIEW_H__) && \
00095 !defined(MFCSTL_STRING_ACCESS_NO_INCLUDE_AFXCVIEW)
00096 # ifndef STLSOFT_INCL_H_AFXCVIEW
00097 # define STLSOFT_INCL_H_AFXCVIEW
00098 # include <afxcview.h>
00099 # endif
00100 #endif
00101
00102 #if defined(STLSOFT_COMPILER_IS_BORLAND)
00103 # pragma warn .8022
00104 # pragma warn .8084
00105 #endif
00106
00107
00108
00109
00110
00111 #ifndef _MFCSTL_NO_NAMESPACE
00112 # if defined(_STLSOFT_NO_NAMESPACE) || \
00113 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00114
00115 namespace mfcstl
00116 {
00117 # else
00118
00119
00120 namespace stlsoft
00121 {
00122
00123 namespace mfcstl_project
00124 {
00125
00126 # endif
00127 #endif
00128
00129
00130
00131
00132
00133 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00134
00135 namespace impl
00136 {
00137
00138 inline ms_size_t GetWindowTextLength_T_(CWnd const& w)
00139 {
00140 return (NULL != w.m_hWnd) ? static_cast<ms_size_t>(w.GetWindowTextLength()) : 0;
00141 }
00142
00143 inline ms_size_t GetWindowText_T_(CWnd const& w, LPTSTR buffer, ms_size_t cchBuffer)
00144 {
00145 MFCSTL_ASSERT(NULL != w.m_hWnd);
00146
00147 return static_cast<ms_size_t>(w.GetWindowText(buffer, cchBuffer));
00148 }
00149
00150
00151 inline ms_size_t GetWindowTextLength_T_(CListBox const& w)
00152 {
00153 int sel;
00154
00155 if( 0 == (w.GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) &&
00156 LB_ERR != (sel = w.GetCurSel()))
00157 {
00158 return static_cast<ms_size_t>(w.GetTextLen(sel));
00159 }
00160 else
00161 {
00162 return static_cast<ms_size_t>(w.GetWindowTextLength());
00163 }
00164 }
00165
00166 inline ms_size_t GetWindowText_T_(CListBox const& w, LPTSTR buffer, ms_size_t cchBuffer)
00167 {
00168 int sel = -1;
00169
00170 if( 0 == (w.GetStyle() & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)) &&
00171 LB_ERR != (sel = w.GetCurSel()))
00172 {
00173 ms_size_t cch = static_cast<ms_size_t>(w.GetText(sel, buffer));
00174
00175 MFCSTL_MESSAGE_ASSERT("Invalid item", LB_ERR != cch);
00176 MFCSTL_MESSAGE_ASSERT("Buffer overwrite", !(cchBuffer < cch));
00177
00178 return static_cast<ms_size_t>(cch);
00179 }
00180 else
00181 {
00182 return w.GetWindowText(buffer, cchBuffer);
00183 }
00184 }
00185
00186 #ifdef __AFXCMN_H__
00187 # if _MFC_VER >= 0x0600
00188 inline ms_size_t GetWindowTextLength_T_(CListCtrl const& w)
00189 {
00190 if(1 == w.GetSelectedCount())
00191 {
00192 POSITION pos = w.GetFirstSelectedItemPosition();
00193 int sel = w.GetNextSelectedItem(pos);
00194
00195 return static_cast<ms_size_t>(w.GetItemText(sel, 0).GetLength());
00196 }
00197 else
00198 {
00199 return static_cast<ms_size_t>(w.GetWindowTextLength());
00200 }
00201 }
00202
00203 inline ms_size_t GetWindowText_T_(CListCtrl const& w, LPTSTR buffer, ms_size_t cchBuffer)
00204 {
00205 if(1 == w.GetSelectedCount())
00206 {
00207 POSITION pos = w.GetFirstSelectedItemPosition();
00208 int sel = w.GetNextSelectedItem(pos);
00209
00210 return static_cast<ms_size_t>(w.GetItemText(sel, 0, buffer, cchBuffer));
00211 }
00212 else
00213 {
00214 return w.GetWindowText(buffer, cchBuffer);
00215 }
00216 }
00217
00218 # ifdef __AFXCVIEW_H__
00219 inline ms_size_t GetWindowTextLength_T_(CListView const& w)
00220 {
00221 return GetWindowTextLength_T_(w.GetListCtrl());
00222 }
00223
00224 inline ms_size_t GetWindowText_T_(CListView const& w, LPTSTR buffer, ms_size_t cchBuffer)
00225 {
00226 return GetWindowText_T_(w.GetListCtrl(), buffer, cchBuffer);
00227 }
00228 # endif
00229 # endif
00230 #endif
00231
00232 }
00233
00234 #endif
00235
00236
00237
00238
00239
00240
00241
00249 class c_str_ptr_null_CWnd_proxy
00250 {
00251 typedef TCHAR char_type;
00252 typedef cstring_maker<TCHAR> string_maker_type;
00253 public:
00254 typedef c_str_ptr_null_CWnd_proxy class_type;
00255
00256
00257 public:
00261 template<ss_typename_param_k W>
00262 c_str_ptr_null_CWnd_proxy(W const& w)
00263 {
00264 stlsoft_constraint_must_have_base(W, CWnd);
00265
00266 ms_size_t length = impl::GetWindowTextLength_T_(w);
00267
00268 if(length == 0)
00269 {
00270 m_buffer = NULL;
00271 }
00272 else
00273 {
00274 m_buffer = string_maker_type::alloc(length);
00275
00276 if(NULL != m_buffer)
00277 {
00278 impl::GetWindowText_T_(w, m_buffer, length + 1);
00279 }
00280 }
00281 }
00282
00283 #ifdef STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT
00292 c_str_ptr_null_CWnd_proxy(class_type& rhs)
00293 : m_buffer(rhs.m_buffer)
00294 {
00295 rhs.m_buffer = NULL;
00296 }
00297 #else
00298
00299 c_str_ptr_null_CWnd_proxy(class_type const& rhs)
00300 : m_buffer(string_maker_type::dup_null(rhs.m_buffer))
00301 {}
00302 #endif
00303
00305 ~c_str_ptr_null_CWnd_proxy() stlsoft_throw_0()
00306 {
00307 string_maker_type::free(m_buffer);
00308 }
00309
00310
00311 public:
00314 operator LPCTSTR () const
00315 {
00316 return m_buffer;
00317 }
00318
00319
00320 private:
00321 LPTSTR m_buffer;
00322
00323
00324 private:
00325 void operator =(class_type const& rhs);
00326 };
00327
00335 class c_str_ptr_CWnd_proxy
00336 {
00337 typedef TCHAR char_type;
00338 typedef cstring_maker<TCHAR> string_maker_type;
00339 private:
00340 typedef c_str_ptr_CWnd_proxy class_type;
00341
00342
00343 public:
00347 template<ss_typename_param_k W>
00348 c_str_ptr_CWnd_proxy(W const& w)
00349 {
00350 stlsoft_constraint_must_have_base(W, CWnd);
00351
00352 ms_size_t length = impl::GetWindowTextLength_T_(w);
00353
00354 if(length == 0)
00355 {
00356 m_buffer = string_maker_type::dup(_T(""));
00357 }
00358 else
00359 {
00360 m_buffer = string_maker_type::alloc(length);
00361
00362 if(NULL != m_buffer)
00363 {
00364 impl::GetWindowText_T_(w, m_buffer, length + 1);
00365 }
00366 }
00367 }
00368
00369 #ifdef STLSOFT_CF_MOVE_CONSTRUCTOR_SUPPORT
00378 c_str_ptr_CWnd_proxy(class_type& rhs)
00379 : m_buffer(rhs.m_buffer)
00380 {
00381 rhs.m_buffer = NULL;
00382 }
00383 #else
00384
00385 c_str_ptr_CWnd_proxy(class_type const& rhs)
00386 : m_buffer(string_maker_type::dup_null(rhs.m_buffer))
00387 {}
00388 #endif
00389
00391 ~c_str_ptr_CWnd_proxy() stlsoft_throw_0()
00392 {
00393 string_maker_type::free(m_buffer);
00394 }
00395
00396
00397 public:
00400 operator LPCTSTR () const
00401 {
00402 static char_type s_ch[1] = { '\0' };
00403
00404 return (NULL == m_buffer) ? s_ch : m_buffer;
00405 }
00406
00407
00408 private:
00409 LPTSTR m_buffer;
00410
00411
00412 private:
00413 void operator =(class_type const& rhs);
00414 };
00415
00416
00417
00418
00419
00420 inline ms_bool_t operator ==(LPCTSTR lhs, c_str_ptr_null_CWnd_proxy const& rhs)
00421 {
00422 return lhs == static_cast<LPCTSTR>(rhs);
00423 }
00424
00425 inline ms_bool_t operator ==(c_str_ptr_null_CWnd_proxy const& lhs, LPCTSTR rhs)
00426 {
00427 return static_cast<LPCTSTR>(lhs) == rhs;
00428 }
00429
00430 inline ms_bool_t operator !=(LPCTSTR lhs, c_str_ptr_null_CWnd_proxy const& rhs)
00431 {
00432 return lhs != static_cast<LPCTSTR>(rhs);
00433 }
00434
00435 inline ms_bool_t operator !=(c_str_ptr_null_CWnd_proxy const& lhs, LPCTSTR rhs)
00436 {
00437 return static_cast<LPCTSTR>(lhs) != rhs;
00438 }
00439
00440
00441
00442
00443
00444 template<ss_typename_param_k S>
00445 inline S& operator <<(S& s, c_str_ptr_null_CWnd_proxy const& shim)
00446 {
00447 s << static_cast<LPCTSTR>(shim);
00448
00449 return s;
00450 }
00451
00452 template <ss_typename_param_k S>
00453 inline S& operator <<(S& s, c_str_ptr_CWnd_proxy const& shim)
00454 {
00455 s << static_cast<LPCTSTR>(shim);
00456
00457 return s;
00458 }
00459
00460
00461
00462
00463
00464
00465
00466
00467
00473 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(CWnd const& w)
00474 {
00475 return c_str_ptr_null_CWnd_proxy(w);
00476 }
00477 #if defined(UNICODE)
00478 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_w(CWnd const& w)
00479 #else
00480 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_a(CWnd const& w)
00481 #endif
00482 {
00483 return c_str_ptr_null(w);
00484 }
00485
00491 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(CListBox const& w)
00492 {
00493 return c_str_ptr_null_CWnd_proxy(w);
00494 }
00495 #if defined(UNICODE)
00496 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_w(CListBox const& w)
00497 #else
00498 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_a(CListBox const& w)
00499 #endif
00500 {
00501 return c_str_ptr_null(w);
00502 }
00503
00504 #ifdef __AFXCMN_H__
00505
00510 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(CListCtrl const& w)
00511 {
00512 return c_str_ptr_null_CWnd_proxy(w);
00513 }
00514 #if defined(UNICODE)
00515 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_w(CListCtrl const& w)
00516 #else
00517 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_a(CListCtrl const& w)
00518 #endif
00519 {
00520 return c_str_ptr_null(w);
00521 }
00522
00523 # ifdef __AFXCVIEW_H__
00524
00529 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null(CListView const& w)
00530 {
00531 return c_str_ptr_null(w.GetListCtrl());
00532 }
00533 #if defined(UNICODE)
00534 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_w(CListView const& w)
00535 #else
00536 inline c_str_ptr_null_CWnd_proxy c_str_ptr_null_a(CListView const& w)
00537 #endif
00538 {
00539 return c_str_ptr_null(w);
00540 }
00541 # endif
00542 #endif
00543
00544
00545
00546
00547
00548
00549
00550
00551
00557 inline c_str_ptr_CWnd_proxy c_str_ptr(CWnd const& w)
00558 {
00559 return c_str_ptr_CWnd_proxy(w);
00560 }
00561 #if defined(UNICODE)
00562 inline c_str_ptr_CWnd_proxy c_str_ptr_w(CWnd const& w)
00563 #else
00564 inline c_str_ptr_CWnd_proxy c_str_ptr_a(CWnd const& w)
00565 #endif
00566 {
00567 return c_str_ptr(w);
00568 }
00569
00575 inline c_str_ptr_CWnd_proxy c_str_ptr(CListBox const& w)
00576 {
00577 return c_str_ptr_CWnd_proxy(w);
00578 }
00579 #if defined(UNICODE)
00580 inline c_str_ptr_CWnd_proxy c_str_ptr_w(CListBox const& w)
00581 #else
00582 inline c_str_ptr_CWnd_proxy c_str_ptr_a(CListBox const& w)
00583 #endif
00584 {
00585 return c_str_ptr(w);
00586 }
00587
00588 #ifdef __AFXCMN_H__
00589
00594 inline c_str_ptr_CWnd_proxy c_str_ptr(CListCtrl const& w)
00595 {
00596 return c_str_ptr_CWnd_proxy(w);
00597 }
00598 #if defined(UNICODE)
00599 inline c_str_ptr_CWnd_proxy c_str_ptr_w(CListCtrl const& w)
00600 #else
00601 inline c_str_ptr_CWnd_proxy c_str_ptr_a(CListCtrl const& w)
00602 #endif
00603 {
00604 return c_str_ptr(w);
00605 }
00606
00607 # ifdef __AFXCVIEW_H__
00608
00613 inline c_str_ptr_CWnd_proxy c_str_ptr(CListView const& w)
00614 {
00615 return c_str_ptr(w.GetListCtrl());
00616 }
00617 #if defined(UNICODE)
00618 inline c_str_ptr_CWnd_proxy c_str_ptr_w(CListView const& w)
00619 #else
00620 inline c_str_ptr_CWnd_proxy c_str_ptr_a(CListView const& w)
00621 #endif
00622 {
00623 return c_str_ptr(w);
00624 }
00625 # endif
00626 #endif
00627
00628
00629
00630
00631
00632
00633
00634
00635
00641 inline c_str_ptr_CWnd_proxy c_str_data(CWnd const& w)
00642 {
00643 return c_str_ptr_CWnd_proxy(w);
00644 }
00645 #if defined(UNICODE)
00646 inline c_str_ptr_CWnd_proxy c_str_data_w(CWnd const& w)
00647 #else
00648 inline c_str_ptr_CWnd_proxy c_str_data_a(CWnd const& w)
00649 #endif
00650 {
00651 return c_str_data(w);
00652 }
00653
00659 inline c_str_ptr_CWnd_proxy c_str_data(CListBox const& w)
00660 {
00661 return c_str_ptr_CWnd_proxy(w);
00662 }
00663 #if defined(UNICODE)
00664 inline c_str_ptr_CWnd_proxy c_str_data_w(CListBox const& w)
00665 #else
00666 inline c_str_ptr_CWnd_proxy c_str_data_a(CListBox const& w)
00667 #endif
00668 {
00669 return c_str_data(w);
00670 }
00671
00672 #ifdef __AFXCMN_H__
00673
00678 inline c_str_ptr_CWnd_proxy c_str_data(CListCtrl const& w)
00679 {
00680 return c_str_ptr_CWnd_proxy(w);
00681 }
00682 #if defined(UNICODE)
00683 inline c_str_ptr_CWnd_proxy c_str_data_w(CListCtrl const& w)
00684 #else
00685 inline c_str_ptr_CWnd_proxy c_str_data_a(CListCtrl const& w)
00686 #endif
00687 {
00688 return c_str_data(w);
00689 }
00690
00691 # ifdef __AFXCVIEW_H__
00692
00697 inline c_str_ptr_CWnd_proxy c_str_data(CListView const& w)
00698 {
00699 return c_str_data(w.GetListCtrl());
00700 }
00701 #if defined(UNICODE)
00702 inline c_str_ptr_CWnd_proxy c_str_data_w(CListView const& w)
00703 #else
00704 inline c_str_ptr_CWnd_proxy c_str_data_a(CListView const& w)
00705 #endif
00706 {
00707 return c_str_data(w);
00708 }
00709 # endif
00710 #endif
00711
00712
00713
00714
00715
00716
00717
00718
00719
00725 inline ms_size_t c_str_len(CWnd const& w)
00726 {
00727 return GetWindowTextLength_T_(w);
00728 }
00729 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00730 # ifdef UNICODE
00731 inline ms_size_t c_str_len_w(CWnd const& w)
00732 # else
00733 inline ms_size_t c_str_len_a(CWnd const& w)
00734 # endif
00735 {
00736 return c_str_len(w);
00737 }
00738 #endif
00739
00745 inline ms_size_t c_str_len(CListBox const& w)
00746 {
00747 return GetWindowTextLength_T_(w);
00748 }
00749 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00750 # ifdef UNICODE
00751 inline ms_size_t c_str_len_w(CListBox const& w)
00752 # else
00753 inline ms_size_t c_str_len_a(CListBox const& w)
00754 # endif
00755 {
00756 return c_str_len(w);
00757 }
00758 #endif
00759
00760
00761 #ifdef __AFXCMN_H__
00762
00767 inline ms_size_t c_str_len(CListCtrl const& w)
00768 {
00769 return GetWindowTextLength_T_(w);
00770 }
00771 # ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00772 # ifdef UNICODE
00773 inline ms_size_t c_str_len_w(CListCtrl const& w)
00774 # else
00775 inline ms_size_t c_str_len_a(CListCtrl const& w)
00776 # endif
00777 {
00778 return c_str_len(w);
00779 }
00780 # endif
00781
00782
00783 # ifdef __AFXCVIEW_H__
00784
00789 inline ms_size_t c_str_len(CListView const& w)
00790 {
00791 return c_str_len(w.GetListCtrl());
00792 }
00793 # ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00794 # ifdef UNICODE
00795 inline ms_size_t c_str_len_w(CListView const& w)
00796 # else
00797 inline ms_size_t c_str_len_a(CListView const& w)
00798 # endif
00799 {
00800 return c_str_len(w);
00801 }
00802 # endif
00803
00804 # endif
00805 #endif
00806
00808
00809
00810 #ifdef STLSOFT_UNITTEST
00811 # include "./unittest/cwnd_unittest_.h"
00812 #endif
00813
00814
00815
00816 #ifndef _MFCSTL_NO_NAMESPACE
00817 # if defined(_STLSOFT_NO_NAMESPACE) || \
00818 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00819 }
00820 # else
00821 }
00822 }
00823 # endif
00824 #endif
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834 #ifndef _MFCSTL_NO_NAMESPACE
00835 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00836 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00837 namespace stlsoft
00838 {
00839 # else
00840
00841 # endif
00842
00843 using ::mfcstl::c_str_data;
00844 #if defined(UNICODE)
00845 using ::mfcstl::c_str_data_w;
00846 #else
00847 using ::mfcstl::c_str_data_a;
00848 #endif
00849
00850 using ::mfcstl::c_str_len;
00851 #if defined(UNICODE)
00852 using ::mfcstl::c_str_len_w;
00853 #else
00854 using ::mfcstl::c_str_len_a;
00855 #endif
00856
00857 using ::mfcstl::c_str_ptr;
00858 #if defined(UNICODE)
00859 using ::mfcstl::c_str_ptr_w;
00860 #else
00861 using ::mfcstl::c_str_ptr_a;
00862 #endif
00863
00864 using ::mfcstl::c_str_ptr_null;
00865 #if defined(UNICODE)
00866 using ::mfcstl::c_str_ptr_null_w;
00867 #else
00868 using ::mfcstl::c_str_ptr_null_a;
00869 #endif
00870
00871
00872 # if !defined(_STLSOFT_NO_NAMESPACE) && \
00873 !defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00874 }
00875 # else
00876
00877 # endif
00878 #endif
00879
00880
00881
00882 #endif
00883
00884