1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* 3 * Authors: 4 * Carl Hetherington <inkscape@carlh.net> 5 * Derek P. Moore <derekm@hackunix.org> 6 * 7 * Copyright (C) 2004 Carl Hetherington 8 * 9 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 10 */ 11 12 #ifndef INKSCAPE_UI_WIDGET_LABELLED_H 13 #define INKSCAPE_UI_WIDGET_LABELLED_H 14 15 #include <gtkmm/box.h> 16 17 namespace Gtk { 18 class Image; 19 class Label; 20 } 21 22 namespace Inkscape { 23 namespace UI { 24 namespace Widget { 25 26 /** 27 * Adds a label with optional icon or suffix to another widget. 28 */ 29 class Labelled : public Gtk::Box 30 { 31 protected: 32 Gtk::Widget *_widget; 33 Gtk::Label *_label; 34 Gtk::Label *_suffix; 35 Gtk::Image *_icon; 36 37 public: 38 /** 39 * Construct a Labelled Widget. 40 * 41 * @param label Label. 42 * @param widget Widget to label; should be allocated with new, as it will 43 * be passed to Gtk::manage(). 44 * @param suffix Suffix, placed after the widget (defaults to ""). 45 * @param icon Icon filename, placed before the label (defaults to ""). 46 * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the text 47 * indicates the next character should be used for the 48 * mnemonic accelerator key (defaults to true). 49 */ 50 Labelled(Glib::ustring const &label, Glib::ustring const &tooltip, 51 Gtk::Widget *widget, 52 Glib::ustring const &suffix = "", 53 Glib::ustring const &icon = "", 54 bool mnemonic = true); 55 56 /** 57 * Allow the setting of the width of the labelled widget 58 */ 59 void setWidgetSizeRequest(int width, int height); 60 getWidget()61 inline decltype(_widget) getWidget() const { return _widget; } 62 Gtk::Label const *getLabel() const; 63 64 void setLabelText(const Glib::ustring &str); 65 void setTooltipText(const Glib::ustring &tooltip); 66 67 void set_hexpand(bool expand = true); 68 69 private: 70 bool on_mnemonic_activate( bool group_cycling ) override; 71 }; 72 73 } // namespace Widget 74 } // namespace UI 75 } // namespace Inkscape 76 77 #endif // INKSCAPE_UI_WIDGET_LABELLED_H 78 79 /* 80 Local Variables: 81 mode:c++ 82 c-file-style:"stroustrup" 83 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 84 indent-tabs-mode:nil 85 fill-column:99 86 End: 87 */ 88 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : 89