[gtkmm] DrawingArea Dilema



Hi List,

I am working on a small personal project. I want to use drawing area. I am using libglademm to generate the GUI. Below is what I am doing so far. This will not compile.....and I can't figure out what the deal is...based on drawing area examples I have found.

I would greatly appreciate it if anyone could point me in the right direction as to what I am doing wrong.

thanks,
Mike

CODE:
#include <libglademm/xml.h>
#include <gtkmm.h>

Gtk::Window* pWindow = 0;
Gtk::DrawingArea* pDrawingArea = 0;

void on_quit1_activate()
{
 pWindow->hide();
}

bool on_expose_event(GdkEventExpose*)
{
 Glib::RefPtr<Gdk::Window> win = get_window();
 Glib::RefPtr<Gdk::GC> 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;
}

int main (int argc, char *argv[])
{
 Gtk::Main kit(argc, argv);

 //Load the Glade file and instantiate its widgets:
 Glib::RefPtr<Gnome::Glade::Xml> refXml;
 try
 {
   refXml = Gnome::Glade::Xml::create("project1.glade");
 }
 catch(const Gnome::Glade::XmlError& ex)
 {
   return 1;
 }

 refXml->get_widget("window1", pWindow);
 if(pWindow)
   {
     Gtk::ImageMenuItem* pMenuItem = 0;
     refXml->get_widget("quit1", pMenuItem);
     if(pMenuItem)
   {
    pMenuItem->signal_activate().connect(SigC::slot(&on_quit1_activate));
   }

     refXml->get_widget("drawingarea1", pDrawingArea);
     if(pDrawingArea)
   {
pDrawingArea->signal_expose_event().connect(SigC::slot(&on_expose_event));
   }

     kit.run(*pWindow);
   }

 return 0;
}


Compiling Error Message:
[mike mike playball]$ g++ main.cc -o main `pkg-config gtkmm-2.0 libglademm-2.0 --cflags --libs`
main.cc: In function `bool on_expose_event(GdkEventExpose*)':
main.cc:14: error: `get_window' undeclared (first use this function)
main.cc:14: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cc:15: error: `get_style' undeclared (first use this function)





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