Canvas Signals



Hi,
In the code below everythhing work exept for the signals. It compiles good, without a error or warning. When I run it NO seg faults, but the signals don't work. Had this too if i put a 'little'- canvas on the main canvas, the 'little'- canvas didn't give any signals.

pls help


/* File: main.cc */
/* Created by Anjuta version 1.2.2 */
/*    This file will not be overwritten */
#define DEBUG

#include <gtkmm/main.h>
#include <libgnomecanvasmm/init.h>

#ifdef DEBUG
   #include <iostream>
#endif

#include "WndMain.h"

int main(int argc, char* argv[])
{
#ifdef DEBUG
   std::cout << "Debuging is turned on!\n";
#endif
 Gnome::Canvas::init();
 Gtk::Main app(argc, argv);

 WndMain* mainwin = new WndMain();
 app.run(*mainwin);

 return 0;
}

/*
* File: WndMain.h
* Created by: Bart <bartverstraete77 hotmail com>
* Created on: Sat Feb 19 21:13:47 2005
*/

#ifndef _WNDMAIN_H_
#define _WNDMAIN_H_

#include <libgnomecanvasmm/canvas.h>
#include <gtkmm/window.h>
#include <gtkmm/scrolledwindow.h>

#ifdef DEBUG
   #include <iostream>
#endif

class WndMain : public Gtk::Window
{
public:
   WndMain();
   virtual ~WndMain();
   void read_settings();
   void make_window(bool);
protected:
   bool on_canvas_button_press(GdkEventButton*);
   bool on_canvas_button_release(GdkEventButton*);
   bool on_canvas_enter_notify(GdkEventCrossing*);
   bool on_canvas_leave_notify(GdkEventCrossing*);
   bool on_item_event(GdkEvent*, Gnome::Canvas::Item*);
Glib::ustring* m_ptrAppTitle;
   bool m_aa;
   int m_wwidth, m_wheight, m_cwidth, m_cheight;
   Gdk::Color* m_ptrBgColorCanvas;
   Gtk::ScrolledWindow* m_ptrScrolledWindow;
   Gnome::Canvas::Canvas* m_ptrCanvas;
};
#endif /*_WNDMAIN_H_*/
/*
* File: WndMain.h
* Created by: Bart <bartverstraete77 hotmail com>
* Created on: Sat Feb 19 21:13:47 2005
*/

#include "WndMain.h"

WndMain::WndMain()
{
   read_settings();

   // Set the window property's here
   set_title(*m_ptrAppTitle);
   set_border_width(0);
   set_size_request(m_wwidth, m_wheight);
if(m_aa)
       m_ptrCanvas = Gtk::manage(new Gnome::Canvas::CanvasAA());
   else
       m_ptrCanvas = Gtk::manage(new Gnome::Canvas::Canvas());
   m_ptrCanvas->set_flags(Gtk::CAN_FOCUS);
   m_ptrCanvas->grab_focus();
   m_ptrCanvas->set_size_request(m_cwidth, m_cheight);
   m_ptrCanvas->set_scroll_region(0, 0, m_cwidth, m_cheight);
   m_ptrCanvas->set_center_scroll_region(true);
   m_ptrCanvas->modify_bg(Gtk::STATE_NORMAL, *m_ptrBgColorCanvas);

   m_ptrScrolledWindow = Gtk::manage(new Gtk::ScrolledWindow());
m_ptrScrolledWindow->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS);
   m_ptrScrolledWindow->add(*m_ptrCanvas);
add(*m_ptrScrolledWindow); show_all_children(); // Atache signals m_ptrCanvas->signal_button_press_event().connect(sigc::mem_fun(*this, &WndMain::on_canvas_button_press)); m_ptrCanvas->signal_button_release_event().connect(sigc::mem_fun(*this, &WndMain::on_canvas_button_release)); m_ptrCanvas->signal_enter_notify_event().connect(sigc::mem_fun(*this, &WndMain::on_canvas_enter_notify)); m_ptrCanvas->signal_leave_notify_event().connect(sigc::mem_fun(*this, &WndMain::on_canvas_leave_notify));
}

WndMain::~WndMain()
{
}

void WndMain::read_settings()
{
   // TODO: Read the settings out of a file or something
   // TODO: Change the bgcolor string for the canvas to a Gdk::Color
// If Setting has no value, give it the default value
   if(!m_ptrAppTitle)
       m_ptrAppTitle = new Glib::ustring("Gnome::Canvas");
   if(!m_aa)
       m_aa = true;
   if(!m_wwidth)
       m_wwidth = 640;
   if(!m_wheight)
       m_wheight = 480;
   if(!m_cwidth)
       m_cwidth = 1280;
   if(!m_cheight)
       m_cheight = 960;
   if(!m_ptrBgColorCanvas)
       m_ptrBgColorCanvas = new Gdk::Color("snow");
}

bool WndMain::on_canvas_button_press(GdkEventButton* button)
{
#ifdef DEBUG
std::cout << "Button #" << button->button << " on the canvas is pressed!\n";
#endif
   return false;
}

bool WndMain::on_canvas_button_release(GdkEventButton* button)
{
#ifdef DEBUG
std::cout << "Button #" << button->button << " on the canvas is released!\n";
#endif
   return false;
}

bool WndMain::on_canvas_enter_notify(GdkEventCrossing* eventcrossing)
{
#ifdef DEBUG
   std::cout << "I entered the canvas!\n";
#endif
   return false;
}

bool WndMain::on_canvas_leave_notify(GdkEventCrossing* eventcrossing)
{
#ifdef DEBUG
   std::cout << "I left the canvas!\n";
#endif
   return false;
}

bool WndMain::on_item_event(GdkEvent* event, Gnome::Canvas::Item* item)
{
#ifdef DEBUG
   std::cout << "Event #" << event->type << std::endl;
#endif
   return false;
}



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