[gtkmm-documentation] Examples: Add a VolumeButton example.



commit 008f99b8746bc8ada6c573c4d774b0484973ef1e
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Feb 2 13:04:53 2015 +0100

    Examples: Add a VolumeButton example.

 examples/Makefile.am                               |    6 ++
 .../book/buttons/volumebutton/examplewindow.cc     |   54 ++++++++++++++++++++
 examples/book/buttons/volumebutton/examplewindow.h |   41 +++++++++++++++
 examples/book/buttons/volumebutton/main.cc         |   30 +++++++++++
 4 files changed, 131 insertions(+), 0 deletions(-)
---
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 8e5c579..433cd3a 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -25,6 +25,7 @@ check_PROGRAMS =                                      \
        book/buttons/radiobutton/radiobuttons           \
        book/buttons/scalebutton/example                        \
        book/buttons/togglebutton/example               \
+       book/buttons/volumebutton/example                       \
        book/clipboard/ideal/example                    \
        book/clipboard/simple/example                   \
        book/combobox/complex/example                   \
@@ -240,6 +241,11 @@ book_buttons_togglebutton_example_SOURCES =                \
        book/buttons/togglebutton/examplewindow.h       \
        book/buttons/togglebutton/main.cc
 
+book_buttons_volumebutton_example_SOURCES =            \
+       book/buttons/volumebutton/examplewindow.cc      \
+       book/buttons/volumebutton/examplewindow.h       \
+       book/buttons/volumebutton/main.cc
+
 book_clipboard_ideal_example_SOURCES =         \
        book/clipboard/ideal/examplewindow.cc   \
        book/clipboard/ideal/examplewindow.h    \
diff --git a/examples/book/buttons/volumebutton/examplewindow.cc 
b/examples/book/buttons/volumebutton/examplewindow.cc
new file mode 100644
index 0000000..189052b
--- /dev/null
+++ b/examples/book/buttons/volumebutton/examplewindow.cc
@@ -0,0 +1,54 @@
+//$Id: buttons.cc 836 2007-05-09 03:02:38Z 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
+ */
+
+#include "examplewindow.h"
+#include <iostream>
+
+ExampleWindow::ExampleWindow()
+{
+  //Make the window big enough to show the popup scale from the GtkVolumeButton.
+  //Otherwise it will be truncated.
+  set_default_size(300, 300);
+
+  set_title("VolumeButton Example");
+  set_border_width(12);
+
+  add(m_grid);
+  m_button.set_vexpand(true);
+  m_button.set_hexpand(true);
+
+  m_grid.attach(m_button, 1, 1, 1, 1);
+  m_button.set_valign(Gtk::ALIGN_END);
+  m_button.set_halign(Gtk::ALIGN_END);
+
+  m_button.set_value(0.4);
+  m_button.signal_value_changed().connect(
+    sigc::mem_fun(*this, &ExampleWindow::on_value_changed));
+
+  show_all_children();
+}
+
+ExampleWindow::~ExampleWindow()
+{
+}
+
+void ExampleWindow::on_value_changed(double value)
+{
+  std::cout << "Value: " << value << std::endl;
+}
+
diff --git a/examples/book/buttons/volumebutton/examplewindow.h 
b/examples/book/buttons/volumebutton/examplewindow.h
new file mode 100644
index 0000000..c0c3cd1
--- /dev/null
+++ b/examples/book/buttons/volumebutton/examplewindow.h
@@ -0,0 +1,41 @@
+//$Id: buttons.h 2 2003-01-21 13:41:59Z 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
+ */
+
+#ifndef GTKMM_EXAMPLE_BUTTONS_H
+#define GTKMM_EXAMPLE_BUTTONS_H
+
+#include <gtkmm/window.h>
+#include <gtkmm/grid.h>
+#include <gtkmm/volumebutton.h>
+
+class ExampleWindow : public Gtk::Window
+{
+public:
+  ExampleWindow();
+  virtual ~ExampleWindow();
+
+protected:
+
+  void on_value_changed(double value);
+
+  //Child widgets:
+  Gtk::Grid m_grid;
+  Gtk::VolumeButton m_button;
+};
+
+#endif //GTKMM_EXAMPLE_BUTTONS_H
diff --git a/examples/book/buttons/volumebutton/main.cc b/examples/book/buttons/volumebutton/main.cc
new file mode 100644
index 0000000..74145c8
--- /dev/null
+++ b/examples/book/buttons/volumebutton/main.cc
@@ -0,0 +1,30 @@
+//$Id: main.cc 836 2007-05-09 03:02:38Z 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
+ */
+
+#include "examplewindow.h"
+#include <gtkmm/application.h>
+
+int main(int argc, char *argv[])
+{
+  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");
+
+  ExampleWindow exampleWindow;
+
+  //Shows the window and returns when it is closed.
+  return app->run(exampleWindow);
+}


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