Пример #1
0
/*
 * SetNumColors - set the number of colors in the image and repaint the window
 */
void SetNumColors( int number_of_colors )
{
    HMENU       hmenu;
    HWND        frame;

    if( numberOfColors == number_of_colors ) {
        return;
    }
    SetCurrentNumColors( number_of_colors );
    numberOfColors = number_of_colors;
    initPaletteBoxes( FALSE );
    _wpi_invalidaterect( hColorsWnd, NULL, FALSE );

    if( numberOfColors == 2 ) {
        if( HMainWindow != NULL ) {
            frame = _wpi_getframe( HMainWindow );
            hmenu = GetMenu( frame );
            if( _wpi_isitemenabled( hmenu, IMGED_RCOLOR ) ) {
                prevRestoreState = TRUE;
            } else {
                prevRestoreState = FALSE;
            }
            _wpi_enablemenuitem( hmenu, IMGED_SCOLOR, FALSE, FALSE );
            _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, FALSE, FALSE );
            _wpi_enablemenuitem( hmenu, IMGED_LCOLOR, FALSE, FALSE );
        }
    } else {
        if( HMainWindow != NULL ) {
            frame = _wpi_getframe( HMainWindow );
            hmenu = GetMenu( frame );
            _wpi_enablemenuitem( hmenu, IMGED_SCOLOR, TRUE, FALSE );
            _wpi_enablemenuitem( hmenu, IMGED_RCOLOR, prevRestoreState, FALSE );
            _wpi_enablemenuitem( hmenu, IMGED_LCOLOR, TRUE, FALSE );
        }
    }

} /* SetNumColors */
Пример #2
0
/*
 * SetToolType - set the tool type
 */
int SetToolType( int toolid )
{
    HMENU       hmenu;
    int         i;
    int         prev_tool;
    img_node    *node;

    if( toolType == IMGED_CLIP ) {
        node = GetCurrentNode();
        if( node != NULL ) {
            RedrawPrevClip( node->hwnd );
            SetRectExists( FALSE );
        }
    }

    prev_tool = toolType;
    toolType = toolid;

    if( toolid == IMGED_PASTE || toolid == IMGED_SNAP ) {
        return( prev_tool );
    }

    if( HMainWindow == NULL ) {
        return( 0 );
    }
    hmenu = _wpi_getmenu( _wpi_getframe( HMainWindow ) );

    switch( toolid ) {
    case IMGED_FREEHAND:
        setTheCursor( PENCIL_CUR, NULL );
        break;
    case IMGED_LINE:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_HOTSPOT:
        setTheCursor( HOTSPOT_CUR, NULL );
        break;
    case IMGED_RECTO:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_RECTF:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_CIRCLEO:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_CIRCLEF:
        setTheCursor( CROSS_CUR, NULL );
        break;
    case IMGED_FILL:
        setTheCursor( FILL_CUR, NULL );
        break;
    case IMGED_BRUSH:
        setTheCursor( BRUSH_CUR, NULL );
        if( prev_tool != IMGED_PASTE && prev_tool !=IMGED_SNAP ) {
            WriteSetSizeText( WIE_BRUSHSIZEIS, ImgedConfigInfo.brush_size,
                              ImgedConfigInfo.brush_size );
        }
        break;
    case IMGED_CLIP:
        setTheCursor( CROSS_CUR, NULL );
        break;

    default:
        setTheCursor( PENCIL_CUR, NULL );
        toolType = IMGED_FREEHAND;
        break;
    }

    for( i = IMGED_CLIP; i <= IMGED_HOTSPOT; i++ ) {
#if 0
        if( _wpi_isitemenabled( hmenu, i ) ) {
            _wpi_checkmenuitem( hmenu, i, FALSE, FALSE );
        }
#else
        if( _wpi_isitemchecked( hmenu, i ) ) {
            _wpi_checkmenuitem( hmenu, i, FALSE, FALSE );
        }
#endif
    }
    _wpi_checkmenuitem( hmenu, toolType, TRUE, FALSE );

    SetDrawTool( toolType );
    return( prev_tool );

} /* SetToolType */