コード例 #1
0
ファイル: wedit.c プロジェクト: Ukusbobra/open-watcom-v2
Bool WSetEditWindowText( HWND dlg, MenuFlags flags, char *text )
{
    Bool    ok;
    char    *t;
    char    *n;

    ok = (dlg != (HWND)NULL);

    if( ok ) {
        if( flags & MENU_SEPARATOR ) {
            t = "";
        } else {
            t = text;
            if( t == NULL ) {
                t = "";
            }
        }
    }

    if( ok ) {
        n = WConvertStringFrom( t, "\t\x8", "ta" );
        if( n != NULL ) {
            ok = WSetEditWithStr( GetDlgItem( dlg, IDM_MENUEDTEXT ), n );
            WMemFree( n );
        } else {
            ok = WSetEditWithStr( GetDlgItem( dlg, IDM_MENUEDTEXT ), t );
        }
    }

    return( ok );
}
コード例 #2
0
ファイル: wstr2rc.c プロジェクト: Ukusbobra/open-watcom-v2
static Bool WWriteStringEntry( WStringBlock *block, uint_16 string_id, FILE *fp )
{
    char        *strtext;
    char        *text;
    Bool        ok;

    strtext = NULL;

    text = WResIDNameToStr( block->block.String[string_id & 0xf] );
    ok = (text != NULL);

    if( ok ) {
        strtext = WConvertStringFrom( text, "\t\n\"\\", "tn\"\\" );
        ok = (strtext != NULL);
    }

    if( ok ) {
        if( block->symbol[string_id & 0xf] ) {
            fprintf( fp, "    %s, \"%s\"\n",
                     block->symbol[string_id & 0xf], strtext );
        } else {
            fprintf( fp, "    %u, \"%s\"\n", string_id, strtext );
        }
    }

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

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

    return( ok );
}
コード例 #3
0
static Bool WWriteMenuEntryItem( WMenuEntry *entry, FILE *fp, int depth )
{
    Bool        ok;
    char        *itemname;
    char        *text;
    char        *flagtext;

    text = NULL;
    flagtext = NULL;
    itemname = NULL;

    ok = ( entry && fp );

    if( ok ) {
        depth++;
        fprintf( fp, "%*s", DEPTH_MULT*depth, "" );
    }

    if( ok ) {
        if( !( entry->item->Item.Normal.ItemFlags & MENU_SEPARATOR ) ) {
            ok = FALSE;
            itemname = WGETMENUITEMTEXT(entry->item);
            if( itemname != NULL ) {
                text = WConvertStringFrom( itemname, "\t\x8\"\\", "ta\"\\" );
                ok = ( text != NULL );
            }
        }
    }

    if( ok ) {
        if( !( entry->item->Item.Normal.ItemFlags & MENU_SEPARATOR ) ) {
            ok = WSetFlagsText( entry->item->Item.Normal.ItemFlags, &flagtext );
        }
    }

    if( ok ) {
        if( entry->item->Item.Normal.ItemFlags & MENU_POPUP ) {
            fprintf( fp, "POPUP \"%s\"%s\n", text, flagtext );
        } else if( entry->item->Item.Normal.ItemFlags & MENU_SEPARATOR ) {
            fprintf( fp, "MENUITEM SEPARATOR\n" );
        } else {
            if( entry->symbol ) {
                fprintf( fp, "MENUITEM \"%s\"\t%s%s\n", text, entry->symbol,
                         flagtext );
            } else {
                fprintf( fp, "MENUITEM \"%s\"\t%u%s\n", text,
                         entry->item->Item.Normal.ItemID, flagtext );
            }
        }
    }

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

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

    return( ok );
}
コード例 #4
0
Bool WAddEditWinLBoxEntry( WStringEditInfo *einfo, WStringBlock *block,
                           uint_16 string_id, int pos )
{
    Bool    ok;
    char    *n;
    char    *lbtext;
    char    *text;
    char    idtext[35];
    int     tlen, idlen;
    HWND    lbox;

    text = NULL;
    lbtext = NULL;
    n = NULL;

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

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

    if( ok ) {
        text = WResIDNameToStr( block->block.String[string_id & 0xf] );
        ok = (text != NULL);
    }

    if( ok ) {
        if( block->symbol[string_id & 0xf] != NULL ) {
            strncpy( idtext, block->symbol[string_id & 0xf], MAX_ID_CHARS );
            idtext[MAX_ID_CHARS] = '\0';
        } else {
            utoa( (int)string_id, idtext, 10 );
        }
        idlen = strlen( idtext );
        idtext[idlen] = '\t';
        ++idlen;
        idtext[idlen] = '\0';
        tlen = strlen( text );
        lbtext = (char *)WMemAlloc( tlen + idlen + 4 );
        ok = (lbtext != NULL);
    }

    if( ok ) {
        memcpy( lbtext, idtext, idlen );
        lbtext[idlen] = ' ';
        lbtext[idlen + 1] = '\"';
        memcpy( lbtext + idlen + 2, text, tlen );
        lbtext[tlen + idlen + 2] = '\"';
        lbtext[tlen + idlen + 3] = '\0';
        n = WConvertStringFrom( lbtext, "\n", "n" );
        ok = WInsertLBoxWithStr( lbox, pos, n, (void *)string_id );
    }

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

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

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

    return( ok );
}