]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
Se agregan ejemplos de gtkmm.
authorLeandro Lucarella <llucax@gmail.com>
Fri, 10 Oct 2003 04:04:06 +0000 (04:04 +0000)
committerLeandro Lucarella <llucax@gmail.com>
Fri, 10 Oct 2003 04:04:06 +0000 (04:04 +0000)
tests/gtkmm.cpp [new file with mode: 0644]
tests/gtkmm_hello.cpp [new file with mode: 0644]
tests/gtkmm_hello.h [new file with mode: 0644]
tests/gtkmm_hello_main.cpp [new file with mode: 0644]

diff --git a/tests/gtkmm.cpp b/tests/gtkmm.cpp
new file mode 100644 (file)
index 0000000..116c1e0
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Ejemplo de GTK--
+ * 
+ * Para compilar: g++ -Wall -g `pkg-config gtkmm-2.0 --cflags --libs` -o gtkmm gtkmm.cpp
+ */
+
+#include <gtkmm.h>
+
+int main(int argc, char *argv[]) {
+    // Procesa argumentos.
+    Gtk::Main kit(argc, argv);
+    // Crea ventana.
+    Gtk::Window window;
+    // Corre programa (hasta que se cierra ventana ppal.
+    Gtk::Main::run(window);
+    // Sale.
+    return 0;
+}
diff --git a/tests/gtkmm_hello.cpp b/tests/gtkmm_hello.cpp
new file mode 100644 (file)
index 0000000..8ba523d
--- /dev/null
@@ -0,0 +1,29 @@
+#include "gtkmm_hello.h"
+#include <iostream>
+
+HelloWorld::HelloWorld()
+: m_button("Hello World") // creates a new button with the label "Hello World".
+{
+  // Sets the border width of the window.
+  set_border_width(10);
+
+  // When the button receives the "clicked" signal, it will call the
+  // hello() method. The hello() method is defined below.
+  m_button.signal_clicked().connect(SigC::slot(*this, &HelloWorld::on_button_clicked));
+
+  // This packs the button into the Window (a container).
+  add(m_button);
+
+  // The final step is to display this newly created widget...
+  m_button.show();
+}
+
+HelloWorld::~HelloWorld()
+{
+}
+
+void HelloWorld::on_button_clicked()
+{
+  std::cout << "Hello World" << std::endl;
+}
+
diff --git a/tests/gtkmm_hello.h b/tests/gtkmm_hello.h
new file mode 100644 (file)
index 0000000..18cfba2
--- /dev/null
@@ -0,0 +1,23 @@
+#ifndef GTKMM_EXAMPLE_HELLOWORLD_H
+#define GTKMM_EXAMPLE_HELLOWORLD_H
+
+#include <gtkmm/button.h>
+#include <gtkmm/window.h>
+
+class HelloWorld : public Gtk::Window
+{
+
+public:
+  HelloWorld();
+  virtual ~HelloWorld();
+
+protected:
+  //Signal handlers:
+  virtual void on_button_clicked();
+
+  //Member widgets:
+  Gtk::Button m_button;
+
+};
+
+#endif // GTKMM_EXAMPLE_HELLOWORLD_H
diff --git a/tests/gtkmm_hello_main.cpp b/tests/gtkmm_hello_main.cpp
new file mode 100644 (file)
index 0000000..538ae20
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Hello World de GTK--
+ * 
+ * Para compilar:
+ *
+ * g++ -Wall -g `pkg-config gtkmm-2.0 --cflags --libs` -o gtkmm_hello \
+ *     gtkmm_hello.cpp gtkmm_hello_main.cpp
+ *
+ */
+
+#include <gtkmm/main.h>
+#include "gtkmm_hello.h"
+
+int main (int argc, char *argv[])
+{
+  Gtk::Main kit(argc, argv);
+  HelloWorld helloworld;
+  Gtk::Main::run(helloworld); //Shows the window and returns when it is closed.
+
+  return 0;
+}