Getting gtkmm and cariomm from GTK and Cairo

From LSDevLinux
Jump to: navigation, search

COM requires c-style objects, but I want to store C++ (mm) objects. GTK will want to use a Gdk Window (as the surface is liable to change). Printing will need a Cairo (possibly a context or a surface).

Types

typedef Glib::RefPtr<Gdk::Window> WindowPtr;
typedef Cairo::RefPtr<Cairo::Context> ContextPtr;
typedef Cairo::RefPtr<Cairo::Surface> SurfacePtr; 

Members

WindowPtr m_window_ptr;
ContextPtr m_ctxt_ptr;

GTK (GDK)

//Glib::RefPtr<Gdk::Window> wrap(GdkWindowObject* object);

m_window_ptr = wrap(win);
m_ctxt_ptr = m_window_ptr->get_cairo_thingy();

Cairo Context

m_ctxt_ptr = ContextPtr(new Cairo::Context(the_cairo_t));

Cairo Surface

m_surface_ptr = SurfacePtr(new Cairo::Surface(the_cairo_surface_t));

It may be best to write a create() or wrap() method similar to the 'standard' ones.