quiet the masses...
[Rockbox.git] / apps / gui / textarea.c
blobb30667df4e8b582e6f92421bfdc75c946e5406b9
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2005 by Kevin Ferrare
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "textarea.h"
21 #include "font.h"
22 #include "lang.h"
23 #include "talk.h"
25 void gui_textarea_clear(struct screen * display)
27 #ifdef HAVE_LCD_BITMAP
28 int y_start = gui_textarea_get_ystart(display);
29 int y_end = gui_textarea_get_yend(display);
30 screen_clear_area(display, 0, y_start, display->width, y_end - y_start);
31 display->stop_scroll();
32 screen_set_ymargin(display, y_start);
33 #else
34 display->clear_display();
35 #endif
38 void gui_textarea_update(struct screen * display)
40 #ifdef HAVE_LCD_BITMAP
41 int y_start = gui_textarea_get_ystart(display);
42 int y_end = gui_textarea_get_yend(display);
43 display->update_rect(0, y_start, display->width, y_end - y_start);
44 #else
45 display->update();
46 #endif
49 int gui_textarea_put_message(struct screen * display,
50 struct text_message * message,
51 int ystart)
53 int i;
54 gui_textarea_clear(display);
55 for(i=0;i<message->nb_lines && i+ystart<display->nb_lines;i++)
56 display->puts_scroll(0, i+ystart, P2STR((unsigned char *)message->
57 message_lines[i]));
58 gui_textarea_update(display);
59 return(i);
62 void gui_textarea_update_nblines(struct screen * display)
64 int height=display->height;
65 #ifdef HAVE_LCD_BITMAP
66 if(global_settings.statusbar)
67 height -= STATUSBAR_HEIGHT;
68 #ifdef HAS_BUTTONBAR
69 if(global_settings.buttonbar && display->has_buttonbar)
70 height -= BUTTONBAR_HEIGHT;
71 #endif
72 display->getstringsize((unsigned char *)"A", &display->char_width,
73 &display->char_height);
74 #else
75 display->char_width = 1;
76 display->char_height = 1;
77 #endif
78 display->nb_lines = height / display->char_height;
81 void talk_text_message(struct text_message * message, bool enqueue)
83 int line;
84 if(message)
85 for(line=0; line<message->nb_lines; line++)
87 long id = P2ID((unsigned char *)message->message_lines[line]);
88 if(id>=0)
90 talk_id(id, enqueue);
91 enqueue = true;