From b660b965bcb679e53cc89e7b8903190d2d162ff6 Mon Sep 17 00:00:00 2001 From: neoraider Date: Thu, 4 Oct 2007 23:38:05 +0000 Subject: zoomedit: Gro?e Teile der GUI in Klassen gekapselt. --- SidebarAdd.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 SidebarAdd.cpp (limited to 'SidebarAdd.cpp') diff --git a/SidebarAdd.cpp b/SidebarAdd.cpp new file mode 100644 index 0000000..78509e0 --- /dev/null +++ b/SidebarAdd.cpp @@ -0,0 +1,43 @@ +#include "SidebarAdd.h" +#include "edit.h" + + +void SidebarAdd::buttonClicked(GtkButton *button, SidebarAdd *sidebar) { + sidebar->editor->finishRoom(); +} + +SidebarAdd::SidebarAdd(EditManager *editor) { + this->editor = editor; + + sidebar = gtk_vbox_new(FALSE, 0); + g_object_ref_sink(G_OBJECT(sidebar)); + + GtkWidget *labelRoomInfo = gtk_label_new(NULL); + gtk_label_set_markup(GTK_LABEL(labelRoomInfo), "Add room"); + gtk_misc_set_alignment(GTK_MISC(labelRoomInfo), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(sidebar), labelRoomInfo, FALSE, FALSE, 5); + + buttonAdd = gtk_button_new_with_label("Add room"); + g_signal_connect(G_OBJECT(buttonAdd), "clicked", G_CALLBACK(buttonClicked), this); + gtk_box_pack_end(GTK_BOX(sidebar), buttonAdd, FALSE, FALSE, 0); + + gtk_widget_show_all(sidebar); +} + +SidebarAdd::~SidebarAdd() { + g_object_unref(G_OBJECT(sidebar)); +} + +GtkWidget* SidebarAdd::getWidget() { + return sidebar; +} + +void SidebarAdd::update() { + if(!getActiveRoom()) + return; + + if(getActiveRoom()->size() > 2 && isPolygonOk(getActiveRoom())) + gtk_widget_set_sensitive(buttonAdd, TRUE); + else + gtk_widget_set_sensitive(buttonAdd, FALSE); +} -- cgit v1.2.3