⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treeview_sequence.hpp

📁 新版本TR1的stl
💻 HPP
📖 第 1 页 / 共 2 页
字号:
    : public treeview_sequence_base<TVGN_NEXT, TVGN_PREVIOUS>
{
/// \name Member Types
/// @{
private:
    typedef treeview_sequence_base<TVGN_NEXT, TVGN_PREVIOUS>            base_class_type;
public:
    /// This class
    typedef treeview_child_sequence                                     class_type;
    /// The non-mutating (const) iterator type
    typedef base_class_type::const_iterator                             const_iterator;
    /// The value type
    typedef base_class_type::value_type                                 value_type;
    /// The difference type
    typedef base_class_type::difference_type                            difference_type;
/// @}

/// \name Construction
/// @{
public:
    /// Create sequence of the children of \c hitem in the given tree
    treeview_child_sequence(HWND hwndTree, HTREEITEM hitem);
    /// Create sequence of the children of the root in the given tree
    ss_explicit_k treeview_child_sequence(HWND hwndTree);
/// @}
};

// class treeview_peer_sequence
/** \brief brief Presents an STL-like sequence interface to the peers of a given node in a tree-view
 *
 * \ingroup group__library__windows_controls
 */
class treeview_peer_sequence
    : public treeview_sequence_base<TVGN_NEXT, TVGN_PREVIOUS>
{
/// \name Member Types
/// @{
private:
    typedef treeview_sequence_base<TVGN_NEXT, TVGN_PREVIOUS>            base_class_type;
public:
    /// This class
    typedef treeview_child_sequence                                     class_type;
    /// The non-mutating (const) iterator type
    typedef base_class_type::const_iterator                             const_iterator;
    /// The value type
    typedef base_class_type::value_type                                 value_type;
    /// The difference type
    typedef base_class_type::difference_type                            difference_type;
/// @}

/// \name Construction
/// @{
public:
    /// Create sequence of the peers of \c hitem in the given tree
    treeview_peer_sequence(HWND hwndTree, HTREEITEM hitem);
/// @}
};

// class treeview_visible_sequence
/** \brief Presents an STL-like sequence interface to the visible items in a tree-view
 *
 * \ingroup group__library__windows_controls
 */
class treeview_visible_sequence
    : public treeview_sequence_base<TVGN_NEXTVISIBLE, TVGN_PREVIOUSVISIBLE>
{
/// \name Member Types
/// @{
private:
    typedef treeview_sequence_base<TVGN_NEXTVISIBLE, TVGN_PREVIOUSVISIBLE>  base_class_type;
public:
    /// This class
    typedef treeview_child_sequence                                         class_type;
    /// The non-mutating (const) iterator type
    typedef base_class_type::const_iterator                                 const_iterator;
    /// The value type
    typedef base_class_type::value_type                                     value_type;
    /// The difference type
    typedef base_class_type::difference_type                                difference_type;
/// @}

/// \name Construction
/// @{
public:
    /// Create sequence of the visible items in the given tree
    ss_explicit_k treeview_visible_sequence(HWND hwndTree);
/// @}
};

/* /////////////////////////////////////////////////////////////////////////
 * Unit-testing
 */

#ifdef STLSOFT_UNITTEST
# include "./unittest/treeview_sequence_unittest_.h"
#endif /* STLSOFT_UNITTEST */

/* /////////////////////////////////////////////////////////////////////////
 * Implementation
 */

#ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION

// treeview_sequence_const_iterator

template <UINT N, UINT P>
inline treeview_sequence_const_iterator<N, P>::treeview_sequence_const_iterator(HWND hwndTree, HTREEITEM hitem)
    : m_hwnd(hwndTree)
    , m_hitem(hitem)
{}

template <UINT N, UINT P>
inline treeview_sequence_const_iterator<N, P>::treeview_sequence_const_iterator()
    : m_hwnd(NULL)
    , m_hitem(NULL)
{}

template <UINT N, UINT P>
inline treeview_sequence_const_iterator<N, P>::treeview_sequence_const_iterator(treeview_sequence_const_iterator<N, P> const& rhs)
    : m_hwnd(rhs.m_hwnd)
    , m_hitem(rhs.m_hitem)
{}

template <UINT N, UINT P>
inline treeview_sequence_const_iterator<N, P> &treeview_sequence_const_iterator<N, P>::operator =(treeview_sequence_const_iterator<N, P> const& rhs)
{
    m_hwnd = rhs.m_hwnd;
    m_hitem = rhs.m_hitem;

    return *this;
}

template <UINT N, UINT P>
inline HTREEITEM treeview_sequence_const_iterator<N, P>::operator *() const
{
    return m_hitem;
}

template <UINT N, UINT P>
inline ss_typename_type_k treeview_sequence_const_iterator<N, P>::class_type &treeview_sequence_const_iterator<N, P>::operator ++()
{
    if(m_hitem != NULL)
    {
        m_hitem = treeview_getnextitem(m_hwnd, m_hitem, N);
    }

    return *this;
}

template <UINT N, UINT P>
inline ss_typename_type_k treeview_sequence_const_iterator<N, P>::class_type treeview_sequence_const_iterator<N, P>::operator ++(int)
{
    class_type  ret(*this);

    operator ++();

    return ret;
}

template <UINT N, UINT P>
inline ws_bool_t treeview_sequence_const_iterator<N, P>::operator ==(treeview_sequence_const_iterator<N, P> const& rhs) const
{
    return m_hitem == rhs.m_hitem;
}

template <UINT N, UINT P>
inline ws_bool_t treeview_sequence_const_iterator<N, P>::operator !=(treeview_sequence_const_iterator<N, P> const& rhs) const
{
    return !operator ==(rhs);
}

// treeview_sequence_base

template <UINT N, UINT P>
inline treeview_sequence_base<N, P>::treeview_sequence_base(HWND hwndTree, HTREEITEM hitem)
    : m_hwnd(hwndTree)
    , m_hitem(hitem)
{}

template <UINT N, UINT P>
inline ss_typename_type_k treeview_sequence_base<N, P>::const_iterator treeview_sequence_base<N, P>::begin() const
{
    return const_iterator(m_hwnd, m_hitem);
}

template <UINT N, UINT P>
inline ss_typename_type_k treeview_sequence_base<N, P>::const_iterator treeview_sequence_base<N, P>::end() const
{
    return const_iterator();
}

// treeview_child_sequence

inline treeview_child_sequence::treeview_child_sequence(HWND hwndTree, HTREEITEM hitem)
    : base_class_type(hwndTree, treeview_getchilditem(hwndTree, hitem))
{}

inline treeview_child_sequence::treeview_child_sequence(HWND hwndTree)
    : base_class_type(hwndTree, treeview_getchilditem(hwndTree, treeview_getrootitem(hwndTree)))
{}

// treeview_peer_sequence

inline treeview_peer_sequence::treeview_peer_sequence(HWND hwndTree, HTREEITEM hitem)
    : base_class_type(hwndTree, hitem)
{}

// treeview_visible_sequence

inline treeview_visible_sequence::treeview_visible_sequence(HWND hwndTree)
    : base_class_type(hwndTree, treeview_getnextitem(hwndTree, NULL, TVGN_FIRSTVISIBLE))
{}

#endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */

/* ////////////////////////////////////////////////////////////////////// */

#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_CONTROLS_HPP_TREEVIEW_SEQUENCE */

/* ////////////////////////////////////////////////////////////////////// */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -