Skip to content

Commit

Permalink
[wiki-app] updated from Symbio
Browse files Browse the repository at this point in the history
to support the new file format

Signed-off-by: Christopher Hall <hsw@openmoko.com>
  • Loading branch information
hxw committed Mar 29, 2010
1 parent 38e7179 commit d0e2994
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 176 deletions.
4 changes: 3 additions & 1 deletion wiki-app/bmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@
#ifndef _BMF_H
#define _BMF_H

#define FONT_COUNT 5
#define FONT_COUNT 7

#define FONT_FILE_DEFAULT "text.bmf"
#define FONT_FILE_ITALIC "texti.bmf"
#define FONT_FILE_TITLE "title.bmf"
#define FONT_FILE_SUBTITLE "subtitle.bmf"
#define FONT_FILE_DEFAULT_ALL "textall.bmf"
#define FONT_FILE_TITLE_ALL "titleall.bmf"
#define FONT_FILE_SUBTITLE_ALL "subtlall.bmf"


#ifdef WIKIPCF
Expand Down
83 changes: 58 additions & 25 deletions wiki-app/lcd_buf_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,16 @@ void init_lcd_draw_buf()
pcfFonts[i].bPartialFont = 1;
pcfFonts[i].supplement_font = &pcfFonts[DEFAULT_ALL_FONT_IDX - 1];
}
else if (i == TITLE_FONT_IDX - 1)
{
pcfFonts[i].bPartialFont = 1;
pcfFonts[i].supplement_font = &pcfFonts[TITLE_ALL_FONT_IDX - 1];
}
else if (i == SUBTITLE_FONT_IDX - 1)
{
pcfFonts[i].bPartialFont = 1;
pcfFonts[i].supplement_font = &pcfFonts[SUBTITLE_ALL_FONT_IDX - 1];
}
else
{
pcfFonts[i].bPartialFont = 0;
Expand Down Expand Up @@ -283,6 +293,12 @@ char* FontFile(int idx) {
case SUBTITLE_FONT_IDX - 1:
return FONT_FILE_SUBTITLE;
break;
case TITLE_ALL_FONT_IDX - 1:
return FONT_FILE_TITLE_ALL;
break;
case SUBTITLE_ALL_FONT_IDX - 1:
return FONT_FILE_SUBTITLE_ALL;
break;
default:
return "";
break;
Expand Down Expand Up @@ -607,10 +623,6 @@ void buf_draw_UTF8_str(unsigned char **pUTF8)
buf_draw_char(u);
if(display_first_page==0 && lcd_draw_buf.current_y>LCD_HEIGHT_LINES)
{
if (restricted_article)
{
draw_restricted_mark(lcd_draw_buf.screen_buf);
}
display_first_page = 1;
lcd_draw_cur_y_pos = 0;
finger_move_speed = 0;
Expand Down Expand Up @@ -1658,37 +1670,47 @@ void scroll_article(void)
}
}

void draw_external_link(char *link_str)
void draw_icon(char *pStr)
{
char lang[3];
int i, j;
int str_width;
int i, j;

memcpy(lang, link_str, 2);
lang[2] = '\0';
str_width = get_external_str_pixel_width(lang, SUBTITLE_FONT_IDX);
str_width = get_external_str_pixel_width(pStr, SUBTITLE_FONT_IDX);
for (i = 0; i < LANGUAGE_LINK_HEIGHT; i++)
{
if (i == 1 || i == LANGUAGE_LINK_HEIGHT - 2)
{
for (j = lcd_draw_buf.current_x + LCD_LEFT_MARGIN + 2; j < lcd_draw_buf.current_x + LCD_LEFT_MARGIN + LANGUAGE_LINK_WIDTH - 3; j++)
for (j = lcd_draw_buf.current_x + LCD_LEFT_MARGIN + 2; j < lcd_draw_buf.current_x + LCD_LEFT_MARGIN + LANGUAGE_LINK_WIDTH - 2; j++)
{
lcd_set_pixel(lcd_draw_buf.screen_buf, j, lcd_draw_buf.current_y + i);
}
}
else if (2 <= i && i <= LANGUAGE_LINK_HEIGHT - 3)
else if (1 < i && i < LANGUAGE_LINK_HEIGHT - 2)
{
for (j = lcd_draw_buf.current_x + LCD_LEFT_MARGIN + 1; j < lcd_draw_buf.current_x + LCD_LEFT_MARGIN + LANGUAGE_LINK_WIDTH - 2; j++)
for (j = lcd_draw_buf.current_x + LCD_LEFT_MARGIN + 1; j < lcd_draw_buf.current_x + LCD_LEFT_MARGIN + LANGUAGE_LINK_WIDTH - 1; j++)
{
lcd_set_pixel(lcd_draw_buf.screen_buf, j, lcd_draw_buf.current_y + i);
}
}
}
buf_render_string(lcd_draw_buf.screen_buf, SUBTITLE_FONT_IDX, lcd_draw_buf.current_x + LCD_LEFT_MARGIN + (LANGUAGE_LINK_WIDTH - str_width) / 2 - 1,
lcd_draw_buf.current_y + 2, lang, 2, 1);
lcd_draw_buf.current_y + 1, pStr, strlen(pStr), 1);
lcd_draw_buf.current_x += LANGUAGE_LINK_WIDTH + LANGUAGE_LINK_WIDTH_GAP;
}

void draw_restricted_mark()
{
draw_icon(get_nls_text("r"));
}

void draw_external_link(char *link_str)
{
char *pLang;

pLang = get_lang_link_display_text(link_str);
draw_icon(pLang);
}

int duplicate_wiki_lang(char *link_str1, char *link_str2)
{
char *p;
Expand Down Expand Up @@ -1732,6 +1754,25 @@ void display_retrieved_article(long idx_article)
articleLink[0].article_id = PREVIOUS_ARTICLE_LINK;
article_link_count = 1;

if (restricted_article)
{
lcd_draw_buf.pPcfFont = &pcfFonts[DEFAULT_FONT_IDX - 1];
lcd_draw_buf.line_height = pcfFonts[DEFAULT_FONT_IDX - 1].Fmetrics.linespace;
lcd_draw_buf.current_x = 0;
lcd_draw_buf.current_y = LCD_TOP_MARGIN;
lcd_draw_buf.vertical_adjustment = 0;
lcd_draw_buf.align_adjustment = 0;
start_x = lcd_draw_buf.current_x;
start_y = lcd_draw_buf.current_y;
end_x = lcd_draw_buf.current_x + LANGUAGE_LINK_WIDTH - 1;
end_y = lcd_draw_buf.current_y + LANGUAGE_LINK_HEIGHT - 1;
draw_restricted_mark();
articleLink[article_link_count].start_xy = (unsigned long)(start_x | (start_y << 8));
articleLink[article_link_count].end_xy = (unsigned long)(end_x | (end_y << 8));
articleLink[article_link_count].article_id = RESTRICTED_MARK_LINK;
article_link_count++;
}

offset = sizeof(ARTICLE_HEADER) + sizeof(ARTICLE_LINK) * article_header.article_link_count;
// externalLink[] is for storing the pointer to the language link string.
// A corresponding artileLink (with the same index) will be used to store the start_xy and end_xy information.
Expand All @@ -1752,7 +1793,7 @@ void display_retrieved_article(long idx_article)
}
if (!bDuplicated)
{
if (article_link_count == 1) // first external link
if (article_link_count == 1) // first external link and no restricted article icon
{
lcd_draw_buf.pPcfFont = &pcfFonts[DEFAULT_FONT_IDX - 1];
lcd_draw_buf.line_height = pcfFonts[DEFAULT_FONT_IDX - 1].Fmetrics.linespace;
Expand All @@ -1761,7 +1802,7 @@ void display_retrieved_article(long idx_article)
lcd_draw_buf.vertical_adjustment = 0;
lcd_draw_buf.align_adjustment = 0;
}
if (lcd_draw_buf.current_x + LCD_LEFT_MARGIN + LANGUAGE_LINK_WIDTH + LANGUAGE_LINK_WIDTH_GAP >= LCD_BUF_WIDTH_PIXELS)
if (lcd_draw_buf.current_x + LCD_LEFT_MARGIN + 2 * LANGUAGE_LINK_WIDTH + 2 * LANGUAGE_LINK_WIDTH_GAP >= LCD_BUF_WIDTH_PIXELS)
{
lcd_draw_buf.current_x = 0;
lcd_draw_buf.current_y += LANGUAGE_LINK_HEIGHT + LANGUAGE_LINK_WIDTH_GAP;
Expand All @@ -1788,18 +1829,10 @@ void display_retrieved_article(long idx_article)
if (article_start_y_pos && !lcd_draw_init_y_pos)
lcd_draw_init_y_pos = article_start_y_pos;

offset = sizeof(ARTICLE_HEADER);
if (restricted_article)
{
articleLink[article_link_count].start_xy = (unsigned long)(211 | ((4 + article_start_y_pos) << 8));
articleLink[article_link_count].end_xy = (unsigned long)(230 | ((24 + article_start_y_pos) << 8));
articleLink[article_link_count].article_id = RESTRICTED_MARK_LINK;
article_link_count++;
}

if(article_header.article_link_count > MAX_ARTICLE_LINKS - article_link_count)
article_header.article_link_count = MAX_ARTICLE_LINKS - article_link_count;

offset = sizeof(ARTICLE_HEADER); // article links start immediately after the article header
for(i = 0; i < article_header.article_link_count && article_link_count < MAX_ARTICLE_LINKS; i++)
{
memcpy(&articleLink[article_link_count],file_buffer+offset,sizeof(ARTICLE_LINK));
Expand Down
23 changes: 13 additions & 10 deletions wiki-app/lcd_buf_draw.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,30 @@
#else
#define LCD_BUF_WIDTH_BYTES LCD_VRAM_WIDTH_PIXELS/8
#endif
#define LANGUAGE_LINK_WIDTH 26
#define LANGUAGE_LINK_HEIGHT 26
#define LANGUAGE_LINK_WIDTH 21
#define LANGUAGE_LINK_HEIGHT 21
#define LANGUAGE_LINK_WIDTH_GAP 6
#define LANGUAGE_LINK_HEIGHT_GAP 6

// The italic fonts may not define the bitmaps for all characters.
// The characters that are minssing in the italic fonts will try to return the bitmaps in the next font file.
// For example, return bitmaps in DEFAULT_FONT_IDX if not found in ITALIC_FONT_IDX.
// The characters that are minssing in the italic fonts will try to return the bitmaps of it's supplement_font file.
// The supplement_font file is assigned in init_lcd_draw_buf().
#define ITALIC_FONT_IDX 1
#define DEFAULT_FONT_IDX 2
#define TITLE_FONT_IDX 3
#define SUBTITLE_FONT_IDX 4
// The above are the primary fonts for the article body. The index of any one of them needs to be under 7.
#define DEFAULT_ALL_FONT_IDX 5
#define SEARCH_HEADING_FONT_IDX TITLE_FONT_IDX
#define SEARCH_LIST_FONT_IDX DEFAULT_FONT_IDX
#define DEFAULT_ALL_FONT_IDX 5
#define TITLE_ALL_FONT_IDX 6
#define SUBTITLE_ALL_FONT_IDX 7

#define SEARCH_HEADING_FONT_IDX TITLE_FONT_IDX
#define SEARCH_LIST_FONT_IDX DEFAULT_FONT_IDX
#define MESSAGE_FONT_IDX BOLD_FONT_IDX
#define H2_FONT_IDX SUBTITLE_FONT_IDX
#define H2_FONT_IDX SUBTITLE_FONT_IDX
#define H3_FONT_IDX SUBTITLE_FONT_IDX
#define H4_FONT_IDX SUBTITLE_FONT_IDX
#define H5_FONT_IDX SUBTITLE_FONT_IDX
#define H4_FONT_IDX SUBTITLE_FONT_IDX
#define H5_FONT_IDX SUBTITLE_FONT_IDX
#define LICENSE_TEXT_FONT ITALIC_FONT_IDX
#define FILE_BUFFER_SIZE (512 * 1024)

Expand Down
40 changes: 0 additions & 40 deletions wiki-app/restricted.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,43 +651,3 @@ int get_password_string_len(void)
{
return password_str_len;
}

void draw_restricted_mark(char *screen_buf)
{
int x, y;
ucs4_t u;
unsigned char *pText;
unsigned char **pUTF8;

for (y = 0; y < 25; y++)
{
for (x = 27; x < 30; x++)
{
if (y < 5 || y == 24)
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0;
else if (y == 5 || y == 23)
{
if (x == 27)
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0x3F;
else if (x == 28)
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0xFF;
else
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0xE0;
}
else
{
if (x == 27)
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0x7F;
else if (x == 28)
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0xFF;
else
screen_buf[y * LCD_VRAM_WIDTH_PIXELS / 8 + x] = 0xF0;
}
}
}

pText = get_nls_text("r");
pUTF8 = &pText;
u = UTF8_to_UCS4(pUTF8);
buf_draw_bmf_char(screen_buf, u, SUBTITLE_FONT_IDX - 1, 221, 6, 1);
}
1 change: 0 additions & 1 deletion wiki-app/restricted.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ int password_remove_char(void);
int clear_password_string(void);
int get_password_string_len(void);
void handle_password_key(char keycode);
void draw_restricted_mark(char *screen_buf);
void filter_option(void);
int init_article_filter(void);

Expand Down
Loading

0 comments on commit d0e2994

Please sign in to comment.