Skip to content

Getting gtkmm and cariomm from GTK and Cairo

marksvc edited this page Jun 17, 2021 · 1 revision

Note: This page contains old documentation from 2006, but may still be helpful. And it would still be okay to update, correct, and add to this page.

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).

Table of Contents

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)

 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.

Clone this wiki locally