diff options
author | Max Horn | 2009-04-24 10:45:09 +0000 |
---|---|---|
committer | Max Horn | 2009-04-24 10:45:09 +0000 |
commit | 86b36574767f0ab43e9e1f25dbe611ab7b35bf78 (patch) | |
tree | 8fe38eec523e56b788e83766d267b2fb37457f78 | |
parent | 6fef323ec7bd028107118a01030844e019372dd3 (diff) | |
download | scummvm-rg350-86b36574767f0ab43e9e1f25dbe611ab7b35bf78.tar.gz scummvm-rg350-86b36574767f0ab43e9e1f25dbe611ab7b35bf78.tar.bz2 scummvm-rg350-86b36574767f0ab43e9e1f25dbe611ab7b35bf78.zip |
SCI: Started to C++ify the gfxw_widget_t codebase
svn-id: r40103
-rw-r--r-- | engines/sci/engine/game.cpp | 16 | ||||
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 186 | ||||
-rw-r--r-- | engines/sci/engine/kmenu.cpp | 8 | ||||
-rw-r--r-- | engines/sci/engine/kpathing.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 6 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 2 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_gui.cpp | 150 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_state_internal.h | 106 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.cpp | 810 | ||||
-rw-r--r-- | engines/sci/gfx/gfx_widgets.h | 4 | ||||
-rw-r--r-- | engines/sci/gfx/menubar.cpp | 2 |
12 files changed, 660 insertions, 638 deletions
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp index b19db3475f..046d089d1a 100644 --- a/engines/sci/engine/game.cpp +++ b/engines/sci/engine/game.cpp @@ -149,7 +149,7 @@ int _reset_graphics_input(EngineState *s) { s->wm_port = gfxw_new_port(s->visual, NULL, s->gfx_state->pic_port_bounds, s->ega_colors[0], transparent); s->iconbar_port = gfxw_new_port(s->visual, NULL, gfx_rect(0, 0, 320, 200), s->ega_colors[0], transparent); - s->iconbar_port->flags |= GFXW_FLAG_NO_IMPLICIT_SWITCH; + s->iconbar_port->_flags |= GFXW_FLAG_NO_IMPLICIT_SWITCH; if (s->resmgr->_sciVersion >= SCI_VERSION_01_VGA) { // This bit sets the foreground and background colors in VGA SCI games @@ -168,11 +168,11 @@ int _reset_graphics_input(EngineState *s) { } else { s->titlebar_port = gfxw_new_port(s->visual, NULL, gfx_rect(0, 0, 320, 10), s->ega_colors[0], s->ega_colors[15]); } - s->titlebar_port->color.mask |= GFX_MASK_PRIORITY; - s->titlebar_port->color.priority = 11; - s->titlebar_port->bgcolor.mask |= GFX_MASK_PRIORITY; - s->titlebar_port->bgcolor.priority = 11; - s->titlebar_port->flags |= GFXW_FLAG_NO_IMPLICIT_SWITCH; + s->titlebar_port->_color.mask |= GFX_MASK_PRIORITY; + s->titlebar_port->_color.priority = 11; + s->titlebar_port->_bgcolor.mask |= GFX_MASK_PRIORITY; + s->titlebar_port->_bgcolor.priority = 11; + s->titlebar_port->_flags |= GFXW_FLAG_NO_IMPLICIT_SWITCH; // but this is correct s->picture_port = gfxw_new_port(s->visual, NULL, s->gfx_state->pic_port_bounds, s->ega_colors[0], transparent); @@ -188,8 +188,8 @@ int _reset_graphics_input(EngineState *s) { s->port = s->picture_port; // Currently using the picture port #if 0 - s->titlebar_port->bgcolor.mask |= GFX_MASK_PRIORITY; - s->titlebar_port->bgcolor.priority = 11; // Standard priority for the titlebar port + s->titlebar_port->_bgcolor.mask |= GFX_MASK_PRIORITY; + s->titlebar_port->_bgcolor.priority = 11; // Standard priority for the titlebar port #endif return 0; diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index c949f3ce92..132bead6d1 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -121,18 +121,18 @@ static inline int sign_extend_byte(int value) { static void assert_primary_widget_lists(EngineState *s) { if (!s->dyn_views) { - rect_t bounds = s->picture_port->bounds; + rect_t bounds = s->picture_port->_bounds; s->dyn_views = gfxw_new_list(bounds, GFXW_LIST_SORTED); - s->dyn_views->flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; + s->dyn_views->_flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; ADD_TO_CURRENT_PICTURE_PORT(s->dyn_views); } if (!s->drop_views) { - rect_t bounds = s->picture_port->bounds; + rect_t bounds = s->picture_port->_bounds; s->drop_views = gfxw_new_list(bounds, GFXW_LIST_SORTED); - s->drop_views->flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; + s->drop_views->_flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; ADD_TO_CURRENT_PICTURE_PORT(s->drop_views); } } @@ -142,7 +142,7 @@ static void reparentize_primary_widget_lists(EngineState *s, gfxw_port_t *newpor newport = s->picture_port; if (s->dyn_views) { - gfxw_remove_widget_from_container(s->dyn_views->parent, GFXW(s->dyn_views)); + gfxw_remove_widget_from_container(s->dyn_views->_parent, GFXW(s->dyn_views)); newport->add(GFXWC(newport), GFXW(s->dyn_views)); } @@ -208,7 +208,7 @@ reg_t graph_save_box(EngineState *s, rect_t area) { void graph_restore_box(EngineState *s, reg_t handle) { gfxw_snapshot_t **ptr; - int port_nr = s->port->ID; + int port_nr = s->port->_ID; if (!handle.segment) { warning("Attempt to restore box with zero handle"); @@ -222,20 +222,20 @@ void graph_restore_box(EngineState *s, reg_t handle) { return; } - while (port_nr > 2 && !(s->port->flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) && (gfxw_widget_matches_snapshot(*ptr, GFXW(s->port)))) { + while (port_nr > 2 && !(s->port->_flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) && (gfxw_widget_matches_snapshot(*ptr, GFXW(s->port)))) { // This shouldn't ever happen, actually, since windows (ports w/ ID > 2) should all be immune gfxw_port_t *newport = gfxw_find_port(s->visual, port_nr); - SCIkwarn(SCIkERROR, "Port %d is not immune against snapshots!\n", s->port->ID); + SCIkwarn(SCIkERROR, "Port %d is not immune against snapshots!\n", s->port->_ID); port_nr--; if (newport) s->port = newport; } - if (s->dyn_views && gfxw_widget_matches_snapshot(*ptr, GFXW(s->dyn_views->parent))) { - gfxw_container_t *parent = s->dyn_views->parent; + if (s->dyn_views && gfxw_widget_matches_snapshot(*ptr, GFXW(s->dyn_views->_parent))) { + gfxw_container_t *parent = s->dyn_views->_parent; do { - parent = parent->parent; + parent = parent->_parent; } while (parent && (gfxw_widget_matches_snapshot(*ptr, GFXW(parent)))); if (!parent) { @@ -353,7 +353,7 @@ reg_t kSetCursor(EngineState *s, int funct_nr, int argc, reg_t *argv) { GFX_ASSERT(gfxop_set_pointer_cursor(s->gfx_state, s->mouse_pointer_view)); if (argc > 2) { - Common::Point newpos = Common::Point(SKPV(2) + s->port->bounds.x, SKPV(3) + s->port->bounds.y); + Common::Point newpos = Common::Point(SKPV(2) + s->port->_bounds.x, SKPV(3) + s->port->_bounds.y); GFX_ASSERT(gfxop_set_pointer_position(s->gfx_state, newpos)); } @@ -457,21 +457,21 @@ void _k_graph_rebuild_port_with_color(EngineState *s, gfx_color_t newbgcolor) { gfxw_port_t *port = s->port; gfxw_port_t *newport; - newport = sciw_new_window(s, port->zone, port->font_nr, port->color, newbgcolor, + newport = sciw_new_window(s, port->zone, port->font_nr, port->_color, newbgcolor, s->titlebar_port->font_nr, s->ega_colors[15], s->ega_colors[8], port->title_text, port->port_flags & ~kWindowTransparent); if (s->dyn_views) { int found = 0; - gfxw_container_t *parent = s->dyn_views->parent; + gfxw_container_t *parent = s->dyn_views->_parent; while (parent && !(found |= (GFXW(parent) == GFXW(port)))) - parent = parent->parent; + parent = parent->_parent; s->dyn_views = NULL; } - port->parent->add(GFXWC(port->parent), GFXW(newport)); + port->_parent->add(GFXWC(port->_parent), GFXW(newport)); port->widfree(GFXW(port)); } @@ -532,7 +532,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) { case K_GRAPH_FILL_BOX_BACKGROUND: - _k_graph_rebuild_port_with_color(s, port->bgcolor); + _k_graph_rebuild_port_with_color(s, port->_bgcolor); port = s->port; redraw_port = 1; @@ -540,7 +540,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) { case K_GRAPH_FILL_BOX_FOREGROUND: - _k_graph_rebuild_port_with_color(s, port->color); + _k_graph_rebuild_port_with_color(s, port->_color); port = s->port; redraw_port = 1; @@ -582,7 +582,7 @@ reg_t kGraph(EngineState *s, int funct_nr, int argc, reg_t *argv) { area.x += s->port->zone.x; area.y += s->port->zone.y; - if (s->dyn_views && s->dyn_views->parent == GFXWC(s->port)) + if (s->dyn_views && s->dyn_views->_parent == GFXWC(s->port)) s->dyn_views->draw(GFXW(s->dyn_views), Common::Point(0, 0)); gfxop_update_box(s->gfx_state, area); @@ -811,13 +811,13 @@ reg_t kCanBeHere(EngineState *s, int funct_nr, int argc, reg_t * argv) { SCIkdebug(SCIkBRESEN, "Checking vs dynviews:\n"); while (widget) { - if (widget->ID && (widget->signal & _K_VIEW_SIG_FLAG_STOPUPD) - && ((widget->ID != obj.segment) || (widget->subID != obj.offset)) - && is_object(s, make_reg(widget->ID, widget->subID))) - if (collides_with(s, abs_zone, make_reg(widget->ID, widget->subID), 1, GASEOUS_VIEW_MASK_ACTIVE, funct_nr, argc, argv)) + if (widget->_ID && (widget->signal & _K_VIEW_SIG_FLAG_STOPUPD) + && ((widget->_ID != obj.segment) || (widget->_subID != obj.offset)) + && is_object(s, make_reg(widget->_ID, widget->_subID))) + if (collides_with(s, abs_zone, make_reg(widget->_ID, widget->_subID), 1, GASEOUS_VIEW_MASK_ACTIVE, funct_nr, argc, argv)) return not_register(s, NULL_REG); - widget = (gfxw_dyn_view_t *) widget->next; + widget = (gfxw_dyn_view_t *) widget->_next; } } @@ -987,7 +987,7 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) { int pic_nr = SKPV(0); int add_to_pic = 1; int palette = SKPV_OR_ALT(3, 0); - gfx_color_t transparent = s->wm_port->bgcolor; + gfx_color_t transparent = s->wm_port->_bgcolor; CHECK_THIS_KERNEL_FUNCTION; @@ -1037,7 +1037,7 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) { s->picture_port = gfxw_new_port(s->visual, NULL, s->gfx_state->pic_port_bounds, s->ega_colors[0], transparent); s->iconbar_port = gfxw_new_port(s->visual, NULL, gfx_rect(0, 0, 320, 200), s->ega_colors[0], transparent); - s->iconbar_port->flags |= GFXW_FLAG_NO_IMPLICIT_SWITCH; + s->iconbar_port->_flags |= GFXW_FLAG_NO_IMPLICIT_SWITCH; s->visual->add(GFXWC(s->visual), GFXW(s->picture_port)); s->visual->add(GFXWC(s->visual), GFXW(s->wm_port)); @@ -1716,13 +1716,13 @@ static void draw_rect_to_control_map(EngineState *s, Common::Rect abs_zone) { } static void draw_obj_to_control_map(EngineState *s, gfxw_dyn_view_t *view) { - reg_t obj = make_reg(view->ID, view->subID); + reg_t obj = make_reg(view->_ID, view->_subID); if (!is_object(s, obj)) - warning("View %d does not contain valid object reference "PREG"", view->ID, PRINT_REG(obj)); + warning("View %d does not contain valid object reference "PREG"", view->_ID, PRINT_REG(obj)); if (!(view->signalp && (((reg_t *)view->signalp)->offset & _K_VIEW_SIG_FLAG_IGNORE_ACTOR))) { - Common::Rect abs_zone = get_nsrect(s, make_reg(view->ID, view->subID), 1); + Common::Rect abs_zone = get_nsrect(s, make_reg(view->_ID, view->_subID), 1); draw_rect_to_control_map(s, abs_zone); } } @@ -1731,7 +1731,7 @@ static void _k_view_list_do_postdraw(EngineState *s, gfxw_list_t *list) { gfxw_dyn_view_t *widget = (gfxw_dyn_view_t *) list->contents; while (widget) { - reg_t obj = make_reg(widget->ID, widget->subID); + reg_t obj = make_reg(widget->_ID, widget->_subID); /* * this fixes a few problems, but doesn't match SSCI's logic. @@ -1776,7 +1776,7 @@ static void _k_view_list_do_postdraw(EngineState *s, gfxw_list_t *list) { *((reg_t *)(widget->signalp)) = make_reg(0, widget->signal & 0xffff); /* Write back signal */ } - widget = (gfxw_dyn_view_t *) widget->next; + widget = (gfxw_dyn_view_t *) widget->_next; } } @@ -1786,12 +1786,12 @@ void _k_view_list_mark_free(EngineState *s, reg_t off) { gfxw_dyn_view_t *w = (gfxw_dyn_view_t *) s->dyn_views->contents; while (w) { - if (w->ID == off.segment - && w->subID == off.offset) { + if (w->_ID == off.segment + && w->_subID == off.offset) { w->under_bitsp = NULL; } - w = (gfxw_dyn_view_t *) w->next; + w = (gfxw_dyn_view_t *) w->_next; } } } @@ -1809,15 +1809,15 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, gfxw_dyn_view_t *widge if (widget) { int retval; // Recurse: - retval = _k_view_list_dispose_loop(s, list, (gfxw_dyn_view_t *) widget->next, funct_nr, argc, argv); + retval = _k_view_list_dispose_loop(s, list, (gfxw_dyn_view_t *) widget->_next, funct_nr, argc, argv); if (retval == -1) // Bail out on annihilation, rely on re-start from Animate() return -1; - if (GFXW_IS_DYN_VIEW(widget) && (widget->ID != GFXW_NO_ID)) { + if (GFXW_IS_DYN_VIEW(widget) && (widget->_ID != GFXW_NO_ID)) { signal = ((reg_t *)widget->signalp)->offset; if (signal & _K_VIEW_SIG_FLAG_DISPOSE_ME) { - reg_t obj = make_reg(widget->ID, widget->subID); + reg_t obj = make_reg(widget->_ID, widget->_subID); reg_t under_bits = NULL_REG; if (!is_object(s, obj)) { @@ -1857,20 +1857,20 @@ int _k_view_list_dispose_loop(EngineState *s, List *list, gfxw_dyn_view_t *widge if (!(signal & _K_VIEW_SIG_FLAG_HIDDEN)) { SCIkdebug(SCIkGRAPHICS, "Adding view at "PREG" to background\n", PRINT_REG(obj)); - if (!(gfxw_remove_id(widget->parent, widget->ID, widget->subID) == GFXW(widget))) { - SCIkwarn(SCIkERROR, "Attempt to remove view with ID %x:%x from list failed!\n", widget->ID, widget->subID); + if (!(gfxw_remove_id(widget->_parent, widget->_ID, widget->_subID) == GFXW(widget))) { + SCIkwarn(SCIkERROR, "Attempt to remove view with ID %x:%x from list failed!\n", widget->_ID, widget->_subID); BREAKPOINT(); } s->drop_views->add(GFXWC(s->drop_views), GFXW(gfxw_picviewize_dynview(widget))); draw_obj_to_control_map(s, widget); - widget->draw_bounds.y += s->dyn_views->bounds.y - widget->parent->bounds.y; - widget->draw_bounds.x += s->dyn_views->bounds.x - widget->parent->bounds.x; + widget->draw_bounds.y += s->dyn_views->_bounds.y - widget->_parent->_bounds.y; + widget->draw_bounds.x += s->dyn_views->_bounds.x - widget->_parent->_bounds.x; dropped = 1; } else { SCIkdebug(SCIkGRAPHICS, "Deleting view at "PREG"\n", PRINT_REG(obj)); - widget->flags |= GFXW_FLAG_VISIBLE; + widget->_flags |= GFXW_FLAG_VISIBLE; gfxw_annihilate(GFXW(widget)); return -1; // restart: Done in Animate() } @@ -1957,7 +1957,7 @@ static gfxw_dyn_view_t *_k_make_dynview_obj(EngineState *s, reg_t obj, int optio if (widget) { widget = (gfxw_dyn_view_t *) gfxw_set_id(GFXW(widget), obj.segment, obj.offset); widget = gfxw_dyn_view_set_params(widget, under_bits.segment, under_bitsp, signal, signalp); - widget->flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; // Only works the first time 'round' + widget->_flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; // Only works the first time 'round' return widget; } else { @@ -2023,20 +2023,20 @@ static void _k_make_view_list(EngineState *s, gfxw_list_t **widget_list, List *l if (widget->signalp) widget->signal = ((reg_t *)(widget->signalp))->offset; - widget = (gfxw_dyn_view_t *) widget->next; + widget = (gfxw_dyn_view_t *) widget->_next; } } static void _k_prepare_view_list(EngineState *s, gfxw_list_t *list, int options) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) list->contents; while (view) { - reg_t obj = make_reg(view->ID, view->subID); + reg_t obj = make_reg(view->_ID, view->_subID); int priority, _priority; - int has_nsrect = (view->ID <= 0) ? 0 : lookup_selector(s, obj, s->selector_map.nsBottom, NULL, NULL) == kSelectorVariable; + int has_nsrect = (view->_ID <= 0) ? 0 : lookup_selector(s, obj, s->selector_map.nsBottom, NULL, NULL) == kSelectorVariable; int oldsignal = view->signal; _k_set_now_seen(s, obj); - _priority = /*GET_SELECTOR(obj, y); */((view->pos.y)); + _priority = /*GET_SELECTOR(obj, y); */((view->_pos.y)); _priority = _find_view_priority(s, _priority - 1); if (options & _K_MAKE_VIEW_LIST_DRAW_TO_CONTROL_MAP) { // Picview @@ -2054,12 +2054,12 @@ static void _k_prepare_view_list(EngineState *s, gfxw_list_t *list, int options) priority = GET_SEL32SV(obj, priority); } - view->color.priority = priority; + view->_color.priority = priority; if (priority > -1) - view->color.mask |= GFX_MASK_PRIORITY; + view->_color.mask |= GFX_MASK_PRIORITY; else - view->color.mask &= ~GFX_MASK_PRIORITY; + view->_color.mask &= ~GFX_MASK_PRIORITY; // CR (from :Bob Heitman:) stopupdated views (like pic views) have // their clipped nsRect drawn to the control map @@ -2107,7 +2107,7 @@ static void _k_prepare_view_list(EngineState *s, gfxw_list_t *list, int options) fprintf(stderr, "Unsetting magic StopUpd for view "PREG"\n", PRINT_REG(obj)); } */ - view = (gfxw_dyn_view_t *) view->next; + view = (gfxw_dyn_view_t *) view->_next; } } @@ -2125,16 +2125,16 @@ static void _k_update_signals_in_view_list(gfxw_list_t *old_list, gfxw_list_t *n gfxw_dyn_view_t *new_widget = (gfxw_dyn_view_t *) new_list->contents; while (new_widget - && (new_widget->ID != old_widget->ID - || new_widget->subID != old_widget->subID)) - new_widget = (gfxw_dyn_view_t *) new_widget->next; + && (new_widget->_ID != old_widget->_ID + || new_widget->_subID != old_widget->_subID)) + new_widget = (gfxw_dyn_view_t *) new_widget->_next; if (new_widget) { int carry = old_widget->signal & _K_VIEW_SIG_FLAG_STOPUPD; // Transfer 'stopupd' flag - if ((new_widget->pos.x != old_widget->pos.x) - || (new_widget->pos.y != old_widget->pos.y) + if ((new_widget->_pos.x != old_widget->_pos.x) + || (new_widget->_pos.y != old_widget->_pos.y) // No idea why this is supposed to be bad /* || (new_widget->z != old_widget->z) || (new_widget->view != old_widget->view) @@ -2146,24 +2146,24 @@ static void _k_update_signals_in_view_list(gfxw_list_t *old_list, gfxw_list_t *n old_widget->signal = new_widget->signal |= carry; } - old_widget = (gfxw_dyn_view_t *) old_widget->next; + old_widget = (gfxw_dyn_view_t *) old_widget->_next; } } static void _k_view_list_kryptonize(gfxw_widget_t *v) { if (v) { - v->flags &= ~GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; - _k_view_list_kryptonize(v->next); + v->_flags &= ~GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; + _k_view_list_kryptonize(v->_next); } } static void _k_raise_topmost_in_view_list(EngineState *s, gfxw_list_t *list, gfxw_dyn_view_t *view) { if (view) { - gfxw_dyn_view_t *next = (gfxw_dyn_view_t *)view->next; + gfxw_dyn_view_t *next = (gfxw_dyn_view_t *)view->_next; // step 11 if ((view->signal & (_K_VIEW_SIG_FLAG_NO_UPDATE | _K_VIEW_SIG_FLAG_HIDDEN | _K_VIEW_SIG_FLAG_ALWAYS_UPDATE)) == 0) { - SCIkdebug(SCIkGRAPHICS, "Forcing precedence 2 at ["PREG"] with %04x\n", PRINT_REG(make_reg(view->ID, view->subID)), view->signal); + SCIkdebug(SCIkGRAPHICS, "Forcing precedence 2 at ["PREG"] with %04x\n", PRINT_REG(make_reg(view->_ID, view->_subID)), view->signal); view->force_precedence = 2; if ((view->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_HIDDEN)) == _K_VIEW_SIG_FLAG_REMOVE) { @@ -2171,7 +2171,7 @@ static void _k_raise_topmost_in_view_list(EngineState *s, gfxw_list_t *list, gfx } } - gfxw_remove_widget_from_container(view->parent, GFXW(view)); + gfxw_remove_widget_from_container(view->_parent, GFXW(view)); if (view->signal & _K_VIEW_SIG_FLAG_HIDDEN) gfxw_hide_widget(GFXW(view)); @@ -2188,7 +2188,7 @@ static void _k_redraw_view_list(EngineState *s, gfxw_list_t *list) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) list->contents; while (view) { - SCIkdebug(SCIkGRAPHICS, " dv["PREG"]: signal %04x\n", make_reg(view->ID, view->subID), view->signal); + SCIkdebug(SCIkGRAPHICS, " dv["PREG"]: signal %04x\n", make_reg(view->_ID, view->_subID), view->signal); // step 1 of subalgorithm if (view->signal & _K_VIEW_SIG_FLAG_NO_UPDATE) { @@ -2221,7 +2221,7 @@ static void _k_redraw_view_list(EngineState *s, gfxw_list_t *list) { SCIkdebug(SCIkGRAPHICS, " -> signal %04x\n", view->signal); - view = (gfxw_dyn_view_t *) view->next; + view = (gfxw_dyn_view_t *) view->_next; } } @@ -2239,14 +2239,14 @@ void _k_draw_view_list(EngineState *s, gfxw_list_t *list, int flags) { // Draws list_nr members of list to s->pic. gfxw_dyn_view_t *widget = (gfxw_dyn_view_t *) list->contents; - if (GFXWC(s->port) != GFXWC(s->dyn_views->parent)) + if (GFXWC(s->port) != GFXWC(s->dyn_views->_parent)) return; // Return if the pictures are meant for a different port while (widget) { if (flags & _K_DRAW_VIEW_LIST_PICVIEW) widget = gfxw_picviewize_dynview(widget); - if (GFXW_IS_DYN_VIEW(widget) && widget->ID) { + if (GFXW_IS_DYN_VIEW(widget) && widget->_ID) { uint16 signal = (flags & _K_DRAW_VIEW_LIST_USE_SIGNAL) ? ((reg_t *)(widget->signalp))->offset : 0; if (signal & _K_VIEW_SIG_FLAG_HIDDEN) @@ -2274,7 +2274,7 @@ void _k_draw_view_list(EngineState *s, gfxw_list_t *list, int flags) { // disposeables and this one isn't disposeable } - widget = (gfxw_dyn_view_t *) widget->next; + widget = (gfxw_dyn_view_t *) widget->_next; } // while (widget) } @@ -2303,7 +2303,7 @@ reg_t kAddToPic(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (!widget) { SCIkwarn(SCIkERROR, "Attempt to single-add invalid picview (%d/%d/%d)\n", view, loop, cel); } else { - widget->ID = -1; + widget->_ID = -1; if (control >= 0) { Common::Rect abs_zone = nsrect_clip(s, y, calculate_nsrect(s, x, y, view, loop, cel), priority); draw_rect_to_control_map(s, abs_zone); @@ -2320,7 +2320,7 @@ reg_t kAddToPic(EngineState *s, int funct_nr, int argc, reg_t *argv) { list = LOOKUP_LIST(list_ref); - pic_views = gfxw_new_list(s->picture_port->bounds, 1); + pic_views = gfxw_new_list(s->picture_port->_bounds, 1); SCIkdebug(SCIkGRAPHICS, "Preparing picview list...\n"); _k_make_view_list(s, &pic_views, list, 0, funct_nr, argc, argv); @@ -2339,7 +2339,7 @@ reg_t kAddToPic(EngineState *s, int funct_nr, int argc, reg_t *argv) { } reg_t kGetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { - return make_reg(0, s->port->ID); + return make_reg(0, s->port->_ID); } reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { @@ -2360,7 +2360,7 @@ reg_t kSetPort(EngineState *s, int funct_nr, int argc, reg_t *argv) { official semantics) would cut off the lower part of the icons in an SCI1 icon bar. Instead we have an iconbar_port that does not exist in SSCI. */ - if (port_nr == (unsigned int) - 1) port_nr = s->iconbar_port->ID; + if (port_nr == (unsigned int) - 1) port_nr = s->iconbar_port->_ID; new_port = gfxw_find_port(s->visual, port_nr); @@ -2445,11 +2445,11 @@ reg_t kDisposeWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) { return s->r_acc; } - if (s->dyn_views && GFXWC(s->dyn_views->parent) == GFXWC(goner)) { - reparentize_primary_widget_lists(s, (gfxw_port_t *) goner->parent); + if (s->dyn_views && GFXWC(s->dyn_views->_parent) == GFXWC(goner)) { + reparentize_primary_widget_lists(s, (gfxw_port_t *) goner->_parent); } - if (s->drop_views && GFXWC(s->drop_views->parent) == GFXWC(goner)) + if (s->drop_views && GFXWC(s->drop_views->_parent) == GFXWC(goner)) s->drop_views = NULL; // Kill it pred = gfxw_remove_port(s->visual, goner); @@ -2458,7 +2458,7 @@ reg_t kDisposeWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) { s->port = pred; // Find the last port that exists and that isn't marked no-switch - while ((!s->visual->port_refs[id] && id >= 0) || (s->visual->port_refs[id]->flags & GFXW_FLAG_NO_IMPLICIT_SWITCH)) + while ((!s->visual->port_refs[id] && id >= 0) || (s->visual->port_refs[id]->_flags & GFXW_FLAG_NO_IMPLICIT_SWITCH)) id--; sciprintf("Activating port %d after disposing window %d\n", id, goner_nr); @@ -2487,7 +2487,7 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) { yl = SKPV(2) - y; xl = SKPV(3) - x; - y += s->wm_port->bounds.y; + y += s->wm_port->_bounds.y; if (x + xl > 319) x -= ((x + xl) - 319); @@ -2546,7 +2546,7 @@ reg_t kNewWindow(EngineState *s, int funct_nr, int argc, reg_t *argv) { s->port = window; // Set active port - return make_reg(0, window->ID); + return make_reg(0, window->_ID); } #define K_ANIMATE_CENTER_OPEN_H 0 // horizontally open from center @@ -2993,12 +2993,12 @@ reg_t kAnimate(EngineState *s, int funct_nr, int argc, reg_t *argv) { assert_primary_widget_lists(s); if (!s->dyn_views->contents // Only reparentize empty dynview list - && ((GFXWC(s->port) != GFXWC(s->dyn_views->parent)) // If dynviews are on other port... - || (s->dyn_views->next))) // ... or not on top of the view list + && ((GFXWC(s->port) != GFXWC(s->dyn_views->_parent)) // If dynviews are on other port... + || (s->dyn_views->_next))) // ... or not on top of the view list reparentize_primary_widget_lists(s, s->port); if (cast_list) { - gfxw_list_t *templist = gfxw_new_list(s->dyn_views->bounds, 0); + gfxw_list_t *templist = gfxw_new_list(s->dyn_views->_bounds, 0); _k_make_view_list(s, &(templist), cast_list, (cycle ? _K_MAKE_VIEW_LIST_CYCLE : 0) | _K_MAKE_VIEW_LIST_CALC_PRIORITY, funct_nr, argc, argv); @@ -3007,8 +3007,8 @@ reg_t kAnimate(EngineState *s, int funct_nr, int argc, reg_t *argv) { assert_primary_widget_lists(s); if (!s->dyn_views->contents // Only reparentize empty dynview list - && ((GFXWC(s->port) != GFXWC(s->dyn_views->parent)) // If dynviews are on other port... - || (s->dyn_views->next))) // ... or not on top of the view list + && ((GFXWC(s->port) != GFXWC(s->dyn_views->_parent)) // If dynviews are on other port... + || (s->dyn_views->_next))) // ... or not on top of the view list reparentize_primary_widget_lists(s, s->port); // End of doit() recovery code @@ -3056,18 +3056,18 @@ reg_t kAnimate(EngineState *s, int funct_nr, int argc, reg_t *argv) { reparentize = 1; if (s->drop_views->contents) { - s->drop_views = gfxw_new_list(s->dyn_views->bounds, GFXW_LIST_SORTED); - s->drop_views->flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; + s->drop_views = gfxw_new_list(s->dyn_views->_bounds, GFXW_LIST_SORTED); + s->drop_views->_flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; ADD_TO_CURRENT_PICTURE_PORT(s->drop_views); } else { assert(s->drop_views); - gfxw_remove_widget_from_container(s->drop_views->parent, GFXW(s->drop_views)); + gfxw_remove_widget_from_container(s->drop_views->_parent, GFXW(s->drop_views)); ADD_TO_CURRENT_PICTURE_PORT(s->drop_views); } if ((reparentize | retval) - && (GFXWC(s->port) == GFXWC(s->dyn_views->parent)) // If dynviews are on the same port... - && (s->dyn_views->next)) // ... and not on top of the view list... + && (GFXWC(s->port) == GFXWC(s->dyn_views->_parent)) // If dynviews are on the same port... + && (s->dyn_views->_next)) // ... and not on top of the view list... reparentize_primary_widget_lists(s, s->port); // ...then reparentize. _k_view_list_kryptonize(s->dyn_views->contents); @@ -3146,8 +3146,8 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) { int font_nr = port->font_nr; gfxw_text_t *text_handle; - color0 = port->color; - bg_color = port->bgcolor; + color0 = port->_color; + bg_color = port->_bgcolor; // TODO: in SCI1VGA the default colors for text and background are #0 (black) // SCI0 case should be checked if (s->resmgr->_sciVersion >= SCI_VERSION_01_VGA) { @@ -3299,12 +3299,12 @@ reg_t kDisplay(EngineState *s, int funct_nr, int argc, reg_t *argv) { } if (save_under) { // Backup - rect_t save_area = text_handle->bounds; - save_area.x += port->bounds.x; - save_area.y += port->bounds.y; + rect_t save_area = text_handle->_bounds; + save_area.x += port->_bounds.x; + save_area.y += port->_bounds.y; s->r_acc = graph_save_box(s, save_area); - text_handle->serial++; // This is evil! + text_handle->_serial++; // This is evil! SCIkdebug(SCIkGRAPHICS, "Saving (%d, %d) size (%d, %d) as "PREG"\n", save_area.x, save_area.y, save_area.width, save_area.height, s->r_acc); } diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp index 7ea852fd69..57ccde7dd2 100644 --- a/engines/sci/engine/kmenu.cpp +++ b/engines/sci/engine/kmenu.cpp @@ -68,10 +68,10 @@ reg_t kDrawStatus(EngineState *s, int funct_nr, int argc, reg_t *argv) { int fgcolor = SKPV_OR_ALT(1, s->status_bar_foreground); int bgcolor = SKPV_OR_ALT(2, s->status_bar_background); - s->titlebar_port->color.visual = get_pic_color(s, fgcolor); - s->titlebar_port->color.mask = GFX_MASK_VISUAL; - s->titlebar_port->bgcolor.visual = get_pic_color(s, bgcolor); - s->titlebar_port->bgcolor.mask = GFX_MASK_VISUAL; + s->titlebar_port->_color.visual = get_pic_color(s, fgcolor); + s->titlebar_port->_color.mask = GFX_MASK_VISUAL; + s->titlebar_port->_bgcolor.visual = get_pic_color(s, bgcolor); + s->titlebar_port->_bgcolor.mask = GFX_MASK_VISUAL; s->status_bar_foreground = fgcolor; s->status_bar_background = bgcolor; diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp index 759bc275ec..942e948b92 100644 --- a/engines/sci/engine/kpathing.cpp +++ b/engines/sci/engine/kpathing.cpp @@ -1543,7 +1543,7 @@ reg_t kAvoidPath(EngineState *s, int funct_nr, int argc, reg_t *argv) { if (!port->decorations) { port->decorations = gfxw_new_list(gfx_rect(0, 0, 320, 200), 0); - port->decorations->set_visual(GFXW(port->decorations), port->visual); + port->decorations->set_visual(GFXW(port->decorations), port->_visual); } else { port->decorations->free_contents(port->decorations); } diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index e8924eedb4..cf5ef2b0ee 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -510,9 +510,9 @@ int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename meta.savegame_time = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF); s->savegame_version = CURRENT_SAVEGAME_VERSION; - s->dyn_views_list_serial = (s->dyn_views)? s->dyn_views->serial : -2; - s->drop_views_list_serial = (s->drop_views)? s->drop_views->serial : -2; - s->port_serial = (s->port)? s->port->serial : -2; + s->dyn_views_list_serial = (s->dyn_views)? s->dyn_views->_serial : -2; + s->drop_views_list_serial = (s->drop_views)? s->drop_views->_serial : -2; + s->port_serial = (s->port)? s->port->_serial : -2; if (s->execution_stack_base) { sciprintf("Cannot save from below kernel function\n"); diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index d2760f7315..f9afa36ae5 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -1663,7 +1663,7 @@ static int c_gfx_current_port(EngineState *s) { if (!s->port) sciprintf("none.\n"); else - sciprintf("%d\n", s->port->ID); + sciprintf("%d\n", s->port->_ID); return 0; } @@ -2767,8 +2767,8 @@ int c_statusbar(EngineState *s) { return 1; } - s->titlebar_port->color = s->ega_colors[cmd_params[0].val]; - s->titlebar_port->bgcolor = s->ega_colors[cmd_params[1].val]; + s->titlebar_port->_color = s->ega_colors[cmd_params[0].val]; + s->titlebar_port->_bgcolor = s->ega_colors[cmd_params[1].val]; s->status_bar_foreground = cmd_params[0].val; s->status_bar_background = cmd_params[1].val; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index e924c86919..0f73deb76c 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -54,7 +54,7 @@ struct gfx_state_t; struct gfxw_port_t; struct gfxw_visual_t; struct gfxw_container_t; -typedef gfxw_container_t gfxw_list_t; +struct gfxw_list_t; class DirSeeker { diff --git a/engines/sci/gfx/gfx_gui.cpp b/engines/sci/gfx/gfx_gui.cpp index e0e57adcc5..9483aa9b63 100644 --- a/engines/sci/gfx/gfx_gui.cpp +++ b/engines/sci/gfx/gfx_gui.cpp @@ -47,13 +47,13 @@ static void clear_titlebar(gfxw_port_t *titlebar) { } static gfxw_list_t *make_titlebar_list(EngineState *s, rect_t bounds, gfxw_port_t *status_bar) { - gfx_color_t color = status_bar->bgcolor; + gfx_color_t color = status_bar->_bgcolor; gfxw_list_t *list; gfxw_box_t *bgbox; - list = gfxw_new_list(status_bar->bounds, 0); - bgbox = gfxw_new_box(s->gfx_state, gfx_rect(0, 0, status_bar->bounds.width, status_bar->bounds.height - 1), + list = gfxw_new_list(status_bar->_bounds, 0); + bgbox = gfxw_new_box(s->gfx_state, gfx_rect(0, 0, status_bar->_bounds.width, status_bar->_bounds.height - 1), color, color, GFX_BOX_SHADE_FLAT); list->add((gfxw_container_t *) list, (gfxw_widget_t *) bgbox); @@ -65,7 +65,7 @@ static gfxw_list_t *finish_titlebar_list(EngineState *s, gfxw_list_t *list, gfxw gfx_color_t black = s->ega_colors[0]; gfxw_primitive_t *line; - line = gfxw_new_line(Common::Point(0, status_bar->bounds.height - 1), Common::Point(status_bar->bounds.width, status_bar->bounds.height - 1), + line = gfxw_new_line(Common::Point(0, status_bar->_bounds.height - 1), Common::Point(status_bar->_bounds.width, status_bar->_bounds.height - 1), black, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL); list->add((gfxw_container_t *)list, (gfxw_widget_t *)line); @@ -75,16 +75,16 @@ static gfxw_list_t *finish_titlebar_list(EngineState *s, gfxw_list_t *list, gfxw void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, const Common::String &text, int fgcolor, int bgcolor) { gfx_state_t *state; gfxw_list_t *list; - gfx_color_t bg = status_bar->bgcolor; - gfx_color_t fg = status_bar->color; + gfx_color_t bg = status_bar->_bgcolor; + gfx_color_t fg = status_bar->_color; gfx_color_t black = s->ega_colors[0]; - if (!status_bar->visual) { + if (!status_bar->_visual) { GFXERROR("Attempt to change title bar without visual!\n"); return; } - state = status_bar->visual->gfx_state; + state = status_bar->_visual->gfx_state; if (!state) { GFXERROR("Attempt to change title bar with stateless visual!\n"); @@ -94,19 +94,19 @@ void sciw_set_status_bar(EngineState *s, gfxw_port_t *status_bar, const Common:: clear_titlebar(status_bar); if (!text.empty()) { - gfxw_text_t *textw = gfxw_new_text(state, gfx_rect(0, 0, status_bar->bounds.width, status_bar->bounds.height), + 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, kFontNoNewlines); - list = make_titlebar_list(s, status_bar->bounds, status_bar); + list = make_titlebar_list(s, status_bar->_bounds, status_bar); list->add((gfxw_container_t *)list, (gfxw_widget_t *)textw); } else { - gfxw_box_t *bgbox = gfxw_new_box(state, gfx_rect(0, 0, status_bar->bounds.width, status_bar->bounds.height - 1), + gfxw_box_t *bgbox = gfxw_new_box(state, gfx_rect(0, 0, status_bar->_bounds.width, status_bar->_bounds.height - 1), black, black, GFX_BOX_SHADE_FLAT); - list = gfxw_new_list(status_bar->bounds, 0); + list = gfxw_new_list(status_bar->_bounds, 0); list->add((gfxw_container_t *)list, (gfxw_widget_t *)bgbox); } @@ -122,11 +122,11 @@ static void sciw_make_window_fit(rect_t *rect, gfxw_port_t *parent) { // This window is meant to cover the whole screen, so we allow it to go through. if (rect->width == 319 && rect->height == 189) return; - if (rect->x + rect->width > parent->bounds.x + parent->bounds.width) - rect->x -= (rect->x + rect->width) - (parent->bounds.x + parent->bounds.width) + 2; + if (rect->x + rect->width > parent->_bounds.x + parent->_bounds.width) + rect->x -= (rect->x + rect->width) - (parent->_bounds.x + parent->_bounds.width) + 2; - if (rect->y + rect->height > parent->bounds.y + parent->bounds.height) - rect->y -= (rect->y + rect->height) - (parent->bounds.y + parent->bounds.height) + 2; + if (rect->y + rect->height > parent->_bounds.y + parent->_bounds.height) + rect->y -= (rect->y + rect->height) - (parent->_bounds.y + parent->_bounds.height) + 2; } gfxw_port_t *sciw_new_window(EngineState *s, @@ -154,12 +154,12 @@ gfxw_port_t *sciw_new_window(EngineState *s, } /* - if (area.y + area.height > visual->bounds.y + visual->bounds.height) { - area.y -= (area.y + area.height) - (visual->bounds.y + visual->bounds.height) + yextra; + if (area.y + area.height > visual->_bounds.y + visual->_bounds.height) { + area.y -= (area.y + area.height) - (visual->_bounds.y + visual->_bounds.height) + yextra; } - if (area.x + area.width > visual->bounds.x + visual->bounds.width) { - area.x -= (area.x + area.width) - (visual->bounds.x + visual->bounds.width) + xextra; + if (area.x + area.width > visual->_bounds.x + visual->_bounds.width) { + area.x -= (area.x + area.width) - (visual->_bounds.x + visual->_bounds.width) + xextra; } */ @@ -176,7 +176,7 @@ gfxw_port_t *sciw_new_window(EngineState *s, win->title_text = title; win->port_flags = flags; - win->flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; + win->_flags |= GFXW_FLAG_IMMUNE_TO_SNAPSHOTS; if (flags & kWindowDontDraw) flags = kWindowTransparent | kWindowNoFrame; @@ -190,7 +190,7 @@ gfxw_port_t *sciw_new_window(EngineState *s, frame = gfx_rect(area.x - 1, area.y - 1, area.width + 2, area.height + 2); // Set visible window boundaries - win->bounds = gfx_rect(frame.x, frame.y, frame.width + shadow_offset, frame.height + shadow_offset); + win->_bounds = gfx_rect(frame.x, frame.y, frame.width + shadow_offset, frame.height + shadow_offset); decorations = gfxw_new_list(gfx_rect(frame.x, frame.y, frame.width + 1 + shadow_offset, frame.height + 1 + shadow_offset), 0); @@ -199,7 +199,7 @@ gfxw_port_t *sciw_new_window(EngineState *s, win->port_bg = (gfxw_widget_t *)gfxw_new_box(state, gfx_rect(1, (flags & kWindowTitle) ? 10 : 1, area.width, area.height), bgcolor, bgcolor, GFX_BOX_SHADE_FLAT); decorations->add((gfxw_container_t *) decorations, win->port_bg); - win->flags |= GFXW_FLAG_OPAQUE; + win->_flags |= GFXW_FLAG_OPAQUE; } if (flags & kWindowTitle) { @@ -254,7 +254,7 @@ gfxw_port_t *sciw_new_window(EngineState *s, } win->decorations = decorations; - decorations->parent = GFXWC(win); + decorations->_parent = GFXWC(win); return win; } @@ -270,17 +270,17 @@ gfxw_list_t *_sciw_add_text_to_list(gfxw_list_t *list, gfxw_port_t *port, rect_t gfx_color_t *color1, *color2, *bgcolor; if (inverse) { - color1 = color2 = &(port->bgcolor); - bgcolor = &(port->color); + color1 = color2 = &(port->_bgcolor); + bgcolor = &(port->_color); } else if (gray_text) { - bgcolor = color1 = &(port->bgcolor); - color2 = &(port->color); + bgcolor = color1 = &(port->_bgcolor); + color2 = &(port->_color); } else { - color1 = color2 = &(port->color); - bgcolor = &(port->bgcolor); + color1 = color2 = &(port->_color); + bgcolor = &(port->_bgcolor); } - list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, zone, font, text, align, ALIGN_TOP, + list->add(GFXWC(list), GFXW(gfxw_new_text(port->_visual->gfx_state, zone, font, text, align, ALIGN_TOP, *color1, *color2, *bgcolor, flags))); zone.width--; @@ -294,7 +294,7 @@ gfxw_list_t *_sciw_add_text_to_list(gfxw_list_t *list, gfxw_port_t *port, rect_t } gfxw_list_t *sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, char *text, int font, char selected, char inverse, char grayed_out) { - gfx_color_t *frame_col = (inverse) ? &(port->bgcolor) : &(port->color); + gfx_color_t *frame_col = (inverse) ? &(port->_bgcolor) : &(port->_color); gfxw_list_t *list; zone.x--; @@ -317,7 +317,7 @@ gfxw_list_t *sciw_new_button_control(gfxw_port_t *port, reg_t ID, rect_t zone, c 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))); + port->_color, port->_color, GFX_BOX_SHADE_FLAT))); 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, kFontIgnoreLF, grayed_out); @@ -348,7 +348,7 @@ gfxw_list_t *sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, cha gfxw_text_t *text_handle; gfxw_list_t *list; - int cursor_height = gfxop_get_font_height(port->visual->gfx_state, font); + int cursor_height = gfxop_get_font_height(port->_visual->gfx_state, font); zone.x--; zone.y--; @@ -361,8 +361,8 @@ gfxw_list_t *sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, cha zone.y = 1; 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, kFontNoNewlines); + text_handle = gfxw_new_text(port->_visual->gfx_state, zone, font, text, ALIGN_LEFT, ALIGN_TOP, + port->_color, port->_color, port->_bgcolor, kFontNoNewlines); list->add(GFXWC(list), GFXW(text_handle)); } else { @@ -374,8 +374,8 @@ gfxw_list_t *sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, cha textdup[cursor] = 0; // terminate 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, kFontNoNewlines); + text_handle = gfxw_new_text(port->_visual->gfx_state, zone, font, textdup, ALIGN_LEFT, ALIGN_TOP, + port->_color, port->_color, port->_bgcolor, kFontNoNewlines); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; @@ -384,28 +384,28 @@ gfxw_list_t *sciw_new_edit_control(gfxw_port_t *port, reg_t ID, rect_t zone, cha if (cursor < strlen(text)) { 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, kFontNoNewlines); + text_handle = gfxw_new_text(port->_visual->gfx_state, zone, font, textdup, ALIGN_LEFT, ALIGN_TOP, + 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, kFontNoNewlines); + text_handle = gfxw_new_text(port->_visual->gfx_state, zone, font, text + cursor + 1, ALIGN_LEFT, ALIGN_TOP, + port->_color, port->_color, port->_bgcolor, kFontNoNewlines); list->add(GFXWC(list), GFXW(text_handle)); zone.x += text_handle->width; }; if (cursor == strlen(text)) list->add(GFXWC(list), GFXW(gfxw_new_line(Common::Point(zone.x, zone.y), Common::Point(zone.x, zone.y + cursor_height - 1), - port->color, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL))); + port->_color, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_NORMAL))); free(textdup); } zone.x = zone.y = 0; - list->add(GFXWC(list), GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + list->add(GFXWC(list), GFXW(gfxw_new_rect(zone, port->_color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); return list; } @@ -416,7 +416,7 @@ gfxw_list_t *sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int gfxw_widget_t *icon; gfxw_set_id(GFXW(list), ID.segment, ID.offset); - if (!port->visual) { + if (!port->_visual) { GFXERROR("Attempting to create icon control for virtual port!\n"); return NULL; } @@ -424,7 +424,7 @@ gfxw_list_t *sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int zone.x = 0; zone.y = 0; - icon = GFXW(gfxw_new_view(port->visual->gfx_state, Common::Point(zone.x, zone.y), view, loop, cel, 0, -1, -1, + icon = GFXW(gfxw_new_view(port->_visual->gfx_state, Common::Point(zone.x, zone.y), view, loop, cel, 0, -1, -1, ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET)); if (!icon) { @@ -432,7 +432,7 @@ gfxw_list_t *sciw_new_icon_control(gfxw_port_t *port, reg_t ID, rect_t zone, int return NULL; } - list->flags |= GFXW_FLAG_MULTI_ID; + list->_flags |= GFXW_FLAG_MULTI_ID; list->add(GFXWC(list), icon); @@ -456,7 +456,7 @@ gfxw_list_t *sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int list = gfxw_new_list(_move_and_extend_rect(zone, Common::Point(port->zone.x, port->zone.y), 1), 0); - font_height = gfxop_get_font_height(port->visual->gfx_state, font_nr); + font_height = gfxop_get_font_height(port->_visual->gfx_state, font_nr); columns = (zone.height - 20); if (font_height <= 0) { @@ -481,15 +481,15 @@ gfxw_list_t *sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int for (i = list_top; columns-- && i < entries_nr; i++) { if (i != selection) list->add(GFXWC(list), - GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(zone.x, zone.y, zone.width - 2, font_height), + 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, kFontNoNewlines))); + 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), + 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, kFontNoNewlines))); + port->_bgcolor, port->_bgcolor, port->_color, kFontNoNewlines))); } zone.y += font_height; @@ -501,33 +501,33 @@ gfxw_list_t *sciw_new_list_control(gfxw_port_t *port, reg_t ID, rect_t zone, int zone.y = 0; // Add up arrow - list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, 0, zone.width - 2, 8), + list->add(GFXWC(list), GFXW(gfxw_new_text(port->_visual->gfx_state, gfx_rect(1, 0, zone.width - 2, 8), port->font_nr, arr_up, ALIGN_CENTER, ALIGN_CENTER, - port->color, port->color, port->bgcolor, 0))); + port->_color, port->_color, port->_bgcolor, 0))); // Add down arrow - list->add(GFXWC(list), GFXW(gfxw_new_text(port->visual->gfx_state, gfx_rect(1, zone.height - 9, zone.width - 2, 8), + list->add(GFXWC(list), GFXW(gfxw_new_text(port->_visual->gfx_state, gfx_rect(1, zone.height - 9, zone.width - 2, 8), port->font_nr, arr_down, ALIGN_CENTER, ALIGN_CENTER, - port->color, port->color, port->bgcolor, 0))); + port->_color, port->_color, port->_bgcolor, 0))); if (list_top & 1) { // Hack to work around aggressive caching - list->add(GFXWC(list), GFXW(gfxw_new_rect(zone, port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + list->add(GFXWC(list), GFXW(gfxw_new_rect(zone, port->_color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); list->add(GFXWC(list), GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.width, zone.height - 20), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + port->_color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); } else { list->add(GFXWC(list), GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y, zone.width, zone.height - 10), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + port->_color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); list->add(GFXWC(list), GFXW(gfxw_new_rect(gfx_rect(zone.x, zone.y + 10, zone.width, zone.height - 10), - port->color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); + port->_color, GFX_LINE_MODE_CORRECT, GFX_LINE_STYLE_NORMAL))); } return list; } void sciw_set_menubar(EngineState *s, gfxw_port_t *status_bar, Menubar *menubar, int selection) { - gfxw_list_t *list = make_titlebar_list(s, status_bar->bounds, status_bar); + gfxw_list_t *list = make_titlebar_list(s, status_bar->_bounds, status_bar); int offset = MENU_LEFT_BORDER; int i; @@ -538,15 +538,15 @@ void sciw_set_menubar(EngineState *s, gfxw_port_t *status_bar, Menubar *menubar, int width = menu->_titleWidth + (MENU_BORDER_SIZE * 2); if (i == selection) { - list->add(GFXWC(list), GFXW(gfxw_new_box(status_bar->visual->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), - status_bar->color, status_bar->color, GFX_BOX_SHADE_FLAT))); + list->add(GFXWC(list), GFXW(gfxw_new_box(status_bar->_visual->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT), + 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, kFontNoNewlines))); + 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, kFontNoNewlines))); + status_bar->_color, status_bar->_color, status_bar->_bgcolor, kFontNoNewlines))); offset += width; } @@ -574,8 +574,8 @@ gfxw_port_t *sciw_new_menu(EngineState *s, gfxw_port_t *status_bar, Menubar *men area.width = menu->_width - 1; area.height = menu->_items.size() * 10; - retval = sciw_new_window(s, area, status_bar->font_nr, status_bar->color, status_bar->bgcolor, - 0, status_bar->color, status_bar->bgcolor, NULL, kWindowNoDropShadow | kWindowTransparent); + retval = sciw_new_window(s, area, status_bar->font_nr, status_bar->_color, status_bar->_bgcolor, + 0, status_bar->_color, status_bar->_bgcolor, NULL, kWindowNoDropShadow | kWindowTransparent); retval->set_visual(GFXW(retval), s->visual); @@ -605,13 +605,13 @@ gfxw_widget_t *_make_menu_entry(MenuItem *item, int offset, int width, gfxw_port xcolor = gray ? color : bgcolor; - 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, + 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, 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, + 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, kFontNoNewlines))); } @@ -626,7 +626,7 @@ gfxw_widget_t *_make_menu_hbar(int offset, int width, gfxw_port_t *port, gfx_col color = un_prioritize(color); bgcolor = un_prioritize(bgcolor); - 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_box(port->_visual->gfx_state, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT))); list->add(GFXWC(list), GFXW(gfxw_new_line(Common::Point(0, 5), Common::Point(width, 5), color, GFX_LINE_MODE_FAST, GFX_LINE_STYLE_STIPPLED))); @@ -637,8 +637,8 @@ gfxw_port_t *sciw_toggle_item(gfxw_port_t *menu_port, Menu *menu, int selection, if (selection < 0 || selection >= (int)menu->_items.size()) return menu_port; - gfx_color_t fgColor = !selected ? menu_port->color : menu_port->bgcolor; - gfx_color_t bgColor = !selected ? menu_port->bgcolor : menu_port->color; + gfx_color_t fgColor = !selected ? menu_port->_color : menu_port->_bgcolor; + gfx_color_t bgColor = !selected ? menu_port->_bgcolor : menu_port->_color; MenuItem *item = &menu->_items[selection]; diff --git a/engines/sci/gfx/gfx_state_internal.h b/engines/sci/gfx/gfx_state_internal.h index d3a71d4783..f434a966eb 100644 --- a/engines/sci/gfx/gfx_state_internal.h +++ b/engines/sci/gfx/gfx_state_internal.h @@ -67,7 +67,6 @@ enum gfxw_widget_type_t { GFXW_SORTED_LIST, GFXW_VISUAL, GFXW_PORT - }; @@ -88,18 +87,21 @@ typedef int gfxw_op_int(gfxw_widget_t *, int); typedef int gfxw_bin_op(gfxw_widget_t *, gfxw_widget_t *); struct gfxw_widget_t { - int magic; /* Extra check after typecasting */ - int serial; /* Serial number */ - int flags; /* Widget flags */ - gfxw_widget_type_t type; - rect_t bounds; /* Boundaries */ - gfxw_widget_t *next; /* Next widget in widget list */ - int ID; /* Unique ID or GFXW_NO_ID */ - int subID; /* A 'sub-ID', or GFXW_NO_ID */ - gfxw_container_t *parent; /* The parent widget, or NULL if not owned */ - gfxw_visual_t *visual; /* The owner visual */ - int widget_priority; /* Drawing priority, or -1 */ - gfxw_point_op *draw; /* Draw widget (if dirty) and anything else required for the display to be consistant */ + int _magic; /* Extra check after typecasting */ + int _serial; /* Serial number */ + int _flags; /* Widget flags */ + gfxw_widget_type_t _type; + rect_t _bounds; /* Boundaries */ + gfxw_widget_t *_next; /* Next widget in widget list */ + int _ID; /* Unique ID or GFXW_NO_ID */ + int _subID; /* A 'sub-ID', or GFXW_NO_ID */ + gfxw_container_t *_parent; /* The parent widget, or NULL if not owned */ + gfxw_visual_t *_visual; /* The owner visual */ + int _widgetPriority; /* Drawing priority, or -1 */ + +public: + // TODO: Replace the following with virtual methods + gfxw_point_op *draw; /* Draw widget (if dirty) and anything else required for the display to be consistent */ gfxw_op *widfree; /* Remove widget (and any sub-widgets it may contain) */ gfxw_op *tag; /* Tag the specified widget */ gfxw_op_int *print; /* Prints the widget's contents, using sciprintf. Second parameter is indentation. */ @@ -108,57 +110,73 @@ struct gfxw_widget_t { gfxw_bin_op *should_replace; /* (only if a equals b) Whether b should replace a even though they are equivalent */ gfxw_bin_op *superarea_of; /* a superarea_of b <=> for each pixel of b there exists an opaque pixel in a at the same location */ gfxw_visual_op *set_visual; /* Sets the visual the widget belongs to */ + + gfxw_widget_t(gfxw_widget_type_t type); }; -#define GFXW_IS_BOX(widget) ((widget)->type == GFXW_BOX) +#define GFXW_IS_BOX(widget) ((widget)->_type == GFXW_BOX) struct gfxw_box_t : public gfxw_widget_t { - gfx_color_t color1, color2; - gfx_box_shade_t shade_type; + gfx_color_t _color1, _color2; + gfx_box_shade_t _shadeType; + + gfxw_box_t(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type); }; -#define GFXW_IS_PRIMITIVE(widget) ((widget)->type == GFXW_RECT || (widget)->type == GFXW_LINE) +#define GFXW_IS_PRIMITIVE(widget) ((widget)->_type == GFXW_RECT || (widget)->_type == GFXW_LINE) struct gfxw_primitive_t : public gfxw_widget_t { - gfx_color_t color; - gfx_line_mode_t line_mode; - gfx_line_style_t line_style; + gfx_color_t _color; + gfx_line_mode_t _lineMode; + gfx_line_style_t _lineStyle; + + gfxw_primitive_t(rect_t area, gfx_color_t color, gfx_line_mode_t mode, + gfx_line_style_t style, gfxw_widget_type_t type); }; -#define GFXW_IS_VIEW(widget) ((widget)->type == GFXW_VIEW || (widget)->type == GFXW_STATIC_VIEW \ - || (widget)->type == GFXW_DYN_VIEW || (widget)->type == GFXW_PIC_VIEW) +#define GFXW_IS_VIEW(widget) ((widget)->_type == GFXW_VIEW || (widget)->_type == GFXW_STATIC_VIEW \ + || (widget)->_type == GFXW_DYN_VIEW || (widget)->_type == GFXW_PIC_VIEW) struct gfxw_view_t : public gfxw_widget_t { - Common::Point pos; /* Implies the value of 'bounds' in gfxw_widget_t */ - gfx_color_t color; - int view, loop, cel; - int palette; + Common::Point _pos; /* Implies the value of 'bounds' in gfxw_widget_t */ + gfx_color_t _color; + int _view, _loop, _cel; + int _palette; + + gfxw_view_t(gfx_state_t *state, Common::Point pos, int view_nr, int loop, int cel, int palette, int priority, int control, + gfx_alignment_t halign, gfx_alignment_t valign, int flags); }; -#define GFXW_IS_DYN_VIEW(widget) ((widget)->type == GFXW_DYN_VIEW || (widget)->type == GFXW_PIC_VIEW) +#define GFXW_IS_DYN_VIEW(widget) ((widget)->_type == GFXW_DYN_VIEW || (widget)->_type == GFXW_PIC_VIEW) struct gfxw_dyn_view_t : public gfxw_view_t { /* FIXME: This code is specific to SCI */ rect_t draw_bounds; /* The correct position to draw to */ void *under_bitsp, *signalp; int under_bits, signal; - int z; /* The z coordinate: Added to y, but used for sorting */ + int _z; /* The z coordinate: Added to y, but used for sorting */ int sequence; /* Sequence number: For sorting */ int force_precedence; /* Precedence enforcement variable for sorting- defaults to 0 */ + + gfxw_dyn_view_t(gfx_state_t *state, Common::Point pos, int z, int view, int loop, int cel, int palette, int priority, int control, + gfx_alignment_t halign, gfx_alignment_t valign, int sequence); }; -#define GFXW_IS_TEXT(widget) ((widget)->type == GFXW_TEXT) +#define GFXW_IS_TEXT(widget) ((widget)->_type == GFXW_TEXT) struct gfxw_text_t : public gfxw_widget_t { int font_nr; int lines_nr, lineheight, lastline_width; char *text; gfx_alignment_t halign, valign; - gfx_color_t color1, color2, bgcolor; + gfx_color_t _color1, _color2, _bgcolor; int text_flags; int width, height; /* Real text width and height */ gfx_text_handle_t *text_handle; + + gfxw_text_t(gfx_state_t *state, rect_t area, int font, const char *text, gfx_alignment_t halign, + gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, gfx_color_t bgcolor, int text_flags); }; @@ -174,34 +192,44 @@ struct gfxw_container_t : public gfxw_widget_t { gfx_dirty_rect_t *dirty; /* List of dirty rectangles */ gfxw_widget_t *contents; gfxw_widget_t **nextpp; /* Pointer to the 'next' pointer in the last entry in contents */ + +public: + // TODO: Replace the following with virtual methods gfxw_unary_container_op *free_tagged; /* Free all tagged contained widgets */ gfxw_unary_container_op *free_contents; /* Free all contained widgets */ gfxw_rect_op *add_dirty_abs; /* Add an absolute dirty rectangle */ gfxw_rect_op *add_dirty_rel; /* Add a relative dirty rectangle */ gfxw_container_op *add; /* Append widget to an appropriate position (for view and control lists) */ + + gfxw_container_t(rect_t area, gfxw_widget_type_t type); }; -#define GFXW_IS_CONTAINER(widget) ((widget)->type == GFXW_PORT || (widget)->type == GFXW_VISUAL || \ - (widget)->type == GFXW_SORTED_LIST || (widget)->type == GFXW_LIST) +#define GFXW_IS_CONTAINER(widget) ((widget)->_type == GFXW_PORT || (widget)->_type == GFXW_VISUAL || \ + (widget)->_type == GFXW_SORTED_LIST || (widget)->_type == GFXW_LIST) + +#define GFXW_IS_LIST(widget) ((widget)->_type == GFXW_LIST || (widget)->_type == GFXW_SORTED_LIST) +#define GFXW_IS_SORTED_LIST(widget) ((widget)->_type == GFXW_SORTED_LIST) -#define GFXW_IS_LIST(widget) ((widget)->type == GFXW_LIST || (widget)->type == GFXW_SORTED_LIST) -#define GFXW_IS_SORTED_LIST(widget) ((widget)->type == GFXW_SORTED_LIST) -typedef gfxw_container_t gfxw_list_t; +struct gfxw_list_t : public gfxw_container_t { + gfxw_list_t(rect_t area, bool sorted); +}; -#define GFXW_IS_VISUAL(widget) ((widget)->type == GFXW_VISUAL) +#define GFXW_IS_VISUAL(widget) ((widget)->_type == GFXW_VISUAL) struct gfxw_visual_t : public gfxw_container_t { gfxw_port_t **port_refs; /* References to ports */ int port_refs_nr; int font_nr; /* Default font */ gfx_state_t *gfx_state; + + gfxw_visual_t(gfx_state_t *state, int font); }; -#define GFXW_IS_PORT(widget) ((widget)->type == GFXW_PORT) +#define GFXW_IS_PORT(widget) ((widget)->_type == GFXW_PORT) struct gfxw_port_t : public gfxw_container_t { gfxw_list_t *decorations; /* optional window decorations- drawn before the contents */ gfxw_widget_t *port_bg; /* Port background widget or NULL */ - gfx_color_t color, bgcolor; + gfx_color_t _color, _bgcolor; int font_nr; Common::Point draw_pos; /* Drawing position */ gfxw_snapshot_t *restore_snap; /* Snapshot to be restored automagically, @@ -209,6 +237,8 @@ struct gfxw_port_t : public gfxw_container_t { int port_flags; /* interpreter-dependant flags */ const char *title_text; byte gray_text; /* Whether text is 'grayed out' (dithered) */ + + gfxw_port_t(gfxw_visual_t *visual, rect_t area, gfx_color_t fgcolor, gfx_color_t bgcolor); }; } // End of namespace Sci diff --git a/engines/sci/gfx/gfx_widgets.cpp b/engines/sci/gfx/gfx_widgets.cpp index 96dacd76cd..d9793ca7c8 100644 --- a/engines/sci/gfx/gfx_widgets.cpp +++ b/engines/sci/gfx/gfx_widgets.cpp @@ -94,29 +94,29 @@ static void _gfxw_print_widget(gfxw_widget_t *widget, int indentation) { indent(indentation); - if (widget->magic == GFXW_MAGIC_VALID) { - if (widget->visual) + if (widget->_magic == GFXW_MAGIC_VALID) { + if (widget->_visual) sciprintf("v "); else sciprintf("NoVis "); - } else if (widget->magic == GFXW_MAGIC_INVALID) + } else if (widget->_magic == GFXW_MAGIC_INVALID) sciprintf("INVALID "); - sciprintf("S%08x", widget->serial); + sciprintf("S%08x", widget->_serial); - if (widget->ID != GFXW_NO_ID) { - sciprintf("#%x", widget->ID); + if (widget->_ID != GFXW_NO_ID) { + sciprintf("#%x", widget->_ID); - if (widget->subID != GFXW_NO_ID) - sciprintf(":%x ", widget->subID); + if (widget->_subID != GFXW_NO_ID) + sciprintf(":%x ", widget->_subID); else sciprintf(" "); } - sciprintf("[(%d,%d)(%dx%d)]", widget->bounds.x, widget->bounds.y, widget->bounds.width, widget->bounds.height); + sciprintf("[(%d,%d)(%dx%d)]", widget->_bounds.x, widget->_bounds.y, widget->_bounds.width, widget->_bounds.height); for (i = 0; i < strlen(flags_list); i++) - if (widget->flags & (1 << i)) + if (widget->_flags & (1 << i)) sciprintf("%c", flags_list[i]); sciprintf(" "); @@ -124,41 +124,38 @@ static void _gfxw_print_widget(gfxw_widget_t *widget, int indentation) { static int _gfxwop_print_empty(gfxw_widget_t *widget, int indentation) { _gfxw_print_widget(widget, indentation); - sciprintf("<untyped #%d>", widget->type); + sciprintf("<untyped #%d>", widget->_type); return 0; } -gfxw_widget_t *_gfxw_new_widget(int size, gfxw_widget_type_t type) { - gfxw_widget_t *widget = (gfxw_widget_t*)sci_malloc(size); -#ifdef SATISFY_PURIFY - memset(widget, 0, size); -#endif - - widget->magic = GFXW_MAGIC_VALID; - widget->parent = NULL; - widget->visual = NULL; - widget->next = NULL; - widget->type = type; - widget->bounds = gfx_rect(0, 0, 0, 0); - widget->flags = GFXW_FLAG_DIRTY; - widget->ID = GFXW_NO_ID; - widget->subID = GFXW_NO_ID; - widget->serial = widget_serial_number_counter++; - widget->widget_priority = -1; +gfxw_widget_t::gfxw_widget_t(gfxw_widget_type_t type_) { + _magic = GFXW_MAGIC_VALID; + _serial = widget_serial_number_counter++; widget_serial_number_counter &= MAX_SERIAL_NUMBER; - widget->draw = NULL; - widget->widfree = NULL; - widget->tag = NULL; - widget->print = _gfxwop_print_empty; - widget->should_replace = NULL; - widget->compare_to = widget->equals = widget->superarea_of = NULL; - - _gfxw_debug_add_widget(widget); - - return widget; + _flags = GFXW_FLAG_DIRTY; + _type = type_; + _bounds = gfx_rect(0, 0, 0, 0); + _next = NULL; + _ID = GFXW_NO_ID; + _subID = GFXW_NO_ID; + _parent = NULL; + _visual = NULL; + _widgetPriority = -1; + + draw = NULL; + widfree = NULL; + tag = NULL; + print = _gfxwop_print_empty; + compare_to = NULL; + equals = NULL; + should_replace = NULL; + superarea_of = NULL; + set_visual = NULL; + + _gfxw_debug_add_widget(this); } static int verify_widget(gfxw_widget_t *widget) { @@ -168,8 +165,8 @@ static int verify_widget(gfxw_widget_t *widget) { BREAKPOINT(); #endif return 1; - } else if (widget->magic != GFXW_MAGIC_VALID) { - if (widget->magic == GFXW_MAGIC_INVALID) { + } else if (widget->_magic != GFXW_MAGIC_VALID) { + if (widget->_magic == GFXW_MAGIC_INVALID) { GFXERROR("Attempt to use invalidated widget\n"); } else { GFXERROR("Attempt to use non-widget\n"); @@ -200,8 +197,8 @@ static void _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { } } - widget->magic = GFXW_MAGIC_INVALID; - free(widget); + widget->_magic = GFXW_MAGIC_INVALID; + delete widget; _gfxw_debug_remove_widget(widget); } @@ -227,18 +224,18 @@ static void _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { return 1; \ } \ if (!(widget)->print) { \ - sciprintf("L%d: Widget of type %d does not have print function", __LINE__, (widget)->type); \ + sciprintf("L%d: Widget of type %d does not have print function", __LINE__, (widget)->_type); \ } \ - if ((widget)->type != (exp_type)) { \ - sciprintf("L%d: Error in widget: Expected type " # exp_type "(%d) but got %d\n", __LINE__, exp_type, (widget)->type); \ + if ((widget)->_type != (exp_type)) { \ + sciprintf("L%d: Error in widget: Expected type " # exp_type "(%d) but got %d\n", __LINE__, exp_type, (widget)->_type); \ sciprintf("Erroneous widget: "); \ widget->print(widget, 4); \ sciprintf("\n"); \ return 1; \ } \ - if (!(widget->flags & GFXW_FLAG_VISIBLE)) \ + if (!(widget->_flags & GFXW_FLAG_VISIBLE)) \ return 0; \ - if (!(widget->type == GFXW_VISUAL || widget->visual)) { \ + if (!(widget->_type == GFXW_VISUAL || widget->_visual)) { \ sciprintf("L%d: Error while drawing widget: Widget has no visual\n", __LINE__); \ sciprintf("Erroneous widget: "); \ widget->print(widget, 1); \ @@ -246,6 +243,8 @@ static void _gfxw_unallocate_widget(gfx_state_t *state, gfxw_widget_t *widget) { return 1; \ } + +// TODO: Turn this into an operator== static int _color_equals(gfx_color_t a, gfx_color_t b) { if (a.mask != b.mask) return 0; @@ -267,11 +266,11 @@ static int _color_equals(gfx_color_t a, gfx_color_t b) { } static int _gfxwop_basic_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) { - widget->visual = visual; + widget->_visual = visual; - if (widget->parent) { - DDIRTY(stderr, "basic_set_visual: DOWNWARDS rel(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->bounds)); - widget->parent->add_dirty_rel(widget->parent, widget->bounds, 1); + if (widget->_parent) { + DDIRTY(stderr, "basic_set_visual: DOWNWARDS rel(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->_bounds)); + widget->_parent->add_dirty_rel(widget->_parent, widget->_bounds, 1); } return 0; @@ -314,7 +313,7 @@ void gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_ } while (*seekerp && *seekerp != widget) - seekerp = &((*seekerp)->next); + seekerp = &((*seekerp)->_next); if (!*seekerp) { GFXERROR("Internal error: Attempt to remove widget from container it was not contained in!\n"); @@ -326,27 +325,27 @@ void gfxw_remove_widget_from_container(gfxw_container_t *container, gfxw_widget_ return; } - if (container->nextpp == &(widget->next)) + if (container->nextpp == &(widget->_next)) container->nextpp = seekerp; - *seekerp = widget->next; // Remove it - widget->parent = NULL; - widget->next = NULL; + *seekerp = widget->_next; // Remove it + widget->_parent = NULL; + widget->_next = NULL; } static int _gfxwop_basic_free(gfxw_widget_t *widget) { - gfxw_visual_t *visual = widget->visual; + gfxw_visual_t *visual = widget->_visual; gfx_state_t *state = (visual) ? visual->gfx_state : NULL; DDIRTY(stderr, "BASIC-FREE: SomeAddDirty\n"); - if (widget->parent) { + if (widget->_parent) { if (GFXW_IS_CONTAINER(widget)) - widget->parent->add_dirty_abs(widget->parent, widget->bounds, 1); + widget->_parent->add_dirty_abs(widget->_parent, widget->_bounds, 1); else - widget->parent->add_dirty_rel(widget->parent, widget->bounds, 1); + widget->_parent->add_dirty_rel(widget->_parent, widget->_bounds, 1); - gfxw_remove_widget_from_container(widget->parent, widget); + gfxw_remove_widget_from_container(widget->_parent, widget); } _gfxw_unallocate_widget(state, widget); @@ -355,7 +354,7 @@ static int _gfxwop_basic_free(gfxw_widget_t *widget) { } static int _gfxwop_basic_tag(gfxw_widget_t *widget) { - widget->flags |= GFXW_FLAG_TAGGED; + widget->_flags |= GFXW_FLAG_TAGGED; return 0; } @@ -392,7 +391,7 @@ static Common::Point _move_point(rect_t rect, Common::Point point) { static int _gfxwop_box_draw(gfxw_widget_t *widget, Common::Point pos) { gfxw_box_t *box = (gfxw_box_t *) widget; DRAW_ASSERT(widget, GFXW_BOX); - GFX_ASSERT(gfxop_draw_box(box->visual->gfx_state, _move_rect(box->bounds, pos), box->color1, box->color2, box->shade_type)); + GFX_ASSERT(gfxop_draw_box(box->_visual->gfx_state, _move_rect(box->_bounds, pos), box->_color1, box->_color2, box->_shadeType)); return 0; } @@ -406,17 +405,17 @@ static int _gfxwop_box_print(gfxw_widget_t *widget, int indentation) { static int _gfxwop_box_superarea_of(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_box_t *box = (gfxw_box_t *) widget; - if (box->color1.alpha) + if (box->_color1.alpha) return 0; - if (box->shade_type != GFX_BOX_SHADE_FLAT && box->color2.alpha) + if (box->_shadeType != GFX_BOX_SHADE_FLAT && box->_color2.alpha) return 0; - // Note: the check for box->bounds and other->bounds is NOT the same as contains() + // Note: the check for box->_bounds and other->_bounds is NOT the same as contains() // in Common::Rect (this one includes equality too) - if (!(box->bounds.x <= other->bounds.x && box->bounds.y <= other->bounds.y && - box->bounds.x + box->bounds.width >= other->bounds.x + other->bounds.width && - box->bounds.y + box->bounds.height >= other->bounds.y + other->bounds.height)) + if (!(box->_bounds.x <= other->_bounds.x && box->_bounds.y <= other->_bounds.y && + box->_bounds.x + box->_bounds.width >= other->_bounds.x + other->_bounds.width && + box->_bounds.y + box->_bounds.height >= other->_bounds.y + other->_bounds.height)) return 0; return 1; @@ -424,22 +423,22 @@ static int _gfxwop_box_superarea_of(gfxw_widget_t *widget, gfxw_widget_t *other) static int _gfxwop_box_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_box_t *wbox = (gfxw_box_t *)widget, *obox; - if (other->type != GFXW_BOX) + if (other->_type != GFXW_BOX) return 0; obox = (gfxw_box_t *) other; - if (!toCommonRect(wbox->bounds).equals(toCommonRect(obox->bounds))) + if (!toCommonRect(wbox->_bounds).equals(toCommonRect(obox->_bounds))) return 0; - if (!_color_equals(wbox->color1, obox->color1)) + if (!_color_equals(wbox->_color1, obox->_color1)) return 0; - if (wbox->shade_type != obox->shade_type) + if (wbox->_shadeType != obox->_shadeType) return 0; - if (wbox->shade_type != GFX_BOX_SHADE_FLAT - && _color_equals(wbox->color2, obox->color2)) + if (wbox->_shadeType != GFX_BOX_SHADE_FLAT + && _color_equals(wbox->_color2, obox->_color2)) return 0; return 1; @@ -455,60 +454,65 @@ static int _gfxw_color_get_priority(gfx_color_t color) { } gfxw_box_t *gfxw_new_box(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) { - gfxw_box_t *widget = (gfxw_box_t *)_gfxw_new_widget(sizeof(gfxw_box_t), GFXW_BOX); + return new gfxw_box_t(state, area, color1, color2, shade_type); +} - widget->widget_priority = _gfxw_color_get_priority(color1); - widget->bounds = area; - widget->color1 = color1; - widget->color2 = color2; - widget->shade_type = shade_type; +gfxw_box_t::gfxw_box_t(gfx_state_t *state, rect_t area, gfx_color_t color1, gfx_color_t color2, gfx_box_shade_t shade_type) + : gfxw_widget_t(GFXW_BOX) { - widget->flags |= GFXW_FLAG_VISIBLE; + _widgetPriority = _gfxw_color_get_priority(color1); + _bounds = area; + _color1 = color1; + _color2 = color2; + _shadeType = shade_type; - if ((color1.mask & GFX_MASK_VISUAL) && ((state && (state->driver->mode->palette)) || (!color1.alpha && !color2.alpha))) - widget->flags |= GFXW_FLAG_OPAQUE; + _flags |= GFXW_FLAG_VISIBLE; - _gfxw_set_ops_BOX(GFXW(widget)); + if ((_color1.mask & GFX_MASK_VISUAL) && ((state && (state->driver->mode->palette)) || (!_color1.alpha && !_color2.alpha))) + _flags |= GFXW_FLAG_OPAQUE; - return widget; + _gfxw_set_ops_BOX(this); } -static gfxw_primitive_t *_gfxw_new_primitive(rect_t area, gfx_color_t color, gfx_line_mode_t mode, - gfx_line_style_t style, gfxw_widget_type_t type) { - gfxw_primitive_t *widget = (gfxw_primitive_t *)_gfxw_new_widget(sizeof(gfxw_primitive_t), type); +gfxw_primitive_t::gfxw_primitive_t(rect_t area, gfx_color_t color_, gfx_line_mode_t mode, + gfx_line_style_t style, gfxw_widget_type_t type_) + : gfxw_widget_t(type_) { - widget->widget_priority = _gfxw_color_get_priority(color); - widget->bounds = area; - widget->color = color; - widget->line_mode = mode; - widget->line_style = style; + _widgetPriority = _gfxw_color_get_priority(color_); + _bounds = area; + _color = color_; + _lineMode = mode; + _lineStyle = style; - widget->flags |= GFXW_FLAG_VISIBLE; - return widget; + _flags |= GFXW_FLAG_VISIBLE; } //*** Rectangles *** +struct gfxw_rect_t : public gfxw_primitive_t { + gfxw_rect_t(rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); +}; + static int _gfxwop_primitive_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_primitive_t *wprim = (gfxw_primitive_t *) widget, *oprim; - if (widget->type != other->type) + if (widget->_type != other->_type) return 0; oprim = (gfxw_primitive_t *) other; // Check if the two primitives are equal (note: the primitives aren't always rectangles, so // the "width" and the "height" here could be negative) - if (wprim->bounds.x != oprim->bounds.x || wprim->bounds.y != oprim->bounds.y || - wprim->bounds.width != oprim->bounds.width || wprim->bounds.height != oprim->bounds.height) + if (wprim->_bounds.x != oprim->_bounds.x || wprim->_bounds.y != oprim->_bounds.y || + wprim->_bounds.width != oprim->_bounds.width || wprim->_bounds.height != oprim->_bounds.height) return 0; - if (!_color_equals(wprim->color, oprim->color)) + if (!_color_equals(wprim->_color, oprim->_color)) return 0; - if (wprim->line_mode != oprim->line_mode) + if (wprim->_lineMode != oprim->_lineMode) return 0; - if (wprim->line_style != oprim->line_style) + if (wprim->_lineStyle != oprim->_lineStyle) return 0; return 1; @@ -518,8 +522,8 @@ static int _gfxwop_rect_draw(gfxw_widget_t *widget, Common::Point pos) { gfxw_primitive_t *rect = (gfxw_primitive_t *) widget; DRAW_ASSERT(widget, GFXW_RECT); - GFX_ASSERT(gfxop_draw_rectangle(rect->visual->gfx_state, gfx_rect(rect->bounds.x + pos.x, rect->bounds.y + pos.y, - rect->bounds.width - 1, rect->bounds.height - 1), rect->color, rect->line_mode, rect->line_style)); + GFX_ASSERT(gfxop_draw_rectangle(rect->_visual->gfx_state, gfx_rect(rect->_bounds.x + pos.x, rect->_bounds.y + pos.y, + rect->_bounds.width - 1, rect->_bounds.height - 1), rect->_color, rect->_lineMode, rect->_lineStyle)); return 0; } @@ -536,20 +540,27 @@ void _gfxw_set_ops_RECT(gfxw_widget_t *prim) { } gfxw_primitive_t *gfxw_new_rect(rect_t rect, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { - gfxw_primitive_t *prim = _gfxw_new_primitive(rect, color, line_mode, line_style, GFXW_RECT); - prim->bounds.width++; - prim->bounds.height++; // Since it is actually one pixel bigger in each direction + return new gfxw_rect_t(rect, color, line_mode, line_style); +} + +gfxw_rect_t::gfxw_rect_t(rect_t rect, gfx_color_t color_, gfx_line_mode_t line_mode_, gfx_line_style_t line_style_) + : gfxw_primitive_t(rect, color_, line_mode_, line_style_, GFXW_RECT) { - _gfxw_set_ops_RECT(GFXW(prim)); + _bounds.width++; + _bounds.height++; // Since it is actually one pixel bigger in each direction - return prim; + _gfxw_set_ops_RECT(this); } //*** Lines *** +struct gfxw_line_t : public gfxw_primitive_t { + gfxw_line_t(Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style); +}; + static int _gfxwop_line_draw(gfxw_widget_t *widget, Common::Point pos) { gfxw_primitive_t *line = (gfxw_primitive_t *)widget; - rect_t linepos = widget->bounds; + rect_t linepos = widget->_bounds; Common::Point p1, p2; linepos.width--; @@ -558,7 +569,7 @@ static int _gfxwop_line_draw(gfxw_widget_t *widget, Common::Point pos) { DRAW_ASSERT(widget, GFXW_LINE); _split_rect(_move_rect(linepos, pos), &p1, &p2); - GFX_ASSERT(gfxop_draw_line(line->visual->gfx_state, p1, p2, line->color, line->line_mode, line->line_style)); + GFX_ASSERT(gfxop_draw_line(line->_visual->gfx_state, p1, p2, line->_color, line->_lineMode, line->_lineStyle)); return 0; } @@ -574,75 +585,64 @@ void _gfxw_set_ops_LINE(gfxw_widget_t *prim) { } gfxw_primitive_t *gfxw_new_line(Common::Point start, Common::Point end, gfx_color_t color, gfx_line_mode_t line_mode, gfx_line_style_t line_style) { - gfxw_primitive_t *prim; - - // Encode into internal representation - rect_t line = gfx_rect(start.x, start.y, end.x - start.x, end.y - start.y); - - line.width++; - line.height++; - - prim = _gfxw_new_primitive(line, color, line_mode, line_style, GFXW_LINE); - - _gfxw_set_ops_LINE(GFXW(prim)); + return new gfxw_line_t(start, end, color, line_mode, line_style); +} - return prim; +gfxw_line_t::gfxw_line_t(Common::Point start, Common::Point end, gfx_color_t color_, gfx_line_mode_t line_mode_, gfx_line_style_t line_style_) + : gfxw_primitive_t(gfx_rect(start.x, start.y, end.x - start.x + 1, end.y - start.y + 1), color_, line_mode_, line_style_, GFXW_LINE) { + _gfxw_set_ops_LINE(this); } //*** Views and static views *** -gfxw_view_t *_gfxw_new_simple_view(gfx_state_t *state, Common::Point pos, int view, int loop, int cel, int palette, int priority, int control, - gfx_alignment_t halign, gfx_alignment_t valign, int size, gfxw_widget_type_t type) { - gfxw_view_t *widget; + +gfxw_view_t::gfxw_view_t(gfx_state_t *state, Common::Point pos_, int view_, int loop_, int cel_, int palette_, int priority, int control, + gfx_alignment_t halign, gfx_alignment_t valign, int flags_) + : gfxw_widget_t((flags_ & GFXW_VIEW_FLAG_STATIC) ? GFXW_STATIC_VIEW : GFXW_VIEW) { + int width, height; Common::Point offset; if (!state) { - GFXERROR("Attempt to create view widget with NULL state!\n"); - return NULL; + error("Attempt to create view widget with NULL state"); } - if (gfxop_get_cel_parameters(state, view, loop, cel, &width, &height, &offset)) { - GFXERROR("Attempt to retrieve cel parameters for (%d/%d/%d) failed (Maybe the values weren't checked beforehand?)\n", - view, cel, loop); - return NULL; + if (gfxop_get_cel_parameters(state, view_, loop_, cel_, &width, &height, &offset)) { + error("Attempt to retrieve cel parameters for (%d/%d/%d) failed (Maybe the values weren't checked beforehand?)", + view_, cel_, loop_); } - widget = (gfxw_view_t *)_gfxw_new_widget(size, type); - - widget->widget_priority = priority; - widget->pos = pos; - widget->color.mask = ((priority < 0) ? 0 : GFX_MASK_PRIORITY) | ((control < 0) ? 0 : GFX_MASK_CONTROL); - widget->color.priority = priority; - widget->color.control = control; - widget->view = view; - widget->loop = loop; - widget->cel = cel; - widget->palette = palette; + _pos = pos_; + _color.mask = ((priority < 0) ? 0 : GFX_MASK_PRIORITY) | ((control < 0) ? 0 : GFX_MASK_CONTROL); + _widgetPriority = priority; + _color.priority = priority; + _color.control = control; + _view = view_; + _loop = loop_; + _cel = cel_; + _palette = palette_; if (halign == ALIGN_CENTER) - widget->pos.x -= width >> 1; + _pos.x -= width >> 1; else if (halign == ALIGN_RIGHT) - widget->pos.x -= width; + _pos.x -= width; if (valign == ALIGN_CENTER) - widget->pos.y -= height >> 1; + _pos.y -= height >> 1; else if (valign == ALIGN_BOTTOM) - widget->pos.y -= height; + _pos.y -= height; - widget->bounds = gfx_rect(widget->pos.x - offset.x, widget->pos.y - offset.y, width, height); + _bounds = gfx_rect(_pos.x - offset.x, _pos.y - offset.y, width, height); - widget->flags |= GFXW_FLAG_VISIBLE; - - return widget; + _flags |= GFXW_FLAG_VISIBLE; } int _gfxwop_view_draw(gfxw_widget_t *widget, Common::Point pos) { gfxw_view_t *view = (gfxw_view_t *)widget; DRAW_ASSERT(widget, GFXW_VIEW); - GFX_ASSERT(gfxop_draw_cel(view->visual->gfx_state, view->view, view->loop, view->cel, - Common::Point(view->pos.x + pos.x, view->pos.y + pos.y), view->color, view->palette)); + GFX_ASSERT(gfxop_draw_cel(view->_visual->gfx_state, view->_view, view->_loop, view->_cel, + Common::Point(view->_pos.x + pos.x, view->_pos.y + pos.y), view->_color, view->_palette)); return 0; } @@ -651,8 +651,8 @@ static int _gfxwop_static_view_draw(gfxw_widget_t *widget, Common::Point pos) { gfxw_view_t *view = (gfxw_view_t *)widget; DRAW_ASSERT(widget, GFXW_VIEW); - GFX_ASSERT(gfxop_draw_cel_static(view->visual->gfx_state, view->view, view->loop, - view->cel, _move_point(view->bounds, pos), view->color, view->palette)); + GFX_ASSERT(gfxop_draw_cel_static(view->_visual->gfx_state, view->_view, view->_loop, + view->_cel, _move_point(view->_bounds, pos), view->_color, view->_palette)); return 0; } @@ -662,9 +662,9 @@ static int _w_gfxwop_view_print(gfxw_widget_t *widget, const char *name, int ind _gfxw_print_widget(widget, indentation); sciprintf("%s", name); - sciprintf("(%d/%d/%d)@(%d,%d)[p:%d,c:%d]", view->view, view->loop, view->cel, view->pos.x, view->pos.y, - (view->color.mask & GFX_MASK_PRIORITY) ? view->color.priority : -1, - (view->color.mask & GFX_MASK_CONTROL) ? view->color.control : -1); + sciprintf("(%d/%d/%d)@(%d,%d)[p:%d,c:%d]", view->_view, view->_loop, view->_cel, view->_pos.x, view->_pos.y, + (view->_color.mask & GFX_MASK_PRIORITY) ? view->_color.priority : -1, + (view->_color.mask & GFX_MASK_CONTROL) ? view->_color.control : -1); return 0; } @@ -695,10 +695,10 @@ gfxw_view_t *gfxw_new_view(gfx_state_t *state, Common::Point pos, int view_nr, i pos.y += offset.y; } - view = _gfxw_new_simple_view(state, pos, view_nr, loop, cel, palette, priority, control, halign, valign, - sizeof(gfxw_view_t), (flags & GFXW_VIEW_FLAG_STATIC) ? GFXW_STATIC_VIEW : GFXW_VIEW); + view = new gfxw_view_t(state, pos, view_nr, loop, cel, palette, priority, control, halign, valign, + (flags & GFXW_VIEW_FLAG_STATIC) ? GFXW_STATIC_VIEW : GFXW_VIEW); - _gfxw_set_ops_VIEW(GFXW(view), (char)(flags & GFXW_VIEW_FLAG_STATIC)); + _gfxw_set_ops_VIEW(view, (char)(flags & GFXW_VIEW_FLAG_STATIC)); return view; } @@ -709,8 +709,8 @@ static int _gfxwop_dyn_view_draw(gfxw_widget_t *widget, Common::Point pos) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) widget; DRAW_ASSERT(widget, GFXW_DYN_VIEW); - GFX_ASSERT(gfxop_draw_cel(view->visual->gfx_state, view->view, view->loop, - view->cel, _move_point(view->draw_bounds, pos), view->color, view->palette)); + GFX_ASSERT(gfxop_draw_cel(view->_visual->gfx_state, view->_view, view->_loop, + view->_cel, _move_point(view->draw_bounds, pos), view->_color, view->_palette)); /* gfx_color_t red; @@ -718,7 +718,7 @@ static int _gfxwop_dyn_view_draw(gfxw_widget_t *widget, Common::Point pos) { red.visual.g = red.visual.b = 0; red.mask = GFX_MASK_VISUAL; GFX_ASSERT(gfxop_draw_rectangle(view->visual->gfx_state, - gfx_rect(view->bounds.x + pos.x, view->bounds.y + pos.y, view->bounds.width - 1, view->bounds.height - 1), red, 0, 0)); + gfx_rect(view->_bounds.x + pos.x, view->_bounds.y + pos.y, view->_bounds.width - 1, view->_bounds.height - 1), red, 0, 0)); */ return 0; @@ -733,13 +733,13 @@ static int _gfxwop_pic_view_draw(gfxw_widget_t *widget, Common::Point pos) { gfxw_dyn_view_t *view = (gfxw_dyn_view_t *) widget; DRAW_ASSERT(widget, GFXW_PIC_VIEW); - GFX_ASSERT(gfxop_set_clip_zone(view->visual->gfx_state, view->parent->zone)); - GFX_ASSERT(gfxop_draw_cel_static_clipped(view->visual->gfx_state, view->view, view->loop, - view->cel, _move_point(view->draw_bounds, pos), view->color, view->palette)); + GFX_ASSERT(gfxop_set_clip_zone(view->_visual->gfx_state, view->_parent->zone)); + GFX_ASSERT(gfxop_draw_cel_static_clipped(view->_visual->gfx_state, view->_view, view->_loop, + view->_cel, _move_point(view->draw_bounds, pos), view->_color, view->_palette)); // Draw again on the back buffer - GFX_ASSERT(gfxop_draw_cel(view->visual->gfx_state, view->view, view->loop, view->cel, - _move_point(view->draw_bounds, pos), view->color, view->palette)); + GFX_ASSERT(gfxop_draw_cel(view->_visual->gfx_state, view->_view, view->_loop, view->_cel, + _move_point(view->draw_bounds, pos), view->_color, view->_palette)); widget->draw = _gfxwop_draw_nop; // No more drawing needs to be done @@ -753,10 +753,10 @@ static int _gfxwop_some_view_print(gfxw_widget_t *widget, int indentation, const _gfxw_print_widget(widget, indentation); sciprintf("%s", type_string); - sciprintf(" SORT=%d z=%d seq=%d (%d/%d/%d)@(%d,%d)[p:%d,c:%d]; sig[%04x@%p]", view->force_precedence, view->z, - view->sequence, view->view, view->loop, view->cel, view->pos.x, view->pos.y, - (view->color.mask & GFX_MASK_PRIORITY) ? view->color.priority : -1, - (view->color.mask & GFX_MASK_CONTROL) ? view->color.control : -1, view->signal, view->signalp); + sciprintf(" SORT=%d z=%d seq=%d (%d/%d/%d)@(%d,%d)[p:%d,c:%d]; sig[%04x@%p]", view->force_precedence, view->_z, + view->sequence, view->_view, view->_loop, view->_cel, view->_pos.x, view->_pos.y, + (view->_color.mask & GFX_MASK_PRIORITY) ? view->_color.priority : -1, + (view->_color.mask & GFX_MASK_CONTROL) ? view->_color.control : -1, view->signal, view->signalp); return 0; } @@ -776,16 +776,16 @@ static int _gfxwop_dyn_view_equals(gfxw_widget_t *widget, gfxw_widget_t *other) oview = (gfxw_dyn_view_t *)other; - if (wview->pos.x != oview->pos.x || wview->pos.y != oview->pos.y || wview->z != oview->z) + if (wview->_pos.x != oview->_pos.x || wview->_pos.y != oview->_pos.y || wview->_z != oview->_z) return 0; - if (wview->view != oview->view || wview->loop != oview->loop || wview->cel != oview->cel) + if (wview->_view != oview->_view || wview->_loop != oview->_loop || wview->_cel != oview->_cel) return 0; - if (!_color_equals(wview->color, oview->color)) + if (!_color_equals(wview->_color, oview->_color)) return 0; - if (wview->flags != oview->flags) + if (wview->_flags != oview->_flags) return 0; return 1; @@ -803,11 +803,11 @@ static int _gfxwop_dyn_view_compare_to(gfxw_widget_t *widget, gfxw_widget_t *oth if (retval) return retval; - retval = wview->pos.y - oview->pos.y; + retval = wview->_pos.y - oview->_pos.y; if (retval) return retval; - retval = (wview->z - oview->z); + retval = (wview->_z - oview->_z); if (retval) return retval; @@ -827,37 +827,40 @@ void _gfxw_set_ops_PICVIEW(gfxw_widget_t *widget) { gfxw_dyn_view_t *gfxw_new_dyn_view(gfx_state_t *state, Common::Point pos, int z, int view, int loop, int cel, int palette, int priority, int control, gfx_alignment_t halign, gfx_alignment_t valign, int sequence) { - gfxw_dyn_view_t *widget; + + return new gfxw_dyn_view_t(state, pos, z, view, loop, cel, palette, priority, control, halign, valign, sequence); +} + +gfxw_dyn_view_t::gfxw_dyn_view_t(gfx_state_t *state, Common::Point pos_, int z_, int view_, int loop_, int cel_, int palette_, int priority, int control, + gfx_alignment_t halign, gfx_alignment_t valign, int sequence_) + : gfxw_view_t(state, pos_, view_, loop_, cel_, palette_, priority, control, halign, valign, 0) { int width, height; int xalignmod, yalignmod; Common::Point offset; + _type = GFXW_DYN_VIEW; + if (!state) { - GFXERROR("Attempt to create view widget with NULL state!\n"); - return NULL; + error("Attempt to create view widget with NULL state!\n"); } - if (gfxop_get_cel_parameters(state, view, loop, cel, &width, &height, &offset)) { - GFXERROR("Attempt to retrieve cel parameters for (%d/%d/%d) failed (Maybe the values weren't checked beforehand?)\n", - view, cel, loop); - return NULL; + if (gfxop_get_cel_parameters(state, view_, loop_, cel_, &width, &height, &offset)) { + error("Attempt to retrieve cel parameters for (%d/%d/%d) failed (Maybe the values weren't checked beforehand?)", + view_, cel_, loop_); } - widget = (gfxw_dyn_view_t *)_gfxw_new_widget(sizeof(gfxw_dyn_view_t), GFXW_DYN_VIEW); - - widget->pos = pos; - widget->color.mask = ((priority < 0) ? 0 : GFX_MASK_PRIORITY) | ((control < 0) ? 0 : GFX_MASK_CONTROL); - widget->widget_priority = priority; - widget->color.priority = priority; - widget->color.control = control; - widget->color.alpha = 0; - widget->color.visual = PaletteEntry(0,0,0); // FIXME: black! - widget->view = view; - widget->loop = loop; - widget->cel = cel; - widget->sequence = sequence; - widget->force_precedence = 0; - widget->palette = palette; + _pos = pos_; + _color.mask = ((priority < 0) ? 0 : GFX_MASK_PRIORITY) | ((control < 0) ? 0 : GFX_MASK_CONTROL); + _widgetPriority = priority; + _color.priority = priority; + _color.control = control; + _view = view_; + _loop = loop_; + _cel = cel_; + _palette = palette_; + + _color.alpha = 0; + _color.visual = PaletteEntry(0,0,0); // FIXME: black! if (halign == ALIGN_CENTER) xalignmod = width >> 1; @@ -873,19 +876,20 @@ gfxw_dyn_view_t *gfxw_new_dyn_view(gfx_state_t *state, Common::Point pos, int z, else yalignmod = 0; - widget->z = z; + draw_bounds = gfx_rect(_pos.x - xalignmod, _pos.y - yalignmod - z_, width, height); + _bounds = gfx_rect(_pos.x - offset.x - xalignmod, _pos.y - offset.y - yalignmod - z_, width, height); - widget->draw_bounds = gfx_rect(widget->pos.x - xalignmod, widget->pos.y - yalignmod - z, width, height); - widget->bounds = gfx_rect(widget->pos.x - offset.x - xalignmod, widget->pos.y - offset.y - yalignmod - z, width, height); + under_bitsp = NULL; + under_bits = 0; + signalp = NULL; + signal = 0; + _z = z_; + sequence = sequence_; + force_precedence = 0; - widget->flags |= GFXW_FLAG_VISIBLE; + _flags |= GFXW_FLAG_VISIBLE; - _gfxw_set_ops_DYNVIEW(GFXW(widget)); - - widget->signalp = NULL; - widget->signal = 0; - - return widget; + _gfxw_set_ops_DYNVIEW(this); } //*** Text *** @@ -901,7 +905,7 @@ static int _gfxwop_text_draw(gfxw_widget_t *widget, Common::Point pos) { gfxw_text_t *text = (gfxw_text_t *)widget; DRAW_ASSERT(widget, GFXW_TEXT); - GFX_ASSERT(gfxop_draw_text(text->visual->gfx_state, text->text_handle, _move_rect(text->bounds, pos))); + GFX_ASSERT(gfxop_draw_text(text->_visual->gfx_state, text->text_handle, _move_rect(text->_bounds, pos))); return 0; } @@ -910,8 +914,8 @@ static int _gfxwop_text_alloc_and_draw(gfxw_widget_t *widget, Common::Point pos) gfxw_text_t *text = (gfxw_text_t *)widget; DRAW_ASSERT(widget, GFXW_TEXT); - text->text_handle = gfxop_new_text(widget->visual->gfx_state, text->font_nr, text->text, text->bounds.width, - text->halign, text->valign, text->color1, text->color2, text->bgcolor, text->text_flags); + text->text_handle = gfxop_new_text(widget->_visual->gfx_state, text->font_nr, text->text, text->_bounds.width, + text->halign, text->valign, text->_color1, text->_color2, text->_bgcolor, text->text_flags); text->draw = _gfxwop_text_draw; @@ -927,12 +931,12 @@ static int _gfxwop_text_print(gfxw_widget_t *widget, int indentation) { static int _gfxwop_text_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_text_t *wtext = (gfxw_text_t *)widget, *otext; - if (other->type != GFXW_TEXT) + if (other->_type != GFXW_TEXT) return 0; otext = (gfxw_text_t *)other; - if ((wtext->bounds.x != otext->bounds.x) || (wtext->bounds.y != otext->bounds.y)) + if ((wtext->_bounds.x != otext->_bounds.x) || (wtext->_bounds.y != otext->_bounds.y)) return 0; if (wtext->halign != otext->halign || wtext->valign != otext->valign) @@ -944,8 +948,8 @@ static int _gfxwop_text_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { if (wtext->font_nr != otext->font_nr) return 0; - /* if (!(_color_equals(wtext->color1, otext->color1) && _color_equals(wtext->color2, otext->color2) - && _color_equals(wtext->bgcolor, otext->bgcolor))) + /* if (!(_color_equals(wtext->_color1, otext->_color1) && _color_equals(wtext->_color2, otext->_color2) + && _color_equals(wtext->_bgcolor, otext->_bgcolor))) return 0; */ return 1; @@ -954,7 +958,7 @@ static int _gfxwop_text_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { static int _gfxwop_text_should_replace(gfxw_widget_t *widget, gfxw_widget_t *other) { gfxw_text_t *wtext = (gfxw_text_t *)widget, *otext; - if (other->type != GFXW_TEXT) + if (other->_type != GFXW_TEXT) return 0; otext = (gfxw_text_t *)other; @@ -975,41 +979,44 @@ void _gfxw_set_ops_TEXT(gfxw_widget_t *widget) { gfxw_text_t *gfxw_new_text(gfx_state_t *state, rect_t area, int font, const char *text, gfx_alignment_t halign, gfx_alignment_t valign, gfx_color_t color1, gfx_color_t color2, gfx_color_t bgcolor, int text_flags) { - gfxw_text_t *widget = (gfxw_text_t *)_gfxw_new_widget(sizeof(gfxw_text_t), GFXW_TEXT); + return new gfxw_text_t(state, area, font, text, halign, valign, color1, color2, bgcolor, text_flags); +} - widget->widget_priority = _gfxw_color_get_priority(color1); - widget->font_nr = font; - widget->text = (char *)sci_malloc(strlen(text) + 1); - widget->halign = halign; - widget->valign = valign; - widget->color1 = color1; - widget->color2 = color2; - widget->bgcolor = bgcolor; - widget->text_flags = text_flags; - widget->text_handle = NULL; +gfxw_text_t::gfxw_text_t(gfx_state_t *state, rect_t area, int font, const char *text_, gfx_alignment_t halign_, + gfx_alignment_t valign_, gfx_color_t color1_, gfx_color_t color2_, gfx_color_t bgcolor_, int text_flags_) + : gfxw_widget_t(GFXW_TEXT) { - strcpy(widget->text, text); + _widgetPriority = _gfxw_color_get_priority(color1_); + font_nr = font; + text = (char *)sci_malloc(strlen(text_) + 1); + halign = halign_; + valign = valign_; + _color1 = color1_; + _color2 = color2_; + _bgcolor = bgcolor_; + text_flags = text_flags_; + text_handle = NULL; - gfxop_get_text_params(state, font, text, area.width, &(widget->width), &(widget->height), text_flags, - &(widget->lines_nr), &(widget->lineheight), &(widget->lastline_width)); + strcpy(text, text_); + + gfxop_get_text_params(state, font, text, area.width, &width, &height, text_flags, + &lines_nr, &lineheight, &lastline_width); /* FIXME: Window is too big - area.x += _calc_needmove(halign, area.width, widget->width); - area.y += _calc_needmove(valign, area.height, widget->height); + area.x += _calc_needmove(halign, area.width, width); + area.y += _calc_needmove(valign, area.height, height); */ if (halign == ALIGN_LEFT) - area.width = widget->width; + area.width = width; if (valign == ALIGN_TOP) - area.height = widget->height; - - widget->bounds = area; + area.height = height; - widget->flags |= GFXW_FLAG_VISIBLE; + _bounds = area; - _gfxw_set_ops_TEXT(GFXW(widget)); + _flags |= GFXW_FLAG_VISIBLE; - return widget; + _gfxw_set_ops_TEXT(this); } void gfxw_text_info(gfx_state_t *state, gfxw_text_t *text, int *lines, int *lineheight, int *offset) { @@ -1053,7 +1060,7 @@ static int _w_gfxwop_container_print_contents(const char *name, gfxw_widget_t *w while (seeker) { seeker->print(seeker, indentation + 1); sciprintf("\n"); - seeker = seeker->next; + seeker = seeker->_next; } return 0; @@ -1063,7 +1070,7 @@ static int _w_gfxwop_container_print(gfxw_widget_t *widget, int indentation) { gfx_dirty_rect_t *dirty; gfxw_container_t *container = (gfxw_container_t *)widget; if (!GFXW_IS_CONTAINER(widget)) { - GFXERROR("_w_gfxwop_container_print() called on type %d widget\n", widget->type); + GFXERROR("_w_gfxwop_container_print() called on type %d widget\n", widget->_type); return 1; } @@ -1085,17 +1092,21 @@ static int _w_gfxwop_container_print(gfxw_widget_t *widget, int indentation) { return 0; } -gfxw_container_t *_gfxw_new_container_widget(rect_t area, int size, gfxw_widget_type_t type) { - gfxw_container_t *widget = (gfxw_container_t *)_gfxw_new_widget(size, type); - - widget->bounds = widget->zone = area; - widget->contents = NULL; - widget->nextpp = &(widget->contents); - widget->dirty = NULL; - widget->flags |= GFXW_FLAG_VISIBLE | GFXW_FLAG_CONTAINER; +gfxw_container_t::gfxw_container_t(rect_t area, gfxw_widget_type_t type_) + : gfxw_widget_t(type_) { + _bounds = zone = area; + contents = NULL; + nextpp = &contents; + dirty = NULL; + + free_tagged = NULL; + free_contents = NULL; + add_dirty_abs = NULL; + add_dirty_rel = NULL; + add = NULL; - return widget; + _flags |= GFXW_FLAG_VISIBLE | GFXW_FLAG_CONTAINER; } static void recursively_free_dirty_rects(gfx_dirty_rect_t *dirty) { @@ -1105,8 +1116,6 @@ static void recursively_free_dirty_rects(gfx_dirty_rect_t *dirty) { } } -int ti = 0; - static int _gfxw_dirty_rect_overlaps_normal_rect(rect_t port_zone, rect_t bounds, rect_t dirty) { bounds.x += port_zone.x; bounds.y += port_zone.y; @@ -1117,7 +1126,7 @@ static int _gfxw_dirty_rect_overlaps_normal_rect(rect_t port_zone, rect_t bounds static int _gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t *contents) { gfxw_container_t *container = (gfxw_container_t *)widget; gfx_dirty_rect_t *dirty = container->dirty; - gfx_state_t *gfx_state = (widget->visual) ? widget->visual->gfx_state : ((gfxw_visual_t *) widget)->gfx_state; + gfx_state_t *gfx_state = (widget->_visual) ? widget->_visual->gfx_state : ((gfxw_visual_t *) widget)->gfx_state; int draw_ports; rect_t nullzone = {0, 0, 0, 0}; @@ -1130,17 +1139,17 @@ static int _gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t while (seeker) { if (_gfxw_dirty_rect_overlaps_normal_rect(GFXW_IS_CONTAINER(seeker) ? nullzone : container->zone, // Containers have absolute coordinates, reflect this. - seeker->bounds, dirty->rect)) { + seeker->_bounds, dirty->rect)) { if (GFXW_IS_CONTAINER(seeker)) {// Propagate dirty rectangles /upwards/ DDIRTY(stderr, "container_draw_contents: propagate upwards (%d,%d,%d,%d ,0)\n", GFX_PRINT_RECT(dirty->rect)); ((gfxw_container_t *)seeker)->add_dirty_abs((gfxw_container_t *)seeker, dirty->rect, 0); } - seeker->flags |= GFXW_FLAG_DIRTY; + seeker->_flags |= GFXW_FLAG_DIRTY; } - seeker = seeker->next; + seeker = seeker->_next; } dirty = dirty->next; @@ -1157,9 +1166,9 @@ static int _gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t byte draw_noncontainers; memcpy(&small_rect, &(dirty->rect), sizeof(rect_t)); - draw_noncontainers = !_gfxop_clip(&small_rect, container->bounds); + draw_noncontainers = !_gfxop_clip(&small_rect, container->_bounds); - if (seeker->flags & GFXW_FLAG_DIRTY) { + if (seeker->_flags & GFXW_FLAG_DIRTY) { if (!GFXW_IS_CONTAINER(seeker) && draw_noncontainers) { GFX_ASSERT(gfxop_set_clip_zone(gfx_state, small_rect)); @@ -1171,10 +1180,10 @@ static int _gfxwop_container_draw_contents(gfxw_widget_t *widget, gfxw_widget_t seeker->draw(seeker, Common::Point(container->zone.x, container->zone.y)); if (!dirty->next) - seeker->flags &= ~GFXW_FLAG_DIRTY; + seeker->_flags &= ~GFXW_FLAG_DIRTY; } - seeker = seeker->next; + seeker = seeker->_next; } dirty = dirty->next; } @@ -1189,7 +1198,7 @@ static int _gfxwop_container_free(gfxw_widget_t *widget) { gfxw_widget_t *seeker = container->contents; while (seeker) { - gfxw_widget_t *next = seeker->next; + gfxw_widget_t *next = seeker->_next; seeker->widfree(seeker); seeker = next; } @@ -1206,7 +1215,7 @@ static int _gfxwop_container_tag(gfxw_widget_t *widget) { while (seeker) { seeker->tag(seeker); - seeker = seeker->next; + seeker = seeker->_next; } return 0; @@ -1215,7 +1224,7 @@ static int _gfxwop_container_tag(gfxw_widget_t *widget) { static int _w_gfxwop_container_set_visual_contents(gfxw_widget_t *contents, gfxw_visual_t *visual) { while (contents) { contents->set_visual(contents, visual); - contents = contents->next; + contents = contents->_next; } return 0; } @@ -1223,11 +1232,11 @@ static int _w_gfxwop_container_set_visual_contents(gfxw_widget_t *contents, gfxw static int _gfxwop_container_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) { gfxw_container_t *container = (gfxw_container_t *) widget; - container->visual = visual; - if (widget->parent) { + container->_visual = visual; + if (widget->_parent) { if (!(GFXW_IS_LIST(widget) && !GFXWC(widget)->contents)) { - DDIRTY(stderr, "set_visual::DOWNWARDS abs(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->bounds)); - widget->parent->add_dirty_abs(widget->parent, widget->bounds, 1); + DDIRTY(stderr, "set_visual::DOWNWARDS abs(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->_bounds)); + widget->_parent->add_dirty_abs(widget->_parent, widget->_bounds, 1); } } @@ -1240,11 +1249,11 @@ static int _gfxwop_container_free_tagged(gfxw_container_t *container) { while (seekerp) { gfxw_widget_t *redshirt = seekerp; - if (redshirt->flags & GFXW_FLAG_TAGGED) { - seekerp = (redshirt->next); + if (redshirt->_flags & GFXW_FLAG_TAGGED) { + seekerp = (redshirt->_next); redshirt->widfree(redshirt); } else - seekerp = (seekerp)->next; + seekerp = (seekerp)->_next; } return 0; @@ -1254,7 +1263,7 @@ static int _gfxwop_container_free_contents(gfxw_container_t *container) { gfxw_widget_t *seeker = container->contents; while (seeker) { - gfxw_widget_t *next = seeker->next; + gfxw_widget_t *next = seeker->_next; seeker->widfree(seeker); seeker = next; } @@ -1263,13 +1272,13 @@ static int _gfxwop_container_free_contents(gfxw_container_t *container) { static void _gfxw_dirtify_container(gfxw_container_t *container, gfxw_widget_t *widget) { if (GFXW_IS_CONTAINER(widget)) - container->add_dirty_abs(GFXWC(container), widget->bounds, 1); + container->add_dirty_abs(GFXWC(container), widget->_bounds, 1); else - container->add_dirty_rel(GFXWC(container), widget->bounds, 1); + container->add_dirty_rel(GFXWC(container), widget->_bounds, 1); } static int _parentize_widget(gfxw_container_t *container, gfxw_widget_t *widget) { - if (widget->parent) { + if (widget->_parent) { GFXERROR("_gfxwop_container_add(): Attempt to give second parent node to widget!\nWidget:"); widget->print(GFXW(widget), 3); sciprintf("\nContainer:"); @@ -1278,12 +1287,12 @@ static int _parentize_widget(gfxw_container_t *container, gfxw_widget_t *widget) return 1; } - widget->parent = GFXWC(container); + widget->_parent = GFXWC(container); if (GFXW_IS_VISUAL(container)) widget->set_visual(widget, (gfxw_visual_t *) container); - else if (container->visual) - widget->set_visual(widget, container->visual); + else if (container->_visual) + widget->set_visual(widget, container->_visual); return 0; } @@ -1294,21 +1303,21 @@ static int _gfxw_container_id_equals(gfxw_container_t *container, gfxw_widget_t if (GFXW_IS_PORT(widget)) return 0; - if (widget->ID == GFXW_NO_ID) + if (widget->_ID == GFXW_NO_ID) return 0; - while (*seekerp && ((*seekerp)->ID != widget->ID || (*seekerp)->subID != widget->subID)) - seekerp = &((*seekerp)->next); + while (*seekerp && ((*seekerp)->_ID != widget->_ID || (*seekerp)->_subID != widget->_subID)) + seekerp = &((*seekerp)->_next); if (!*seekerp) return 0; if ((*seekerp)->equals(*seekerp, widget) && !(*seekerp)->should_replace(*seekerp, widget)) { widget->widfree(widget); - (*seekerp)->flags &= ~GFXW_FLAG_TAGGED; + (*seekerp)->_flags &= ~GFXW_FLAG_TAGGED; return 1; } else { - if (!(widget->flags & GFXW_FLAG_MULTI_ID)) + if (!(widget->_flags & GFXW_FLAG_MULTI_ID)) (*seekerp)->widfree(*seekerp); return 0; } @@ -1318,11 +1327,11 @@ static int _gfxwop_container_add_dirty(gfxw_container_t *container, rect_t dirty #if 0 // This code has been disabled because containers may contain sub-containers with // bounds greater than their own. - if (_gfxop_clip(&dirty, container->bounds)) + if (_gfxop_clip(&dirty, container->_bounds)) return 0; #endif - DDIRTY(stderr, "Effectively adding dirty %d,%d,%d,%d %d to ID %d\n", GFX_PRINT_RECT(dirty), propagate, container->ID); + DDIRTY(stderr, "Effectively adding dirty %d,%d,%d,%d %d to ID %d\n", GFX_PRINT_RECT(dirty), propagate, container->_ID); container->dirty = gfxdr_add_dirty(container->dirty, dirty, GFXW_DIRTY_STRATEGY); return 0; } @@ -1335,12 +1344,12 @@ static int _gfxwop_container_add(gfxw_container_t *container, gfxw_widget_t *wid return 1; if (!(GFXW_IS_LIST(widget) && (!GFXWC(widget)->contents))) { // Don't dirtify self on empty lists - DDIRTY(stderr, "container_add: dirtify DOWNWARDS (%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->bounds)); + DDIRTY(stderr, "container_add: dirtify DOWNWARDS (%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(widget->_bounds)); _gfxw_dirtify_container(container, widget); } *(container->nextpp) = widget; - container->nextpp = &(widget->next); + container->nextpp = &(widget->_next); return 0; } @@ -1353,7 +1362,7 @@ static int _gfxwop_list_draw(gfxw_widget_t *list, Common::Point pos) { _gfxwop_container_draw_contents(list, ((gfxw_list_t *)list)->contents); recursively_free_dirty_rects(GFXWC(list)->dirty); GFXWC(list)->dirty = NULL; - list->flags &= ~GFXW_FLAG_DIRTY; + list->_flags &= ~GFXW_FLAG_DIRTY; return 0; } @@ -1383,35 +1392,11 @@ static int _gfxwop_sorted_list_print(gfxw_widget_t *list, int indentation) { return _w_gfxwop_list_print(list, "SORTED_LIST", indentation); } -#if 0 -struct gfxw_widget_list { - gfxw_widget_t *widget; - struct gfxw_widget_list *next; -}; - -static struct gfxw_widtet_list *_gfxw_make_widget_list_recursive(gfxw_widget_t *widget) { - gfxw_widget_list *node; - - if (!widget) - return NULL; - - node = sci_malloc(sizeof(struct gfxw_widget_list)); - node->widget = widget; - node->next = _gfxw_make_widget_list_recursive(widget->next); - - return node; -} - -static struct gfxw_widget_list *_gfxw_make_widget_list(gfxw_container_t *container) { - return _gfxw_make_widget_list_recursive(container->contents); -} -#endif - static int _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { // Requires identical order of list elements. gfxw_list_t *wlist, *olist; - if (widget->type != other->type) + if (widget->_type != other->_type) return 0; if (!GFXW_IS_LIST(widget)) { @@ -1424,7 +1409,7 @@ static int _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { wlist = (gfxw_list_t *)widget; olist = (gfxw_list_t *)other; - if (memcmp(&(wlist->bounds), &(olist->bounds), sizeof(rect_t))) + if (memcmp(&(wlist->_bounds), &(olist->_bounds), sizeof(rect_t))) return 0; widget = wlist->contents; @@ -1434,8 +1419,8 @@ static int _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { if (!(widget->equals(widget, other) && !widget->should_replace(widget, other))) return 0; - widget = widget->next; - other = other->next; + widget = widget->_next; + other = other->_next; } return (!widget && !other); // True if both are finished now @@ -1444,13 +1429,13 @@ static int _gfxwop_list_equals(gfxw_widget_t *widget, gfxw_widget_t *other) { static int _gfxwop_list_add_dirty(gfxw_container_t *container, rect_t dirty, int propagate) { // Lists add dirty boxes to both themselves and their parenting port/visual - container->flags |= GFXW_FLAG_DIRTY; + container->_flags |= GFXW_FLAG_DIRTY; DDIRTY(stderr, "list_add_dirty %d,%d,%d,%d %d\n", GFX_PRINT_RECT(dirty), propagate); if (propagate) - if (container->parent) { + if (container->_parent) { DDIRTY(stderr, "->PROPAGATING\n"); - container->parent->add_dirty_abs(container->parent, dirty, 1); + container->_parent->add_dirty_abs(container->_parent, dirty, 1); } return _gfxwop_container_add_dirty(container, dirty, propagate); @@ -1460,7 +1445,7 @@ int _gfxwop_ordered_add(gfxw_container_t *container, gfxw_widget_t *widget, int // O(n) gfxw_widget_t **seekerp = &(container->contents); - if (widget->next) { + if (widget->_next) { GFXERROR("_gfxwop_sorted_list_add(): Attempt to add widget to two lists!\nWidget:"); widget->print(GFXW(widget), 3); sciprintf("\nList:"); @@ -1477,14 +1462,14 @@ int _gfxwop_ordered_add(gfxw_container_t *container, gfxw_widget_t *widget, int if (widget->equals(GFXW(widget), GFXW(*seekerp))) { if (compare_all) { - if ((*seekerp)->visual) + if ((*seekerp)->_visual) (*seekerp)->widfree(GFXW(*seekerp)); // If it's a fresh widget else gfxw_annihilate(GFXW(*seekerp)); return _gfxwop_ordered_add(container, widget, compare_all); // We might have destroyed the container's contents } else { - widget->next = (*seekerp)->next; + widget->_next = (*seekerp)->_next; (*seekerp)->widfree(GFXW(*seekerp)); *seekerp = widget; return (_parentize_widget(container, widget)); @@ -1492,10 +1477,10 @@ int _gfxwop_ordered_add(gfxw_container_t *container, gfxw_widget_t *widget, int } if (*seekerp) - seekerp = &((*seekerp)->next); + seekerp = &((*seekerp)->_next); } - widget->next = *seekerp; + widget->_next = *seekerp; *seekerp = widget; return _parentize_widget(container, widget); @@ -1517,14 +1502,17 @@ void _gfxw_set_ops_LIST(gfxw_container_t *list, char sorted) { } gfxw_list_t *gfxw_new_list(rect_t area, int sorted) { - gfxw_list_t *list = (gfxw_list_t *) _gfxw_new_container_widget(area, sizeof(gfxw_list_t), - sorted ? GFXW_SORTED_LIST : GFXW_LIST); + return new gfxw_list_t(area, sorted); +} - _gfxw_set_ops_LIST(GFXWC(list), (char)sorted); +gfxw_list_t::gfxw_list_t(rect_t area, bool sorted) + : gfxw_container_t(area, sorted ? GFXW_SORTED_LIST : GFXW_LIST) { - return list; + _gfxw_set_ops_LIST(this, sorted); } + + //*** Visuals *** static int _gfxwop_visual_draw(gfxw_widget_t *widget, Common::Point pos) { @@ -1549,7 +1537,7 @@ static int _gfxwop_visual_draw(gfxw_widget_t *widget, Common::Point pos) { recursively_free_dirty_rects(visual->dirty); visual->dirty = NULL; - widget->flags &= ~GFXW_FLAG_DIRTY; + widget->_flags &= ~GFXW_FLAG_DIRTY; return 0; } @@ -1580,7 +1568,7 @@ static int _gfxwop_visual_print(gfxw_widget_t *widget, int indentation) { gfxw_visual_t *visual = (gfxw_visual_t *) widget; if (!GFXW_IS_VISUAL(visual)) { - GFXERROR("_gfxwop_visual_free() called on non-visual!Widget was: "); + GFXERROR("_gfxwop_visual_print() called on non-visual!Widget was: "); widget->print(widget, 3); return 1; } @@ -1620,17 +1608,19 @@ void _gfxw_set_ops_VISUAL(gfxw_container_t *visual) { } gfxw_visual_t *gfxw_new_visual(gfx_state_t *state, int font) { - gfxw_visual_t *visual = (gfxw_visual_t *) _gfxw_new_container_widget(gfx_rect(0, 0, 320, 200), sizeof(gfxw_visual_t), GFXW_VISUAL); + return new gfxw_visual_t(state, font); +} - visual->font_nr = font; - visual->gfx_state = state; +gfxw_visual_t::gfxw_visual_t(gfx_state_t *state, int font) + : gfxw_container_t(gfx_rect(0, 0, 320, 200), GFXW_VISUAL) { - visual->port_refs_nr = 16; - visual->port_refs = (gfxw_port_t **)sci_calloc(sizeof(gfxw_port_t), visual->port_refs_nr); + font_nr = font; + gfx_state = state; - _gfxw_set_ops_VISUAL(GFXWC(visual)); + port_refs_nr = 16; + port_refs = (gfxw_port_t **)sci_calloc(sizeof(gfxw_port_t), port_refs_nr); // FIXME: Isn't this bogus??? - return visual; + _gfxw_set_ops_VISUAL(this); } static int _visual_find_free_ID(gfxw_visual_t *visual) { @@ -1642,7 +1632,7 @@ static int _visual_find_free_ID(gfxw_visual_t *visual) { if (id == visual->port_refs_nr) { // Out of ports? visual->port_refs_nr += newports; - visual->port_refs = (gfxw_port_t**)sci_realloc(visual->port_refs, visual->port_refs_nr); + visual->port_refs = (gfxw_port_t**)sci_realloc(visual->port_refs, visual->port_refs_nr); // FIXME: Isn't this bogus??? memset(visual->port_refs + id, 0, newports * sizeof(gfxw_port_t *)); // Clear new port refs } @@ -1650,7 +1640,7 @@ static int _visual_find_free_ID(gfxw_visual_t *visual) { } static int _gfxwop_add_dirty_rects(gfxw_container_t *dest, gfx_dirty_rect_t *src) { - DDIRTY(stderr, "Adding multiple dirty to #%d\n", dest->ID); + DDIRTY(stderr, "Adding multiple dirty to #%d\n", dest->_ID); if (src) { dest->dirty = gfxdr_add_dirty(dest->dirty, src->rect, GFXW_DIRTY_STRATEGY); _gfxwop_add_dirty_rects(dest, src->next); @@ -1679,7 +1669,7 @@ static int _gfxwop_port_draw(gfxw_widget_t *widget, Common::Point pos) { recursively_free_dirty_rects(port->dirty); port->dirty = NULL; - widget->flags &= ~GFXW_FLAG_DIRTY; + widget->_flags &= ~GFXW_FLAG_DIRTY; return 0; } @@ -1687,9 +1677,9 @@ static int _gfxwop_port_draw(gfxw_widget_t *widget, Common::Point pos) { static int _gfxwop_port_free(gfxw_widget_t *widget) { gfxw_port_t *port = (gfxw_port_t *) widget; - if (port->visual) { - gfxw_visual_t *visual = port->visual; - int ID = port->ID; + if (port->_visual) { + gfxw_visual_t *visual = port->_visual; + int ID = port->_ID; if (ID < 0 || ID >= visual->port_refs_nr) { GFXWARN("Attempt to free port #%d; allowed: [0..%d]!\n", ID, visual->port_refs_nr); @@ -1733,7 +1723,7 @@ static int _gfxwop_port_superarea_of(gfxw_widget_t *self, gfxw_widget_t *other) static int _gfxwop_port_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) { gfxw_list_t *decorations = ((gfxw_port_t *) widget)->decorations; - widget->visual = visual; + widget->_visual = visual; if (decorations) if (decorations->set_visual(GFXW(decorations), visual)) { @@ -1748,13 +1738,13 @@ static int _gfxwop_port_set_visual(gfxw_widget_t *widget, gfxw_visual_t *visual) static int _gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int propagate) { gfxw_port_t *self = (gfxw_port_t *) widget; - self->flags |= GFXW_FLAG_DIRTY; + self->_flags |= GFXW_FLAG_DIRTY; _gfxwop_container_add_dirty(widget, dirty, propagate); - DDIRTY(stderr, "Added dirty to ID %d\n", widget->ID); + DDIRTY(stderr, "Added dirty to ID %d\n", widget->_ID); DDIRTY(stderr, "dirty= (%d,%d,%d,%d) bounds (%d,%d,%d,%d)\n", dirty.x, dirty.x, dirty.width, dirty.height, - widget->bounds.x, widget->bounds.y, widget->bounds.width, widget->bounds.height); + widget->_bounds.x, widget->_bounds.y, widget->_bounds.width, widget->_bounds.height); #if 0 // FIXME: This is a worthwhile optimization if (self->port_bg) { @@ -1764,11 +1754,11 @@ static int _gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int pr foo.bounds.x -= self->zone.x; foo.bounds.y -= self->zone.y; if (self->port_bg->superarea_of(self->port_bg, &foo)) { - gfxw_container_t *parent = self->parent; + gfxw_container_t *parent = self->_parent; while (parent) { - fprintf(stderr, "Dirtifying parent id %d\n", parent->ID); - parent->flags |= GFXW_FLAG_DIRTY; - parent = parent->parent; + fprintf(stderr, "Dirtifying parent id %d\n", parent->_ID); + parent->_flags |= GFXW_FLAG_DIRTY; + parent = parent->_parent; } return 0; } @@ -1776,9 +1766,9 @@ static int _gfxwop_port_add_dirty(gfxw_container_t *widget, rect_t dirty, int pr #endif if (propagate) - if (self->parent) { + if (self->_parent) { DDIRTY(stderr, "PROPAGATE\n"); - return self->parent->add_dirty_abs(self->parent, dirty, 1); + return self->_parent->add_dirty_abs(self->_parent, dirty, 1); } return 0; @@ -1797,25 +1787,26 @@ void _gfxw_set_ops_PORT(gfxw_container_t *widget) { } gfxw_port_t *gfxw_new_port(gfxw_visual_t *visual, gfxw_port_t *predecessor, rect_t area, gfx_color_t fgcolor, gfx_color_t bgcolor) { - gfxw_port_t *widget = (gfxw_port_t *)_gfxw_new_container_widget(area, sizeof(gfxw_port_t), GFXW_PORT); - - VERIFY_WIDGET(visual); + return new gfxw_port_t(visual, area, fgcolor, bgcolor); +} - widget->port_bg = NULL; - widget->parent = NULL; - widget->decorations = NULL; - widget->title_text = NULL; - widget->draw_pos = Common::Point(0, 0); - widget->gray_text = 0; - widget->color = fgcolor; - widget->bgcolor = bgcolor; - widget->font_nr = visual->font_nr; - widget->ID = _visual_find_free_ID(visual); - visual->port_refs[widget->ID] = widget; +gfxw_port_t::gfxw_port_t(gfxw_visual_t *visual_, rect_t area, gfx_color_t fgcolor, gfx_color_t bgcolor_) + : gfxw_container_t(area, GFXW_PORT) { + VERIFY_WIDGET(visual_); - _gfxw_set_ops_PORT(GFXWC(widget)); + port_bg = NULL; + _parent = NULL; + decorations = NULL; + title_text = NULL; + draw_pos = Common::Point(0, 0); + gray_text = 0; + _color = fgcolor; + _bgcolor = bgcolor_; + font_nr = visual_->font_nr; + _ID = _visual_find_free_ID(visual_); + visual_->port_refs[_ID] = this; - return widget; + _gfxw_set_ops_PORT(this); } void gfxw_port_auto_restore_background(gfxw_visual_t *visual, gfxw_port_t *window, rect_t auto_rect) { @@ -1833,7 +1824,7 @@ gfxw_port_t *gfxw_remove_port(gfxw_visual_t *visual, gfxw_port_t *port) { return NULL; } - parent = (gfxw_port_t *)port->parent; + parent = (gfxw_port_t *)port->_parent; if (port->port_flags & kWindowAutoRestore) gfxw_restore_snapshot(visual, port->restore_snap); @@ -1841,7 +1832,7 @@ gfxw_port_t *gfxw_remove_port(gfxw_visual_t *visual, gfxw_port_t *port) { return parent; while (parent && !GFXW_IS_PORT(parent)) - parent = (gfxw_port_t *)parent->parent; // Ascend through ancestors + parent = (gfxw_port_t *)parent->_parent; // Ascend through ancestors return parent; } @@ -1870,8 +1861,8 @@ gfxw_port_t *gfxw_find_default_port(gfxw_visual_t *visual) { gfxw_widget_t *gfxw_set_id(gfxw_widget_t *widget, int ID, int subID) { if (widget) { - widget->ID = ID; - widget->subID = subID; + widget->_ID = ID; + widget->_subID = subID; } return widget; @@ -1893,40 +1884,40 @@ gfxw_widget_t *gfxw_remove_id(gfxw_container_t *container, int ID, int subID) { gfxw_widget_t **wp = &(container->contents); while (*wp) { - if ((*wp)->ID == ID && (subID == GFXW_NO_ID || (*wp)->subID == subID)) { + if ((*wp)->_ID == ID && (subID == GFXW_NO_ID || (*wp)->_subID == subID)) { gfxw_widget_t *widget = *wp; - *wp = (*wp)->next; - widget->next = NULL; - widget->parent = NULL; - widget->visual = NULL; + *wp = (*wp)->_next; + widget->_next = NULL; + widget->_parent = NULL; + widget->_visual = NULL; return widget; } - wp = &((*wp)->next); + wp = &((*wp)->_next); } return NULL; } gfxw_widget_t *gfxw_hide_widget(gfxw_widget_t *widget) { - if (widget->flags & GFXW_FLAG_VISIBLE) { - widget->flags &= ~GFXW_FLAG_VISIBLE; + if (widget->_flags & GFXW_FLAG_VISIBLE) { + widget->_flags &= ~GFXW_FLAG_VISIBLE; - if (widget->parent) - widget->parent->add_dirty_rel(widget->parent, widget->bounds, 1); + if (widget->_parent) + widget->_parent->add_dirty_rel(widget->_parent, widget->_bounds, 1); } return widget; } gfxw_widget_t *gfxw_show_widget(gfxw_widget_t *widget) { - if (!(widget->flags & GFXW_FLAG_VISIBLE)) { - widget->flags |= GFXW_FLAG_VISIBLE; + if (!(widget->_flags & GFXW_FLAG_VISIBLE)) { + widget->_flags |= GFXW_FLAG_VISIBLE; - if (widget->parent) - widget->parent->add_dirty_rel(widget->parent, widget->bounds, 1); + if (widget->_parent) + widget->_parent->add_dirty_rel(widget->_parent, widget->_bounds, 1); } return widget; @@ -1941,7 +1932,8 @@ gfxw_snapshot_t *gfxw_make_snapshot(gfxw_visual_t *visual, rect_t area) { // Work around subset semantics in gfx_rect_subset. // This fixes the help icon in LSL5. */ - if (retval->area.width == 320) retval->area.width = 321; + if (retval->area.width == 320) + retval->area.width = 321; return retval; } @@ -1949,18 +1941,18 @@ gfxw_snapshot_t *gfxw_make_snapshot(gfxw_visual_t *visual, rect_t area) { int gfxw_widget_matches_snapshot(gfxw_snapshot_t *snapshot, gfxw_widget_t *widget) { int free_below = (snapshot->serial < widget_serial_number_counter) ? 0 : widget_serial_number_counter; int free_above_eq = snapshot->serial; - rect_t bounds = widget->bounds; + rect_t bounds = widget->_bounds; - if (!GFXW_IS_CONTAINER(widget) && widget->parent) { - bounds.x += widget->parent->bounds.x; - bounds.y += widget->parent->bounds.y; + if (!GFXW_IS_CONTAINER(widget) && widget->_parent) { + bounds.x += widget->_parent->_bounds.x; + bounds.y += widget->_parent->_bounds.y; } // Note: the check for snapshot->area and bounds is NOT the same as contains() in Common::Rect // (this one includes equality too) - return ((widget->serial >= free_above_eq || widget->serial < free_below) && + return ((widget->_serial >= free_above_eq || widget->_serial < free_below) && (snapshot->area.x <= bounds.x && snapshot->area.y <= bounds.y && - snapshot->area.x + snapshot->area.width >= bounds.x + bounds.width && + snapshot->area.x + snapshot->area.width >= bounds.x + bounds.width && snapshot->area.y + snapshot->area.height >= bounds.y + bounds.height)); } @@ -1970,10 +1962,10 @@ void _gfxw_free_contents_appropriately(gfxw_container_t *container, gfxw_snapsho gfxw_widget_t *widget = container->contents; while (widget) { - gfxw_widget_t *next = widget->next; + gfxw_widget_t *next = widget->_next; - if (gfxw_widget_matches_snapshot(snapshot, widget) && !(widget->flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) - && (priority == MAGIC_FREE_NUMBER || priority <= widget->widget_priority || widget->widget_priority == -1)) { + if (gfxw_widget_matches_snapshot(snapshot, widget) && !(widget->_flags & GFXW_FLAG_IMMUNE_TO_SNAPSHOTS) + && (priority == MAGIC_FREE_NUMBER || priority <= widget->_widgetPriority || widget->_widgetPriority == -1)) { widget->widfree(widget); } else { if (GFXW_IS_CONTAINER(widget)) @@ -1991,18 +1983,18 @@ gfxw_snapshot_t *gfxw_restore_snapshot(gfxw_visual_t *visual, gfxw_snapshot_t *s } void gfxw_annihilate(gfxw_widget_t *widget) { - gfxw_visual_t *visual = widget->visual; + gfxw_visual_t *visual = widget->_visual; int widget_priority = 0; int free_overdrawn = 0; gfxw_snapshot_t snapshot; - if (!GFXW_IS_CONTAINER(widget) && widget->parent && visual && (widget->flags & GFXW_FLAG_VISIBLE)) { + if (!GFXW_IS_CONTAINER(widget) && widget->_parent && visual && (widget->_flags & GFXW_FLAG_VISIBLE)) { snapshot.serial = 0; - snapshot.area = widget->bounds; - snapshot.area.x += widget->parent->zone.x; - snapshot.area.y += widget->parent->zone.y; + snapshot.area = widget->_bounds; + snapshot.area.x += widget->_parent->zone.x; + snapshot.area.y += widget->_parent->zone.y; free_overdrawn = 1; - widget_priority = widget->widget_priority; + widget_priority = widget->_widgetPriority; } widget->widfree(GFXW(widget)); @@ -2012,13 +2004,13 @@ void gfxw_annihilate(gfxw_widget_t *widget) { } gfxw_dyn_view_t *gfxw_picviewize_dynview(gfxw_dyn_view_t *dynview) { - dynview->type = GFXW_PIC_VIEW; - dynview->flags |= GFXW_FLAG_DIRTY; + dynview->_type = GFXW_PIC_VIEW; + dynview->_flags |= GFXW_FLAG_DIRTY; _gfxw_set_ops_PICVIEW(GFXW(dynview)); - if (dynview->parent) - _gfxw_dirtify_container(dynview->parent, GFXW(dynview)); + if (dynview->_parent) + _gfxw_dirtify_container(dynview->_parent, GFXW(dynview)); return dynview; } diff --git a/engines/sci/gfx/gfx_widgets.h b/engines/sci/gfx/gfx_widgets.h index 3cae3afb0e..7800227e4b 100644 --- a/engines/sci/gfx/gfx_widgets.h +++ b/engines/sci/gfx/gfx_widgets.h @@ -39,7 +39,7 @@ struct gfx_state_t; struct gfxw_box_t; struct gfxw_dyn_view_t; struct gfxw_container_t; -typedef gfxw_container_t gfxw_list_t; +struct gfxw_list_t; struct gfxw_port_t; struct gfxw_primitive_t; struct gfxw_snapshot_t; @@ -82,7 +82,7 @@ struct gfxw_widget_t; /*********************************/ -#define GFXW(foo) ((gfxw_widget_t *) foo) +#define GFXW(foo) (foo) /* Typecast an arbitrary widget to gfxw_widget_t*. Might eventually be changed to do tests as well. */ #define GFXWC(foo) ((gfxw_container_t *) foo) diff --git a/engines/sci/gfx/menubar.cpp b/engines/sci/gfx/menubar.cpp index 57b837085e..cbd27b9573 100644 --- a/engines/sci/gfx/menubar.cpp +++ b/engines/sci/gfx/menubar.cpp @@ -416,7 +416,7 @@ bool Menubar::mapPointer(const Common::Point &pointerPos, int &menu_nr, int &ite if ((int)menu._items.size() <= row) return true; - if ((pointerPos.x < port->bounds.x) || (pointerPos.x > port->bounds.x + port->bounds.width)) + if ((pointerPos.x < port->_bounds.x) || (pointerPos.x > port->_bounds.x + port->_bounds.width)) return true; if (itemValid(menu_nr, row)) |