static void MCInterfaceMarginsParse(MCExecContext& ctxt, MCStringRef p_input, MCInterfaceMargins& r_output)
{
    if (MCU_stoi2(p_input, r_output . margin))
    {
        r_output . type = kMCInterfaceMarginsTypeSingle;
        return;
    }

    if (MCU_stoi2x4(p_input, r_output . margins[0], r_output . margins[1], r_output . margins[2], r_output . margins[3]))
    {
        r_output . type = kMCInterfaceMarginsTypeQuadruple;
        return;
    }
    
    ctxt . LegacyThrow(EE_OBJECT_MARGINNAN);
}
Beispiel #2
0
Exec_stat MCF_parsetextatts(Properties which, MCStringRef data,
                            uint4 &flags, MCStringRef &fname, uint2 &height,
                            uint2 &size, uint2 &style)
{
	int2 i1;
	switch (which)
	{
	case P_TEXT_ALIGN:
		flags &= ~F_ALIGNMENT;
		if (MCStringIsEqualToCString(data, MCleftstring, kMCCompareCaseless) || MCStringIsEmpty(data))
			flags |= F_ALIGN_LEFT;
		else
			if (MCStringIsEqualToCString(data, MCcenterstring, kMCCompareCaseless))
				flags |= F_ALIGN_CENTER;
			else
				if (MCStringIsEqualToCString(data, MCrightstring, kMCCompareCaseless))
					flags |= F_ALIGN_RIGHT;
				else
					if (MCStringIsEqualToCString(data, MCjustifystring, kMCCompareCaseless))
						flags |= F_ALIGN_JUSTIFY;
					else
					{
						MCeerror->add(EE_OBJECT_BADALIGN, 0, 0, data);
						return ES_ERROR;
					}
		break;
	case P_TEXT_FONT:
		{// MW-2012-02-17: [[ IntrinsicUnicode ]] Strip any lang tag from the
			//   fontname.
			uindex_t t_offset;
			if (MCStringFirstIndexOfChar(data, ',', 0, kMCCompareExact, t_offset))
				/* UNCHECKED */ MCStringCopySubstring(data, MCRangeMake(t_offset + 1, MCStringGetLength(data) - (t_offset + 1)), fname);
			else
				fname = MCValueRetain(data);
		}
		break;
	case P_TEXT_HEIGHT:
		if (!MCU_stoi2(data, i1))
		{
			MCeerror->add
			(EE_OBJECT_TEXTHEIGHTNAN, 0, 0, data);
			return ES_ERROR;
		}
		height = i1;
		break;
	case P_TEXT_SIZE:
		if (MCStringIsEmpty(data))
			i1 = 0;
		else
			if (!MCU_stoi2(data, i1))
			{
				MCeerror->add
				(EE_OBJECT_TEXTSIZENAN, 0, 0, data);
				return ES_ERROR;
			}
		size = i1;
		break;
	case P_TEXT_STYLE:
		{
			// MW-2012-02-17: [[ SplitTextAttrs ]] If the string is empty, then
			//   return 0 for the style - indicating to unset the property.
            if (MCStringIsEmpty(data))
				style = 0;
			else
            {
                style = FA_DEFAULT_STYLE;
                uindex_t t_start_pos, t_end_pos;
                t_end_pos = 0;
                
                while (t_end_pos < MCStringGetLength(data))
                {
                    t_start_pos = t_end_pos;
                    // skip spaces at the beginning or after a comma (if any)
                    MCU_skip_spaces(data, t_start_pos);
                    
                    uindex_t t_comma;
                    if (!MCStringFirstIndexOfChar(data, ',', t_start_pos, kMCCompareExact, t_comma))
                        t_end_pos = MCStringGetLength(data);
                    else
                        t_end_pos = t_comma;
                    
                    MCAutoStringRef tdata;
                    /* UNCHECKED */ MCStringCopySubstring(data, MCRangeMake(t_start_pos, t_end_pos - t_start_pos), &tdata);
                    t_end_pos++;
                    if (MCF_setweightstring(style, *tdata))
						continue;
					if (MCF_setexpandstring(style, *tdata))
						continue;
					if (MCF_setslantlongstring(style, *tdata))
						continue;
					if (MCStringIsEqualToCString(*tdata, MCplainstring, kMCCompareCaseless))
					{
						style = FA_DEFAULT_STYLE;
						continue;
					}
					if (MCStringIsEqualToCString(*tdata, MCmixedstring, kMCCompareCaseless))
					{
						style = FA_DEFAULT_STYLE;
						continue;
					}
					if (MCStringIsEqualToCString(*tdata, MCboxstring, kMCCompareCaseless))
					{
						style &= ~FA_3D_BOX;
						style |= FA_BOX;
						continue;
                    }
                
					if (MCStringIsEqualToCString(*tdata, MCthreedboxstring, kMCCompareCaseless))
					{
						style &= ~FA_BOX;
						style |= FA_3D_BOX;
						continue;
					}
					if (MCStringIsEqualToCString(*tdata, MCunderlinestring, kMCCompareCaseless))
					{
						style |= FA_UNDERLINE;
						continue;
					}
					if (MCStringIsEqualToCString(*tdata, MCstrikeoutstring, kMCCompareCaseless))
					{
						style |= FA_STRIKEOUT;
						continue;
					}
					if (MCStringIsEqualToCString(*tdata, MCgroupstring, kMCCompareCaseless) || MCStringIsEqualToCString(*tdata, MClinkstring, kMCCompareCaseless))
					{
						style |= FA_LINK;
						continue;
					}
					MCeerror->add(EE_OBJECT_BADSTYLE, 0, 0, data);
					return ES_ERROR;
				}
			}
		}
		break;
	default:
		break;
	}
	return ES_NORMAL;
}
Beispiel #3
0
Exec_stat MCF_parsetextatts(Properties which, const MCString &data,
                            uint4 &flags, char *&fname, uint2 &height,
                            uint2 &size, uint2 &style)
{
	int2 i1;
	switch (which)
	{
	case P_TEXT_ALIGN:
		flags &= ~F_ALIGNMENT;
		if (data == MCleftstring || data.getlength() == 0)
			flags |= F_ALIGN_LEFT;
		else
			if (data == MCcenterstring)
				flags |= F_ALIGN_CENTER;
			else
				if (data == MCrightstring)
					flags |= F_ALIGN_RIGHT;
				else
					if (data == MCjustifystring)
						flags |= F_ALIGN_JUSTIFY;
					else
					{
						MCeerror->add(EE_OBJECT_BADALIGN, 0, 0, data);
						return ES_ERROR;
					}
		break;
	case P_TEXT_FONT:
		{
			fname = data.clone();
			
			// MW-2012-02-17: [[ IntrinsicUnicode ]] Strip any lang tag from the
			//   fontname.
			char *t_tag;
			t_tag = strchr(fname, ',');
			if (t_tag != nil)
				t_tag[0] = '\0';
		}
		break;
	case P_TEXT_HEIGHT:
		if (!MCU_stoi2(data, i1))
		{
			MCeerror->add
			(EE_OBJECT_TEXTHEIGHTNAN, 0, 0, data);
			return ES_ERROR;
		}
		height = i1;
		break;
	case P_TEXT_SIZE:
		if (data.getlength() == 0)
			i1 = 0;
		else
			if (!MCU_stoi2(data, i1))
			{
				MCeerror->add
				(EE_OBJECT_TEXTSIZENAN, 0, 0, data);
				return ES_ERROR;
			}
		size = i1;
		break;
	case P_TEXT_STYLE:
		{
			// MW-2012-02-17: [[ SplitTextAttrs ]] If the string is empty, then
			//   return 0 for the style - indicating to unset the property.
			uint4 l = data.getlength();
			const char *sptr = data.getstring();
			if (l == 0)
				style = 0;
			else
			{
				style = FA_DEFAULT_STYLE;
				while (l)
				{
					const char *startptr = sptr;
					if (!MCU_strchr(sptr, l, ','))
					{
						sptr += l;
						l = 0;
					}
					MCString tdata(startptr, sptr - startptr);
					MCU_skip_char(sptr, l);
					MCU_skip_spaces(sptr, l);
					if (MCF_setweightstring(style, tdata))
						continue;
					if (MCF_setexpandstring(style, tdata))
						continue;
					if (MCF_setslantlongstring(style, tdata))
						continue;
					if (tdata == MCplainstring)
					{
						style = FA_DEFAULT_STYLE;
						continue;
					}
					if (tdata == MCmixedstring)
					{
						style = FA_DEFAULT_STYLE;
						continue;
					}
					if (tdata == MCboxstring)
					{
						style &= ~FA_3D_BOX;
						style |= FA_BOX;
						continue;
					}
					if (tdata == MCthreedboxstring)
					{
						style &= ~FA_BOX;
						style |= FA_3D_BOX;
						continue;
					}
					if (tdata == MCunderlinestring)
					{
						style |= FA_UNDERLINE;
						continue;
					}
					if (tdata == MCstrikeoutstring)
					{
						style |= FA_STRIKEOUT;
						continue;
					}
					if (tdata == MCgroupstring || tdata == MClinkstring)
					{
						style |= FA_LINK;
						continue;
					}
					MCeerror->add(EE_OBJECT_BADSTYLE, 0, 0, data);
					return ES_ERROR;
				}
			}
		}
		break;
	default:
		break;
	}
	return ES_NORMAL;
}
Beispiel #4
0
Exec_stat MCEPS::setprop_legacy(uint4 parid, Properties p, MCExecPoint &ep, Boolean effective)
{
	Boolean dirty = True;
	real8 n;
	int2 i;
	int2 i1, i2, i3, i4;
	MCString data = ep.getsvalue();

	switch (p)
	{
#ifdef /* MCEPS::setprop */ LEGACY_EXEC
	case P_TRAVERSAL_ON:
	case P_SHOW_BORDER:
		if (MCControl::setprop(parid, p, ep, effective) != ES_NORMAL)
			return ES_ERROR;
		resetscale();
		break;
	case P_ANGLE:
		if (!MCU_stoi2(data, i))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		angle = i;
		break;
	case P_POSTSCRIPT:
		delete postscript;
		postscript = data.clone();
		size = data.getlength() + 1;
		setextents();
		resetscale();
		break;
	case P_PROLOG:
		delete prolog;
		prolog = data.clone();
		break;
	case P_RETAIN_IMAGE:
		if (!MCU_matchflags(data, flags, F_RETAIN_IMAGE, dirty))
		{
			MCeerror->add
			(EE_OBJECT_NAB, 0, 0, data);
			return ES_ERROR;
		}
		dirty = False;
		break;
	case P_RETAIN_POSTSCRIPT:
		if (!MCU_matchflags(data, flags, F_RETAIN_POSTSCRIPT, dirty))
		{
			MCeerror->add
			(EE_OBJECT_NAB, 0, 0, data);
			return ES_ERROR;
		}
		dirty = False;
		break;
	case P_SCALE_INDEPENDENTLY:
		if (!MCU_matchflags(data, flags, F_SCALE_INDEPENDENTLY, dirty))
		{
			MCeerror->add
			(EE_OBJECT_NAB, 0, 0, data);
			return ES_ERROR;
		}
		if (dirty)
			resetscale();
		break;
	case P_BOUNDING_RECT:
		if (!MCU_stoi2x4(data, i1, i2, i3, i4))
		{
			MCeerror->add
			(EE_OBJECT_NAR, 0, 0, data);
			return ES_ERROR;
		}
		if (tx != i1 || ty != i2 || tx + ex != i3 || ty + ey != i4)
		{
			tx = i1;
			ty = i2;
			ex = MCU_max(i3 - i1, 1);
			ey = MCU_max(i4 - i2, 1);
			resetscale();
		}
		else
			dirty = False;
		break;
	case P_SCALE:
		if (!MCU_stor8(data, n))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		xscale = yscale = n;
		break;
	case P_X_SCALE:
		if (!MCU_stor8(data, n))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		xscale = n;
		ex = (uint2)(rect.width * xf / xscale + 0.5);
		flags |= F_SCALE_INDEPENDENTLY;
		break;
	case P_Y_SCALE:
		if (!MCU_stor8(data, n))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		yscale = n;
		ey = (uint2)(rect.height * yf / yscale + 0.5);
		flags |= F_SCALE_INDEPENDENTLY;
		break;
	case P_X_OFFSET:
		if (!MCU_stoi2(data, i))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		tx = i;
		break;
	case P_Y_OFFSET:
		if (!MCU_stoi2(data, i))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		ty = i;
		break;
	case P_X_EXTENT:
		if (!MCU_stoi2(data, i))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		ex = i;
		resetscale();
		break;
	case P_Y_EXTENT:
		if (!MCU_stoi2(data, i))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		ey = i;
		resetscale();
		break;
	case P_CURRENT_PAGE:    //set eps current page to display
		if (!MCU_stoi2(data, i))
		{
			MCeerror->add
			(EE_OBJECT_NAN, 0, 0, data);
			return ES_ERROR;
		}
		if ((uint2)i > pagecount)
			curpage = pagecount;
		else
			curpage = i;
		break;
#endif /* MCEPS::setprop */
	default:
		return MCControl::setprop_legacy(parid, p, ep, effective);
	}
	if (dirty && opened)
	{
		// MW-2011-08-18: [[ Layers ]] Invalidate the whole object.
		layer_redrawall();
	}
	return ES_NORMAL;
}
Beispiel #5
0
Exec_stat MCAudioClip::setprop(uint4 parid, Properties p, MCExecPoint &ep, Boolean effective)
{
	int2 i1;
	MCString data = ep.getsvalue();

	switch (p)
	{
#ifdef /* MCAudioClip::setprop */ LEGACY_EXEC
	case P_PLAY_DESTINATION:
	case P_PLAY_LOUDNESS:
		if (p == P_PLAY_DESTINATION)
		{
			if (data == "external")
				flags |= F_EXTERNAL;
			else
				flags &= ~F_EXTERNAL;
		}
		else
		{
			if (!MCU_stoi2(data, i1))
			{
				MCeerror->add
				(EE_ACLIP_LOUDNESSNAN, 0, 0, data);
				return ES_ERROR;
			}
			loudness = MCU_max(MCU_min(i1, 100), 0);
			if (loudness == 100)
				flags &= ~F_LOUDNESS;
			else
				flags |= F_LOUDNESS;
		}
		if (this == MCtemplateaudio)
		{
			extern bool MCSystemSetPlayLoudness(uint2 loudness);
#ifdef _MOBILE
			if (MCSystemSetPlayLoudness(loudness))
				return ES_NORMAL;
#endif
			if (MCplayers != NULL)
			{
				MCPlayer *tptr = MCplayers;
				while (tptr != NULL)
				{
					tptr->setvolume(loudness);
					tptr = tptr->getnextplayer();
				}
			}
#if defined _WINDOWS
			WORD v = loudness * MAXUINT2 / 100;
			if (hwaveout != NULL)
				waveOutSetVolume(hwaveout, v | (v << 16));
			else
			{
				WAVEFORMATEX pwfx;
				pwfx.wFormatTag = WAVE_FORMAT_PCM;
				pwfx.nChannels = 1;
				pwfx.nSamplesPerSec = 22050;
				pwfx.nAvgBytesPerSec = 22050;
				pwfx.nBlockAlign = 1;
				pwfx.wBitsPerSample = 8;
				pwfx.cbSize = 0;
				if (waveOutOpen(&hwaveout, WAVE_MAPPER, &pwfx, 0, 0,
								CALLBACK_NULL | WAVE_ALLOWSYNC) == MMSYSERR_NOERROR)
				{
					waveOutSetVolume(hwaveout, v | (v << 16));
					waveOutClose(hwaveout);
					hwaveout = NULL;
				}
			}

#elif defined _MACOSX
			long volume = loudness * 255 / 100;
			SetDefaultOutputVolume(volume | volume << 16);
#elif defined TARGET_PLATFORM_LINUX
			if ( x11audio != NULL)
				x11audio -> setloudness ( loudness ) ;
#endif

		}
		return ES_NORMAL;
#endif /* MCAudioClip::setprop */
	default:
		break;
	}
	return MCObject::setprop(parid, p, ep, effective);
}