Skip to content

Commit

Permalink
[wiki] Update from Symbio: ok button size increase
Browse files Browse the repository at this point in the history
Enlarge the ok button when typing the parental control password.  It
will be good for 4 low-case characters.  It will also be good for 3
Chinese/Japanese characters.

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information
hxw committed Nov 30, 2010
1 parent e664c2e commit 0252051
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 10 deletions.
28 changes: 28 additions & 0 deletions wiki/glyph.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,31 @@ int render_string_right(const int font, int start_x,
guilib_clear_area(x, start_y, LCD_BUF_WIDTH_PIXELS - 1, start_y + GetFontLinespace(font));
return rc;
}

void render_string_centered(const int font, int start_x, int start_y, int max_width,
const unsigned char *string, int text_length, int inverted)
{
int x;
int width = 0;
long len = text_length;
const unsigned char *p = string;
int nCharBytes;
ucs4_t c;

while (len > 0)
{
width += get_UTF8_char_width(font, &p, &len, &nCharBytes);
}

if (width < max_width)
start_x += (max_width - width) / 2;

x = start_x;
const unsigned char *q = (const unsigned char *)string;
while (*q) {
c = UTF8_to_UCS4(&q);
x = draw_bmf_char(c,font-1,x,start_y, inverted, 1);
if(x<0)
return;
}
}
2 changes: 2 additions & 0 deletions wiki/glyph.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ int draw_glyphs_to_buf(const int font, int start_x, int start_y, const char *str
int render_string_and_clear(const int font, int start_x,
int start_y, const unsigned char *string, int text_length, int inverted,
int clear_start_x, int clear_start_y, int clear_end_x, int clear_end_y);
void render_string_centered(const int font, int start_x, int start_y, int max_width,
const unsigned char *string, int text_length, int inverted);
#endif /* GLYPH_H */

7 changes: 4 additions & 3 deletions wiki/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static struct keyboard_key phone_tw_123[] = {
KEY(198, 84, 233, 119, 198, 84, 233, 119, WL_KEY_NLS_STR),
};
static struct keyboard_key password_char[] = {
KEY(175, 81, 204, 105, 177, 83, 202, 103, "Y"),
KEY(175, 81, 228, 105, 177, 83, 226, 103, "Y"),

KEY( 0, 126, 23, 152, 3, 128, 21, 150, "q"),
KEY( 0, 153, 23, 180, 3, 156, 21, 178, "a"),
Expand Down Expand Up @@ -434,7 +434,7 @@ static struct keyboard_key password_char[] = {
KEY(216, 181, 239, 207, 218, 183, 236, 205, WL_KEY_SWITCH_KEYBOARD_STR),
};
static struct keyboard_key password_num[] = {
KEY(175, 81, 204, 105, 175, 81, 204, 105, "Y"),
KEY(175, 81, 228, 105, 177, 83, 226, 103, "Y"),

KEY( 0, 126, 23, 152, 3, 128, 21, 150, "1"),
KEY( 0, 153, 23, 180, 3, 156, 21, 178, "*"),
Expand Down Expand Up @@ -579,7 +579,8 @@ int keyboard_get_mode()

int nls_button_enabled()
{
return (get_search_string_len() == 0 && get_wiki_count() > 1);
return (get_search_string_len() == 0 && get_wiki_count() > 1 &&
kb_mode != KEYBOARD_PASSWORD_CHAR && kb_mode != KEYBOARD_PASSWORD_NUM);
}


Expand Down
14 changes: 7 additions & 7 deletions wiki/restricted.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ void enter_password_screen(const unsigned char *msg)
framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 21] = 0x07;

framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 22] = 0x80;
memset(&framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 23], 0, 2);
framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 25] = 0x1F;
memset(&framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 23], 0, 5);
framebuffer[82 * LCD_BUFFER_WIDTH / 8 + 28] = 0x1F;

for (i = 83; i <= 103; i++)
{
Expand All @@ -163,20 +163,20 @@ void enter_password_screen(const unsigned char *msg)
framebuffer[i * LCD_BUFFER_WIDTH / 8 + 21] = 0x03;

framebuffer[i * LCD_BUFFER_WIDTH / 8 + 22] = 0x00;
memset(&framebuffer[i * LCD_BUFFER_WIDTH / 8 + 23], 0, 2);
framebuffer[i * LCD_BUFFER_WIDTH / 8 + 25] = 0x0F;
memset(&framebuffer[i * LCD_BUFFER_WIDTH / 8 + 23], 0, 5);
framebuffer[i * LCD_BUFFER_WIDTH / 8 + 28] = 0x0F;
}

framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 4] = 0xFC;
memset(&framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 5], 0, 16);
framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 21] = 0x07;

framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 22] = 0x80;
memset(&framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 23], 0, 2);
framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 25] = 0x1F;
memset(&framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 23], 0, 5);
framebuffer[104 * LCD_BUFFER_WIDTH / 8 + 28] = 0x1F;

pText = get_nls_text("ok");
render_string(SUBTITLE_FONT_IDX, 180, 85, pText, ustrlen(pText), 0);
render_string_centered(SUBTITLE_FONT_IDX, 177, 85, 50, pText, ustrlen(pText), 0);
guilib_fb_unlock();
}

Expand Down

0 comments on commit 0252051

Please sign in to comment.