diff options
author | Filippos Karapetis | 2009-03-25 17:51:22 +0000 |
---|---|---|
committer | Filippos Karapetis | 2009-03-25 17:51:22 +0000 |
commit | a3a7893f163bdff7845a23c5a4f29709eaffb4a0 (patch) | |
tree | f10c2ef028a141c3c4f691c4ab2e391b02fbb264 /engines/sci/gfx | |
parent | 4723f80fe26ba0d6f4b21a9583af35fbf24aff25 (diff) | |
download | scummvm-rg350-a3a7893f163bdff7845a23c5a4f29709eaffb4a0.tar.gz scummvm-rg350-a3a7893f163bdff7845a23c5a4f29709eaffb4a0.tar.bz2 scummvm-rg350-a3a7893f163bdff7845a23c5a4f29709eaffb4a0.zip |
Changed the font flag defines to an enumeration
svn-id: r39690
Diffstat (limited to 'engines/sci/gfx')
-rw-r--r-- | engines/sci/gfx/font.cpp | 4 | ||||
-rw-r--r-- | engines/sci/gfx/font.h | 16 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_gui.cpp | 38 | ||||
-rw-r--r-- | engines/sci/gfx/operations.cpp | 4 |
4 files changed, 28 insertions, 34 deletions
diff --git a/engines/sci/gfx/font.cpp b/engines/sci/gfx/font.cpp index becc354296..a562219932 100644 --- a/engines/sci/gfx/font.cpp +++ b/engines/sci/gfx/font.cpp @@ -82,7 +82,7 @@ text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width } } - if (((foo == '\n') || (foo == 0x0d)) && !(flags & GFXR_FONT_FLAG_NO_NEWLINES)) { + if (((foo == '\n') || (foo == 0x0d)) && !(flags & kFontNoNewlines)) { fragments[current_fragment-1].length = text - 1 - fragments[current_fragment-1].offset; if (*text) @@ -133,7 +133,7 @@ text_fragment_t *gfxr_font_calculate_size(gfx_bitmap_font_t *font, int max_width fragments = (text_fragment_t*)sci_realloc(fragments, sizeof(text_fragment_t *) * (fragments_nr <<= 1)); localmaxwidth = localmaxwidth - last_breakpoint; - if (!(flags & GFXR_FONT_FLAG_COUNT_WHITESPACE)) + if (!(flags & kFontCountWhitespace)) localmaxwidth -= last_break_width; last_breakpoint = localmaxwidth = 0; diff --git a/engines/sci/gfx/font.h b/engines/sci/gfx/font.h index 5e97e5bfa3..8bd5f6b33a 100644 --- a/engines/sci/gfx/font.h +++ b/engines/sci/gfx/font.h @@ -65,18 +65,14 @@ struct gfx_bitmap_font_t { /* gfx_bitmap_font_t: Bitmap font information */ /*******************/ /* SCI0, SCI01 and SCI1 all use the same font format. */ - -/* SQ3 uses a somewhat different scheme for calculating text sizes: it counts -** whitespace while calculating the text size. */ -#define GFXR_FONT_FLAG_COUNT_WHITESPACE (1<<0) -/* Don't give newline characters special semantics */ -#define GFXR_FONT_FLAG_NO_NEWLINES (1<<1) -/* Interpret CR LF sequences as a single newline, rather than two of them */ -#define GFXR_FONT_FLAG_EAT_TRAILING_LF (1<<2) - +enum fontFlags { + kFontCountWhitespace = 1 << 0, // In SQ3, whitespace is included in text size + kFontNoNewlines = 1 << 1, // Don't treat newline characters + kFontIgnoreLF = 1 << 2 // Interpret CR LF sequences as a single newline, rather than two +}; gfx_bitmap_font_t *gfxr_read_font(int id, byte *resource, int size); -/* Geneartes a bitmap font data structure from a resource +/* Generates a bitmap font data structure from a resource ** Parameters: (int) id: Resource ID of the resulting font ** (byte *) resource: Pointer to the resource data ** (int) size: Size of the resource block diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp index 7bdbb745fa..e0e57adcc5 100644 --- a/engines/sci/gfx/gfx_gui.cpp +++ b/engines/sci/gfx/gfx_gui.cpp @@ -96,7 +96,7 @@ void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, const Common:: if (!text.empty()) { gfxw_text_t *textw = gfxw_new_text(state, gfx_rect(0, 0, status_bar->bounds.width, status_bar->bounds.height), status_bar->font_nr, text.c_str(), ALIGN_LEFT, ALIGN_CENTER, - fg, fg, bg, GFXR_FONT_FLAG_NO_NEWLINES); + fg, fg, bg, kFontNoNewlines); list = make_titlebar_list(s, status_bar->bounds, status_bar); @@ -211,7 +211,7 @@ gfxw_port_t *sciw_new_window(EngineState *s, decorations->add((gfxw_container_t *)decorations, (gfxw_widget_t *) gfxw_new_text(state, title_rect, title_font, title, ALIGN_CENTER, ALIGN_CENTER, title_color, title_color, - title_bgcolor, GFXR_FONT_FLAG_NO_NEWLINES)); + title_bgcolor, kFontNoNewlines)); } if (!(flags & kWindowNoFrame)) { @@ -309,21 +309,19 @@ gfxw_list_t *sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, c zone.x = 0; zone.y = 0; - if (inverse) - list->add(GFXWC(list), GFXW(gfxw_new_box(NULL, gfx_rect(zone.x, zone.y, zone.width + 1, zone.height + 1), - port->color, port->color, GFX_BOX_SHADE_FLAT))); - if (!inverse) { list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.width - 1, zone.height), - text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); + text, font, ALIGN_CENTER, 0, inverse, kFontIgnoreLF, grayed_out); list->add(GFXWC(list), GFXW(gfxw_new_rect(zone, *frame_col, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); - } + } else { + list->add(GFXWC(list), GFXW(gfxw_new_box(NULL, gfx_rect(zone.x, zone.y, zone.width + 1, zone.height + 1), + port->color, port->color, GFX_BOX_SHADE_FLAT))); - if (inverse) list = _sciw_add_text_to_list(list, port, gfx_rect(zone.x + 1, zone.y + 2, zone.width - 1, zone.height), - text, font, ALIGN_CENTER, 0, inverse, GFXR_FONT_FLAG_EAT_TRAILING_LF, grayed_out); + text, font, ALIGN_CENTER, 0, inverse, kFontIgnoreLF, grayed_out); + } if (selected) list->add(GFXWC(list), @@ -364,7 +362,7 @@ gfxw_list_t *sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, cha if ((g_system->getMillis() % 1000) < 500) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, font, text, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + port->color, port->color, port->bgcolor, kFontNoNewlines); list->add(GFXWC(list), GFXW(text_handle)); } else { @@ -377,7 +375,7 @@ gfxw_list_t *sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, cha if (cursor > 0) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, font, textdup, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + port->color, port->color, port->bgcolor, kFontNoNewlines); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; @@ -387,14 +385,14 @@ gfxw_list_t *sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, cha textdup[0] = text[cursor]; textdup[1] = 0; text_handle = gfxw_new_text(port->visual->gfx_state, zone, font, textdup, ALIGN_LEFT, ALIGN_TOP, - port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES); + port->bgcolor, port->bgcolor, port->color, kFontNoNewlines); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; }; if (cursor + 1 < strlen(text)) { text_handle = gfxw_new_text(port->visual->gfx_state, zone, font, text + cursor + 1, ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES); + port->color, port->color, port->bgcolor, kFontNoNewlines); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; }; @@ -485,13 +483,13 @@ gfxw_list_t *sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.width - 2, font_height), font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, - port->color, port->color, port->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + port->color, port->color, port->bgcolor, kFontNoNewlines))); else { list->add(GFXWC(list), GFXW(gfxw_new_box(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.width - 1, font_height), port->color, port->color, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.width - 2, font_height), font_nr, entries_list[i], ALIGN_LEFT, ALIGN_TOP, - port->bgcolor, port->bgcolor, port->color, GFXR_FONT_FLAG_NO_NEWLINES))); + port->bgcolor, port->bgcolor, port->color, kFontNoNewlines))); } zone.y += font_height; @@ -544,11 +542,11 @@ void sciw_set_menubar(EngineState *s, gfxw_port_t *status_bar, Menubar *menubar, status_bar->color, status_bar->color, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), status_bar->font_nr, menu->_title.c_str(), ALIGN_CENTER, ALIGN_CENTER, - status_bar->bgcolor, status_bar->bgcolor, status_bar->color, GFXR_FONT_FLAG_NO_NEWLINES))); + status_bar->bgcolor, status_bar->bgcolor, status_bar->color, kFontNoNewlines))); } else list->add(GFXWC(list), GFXW(gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), status_bar->font_nr, menu->_title.c_str(), ALIGN_CENTER, ALIGN_CENTER, - status_bar->color, status_bar->color, status_bar->bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + status_bar->color, status_bar->color, status_bar->bgcolor, kFontNoNewlines))); offset += width; } @@ -609,12 +607,12 @@ gfxw_widget_t *_make_menu_entry(MenuItem *item, int offset, int width, gfxw_port list->add(GFXWC(list), GFXW(gfxw_new_box(port->visual->gfx_state, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, area, port->font_nr, item->_text.c_str(), ALIGN_LEFT, ALIGN_CENTER, - color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + color, xcolor, bgcolor, kFontNoNewlines))); if (!item->_keytext.empty()) { area.width -= MENU_BOX_RIGHT_PADDING; list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, area, port->font_nr, item->_keytext.c_str(), ALIGN_RIGHT, ALIGN_CENTER, - color, xcolor, bgcolor, GFXR_FONT_FLAG_NO_NEWLINES))); + color, xcolor, bgcolor, kFontNoNewlines))); } return GFXW(list); diff --git a/engines/sci/gfx/operations.cpp b/engines/sci/gfx/operations.cpp index 8932365dc5..9bcc951889 100644 --- a/engines/sci/gfx/operations.cpp +++ b/engines/sci/gfx/operations.cpp @@ -1943,7 +1943,7 @@ gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, i handle->lines = gfxr_font_calculate_size(font, maxwidth, handle->text, &(handle->width), &(handle->height), &(handle->lines_nr), NULL, NULL, ((state->options->workarounds & GFX_WORKAROUND_WHITESPACE_COUNT) ? - GFXR_FONT_FLAG_COUNT_WHITESPACE : 0) | flags); + kFontCountWhitespace : 0) | flags); if (!handle->lines) { free(handle->text); @@ -1952,7 +1952,7 @@ gfx_text_handle_t *gfxop_new_text(gfx_state_t *state, int font_nr, char *text, i return NULL; } - if (flags & GFXR_FONT_FLAG_NO_NEWLINES) { + if (flags & kFontNoNewlines) { handle->lines_nr = 1; handle->lines->length = strlen(text); } |