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, VfvCP select, int fmask=M_CLOSE);
void Item(int tag, const char* text, int fmask, VfvCP select, gkey hotkey=0); void Item(int tag, const char* text, int fmask, VfvCP select, gkey hotkey=0);
void ItemDesc(const char* text); void ItemDesc(const char* text);
void ItemSep();
void ItemFuncs(VfvCP before, VfvCP after); void ItemFuncs(VfvCP before, VfvCP after);
void SetNextItem(int tag); void SetNextItem(int tag);

View File

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

View File

@ -215,38 +215,57 @@ static void disp_item(_item_t *witem,int bar)
textend = gwin.cmenu->textpos+strlen(p)-1; textend = gwin.cmenu->textpos+strlen(p)-1;
wgotoxy(witem->wrow,wcol=witem->wcol); wgotoxy(witem->wrow,wcol=witem->wcol);
// display menu item including selection bar // display separators
for(i=0; i<width; i++) { 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);
// see if currently in bar region. if so, then use if (border) *ptr++ = vcatch(_box_table(btype, 9), attr);
// a space for the character. otherwise use the for (i = 0; i < width; i++) *ptr++ = line;
// character from the current position in the string if (border) *ptr = vcatch(_box_table(btype, 10), attr);
ch = ((i<gwin.cmenu->textpos) or (i>textend)) ? ' ' : (*p++);
// select attribute of character to be displayed based upon if int row = gwin.active->srow + witem->wrow + border;
// selection bar was specified, if the menu item is non-selectable, int col = gwin.active->scol + wcol;
// if the character is a tag character, or none of the above. vputws(row, col, (vatch*)buf, width+2);
if(bar)
chattr = gwin.cmenu->barattr;
else if(witem->fmask&M_NOSEL)
chattr = gwin.cmenu->noselattr;
else if((ch==witem->schar) and not found) {
found = YES;
chattr = gwin.cmenu->scharattr;
}
else
chattr = gwin.cmenu->textattr;
// display character in selected attribute
//wprintc(witem->wrow,wcol++,chattr,ch);
// Build menu line buffer
*ptr++ = vcatch(ch,chattr);
} }
else
{
// display menu item including selection bar
for(i=0; i<width; i++) {
// Display complete buffer // see if currently in bar region. if so, then use
wprintws(witem->wrow, wcol, (vatch*)buf, width); // a space for the character. otherwise use the
// character from the current position in the string
ch = ((i<gwin.cmenu->textpos) or (i>textend)) ? ' ' : (*p++);
// select attribute of character to be displayed based upon if
// selection bar was specified, if the menu item is non-selectable,
// if the character is a tag character, or none of the above.
if(bar)
chattr = gwin.cmenu->barattr;
else if(witem->fmask&M_NOSEL)
chattr = gwin.cmenu->noselattr;
else if((ch==witem->schar) and not found) {
found = YES;
chattr = gwin.cmenu->scharattr;
}
else
chattr = gwin.cmenu->textattr;
// display character in selected attribute
//wprintc(witem->wrow,wcol++,chattr,ch);
// Build menu line buffer
*ptr++ = vcatch(ch,chattr);
}
// Display complete buffer
wprintws(witem->wrow, wcol, (vatch*)buf, width);
}
// display text description, if one exists // display text description, if one exists
if((witem->desc!=NULL) and dispdesc) { 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) { void GMnu::ItemFuncs(VfvCP before, VfvCP after) {