/[svn]/gigedit/trunk/src/gigedit/scripteditor.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/scripteditor.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3367 by schoenebeck, Tue Nov 14 18:07:25 2017 UTC revision 3368 by schoenebeck, Thu Nov 16 19:18:42 2017 UTC
# Line 253  ScriptEditor::ScriptEditor() : Line 253  ScriptEditor::ScriptEditor() :
253      m_lineNrView.set_right_margin(3);      m_lineNrView.set_right_margin(3);
254      m_lineNrTextViewSpacer.set_size_request(5);      m_lineNrTextViewSpacer.set_size_request(5);
255      {      {
256  #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
257          Gdk::Color color;          Gdk::Color color;
258  #else  #else
259          Gdk::RGBA color;          Gdk::RGBA color;
260  #endif  #endif
261          color.set("#F5F5F5");          color.set("#F5F5F5");
262          GtkWidget* widget = (GtkWidget*) m_lineNrView.gobj();          GtkWidget* widget = (GtkWidget*) m_lineNrView.gobj();
263  #if GTK_MAJOR_VERSION < 3  #if GTK_MAJOR_VERSION < 3 || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION <= 22)
264          gtk_widget_modify_base(widget, GTK_STATE_NORMAL, color.gobj());          gtk_widget_modify_base(widget, GTK_STATE_NORMAL, color.gobj());
265          gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color.gobj());          gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color.gobj());
266  #endif  #endif
267      }      }
268      {      {
269  #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
270          Gdk::Color color;          Gdk::Color color;
271  #else  #else
272          Gdk::RGBA color;          Gdk::RGBA color;
273  #endif  #endif
274          color.set("#EEEEEE");          color.set("#EEEEEE");
275          GtkWidget* widget = (GtkWidget*) m_lineNrTextViewSpacer.gobj();          GtkWidget* widget = (GtkWidget*) m_lineNrTextViewSpacer.gobj();
276  #if GTK_MAJOR_VERSION < 3  #if GTK_MAJOR_VERSION < 3 || (GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION <= 22)
277          gtk_widget_modify_base(widget, GTK_STATE_NORMAL, color.gobj());          gtk_widget_modify_base(widget, GTK_STATE_NORMAL, color.gobj());
278          gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color.gobj());          gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, color.gobj());
279  #endif  #endif
# Line 384  int ScriptEditor::currentFontSize() cons Line 384  int ScriptEditor::currentFontSize() cons
384      return fontSize;      return fontSize;
385  }  }
386    
387  void ScriptEditor::setFontSize(int size, bool save) {  void ScriptEditor::setFontSize(int sizePt, bool save) {
388      //printf("setFontSize(%d,%d)\n", size, save);      //printf("setFontSize(%d,%d)\n", size, save);
389    
390        // make sure the real size on the screen for the editor's font is consistent
391        // on all screens (which otherwise may vary between models and DPI settings)
392        const double referenceDPI = 96;
393        double dpi = Gdk::Screen::get_default()->get_resolution();
394        double sizePx = sizePt * dpi / referenceDPI;
395    
396  #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)
397      Pango::FontDescription fdesc;      Pango::FontDescription fdesc;
398      fdesc.set_family("monospace");      fdesc.set_family("monospace");
# Line 394  void ScriptEditor::setFontSize(int size, Line 401  void ScriptEditor::setFontSize(int size,
401      if (macIsMinMac10_6())      if (macIsMinMac10_6())
402          fdesc.set_family("Menlo");          fdesc.set_family("Menlo");
403  # endif  # endif
404      fdesc.set_size(size * PANGO_SCALE);      fdesc.set_size(sizePx * PANGO_SCALE);
405  # if GTKMM_MAJOR_VERSION < 3  # if GTKMM_MAJOR_VERSION < 3
406      m_lineNrView.modify_font(fdesc);      m_lineNrView.modify_font(fdesc);
407      m_textView.modify_font(fdesc);      m_textView.modify_font(fdesc);
# Line 416  void ScriptEditor::setFontSize(int size, Line 423  void ScriptEditor::setFontSize(int size,
423      }      }
424      m_css->load_from_data(      m_css->load_from_data(
425          "* {"          "* {"
426          "  font: " + ToString(size) + " " + family + ";"          "  font: " + ToString(sizePt) + "pt " + family + ";"
427          "}"          "}"
428      );      );
429  #endif  #endif
430      if (save) Settings::singleton()->scriptEditorFontSize = size;      if (save) Settings::singleton()->scriptEditorFontSize = sizePt;
431  }  }
432    
433  void ScriptEditor::setScript(gig::Script* script) {  void ScriptEditor::setScript(gig::Script* script) {

Legend:
Removed from v.3367  
changed lines
  Added in v.3368

  ViewVC Help
Powered by ViewVC