[Scummvm-cvs-logs] SF.net SVN: scummvm:[40108] scummvm/trunk/engines/sci

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Fri Apr 24 12:48:51 CEST 2009


Revision: 40108
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40108&view=rev
Author:   fingolfin
Date:     2009-04-24 10:48:51 +0000 (Fri, 24 Apr 2009)

Log Message:
-----------
SCI: Changed GfxWidget::set_visual function pointer to virtual method setVisual

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kpathing.cpp
    scummvm/trunk/engines/sci/gfx/gfx_gui.cpp
    scummvm/trunk/engines/sci/gfx/gfx_state_internal.h
    scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp
    scummvm/trunk/engines/sci/gfx/gfx_widgets.h

Modified: scummvm/trunk/engines/sci/engine/kpathing.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-04-24 10:48:25 UTC (rev 40107)
+++ scummvm/trunk/engines/sci/engine/kpathing.cpp	2009-04-24 10:48:51 UTC (rev 40108)
@@ -319,7 +319,7 @@
 	// Yellow: Contained access
 	int poly_colors[][3] = {{0, 255, 0}, {0, 0, 255}, {255, 0, 0}, {255, 255, 0}};
 	gfx_color_t col;
-	GfxList *decorations = s->picture_port->decorations;
+	GfxList *decorations = s->picture_port->_decorations;
 	GfxPrimitive *line;
 
 	col.visual = PaletteEntry(poly_colors[type][0], poly_colors[type][1], poly_colors[type][2]);
@@ -341,7 +341,7 @@
 	// Blue: Starting point
 	int point_colors[][3] = {{0, 255, 0}, {0, 0, 255}};
 	gfx_color_t col;
-	GfxList *decorations = s->picture_port->decorations;
+	GfxList *decorations = s->picture_port->_decorations;
 	GfxBox *box;
 
 	col.visual = PaletteEntry(point_colors[start][0], point_colors[start][1], point_colors[start][2]);
@@ -351,7 +351,7 @@
 	col.mask = GFX_MASK_VISUAL | GFX_MASK_PRIORITY;
 
 	box = gfxw_new_box(s->gfx_state, gfx_rect(p.x - 1, p.y - 1 + 10, 3, 3), col, col, GFX_BOX_SHADE_FLAT);
-	decorations->add((GfxContainer *) decorations, (GfxWidget *) box);
+	decorations->add((GfxContainer *)decorations, (GfxWidget *)box);
 }
 
 static void draw_polygon(EngineState *s, reg_t polygon) {
@@ -1541,11 +1541,11 @@
 	if (s->debug_mode & (1 << SCIkAVOIDPATH_NR)) {
 		GfxPort *port = s->picture_port;
 
-		if (!port->decorations) {
-			port->decorations = gfxw_new_list(gfx_rect(0, 0, 320, 200), 0);
-			port->decorations->set_visual(port->decorations, port->_visual);
+		if (!port->_decorations) {
+			port->_decorations = gfxw_new_list(gfx_rect(0, 0, 320, 200), 0);
+			port->_decorations->setVisual(port->_visual);
 		} else {
-			port->decorations->free_contents(port->decorations);
+			port->_decorations->free_contents(port->_decorations);
 		}
 	}
 

Modified: scummvm/trunk/engines/sci/gfx/gfx_gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_gui.cpp	2009-04-24 10:48:25 UTC (rev 40107)
+++ scummvm/trunk/engines/sci/gfx/gfx_gui.cpp	2009-04-24 10:48:51 UTC (rev 40108)
@@ -84,7 +84,7 @@
 		return;
 	}
 
-	state = status_bar->_visual->gfx_state;
+	state = status_bar->_visual->_gfxState;
 
 	if (!state) {
 		GFXERROR("Attempt to change title bar with stateless visual!\n");
@@ -198,7 +198,7 @@
 		// Draw window background
 		win->port_bg = (GfxWidget *)gfxw_new_box(state, gfx_rect(1, (flags & kWindowTitle) ? 10 : 1,
 		                        area.width, area.height), bgcolor, bgcolor, GFX_BOX_SHADE_FLAT);
-		decorations->add((GfxContainer *) decorations, win->port_bg);
+		decorations->add((GfxContainer *)decorations, win->port_bg);
 		win->_flags |= GFXW_FLAG_OPAQUE;
 	}
 
@@ -253,7 +253,7 @@
 		}
 	}
 
-	win->decorations = decorations;
+	win->_decorations = decorations;
 	decorations->_parent = GFXWC(win);
 
 	return win;
@@ -280,7 +280,7 @@
 		bgcolor = &(port->_bgcolor);
 	}
 
-	list->add(GFXWC(list), gfxw_new_text(port->_visual->gfx_state, zone, font, text, align, ALIGN_TOP,
+	list->add(GFXWC(list), gfxw_new_text(port->_visual->_gfxState, zone, font, text, align, ALIGN_TOP,
 	                            *color1, *color2, *bgcolor, flags));
 
 	zone.width--;
@@ -348,7 +348,7 @@
 	GfxText *text_handle;
 
 	GfxList *list;
-	int cursor_height = gfxop_get_font_height(port->_visual->gfx_state, font);
+	int cursor_height = gfxop_get_font_height(port->_visual->_gfxState, font);
 
 	zone.x--;
 	zone.y--;
@@ -361,7 +361,7 @@
 	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,
+		text_handle = gfxw_new_text(port->_visual->_gfxState, zone, font, text, ALIGN_LEFT, ALIGN_TOP,
 		                            port->_color, port->_color, port->_bgcolor, kFontNoNewlines);
 
 		list->add(GFXWC(list), text_handle);
@@ -374,7 +374,7 @@
 			textdup[cursor] = 0; // terminate
 
 		if (cursor > 0) {
-			text_handle = gfxw_new_text(port->_visual->gfx_state, zone, font, textdup, ALIGN_LEFT, ALIGN_TOP,
+			text_handle = gfxw_new_text(port->_visual->_gfxState, zone, font, textdup, ALIGN_LEFT, ALIGN_TOP,
 			                            port->_color, port->_color, port->_bgcolor, kFontNoNewlines);
 
 			list->add(GFXWC(list), text_handle);
@@ -384,14 +384,14 @@
 		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,
+			text_handle =  gfxw_new_text(port->_visual->_gfxState, zone, font, textdup, ALIGN_LEFT, ALIGN_TOP,
 			                             port->_bgcolor, port->_bgcolor, port->_color, kFontNoNewlines);
 			list->add(GFXWC(list), 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,
+			text_handle = gfxw_new_text(port->_visual->_gfxState, zone, font, text + cursor + 1, ALIGN_LEFT, ALIGN_TOP,
 			                            port->_color, port->_color, port->_bgcolor, kFontNoNewlines);
 			list->add(GFXWC(list), text_handle);
 			zone.x += text_handle->width;
@@ -424,7 +424,7 @@
 	zone.x = 0;
 	zone.y = 0;
 
-	icon = gfxw_new_view(port->_visual->gfx_state, Common::Point(zone.x, zone.y), view, loop, cel, 0, -1, -1,
+	icon = gfxw_new_view(port->_visual->_gfxState, Common::Point(zone.x, zone.y), view, loop, cel, 0, -1, -1,
 	                          ALIGN_LEFT, ALIGN_TOP, GFXW_VIEW_FLAG_DONT_MODIFY_OFFSET);
 
 	if (!icon) {
@@ -456,7 +456,7 @@
 
 	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->_gfxState, font_nr);
 	columns = (zone.height - 20);
 
 	if (font_height <= 0) {
@@ -481,13 +481,13 @@
 	for (i = list_top; columns-- && i < entries_nr; i++) {
 		if (i != selection)
 			list->add(GFXWC(list),
-			          gfxw_new_text(port->_visual->gfx_state, gfx_rect(zone.x, zone.y, zone.width - 2, font_height),
+			          gfxw_new_text(port->_visual->_gfxState, 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));
 		else {
-			list->add(GFXWC(list), gfxw_new_box(port->_visual->gfx_state, gfx_rect(zone.x, zone.y, zone.width - 1, font_height),
+			list->add(GFXWC(list), gfxw_new_box(port->_visual->_gfxState, gfx_rect(zone.x, zone.y, zone.width - 1, font_height),
 			                            port->_color, port->_color, GFX_BOX_SHADE_FLAT));
-			list->add(GFXWC(list), gfxw_new_text(port->_visual->gfx_state, gfx_rect(zone.x, zone.y, zone.width - 2, font_height),
+			list->add(GFXWC(list), gfxw_new_text(port->_visual->_gfxState, 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));
 		}
@@ -501,12 +501,12 @@
 	zone.y = 0;
 
 	// Add up arrow
-	list->add(GFXWC(list), gfxw_new_text(port->_visual->gfx_state, gfx_rect(1, 0, zone.width - 2, 8),
+	list->add(GFXWC(list), gfxw_new_text(port->_visual->_gfxState, gfx_rect(1, 0, zone.width - 2, 8),
 	                             port->_font, arr_up, ALIGN_CENTER, ALIGN_CENTER,
 	                             port->_color, port->_color, port->_bgcolor, 0));
 
 	// Add down arrow
-	list->add(GFXWC(list), gfxw_new_text(port->_visual->gfx_state, gfx_rect(1, zone.height - 9, zone.width - 2, 8),
+	list->add(GFXWC(list), gfxw_new_text(port->_visual->_gfxState, gfx_rect(1, zone.height - 9, zone.width - 2, 8),
 	                             port->_font, arr_down, ALIGN_CENTER, ALIGN_CENTER,
 	                             port->_color, port->_color, port->_bgcolor, 0));
 
@@ -538,7 +538,7 @@
 		int width = menu->_titleWidth + (MENU_BORDER_SIZE * 2);
 
 		if (i == selection) {
-			list->add(GFXWC(list), gfxw_new_box(status_bar->_visual->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT),
+			list->add(GFXWC(list), gfxw_new_box(status_bar->_visual->_gfxState, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT),
 			                            status_bar->_color, status_bar->_color, GFX_BOX_SHADE_FLAT));
 			list->add(GFXWC(list), gfxw_new_text(s->gfx_state, gfx_rect(offset, 0, width, MENU_BAR_HEIGHT),
 			                             status_bar->_font, menu->_title.c_str(), ALIGN_CENTER, ALIGN_CENTER,
@@ -577,7 +577,7 @@
 	retval = sciw_new_window(s, area, status_bar->_font, status_bar->_color, status_bar->_bgcolor,
 	                         0, status_bar->_color, status_bar->_bgcolor, NULL, kWindowNoDropShadow | kWindowTransparent);
 
-	retval->set_visual(retval, s->visual);
+	retval->setVisual(s->visual);
 
 	for (i = 0; i < (int)menu->_items.size(); i++)
 		sciw_toggle_item(retval, menu, i, false);
@@ -605,13 +605,13 @@
 
 	xcolor = gray ? color : bgcolor;
 
-	list->add(GFXWC(list), gfxw_new_box(port->_visual->gfx_state, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT));
-	list->add(GFXWC(list), gfxw_new_text(port->_visual->gfx_state, area, port->_font, item->_text.c_str(), ALIGN_LEFT, ALIGN_CENTER,
+	list->add(GFXWC(list), gfxw_new_box(port->_visual->_gfxState, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT));
+	list->add(GFXWC(list), gfxw_new_text(port->_visual->_gfxState, area, port->_font, 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_new_text(port->_visual->gfx_state, area, port->_font, item->_keytext.c_str(), ALIGN_RIGHT, ALIGN_CENTER,
+		list->add(GFXWC(list), gfxw_new_text(port->_visual->_gfxState, area, port->_font, item->_keytext.c_str(), ALIGN_RIGHT, ALIGN_CENTER,
 		                            color, xcolor, bgcolor, kFontNoNewlines));
 	}
 
@@ -626,7 +626,7 @@
 	color = un_prioritize(color);
 	bgcolor = un_prioritize(bgcolor);
 
-	list->add(GFXWC(list), gfxw_new_box(port->_visual->gfx_state, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT));
+	list->add(GFXWC(list), gfxw_new_box(port->_visual->_gfxState, area, bgcolor, bgcolor, GFX_BOX_SHADE_FLAT));
 	list->add(GFXWC(list), gfxw_new_line(Common::Point(0, 5), Common::Point(width, 5), color,
 	                            GFX_LINE_MODE_FAST, GFX_LINE_STYLE_STIPPLED));
 

Modified: scummvm/trunk/engines/sci/gfx/gfx_state_internal.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_state_internal.h	2009-04-24 10:48:25 UTC (rev 40107)
+++ scummvm/trunk/engines/sci/gfx/gfx_state_internal.h	2009-04-24 10:48:51 UTC (rev 40108)
@@ -81,7 +81,6 @@
 struct GfxPort;
 
 typedef int gfxw_point_op(GfxWidget *, Common::Point);
-typedef int gfxw_visual_op(GfxWidget *, GfxVisual *);
 typedef int gfxw_op(GfxWidget *);
 typedef int gfxw_op_int(GfxWidget *, int);
 typedef int gfxw_bin_op(GfxWidget *, GfxWidget *);
@@ -100,6 +99,15 @@
 	int _widgetPriority; /* Drawing priority, or -1 */
 
 public:
+	GfxWidget(gfxw_widget_type_t type);
+
+	/*
+	 * The widget automatically removes itself from its owner, if it has one.
+	 * Deleting a container will recursively free all of its
+	 * contents.
+	 */
+	virtual ~GfxWidget();
+
 	// 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 *tag; /* Tag the specified widget */
@@ -108,17 +116,13 @@
 	gfxw_bin_op *equals; /* a equals b if both cause the same data to be displayed */
 	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 */
 
-public:
-	GfxWidget(gfxw_widget_type_t type);
-
-	/*
-	 * The widget automatically removes itself from its owner, if it has one.
-	 * Deleting a container will recursively free all of its
-	 * contents.
+	/**
+	 * Sets the visual for the widget
+	 * This function is called by container->add() and need not be invoked explicitly.
+	 * It also makes sure that dirty rectangles are passed to parent containers.
 	 */
-	virtual ~GfxWidget();
+	virtual int setVisual(GfxVisual *);
 };
 
 
@@ -210,8 +214,11 @@
 	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) */
 
+	// FIXME: This should be a virtual base class, mark it so somehow?
 	GfxContainer(rect_t area, gfxw_widget_type_t type);
 	~GfxContainer();
+
+	virtual int setVisual(GfxVisual *);
 };
 
 
@@ -229,14 +236,17 @@
 struct GfxVisual : public GfxContainer {
 	Common::Array<GfxPort *> _portRefs; /* References to ports */
 	int _font; /* Default font */
-	gfx_state_t *gfx_state;
+	gfx_state_t *_gfxState;
 
+public:
 	GfxVisual(gfx_state_t *state, int font);
+
+	virtual int setVisual(GfxVisual *);
 };
 
 #define GFXW_IS_PORT(widget) ((widget)->_type == GFXW_PORT)
 struct GfxPort : public GfxContainer {
-	GfxList *decorations; /* optional window decorations- drawn before the contents */
+	GfxList *_decorations; /* optional window decorations- drawn before the contents */
 	GfxWidget *port_bg; /* Port background widget or NULL */
 	gfx_color_t _color, _bgcolor;
 	int _font;
@@ -247,8 +257,11 @@
 	const char *title_text;
 	byte gray_text; /* Whether text is 'grayed out' (dithered) */
 
+public:
 	GfxPort(GfxVisual *visual, rect_t area, gfx_color_t fgcolor, gfx_color_t bgcolor);
 	~GfxPort();
+
+	virtual int setVisual(GfxVisual *);
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp	2009-04-24 10:48:25 UTC (rev 40107)
+++ scummvm/trunk/engines/sci/gfx/gfx_widgets.cpp	2009-04-24 10:48:51 UTC (rev 40108)
@@ -152,7 +152,6 @@
 	equals = NULL;
 	should_replace = NULL;
 	superarea_of = NULL;
-	set_visual = NULL;
 
 	_gfxw_debug_add_widget(this);
 }
@@ -244,12 +243,12 @@
 	return 1;
 }
 
-static int _gfxwop_basic_set_visual(GfxWidget *widget, GfxVisual *visual) {
-	widget->_visual = visual;
+int GfxWidget::setVisual(GfxVisual *visual) {
+	_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 (_parent) {
+		DDIRTY(stderr, "GfxWidget::setVisual: DOWNWARDS rel(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(_bounds));
+		_parent->add_dirty_rel(_parent, _bounds, 1);
 	}
 
 	return 0;
@@ -269,7 +268,6 @@
 	widget->superarea_of = superarea_of;
 
 	widget->should_replace = _gfxwop_basic_should_replace;
-	widget->set_visual = _gfxwop_basic_set_visual;
 }
 
 void gfxw_remove_widget_from_container(GfxContainer *container, GfxWidget *widget) {
@@ -284,8 +282,8 @@
 
 	if (GFXW_IS_LIST(widget) && GFXW_IS_PORT(container)) {
 		GfxPort *port = (GfxPort *) container;
-		if (port->decorations == (GfxList *) widget) {
-			port->decorations = NULL;
+		if (port->_decorations == (GfxList *) widget) {
+			port->_decorations = NULL;
 			return;
 		}
 	}
@@ -365,7 +363,7 @@
 static int _gfxwop_box_draw(GfxWidget *widget, Common::Point pos) {
 	GfxBox *box = (GfxBox *) 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->_shadeType));
+	GFX_ASSERT(gfxop_draw_box(box->_visual->_gfxState, _move_rect(box->_bounds, pos), box->_color1, box->_color2, box->_shadeType));
 
 	return 0;
 }
@@ -496,7 +494,7 @@
 	GfxPrimitive *rect = (GfxPrimitive *) 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,
+	GFX_ASSERT(gfxop_draw_rectangle(rect->_visual->_gfxState, 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;
 }
@@ -543,7 +541,7 @@
 	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->_lineMode, line->_lineStyle));
+	GFX_ASSERT(gfxop_draw_line(line->_visual->_gfxState, p1, p2, line->_color, line->_lineMode, line->_lineStyle));
 	return 0;
 }
 
@@ -615,7 +613,7 @@
 	GfxView *view = (GfxView *)widget;
 	DRAW_ASSERT(widget, GFXW_VIEW);
 
-	GFX_ASSERT(gfxop_draw_cel(view->_visual->gfx_state, view->_view, view->_loop, view->_cel,
+	GFX_ASSERT(gfxop_draw_cel(view->_visual->_gfxState, view->_view, view->_loop, view->_cel,
 				Common::Point(view->_pos.x + pos.x, view->_pos.y + pos.y), view->_color, view->_palette));
 
 	return 0;
@@ -625,7 +623,7 @@
 	GfxView *view = (GfxView *)widget;
 	DRAW_ASSERT(widget, GFXW_VIEW);
 
-	GFX_ASSERT(gfxop_draw_cel_static(view->_visual->gfx_state, view->_view, view->_loop,
+	GFX_ASSERT(gfxop_draw_cel_static(view->_visual->_gfxState, view->_view, view->_loop,
 	                                 view->_cel, _move_point(view->_bounds, pos), view->_color, view->_palette));
 
 	return 0;
@@ -683,7 +681,7 @@
 	GfxDynView *view = (GfxDynView *) widget;
 	DRAW_ASSERT(widget, GFXW_DYN_VIEW);
 
-	GFX_ASSERT(gfxop_draw_cel(view->_visual->gfx_state, view->_view, view->_loop,
+	GFX_ASSERT(gfxop_draw_cel(view->_visual->_gfxState, view->_view, view->_loop,
 	                          view->_cel, _move_point(view->draw_bounds, pos), view->_color, view->_palette));
 
 	/*
@@ -691,7 +689,7 @@
 	  red.visual.r = 0xff;
 	  red.visual.g = red.visual.b = 0;
 	  red.mask = GFX_MASK_VISUAL;
-	  GFX_ASSERT(gfxop_draw_rectangle(view->visual->gfx_state,
+	  GFX_ASSERT(gfxop_draw_rectangle(view->visual->_gfxState,
 	  gfx_rect(view->_bounds.x + pos.x, view->_bounds.y + pos.y, view->_bounds.width - 1, view->_bounds.height - 1), red, 0, 0));
 	*/
 
@@ -707,12 +705,12 @@
 	GfxDynView *view = (GfxDynView *) 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,
+	GFX_ASSERT(gfxop_set_clip_zone(view->_visual->_gfxState, view->_parent->zone));
+	GFX_ASSERT(gfxop_draw_cel_static_clipped(view->_visual->_gfxState, 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,
+	GFX_ASSERT(gfxop_draw_cel(view->_visual->_gfxState, view->_view, view->_loop, view->_cel,
 	                          _move_point(view->draw_bounds, pos), view->_color, view->_palette));
 
 
@@ -873,7 +871,7 @@
 	text = NULL;
 
 	if (text_handle) {
-		gfx_state_t *state = _visual ? _visual->gfx_state : NULL;
+		gfx_state_t *state = _visual ? _visual->_gfxState : NULL;
 		if (!state) {
 			GFXERROR("Attempt to free text without supplying mode to free it from!\n");
 			BREAKPOINT();
@@ -888,7 +886,7 @@
 	GfxText *text = (GfxText *)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->_gfxState, text->text_handle, _move_rect(text->_bounds, pos)));
 
 	return 0;
 }
@@ -897,7 +895,7 @@
 	GfxText *text = (GfxText *)widget;
 	DRAW_ASSERT(widget, GFXW_TEXT);
 
-	text->text_handle = gfxop_new_text(widget->_visual->gfx_state, text->_font, text->text, text->_bounds.width,
+	text->text_handle = gfxop_new_text(widget->_visual->_gfxState, text->_font, text->text, text->_bounds.width,
 	                   text->halign, text->valign, text->_color1, text->_color2, text->_bgcolor, text->text_flags);
 
 	text->draw = _gfxwop_text_draw;
@@ -1020,7 +1018,7 @@
 
 static void _gfxw_set_container_ops(GfxContainer *container, gfxw_point_op *draw, gfxw_op *tag,
 	gfxw_op_int *print, gfxw_bin_op *compare_to, gfxw_bin_op *equals,
-	gfxw_bin_op *superarea_of, gfxw_visual_op *set_visual,
+	gfxw_bin_op *superarea_of,
 	gfxw_unary_container_op *free_tagged, gfxw_unary_container_op *free_contents,
 	gfxw_rect_op *add_dirty, gfxw_container_op *add) {
 	_gfxw_set_ops(container, draw, tag, print, compare_to, equals, superarea_of);
@@ -1030,7 +1028,6 @@
 	container->add_dirty_abs = add_dirty;
 	container->add_dirty_rel = _gfxwop_container_add_dirty_rel;
 	container->add = add;
-	container->set_visual = set_visual;
 }
 
 static int _w_gfxwop_container_print_contents(const char *name, GfxWidget *widget, int indentation) {
@@ -1109,7 +1106,7 @@
 static int _gfxwop_container_draw_contents(GfxWidget *widget, GfxWidget *contents) {
 	GfxContainer *container = (GfxContainer *)widget;
 	gfx_dirty_rect_t *dirty = container->dirty;
-	gfx_state_t *gfx_state = (widget->_visual) ? widget->_visual->gfx_state : ((GfxVisual *) widget)->gfx_state;
+	gfx_state_t *gfx_state = (widget->_visual) ? widget->_visual->_gfxState : ((GfxVisual *) widget)->_gfxState;
 	int draw_ports;
 	rect_t nullzone = {0, 0, 0, 0};
 
@@ -1203,24 +1200,22 @@
 
 static int _w_gfxwop_container_set_visual_contents(GfxWidget *contents, GfxVisual *visual) {
 	while (contents) {
-		contents->set_visual(contents, visual);
+		contents->setVisual(visual);
 		contents = contents->_next;
 	}
 	return 0;
 }
 
-static int _gfxwop_container_set_visual(GfxWidget *widget, GfxVisual *visual) {
-	GfxContainer *container = (GfxContainer *) widget;
-
-	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);
+int GfxContainer::setVisual(GfxVisual *visual) {
+	_visual = visual;
+	if (_parent) {
+		if (!(GFXW_IS_LIST(this) && !GFXWC(this)->contents)) {
+			DDIRTY(stderr, "set_visual::DOWNWARDS abs(%d,%d,%d,%d, 1)\n", GFX_PRINT_RECT(_bounds));
+			_parent->add_dirty_abs(_parent, _bounds, 1);
 		}
 	}
 
-	return _w_gfxwop_container_set_visual_contents(container->contents, visual);
+	return _w_gfxwop_container_set_visual_contents(contents, visual);
 }
 
 static int _gfxwop_container_free_tagged(GfxContainer *container) {
@@ -1270,9 +1265,9 @@
 	widget->_parent = GFXWC(container);
 
 	if (GFXW_IS_VISUAL(container))
-		widget->set_visual(widget, (GfxVisual *) container);
+		widget->setVisual((GfxVisual *)container);
 	else if (container->_visual)
-		widget->set_visual(widget, container->_visual);
+		widget->setVisual(container->_visual);
 
 	return 0;
 }
@@ -1476,7 +1471,7 @@
 	                        _gfxwop_container_tag,
 	                        sorted ? _gfxwop_sorted_list_print : _gfxwop_list_print,
 	                        _gfxwop_basic_compare_to, sorted ? _gfxwop_basic_equals : _gfxwop_list_equals,
-	                        _gfxwop_basic_superarea_of, _gfxwop_container_set_visual,
+	                        _gfxwop_basic_superarea_of,
 	                        _gfxwop_container_free_tagged, _gfxwop_container_free_contents,
 	                        _gfxwop_list_add_dirty, sorted ? _gfxwop_sorted_list_add : _gfxwop_container_add);
 }
@@ -1501,7 +1496,7 @@
 	DRAW_ASSERT(widget, GFXW_VISUAL);
 
 	while (dirty) {
-		int err = gfxop_clear_box(visual->gfx_state, dirty->rect);
+		int err = gfxop_clear_box(visual->_gfxState, dirty->rect);
 
 		if (err) {
 			GFXERROR("Error while clearing dirty rect (%d,%d,(%dx%d))\n", dirty->rect.x,
@@ -1549,11 +1544,11 @@
 	return _w_gfxwop_container_print(widget, indentation);
 }
 
-static int _gfxwop_visual_set_visual(GfxWidget *self, GfxVisual *visual) {
-	if (self != visual) {
-		GFXWARN("Attempt to set a visual's parent visual to something else!\n");
+int GfxVisual::setVisual(GfxVisual *visual) {
+	if (this != visual) {
+		warning("Attempt to set a visual's parent visual to something else");
 	} else {
-		GFXWARN("Attempt to set a visual's parent visual!\n");
+		warning("Attempt to set a visual's parent visual to itself");
 	}
 
 	return 1;
@@ -1562,7 +1557,7 @@
 void _gfxw_set_ops_VISUAL(GfxContainer *visual) {
 	_gfxw_set_container_ops((GfxContainer *)visual, _gfxwop_visual_draw,
 	                        _gfxwop_container_tag, _gfxwop_visual_print, _gfxwop_basic_compare_to,
-	                        _gfxwop_basic_equals, _gfxwop_basic_superarea_of, _gfxwop_visual_set_visual,
+	                        _gfxwop_basic_equals, _gfxwop_basic_superarea_of,
 	                        _gfxwop_container_free_tagged, _gfxwop_container_free_contents,
 	                        _gfxwop_container_add_dirty, _gfxwop_container_add);
 }
@@ -1575,7 +1570,7 @@
 	: GfxContainer(gfx_rect(0, 0, 320, 200), GFXW_VISUAL) {
 
 	_font = font;
-	gfx_state = state;
+	_gfxState = state;
 
 	_gfxw_set_ops_VISUAL(this);
 }
@@ -1609,14 +1604,14 @@
 	GfxPort *port = (GfxPort *) widget;
 	DRAW_ASSERT(widget, GFXW_PORT);
 
-	if (port->decorations) {
+	if (port->_decorations) {
 		DDIRTY(stderr, "Getting/applying deco dirty (multi)\n");
-		_gfxwop_add_dirty_rects(GFXWC(port->decorations), port->dirty);
-		if (port->decorations->draw(port->decorations, gfxw_point_zero)) {
-			port->decorations->dirty = NULL;
+		_gfxwop_add_dirty_rects(GFXWC(port->_decorations), port->dirty);
+		if (port->_decorations->draw(port->_decorations, gfxw_point_zero)) {
+			port->_decorations->dirty = NULL;
 			return 1;
 		}
-		port->decorations->dirty = NULL;
+		port->_decorations->dirty = NULL;
 	}
 
 	_gfxwop_container_draw_contents(widget, port->contents);
@@ -1641,7 +1636,7 @@
 
 	}
 
-	delete decorations;
+	delete _decorations;
 }
 
 static int _gfxwop_port_print(GfxWidget *widget, int indentation) {
@@ -1654,7 +1649,7 @@
 		sciprintf(" (gray)");
 	_w_gfxwop_container_print(port, indentation);
 
-	return _w_gfxwop_container_print_contents("decorations", port->decorations, indentation);
+	return _w_gfxwop_container_print_contents("decorations", port->_decorations, indentation);
 }
 
 static int _gfxwop_port_superarea_of(GfxWidget *self, GfxWidget *other) {
@@ -1666,18 +1661,17 @@
 	return port->port_bg->superarea_of(port->port_bg, other);
 }
 
-static int _gfxwop_port_set_visual(GfxWidget *widget, GfxVisual *visual) {
-	GfxList *decorations = ((GfxPort *) widget)->decorations;
-	widget->_visual = visual;
+int GfxPort::setVisual(GfxVisual *visual) {
+	_visual = visual;
 
-	if (decorations)
-		if (decorations->set_visual(decorations, visual)) {
+	if (_decorations)
+		if (_decorations->setVisual(visual)) {
 			GFXWARN("Setting the visual for decorations failed for port ");
-			widget->print(widget, 1);
+			this->print(this, 1);
 			return 1;
 		}
 
-	return _gfxwop_container_set_visual(widget, visual);
+	return GfxContainer::setVisual(visual);
 }
 
 static int _gfxwop_port_add_dirty(GfxContainer *widget, rect_t dirty, int propagate) {
@@ -1727,7 +1721,7 @@
 void _gfxw_set_ops_PORT(GfxContainer *widget) {
 	_gfxw_set_container_ops((GfxContainer *)widget, _gfxwop_port_draw, _gfxwop_container_tag,
 	                        _gfxwop_port_print, _gfxwop_basic_compare_to, _gfxwop_basic_equals, _gfxwop_port_superarea_of,
-	                        _gfxwop_port_set_visual, _gfxwop_container_free_tagged, _gfxwop_container_free_contents,
+	                        _gfxwop_container_free_tagged, _gfxwop_container_free_contents,
 	                        _gfxwop_port_add_dirty, _gfxwop_port_add);
 }
 
@@ -1741,7 +1735,7 @@
 
 	port_bg = NULL;
 	_parent = NULL;
-	decorations = NULL;
+	_decorations = NULL;
 	title_text = NULL;
 	draw_pos = Common::Point(0, 0);
 	gray_text = 0;

Modified: scummvm/trunk/engines/sci/gfx/gfx_widgets.h
===================================================================
--- scummvm/trunk/engines/sci/gfx/gfx_widgets.h	2009-04-24 10:48:25 UTC (rev 40107)
+++ scummvm/trunk/engines/sci/gfx/gfx_widgets.h	2009-04-24 10:48:51 UTC (rev 40108)
@@ -165,15 +165,7 @@
 ** Returns   : (int) 1 if self is superarea_of other, 0 otherwise
 **
 **
-** -- set_visual(GfxWidget *self)
-** Sets the visual for the widget
-** Parameters: (GfxWidget *) self: self reference
-** Returns   : (int) 0
-** This function is called by container->add() and need not be invoked explicitly.
-** It also makes sure that dirty rectangles are passed to parent containers.
 **
-**
-**
 ** **************************
 ** ** Container operations **
 ** **************************


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list