⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wgui_inline_edit.c

📁 The font library converting tool MCT mainly introduces the process of the font formats to give us a
💻 C
📖 第 1 页 / 共 5 页
字号:

	attach_item = (wgui_inline_image_attachment *) item->item;

	attach_item->title = title;
	attach_item->title_icon = title_icon;
	attach_item->highlited_image = highlight_image;
	attach_item->flags = 0;
	attach_item->image1 = image1;
	attach_item->image2 = image2;
	attach_item->image3 = image3;
	item->handler = handle_attachment_image;
#ifdef __MMI_TOUCH_SCREEN__
	attach_item->highlight_changed = 0;
	memset(attach_item->image_left_top, 0, sizeof(attach_item->image_left_top));
	memset(attach_item->image_right_bottom, 0, sizeof(attach_item->image_right_bottom));
#endif /*__MMI_TOUCH_SCREEN__*/
}


void ShowImageAttach(UI_image_type image, UI_string_type str)
{
	S32 width = 0, height = 0, img_x = 0, img_y = 0;

	gdi_layer_lock_frame_buffer();

	clear_screen();

	change_left_softkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
	change_right_softkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);

	MMI_menu_shortcut_number = -1;
	MMI_disable_title_shortcut_display = 1;

	clear_key_handlers();

	clear_left_softkey();
	clear_right_softkey();

	register_left_softkey_handler();
	register_right_softkey_handler();
	register_default_hide_softkeys();

	change_left_softkey(STR_GLOBAL_OK, IMG_GLOBAL_OK);
	change_right_softkey(STR_GLOBAL_BACK, IMG_GLOBAL_BACK);

	MMI_title_string = (UI_string_type) str;
	MMI_title_icon = 0;

	pixtel_UI_measure_image(image, &width, &height);

	img_x = (UI_device_width >> 1) - (width >> 1);
	img_y = (MMI_title_y + MMI_title_height) + 1;

	img_y = img_y + ((MMI_CONTENT_HEIGHT >> 1) - (height >> 1));

	draw_title();
	pixtel_UI_show_image(img_x, img_y, image);

	gdi_layer_unlock_frame_buffer();

	gdi_layer_blt_previous(0, 0, UI_device_width - 1, UI_device_height - 1);
}


void handle_attachment_image(S32 x, S32 y, S32 iwidth, S32 iheight, S32 key_code, S32 key_event, U8 ** text_p,
									  void *item, dword flags, U8 * history_buffer)
{
	S32 width = 0, height = 0;
	wgui_inline_image_attachment *image_attach = (wgui_inline_image_attachment *) item;

	UI_UNUSED_PARAMETER(x);
	UI_UNUSED_PARAMETER(y);
	UI_UNUSED_PARAMETER(width);
	UI_UNUSED_PARAMETER(height);
	UI_UNUSED_PARAMETER(key_code);
	UI_UNUSED_PARAMETER(key_event);
	UI_UNUSED_PARAMETER(flags);

	image_attach->lsk_function(image_attach->attach_image[image_attach->highlited_image].image1,
										(UI_string_type) image_attach->attach_image[image_attach->highlited_image].
										image_file_name);
}


void register_inline_image_attach_keys(void)
{
	SetKeyHandler(attach_control_right_arrow, KEY_RIGHT_ARROW, KEY_EVENT_DOWN);
	SetKeyHandler(attach_control_left_arrow, KEY_LEFT_ARROW, KEY_EVENT_DOWN);
}


void show_attachment_images(S32 x1, S32 y1, S32 iwidth, S32 iheight, wgui_inline_image_attachment * image_control,
									 U8 highlight)
{

	S32 width = 0, height = 0, temp_x = x1 + 1, index = 0, img_y1 = 0;
	color blue_col = pixtel_UI_color(0, 0, 255);

	if (highlight)
	{
		gdi_layer_lock_frame_buffer();
	}

	gdi_layer_reset_clip();
	pixtel_UI_reset_text_clip();

	if (!r2lMMIFlag)
	{
		if (image_control->image1)
		{
			pixtel_UI_measure_image((UI_image_type) image_control->image1, &width, &height);
			img_y1 = (iheight >> 1) - (height >> 1);
			pixtel_UI_show_transparent_image(temp_x, (y1 + img_y1), image_control->image1, 0);
			temp_x = x1 + width + ATTACHMENT_IMAGE_ITEM_ICON_MARGIN;
		}

		if (image_control->image2)
		{
			pixtel_UI_measure_image(image_control->image2, &width, &height);
			img_y1 = (iheight >> 1) - (height >> 1);
			pixtel_UI_show_transparent_image(temp_x, (y1 + img_y1), image_control->image2, 0);
			temp_x += width + ATTACHMENT_IMAGE_ICON_MARGIN;

		}

		/** Show attachment images*/
		n_images_in_inline_attach_item = 0;
		for (index = 0; index < MAX_IMAGES_IN_INLINE_ATTACHMENT; index++)
		{
			if (image_control->attach_image[index].image1)
			{
				n_images_in_inline_attach_item++;
				pixtel_UI_measure_image((UI_image_type) image_control->attach_image[index].image1, &width, &height);
				img_y1 = (iheight >> 1) - (height >> 1);

				if ((image_control->highlited_image == index) && (highlight == ATTACHMENT_IMAGE_ITEM_HIGHLIGHTED))
					pixtel_UI_fill_rectangle(temp_x - 1, y1 + img_y1 - 1, (temp_x + width), (y1 + img_y1 + height),
													 blue_col);

				pixtel_UI_show_transparent_image(temp_x, (y1 + img_y1), image_control->attach_image[index].image1, 0);

#ifdef __MMI_TOUCH_SCREEN__
				image_control->image_left_top[index].x = temp_x;
				image_control->image_left_top[index].y = y1 + img_y1;
				image_control->image_right_bottom[index].x = temp_x + width - 1;
				image_control->image_right_bottom[index].y = y1 + img_y1 + height - 1;
#endif /* __MMI_TOUCH_SCREEN__ */

				temp_x = temp_x + width + ATTACHMENT_IMAGE_ICON_MARGIN;
			}
		}

		/********/

		if (image_control->image3)
		{
			pixtel_UI_measure_image(image_control->image3, &width, &height);
			img_y1 = (MMI_INLINE_EDIT_MENUITEM_HEIGHT >> 1) - (height >> 1);
			//temp_x = (UI_device_width - width - 8);
			temp_x = (x1 + 1) + iwidth - (width + ATTACHMENT_IMAGE_ICON_MARGIN);
			pixtel_UI_show_transparent_image(temp_x, (y1 + img_y1), image_control->image3, 0);
		}

	}
	else
	{
		temp_x = UI_device_width - 1;
		if (image_control->image1)
		{
			pixtel_UI_measure_image((UI_image_type) image_control->image1, &width, &height);
			img_y1 = (iheight >> 1) - (height >> 1);
			temp_x -= width;
			pixtel_UI_show_transparent_image(temp_x, (y1 + img_y1), image_control->image1, 0);
		}

		if (image_control->image3)
		{
			pixtel_UI_measure_image(image_control->image3, &width, &height);
			img_y1 = (iheight >> 1) - (height >> 1);
			temp_x -= (width + ATTACHMENT_IMAGE_ICON_MARGIN);
			pixtel_UI_show_transparent_image(temp_x, (y1 + img_y1), image_control->image3, 0);
		}

		/** Show attachment images*/
		n_images_in_inline_attach_item = 0;
		for (index = MAX_IMAGES_IN_INLINE_ATTACHMENT - 1; index >= 0; index--)
		{
			if (image_control->attach_image[index].image1)
			{
				n_images_in_inline_attach_item++;
				pixtel_UI_measure_image((UI_image_type) image_control->attach_image[index].image1, &width, &height);
				img_y1 = (iheight >> 1) - (height >> 1);
				temp_x -= (width + ATTACHMENT_IMAGE_ICON_MARGIN);
				if ((image_control->highlited_image == index) && (highlight == ATTACHMENT_IMAGE_ITEM_HIGHLIGHTED))
					pixtel_UI_fill_rectangle((temp_x - 1), y1 + img_y1 - 1, (temp_x + width), (y1 + img_y1 + height),
													 blue_col);

				pixtel_UI_show_transparent_image(temp_x, (y1 + img_y1), image_control->attach_image[index].image1, 0);

#ifdef __MMI_TOUCH_SCREEN__
				image_control->image_left_top[index].x = temp_x;
				image_control->image_left_top[index].y = y1 + img_y1;
				image_control->image_right_bottom[index].x = temp_x + width - 1;
				image_control->image_right_bottom[index].y = y1 + img_y1 + height - 1;
#endif /* __MMI_TOUCH_SCREEN__ */
			}
		}

		if (image_control->image2)
		{
			pixtel_UI_measure_image(image_control->image2, &width, &height);
			img_y1 = (MMI_INLINE_EDIT_MENUITEM_HEIGHT >> 1) - (height >> 1);
			temp_x = (UI_device_width - 1) - iwidth + ATTACHMENT_IMAGE_ICON_MARGIN;
			pixtel_UI_show_transparent_image(temp_x, (y1 + img_y1), image_control->image2, 0);
		}
	}

	if (highlight)
	{
		gdi_layer_unlock_frame_buffer();
		gdi_layer_blt_previous(1, y1, (x1 + iwidth - 1), (y1 + iheight - 1));
	}
}


void wpixtel_UI_show_image_attachment_item(S32 x1, S32 y1, S32 iwidth, S32 iheight, wgui_inline_item * item)
{
	wgui_inline_image_attachment *image = (wgui_inline_image_attachment *) item->item;

	if ((item->flags & INLINE_ITEM_DISABLE_HIGHLIGHT))
		attach_disable_flag = MMI_TRUE;
	else
		attach_disable_flag = MMI_FALSE;

	image->highlited_image = 0;
    if ( image->image_change_cb )
    {
        image->image_change_cb(0);
    }
	show_attachment_images(x1, y1, iwidth, iheight, image, ATTACHMENT_IMAGE_ITEM_UNHIGHLIGHTED);
}


void wpixtel_UI_show_image_attachment_item_highlight(S32 x1, S32 y1, S32 iwidth, S32 iheight, wgui_inline_item * item)
{
	wgui_inline_image_attachment *image = (wgui_inline_image_attachment *) item->item;

	image->control_x1 = (U8) x1;
	image->control_y1 = (U8) y1;
	image->control_width = (U8) iwidth;
	image->control_height = (U8) iheight;

	current_attach_control = image;
	register_inline_image_attach_keys();

	clear_inline_item_keys = clear_inline_image_attachment_item;
	redraw_current_inline_item = redraw_image_attachment_control;

	register_inline_image_attach_keys();
#ifdef __MMI_TOUCH_SCREEN__
	wgui_current_inline_item_pen_function = inline_image_attachment_pen_handler;
#endif /* __MMI_TOUCH_SCREEN__ */

	show_attachment_images(x1, y1, iwidth, iheight, image, ATTACHMENT_IMAGE_ITEM_HIGHLIGHTED);
}


/*****************************************************************************
* FUNCTION
*	 RegisterAttachmentHighlightedFunction()
* DESCRIPTION
*   Register highlighted item callback function
* PARAMETERS
*	 item		IN			inline item
*	 f			IN			callback function
* RETURNS
*   void
* GLOBALS AFFECTED
*   nil
*****************************************************************************/
void RegisterAttachmentHighlightedFunction (InlineItem * item, void (*f)(S32 index))
{
	
	wgui_inline_image_attachment *attach_item;

	if (f)
	{
		attach_item = (wgui_inline_image_attachment *) item->item;
		attach_item->image_change_cb= f;
	}
}
#ifdef __MMI_TOUCH_SCREEN__

/* If success, *item_index >= 0 and return MMI_TRUE
 * Otherwise, *item_index < 0 and return MMI_FALSE
 */
static BOOL pixtel_UI_image_attachment_translate_pen_position(S16 x, S16 y, S32 * item_index)
{
	S32 index;
	S32 x1, y1, x2, y2;
	wgui_inline_image_attachment *image_control;

	MMI_DBG_ASSERT(current_attach_control);

	image_control = current_attach_control;

	*item_index = -1;

	for (index = 0; index < n_images_in_inline_attach_item; index++)
	{
		if (image_control->attach_image[index].image1)
		{
			x1 = image_control->image_left_top[index].x;
			y1 = image_control->image_left_top[index].y;
			x2 = image_control->image_right_bottom[index].x;
			y2 = image_control->image_right_bottom[index].y;

			if (x >= x1 && x <= x2 && y >= y1 && y <= y2)
			{
				*item_index = index;
				break;
			}
		}
	}

	if (*item_index < 0)
	{
		return MMI_FALSE;
	}
	else
	{
		return MMI_TRUE;
	}
}


BOOL inline_image_attachment_pen_handler(mmi_pen_event_type_enum pen_event, S16 x, S16 y,
													  mmi_gui_inline_item_pen_enum * item_event)
{
	BOOL ret;
	S32 x1, y1, x2, y2;
	wgui_inline_image_attachment *image_control;

	MMI_DBG_ASSERT(current_attach_control);

	image_control = current_attach_control;

	x1 = image_control->control_x1;
	y1 = image_control->control_y1;
	x2 = x1 + image_control->control_width;
	y2 = y1 + image_control->control_height;

	ret = MMI_TRUE;
	*item_event = GUI_INLINE_ITEM_PEN_NONE;

	switch (pen_event)
	{
		case MMI_PEN_EVENT_DOWN:
		{
			if (PEN_CHECK_BOUND(x, y, x1, y1, x2, y2))
			{
				S32 index;

				if (pixtel_UI_image_attachment_translate_pen_position(x, y, &index))
				{
					image_control->highlited_image = index;
					if ( image_control->image_change_cb )
					{
						image_control->image_change_cb(image_control->highlited_image);
					}
					*item_event = GUI_INLINE_ITEM_PEN_NEED_REDRAW_ITEM;
				}
				image_control->highlight_changed = 0;
			}
			else
			{
				ret = MMI_FALSE;
			}
		}
			break;

		case MMI_PEN_EVENT_MOVE:
		{
			S32 index;

			pixtel_UI_image_attachment_translate_pen_position(x, y, &index);
			if (index != image_control->highlited_image)
			{
				image_control->highlight_changed = 1;
			}
		}
			break;

		case MMI_PEN_EVENT_UP:
		{
			S32 index;

			pixtel_UI_image_attachment_translate_pen_position(x, y, &index);
			if (index == image_control->highlited_image && !image_control->highlight_changed)
			{
				*item_event = GUI_INLINE_ITEM_PEN_SELECTED;
			}
		}
			break;

		case MMI_PEN_EVENT_LONG_TAP:
			/*Do Nothing */
			break;

		case MMI_PEN_EVENT_REPEAT:
			/*Do Nothing */
			break;

		case MMI_PEN_EVENT_ABORT:
			/*Do Nothing */
			break;

		default:
			MMI_DBG_ASSERT(0);
	}

	return ret;
}

#endif /*__MMI_TOUCH_SCREEN__*/

#endif //__MMI_PLUTO_GPRS__


/************************** Image Text Control End ********/

void inline_fixed_list_goto_previous_item(void)
{
	/* FIXME. register as complete_inline_item_edit()? */
	if (!(MMI_multiline_inputbox.flags & UI_MULTI_LINE_INPUT_BOX_VIEW_MODE) &&
		 (MMI_multiline_inputbox.flags & UI_MULTI_LINE_INPUT_BOX_INSIDE_INLINE_MENU))
	{
		handle_inline_multi_line_

⌨️ 快捷键说明

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