Exemple #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 );
}
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 );
}
Exemple #3
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 );
    }
}