Commit 263cfc45 authored by Claes Sjofors's avatar Claes Sjofors

Wb menu methods, subclass override of method implemented

parent 65e7eefd
......@@ -3227,6 +3227,9 @@ GtkWidget *WttGtk::build_submenu( GtkWidget *Parent, int MenuType,
for (; Items[*idx].Level != 0 && Items[*idx].Level >= Level; (*idx)++) {
if ( Items[*idx].Disabled)
continue;
if (Items[*idx].Item == ldh_eMenuItem_Cascade) {
if (MenuType == MENU_OPTION) {
printf("You can't have submenus from option menu items.");
......
......@@ -2452,6 +2452,9 @@ Widget WttMotif::build_submenu( Widget Parent, int MenuType,
Level = Items[*idx].Level;
for (; Items[*idx].Level != 0 && Items[*idx].Level >= Level; (*idx)++) {
if ( Items[*idx].Disabled)
continue;
if (Items[*idx].Item == ldh_eMenuItem_Cascade) {
if (MenuType == MENU_OPTION) {
XtWarning("You can't have submenus from option menu items.");
......
......@@ -349,6 +349,7 @@ struct ldh_s_MenuItem {
ldh_mMenuFlags Flags;
pwr_tStatus (*Method)();
pwr_tObjid MenuObject;
int Disabled;
};
#ifdef __cplusplus
......
......@@ -923,6 +923,23 @@ void wb_session::getAllMenuItems( ldh_sMenuCall *ip, ldh_sMenuItem **Item, wb_cd
}
else if ( o->cid() == pwr_eClass_MenuButton) {
mbp = (pwr_sMenuButton *)o_body;
if ( Level == 1) {
// Check if method is overridden, ie name already exist
for ( int i = 0; i < *nItems; i++) {
if ( ldh_lMenuItem[i].Level == Level &&
strcmp( ldh_lMenuItem[i].Name, mbp->ButtonName) == 0) {
ldh_lMenuItem[i].Disabled = 1;
for ( int j = i + 1; j < *nItems; j++) {
if ( ldh_lMenuItem[j].Level > ldh_lMenuItem[i].Level)
ldh_lMenuItem[j].Disabled = 1;
else if ( ldh_lMenuItem[j].Level == ldh_lMenuItem[i].Level)
break;
}
}
}
}
(*Item)->Level = Level;
(*Item)->Item = ldh_eMenuItem_Button;
(*Item)->MenuObject = o->oid();
......@@ -952,6 +969,23 @@ void wb_session::getAllMenuItems( ldh_sMenuCall *ip, ldh_sMenuItem **Item, wb_cd
(*nItems)++;
} else if (o->cid() == pwr_eClass_MenuCascade) {
mcp = (pwr_sMenuCascade *)o_body;
if ( Level == 1) {
// Check if method is overridden, ie name already exist
for ( int i = 0; i < *nItems; i++) {
if ( ldh_lMenuItem[i].Level == Level &&
strcmp( ldh_lMenuItem[i].Name, mcp->ButtonName) == 0) {
ldh_lMenuItem[i].Disabled = 1;
for ( int j = i + 1; j < *nItems; j++) {
if ( ldh_lMenuItem[j].Level > ldh_lMenuItem[i].Level)
ldh_lMenuItem[j].Disabled = 1;
else if ( ldh_lMenuItem[j].Level == ldh_lMenuItem[i].Level)
break;
}
}
}
}
(*Item)->Level = Level;
(*Item)->Item = ldh_eMenuItem_Cascade;
(*Item)->Flags.f.Sensitive = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment