Esempio n. 1
0
ScreenArea::ScreenArea(int _iWidth, int _iHeight, int _iScale)
    : m_iFilterScale(1)
    , m_vFilter2x(NULL)
    , m_vFilterIB(NULL)
    , m_puiPixels(NULL)
    , m_puiDelta(NULL)
    , m_iScaledWidth(_iWidth)
    , m_iScaledHeight(_iHeight)
    , m_bEnableRender(true)
    , m_bShowCursor(true)
{
    g_assert(_iWidth >= 1 && _iHeight >= 1 && _iScale >= 1);

    m_iWidth = _iWidth;
    m_iHeight = _iHeight;
    m_iScale = _iScale;

    set_events(Gdk::EXPOSURE_MASK
        | Gdk::POINTER_MOTION_MASK
        | Gdk::ENTER_NOTIFY_MASK
        | Gdk::LEAVE_NOTIFY_MASK);

    Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, 8, 8);
    pixbuf->fill(0);

#if !GTK_CHECK_VERSION(3, 0, 0)
    m_poEmptyCursor = new Gdk::Cursor(get_display, pixbuf, 0, 0);
#else
    m_poEmptyCursor = Gdk::Cursor::create(get_display(), pixbuf, 0, 0);
#endif
}
Glib::RefPtr<Gdk::Pixbuf> ContactsTreeWidget::resizeAvatar(Glib::RefPtr<Gdk::Pixbuf> src) {
  appInstance->logEvent("ContactsTreeWidget::resizeAvatar()", SEVERITY_DEBUG);
  gint WIDTH = Utils::parseNum<gint>(appInstance->getVariable("AVATAR_WIDTH"));
  gint HEIGHT = Utils::parseNum<gint>(appInstance->getVariable("AVATAR_HEIGHT"));
  guint32 BGCOLOR = Utils::parseNum<guint32>(appInstance->getVariable("AVATAR_BGCOLOR"));
  Glib::RefPtr<Gdk::Pixbuf> bg = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, WIDTH, HEIGHT);
  bg->fill(BGCOLOR);
  gint w, h, tw, th, dx, dy;
  double sx, sy;
  w = src->get_width();
  h = src->get_height();
  if (w > h) {
    tw = WIDTH;
    th = (gint)(tw * h * 1.0 / w);
  } else {
    th = HEIGHT;
    tw = (gint)(th * w * 1.0 / h);
  }
  sx = tw * 1.0 / w;
  sy = th * 1.0 / h;
  dx = (WIDTH - tw) / 2;
  dy = (HEIGHT - th) / 2;
  src->scale(bg, dx, dy, tw, th, dx, dy, sx, sy, Gdk::INTERP_BILINEAR);
  return bg;
}
//------------------------------------------------------------------------------
void mforms::gtk::ToolBarImpl::set_selector_items(ToolBarItem *item, const std::vector<std::string> &values) {
  if (item->get_type() == mforms::SelectorItem || item->get_type() == mforms::FlatSelectorItem) {
    Gtk::ComboBoxText *w = cast<Gtk::ComboBoxText *>(item->get_data_ptr());
    if (w) {
      w->set_data("ignore_signal", (void *)1);
#if ((GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION >= 24) || GTKMM_MAJOR_VERSION > 2)
      w->remove_all();
#else
      w->clear_items();
#endif
      const int size = values.size();
      for (int i = 0; i < size; ++i)
        w->append(values[i]);

      if (w->get_active_row_number() < 0 && !values.empty())
        w->set_active_text(values[0]);

      w->set_data("ignore_signal", 0);
    }
  } else if (item->get_type() == mforms::ColorSelectorItem) {
    Gtk::ComboBox *w = cast<Gtk::ComboBox *>(item->get_data_ptr());
    if (w) {
      w->set_data("ignore_signal", (void *)1);
      Glib::RefPtr<Gtk::ListStore> model = Gtk::ListStore::create(*color_combo_columns);
      const int size = values.size();
      for (int i = 0; i < size; ++i) {
        Gtk::TreeRow row = *model->append();
        Gdk::Color color(values[i]);
        Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, false, 8, 16, 14);
        pixbuf->fill((guint32)color.get_red() << 24 | (guint32)color.get_green() << 16 | (guint32)color.get_blue() << 8);

        row[color_combo_columns->color] = values[i];
        row[color_combo_columns->image] = pixbuf;
      }

      w->set_model(model);

      if (w->get_active_row_number() < 0)
        w->set_active(0);

      w->set_data("ignore_signal", 0);
    }
  }
}