diff options
| author | su_v <suv-sf@users.sourceforge.net> | 2013-01-01 18:24:47 +0000 |
|---|---|---|
| committer | ~suv <suv-sf@users.sourceforge.net> | 2013-01-01 18:24:47 +0000 |
| commit | 0b3b386881da011ac7ee60dd20bd610fd9670677 (patch) | |
| tree | 59d08dfb788ebbe333fa21140fcd8203faadc356 /src/ui/widget | |
| parent | merge from trunk (r11952) (diff) | |
| parent | clip path visual bbox refresh, second try (Bug 1005085) (diff) | |
| download | inkscape-0b3b386881da011ac7ee60dd20bd610fd9670677.tar.gz inkscape-0b3b386881da011ac7ee60dd20bd610fd9670677.zip | |
merge from trunk (r12005)
(bzr r11668.1.47)
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/color-preview.cpp | 90 | ||||
| -rw-r--r-- | src/ui/widget/color-preview.h | 19 | ||||
| -rw-r--r-- | src/ui/widget/imageicon.cpp | 6 | ||||
| -rw-r--r-- | src/ui/widget/object-composite-settings.cpp | 4 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.cpp | 52 | ||||
| -rw-r--r-- | src/ui/widget/page-sizer.h | 24 | ||||
| -rw-r--r-- | src/ui/widget/panel.cpp | 6 | ||||
| -rw-r--r-- | src/ui/widget/panel.h | 16 | ||||
| -rw-r--r-- | src/ui/widget/preferences-widget.cpp | 34 | ||||
| -rw-r--r-- | src/ui/widget/preferences-widget.h | 7 |
10 files changed, 202 insertions, 56 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/page-sizer.cpp b/src/ui/widget/page-sizer.cpp index 2ab72d6c7..fa3f8e3a1 100644 --- a/src/ui/widget/page-sizer.cpp +++ b/src/ui/widget/page-sizer.cpp @@ -330,14 +330,36 @@ PageSizer::PageSizer(Registry & _wr) pack_start (_customFrame, false, false, 0); _customFrame.add(_customDimTable); - _customDimTable.resize(3, 2); _customDimTable.set_border_width(4); + +#if WITH_GTKMM_3_0 + _customDimTable.set_row_spacing(4); + _customDimTable.set_column_spacing(4); + + _dimensionWidth.set_hexpand(); + _dimensionWidth.set_vexpand(); + _customDimTable.attach(_dimensionWidth, 0, 0, 1, 1); + + _dimensionUnits.set_hexpand(); + _dimensionUnits.set_vexpand(); + _customDimTable.attach(_dimensionUnits, 1, 0, 1, 1); + + _dimensionHeight.set_hexpand(); + _dimensionHeight.set_vexpand(); + _customDimTable.attach(_dimensionHeight, 0, 1, 1, 1); + + _fitPageMarginExpander.set_hexpand(); + _fitPageMarginExpander.set_vexpand(); + _customDimTable.attach(_fitPageMarginExpander, 0, 2, 2, 1); +#else + _customDimTable.resize(3, 2); _customDimTable.set_row_spacings(4); _customDimTable.set_col_spacings(4); _customDimTable.attach(_dimensionWidth, 0,1, 0,1); _customDimTable.attach(_dimensionUnits, 1,2, 0,1); _customDimTable.attach(_dimensionHeight, 0,1, 1,2); _customDimTable.attach(_fitPageMarginExpander, 0,2, 2,3); +#endif _dimTabOrderGList = NULL; _dimTabOrderGList = g_list_append(_dimTabOrderGList, _dimensionWidth.gobj()); @@ -353,7 +375,32 @@ PageSizer::PageSizer(Registry & _wr) _fitPageMarginExpander.add(_marginTable); //## Set up margin settings - _marginTable.resize(4, 2); + _marginTable.set_border_width(4); + +#if WITH_GTKMM_3_0 + _marginTable.set_row_spacing(4); + _marginTable.set_column_spacing(4); + + _marginTopAlign.set_hexpand(); + _marginTopAlign.set_vexpand(); + _marginTable.attach(_marginTopAlign, 0, 0, 2, 1); + + _marginLeftAlign.set_hexpand(); + _marginLeftAlign.set_vexpand(); + _marginTable.attach(_marginLeftAlign, 0, 1, 1, 1); + + _marginRightAlign.set_hexpand(); + _marginRightAlign.set_vexpand(); + _marginTable.attach(_marginRightAlign, 1, 1, 1, 1); + + _marginBottomAlign.set_hexpand(); + _marginBottomAlign.set_vexpand(); + _marginTable.attach(_marginBottomAlign, 0, 2, 2, 1); + + _fitPageButtonAlign.set_hexpand(); + _fitPageButtonAlign.set_vexpand(); + _marginTable.attach(_fitPageButtonAlign, 0, 3, 2, 1); +#else _marginTable.set_border_width(4); _marginTable.set_row_spacings(4); _marginTable.set_col_spacings(4); @@ -362,6 +409,7 @@ PageSizer::PageSizer(Registry & _wr) _marginTable.attach(_marginRightAlign, 1,2, 1,2); _marginTable.attach(_marginBottomAlign, 0,2, 2,3); _marginTable.attach(_fitPageButtonAlign, 0,2, 3,4); +#endif _marginTopAlign.set(0.5, 0.5, 0.0, 1.0); _marginTopAlign.add(_marginTop); diff --git a/src/ui/widget/page-sizer.h b/src/ui/widget/page-sizer.h index 17fd7b1ea..d1fbb56e0 100644 --- a/src/ui/widget/page-sizer.h +++ b/src/ui/widget/page-sizer.h @@ -10,6 +10,10 @@ #ifndef INKSCAPE_UI_WIDGET_PAGE_SIZER_H #define INKSCAPE_UI_WIDGET_PAGE_SIZER_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <stddef.h> #include "ui/widget/registered-widget.h" #include <sigc++/sigc++.h> @@ -21,7 +25,13 @@ #include <gtkmm/frame.h> #include <gtkmm/liststore.h> #include <gtkmm/scrolledwindow.h> -#include <gtkmm/table.h> + +#if WITH_GTKMM_3_0 +# include <gtkmm/grid.h> +#else +# include <gtkmm/table.h> +#endif + #include <gtkmm/radiobutton.h> namespace Inkscape { @@ -207,7 +217,13 @@ protected: //### Custom size frame Gtk::Frame _customFrame; + +#if WITH_GTKMM_3_0 + Gtk::Grid _customDimTable; +#else Gtk::Table _customDimTable; +#endif + RegisteredUnitMenu _dimensionUnits; RegisteredScalarUnit _dimensionWidth; RegisteredScalarUnit _dimensionHeight; @@ -215,7 +231,13 @@ protected: //### Fit Page options Gtk::Expander _fitPageMarginExpander; + +#if WITH_GTKMM_3_0 + Gtk::Grid _marginTable; +#else Gtk::Table _marginTable; +#endif + Gtk::Alignment _marginTopAlign; Gtk::Alignment _marginLeftAlign; Gtk::Alignment _marginRightAlign; diff --git a/src/ui/widget/panel.cpp b/src/ui/widget/panel.cpp index dcf5956bf..48749fda2 100644 --- a/src/ui/widget/panel.cpp +++ b/src/ui/widget/panel.cpp @@ -591,7 +591,13 @@ void Panel::_addResponseButton(Gtk::Button *button, int response_id, bool pack_s { // Create a button box for the response buttons if it's the first button to be added if (!_action_area) { +#if WITH_GTKMM_3_0 + _action_area = new Gtk::ButtonBox(); + _action_area->set_layout(Gtk::BUTTONBOX_END); + _action_area->set_spacing(6); +#else _action_area = new Gtk::HButtonBox(Gtk::BUTTONBOX_END, 6); +#endif _action_area->set_border_width(4); pack_end(*_action_area, Gtk::PACK_SHRINK, 0); } diff --git a/src/ui/widget/panel.h b/src/ui/widget/panel.h index b4cc04809..5bb054577 100644 --- a/src/ui/widget/panel.h +++ b/src/ui/widget/panel.h @@ -13,6 +13,10 @@ #ifndef SEEN_INKSCAPE_UI_WIDGET_PANEL_H #define SEEN_INKSCAPE_UI_WIDGET_PANEL_H +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <gtkmm/box.h> #include <gtkmm/arrow.h> #include <gtkmm/button.h> @@ -27,7 +31,13 @@ class SPDocument; namespace Gtk { class CheckMenuItem; + +#if WITH_GTKMM_3_0 + class ButtonBox; +#else class HButtonBox; +#endif + class MenuItem; } @@ -157,7 +167,13 @@ private: Gtk::EventBox _menu_popper; Gtk::Button _close_button; Gtk::Menu *_menu; + +#if WITH_GTKMM_3_0 + Gtk::ButtonBox *_action_area; //< stores response buttons +#else Gtk::HButtonBox *_action_area; //< stores response buttons +#endif + std::vector<Gtk::Widget *> _non_horizontal; std::vector<Gtk::Widget *> _non_vertical; PreviewFillable *_fillable; 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; |
