Пример #1
0
void CheckButton::_notification(int p_what) {

	if (p_what == NOTIFICATION_THEME_CHANGED) {

		_set_internal_margin(MARGIN_RIGHT, get_icon_size().width);
	} else if (p_what == NOTIFICATION_DRAW) {

		RID ci = get_canvas_item();

		Ref<Texture> on = Control::get_icon("on");
		Ref<Texture> off = Control::get_icon("off");

		Ref<StyleBox> sb = get_stylebox("normal");
		Vector2 ofs;
		Size2 tex_size = get_icon_size();

		ofs.x = get_size().width - (tex_size.width + sb->get_margin(MARGIN_RIGHT));
		ofs.y = (get_size().height - tex_size.height) / 2;

		if (is_pressed())
			on->draw(ci, ofs);
		else
			off->draw(ci, ofs);
	}
}
Пример #2
0
	//	Draw the icons into the window
	//
	void Container::draw_icons(void)
	{
		Busy dummy;
		for (size_t i=0; i<icon_list.size(); ++i)
			icon_list[i]->update_highlight();
		if ((mouse_over_icon >= 0) && ((size_t)mouse_over_icon < icon_list.size()))
			icon_list[mouse_over_icon]->set_highlight(true);
		float uoffset = 31.0/256.0, voffset = 31.0/256.0;
#ifdef	NEW_TEXTURES
		bind_texture(icons_text);
#else	/* NEW_TEXTURES */
		get_and_set_texture_id(icons_text);
		voffset *= -1;
#endif	/* NEW_TEXTURES */
		glColor3f(1.0f,1.0f,1.0f);
		glBegin(GL_QUADS);
		for (size_t i=0; i<icon_list.size(); ++i)
		{
			std::pair<float, float> uv = icon_list[i]->get_uv();
			draw_2d_thing( uv.first, uv.second, uv.first+uoffset, uv.second+voffset, i*get_icon_size(), 0, i*get_icon_size()+(get_icon_size()-1), get_icon_size() );
		}
		glEnd();
		if (show_help_text && (mouse_over_icon >= 0) && ((size_t)mouse_over_icon < icon_list.size()))
			show_help(icon_list[mouse_over_icon]->get_help_message(), get_icon_size()*(mouse_over_icon+1)+2, 10);
		mouse_over_icon = -1;
	}
static void
retrieve_highres_icon (WebappMonitor *monitor, const gchar *desktop_file)
{
  GKeyFile *key_file;
  gchar *s;
  GError *error = NULL;

  /* Get URL to get icon for */
  key_file = g_key_file_new ();
  if (!g_key_file_load_from_data (key_file, desktop_file, strlen (desktop_file), 0, &error)) {
    g_warning ("Could not parse desktop file: %s", error->message);
    g_error_free (error);

    goto out;
  }

  if (get_icon_size (key_file) >= 64)
    goto out;

  s =  g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, G_KEY_FILE_DESKTOP_KEY_EXEC, NULL);
  if (s != NULL) {
    gint n_args, i;
    gchar **args, *url = NULL;

    g_debug ("Parsing command line %s", s);

    if (!g_shell_parse_argv (s, &n_args, &args, &error)) {
      g_debug ("Failed parsing command line %s", s);
      goto out;
    }

    for (i = 0; i < n_args && args[i] != NULL; i++) {
      g_debug ("Processing argument %s", args[i]);
      if (g_str_has_prefix (args[i], "--app=")) {
	url = g_strdup (args[i] + 6);
	g_debug ("Found URL %s", url);
	break;
      }
    }

    if (url != NULL) {
      NPVariant url_varg, result;

      STRINGZ_TO_NPVARIANT(url, url_varg);
      NULL_TO_NPVARIANT(result);

      if (!NPN_InvokeDefault (monitor->instance, monitor->icon_loader_callback, &url_varg, 1, &result))
      	g_debug ("Failed calling JS callback");

      g_free (url);
      NPN_ReleaseVariantValue (&result);
    }

    g_strfreev (args);
    g_free (s);
  }

 out:
  g_key_file_free (key_file);
}
//------------------------------------------------------------------------------
void TreeModelWrapper::get_icon_value(const iterator& iter, int column, const bec::NodeId& node,
                                      Glib::ValueBase& value) const {
  if (!tm())
    return;

  static ImageCache* pixbufs = ImageCache::get_instance();
  static Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
  GValue* gval = value.gobj();

  g_value_init(gval, GDK_TYPE_PIXBUF);

  bec::IconId icon_id = tm()->get_field_icon(node, column, get_icon_size());
  if (icon_id != 0) {
    Glib::RefPtr<Gdk::Pixbuf> pixbuf = pixbufs->image(icon_id);

    if (pixbuf)
      g_value_set_object(gval, pixbuf->gobj());
    else {
      if (tm()->is_expandable(node)) {
        Glib::RefPtr<Gdk::Pixbuf> pixbuf = icon_theme->load_icon("folder", 16, (Gtk::IconLookupFlags)0);

        if (pixbuf)
          g_value_set_object(gval, pixbuf->gobj());
      }
    }
  } else {
    if (tm()->is_expandable(node)) {
      Glib::RefPtr<Gdk::Pixbuf> pixbuf = icon_theme->load_icon("folder", 16, (Gtk::IconLookupFlags)0);

      if (pixbuf)
        g_value_set_object(gval, pixbuf->gobj());
    }
  }
}
Пример #5
0
CheckButton::CheckButton() {

	set_toggle_mode(true);
	set_text_align(ALIGN_LEFT);

	_set_internal_margin(MARGIN_RIGHT, get_icon_size().width);
}
Пример #6
0
Fl_Divider *Fl_Tool_Bar::add_divider()
{
    begin();

    int dw, dh;
    get_icon_size(tb_size(), dw, dh);

    Fl_VertDivider *l = new Fl_VertDivider(5, dh);

    end();
    return l;
}
Пример #7
0
Size2 CheckBox::get_minimum_size() const {

	Size2 minsize = Button::get_minimum_size();
	Size2 tex_size = get_icon_size();
	minsize.width += tex_size.width;
	if (get_text().length() > 0) {
		minsize.width += get_constant("hseparation");
	}
	Ref<StyleBox> sb = get_stylebox("normal");
	minsize.height = MAX(minsize.height, tex_size.height + sb->get_margin(MARGIN_TOP) + sb->get_margin(MARGIN_BOTTOM));

	return minsize;
}
Пример #8
0
void CheckBox::_notification(int p_what) {

	if (p_what == NOTIFICATION_THEME_CHANGED) {

		_set_internal_margin(MARGIN_LEFT, get_icon_size().width);
	} else if (p_what == NOTIFICATION_DRAW) {

		RID ci = get_canvas_item();

		Ref<Texture> on = Control::get_icon(is_radio() ? "radio_checked" : "checked");
		Ref<Texture> off = Control::get_icon(is_radio() ? "radio_unchecked" : "unchecked");
		Ref<StyleBox> sb = get_stylebox("normal");

		Vector2 ofs;
		ofs.x = sb->get_margin(MARGIN_LEFT);
		ofs.y = int((get_size().height - get_icon_size().height) / 2);

		if (is_pressed())
			on->draw(ci, ofs);
		else
			off->draw(ci, ofs);
	}
}
//------------------------------------------------------------------------------
void ListModelWrapper::get_icon_value(const iterator& iter, int column, const bec::NodeId& node,
                                      Glib::ValueBase& value) const {
  if (!*_tm)
    return;

  static ImageCache* pixbufs = ImageCache::get_instance();
  static Glib::RefPtr<Gtk::IconTheme> icon_theme = Gtk::IconTheme::get_default();
  bec::IconId icon_id = (*_tm)->get_field_icon(node, column, get_icon_size());
  value.init(Glib::Value<Glib::RefPtr<Gdk::Pixbuf>>::value_type());
  if (icon_id != 0 && icon_id != -1) {
    Glib::RefPtr<Gdk::Pixbuf> pixbuf = pixbufs->image(icon_id);
    if (pixbuf) {
      Glib::Value<Glib::RefPtr<Gdk::Pixbuf>> pixbufValue;
      pixbufValue.init(Glib::Value<Glib::RefPtr<Gdk::Pixbuf>>::value_type());
      pixbufValue.set(pixbuf);
      value = pixbufValue;
    }
  }
}
//------------------------------------------------------------------------------
void ListModelWrapper::get_icon_value(const iterator& iter, int column, const bec::NodeId &node, Glib::ValueBase& value) const
{
  if (!*_tm)
    return;

  static ImageCache       *pixbufs      =  ImageCache::get_instance();
  static Glib::RefPtr<Gtk::IconTheme> icon_theme= Gtk::IconTheme::get_default();
  GValue *gval = value.gobj();

  bec::IconId               icon_id = (*_tm)->get_field_icon(node, column, get_icon_size());

  g_value_init(gval, GDK_TYPE_PIXBUF);
  if (icon_id != 0)
  {
    Glib::RefPtr<Gdk::Pixbuf>  pixbuf = pixbufs->image(icon_id);

    if ( pixbuf )
    {
      g_value_set_object(gval, pixbuf->gobj());
    }
  }
}
Пример #11
0
static BOOL
IntDrawState(HDC hdc, HBRUSH hbr, DRAWSTATEPROC func, LPARAM lp, WPARAM wp,
             INT x, INT y, INT cx, INT cy, UINT flags, BOOL unicode)
{
    HBITMAP hbm, hbmsave;
    HFONT hfsave;
    HBRUSH hbsave, hbrtmp = 0;
    HDC memdc;
    RECT rc;
    UINT dtflags = DT_NOCLIP;
    COLORREF fg, bg;
    UINT opcode = flags & 0xf;
    INT len = wp;
    BOOL retval, tmp;

    if((opcode == DST_TEXT || opcode == DST_PREFIXTEXT) && !len)    /* The string is '\0' terminated */
    {
        if(unicode)
            len = lstrlenW((LPWSTR)lp);
        else
            len = lstrlenA((LPSTR)lp);
    }

    /* Find out what size the image has if not given by caller */
    if(!cx || !cy)
    {
        SIZE s;
        BITMAP bm;

        switch(opcode)
        {
            case DST_TEXT:
            case DST_PREFIXTEXT:
                if(unicode)
                    retval = GetTextExtentPoint32W(hdc, (LPWSTR)lp, len, &s);
                else
                    retval = GetTextExtentPoint32A(hdc, (LPSTR)lp, len, &s);
                if(!retval)
                    return FALSE;
                break;

            case DST_ICON:
                if(!get_icon_size((HICON)lp, &s))
                    return FALSE;
                break;

            case DST_BITMAP:
                if(!GetObjectW((HBITMAP)lp, sizeof(bm), &bm))
                    return FALSE;
                s.cx = bm.bmWidth;
                s.cy = bm.bmHeight;
                break;

            case DST_COMPLEX: /* cx and cy must be set in this mode */
                return FALSE;

            default:
                ERR("Invalid opcode: %u\n", opcode);
                return FALSE;
        }

        if(!cx)
            cx = s.cx;
        if(!cy)
            cy = s.cy;
    }

    rc.left   = x;
    rc.top    = y;
    rc.right  = x + cx;
    rc.bottom = y + cy;

    if(flags & DSS_RIGHT)    /* This one is not documented in the win32.hlp file */
        dtflags |= DT_RIGHT;
    if(opcode == DST_TEXT)
        dtflags |= DT_NOPREFIX;
    else if(opcode == DST_PREFIXTEXT)
    {
        if (flags & DSS_HIDEPREFIX)
            dtflags |= DT_HIDEPREFIX;
        if (flags & DSS_PREFIXONLY)
            dtflags |= DT_PREFIXONLY;
    }

    /* For DSS_NORMAL we just jam in the image and return */
    if((flags & 0x79f0) == DSS_NORMAL)
    {
        return PAINTING_DrawStateJam(hdc, opcode, func, lp, len, &rc, dtflags, unicode);
    }

    /* For all other states we need to convert the image to B/W in a local bitmap */
    /* before it is displayed */
    fg = SetTextColor(hdc, RGB(0, 0, 0));
    bg = SetBkColor(hdc, RGB(255, 255, 255));
    hbm = NULL; hbmsave = NULL;
    memdc = NULL; hbsave = NULL;
    retval = FALSE; /* assume failure */

    /* From here on we must use "goto cleanup" when something goes wrong */
    hbm     = CreateBitmap(cx, cy, 1, 1, NULL);
    if(!hbm)
        goto cleanup;
    memdc   = CreateCompatibleDC(hdc);
    if(!memdc)
        goto cleanup;
    hbmsave = (HBITMAP)SelectObject(memdc, hbm);
    if(!hbmsave)
        goto cleanup;
    rc.left = rc.top = 0;
    rc.right = cx;
    rc.bottom = cy;
    if(!FillRect(memdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH)))
        goto cleanup;
    SetBkColor(memdc, RGB(255, 255, 255));
    SetTextColor(memdc, RGB(0, 0, 0));
    hfsave  = (HFONT)SelectObject(memdc, GetCurrentObject(hdc, OBJ_FONT));

    /* DST_COMPLEX may draw text as well,
     * so we must be sure that correct font is selected
     */
    if(!hfsave && (opcode <= DST_PREFIXTEXT))
        goto cleanup;
    tmp = PAINTING_DrawStateJam(memdc, opcode, func, lp, len, &rc, dtflags, unicode);
    if(hfsave)
        SelectObject(memdc, hfsave);
    if(!tmp)
        goto cleanup;

    /* This state cause the image to be dithered */
    if(flags & DSS_UNION)
    {
        hbsave = (HBRUSH)SelectObject(memdc, gpsi->hbrGray);
        if(!hbsave) goto cleanup;
        tmp = PatBlt(memdc, 0, 0, cx, cy, 0x00FA0089);
        SelectObject(memdc, hbsave);
        if(!tmp) goto cleanup;
    }

    if (flags & DSS_DISABLED)
        hbrtmp = GetSysColorBrush(COLOR_3DHILIGHT);
    else if (flags & DSS_DEFAULT)
        hbrtmp = GetSysColorBrush(COLOR_3DSHADOW);

    /* Draw light or dark shadow */
    if (flags & (DSS_DISABLED|DSS_DEFAULT))
    {
        if(!hbrtmp)
            goto cleanup;
        hbsave = (HBRUSH)SelectObject(hdc, hbrtmp);
        if(!hbsave)
            goto cleanup;
        if(!BitBlt(hdc, x+1, y+1, cx, cy, memdc, 0, 0, 0x00B8074A))
            goto cleanup;
        SelectObject(hdc, hbsave);
    }

    if (flags & DSS_DISABLED)
    {
        hbr = hbrtmp = GetSysColorBrush(COLOR_3DSHADOW);
        if(!hbrtmp)
            goto cleanup;
    }
    else if (!hbr)
    {
        hbr = (HBRUSH)GetStockObject(BLACK_BRUSH);
    }

    hbsave = (HBRUSH)SelectObject(hdc, hbr);

    if(!BitBlt(hdc, x, y, cx, cy, memdc, 0, 0, 0x00B8074A))
        goto cleanup;

    retval = TRUE; /* We succeeded */

cleanup:
    SetTextColor(hdc, fg);
    SetBkColor(hdc, bg);

    if(hbsave)
        SelectObject(hdc, hbsave);
    if(hbmsave)
        SelectObject(memdc, hbmsave);
    if(hbm)
        DeleteObject(hbm);
    if(memdc)
        DeleteDC(memdc);

    return retval;
}
Пример #12
0
CheckBox::CheckBox(const String &p_text) :
		Button(p_text) {
	set_toggle_mode(true);
	set_text_align(ALIGN_LEFT);
	_set_internal_margin(MARGIN_LEFT, get_icon_size().width);
}