Exemple #1
0
void GUIPaint( gui_window *wnd, HWND hwnd, bool isdlg )
{
    HDC         prev_hdc;
    PAINTSTRUCT *prev_ps;
    gui_row_num row_num;
    PAINTSTRUCT ps;
    WPI_RECT    fill_area;
#ifdef __OS2_PM__
    ULONG       flags;
    RECTL       client;
#endif

    isdlg=isdlg;
    /* save old state */
    prev_hdc = wnd->hdc;
    prev_ps = wnd->ps;

    /* Setup Paint */
    wnd->ps = &ps;
    wnd->hdc = _wpi_beginpaint( hwnd, NULLHANDLE, wnd->ps );
    _wpi_torgbmode( wnd->hdc );
    _wpi_getpaintrect( wnd->ps, &fill_area );
#ifdef __OS2_PM__
    fill_area = *(wnd->ps);
    if( isdlg ) {
        _wpi_inflaterect( GUIMainHInst, &fill_area, 10, 10);
    }
    WinFillRect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ) );
#endif
#if defined( __NT__ )
    if( isdlg ) {
        _wpi_fillrect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ),
                       wnd->bk_brush );
    }
#endif
    if( wnd->font != NULL ) {
        wnd->prev_font = _wpi_selectfont( wnd->hdc, wnd->font );
    } else {
        wnd->prev_font = NULL;
    }

    /* send paint to app */
    GUIGetUpdateRows( wnd, hwnd, &row_num.start, &row_num.num );
    if( row_num.num > 0 ) {
        GUIEVENTWND( wnd, GUI_PAINT, &row_num );
    }

    /* finish painting */
    if( wnd->prev_font != NULL ) {
        _wpi_getoldfont( wnd->hdc, wnd->prev_font );
        wnd->prev_font = NULL;
    }

#ifdef __OS2_PM__
    if( isdlg ) {
        flags = DB_AREAATTRS | DB_DLGBORDER;
  #ifdef _M_I86
        if( WinQueryActiveWindow( HWND_DESKTOP, FALSE ) != hwnd ) {
  #else
        if( WinQueryActiveWindow( HWND_DESKTOP ) != hwnd ) {
  #endif
        //if( _wpi_getfocus() != hwnd ) {
            flags |= DB_PATINVERT;
        }
        WinQueryWindowRect( hwnd, &client );
        WinDrawBorder( wnd->hdc, &client, 1, 1, 0, 0, flags );
    }
#endif

    _wpi_endpaint( hwnd, wnd->hdc, wnd->ps );

    /* restore old state */
    wnd->hdc = prev_hdc;
    wnd->ps = prev_ps;
}

#else

// this is some experimental PM stuff
void GUIPaint( gui_window *wnd, HWND hwnd, bool isdlg )
{
    HDC         prev_hdc;
    PAINTSTRUCT *prev_ps;
    gui_row_num row_num;
    PAINTSTRUCT ps;
    PAINTSTRUCT fill_area;

    // experimenal stuff
    HPS                 hps;
    RECTL               client;
    LONG                width, height;
    ULONG               flags;
    int                 compat_created;
    gui_paint_info      *pinfo;

    // figure out which paint info to use
    if( !isdlg && wnd->root == hwnd ) {
        pinfo = &wnd->root_pinfo;
    } else {
        pinfo = &wnd->hwnd_pinfo;
    }
    pinfo->in_use++;
    compat_created = FALSE;

    /* save old state */
    prev_hdc = wnd->hdc;
    prev_ps = wnd->ps;
    if( isdlg ) {
        _wpi_getclientrect( hwnd, &client );
    } else {
        WinQueryWindowRect( hwnd, &client );
    }
    width = client.xRight - client.xLeft;
    height = client.yTop - client.yBottom;

    wnd->ps = &ps;
    //hps = _wpi_beginpaint( hwnd, pinfo->normal_pres, wnd->ps );
    hps = _wpi_beginpaint( hwnd, NULL, wnd->ps );
    if( pinfo->compatible_pres == (WPI_PRES)NULL ) {
        compat_created = TRUE;
        pinfo->compatible_pres = _wpi_createcompatiblepres( hps, GUIMainHInst, &pinfo->compatible_hdc );
        pinfo->draw_bmp = _wpi_createcompatiblebitmap( hps, width, height );
        pinfo->old_bmp = _wpi_selectbitmap( pinfo->compatible_pres, pinfo->draw_bmp );
    }

    // the condition is here VERY conservative!!
    // its gains have to analyzed
    if( compat_created || pinfo->force_count ) {
        wnd->hdc = pinfo->compatible_pres;
        //wnd->hdc = hps;
        _wpi_torgbmode( wnd->hdc );
        fill_area = *(wnd->ps);
        if( isdlg ) {
            _wpi_inflaterect( GUIMainHInst, &fill_area, 10, 10);
        }
        WinFillRect( wnd->hdc, &fill_area, GUIGetBack( wnd, GUI_BACKGROUND ) );
        wnd->prev_font = NULL;
        if( wnd->font != NULL ) {
            wnd->prev_font = _wpi_selectfont( wnd->hdc, wnd->font );
        }

        /* send paint to app */
        GUIGetUpdateRows( wnd, hwnd, &row_num.start, &row_num.num );
        if( row_num.num > 0 ) {
            GUIEVENTWND( wnd, GUI_PAINT, &row_num );
        }

        /* finish painting */
        if( wnd->prev_font != NULL ) {
            _wpi_getoldfont( wnd->hdc, wnd->prev_font );
            wnd->prev_font = NULL;
        }

        if( pinfo->force_count ) {
            //pinfo->force_count--;
        }
    }

    //_wpi_bitblt( hps, client.xLeft, client.yBottom, width, height,
    //       wnd->hdc, 0, 0, SRCCOPY );

    if( pinfo->in_use == 1 ) {
        //_wpi_bitblt( hps, client.xLeft, client.yBottom, width, height,
        //               wnd->hdc, 0, 0, SRCCOPY );
        _wpi_bitblt( hps, ps.xLeft, ps.yBottom,
                     ps.xRight - ps.xLeft,
                     ps.yTop - ps.yBottom,
                     wnd->hdc,
                     ps.xLeft, ps.yBottom,
                     SRCCOPY );
        if( pinfo->delete_when_done ) {
            GUIFreePaintHandles( pinfo, TRUE );
        }
    }

    if( isdlg ) {
        flags = DB_AREAATTRS | DB_DLGBORDER;
  #ifdef _M_I86
        if( WinQueryActiveWindow( HWND_DESKTOP, FALSE ) != hwnd ) {
  #else
        if( WinQueryActiveWindow( HWND_DESKTOP ) != hwnd ) {
  #endif
        //if( _wpi_getfocus() != hwnd ) {
            flags |= DB_PATINVERT;
        }
        WinQueryWindowRect( hwnd, &client );
        WinDrawBorder( hps, &client, 1, 1, 0, 0, flags );
    }

    _wpi_endpaint( hwnd, hps, wnd->ps );

    /* restore old state */
    wnd->hdc = prev_hdc;
    wnd->ps = prev_ps;

    if( pinfo->in_use ) {
        pinfo->in_use--;
    }
}

#endif

void GUIInvalidatePaintHandles( gui_window *wnd )
{
    GUIFreeWndPaintHandles( wnd, FALSE );
}
Exemple #2
0
/*
 * StatusWndCallback - handle messages for the status window
 */
WPI_MRESULT CALLBACK StatusWndCallback( HWND hwnd, WPI_MSG msg, WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    PAINTSTRUCT ps;
    WPI_RECT    r;
    int         i;
    WPI_PRES    pres;
    statwnd     *sw;

    sw = (statwnd *)_wpi_getwindowlongptr( hwnd, classWinExtra );

    if( statusWndHookFunc != NULL ) {
        if( statusWndHookFunc( hwnd, msg, wparam, lparam ) ) {
            return( 0 );
        }
    }

    if( (msg == WM_SIZE || msg == WM_PAINT) && sw == NULL ) {
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
    }

    switch( msg ) {
    case WM_CREATE:
        _wpi_setwindowlongptr( hwnd, classWinExtra, (LONG_PTR)currentStatWnd );
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
    case WM_SIZE:
        GetClientRect( hwnd, &sw->statusRect );
        sw->wndHeight = _wpi_getheightrect( sw->statusRect );
        _wpi_inflaterect( classHandle, &sw->statusRect, -HORZ_BORDER, -VERT_BORDER );
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
    case WM_PAINT:
        pres = _wpi_beginpaint( hwnd, NULLHANDLE, &ps );
#ifdef __OS2_PM__
        WinFillRect( pres, &ps, CLR_PALEGRAY );
#endif
#ifdef __NT__
        /*
         * We have to do this little trick because currently this window does not receive
         * the WM_SYSCOLORCHANGE message when it should.
         */
        if( colorButtonFace != GetSysColor( COLOR_BTNFACE ) ) {
            RECT rs;
            if( hasGDIObjects ) {
                _wpi_deleteobject( penLight );
                _wpi_deleteobject( penShade );
                _wpi_deleteobject( brushButtonFace );
            }
            colorButtonFace = GetSysColor( COLOR_BTNFACE );
            _wpi_setbackcolour( pres, colorButtonFace );
            brushButtonFace = CreateSolidBrush( colorButtonFace );
            penLight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );
            penShade = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
            hasGDIObjects = true;
            GetClientRect( hwnd, &rs );
            FillRect( pres, &rs, brushButtonFace );
        }
#endif
        StatusWndDraw3DBox( sw, pres );
        if( initPRES( sw, pres ) ) {
            for( i = 0; i <= sw->numSections; i++ ) {
                if( sw->sectionData[i] != NULL ) {
                    getRect( sw, &r, i );
                    makeInsideRect( &r );
                    _wpi_drawtext( pres, sw->sectionData[i], -1, &r, sw->sectionDataFlags[i] );
                }
            }
            finiPRES( pres );
        }
        _wpi_endpaint( hwnd, pres, &ps );
        break;
#ifdef __NT__
    case WM_SYSCOLORCHANGE:
        if( hasGDIObjects ) {
            DeleteObject( penLight );
            DeleteObject( penShade );
            DeleteObject( brushButtonFace );
            hasGDIObjects = false;
        }
        colorButtonFace = GetSysColor( COLOR_BTNFACE );
        colorTextFace = GetSysColor( COLOR_BTNTEXT );
        brushButtonFace = CreateSolidBrush( colorButtonFace );
        penLight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) );
        penShade = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) );
        hasGDIObjects = true;
        break;
#endif
    case WM_ERASEBKGND:
#ifdef __NT__
        if( colorButtonFace != GetSysColor( COLOR_BTNFACE ) ) {
            /*
             * If WM_SYSCOLORCHANGE message is not received by this window, we
             * have to fake it.
             */
            SendMessage( hwnd, WM_SYSCOLORCHANGE, 0, 0L );
        }
#endif
        GetClientRect( hwnd, &r );
        _wpi_unrealizeobject( brushButtonFace );
        _wpi_fillrect( (WPI_PRES)wparam, &r, colorButtonFace, brushButtonFace );
        break;
    default:
        return( _wpi_defwindowproc( hwnd, msg, wparam, lparam ) );
    }
    return( 0 );

} /* StatusWndCallback */