From: Leandro Lucarella Date: Sat, 11 Oct 2003 23:18:46 +0000 (+0000) Subject: Se agregan ejemplos de glademm, inlcuyendo uno que levanta la interfaz de mi TP5. X-Git-Tag: svn_import~449 X-Git-Url: https://git.llucax.com/z.facultad/75.42/plaqui.git/commitdiff_plain/b19474cc8b39c63635449009203c0aa122daa631 Se agregan ejemplos de glademm, inlcuyendo uno que levanta la interfaz de mi TP5. --- diff --git a/tests/gtkmm/glademm/basic.cc b/tests/gtkmm/glademm/basic.cc new file mode 100644 index 0000000..a7c2ff1 --- /dev/null +++ b/tests/gtkmm/glademm/basic.cc @@ -0,0 +1,39 @@ +#include +#include +#include + +int main (int argc, char **argv) +{ + Gtk::Main kit(argc, argv); + + //Load the Glade file and instiate its widgets: + Glib::RefPtr refXml; + try + { + refXml = Gnome::Glade::Xml::create("basic.glade"); + } + catch(const Gnome::Glade::XmlError& ex) + { + std::cerr << ex.what() << std::endl; + return 1; + } + + //Get the Glade-instantiated Dialog: + Gtk::Dialog* pDialog = 0; + refXml->get_widget("DialogBasic", pDialog); + if(pDialog) + { + //Get the Glade-instantiated Button, and connect a signal handler: + Gtk::Button* pButton = 0; + refXml->get_widget("quit_button", pButton); + if(pButton) + { + pButton->signal_clicked().connect(SigC::slot(*pDialog, &Gtk::Dialog::hide)); //hide() will cause main::run() to end. + } + + kit.run(*pDialog); + } + + return 0; +} + diff --git a/tests/gtkmm/glademm/basic.glade b/tests/gtkmm/glademm/basic.glade new file mode 100644 index 0000000..890f08c --- /dev/null +++ b/tests/gtkmm/glademm/basic.glade @@ -0,0 +1,73 @@ + + + + + + + basic libglademm example + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + + + + 2 + True + False + 0 + + + + 5 + True + GTK_BUTTONBOX_END + 10 + + + + True + True + True + gtk-quit + True + GTK_RELIEF_NORMAL + 0 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + This is a basic libglademm example + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + + diff --git a/tests/gtkmm/glademm/midrawingarea.cc b/tests/gtkmm/glademm/midrawingarea.cc new file mode 100644 index 0000000..7439f49 --- /dev/null +++ b/tests/gtkmm/glademm/midrawingarea.cc @@ -0,0 +1,42 @@ +//$Id$ -*- c++ -*- + +/* libglademm example Copyright (C) 2003 libglademm 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 "midrawingarea.h" + +MiDrawingArea::MiDrawingArea(BaseObjectType* cobject, const Glib::RefPtr& refGlade) +: Gtk::DrawingArea(cobject) +{ + //signal_expose_event().connect(slot(*this, &MiDrawingArea::on_expose_event)); +} + +MiDrawingArea::~MiDrawingArea() +{ +} + +bool MiDrawingArea::on_expose_event(GdkEventExpose* event) +{ + Glib::RefPtr win = get_window(); + Glib::RefPtr gc = get_style()->get_black_gc(); + win->draw_line(gc, 5, 2, 5, 20); + win->draw_line(gc, 5, 11, 10, 11); + win->draw_line(gc, 10, 2, 10, 20); + win->draw_line(gc, 15, 2, 21, 2); + win->draw_line(gc, 18, 2, 18, 20); + win->draw_line(gc, 15, 20, 21, 20); + return true; // No llama otros handlers. +} diff --git a/tests/gtkmm/glademm/midrawingarea.h b/tests/gtkmm/glademm/midrawingarea.h new file mode 100644 index 0000000..f829425 --- /dev/null +++ b/tests/gtkmm/glademm/midrawingarea.h @@ -0,0 +1,37 @@ +//$Id$ -*- c++ -*- + +/* libglademm example Copyright (C) 2003 libglademm 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 LIBGLADEMM_EXAMPLE_DERIVED_DIALOG_H +#define LIBGLADEMM_EXAMPLE_DERIVED_DIALOG_H + +#include +#include + + +class MiDrawingArea : public Gtk::DrawingArea +{ +public: + MiDrawingArea(BaseObjectType* cobject, const Glib::RefPtr& refGlade); + virtual ~MiDrawingArea(); + +protected: + //Signal handlers: + virtual bool on_expose_event(GdkEventExpose* event); +}; + +#endif //LIBGLADEMM_EXAMPLE_DERIVED_WINDOW_H diff --git a/tests/gtkmm/glademm/tp5.cc b/tests/gtkmm/glademm/tp5.cc new file mode 100644 index 0000000..ef3ded5 --- /dev/null +++ b/tests/gtkmm/glademm/tp5.cc @@ -0,0 +1,43 @@ +/* + * Ejemplo dummy levantando la interfaz de mi TP5 con glade en gtkmm. + * + * para compilar: + * g++ -Wall -g `pkg-config --cflags --libs libglademm-2.0` -o tp5 tp5.cc midrawingarea.cc + * + * $Id$ + */ + +#include "midrawingarea.h" +#include + +int main (int argc, char **argv) +{ + Gtk::Main kit(argc, argv); + + //Load the Glade file and instiate its widgets: + Glib::RefPtr refXml; + try + { + refXml = Gnome::Glade::Xml::create("tp5.glade"); + } + catch(const Gnome::Glade::XmlError& ex) + { + std::cerr << ex.what() << std::endl; + return 1; + } + + Gtk::Window* pWindow = 0; + refXml->get_widget("window", pWindow); + if(pWindow) + { + MiDrawingArea* pDrawingArea = 0; + refXml->get_widget_derived("drawingarea", pDrawingArea); + if (pDrawingArea) + { + kit.run(*pWindow); + } + } + + return 0; +} + diff --git a/tests/gtkmm/glademm/tp5.glade b/tests/gtkmm/glademm/tp5.glade new file mode 100644 index 0000000..6b59147 --- /dev/null +++ b/tests/gtkmm/glademm/tp5.glade @@ -0,0 +1,1048 @@ + + + + + + + 5 + True + Trabajo Práctico V + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + + + + + True + False + 0 + + + + True + False + 5 + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + 200 + 200 + True + + + + + + + True + Dibujo + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + True + True + + + + + + 5 + True + GTK_BUTTONBOX_SPREAD + 0 + + + + True + True + True + gtk-clear + True + GTK_RELIEF_NORMAL + + + + + + + True + True + True + gtk-refresh + True + GTK_RELIEF_NORMAL + + + + + + + True + True + True + gtk-quit + True + GTK_RELIEF_NORMAL + + + + + + 0 + False + True + + + + + 0 + True + True + + + + + + True + False + 0 + + + + True + 0 + 0.5 + GTK_SHADOW_ETCHED_IN + + + + True + False + 0 + + + + True + True + Lí_nea + True + GTK_RELIEF_NORMAL + True + False + True + + + + 0 + False + False + + + + + + True + True + _Cuadrado + True + GTK_RELIEF_NORMAL + False + False + True + radiobutton_linea + + + + 0 + False + False + + + + + + True + True + _Rectángulo + True + GTK_RELIEF_NORMAL + False + False + True + radiobutton_linea + + + + 0 + False + False + + + + + + True + True + Círc_ulo + True + GTK_RELIEF_NORMAL + False + False + True + radiobutton_linea + + + + 0 + False + False + + + + + + + + True + Figura + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + False + + + + + + True + False + 0 + + + + 5 + True + 3 + 2 + False + 3 + 5 + + + + True + Nombre + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Color + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Grosor + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + 100 + True + True + True + True + 0 + + True + * + False + + + 1 + 2 + 0 + 1 + expand + + + + + + 150 + True + True + False + False + True + False + + + + True + True + False + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + True + True + Negro + + + + + + True + True + Blanco + + + + + + True + True + Rojo + + + + + + True + True + Verde + + + + + + True + True + Azul + + + + + + True + True + Cian + + + + + + True + True + Magenta + + + + + + True + True + Amarillo + + + + + + True + True + Gris + + + + + + True + True + Rojo Oscuro + + + + + + True + True + Verde Oscuro + + + + + + True + True + Azul Oscuro + + + + + + True + True + Cian Oscuro + + + + + + True + True + Magenta Oscuro + + + + + + True + True + Amarillo Oscuro + + + + + + True + True + Naranja + + + + + + + 1 + 2 + 1 + 2 + expand + + + + + + 48 + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 1 10 1 10 10 + + + 1 + 2 + 2 + 3 + expand + + + + + 0 + True + True + + + + + + True + True + gtk-add + True + GTK_RELIEF_NORMAL + + + + 0 + False + False + + + + + 0 + True + True + + + + + + 5 + True + False + 5 + + + + True + 4 + 3 + False + 0 + 2 + + + + True + Centro + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Inicio + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + Fin + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + X + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 1 + 2 + 0 + 1 + + + + + + + + True + Y + False + False + GTK_JUSTIFY_CENTER + False + False + 0 + 0.5 + 0 + 0 + + + 2 + 3 + 0 + 1 + expand + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 1000 1 10 10 + + + 1 + 2 + 1 + 2 + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 1000 1 10 10 + + + 2 + 3 + 1 + 2 + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 1000 1 10 10 + + + 1 + 2 + 2 + 3 + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 1000 1 10 10 + + + 2 + 3 + 2 + 3 + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 1000 1 10 10 + + + 1 + 2 + 3 + 4 + + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 0 0 1000 1 10 10 + + + 2 + 3 + 3 + 4 + + + + + + 0 + False + False + + + + + + True + 3 + 2 + False + 0 + 2 + + + + True + Alto + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Ancho + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Radio + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + 1 + 2 + 3 + fill + + + + + + + True + False + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 1 1000 1 10 10 + + + 1 + 2 + 0 + 1 + + + + + + + True + False + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 1 1000 1 10 10 + + + 1 + 2 + 1 + 2 + + + + + + + True + False + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 1 1000 1 10 10 + + + 1 + 2 + 2 + 3 + + + + + + 0 + False + False + + + + + 0 + False + False + + + + + 0 + False + True + + + + + + +