예제 #1
0
Bool WGetEditWindowMenuEntry( WMenuEditInfo *einfo, WMenuEntry *entry,
                              Bool test_mod, Bool *reset )
{
    MenuFlags   flags;
    MenuFlags   iflags;
    uint_16     id;
    char        *text;
    char        *symbol;
    Bool        ok;

    flags = 0;
    id = 0;
    text = NULL;
    symbol = NULL;

    if( reset ) {
        *reset = FALSE;
    }

    ok = (einfo != NULL && einfo->edit_dlg != NULL && entry != NULL);

    if( ok ) {
        ok = WGetEditWindowFlags( einfo->edit_dlg, &flags );
    }

    if( ok ) {
        if( !(flags & MENU_SEPARATOR) ) {
            ok = WGetEditWindowText( einfo->edit_dlg, &text );
        }
    }

    if( ok ) {
        if( !(flags & MENU_POPUP) ) {
            ok = WGetEditWindowID( einfo->edit_dlg, &symbol, &id,
                                   einfo->info->symbol_table,
                                   einfo->combo_change );
        }
    }

    /* check if anything was actually modified */
    if( ok ) {
        // make sure the symbol info did not change
        ok = (entry->symbol == NULL && symbol != NULL) ||
             (entry->symbol != NULL && symbol == NULL);
        if( !ok ) {
            ok = symbol && stricmp( entry->symbol, symbol );
            if( !ok ) {
                iflags = entry->item->Item.Popup.ItemFlags;
                iflags &= ~MENU_ENDMENU;
                ok = (iflags != flags);
                if( !ok ) {
                    if( flags & MENU_POPUP ) {
                        ok = strcmp( entry->item->Item.Popup.ItemText, text );
                    } else if( flags & MENU_SEPARATOR ) {
                        ok = FALSE;
                    } else {
                        ok = (entry->item->Item.Normal.ItemID != id ||
                              strcmp( entry->item->Item.Normal.ItemText, text ));
                    }
                }
            }
        }
        if( test_mod ) {
            return( ok );
        }
    }

    if( ok ) {
        if( entry->item->IsPopup ) {
            if( entry->child != NULL && (flags & MENU_POPUP) == 0 ) {
                ok = WQueryNukePopup( einfo );
            }
        }
    }

    if( ok ) {
        if( entry->item->IsPopup ) {
            if( (flags & MENU_POPUP) == 0 ) {
                if( reset ) {
                    *reset = TRUE;
                }
                entry->preview_popup = (HMENU)NULL;
                if( entry->child != NULL ) {
                    WFreeMenuEntries( entry->child );
                    entry->child = NULL;
                }
            }
            if( entry->item->Item.Popup.ItemText ) {
                WMemFree( entry->item->Item.Popup.ItemText );
            }
        } else {
            // if the item is being changed from a normal item into a popup
            // or separator then reset the preview
            if( (flags & MENU_POPUP) != 0 || (flags & MENU_SEPARATOR) != 0 ) {
                if( reset ) {
                    *reset = TRUE;
                }
                entry->preview_popup = (HMENU)NULL;
            }
            if( entry->item->Item.Normal.ItemText ) {
                WMemFree( entry->item->Item.Normal.ItemText );
            }
        }
        if( entry->symbol != NULL ) {
            WMemFree( entry->symbol );
        }
        entry->item->IsPopup = ((flags & MENU_POPUP) != 0);
        if( entry->item->IsPopup ) {
            entry->item->Item.Popup.ItemText = text;
            entry->item->Item.Popup.ItemFlags = flags;
        } else {
            // if the flags are zero - indicating a normal item - and the
            // id is also zero then change it to the default
            // flag == id == 0 indicates a separator
            if( flags == 0 && id == 0 ) {
                id = DEFAULT_MENU_ID;
            }
            entry->item->Item.Normal.ItemText = text;
            entry->item->Item.Normal.ItemID = id;
            entry->item->Item.Normal.ItemFlags = flags;
        }
        entry->symbol = symbol;
    } else {
        if( symbol != NULL ) {
            WMemFree( symbol );
        }
        if( text != NULL ) {
            WMemFree( text );
        }
    }

    return( ok );
}
예제 #2
0
bool WGetEditWindowKeyEntry( WAccelEditInfo *einfo, WAccelEntry *entry,
                             bool check_mod )
{
    bool        ok;
    bool        force_ascii;
    uint_16     key, flags, id;
    char        *symbol;

    symbol = NULL;
    flags = 0;
    force_ascii = FALSE;

    ok = (einfo != NULL && einfo->edit_dlg != NULL && entry != NULL);

    if( ok ) {
        ok = WGetEditWindowFlags( einfo->edit_dlg, &flags );
    }

    if( ok ) {
        ok = WGetEditWindowKey( einfo->edit_dlg, &key, &flags, &force_ascii );
        if( !ok ) {
            WSetStatusByID( einfo->wsb, -1, W_INVALIDACCELKEY );
        }
    }

    if( ok ) {
        ok = WGetEditWindowID( einfo->edit_dlg, &symbol, &id,
                               einfo->info->symbol_table, einfo->combo_change );
    }

    if( ok ) {
        if( force_ascii ) {
            flags &= ~(ACCEL_VIRTKEY | ACCEL_SHIFT | ACCEL_CONTROL | ACCEL_ALT);
        }
    }

    /* check if anything was actually modified */
    if( ok ) {
        // make sure the symbol info did not change
        ok = (entry->symbol == NULL && symbol != NULL) ||
             (entry->symbol != NULL && symbol == NULL);
        if( !ok ) {
            ok = (symbol != NULL && stricmp( entry->symbol, symbol ));
            if( !ok ) {
                if( entry->is32bit ) {
                    ok = (entry->u.entry32.Ascii != key || entry->u.entry32.Flags != flags ||
                          entry->u.entry32.Id != id);
                } else {
                    ok = (entry->u.entry.Ascii != key || entry->u.entry.Flags != (uint_8)flags ||
                          entry->u.entry.Id != id);
                }
            }
        }
        if( check_mod ) {
            return( ok );
        }
    }

    if( ok ) {
        if( entry->is32bit ) {
            entry->u.entry32.Ascii = key;
            entry->u.entry32.Flags = flags;
            entry->u.entry32.Id = id;
        } else {
            entry->u.entry.Ascii = key;
            entry->u.entry.Flags = (uint_8)flags;
            entry->u.entry.Id = id;
        }
        if( entry->symbol != NULL ) {
            WRMemFree( entry->symbol );
        }
        entry->symbol = symbol;
    } else {
        if( symbol != NULL ) {
            WRMemFree( symbol );
        }
    }

    return( ok );
}