wgui_categories_imps.c

来自「The font library converting tool MCT mai」· C语言 代码 · 共 1,967 行 · 第 1/5 页

C
1,967
字号

static const UI_filled_area g_mmi_gui_cat435_multitap_filler=
{	UI_FILLED_AREA_TYPE_COLOR,
	NULL,
	NULL,
	{	216, 208, 200, 100		},
	{	0, 0, 0, 0					},
	{	0, 0, 0, 0					},
	{	0, 0, 0, 0					},
	0
};

static const color g_mmi_gui_cat435_popup_color = {216,  208, 200, 100}; 

#if defined (__MMI_WALLPAPER_ON_BOTTOM__)
static UI_image_ID_type editor_scr_bg_ID;
static S8* editor_scr_bg_filename;
static S32 editor_scr_bg_x, editor_scr_bg_y;
static U8 editor_scr_bg_opacity;
#endif

/***************************************************************************** 
* Local Function
*****************************************************************************/

/* 
 * Category 420 
 */

static void category420_compute_layout(void)
{
	S32 sw, sh; /* string width/height */
	S32 iw, ih; /* image width/height */
	S32 cw; /* content width */
	S32 line_height, tmp_y;
	S32 img_left_bound, img_left_lower_bound;

	cw = CAT420_CTX->content_width = UI_device_width - current_MMI_theme->scrollbar_size;

	pixtel_UI_set_font(&MMI_medium_font);

	/* Name */
	Get_StringWidthHeight((U8*) CAT420_CTX->name, &sw, &sh);
	if (sw > UI_device_width - (CAT420_LINE_EXTRA_PIXEL<<1))
	{
		sw = UI_device_width - (CAT420_LINE_EXTRA_PIXEL<<1);
	}
	CAT420_CTX->name_x = (cw - sw) >> 1;
	CAT420_CTX->name_y = CAT420_TOP_MARGIN;
	CAT420_CTX->name_width = sw;
	
	CAT420_CTX->line_x1 = CAT420_CTX->name_x - CAT420_LINE_EXTRA_PIXEL;
	CAT420_CTX->line_x2 = CAT420_CTX->name_x + sw + CAT420_LINE_EXTRA_PIXEL - 1;
	if (CAT420_CTX->line_x1 < 0)
	{
		CAT420_CTX->line_x1 = 0;
	}
	if (CAT420_CTX->line_x2 >= cw)
	{
		CAT420_CTX->line_x2 = cw - 1;
	}
	CAT420_CTX->line_y = CAT420_CTX->name_y + sh + CAT420_NAME_LINE_V_SPACING;

	img_left_lower_bound = 0;

	/* Mood */
#ifdef CAT420_DISP_INFO_TEXT
	tmp_y = CAT420_CTX->line_y + CAT420_LINE_IMAGE_V_SPACING;
	Get_StringWidthHeight((U8*) GetString(CAT420_CTX->mood_caption), &sw, &sh);
	pixtel_UI_measure_image(CAT420_CTX->mood_icon, &iw, &ih);
	CAT420_CTX->mood_caption_x = CAT420_LEFT_MARGIN;
	CAT420_CTX->mood_image_x = CAT420_CTX->mood_caption_x + sw + CAT420_CAPTION_IMAGE_H_SPACING ;
	line_height = sh > ih ? sh : ih;
	CAT420_CTX->mood_caption_y = tmp_y +  ((line_height - sh) >> 1);
	CAT420_CTX->mood_image_y = tmp_y + ((line_height - ih) >> 1);
	if (CAT420_CTX->mood_image_x + iw > img_left_lower_bound)
	{
		img_left_lower_bound = CAT420_CTX->mood_image_x + iw;
	}
	Get_StringWidthHeight((U8*)CAT420_CTX->mood_string, &sw, &sh);
	CAT420_CTX->mood_text_x = CAT420_LEFT_MARGIN;
	CAT420_CTX->mood_text_y = tmp_y + line_height + CAT420_MOOD_STATUS_V_SPACING;
	if (CAT420_CTX->mood_text_x + sw > img_left_lower_bound)
	{
		img_left_lower_bound = CAT420_CTX->mood_text_x + sw;
	}
#else
	UI_UNUSED_PARAMETER(line_height);
	tmp_y = CAT420_CTX->line_y + CAT420_LINE_IMAGE_V_SPACING;
	Get_StringWidthHeight((U8*) GetString(CAT420_CTX->mood_caption), &sw, &sh);
	pixtel_UI_measure_image(CAT420_CTX->mood_icon, &iw, &ih);
	CAT420_CTX->mood_caption_x = CAT420_LEFT_MARGIN;
	CAT420_CTX->mood_caption_y = tmp_y;
	CAT420_CTX->mood_image_x = CAT420_LEFT_MARGIN;
	CAT420_CTX->mood_image_y = tmp_y + sh + CAT420_MOOD_STATUS_V_SPACING;
	if (CAT420_CTX->mood_caption_x + sw > img_left_lower_bound)
	{
		img_left_lower_bound = CAT420_CTX->mood_caption_x + sw;
	}
	if (CAT420_CTX->mood_image_x + iw > img_left_lower_bound)
	{
		img_left_lower_bound = CAT420_CTX->mood_image_x + iw;
	}
#endif /* CAT420_DISP_INFO_TEXT */

	/* Status */
#ifdef CAT420_DISP_INFO_TEXT
	tmp_y = CAT420_CTX->mood_text_y + sh + CAT420_MOOD_STATUS_V_SPACING;
	Get_StringWidthHeight((U8*) GetString(CAT420_CTX->status_caption), &sw, &sh);
	pixtel_UI_measure_image(CAT420_CTX->status_icon, &iw, &ih);
	CAT420_CTX->status_caption_x = CAT420_LEFT_MARGIN;
	CAT420_CTX->status_image_x = CAT420_CTX->status_caption_x + sw + CAT420_CAPTION_IMAGE_H_SPACING ;
	line_height = sh > ih ? sh : ih;
	CAT420_CTX->status_caption_y = tmp_y + ((line_height - sh) >> 1);
	CAT420_CTX->status_image_y = tmp_y +  ((line_height - ih) >> 1);
	if (CAT420_CTX->status_image_x + iw > img_left_lower_bound)
	{
		img_left_lower_bound = CAT420_CTX->status_image_x + iw;
	}
	Get_StringWidthHeight((U8*)CAT420_CTX->status_string, &sw, &sh);
	CAT420_CTX->status_text_x = CAT420_LEFT_MARGIN;
	CAT420_CTX->status_text_y = tmp_y + line_height + CAT420_MOOD_STATUS_V_SPACING;
	if (CAT420_CTX->status_text_x + sw > img_left_lower_bound)
	{
		img_left_lower_bound = CAT420_CTX->status_text_x + sw;
	}
#else
	tmp_y = CAT420_CTX->mood_image_y + ih + CAT420_MOOD_STATUS_V_SPACING;
	Get_StringWidthHeight((U8*) GetString(CAT420_CTX->status_caption), &sw, &sh);
	pixtel_UI_measure_image(CAT420_CTX->status_icon, &iw, &ih);
	
	CAT420_CTX->status_caption_x = CAT420_LEFT_MARGIN;
	CAT420_CTX->status_caption_y = tmp_y;
	CAT420_CTX->status_image_x = CAT420_LEFT_MARGIN;
	CAT420_CTX->status_image_y = tmp_y + sh + CAT420_MOOD_STATUS_V_SPACING;

	if (CAT420_CTX->status_caption_x + sw > img_left_lower_bound)
	{
		img_left_lower_bound = CAT420_CTX->status_caption_x + sw;
	}
	if (CAT420_CTX->status_image_x + iw > img_left_lower_bound)
	{
		img_left_lower_bound = CAT420_CTX->status_image_x + iw;
	}
#endif /* CAT420_DISP_INFO_TEXT */

	/* Compute image width */
	img_left_lower_bound += CAT420_IMAGE_H_SPACING;
	if (img_left_lower_bound > cw - CAT420_RIGHT_MARGIN - CAT420_IMAGE_AREA_MIN_WIDTH)
	{
		img_left_lower_bound = cw - CAT420_RIGHT_MARGIN - CAT420_IMAGE_AREA_MIN_WIDTH;
	}
	img_left_bound = cw - CAT420_RIGHT_MARGIN - CAT420_IMAGE_AREA_WIDTH;
	if (img_left_bound < img_left_lower_bound)
	{
		img_left_bound = img_left_lower_bound;
	}
	img_left_lower_bound -= CAT420_IMAGE_H_SPACING;

	/* Total height */
#ifdef CAT420_DISP_INFO_TEXT
	CAT420_CTX->editor_header_height = CAT420_CTX->status_text_y + sh + CAT420_BOTTOM_MARGIN;
#else
	CAT420_CTX->editor_header_height = CAT420_CTX->status_image_y + ih + CAT420_BOTTOM_MARGIN;
#endif

	/* Image */
	if (img_left_bound + CAT420_RIGHT_MARGIN >= cw || CAT420_CTX->image_ori_width == 0 || CAT420_CTX->image_ori_height == 0)
	{
		CAT420_CTX->display_image = MMI_FALSE;
	}

	CAT420_CTX->image_area_x = img_left_bound;
	CAT420_CTX->image_area_y = CAT420_CTX->line_y + CAT420_LINE_IMAGE_V_SPACING;
	CAT420_CTX->image_area_width = cw - CAT420_RIGHT_MARGIN - img_left_bound;
#ifdef CAT420_DISP_INFO_TEXT
	CAT420_CTX->image_area_height = CAT420_CTX->status_text_y + sh - CAT420_CTX->image_area_y;
#else
	CAT420_CTX->image_area_height = CAT420_CTX->status_image_y + ih - CAT420_CTX->image_area_y;
#endif

	/* Align text/icon to right for Arabic language */
	if (r2lMMIFlag) 
	{
		S32 xd;
	
		/* Align mood to right */
		xd = CAT420_CTX->mood_caption_x - CAT420_LEFT_MARGIN;
		sw = pixtel_UI_get_string_width((UI_string_type)GetString(CAT420_CTX->mood_caption));
		CAT420_CTX->mood_caption_x = img_left_lower_bound - xd - sw + 1;

		xd = CAT420_CTX->mood_image_x - CAT420_LEFT_MARGIN;
		pixtel_UI_measure_image(CAT420_CTX->mood_icon, &iw, &ih);
		CAT420_CTX->mood_image_x = img_left_lower_bound - xd - iw + 1;

#ifdef CAT420_DISP_INFO_TEXT
		xd = CAT420_CTX->mood_text_x - CAT420_LEFT_MARGIN;
		sw = pixtel_UI_get_string_width(CAT420_CTX->mood_string);
		CAT420_CTX->mood_text_x = img_left_lower_bound - xd - sw + 1;
#endif

		/* Align status to right */
		xd = CAT420_CTX->status_caption_x - CAT420_LEFT_MARGIN;
		sw = pixtel_UI_get_string_width((UI_string_type)GetString(CAT420_CTX->status_caption));
		CAT420_CTX->status_caption_x = img_left_lower_bound - xd - sw + 1;

		xd = CAT420_CTX->status_image_x - CAT420_LEFT_MARGIN;
		pixtel_UI_measure_image(CAT420_CTX->status_icon, &iw, &ih);
		CAT420_CTX->status_image_x = img_left_lower_bound - xd - iw + 1;

#ifdef CAT420_DISP_INFO_TEXT
		xd = CAT420_CTX->status_text_x - CAT420_LEFT_MARGIN;
		sw = pixtel_UI_get_string_width(CAT420_CTX->status_string);
		CAT420_CTX->status_text_x = img_left_lower_bound - xd - sw + 1;
#endif


	}


	/* Resize photo if required */
	if (CAT420_CTX->display_image)
	{
		S32 zoom_offset_x, zoom_offset_y, zoom_size_width, zoom_size_height;
		
		if (CAT420_CTX->image_ori_width <= CAT420_CTX->image_area_width &&
		  CAT420_CTX->image_ori_height <= CAT420_CTX->image_area_height)
		{
			zoom_offset_x = (CAT420_CTX->image_area_width -CAT420_CTX->image_ori_width) >> 1 ;
			zoom_offset_y = (CAT420_CTX->image_area_height -CAT420_CTX->image_ori_height) >> 1 ;
			zoom_size_width = 0;
			zoom_size_height = 0;
		}
		else
		{
			gdi_image_util_fit_bbox((S32)CAT420_CTX->image_area_width, (S32)CAT420_CTX->image_area_height , 
				(S32)CAT420_CTX->image_ori_width, (S32)CAT420_CTX->image_ori_height, 
				&zoom_offset_x, &zoom_offset_y, &zoom_size_width, &zoom_size_height);
		}
		CAT420_CTX->image_x_offset = (S16) CAT420_CTX->image_area_x + zoom_offset_x;
		CAT420_CTX->image_y_offset = (S16) CAT420_CTX->image_area_y + zoom_offset_y;
		CAT420_CTX->image_resized_width = (S16) zoom_size_width;
		CAT420_CTX->image_resized_height = (S16) zoom_size_height;
	}
}


/* FIXME. We may move image caching routines to wgui.c */
static void category420_cache_image(S8 *image_path, U8 *alternative_image, S32 use_alternative_image)
{
	if (!CAT420_CTX->display_image)
	{
		CAT420_CTX->image_is_cached = 0;
		CAT420_CTX->cache_layer = GDI_LAYER_EMPTY_HANDLE;
	}
	else
	{
		CAT420_CTX->image_is_cached = 1;
		gdi_layer_multi_layer_enable();
		gdi_layer_create(0, 0, UI_device_width, UI_device_height, &CAT420_CTX->cache_layer);
		gdi_layer_push_and_set_active(CAT420_CTX->cache_layer);

		if (CAT420_CTX->image_resized_width == 0 || CAT420_CTX->image_resized_height == 0)
		{
			/* Fill background in case that the image is truncated */
			gdi_draw_solid_rect(0, 0, CAT420_CTX->image_ori_width, CAT420_CTX->image_ori_height, gdi_act_color_from_rgb(255, 255, 255, 255));
			if (use_alternative_image)
			{
				gdi_image_draw(0, 0, alternative_image);
			}
			else
			{
				gdi_image_draw_file(0, 0, image_path);
			}
		}
		else
		{
			gdi_draw_solid_rect(0, 0, CAT420_CTX->image_resized_width, CAT420_CTX->image_resized_height, gdi_act_color_from_rgb(255, 255, 255, 255));
			if (use_alternative_image)
			{
				gdi_image_draw_resized(0, 0, CAT420_CTX->image_resized_width, CAT420_CTX->image_resized_height, alternative_image);
			}
			else
			{
				gdi_image_draw_resized_file(0, 0, CAT420_CTX->image_resized_width, CAT420_CTX->image_resized_height, image_path);
			}
		}

		gdi_layer_pop_and_restore_active();
	}
}

/* Free GDI layer of the image cache */
static void category420_free_image_cache(void)
{
	if (CAT420_CTX->image_is_cached)
	{
		gdi_layer_free(CAT420_CTX->cache_layer);
		gdi_layer_multi_layer_disable();
	}
}


static void category420_show_cached_image(S32 x_offset, S32 y_offset, S32 width, S32 height)
{
	S32 x1, y1, x2, y2, x, y, y_multiple;
	U16 *cached_buffer;

	if (!CAT420_CTX->image_is_cached)
		return;

	/* Get clipping region inside the editor */
	gdi_layer_get_clip(&x1, &y1, &x2, &y2);

	gdi_layer_push_and_set_active(CAT420_CTX->cache_layer);
	gdi_layer_get_buffer_ptr((U8 **)&cached_buffer);
	gdi_layer_pop_and_restore_active();

	if (x1 < x_offset)
		x1 = x_offset;
	if (y1 < y_offset)
		y1 = y_offset;
	if (x2 > x_offset + width - 1)
		x2 = x_offset + width - 1;
	if (y2 > y_offset + height - 1)
		y2 = y_offset + height - 1;

	y_multiple = (y1 - y_offset) * UI_device_width;
	for (y = y1; y <= y2; y++)
	{
		for (x = x1; x <= x2; x++)
		{
			GDI_SET_BUFFER_PIXEL(x, y, cached_buffer[y_multiple + x - x_offset]);
		}
		y_multiple += UI_device_width;
	}
}


static void category420_header_callback(S32 yoffset, S32 clip_x1, S32 clip_y1, S32 clip_x2, S32 clip_y2)
{
	S32 sw, sh; /* string width/height */
	color tc;
	gdi_color c;
	S32 xoffset = 0;

	/* Hack. xoffset should be provided in callback function */
	if (r2lMMIFlag)
	{
		xoffset = MMI_multiline_inputbox.vbar.width;
	}

	pixtel_UI_push_clip();
	pixtel_UI_push_text_clip();
	pixtel_UI_set_clip(clip_x1, clip_y1, clip_x2, clip_y2);
	pixtel_UI_set_text_clip(clip_x1, clip_y1, clip_x2, clip_y2);
	pixtel_UI_set_font(&MMI_medium_font);

	tc.r = CAT420_TEXT_COLOR_R;
	tc.g = CAT420_TEXT_COLOR_G;
	tc.b = CAT420_TEXT_COLOR_B;
	tc.alpha = 100;
	pixtel_UI_set_text_color(tc);

	c = gdi_act_color_from_rgb(255, CAT420_LINE_COLOR_R, CAT420_LINE_COLOR_G, CAT420_LINE_COLOR_B);
	
	/* Name */
	Get_StringWidthHeight((U8*) CAT420_CTX->name, &sw, &sh);
	if (sw > CAT420_CTX->name_width)
	{
		if (r2lMMIFlag)
		{
			pixtel_UI_print_truncated_text(xoffset + CAT420_CTX->name_x + CAT420_CTX->name_width - 1, yoffset + CAT420_CTX->name_y, CAT420_CTX->name_width, CAT420_CTX->name);
		}
		else
		{
			pixtel_UI_print_truncated_text(xoffset + CAT420_CTX->name_x, yoffset + CAT420_CTX->name_y, CAT420_CTX->name_width, CAT420_CTX->name);
		}
	}
	else
	{
		if (r2lMMIFlag)
		{
			pixtel_UI_move_text_cursor(xoffset + CAT420_CTX->name_x + sw - 1, yoffset + CAT420_CTX->name_y);
		}
		else
		{
			pixtel_UI_move_text_cursor(xoffset + CAT420_CTX->name_x, yoffset + CAT420_CTX->name_y);
		}
		pixtel_UI_print_text(CAT420_CTX->name);
	}

	gdi_draw_line_style(xoffset + CAT420_CTX->line_x1, yoffset + CAT420_CTX->line_y, xoffset + CAT420_CTX->line_x2, yoffset + CAT420_CTX->line_y, 
					c, sizeof(g_mmi_gui_cat420_line_style), g_mmi_gui_cat420_line_style);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?