summaryrefslogtreecommitdiffstats
path: root/src/Gui
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2010-01-09 03:18:25 +0100
committerMatthias Schiffer <matthias@gamezock.de>2010-01-09 03:18:25 +0100
commitb4adc20ef08257124a01499436f2b8b447adcb33 (patch)
tree2d5440ccce94c464baf9869ceaf6b833b45ce51e /src/Gui
parent2bd663e0db1f365595aa9f04a8423ca85b9a1063 (diff)
downloadzoomedit-b4adc20ef08257124a01499436f2b8b447adcb33.tar
zoomedit-b4adc20ef08257124a01499436f2b8b447adcb33.zip
Use room list
Diffstat (limited to 'src/Gui')
-rw-r--r--src/Gui/Renderer/RoomListRenderer.cpp66
-rw-r--r--src/Gui/Renderer/RoomListRenderer.h53
-rw-r--r--src/Gui/Window.cpp14
-rw-r--r--src/Gui/Window.h38
4 files changed, 167 insertions, 4 deletions
diff --git a/src/Gui/Renderer/RoomListRenderer.cpp b/src/Gui/Renderer/RoomListRenderer.cpp
new file mode 100644
index 0000000..83b0402
--- /dev/null
+++ b/src/Gui/Renderer/RoomListRenderer.cpp
@@ -0,0 +1,66 @@
+/*
+ * RoomListRenderer.cpp
+ *
+ * Copyright (C) 2010 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "RoomListRenderer.h"
+#include <Data/Room.h>
+
+#include <pangomm/layout.h>
+
+namespace ZoomEdit {
+namespace Gui {
+namespace Renderer {
+
+void RoomListRenderer::get_size_vfunc(Gtk::Widget &/*widget*/, const Gdk::Rectangle * /*cell_area*/,
+ int * /*x_offset*/, int * /*y_offset*/, int * /*width*/, int *height) const {
+ int xpad, ypad;
+ get_padding(xpad, ypad);
+
+ *height = 60 + ypad*2;
+}
+
+void RoomListRenderer::render_vfunc(const Glib::RefPtr<Gdk::Drawable> &window, Gtk::Widget &widget,
+ const Gdk::Rectangle &/*background_area*/, const Gdk::Rectangle &cell_area,
+ const Gdk::Rectangle &/*expose_area*/, Gtk::CellRendererState /*flags*/) {
+
+ Data::Room *room = reinterpret_cast<Data::Room*>(value.get_value());
+
+ int xpad, ypad;
+ get_padding(xpad, ypad);
+
+ int x = xpad + cell_area.get_x();
+ int y = ypad + cell_area.get_y();
+
+ int width = cell_area.get_width() - 2*xpad;
+ int height = cell_area.get_height() - 2*ypad;
+
+ Glib::RefPtr<Gdk::GC> gc = Gdk::GC::create(window);
+ gc->set_rgb_fg_color(Gdk::Color("000000"));
+
+ Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create(widget.get_pango_context());
+
+ layout->set_width(width);
+ layout->set_height(height);
+ layout->set_markup("<b>" + room->getId() + "</b>");
+
+ window->draw_layout(gc, x, y, layout);
+}
+
+}
+}
+}
diff --git a/src/Gui/Renderer/RoomListRenderer.h b/src/Gui/Renderer/RoomListRenderer.h
new file mode 100644
index 0000000..ee2ac9f
--- /dev/null
+++ b/src/Gui/Renderer/RoomListRenderer.h
@@ -0,0 +1,53 @@
+/*
+ * RoomListRenderer.h
+ *
+ * Copyright (C) 2010 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef ZOOMEDIT_GUI_RENDERER_ROOMLISTRENDERER_H_
+#define ZOOMEDIT_GUI_RENDERER_ROOMLISTRENDERER_H_
+
+#include <gtkmm/cellrenderer.h>
+
+namespace ZoomEdit {
+namespace Gui {
+namespace Renderer {
+
+class RoomListRenderer : public virtual Glib::ObjectBase, public Gtk::CellRenderer {
+ public:
+ RoomListRenderer() : Glib::ObjectBase(typeid(RoomListRenderer)), value(*this, "value") {}
+
+ Glib::PropertyProxy<void*> property_value() {
+ return value.get_proxy();
+ }
+
+ protected:
+ virtual void get_size_vfunc(Gtk::Widget &widget, const Gdk::Rectangle *cell_area,
+ int *x_offset, int *y_offset, int *width, int *height) const;
+
+ virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable> &window, Gtk::Widget &widget,
+ const Gdk::Rectangle &background_area, const Gdk::Rectangle &cell_area,
+ const Gdk::Rectangle &expose_area, Gtk::CellRendererState flags);
+
+ private:
+ Glib::Property<void*> value;
+};
+
+}
+}
+}
+
+#endif /* ZOOMEDIT_GUI_RENDERER_ROOMLISTRENDERER_H_ */
diff --git a/src/Gui/Window.cpp b/src/Gui/Window.cpp
index dcc8f45..9e3722c 100644
--- a/src/Gui/Window.cpp
+++ b/src/Gui/Window.cpp
@@ -26,6 +26,8 @@
namespace ZoomEdit {
namespace Gui {
+const Window::RoomListColumnRecord Window::ROOM_LIST_COLUMN_RECORD;
+
Window::Window(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder)
: Gtk::Window(cobject) {
@@ -37,6 +39,18 @@ Window::Window(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builde
builder->get_widget_derived("RenderArea", renderArea);
builder->get_widget_derived("MapArea", mapArea);
builder->get_widget_derived("AspectFrameMap", aspectFrameMap);
+
+ roomListStore = Gtk::ListStore::create(ROOM_LIST_COLUMN_RECORD);
+
+ builder->get_widget("RoomList", roomList);
+
+ roomList->set_model(roomListStore);
+ int colCount = roomList->append_column("Room", roomListRenderer);
+ Gtk::TreeViewColumn *roomColumn = roomList->get_column(colCount-1);
+
+ if(roomColumn) {
+ roomColumn->add_attribute(roomListRenderer.property_value(), ROOM_LIST_COLUMN_RECORD.room);
+ }
}
Window::~Window() {
diff --git a/src/Gui/Window.h b/src/Gui/Window.h
index 97ebcda..ce0b1e2 100644
--- a/src/Gui/Window.h
+++ b/src/Gui/Window.h
@@ -21,25 +21,55 @@
#define ZOOMEDIT_GUI_WINDOW_H_
#include <gtkmm/builder.h>
+#include <gtkmm/liststore.h>
+#include <gtkmm/treeview.h>
#include <gtkmm/window.h>
+#include "Renderer/RoomListRenderer.h"
+
namespace ZoomEdit {
+
+namespace Data {
+class Room;
+}
+
namespace Gui {
class AspectFrame;
class RenderArea;
class Window : public Gtk::Window {
- private:
- RenderArea *renderArea, *mapArea;
- AspectFrame *aspectFrameMap;
-
public:
Window(BaseObjectType *cobject, const Glib::RefPtr<Gtk::Builder> &builder);
virtual ~Window();
RenderArea* getRenderArea() const {return renderArea;}
RenderArea* getMapArea() const {return mapArea;}
+
+ Glib::RefPtr<Gtk::ListStore> getRoomListStore() {return roomListStore;}
+ Gtk::TreeView* getRoomList() {return roomList;}
+
+ class RoomListColumnRecord : public Gtk::TreeModel::ColumnRecord {
+ public:
+ friend class Window;
+
+ Gtk::TreeModelColumn<void*> room;
+
+ private:
+ RoomListColumnRecord() {
+ add(room);
+ }
+ };
+
+ static const RoomListColumnRecord ROOM_LIST_COLUMN_RECORD;
+
+ private:
+ RenderArea *renderArea, *mapArea;
+ AspectFrame *aspectFrameMap;
+ Gtk::TreeView *roomList;
+
+ Glib::RefPtr<Gtk::ListStore> roomListStore;
+ Renderer::RoomListRenderer roomListRenderer;
};
}