Esempio n. 1
0
extern bool CmdEvent( gui_window * gui, gui_event gui_ev, void * param )
{
    gui_ctl_id  id;
    char        *text;
    char        *cmd;
    int         i;

    cmd = GUIGetExtra( gui );
    switch( gui_ev ) {
    case GUI_INIT_DIALOG:
        GUISetText( gui, CTL_CMD_EDIT, "Hi Lisa!" );
        GUISetFocus( gui, CTL_CMD_EDIT );
        GUIClearList( gui, CTL_CMD_HISTORY );
        for( i = 0; i < ArraySize( Stuff ); ++i ) {
            GUIAddText( gui, CTL_CMD_HISTORY, Stuff[i] );
        }
        GUISetCurrSelect( gui, CTL_CMD_HISTORY, 1 );
        return( TRUE );
    case GUI_KEY_CONTROL:
        GUISetCurrSelect( gui, CTL_CMD_HISTORY, 2 );
        cmd = GUIGetText( gui, CTL_CMD_HISTORY );
        GUISetText( gui, CTL_CMD_EDIT, cmd );
        GUISelectAll( gui, CTL_CMD_EDIT, TRUE );
        GUIMemFree( cmd );
        return( TRUE );
    case GUI_CONTROL_DCLICKED:
    case GUI_CONTROL_CLICKED:
        GUI_GETID( param, id );
        switch( id ) {
        case CTL_CMD_HISTORY:
            text = GUIGetText( gui, CTL_CMD_HISTORY );
            GUISetText( gui, CTL_CMD_EDIT, text );
            GUIMemFree( text );
            if( gui_ev == GUI_CONTROL_CLICKED )
                return( TRUE );
            /* fall through */
        case CTL_CMD_OK:
            text = GUIGetText( gui, CTL_CMD_EDIT );
            if( text != NULL )
                DoCmd( text );
            GUIMemFree( text );
            break;
        case CTL_CMD_CHECK:
            return( FALSE );
        }
        GUICloseDialog( gui );
        /* fall through */
    case GUI_DESTROY:
        WndFree( cmd );
        return( TRUE );
    default:
        return( FALSE );
    }
}
Esempio n. 2
0
extern void DlgSetHistory( gui_window *gui, void *history, char *cmd,
                           int edit, int list )
{
    int         i;

    GUISetFocus( gui, edit );
    if( !WndPrevFromHistory( history, cmd ) ) return;
    GUISetText( gui, edit, cmd );
    GUISelectAll( gui, edit, true );
    GUIClearList( gui, list );
    while( WndPrevFromHistory( history, cmd ) ) {
        /* nothing */
    }
    i = -1;
    for( ;; ) {
        if( !WndNextFromHistory( history, cmd ) ) break;
        GUIAddText( gui, list, cmd );
        ++i;
    }
    if( i >= 0 ) GUISetCurrSelect( gui, list, i );
}
Esempio n. 3
0
void WEXPORT WListBox::reset() {
/******************************/

    GUIClearList( parent()->handle(), controlId() );
}
Esempio n. 4
0
static bool SourceEvent( gui_window *gui, gui_event gui_ev, void *param )
{
    gui_ctl_id  id;
    void        *curr;
    int         i;
    int         size;
    char        *text;
    dlg_list    *dlg;

    dlg = GUIGetExtra( gui );
    switch( gui_ev ) {
    case GUI_DESTROY:
        WndFree( dlg->title );
        return( true );
    case GUI_INIT_DIALOG:
        GUISetWindowText( gui, dlg->title );
        GUIClearList( gui, CTL_LIST_LIST );
        for( curr = dlg->next( NULL ); curr != NULL; curr = dlg->next( curr ) ) {
            AddText( gui, dlg->name( curr ) );
        }
        GUISetFocus( gui, CTL_LIST_EDIT );
        return( true );
    case GUI_CONTROL_CLICKED:
        GUI_GETID( param, id );
        switch( id ) {
        case CTL_LIST_LIST:
            GUIDlgBuffGetText( gui, CTL_LIST_LIST, TxtBuff, TXT_LEN );
            GUISetText( gui, CTL_LIST_EDIT, TxtBuff );
            break;
        case CTL_LIST_DELETE:
            i = GUIGetCurrSelect( gui, CTL_LIST_LIST );
            if( i != -1 ) {
                GUIDeleteItem( gui, CTL_LIST_LIST, i );
            }
            size = GUIGetListSize( gui, CTL_LIST_LIST );
            if( i < size ) {
                GUISetCurrSelect( gui, CTL_LIST_LIST, i );
            } else {
                SelectListLast( gui );
            }
            GUISetFocus( gui, CTL_LIST_LIST );
            GUISetText( gui, CTL_LIST_EDIT, NULL );
            break;
        case CTL_LIST_ADD:
        case CTL_LIST_OK:
            GUIDlgBuffGetText( gui, CTL_LIST_EDIT, TxtBuff, TXT_LEN );
            if( TxtBuff[0] != '\0' )
                AddText( gui, TxtBuff );
            SelectListLast( gui );
            GUIClearText( gui, CTL_LIST_EDIT );
            GUISetFocus( gui, CTL_LIST_EDIT );
            if( id == CTL_LIST_ADD )
                break;
            dlg->clear();
            size = GUIGetListSize( gui, CTL_LIST_LIST );
            for( i = 0; i < size; ++i ) {
                text = GUIGetListItem( gui, CTL_LIST_LIST, i );
                if( text != NULL ) {
                    dlg->add( text, strlen( text ) );
                    GUIMemFree( text );
                }
            }
            /* fall through */
        case CTL_LIST_CANCEL:
            GUICloseDialog( gui );
            break;
        case CTL_LIST_BROWSE:
            GUIDlgBuffGetText( gui, CTL_LIST_EDIT, TxtBuff, TXT_LEN );
            if( !AllBrowse( TxtBuff ) )
                return( true );
            GUISetText( gui, CTL_LIST_EDIT, TxtBuff );
            GUISetFocus( gui, CTL_LIST_EDIT );
            return( true );
        }
        return( true );
    default:
        return( false );
    }
}
Esempio n. 5
0
/*
 * setDirList - set current directory list
 */
static bool setDirList( gui_window *gui )
{
    char                path[_MAX_PATH];
    char                dir[_MAX_DIR];
    char                drive[_MAX_DRIVE + 3];
    DIR                 *directory;
    struct dirent       *dent;
    char                *ptr,*start;
    char                indent[80];
    char                tmp[256];
    const char          **drvlist;
    int                 i;
    size_t              len;
    int                 curr,cnt;
    const char          **list;

    GUIClearList( gui, CTL_DIR_LIST );
    cnt = 0;
    list = NULL;

    if( getcwd( path, sizeof( path ) ) == NULL ) {
        return( true );
    }

    if( path[strlen( path ) - 1] == FILE_SEP_CHAR ) {
#if !defined( __UNIX__ ) && !defined( __NETWARE__ )
        strcat( path, FILES_ALL );
#endif
    } else {
#if defined( __UNIX__ ) || defined( __NETWARE__ )
        strcat( path, FILE_SEP );
#else
        strcat( path, FILE_SEP FILES_ALL );
#endif
    }
    splitPath( path, drive + 1, dir, NULL, NULL );

    directory = opendir( path );
    if( directory == NULL ) {
        return( false );
    }

    drive[0] = OPENED_DIR_CHAR;
    drvlist = NULL;
#if !defined( __UNIX__ ) && !defined( __NETWARE__ )
    drvlist = GetDriveTextList();
#endif
    i = 0;
    while( drvlist != NULL ) {
        if( drvlist[i] == NULL ) {
            break;
        }
        if( drvlist[i][0] == drive[1] ) {
            GUISetCurrSelect( gui, CTL_DRIVES, i );
            break;
        }
        i++;
    }
#if !defined( __UNIX__ ) && !defined( __NETWARE__ )
    drive[3] = '\\';
    drive[4] = '\0';
#endif
    if( !addToList( &list, cnt, drive, strlen( drive ) ) ) {
        freeStringList( &list );
        return( false );
    }
    cnt++;
    strcpy( indent, INDENT_STR );

    ptr = dir + 1;
    start = ptr;
    while( *ptr != 0 ) {
        if( *ptr == FILE_SEP_CHAR ) {
            *ptr = 0;
            len = strlen( indent );
            memcpy( tmp, indent, len );
            tmp[len++] = OPENED_DIR_CHAR;
            strcpy( tmp + len, start );
            if( !addToList( &list, cnt, tmp, strlen( tmp ) ) ) {
                freeStringList( &list );
                return( false );
            }
            cnt++;
            start = ptr + 1;
            strcat( indent, INDENT_STR );
        }
        ptr++;
    }

    curr = cnt;
    while( ( dent = readdir( directory ) ) != NULL ) {
        if( isdir( dent, path ) ) {
            if( (dent->d_name[0] == '.') && ((dent->d_name[1] == 0) ||
                (dent->d_name[1] == '.' && dent->d_name[2] == 0)) ) {
                continue;
            }
            len = strlen( indent );
            memcpy( tmp, indent, len );
            tmp[len++] = UNOPENED_DIR_CHAR;
            strcpy( tmp + len, dent->d_name );
            if( !addToList( &list, cnt, tmp, strlen( tmp ) ) ) {
                freeStringList( &list );
                return( false );
            }
            cnt++;
        }
    }
    closedir( directory );

    qsort( list, cnt, sizeof( char * ), Compare );
    for( i = 0; i < cnt; i++ ) {
        GUIAddText( gui, CTL_DIR_LIST, list[i] );
    }
    GUISetCurrSelect( gui, CTL_DIR_LIST, curr - 1 );
    freeStringList( &list );

    return( true );

} /* setDirList */
Esempio n. 6
0
/*
 * setFileList - get list of files in current directory
 */
static bool setFileList( gui_window *gui, const char *ext )
{
    char                path[_MAX_PATH];
    DIR                 *directory;
    struct dirent       *dent;
    char                *ptr;
    const char          **list;
    int                 cnt;
    char                ext1[_MAX_PATH];
    int                 i;
    dlg_info            *dlg = GUIGetExtra( gui );

    cnt = 0;
    list = NULL;
    strcpy( ext1, ext );

    ptr = strtok( ext1, ";" );
    while( ptr != NULL ) {

        if( getcwd( path, sizeof( path ) ) == NULL ) {
            break;
        }

#if !defined( __UNIX__ ) && !defined( __NETWARE__ )
        if( path[strlen(path)-1] != FILE_SEP_CHAR ) {
            strcat( path, FILE_SEP );
        }
        strcat( path, ptr );
#endif

        directory = opendir( path );
        if( directory != NULL ) {
            while( ( dent = readdir( directory ) ) != NULL ) {
                if( !isdir( dent, path ) ) {
                    if( ( dlg->currOFN->flags & OFN_HIDEREADONLY ) && isrdonly( dent, path ) ) {
                        continue;
                    }
#if defined( __UNIX__ ) || defined( __NETWARE__ )
                    if( fnmatch( ptr, dent->d_name, FNM_PATHNAME ) != 0 ) {
                        continue;
                    }
#endif
                    if( !addToList( &list, cnt, dent->d_name, strlen( dent->d_name ) ) ) {
                        freeStringList( &list );
                        closedir( directory );
                        return( false );
                    }
                    cnt++;
                }
            }
            closedir( directory );
        }
        ptr = strtok( NULL, ";" );
    }
    GUIClearList( gui, CTL_FILE_LIST );
    if( cnt > 0 ) {
        qsort( list, cnt, sizeof( char * ), Compare );
        for( i = 0; i < cnt; i++ ) {
            GUIAddText( gui, CTL_FILE_LIST, list[i] );
        }
        freeStringList( &list );
    }
    return( true );

} /* setFileList */