diff options
author | Andrzej Rybczak <electricityispower@gmail.com> | 2009-05-25 21:46:36 +0200 |
---|---|---|
committer | Andrzej Rybczak <electricityispower@gmail.com> | 2009-05-25 21:46:36 +0200 |
commit | d965f4e517e749ec1d93810b77088aca30c57df5 (patch) | |
tree | 3d4113b4ac1c96e3dcc36dcc4673229a6ffb63ae /src/menu.h | |
parent | dd266b0103b5cd05e509c209503d46bbcdcc97b0 (diff) |
new feature: mouse support
Diffstat (limited to 'src/menu.h')
-rw-r--r-- | src/menu.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -118,6 +118,9 @@ namespace NCurses void IntoSeparator(size_t pos); void Swap(size_t one, size_t two); void Move(size_t from, size_t to); + bool Goto(size_t y); + + size_t GetPosition() const { return itsHighlight; } bool isBold(int id = -1); void BoldOption(int index, bool bold); @@ -358,6 +361,19 @@ template <typename T> void NCurses::Menu<T>::Move(size_t from, size_t to) } } +template <typename T> bool NCurses::Menu<T>::Goto(size_t y) +{ + if (!itsOptionsPtr->at(itsBeginning+y) || itsOptionsPtr->at(itsBeginning+y)->isStatic) + return false; + size_t cur_pos = itsHighlight-itsBeginning; + while (itsHighlight-itsBeginning != int(y) && (y < cur_pos || size_t(itsHighlight) < itsOptions.size()-1)) + { + Scroll(y < cur_pos ? wUp : wDown); + y < cur_pos ? cur_pos-- : cur_pos++; + } + return true; +} + template <typename T> void NCurses::Menu<T>::Refresh() { if (itsOptionsPtr->empty()) |