Пример #1
0
void CSizeImageDlg::OnCancel()
{
    SetUnitResolution( 0 );
    SetUnitInfo((UNIT_TYPE)(m_Units-IDC_PREF_UNITINCHES), m_UnitRes, m_Points);

    CPPViewModalDlg::OnCancel();
}
Пример #2
0
void CExpandImageDlg::OnCancel() 
{
	SetUnitResolution( 0 );
	Control.Units = m_SaveUnits;
	SetUnitInfo((UNIT_TYPE)(Control.Units-IDC_PREF_UNITINCHES), Control.UnitRes, Control.Points);
	
	CPPViewModalDlg::OnCancel();
}
Пример #3
0
void CSizeImageDlg::OnOK()
{
    if ( (FMUL( m_Resolution, m_Width ) > MAX_IMAGE_WIDTH) ||
       (FMUL( m_Resolution, m_Height) > MAX_IMAGE_HEIGHT))
    {
        Message( IDS_ETOOWIDE );
        OnCancel();            
        return;
    }
	SetUnitResolution( 0 );
	SetUnitInfo((UNIT_TYPE)(m_Units-IDC_PREF_UNITINCHES), m_UnitRes, m_Points);

    PostDoModal();

    CPPViewModalDlg::OnOK();
}
Пример #4
0
int CSizeImageDlg::SetUnitResolution( int res )
{
	int OldUnitRes;
	LPIMAGE lpImage = GetImage();

	OldUnitRes = m_UnitRes;

	if ( !(m_UnitRes = res) )
	{
		m_UnitRes =
			( lpImage ? FrameResolution(ImgGetBaseEditFrame(lpImage)) : 1000 );
	}
	// setup control library
	SetUnitInfo((UNIT_TYPE)(m_Units-IDC_PREF_UNITINCHES), m_UnitRes, m_Points);

	return( OldUnitRes );
}
Пример #5
0
BOOL CSizeImageDlg::DoSizeControls( ITEMID id, UINT codeNotify, BOOL bResAdjust )
{
    BOOL bResult = TRUE;
    HWND hDlg = GetSafeHwnd();
    BOOL Bool;
    long x, y;
    int npix, nlin;
    HWND hWnd, hControl;
    RECT rArea;
    LFIXED scale;
    LPIMAGE lpImage;
    FRMDATATYPE Type;

    lpImage = GetImage();
    ImgGetInfo(lpImage, NULL, NULL, NULL, &Type);
    npix = CROPWIDTH();
    nlin = CROPHEIGHT();

    switch( id )
    {
	    case IDC_SMARTSIZE:
	        m_SmartSize = !m_SmartSize;
	        CheckDlgButton( IDC_SMARTSIZE, m_SmartSize );
            break;

	    case IDC_MAINTAINSIZE:
	        m_MaintainSize = !m_MaintainSize;
	        if (m_MaintainSize)
		        m_Distortable = NO;

	        ControlEnable(hDlg, IDC_DISTORT, !m_MaintainSize);
	        ControlEnable(hDlg, IDC_SMARTSIZE, !m_MaintainSize);
	        Bool = !m_MaintainSize || m_Units != IDC_PREF_UNITPIXELS;
	        ControlEnable(hDlg, IDC_WIDTH, Bool);
	        ControlEnable(hDlg, IDC_HEIGHT, Bool);
	        ControlEnable(hDlg, IDC_SCALEX, Bool);
	        ControlEnable(hDlg, IDC_SCALEY, Bool);

	        if (m_MaintainSize)
	        {
		        m_Resolution = m_CropResolution = m_OrigResolution;
		        m_Width  = FGET( npix, m_CropResolution );
		        m_Height = FGET( nlin, m_CropResolution );
		        SetUnitResolution( m_CropResolution );
		        SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO );
		        SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES );
		        SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES );
	        }
	        CheckDlgButton( IDC_MAINTAINSIZE, m_MaintainSize );
	        CheckDlgButton( IDC_SMARTSIZE, !m_MaintainSize && m_SmartSize );
	        break;

	    case IDC_PREF_UNITS:
			{
			WORD wUnits;				
	        if ( !(wUnits = HandleCombo( hDlg, id, codeNotify )) )
		        break;
	        
			m_Units = wUnits;
	        SetUnitInfo((UNIT_TYPE)(m_Units-IDC_PREF_UNITINCHES), m_UnitRes, 
                m_Points);
	        CheckComboItem(hDlg, IDC_PREF_UNITS, IDC_PREF_UNITFIRST,
		        IDC_PREF_UNITLAST, m_Units);

	        Bool = !m_MaintainSize || m_Units != IDC_PREF_UNITPIXELS;
	        ControlEnable(hDlg, IDC_WIDTH, Bool);
	        ControlEnable(hDlg, IDC_HEIGHT, Bool);
	        ControlEnable(hDlg, IDC_SCALEX, Bool);
	        ControlEnable(hDlg, IDC_SCALEY, Bool);

	        if (m_MaintainSize && m_Units == IDC_PREF_UNITPIXELS)
	        {
		        m_CropResolution = m_Resolution;
		        SetUnitResolution( m_CropResolution );
		        m_Width  = FGET( npix, m_CropResolution );
		        m_Height = FGET( nlin, m_CropResolution );
		        y = FMUL( m_CropResolution, m_Height );
		        m_ScaleY = ((y*100L) + nlin/2) / nlin;
		        SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO );
		        x = FMUL( m_CropResolution, m_Width );
		        m_ScaleX = ((x*100L) + npix/2) / npix;
		        SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO );
	        }
	       	SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES );
	       	SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES );
	        SetUnitLabels();
			}
	        break;

        case IDC_DISTORT:
	        m_Distortable = !m_Distortable;
	        CheckDlgButton( IDC_DISTORT, m_Distortable );
	        if (m_Distortable)
		        m_MaintainSize = NO;
	        ControlEnable(hDlg, IDC_MAINTAINSIZE, !m_MaintainSize);
	        if ( m_ScaleX != m_ScaleY )
	        {
		        m_ScaleX = m_ScaleY;
		        x = (((long)npix * m_ScaleX)+50L)/100L;
		        m_Width  = FGET( x, m_CropResolution );
		        SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES );
		        SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO );
	        }
	        CheckDlgButton( IDC_SMARTSIZE,m_SmartSize && !m_Distortable);
	        ControlEnable( hDlg, IDC_SMARTSIZE, !m_Distortable && CANDOTRANSPARENCY(Type));
	        ControlEnable(hDlg, IDC_MAINTAINSIZE, !m_Distortable && lpImage);
	        if ( Page.PrintNumeric )
		        break;
	        if ( !(hWnd = ::GetDlgItem( hDlg,IDC_PRINTVIEWPAGE)) )
		        break;
	        if ( !(hControl = ::GetDlgItem( hDlg,IDC_PRINTVIEWIMAGE)) )
		        break;
	        SetLongBit(hControl, GWL_STYLE, IS_RATIO_CONSTRAIN,
		        !m_Distortable );
	        if (!m_Distortable)
	        {
		        ::GetWindowRect(hControl, &rArea);
		        ::ScreenToClient(hWnd, (LPPOINT)&rArea.left);
		        ::ScreenToClient(hWnd, (LPPOINT)&rArea.right);
		        ::MoveWindow(hControl, rArea.left, rArea.top,
			        RectWidth(&rArea)-1, RectHeight(&rArea)-1, TRUE);
	        }
	        break;

        case IDC_HEIGHT:
	        if ( ::GetFocus() != ::GetDlgItem( hDlg,id ) )
		        break;
	        if ( codeNotify != EN_CHANGE )
		        break;
	        m_Height = GetDlgItemSpinFixed( hDlg, IDC_HEIGHT, &Bool, YES);
	        if (m_MaintainSize)
	        {
		        scale = FGET(FUNITY, m_Height);
		        m_Resolution = FMUL(nlin, scale);
		        SetUnitResolution( m_Resolution );
		        SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO );
	        }
	        // y = number of new pixels x 100
	        y = FMUL( m_CropResolution, m_Height );
	        // calculate scale factor = (new pixels * 100) / old pixels
	        m_ScaleY = ((y * 100L) + nlin/2) / nlin;
	        SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO );
	        if ( !m_Distortable )
	        {
		        m_ScaleX = m_ScaleY;
				x = (((long)npix * (long)y) + (nlin/2))/ (long)nlin;
		        m_Width  = FGET( x, m_CropResolution );
		        SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES );
		        SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO );
	        }
	        ImageMemory( hDlg, IDC_MEMORY,
			        m_MaintainSize ? FGET(npix,1) : m_Width,
			        m_MaintainSize ? FGET(nlin,1) : m_Height,
			        m_MaintainSize ? 1 : m_Resolution, m_Depth );
	        break;

        case IDC_WIDTH:
	        if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
		        break;
	        if ( codeNotify != EN_CHANGE )
		        break;
	        m_Width = GetDlgItemSpinFixed( hDlg, IDC_WIDTH, &Bool, YES );
	        if (m_MaintainSize)
	        {
		        scale = FGET(FUNITY, m_Width);
		        m_Resolution = FMUL(npix, scale);
		        SetUnitResolution( m_Resolution );
		        SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO );
	        }
	        x = FMUL( m_CropResolution, m_Width );
	        m_ScaleX = ((x * 100L) + npix/2L) / (long)npix;
	        SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO );
	        if ( !m_Distortable )
	        {
				m_ScaleY = m_ScaleX;
				y = (((long)nlin * (long)x) + (npix/2))/ (long)npix;
		        m_Height  = FGET( y, m_CropResolution );
		        SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES );
		        SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO );
	        }
	        ImageMemory( hDlg, IDC_MEMORY,
			        m_MaintainSize ? FGET(npix,1) : m_Width,
			        m_MaintainSize ? FGET(nlin,1) : m_Height,
			        m_MaintainSize ? 1 : m_Resolution, m_Depth );
	        break;

        case IDC_RES:
	        if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
		        break;
	        if ( codeNotify != EN_CHANGE )
		        break;
	        m_Resolution = GetDlgItemSpin( hDlg, IDC_RES, &Bool, NO );
	        if ( m_Resolution <= 0 )
		        m_Resolution = 2;
	        if (m_MaintainSize)
	        {
		        m_Width = FGET(npix, m_Resolution);
		        m_Height = FGET(nlin, m_Resolution);
		        SetUnitResolution( m_Resolution );
		        if (m_Units != IDC_PREF_UNITPIXELS)
		        {
			        SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES );
			        SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES );
			        y = FMUL( m_CropResolution, m_Height );
			        m_ScaleY = ((y*100L) + nlin/2) / nlin;
			        SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO );
			        x = FMUL( m_CropResolution, m_Width );
			        m_ScaleX = ((x*100L) + npix/2) / npix;
			        SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO );
		        }
	        }
	
	        if ( m_Units == IDC_PREF_UNITPIXELS )
            {
	            if ( bResAdjust )
                { // Extract the values again (inch values changed)
			        m_CropResolution = m_Resolution;
			        SetUnitResolution( m_Resolution );
			        ::SetFocus( hWnd = ::GetDlgItem( hDlg,IDC_HEIGHT ) );
					FORWARD_WM_COMMAND(hDlg, IDC_HEIGHT, hWnd, EN_CHANGE,
									   ::SendMessage);
			        ::SetFocus( hWnd = ::GetDlgItem( hDlg,IDC_WIDTH ) );
					FORWARD_WM_COMMAND(hDlg, IDC_WIDTH, hWnd, EN_CHANGE,
									   ::SendMessage);
			        ::SetFocus( ::GetDlgItem( hDlg,id ) );
		        }
	            else
		        { // Change the edit box
			        SetUnitResolution( m_Resolution );
			        SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES);
			        SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES );
		        }
            }
	        ImageMemory( hDlg, IDC_MEMORY,
			        m_MaintainSize ? FGET(npix,1) : m_Width,
			        m_MaintainSize ? FGET(nlin,1) : m_Height,
			        m_MaintainSize ? 1 : m_Resolution, m_Depth );
	        break;

        case IDC_SCALEX:
	        if ( GetFocus() != GetDlgItem( id ) )
		        break;
	        if ( codeNotify != EN_CHANGE )
		        break;
	        m_ScaleX = GetDlgItemSpin( hDlg, IDC_SCALEX, &Bool, NO );
	        x = (((long)npix * m_ScaleX)+50L)/100L;
	        m_Width  = FGET( x, m_CropResolution );
	        SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES );
	        if (m_MaintainSize)
	        {
		        scale = FGET(FUNITY, m_Width);
		        m_Resolution = FMUL(npix, scale);
		        SetUnitResolution( m_Resolution );
		        SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO );
	        }
	        if ( !m_Distortable )
	        {
		        m_ScaleY = m_ScaleX;
		        y = (((long)nlin * m_ScaleY)+50)/100L;
		        m_Height  = FGET( y, m_CropResolution );
		        SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES );
		        SetDlgItemSpin( hDlg, IDC_SCALEY, m_ScaleY, NO );
	        }
	        ImageMemory( hDlg, IDC_MEMORY,
			        m_MaintainSize ? FGET(npix,1) : m_Width,
			        m_MaintainSize ? FGET(nlin,1) : m_Height,
			        m_MaintainSize ? 1 : m_Resolution, m_Depth );
	        break;

        case IDC_SCALEY:
	        if ( GetFocus() != GetDlgItem( id ) )
		        break;
	        if ( codeNotify != EN_CHANGE )
		        break;
	        m_ScaleY = GetDlgItemSpin( hDlg, IDC_SCALEY, &Bool, NO );
	        y = (((long)nlin * m_ScaleY)+50)/100L;
	        m_Height = FGET( y, m_CropResolution );
	        SetDlgItemSpinFixed( hDlg, IDC_HEIGHT, m_Height, YES );
	        if (m_MaintainSize)
	        {
		        scale = FGET(FUNITY, m_Height);
		        m_Resolution = FMUL(nlin, scale);
		        SetUnitResolution( m_Resolution );
		        SetDlgItemSpin( hDlg, IDC_RES, m_Resolution, NO );
	        }
	        if ( !m_Distortable )
	        {
		        m_ScaleX = m_ScaleY;
		        x = (((long)npix * m_ScaleX)+50L)/100L;
		        m_Width  = FGET( x, m_CropResolution );
		        SetDlgItemSpinFixed( hDlg, IDC_WIDTH, m_Width, YES);
		        SetDlgItemSpin( hDlg, IDC_SCALEX, m_ScaleX, NO );
	        }
	        ImageMemory( hDlg, IDC_MEMORY,
			        m_MaintainSize ? FGET(npix,1) : m_Width,
			        m_MaintainSize ? FGET(nlin,1) : m_Height,
			        m_MaintainSize ? 1 : m_Resolution, m_Depth );
	        break;

        case IDC_MEMORY:
        default:
            bResult = FALSE;
    	    break;
    }
    return bResult;        
}
Пример #6
0
BOOL CExpandImageDlg::OnCommand(WPARAM wParam, LPARAM lParam) 
{
int id = LOWORD(wParam);			//ID of control
WORD codeNotify = HIWORD(wParam);	//Control notification code
HWND hControl = (HWND) lParam;		//Handle of control


LPIMAGE     lpImage;
FRMTYPEINFO TypeInfo;
long        Color;

switch (id)
	{
	case IDC_EXPANDLEFT:
	case IDC_EXPANDRIGHT:
	case IDC_EXPANDTOP:
	case IDC_EXPANDBOTTOM:
	case IDC_HEIGHT:
	case IDC_WIDTH:
	case IDC_PREF_UNITS:
	DoExpandControls(id, codeNotify);
	break;
	
	case IDC_FILLINCOLOR:
	if (codeNotify != 1)
		break;
	lpImage = GetImage();
	if (lpImage)
	   ImgGetTypeInfo(lpImage, &TypeInfo);
	else
	   FrameSetTypeInfo(&TypeInfo, FDT_RGBCOLOR, NULL);

	if (TypeInfo.DataType == FDT_LINEART) 
		{
		if(m_FillColor.gray == 255)
			m_FillColor.gray = 0;
		else
			m_FillColor.gray = 255;
		SetColorInfo(&m_FillColor, &m_FillColor, CS_GRAY);
		}
	else if (TypeInfo.DataType == FDT_GRAYSCALE || TypeInfo.DataType == FDT_PALETTECOLOR) 
	   {
	   if (!PalettePicker(&m_FillColor, NULL, TypeInfo.ColorMap))
	      break;
	   }
	else if (!ColorPicker(&m_FillColor, NULL))
	   break;
	CopyRGB( &m_FillColor.rgb, &Color );
	SetWindowLong(::GetDlgItem(GetSafeHwnd(),IDC_FILLINCOLOR), GWL_ACTIVE, Color );
	AstralControlRepaint(GetSafeHwnd(), IDC_FILLINCOLOR);
	break;

	case IDOK:
	if ( (FMUL( m_Resolution, m_Width ) > MAX_IMAGE_WIDTH) ||
		 (FMUL( m_Resolution, m_Height) > MAX_IMAGE_HEIGHT))
		{
		Message( IDS_ETOOWIDE );
		break;
		}
	SetUnitResolution( 0 );
	Control.Units = m_SaveUnits;
	SetUnitInfo((UNIT_TYPE)(Control.Units-IDC_PREF_UNITINCHES), Control.UnitRes,
																		 Control.Points);
	AstralDlgEnd( GetSafeHwnd(), TRUE );
	break;
   
   default:
	break;
   }
	
	return CPPViewModalDlg::OnCommand(wParam, lParam);
}
Пример #7
0
VOID CExpandImageDlg::DoExpandControls(ITEMID id, UINT codeNotify )
/***********************************************************************/
{
BOOL Bool;
WORD idUnits;
LFIXED Right, Bottom;

switch( id )
    {
	case IDC_PREF_UNITS:
	if ( !(idUnits = HandleCombo( GetSafeHwnd(), id, codeNotify )) )
		break;
	Control.Units = idUnits;
	SetUnitInfo((UNIT_TYPE)(Control.Units-IDC_PREF_UNITINCHES), Control.UnitRes, Control.Points);
	CheckComboItem(GetSafeHwnd(), IDC_PREF_UNITS, IDC_PREF_UNITFIRST,
		IDC_PREF_UNITLAST, Control.Units);
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_WIDTH, m_Width, YES );
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_HEIGHT, m_Height, YES );
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_EXPANDLEFT, m_Left, YES );
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_EXPANDRIGHT, m_Width-m_OrigWidth-m_Left, YES );
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_EXPANDTOP, m_Top, YES );
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_EXPANDBOTTOM, m_Height-m_OrigHeight-m_Top, YES );
	SetUnitLabels(GetSafeHwnd());
	break;

   case IDC_HEIGHT:
	if (codeNotify == EN_KILLFOCUS)
		{
		if (m_Height < m_OrigHeight)
			{
			m_Height = m_OrigHeight;
			m_Top = 0;
			MessageBeep(0);
			SetDlgItemSpinFixed( GetSafeHwnd(), IDC_HEIGHT, m_Height, YES );
			ControlEnable(GetSafeHwnd(), IDOK, 	(m_Height > m_OrigHeight) ||
								(m_OrigHeight > m_OrigWidth));
			}
		else
			break;
		}
	else
		{
		if ( ::GetFocus() != ::GetDlgItem( GetSafeHwnd(), id ) )
			break;
		if ( codeNotify != EN_CHANGE )
			break;
		m_Height = GetDlgItemSpinFixed( GetSafeHwnd(), IDC_HEIGHT, &Bool, YES);
		if (m_Height < m_OrigHeight)
			{
			ControlEnable(GetSafeHwnd(), IDOK, FALSE);
			::SetFocus(::GetDlgItem( GetSafeHwnd(),id));
			break;
			}
		}
	if ((m_OrigHeight + m_Top) > m_Height)
		m_Top = m_Height - m_OrigHeight;
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_EXPANDTOP, m_Top, YES );
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_EXPANDBOTTOM,m_Height - m_OrigHeight- m_Top,YES );
	ImageMemory( GetSafeHwnd(), IDC_MEMORY, m_Width, m_Height, m_Resolution,
				 m_Depth );
	ControlEnable(GetSafeHwnd(), IDOK, 	(m_Height > m_OrigHeight) || (m_Width > m_OrigWidth));
	break;

    case IDC_WIDTH:
	if (codeNotify == EN_KILLFOCUS)
		{
		if (m_Width < m_OrigWidth)
			{
			m_Width = m_OrigWidth;
			m_Left = 0;
			MessageBeep(0);
			SetDlgItemSpinFixed( GetSafeHwnd(), IDC_WIDTH, m_Width, YES );
			ControlEnable(GetSafeHwnd(), IDOK, 	(m_Height > m_OrigHeight)
																 ||(m_Width > m_OrigWidth));
			}
		else
			break;
		}
	else
		{
		if ( ::GetFocus() != ::GetDlgItem( GetSafeHwnd(), id ) )
			break;
		if ( codeNotify != EN_CHANGE )
			break;
		m_Width = GetDlgItemSpinFixed( GetSafeHwnd(), IDC_WIDTH, &Bool, YES );
		if (m_Width < m_OrigWidth)
			{
			ControlEnable(GetSafeHwnd(), IDOK, FALSE);
			::SetFocus(::GetDlgItem(GetSafeHwnd(),id));
			break;
			}
		}
	if (m_OrigWidth + m_Left > m_Width)
		m_Left = m_Width - m_OrigWidth;
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_EXPANDLEFT, m_Left, YES );
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_EXPANDRIGHT, m_Width - m_OrigWidth - m_Left, YES );
	ImageMemory( GetSafeHwnd(), IDC_MEMORY, m_Width, m_Height, m_Resolution, m_Depth );
	ControlEnable(GetSafeHwnd(), IDOK, 	(m_Height > m_OrigHeight) ||(m_Width > m_OrigWidth));
	break;

	case IDC_EXPANDLEFT:
	if ( GetFocus() != GetDlgItem(id ) )
		break;
	if ( codeNotify != EN_CHANGE )
		break;
	Right = m_Width - m_OrigWidth - m_Left;
	m_Left = GetDlgItemSpinFixed(GetSafeHwnd(), id, &Bool, YES);
	m_Width = (m_OrigWidth + m_Left + Right);
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_WIDTH, m_Width, YES );
	ImageMemory( GetSafeHwnd(), IDC_MEMORY, m_Width, m_Height, m_Resolution,m_Depth );
	ControlEnable(GetSafeHwnd(), IDOK, (m_Height > m_OrigHeight) ||(m_Width > m_OrigWidth));
	break;

	case IDC_EXPANDRIGHT:
	if ( GetFocus() != GetDlgItem( id ) )
		break;
	if ( codeNotify != EN_CHANGE )
		break;
	Right = GetDlgItemSpinFixed(GetSafeHwnd(), id, &Bool, YES);
	m_Width = m_OrigWidth + m_Left+ Right;
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_WIDTH, m_Width, YES );
	ImageMemory( GetSafeHwnd(), IDC_MEMORY, m_Width, m_Height, m_Resolution,m_Depth );
	ControlEnable(GetSafeHwnd(), IDOK, 	(m_Height > m_OrigHeight) ||(m_Width > m_OrigWidth));
	break;

	case IDC_EXPANDTOP:
	if ( GetFocus() != GetDlgItem( id ) )
		break;
	if ( codeNotify != EN_CHANGE )
		break;
	Bottom = m_Height- m_OrigHeight - m_Top;
	m_Top = GetDlgItemSpinFixed(GetSafeHwnd(), id, &Bool, YES);
	m_Height = m_OrigHeight + m_Top + Bottom;
	SetDlgItemSpinFixed(GetSafeHwnd(), IDC_HEIGHT, m_Height, YES );
	ImageMemory( GetSafeHwnd(), IDC_MEMORY, m_Width, m_Height, m_Resolution,m_Depth );
	ControlEnable(GetSafeHwnd(), IDOK, 	(m_Height > m_OrigHeight) ||(m_Width > m_OrigWidth));
	break;

	case IDC_EXPANDBOTTOM:
	if ( GetFocus() != GetDlgItem(id) )
		break;
	if ( codeNotify != EN_CHANGE )
		break;
	Bottom = GetDlgItemSpinFixed(GetSafeHwnd(), id, &Bool, YES);
	m_Height = m_OrigHeight + m_Top + Bottom;
	SetDlgItemSpinFixed( GetSafeHwnd(), IDC_HEIGHT, m_Height, YES );
	ImageMemory( GetSafeHwnd(), IDC_MEMORY, m_Width, m_Height, m_Resolution,m_Depth );
	ControlEnable(GetSafeHwnd(), IDOK, 	(m_Height > m_OrigHeight) ||(m_Width > m_OrigWidth));
	break;

    default:
	break;
    }
}
Пример #8
0
LOCAL void Pos_OnCommand(HWND hDlg, int id, HWND hControl, UINT codeNotify)
/************************************************************************/
{
int						idUnits;
BOOL						Bool;
LFIXED					fx, fy;
LPIMAGE              lpImage;
int                  res;

switch (id)
	{
	case IDC_PREF_UNITS:
		if ( !(idUnits = HandleCombo( hDlg, id, codeNotify )) )
			break;
		fx = GetDlgItemSpinFixed( hDlg, IDC_POS_X, &Bool, YES);
		fy = GetDlgItemSpinFixed( hDlg, IDC_POS_Y, &Bool, YES);
		Control.Units = idUnits;
		SetUnitInfo((UNIT_TYPE)(Control.Units-IDC_PREF_UNITINCHES), Control.UnitRes, Control.Points);
		InitSpin( hDlg, fx, fy,3);
	break;

   case IDC_POS_X:
	if (codeNotify == EN_KILLFOCUS)
		{
		fx = GetDlgItemSpinFixed( hDlg, IDC_POS_X, &Bool, YES);
		InitSpin( hDlg, fx, 0,1);
		}
	else
		{
		if ( GetFocus() != GetDlgItem( hDlg, id ) )
			break;
		if ( codeNotify != EN_CHANGE )
			break;
		GetDlgItemSpinFixed( hDlg, IDC_POS_X, &Bool, YES );
      }
   break;

   case IDC_POS_Y:
	if (codeNotify == EN_KILLFOCUS)
		{
		fy = GetDlgItemSpinFixed( hDlg, IDC_POS_Y, &Bool, YES);
		InitSpin( hDlg, 0, fy,2);
		}
	else
		{
		if ( GetFocus() != GetDlgItem( hDlg, id ) )
			break;
		if ( codeNotify != EN_CHANGE )
			break;
		GetDlgItemSpinFixed( hDlg, IDC_POS_Y, &Bool, YES );
      }
   break;

	case IDOK:
      if(lpImage = GetActiveImage())
         {
		   fx = GetDlgItemSpinFixed( hDlg, IDC_POS_X, &Bool, YES );
		   fy = GetDlgItemSpinFixed( hDlg, IDC_POS_Y, &Bool, YES );

	       ImgGetInfoEx(lpImage, NULL, NULL, NULL, NULL, &res);
		   Control.Units = Edit.SaveUnits;
		   // get pixels
		   lpPosParms->iBaseRes = res;
		   lpPosParms->XOffset = FMUL(res,fx);
		   lpPosParms->YOffset = FMUL(res,fy);
		   AstralDlgEnd( hDlg, TRUE );
         }
	   break;
	
	case IDCANCEL:
		Control.Units = Edit.SaveUnits;
		AstralDlgEnd( hDlg, FALSE );
	break;
	
   default:
	break;
   }
}
Пример #9
0
BOOL CUnitsPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	BOOL 	Bool;
	LPSTR 	lpUnit;
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_PREF_USERULERS:
			View.UseRulers = !View.UseRulers;
			::CheckDlgButton( hDlg, id, View.UseRulers );
			SetModified(TRUE);
		break;

		case IDC_PREF_DISPLAYPIXELS:
			Control.DisplayPixelValue = !Control.DisplayPixelValue;
			::CheckDlgButton( hDlg, id, !Control.DisplayPixelValue );
			SetModified(TRUE);
		break;

		case IDC_PREF_SCREENWIDTH:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
				break;
			if ( codeNotify != EN_CHANGE )
				break;
			Control.ScreenWidth = AstralGetDlgItemFixed( hDlg, id, &Bool, NO);
			SetModified(TRUE);
		break;

		case IDC_PREF_UNITS:
//		case IDC_PREF_UNITINCHES:
//		case IDC_PREF_UNITMM:
//		case IDC_PREF_UNITCM:
//		case IDC_PREF_UNITPICAS:
//		case IDC_PREF_UNITPIXELS:
			if ( !(id = HandleCombo( hDlg, id, codeNotify )) )
				break;
			Control.Units = id;
			SetUnitInfo((UNIT_TYPE)(Control.Units-IDC_PREF_UNITINCHES), Control.UnitRes, Control.Points);
			if ( AstralStr( Control.Units-IDC_PREF_UNITINCHES+IDS_INCHES,
	     		&lpUnit ) )
				::SetDlgItemText( hDlg, IDC_WIDTHLABEL, lpUnit );
			ControlEnable( hDlg, IDC_PREF_SCREENWIDTH,
				Control.Units != IDC_PREF_UNITPIXELS );

			if ( Control.Units != IDC_PREF_UNITPIXELS )
				AstralSetDlgItemFixed( hDlg, IDC_PREF_SCREENWIDTH, Control.ScreenWidth, NO );
			else
				::SetDlgItemInt( hDlg, IDC_PREF_SCREENWIDTH, GetSystemMetrics( SM_CXSCREEN ), NO );
			SetModified(TRUE);
		break;

	   	default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
   	}
	return(TRUE);
}