View Full Version : Wrapping Scintilla into a C++ object

March 12th, 2009, 03:10 PM
I want to use Scintilla to manage highlighted text editing in a program I'm making with Gtkmm, and I'm investigating ways of integrating the two. Currently, I'm using a method something like this:

class MyScint
GtkWidget* cEditor = scintilla_new();
sci = SCINTILLA(cEditor);
scintilla_set_id(sci, 0);

editor = Glib::wrap(cEditor);

Gtk::Widget& getWidget()
return *editor;

int _scintillaSendMessage(int message, int param1 = 0, int param2 = 0)
return scintilla_send_message(sci, message, param1, param2);

// void setMarginType(int, int) ...
// ...

Gtk::Widget* editor;
ScintillaObject* sci;

It works well enough, but I wonder if a more logical and convenient method might be to make a custom widget, with the widget returned by scintilla_new used as the underlying object. Unfortunately, I've been having a hard time understanding how to do this. Can anyone suggest what to do? Thanks.

March 12th, 2009, 08:58 PM
Out of interest why not use gtksourceviewmm (http://projects.gnome.org/gtksourceviewmm/)? it works pretty nicely.

If you are going to wrap the scintilla widget you might as well do it properly and get all the gtkmm niceties this guide (http://www.gtkmm.org/docs/gtkmm-2.4/docs/tutorial/html/chapter-wrapping-c-libraries.html) will show you how to do it.

March 13th, 2009, 12:10 AM
Thankyou, I've looked at some GtkSourceView docs and it looks a lot simpler than Scintilla. As long as it's supported on at least Linux and Windows platforms I think I'll use it.

Thanks for the link about wrapping C Libraries also, that may come in useful.

March 13th, 2009, 12:13 AM
If you do go with gtksourceviewmm you might find this link useful, it was a blog post I did on how to set the highlighting.


March 13th, 2009, 03:20 AM
Geany uses scintilla as it's editor, but I'm not sure if it's in C++. Check it out though.

(and scintilla better than gtksourceview from my experiences - in anjuta at least.)