From d7a846e58a85ed311e83362af0b6474652d85c8a Mon Sep 17 00:00:00 2001 From: neoraider Date: Sun, 16 Sep 2007 22:24:02 +0000 Subject: zoomedit: Alle Datenstrukturen durch Klassen ersetzt. --- window.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'window.cpp') diff --git a/window.cpp b/window.cpp index db4ec32..d347964 100644 --- a/window.cpp +++ b/window.cpp @@ -3,7 +3,6 @@ #include "edit.h" #include "draw.h" #include "geometry.h" -#include "level.h" #include #include #include @@ -52,7 +51,7 @@ static gboolean buttonEvent(GtkWidget *widget, GdkEventButton *event, gpointer u viewToImage(&v); if(isVertexOk(&v)) { - getActiveRoom()->polygon.push_back(v); + getActiveRoom()->push_back(v); updateSidebar(); } } @@ -86,7 +85,7 @@ gboolean crossingNotifyEvent(GtkWidget *widget, GdkEventCrossing *event, gpointe gboolean motionNotifyEvent(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) { Vertex v(event->x, event->y); - ROOM *last = getHoveredRoom(); + Room *last = getHoveredRoom(); viewToImage(&v); @@ -153,8 +152,7 @@ static void updateScrollbarsCentered() { static void sidebarNameChanged(GtkEditable *editable, gpointer user_data) { if(getActiveRoom() == NULL) return; - free(getActiveRoom()->name); - getActiveRoom()->name = strdup(gtk_entry_get_text(GTK_ENTRY(entryName))); + getActiveRoom()->setName(std::string(gtk_entry_get_text(GTK_ENTRY(entryName)))); } static void sidebarButtonClicked(GtkButton *button, gpointer user_data) { @@ -165,9 +163,9 @@ static void sidebarButtonClicked(GtkButton *button, gpointer user_data) { gtk_widget_queue_draw(drawingArea); } else if(button == GTK_BUTTON(buttonAddDo)) { - if(getActiveRoom() && getActiveRoom()->polygon.size() > 2 && isPolygonOk(&getActiveRoom()->polygon)) { - addRoom(getLevel(), getActiveRoom()); - setActiveRoom(&getLevel()->rooms[getLevel()->nRooms-1]); + if(getActiveRoom() && getActiveRoom()->size() > 2 && isPolygonOk(getActiveRoom())) { + getLevel()->push_back(*getActiveRoom()); + setActiveRoom(&getLevel()->back()); } endAddMode(); @@ -310,14 +308,14 @@ void updateSidebar() { gtk_widget_show(sidebarView); if(getActiveRoom()) { - gtk_entry_set_text(GTK_ENTRY(entryName), getActiveRoom()->name); + gtk_entry_set_text(GTK_ENTRY(entryName), getActiveRoom()->getName().c_str()); gtk_widget_set_sensitive(entryName, TRUE); - string = g_strdup_printf("%.2f", getActiveRoom()->polygon.area()); + string = g_strdup_printf("%.2f", getActiveRoom()->area()); gtk_label_set_text(GTK_LABEL(labelArea), string); g_free(string); - string = g_strdup_printf("%.2f", getActiveRoom()->polygon.perimeter()); + string = g_strdup_printf("%.2f", getActiveRoom()->perimeter()); gtk_label_set_text(GTK_LABEL(labelPerimeter), string); g_free(string); } @@ -335,7 +333,7 @@ void updateSidebar() { gtk_widget_show(sidebarAdd); if(getActiveRoom()) { - if(getActiveRoom()->polygon.size() > 2 && isPolygonOk(&getActiveRoom()->polygon)) + if(getActiveRoom()->size() > 2 && isPolygonOk(getActiveRoom())) gtk_widget_set_sensitive(buttonAddDo, TRUE); else gtk_widget_set_sensitive(buttonAddDo, FALSE); -- cgit v1.2.3