[gtkmm] demo: Add Stack demo
- From: Juan R. Garcia Blanco <juanrgar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] demo: Add Stack demo
- Date: Sun, 13 Jul 2014 17:00:35 +0000 (UTC)
commit 3ee85fe263375dc3ceea5aeb72246122ec77dcb4
Author: Juan R. GarcĂa Blanco <juanrgar gmail com>
Date: Sun Jul 13 18:54:17 2014 +0200
demo: Add Stack demo
* demos/Makefile.am: Add gtk-demo/example_stack.cc.
* demos/gtk-demo/demos.h: Declare do_stack(); add new entry in
testgtk_demos.
* demos/gtk-demo/example_stack.cc: New file.
demos/Makefile.am | 1 +
demos/gtk-demo/demos.h | 2 +
demos/gtk-demo/example_stack.cc | 73 +++++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 0 deletions(-)
---
diff --git a/demos/Makefile.am b/demos/Makefile.am
index 8944c23..24554ac 100644
--- a/demos/Makefile.am
+++ b/demos/Makefile.am
@@ -44,6 +44,7 @@ gtk_demo_gtkmm_demo_SOURCES = \
gtk-demo/example_panes.cc \
gtk-demo/example_pixbufs.cc \
gtk-demo/example_sizegroup.cc \
+ gtk-demo/example_stack.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 7e96a4f..5e029fe 100644
--- a/demos/gtk-demo/demos.h
+++ b/demos/gtk-demo/demos.h
@@ -34,6 +34,7 @@ Gtk::Window* do_overlay();
Gtk::Window* do_pixbufs();
Gtk::Window* do_panes();
Gtk::Window* do_sizegroup();
+Gtk::Window* do_stack();
Gtk::Window* do_textview();
Gtk::Window* do_treeview_editable_cells();
@@ -69,6 +70,7 @@ Demo testgtk_demos[] =
{ "Paned Widgets", "example_panes.cc", sigc::ptr_fun(&do_panes), 0 },
{ "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 },
{ "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_stack.cc b/demos/gtk-demo/example_stack.cc
new file mode 100644
index 0000000..09ac84c
--- /dev/null
+++ b/demos/gtk-demo/example_stack.cc
@@ -0,0 +1,73 @@
+/* Stack
+ *
+ * Gtk::Stack is a container that shows a single child at a time,
+ * with nice transitions when the visible child changes.
+ *
+ * Gtk::StackSwitcher adds buttons to control which child is visible.
+ */
+
+#include "gtkmm.h"
+
+class Example_Stack : public Gtk::Window
+{
+public:
+ Example_Stack();
+ virtual ~Example_Stack();
+
+protected:
+
+ // Containers
+ Gtk::Grid m_grid;
+ Gtk::Stack m_stack;
+
+ // Widgets
+ Gtk::StackSwitcher m_stack_switcher;
+ Gtk::Image m_image;
+ Gtk::CheckButton m_check_button;
+ Gtk::Spinner m_spinner;
+
+private:
+};
+
+//Called by DemoWindow;
+Gtk::Window* do_stack()
+{
+ return new Example_Stack();
+}
+
+Example_Stack::Example_Stack()
+{
+ // Window properties
+ set_title("Stack");
+
+ // Build stack
+ m_stack.add(m_image, "page1", "Page 1");
+ m_stack.add(m_check_button, "page2", "Page 2");
+ m_stack.add(m_spinner, "page3");
+
+ // Page 1
+ m_image.set_from_icon_name("gtk3-demo", Gtk::ICON_SIZE_DIALOG);
+
+ // Page 2
+ m_check_button.set_label("Page 2");
+ m_check_button.set_halign(Gtk::ALIGN_CENTER);
+
+ // Page 3
+ m_stack.child_property_icon_name(m_spinner) = "face-laugh-symbolic";
+ m_spinner.property_active() = true;
+
+ // Stack transition
+ m_stack.set_transition_type(Gtk::STACK_TRANSITION_TYPE_CROSSFADE);
+
+ // Layout
+ m_stack_switcher.set_stack(m_stack);
+ m_grid.attach(m_stack_switcher, 0, 0, 1, 1);
+ m_grid.attach(m_stack, 0, 1, 1, 1);
+ add(m_grid);
+
+ show_all_children();
+}
+
+Example_Stack::~Example_Stack()
+{
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]