Beispiel #1
0
void ftk_path_destroy(FtkPath* thiz)
{
	if(thiz != NULL)
	{
		FTK_FREE(thiz->path);
		FTK_FREE(thiz);
	}

	return;
}
Beispiel #2
0
static void ftk_font_desc_destroy(FtkFontDesc* thiz)
{
	if(thiz != NULL)
	{
	    if (thiz->fontname != NULL) {
	        FTK_FREE(thiz->fontname);
	    }
		FTK_FREE(thiz);
	}

	return;
}
Beispiel #3
0
static void ftk_app_demo_destroy(FtkApp* thiz)
{
    if(thiz != NULL)
    {
        DECL_PRIV(thiz, priv);
        FTK_FREE(priv->name);
        ftk_bitmap_unref(priv->icon);
        FTK_FREE(thiz);
    }

    return;
}
Beispiel #4
0
static void info_destroy(void* data)
{
	Info* info = (Info*)data;
	if(info->init_path != NULL)
	{
		FTK_FREE(info->init_path);
	}

	FTK_FREE(data);
	
	return;
}
static void ftk_animation_trigger_default_destroy(FtkAnimationTrigger* thiz)
{
	if(thiz != NULL)
	{
		int i = 0;
		DECL_PRIV(thiz, priv);

		for(i = 0; i < priv->type_and_animations_nr; i++)
		{
			size_t j = 0;
			for(j = 0; j < FTK_MAX_ANIMATION_NR; j++)
			{
				if(priv->type_and_animations[i].animations[j] != NULL)
				{
					ftk_animation_destroy(priv->type_and_animations[i].animations[j]);
				}
			}
		}

		ftk_canvas_destroy(priv->old_window);
		ftk_canvas_destroy(priv->new_window);
		FTK_FREE(thiz);
	}

	return;
}
Beispiel #6
0
static int parse_token(const char* text, const char* delims, OnTokenFunc on_token, void* ctx, char** ret_copy_text)
{
	enum _State
	{
		STAT_INIT,
		STAT_IN,
		STAT_OUT,
	}state = STAT_INIT;

	int   count		= 0;
	char* copy_text = ftk_strdup(text);
	char* p			= copy_text;
	char* token		= copy_text;

	for(p = copy_text; *p != '\0'; p++)
	{
		switch(state)
		{
			case STAT_INIT:
			case STAT_OUT:
			{
				if(!IS_DELIM(*p))
				{
					token = p;
					state = STAT_IN;
				}
				break;
			}
			case STAT_IN:
			{
				if(IS_DELIM(*p))
				{
					*p = '\0';
					on_token(ctx, count++, token);
					state = STAT_OUT;
				}
				break;
			}
			default:break;
		}
	}

	if(state == STAT_IN)
	{
		on_token(ctx, count++, token);
	}

	on_token(ctx, -1, NULL);

	if(ret_copy_text != NULL)
	{
		*ret_copy_text = copy_text;
	}
	else
	{
		FTK_FREE(copy_text);
	}

	return count;
}
Beispiel #7
0
FtkWidget* ftk_check_button_create_ex(FtkWidget* parent, int x, int y, int width, int height, int radio)
{
	FtkWidget* thiz = (FtkWidget*)FTK_ZALLOC(sizeof(FtkWidget));
	return_val_if_fail(thiz != NULL, NULL);

	thiz->priv_subclass[0] = (PrivInfo*)FTK_ZALLOC(sizeof(PrivInfo));
	if(thiz->priv_subclass[0] != NULL)
	{
		DECL_PRIV0(thiz, priv);

		priv->is_radio = radio;
		thiz->on_event = ftk_check_button_on_event;
		thiz->on_paint = ftk_check_button_on_paint;
		thiz->destroy  = ftk_check_button_destroy;

		ftk_widget_init(thiz, radio ? FTK_RADIO_BUTTON : FTK_CHECK_BUTTON, 0, x, y, width, height, FTK_ATTR_TRANSPARENT);
		ftk_widget_append_child(parent, thiz);
	}
	else
	{
		FTK_FREE(thiz);
	}

	return thiz;
}
Beispiel #8
0
FtkWidget* ftk_wait_box_create(FtkWidget* parent, int x, int y, int w, int h)
{
	FtkWidget* thiz = (FtkWidget*)FTK_ZALLOC(sizeof(FtkWidget));
	return_val_if_fail(thiz != NULL, NULL);

	thiz->priv_subclass[0] = (PrivInfo*)FTK_ZALLOC(sizeof(PrivInfo));
	if(thiz->priv_subclass[0] != NULL)
	{
		int w = 0;
		DECL_PRIV0(thiz, priv);

		thiz->on_event = ftk_wait_box_on_event;
		thiz->on_paint = ftk_wait_box_on_paint;
		thiz->destroy  = ftk_wait_box_destroy;

		priv->bitmap = ftk_theme_load_image(ftk_default_theme(), "wait_box"FTK_STOCK_IMG_SUFFIX);
		assert(priv->bitmap != NULL);
		
		w = ftk_bitmap_width(priv->bitmap);
		ftk_widget_init(thiz, FTK_WAIT_BOX, 0, x, y, w, w, FTK_ATTR_TRANSPARENT|FTK_ATTR_INSENSITIVE);
		ftk_widget_set_attr(thiz, FTK_ATTR_TRANSPARENT|FTK_ATTR_INSENSITIVE);

		priv->timer = ftk_source_timer_create(500, (FtkTimer)ftk_widget_invalidate, thiz);
		ftk_widget_append_child(parent, thiz);
	}
	else
	{
		FTK_FREE(thiz);
	}

	return thiz;
}
Beispiel #9
0
FontData* font_data_load_file(const char* file_name)
{
	FontData* thiz = NULL;
	return_val_if_fail(file_name != NULL, NULL);

	if((thiz = font_data_create(0, 0)) != NULL)
	{
		FtkFsHandle fp = ftk_file_open(file_name, "rb");
		if(fp != NULL)
		{
			int ret = 0;
			unsigned glyphs_size = 0;
			ret = ftk_file_read(fp, &thiz->header, sizeof(thiz->header));
			assert(ret == sizeof(thiz->header));
			glyphs_size = thiz->header.char_nr * sizeof(FGlyph);
			thiz->glyphs = (FGlyph*)FTK_ZALLOC(glyphs_size);
			assert(thiz->glyphs != NULL);
			ftk_file_read(fp, thiz->glyphs, glyphs_size);
			thiz->data = NULL;
			thiz->data_size = 0;
			thiz->new_created = 0;
			thiz->org_data = NULL;
			ftk_file_close(fp);
			ftk_strncpy(thiz->file_name, file_name, sizeof(thiz->file_name)-1);
		}
		else
		{
			FTK_FREE(thiz);
		}
	}

	return thiz;
}
Beispiel #10
0
static Ret font_data_read_glyph(FontData* thiz, unsigned offset, unsigned size, Glyph* glyph)
{
	int ret = 0;
	FtkFsHandle fp = ftk_file_open(thiz->file_name, "rb");
	unsigned skip = sizeof(thiz->header) + thiz->header.char_nr * sizeof(FGlyph) + offset;
	return_val_if_fail(fp != NULL && glyph != NULL, RET_FAIL);

	ret = ftk_file_seek(fp, skip);
	assert(ret == 0);
	
	if(thiz->current_glyph_data_size < size)
	{
		FTK_FREE(thiz->current_glyph_data);
		thiz->current_glyph_data = FTK_ALLOC(size * 2);
		thiz->current_glyph_data_size = size * 2;
	}

	ret = ftk_file_read(fp, thiz->current_glyph_data, size);
	ftk_logd("%s: offset=%d size=%d ret=%d\n", __func__, offset, size, ret);
	ftk_file_close(fp);
	assert(ret == size);
	glyph->data = thiz->current_glyph_data;

	return RET_OK;
}
FtkAnimationTrigger* ftk_animation_trigger_default_create(const char* theme, const char* name)
{
	FtkAnimationTrigger* thiz = FTK_NEW_PRIV(FtkAnimationTrigger);

	if(thiz != NULL)
	{
		char filename[FTK_MAX_PATH + 1] = {0};

		ftk_strs_cat(filename, FTK_MAX_PATH, 
			ftk_config_get_data_dir(ftk_default_config()), "/theme/", theme, "/", name, NULL);

		ftk_normalize_path(filename);
		thiz->on_event = ftk_animation_trigger_default_on_event;
		thiz->destroy = ftk_animation_trigger_default_destroy;

		if(ftk_animation_trigger_parse_file(thiz, filename) == RET_OK)
		{	
			//ftk_animation_trigger_default_dump(thiz);
			ftk_logd("%s: them=%s\n", __func__, theme);
		}
		else
		{
			FTK_FREE(thiz);
		}
	}

	return thiz;
}
Beispiel #12
0
static void priv_info_destroy(void* obj)
{
	PrivInfo* priv = (PrivInfo*)obj;

	FTK_FREE(priv);

	return;
}
static void ftk_animation_builder_destroy(FtkXmlBuilder* thiz)
{
	if(thiz != NULL)
	{
		FTK_FREE(thiz);
	}

	return;
}
void ftk_text_layout_destroy(FtkTextLayout* thiz)
{
	if(thiz != NULL)
	{
		FTK_FREE(thiz);
	}

	return;
}
Beispiel #15
0
Ret		   ftk_file_browser_set_filter(FtkWidget* thiz, const char* mime_type)
{
	PrivInfo* priv = (PrivInfo*)ftk_widget_user_data(thiz);
	return_val_if_fail(priv != NULL, RET_FAIL);	

	FTK_FREE(priv->filter_mime_type);
	priv->filter_mime_type = FTK_STRDUP(mime_type);

	return RET_OK;
}
Beispiel #16
0
void ftk_mmap_destroy(FtkMmap* thiz)
{
	if(thiz != NULL)
	{
		FTK_FREE(thiz->data);
		FTK_ZFREE(thiz, sizeof(*thiz));
	}

	return;
}
Beispiel #17
0
static void ftk_menu_item_destroy(FtkWidget* thiz)
{
	if(thiz != NULL)
	{
		DECL_PRIV0(thiz, priv);
		FTK_FREE(priv);
	}

	return;
}
Beispiel #18
0
static void fb_close(struct FbInfo *fb)
{
	if(fb != NULL)
	{
		munmap(fb->bits, fb_size(fb));
		close(fb->fd);
		FTK_FREE(fb);
	}

	return;
}
static Ret  ftk_input_method_win32_handle_event(FtkInputMethod* thiz, FtkEvent* event)
{
	Ret ret = RET_OK;
	DECL_PRIV(thiz, priv);
	return_val_if_fail(priv != NULL && event != NULL, RET_FAIL);

	switch(event->type)
	{
		case FTK_EVT_OS_IM_COMMIT:
		{
			FtkEvent evt = {0};

			ftk_logd("%s:%d FTK_EVT_OS_IM_COMMIT:%s\n", __FILE__, __LINE__, event->u.extra);

			if(priv->editor == NULL)
			{
				FTK_FREE(event->u.extra);
				ret = RET_REMOVE;
				break;
			}

			/* TODO: priv->input_type */

			evt.type = FTK_EVT_IM_COMMIT;
			evt.u.extra = event->u.extra;
			evt.widget = priv->editor;
			ftk_widget_event(priv->editor, &evt);

			FTK_FREE(event->u.extra);
			ret = RET_REMOVE;
			break;
		}
		case FTK_EVT_IM_ACT_COMMIT:
		{
			break;
		}
		default:break;
	}

	return ret;
}
Beispiel #20
0
void ftk_input_pattern_destroy(FtkInputPattern* thiz)
{
	InputPattern* save = NULL;
	InputPattern* iter = NULL;

	if(thiz != NULL)
	{
		iter = thiz->pattern;

		while(iter != NULL)
		{
			save = iter->next;
			FTK_FREE(iter);
			iter = save;
		}

		FTK_FREE(thiz);
	}

	return;
}
Beispiel #21
0
static void access_avi_destroy(Access *thiz)
{
	if(thiz)
	{
		DECL_PRIV(thiz, priv);
		
		block_destroy(priv->block);
		FTK_FREE(priv->file_path);
		av_close_input_file(priv->format_ctx);
		
		FTK_ZFREE(thiz, sizeof(*thiz) + sizeof(PrivInfo));
	}
	return;
}
Beispiel #22
0
static void ftk_key_board_desc_destroy(FtkKeyBoardDesc* desc)
{
	size_t v = 0;
	size_t r = 0;
	size_t c = 0;
	if(desc != NULL)
	{
		ftk_key_board_desc_dump(desc);

		for(v = 0 ; v < desc->view_nr; v++)
		{
			FtkKeyBoardView* view = desc->views+v;
			for(r = 0; r < view->row_nr; r++)
			{
				FtkKeyBoardRow* row = view->rows+r;
				for(c = 0; c < row->cell_nr; c++)
				{
					FtkKeyBoardCell* cell = row->cells+c;
					ftk_bitmap_unref(cell->icon);
					ftk_bitmap_unref(cell->bg_active);
					ftk_bitmap_unref(cell->bg_normal);
				}
				FTK_FREE(row->cells);
			}
			FTK_FREE(view->rows);
			ftk_bitmap_unref(view->bg);
			ftk_bitmap_unref(view->cell_bg_active);
			ftk_bitmap_unref(view->cell_bg_normal);
		}
		FTK_FREE(desc->views);
		ftk_bitmap_unref(desc->candidates_vertical_line);
		FTK_FREE(desc);
	}

	return;
}
Beispiel #23
0
static void ftk_app_bluetooth_destroy(FtkApp* thiz)
{
	if(thiz != NULL)
	{
		DECL_PRIV(thiz, priv);
		ftk_bitmap_unref(priv->icon);
		FTK_FREE(thiz);

		if (_bt) {
			bt_close(_bt);
			_bt = NULL;
		}
	}

	return;
}
Beispiel #24
0
Ret ftk_path_set_path(FtkPath* thiz, const char* path)
{
	return_val_if_fail(thiz != NULL, RET_FAIL);

	if(path != NULL)
	{
		thiz->nr = 0;
		thiz->cur = 0;
		thiz->full[0] = '\0';
		FTK_FREE(thiz->path);
		parse_token(path, "/\\", on_sub_path, thiz, &thiz->path);
		thiz->subs[thiz->nr] = NULL;
	}

	return RET_OK;
}
Beispiel #25
0
void fbus_proxy_destroy(FBusProxy* thiz)
{
	if(thiz != NULL)
	{
		if(thiz->source != NULL)
		{
			fbus_proxy_set_notify_listener(thiz, NULL, NULL);
		}
		fbus_stream_destroy(thiz->stream);
		if(thiz->parcel != NULL)
		{
			fbus_parcel_destroy(thiz->parcel);
		}

		FTK_FREE(thiz);
	}

	return;
}
Beispiel #26
0
FBusServiceInfos* fbus_service_infos_create(int capacity)
{
	FBusServiceInfos* thiz = FTK_ZALLOC(sizeof(FBusServiceInfos));
	
	if(thiz != NULL)
	{
		capacity = capacity < 5 ? 5 : capacity;
		thiz->service_infos = FTK_ZALLOC(sizeof(FBusServiceInfo) * capacity);
		if(thiz->service_infos != NULL)
		{
			thiz->port = FBUS_SERVICE_PORT_START;
			thiz->capacity = capacity;
		}
		else
		{
			FTK_FREE(thiz);
		}
	}

	return thiz;
}
Beispiel #27
0
static Ret timeout(void* ctx)
{
	TimerInfo* info = ctx;
	char buffer[32] = {0};
	if(info->times > 0)
	{
		ftk_snprintf(buffer, sizeof(buffer), "Quit after %d seconds", info->times);
		ftk_widget_set_text(info->label, buffer);
		info->times--;

		return RET_OK;
	}
	else
	{
		ftk_widget_unref(ftk_widget_toplevel(info->label));
		ftk_logd("%s: timeout and quit.\n", __func__);
		FTK_FREE(info);
		FTK_QUIT();
		return RET_REMOVE;
	}
}
Beispiel #28
0
FtkWidget* ftk_key_board_create(FtkWidget* parent, int x, int y, int width, int height)
{
	FtkWidget* thiz = (FtkWidget*)FTK_ZALLOC(sizeof(FtkWidget));
	return_val_if_fail(thiz != NULL, NULL);
	
	thiz->priv_subclass[0] = (PrivInfo*)FTK_ZALLOC(sizeof(PrivInfo));
	if(thiz->priv_subclass[0] != NULL)
	{
		thiz->on_event = ftk_key_board_on_event;
		thiz->on_paint = ftk_key_board_on_paint;
		thiz->destroy  = ftk_key_board_destroy;

		ftk_widget_init(thiz, FTK_KEY_BOARD, 0, x, y, width, height, FTK_ATTR_BG_FOUR_CORNER|FTK_ATTR_NO_FOCUS);
		ftk_widget_append_child(parent, thiz);
	}
	else
	{
		FTK_FREE(thiz);
	}

	return thiz;
}
Beispiel #29
0
FtkWidget* ftk_painter_create(FtkWidget* parent, int x, int y, int width, int height)
{
	FtkWidget* thiz = (FtkWidget*)FTK_ZALLOC(sizeof(FtkWidget));
	return_val_if_fail(thiz != NULL, NULL);
	
	thiz->priv_subclass[0] = (PrivInfo*)FTK_ZALLOC(sizeof(PrivInfo));
	if(thiz->priv_subclass[0] != NULL)
	{
		thiz->on_event = ftk_painter_on_event;
		thiz->on_paint = ftk_painter_on_paint;
		thiz->destroy  = ftk_painter_destroy;

		ftk_widget_init(thiz, FTK_PAINTER, 0, x, y, width, height, 0);
		ftk_widget_append_child(parent, thiz);
	}
	else
	{
		FTK_FREE(thiz);
	}

	return thiz;
}
Beispiel #30
0
FtkWidget* ftk_progress_bar_create(FtkWidget* parent, int x, int y, int width, int height)
{
	FtkWidget* thiz = (FtkWidget*)FTK_ZALLOC(sizeof(FtkWidget));
	return_val_if_fail(thiz != NULL, NULL);

	thiz->priv_subclass[0] = (PrivInfo*)FTK_ZALLOC(sizeof(PrivInfo));
	if(thiz->priv_subclass[0] != NULL)
	{
		thiz->on_event = ftk_progress_bar_on_event;
		thiz->on_paint = ftk_progress_bar_on_paint;
		thiz->destroy  = ftk_progress_bar_destroy;

		ftk_widget_init(thiz, FTK_PROGRESS_BAR, 0, x, y, width, height, 
			FTK_ATTR_TRANSPARENT|FTK_ATTR_INSENSITIVE);
		ftk_widget_append_child(parent, thiz);
	}
	else
	{
		FTK_FREE(thiz);
	}

	return thiz;
}