PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Gtkmm mit cairo



barton4
09-03-2008, 22:14
Hi, ich habe versucht aus der Gtkmm Anleitung etwas mit Cairo zu zeichnen: http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/sec-cairo-drawing-lines.html

habe Beispiel code aus der Anleitung etwas geändert:

.h


#include <vector>
#include <string>
#include <iostream>
#include <gtkmm.h>
#include <cairomm/context.h>
#include <gtkmm/drawingarea.h>
#include <gtkmm/main.h>
#include <gtkmm/window.h>

class CDrawTree : public Gtk::DrawingArea
{
public:
CDrawTree();
//~CDrawTree();
protected:
virtual bool on_expose_event(GdkEventExpose* event);

Glib::RefPtr<Gdk::Window> window;
Gtk::Allocation allocation;
Cairo::RefPtr<Cairo::Context> cr;

};

.cpp




CDrawTree::CDrawTree()
{
std::cout<<"debug: construct CDrawTree::CDrawTree()"<<std::endl;
}

bool CDrawTree::on_expose_event(GdkEventExpose* event)
{
window = get_window();
if(window)
{
allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();

// coordinates for the center of the window
int xc, yc;
xc = width / 2;
yc = height / 2;

cr = window->create_cairo_context();
cr->set_line_width(10.0);

// clip to the area indicated by the expose event so that we only redraw
// the portion of the window that needs to be redrawn
cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height);
cr->clip();

// draw red lines out from the center of the window
cr->set_source_rgb(0.8, 0.0, 0.0);
cr->move_to(0, 0);
cr->line_to(xc, yc);
cr->line_to(0, height);
cr->move_to(xc, yc);
cr->line_to(width, yc);
cr->stroke();
}

}


beim compilieren kommt folgende Fehlermeldungen:


martin@turion64:~/mydatastorage/myfiles/Programmieren/Stammbaum$ make
g++ `pkg-config --cflags gtkmm-2.4 cairomm-1.0` -c main.cpp -o build/main.o
g++ `pkg-config --cflags gtkmm-2.4 cairomm-1.0` -c gui_root.cpp -o build/gtk_root.o
gui_root.cpp: In member function ‘virtual bool CDrawTree::on_expose_event(GdkEventExpose*)’:
gui_root.cpp:112: error: ‘class Gdk::Window’ has no member named ‘create_cairo_context’
make: *** [gtk_root.o] Error 1
martin@turion64:~/mydatastorage/myfiles/Programmieren/Stammbaum$





//cr = window->create_cairo_context();

hat jemand ne Ahung was da noch fehlt?