[gtkmm] demos: Add stacksidebar demo



commit c3f4a24a191e64b2ce39c626dfde934d51df6715
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Thu Feb 19 10:20:53 2015 +0100

    demos: Add stacksidebar demo
    
    * demos/Makefile.am:
    * demos/gtk-demo/demos.h: Add example_stacksidebar.cc.
    * demos/gtk-demo/example_stacksidebar.cc: New file. Translated to gtkmm/C++
    from gtk+/demos/gtk-demo/sidebar.c.

 demos/Makefile.am                      |    1 +
 demos/gtk-demo/demos.h                 |    2 +
 demos/gtk-demo/example_stacksidebar.cc |   97 ++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+), 0 deletions(-)
---
diff --git a/demos/Makefile.am b/demos/Makefile.am
index 24554ac..8f6df6e 100644
--- a/demos/Makefile.am
+++ b/demos/Makefile.am
@@ -45,6 +45,7 @@ gtk_demo_gtkmm_demo_SOURCES =                         \
        gtk-demo/example_pixbufs.cc                     \
        gtk-demo/example_sizegroup.cc                   \
        gtk-demo/example_stack.cc                       \
+       gtk-demo/example_stacksidebar.cc        \
        gtk-demo/example_textview.cc                    \
        gtk-demo/example_treeview_editable_cells.cc     \
        gtk-demo/example_treeview_liststore.cc          \
diff --git a/demos/gtk-demo/demos.h b/demos/gtk-demo/demos.h
index 5e029fe..46137ce 100644
--- a/demos/gtk-demo/demos.h
+++ b/demos/gtk-demo/demos.h
@@ -35,6 +35,7 @@ Gtk::Window* do_pixbufs();
 Gtk::Window* do_panes();
 Gtk::Window* do_sizegroup();
 Gtk::Window* do_stack();
+Gtk::Window* do_stacksidebar();
 Gtk::Window* do_textview();
 
 Gtk::Window* do_treeview_editable_cells();
@@ -71,6 +72,7 @@ Demo testgtk_demos[] =
   { "Pixbufs", "example_pixbufs.cc", sigc::ptr_fun(&do_pixbufs), 0 },
   { "Size Groups", "example_sizegroup.cc", sigc::ptr_fun(&do_sizegroup), 0 },
   { "Stack", "example_stack.cc", sigc::ptr_fun(&do_stack), 0 },
+  { "Stack Sidebar", "example_stacksidebar.cc", sigc::ptr_fun(&do_stacksidebar), 0 },
   { "Text Widget", "example_textview.cc", sigc::ptr_fun(&do_textview), 0 },
   { "Tree View", "", type_slotDo(), child0 },
   { 0, 0, type_slotDo(), 0 }
diff --git a/demos/gtk-demo/example_stacksidebar.cc b/demos/gtk-demo/example_stacksidebar.cc
new file mode 100644
index 0000000..52aeaa5
--- /dev/null
+++ b/demos/gtk-demo/example_stacksidebar.cc
@@ -0,0 +1,97 @@
+/* Stack Sidebar
+ *
+ * Gtk::StackSidebar provides an automatic sidebar widget to control
+ * navigation of a Gtk::Stack object. This widget automatically updates its
+ * contents based on what is presently available in the Gtk::Stack object,
+ * and using the "title" child property to set the display labels.
+ */
+
+#include <gtkmm.h>
+#include <vector>
+
+class Example_StackSidebar : public Gtk::Window
+{
+public:
+  Example_StackSidebar();
+  virtual ~Example_StackSidebar();
+
+protected:
+  // Container:
+  Gtk::Box m_Box;
+
+  // Widgets:
+  Gtk::HeaderBar m_HeaderBar;
+  Gtk::StackSidebar m_StackSidebar;
+  Gtk::Separator m_Separator;
+  Gtk::Stack m_Stack;
+
+private:
+  void fill_page_names();
+  std::vector<Glib::ustring> m_page_names;
+};
+
+Gtk::Window* do_stacksidebar()
+{
+  return new Example_StackSidebar();
+}
+
+Example_StackSidebar::Example_StackSidebar()
+:
+  m_Box(Gtk::ORIENTATION_HORIZONTAL),
+  m_HeaderBar(),
+  m_StackSidebar(),
+  m_Separator(Gtk::ORIENTATION_VERTICAL),
+  m_Stack()
+{
+  m_HeaderBar.set_show_close_button(true);
+  set_titlebar(m_HeaderBar);
+  set_title("Stack Sidebar demo");
+  set_default_size(500, 350);
+
+  add(m_Box);
+
+  m_Box.pack_start(m_StackSidebar, Gtk::PACK_SHRINK);
+  m_Box.pack_start(m_Separator, Gtk::PACK_SHRINK);
+  m_Box.pack_start(m_Stack, Gtk::PACK_EXPAND_WIDGET);
+
+  m_Stack.set_transition_type(Gtk::STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);
+  m_StackSidebar.set_stack(m_Stack);
+
+  // Stack pages
+  fill_page_names();
+  for (std::size_t i = 0; i != m_page_names.size(); ++i)
+  {
+    Gtk::Widget* widget = 0;
+    if (i == 0)
+    {
+      Gtk::Image* image = Gtk::manage(new Gtk::Image());
+      image->set_from_icon_name("help-about", Gtk::ICON_SIZE_MENU);
+      image->set_pixel_size(256);
+      widget = image;
+    }
+    else
+    {
+      widget = Gtk::manage(new Gtk::Label(m_page_names[i]));
+    }
+    m_Stack.add(*widget, m_page_names[i], m_page_names[i]);
+  }
+
+  show_all();
+}
+
+Example_StackSidebar::~Example_StackSidebar()
+{
+}
+
+void Example_StackSidebar::fill_page_names()
+{
+  m_page_names.push_back("Welcome to gtkmm");
+  m_page_names.push_back("Gtk::StackSidebar Widget");
+  m_page_names.push_back("Automatic navigation");
+  m_page_names.push_back("Consistent appearance");
+  m_page_names.push_back("Scrolling");
+  m_page_names.push_back("Page 6");
+  m_page_names.push_back("Page 7");
+  m_page_names.push_back("Page 8");
+  m_page_names.push_back("Page 9");
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]