Esempio n. 1
0
/*
 * etox_line_merge_append - merge lines into the first line, empty the second
 * @line1: the destination of the merged lines
 * @line2: the line that will be merged with line1
 *
 * Returns no value. Moves the bits from line2 into line 1.
 */
void etox_line_merge_append(Etox_Line * line1, Etox_Line * line2)
{
	Evas_Object *bit;

	CHECK_PARAM_POINTER("line1", line1);
	CHECK_PARAM_POINTER("line2", line2);

	/*
	 * Move the bits from line2 to line1.
	 */
	while (line2->bits) {
		bit = line2->bits->data;
		line1->bits = eina_list_append(line1->bits, bit);
		line2->bits = eina_list_remove(line2->bits, bit);
		line1->length += etox_style_length(bit);

        	etox_selections_update(bit, line1);
	}
	/*
	 * Adjust the height, width and length of the merged line.
	 */
	line1->w += line2->w;
	if (line2->h > line1->h)
		line1->h = line2->h;
}
Esempio n. 2
0
/**
 * Clear the entire xml document
 * @param   xml The xml document
 * @return  nothing
 */
void exml_clear(EXML *xml)
{
	CHECK_PARAM_POINTER("xml", xml);

	exml_goto_top(xml);
	exml_tag_remove(xml);
}
/**
 * Sort the data in the heap
 * @param  heap The heap to be sorted
 *
 * Sorts the data in the heap into the order that is used for the heap's
 * data.
 */
EAPI void
ecore_sheap_sort(Ecore_Sheap *heap)
{
   int i = 0;
   void **new_data;

   CHECK_PARAM_POINTER("heap", heap);

   new_data = (void **)malloc(heap->size * sizeof(void *));

   /*
    * Extract the heap and insert into the new data array in order.
    */
   while (heap->size > 0)
     new_data[i++] = ecore_sheap_extract(heap);

   /*
    * Free the old data array and update the heap with the new data, also
    * mark as sorted.
    */
   FREE(heap->data);
   heap->data = new_data;
   heap->size = i;
   heap->sorted = TRUE;
}
Esempio n. 4
0
/*
 * etox_line_minimize - reduce the number of bits on a line
 */
void etox_line_minimize(Etox_Line * line)
{
	Evas_Object *bit, *last_bit = NULL;
	Eina_List *l;

	CHECK_PARAM_POINTER("line", line);

	l = line->bits;
	if (!l)
		return;

	last_bit = l->data;
	l = l->next;
	while (l) {
		bit = l->data;

		/*
		 * Attempt to merge the bits if possible, remove the second
		 * one if successful.
		 */
		if (etox_style_merge(last_bit, bit)) {
			line->bits = eina_list_remove(line->bits, bit);
			l = eina_list_data_find_list(line->bits, last_bit);
			l = l->next;
		}
		else {
			last_bit = bit;
			l = l->next;
		}
	}
}
Esempio n. 5
0
/**
 * Free memory allocated by a call to exml_mem_write
 * @param   xml The xml document
 * @param   ptr The xml buffer content
 * @return  nothing
 */
void exml_mem_free(EXML *xml, void *ptr)
{
	CHECK_PARAM_POINTER("xml", xml);

	if (ecore_hash_get(xml->buffers, ptr)) {
		ecore_hash_remove(xml->buffers, ptr);
	}
}
Esempio n. 6
0
/**
 * Change the order of the heap
 * @param  heap  The heap to change the order
 * @param  order The new order of the heap
 *
 * Changes the heap order of @heap and re-heapifies the data to this new
 * order. The default order is a min heap.
 */
EAPI void edata_sheap_order_set(Edata_Sheap *heap, char order)
{
	CHECK_PARAM_POINTER("heap", heap);

	heap->order = order;

	_edata_sheap_update_data(heap);
}
Esempio n. 7
0
/*
 * etox_line_remove - remove a bit from the line
 * @line: the line to remove the bit
 * @bit: the bit to be from @line
 *
 * Removes @bit from @line and updates the appearance of surrounding bits to
 * reflect this change.
 */
void etox_line_remove(Etox_Line * line, Evas_Object * bit)
{
	Evas_Coord w;

	CHECK_PARAM_POINTER("line", line);
	CHECK_PARAM_POINTER("bit", bit);

	line->bits = eina_list_remove(line->bits, bit);
	line->length -= etox_style_length(bit);
	evas_object_geometry_get(bit, NULL, NULL, &w, NULL);
	line->w -= w;

	/*
	 * FIXME: Need to fix-up line minimizing to ensure it doesn't stomp on
	 * selections.
	 * etox_line_minimize(line);
	 */
}
Esempio n. 8
0
/**
 * Destroys this xml document
 * @param   xml The xml document
 * @return  nothing
 */
void exml_destroy(EXML *xml)
{
	CHECK_PARAM_POINTER("xml", xml);

	exml_clear(xml);

	ecore_hash_destroy(xml->buffers);

	FREE(xml);
}
Esempio n. 9
0
/**
 * Free memory allocated by a call to exml_transform_mem_write
 * @param   xsl The xml stylesheet
 * @param   ptr The xslt buffer
 * @return  nothing
 * @ingroup	 EXML_XSLT_Group
 */
void exml_transform_mem_free( EXML_XSL *xsl, void *ptr )
{
	CHECK_PARAM_POINTER("xsl", xsl);

	/**
	 * xmlFree as destroy cb will take care of business for us
	 */
	if( ecore_list_goto(xsl->buffers, ptr) == ptr )
		ecore_list_remove_destroy(ptr);
}
Esempio n. 10
0
/*
 * etox_line_prepend - prepend a bit to a line
 * @line: the line to prepend the bit
 * @bit: the bit to prepend to the line
 *
 * Returns no value. Prepends the bit @bit to the line @line and updates
 * display to reflect the change.
 */
void etox_line_prepend(Etox_Line * line, Evas_Object * bit)
{
	Evas_Coord x, y, w, h;

	CHECK_PARAM_POINTER("line", line);
	CHECK_PARAM_POINTER("bit", bit);

	/*
	 * Prepend the text and update necessary fields
	 */
	line->bits = eina_list_prepend(line->bits, bit);
	evas_object_geometry_get(bit, &x, &y, &w, &h);

	line->w += w;
	if (h > line->h)
		line->h = h;
	line->length += etox_style_length(bit);

        etox_selections_update(bit, line);
}
Esempio n. 11
0
/**
 * Destroys this xml stylesheet
 * @param   xsl The xml stylesheet
 * @return  nothing
 */
void exml_xsl_destroy( EXML_XSL *xsl )
{
	CHECK_PARAM_POINTER("xsl", xsl);

	if( xsl->buffers )
		ecore_list_destroy(xsl->buffers);

	if( xsl->cur )
		xsltFreeStylesheet(xsl->cur);

	free(xsl);
}
Esempio n. 12
0
/*
 * etox_line_show - display all of the bits in the selected line
 * @line: the line to be displayed
 *
 * Returns no value. Displays the text on the specified line.
 */
void etox_line_show(Etox_Line * line)
{
	Evas_Object *bit;
	Eina_List *l;

	CHECK_PARAM_POINTER("line", line);

	/*
	 * Display all of the bits in the line.
	 */
	for (l = line->bits; l; l = l->next) {
		bit = l->data;
		evas_object_show(bit);
	}
}
Esempio n. 13
0
/*
 * etox_line_hide - hide all the bits in the selected line
 * @line: the line to hide
 *
 * Returns no value
 */
void etox_line_hide(Etox_Line * line)
{
	Evas_Object *bit;
	Eina_List *l;

	CHECK_PARAM_POINTER("line", line);

	/*
	 * Hide all the bits in this line
	 */
	for (l = line->bits; l; l = l->next) {
		bit = l->data;
		evas_object_hide(bit);
	}
}
Esempio n. 14
0
/*
 * etox_line_free - free the data structures in a line
 * @line: the line that will be freed
 *
 * Returns no value. Frees all of the data tracked by @line as well as @line
 * itself.
 */
void etox_line_free(Etox_Line * line)
{
	Evas_Object *bit;

	CHECK_PARAM_POINTER("line", line);

	/*
	 * Free all of the bits on the line.
	 */
	while (line->bits) {
		bit = line->bits->data;
		evas_object_del(bit);
		line->bits = eina_list_remove(line->bits, bit);
	}

	FREE(line);
}
Esempio n. 15
0
/**
 * Free up the memory used by the heap
 *
 * Frees the memory used by @a heap, calls the destroy function on each data
 * item if necessary.
 *
 * @param  heap The heap to be freed
 */
EAPI void edata_sheap_destroy(Edata_Sheap *heap)
{
	int i;

	CHECK_PARAM_POINTER("heap", heap);

	/*
	 * Free data in heap
	 */
	if (heap->free_func)
		for (i = 0; i < heap->size; i++)
			heap->free_func(heap->data[i]);

	FREE(heap->data);

	FREE(heap);
}
Esempio n. 16
0
/**
 * Notes that the given string has lost an instance.
 *
 * It will free the string if no other instances are left.
 *
 * @param   string The given string.
 * @ingroup Ecore_String_Group
 */
EAPI void
ecore_string_release(const char *string)
{
   Ecore_String *str;

   CHECK_PARAM_POINTER("string", string);

   str = ecore_hash_get(ecore_strings, (char *)string);
   if (!str)
      return;

   str->references--;
   if (str->references < 1)
     {
        ecore_hash_remove(ecore_strings, (char *)string);
        FREE(str);
     }
}
/**
 * Frees the hash table and the data contained inside it.
 * @param   hash The hash table to destroy.
 * @return  @c TRUE on success, @c FALSE on error.
 * @ingroup Ecore_Data_Hash_ADT_Destruction_Group
 */
EAPI void
ecore_hash_destroy(Ecore_Hash *hash)
{
   unsigned int i = 0;

   CHECK_PARAM_POINTER("hash", hash);

   if (hash->buckets)
     {
        while (i < ecore_prime_table[hash->size])
          {
             if (hash->buckets[i])
               {
                  Ecore_Hash_Node *bucket;

                  /*
                   * Remove the bucket list to avoid possible recursion
                   * on the free callbacks.
                   */
                  bucket = hash->buckets[i];
                  hash->buckets[i] = NULL;
                  _ecore_hash_bucket_destroy(bucket,
                                             hash->free_key,
                                             hash->free_value);
               }

             i++;
          }

        FREE(hash->buckets);
     }

        FREE(hash);

   return;
}
Esempio n. 18
0
/*
 * etox_line_layout - layout the bits in a line across the etox
 * @line: the line that has the list of bits and bounding geometry
 *
 * Returns no value. Places the bits in @line across the screen and wraps them
 * appropriately around any fixed bits.
 */
void etox_line_layout(Etox_Line * line)
{
	int x;
	Evas_Object *bit;
	Evas_Coord tx, ty, tw, th;
	Eina_List *l;

	CHECK_PARAM_POINTER("line", line);

	if (!line->bits)
		return;

	/*
	 * Determine the horizontal alignment of the text and set the starting
	 * x coordinate appropriately.
	 */
	if (line->flags & ETOX_ALIGN_LEFT) {
		x = line->et->x;
	} else if (line->flags & ETOX_ALIGN_RIGHT) {
		x = line->et->x + line->et->w - line->w;
	} else {
		x = line->et->x + (line->et->w / 2) - (line->w / 2);
	}

	if ((line->et->flags & ETOX_SOFT_WRAP) && (x < line->et->x))
		x = line->et->x;

	/*
	 * Determine the veritcal alignment and perform the layout of the
	 * bits.
	 */
	for (l = line->bits; l; l = l->next) {
		bit = l->data;
		evas_object_geometry_get(bit, &tx, &ty, &tw, &th);
		if (!etox_style_fixed(bit)) {

			if (line->h < th)
				line->h = th;

			/*
			 * Adjust the y position based on alignment.
			 */
			if (line->flags & ETOX_ALIGN_TOP)
				ty = line->y;
			else if (line->flags & ETOX_ALIGN_BOTTOM)
				ty = line->y + line->h - th;
			else
				ty = line->y + (line->h / 2) - (th / 2);

			/*
			 * Move the evas object into place.
			 */
#ifdef DEBUG
			printf("etox_line_layout() - moving bit to %d,%d. Bit text is (%s)\n",
			       x, ty, etox_style_get_text(bit));
#endif
			evas_object_move(bit, x, ty);
		}
#ifdef DEBUG
		else
			printf("Encountered an obstacle!!\n");
#endif

		/*
		 * Move horizontally to place the next bit.
		 */
		x += tw;
	}
#ifdef DEBUG
	printf("etox_line_layout() - done\n");
#endif
}
Esempio n. 19
0
/*
 * etox_line_get_text - retrieve the text from a specified line into a buffer
 * @line: the line to retrieve text
 * @buf: the char buffer to store the found text, must have enough space
 *
 * Returns no value. Saves the text from the line @line into the char buffer
 * @buf.
 */
void etox_line_get_text(Etox_Line * line, char *buf, int len)
{
#ifdef DEBUG
	printf("etox_line_get_text() - called. len = %d\n", len);
#endif
	char *temp;
	Evas_Object *es;
	Eina_List *l;
	int sum = 0, pos = 0;

	CHECK_PARAM_POINTER("line", line);
	CHECK_PARAM_POINTER("buf", buf);

	/*
	 * Examine each bit on the list of bits and cat it's text onto the end
	 * of the buffer. Then append a \n to the buffer at the end of the
	 * line.
	 */
	if (len < 1) return;
	buf[0] = 0;
	for (l = line->bits; l; l = l->next) {
		int t;
		int tlen;
		es = l->data;

		sum += etox_style_length(es);
#ifdef DEBUG
		printf("etox_line_get_text() - etox_style_length() returned %d\n", etox_style_length(es));
#endif

		t = etox_style_get_type(es);
		if (t == ETOX_BIT_TYPE_WRAP_MARKER)
			continue;
		else if (t == ETOX_BIT_TYPE_TAB)
		{
			temp = strdup("\t");
			sum -= 7; // etox_style_length returns 8 but we're only inserting 1
		}                   
		else
			temp = etox_style_get_text(es);
		tlen = strlen(temp);
#ifdef DEBUG
		printf("etox_line_get_text() - actual length of returned text is %d\n", tlen);
#endif
		if (pos + tlen < len) {
#ifdef DEBUG
			printf("etox_line_get_text() - appending %d characters at pos = %d\n", tlen, pos);
#endif
			pos += tlen;
			strcat(buf, temp);
		}
		else {
#ifdef DEBUG
			printf("etox_line_get_text() - appending %d characters (limited) at pos = %d\n", (len-pos), pos);
#endif
			strncat(buf, temp, (len - pos));
			pos = len;
		}
		FREE(temp);
	}
	line->length = sum;
#ifdef DEBUG
	printf("etox_line_get_text() - done\n");
#endif
}