Beispiel #1
0
static void PrintUpdate( int inx0 )
/*
 * Called when print page size (x or y) is changed.
 * Checks for valid values
 */
{
	int inx;

	DrawPrintGrid();
	ParamLoadData( &printPG );

	if (newPrintGrid.size.x > maxPageSize.x+0.01 ||
		newPrintGrid.size.y > maxPageSize.y+0.01) {
		NoticeMessage( MSG_PRINT_MAX_SIZE, _("Ok"), NULL,
				FormatSmallDistance(maxPageSize.x), FormatSmallDistance(maxPageSize.y) );
	}
	if (newPrintGrid.size.x > maxPageSize.x) {
		newPrintGrid.size.x = maxPageSize.x;
		ParamLoadControl( &printPG, 1 );
	}
	if (newPrintGrid.size.y > maxPageSize.y) {
		newPrintGrid.size.y = maxPageSize.y;
		ParamLoadControl( &printPG, 3 );
	}
	currPrintGrid = newPrintGrid;
	for ( inx = 0; inx < sizeof printPLs/sizeof printPLs[0]; inx++ ) {
		if ( inx != inx0 && printPLs[inx].context == (void*)2 )
			ParamLoadControl( &printPG, inx );
	}
	ChangeDim();
	DrawPrintGrid();
}
Beispiel #2
0
Unit
FormatSmallUserDistance(TCHAR *buffer, fixed value, bool include_unit,
                        int precision)
{
  return FormatSmallDistance(buffer, value, Units::GetUserDistanceUnit(),
                             include_unit, precision);
}
Beispiel #3
0
static void
TestSmallDistance()
{
  TCHAR buffer[256];

  // Test FormatSmallDistance()
  FormatSmallDistance(buffer, 123.4, Unit::METER);
  ok1(StringIsEqual(buffer, _T("123 m")));

  FormatSmallDistance(buffer, 123.4, Unit::METER, false);
  ok1(StringIsEqual(buffer, _T("123")));

  FormatSmallDistance(buffer, 123.4, Unit::METER, true, 1);
  ok1(StringIsEqual(buffer, _T("123.4 m")));

  FormatSmallDistance(buffer, 123.4, Unit::METER, false, 1);
  ok1(StringIsEqual(buffer, _T("123.4")));

  FormatSmallDistance(buffer, 123.4, Unit::METER, true, 2);
  ok1(StringIsEqual(buffer, _T("123.40 m")));

  FormatSmallDistance(buffer, 123.4, Unit::METER, false, 2);
  ok1(StringIsEqual(buffer, _T("123.40")));

  FormatSmallDistance(buffer, 123.4, Unit::KILOMETER);
  ok1(StringIsEqual(buffer, _T("123 m")));

  FormatSmallDistance(buffer, 123.4, Unit::KILOMETER, false);
  ok1(StringIsEqual(buffer, _T("123")));

  FormatSmallDistance(buffer, 123.4, Unit::KILOMETER, true, 1);
  ok1(StringIsEqual(buffer, _T("123.4 m")));

  FormatSmallDistance(buffer, 123.4, Unit::KILOMETER, false, 1);
  ok1(StringIsEqual(buffer, _T("123.4")));

  FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET),
                      Unit::NAUTICAL_MILES);
  ok1(StringIsEqual(buffer, _T("123 ft")));

  FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET),
                      Unit::NAUTICAL_MILES, false);
  ok1(StringIsEqual(buffer, _T("123")));

  FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET),
                      Unit::NAUTICAL_MILES, true, 1);
  ok1(StringIsEqual(buffer, _T("123.4 ft")));

  FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET),
                      Unit::NAUTICAL_MILES, false, 1);
  ok1(StringIsEqual(buffer, _T("123.4")));

  FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET),
                      Unit::STATUTE_MILES);
  ok1(StringIsEqual(buffer, _T("123 ft")));

  FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET),
                      Unit::STATUTE_MILES, false);
  ok1(StringIsEqual(buffer, _T("123")));

  FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET),
                      Unit::STATUTE_MILES, true, 1);
  ok1(StringIsEqual(buffer, _T("123.4 ft")));

  FormatSmallDistance(buffer, Units::ToSysUnit(123.4, Unit::FEET),
                      Unit::STATUTE_MILES, false, 1);
  ok1(StringIsEqual(buffer, _T("123.4")));
}