summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2006-09-30 13:14:48 (GMT)
committer James Bursa <james@netsurf-browser.org>2006-09-30 13:14:48 (GMT)
commit32f9aa05fc3112735a664ffc91398ea4cd6d9f2c (patch)
tree0610a6bfdd26d953512eb60e0472527bedc65625
parent406f2c0a523141829e14b98068e3905e6f89c3ac (diff)
downloadlibrufl-32f9aa05fc3112735a664ffc91398ea4cd6d9f2c.tar.gz
librufl-32f9aa05fc3112735a664ffc91398ea4cd6d9f2c.tar.bz2
Add built-in font family menu.
svn path=/trunk/rufl/; revision=2970
-rw-r--r--rufl.h3
-rw-r--r--rufl_init.c52
-rw-r--r--rufl_quit.c3
3 files changed, 58 insertions, 0 deletions
diff --git a/rufl.h b/rufl.h
index 1e541aa..1b853d7 100644
--- a/rufl.h
+++ b/rufl.h
@@ -55,6 +55,9 @@ extern char **rufl_family_list;
/** Number of entries in rufl_family_list. */
extern unsigned int rufl_family_list_entries;
+/** Menu of font families. */
+extern void *rufl_family_menu;
+
/* Callbacks used by rufl_decompose_glyph */
typedef int (*rufl_move_to_func)(os_coord *to, void *user);
typedef int (*rufl_line_to_func)(os_coord *to, void *user);
diff --git a/rufl_init.c b/rufl_init.c
index bb39264..910c47a 100644
--- a/rufl_init.c
+++ b/rufl_init.c
@@ -30,6 +30,7 @@ char **rufl_family_list = 0;
unsigned int rufl_family_list_entries = 0;
struct rufl_family_map_entry *rufl_family_map = 0;
os_error *rufl_fm_error = 0;
+void *rufl_family_menu = 0;
unsigned short *rufl_substitution_table;
struct rufl_cache_entry rufl_cache[rufl_CACHE_SIZE];
int rufl_cache_time = 0;
@@ -82,6 +83,7 @@ static rufl_code rufl_init_substitution_table(void);
static rufl_code rufl_save_cache(void);
static rufl_code rufl_load_cache(void);
static int rufl_font_list_cmp(const void *keyval, const void *datum);
+static rufl_code rufl_init_family_menu(void);
static void rufl_init_status_open(void);
static void rufl_init_status(const char *status, float progress);
static void rufl_init_status_close(void);
@@ -200,6 +202,14 @@ rufl_code rufl_init(void)
for (i = 0; i != rufl_CACHE_SIZE; i++)
rufl_cache[i].font = rufl_CACHE_NONE;
+ code = rufl_init_family_menu();
+ if (code != rufl_OK) {
+ LOG("rufl_init_substitution_table: 0x%x", code);
+ rufl_quit();
+ xhourglass_off();
+ return code;
+ }
+
rufl_init_status_close();
xhourglass_off();
@@ -1045,6 +1055,48 @@ int rufl_font_list_cmp(const void *keyval, const void *datum)
/**
+ * Create a menu of font families.
+ */
+
+rufl_code rufl_init_family_menu(void)
+{
+ wimp_menu *menu;
+ unsigned int i;
+
+ menu = malloc(wimp_SIZEOF_MENU(rufl_family_list_entries));
+ if (!menu)
+ return rufl_OUT_OF_MEMORY;
+ menu->title_data.indirected_text.text = "Fonts";
+ menu->title_fg = wimp_COLOUR_BLACK;
+ menu->title_bg = wimp_COLOUR_LIGHT_GREY;
+ menu->work_fg = wimp_COLOUR_BLACK;
+ menu->work_bg = wimp_COLOUR_WHITE;
+ menu->width = 200;
+ menu->height = wimp_MENU_ITEM_HEIGHT;
+ menu->gap = wimp_MENU_ITEM_GAP;
+ for (i = 0; i != rufl_family_list_entries; i++) {
+ menu->entries[i].menu_flags = 0;
+ menu->entries[i].sub_menu = wimp_NO_SUB_MENU;
+ menu->entries[i].icon_flags = wimp_ICON_TEXT |
+ wimp_ICON_INDIRECTED |
+ (wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
+ (wimp_COLOUR_WHITE << wimp_ICON_BG_COLOUR_SHIFT);
+ menu->entries[i].data.indirected_text.text =
+ rufl_family_list[i];
+ menu->entries[i].data.indirected_text.validation = (char *) -1;
+ menu->entries[i].data.indirected_text.size =
+ strlen(rufl_family_list[i]);
+ }
+ menu->entries[0].menu_flags = wimp_MENU_TITLE_INDIRECTED;
+ menu->entries[i - 1].menu_flags |= wimp_MENU_LAST;
+
+ rufl_family_menu = menu;
+
+ return rufl_OK;
+}
+
+
+/**
* Create and open the init status window.
*/
diff --git a/rufl_quit.c b/rufl_quit.c
index e15a80b..c74bddc 100644
--- a/rufl_quit.c
+++ b/rufl_quit.c
@@ -40,4 +40,7 @@ void rufl_quit(void)
rufl_cache[i].font = rufl_CACHE_NONE;
}
}
+
+ free(rufl_family_menu);
+ rufl_family_menu = 0;
}