diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-04-17 08:31:13 +0000 |
|---|---|---|
| committer | John Smith <removethis.john.q.public@bigmail.com> | 2012-04-17 08:31:13 +0000 |
| commit | 0c63499f4369d78f9f7186438dfc2051d4f677bb (patch) | |
| tree | 58693855f3c7b6108f150197faed10a621bba234 /src/ui/widget | |
| parent | some more string class usage as opposed to c-strings to prevent issues (diff) | |
| download | inkscape-0c63499f4369d78f9f7186438dfc2051d4f677bb.tar.gz inkscape-0c63499f4369d78f9f7186438dfc2051d4f677bb.zip | |
Fix for 169888 : HIG Style frame
(bzr r11260)
Diffstat (limited to 'src/ui/widget')
| -rw-r--r-- | src/ui/widget/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/ui/widget/frame.cpp | 83 | ||||
| -rw-r--r-- | src/ui/widget/frame.h | 79 |
3 files changed, 164 insertions, 0 deletions
diff --git a/src/ui/widget/Makefile_insert b/src/ui/widget/Makefile_insert index 4dc83a81d..cea869300 100644 --- a/src/ui/widget/Makefile_insert +++ b/src/ui/widget/Makefile_insert @@ -19,6 +19,8 @@ ink_common_sources += \ ui/widget/entry.h \ ui/widget/filter-effect-chooser.h \ ui/widget/filter-effect-chooser.cpp \ + ui/widget/frame.cpp \ + ui/widget/frame.h \ ui/widget/handlebox.cpp \ ui/widget/handlebox.h \ ui/widget/icon-widget.cpp \ diff --git a/src/ui/widget/frame.cpp b/src/ui/widget/frame.cpp new file mode 100644 index 000000000..b2968f806 --- /dev/null +++ b/src/ui/widget/frame.cpp @@ -0,0 +1,83 @@ +/* + * Authors: + * Murray C + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include "frame.h" + + +// Inkscape::UI::Widget::Frame + +namespace Inkscape { +namespace UI { +namespace Widget { + +Frame::Frame(Glib::ustring const &label_text /*= ""*/, gboolean label_bold /*= TRUE*/ ) + : _label(label_text, 1.0, 0.5, TRUE), + _alignment() +{ + set_shadow_type(Gtk::SHADOW_NONE); + + //Put an indented GtkAlignment inside the frame. + //Further children should be children of this GtkAlignment: + Gtk::Frame::add(_alignment); + set_padding(4, 0, 8, 0); + + set_label_widget(_label); + set_label(label_text, label_bold); + + show_all_children(); +} + +void +Frame::add(Widget& widget) +{ + _alignment.add(widget); +} + +void +Frame::set_label(const Glib::ustring &label_text, gboolean label_bold /*= TRUE*/) +{ + if (label_bold) { + _label.set_markup(Glib::ustring("<b>") + label_text + "</b>"); + } else { + _label.set_text(label_text); + } +} + +void +Frame::set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right) +{ +#if WITH_GTKMM_2_24 + _alignment.set_padding(padding_top, padding_bottom, padding_left, padding_right); +#endif +} + +Gtk::Label const * +Frame::get_label_widget() const +{ + return &_label; +} + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +/* + 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/ui/widget/frame.h b/src/ui/widget/frame.h new file mode 100644 index 000000000..cf736d8a1 --- /dev/null +++ b/src/ui/widget/frame.h @@ -0,0 +1,79 @@ +/* + * Authors: + * Murray C + * + * Copyright (C) 2012 Authors + * + * Released under GNU GPL. Read the file 'COPYING' for more information. + */ + +#ifndef INKSCAPE_UI_WIDGET_FRAME_H +#define INKSCAPE_UI_WIDGET_FRAME_H + +#include <gtkmm.h> + +namespace Gtk { +class Frame; +} + +namespace Inkscape { +namespace UI { +namespace Widget { + +/** + * Creates a Gnome HIG style indented frame with bold label + * See http://developer.gnome.org/hig-book/stable/controls-frames.html.en + */ +class Frame : public Gtk::Frame +{ +public: + + /** + * Construct a Frame Widget. + * + * @param label The frame text. + */ + Frame(Glib::ustring const &label = "", gboolean label_bold = TRUE); + + /** + * Return the label widget + */ + Gtk::Label const *get_label_widget() const; + + /** + * Add a widget to this frame + */ + virtual void add(Widget& widget); + + /** + * Set the frame label text and if bold or not + */ + void set_label(const Glib::ustring &label, gboolean label_bold = TRUE); + + /** + * Set the frame padding + */ + void set_padding (guint padding_top, guint padding_bottom, guint padding_left, guint padding_right); + +protected: + Gtk::Label _label; + Gtk::Alignment _alignment; + +}; + +} // namespace Widget +} // namespace UI +} // namespace Inkscape + +#endif // INKSCAPE_UI_WIDGET_FRAME_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 : |
