Beispiel #1
0
static Ret _movie_user_on_event(FtkWidget* thiz, FtkEvent* event)
{
	FtkWidget* panel = NULL;

	if (event->type == FTK_EVT_MOUSE_UP)
	{
		system("killall mplayer");
		ftk_widget_invalidate(thiz);

		panel = ftk_default_status_panel();
		if (panel)
			ftk_widget_invalidate(panel);
	}

	return RET_OK;
}
static Ret  ftk_wnd_manager_default_map_panels(FtkWndManager* thiz, int map)
{
	int i = 0;
	Ret ret = RET_IGNORED;
	FtkEvent event;
	FtkWidget* win = NULL;
	DECL_PRIV(thiz, priv);
	return_val_if_fail(thiz != NULL && priv->top > 0, RET_FAIL);
	
	for(i = 0; i < priv->top; i++)
	{
		win = priv->windows[i];
		if(ftk_widget_type(win) == FTK_STATUS_PANEL && ftk_widget_is_visible(win))
		{
			if(!(map && ftk_window_is_mapped(win)))
			{
				ftk_event_init(&event, map ? FTK_EVT_MAP : FTK_EVT_UNMAP);
				event.widget = win;
				ftk_wnd_manager_dispatch_event(thiz, &event);
				ret = RET_OK;
			}
			ftk_widget_invalidate(win);
		}
	}

	return ret;
}
Beispiel #3
0
Ret        ftk_check_button_set_checked(FtkWidget* thiz, int checked)
{
	DECL_PRIV0(thiz, priv);
	return_val_if_fail(thiz != NULL, RET_FAIL);

	if(priv->checked != checked)
	{
		priv->checked = checked;
		ftk_widget_invalidate(thiz);
	}

	return RET_OK;
}
Beispiel #4
0
Ret ftk_check_button_set_icon_position(FtkWidget* thiz, int at_right)
{
	DECL_PRIV0(thiz, priv);
	return_val_if_fail(thiz != NULL, RET_FAIL);

	if(priv->icon_at_right != at_right)
	{
		priv->icon_at_right = at_right;
		ftk_widget_invalidate(thiz);
	}

	return RET_OK;
}
Beispiel #5
0
static Ret designer_on_delete(void* ctx, void* item)
{
	FtkWidget* win = (FtkWidget*)ctx;
	Info* info = (Info*)ftk_widget_user_data(win);
	
	if(designer_has_selected_widget(win))
	{
		ftk_widget_remove_child(ftk_widget_parent(info->selected_widget), info->selected_widget);
		info->selected_widget = NULL;
		ftk_widget_invalidate(win);
	}

	return RET_OK;
}
Beispiel #6
0
Ret ftk_image_set_image(FtkWidget* thiz, FtkBitmap* image)
{
	FtkGc gc = {0};
	return_val_if_fail(thiz != NULL && image != NULL, RET_FAIL);

	gc.mask = FTK_GC_BITMAP;
	gc.bitmap = image;
	ftk_widget_set_gc(thiz, FTK_WIDGET_INSENSITIVE, &gc);
	ftk_bitmap_unref(image);

	ftk_widget_invalidate(thiz);

	return RET_OK;
}
Beispiel #7
0
Ret ftk_key_board_load(FtkWidget* thiz, const char* filename)
{
	DECL_PRIV0(thiz, priv);
	
	return_val_if_fail(thiz != NULL && filename != NULL && priv->desc == NULL, RET_FAIL);
	
	priv->desc = ftk_key_board_desc_create(filename);
	return_val_if_fail(priv->desc != NULL, RET_FAIL);

	priv->desc->current_view = 0;
	ftk_key_board_desc_layout(priv->desc, ftk_widget_width(thiz), ftk_widget_height(thiz));
	ftk_widget_invalidate(thiz);

	return RET_OK;
}
Beispiel #8
0
Ret ftk_progress_bar_set_percent(FtkWidget* thiz, int percent)
{
	DECL_PRIV0(thiz, priv);
	return_val_if_fail(thiz != NULL, RET_FAIL);

	percent = percent < 0 ? 0 : percent;
	percent = percent > 100 ? 100 : percent;
	if(percent != priv->percent)
	{
		priv->percent = percent;
		ftk_widget_invalidate(thiz);
	}

	return RET_OK;
}
Beispiel #9
0
Ret ftk_scroll_bar_set_value(FtkWidget* thiz, int value)
{
	DECL_PRIV0(thiz, priv);
	return_val_if_fail(priv != NULL, RET_FAIL);
	value = value < 0 ? 0 : value;
	value = (value + priv->page_delta) < priv->max_value ? value : priv->max_value - priv->page_delta;
	
	if(value != priv->value)
	{
		priv->value = value;
		ftk_widget_invalidate(thiz);	
		return FTK_CALL_LISTENER(priv->listener, priv->listener_ctx, thiz);
	}

	return RET_OK;
}
Beispiel #10
0
Ret ftk_scroll_bar_set_param(FtkWidget* thiz, int value, int max_value, int page_delta)
{
	DECL_PRIV0(thiz, priv);
	return_val_if_fail(priv != NULL, RET_FAIL);
	return_val_if_fail(value <= max_value && page_delta <= max_value, RET_FAIL);
	return_val_if_fail(max_value > 0 && page_delta > 0, RET_FAIL);

	if(priv->value == value 
		&& priv->max_value == max_value 
		&& priv->page_delta == page_delta)
	{
		return RET_OK;
	}

	priv->value      = value < 0 ? 0 : value;
	priv->max_value  = max_value;
	priv->page_delta = page_delta;
	ftk_widget_invalidate(thiz);	

	return RET_OK;
}
Beispiel #11
0
static Ret ftk_key_board_switch_view(FtkWidget* thiz, FtkKeyBoardCell* cell)
{
	DECL_PRIV0(thiz, priv);
	FtkKeyBoardDesc* desc = priv->desc;
	const char* im_str = strchr(cell->action_args, ',');
	
	desc->current_view = ftk_atoi(cell->action_args);

	/*The second args is optional, means input method.*/
	if(im_str != NULL)
	{
		int im_index = ftk_atoi(im_str + 1);
		ftk_input_method_manager_set_current(ftk_default_input_method_manager(), im_index);
		ftk_logd("%s: input method change to %d\n", __func__, im_index);
	}
	ftk_widget_invalidate(thiz);

	ftk_logd("%s:%d %s %s\n", __func__, __LINE__, cell->text, cell->action_args);

	return RET_OK;
}
Beispiel #12
0
static Ret ftk_key_board_on_mouse_event(FtkWidget* thiz, FtkEventType event, size_t x, size_t y)
{
	DECL_PRIV0(thiz, priv);
	FtkKeyBoardCell* cell = NULL;
	FtkKeyBoardDesc* desc = priv->desc;	
	FtkKeyBoardView* view = desc->views + desc->current_view;

	x -= ftk_widget_left_abs(thiz);
	y -= ftk_widget_top_abs(thiz);

	view->last_click_pos.x = x;
	view->last_click_pos.y = y;
	cell = ftk_key_board_find_cell(thiz, x, y);

	if(cell == NULL)
	{
		return RET_OK;
	}

	if(cell->action == ftk_key_board_candidate_text)
	{
		size_t i = 0;
		size_t x_c = cell->x;

		for(i = desc->candidate_start; i < desc->candidate_nr; i++)
		{
			FtkKeyBoardCandidate* candidate = desc->candidates+i;
			if(x >= x_c && x < (x_c + candidate->extent))
			{
				desc->candidate_focus = i;
				ftk_logd("%s:%d on %s\n", __func__, __LINE__, candidate->text);
				break;
			}
			x_c += candidate->extent + desc->candidate_space;
		}
		ftk_widget_invalidate(thiz);
	}

	switch(event)
	{
		case FTK_EVT_MOUSE_DOWN:
		{
			view->focus = cell;
			ftk_window_grab(ftk_widget_toplevel(thiz), thiz);
			break;
		}	
		case FTK_EVT_MOUSE_UP:
		{
			if(cell->action != NULL)
			{
				cell->action(thiz, cell);
			}
		
			view->focus = NULL;
			desc->candidate_focus = -1;
			ftk_window_ungrab(ftk_widget_toplevel(thiz), thiz);
		}
		default:
		{
			if(view->focus == cell)
			{
				return RET_OK;
			}
			
			if(view->focus != NULL)
			{
				view->focus = cell;
			}

		}
	}
	
	if(cell->action != NULL)
	{
		ftk_widget_invalidate(thiz);
	}

	return RET_OK;
}