コード例 #1
0
int GetDlgItemSpin(
	HWND  hWindow,
	int   idControl,
	LPINT lpTranslated,
	BOOL  bSigned)
{
	HWND hEditControl;
	HWND hSpinControl;
	int iMin, iMax, iValue, iNewValue;
	STRING szString;
	long l;

	iValue = GetDlgItemInt( hWindow, idControl, lpTranslated, bSigned );

	/* Get the handle to the control */
	if ( !(hEditControl = GetDlgItem( hWindow, idControl ) ) )
		return( iValue );

	if ( !(hSpinControl = GetWindow(hEditControl, GW_HWNDNEXT) ) )
		return( iValue );

	if ( GetDlgCtrlID(hSpinControl) != idControl )
		return( iValue );

	iMin = (int)GetWindowWord( hSpinControl, GWW_SPINMIN );
	iMax = (int)GetWindowWord( hSpinControl, GWW_SPINMAX );

	if ( !iValue && !(*lpTranslated))
	{ // if zero from the control, check to see if it's empty (which is OK)
		GetDlgItemText(hWindow, idControl, szString, MAX_STR_LEN);
		if ( !lstrlen( szString ) )
			return( iMin); // it's empty
	  	if ( bSigned && szString[0] == '-' && szString[1] == '\0' )
			return( iMin); // it's a minus sign
		l = atol(szString);
		iNewValue = mbound(l, iMin, iMax);
	}
	else if (iValue < iMin)
		iNewValue = iMin;
	else if (iValue > iMax)
		iNewValue = iMax;
	else if (!(*lpTranslated))
		iNewValue = iValue; //  != 0 so was partialy translated
	else
	{
		return( iValue );
	}

	MessageBeep(0);
	iNewValue = mbound(iNewValue, INT_MIN, INT_MAX);
	SetDlgItemInt( hWindow, idControl, iNewValue, bSigned );

	return( iNewValue );
}
コード例 #2
0
void HandleSpinValue(
	HWND 	hWindow,
	BOOL 	bInTopRect,
	BOOL	bInBottomRect)
{
	LFIXED fValue;
	int    iValue;
	BOOL   Bool;
	STRING szString;
	long   l;
	long   step;

	step = GetWindowLong( hWindow, GWL_SPINSTEP );

	if ( GetWindowWord( hWindow, GWW_SPINTYPE ) )
	{ // Its a fixed spinner...
		fValue = GetWindowLong(hWindow, GWL_FSPINVALUE);

		if (bInTopRect) 
			fValue = BumpFixedSpinnerValue(fValue, TRUE,  step);
		else if (bInBottomRect)
			fValue = BumpFixedSpinnerValue(fValue, FALSE, step);

		SetDlgItemSpinFixed(GetParent(hWindow),
			GET_WINDOW_ID(hWindow), fValue, step == 0);
	}
	else
	{
		iValue = GetDlgItemInt( GetParent(hWindow), 
			GET_WINDOW_ID(hWindow), &Bool, YES );

		if ( !iValue && !Bool)
		{ // if zero from the control, check to see if it's empty (which is OK)
			GetDlgItemText( GetParent(hWindow),GET_WINDOW_ID(hWindow),
				szString, MAX_STR_LEN);
			l = atol(szString);
			iValue = mbound(l, INT_MIN, INT_MAX);
		}

		if (step == 0)
		{
			if ( bInTopRect )	 iValue++;
			if ( bInBottomRect ) iValue--;
		}
		else
		{
			if ( bInTopRect )	 iValue += step;
			if ( bInBottomRect ) iValue -= step;
		}

		SetDlgItemSpin( GetParent(hWindow), GET_WINDOW_ID(hWindow),
			iValue, YES );
	}
}
コード例 #3
0
int SetDlgItemSpin(
	HWND hWindow,
	int  idControl,
	int  iValue,
	BOOL bSigned)
{
	HWND hEditControl;
	HWND hSpinControl;
	int  iMin, iMax;

	/* Get the handle to the control */
	if ( !(hEditControl = GetDlgItem( hWindow, idControl ) ) )
		goto Exit;

	if ( !(hSpinControl = GetWindow(hEditControl, GW_HWNDNEXT) ) )
		goto Exit;

	if ( GetDlgCtrlID(hSpinControl) != idControl )
		goto Exit;

	if ( GetWindowLong(hEditControl, GWL_STYLE) & WS_DISABLED )
		goto Exit;

	iMin = (int)GetWindowWord( hSpinControl, GWW_SPINMIN );
	iMax = (int)GetWindowWord( hSpinControl, GWW_SPINMAX );

	if (iValue < iMin)
	{
		MessageBeep(0);
		iValue = iMin;
	}
	else
	if (iValue > iMax)
	{
		MessageBeep(0);
		iValue = iMax;
	}

Exit:
	iValue = mbound(iValue, INT_MIN, INT_MAX);

	SetDlgItemInt( hWindow, idControl, iValue, bSigned );

	return(iValue);
}
コード例 #4
0
BOOL Palette_FillEntries( LPPALETTE lpHeadPalette, int iPalette, int iAfter,
                           LPCOLORINFO lpColor1, LPCOLORINFO lpColor2,
                           int iEntries, BOOL DoHSL )
/************************************************************************/
{
	LFIXED rate1, rate2;
	long range1, range2, range3;
	int  start1, start2, start3;

	int iNewColors, iColors;
	LPCOLORINFO lpNewColors, lpSrc, lpDst;
	int iBefore, i, n, iStart, j;
	LPPALETTE lpPalette;
	BOOL fDoHS, fDoSL, fDoHL, fDoRG, fDoGB, fDoRB;
	BYTE Value;

	lpPalette = Palette_Get(lpHeadPalette, NULL, iPalette);
	if (!lpPalette)
		return(FALSE);

	iStart = iAfter;

	if (DoHSL)
		{
		range1 = (long)lpColor2->hsl.hue - (long)lpColor1->hsl.hue;
		range2 = (long)lpColor2->hsl.sat - (long)lpColor1->hsl.sat;
		range3 = (long)lpColor2->hsl.lum - (long)lpColor1->hsl.lum;
		}
	else
		{
		range1 = (long)lpColor2->rgb.red   - (long)lpColor1->rgb.red;
		range2 = (long)lpColor2->rgb.green - (long)lpColor1->rgb.green;
		range3 = (long)lpColor2->rgb.blue  - (long)lpColor1->rgb.blue;
		}

	if (iEntries)
		iNewColors = iEntries;
	else
	{
		iNewColors = max(max(abs(range1), abs(range2)), abs(range3));
		iNewColors -= 2;
	}

	if (iNewColors <= 0)
		return(FALSE);

	fDoRG = iNewColors == 256 && !DoHSL && OPTION1;
	fDoGB = iNewColors == 256 && !DoHSL && OPTION2;
	fDoRB = iNewColors == 256 && !DoHSL && OPTION3;
	fDoHS = iNewColors == 256 && DoHSL && OPTION1;
	fDoSL = iNewColors == 256 && DoHSL && OPTION2;
	fDoHL = iNewColors == 256 && DoHSL && OPTION3;

	iColors     = lpPalette->iColors + iNewColors;
	lpNewColors = (LPCOLORINFO)Alloc((long)iColors*(long)sizeof(COLORINFO));

	if (!lpNewColors)
		return(FALSE);

	iBefore = iAfter + 1;
	lpSrc   = lpPalette->lpColorInfo;
	lpDst   = lpNewColors;

	if (lpPalette->iColors && iBefore > 0)
	{
		copy((LPTR)lpSrc, (LPTR)lpDst, iBefore*sizeof(COLORINFO));
		lpSrc += iBefore;
		lpDst += iBefore;
	}

	if (fDoHS || fDoSL || fDoHL)
	{
		if (fDoHS)
			Value = lpColor1->hsl.lum;
		else if (fDoSL)
			Value = lpColor1->hsl.hue;
		else
			Value = lpColor1->hsl.sat;

		rate1 = FGET(251, 15);
		rate2 = FGET(255, 15);
		for (i = 0; i < 16; ++i)
		{
			for (j = 0; j < 16; ++j)
			{
				if (fDoHL)
				{
					n = FMUL(i, rate1);
					lpDst->hsl.hue = mbound( n, 0, 251 );
					lpDst->hsl.sat = Value;
					n = FMUL(j, rate2);
					lpDst->hsl.lum = mbound( n, 0, 255 );
				}
				else
				if (fDoHS)
				{
					n = FMUL(i, rate1);
					lpDst->hsl.hue = mbound( n, 0, 251 );
					n = FMUL(j, rate2);
					lpDst->hsl.sat = mbound( n, 0, 255 );
					lpDst->hsl.lum = Value;
				}
				else  // fDoSL
				{
					lpDst->hsl.hue = Value;
					n = FMUL(i, rate2);
					lpDst->hsl.sat = mbound( n, 0, 255 );
					n = FMUL(j, rate2);
					lpDst->hsl.lum = mbound( n, 0, 255 );
				}

				SetColorInfo( lpDst, lpDst, CS_HSL );
				++lpDst;
			}
		}
	}
	else if (fDoRG || fDoGB || fDoRB)
	{
		if (fDoRG)
			Value = lpColor1->rgb.blue;
		else if (fDoGB)
			Value = lpColor1->rgb.red;
		else
			Value = lpColor1->rgb.green;
		rate1 = FGET(255, 15);
		for (i = 0; i < 16; ++i)
		{
			for (j = 0; j < 16; ++j)
			{
				if (fDoRG)
				{
					n = FMUL(i, rate1);
					lpDst->rgb.red = mbound( n, 0, 255 );
					n = FMUL(j, rate1);
					lpDst->rgb.green = mbound( n, 0, 255 );
					lpDst->rgb.blue = Value;
				}
				else
				if (fDoGB)
				{
					lpDst->rgb.red = Value;
					n = FMUL(i, rate1);
					lpDst->rgb.green = mbound( n, 0, 255 );
					n = FMUL(j, rate1);
					lpDst->rgb.blue = mbound( n, 0, 255 );
				}
				else  // fDoRB
				{
					n = FMUL(i, rate1);
					lpDst->rgb.red = mbound( n, 0, 255 );
					lpDst->rgb.green = Value;
					n = FMUL(j, rate1);
					lpDst->rgb.blue = mbound( n, 0, 255 );
				}

				SetColorInfo( lpDst, lpDst, CS_RGB );
				++lpDst;
			}
		}
	}
	else if (DoHSL)
	{
		start1 = lpColor1->hsl.hue;
		start2 = lpColor1->hsl.sat;
		start3 = lpColor1->hsl.lum;

		for (i = 0; i < iNewColors; ++i)
		{
			// range from 0 to 1
			rate1 = FGET(i+1, iNewColors+1);

			n = start1 + WHOLE(rate1*range1);
			lpDst->hsl.hue = mbound( n, 0, 255 );
			n = start2 + WHOLE(rate1*range2);
			lpDst->hsl.sat = mbound( n, 0, 255 );
			n = start3 + WHOLE(rate1*range3);
			lpDst->hsl.lum = mbound( n, 0, 255 );

			SetColorInfo( lpDst, lpDst, CS_HSL );
			++lpDst;
		}
	}
	else
	{
		start1 = lpColor1->rgb.red;
		start2 = lpColor1->rgb.green;
		start3 = lpColor1->rgb.blue;

		for (i = 0; i < iNewColors; ++i)
		{
			// range from 0 to 1
			rate1 = FGET(i+1, iNewColors+1);

			n = start1 + WHOLE(rate1*range1);
			lpDst->rgb.red   = mbound( n, 0, 255 );
			n = start2 + WHOLE(rate1*range2);
			lpDst->rgb.green = mbound( n, 0, 255 );
			n = start3 + WHOLE(rate1*range3);
			lpDst->rgb.blue  = mbound( n, 0, 255 );

			SetColorInfo( lpDst, lpDst, CS_RGB );
			++lpDst;
		}
	}

	iAfter = lpPalette->iColors-iAfter-1;

	if (lpPalette->iColors && iAfter > 0)
		copy((LPTR)lpSrc, (LPTR)lpDst, iAfter*sizeof(COLORINFO));

	if (lpPalette->lpColorInfo)
		FreeUp((LPTR)lpPalette->lpColorInfo);

	lpPalette->lpColorInfo = lpNewColors;
	lpPalette->iColors = iColors;

	Palette_AppendAdjustLabels(lpHeadPalette, iPalette, iStart, iNewColors);

	return(TRUE);
}