summaryrefslogtreecommitdiffstats
path: root/src/ui/widget
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-01-06 19:53:50 +0000
committerJabiertxo Arraiza Cenoz <jtx@jtx.marker.es>2013-01-06 19:53:50 +0000
commit38cba87ca97f83927c94519eda2c326c8bde16cd (patch)
tree0390c36513eaf3ab61ff9b182000e63bfc592ffe /src/ui/widget
parentFixed StartAnchor continue errors with bspline (diff)
parentvisual bbox minimum width (Bug 1094802) (diff)
downloadinkscape-38cba87ca97f83927c94519eda2c326c8bde16cd.tar.gz
inkscape-38cba87ca97f83927c94519eda2c326c8bde16cd.zip
Update to trunk
(bzr r11950.1.14)
Diffstat (limited to 'src/ui/widget')
-rw-r--r--src/ui/widget/color-preview.cpp90
-rw-r--r--src/ui/widget/color-preview.h19
-rw-r--r--src/ui/widget/imageicon.cpp6
-rw-r--r--src/ui/widget/object-composite-settings.cpp4
-rw-r--r--src/ui/widget/preferences-widget.cpp34
-rw-r--r--src/ui/widget/preferences-widget.h7
6 files changed, 107 insertions, 53 deletions
diff --git a/src/ui/widget/color-preview.cpp b/src/ui/widget/color-preview.cpp
index 3ebb282ec..4b4a7b738 100644
--- a/src/ui/widget/color-preview.cpp
+++ b/src/ui/widget/color-preview.cpp
@@ -26,13 +26,6 @@ ColorPreview::ColorPreview (guint32 rgba)
}
void
-ColorPreview::on_size_request (Gtk::Requisition *req)
-{
- req->width = SPCP_DEFAULT_WIDTH;
- req->height = SPCP_DEFAULT_HEIGHT;
-}
-
-void
ColorPreview::on_size_allocate (Gtk::Allocation &all)
{
set_allocation (all);
@@ -40,14 +33,55 @@ ColorPreview::on_size_allocate (Gtk::Allocation &all)
queue_draw();
}
+#if WITH_GTKMM_3_0
+void
+ColorPreview::get_preferred_height_vfunc(int& minimum_height, int& natural_height) const
+{
+ minimum_height = natural_height = SPCP_DEFAULT_HEIGHT;
+}
+
+void
+ColorPreview::get_preferred_height_for_width_vfunc(int /* width */, int& minimum_height, int& natural_height) const
+{
+ minimum_height = natural_height = SPCP_DEFAULT_HEIGHT;
+}
+
+void
+ColorPreview::get_preferred_width_vfunc(int& minimum_width, int& natural_width) const
+{
+ minimum_width = natural_width = SPCP_DEFAULT_WIDTH;
+}
+
+void
+ColorPreview::get_preferred_width_for_height_vfunc(int /* height */, int& minimum_width, int& natural_width) const
+{
+ minimum_width = natural_width = SPCP_DEFAULT_WIDTH;
+}
+#else
+void
+ColorPreview::on_size_request (Gtk::Requisition *req)
+{
+ req->width = SPCP_DEFAULT_WIDTH;
+ req->height = SPCP_DEFAULT_HEIGHT;
+}
+
bool
ColorPreview::on_expose_event (GdkEventExpose *event)
{
+ bool result = true;
+
if (get_is_drawable())
- paint (&event->area);
+ {
+ Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
+ cr->rectangle(event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cr->clip();
+ result = on_draw(cr);
+ }
- return true;
+ return result;
}
+#endif
void
ColorPreview::setRgba32 (guint32 rgba)
@@ -58,11 +92,10 @@ ColorPreview::setRgba32 (guint32 rgba)
queue_draw();
}
-void
-ColorPreview::paint (GdkRectangle *area)
+bool
+ColorPreview::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
GdkRectangle warea, carea;
- GdkRectangle wpaint, cpaint;
gint w2;
const Gtk::Allocation& allocation = get_allocation();
@@ -71,12 +104,6 @@ ColorPreview::paint (GdkRectangle *area)
warea.width = allocation.get_width();
warea.height = allocation.get_height();
- if (!gdk_rectangle_intersect (area, &warea, &wpaint))
- return;
-
- GtkWidget *widget = GTK_WIDGET(this->gobj());
- cairo_t *ct = gdk_cairo_create(gtk_widget_get_window(widget));
-
/* Transparent area */
w2 = warea.width / 2;
@@ -86,17 +113,15 @@ ColorPreview::paint (GdkRectangle *area)
carea.width = w2;
carea.height = warea.height;
- if (gdk_rectangle_intersect (area, &carea, &cpaint)) {
- cairo_pattern_t *checkers = ink_cairo_pattern_create_checkerboard();
+ cairo_pattern_t *checkers = ink_cairo_pattern_create_checkerboard();
- cairo_rectangle(ct, carea.x, carea.y, carea.width, carea.height);
- cairo_set_source(ct, checkers);
- cairo_fill_preserve(ct);
- ink_cairo_set_source_rgba32(ct, _rgba);
- cairo_fill(ct);
+ cr->rectangle(carea.x, carea.y, carea.width, carea.height);
+ cairo_set_source(cr->cobj(), checkers);
+ cr->fill_preserve();
+ ink_cairo_set_source_rgba32(cr->cobj(), _rgba);
+ cr->fill();
- cairo_pattern_destroy(checkers);
- }
+ cairo_pattern_destroy(checkers);
/* Solid area */
@@ -105,13 +130,11 @@ ColorPreview::paint (GdkRectangle *area)
carea.width = warea.width - w2;
carea.height = warea.height;
- if (gdk_rectangle_intersect (area, &carea, &cpaint)) {
- cairo_rectangle(ct, carea.x, carea.y, carea.width, carea.height);
- ink_cairo_set_source_rgba32(ct, _rgba | 0xff);
- cairo_fill(ct);
- }
+ cr->rectangle(carea.x, carea.y, carea.width, carea.height);
+ ink_cairo_set_source_rgba32(cr->cobj(), _rgba | 0xff);
+ cr->fill();
- cairo_destroy(ct);
+ return true;
}
GdkPixbuf*
@@ -173,3 +196,4 @@ ColorPreview::toPixbuf (int width, int height)
fill-column:99
End:
*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/ui/widget/color-preview.h b/src/ui/widget/color-preview.h
index d6d3da01c..caddfb9a2 100644
--- a/src/ui/widget/color-preview.h
+++ b/src/ui/widget/color-preview.h
@@ -11,6 +11,10 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <gtkmm/widget.h>
namespace Inkscape {
@@ -27,10 +31,19 @@ public:
GdkPixbuf* toPixbuf (int width, int height);
protected:
- virtual void on_size_request (Gtk::Requisition *req);
virtual void on_size_allocate (Gtk::Allocation &all);
- virtual bool on_expose_event (GdkEventExpose *event);
- void paint (GdkRectangle *area);
+
+#if WITH_GTKMM_3_0
+ virtual void get_preferred_height_vfunc(int& minimum_height, int& natural_height) const;
+ virtual void get_preferred_height_for_width_vfunc(int width, int& minimum_height, int& natural_height) const;
+ virtual void get_preferred_width_vfunc(int& minimum_width, int& natural_width) const;
+ virtual void get_preferred_width_for_height_vfunc(int height, int& minimum_width, int& natural_width) const;
+#else
+ virtual void on_size_request (Gtk::Requisition *req);
+ virtual bool on_expose_event(GdkEventExpose *event);
+#endif
+
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
guint32 _rgba;
};
diff --git a/src/ui/widget/imageicon.cpp b/src/ui/widget/imageicon.cpp
index 567608ef8..1c36dc36e 100644
--- a/src/ui/widget/imageicon.cpp
+++ b/src/ui/widget/imageicon.cpp
@@ -117,7 +117,7 @@ bool ImageIcon::showSvgDocument(const SPDocument *docArg)
viewerGtkmm->show();
pack_start(*viewerGtkmm, TRUE, TRUE, 0);
- //GtkWidget *vbox = (GtkWidget *)gobj();
+ //GtkWidget *vbox = GTK_WIDGET(gobj());
//gtk_box_pack_start(GTK_BOX(vbox), viewerGtk, TRUE, TRUE, 0);
return true;
@@ -306,7 +306,7 @@ void ImageIcon::showBrokenImage(const Glib::ustring &errorMessage)
"</svg>";
//Fill in the template
- char *cErrorMessage = (char *)errorMessage.c_str();
+ char *cErrorMessage = const_cast<char *>(errorMessage.c_str());
gchar *xmlBuffer = g_strdup_printf(xformat, cErrorMessage);
//g_message("%s\n", xmlBuffer);
@@ -375,7 +375,7 @@ bool ImageIcon::show(const Glib::ustring &fileName)
if (!Glib::file_test(fileName, Glib::FILE_TEST_EXISTS))
return false;
- gchar *fName = (gchar *)fileName.c_str();
+ gchar *fName = const_cast<gchar *>(fileName.c_str());
//g_message("fname:%s\n", fName);
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index 2789676ea..537db0fdd 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -89,8 +89,8 @@ ObjectCompositeSettings::ObjectCompositeSettings(unsigned int verb_code, char co
/* SizeGroup keeps the blur and opacity labels aligned in Fill & Stroke dlg */
/*
GtkSizeGroup *labels = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
- gtk_size_group_add_widget(labels, (GtkWidget *) _opacity_label.gobj());
- gtk_size_group_add_widget(labels, (GtkWidget *) _fe_cb.get_blur_label()->gobj());
+ gtk_size_group_add_widget(labels, GTK_WIDGET(_opacity_label.gobj()));
+ gtk_size_group_add_widget(labels, GTK_WIDGET(_fe_cb.get_blur_label()->gobj()));
*/
show_all_children();
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index e7e317d11..e5b062ec9 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -373,10 +373,27 @@ ZoomCorrRuler::draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int maj
}
}
-void
-ZoomCorrRuler::redraw() {
+#if !WITH_GTKMM_3_0
+bool
+ZoomCorrRuler::on_expose_event(GdkEventExpose *event) {
+ bool result = false;
+
+ if(get_is_drawable())
+ {
+ Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
+ cr->rectangle(event->area.x, event->area.y,
+ event->area.width, event->area.height);
+ cr->clip();
+ result = on_draw(cr);
+ }
+
+ return result;
+}
+#endif
+
+bool
+ZoomCorrRuler::on_draw(const Cairo::RefPtr<Cairo::Context>& cr) {
Glib::RefPtr<Gdk::Window> window = get_window();
- Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
int w = window->get_width();
_drawing_width = w - _border * 2;
@@ -415,14 +432,11 @@ ZoomCorrRuler::redraw() {
draw_marks(cr, 1, 1);
}
cr->stroke();
-}
-bool
-ZoomCorrRuler::on_expose_event(GdkEventExpose */*event*/) {
- this->redraw();
return true;
}
+
void
ZoomCorrRulerSlider::on_slider_value_changed()
{
@@ -432,7 +446,7 @@ ZoomCorrRulerSlider::on_slider_value_changed()
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/options/zoomcorrection/value", _slider.get_value() / 100.0);
_sb.set_value(_slider.get_value());
- _ruler.redraw();
+ _ruler.queue_draw();
freeze = false;
}
}
@@ -446,7 +460,7 @@ ZoomCorrRulerSlider::on_spinbutton_value_changed()
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setDouble("/options/zoomcorrection/value", _sb.get_value() / 100.0);
_slider.set_value(_sb.get_value());
- _ruler.redraw();
+ _ruler.queue_draw();
freeze = false;
}
}
@@ -463,7 +477,7 @@ ZoomCorrRulerSlider::on_unit_changed() {
double conv = _unit.getConversion(_unit.getUnitAbbr(), "px");
_ruler.set_unit_conversion(conv);
if (_ruler.get_visible()) {
- _ruler.redraw();
+ _ruler.queue_draw();
}
}
diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h
index bfe0deaba..646a8b2fa 100644
--- a/src/ui/widget/preferences-widget.h
+++ b/src/ui/widget/preferences-widget.h
@@ -101,8 +101,6 @@ public:
ZoomCorrRuler(int width = 100, int height = 20);
void set_size(int x, int y);
void set_unit_conversion(double conv) { _unitconv = conv; }
- void set_cairo_context(Cairo::RefPtr<Cairo::Context> cr);
- void redraw();
int width() { return _min_width + _border*2; }
@@ -110,7 +108,12 @@ public:
static const double textpadding;
private:
+#if !WITH_GTKMM_3_0
bool on_expose_event(GdkEventExpose *event);
+#endif
+
+ bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
+
void draw_marks(Cairo::RefPtr<Cairo::Context> cr, double dist, int major_interval);
double _unitconv;