Ejemplo n.º 1
0
static Bool WInitEditWindow( WMenuEditInfo *einfo )
{
    HWND    lbox;
    Bool    ok;

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

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

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

    if( ok ) {
        WSetEditWindowControls( einfo, einfo->menu->first_entry );
        if( einfo->menu->first_entry != NULL ) {
            ok = WSetEditWindowMenuEntry( einfo, einfo->menu->first_entry );
            if( ok ) {
                lbox = GetDlgItem( einfo->edit_dlg, IDM_MENUEDLIST );
                ok = (SendMessage( lbox, LB_SETCURSEL, 0, 0 ) != LB_ERR);
                einfo->current_entry = einfo->menu->first_entry;
                einfo->current_pos = 0;
            }
        } else {
            CheckDlgButton( einfo->edit_dlg, IDM_MENUEDPOPUP, TRUE );
        }
    }

    return( ok );
}
Ejemplo n.º 2
0
static void handleLoadSymbols( WAccelEditInfo *einfo )
{
    char        *file;

    file = WLoadSymbols( &einfo->info->symbol_table, einfo->info->symbol_file,
                         einfo->win, TRUE );
    if( file == NULL ) {
        return;
    }

    if( einfo->info->symbol_file != NULL ) {
        WRMemFree( einfo->info->symbol_file );
    }
    einfo->info->symbol_file = file;

    // lookup the id associated with the symbol for all entries
    WResolveAllEntrySymIDs( einfo );

    // look for the symbol matching the id for all entries
    WResolveAllEntrySymbols( einfo );

    WInitEditWindowListBox( einfo );

    if( einfo->current_pos != -1 ) {
        SendDlgItemMessage( einfo->edit_dlg, IDM_ACCEDLIST,
                            LB_SETCURSEL, einfo->current_pos, 0 );
    }

    WRAddSymbolsToComboBox( einfo->info->symbol_table, einfo->edit_dlg,
                            IDM_ACCEDCMDID, WR_HASHENTRY_ALL );

    einfo->info->modified = true;

    WDoHandleSelChange( einfo, FALSE, TRUE );
}
Ejemplo n.º 3
0
static bool WInitEditWindow( WAccelEditInfo *einfo )
{
    HWND    lbox;
    bool    ok;

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

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

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

    if( ok ) {
        if( einfo->tbl->first_entry != NULL ) {
            ok = WSetEditWindowKeyEntry( einfo, einfo->tbl->first_entry );
            if( ok ) {
                lbox = GetDlgItem( einfo->edit_dlg, IDM_ACCEDLIST );
                ok = (SendMessage( lbox, LB_SETCURSEL, 0, 0 ) != LB_ERR);
                einfo->current_entry = einfo->tbl->first_entry;
                einfo->current_pos = 0;
            }
        }
    }

    return( ok );
}
Ejemplo n.º 4
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 );
}
Ejemplo n.º 5
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 );
}
Ejemplo n.º 6
0
void WDoHandleSelChange( WMenuEditInfo *einfo, Bool change, Bool reset )
{
    HWND        lbox;
    LRESULT     index;
    WMenuEntry  *entry;
    Bool        reinit;
    Bool        mod;

    if( einfo == NULL ) {
        return;
    }

    reinit = FALSE;

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

    index = SendMessage( lbox, LB_GETCURSEL, 0, 0 );
    if( index != LB_ERR ) {
        entry = (WMenuEntry *)SendMessage( lbox, LB_GETITEMDATA, (WPARAM)index, 0 );
    } else {
        entry = NULL;
    }

    if( einfo->current_entry != NULL && !reset ) {
        mod = WGetEditWindowMenuEntry( einfo, einfo->current_entry, TRUE, NULL );
        if( mod && einfo->current_pos != -1 ) {
            if( change || WQueryChangeEntry( einfo ) ) {
                WGetEditWindowMenuEntry( einfo, einfo->current_entry, FALSE, &reinit );
                einfo->info->modified = TRUE;
                if( reinit ) {
                    WInitEditWindowListBox( einfo );
                } else {
                    SendMessage( lbox, LB_DELETESTRING, einfo->current_pos, 0 );
                    WAddEditWinLBoxEntry( lbox, einfo->current_entry, einfo->current_pos );
                    WModifyEntryInPreview( einfo, einfo->current_entry );
                }
            }
        }
    }

    WSetEditWindowControls( einfo, entry );
    if( entry != NULL ) {
        if( !change || reinit ) {
            WSetEditWindowMenuEntry( einfo, entry );
        } else {
            uint_16     id;
            Bool        pop_sep;
            MenuFlags   flags;
            if( entry->item->IsPopup ) {
                flags = entry->item->Item.Popup.ItemFlags;
            } else {
                flags = entry->item->Item.Normal.ItemFlags;
                id = entry->item->Item.Normal.ItemID;
            }
            pop_sep = (entry->item->IsPopup || (flags & MENU_SEPARATOR));
            WSetEditWindowID( einfo->edit_dlg, id, pop_sep, entry->symbol );
        }
    }

    einfo->current_entry = entry;
    einfo->current_pos = (index == LB_ERR ? -1 : index);
    if( index != LB_ERR ) {
        SendMessage( lbox, LB_SETCURSEL, (WPARAM)index, 0 );
    }
}