[gtkmm-documentation] Added ToolPalette example.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Added ToolPalette example.
- Date: Mon, 28 Dec 2009 13:53:33 +0000 (UTC)
commit 2df6ab5b4d0759f9e0e1c9c0ca30fc04cc8cea22
Author: Murray Cumming <murrayc murrayc com>
Date: Mon Dec 28 14:53:01 2009 +0100
Added ToolPalette example.
* examples/Makefile.am:
* examples/book/toolpalette/: Added an example based on the code in
gtk-demo.
ChangeLog | 8 +
examples/Makefile.am | 8 +
examples/book/toolpalette/canvas.cc | 118 +++++++++++
examples/book/toolpalette/canvas.h | 64 ++++++
examples/book/toolpalette/examplewindow.cc | 292 ++++++++++++++++++++++++++++
examples/book/toolpalette/examplewindow.h | 83 ++++++++
examples/book/toolpalette/main.cc | 31 +++
7 files changed, 604 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5a7da35..0949bf4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-12-28 Murray Cumming <murrayc murrayc com>
+
+ Added ToolPalette example.
+
+ * examples/Makefile.am:
+ * examples/book/toolpalette/: Added an example based on the code in
+ gtk-demo.
+
2009-11-11 Murray Cumming <murrayc murrayc com>
* docs/tutorial/C/gtkmm-tutorial-in.xml: Glade and Gtk::Builder chapter:
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 0668484..afb306b 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -82,6 +82,7 @@ check_PROGRAMS = \
book/textview/example \
book/timeout/timeout \
book/toolbar/example \
+ book/toolpalette/example \
book/tooltips/example \
book/treeview/combo_renderer/example \
book/treeview/drag_and_drop/example \
@@ -507,6 +508,13 @@ book_toolbar_example_SOURCES = \
book/toolbar/examplewindow.h \
book/toolbar/main.cc
+book_toolpalette_example_SOURCES = \
+ book/toolpalette/examplewindow.cc \
+ book/toolpalette/examplewindow.h \
+ book/toolpalette/canvas.cc \
+ book/toolpalette/canvas.h \
+ book/toolpalette/main.cc
+
book_tooltips_example_SOURCES = \
book/tooltips/examplewindow.cc \
book/tooltips/examplewindow.h \
diff --git a/examples/book/toolpalette/canvas.cc b/examples/book/toolpalette/canvas.cc
new file mode 100644
index 0000000..91f225c
--- /dev/null
+++ b/examples/book/toolpalette/canvas.cc
@@ -0,0 +1,118 @@
+//$Id: canvas.cc 870 2007-07-13 19:08:46Z murrayc $ -*- c++ -*-
+
+/* gtkmm example Copyright (C) 2009 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "canvas.h"
+#include <iostream>
+
+Canvas::Canvas()
+: m_drop_item(0)
+{
+ set_app_paintable();
+}
+
+Canvas::~Canvas()
+{
+ while(!m_canvas_items.empty())
+ {
+ type_list_items::iterator iter = m_canvas_items.begin();
+ CanvasItem* item = *iter;
+ delete item;
+ m_canvas_items.erase(iter);
+ }
+}
+
+void Canvas::item_draw(const CanvasItem *item,
+ const Cairo::RefPtr<Cairo::Context>& cr,
+ bool preview)
+{
+ if(!item || !item->pixbuf)
+ return;
+
+ const double cx = item->pixbuf->get_width();
+ const double cy = item->pixbuf->get_height();
+
+ Gdk::Cairo::set_source_pixbuf(cr,
+ item->pixbuf,
+ item->x - cx * 0.5, item->y - cy * 0.5);
+
+ if(preview)
+ cr->paint_with_alpha(0.6);
+ else
+ cr->paint();
+}
+
+bool Canvas::on_expose_event(GdkEventExpose* event)
+{
+ // This is where we draw on the window
+ Glib::RefPtr<Gdk::Window> window = get_window();
+ if(!window)
+ return false;
+
+ Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+ const Gdk::Region region(event->region, true /* copy */);
+ Gdk::Cairo::region(cr, region);
+ cr->clip();
+
+ cr->set_source_rgb(1.0, 1.0, 1.0);
+ const Gtk::Allocation allocation = get_allocation();
+ cr->rectangle(0, 0, allocation.get_width(), allocation.get_height());
+ cr->fill();
+
+ for(type_list_items::iterator iter = m_canvas_items.begin();
+ iter != m_canvas_items.end(); ++iter )
+ {
+ item_draw(*iter, cr, false);
+ }
+
+ if(m_drop_item)
+ item_draw (m_drop_item, cr, true);
+
+ return true;
+}
+
+void Canvas::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time)
+{
+ // Find the tool button which is the source of this DnD operation.
+ Gtk::Widget* widget = drag_get_source_widget(context);
+
+ Gtk::ToolPalette* drag_palette = dynamic_cast<Gtk::ToolPalette*>(widget);
+ while(widget && !drag_palette)
+ {
+ widget = widget->get_parent();
+ drag_palette = dynamic_cast<Gtk::ToolPalette*>(widget);
+ }
+
+ Gtk::ToolItem* drag_item = 0;
+ if(drag_palette)
+ drag_item = drag_palette->get_drag_item(selection_data);
+
+ Gtk::ToolButton* button = dynamic_cast<Gtk::ToolButton*>(drag_item);
+ if(!button)
+ return;
+
+ // Add a canvas item at the position,
+ // to be drawn in our expose_event handler.
+ CanvasItem* canvas_item = new CanvasItem(this, button, x, y);
+ m_canvas_items.push_back(canvas_item);
+ queue_draw();
+
+ Gtk::DrawingArea::on_drag_data_received(context, x, y, selection_data, info, time);
+}
+
+
+
diff --git a/examples/book/toolpalette/canvas.h b/examples/book/toolpalette/canvas.h
new file mode 100644
index 0000000..22b320f
--- /dev/null
+++ b/examples/book/toolpalette/canvas.h
@@ -0,0 +1,64 @@
+//$Id: examplewindow.h 705 2006-07-19 02:55:32Z jjongsma $ -*- c++ -*-
+
+/* gtkmm example Copyright (C) 2002 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef GTKMM_EXAMPLE_CANVAS_H
+#define GTKMM_EXAMPLE_CANVAS_H
+
+#include <gtkmm.h>
+
+// This little canvas class is only here
+// because gtkmm does not have a canvas class yet.
+// Applications should probably use GooCanvas::Canvas (goocanvasmm) instead.
+class Canvas : public Gtk::DrawingArea
+{
+public:
+ Canvas();
+ virtual ~Canvas();
+
+private:
+
+ class CanvasItem
+ {
+ public:
+ CanvasItem(Gtk::Widget* canvas, Gtk::ToolButton* button, double x, double y)
+ {
+ const Gtk::StockID stock_id = Gtk::StockID(button->get_stock_id());
+ this->pixbuf = canvas->render_icon(stock_id, Gtk::ICON_SIZE_DIALOG);
+ this->x = x;
+ this->y = y;
+ }
+
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf;
+ double x, y;
+ };
+
+ void item_draw(const CanvasItem *item,
+ const Cairo::RefPtr<Cairo::Context>& cr,
+ bool preview);
+
+ virtual bool on_expose_event(GdkEventExpose* event);
+ virtual void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
+
+
+ CanvasItem* m_drop_item;
+
+ typedef std::list<CanvasItem*> type_list_items;
+ type_list_items m_canvas_items;
+};
+
+#endif //GTKMM_EXAMPLE_CANVAS_H
diff --git a/examples/book/toolpalette/examplewindow.cc b/examples/book/toolpalette/examplewindow.cc
new file mode 100644
index 0000000..80ba141
--- /dev/null
+++ b/examples/book/toolpalette/examplewindow.cc
@@ -0,0 +1,292 @@
+//$Id: examplewindow.cc 870 2007-07-13 19:08:46Z murrayc $ -*- c++ -*-
+
+/* gtkmm example Copyright (C) 2002 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "examplewindow.h"
+
+static bool sort_predicate(const Gtk::StockID& a, const Gtk::StockID& b)
+{
+ return a.get_string() < b.get_string();
+}
+
+
+void ExampleWindow::load_stock_items()
+{
+ Gtk::ToolItemGroup* group_af =
+ Gtk::manage(new Gtk::ToolItemGroup("Stock Icons (A-F)"));
+ m_ToolPalette.add(*group_af);
+ Gtk::ToolItemGroup* group_gn =
+ Gtk::manage(new Gtk::ToolItemGroup("Stock Icons (G-N)"));
+ m_ToolPalette.add(*group_gn);
+ Gtk::ToolItemGroup* group_or =
+ Gtk::manage(new Gtk::ToolItemGroup("Stock Icons (O-R)"));
+ m_ToolPalette.add(*group_or);
+ Gtk::ToolItemGroup* group_sz =
+ Gtk::manage(new Gtk::ToolItemGroup("Stock Icons (S-Z)"));
+ m_ToolPalette.add(*group_sz);
+
+ // Obtain the IDs of all stock items:
+ typedef std::vector<Gtk::StockID> type_vecIDs;
+ type_vecIDs vecIDs = Gtk::Stock::get_ids();
+
+ std::sort(vecIDs.begin(), vecIDs.end(), &sort_predicate);
+
+ Gtk::ToolItemGroup* group = 0;
+
+ // Iterate through them, populating the ListStore as appropriate:
+ for(type_vecIDs::const_iterator iterIDs = vecIDs.begin(); iterIDs != vecIDs.end(); ++iterIDs)
+ {
+ const Gtk::StockID& stockid = *iterIDs;
+ const Glib::ustring str = stockid.get_string();
+ if(str.size() < 4)
+ continue;
+
+ switch(str[4])
+ {
+ case 'a':
+ group = group_af;
+ break;
+ case 'g':
+ group = group_gn;
+ break;
+ case 'o':
+ group = group_or;
+ break;
+ case 's':
+ group = group_sz;
+ break;
+ default:
+ //Use the previous group
+ //(They are sorted.)
+ break;
+ }
+
+ if(!group)
+ continue;
+
+ Gtk::ToolButton* button = Gtk::manage(new Gtk::ToolButton(stockid));
+ button->set_tooltip_text(str);
+ button->set_is_important();
+ group->insert(*button, -1);
+
+ Gtk::StockItem stockitem;
+ if(!Gtk::StockItem::lookup(stockid, stockitem) ||
+ stockitem.get_label().empty())
+ button->set_label(str);
+ }
+}
+
+
+void ExampleWindow::load_toggle_items()
+{
+ Gtk::ToolItemGroup* group =
+ Gtk::manage(new Gtk::ToolItemGroup("Radio Item"));
+ m_ToolPalette.add(*group);
+
+ Gtk::RadioToolButton::Group radio_group;
+
+ for(int i = 1; i <= 10; ++i)
+ {
+ const Glib::ustring label = Glib::ustring::compose("#%1", i);
+ Gtk::RadioToolButton* button = Gtk::manage(new Gtk::RadioToolButton());
+ button->set_group(radio_group);
+ button->set_label(label);
+
+ group->insert(*button, -1);
+ }
+}
+
+
+static Gtk::ToolItem* create_entry_item(const Glib::ustring& text)
+{
+ Gtk::Entry* entry = Gtk::manage(new Gtk::Entry());
+ entry->set_text(text);
+ entry->set_width_chars(5);
+
+ Gtk::ToolItem* item = Gtk::manage(new Gtk::ToolItem());
+ item->add(*entry);
+
+ return item;
+}
+
+void ExampleWindow::load_special_items()
+{
+ Gtk::ToolItemGroup* group = Gtk::manage(new Gtk::ToolItemGroup());
+
+ Gtk::Button *label_button = Gtk::manage(new Gtk::Button("Advanced Features"));
+ label_button->show();
+ group->set_label_widget(*label_button);
+ m_ToolPalette.add(*group);
+
+ Gtk::ToolItem* item = create_entry_item ("homogeneous=false");
+ group->insert(*item, -1);
+ //TODO: Add Gtk::Container::set_child_property().
+ gtk_container_child_set (GTK_CONTAINER (group->gobj()), GTK_WIDGET (item->gobj()),
+ "homogeneous", FALSE, NULL);
+
+ item = create_entry_item ("homogeneous=FALSE, expand=TRUE");
+ group->insert(*item, -1);
+ gtk_container_child_set (GTK_CONTAINER (group->gobj()), GTK_WIDGET (item->gobj()),
+ "homogeneous", FALSE, "expand", TRUE,
+ NULL);
+
+ item = create_entry_item ("homogeneous=FALSE, expand=TRUE, fill=FALSE");
+ group->insert(*item, -1);
+ gtk_container_child_set (GTK_CONTAINER (group->gobj()), GTK_WIDGET (item->gobj()),
+ "homogeneous", FALSE, "expand", TRUE,
+ "fill", FALSE, NULL);
+
+ item = create_entry_item ("homogeneous=FALSE, expand=TRUE, new-row=TRUE");
+ group->insert(*item, -1);
+ gtk_container_child_set (GTK_CONTAINER (group->gobj()), GTK_WIDGET (item->gobj()),
+ "homogeneous", FALSE, "expand", TRUE,
+ "new-row", TRUE, NULL);
+
+ item = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::GO_UP));
+ item->set_tooltip_text("Show on vertical palettes only");
+ group->insert(*item, -1);
+ item->set_visible_horizontal(false);
+
+ item = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::GO_FORWARD));
+ item->set_tooltip_text("Show on horizontal palettes only");
+ group->insert(*item, -1);
+ item->set_visible_vertical(false);
+
+ item = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::FULLSCREEN));
+ item->set_tooltip_text("Expanded this item");
+ group->insert(*item, -1);
+ gtk_container_child_set (GTK_CONTAINER (group->gobj()), GTK_WIDGET (item->gobj()),
+ "homogeneous", FALSE,
+ "expand", TRUE,
+ NULL);
+
+ item = Gtk::manage(new Gtk::ToolButton(Gtk::Stock::HELP));
+ item->set_tooltip_text("A regular item");
+ group->insert(*item, -1);
+}
+
+ExampleWindow::ExampleWindow()
+: m_VBox(false, 6),
+ m_HBox(false, 6)
+{
+ set_title("Gtk::ToolPalette example");
+ set_size_request(600, 600);
+ set_border_width(6);
+
+ add(m_VBox);
+
+ //The Orientation ComboBox:
+ m_refTreeModelOrientation = Gtk::ListStore::create(m_ColumnsOrientation);
+ Gtk::TreeModel::Row row = *(m_refTreeModelOrientation->append());
+ row[m_ColumnsOrientation.m_col_value] = Gtk::ORIENTATION_HORIZONTAL;
+ row[m_ColumnsOrientation.m_col_name] = "Horizontal";\
+ row = *(m_refTreeModelOrientation->append());
+ row[m_ColumnsOrientation.m_col_value] = Gtk::ORIENTATION_VERTICAL;
+ row[m_ColumnsOrientation.m_col_name] = "Vertical";
+ m_ComboOrientation.set_model(m_refTreeModelOrientation);
+ m_VBox.pack_start(m_ComboOrientation, Gtk::PACK_SHRINK);
+ m_ComboOrientation.pack_start(m_ColumnsOrientation.m_col_name);
+ m_ComboOrientation.signal_changed().connect(
+ sigc::mem_fun(*this, &ExampleWindow::on_combo_orientation_changed) );
+ m_ComboOrientation.set_active(row);
+
+ //The Style ComboBox:
+ m_refTreeModelStyle = Gtk::ListStore::create(m_ColumnsStyle);
+ row = *(m_refTreeModelStyle->append());
+ row[m_ColumnsStyle.m_col_value] = Gtk::TOOLBAR_TEXT;
+ row[m_ColumnsStyle.m_col_name] = "Text";\
+ row = *(m_refTreeModelStyle->append());
+ row[m_ColumnsStyle.m_col_value] = Gtk::TOOLBAR_BOTH;
+ row[m_ColumnsStyle.m_col_name] = "Both";
+ row = *(m_refTreeModelStyle->append());
+ row[m_ColumnsStyle.m_col_value] = Gtk::TOOLBAR_BOTH_HORIZ;
+ row[m_ColumnsStyle.m_col_name] = "Both: Horizontal";
+ row = *(m_refTreeModelStyle->append());
+ row[m_ColumnsStyle.m_col_value] = Gtk::TOOLBAR_ICONS;
+ row[m_ColumnsStyle.m_col_name] = "Icons";
+ row = *(m_refTreeModelStyle->append());
+ row[m_ColumnsStyle.m_col_value] = -1; // A custom meaning for this demo.
+ row[m_ColumnsStyle.m_col_name] = "Default";
+ m_ComboStyle.set_model(m_refTreeModelStyle);
+ m_VBox.pack_start(m_ComboStyle, Gtk::PACK_SHRINK);
+ m_ComboStyle.pack_start(m_ColumnsStyle.m_col_name);
+ m_ComboStyle.signal_changed().connect(
+ sigc::mem_fun(*this, &ExampleWindow::on_combo_style_changed) );
+ m_ComboStyle.set_active(row);
+
+ //Add and fill the ToolPalette:
+ load_stock_items();
+ load_toggle_items();
+ load_special_items();
+
+ m_VBox.pack_start(m_HBox, Gtk::PACK_EXPAND_WIDGET);
+
+ m_ScrolledWindowPalette.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
+ m_ScrolledWindowPalette.set_border_width(6);
+ m_ScrolledWindowPalette.add(m_ToolPalette);
+ m_HBox.pack_start(m_ScrolledWindowPalette);
+
+ on_combo_orientation_changed();
+
+ m_ScrolledWindowCanvas.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
+ m_ScrolledWindowCanvas.set_border_width(6);
+ m_ScrolledWindowCanvas.add(m_Canvas);
+ m_ScrolledWindowCanvas.set_size_request(200, -1);
+ m_HBox.pack_start(m_ScrolledWindowCanvas);
+
+ m_ToolPalette.add_drag_dest(m_Canvas,
+ Gtk::DEST_DEFAULT_ALL, Gtk::TOOL_PALETTE_DRAG_ITEMS, Gdk::ACTION_COPY);
+
+ show_all_children();
+}
+
+ExampleWindow::~ExampleWindow()
+{
+}
+
+void ExampleWindow::on_combo_orientation_changed()
+{
+ Gtk::TreeModel::iterator iter = m_ComboOrientation.get_active();
+ if(!iter)
+ return;
+
+ Gtk::TreeModel::Row row = *iter;
+ const Gtk::Orientation value = row[m_ColumnsOrientation.m_col_value];
+
+ m_ToolPalette.set_orientation(value);
+
+ if(value == Gtk::ORIENTATION_HORIZONTAL)
+ m_ScrolledWindowPalette.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_NEVER);
+ else
+ m_ScrolledWindowPalette.set_policy(Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
+}
+
+void ExampleWindow::on_combo_style_changed()
+{
+ Gtk::TreeModel::iterator iter = m_ComboStyle.get_active();
+ if(!iter)
+ return;
+
+ Gtk::TreeModel::Row row = *iter;
+ const int value = row[m_ColumnsStyle.m_col_value];
+
+ if(value == -1)
+ m_ToolPalette.unset_style();
+ else
+ m_ToolPalette.set_style((Gtk::ToolbarStyle)value);
+}
+
diff --git a/examples/book/toolpalette/examplewindow.h b/examples/book/toolpalette/examplewindow.h
new file mode 100644
index 0000000..eb86460
--- /dev/null
+++ b/examples/book/toolpalette/examplewindow.h
@@ -0,0 +1,83 @@
+//$Id: examplewindow.h 705 2006-07-19 02:55:32Z jjongsma $ -*- c++ -*-
+
+/* gtkmm example Copyright (C) 2002 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef GTKMM_EXAMPLEWINDOW_H
+#define GTKMM_EXAMPLEWINDOW_H
+
+#include <gtkmm.h>
+#include "canvas.h"
+
+class ExampleWindow : public Gtk::Window
+{
+public:
+ ExampleWindow();
+ virtual ~ExampleWindow();
+
+private:
+
+ void load_stock_items();
+ void load_toggle_items();
+ void load_special_items();
+
+ //Signal handlers:
+ void on_combo_orientation_changed();
+ void on_combo_style_changed();
+
+ //Tree model columns:
+ class ModelColumnsOrientation : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+
+ ModelColumnsOrientation()
+ { add(m_col_value); add(m_col_name); }
+
+ Gtk::TreeModelColumn<Gtk::Orientation> m_col_value;
+ Gtk::TreeModelColumn<Glib::ustring> m_col_name;
+ };
+
+ ModelColumnsOrientation m_ColumnsOrientation;
+
+ //Tree model columns:
+ class ModelColumnsStyle : public Gtk::TreeModel::ColumnRecord
+ {
+ public:
+
+ ModelColumnsStyle()
+ { add(m_col_value); add(m_col_name); }
+
+ Gtk::TreeModelColumn<int> m_col_value; //We use int to also allow -1
+ Gtk::TreeModelColumn<Glib::ustring> m_col_name;
+ };
+
+ ModelColumnsStyle m_ColumnsStyle;
+
+
+ //Child widgets:
+ Gtk::VBox m_VBox;
+ Gtk::HBox m_HBox;
+ Gtk::ComboBox m_ComboOrientation;
+ Glib::RefPtr<Gtk::ListStore> m_refTreeModelOrientation;
+ Gtk::ComboBox m_ComboStyle;
+ Glib::RefPtr<Gtk::ListStore> m_refTreeModelStyle;
+ Gtk::ToolPalette m_ToolPalette;
+ Gtk::ScrolledWindow m_ScrolledWindowPalette;
+ Gtk::ScrolledWindow m_ScrolledWindowCanvas;
+ Canvas m_Canvas;
+};
+
+#endif //GTKMM_EXAMPLEWINDOW_H
diff --git a/examples/book/toolpalette/main.cc b/examples/book/toolpalette/main.cc
new file mode 100644
index 0000000..6b3659e
--- /dev/null
+++ b/examples/book/toolpalette/main.cc
@@ -0,0 +1,31 @@
+//$Id: main.cc 836 2007-05-09 03:02:38Z jjongsma $ -*- c++ -*-
+
+/* gtkmm example Copyright (C) 2009 gtkmm development team
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <gtkmm/main.h>
+#include "examplewindow.h"
+
+int main(int argc, char *argv[])
+{
+ Gtk::Main kit(argc, argv);
+
+ ExampleWindow window;
+ //Shows the window and returns when it is closed.
+ Gtk::Main::run(window);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]