예제 #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 );
    }
}
예제 #2
0
static void SelectListLast( gui_window *gui )
{
    int         size;

    size = GUIGetListSize( gui, CTL_LIST_LIST );
    if( size != 0 ) {
        GUISetCurrSelect( gui, CTL_LIST_LIST, size - 1 );
    }
}
예제 #3
0
static void InitTextList( gui_window *gui, unsigned id, const char **text_list )
{
    int         i;

    for( i = 0; text_list[i] != NULL; i++ ) {
        GUIAddText( gui, id, text_list[i] );
    }
    GUISetCurrSelect( gui, id, 0 );
}
예제 #4
0
static void InitList( gui_window *gui, unsigned id, int index )
{
    int         i;
    char        **text;

    text = (char **)dlgControls[index].text;
    for( i = 0; text[i] != NULL; i++ ) {
        GUIAddText( gui, id, text[i] );
    }
    GUISetCurrSelect( gui, id, 0 );
}
예제 #5
0
static void DlgInit( gui_window *wnd, void *param )
{
    char        buffer[MAX_LENGTH];
    dlg_init    *info;

    info = (dlg_init *)param;
    TotalWindows++;
    ChildWindows[TotalWindows-1] = wnd;
    if( GUIGetWindowText( wnd, buffer, sizeof( buffer ) ) != 0 ) {
        GUIAddText( info->dlg_wnd, info->list_id, buffer );
    } else {
        GUIAddText( info->dlg_wnd, info->list_id, "" );
    }
    if( wnd == GUICurrWnd ) {
        GUISetCurrSelect( info->dlg_wnd, info->list_id, TotalWindows - 1 );
    }
}
예제 #6
0
static void MoveCursor( gui_window *gui, int edit, int list, int direction )
{
    int         i,size;
    char        *cmd;

    i = GUIGetCurrSelect( gui, list );
    size = GUIGetListSize( gui, list );
    if( size == 0 ) return;
    --size;
    i += direction;
    if( i < 0 ) i = 0;
    if( i > size ) i = size;
    GUISetCurrSelect( gui, list, i );
    cmd = GUIGetText( gui, list );
    GUISetText( gui, edit, cmd );
    GUIMemFree( cmd );
    GUISelectAll( gui, edit, true );
}
예제 #7
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 );
}
예제 #8
0
void WEXPORT WListBox::select( int index ) {
/******************************************/

    GUISetCurrSelect( parent()->handle(), controlId(), index );
}
예제 #9
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 );
    }
}
예제 #10
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 */
예제 #11
0
/*
 * ProcessOKorDClick -- user clicked OK or double clicked on a file
 */
void ProcessOKorDClick( gui_window *gui, unsigned id  )
{
    process_rc  prc;
    int         sel;
    int         realsel;
    char        path[_MAX_PATH];
    char        *optr;
    char        *ptr;
    int         i;
    unsigned    focusid;
    dlg_info    *dlg = GUIGetExtra( gui );

    if( id == CTL_OK ) { /* hit enter or clicked ok */
        GUIGetFocus( gui, &focusid );
        switch( focusid ) {
        case CTL_DIR_LIST  :
            id = focusid;
            break;
        case CTL_FILE_LIST :
            ptr = GUIGetText( gui, CTL_FILE_LIST );
            GUISetText( gui, CTL_EDIT, ptr );
            GUIMemFree( ptr );
            break;
        }
    }
    switch( id ) {
    case CTL_FILE_LIST :
    case CTL_OK :
        prc = processFileName( gui );
        if( prc == PROCESS_TRUE ) {
            dlg->dialogRC = OFN_RC_FILE_SELECTED;
            GUICloseDialog( gui );
        } else if( prc == PROCESS_FAIL ) {
            dlg->dialogRC = OFN_RC_RUNTIME_ERROR;
            GUICloseDialog( gui );
        }
        break;
    case CTL_DIR_LIST :
        sel = GUIGetCurrSelect( gui, id );
#if defined( __UNIX__ ) || defined( __NETWARE__ )
        path[0] = FILE_SEP_CHAR;
        path[1] = 0;
#else
        path[0] = 0;
#endif
        realsel = 0;
        for( i=0;i<sel;i++ ) {
            ptr = GUIGetListItem( gui, id, i );
            if( ptr == NULL ) {
                return;
            }
            optr = ptr;
            while( *ptr == INDENT_CHAR ) {
                ptr++;
            }
            if( *ptr == '-' ) {
                strcat( path, ptr+1 );
                realsel++;
                if( i > 0 ) {
                    strcat( path, FILE_SEP );
                }
            } else {
                GUIMemFree( optr );
                break;
            }
            GUIMemFree( optr );
        }
        ptr = GUIGetListItem( gui, id, sel );
        if( ptr == NULL ) {
            return;
        }
        optr = ptr;
        while( *ptr == INDENT_CHAR ) {
            ptr++;
        }
        strcat( path, ptr+1 );
        GUIMemFree( optr );
        goToDir( gui, path );
        if( !initDialog( gui, NULL, NULL ) ) {
            dlg->dialogRC = OFN_RC_RUNTIME_ERROR;
            GUICloseDialog( gui );
        } else {
            GUISetCurrSelect( gui, id, realsel );
        }
        break;
   }

} /* ProcessOKorDClick */