|
|
|
@ -48,7 +48,7 @@ class Menu : public Window |
|
|
|
typedef string (*ItemDisplayer) (const T &, void *, const Menu<T> *); |
|
|
|
typedef string (*ItemDisplayer) (const T &, void *, const Menu<T> *); |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
Menu(int startx, int starty, int width, int height, string title, Color color, Border border) : Window(startx, starty, width, height, title, color, border), itsItemDisplayer(0), itsItemDisplayerUserdata(0), itsSelectedPrefix("[.r]"), itsSelectedSuffix("[/r]"), itsStaticsNumber(0), itsBeginning(0), itsHighlight(0), itsHighlightColor(itsBaseColor), itsHighlightEnabled(1) { } |
|
|
|
Menu(int, int, int, int, const string &, Color, Border); |
|
|
|
Menu(const Menu &); |
|
|
|
Menu(const Menu &); |
|
|
|
virtual ~Menu(); |
|
|
|
virtual ~Menu(); |
|
|
|
|
|
|
|
|
|
|
|
@ -126,6 +126,19 @@ class Menu : public Window |
|
|
|
bool itsHighlightEnabled; |
|
|
|
bool itsHighlightEnabled; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <class T> |
|
|
|
|
|
|
|
Menu<T>::Menu(int startx, int starty, int width, int height, const string &title, Color color, Border border) : |
|
|
|
|
|
|
|
Window(startx, starty, width, height, title, color, border), |
|
|
|
|
|
|
|
itsItemDisplayer(0), |
|
|
|
|
|
|
|
itsItemDisplayerUserdata(0), |
|
|
|
|
|
|
|
itsSelectedPrefix("[.r]"), |
|
|
|
|
|
|
|
itsSelectedSuffix("[/r]"), |
|
|
|
|
|
|
|
itsStaticsNumber(0), |
|
|
|
|
|
|
|
itsBeginning(0), |
|
|
|
|
|
|
|
itsHighlight(0), |
|
|
|
|
|
|
|
itsHighlightColor(itsBaseColor), |
|
|
|
|
|
|
|
itsHighlightEnabled(1) { } |
|
|
|
|
|
|
|
|
|
|
|
template <class T> |
|
|
|
template <class T> |
|
|
|
Menu<T>::Menu(const Menu &m) : Window(m) |
|
|
|
Menu<T>::Menu(const Menu &m) : Window(m) |
|
|
|
{ |
|
|
|
{ |
|
|
|
@ -355,7 +368,13 @@ void Menu<T>::Refresh(bool redraw_whole_window) |
|
|
|
int ch = itsOptions[*it]->have_separator ? 0 : 32; |
|
|
|
int ch = itsOptions[*it]->have_separator ? 0 : 32; |
|
|
|
mvwhline(itsWindow,line, 0, ch, itsWidth); |
|
|
|
mvwhline(itsWindow,line, 0, ch, itsWidth); |
|
|
|
|
|
|
|
|
|
|
|
string option = DisplayOption(itsOptions[*it]->item); |
|
|
|
string option; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (itsOptions[*it]->selected) |
|
|
|
|
|
|
|
option += itsSelectedPrefix; |
|
|
|
|
|
|
|
option += DisplayOption(itsOptions[*it]->item); |
|
|
|
|
|
|
|
if (itsOptions[*it]->selected) |
|
|
|
|
|
|
|
option += itsSelectedSuffix; |
|
|
|
|
|
|
|
|
|
|
|
int strlength = itsOptions[*it]->location != lLeft && BBEnabled ? Window::RealLength(option) : option.length(); |
|
|
|
int strlength = itsOptions[*it]->location != lLeft && BBEnabled ? Window::RealLength(option) : option.length(); |
|
|
|
|
|
|
|
|
|
|
|
@ -386,9 +405,6 @@ void Menu<T>::Refresh(bool redraw_whole_window) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (itsOptions[*it]->selected) |
|
|
|
|
|
|
|
WriteXY(x, line, itsWidth, TO_WSTRING(itsSelectedPrefix + option + itsSelectedSuffix), 0); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
WriteXY(x, line, itsWidth, TO_WSTRING(option), 0); |
|
|
|
WriteXY(x, line, itsWidth, TO_WSTRING(option), 0); |
|
|
|
|
|
|
|
|
|
|
|
if (!ch && (itsOptions[*it]->location == lCenter || itsOptions[*it]->location == lLeft)) |
|
|
|
if (!ch && (itsOptions[*it]->location == lCenter || itsOptions[*it]->location == lLeft)) |
|
|
|
@ -415,7 +431,9 @@ void Menu<T>::Refresh(bool redraw_whole_window) |
|
|
|
template <class T> |
|
|
|
template <class T> |
|
|
|
void Menu<T>::Go(Where where) |
|
|
|
void Menu<T>::Go(Where where) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (Empty()) return; |
|
|
|
if (Empty()) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
int MaxHighlight = itsOptions.size()-1; |
|
|
|
int MaxHighlight = itsOptions.size()-1; |
|
|
|
int MaxBeginning = itsOptions.size() < itsHeight ? 0 : itsOptions.size()-itsHeight; |
|
|
|
int MaxBeginning = itsOptions.size() < itsHeight ? 0 : itsOptions.size()-itsHeight; |
|
|
|
int MaxCurrentHighlight = itsBeginning+itsHeight-1; |
|
|
|
int MaxCurrentHighlight = itsBeginning+itsHeight-1; |
|
|
|
@ -431,7 +449,9 @@ void Menu<T>::Go(Where where) |
|
|
|
wscrl(itsWindow, -1); |
|
|
|
wscrl(itsWindow, -1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (itsHighlight == 0) |
|
|
|
if (itsHighlight == 0) |
|
|
|
|
|
|
|
{ |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
NeedsRedraw.push_back(itsHighlight--); |
|
|
|
NeedsRedraw.push_back(itsHighlight--); |
|
|
|
@ -439,10 +459,7 @@ void Menu<T>::Go(Where where) |
|
|
|
} |
|
|
|
} |
|
|
|
if (is_static()) |
|
|
|
if (is_static()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (itsHighlight == 0) |
|
|
|
itsHighlight == 0 ? Go(wDown) : Go(wUp); |
|
|
|
Go(wDown); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Go(wUp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -454,7 +471,9 @@ void Menu<T>::Go(Where where) |
|
|
|
wscrl(itsWindow, 1); |
|
|
|
wscrl(itsWindow, 1); |
|
|
|
} |
|
|
|
} |
|
|
|
if (itsHighlight == MaxHighlight) |
|
|
|
if (itsHighlight == MaxHighlight) |
|
|
|
|
|
|
|
{ |
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
NeedsRedraw.push_back(itsHighlight++); |
|
|
|
NeedsRedraw.push_back(itsHighlight++); |
|
|
|
@ -462,10 +481,7 @@ void Menu<T>::Go(Where where) |
|
|
|
} |
|
|
|
} |
|
|
|
if (is_static()) |
|
|
|
if (is_static()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (itsHighlight == MaxHighlight) |
|
|
|
itsHighlight == MaxHighlight ? Go(wUp) : Go(wDown); |
|
|
|
Go(wUp); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Go(wDown); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -476,14 +492,12 @@ void Menu<T>::Go(Where where) |
|
|
|
if (itsBeginning < 0) |
|
|
|
if (itsBeginning < 0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
itsBeginning = 0; |
|
|
|
itsBeginning = 0; |
|
|
|
if (itsHighlight < 0) itsHighlight = 0; |
|
|
|
if (itsHighlight < 0) |
|
|
|
|
|
|
|
itsHighlight = 0; |
|
|
|
} |
|
|
|
} |
|
|
|
if (is_static()) |
|
|
|
if (is_static()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (itsHighlight == 0) |
|
|
|
itsHighlight == 0 ? Go(wDown) : Go(wUp); |
|
|
|
Go(wDown); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Go(wUp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
redraw_screen(); |
|
|
|
redraw_screen(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
@ -495,14 +509,12 @@ void Menu<T>::Go(Where where) |
|
|
|
if (itsBeginning > MaxBeginning) |
|
|
|
if (itsBeginning > MaxBeginning) |
|
|
|
{ |
|
|
|
{ |
|
|
|
itsBeginning = MaxBeginning; |
|
|
|
itsBeginning = MaxBeginning; |
|
|
|
if (itsHighlight > MaxHighlight) itsHighlight = MaxHighlight; |
|
|
|
if (itsHighlight > MaxHighlight) |
|
|
|
|
|
|
|
itsHighlight = MaxHighlight; |
|
|
|
} |
|
|
|
} |
|
|
|
if (is_static()) |
|
|
|
if (is_static()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (itsHighlight == MaxHighlight) |
|
|
|
itsHighlight == MaxHighlight ? Go(wUp) : Go(wDown); |
|
|
|
Go(wUp); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Go(wDown); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
redraw_screen(); |
|
|
|
redraw_screen(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
@ -513,10 +525,7 @@ void Menu<T>::Go(Where where) |
|
|
|
itsBeginning = 0; |
|
|
|
itsBeginning = 0; |
|
|
|
if (is_static()) |
|
|
|
if (is_static()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (itsHighlight == 0) |
|
|
|
itsHighlight == 0 ? Go(wDown) : Go(wUp); |
|
|
|
Go(wDown); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Go(wUp); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
redraw_screen(); |
|
|
|
redraw_screen(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
@ -527,10 +536,7 @@ void Menu<T>::Go(Where where) |
|
|
|
itsBeginning = MaxBeginning; |
|
|
|
itsBeginning = MaxBeginning; |
|
|
|
if (is_static()) |
|
|
|
if (is_static()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (itsHighlight == MaxHighlight) |
|
|
|
itsHighlight == MaxHighlight ? Go(wUp) : Go(wDown); |
|
|
|
Go(wUp); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
Go(wDown); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
redraw_screen(); |
|
|
|
redraw_screen(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
|