Added separator item type for menus

This commit is contained in:
Ianos Gnatiuc 2005-11-28 16:27:49 +00:00
parent bb0d42bbc2
commit df30d36fe5
4 changed files with 57 additions and 29 deletions

View File

@ -116,6 +116,7 @@ public:
void Item(int tag, const char* text, VfvCP select, int fmask=M_CLOSE);
void Item(int tag, const char* text, int fmask, VfvCP select, gkey hotkey=0);
void ItemDesc(const char* text);
void ItemSep();
void ItemFuncs(VfvCP before, VfvCP after);
void SetNextItem(int tag);

View File

@ -294,7 +294,7 @@ extern GWin gwin;
#define M_CLOSE 4 // close menu after select func
#define M_CLALL 8 // close all menus when selected
#define M_CLOSB 16 // close menu before select func
#define M_SEPAR (32 + M_NOSEL) // item is separator
// ------------------------------------------------------------------
// Menutype definitions for wmenuend()

View File

@ -215,6 +215,24 @@ static void disp_item(_item_t *witem,int bar)
textend = gwin.cmenu->textpos+strlen(p)-1;
wgotoxy(witem->wrow,wcol=witem->wcol);
// display separators
if (witem->fmask & M_SEPAR)
{
const int &border = gwin.active->border;
const int &btype = gwin.active->btype;
const int &attr = gwin.active->loattr;
vatch line = vcatch(_box_table(btype, 1), attr);
if (border) *ptr++ = vcatch(_box_table(btype, 9), attr);
for (i = 0; i < width; i++) *ptr++ = line;
if (border) *ptr = vcatch(_box_table(btype, 10), attr);
int row = gwin.active->srow + witem->wrow + border;
int col = gwin.active->scol + wcol;
vputws(row, col, (vatch*)buf, width+2);
}
else
{
// display menu item including selection bar
for(i=0; i<width; i++) {
@ -247,6 +265,7 @@ static void disp_item(_item_t *witem,int bar)
// Display complete buffer
wprintws(witem->wrow, wcol, (vatch*)buf, width);
}
// display text description, if one exists
if((witem->desc!=NULL) and dispdesc) {

View File

@ -271,6 +271,14 @@ void GMnu::ItemDesc(const char* text) {
}
// ------------------------------------------------------------------
void GMnu::ItemSep()
{
Item(-1, " ", M_SEPAR, NULL, 0);
}
// ------------------------------------------------------------------
void GMnu::ItemFuncs(VfvCP before, VfvCP after) {