예제 #1
0
bool WEXPORT WFileDialog::getOpenFileName( WFileNameList &flist,
                                           const char *fn,
                                           const char *title,
                                           unsigned style ) {
/***********************************************************/

    init( fn, title );
    _ofn.flags = style | OFN_ALLOWMULTISELECT;
    if( GUIGetFileName( _parent->handle(), &_ofn ) == OFN_RC_FILE_SELECTED ) {
        flist.parseIn( _fileName );
#if defined( __WINDOWS__ ) || defined( __NT__ )
        if( flist.count() > 1 ) {
            WFileName path( flist.stringAt( 0 ) );
            path.concat( '\\' );
            for( int i = 1; i < flist.count(); ++i ) {
                flist.stringAt(i).absoluteTo( path );
            }
            flist.removeAt( 0 );
        }
#endif
        return( TRUE );
    }
    return( FALSE );
}
예제 #2
0
void EdModule::addButton( WWindow * )
//-----------------------------------
{
    int             i;
    int             fileIdx;
    WFileNameList   files;
    WFileDialog     fileSelect( this, EdModuleFilter );
    bool            result;
    WFileName *     file;
    bool            found;

    result = fileSelect.getOpenFileName( files, NULL,
                                        "Select Module File(s)",
                                        WFOpenNew );

    if( result ) {
        for( fileIdx = 0; fileIdx < files.count(); fileIdx += 1 ) {
            file = new WFileName( files.cStringAt( fileIdx ) );

            if( *( file->ext() ) == '\0' ) {
                file->setExt("mbr");
            }
            file->absoluteTo();
            file->toLower();

            found = false;

            if( !file->attribs() ) {
                errMessage( "Module %s%s does not exist", file->fName(), file->ext() );
                found = true;
            }

            for( i = 0; i < _moduleBox->count() && !found; i += 1 ) {
                WString * str = (*_moduleBox)[ i ]->_str;

                if( *str == *file ) {
                    errMessage( "Module %s%s already in project", file->fName(), file->ext() );
                    found = true;
                }
            }

            for( int i = 0; i < _removedModuleItems->entries() && !found; i++ ) {
                WString * str = (*_removedModuleItems)[ i ]->_str;

                if( *str == *file ) {
                    ModuleItem * item = _removedModuleItems->removeAt( i ) ;
                    item->_enabled = true;
                    _moduleBox->insert( item );

                    found = true;
                }
            }

            if( !found ) {
                ModuleItem * item = new ModuleItem( file, true );
                _moduleBox->insert( item );
            }

        } /* for( i < files.count() ) */

    } /* if( result ) */
    _moduleBox->reset();

}