248 |
#endif |
#endif |
249 |
|
|
250 |
m_lineNrBuffer = Gtk::TextBuffer::create(m_tagTable); |
m_lineNrBuffer = Gtk::TextBuffer::create(m_tagTable); |
251 |
|
m_lineNrView.set_size_request(22,14); |
252 |
m_lineNrView.set_buffer(m_lineNrBuffer); |
m_lineNrView.set_buffer(m_lineNrBuffer); |
253 |
m_lineNrView.set_left_margin(3); |
m_lineNrView.set_left_margin(3); |
254 |
m_lineNrView.set_right_margin(3); |
m_lineNrView.set_right_margin(3); |
255 |
m_lineNrTextViewSpacer.set_size_request(5); |
m_lineNrView.property_editable() = false; |
256 |
|
m_lineNrView.property_sensitive() = false; |
257 |
|
m_lineNrTextViewSpacer.set_size_request(5,14); |
258 |
|
m_lineNrTextViewSpacer.property_editable() = false; |
259 |
|
m_lineNrTextViewSpacer.property_sensitive() = false; |
260 |
{ |
{ |
261 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if 1 //(GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
262 |
Gdk::Color color; |
Gdk::Color color; |
263 |
#else |
#else |
264 |
Gdk::RGBA color; |
Gdk::RGBA color; |
265 |
#endif |
#endif |
266 |
color.set("#F5F5F5"); |
color.set("#F5F5F5"); |
267 |
GtkWidget* widget = (GtkWidget*) m_lineNrView.gobj(); |
GtkWidget* widget = (GtkWidget*) m_lineNrView.gobj(); |
268 |
#if GTK_MAJOR_VERSION < 3 |
#if GTK_MAJOR_VERSION < 3 || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION <= 24) |
269 |
gtk_widget_modify_base(widget, GTK_STATE_NORMAL, color.gobj()); |
gtk_widget_modify_base(widget, GTK_STATE_NORMAL, color.gobj()); |
270 |
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color.gobj()); |
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color.gobj()); |
271 |
#endif |
#endif |
272 |
} |
} |
273 |
{ |
{ |
274 |
#if (GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
#if 1 //(GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION < 90) || GTKMM_MAJOR_VERSION < 2 |
275 |
Gdk::Color color; |
Gdk::Color color; |
276 |
#else |
#else |
277 |
Gdk::RGBA color; |
Gdk::RGBA color; |
278 |
#endif |
#endif |
279 |
color.set("#EEEEEE"); |
color.set("#EEEEEE"); |
280 |
GtkWidget* widget = (GtkWidget*) m_lineNrTextViewSpacer.gobj(); |
GtkWidget* widget = (GtkWidget*) m_lineNrTextViewSpacer.gobj(); |
281 |
#if GTK_MAJOR_VERSION < 3 |
#if GTK_MAJOR_VERSION < 3 || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION <= 24) |
282 |
gtk_widget_modify_base(widget, GTK_STATE_NORMAL, color.gobj()); |
gtk_widget_modify_base(widget, GTK_STATE_NORMAL, color.gobj()); |
283 |
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color.gobj()); |
gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color.gobj()); |
284 |
#endif |
#endif |
389 |
return fontSize; |
return fontSize; |
390 |
} |
} |
391 |
|
|
392 |
void ScriptEditor::setFontSize(int size, bool save) { |
void ScriptEditor::setFontSize(int sizePt, bool save) { |
393 |
//printf("setFontSize(%d,%d)\n", size, save); |
//printf("setFontSize(%d,%d)\n", size, save); |
394 |
|
|
395 |
|
// make sure the real size on the screen for the editor's font is consistent |
396 |
|
// on all screens (which otherwise may vary between models and DPI settings) |
397 |
|
const double referenceDPI = 96; |
398 |
|
double dpi = Gdk::Screen::get_default()->get_resolution(); |
399 |
|
double sizePx = sizePt * dpi / referenceDPI; |
400 |
|
|
401 |
#if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 20) |
#if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION < 20) |
402 |
Pango::FontDescription fdesc; |
Pango::FontDescription fdesc; |
403 |
fdesc.set_family("monospace"); |
fdesc.set_family("monospace"); |
406 |
if (macIsMinMac10_6()) |
if (macIsMinMac10_6()) |
407 |
fdesc.set_family("Menlo"); |
fdesc.set_family("Menlo"); |
408 |
# endif |
# endif |
409 |
fdesc.set_size(size * PANGO_SCALE); |
fdesc.set_size(sizePx * PANGO_SCALE); |
410 |
# if GTKMM_MAJOR_VERSION < 3 |
# if GTKMM_MAJOR_VERSION < 3 |
411 |
m_lineNrView.modify_font(fdesc); |
m_lineNrView.modify_font(fdesc); |
412 |
m_textView.modify_font(fdesc); |
m_textView.modify_font(fdesc); |
428 |
} |
} |
429 |
m_css->load_from_data( |
m_css->load_from_data( |
430 |
"* {" |
"* {" |
431 |
" font: " + ToString(size) + " " + family + ";" |
" font: " + ToString(sizePt) + "pt " + family + ";" |
432 |
"}" |
"}" |
433 |
); |
); |
434 |
#endif |
#endif |
435 |
if (save) Settings::singleton()->scriptEditorFontSize = size; |
if (save) Settings::singleton()->scriptEditorFontSize = sizePt; |
436 |
} |
} |
437 |
|
|
438 |
void ScriptEditor::setScript(gig::Script* script) { |
void ScriptEditor::setScript(gig::Script* script) { |
448 |
//printf("text : '%s'\n", txt.c_str()); |
//printf("text : '%s'\n", txt.c_str()); |
449 |
m_textBuffer->set_text(txt); |
m_textBuffer->set_text(txt); |
450 |
m_textBuffer->set_modified(false); |
m_textBuffer->set_modified(false); |
451 |
|
|
452 |
|
// on Gtk 3 the respective text change callback would not be called, so force this update here |
453 |
|
if (txt.empty()) |
454 |
|
updateLineNumbers(); |
455 |
} |
} |
456 |
|
|
457 |
void ScriptEditor::updateLineNumbers() { |
void ScriptEditor::updateLineNumbers() { |
458 |
const int n = m_textBuffer->get_line_count(); |
int n = m_textBuffer->get_line_count(); |
459 |
const int old = m_lineNrBuffer->get_line_count(); |
int old = m_lineNrBuffer->get_line_count(); |
460 |
if (n == old) return; |
if (n == old && old > 1) return; |
461 |
|
if (n < 1) n = 1; |
462 |
const int digits = log10(n) + 1; |
const int digits = log10(n) + 1; |
463 |
const int bufSz = digits + 2; |
const int bufSz = digits + 2; |
464 |
char* buf = new char[bufSz]; |
char* buf = new char[bufSz]; |
759 |
//TODO: event throttling would be a good idea here |
//TODO: event throttling would be a good idea here |
760 |
updateIssueTooltip(e); |
updateIssueTooltip(e); |
761 |
#endif |
#endif |
762 |
#if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION <= 22) |
#if GTKMM_MAJOR_VERSION < 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION <= 24) |
763 |
return ManagedWindow::on_motion_notify_event(e); |
return ManagedWindow::on_motion_notify_event(e); |
764 |
#else |
#else |
765 |
Gdk::EventMotion em = Glib::wrap(e, true); |
Gdk::EventMotion em = Glib::wrap(e, true); |