Exemplo n.º 1
0
/*
 * SetViewWindow - set whether there is a single view window or multiple ones
 */
void SetViewWindow( BOOL justone )
{
    WPI_ENUMPROC        fp_enum;
    int                 prev_show_state;

    fOneViewWindow = justone;

    if( !justone ) {
        if( _wpi_iswindow( Instance, ClientWindow ) ) {
            fp_enum = _wpi_makeenumprocinstance( ViewEnumProc, Instance );
            _wpi_enumchildwindows( ClientWindow, fp_enum, 0L );
            _wpi_freeprocinstance( fp_enum );
        }
    } else {
        prev_show_state = showState;
        showState = SW_HIDE;
        if( _wpi_iswindow( Instance, ClientWindow ) ) {
            fp_enum = _wpi_makeenumprocinstance( ViewEnumProc, Instance );
            _wpi_enumchildwindows( ClientWindow, fp_enum, 0L );
            _wpi_freeprocinstance( fp_enum );
        }
        showState = prev_show_state;
        if( _wpi_iswindow( Instance, hViewWindow ) ) {
            ShowWindow( hViewWindow, showState );
        }
    }

} /* SetViewWindow */
Exemplo n.º 2
0
/*
 * CheckViewItem - handle when the view window option is selected from the menu
 */
void CheckViewItem( HMENU hmenu )
{
    WPI_ENUMPROC        fp_enum;

    if( _wpi_isitemchecked( hmenu, IMGED_VIEW ) ) {
        _wpi_checkmenuitem( hmenu, IMGED_VIEW, MF_UNCHECKED, FALSE );
        showState = SW_HIDE;
        ImgedConfigInfo.show_state &= ~SET_SHOW_VIEW;
    } else {
        _wpi_checkmenuitem( hmenu, IMGED_VIEW, MF_CHECKED, FALSE );
        showState = SW_SHOWNORMAL;
        ImgedConfigInfo.show_state |= SET_SHOW_VIEW;
    }

    if( hViewWindow == NULL ) {
        return;
    }

    ShowWindow( _wpi_getframe( hViewWindow ), showState );
    if( _wpi_iswindow( Instance, ClientWindow ) ) {
        fp_enum = _wpi_makeenumprocinstance( ViewEnumProc, Instance );
        _wpi_enumchildwindows( ClientWindow, fp_enum, 0L );
        _wpi_freeprocinstance( fp_enum );
    }

} /* CheckViewItem */
Exemplo n.º 3
0
/*
 * CheckGridItem - Check the grid item and display the grid if necessary.
 *                 First we check if an item has been created or not, if not
 *                 we just check some flags so that when it is created, a
 *                 grid will (not) be displayed.
 */
void CheckGridItem( HMENU hmenu )
{
    WPI_ENUMPROC        fp_enum;
    HCURSOR             prevcursor;

    prevcursor = _wpi_setcursor( _wpi_getsyscursor(IDC_WAIT) );
    if ( _wpi_isitemchecked(hmenu, IMGED_GRID) ) {
        _wpi_checkmenuitem( hmenu, IMGED_GRID, MF_UNCHECKED, FALSE );
        ImgedConfigInfo.grid_on = FALSE;
        BlowupImage( NULL, NULL );
        PrintHintTextByID( WIE_GRIDTURNEDOFF, NULL );
    } else {
        _wpi_checkmenuitem( hmenu, IMGED_GRID, MF_CHECKED, FALSE );
        ImgedConfigInfo.grid_on = TRUE;
        BlowupImage( NULL, NULL );
        PrintHintTextByID( WIE_GRIDTURNEDON, NULL );
    }
    PressGridButton();

    if( DoImagesExist() ) {
        fp_enum = _wpi_makeenumprocinstance( GridEnumProc, Instance );
        _wpi_enumchildwindows( ClientWindow, fp_enum, 0L );
        _wpi_freeprocinstance( fp_enum );
    }
    _wpi_setcursor( prevcursor );
} /* CheckGridItem */
Exemplo n.º 4
0
bool GUIDoCreateResDialog( long dlg_id, HWND parent, void *data )
{
    WPI_PROC    fp;

    fp = _wpi_makeprocinstance( (WPI_PROC)GUIDialogFunc, GUIMainHInst );
    if( !fp ) {
        return( FALSE );
    }
    if( _wpi_dialogbox( parent, (LPVOID)fp, GUIResHInst, DLG_RESOURCE(dlg_id), data ) == -1 ) {
        _wpi_freeprocinstance( fp );
        return( FALSE );
    }
    _wpi_freeprocinstance( fp );

    return( TRUE );
}
Exemplo n.º 5
0
/*
 * Paint - When the mouse button is down, we want to paint on the
 *                   drawing area.
 */
void Paint( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt, int mousebutton )
{
    WPI_POINT           s_pt;
    WPI_POINT           e_pt;
    WPI_PARAM2          lparam;
    WPI_LINEDDAPROC     fp;

    s_pt.x = MAKELOGPTX(start_pt->x);
    s_pt.y = MAKELOGPTY(start_pt->y);
    e_pt.x =  MAKELOGPTX(end_pt->x);
    e_pt.y = MAKELOGPTY(end_pt->y);

    CheckBounds( hwnd, &s_pt );
    CheckBounds( hwnd, &e_pt );

    s_pt.x = s_pt.x / pointSize.x;
    s_pt.y = s_pt.y / pointSize.y;
    e_pt.x = e_pt.x / pointSize.x;
    e_pt.y = e_pt.y / pointSize.y;

    currentMouseButton = mousebutton;
    SET_HWND_PARAM2( lparam, hwnd );
    fp = _wpi_makelineddaprocinstance( drawPt, Instance );
    _wpi_linedda( s_pt.x, s_pt.y, e_pt.x, e_pt.y, (WPI_LINEDDAPROC)fp, lparam);
    _wpi_freeprocinstance( fp );

    DrawSinglePoint( hwnd, end_pt, mousebutton );
    memcpy(start_pt, end_pt, sizeof(WPI_POINT));
} /* Paint */
Exemplo n.º 6
0
bool GUIInsertResDialogControls( gui_window *wnd )
{
    WPI_ENUMPROC        enum_func;

    enum_func = _wpi_makeenumprocinstance( (WPI_PROC)InsertResDlgCntlFunc, GUIMainHInst );
    _wpi_enumchildwindows( wnd->hwnd, enum_func, (LPARAM)wnd );
    _wpi_freeprocinstance( (WPI_PROC)enum_func );

    return( TRUE );
}
Exemplo n.º 7
0
/*
 * CreateStatusFont - creates the font used in the status window
 */
void CreateStatusFont( void )
{
    WPI_LOGFONT                 logfont;
    WPI_PROC                    fp;
    WPI_PRES                    pres;

    pres = _wpi_getpres( HWND_DESKTOP );
#ifdef __OS2_PM__
    _wpi_enumfonts( pres, NULL, (WPI_ENUMFONTPROC)EnumFontFunc, "Helv" );
    fp = fp;
#else
    fp = _wpi_makeprocinstance( EnumFontFunc, Instance );
#ifdef __NT__
    EnumFonts( hdc, NULL, (LPVOID)fp, (LPARAM)(LPCSTR)"ms sans serif");
#else
    EnumFonts( hdc, NULL, (LPVOID)fp, (LPVOID)"ms sans serif");
#endif
#endif
    _wpi_freeprocinstance( fp );

    if( currentLogFont == NULL ) {
//      SmallFont = GetStockObject( ANSI_FIXED_FONT );
//      GetObject( SmallFont, sizeof( LOGFONT ), (LPSTR) &logfont );
//      SmallFont = CreateFontIndirect( &logfont );
    } else {
        memcpy( &logfont, currentLogFont, sizeof(WPI_LOGFONT) );
//      _wpi_setfontheight( &logfont, 11 );
//      _wpi_setfontwidth( &logfont, 10 );
        _wpi_setfontpointsize( &logfont, 10, 0, _wpi_fontmatch(&logfont) );
        _wpi_createrealfont( logfont, SmallFont );

#if 0
        SmallFont = CreateFont(
            10,
            0,
            0,
            0,
            FW_NORMAL,
            FALSE,
            FALSE,
            FALSE,
            currentLogFont->lfCharSet,
            OUT_DEFAULT_PRECIS,
            CLIP_DEFAULT_PRECIS,
            DEFAULT_QUALITY,
            currentLogFont->lfPitchAndFamily,
            currentLogFont->lfFaceName );
#endif
        free( currentLogFont );
        currentLogFont = NULL;
    }
    _wpi_releasepres( HWND_DESKTOP, pres );
} /* CreateStatusFont */
Exemplo n.º 8
0
extern void GUIEnumChildWindows( gui_window *wnd, ENUMCALLBACK *func, void *param )
{
    WPI_ENUMPROC    fp;
    enum_info       info;

    fp = _wpi_makeenumprocinstance( GUIEnumChildWindowsEnumFunc, GUIMainHInst );
    info.parent = wnd;
    info.func = func;
    info.param = param;
    _wpi_enumchildwindows( wnd->hwnd, fp, (LPARAM)&info );
    _wpi_freeprocinstance( (WPI_PROC)fp );
}
Exemplo n.º 9
0
void GUIUnHookF1( void )
{
    if( F1Hooked == 1 ) {
#ifndef __OS2_PM__
        UnhookWindowsHookEx( F1HookHandle );
#else
        WinReleaseHook( GUIMainHInst.hab, HMQ_CURRENT, HK_INPUT,
                        (PFN) F1ProcInst, GUIMainHInst.mod_handle );
#endif
        _wpi_freeprocinstance( F1ProcInst );
    }

    if( F1Hooked != 0 ) {
        F1Hooked--;
    }
}
Exemplo n.º 10
0
/*
 * SetViewBkColor - set the background color (and appropriate inverse)
 */
void SetViewBkColor( COLORREF color )
{
    WPI_ENUMPROC        fp_enum;

    if( color == bkgroundColor ) {
        return;
    }

    bkgroundColor = color;
    if( !_wpi_iswindow( Instance, hViewWindow ) ) {
        return;
    }
    InvalidateRect( hViewWindow, NULL, TRUE );

    fp_enum = _wpi_makeenumprocinstance( BkColorEnumProc, Instance );
    _wpi_enumchildwindows( ClientWindow, fp_enum, 0L );
    _wpi_freeprocinstance( fp_enum );

} /* SetViewBkColor */
Exemplo n.º 11
0
/*
 * SelectOptions - bring up the current settings dialog box
 */
void SelectOptions( void )
{
    WPI_PROC        fp;
    WPI_DLGRESULT   button_type;
    HMENU           hmenu;

    fp = _wpi_makeprocinstance( (WPI_PROC)CurrentSettingsProc, Instance );
    button_type = _wpi_dialogbox( HMainWindow, (WPI_DLGPROC)fp, Instance, CURRENT_SETTINGS, 0L );
    _wpi_freeprocinstance( fp );

    if( button_type == DLGID_CANCEL ) {
        return;
    }

    hmenu = GetMenu( _wpi_getframe( HMainWindow ) );
    if( fCheckSquareGrid ) {
        CheckSquareGrid( hmenu );
    }

} /* SelectOptions */
Exemplo n.º 12
0
/*
 * readInResourceFile
 */
static bool readInResourceFile( char *fullname )
{
    BYTE                *data;
    uint_32             dsize;
    WRInfo              *info;
    WRSelectImageInfo   *sii;
    WPI_PROC            cb;
    bool                ok;

    info = NULL;
    sii = NULL;
    data = NULL;
    ok = (fullname != NULL);

    if( ok ) {
        info = WRLoadResource( fullname, WR_DONT_KNOW );
        ok = (info != NULL);
    }

    if( ok ) {
        cb = _wpi_makeprocinstance( (WPI_PROC)IEHelpCallBack, Instance );
        sii = WRSelectImage( HMainWindow, info, cb );
        _wpi_freeprocinstance( cb );
        ok = (sii != NULL && sii->lnode != NULL);
    }

    if( ok ) {
        if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) {
            imgType = BITMAP_IMG;
            data = WRCopyResData( info, sii->lnode );
            dsize = sii->lnode->Info.Length;
            ok = (data != NULL);
            if( ok ) {
                ok = WRAddBitmapFileHeader( &data, &dsize );
            }
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) {
            imgType = CURSOR_IMG;
            ok = WRCreateCursorData( info, sii->lnode, &data, &dsize );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) {
            imgType = ICON_IMG;
            ok = WRCreateIconData( info, sii->lnode, &data, &dsize );
        } else {
            imgType = UNDEF_IMG;
            ok = false;
        }
    }

    if( ok ) {
        if( sii->type == (uint_16)(pointer_int)RT_BITMAP ) {
            ok = ReadBitmapFromData( data, fullname, info, sii->lnode );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_CURSOR ) {
            ok = ReadCursorFromData( data, fullname, info, sii->lnode );
        } else if( sii->type == (uint_16)(pointer_int)RT_GROUP_ICON ) {
            ok = ReadIconFromData( data, fullname, info, sii->lnode );
        }
    }

    if( sii != NULL ) {
        WRFreeSelectImageInfo( sii );
    }

    if( data != NULL ) {
        MemFree( data );
    }

    return( ok );

} /* readInResourceFile */
Exemplo n.º 13
0
/*
 * FindOrigin - "cascade" the windows to find the placement of the new MDI child
 *            - origin is expected to come in as (0, 0) or the equivalent for PM
 */
void FindOrigin( WPI_POINT *new_origin )
{
    WPI_ENUMPROC    fp;
    int             image_count;
    int             i, j;
    WPI_POINT       temp;
    WPI_RECT        proposed;
    WPI_RECTDIM     width;
    int             base;

    image_count = DoImagesExist();

    if( image_count == 0 ) {
        return;
    }

#ifdef __OS2_PM__
    imageMax = image_count;
#endif
    windowCoords = MemAlloc( image_count * sizeof( WPI_POINT ) );
    windowIndex = 0;

    fp = _wpi_makeenumprocinstance( GetPosProc, Instance );
    _wpi_enumchildwindows( ClientWindow, fp, 0L );
    _wpi_freeprocinstance( fp );

    /*
     * I'm just using a simple bubble sort ... we're using small amounts of data
     */
    for( i = 0; i < image_count; i++ ) {
        for( j = 0; j < image_count - i - 1; j++ ) {
            if( windowCoords[j].x > windowCoords[j + 1].x ) {
                temp = windowCoords[j];
                windowCoords[j] = windowCoords[j + 1];
                windowCoords[j + 1] = temp;
            }
        }
    }

    /*
     * Minimized windows will have coordinates set to negative, and we only
     * want non-minimized windows.
     */
    for( base = 0; base < image_count; base++ ) {
        if( windowCoords[base].x >= 0 ) {
            break;
        }
    }
    if( base >= image_count ) {
        MemFree( windowCoords );
        return;
    }

    width = _wpi_getsystemmetrics( SM_CYCAPTION );
#ifndef __OS2_PM__
    _wpi_setintrectvalues( &proposed, new_origin->x, new_origin->y,
                           new_origin->x + width, new_origin->y + width );
#else
    _wpi_setrectvalues( &proposed, new_origin->x, new_origin->y - 1,
                        new_origin->x + width, new_origin->y + width - 1 );
#endif

    /*
     * Try to place at the origin passed in if we can.
     */
    if( !_wpi_ptinrect( &proposed, windowCoords[base] ) ) {
        MemFree( windowCoords );
        return;
    }

    for( i = base; i < image_count - 1; i++ ) {
        if( windowCoords[i + 1].x - windowCoords[i].x > 2 * width ) {
            break;
        }
    }

    temp.x = windowCoords[i].x + width;
#ifndef __OS2_PM__
    temp.y = windowCoords[i].x + width;
#else
    temp.y = windowCoords[i].y - width;
#endif

    _wpi_getclientrect( ClientWindow, &proposed );
#ifndef __OS2_PM__
    if( !_wpi_ptinrect( &proposed, temp ) ) {
        return;
    } else {
        new_origin->x = temp.x;
        new_origin->y = temp.y;
    }
#else
    new_origin->x = temp.x;
    new_origin->y = temp.y;
#endif

    MemFree( windowCoords );

} /* FindOrigin */
Exemplo n.º 14
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 = (LPVOID)NULL;
    if( hookFileDlg ) {
        wofn.lpfnHook = (LPVOID) _wpi_makeprocinstance( (LPVOID) 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 ) {
#if !defined(__NT__)
        _wpi_freeprocinstance( (WPI_PROC)wofn.lpfnHook );
#endif
    }

    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 */