]> git.llucax.com Git - z.facultad/75.42/plaqui.git/commitdiff
le cambie el nombre a las clases y a los archivos y ahora el popup anda bien, rotar...
authorNicolás Dimov <ndimov@gmail.com>
Fri, 24 Oct 2003 23:21:15 +0000 (23:21 +0000)
committerNicolás Dimov <ndimov@gmail.com>
Fri, 24 Oct 2003 23:21:15 +0000 (23:21 +0000)
13 files changed:
Constructor/cistern.cpp [new file with mode: 0644]
Constructor/cistern.h [new file with mode: 0644]
Constructor/conduct.cpp [moved from Constructor/canio.cpp with 84% similarity]
Constructor/conduct.h [moved from Constructor/canio.h with 61% similarity]
Constructor/constructor.cpp
Constructor/constructor.h
Constructor/item.cpp
Constructor/item.h
Constructor/splitter.cpp [moved from Constructor/codo.cpp with 86% similarity]
Constructor/splitter.h [moved from Constructor/y.h with 66% similarity]
Constructor/tanque_null.png [new file with mode: 0644]
Constructor/union.cpp [moved from Constructor/y.cpp with 85% similarity]
Constructor/union.h [moved from Constructor/codo.h with 63% similarity]

diff --git a/Constructor/cistern.cpp b/Constructor/cistern.cpp
new file mode 100644 (file)
index 0000000..31bd367
--- /dev/null
@@ -0,0 +1,49 @@
+#include "cistern.h"
+
+Cistern::Cistern()
+{
+       imageE = Gdk::Pixbuf::create_from_file("tanque_e.png");
+       imageO = Gdk::Pixbuf::create_from_file("tanque_o.png");
+       null = Gdk::Pixbuf::create_from_file("null.png");
+       imgActual = 0;
+       image = imageE;
+       set_size_request(image->get_width(), image->get_height());
+}
+
+Cistern::~Cistern()
+{
+}
+
+bool Cistern::on_button_press_event(GdkEventButton *event)
+{
+       int w, h;
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
+               image = null; 
+               image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
+               imgActual++;
+               switch (imgActual) {
+                       case 1:
+                               image = imageO;
+                               break;
+                       default: 
+                               imgActual = 0;
+                               image = imageE;                 
+               }
+               get_size_request(w, h);
+               set_size_request(h, w);         
+               image->render_to_drawable(get_window(),get_style()->get_black_gc(),0,0,0,0,image->get_width(),image->get_height(),Gdk::RGB_DITHER_NONE,0,0);
+       }
+       if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 3)){
+               menu_popup.popup(event->button, event->time);
+                return true; //It has been handled.
+       }
+       return true;
+}
+
+void Cistern::on_menu_popup_rotar()
+{
+       GdkEventButton event; 
+               event.type = GDK_BUTTON_PRESS;
+               event.button = 2;
+       Cistern::on_button_press_event(&event);
+}
diff --git a/Constructor/cistern.h b/Constructor/cistern.h
new file mode 100644 (file)
index 0000000..3fb32ba
--- /dev/null
@@ -0,0 +1,20 @@
+// cistern.h
+#ifndef _CISTERN_H_
+#define _CISTERN_H_
+
+#include "item.h"
+
+class Cistern : public CItem {
+       public:
+               Cistern();
+               virtual ~Cistern();
+               virtual bool on_button_press_event(GdkEventButton *event);
+               virtual void on_menu_popup_rotar();
+       private:
+               int imgActual;  
+       
+               Glib::RefPtr<Gdk::Pixbuf> imageE; // 0 
+               Glib::RefPtr<Gdk::Pixbuf> imageO; // 1
+               Glib::RefPtr<Gdk::Pixbuf> null; 
+};
+#endif
similarity index 84%
rename from Constructor/canio.cpp
rename to Constructor/conduct.cpp
index c458079d03e67f951d4e4ec551086cfedbb58113..075f645e264060a3638f30fbb56b77455b8d263c 100644 (file)
@@ -1,6 +1,6 @@
-#include "canio.h"
+#include "conduct.h"
 
-Canio::Canio()
+Conduct::Conduct()
 {
        imageN = Gdk::Pixbuf::create_from_file("canio_n.png");
        imageS = Gdk::Pixbuf::create_from_file("canio_s.png");
@@ -10,11 +10,11 @@ Canio::Canio()
        set_size_request(image->get_width(), image->get_height());
 }
 
-Canio::~Canio()
+Conduct::~Conduct()
 {
 }
 
-bool Canio::on_button_press_event(GdkEventButton *event)
+bool Conduct::on_button_press_event(GdkEventButton *event)
 {
        int w, h;
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button ==2)){
@@ -40,10 +40,10 @@ bool Canio::on_button_press_event(GdkEventButton *event)
        return true;
 }
 
-void Canio::on_menu_popup_generic()
+void Conduct::on_menu_popup_rotar()
 {
        GdkEventButton event; 
                event.type = GDK_BUTTON_PRESS;
                event.button = 2;
-       Canio::on_button_press_event(&event);
+       Conduct::on_button_press_event(&event);
 }
similarity index 61%
rename from Constructor/canio.h
rename to Constructor/conduct.h
index 7093d39d82c78b127a538e46955c1786d4267d66..2a44ce15458819191b119c9ed9725a126a40f483 100644 (file)
@@ -1,15 +1,15 @@
-// canio.h
-#ifndef _CANIO_H_
-#define _CANIO_H_
+// Conduct.h
+#ifndef _CONDUCT_H_
+#define _CONDUCT_H_
 
 #include "item.h"
 
-class Canio : public CItem {
+class Conduct : public CItem {
        public:
-               Canio();
-               virtual ~Canio();
+               Conduct();
+               virtual ~Conduct();
                virtual bool on_button_press_event(GdkEventButton *event);
-               virtual void on_menu_popup_generic();
+               virtual void on_menu_popup_rotar();
        private:
                int imgActual;  
        
index fe4b3636817e86e653bbe4805e0b6d239cfa9209..19a59729b57568536790cc718c04e9af3d365ffe 100644 (file)
@@ -117,14 +117,16 @@ void Constructor::on_item_drop_drag_received(const Glib::RefPtr<Gdk::DragContext
   {
        CItem *a;
        if (strcmp((const char *)selection_data->data, "item_codo.png")==0) 
-               a = Gtk::manage( new Codo() );
+               a = Gtk::manage( new Splitter() );
        else    if (strcmp((const char *)selection_data->data, "item_canio.png")==0) 
-                               a = Gtk::manage( new Canio() );
-                       else if (strcmp((const char *)selection_data->data, "item_y.png")==0) {
-                                               a = Gtk::manage( new Y() );
-                                       } else {
-                                                       a = Gtk::manage( new CItem((const char *)selection_data->data) );
-                                               }
+                               a = Gtk::manage( new Conduct() );
+                       else if (strcmp((const char *)selection_data->data, "item_y.png")==0) 
+                                               a = Gtk::manage( new Union() );
+                                       else if (strcmp((const char *)selection_data->data, "item_tanque.png")==0) 
+                                                               a = Gtk::manage( new Cistern() );
+                                                       else
+                                                               a = Gtk::manage( new CItem((const char *)selection_data->data) );
+                                               
                workplace->put(*a, i*32, j*32);
                // Seteo la lista de tipos de drags 
                a->drag_source_set(listTargets);
index 104cace7a7f5ad47c44f848a7799b2b758ebf543..1556d73987015774784f0c80d689d0a1c4d3e5d1 100644 (file)
 #include <gtkmm/scrolledwindow.h>
 #include "workplace.h"
 #include "item.h"
-#include "codo.h"
-#include "canio.h"
-#include "y.h"
-
+#include "splitter.h"
+#include "conduct.h"
+#include "union.h"
+#include "cistern.h"
 
 class Constructor : public Gtk::Window {
        public: 
index 9e97bef99561d452f125958ff816a3c335fec9d0..720a86c69ad54fa62524e21fea59cff75beb1949 100644 (file)
@@ -11,9 +11,9 @@ CItem::CItem()
 {
        menu_image.set(Gtk::Stock::CANCEL, Gtk::ICON_SIZE_MENU);
        Gtk::Menu::MenuList& menulist = menu_popup.items();
-    menulist.push_back( Gtk::Menu_Helpers::MenuElem("Opcion", SigC::slot(*this, &CItem::on_menu_popup_generic) ) );
-    menulist.push_back( Gtk::Menu_Helpers::MenuElem("Rotar", Gtk::Menu::AccelKey("<control>r"),SigC::slot(*this, &CItem::on_menu_popup_generic) ) );
-    menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Eliminar", menu_image,SigC::slot(*this, &CItem::on_menu_popup_generic) ) ) ;
+    menulist.push_back( Gtk::Menu_Helpers::MenuElem("Opcion", SigC::slot(*this, &CItem::on_menu_popup_opcion) ) );
+    menulist.push_back( Gtk::Menu_Helpers::MenuElem("Rotar", Gtk::Menu::AccelKey("<control>r"),SigC::slot(*this, &CItem::on_menu_popup_rotar) ) );
+    menulist.push_back( Gtk::Menu_Helpers::ImageMenuElem("Eliminar", menu_image,SigC::slot(*this, &CItem::on_menu_popup_eliminar) ) ) ;
        menu_popup.accelerate(*this);
 }
 
@@ -32,7 +32,14 @@ bool CItem::on_expose_event(GdkEventExpose* event)
        return true;
 }
 
-void CItem::on_menu_popup_generic()
+void CItem::on_menu_popup_opcion()
+{
+}
+
+void CItem::on_menu_popup_rotar()
+{
+}
+
+void CItem::on_menu_popup_eliminar()
 {
-   std::cout << "A popup menu item was selected." << std::endl;
 }
index 0b51b305cd155333ca0a8c287b034ac192aab89a..5aef5c60a4d9716de0e08b6a49c84dc71b62a244 100644 (file)
@@ -8,14 +8,15 @@
 #include <gtkmm.h>
 #include <gdkmm.h>
 
-
 class CItem:public Gtk::DrawingArea {
 public:
        CItem();
        CItem(const char *filename);
        ~CItem();
        virtual bool on_expose_event(GdkEventExpose* event);
-       virtual void on_menu_popup_generic();
+       virtual void on_menu_popup_opcion();
+       virtual void on_menu_popup_rotar();
+       virtual void on_menu_popup_eliminar();
        Glib::RefPtr<Gdk::Pixbuf> get_image() { return image; }
 protected:
        Gtk::Menu menu_popup;
similarity index 86%
rename from Constructor/codo.cpp
rename to Constructor/splitter.cpp
index f3466a89861ec3181b3e6a10c3da8746ddd269f5..f5c96fb4c0129dd1e0e137684970a8ea17bf91ce 100644 (file)
@@ -1,6 +1,6 @@
-#include "codo.h"
+#include "splitter.h"
 
-Codo::Codo()
+Splitter::Splitter()
 {
        imageN = Gdk::Pixbuf::create_from_file("codo_n.png");
        imageS = Gdk::Pixbuf::create_from_file("codo_s.png");
@@ -12,11 +12,11 @@ Codo::Codo()
        set_size_request(image->get_width(), image->get_height());
 }
 
-Codo::~Codo()
+Splitter::~Splitter()
 {
 }
 
-bool Codo::on_button_press_event(GdkEventButton *event)
+bool Splitter::on_button_press_event(GdkEventButton *event)
 {
        if ((event->type == GDK_BUTTON_PRESS) && ( event->button == 2)){
                image = null;   
@@ -45,10 +45,10 @@ bool Codo::on_button_press_event(GdkEventButton *event)
        }
        return true;
 }
-void Codo::on_menu_popup_generic()
+void Splitter::on_menu_popup_rotar()
 {
        GdkEventButton event; 
                event.type = GDK_BUTTON_PRESS;
                event.button = 2;
-       Codo::on_button_press_event(&event);
+       Splitter::on_button_press_event(&event);
 }
similarity index 66%
rename from Constructor/y.h
rename to Constructor/splitter.h
index eaf4911974603df7b72daf0b6713dceba1c6028f..c814988de50df5010cdba9add861f74601596819 100644 (file)
@@ -1,15 +1,15 @@
-// y.h
-#ifndef _Y_H_
-#define _Y_H_
+// Splitter.h
+#ifndef _SPLITTER_H_
+#define _SPLITTER_H_
 
 #include "item.h"
 
-class Y : public CItem {
+class Splitter : public CItem {
        public:
-               Y();
-               virtual ~Y();
+               Splitter();
+               virtual ~Splitter();
                virtual bool on_button_press_event(GdkEventButton *event);
-               virtual void on_menu_popup_generic();
+               virtual void on_menu_popup_rotar();
        private:
                int imgActual;  
        
diff --git a/Constructor/tanque_null.png b/Constructor/tanque_null.png
new file mode 100644 (file)
index 0000000..9ae5e50
Binary files /dev/null and b/Constructor/tanque_null.png differ
similarity index 85%
rename from Constructor/y.cpp
rename to Constructor/union.cpp
index afc5e8c62c11ef42b42f0f662b8f55dc5eba660f..427c672b1764df8452f1ad39552d981b1dd5b69f 100644 (file)
@@ -1,6 +1,6 @@
-#include "y.h"
+#include "union.h"
 
-Y::Y()
+Union::Union()
 {
        imageN = Gdk::Pixbuf::create_from_file("y_n.png");
        imageS = Gdk::Pixbuf::create_from_file("y_s.png");
@@ -12,11 +12,11 @@ Y::Y()
        set_size_request(image->get_width(), image->get_height());
 }
 
-Y::~Y()
+Union::~Union()
 {
 }
 
-bool Y::on_button_press_event(GdkEventButton *event)
+bool Union::on_button_press_event(GdkEventButton *event)
 {
        int w,h;
        if ((event->type == GDK_BUTTON_PRESS) && (event->button == 2 )){
@@ -48,10 +48,14 @@ bool Y::on_button_press_event(GdkEventButton *event)
        return true;
 }
 
-void Y::on_menu_popup_generic()
+void Union::on_menu_popup_rotar()
 {
        GdkEventButton event; 
                event.type = GDK_BUTTON_PRESS;
                event.button = 2;
-       Y::on_button_press_event(&event);
+       Union::on_button_press_event(&event);
+}
+
+void Union::on_menu_popup_eliminar()
+{
 }
similarity index 63%
rename from Constructor/codo.h
rename to Constructor/union.h
index d3d546ae67611475fce3c7f47b00fdbda81e822f..aba6543ebe155b6a1d8cf85a6a3b7c0dd9250ea1 100644 (file)
@@ -1,15 +1,16 @@
-// codo.h
-#ifndef _CODO_H_
-#define _CODO_H_
+// Union.h
+#ifndef _UNION_H_
+#define _UNION_H_
 
 #include "item.h"
 
-class Codo : public CItem {
+class Union : public CItem {
        public:
-               Codo();
-               virtual ~Codo();
+               Union();
+               virtual ~Union();
                virtual bool on_button_press_event(GdkEventButton *event);
-               virtual void on_menu_popup_generic();
+               virtual void on_menu_popup_rotar();
+               virtual void on_menu_popup_eliminar();
        private:
                int imgActual;