summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorKrzysztof Kosi??ski <tweenk.pl@gmail.com>2011-06-20 19:33:57 +0000
committerKrzysztof KosiƄski <tweenk.pl@gmail.com>2011-06-20 19:33:57 +0000
commita39e3c37a508f9a389fc55270ae0336ad2f76f0e (patch)
tree952db81c3238005e975f21845734444bba28ff40 /src/widgets
parentMeasure Tool: support measuring of text elements (without having to manually ... (diff)
parentFix outline view (diff)
downloadinkscape-a39e3c37a508f9a389fc55270ae0336ad2f76f0e.tar.gz
inkscape-a39e3c37a508f9a389fc55270ae0336ad2f76f0e.zip
Merge Cairo rendering branch
(bzr r10326)
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/Makefile_insert2
-rw-r--r--src/widgets/font-selector.cpp362
-rw-r--r--src/widgets/font-selector.h21
-rw-r--r--src/widgets/gradient-image.cpp148
-rw-r--r--src/widgets/gradient-image.h5
-rw-r--r--src/widgets/gradient-vector.cpp9
-rw-r--r--src/widgets/icon.cpp52
-rw-r--r--src/widgets/sp-color-preview.cpp211
-rw-r--r--src/widgets/sp-color-preview.h55
-rw-r--r--src/widgets/stroke-style.cpp2
-rw-r--r--src/widgets/toolbox.cpp2
11 files changed, 89 insertions, 780 deletions
diff --git a/src/widgets/Makefile_insert b/src/widgets/Makefile_insert
index af32ec700..86046b918 100644
--- a/src/widgets/Makefile_insert
+++ b/src/widgets/Makefile_insert
@@ -42,8 +42,6 @@ ink_common_sources += \
widgets/sp-color-icc-selector.h \
widgets/sp-color-notebook.cpp \
widgets/sp-color-notebook.h \
- widgets/sp-color-preview.cpp \
- widgets/sp-color-preview.h \
widgets/sp-color-scales.cpp \
widgets/sp-color-scales.h \
widgets/sp-color-selector.cpp \
diff --git a/src/widgets/font-selector.cpp b/src/widgets/font-selector.cpp
index 8c6afeb4c..965910ba2 100644
--- a/src/widgets/font-selector.cpp
+++ b/src/widgets/font-selector.cpp
@@ -20,24 +20,24 @@
# include "config.h"
#endif
-#include <libnr/nr-blit.h>
-#include <libnr/nr-convert2geom.h>
#include <libnrtype/font-instance.h>
-#include <libnrtype/raster-glyph.h>
-#include <libnrtype/RasterFont.h>
-#include <libnrtype/TextWrapper.h>
-#include <libnrtype/one-glyph.h>
#include <libnrtype/font-lister.h>
#include <2geom/transforms.h>
#include <gtk/gtk.h>
+#include <gtk/gtkframe.h>
+#include <gtk/gtkscrolledwindow.h>
+#include <gtk/gtkclist.h>
+#include <gtk/gtkvbox.h>
+#include <gtk/gtkcombo.h>
+#include <gtk/gtkentry.h>
+#include <gtk/gtkdrawingarea.h>
-#include "../display/nr-plain-stuff-gdk.h"
#include <glibmm/i18n.h>
-#include "../desktop.h"
-#include "font-selector.h"
+#include "desktop.h"
+#include "widgets/font-selector.h"
/* SPFontSelector */
@@ -130,13 +130,12 @@ static void sp_font_selector_class_init(SPFontSelectorClass *c)
fs_parent_class = (GtkHBoxClass* )gtk_type_class(GTK_TYPE_HBOX);
- fs_signals[FONT_SET] = g_signal_new ("font_set",
- G_TYPE_FROM_CLASS(object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(SPFontSelectorClass, font_set),
- NULL, NULL,
+ fs_signals[FONT_SET] = gtk_signal_new ("font_set",
+ GTK_RUN_FIRST,
+ GTK_CLASS_TYPE(object_class),
+ GTK_SIGNAL_OFFSET(SPFontSelectorClass, font_set),
gtk_marshal_NONE__POINTER,
- G_TYPE_NONE,
+ GTK_TYPE_NONE,
1, GTK_TYPE_POINTER);
object_class->destroy = sp_font_selector_destroy;
@@ -148,10 +147,7 @@ static void sp_font_selector_init(SPFontSelector *fsel)
gtk_box_set_spacing(GTK_BOX(fsel), 4);
/* Family frame */
- GtkWidget *ft = gtk_label_new_with_mnemonic(_("F_ont family"));
- GtkWidget *f = gtk_frame_new(NULL);
- gtk_frame_set_label_widget ((GtkFrame*)f, ft);
-
+ GtkWidget *f = gtk_frame_new(_("Font family"));
gtk_widget_show (f);
gtk_box_pack_start (GTK_BOX(fsel), f, TRUE, TRUE, 0);
@@ -175,7 +171,6 @@ static void sp_font_selector_init(SPFontSelector *fsel)
gtk_tree_view_set_model (GTK_TREE_VIEW(fsel->family_treeview), GTK_TREE_MODEL (Glib::unwrap (store)));
gtk_container_add(GTK_CONTAINER(sw), fsel->family_treeview);
gtk_widget_show_all (sw);
- gtk_label_set_mnemonic_widget((GtkLabel*)ft, fsel->family_treeview);
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fsel->family_treeview));
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_family_select_row), fsel);
@@ -183,9 +178,7 @@ static void sp_font_selector_init(SPFontSelector *fsel)
/* Style frame */
- ft = gtk_label_new_with_mnemonic(C_("Font selector", "_Style"));
- f = gtk_frame_new(NULL);
- gtk_frame_set_label_widget ((GtkFrame*)f, ft);
+ f = gtk_frame_new(C_("Font selector", "Style"));
gtk_widget_show(f);
gtk_box_pack_start(GTK_BOX (fsel), f, TRUE, TRUE, 0);
@@ -210,7 +203,6 @@ static void sp_font_selector_init(SPFontSelector *fsel)
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(fsel->style_treeview), FALSE);
gtk_container_add(GTK_CONTAINER(sw), fsel->style_treeview);
gtk_widget_show_all (sw);
- gtk_label_set_mnemonic_widget((GtkLabel*)ft, fsel->style_treeview);
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(fsel->style_treeview));
g_signal_connect (G_OBJECT(selection), "changed", G_CALLBACK (sp_font_selector_style_select_row), fsel);
@@ -224,14 +216,13 @@ static void sp_font_selector_init(SPFontSelector *fsel)
g_signal_connect (G_OBJECT(fsel->size), "changed", G_CALLBACK (sp_font_selector_size_changed), fsel);
gtk_box_pack_end (GTK_BOX(hb), fsel->size, FALSE, FALSE, 0);
- GtkWidget *l = gtk_label_new_with_mnemonic(_("Font si_ze:"));
+ GtkWidget *l = gtk_label_new(_("Font size:"));
gtk_widget_show_all (l);
gtk_box_pack_end(GTK_BOX (hb), l, FALSE, FALSE, 0);
- gtk_label_set_mnemonic_widget((GtkLabel*)l, fsel->size);
for (unsigned int n = 0; sizes[n]; ++n)
{
- gtk_combo_box_append_text ((GtkComboBox *)fsel->size, sizes[n]);
+ gtk_combo_box_append_text (GTK_COMBO_BOX(fsel->size), sizes[n]);
}
gtk_widget_show_all (fsel->size);
@@ -389,7 +380,7 @@ static void sp_font_selector_emit_set (SPFontSelector *fsel)
fsel->font->Unref();
}
fsel->font = font;
- g_signal_emit(G_OBJECT(fsel), fs_signals[FONT_SET], 0, fsel->font);
+ gtk_signal_emit(GTK_OBJECT(fsel), fs_signals[FONT_SET], fsel->font);
}
fsel->fontsize_dirty = false;
if (font) {
@@ -521,321 +512,6 @@ double sp_font_selector_get_size(SPFontSelector *fsel)
return fsel->fontsize;
}
-/* SPFontPreview */
-
-struct SPFontPreview
-{
- GtkDrawingArea darea;
-
- font_instance *font;
- raster_font *rfont;
- gchar *phrase;
- unsigned long rgba;
-};
-
-struct SPFontPreviewClass
-{
- GtkDrawingAreaClass parent_class;
-};
-
-static void sp_font_preview_class_init(SPFontPreviewClass *c);
-static void sp_font_preview_init(SPFontPreview *fsel);
-static void sp_font_preview_destroy(GtkObject *object);
-
-void sp_font_preview_size_request(GtkWidget *widget, GtkRequisition *req);
-static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event);
-
-static GtkDrawingAreaClass *fp_parent_class = NULL;
-
-GType sp_font_preview_get_type()
-{
- static GType type = 0;
- if (!type) {
- GTypeInfo info = {
- sizeof(SPFontPreviewClass),
- 0, // base_init
- 0, // base_finalize
- (GClassInitFunc)sp_font_preview_class_init,
- 0, // class_finalize
- 0, // class_data
- sizeof(SPFontPreview),
- 0, // n_preallocs
- (GInstanceInitFunc)sp_font_preview_init,
- 0 // value_table
- };
- type = g_type_register_static(GTK_TYPE_DRAWING_AREA, "SPFontPreview", &info, static_cast<GTypeFlags>(0));
- }
- return type;
-}
-
-static void sp_font_preview_class_init (SPFontPreviewClass *c)
-{
- GtkObjectClass *object_class = (GtkObjectClass *) c;
- GtkWidgetClass *widget_class = (GtkWidgetClass *) c;
-
- fp_parent_class = (GtkDrawingAreaClass*) gtk_type_class(GTK_TYPE_DRAWING_AREA);
-
- object_class->destroy = sp_font_preview_destroy;
-
- widget_class->size_request = sp_font_preview_size_request;
- widget_class->expose_event = sp_font_preview_expose;
-}
-
-static void sp_font_preview_init(SPFontPreview *fprev)
-{
- fprev->rgba = 0x000000ff;
-}
-
-static void sp_font_preview_destroy(GtkObject *object)
-{
- SPFontPreview *fprev = SP_FONT_PREVIEW (object);
-
- if (fprev->rfont) {
- fprev->rfont->Unref();
- fprev->rfont = NULL;
- }
-
- if (fprev->font) {
- fprev->font->Unref();
- fprev->font = NULL;
- }
-
- g_free(fprev->phrase);
- fprev->phrase = NULL;
-
- if (GTK_OBJECT_CLASS (fp_parent_class)->destroy) {
- GTK_OBJECT_CLASS (fp_parent_class)->destroy(object);
- }
-}
-
-void sp_font_preview_size_request(GtkWidget */*widget*/, GtkRequisition *req)
-{
- req->width = 256;
- req->height = 32;
-}
-
-#define SPFP_MAX_LEN 64
-
-static gint sp_font_preview_expose(GtkWidget *widget, GdkEventExpose *event)
-{
- SPFontPreview *fprev = SP_FONT_PREVIEW(widget);
-
- if (gtk_widget_is_drawable (widget)) {
- if (fprev->rfont) {
-
- int glyphs[SPFP_MAX_LEN];
- double hpos[SPFP_MAX_LEN];
-
- font_instance *tface = fprev->rfont->daddy;
-
- double theSize = fprev->rfont->style.transform.descrim();
-
- gchar const *p;
- if (fprev->phrase) {
- p = fprev->phrase;
- } else {
- /* TRANSLATORS: Test string used in text and font dialog (when no
- * text has been entered) to get a preview of the font. Choose
- * some representative characters that users of your locale will be
- * interested in. */
- p = _("AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()");
- }
- int len = 0;
-
- NRRect bbox;
- bbox.x0 = bbox.y0 = bbox.x1 = bbox.y1 = 0.0;
-
- text_wrapper* str_text=new text_wrapper;
- str_text->SetDefaultFont(tface);
- str_text->AppendUTF8(p,-1);
- if ( str_text->uni32_length > 0 ) {
- str_text->DoLayout();
- if ( str_text->glyph_length > 0 ) {
- PangoFont *curPF = NULL;
- font_instance *curF = NULL;
- for (int i = 0; i < str_text->glyph_length && i < SPFP_MAX_LEN; i++) {
- if ( str_text->glyph_text[i].font != curPF ) {
- curPF = str_text->glyph_text[i].font;
- if (curF) {
- curF->Unref();
- }
- curF = NULL;
- if ( curPF ) {
- PangoFontDescription* pfd = pango_font_describe(curPF);
- curF = (font_factory::Default())->Face(pfd);
- pango_font_description_free(pfd);
- }
- }
- Geom::Point base_pt(str_text->glyph_text[i].x, str_text->glyph_text[i].y);
- base_pt *= theSize;
-
- glyphs[len] = str_text->glyph_text[i].gl;
- hpos[len] = base_pt[0];
- len++;
- if ( curF ) {
- Geom::OptRect nbbox = curF->BBox(str_text->glyph_text[i].gl);
- if (nbbox) {
- bbox.x0 = MIN(bbox.x0, base_pt[Geom::X] + theSize * (nbbox->min())[0]);
- bbox.y0 = MIN(bbox.y0, base_pt[Geom::Y] - theSize * (nbbox->max())[1]);
- bbox.x1 = MAX(bbox.x1, base_pt[Geom::X] + theSize * (nbbox->max())[0]);
- bbox.y1 = MAX(bbox.y1, base_pt[Geom::Y] - theSize * (nbbox->min())[1]);
- }
- }
- }
- if ( curF ) {
- curF->Unref();
- }
- }
- }
-
- // XXX: FIXME: why does this code ignore adv.y
- /* while (p && *p && (len < SPFP_MAX_LEN)) {
- unsigned int unival;
- NRRect gbox;
- unival = g_utf8_get_char (p);
- glyphs[len] = tface->MapUnicodeChar( unival);
- hpos[len] = (int)px;
- Geom::Point adv = fprev->rfont->Advance(glyphs[len]);
- fprev->rfont->BBox( glyphs[len], &gbox);
- bbox.x0 = MIN (px + gbox.x0, bbox.x0);
- bbox.y0 = MIN (py + gbox.y0, bbox.y0);
- bbox.x1 = MAX (px + gbox.x1, bbox.x1);
- bbox.y1 = MAX (py + gbox.y1, bbox.y1);
- px += adv[Geom::X];
- len += 1;
- p = g_utf8_next_char (p);
- }*/
-
- float startx = (widget->allocation.width - (bbox.x1 - bbox.x0)) / 2;
- float starty = widget->allocation.height - (widget->allocation.height - (bbox.y1 - bbox.y0)) / 2 - bbox.y1;
-
- for (int y = event->area.y; y < event->area.y + event->area.height; y += 64) {
- for (int x = event->area.x; x < event->area.x + event->area.width; x += 64) {
- NRPixBlock pb, m;
- int x0 = x;
- int y0 = y;
- int x1 = MIN(x0 + 64, event->area.x + event->area.width);
- int y1 = MIN(y0 + 64, event->area.y + event->area.height);
- guchar *ps = nr_pixelstore_16K_new (TRUE, 0xff);
- nr_pixblock_setup_extern(&pb, NR_PIXBLOCK_MODE_R8G8B8, x0, y0, x1, y1, ps, 3 * (x1 - x0), FALSE, FALSE);
- nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, x0, y0, x1, y1, TRUE);
- pb.empty = FALSE;
-
- PangoFont *curPF = NULL;
- font_instance *curF = NULL;
- raster_font *curRF = NULL;
- for (int i=0; i < len; i++) {
- if ( str_text->glyph_text[i].font != curPF ) {
- curPF=str_text->glyph_text[i].font;
- if ( curF ) {
- curF->Unref();
- }
- curF = NULL;
- if ( curPF ) {
- PangoFontDescription* pfd = pango_font_describe(curPF);
- curF=(font_factory::Default())->Face(pfd);
- pango_font_description_free(pfd);
- }
- if ( curF ) {
- if ( curRF ) {
- curRF->Unref();
- }
- curRF = NULL;
- curRF = curF->RasterFont(fprev->rfont->style);
- }
- }
- raster_glyph *g = (curRF) ? curRF->GetGlyph(glyphs[i]) : NULL;
- if ( g ) {
- g->Blit(Geom::Point(hpos[i] + startx, starty), m);
- }
- }
- if (curRF) {
- curRF->Unref();
- }
- if (curF) {
- curF->Unref();
- }
-
- nr_blit_pixblock_mask_rgba32(&pb, &m, fprev->rgba);
- gdk_draw_rgb_image(widget->window, widget->style->black_gc,
- x0, y0, x1 - x0, y1 - y0,
- GDK_RGB_DITHER_NONE, NR_PIXBLOCK_PX (&pb), pb.rs);
- nr_pixblock_release(&m);
- nr_pixblock_release(&pb);
- nr_pixelstore_16K_free(ps);
- }
- }
-
- delete str_text;
-
- } else {
- nr_gdk_draw_gray_garbage(widget->window, widget->style->black_gc,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
- }
- }
-
- return TRUE;
-}
-
-GtkWidget * sp_font_preview_new()
-{
- GtkWidget *w = (GtkWidget*) gtk_type_new(SP_TYPE_FONT_PREVIEW);
-
- return w;
-}
-
-void sp_font_preview_set_font(SPFontPreview *fprev, font_instance *font, SPFontSelector *fsel)
-{
- if (font)
- {
- font->Ref();
- }
-
- if (fprev->font)
- {
- fprev->font->Unref();
- }
-
- fprev->font = font;
-
- if (fprev->rfont)
- {
- fprev->rfont->Unref();
- fprev->rfont=NULL;
- }
-
- if (fprev->font)
- {
- Geom::Affine flip(Geom::Scale(fsel->fontsize, -fsel->fontsize));
- fprev->rfont = fprev->font->RasterFont(flip, 0);
- }
-
- if (gtk_widget_is_drawable (GTK_WIDGET (fprev))) gtk_widget_queue_draw (GTK_WIDGET (fprev));
-}
-
-void sp_font_preview_set_rgba32(SPFontPreview *fprev, guint32 rgba)
-{
- fprev->rgba = rgba;
- if (gtk_widget_is_drawable (GTK_WIDGET (fprev))) {
- gtk_widget_queue_draw (GTK_WIDGET (fprev));
- }
-}
-
-void sp_font_preview_set_phrase(SPFontPreview *fprev, const gchar *phrase)
-{
- g_free (fprev->phrase);
- if (phrase) {
- fprev->phrase = g_strdup (phrase);
- } else {
- fprev->phrase = NULL;
- }
- if (gtk_widget_is_drawable( GTK_WIDGET (fprev))) {
- gtk_widget_queue_draw (GTK_WIDGET (fprev));
- }
-}
-
-
/*
Local Variables:
mode:c++
diff --git a/src/widgets/font-selector.h b/src/widgets/font-selector.h
index 41a671bae..febd4a34a 100644
--- a/src/widgets/font-selector.h
+++ b/src/widgets/font-selector.h
@@ -17,18 +17,13 @@
#include <glib.h>
struct SPFontSelector;
-struct SPFontPreview;
#define SP_TYPE_FONT_SELECTOR (sp_font_selector_get_type ())
-#define SP_FONT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector))
-#define SP_IS_FONT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_FONT_SELECTOR))
-
-#define SP_TYPE_FONT_PREVIEW (sp_font_preview_get_type ())
-#define SP_FONT_PREVIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_FONT_PREVIEW, SPFontPreview))
-#define SP_IS_FONT_PREVIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_FONT_PREVIEW))
+#define SP_FONT_SELECTOR(o) (GTK_CHECK_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector))
+#define SP_IS_FONT_SELECTOR(o) (GTK_CHECK_TYPE ((o), SP_TYPE_FONT_SELECTOR))
#include <libnrtype/nrtype-forward.h>
-#include <gtk/gtk.h>
+#include <gtk/gtkwidget.h>
/* SPFontSelector */
@@ -41,16 +36,6 @@ void sp_font_selector_set_font (SPFontSelector *fsel, font_instance *font, doubl
font_instance *sp_font_selector_get_font (SPFontSelector *fsel);
double sp_font_selector_get_size (SPFontSelector *fsel);
-/* SPFontPreview */
-
-GtkType sp_font_preview_get_type (void);
-
-GtkWidget *sp_font_preview_new (void);
-
-void sp_font_preview_set_font (SPFontPreview *fprev, font_instance *font, SPFontSelector *fsel);
-void sp_font_preview_set_rgba32 (SPFontPreview *fprev, guint32 rgba);
-void sp_font_preview_set_phrase (SPFontPreview *fprev, const gchar *phrase);
-
#endif
diff --git a/src/widgets/gradient-image.cpp b/src/widgets/gradient-image.cpp
index f3a471bfc..ef05ad381 100644
--- a/src/widgets/gradient-image.cpp
+++ b/src/widgets/gradient-image.cpp
@@ -12,10 +12,8 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include <libnr/nr-pixblock-pattern.h>
#include "macros.h"
-#include "../display/nr-plain-stuff.h"
-#include "../display/nr-plain-stuff-gdk.h"
+#include "display/cairo-utils.h"
#include "gradient-image.h"
#include "sp-gradient.h"
#include "sp-gradient-fns.h"
@@ -29,10 +27,7 @@ static void sp_gradient_image_class_init (SPGradientImageClass *klass);
static void sp_gradient_image_init (SPGradientImage *image);
static void sp_gradient_image_destroy (GtkObject *object);
-static void sp_gradient_image_realize (GtkWidget *widget);
-static void sp_gradient_image_unrealize (GtkWidget *widget);
static void sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition);
-static void sp_gradient_image_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
static gint sp_gradient_image_expose (GtkWidget *widget, GdkEventExpose *event);
static void sp_gradient_image_gradient_release (SPObject *, SPGradientImage *im);
@@ -76,20 +71,16 @@ sp_gradient_image_class_init (SPGradientImageClass *klass)
object_class->destroy = sp_gradient_image_destroy;
- widget_class->realize = sp_gradient_image_realize;
- widget_class->unrealize = sp_gradient_image_unrealize;
widget_class->size_request = sp_gradient_image_size_request;
- widget_class->size_allocate = sp_gradient_image_size_allocate;
widget_class->expose_event = sp_gradient_image_expose;
}
static void
sp_gradient_image_init (SPGradientImage *image)
{
- gtk_widget_set_has_window (GTK_WIDGET (image), FALSE);
+ GTK_WIDGET_SET_FLAGS (image, GTK_NO_WINDOW);
image->gradient = NULL;
- image->px = NULL;
new (&image->release_connection) sigc::connection();
new (&image->modified_connection) sigc::connection();
@@ -116,104 +107,39 @@ sp_gradient_image_destroy (GtkObject *object)
}
static void
-sp_gradient_image_realize (GtkWidget *widget)
-{
- SPGradientImage *image;
-
- image = SP_GRADIENT_IMAGE (widget);
-
- if (((GtkWidgetClass *) parent_class)->realize)
- (* ((GtkWidgetClass *) parent_class)->realize) (widget);
-
- g_assert (!image->px);
- image->px = g_new (guchar, 3 * VBLOCK * widget->allocation.width);
- sp_gradient_image_update (image);
-}
-
-static void
-sp_gradient_image_unrealize (GtkWidget *widget)
-{
- SPGradientImage *image;
-
- image = SP_GRADIENT_IMAGE (widget);
-
- if (((GtkWidgetClass *) parent_class)->unrealize)
- (* ((GtkWidgetClass *) parent_class)->unrealize) (widget);
-
- g_assert (image->px);
- g_free (image->px);
- image->px = NULL;
-}
-
-static void
sp_gradient_image_size_request (GtkWidget *widget, GtkRequisition *requisition)
{
- SPGradientImage *slider;
-
- slider = SP_GRADIENT_IMAGE (widget);
-
requisition->width = 64;
requisition->height = 12;
}
-static void
-sp_gradient_image_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- SPGradientImage *image;
-
- image = SP_GRADIENT_IMAGE (widget);
-
- widget->allocation = *allocation;
-
- if (gtk_widget_get_realized (widget)) {
- g_free (image->px);
- image->px = g_new (guchar, 3 * VBLOCK * allocation->width);
- }
-
- sp_gradient_image_update (image);
-}
-
static gint
sp_gradient_image_expose (GtkWidget *widget, GdkEventExpose *event)
{
- SPGradientImage *image;
-
- image = SP_GRADIENT_IMAGE (widget);
-
- if (gtk_widget_is_drawable (widget)) {
- gint x0, y0, x1, y1;
- x0 = MAX (event->area.x, widget->allocation.x);
- y0 = MAX (event->area.y, widget->allocation.y);
- x1 = MIN (event->area.x + event->area.width, widget->allocation.x + widget->allocation.width);
- y1 = MIN (event->area.y + event->area.height, widget->allocation.y + widget->allocation.height);
- if ((x1 > x0) && (y1 > y0)) {
- if (image->px) {
- if (image->gradient) {
- gint y;
- guchar *p;
- p = image->px + 3 * (x0 - widget->allocation.x);
- for (y = y0; y < y1; y += VBLOCK) {
- gdk_draw_rgb_image (widget->window, widget->style->black_gc,
- x0, y,
- (x1 - x0), MIN (VBLOCK, y1 - y),
- GDK_RGB_DITHER_MAX,
- p, widget->allocation.width * 3);
- }
- } else {
- nr_gdk_draw_gray_garbage (widget->window, widget->style->black_gc,
- x0, y0,
- x1 - x0, y1 - y0);
- }
- } else {
- gdk_draw_rectangle (widget->window, widget->style->black_gc,
- x0, y0,
- (x1 - x0), (y1 - x0),
- TRUE);
- }
- }
- }
-
- return TRUE;
+ SPGradientImage *image = SP_GRADIENT_IMAGE (widget);
+ SPGradient *gr = image->gradient;
+
+ cairo_t *ct = gdk_cairo_create(widget->window);
+
+ cairo_rectangle(ct, event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cairo_clip(ct);
+ cairo_translate(ct, widget->allocation.x, widget->allocation.y);
+
+ cairo_pattern_t *check = ink_cairo_pattern_create_checkerboard();
+ cairo_set_source(ct, check);
+ cairo_paint(ct);
+ cairo_pattern_destroy(check);
+
+ if (gr) {
+ cairo_pattern_t *p = sp_gradient_create_preview_pattern(gr, widget->allocation.width);
+ cairo_set_source(ct, p);
+ cairo_paint(ct);
+ cairo_pattern_destroy(p);
+ }
+ cairo_destroy(ct);
+
+ return TRUE;
}
GtkWidget *
@@ -268,27 +194,7 @@ sp_gradient_image_gradient_modified (SPObject *, guint /*flags*/, SPGradientImag
static void
sp_gradient_image_update (SPGradientImage *image)
{
- GtkAllocation *allocation;
-
- if (!image->px) return;
-
- allocation = &((GtkWidget *) image)->allocation;
-
- if (image->gradient) {
- nr_render_checkerboard_rgb (image->px, allocation->width, VBLOCK, 3 * allocation->width, 0, 0);
- sp_gradient_render_vector_block_rgb (image->gradient,
- image->px, allocation->width, VBLOCK, 3 * allocation->width,
- 0, allocation->width, TRUE);
- } else {
- NRPixBlock pb;
- nr_pixblock_setup_extern (&pb, NR_PIXBLOCK_MODE_R8G8B8,
- 0, 0, allocation->width, VBLOCK,
- image->px, 3 * allocation->width, TRUE, FALSE);
- nr_pixblock_render_gray_noise (&pb, NULL);
- nr_pixblock_release (&pb);
- }
-
- if (gtk_widget_is_drawable (GTK_WIDGET (image))) {
+ if (GTK_WIDGET_DRAWABLE (image)) {
gtk_widget_queue_draw (GTK_WIDGET (image));
}
}
diff --git a/src/widgets/gradient-image.h b/src/widgets/gradient-image.h
index 0f911d4ef..ae5d40f56 100644
--- a/src/widgets/gradient-image.h
+++ b/src/widgets/gradient-image.h
@@ -14,7 +14,7 @@
*/
#include <gtk/gtk.h>
-#include "../libnr/nr-matrix.h"
+
class SPGradient;
#include <glib.h>
@@ -31,7 +31,6 @@ class SPGradient;
struct SPGradientImage {
GtkWidget widget;
SPGradient *gradient;
- guchar *px;
sigc::connection release_connection;
sigc::connection modified_connection;
@@ -46,6 +45,4 @@ GtkType sp_gradient_image_get_type (void);
GtkWidget *sp_gradient_image_new (SPGradient *gradient);
void sp_gradient_image_set_gradient (SPGradientImage *gi, SPGradient *gr);
-
-
#endif
diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp
index bc29bc974..a58b22d7c 100644
--- a/src/widgets/gradient-vector.cpp
+++ b/src/widgets/gradient-vector.cpp
@@ -424,7 +424,7 @@ void SPGradientVectorSelector::setSwatched()
##################################################################*/
#include "../widgets/sp-color-notebook.h"
-#include "../widgets/sp-color-preview.h"
+#include "ui/widget/color-preview.h"
#include "../widgets/widget-sizes.h"
#include "../xml/node-event-vector.h"
#include "../svg/svg-color.h"
@@ -562,7 +562,8 @@ static void update_stop_list( GtkWidget *mnu, SPGradient *gradient, SPStop *new_
gtk_widget_show(i);
g_object_set_data(G_OBJECT(i), "stop", stop);
GtkWidget *hb = gtk_hbox_new(FALSE, 4);
- GtkWidget *cpv = sp_color_preview_new(sp_stop_get_rgba32(stop));
+ GtkWidget *cpv = GTK_WIDGET(Gtk::manage(
+ new Inkscape::UI::Widget::ColorPreview(sp_stop_get_rgba32(stop)))->gobj());
gtk_widget_show(cpv);
gtk_container_add( GTK_CONTAINER(hb), cpv );
g_object_set_data( G_OBJECT(i), "preview", cpv );
@@ -1188,8 +1189,8 @@ static void sp_gradient_vector_color_changed(SPColorSelector *csel, GtkObject *o
blocked = FALSE;
- SPColorPreview *cpv = static_cast<SPColorPreview *>(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "preview"));
- sp_color_preview_set_rgba32(cpv, sp_stop_get_rgba32(stop));
+ Inkscape::UI::Widget::ColorPreview *cpv = static_cast<Inkscape::UI::Widget::ColorPreview *>(g_object_get_data(G_OBJECT(gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(mnu)))), "preview"));
+ cpv->setRgba32(sp_stop_get_rgba32(stop));
}
/*
diff --git a/src/widgets/icon.cpp b/src/widgets/icon.cpp
index b1d5c73bb..450c5f0d9 100644
--- a/src/widgets/icon.cpp
+++ b/src/widgets/icon.cpp
@@ -29,6 +29,7 @@
#include "inkscape.h"
#include "document.h"
#include "sp-item.h"
+#include "display/cairo-utils.h"
#include "display/nr-arena.h"
#include "display/nr-arena-item.h"
#include "io/sys.h"
@@ -88,7 +89,7 @@ struct IconImpl {
static std::list<gchar*> &icons_svg_paths();
static guchar *load_svg_pixels(std::list<Glib::ustring> const &names,
- unsigned lsize, unsigned psize);
+ unsigned psize, unsigned &stride);
static std::string fileEscape( std::string const & str );
@@ -1072,8 +1073,10 @@ GdkPixbuf *IconImpl::loadPixmap(gchar const *name, unsigned /*lsize*/, unsigned
}
// takes doc, root, icon, and icon name to produce pixels
-extern "C" guchar *sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root,
- gchar const *name, unsigned psize )
+extern "C" guchar *
+sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root,
+ gchar const *name, unsigned psize,
+ unsigned &stride)
{
bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg");
guchar *px = NULL;
@@ -1174,22 +1177,29 @@ extern "C" guchar *sp_icon_doc_icon( SPDocument *doc, NRArenaItem *root,
g_message( " area --'%s' (%f,%f)-(%f,%f)", name, (double)area.x0, (double)area.y0, (double)area.x1, (double)area.y1 );
g_message( " ua --'%s' (%f,%f)-(%f,%f)", name, (double)ua.x0, (double)ua.y0, (double)ua.x1, (double)ua.y1 );
}
+
+ stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, psize);
+
/* Set up pixblock */
- px = g_new(guchar, 4 * psize * psize);
- memset(px, 0x00, 4 * psize * psize);
+ px = g_new(guchar, stride * psize);
+ memset(px, 0x00, stride * psize);
+
/* Render */
- NRPixBlock B;
- nr_pixblock_setup_extern( &B, NR_PIXBLOCK_MODE_R8G8B8A8N,
- ua.x0, ua.y0, ua.x1, ua.y1,
- px + 4 * psize * (ua.y0 - area.y0) +
- 4 * (ua.x0 - area.x0),
- 4 * psize, FALSE, FALSE );
- nr_arena_item_invoke_render(NULL, root, &ua, &B,
+ cairo_surface_t *s = cairo_image_surface_create_for_data(px,
+ CAIRO_FORMAT_ARGB32, psize, psize, stride);
+ cairo_t *ct = cairo_create(s);
+ cairo_translate(ct, -ua.x0, -ua.y0);
+
+ nr_arena_item_invoke_render(ct, root, &ua, NULL,
NR_ARENA_ITEM_RENDER_NO_CACHE );
- nr_pixblock_release(&B);
+ cairo_destroy(ct);
+ cairo_surface_destroy(s);
+
+ // convert to GdkPixbuf format
+ convert_pixels_argb32_to_pixbuf(px, psize, psize, stride);
if ( Inkscape::Preferences::get()->getBool("/debug/icons/overlaySvg") ) {
- IconImpl::overlayPixels( px, psize, psize, 4 * psize, 0x00, 0x00, 0xff );
+ IconImpl::overlayPixels( px, psize, psize, stride, 0x00, 0x00, 0xff );
}
}
}
@@ -1245,7 +1255,7 @@ std::list<gchar*> &IconImpl::icons_svg_paths()
// this function renders icons from icons.svg and returns the pixels.
guchar *IconImpl::load_svg_pixels(std::list<Glib::ustring> const &names,
- unsigned /*lsize*/, unsigned psize)
+ unsigned psize, unsigned &stride)
{
bool const dump = Inkscape::Preferences::get()->getBool("/debug/icons/dumpSvg");
std::list<gchar *> &sources = icons_svg_paths();
@@ -1292,7 +1302,7 @@ guchar *IconImpl::load_svg_pixels(std::list<Glib::ustring> const &names,
}
if (info) {
for (std::list<Glib::ustring>::const_iterator it = names.begin(); !px && (it != names.end()); ++it ) {
- px = sp_icon_doc_icon( info->doc, info->root, it->c_str(), psize );
+ px = sp_icon_doc_icon( info->doc, info->root, it->c_str(), psize, stride );
}
}
}
@@ -1416,10 +1426,11 @@ bool IconImpl::prerenderIcon(gchar const *name, GtkIconSize lsize, unsigned psiz
g_message("load_svg_pixels([%s] = %s, %d, %d)", name, legacyNames[name].c_str(), lsize, psize);
}
}
- guchar* px = load_svg_pixels(names, lsize, psize);
+ unsigned stride;
+ guchar* px = load_svg_pixels(names, psize, stride);
if (px) {
GdkPixbuf* pb = gdk_pixbuf_new_from_data( px, GDK_COLORSPACE_RGB, TRUE, 8,
- psize, psize, psize * 4,
+ psize, psize, stride,
reinterpret_cast<GdkPixbufDestroyNotify>(g_free), NULL );
pb_cache[key] = pb;
addToIconSet(pb, name, lsize, psize);
@@ -1457,10 +1468,11 @@ GdkPixbuf *IconImpl::loadSvg(std::list<Glib::ustring> const &names, GtkIconSize
// did we already load this icon at this scale/size?
GdkPixbuf* pb = get_cached_pixbuf(key);
if (!pb) {
- guchar *px = load_svg_pixels(names, lsize, psize);
+ unsigned stride;
+ guchar *px = load_svg_pixels(names, psize, stride);
if (px) {
pb = gdk_pixbuf_new_from_data(px, GDK_COLORSPACE_RGB, TRUE, 8,
- psize, psize, psize * 4,
+ psize, psize, stride,
(GdkPixbufDestroyNotify)g_free, NULL);
pb_cache[key] = pb;
addToIconSet(pb, names.begin()->c_str(), lsize, psize);
diff --git a/src/widgets/sp-color-preview.cpp b/src/widgets/sp-color-preview.cpp
deleted file mode 100644
index 433301f85..000000000
--- a/src/widgets/sp-color-preview.cpp
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * A simple color preview widget
- *
- * Author:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * Copyright (C) 2001-2002 Lauris Kaplinski
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "../display/nr-plain-stuff-gdk.h"
-#include "sp-color-preview.h"
-
-#define SPCP_DEFAULT_WIDTH 32
-#define SPCP_DEFAULT_HEIGHT 11
-
-static void sp_color_preview_class_init (SPColorPreviewClass *klass);
-static void sp_color_preview_init (SPColorPreview *image);
-static void sp_color_preview_destroy (GtkObject *object);
-
-static void sp_color_preview_size_request (GtkWidget *widget, GtkRequisition *requisition);
-static void sp_color_preview_size_allocate (GtkWidget *widget, GtkAllocation *allocation);
-static gint sp_color_preview_expose (GtkWidget *widget, GdkEventExpose *event);
-
-static void sp_color_preview_paint (SPColorPreview *cp, GdkRectangle *area);
-
-static GtkWidgetClass *parent_class;
-
-GType sp_color_preview_get_type(void)
-{
- static GType type = 0;
- if (!type) {
- static const GTypeInfo info = {
- sizeof(SPColorPreviewClass),
- NULL, /* base_init */
- NULL, /* base_finalize */
- (GClassInitFunc) sp_color_preview_class_init,
- NULL, /* class_finalize */
- NULL, /* class_data */
- sizeof(SPColorPreview),
- 0, /* n_preallocs */
- (GInstanceInitFunc) sp_color_preview_init,
- 0, /* value_table */
- };
-
- type = g_type_register_static( GTK_TYPE_WIDGET,
- "SPColorPreview",
- &info,
- static_cast< GTypeFlags > (0) );
- }
- return type;
-}
-
-static void
-sp_color_preview_class_init (SPColorPreviewClass *klass)
-{
- GtkObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = (GtkObjectClass *) klass;
- widget_class = (GtkWidgetClass *) klass;
-
- parent_class = (GtkWidgetClass*)gtk_type_class (GTK_TYPE_WIDGET);
-
- object_class->destroy = sp_color_preview_destroy;
-
- widget_class->size_request = sp_color_preview_size_request;
- widget_class->size_allocate = sp_color_preview_size_allocate;
- widget_class->expose_event = sp_color_preview_expose;
-}
-
-static void
-sp_color_preview_init (SPColorPreview *image)
-{
- gtk_widget_set_has_window (GTK_WIDGET (image), FALSE);
-
- image->rgba = 0xffffffff;
-}
-
-static void
-sp_color_preview_destroy (GtkObject *object)
-{
- SPColorPreview *image;
-
- image = SP_COLOR_PREVIEW (object);
-
- if (((GtkObjectClass *) (parent_class))->destroy)
- (* ((GtkObjectClass *) (parent_class))->destroy) (object);
-}
-
-static void
-sp_color_preview_size_request (GtkWidget *widget, GtkRequisition *requisition)
-{
- SPColorPreview *slider;
-
- slider = SP_COLOR_PREVIEW (widget);
-
- requisition->width = SPCP_DEFAULT_WIDTH;
- requisition->height = SPCP_DEFAULT_HEIGHT;
-}
-
-static void
-sp_color_preview_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
-{
- SPColorPreview *image;
-
- image = SP_COLOR_PREVIEW (widget);
-
- widget->allocation = *allocation;
-
- if (gtk_widget_is_drawable (GTK_WIDGET (image))) {
- gtk_widget_queue_draw (GTK_WIDGET (image));
- }
-}
-
-static gint
-sp_color_preview_expose (GtkWidget *widget, GdkEventExpose *event)
-{
- SPColorPreview *cp;
-
- cp = SP_COLOR_PREVIEW (widget);
-
- if (gtk_widget_is_drawable (widget)) {
- sp_color_preview_paint (cp, &event->area);
- }
-
- return TRUE;
-}
-
-GtkWidget *
-sp_color_preview_new (guint32 rgba)
-{
- SPColorPreview *image;
-
- image = (SPColorPreview*)gtk_type_new (SP_TYPE_COLOR_PREVIEW);
-
- sp_color_preview_set_rgba32 (image, rgba);
-
- return (GtkWidget *) image;
-}
-
-void
-sp_color_preview_set_rgba32 (SPColorPreview *cp, guint32 rgba)
-{
- cp->rgba = rgba;
-
- if (gtk_widget_is_drawable (GTK_WIDGET (cp))) {
- gtk_widget_queue_draw (GTK_WIDGET (cp));
- }
-}
-
-static void
-sp_color_preview_paint (SPColorPreview *cp, GdkRectangle *area)
-{
- GtkWidget *widget;
- GdkRectangle warea, carea;
- GdkRectangle wpaint, cpaint;
- gint w2;
-
- widget = GTK_WIDGET (cp);
-
- warea.x = widget->allocation.x;
- warea.y = widget->allocation.y;
- warea.width = widget->allocation.width;
- warea.height = widget->allocation.height;
-
- if (!gdk_rectangle_intersect (area, &warea, &wpaint)) return;
-
- /* Transparent area */
-
- w2 = warea.width / 2;
-
- carea.x = warea.x;
- carea.y = warea.y;
- carea.width = w2;
- carea.height = warea.height;
-
- if (gdk_rectangle_intersect (area, &carea, &cpaint)) {
- nr_gdk_draw_rgba32_solid (widget->window, widget->style->black_gc,
- cpaint.x, cpaint.y,
- cpaint.width, cpaint.height,
- cp->rgba);
- }
-
- /* Solid area */
-
- carea.x = warea.x + w2;
- carea.y = warea.y;
- carea.width = warea.width - w2;
- carea.height = warea.height;
-
- if (gdk_rectangle_intersect (area, &carea, &cpaint)) {
- nr_gdk_draw_rgba32_solid (widget->window, widget->style->black_gc,
- cpaint.x, cpaint.y,
- cpaint.width, cpaint.height,
- cp->rgba | 0xff);
- }
-}
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/sp-color-preview.h b/src/widgets/sp-color-preview.h
deleted file mode 100644
index 43abdf11f..000000000
--- a/src/widgets/sp-color-preview.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#ifndef SEEN_COLOR_PREVIEW_H
-#define SEEN_COLOR_PREVIEW_H
-
-/*
- * A simple color preview widget
- *
- * Author:
- * Lauris Kaplinski <lauris@kaplinski.com>
- *
- * Copyright (C) 2001-2002 Lauris Kaplinski
- * Copyright (C) 2001 Ximian, Inc.
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <gtk/gtk.h>
-
-#include <glib.h>
-
-
-
-#define SP_TYPE_COLOR_PREVIEW (sp_color_preview_get_type ())
-#define SP_COLOR_PREVIEW(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_COLOR_PREVIEW, SPColorPreview))
-#define SP_COLOR_PREVIEW_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), SP_TYPE_COLOR_PREVIEW, SPColorPreviewClass))
-#define SP_IS_COLOR_PREVIEW(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SP_TYPE_COLOR_PREVIEW))
-#define SP_IS_COLOR_PREVIEW_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_PREVIEW))
-
-struct SPColorPreview {
- GtkWidget widget;
-
- guint32 rgba;
-};
-
-struct SPColorPreviewClass {
- GtkWidgetClass parent_class;
-};
-
-GType sp_color_preview_get_type(void);
-
-GtkWidget *sp_color_preview_new(guint32 rgba);
-
-void sp_color_preview_set_rgba32(SPColorPreview *cp, guint32 color);
-
-
-#endif // SEEN_COLOR_PREVIEW_H
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index d2b280e44..9da39bac4 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -613,7 +613,7 @@ static gboolean stroke_width_set_unit(SPUnitSelector *,
gdouble average = stroke_average_width (objects);
- if (average == NR_HUGE || average == 0)
+ if (average == Geom::infinity() || average == 0)
return FALSE;
a->set_value (100.0 * w / average);
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 8241f1941..01308104e 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -3454,7 +3454,7 @@ static void box3d_set_button_and_adjustment(Persp3D *persp,
gtk_action_set_sensitive(act, TRUE);
double angle = persp3d_get_infinite_angle(persp, axis);
- if (angle != NR_HUGE) { // FIXME: We should catch this error earlier (don't show the spinbutton at all)
+ if (angle != Geom::infinity()) { // FIXME: We should catch this error earlier (don't show the spinbutton at all)
gtk_adjustment_set_value(adj, box3d_normalize_angle(angle));
}
} else {