Mtk mmi Summary

Source: Internet
Author: User

 

MMI Summary
1. Draw a string
Declare the header file "Gui. H"
Set Font:
Void (* pixtel_ui_set_font) (ui_font_type f) = NULL;
The parameter F is the font to be used. You can use the existing font of the system, for example, mmi_sublcd_font. You can also customize the font. Use stfontattribute xxxx to define the font you need.
Definitions of Chinese fonts in the decryption MTK document/MMI/176x220upls.pdf
Set the text display position:
Void (* pixtel_ui_move_text_cursor) (s32 X, s32 y) = NULL;
The X and Y parameters are the coordinates in the upper left corner of the string to be displayed.
Set text color:
Void (* pixtel_ui_set_text_color) (color C) = NULL;
Color is a struct. Used to define the RGB color and Alpha Channel
Typedef struct _ color
{
Byte R;
Byte g;
Byte B;
Byte Alpha;
} Color;
Print text:
Void (* pixtel_ui_print_text) (ui_string_type_text) = NULL;
Note that l must be added before the string.
2. Image Rendering
How to make transparent background images:
1. First, use Photoshop to design a BMP Image
2 [Image] [mode] change its color to index color
3. [Image] [mode] Open the color table of the image. Change the color value of the first cell to other colors not used in the image. Click Save.
4. After the image is imported into the MTK project, the background is transparent when the image is covered in other images.
MTK does not support PNG images. resource files in the images directory do not support JPEG images, and PNG images are also not supported.
Image Rendering:
Void (* pixtel_ui_show_transparent_image) (s32 X, s32 y, ui_image_type I, ui_transparent_color_type T) = NULL;
This function uses X and Y as the coordinates to draw an image, and specifies the color T as the transparent color, that is, t color is not displayed, as transparent.
For example, an image with the ID of img_global_test is displayed at the origin.
Pixtel_ui_show_transparent_image (0, 0, get_image (img_global_test), pixel tel_ui_transparent_color (255,255,203 ));
Then, you need to set a buffer for the image to be displayed on the screen, which is essential.
Pixtel_ui_blt_double_buffer (, UI_device_width-1, UI_device_height-1 );
There are many ways to draw images,
For details, see the decryption MTK document/MMI design DOC/pixtel_ui_programmers_manual.pdf
3 Touch Screen
1. Compile the handle function when the touch pen is pressed, which contains the user's required response. For example, when we press the touch pen, set the variable touch_pressed to true, and the POs records the coordinates of the touch pen on the screen.
Void mmi_pen_down_hdlr (mmi_pen_point_struct POS)
{
Touch_pressed = true;
}
2 call the system function mmi_wgui_register_pen_down_handler (mmi_pen_hdlr pen_down_hdlr)
Register the handle function of the previous touch pen:
Mmi_wgui_register_pen_down_handler (mmi_pen_down_hdlr)
Then, the touch pen will take effect. When we click the touch pen, touch_pressed is true.
3. The same applies to the release of touch pens. You also need to set the released function mmi_pen_up_hdlr and then call
Mmi_wgui_register_pen_up_handler (mmi_pen_up_hdlr) registers the previous release function.
Among the two system functions, mmi_pen_hdlr is the function pointer. Function pointers can be used to implement a common function to implement various specialized functions.
Typedef void (* mmi_pen_hdlr) (mmi_pen_point_struct POS );
4. Buttons
Similar to a touch pen operation, you must first compile a key function to implement the desired functions. For example
Void key_2_press (void)
{
Key 2 press the flag = true;
}
Then call the system function
Setkeyhandler (key_2_press, key_2, key_event_down); registers the function and binds the event type of key 2 to the function.
After the above work, the key 2 can work in the MTK.
5 about categoryscreen ()
There are various types of Screen Display in MTK. They have the same structure. The difference lies in whether the titles, buttons, and some controls on the screen are the same.
Showcategoryxscreen (argument list)
This function is often used by applications. The parameter list specifies the left soft key and right soft key on the screen, and the title display. You can also specify some special elements, such as text input boxes and list items.
The following functions are used as an example:
Void showcategory221screen (2010title,
2010title_icon,
2010left_softkey,
2010left_softkey_icon,
2010right_softkey,
2010right_softkey_icon,
Gdi_color background_color,
Funcptr redraw_content_callback)
Title indicates the name of the title bar on the screen.
Title_icon the icon used in the title bar
String ID of the Left soft key of left_softkey
ID of the Left soft key of the left_softkey_icon
Right_softkey string ID of the Right soft key
Right_softkey_icon ID of the Right soft key
Background_color background color
Redraw_content_callback refers to the callback function pointer used for re-painting. It is generally called by the framework during topic update and generally set to 0.
6. About timer and loop
The MTK can also implement loops similar to those in j2s.
First, write a function for calling the specified delay time when it expires. For example
Cyclic_timer ();
Then call the pixtel_ui_start_timer (500, cyclic_timer) function );
It should be noted that we need to write pixtel_ui_start_timer (500, cyclic_timer); To cyclic_timer (), so that the function will call itself whenever 500 milliseconds expire, enter the function again to implement the loop. We can add condition judgment in it to realize the jump out of the loop and other work.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.