Beispiel #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 );
        }
    }
}
Beispiel #2
0
Bool WSetEditWindowMenuEntry( WMenuEditInfo *einfo, WMenuEntry *entry )
{
    Bool        ok;
    Bool        pop_sep;
    MenuFlags   flags;
    uint_16     id;
    char        *text;

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

    if( ok ) {
        if( entry->item->IsPopup ) {
            flags = entry->item->Item.Popup.ItemFlags;
            text = entry->item->Item.Popup.ItemText;
        } else {
            flags = entry->item->Item.Normal.ItemFlags;
            id = entry->item->Item.Normal.ItemID;
            text = entry->item->Item.Normal.ItemText;
        }
        ok = WSetEditWindowText( einfo->edit_dlg, flags, text );
    }

    if( ok ) {
        ok = WSetEditWindowFlags( einfo->edit_dlg, flags, FALSE );
    }

    if( ok ) {
        pop_sep = (entry->item->IsPopup || (flags & MENU_SEPARATOR));
        ok = WSetEditWindowID( einfo->edit_dlg, id, pop_sep, entry->symbol );
    }

    return( ok );
}
Beispiel #3
0
void WDoHandleSelChange( WAccelEditInfo *einfo, bool change, bool reset )
{
    HWND        lbox;
    box_pos     pos;
    WAccelEntry *entry;
    bool        mod;

    if( einfo == NULL ) {
        return;
    }

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

    pos = (box_pos)SendMessage( lbox, LB_GETCURSEL, 0, 0 );
    if( pos != LB_ERR ) {
        entry = (WAccelEntry *)SendMessage( lbox, LB_GETITEMDATA, pos, 0 );
    } else {
        entry = NULL;
    }

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

    if( entry != NULL ) {
        if( change ) {
            uint_16 id;
            if( entry->is32bit ) {
                id = entry->u.entry32.Id;
            } else {
                id = (uint_16)entry->u.entry.Id;
            }
            WSetEditWindowID( einfo->edit_dlg, entry->symbol, id );
        } else {
            WSetEditWindowKeyEntry( einfo, entry );
        }
    }

    einfo->current_entry = entry;
    einfo->current_pos = (pos == LB_ERR) ? -1 : pos;
    if ( pos != LB_ERR ) {
        SendMessage ( lbox, LB_SETCURSEL, pos, 0 );
    }
}
Beispiel #4
0
bool WSetEditWindowKeyEntry( WAccelEditInfo *einfo, WAccelEntry *entry )
{
    bool    ok;
    uint_16 key, flags, id;

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

    if( ok ) {
        if( entry->is32bit ) {
            key = entry->u.entry32.Ascii;
            flags = entry->u.entry32.Flags;
            id = entry->u.entry32.Id;
        } else {
            key = entry->u.entry.Ascii;
            flags = entry->u.entry.Flags;
            id = (uint_16)entry->u.entry.Id;
        }
        ok = WSetEditWindowKey( einfo->edit_dlg, key, flags );
        if( !ok ) {
            WSetStatusByID( einfo->wsb, -1, W_INVALIDACCEL );
            memcpy( entry, &DefaultEntry, sizeof( WAccelEntry ) );
            key = entry->u.entry.Ascii;
            flags = entry->u.entry.Flags;
            id = (uint_16)entry->u.entry.Id;
            ok = WSetEditWindowKey( einfo->edit_dlg, key, flags );
        }
    }

    if( ok ) {
        ok = WSetEditWindowID( einfo->edit_dlg, entry->symbol, id );
    }

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

    return( ok );
}
Beispiel #5
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 );
    }
}
Beispiel #6
0
Bool WInsertStringEntry( WStringEditInfo *einfo )
{
    HWND                lbox;
    Bool                ok;
    Bool                replace;
    WStringBlock        *block;
    uint_16             id;
    char                *text;
    char                *symbol;
    int                 pos;

    text = NULL;
    symbol = NULL;
    replace = FALSE;

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

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

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

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

    if( ok ) {
        if( id == 0 ) {
            id = DEFAULT_STRING_ID;
        }
        block = WInsertStringData( einfo, id, text, symbol, &replace );
        ok = (block != NULL);
    }

    if( ok ) {
        pos = WFindStringPos( einfo->tbl, id );
        ok = (pos != -1);
    }

    if( ok ) {
        if( replace ) {
            SendMessage( lbox, LB_DELETESTRING, pos, 0 );
        }
        ok = WAddEditWinLBoxEntry( einfo, block, id, pos );
    }


    if( ok ) {
        WSetEditWindowID( einfo->edit_dlg, id, block->symbol[id & 0xf] );
        ok = (SendMessage( lbox, LB_SETCURSEL, pos, 0 ) != LB_ERR);
        if( ok ) {
            einfo->current_block = block;
            einfo->current_string = id;
            einfo->current_pos = pos;
#if 0
            einfo->current_block = NULL;
            einfo->current_string = 0;
            einfo->current_pos = -1;
            WHandleSelChange( einfo );
#endif
        }
    }

    if( ok ) {
        SetFocus( GetDlgItem( einfo->edit_dlg, IDM_STREDTEXT ) );
        SendDlgItemMessage( einfo->edit_dlg, IDM_STREDTEXT, EM_SETSEL,
                            GET_EM_SETSEL_MPS( 0, -1 ) );
    }

    if( symbol != NULL ) {
        WMemFree( symbol );
    }

    if( text != NULL ) {
        WMemFree( text );
    }

    return( ok );
}