示例#1
0
/*
 * DrawLine - draw a line on the drawing area
 */
void DrawLine( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt, int mousebutton )
{
    COLORREF    color;
    COLORREF    dithered;
    WPI_POINT   imgstart_pt;
    WPI_POINT   imgend_pt;
    wie_clrtype type;
    img_node    *node;

    CheckBounds( hwnd, start_pt );
    CheckBounds( hwnd, end_pt );
    imgstart_pt.x = start_pt->x / pointSize.x;
    imgstart_pt.y = start_pt->y / pointSize.y;
    imgend_pt.x = end_pt->x / pointSize.x;
    imgend_pt.y = end_pt->y / pointSize.y;

    dithered = GetSelectedColor( mousebutton, &color, &type );

    if( type == SCREEN_CLR ) {
        LineXorAnd( BLACK, WHITE, &imgstart_pt, &imgend_pt );
    } else if( type == INVERSE_CLR ) {
        LineXorAnd( WHITE, WHITE, &imgstart_pt, &imgend_pt );
    } else {
        LineXorAnd( color, BLACK, &imgstart_pt, &imgend_pt );
    }
    node = SelectImage( hwnd );
    InvalidateRect( node->viewhwnd, NULL, FALSE );
    BlowupImage( hwnd, NULL );

} /* DrawLine */
示例#2
0
void CDriveViewer::GridCallBack (GV_DISPINFO *pDispInfo) 
{
	pDispInfo->item.nState |= GVIS_READONLY;

	if (pDispInfo->item.row == 0)
	{
		pDispInfo->item.strText = Headers[pDispInfo->item.col];
	//	pDispInfo->item.lfFont.lfWeight  = FW_BOLD;
		return ;
	}

	int row = pDispInfo->item.row-1;
	int col = pDispInfo->item.col;

	
	if (row > static_cast<int>(m_Array.size()))
	{
		TRACE (_T("Asking for %d from %d !!!!\n"), row, m_Array.size ());
		return;
	}
	
	switch (pDispInfo->item.col)
	{
		case 0:
			{
				pDispInfo->item.iImage = m_Array[row].m_nImage;
				pDispInfo->item.strText = m_Array[row].as_text (col);
			}
			break;
		
		case 3:
		case 2:
			pDispInfo->item.nFormat |= DT_RIGHT;
			pDispInfo->item.strText.Format (_T("%s "), m_Array[row].as_text (col));			
		break;
		
		case 1:
			pDispInfo->item.strText = m_Array[row].as_text (col);					
			break;		

		default:
			pDispInfo->item.strText = m_Array[row].as_text (col);			
			break;

	}
	
	 /*pDispInfo->item.crFgClr = GetSysColor (COLOR_BTNTEXT);

	 if (pDispInfo->item.col == m_State.m_nSortColumn)
			pDispInfo->item.crBkClr = RGB(247,247,247);  */

	if (pDispInfo->item.col == m_State.m_nSortColumn)
		pDispInfo->item.crBkClr = //RGB(247,247,247);             
		HLS_TRANSFORM (GetSysColor(COLOR_WINDOW),0, 5);

	if (pDispInfo->item.nState & GVIS_SELECTED)
			pDispInfo->item.crBkClr = GetSelectedColor();	

}
示例#3
0
/*
 * SetNewPalette - set a new palette from a loaded file
 */
void SetNewPalette( a_pal_file *pal_file )
{
    int         i;
    wie_clrtype type;
    HMENU       hmenu;

    if( currentPalIndex != COLOR_16 && currentPalIndex != COLOR_256 ) {
        return;
    }

    leftColorIndex = getColorIndex( GetSelectedColor( LMOUSEBUTTON, NULL, &type ) );
    rightColorIndex = getColorIndex( GetSelectedColor( RMOUSEBUTTON, NULL, &type ) );

    for( i = 0; i < PALETTE_SIZE - 1; i++ ) {
        palette[currentPalIndex][i].rgbRed = pal_file->rgbqs[i].rgbBlue;
        palette[currentPalIndex][i].rgbGreen = pal_file->rgbqs[i].rgbGreen;
        palette[currentPalIndex][i].rgbBlue = pal_file->rgbqs[i].rgbRed;
        ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed,
                              palette[currentPalIndex][i].rgbGreen,
                              palette[currentPalIndex][i].rgbBlue ), FALSE );
        restorePalette[i] = palette[currentPalIndex][i];
    }
    palette[currentPalIndex][i].rgbRed = pal_file->rgbqs[i].rgbBlue;
    palette[currentPalIndex][i].rgbGreen = pal_file->rgbqs[i].rgbGreen;
    palette[currentPalIndex][i].rgbBlue = pal_file->rgbqs[i].rgbRed;
    restorePalette[i] = palette[currentPalIndex][i];

    ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed,
                          palette[currentPalIndex][i].rgbGreen,
                          palette[currentPalIndex][i].rgbBlue ), TRUE );
    SetCurrentColors( TRUE );

    if( HMainWindow != NULL ) {
        hmenu = GetMenu( _wpi_getframe( HMainWindow ) );
        _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, TRUE, FALSE );
    }

} /* SetNewPalette */
示例#4
0
void CRecBinViewer::GridCallBack (GV_DISPINFO *pDispInfo) 
{
	pDispInfo->item.nState |= GVIS_READONLY;

    if (pDispInfo->item.row == 0)
	{
		pDispInfo->item.strText = m_Headers[pDispInfo->item.col];
		//pDispInfo->item.lfFont.lfWeight  = FW_BOLD;
		return ;
	}

    int row = pDispInfo->item.row - 1;
    if (row >= static_cast<int>(m_List.size ()))
        return;

	if (pDispInfo->item.col == 0 )
	{
		if (m_List[row].m_PIDL)
		{
			SHFILEINFO		fi;

			ZeroMemory (&fi, sizeof (fi));				
			HRESULT hr = SHGetFileInfo ((LPCTSTR)m_List[row].m_PIDL, 0, &fi, sizeof (fi), SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_PIDL);

			if (SUCCEEDED (hr))			
				pDispInfo->item.iImage = fi.iIcon;			
		}
	}
		
	pDispInfo->item.crFgClr = GetSysColor (COLOR_BTNTEXT);

    if (pDispInfo->item.col < static_cast<int>(m_List[row].m_Ar.size()))
        pDispInfo->item.strText = m_List[row][pDispInfo->item.col];

	/*if (pDispInfo->item.col == m_State.m_nSortColumn)
		pDispInfo->item.crBkClr = RGB(247,247,247);  */

	if (pDispInfo->item.col == m_State.m_nSortColumn)
		pDispInfo->item.crBkClr = //RGB(247,247,247);             
		HLS_TRANSFORM (GetSysColor(COLOR_WINDOW),0, 5);

	if (pDispInfo->item.nState & GVIS_SELECTED)
		pDispInfo->item.crBkClr = GetSelectedColor();	
}
示例#5
0
/*
 * FillArea - fill the area
 */
void FillArea( WPI_POINT *pt, int mousebutton )
{
    WPI_POINT   devicept;
    COLORREF    color;
    wie_clrtype type;
    img_node    *node;

    devicept.x = pt->x / pointSize.x;
    devicept.y = pt->y / pointSize.y;
    color = GetSelectedColor( mousebutton, NULL, &type );

    FillXorAnd( color, &devicept, type );
    node = GetCurrentNode();
    InvalidateRect( node->viewhwnd, NULL, FALSE );
    BlowupImage( node->hwnd, NULL );
#ifdef __OS2_PM__
    currentMouseButton = currentMouseButton;    // just to suppres complaints
#endif

} /* FillArea */
示例#6
0
/*
 * EditColors - edit the current color selection
 */
void EditColors( void )
{
    static CHOOSECOLOR          choosecolor;
    BOOL                        setcolor = FALSE;
    wie_clrtype                 type;
    COLORREF                    current_color;
    HMENU                       hmenu;
    HWND                        parent;

    if( ImgedConfigInfo.show_state & SET_SHOW_CLR ) {
        parent = HColorPalette;
    } else {
        parent = HMainWindow;
    }

    current_color = GetSelectedColor( LMOUSEBUTTON, NULL, &type );

    choosecolor.lStructSize = sizeof( CHOOSECOLOR );
    choosecolor.hwndOwner = parent;
    choosecolor.hInstance = NULL;
    choosecolor.rgbResult = current_color;
    choosecolor.lpCustColors = (LPDWORD)customcolors;
    choosecolor.Flags = CC_RGBINIT | CC_FULLOPEN;
    choosecolor.lCustData = 0l;
    choosecolor.lpfnHook = 0;
    choosecolor.lpTemplateName = (LPSTR)NULL;

    setcolor = ChooseColor( &choosecolor );

    if( !setcolor ) {
        return;
    }

    ReplacePaletteEntry( choosecolor.rgbResult );
    fRestEnabled = TRUE;
    hmenu = GetMenu( HMainWindow );
    EnableMenuItem( hmenu, IMGED_CRESET, MF_ENABLED );

    PrintHintTextByID( WIE_COLORPALETTEMODIFIED, NULL );

} /* EditColors */
示例#7
0
/*
 * DisplayRegion - draw the region (rectangle or ellipse) first in the view
 *                 window, then in the draw area
 */
void DisplayRegion( HWND hwnd, WPI_POINT *start_pt, WPI_POINT *end_pt, int mousebutton )
{
    COLORREF    color;
    COLORREF    dithered;
    COLORREF    solid;
    WPI_POINT   imgstart_pt;
    WPI_POINT   imgend_pt;
    WPI_RECT    rect;
    BOOL        dofillrgn;
    BOOL        is_rect;
    wie_clrtype type;
    img_node    *node;
    int         tmps;
    int         tmpe;

    CheckBounds( hwnd, start_pt );
    CheckBounds( hwnd, end_pt );
    tmps = start_pt->x / pointSize.x;
    tmpe = end_pt->x / pointSize.x;
    imgstart_pt.x = tmps;
    if( imgstart_pt.x > tmpe )
        imgstart_pt.x = tmpe;
    imgend_pt.x = tmps;
    if( imgend_pt.x > tmpe )
        imgend_pt.x = tmpe;
    imgend_pt.x++;

    tmps = start_pt->y / pointSize.y;
    tmpe = end_pt->y / pointSize.y;
    imgstart_pt.y = tmps;
#ifdef __OS2_PM__
    if( imgstart_pt.y < tmpe )
        imgstart_pt.y = tmpe;
#else
    if( imgstart_pt.y > tmpe )
        imgstart_pt.y = tmpe;
#endif
    imgend_pt.y = tmps;
#ifdef __OS2_PM__
    if( imgend_pt.y > tmpe )
        imgend_pt.y = tmpe;
    --imgend_pt.y;
#else
    if( imgend_pt.y < tmpe )
        imgend_pt.y = tmpe;
    ++imgend_pt.y;
#endif

    dithered = GetSelectedColor( mousebutton, &solid, &type );
    switch( toolType ) {
    case IMGED_RECTO:
        dofillrgn = FALSE;
        is_rect = TRUE;
        color = solid;
        break;

    case IMGED_RECTF:
        dofillrgn = TRUE;
        is_rect = TRUE;
        color = dithered;
        break;

    case IMGED_CIRCLEO:
        dofillrgn = FALSE;
        is_rect = FALSE;
        color = solid;
        break;

    case IMGED_CIRCLEF:
        dofillrgn = TRUE;
        is_rect = FALSE;
        color = dithered;
        break;

    default:
        return;
    }

    _wpi_setrectvalues( &rect, imgstart_pt.x, imgstart_pt.y, imgend_pt.x, imgend_pt.y );
    if( type == SCREEN_CLR ) {
        RegionXorAnd( BLACK, WHITE, dofillrgn, &rect, is_rect );
    } else if( type == INVERSE_CLR ) {
        RegionXorAnd( WHITE, WHITE, dofillrgn, &rect, is_rect );
    } else {
        RegionXorAnd( color, BLACK, dofillrgn, &rect, is_rect );
    }

    node = GetCurrentNode();
    InvalidateRect( node->viewhwnd, NULL, FALSE );
    BlowupImage( hwnd, NULL );

} /* DisplayRegion */
示例#8
0
/*
 * DrawPt - actually draw the point on the drawing region (uses LineDDA)
 */
void CALLBACK DrawPt( int xpos, int ypos, WPI_PARAM2 lparam )
{
    HBRUSH      colorbrush;
    HBRUSH      oldbrush;
    HPEN        colorpen;
    HPEN        oldpen;
    COLORREF    selected_color;
    COLORREF    dithered;
    short       mousebutton;
    WPI_PRES    pres;
    HWND        hwnd;
    short       area_x;
    short       area_y;
    short       width;
    short       height;
    short       i;
    short       j;
    WPI_POINT   pt;
    WPI_RECT    rcclient;
    wie_clrtype type;
    int         brushsize;
    BOOL        gridvisible;

    hwnd = (HWND)GET_HWND_PARAM2( lparam );
    mousebutton = currentMouseButton;
    _wpi_getclientrect( hwnd, &rcclient );
    brushsize = ImgedConfigInfo.brush_size;

    gridvisible = (ImgedConfigInfo.grid_on &&
                   pointSize.x >= POINTSIZE_MIN && pointSize.y >= POINTSIZE_MIN);
    if( !gridvisible && toolType == IMGED_FREEHAND ) {
        area_x = xpos * pointSize.x;
        area_y = ypos * pointSize.y;
        width = (short)pointSize.x;
        height = (short)pointSize.y;
    } else if( !gridvisible && toolType == IMGED_BRUSH ) {
        area_x = 0;
        if( xpos > brushsize )
            area_x = ( xpos - brushsize / 2 ) * pointSize.x;
        area_y = 0;
        if( ypos > brushsize )
            area_y = ( ypos - brushsize / 2 ) * pointSize.y;
        width = (short)(brushsize * pointSize.x);
        height = (short)(brushsize * pointSize.y);
        /*
         * We just have to check that we don't spill over the image dimensions.
         */
        if( area_x > _wpi_getwidthrect( rcclient ) - width )
            area_x = _wpi_getwidthrect( rcclient ) - width;
        if( area_y > _wpi_getheightrect( rcclient ) - width ) {
            area_y = _wpi_getheightrect( rcclient ) - width;
        }
    } else if( gridvisible && toolType == IMGED_FREEHAND ) {
        area_x = xpos * pointSize.x + 1;
        area_y = ypos * pointSize.y + 1;
        width = (short)(pointSize.x - 1);
        height = (short)(pointSize.y - 1);
    } else {
        area_x = 0;
        if( xpos > brushsize )
            area_x = ( xpos - brushsize / 2 ) * pointSize.x;
        ++area_x;
        area_y = 0;
        if( ypos > brushsize )
            area_y = ( ypos - brushsize / 2 ) * pointSize.y;
        ++area_y;
        width = (short)(pointSize.x - 1);
        height = (short)(pointSize.y - 1);
        /*
         * We just have to check that we don't spill over the image dimensions.
         */
        if( area_x > _wpi_getwidthrect( rcclient ) - pointSize.x * brushsize + 1 )
            area_x = _wpi_getwidthrect( rcclient ) - pointSize.x * brushsize + 1;
        if( area_y > _wpi_getheightrect( rcclient ) - pointSize.y * brushsize + 1 ) {
            area_y = _wpi_getheightrect( rcclient ) - pointSize.y * brushsize + 1;
        }
    }

    pres = _wpi_getpres( hwnd );
    _wpi_torgbmode( pres );
    dithered = GetSelectedColor( mousebutton, &selected_color, &type );

    colorbrush = _wpi_createsolidbrush( selected_color );
    oldbrush = _wpi_selectobject( pres, colorbrush );
    colorpen = _wpi_createpen( PS_SOLID, 0, selected_color );
    oldpen = _wpi_selectobject( pres, colorpen );

    if( gridvisible && toolType == IMGED_BRUSH ) {
        for( i = 0; i < brushsize; i++ ) {
            for( j = 0; j < brushsize; j++ ) {
                _wpi_patblt( pres, area_x + i * pointSize.x, area_y + j * pointSize.y,
                             width, height, PATCOPY );
            }
        }
    } else {
        _wpi_patblt( pres, area_x, area_y, width, height, PATCOPY );
    }

    _wpi_selectobject( pres, oldbrush );
    _wpi_selectobject( pres, oldpen );
    _wpi_releasepres( hwnd, pres );

    _wpi_deleteobject( colorbrush );
    _wpi_deleteobject( colorpen );

    pt.x = area_x / pointSize.x;
    pt.y = area_y / pointSize.y;
    if( toolType == IMGED_BRUSH ) {
        if( type == SCREEN_CLR ) {
            BrushThePoints( selected_color, BLACK, WHITE, &pt, brushsize );
        } else if( type == INVERSE_CLR ) {
            BrushThePoints( selected_color, WHITE, WHITE, &pt, brushsize );
        } else {
            BrushThePoints( selected_color, selected_color, BLACK, &pt, brushsize );
        }
    } else {
        if( type == SCREEN_CLR ) {
            DrawThePoints( selected_color, BLACK, WHITE, &pt );
        } else if( type == INVERSE_CLR ) {
            DrawThePoints( selected_color, WHITE, WHITE, &pt );
        } else {
            DrawThePoints( selected_color, selected_color, BLACK, &pt );
        }
    }

} /* DrawPt */
示例#9
0
/*
 * DrawSinglePoint - needed for when the mouse button is initially pressed
 */
void DrawSinglePoint( HWND hwnd, WPI_POINT *pt, short mousebutton )
{
    HBRUSH      colorbrush;
    HBRUSH      oldbrush;
    HPEN        colorpen;
    HPEN        oldpen;
    COLORREF    selected_color;
    COLORREF    dithered;
    short       truncated_x;
    short       truncated_y;
    short       i;
    short       j;
    WPI_POINT   logical_pt;
    WPI_RECT    rcclient;
    short       width;
    short       height;
    short       wndwidth;
    short       wndheight;
    wie_clrtype type;
    WPI_PRES    pres;
    int         brushsize;
    BOOL        gridvisible;

    GetClientRect( hwnd, &rcclient );
    wndwidth = _wpi_getwidthrect( rcclient );
    wndheight = _wpi_getheightrect( rcclient );
    brushsize = ImgedConfigInfo.brush_size;

    CheckBounds( hwnd, pt );

    gridvisible = (ImgedConfigInfo.grid_on &&
                   pointSize.x >= POINTSIZE_MIN && pointSize.y >= POINTSIZE_MIN);
    if( gridvisible ) {
        if( toolType == IMGED_BRUSH ) {
            truncated_x = 0;
            if( pointSize.x > brushsize )
                truncated_x = ( pt->x / pointSize.x - brushsize / 2 ) * pointSize.x;
            ++truncated_x;

            truncated_y = 0;
            if( pointSize.y > brushsize )
                truncated_y = ( pt->y / pointSize.y - brushsize / 2 ) * pointSize.y;
            ++truncated_y;
            width = (short)(pointSize.x - 1);
            height = (short)(pointSize.y - 1);
            /*
             * We just have to check that we don't spill over the image dimensions
             */
            if( truncated_x > wndwidth - pointSize.x * brushsize + 1 )
                truncated_x = wndwidth - pointSize.x * brushsize + 1;
            if( truncated_y > wndheight - pointSize.y * brushsize + 1 ) {
                truncated_y = wndheight - pointSize.y * brushsize + 1;
            }
        } else {
            truncated_x = (pt->x / pointSize.x) * pointSize.x + 1;
            truncated_y = (pt->y / pointSize.y) * pointSize.y + 1;
            width = (short)(pointSize.x - 1);
            height = (short)(pointSize.y - 1);
        }
    } else {
        if( toolType == IMGED_BRUSH ) {
            truncated_x = 0;
            if( pointSize.x > brushsize )
                truncated_x = ( pt->x / pointSize.x - brushsize / 2 ) * pointSize.x;
            truncated_y = 0;
            if( pointSize.y > brushsize )
                truncated_y = ( pt->y / pointSize.y - brushsize / 2 ) * pointSize.y;
            width = (short)(pointSize.x * brushsize);
            height = (short)(pointSize.y * brushsize);
            /*
             * We just have to check that we don't spill over the image dimensions
             */
            if( truncated_x > wndwidth - width )
                truncated_x = wndwidth - width;
            if( truncated_y > wndheight - width ) {
                truncated_y = wndheight - width;
            }
        } else {
            truncated_x = (pt->x / pointSize.x) * pointSize.x;
            truncated_y = (pt->y / pointSize.y) * pointSize.y;
            width = (short)pointSize.x;
            height = (short)pointSize.y;
        }
    }
    logical_pt.x = truncated_x / pointSize.x;
    logical_pt.y = truncated_y / pointSize.y;

    pres = _wpi_getpres( hwnd );
    _wpi_torgbmode( pres );
    dithered = GetSelectedColor( mousebutton, &selected_color, &type );
    colorbrush = _wpi_createsolidbrush( selected_color );
    oldbrush = _wpi_selectobject( pres, colorbrush );
    colorpen = _wpi_createpen( PS_SOLID, 0, selected_color );
    oldpen = _wpi_selectobject( pres, colorpen );

    if( gridvisible && toolType == IMGED_BRUSH ) {
        for( i = 0; i < brushsize; i++ ) {
            for( j = 0; j < brushsize; j++ ) {
                _wpi_patblt( pres, truncated_x + i * pointSize.x,
                             truncated_y + j * pointSize.y, width, height, PATCOPY );
            }
        }
    } else {
        _wpi_patblt( pres, truncated_x, truncated_y, width, height, PATCOPY );
    }

    _wpi_selectobject( pres, oldbrush );
    _wpi_selectobject( pres, oldpen );
    _wpi_releasepres( hwnd, pres );

    _wpi_deleteobject( colorbrush );
    _wpi_deleteobject( colorpen );

    /*
     * Draw the points in the view window.
     */
    if( toolType == IMGED_BRUSH ) {
        if( type == SCREEN_CLR ) {
            BrushThePoints( selected_color, BLACK, WHITE, &logical_pt, brushsize );
        } else if( type == INVERSE_CLR ) {
            BrushThePoints( selected_color, WHITE, WHITE, &logical_pt, brushsize );
        } else {
            BrushThePoints( selected_color, selected_color, BLACK, &logical_pt, brushsize );
        }
    } else {
        if( type == SCREEN_CLR ) {
            DrawThePoints( selected_color, BLACK, WHITE, &logical_pt );
        } else if( type == INVERSE_CLR ) {
            DrawThePoints( selected_color, WHITE, WHITE, &logical_pt );
        } else {
            DrawThePoints( selected_color, selected_color, BLACK, &logical_pt );
        }
    }

} /* DrawSinglePoint */
示例#10
0
/*
 * RestoreColorPalette - restore the color palette to the hard-coded colors
 *                       in the initialization routine
 */
void RestoreColorPalette( void )
{
    int         i;
    COLORREF    leftcolor;
    COLORREF    rightcolor;
    COLORREF    color;
    WPI_PRES    pres;
    int         leftindex;
    int         rightindex;
    wie_clrtype lefttype;
    wie_clrtype righttype;
    HMENU       hmenu;
    HWND        frame;

    if( currentPalIndex != COLOR_16 && currentPalIndex != COLOR_256 ) {
        return;
    }
    leftcolor = GetSelectedColor( LMOUSEBUTTON, NULL, &lefttype );
    rightcolor = GetSelectedColor( RMOUSEBUTTON, NULL, &righttype );

    leftindex = getColorIndex( leftcolor );
    rightindex = getColorIndex( rightcolor );

    InitPalette();
    for( i = 0; i < PALETTE_SIZE - 1; i++ ) {
        ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed,
                              palette[currentPalIndex][i].rgbGreen,
                              palette[currentPalIndex][i].rgbBlue ), FALSE );
    }
    /*
     * We do the last one separately to invalidate the window.
     */
    ShowNewColor( i, RGB( palette[currentPalIndex][i].rgbRed,
                          palette[currentPalIndex][i].rgbGreen,
                          palette[currentPalIndex][i].rgbBlue ), TRUE );

    if( lefttype == NORMAL_CLR ) {
        color = RGB( palette[currentPalIndex][leftindex].rgbRed,
                     palette[currentPalIndex][leftindex].rgbGreen,
                     palette[currentPalIndex][leftindex].rgbBlue );
        pres = _wpi_getpres( HWND_DESKTOP );
        _wpi_torgbmode( pres );
        SetColor( LMOUSEBUTTON, color, _wpi_getnearestcolor( pres, color ), NORMAL_CLR );
        _wpi_releasepres( HWND_DESKTOP, pres );
    }
    if( righttype == NORMAL_CLR ) {
        color = RGB( palette[currentPalIndex][rightindex].rgbRed,
                     palette[currentPalIndex][rightindex].rgbGreen,
                     palette[currentPalIndex][rightindex].rgbBlue );
        pres = _wpi_getpres( HWND_DESKTOP );
        _wpi_torgbmode( pres );
        SetColor( RMOUSEBUTTON, color, _wpi_getnearestcolor( pres, color ), NORMAL_CLR );
        _wpi_releasepres( HWND_DESKTOP, pres );
    }

    PrintHintTextByID( WIE_PALETTERESTORED, NULL );

    if( HMainWindow != NULL ) {
        frame = _wpi_getframe( _wpi_getframe( HMainWindow ) );
        hmenu = GetMenu( frame );
        _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE );
    }

} /* RestoreColorPalette */
示例#11
0
/*
 * SetCurrentColors - set the current color selection (we need to be
 *                    careful that the image supports the current palette)
 */
void SetCurrentColors( BOOL fshowscreenclrs )
{
    COLORREF    leftcolor;
    COLORREF    rightcolor;
    COLORREF    solid;
    wie_clrtype type;
    WPI_PRES    pres;

    leftcolor = GetSelectedColor( LMOUSEBUTTON, NULL, &type );
    if( type == NORMAL_CLR ) {
        leftcolor = GetPaletteColor( leftColorIndex );
        if( currentPalIndex == COLOR_16 || currentPalIndex == COLOR_256 ) {
            pres = _wpi_getpres( HWND_DESKTOP );
            _wpi_torgbmode( pres );
            solid = _wpi_getnearestcolor( pres, leftcolor );
            _wpi_releasepres( HWND_DESKTOP, pres );
        } else if( currentPalIndex == COLOR_2 &&
                   leftColorIndex / 2 == (leftColorIndex + 1) / 2 ) {
            solid = WHITE;
        } else {
            solid = BLACK;
        }
        SetColor( LMOUSEBUTTON, leftcolor, solid, NORMAL_CLR );
    } else if( !fshowscreenclrs ) {
        leftcolor = GetPaletteColor( 1 );
        if( currentPalIndex == COLOR_16 || currentPalIndex == COLOR_256 ) {
            pres = _wpi_getpres( HWND_DESKTOP );
            _wpi_torgbmode( pres );
            solid = _wpi_getnearestcolor( pres, leftcolor );
            _wpi_releasepres( HWND_DESKTOP, pres );
        } else if( currentPalIndex == COLOR_2 ) {
            solid = BLACK;
        }
        SetColor( LMOUSEBUTTON, leftcolor, solid, NORMAL_CLR );
    } else {
        SetColor( LMOUSEBUTTON, leftcolor, leftcolor, type );
    }

    rightcolor = GetSelectedColor( RMOUSEBUTTON, NULL, &type );
    if( type == NORMAL_CLR ) {
        rightcolor = GetPaletteColor( rightColorIndex );
        if( currentPalIndex == COLOR_16 || currentPalIndex == COLOR_256 ) {
            pres = _wpi_getpres( HWND_DESKTOP );
            _wpi_torgbmode( pres );
            solid = _wpi_getnearestcolor( pres, rightcolor );
            _wpi_releasepres( HWND_DESKTOP, pres );
        } else if( currentPalIndex == COLOR_2 &&
                   rightColorIndex / 2 == (rightColorIndex + 1) / 2 ) {
            solid = WHITE;
        } else {
            solid = BLACK;
        }
        SetColor( RMOUSEBUTTON, rightcolor, solid, NORMAL_CLR );
    } else if( !fshowscreenclrs ) {
        rightcolor = GetPaletteColor( 0 );
        if( currentPalIndex == COLOR_16 || currentPalIndex == COLOR_256 ) {
            pres = _wpi_getpres( HWND_DESKTOP );
            _wpi_torgbmode( pres );
            solid = _wpi_getnearestcolor( pres, rightcolor );
            _wpi_releasepres( HWND_DESKTOP, pres );
        } else if( currentPalIndex == COLOR_2 ) {
            solid = WHITE;
        }
        SetColor( RMOUSEBUTTON, rightcolor, solid, NORMAL_CLR );
    } else {
        SetColor( RMOUSEBUTTON, rightcolor, rightcolor, type );
    }

} /* SetCurrentColors */