diff options
author | neoraider <devnull@localhost> | 2007-09-17 00:24:02 +0200 |
---|---|---|
committer | neoraider <devnull@localhost> | 2007-09-17 00:24:02 +0200 |
commit | d7a846e58a85ed311e83362af0b6474652d85c8a (patch) | |
tree | 965e42028a4eacb6790b908692dc321ddf5fc45f /window.cpp | |
parent | 96e9d04527dc17a2a4f8c2f7034c1c356ed5186e (diff) | |
download | zoomedit-d7a846e58a85ed311e83362af0b6474652d85c8a.tar zoomedit-d7a846e58a85ed311e83362af0b6474652d85c8a.zip |
zoomedit: Alle Datenstrukturen durch Klassen ersetzt.
Diffstat (limited to 'window.cpp')
-rw-r--r-- | window.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
@@ -3,7 +3,6 @@ #include "edit.h" #include "draw.h" #include "geometry.h" -#include "level.h" #include <gtk/gtk.h> #include <stdlib.h> #include <string.h> @@ -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); |