Ejemplo n.º 1
0
static void GUIFreeRadio( a_radio * radio )
{
    GUIMemFree( radio->str );
    GUIMemFree( radio );
}
Ejemplo n.º 2
0
static void GUIFreeCheck( a_check * check )
{
    GUIMemFree( check->str );
    GUIMemFree( check );
}
Ejemplo n.º 3
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 );
    }
}
Ejemplo n.º 4
0
static void FreeRadioGroup( a_radio_group * group )
{
    GUIMemFree( group->caption );
    GUIMemFree( group );
}
Ejemplo n.º 5
0
/*
 * GetFileNameEvent - event handler for GetFileName dialog
 */
extern bool GetFileNameEvent( gui_window *gui, gui_event gui_ev, void *param )
{
    unsigned    id;
    int         sel;
    char        *ptr;
    char        path[_MAX_PATH];
    dlg_info    *dlg = GUIGetExtra( gui );

    switch( gui_ev ) {
    case GUI_INIT_DIALOG:
        dlg->initted = false;
        InitTextList( gui, CTL_FILE_TYPES, GetFileTypesTextList() );
#if !defined( __UNIX__ ) && !defined( __NETWARE__ )
        InitTextList( gui, CTL_DRIVES, GetDriveTextList() );
#endif
        if( !initDialog( gui, dlg->fileExtensions[dlg->currExtIndex], dlg->currOFN->file_name ) ) {
            dlg->dialogRC = OFN_RC_FAILED_TO_INITIALIZE;
            return( false );
        }
        dlg->initted = true;
        GUISetFocus( gui, CTL_EDIT );
        return( true );
        break;
    case GUI_CONTROL_DCLICKED:
        GUI_GETID( param, id );
        switch( id ) {
        case CTL_FILE_LIST:
        case CTL_DIR_LIST:
            ProcessOKorDClick( gui, id );
            break;
        }
        break;
    case GUI_CONTROL_CLICKED:
        if( !dlg->initted ) break;
        GUI_GETID( param, id );
        switch( id ) {
        case CTL_OK:
            ProcessOKorDClick( gui, id );
            break;
        case CTL_CANCEL:
            GUICloseDialog( gui );
            break;
        case CTL_FILE_LIST:
            ptr = GUIGetText( gui, id );
            GUISetText( gui, CTL_EDIT, ptr );
            GUIMemFree( ptr );
            break;
        case CTL_DRIVES :
            sel = GUIGetCurrSelect( gui, id );
            strcpy( path, GetDriveTextList()[sel] );
            path[2] = 0;
            goToDir( gui, path );
            if( !initDialog( gui, NULL, NULL ) ) {
                dlg->dialogRC = OFN_RC_RUNTIME_ERROR;
                GUICloseDialog( gui );
            }
            break;
        case CTL_FILE_TYPES:
            sel = GUIGetCurrSelect( gui, id );
            if( !initDialog( gui, dlg->fileExtensions[sel], NULL ) ) {
                dlg->dialogRC = OFN_RC_RUNTIME_ERROR;
                GUICloseDialog( gui );
            }
            break;
        }
        return( true );
    default:
        break;  // makes GCC happy.
    }
    return( false );

} /* GetFileNameEvent */
Ejemplo n.º 6
0
/*
 * processFileName - process a new file name
 */
static process_rc processFileName( gui_window *gui )
{
    char        *tmp;
    char        *txt;
    size_t      len;
    char        path[_MAX_PATH];
    char        dir[_MAX_DIR];
    char        drive[_MAX_DRIVE];
    char        fname[_MAX_PATH];
    char        ext[_MAX_PATH];
    char        *buff;
    bool        has_wild;
    struct stat buf;
    int         rc;
    dlg_info            *dlg = GUIGetExtra( gui );

    tmp = GUIGetText( gui, CTL_EDIT );
    if( tmp == NULL ) {
        return( PROCESS_FALSE );
    }
    txt = alloca( strlen( tmp ) + 1 );
    if( txt == NULL ) {
        GUIMemFree( tmp );
        return( PROCESS_FALSE );
    }
    strcpy( txt, tmp );
    GUIMemFree( tmp );
    splitPath( txt, drive, dir, fname, ext );

    has_wild = hasWild( txt );
    if( has_wild && fname[0] == 0 ) {
        return( PROCESS_FALSE );
    }

    if( !has_wild ) {

        rc = stat( txt, &buf );
        if( !rc ) {
            if( S_ISDIR( buf.st_mode ) ) {
                goToDir( gui, txt );
                if( !initDialog( gui, dlg->fileExtensions[dlg->currExtIndex], NULL ) ) {
                    return( PROCESS_FAIL );
                }
                return( PROCESS_FALSE );
            }
        }
        _makepath( path, drive, dir, NULL, NULL );
        if( !goToDir( gui, path ) ) {
            return( PROCESS_FALSE );
        }
        if( !rc && (dlg->currOFN->flags & OFN_OVERWRITEPROMPT) ) {
            buff = alloca( strlen( txt ) + 100 );
            strcpy( buff, txt );
            strcat( buff, LIT( File_Exists_Replace ) );
            rc = GUIDisplayMessage( gui, buff, dlg->currOFN->title, GUI_YES_NO );
            if( rc == GUI_RET_NO ) {
                return( PROCESS_FALSE );
            }
        }
        _makepath( path, NULL, NULL, fname, ext );

        if( dlg->currOFN->base_file_name != NULL ) {
            len = strlen( txt );
            if( len >= dlg->currOFN->max_base_file_name ) {
                len = dlg->currOFN->max_base_file_name - 1;
            }
            memcpy( dlg->currOFN->base_file_name, txt, len );
            dlg->currOFN->base_file_name[len] = 0;
        }
        if( dlg->currOFN->file_name != NULL ) {
            getcwd( path, sizeof( path ) );
            len = strlen( path );
            if( path[len - 1] != FILE_SEP_CHAR ) {
                path[len] = FILE_SEP_CHAR;
                path[len + 1] = 0;
            }
            strcat( path, fname );
            strcat( path, ext );
            len = strlen( path );
            if( len >= dlg->currOFN->max_file_name ) {
                len = dlg->currOFN->max_file_name-1;
            }
            memcpy( dlg->currOFN->file_name, path, len );
            dlg->currOFN->file_name[len] = 0;
        }
        return( PROCESS_TRUE );
    }
    _makepath( path, drive, dir, NULL, NULL );
    if( !goToDir( gui, path ) ) {
        return( PROCESS_FALSE );
    }
    _makepath( path, NULL, NULL, fname, ext );
    if( !initDialog( gui, path, NULL ) ) {
        return( PROCESS_FAIL );
    }
    return( PROCESS_FALSE );

} /* processFileName */
Ejemplo n.º 7
0
extern void GUImain( void )
/*************************/
{
    int                 argc = 0;
    char                **argv = NULL;
    char                *dir;
    char                *drive;
    char                *inf_name;
    char                *tmp_path;
    char                *arc_name;
    char                *new_inf;
    char                current_dir[_MAX_PATH];
    bool                ret = FALSE;
    dlg_state           state;

    GUIMemOpen();
    GUIGetArgs( &argv, &argc );
#if defined( __NT__ ) && !defined( _M_X64 )
    if( CheckWin95Uninstall( argc, argv ) ) return;
    if( CheckWow64() ) return;
#endif
#ifdef __WINDOWS__
    if( CheckForSetup32( argc, argv ) ) return;
#endif

    // initialize paths and env. vbls.

    if( !SetupPreInit() ) return;
    if( !GetDirParams( argc, argv, &inf_name, &tmp_path, &arc_name ) ) return;
    if( !SetupInit() ) return;
    GUIDrainEvents();   // push things along
    FileInit( arc_name );
    InitGlobalVarList();
    strcpy( current_dir, tmp_path );
    while( InitInfo( inf_name, tmp_path ) ) {

        ret = DoMainLoop( &state );

        if( state == DLG_DONE ) break;
//        if( CancelSetup == TRUE || !ret ) break;
        if( CancelSetup == TRUE ) break;
//        if( !ret ) break;

        // look for another SETUP.INF
        if( GetVariableByName( "SetupPath" ) == NO_VAR ) {
            if( DirParamStack( &inf_name, &tmp_path, Stack_IsEmpty ) == FALSE ) {  // "IsEmpty"?
                DirParamStack( &inf_name, &tmp_path, Stack_Pop ); // "Pop"
                CloseDownMessage( ret );
                CancelSetup = FALSE;
                ret = TRUE;
            } else {
                CloseDownMessage( ret );
                break;
            }
        } else {
            if( GetVariableIntVal( "IsMultiInstall" ) ) {
                // push current script on stack
                DirParamStack( &inf_name, &tmp_path, Stack_Push ); // "Push"
            }
            new_inf = GUIMemAlloc( _MAX_PATH );
            drive = GUIMemAlloc( _MAX_DRIVE );
            dir = GUIMemAlloc( _MAX_PATH );
            if( new_inf == NULL || drive == NULL || dir == NULL ) {
                GUIMemFree( new_inf );
                GUIMemFree( drive );
                GUIMemFree( dir );
                break;
            }
            // construct new path relative to previous
            ReplaceVars( new_inf, GetVariableStrVal( "SetupPath" ) );
            _splitpath( current_dir, drive, dir, NULL, NULL );
            _makepath( inf_name, drive, dir, new_inf, NULL );

            _splitpath( inf_name, drive, dir, NULL, NULL );
            _makepath( tmp_path, drive, dir, NULL, NULL );
//          strcpy( current_dir, tmp_path );

            GUIMemFree( new_inf );
            GUIMemFree( drive );
            GUIMemFree( dir );
        } /* if */

        FreeGlobalVarList( FALSE );
        FreeDefaultDialogs();
        FreeAllStructs();
        ConfigModified = FALSE;
    } /* while */


    FileFini();
    FreeGlobalVarList( TRUE );
    FreeDefaultDialogs();
    FreeAllStructs();
    FreeDirParams( &inf_name, &tmp_path, &arc_name );
    CloseDownProgram();
}
Ejemplo n.º 8
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 */
Ejemplo n.º 9
0
void WndSetSrchItem( a_window *wnd, char *expr )
{
    GUIMemFree( wnd->searchitem );
    wnd->searchitem = GUIMemAlloc( strlen( expr ) + 1 );
    strcpy( wnd->searchitem, expr );
}
Ejemplo n.º 10
0
int GUIGetFileName( gui_window *wnd, open_file_name *ofn )
{
    OPENFILENAME        wofn;
    bool                issave;
    int                 rc;
    unsigned            drive;
#if defined(HAVE_DRIVES)
    unsigned            old_drive;
    unsigned            drives;
#endif

    LastPath = NULL;
    if( ofn->initial_dir != NULL && ofn->initial_dir[0] != '\0' && ofn->initial_dir[1] == ':' ) {
        drive = ofn->initial_dir[0];
        memmove( ofn->initial_dir, ofn->initial_dir+2, strlen( ofn->initial_dir+2 ) + 1 );
    } else {
        drive = 0;
    }

    memset( &wofn, 0 , sizeof( wofn ) );

    if( ofn->flags & OFN_ISSAVE ) {
        issave = true;
    } else {
        issave = false;
    }

    wofn.Flags = 0;
    if( hookFileDlg ) {
        wofn.Flags |= OFN_ENABLEHOOK;
    }
    if( !(ofn->flags & OFN_CHANGEDIR) ) {
        wofn.Flags |= OFN_NOCHANGEDIR;
    }

    if( ofn->flags & OFN_OVERWRITEPROMPT ) {
        wofn.Flags |= OFN_OVERWRITEPROMPT;
    }
    if( ofn->flags & OFN_HIDEREADONLY ) {
        wofn.Flags |= OFN_HIDEREADONLY;
    }
    if( ofn->flags & OFN_FILEMUSTEXIST ) {
        wofn.Flags |= OFN_FILEMUSTEXIST;
    }
    if( ofn->flags & OFN_PATHMUSTEXIST ) {
        wofn.Flags |= OFN_PATHMUSTEXIST;
    }
    if( ofn->flags & OFN_ALLOWMULTISELECT ) {
        wofn.Flags |= OFN_ALLOWMULTISELECT;
    }
    wofn.hwndOwner = GUIGetParentFrameHWND( wnd );
    wofn.hInstance = GUIMainHInst;
    wofn.lStructSize = sizeof( wofn );
    wofn.lpstrFilter = ofn->filter_list;
    wofn.nFilterIndex = ofn->filter_index;
    wofn.lpstrFile = ofn->file_name;
    wofn.nMaxFile = ofn->max_file_name;
    wofn.lpstrFileTitle = ofn->base_file_name;
    wofn.nMaxFileTitle = ofn->max_base_file_name;
    wofn.lpstrTitle = ofn->title;
    wofn.lpstrInitialDir = ofn->initial_dir;
    wofn.lpfnHook = (LPOFNHOOKPROC)NULL;
    if( hookFileDlg ) {
        wofn.lpfnHook = (LPOFNHOOKPROC)MakeOpenFileHookProcInstance( OpenHook, GUIMainHInst );
    }

#if defined( HAVE_DRIVES )
    if( drive ) {
        _dos_getdrive( &old_drive );
        _dos_setdrive( tolower( drive ) - 'a' + 1, &drives );
    }
#endif
    if( issave ) {
        rc = GetSaveFileName( &wofn );
    } else {
        rc = GetOpenFileName( &wofn );
    }

    if( hookFileDlg ) {
        (void)FreeProcInstance( (FARPROC)wofn.lpfnHook );
    }

    if( LastPath && ( !rc || !( ofn->flags & OFN_WANT_LAST_PATH ) ) ) {
        GUIMemFree( LastPath );
        LastPath = NULL;
    }
    ofn->last_path = LastPath;
#if defined( HAVE_DRIVES )
    if( drive ) {
        _dos_setdrive( old_drive, &drives );
    }
#endif
    if( rc ) {
        return( OFN_RC_FILE_SELECTED );
    }
    if( !CommDlgExtendedError() ) {
        return( OFN_RC_NO_FILE_SELECTED );
    }
    return( OFN_RC_FAILED_TO_INITIALIZE );
} /* _GUIGetFileName */
Ejemplo n.º 11
0
void GUIFreeWindowMemory( gui_window *wnd, bool from_parent, bool dialog )
{
    gui_window  *root;
    HWND        capture;

    from_parent = from_parent;
    if( ( wnd->hwnd != NULLHANDLE ) && ( GUICurrWnd == wnd ) ) {
        capture = _wpi_getcapture();
        if( capture == wnd->hwnd ) {
            _wpi_releasecapture();
        }
    }
    if( wnd->font != NULL ) {
        _wpi_deletefont( wnd->font );
        wnd->font = NULL;
    }
    if( wnd->icon != (WPI_HICON)NULL ) {
        _wpi_destroyicon( wnd->icon );
    }
    GUIFreeColours( wnd );
    GUIFreeBKBrush( wnd );
    GUIControlDeleteAll( wnd );
    //GUICloseToolBar( wnd );
    GUIFreeHint( wnd );
    _wpi_setwindowlong( wnd->hwnd, GUI_EXTRA_WORD * EXTRA_SIZE, 0 );
    if( wnd->root != NULLHANDLE ) {
        _wpi_setwindowlong( wnd->root, GUI_EXTRA_WORD * EXTRA_SIZE, 0 );
    }
    if( !dialog ) {
        GUIMDIDelete( wnd );
        if( GUICurrWnd == wnd ) {
            GUICurrWnd = NULL;
        }
        GUIFreePopupList( wnd );
    }
    GUIDeleteFromList( wnd );
    /* If the window being deleted was the current window, choose a new
     * window to bring to front.  Don't do this if the window that's being
     * destroyed is being destroyed because it's parent is being destroyed
     * (ie never got WM_CLOSE so DOING_CLOSE isn't set).
     */
    if( !dialog && ( wnd->flags & DOING_CLOSE ) && ( GUICurrWnd == NULL ) &&
        !GUIIsParentADialog( wnd ) ) {
        // if the root window has received a WM_DESTROY then just run away
        root = GUIGetRootWindow();
        if( root && !( root->flags & DOING_DESTROY ) ) {
            GUIBringNewToFront( wnd );
        }
    }
    if( wnd->hdc != (WPI_PRES)NULL ) {
        _wpi_releasepres( wnd->hwnd, wnd->hdc );
        wnd->hdc = NULLHANDLE;
    }
#ifdef __OS2_PM__
    GUIFreeWndPaintHandles( wnd, TRUE );
    if( wnd->root_pinfo.normal_pres != (WPI_PRES)NULL ) {
        _wpi_deleteos2normpres( wnd->root_pinfo.normal_pres );
        wnd->root_pinfo.normal_pres = (WPI_PRES)NULL;
    }
    if( wnd->hwnd_pinfo.normal_pres != (WPI_PRES)NULL ) {
        _wpi_deleteos2normpres( wnd->hwnd_pinfo.normal_pres );
        wnd->hwnd_pinfo.normal_pres = (WPI_PRES)NULL;
    }
#endif
    GUIMemFree( wnd );
}
Ejemplo n.º 12
0
bool GUIXCreateDialog( gui_create_info *dlg_info, gui_window *wnd,
                       int num_controls, gui_control_info *controls_info,
                       bool sys, res_name_or_id dlg_id )
{
    EVENT       ev;
    int         i;
    a_dialog    *ui_dlg_info;
    VFIELD      *fields;
    char        *title;
    VFIELD      *focus;
    int         size;
    bool        colours_set;
    bool        ok;

    if( dlg_id != NULL ) {
        if( !GUICreateDialogFromRes( dlg_id, dlg_info->parent,
                                     dlg_info->call_back, dlg_info->extra ) ) {
            return( false );
        }
        GUIMemFree( wnd );
        return( true );
    }

    sys = sys;
    RadioGroup = NULL;
    Group = false;
    fields = NULL;
    title = NULL;
    ui_dlg_info = NULL;
    colours_set = false;

    wnd->flags |= DIALOG;
    if( !GUISetupStruct( wnd, dlg_info, true ) ) {
        return( false );
    }

    size = ( num_controls + 1 ) * sizeof( VFIELD );
    fields = (VFIELD *)GUIMemAlloc( size );
    if( fields == NULL ) {
       return( false );
    }
    memset( fields, 0, size );
    focus = NULL;
    for( i = 0; i < num_controls; i++ ) {
        uiyield();
        if( !GUIDoAddControl( &controls_info[i], wnd, &fields[i] ) ) {
            GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true );
            return( false );
        } else {
            if( ( focus == NULL ) && ( controls_info[i].style & GUI_FOCUS ) ) {
                focus = &fields[i];
            }
        }
    }
    CleanUpRadioGroups();
    fields[num_controls].typ = FLD_VOID; /* mark end of list */
    title = GUIStrDup( dlg_info->title, &ok );
    if( !ok ) {
        GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true );
        return( false );
    }
    colours_set = GUISetDialColours();
    ui_dlg_info = uibegdialog( title, fields, wnd->screen.area.height,
                             wnd->screen.area.width, wnd->screen.area.row,
                             wnd->screen.area.col );
    if( ui_dlg_info == NULL ) {
        GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true );
        return( false );
    }
    if( focus != NULL ) {
        uidialogsetcurr( ui_dlg_info, focus );
    }
    if( !InsertDialog( wnd, ui_dlg_info, num_controls, title, colours_set ) ) {
        GUIFreeDialog( ui_dlg_info, fields, title, colours_set, true );
        return( false );
    }
    for( i = 0; i < num_controls; i++ ) {
        uiyield();
        GUIInsertControl( wnd, &controls_info[i], i );
    }
    GUIEVENTWND( wnd, GUI_INIT_DIALOG, NULL );
    uipushlist( NULL );
    uipushlist( GUIUserEvents );
    uipushlist( GUIControlEvents );
    uipushlist( GUIDlgEvents );
    while( ( GetDialog( ui_dlg_info ) != NULL ) ) {
        ev = uidialog( ui_dlg_info );
        switch( ev ) {
        case EV_KILL_UI:
            uiforceevadd( EV_KILL_UI );
        case EV_ESCAPE:
            GUIEVENTWND( wnd, GUI_DIALOG_ESCAPE, NULL );
            GUICloseDialog( wnd );
            break;
        default :
            GUIProcessControlNotify( ev, ui_dlg_info, wnd );
        }
    }
    return( true );
}
Ejemplo n.º 13
0
bool GUIDeleteField( gui_window *wnd, gui_ctl_id id )
{
    dialog_node *dlg_node;
    a_dialog    *ui_dlg_info;
    int         index;
    VFIELD      *new_fields;
    VFIELD      *field;
    int         new_index;
    int         i;
    gui_control *control;

    dlg_node = GUIGetDlgByWnd( wnd );
    if( dlg_node == NULL ) {
        return( false );
    }
    ui_dlg_info = dlg_node->ui_dlg_info;
    field = GUIGetField( wnd, id );
    if( GetIndexOfField( ui_dlg_info, field, dlg_node->num_controls, &index ) ) {
        GUIDoFreeField( field, NULL );
        new_fields = (VFIELD *)GUIMemAlloc( sizeof( VFIELD ) * dlg_node->num_controls );
        for( i=0; i <= dlg_node->num_controls; i++ ) {
            new_index = i;
            if( i != index ) {
                if( i > index ) {
                    new_index--;
                    control = GUIGetControlByIndex( wnd, i );
                    if( control != NULL ) {
                        control->index = new_index;
                    }
                }
                memcpy( &new_fields[new_index], &ui_dlg_info->fields[i], sizeof( VFIELD ) );
            }
            if( ui_dlg_info->other == &ui_dlg_info->fields[i] ) {
                if( i == index ) {
                    ui_dlg_info->other = NULL;
                } else {
                    ui_dlg_info->other = &new_fields[new_index];
                }
            }
            if( ui_dlg_info->curr == &ui_dlg_info->fields[i] ) {
                if( i == index ) {
                    ui_dlg_info->curr = NULL;
                } else {
                    ui_dlg_info->curr = &new_fields[new_index];
                }
            }
            if( ui_dlg_info->first == &ui_dlg_info->fields[i] ) {
                if( i == index ) {
                    ui_dlg_info->first = NULL;
                } else {
                    ui_dlg_info->first = &new_fields[new_index];
                }
            }
        }
        GUIMemFree( ui_dlg_info->fields );
        ui_dlg_info->fields = new_fields;
        dlg_node->num_controls--;
        return( true );
    }
    return( false );
}
Ejemplo n.º 14
0
static void DoWndDump( a_window *wnd, WRITERTN *rtn, handle file )
{
    int                 row;
    int                 piece;
    wnd_line_piece      line;
    int                 indent_per_char;
    int                 chars_written;
    int                 indent_pos;
    char                *font;
    gui_ord             gadget_len;
    char                *p;
    char                buff[TXT_LEN];
//    int                 len;
    int                 i;

    font = WndGetFontInfo( wnd );
    gadget_len = MaxGadgetLength;
    MaxGadgetLength = ( strlen( WndGadgetArray[0].chars ) + 1 ) * WndAvgCharX( wnd );
    WndSetSysFont( wnd, TRUE );
    indent_per_char = WndAvgCharX( wnd );
//    len = WndGetTitle( wnd, buff, TXT_LEN );
    WndGetTitle( wnd, buff, TXT_LEN );
    p = TxtBuff;
    for( i = 0; i < 7; ++i ) {
        *p++ = '=';
    }
    *p++ = '|';
    *p++ = ' ';
    p = StrCopy( buff, p );
    *p++ = ' ';
    *p++ = '|';
    for( i = 0; i < 7; ++i ) {
        *p++ = '=';
    }
    *p = '\0';
    rtn( file, TxtBuff );
    for( row = -WndTitleSize( wnd );; ++row ) {
        p = buff;
        chars_written = 0;
        for( piece = 0; ; ++piece ) {
            if( !WndGetLineAbs( wnd, row, piece, &line ) )
                break;
            indent_pos = line.indent / indent_per_char;
            while( indent_pos > chars_written ) {
                p = StrCopy( " ", p );
                ++chars_written;
            }
            if( line.bitmap ) {
                line.text = WndGadgetArray[(int)line.text[0]].chars;
                line.length = strlen( line.text );
            }
            p = StrCopy( line.text, p );
            chars_written += line.length;
        }
        if( piece == 0 )
            break;
        rtn( file, buff );
    }
    MaxGadgetLength = gadget_len;
    if( font != NULL )
        WndSetFontInfo( wnd, font );
    GUIMemFree( font );
}
Ejemplo n.º 15
0
bool GUIXCreateToolBarWithTips( gui_window *wnd, bool fixed, gui_ord height,
                                int num_toolbar_items, gui_toolbar_struct *toolinfo,
                                bool excl, gui_colour_set *plain,
                                gui_colour_set *standout, gui_rect *float_pos,
                                bool use_tips )
{
    gui_coord           size;
    gui_coord           pos;
    HWND                parent;
    HWND                toolhwnd;
    toolbarinfo         *toolbar;
    int                 i;
    TOOLITEMINFO        info;
    int                 fixed_height;
    int                 fixed_width;
    int                 adjust_amount;
    int                 width;
    int                 new_right;
    int                 bm_h;
    int                 bm_w;
    GUI_RECTDIM         left, top, right, bottom;
    int                 h;

    excl = excl;
    plain = plain;
    standout = standout;
    fixed_height = 0;
    fixed_width = 0;
    if( ( wnd == NULL ) || ( num_toolbar_items < 1 ) || ( toolinfo == NULL ) ||
        ( wnd->hwnd == NULLHANDLE ) || ( wnd->root == NULLHANDLE ) ) {
        return( FALSE );
    }
    if( wnd->toolbar != NULL ) {
        GUICloseToolBar( wnd );
    }
    wnd->toolbar = ( toolbarinfo * )GUIMemAlloc( sizeof( toolbarinfo ) );
    if( wnd->toolbar == NULL ) {
        return( FALSE );
    }
    toolbar = wnd->toolbar;
    memset( toolbar, 0, sizeof( toolbarinfo ) );
    parent = wnd->root;
    toolbar->fixedrect = wnd->hwnd_client;
    toolbar->bitmaps = (HBITMAP *)GUIMemAlloc( num_toolbar_items * sizeof( HBITMAP ) );
    if( toolbar->bitmaps == NULL ) {
        GUIMemFree( wnd->toolbar );
        wnd->toolbar = NULL;
        return( FALSE );
    }
    for( i = 0; i < num_toolbar_items; i++ ) {
        toolbar->bitmaps[i] = _wpi_loadbitmap( GUIResHInst,
                                _wpi_makeintresource( toolinfo[i].bitmap ) );
        if( height == 0 ) {
            _wpi_getbitmapdim( toolbar->bitmaps[i], &bm_w, &bm_h );
            if( bm_h > fixed_height ) {
                fixed_height = bm_h;
            }
            if( bm_w > fixed_width ) {
                fixed_width = bm_w;
            }
        }
    }
    toolbar->info.border_size.x = BORDER_AMOUNT;
    toolbar->info.border_size.y = BORDER_AMOUNT;
    /* space for border and space before border */
    adjust_amount = 2*(_wpi_getsystemmetrics( SM_CYBORDER )+BORDER_AMOUNT);
    if( height == 0 ) { /* maintian # of pixels in bitmap */
        height = fixed_height + adjust_amount + OUTLINE_AMOUNT;
        width = fixed_width + OUTLINE_AMOUNT;
    } else {
        /* only height of windows given, make bitmaps square */
        size.x = 0;
        size.y = height - 2;
        GUIScaleToScreenR( &size );
        height = size.y;
        width = size.y;
    }

    _wpi_getrectvalues( toolbar->fixedrect, &left, &top, &right, &bottom );
    h      = _wpi_getheightrect( toolbar->fixedrect );
    bottom = _wpi_cvth_y_plus1( height, h );
    top    = _wpi_cvth_y_plus1( top, h );
    _wpi_setwrectvalues( &toolbar->fixedrect, left, top, right, bottom );
    height -= adjust_amount; /* leaving just button size */
    toolbar->info.button_size.x = width;
    toolbar->info.button_size.y = height;
    bottom = height + BORDER_AMOUNT * 2 +
             _wpi_getsystemmetrics( SM_CYCAPTION ) +
             2 * ( _wpi_getsystemmetrics( SM_CYFRAME ) -
                   _wpi_getsystemmetrics( SM_CYBORDER ) );
    bottom = _wpi_cvth_y_plus1( bottom, h );
#ifdef __OS2_PM__
    bottom -= 2;
#endif
    new_right = width * num_toolbar_items -
                (num_toolbar_items - 1) * toolbar->info.border_size.x +
                left + 2 * _wpi_getsystemmetrics( SM_CXFRAME ) +
                BORDER_AMOUNT * 2;
    if( new_right < right ) {
        right = new_right;
    }

    _wpi_setwrectvalues( &toolbar->floatrect, left, top, right, bottom );
    _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&toolbar->floatrect, 2 );

    if( fixed ) {
        toolbar->info.area = toolbar->fixedrect;
        toolbar->info.style = TOOLBAR_FIXED_STYLE;
    } else {
        if( float_pos != NULL ) {
            GUICalcLocation( float_pos, &pos, &size, parent );
            _wpi_setwrectvalues( &toolbar->floatrect, pos.x, pos.y,
                                 pos.x + size.x, pos.y + size.y );
            _wpi_mapwindowpoints( parent, HWND_DESKTOP, (WPI_PPOINT)&toolbar->floatrect, 2 );
        }
        toolbar->info.area = toolbar->floatrect;
        toolbar->info.style = TOOLBAR_FLOAT_STYLE;
    }

    toolbar->info.hook = GUIToolBarProc;
    toolbar->info.helphook = GUIToolBarHelp;
    toolbar->info.background = 0;
    toolbar->info.foreground = 0;
    toolbar->num = num_toolbar_items;
    toolbar->info.is_fixed = fixed;
    toolbar->info.use_tips = use_tips;

    toolbar->hdl = ToolBarInit( parent );

    ToolBarDisplay( toolbar->hdl, &toolbar->info );

    GUIResizeBackground( wnd, TRUE );

    for( i = 0; i < num_toolbar_items; i++ ) {
        info.u.bmp = toolbar->bitmaps[i];
        info.id = (WORD)toolinfo[i].id;
        info.flags = 0;
        if( use_tips && toolinfo[i].tip != NULL ) {
            strncpy( info.tip, toolinfo[i].tip, MAX_TIP );
        } else {
            info.tip[0] = '\0';
        }
        ToolBarAddItem( toolbar->hdl, &info );
    }
    toolhwnd = ToolBarWindow( toolbar->hdl );
    _wpi_showwindow( toolhwnd, SW_SHOWNORMAL );
    _wpi_updatewindow( toolhwnd );
    return( TRUE );
}