Beispiel #1
0
WdeResInfo *WdeCreateNewResource( char *title )
{
    WdeResInfo  *res_info;
    bool        ok;

    ok = ((res_info = WdeAllocResInfo()) != NULL);

    if( ok ) {
        ok = ((res_info->info = WRAllocWRInfo()) != NULL);
    }

    if( ok ) {
        res_info->hash_table = WRInitHashTable();
        ok = (res_info->hash_table != NULL);
    }

    if( ok ) {
        if( title != NULL ) {
            res_info->info->save_name = WdeStrDup( title );
            ok = (res_info->info->save_name != NULL);
        }
    }

    if( ok ) {
#ifdef __NT__
        res_info->is32bit = TRUE;
#else
        res_info->is32bit = FALSE;
#endif
        ok = WdeCreateResourceWindow( res_info, 0, title );
    }

    if( ok ) {
        ListAddElt( &WdeResList, (void *)res_info );
        if( !WdeIsDDE() || title == NULL ) {
            ok = (WdeCreateNewDialog( NULL, res_info->is32bit ) != NULL);
        }
    }

    if( ok ) {
        WdeCheckBaseScrollbars( FALSE );
    }

    if( res_info ) {
        if( ok ) {
            WdeSetResModified( res_info, FALSE );
        } else {
            WdeRemoveResource( res_info );
            res_info = NULL;
        }
    }

    return( res_info );
}
Beispiel #2
0
Bool WREOpenResource( char *fn )
{
    char                *name;
    WREResInfo          *res_info;
    WREGetFileStruct    gf;
    Bool                ok, got_name;

    res_info = NULL;
    name = NULL;
    got_name = FALSE;

    if( fn != NULL ) {
        if( WRFileExists( fn ) ) {
            ok = ((name = WREStrDup( fn )) != NULL);
        } else {
            ok = FALSE;
        }
    } else {
        gf.file_name = NULL;
        gf.title = WREResOpenTitle;
        gf.filter = WREResFilter;
        gf.save_ext = TRUE;
        ok = ((name = WREGetOpenFileName( &gf )) != NULL);
    }

    if( ok ) {
        got_name = TRUE;
        ok = ((res_info = WRELoadResource( name )) != NULL);
    }

    if( ok ) {
        WREFindAndLoadSymbols( res_info );
        ok = WRECreateResourceWindow( res_info );
    }

    if( ok ) {
        ListAddElt( &WREResList, (void *)res_info );
    } else {
        if( res_info != NULL ) {
            WREFreeResInfo( res_info );
            res_info = NULL;
        }
        if( got_name ) {
            WREDisplayErrorMsg( WRE_RESOURCESNOTLOADED );
        }
    }

    if( name != NULL ) {
        WREMemFree( name );
    }

    return( ok );
}
Beispiel #3
0
void WdeAddCustControlToCustLib( WdeCustLib *lib, WdeCustControl *control )
{
    LIST *end;

    if( lib->controls == NULL ) {
        ListAddElt( &lib->controls, (void *)control );
    } else {
        /* make sure item is inserted at end of list */
        WdeListLastElt( lib->controls, &end );
        ListInsertElt( end, (void *)control );
    }

    WRMemValidate( lib );
    WRMemValidate( control );
}
Beispiel #4
0
WREResInfo *WRECreateNewResource( char *filename )
{
    WREResInfo  *res_info;
    Bool        ok;

    ok = ((res_info = WREAllocResInfo()) != NULL);

    if( ok ) {
        res_info->info = WRAllocWRInfo();
        ok = (res_info->info != NULL);
    }

    if( ok ) {
        res_info->symbol_table = WRInitHashTable();
        ok = (res_info->symbol_table != NULL);
    }

    if( ok && filename != NULL ) {
        res_info->info->save_name = WREStrDup( filename );
        ok = (res_info->info->save_name != NULL);
    }

    if( ok ) {
#ifdef __NT__
        res_info->is32bit = TRUE;
#else
        res_info->is32bit = FALSE;
#endif
        if( res_info->is32bit ) {
            res_info->info->internal_type = WR_WINNTW_RES;
        } else {
            res_info->info->internal_type = WR_WIN16W_RES;
        }
        WREFindAndLoadSymbols( res_info );
        ok = WRECreateResourceWindow( res_info );
    }

    if( res_info != NULL ) {
        if( ok ) {
            ListAddElt( &WREResList, (void *)res_info );
        } else {
            WREFreeResInfo( res_info );
            res_info = NULL;
        }
    }

    return( res_info );
}
Beispiel #5
0
LIST *FMEDITAPI GetCurrObjectList( void )
/***************************************/
{
    /* return pointer to the current object */
    OBJPTR      currobj;
    OBJPTR      userobj;
    LIST        *objlist;

    objlist = NULL;
    for( currobj = GetEditCurrObject(); currobj != NULL; currobj = GetNextEditCurrObject( currobj ) ) {
        userobj = NULL;
        OBJ_DISPATCHER( currobj )( GET_OBJPTR, currobj, &userobj, NULL );
        if( userobj != NULL ) {
            ListAddElt( &objlist, userobj );
        }
    }
    return( objlist );
}
Beispiel #6
0
Bool WdeCreateWdePopupListItem( int num, HMENU menu, WdePopupHintItem *hint_items )
{
    WdePopupListItem *p;

    p = (WdePopupListItem *)WdeMemAlloc( sizeof( WdePopupListItem ) );

    if( p != NULL ) {
        p->num = num;
        p->menu = menu;
        p->hint_items = hint_items;
        if( WdeInitHintItems( num, menu, hint_items ) ) {
            ListAddElt( &WdePopupList, p );
        } else {
            WdeMemFree( p );
            return( FALSE );
        }
    } else {
        return( FALSE );
    }

    return( TRUE );
}
Beispiel #7
0
WdeDialogBoxInfo *WdeMem2DBI( const uint_8 *data, size_t size, bool is32bit )
{
    WdeDialogBoxInfo    *dbi;
    WdeDialogBoxControl *control;
    LIST                *prev_control;
    int                 index;
    const uint_8        *start;
    bool                ok;
    bool                is32bitEx = false;
    uint_16             sign0;
    uint_16             sign1;

    dbi = NULL;
    start = NULL;

    ok = (data != NULL && size != 0);

    if( ok ) {
        dbi = (WdeDialogBoxInfo *)WRMemAlloc( sizeof( WdeDialogBoxInfo ) );
        ok = (dbi != NULL);
    }


    if( ok ) {
        start = data;

        /* check if the dialog is extended by testing for the signature */
        U16FromMem( data, sign0 );
        U16FromMem( data, sign1 );
        is32bitEx = (sign0 == 0x0001 && sign1 == 0xFFFF);

        data = start;
        dbi->control_list = NULL;
        dbi->MemoryFlags = 0;
        dbi->dialog_header = WdeMem2DialogBoxHeader( &data, is32bit, is32bitEx );
        ok = (dbi->dialog_header != NULL);
    }

    if( ok ) {
        prev_control = NULL;
        for( index = 0; index < GETHDR_NUMITEMS( dbi->dialog_header ); index++ ) {
            if( is32bit ) {
                PADDING_SET( data, start );
            }
            control = WdeMem2DialogBoxControl( &data, is32bit, is32bitEx );
            if( control == NULL ) {
                ok = false;
                break;
            }
            if( prev_control == NULL ) {
                ListAddElt( &dbi->control_list, (void *)control );
                prev_control = dbi->control_list;
            } else {
                ListInsertElt( prev_control, (void *)control );
                prev_control = ListNext( prev_control );
            }
        }
    }

    if( ok ) {
        ok = ( size >= data - start );
    }

    if( !ok ) {
        if( dbi != NULL ) {
            WdeFreeDialogBoxInfo( dbi );
            dbi = NULL;
        }
    }

    return( dbi );
}
Beispiel #8
0
bool WdeOpenResource( char *fn )
{
    char                *name;
    WdeResInfo          *res_info;
    WdeGetFileStruct    gf;
    bool                ok, got_name;

    WdeSetWaitCursor( TRUE );

    res_info = NULL;
    name = NULL;
    got_name = FALSE;

    if( fn != NULL ) {
        if( WdeFileExists( fn ) ) {
            name = WdeStrDup( fn );
            gf.fn_offset = WRFindFnOffset( name );
        } else {
            return( FALSE );
        }
    } else {
        gf.file_name = NULL;
        gf.title = WdeResOpenTitle;
        gf.filter = WdeResOpenFilter;
        ok = ((name = WdeGetOpenFileName( &gf )) != NULL);
    }

    if( ok ) {
        got_name = TRUE;
        ok = ((res_info = WdeLoadResource( name )) != NULL);
    }

    if( ok ) {
        res_info->hash_table = WRInitHashTable();
        ok = (res_info->hash_table != NULL);
    }

    if( ok ) {
        if( res_info->info->internal_type != WR_DONT_KNOW ) {
            res_info->is32bit = WRIs32Bit( res_info->info->internal_type );
        } else {
            res_info->is32bit = WRIs32Bit( res_info->info->file_type );
        }
        ok = WdeAddDlgItems( res_info );
    }

    if( ok ) {
        WdeFindAndLoadSymbols( res_info );
        ok = WdeCreateResourceWindow( res_info, gf.fn_offset, NULL );
    }

    if( ok ) {
        if( WdeResInfoHasDialogs( res_info ) ) {
            WdeSelectDialog( res_info );
        } else {
            WdeDisplayErrorMsg( WDE_PRJHASNODIALOGS );
        }
        ListAddElt( &WdeResList, (void *)res_info );
        WdeSetResModified( res_info, FALSE );
        WdeCheckBaseScrollbars( FALSE );
    }

    if( !ok ) {
        if( res_info != NULL ) {
            WdeFreeResInfo( res_info );
            res_info = NULL;
        }
        if( got_name ) {
            WdeDisplayErrorMsg( WDE_RESOURCESNOTLOADED );
        }
    }

    if( name != NULL ) {
        WRMemFree( name );
    }

    WdeSetWaitCursor( FALSE );

    return( ok );
}
Beispiel #9
0
WdeDialogBoxInfo *WdeMem2DBI( uint_8 *data, uint_32 size, Bool is32bit )
{
    WdeDialogBoxInfo    *dbi;
    WdeDialogBoxControl *control;
    LIST                *prev_control;
    int                 index, pad;
    uint_8              *d;
    Bool                ok;
    Bool                is32bitEx = FALSE;
    uint_16             signa[2];

    dbi = NULL;

    ok = ( data && size );

    if( ok ) {
        d = data;
        dbi = (WdeDialogBoxInfo *) WdeMemAlloc( sizeof(WdeDialogBoxInfo) );
        ok = ( dbi != NULL );
    }


    if( ok ) {
        /* check if the dialog is extended by testing for the signature */
        memcpy(signa, data, sizeof(signa));
        is32bitEx = (signa[0] == 0x0001 && signa[1] == 0xFFFF);

        dbi->control_list  = NULL;
        dbi->MemoryFlags   = 0;
        if (is32bitEx) {
            dbi->dialog_header = WdeMem2DialogBoxExHeader( &data );
        } else {
            dbi->dialog_header = WdeMem2DialogBoxHeader( &data, is32bit );
        }
        ok = ( dbi->dialog_header != NULL );
    }

    if( ok ) {
        prev_control = NULL;
        for( index = 0; index < GETHDR_NUMITEMS(dbi->dialog_header); index++ ) {
            if( is32bit ) {
                pad = CALC_PAD( data - d, sizeof(uint_32) );
                data += pad;
            }
            control = WdeMem2DialogBoxControl( &data, is32bit, is32bitEx );
            if( control == NULL  ) {
                ok = FALSE;
                break;
            }
            if ( prev_control == NULL ) {
                ListAddElt( &(dbi->control_list), (void *) control);
                prev_control = dbi->control_list;
            } else {
                ListInsertElt( prev_control, (void *) control);
                prev_control = ListNext(prev_control);
            }
        }
    }

    if( ok ) {
        ok = ( size >= ( data - d ) );
    }

    if( !ok ) {
        if( dbi ) {
            WdeFreeDialogBoxInfo( dbi );
            dbi = NULL;
        }
    }

    return ( dbi );
}
Beispiel #10
0
Bool pleaseOpenFile( UINT msg )
{
    char                *filter;
    char                *title;
    char                *name;
    WREResInfo          *res_info;
    WREResInfo          *old_info;
    WREGetFileStruct    gf;
    uint_16             type;
    Bool                ok;

    old_info = WREGetCurrentRes();
    res_info = NULL;
    filter = NULL;
    title = NULL;
    name = NULL;

    if( msg == ACCEL_PLEASE_OPENME ) {
        filter = WREAccelFilter;
        title = WREAllocRCString( WRE_OPENACCEL );
        type = (uint_16)RT_ACCELERATOR;
    } else if( msg == MENU_PLEASE_OPENME ) {
        filter = WREMenuFilter;
        title = WREAllocRCString( WRE_OPENMENU );
        type = (uint_16)RT_MENU;
    } else if( msg == STRING_PLEASE_OPENME ) {
        filter = WREStringFilter;
        title = WREAllocRCString( WRE_OPENSTRING );
        type = (uint_16)RT_STRING;
    }

    ok = (filter != NULL && title != NULL);

    if( ok ) {
        gf.file_name = NULL;
        gf.title = title;
        gf.filter = filter;
        gf.save_ext = FALSE;
        ok = ((name = WREGetOpenFileName( &gf )) != NULL);
    }

    if( ok ) {
        ok = ((res_info = WRELoadResource( name )) != NULL);
    }

    if( ok ) {
        WREFindAndLoadSymbols( res_info );
        ok = WRECreateResourceWindow( res_info );
    }

    if( ok ) {
        ListAddElt( &WREResList, (void *)res_info );
    }

    if( ok ) {
        ok = (WREFindTypeNode( res_info->info->dir, type, NULL ) != NULL);
    }

    if( ok ) {
        ok = WRESetResNamesFromType( res_info, type, FALSE, NULL, 0 );
    }

    if( ok ) {
        ok = WREHandleResEdit();
    }

    if( ok ) {
        SendMessage( old_info->res_win, WM_CLOSE, 0, 0 );
    }

    if( !ok ) {
        if( res_info != NULL ) {
            WREFreeResInfo( res_info );
            res_info = NULL;
        }
    }

    if( name != NULL ) {
        WREMemFree( name );
    }

    if( title != NULL ) {
        WREFreeRCString( title );
    }

    return( ok );
}
Beispiel #11
0
WdeDialogBoxInfo *WdeLoadDialogFromRes( WdeResInfo *res_info,
                                        WResLangNode *lnode, bool is32bit )
{
    DialogExHeader32        h32ex;
    DialogBoxHeader32       h32;
    DialogBoxHeader         h16;

    DialogBoxControl        c16;
    DialogBoxControl32      c32;
    DialogBoxExControl32    c32ex;

    WdeDialogBoxInfo        *dlg_info;
    WResFileID              fid;
    WdeDialogBoxControl     *control;
    LIST                    *prev_control;
#if 0
    WdeDialogBoxControl     *nc;
    LIST                    *clist;
#endif
    int                     index;
    char                    *file_name;
    bool                    ok;

    dlg_info = NULL;
    fid = WRES_NIL_HANDLE;

    ok = (res_info != NULL && lnode != NULL);

    if( ok ) {
        file_name = res_info->info->tmp_file;
        dlg_info = (WdeDialogBoxInfo *)WRMemAlloc( sizeof( WdeDialogBoxInfo ) );
        ok = (dlg_info != NULL);
    }

    if( ok ) {
        dlg_info->dialog_header = WdeAllocDialogBoxHeader();
        ok = (dlg_info->dialog_header != NULL);
    }

    if( ok ) {
        dlg_info->dialog_header->is32bit = is32bit;
        dlg_info->control_list = NULL;
        dlg_info->MemoryFlags = 0;
        ok = ((fid = ResOpenFileRO( file_name )) != WRES_NIL_HANDLE);
    }

    if( ok ) {
        dlg_info->MemoryFlags = lnode->Info.MemoryFlags;
        ok = (ResSeek( fid, lnode->Info.Offset, SEEK_SET ) != -1);
    }

    if( ok ) {
        if( is32bit ) {
            /* JPK - check if its an extended dialog */
            dlg_info->dialog_header->is32bitEx = ResIsDialogEx( fid );
            ResSeek( fid, lnode->Info.Offset, SEEK_SET );

            if( dlg_info->dialog_header->is32bitEx ) {
                ok = !ResReadDialogExHeader32( &h32, &h32ex, fid );
            } else {
                ok = !ResReadDialogBoxHeader32( &h32, fid );
            }
        } else {
            ok = !ResReadDialogBoxHeader( &h16, fid );
        }
    }

    if( ok ) {
        if( is32bit ) {
            if( dlg_info->dialog_header->is32bitEx ) {
                dlg_info->dialog_header->FontWeight = h32ex.FontWeight;
                dlg_info->dialog_header->FontItalic = h32ex.FontItalic;
                dlg_info->dialog_header->FontCharset = h32ex.FontCharset;
                dlg_info->dialog_header->HelpId = h32ex.HelpId;
                dlg_info->dialog_header->FontWeightDefined = (h32ex.FontWeightDefined != 0);
                dlg_info->dialog_header->FontItalicDefined = (h32ex.FontItalicDefined != 0);
                dlg_info->dialog_header->FontCharsetDefined = (h32ex.FontCharsetDefined != 0);
            }
            dlg_info->dialog_header->Style = h32.Style;
            dlg_info->dialog_header->ExtendedStyle = h32.ExtendedStyle;
            dlg_info->dialog_header->NumOfItems = h32.NumOfItems;
            dlg_info->dialog_header->Size = h32.Size;
            dlg_info->dialog_header->MenuName = h32.MenuName;
            dlg_info->dialog_header->ClassName = h32.ClassName;
            dlg_info->dialog_header->Caption = h32.Caption;
            dlg_info->dialog_header->PointSize = h32.PointSize;
            dlg_info->dialog_header->FontName = h32.FontName;
        } else {
            dlg_info->dialog_header->Style = h16.Style;
            dlg_info->dialog_header->NumOfItems = h16.NumOfItems;
            dlg_info->dialog_header->Size = h16.Size;
            dlg_info->dialog_header->MenuName = h16.MenuName;
            dlg_info->dialog_header->ClassName = h16.ClassName;
            dlg_info->dialog_header->Caption = h16.Caption;
            dlg_info->dialog_header->PointSize = h16.PointSize;
            dlg_info->dialog_header->FontName = h16.FontName;
        }

        prev_control = NULL;
        for( index = 0; index < GETHDR_NUMITEMS( dlg_info->dialog_header ); index++ ) {
            control = WdeAllocDialogBoxControl();
            if( control == NULL ) {
                ok = false;
                break;
            }
            if( is32bit ) {
                /*
                 * JPK - check which control structure to expect based on
                 *       whether this an extended dialog or not
                */
                if( dlg_info->dialog_header->is32bitEx ) {
                    if( ResReadDialogExControl32( &c32ex, fid ) ) {
                        ok = false;
                        break;
                    }
                    control->HelpId = c32ex.HelpId;
                    control->ExtendedStyle = c32ex.ExtendedStyle;
                    control->Style = c32ex.Style;
                    control->Size = c32ex.Size;
                    control->ID = c32ex.ID;
                    control->ClassID = c32ex.ClassID;
                    control->Text = c32ex.Text;
                    control->ExtraBytes = c32ex.ExtraBytes;
                } else {
                    if( ResReadDialogBoxControl32( &c32, fid ) ) {
                        ok = false;
                        break;
                    }
                    control->Style = c32.Style;
                    control->ExtendedStyle = c32.ExtendedStyle;
                    control->Size = c32.Size;
                    control->ID = c32.ID;
                    control->ClassID = c32.ClassID;
                    control->Text = c32.Text;
                    control->ExtraBytes = c32.ExtraBytes;
                }
            } else {
                if( ResReadDialogBoxControl( &c16, fid ) ) {
                    ok = false;
                    break;
                }
                control->Size = c16.Size;
                control->ID = c16.ID;
                control->Style = c16.Style;
                control->ClassID = c16.ClassID;
                control->Text = c16.Text;
                control->ExtraBytes = c16.ExtraBytes;
            }
            if ( prev_control == NULL ) {
                ListAddElt( &dlg_info->control_list, (void *)control );
                prev_control = dlg_info->control_list;
            } else {
                ListInsertElt( prev_control, (void *)control );
                prev_control = ListNext( prev_control );
            }
        }
    }

#if 0
    /*
     * JPK - if the dialog is 32 bit but not EX, then convert the dialog
     *       header and the control list to EX; this will force all
     *       dialogs to EX, for now
    */
    if( is32bit && !dlg_info->dialog_header->is32bitEx ) {
        /* deal with the dialog header first */
        dlg_info->dialog_header->is32bitEx = TRUE;

        dlg_info->dialog_header->FontWeight = 0;
        dlg_info->dialog_header->FontItalic = 0;
        dlg_info->dialog_header->FontCharset = DEFAULT_CHARSET;
        dlg_info->dialog_header->HelpId = 0;
        dlg_info->dialog_header->FontWeightDefined = FALSE;
        dlg_info->dialog_header->FontItalicDefined = FALSE;
        dlg_info->dialog_header->FontCharsetDefined = FALSE;

        /* now deal with the list of controls */
        nc = (WdeDialogBoxControl *)WRMemAlloc( sizeof( WdeDialogBoxControl ) );
        for( clist = dlg_info->control_list; clist != NULL; clist = ListNext( clist ) ) {
            control = (WdeDialogBoxControl *)ListElement( clist );
            memcpy( nc, control, sizeof( WdeDialogBoxControl ) );

            nc->HelpId = 0;
            nc->ExtendedStyle = control->ExtendedStyle;
            nc->Style = control->Style;
            memcpy( &nc->Size, &control->Size, sizeof( DialogSizeInfo ) );
            nc->ID = control->ID;
            nc->ClassID = control->ClassID;
            nc->Text = control->Text;
            nc->ExtraBytes = control->ExtraBytes;

            memcpy( control, nc, sizeof( WdeDialogBoxControl ) );
        }
        WRMemFree( nc );
    }
#endif

    if( !ok ) {
        if( dlg_info != NULL ) {
            WdeFreeDialogBoxInfo( dlg_info );
            dlg_info = NULL;
        }
    }

    if( fid != WRES_NIL_HANDLE ) {
        ResCloseFile( fid );
    }

    return( dlg_info );
}