functionals.hpp
来自「用STL的方式封装了WindowsAPI、COM调用、ACE、ATL、MFC、W」· HPP 代码 · 共 757 行 · 第 1/2 页
HPP
757 行
typedef listbox_add_inserter class_type;
public:
/// Construct with the target list-box window
ss_explicit_k listbox_add_inserter(HWND hwndListbox)
: m_hwndListbox(hwndListbox)
, m_bUnicode(::IsWindowUnicode(hwndListbox))
{}
listbox_add_inserter(class_type const &rhs)
: m_hwndListbox(rhs.m_hwndListbox)
, m_bUnicode(rhs.m_bUnicode)
{}
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
template <ss_typename_param_k S>
void operator ()(S const &s)
{
add(stlsoft_ns_qual(c_str_ptr)(s));
}
#endif // STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
void operator ()(ws_char_a_t const *s)
{
add(s);
}
/// Function call operator taking the item string
void operator ()(ws_char_w_t const *s)
{
add(s);
}
// Implementation
private:
void add(ws_char_a_t const *s)
{
if(m_bUnicode)
{
listbox_addstring_w(m_hwndListbox, a2w(s));
}
else
{
listbox_addstring_a(m_hwndListbox, s);
}
}
void add(ws_char_w_t const *s)
{
if(m_bUnicode)
{
listbox_addstring_w(m_hwndListbox, s);
}
else
{
listbox_addstring_a(m_hwndListbox, w2a(s));
}
}
private:
HWND m_hwndListbox;
ws_int32_t m_bUnicode;
};
/** \brief Function object used to insert items to the back of a list-box
*
* \ingroup group__library__windows_controls
*/
// [[synesis:class:unary-functor: listbox_back_inserter]]
struct listbox_back_inserter
: public stlsoft_ns_qual(unary_function_output_iterator_adaptor)<listbox_back_inserter>
{
public:
typedef listbox_back_inserter class_type;
public:
/// Construct with the target list-box window
ss_explicit_k listbox_back_inserter(HWND hwndListbox)
: m_hwndListbox(hwndListbox)
, m_bUnicode(::IsWindowUnicode(hwndListbox))
{}
listbox_back_inserter(class_type const &rhs)
: m_hwndListbox(rhs.m_hwndListbox)
, m_bUnicode(rhs.m_bUnicode)
{}
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
template <ss_typename_param_k S>
void operator ()(S const &s)
{
insert(stlsoft_ns_qual(c_str_ptr)(s));
}
#endif // STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
void operator ()(ws_char_a_t const *s)
{
insert(s);
}
/// Function call operator taking the item string
void operator ()(ws_char_w_t const *s)
{
insert(s);
}
// Implementation
private:
void insert(ws_char_a_t const *s)
{
if(m_bUnicode)
{
listbox_insertstring_w(m_hwndListbox, a2w(s), -1);
}
else
{
listbox_insertstring_a(m_hwndListbox, s, -1);
}
}
void insert(ws_char_w_t const *s)
{
if(m_bUnicode)
{
listbox_insertstring_w(m_hwndListbox, s, -1);
}
else
{
listbox_insertstring_a(m_hwndListbox, w2a(s), -1);
}
}
private:
HWND m_hwndListbox;
ws_int32_t m_bUnicode;
};
/** \brief Function object used to insert items at the front of combo-box
*
* \ingroup group__library__windows_controls
*/
// [[synesis:class:unary-functor: combobox_front_inserter]]
struct combobox_front_inserter
: public stlsoft_ns_qual(unary_function_output_iterator_adaptor)<combobox_front_inserter>
{
public:
typedef combobox_front_inserter class_type;
public:
/// Construct with the target combo-box window
ss_explicit_k combobox_front_inserter(HWND hwndListbox)
: m_hwndListbox(hwndListbox)
, m_bUnicode(::IsWindowUnicode(hwndListbox))
{}
combobox_front_inserter(class_type const &rhs)
: m_hwndListbox(rhs.m_hwndListbox)
, m_bUnicode(rhs.m_bUnicode)
{}
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
template <ss_typename_param_k S>
void operator ()(S const &s)
{
insert(stlsoft_ns_qual(c_str_ptr)(s));
}
#endif // STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
void operator ()(ws_char_a_t const *s)
{
insert(s);
}
/// Function call operator taking the item string
void operator ()(ws_char_w_t const *s)
{
insert(s);
}
// Implementation
private:
void insert(ws_char_a_t const *s)
{
if(m_bUnicode)
{
combobox_insertstring_w(m_hwndListbox, a2w(s), 0);
}
else
{
combobox_insertstring_a(m_hwndListbox, s, 0);
}
}
void insert(ws_char_w_t const *s)
{
if(m_bUnicode)
{
combobox_insertstring_w(m_hwndListbox, s, 0);
}
else
{
combobox_insertstring_a(m_hwndListbox, w2a(s), 0);
}
}
private:
HWND m_hwndListbox;
ws_int32_t m_bUnicode;
};
/** \brief Function object used to add items to a combo-box
*
* \ingroup group__library__windows_controls
*/
// [[synesis:class:unary-functor: combobox_add_inserter]]
struct combobox_add_inserter
: public stlsoft_ns_qual(unary_function_output_iterator_adaptor)<combobox_add_inserter>
{
public:
typedef combobox_add_inserter class_type;
public:
/// Construct with the target combo-box window
ss_explicit_k combobox_add_inserter(HWND hwndListbox)
: m_hwndListbox(hwndListbox)
, m_bUnicode(::IsWindowUnicode(hwndListbox))
{}
combobox_add_inserter(class_type const &rhs)
: m_hwndListbox(rhs.m_hwndListbox)
, m_bUnicode(rhs.m_bUnicode)
{}
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
template <ss_typename_param_k S>
void operator ()(S const &s)
{
add(stlsoft_ns_qual(c_str_ptr)(s));
}
#endif // STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
void operator ()(ws_char_a_t const *s)
{
add(s);
}
/// Function call operator taking the item string
void operator ()(ws_char_w_t const *s)
{
add(s);
}
// Implementation
private:
void add(ws_char_a_t const *s)
{
if(m_bUnicode)
{
combobox_addstring_w(m_hwndListbox, a2w(s));
}
else
{
combobox_addstring_a(m_hwndListbox, s);
}
}
void add(ws_char_w_t const *s)
{
if(m_bUnicode)
{
combobox_addstring_w(m_hwndListbox, s);
}
else
{
combobox_addstring_a(m_hwndListbox, w2a(s));
}
}
private:
HWND m_hwndListbox;
ws_int32_t m_bUnicode;
};
/** \brief Function object used to insert items to the back of a combo-box
*
* \ingroup group__library__windows_controls
*/
// [[synesis:class:unary-functor: combobox_back_inserter]]
struct combobox_back_inserter
: public stlsoft_ns_qual(unary_function_output_iterator_adaptor)<combobox_back_inserter>
{
public:
typedef combobox_back_inserter class_type;
public:
/// Construct with the target combo-box window
ss_explicit_k combobox_back_inserter(HWND hwndListbox)
: m_hwndListbox(hwndListbox)
, m_bUnicode(::IsWindowUnicode(hwndListbox))
{}
combobox_back_inserter(class_type const &rhs)
: m_hwndListbox(rhs.m_hwndListbox)
, m_bUnicode(rhs.m_bUnicode)
{}
#ifdef STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
template <ss_typename_param_k S>
void operator ()(S const &s)
{
insert(stlsoft_ns_qual(c_str_ptr)(s));
}
#endif // STLSOFT_CF_MEMBER_TEMPLATE_FUNCTION_SUPPORT
/// Function call operator taking the item string
void operator ()(ws_char_a_t const *s)
{
insert(s);
}
/// Function call operator taking the item string
void operator ()(ws_char_w_t const *s)
{
insert(s);
}
// Implementation
private:
void insert(ws_char_a_t const *s)
{
if(m_bUnicode)
{
combobox_insertstring_w(m_hwndListbox, a2w(s), -1);
}
else
{
combobox_insertstring_a(m_hwndListbox, s, -1);
}
}
void insert(ws_char_w_t const *s)
{
if(m_bUnicode)
{
combobox_insertstring_w(m_hwndListbox, s, -1);
}
else
{
combobox_insertstring_a(m_hwndListbox, w2a(s), -1);
}
}
private:
HWND m_hwndListbox;
ws_int32_t m_bUnicode;
};
////////////////////////////////////////////////////////////////////////////
// Unit-testing
#ifdef STLSOFT_UNITTEST
# include "./unittest/functionals_unittest_.h"
#endif /* STLSOFT_UNITTEST */
/* ////////////////////////////////////////////////////////////////////// */
#ifndef _WINSTL_NO_NAMESPACE
# if defined(_STLSOFT_NO_NAMESPACE) || \
defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
} // namespace winstl
# else
} // namespace winstl_project
} // namespace stlsoft
# endif /* _STLSOFT_NO_NAMESPACE */
#endif /* !_WINSTL_NO_NAMESPACE */
/* ////////////////////////////////////////////////////////////////////// */
#endif /* WINSTL_INCL_WINSTL_CONTROL_HPP_FUNCTIONALS */
/* ////////////////////////////////////////////////////////////////////// */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?