From df30d36fe59ad2c58a1bac7233070f77926976fa Mon Sep 17 00:00:00 2001 From: Ianos Gnatiuc Date: Mon, 28 Nov 2005 16:27:49 +0000 Subject: [PATCH] Added separator item type for menus --- goldlib/gall/gmnubase.h | 1 + goldlib/gall/gwinall.h | 2 +- goldlib/gall/gwinmenu.cpp | 75 ++++++++++++++++++++++++--------------- goldlib/gall/gwinmnub.cpp | 8 +++++ 4 files changed, 57 insertions(+), 29 deletions(-) diff --git a/goldlib/gall/gmnubase.h b/goldlib/gall/gmnubase.h index 65e5a98..ed01e83 100644 --- a/goldlib/gall/gmnubase.h +++ b/goldlib/gall/gmnubase.h @@ -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); diff --git a/goldlib/gall/gwinall.h b/goldlib/gall/gwinall.h index e5d62da..d81dd03 100644 --- a/goldlib/gall/gwinall.h +++ b/goldlib/gall/gwinall.h @@ -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() diff --git a/goldlib/gall/gwinmenu.cpp b/goldlib/gall/gwinmenu.cpp index e22c60f..c3feae9 100644 --- a/goldlib/gall/gwinmenu.cpp +++ b/goldlib/gall/gwinmenu.cpp @@ -215,38 +215,57 @@ static void disp_item(_item_t *witem,int bar) textend = gwin.cmenu->textpos+strlen(p)-1; wgotoxy(witem->wrow,wcol=witem->wcol); - // display menu item including selection bar - for(i=0; ifmask & 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 - // a space for the character. otherwise use the - // character from the current position in the string - ch = ((itextpos) or (i>textend)) ? ' ' : (*p++); + 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); - // 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); + 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; iwrow, wcol, (vatch*)buf, width); + // see if currently in bar region. if so, then use + // a space for the character. otherwise use the + // character from the current position in the string + ch = ((itextpos) 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 if((witem->desc!=NULL) and dispdesc) { diff --git a/goldlib/gall/gwinmnub.cpp b/goldlib/gall/gwinmnub.cpp index 1e2e4b5..b83d432 100644 --- a/goldlib/gall/gwinmnub.cpp +++ b/goldlib/gall/gwinmnub.cpp @@ -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) {