# Define rolling_text_len XXXX // The total length of the rolling subtitle. This can be a constant, which depends on the screen.
# Define rolling_text_x XXXX // The Position of the starting subtitle of the rolling subtitle, the position of the first word
Parameters:
Rolling_text_y: Y coordinate of the rolling subtitle
Rolling_text_ptr: Rolling subtitle content
Text_bg_x: X coordinate of the rolling subtitle background
Text_bg_y: Y coordinate of the rolling subtitle background
Text_bg_len: Specifies the background length of a rolling subtitle.
Text_bg_height: the height of the background of the rolling subtitle.
These are all variables and can be set as global variables. Because these variables change every time you change a line to display different subtitles.
Void draw_rolling_text (s32 rolling_text_y, 2010* rolling_text_ptr, s32 text_bg_x, s32 text_bg_y, s32 text_bg_len, s32 text_bg_height)
{
Int I = rolling_text_start_num;
Color white_color ={ 255,255,255,100 };
Int word_nums = 0;
Static int rolling_text_start_num = 0;
Int total_width = 0;
Char rolling_text_start_num_return_0 = false;
2010* show_text = NULL;
For (word_nums = 0; total_width <rolling_text_len; word_nums ++, I ++) // calculates the size of show_text.
{
If (0x0000 = rolling_text_ptr [I])
{
Rolling_text_start_num_return_0 = true;
Total_width = rolling_text_len;
}
Else
Total_width + = gui_get_character_width (rolling_text_ptr [I]);
}
Show_text = popo_sys_malloc (word_nums + 1) * sizeof (002 ));
I = 0;
While (I <word_nums) & (rolling_text_ptr [rolling_text_start_num]! = 0x0000 ))
Show_text [I ++] = rolling_text_ptr [rolling_text_start_num ++];
Show_text [I] = 0x0000;
If (true = rolling_text_start_num_return_0)
Rolling_text_start_num = 0;
Else
Rolling_text_start_num ++;
Gui_set_text_color (white_color );
Gui_lock_double_buffer ();
Gui_move_text_cursor (rolling_text_x, rolling_text_y );
Gui_set_font (& mmi_medium_font );
******************* ***/
Gui_fill_rectangle (rolling_text_x, text_bg_y,
Rolling_text_x + text_bg_len,
Text_bg_y + text_bg_height );
******************* ***/
Gui_print_text (show_text );
Gui_unlock_double_buffer ();
Gui_blt_double_buffer (rolling_text_x, text_bg_y,
Rolling_text_x + text_bg_len,
Text_bg_y + text_bg_height );
Popo_sys_free (show_text );
}
As long as you run this program in a timer, it will have a dynamic rolling effect.