コード例 #1
0
ファイル: statemnt.cpp プロジェクト: Bjoernke/livecode
MCComref::MCComref(MCNameRef n)
{
	/* UNCHECKED */ MCNameClone(n, name);
	handler = nil;
	params = NULL;
	resolved = false;
}
コード例 #2
0
ファイル: mblspec.cpp プロジェクト: n9yty/livecode
MCUrlLoadEvent *MCUrlLoadEvent::CreateUrlLoadEvent(MCObjectHandle *p_object, MCNameRef p_message, const char *p_url, MCSystemUrlStatus p_status, void *p_data, uint32_t p_size, const char *p_error)
{
    MCUrlLoadEvent *t_event;
    t_event = new MCUrlLoadEvent();
    if (t_event == nil)
        return nil;

    t_event->m_url = nil;
    t_event->m_object = nil;
    t_event->m_status = kMCSystemUrlStatusNone;
    t_event->m_error = nil;
    t_event->m_message = nil;

    bool t_success;
    t_success = true;

    if (t_success)
        t_success = MCCStringClone(p_url, t_event->m_url);
    if (t_success)
        t_success = MCNameClone(p_message, t_event->m_message);
    if (t_success && p_status == kMCSystemUrlStatusError)
        t_success = MCCStringClone(p_error, t_event->m_error);

    if (t_success)
    {
        t_event->m_status = p_status;
        t_event->m_object = p_object;
        t_event->m_object->Retain();
        if (t_event->m_status == kMCSystemUrlStatusFinished)
        {
            t_event->m_data.bytes = p_data;
            t_event->m_data.size = p_size;
        }
    }
    else
    {
        MCCStringFree(t_event->m_url);
        MCNameDelete(t_event->m_message);
        MCCStringFree(t_event->m_error);
        delete t_event;
        return nil;
    }

    return t_event;
}
コード例 #3
0
ファイル: fonttable.cpp プロジェクト: Bjoernke/livecode
static uint32_t MCLogicalFontTableLookupEntry(MCNameRef p_textfont, uint2 p_textstyle, uint2 p_textsize, bool p_unicode, bool p_add)
{
	MCLogicalFontTableEntry t_entry;
	t_entry . textfont = p_textfont;
	t_entry . textstyle = p_textstyle;
	t_entry . textsize = p_textsize & 0x7fff;
	if (p_unicode)
		t_entry . textsize |= 0x8000;
	
	for(uint32_t i = 0; i < s_logical_font_table_size; i++)
		if (memcmp(&t_entry, &s_logical_font_table[i], sizeof(MCLogicalFontTableEntry)) == 0)
			return i;

	if (p_add)
	{
		if (s_logical_font_table_size == s_logical_font_table_capacity)
			/* UNCHECKED */ MCMemoryResizeArray(s_logical_font_table_capacity > 0 ? s_logical_font_table_capacity * 2 : 32, s_logical_font_table, s_logical_font_table_capacity);
		
		s_logical_font_table[s_logical_font_table_size++] = t_entry;
		MCNameClone(t_entry . textfont, t_entry . textfont);
	}

	return s_logical_font_table_size - 1;
}
コード例 #4
0
ファイル: rtfsupport.cpp プロジェクト: Bjoernke/livecode
RTFStatus RTFState::Save(void)
{
	RTFStatus t_status;
	t_status = kRTFStatusSuccess;
	
	Entry *t_new_entry;
	t_new_entry = NULL;
	if (t_status == kRTFStatusSuccess)
	{
		t_new_entry = new Entry;
		if (t_new_entry == NULL)
			t_status = kRTFStatusOverflow;
	}
	
	if (t_status == kRTFStatusSuccess)
	{
		t_new_entry -> previous = m_entries;
		if (m_entries != NULL)
		{
			t_new_entry -> destination = m_entries -> destination;
			t_new_entry -> text_encoding = m_entries -> text_encoding;
			t_new_entry -> font_name = m_entries -> font_name;
			t_new_entry -> font_style = m_entries -> font_style;
			t_new_entry -> font_size = m_entries -> font_size;
			t_new_entry -> foreground_color = m_entries -> foreground_color;
			t_new_entry -> background_color = m_entries -> background_color;
			t_new_entry -> unicode_skip = m_entries -> unicode_skip;
			t_new_entry -> list_style = m_entries -> list_style;
			t_new_entry -> list_level = m_entries -> list_level;
			t_new_entry -> list_index = m_entries -> list_index;

			// MW-2012-03-14: [[ RtfParaStyles ]] Copy across all the previous paragraph styling.
			t_new_entry -> text_align = m_entries -> text_align;
			t_new_entry -> border_width = m_entries -> border_width;
			t_new_entry -> padding = m_entries -> padding;
			t_new_entry -> first_indent = m_entries -> first_indent;
			t_new_entry -> left_indent = m_entries -> left_indent;
			t_new_entry -> right_indent = m_entries -> right_indent;
			t_new_entry -> space_above = m_entries -> space_above;
			t_new_entry -> space_below = m_entries -> space_below;
			t_new_entry -> paragraph_background_color = m_entries -> paragraph_background_color;
			t_new_entry -> border_color = m_entries -> border_color;

			MCNameClone(m_entries -> metadata, t_new_entry -> metadata);
			MCNameClone(m_entries -> paragraph_metadata, t_new_entry -> paragraph_metadata);
			MCNameClone(m_entries -> hyperlink, t_new_entry -> hyperlink);
		}
		else
		{
			t_new_entry -> destination = kRTFDestinationNormal;
			t_new_entry -> text_encoding = kMCTextEncodingUndefined;
			t_new_entry -> font_name = NULL;
			t_new_entry -> font_style = 0;
			t_new_entry -> font_size = 0;
			t_new_entry -> foreground_color = 0xffffffff;
			t_new_entry -> background_color = 0xffffffff;
			t_new_entry -> unicode_skip = 1;
			t_new_entry -> list_style = kMCTextListStyleNone;
			t_new_entry -> list_level = 0;
			t_new_entry -> list_index = 0;

			// MW-2012-03-14: [[ RtfParaStyles ]] Set all the paragraph styling to defaults.
			t_new_entry -> text_align = kMCTextTextAlignLeft;
			t_new_entry -> border_width = 0;
			t_new_entry -> padding = 0;
			t_new_entry -> first_indent = 0;
			t_new_entry -> left_indent = 0;
			t_new_entry -> right_indent = 0;
			t_new_entry -> space_above = 0;
			t_new_entry -> space_below = 0;
			t_new_entry -> paragraph_background_color = 0xffffffff;
			t_new_entry -> border_color = 0xffffffff;

			MCNameClone(kMCEmptyName, t_new_entry -> metadata);
			MCNameClone(kMCEmptyName, t_new_entry -> paragraph_metadata);
			MCNameClone(kMCEmptyName, t_new_entry -> hyperlink);
		}
		
		m_entries = t_new_entry;
	}
	
	return t_status;
}
コード例 #5
0
ファイル: rtf.cpp プロジェクト: simonasato/livecode
RTFStatus RTFReader::Flush(bool p_force)
{
	RTFStatus t_status;
	t_status = kRTFStatusSuccess;

	if (!m_attributes_changed && !p_force)
		return t_status;

	MCTextBlock t_block;
	bool t_changed;
	t_changed = false;
	if (m_attributes_changed)
	{
		t_block . foreground_color = m_state . GetForegroundColor();
		t_block . background_color = m_state . GetBackgroundColor();
		t_block . font_name = m_state . GetFontName();
		if (m_state . GetFontSize() != 0)
			t_block . font_size = half_points_to_pixels(m_state . GetFontSize());
		else
			t_block . font_size = 0;
		
		t_block . font_style = FA_DEFAULT_STYLE;
		if ((m_state . GetFontStyle() & kRTFFontStyleItalic) != 0)
			t_block . font_style |= FA_ITALIC;
		if ((m_state . GetFontStyle() & kRTFFontStyleBold) != 0)
			t_block . font_style |= FA_BOLD;
		if ((m_state . GetFontStyle() & kRTFFontStyleUnderline) != 0)
			t_block . font_style |= FA_UNDERLINE;
		if ((m_state . GetFontStyle() & kRTFFontStyleStrikethrough) != 0)
			t_block . font_style |= FA_STRIKEOUT;
		if ((m_state . GetFontStyle() & kRTFFontStyleLink) != 0)
			t_block . font_style |= FA_LINK;

		if ((m_state . GetFontStyle() & kRTFFontStyleSuperscript) != 0)
			t_block . text_shift = -4;
		else if ((m_state . GetFontStyle() & kRTFFontStyleSubscript) != 0)
			t_block . text_shift = 4;
		else
			t_block . text_shift = 0;
		
		if (m_state . GetHyperlink() != kMCEmptyName)
			MCNameClone(m_state . GetHyperlink(), t_block . text_link);
		else
			t_block . text_link = nil;

		if (m_state . GetMetadata() != kMCEmptyName)
			MCNameClone(m_state . GetMetadata(), t_block . text_metadata);
		else
			t_block . text_metadata = nil;

		t_block . string_native = false;
		t_block . string_buffer = NULL;
		t_block . string_length = 0;

		if (t_block . foreground_color != m_attributes . foreground_color ||
			t_block . background_color != m_attributes . background_color ||
			t_block . font_size != m_attributes . font_size ||
			t_block . font_style != m_attributes . font_style ||
			t_block . text_shift != m_attributes . text_shift ||
			CStringCompare(t_block . font_name, m_attributes . font_name) != 0 ||
			t_block . text_link != m_attributes . text_link ||
			t_block . text_metadata != m_attributes . text_metadata)
			t_changed = true;
	}

	const uint2 *t_string_buffer;
	uint4 t_string_length;
	if (t_status == kRTFStatusSuccess)
		t_status = m_text . Borrow(t_string_buffer, t_string_length);

	if (t_status == kRTFStatusSuccess && t_string_length > 0 && (t_changed || p_force))
	{
		if (m_needs_paragraph)
		{
			m_needs_paragraph = false;

			// MW-2012-03-14: [[ RtfParaStyles ]] Use the 'Paragraph()' method to ensure
			//   paragraph styles get applied.
			Paragraph();
		}

		m_attributes . string_native = false;
		m_attributes . string_buffer = t_string_buffer;
		m_attributes . string_length = t_string_length / 2;
		m_converter(m_converter_context, NULL, &m_attributes);
		m_text . Clear();
	}

	if (t_changed)
	{
		MCNameDelete(m_attributes . text_metadata);
		MCNameDelete(m_attributes . text_link);
		memcpy(&m_attributes, &t_block, sizeof(MCTextBlock));
		m_attributes_changed = false;
	}

	return t_status;
}
コード例 #6
0
ファイル: font.cpp プロジェクト: alilloyd/livecode
bool MCFontCreate(MCNameRef p_name, MCFontStyle p_style, int32_t p_size, MCFontRef& r_font)
{
	for(MCFont *t_font = s_fonts; t_font != nil; t_font = t_font -> next)
	{
		if (p_name == t_font -> name &&
			p_style == t_font -> style &&
			p_size == t_font -> size)
		{
			t_font -> references += 1;
			r_font = t_font;
			return true;
		}
	}

	MCFontRef self;
	if (!MCMemoryNew(self))
		return false;

	self -> references = 1;
	/* UNCHECKED */ MCNameClone(p_name, self -> name);
	self -> style = p_style;
	self -> size = p_size;

	uint2 t_temp_size;
	t_temp_size = self -> size;
	self -> fontstruct = MCdispatcher -> loadfont(self -> name, t_temp_size, MCFontStyleToTextStyle(self -> style), (self -> style & kMCFontStylePrinterMetrics) != 0);

	// MW-2013-12-04: [[ Bug 11535 ]] Test to see if the font is fixed-width, at least for
	//   Roman script.
    MCGFont t_gfont;
	t_gfont = MCFontStructToMCGFont(self -> fontstruct);
	t_gfont . fixed_advance = 0;

	// We check the width of ' ', i, l, m and w. If they are all the same width
	// we assume the font is monospaced and subsequently set the fixed_advance
	// field to a suitable value.
	MCGFloat t_last_width;
	for(uindex_t i = 0; i < 5; i++)
	{
		unichar_t t_char;
		t_char = (unichar_t)((" ilmw")[i]);
		
		// MM-2014-04-16: [[ Bug 11964 ]] MCGContextMeasurePlatformText prototype updated to take scale. Pass identity.
		MCGFloat t_this_width;
		t_this_width = MCGContextMeasurePlatformText(nil, &t_char, 2, t_gfont, MCGAffineTransformMakeIdentity());
		if (t_this_width == 0.0 ||
			(i != 0 && t_this_width != t_last_width))
		{
			t_last_width = 0;
			break;
		}
		t_last_width = t_this_width;
	}
	self -> fixed_advance = floorf(t_last_width + 0.5);
	
	self -> next = s_fonts;
	s_fonts = self;

	r_font = self;

	return true;
}
コード例 #7
0
bool MCModeHandleMessageBoxChanged(MCExecPoint& ep)
{
	// IM-2013-04-16: [[ BZ 10836 ]] update revMessageBoxLastObject
	// if the source of the change is not within the message box
	MCObject *t_msg_box = nil;
	if (MCmessageboxredirect != nil)
		t_msg_box = MCmessageboxredirect;
	else
	{
		if (MCmbstackptr == nil)
			MCmbstackptr = MCdispatcher->findstackname(MCmessagenamestring);
		t_msg_box = MCmbstackptr;
	}
	
	MCObject *t_src_object = nil;
	if (ep.getobj() != nil)
		t_src_object = ep.getobj();
	
	bool t_in_msg_box = false;
	
	MCObject *t_obj_ptr = t_src_object;
	while (t_obj_ptr != nil)
	{
		if (t_obj_ptr == t_msg_box)
		{
			t_in_msg_box = true;
			break;
		}
		t_obj_ptr = t_obj_ptr->getparent();
	}
	
	if (!t_in_msg_box)
	{
		if (MCmessageboxlastobject != nil)
			MCmessageboxlastobject->Release();
		MCmessageboxlastobject = t_src_object->gethandle();
		
		MCNameDelete(MCmessageboxlasthandler);
		MCmessageboxlasthandler = nil;
		MCNameClone(ep.gethandler()->getname(), MCmessageboxlasthandler);
		
		MCmessageboxlastline = ep.getline();
	}
	
	if (MCmessageboxredirect != NULL)
	{
		if (MCmessageboxredirect -> gettype() == CT_FIELD)
		{
			MCStack *t_msg_stack;
			t_msg_stack = MCmessageboxredirect -> getstack();
			Window_mode newmode = t_msg_stack -> userlevel() == 0 ? WM_MODELESS
										: (Window_mode)(t_msg_stack -> userlevel() + WM_TOP_LEVEL_LOCKED);
			
			// MW-2011-07-05: [[ Bug 9608 ]] The 'ep' that is passed through to us does
			//   not necessarily have an attached object any more. Given that the 'rel'
			//   parameter of the open stack call is unused, computing it from that
			//   context is redundent.
			if (t_msg_stack -> getmode() != newmode)
				t_msg_stack -> openrect(t_msg_stack -> getrect(), newmode, NULL, WP_DEFAULT, OP_NONE);
			else
				t_msg_stack -> raise();

			((MCField *)MCmessageboxredirect) -> settext(0, ep . getsvalue(), False);
		}
		else
		{
			MCAutoNameRef t_msg_changed;
			/* UNCHECKED */ t_msg_changed . CreateWithCString("msgchanged");
			
			bool t_added;
			if (MCnexecutioncontexts < MAX_CONTEXTS && ep . getobj() != nil)
			{
				MCexecutioncontexts[MCnexecutioncontexts++] = &ep;
				t_added = true;
			}
			
			MCmessageboxredirect -> message(t_msg_changed);
		
			if (t_added)
				MCnexecutioncontexts--;
		}

		return true;
	}

	return false;
}