Exemple #1
0
void WHandleClear( WMenuEditInfo *einfo )
{
    if( einfo->menu != NULL && einfo->menu->first_entry != NULL ) {
        if( WQueryClearRes( einfo ) ) {
            WSetEditWindowText( einfo->edit_dlg, 0, NULL );
            WSetEditWindowID( einfo->edit_dlg, 0, TRUE, NULL );
            WResetEditWindowFlags( einfo->edit_dlg );
            SendDlgItemMessage( einfo->edit_dlg, IDM_MENUEDLIST, LB_RESETCONTENT, 0, 0 );
            WFreeMenuEntries( einfo->menu->first_entry );
            einfo->menu->first_entry = NULL;
            einfo->current_entry = NULL;
            einfo->current_pos = -1;
            einfo->first_preview_id = FIRST_PREVIEW_ID;
            WResetPrevWindowMenu( einfo );
            if( einfo->info->stand_alone ) {
                if( einfo->file_name != NULL ) {
                    WMemFree( einfo->file_name );
                    einfo->file_name = NULL;
                    WSetEditTitle( einfo );
                }
                if( einfo->info->symbol_table != NULL ) {
                    WRFreeHashTable( einfo->info->symbol_table );
                    einfo->info->symbol_table = WRInitHashTable();
                }
            }
            einfo->info->modified = TRUE;
            SetFocus( einfo->edit_dlg );
            WSetStatusByID( einfo->wsb, W_MENUCLEARMSG, -1 );
        }
    }
}
Exemple #2
0
bool WDeleteEditWinLBoxEntry( WMenuEditInfo *einfo, LRESULT pos, bool free_it )
{
    HWND        lbox;
    bool        ok;
    WMenuEntry  *entry;
    LRESULT     ret;
    LRESULT     count;

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

    if( ok ) {
        lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST );
        ok = ( lbox != NULL );
    }

    if( ok ) {
        count = SendMessage( lbox, LB_GETCOUNT, 0, 0 );
        ok = ( count != 0 && count != LB_ERR && pos < count );
    }

    if( ok ) {
        entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)pos, 0 );
        if( entry != NULL ) {
            if( free_it ) {
                ok = WRemoveMenuEntry( einfo->menu, entry );
                if( ok ) {
                    WFreeMenuEntries( entry->child );
                    WFreeMenuEntry( entry );
                }
            }
        } else {
            ok = false;
        }
    }

    if( ok ) {
        einfo->info->modified = true;
        if( free_it ) {
            ret = WInitEditWindowListBox( einfo );
        } else {
            ret = SendMessage( lbox, LB_DELETESTRING, (WPARAM)pos, 0 );
        }
        ok = ( ret != LB_ERR );
    }

    if( ok ) {
        einfo->current_entry = NULL;
        einfo->current_pos = LB_ERR;
        if( pos > count - 2 )
            pos = count - 2;
        ok = ( SendMessage( lbox, LB_SETCURSEL, (WPARAM)pos, 0 ) != LB_ERR );
        if( ok ) {
            WHandleSelChange( einfo );
        } else {
            WSetEditWindowControls( einfo, NULL );
        }
    }

    return( ok );
}
static void WFreeMenuEntries( GUIRMenuEntry *entry )
{
    GUIRMenuEntry *e;

    while( entry ) {
        e = entry;
        entry = entry->next;
        if( e->child ) {
            WFreeMenuEntries ( e->child );
        }
        WFreeMenuEntry( e );
    }
}
Exemple #4
0
static Bool WShiftEntry( WMenuEditInfo *einfo, Bool left )
{
    WMenuEntry  *prev;
    WMenuEntry  *parent;
    WMenuEntry  *entry;
    LRESULT     ret;
    HWND        lbox;
    Bool        entry_removed;
    Bool        ok;

    entry_removed = FALSE;

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

    if( ok ) {
        lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST );
        ok = (lbox != NULL);
    }

    if( ok ) {
        ret = SendMessage( lbox, LB_GETCURSEL, 0, 0 );
        ok = (ret != LB_ERR);
    }

    if( ok ) {
        entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)ret, 0 );
        ok = (entry != NULL);
    }

    if( ok ) {
        parent = entry->parent;
        prev = entry->prev;
        ok = WRemoveMenuEntry( einfo->menu, entry );
        if( ok ) {
            entry_removed = TRUE;
        }
    }

    if( ok ) {
        if( left ) {
            ok = WInsertEntryIntoMenu( einfo, parent, parent->parent, entry, FALSE );
        } else {
            if( prev->child != NULL ) {
                parent = prev;
                for( prev = parent->child; prev != NULL && prev->next != NULL;
                     prev = prev->next );
                ok = WInsertEntryIntoMenu( einfo, prev, parent, entry, FALSE );
            } else {
                ok = WInsertEntryIntoMenu( einfo, prev, parent, entry, TRUE );
            }
        }
    }

    if( ok ) {
        ok = WInitEditWindowListBox( einfo );
    }

    if( ok ) {
        einfo->info->modified = TRUE;
        einfo->current_entry = NULL;
        einfo->current_pos = -1;
        ret = SendMessage( lbox, LB_SETCURSEL, (WPARAM)ret, 0 );
        ok = (ret != LB_ERR);
        if( ok ) {
            WHandleSelChange( einfo );
        }
    }

    if( !ok ) {
        if( entry_removed ) {
            WFreeMenuEntries( entry->child );
            WFreeMenuEntry( entry );
            WInitEditWindowListBox( einfo );
        }
    }

    return( ok );
}
Exemple #5
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 );
}