Example #1
0
static void a3d_textbox_printText(a3d_textbox_t* self,
                                  const char* string)
{
	assert(self);
	assert(string);
	LOGD("debug string=%s", string);

	a3d_widget_t* widget = (a3d_widget_t*) self;
	a3d_text_t* text = a3d_text_new(widget->screen,
	                                0,
	                                self->anchor,
	                                self->style_border,
	                                self->style_line,
	                                self->style_text,
	                                &(self->color_fill),
	                                &(self->color_line),
	                                &(self->color_text),
	                                self->max_len,
	                                NULL, NULL);
	if(text == NULL)
	{
		return;
	}
	a3d_text_wrapx(text, self->text_wrapx);

	a3d_listbox_t* listbox = (a3d_listbox_t*) self;
	if(a3d_list_enqueue(listbox->list, (const void*) text) == 0)
	{
		goto fail_enqueue;
	}

	a3d_text_printf(text, "%s", string);

	// success
	return;

	// failure
	fail_enqueue:
		a3d_text_delete(&text);
}
Example #2
0
void a3d_textbox_printf(a3d_textbox_t* self,
                        const char* fmt, ...)
{
	assert(self);
	assert(fmt);

	char* string = (char*) calloc(self->max_len, sizeof(char));
	if(string == NULL)
	{
		LOGE("calloc failed");
		return;
	}

	// decode string
	va_list argptr;
	va_start(argptr, fmt);
	vsnprintf(string, self->max_len, fmt, argptr);
	va_end(argptr);

	LOGD("debug %s", string);

	self->dirty = 1;

	if(a3d_list_enqueue(self->strings, (const void*) string) == 0)
	{
		goto fail_enqueue;
	}

	a3d_textbox_printText(self, string);

	// success
	return;

	// failure
	fail_enqueue:
		free(string);
}
Example #3
0
static void naip_parseStart(void* _null,
                            const XML_Char* name,
                            const XML_Char** atts)
{
	assert(name);
	assert(atts);

	// validate name
	if(strcmp(name, "naip") == 0)
	{
		// ignore
		return;
	}
	else if(strcmp(name, "node") != 0)
	{
		LOGW("invalid name=%s", name);
		return;
	}

	// validate atts
	if((atts[ 0] == NULL) ||
	   (atts[ 1] == NULL) ||
	   (atts[ 2] == NULL) ||
	   (atts[ 3] == NULL) ||
	   (atts[ 4] == NULL) ||
	   (atts[ 5] == NULL) ||
	   (atts[ 6] == NULL) ||
	   (atts[ 7] == NULL) ||
	   (atts[ 8] == NULL) ||
	   (atts[ 9] == NULL) ||
	   (atts[10] == NULL) ||
	   (atts[11] == NULL) ||
	   (atts[12] != NULL) ||
	   (strcmp(atts[ 0], "id")  != 0) ||
	   (strcmp(atts[ 2], "url") != 0) ||
	   (strcmp(atts[ 4], "t")   != 0) ||
	   (strcmp(atts[ 6], "l")   != 0) ||
	   (strcmp(atts[ 8], "b")   != 0) ||
	   (strcmp(atts[10], "r")   != 0))
	{
		int idx = 0;
		while(atts[idx])
		{
			LOGW("invalid atts=%s", atts[idx]);
			++idx;
		}
		return;
	}

	naip_node_t* node = naip_node_new(atts[1], atts[5],
                                      atts[7], atts[9],
	                                  atts[11]);
	if(node == NULL)
	{
		return;
	}

	if(a3d_list_enqueue(glist, (const void*) node) == 0)
	{
		naip_node_delete(&node);
	}
}