| 1 |
/* Copyright (C) 2002 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
_CONFIGINCLUDE(gtkmmconfig.h) |
| 18 |
|
| 19 |
#include <glibmm/value.h> |
| 20 |
#include <gtk/gtk.h> |
| 21 |
|
| 22 |
_DEFS(gtkmm,gtk) |
| 23 |
|
| 24 |
namespace Gtk |
| 25 |
{ |
| 26 |
|
| 27 |
_CC_INCLUDE(gtk/gtk.h) |
| 28 |
|
| 29 |
_WRAP_ENUM(AccelFlags, GtkAccelFlags, decl_prefix GTKMM_API) |
| 30 |
_WRAP_ENUM(Align, GtkAlign, decl_prefix GTKMM_API) |
| 31 |
_WRAP_ENUM(ArrowType, GtkArrowType, decl_prefix GTKMM_API) |
| 32 |
_WRAP_ENUM(AttachOptions, GtkAttachOptions, decl_prefix GTKMM_API) |
| 33 |
_WRAP_ENUM(ButtonBoxStyle, GtkButtonBoxStyle, decl_prefix GTKMM_API) |
| 34 |
_WRAP_ENUM(DeleteType, GtkDeleteType, decl_prefix GTKMM_API) |
| 35 |
_WRAP_ENUM(DirectionType, GtkDirectionType, decl_prefix GTKMM_API) |
| 36 |
|
| 37 |
//TODO: let _WRAP_ENUM() take a deprecated option. |
| 38 |
/** |
| 39 |
* @deprecated This is not used in the gtkmm API. |
| 40 |
*/ |
| 41 |
_WRAP_ENUM(ExpanderStyle, GtkExpanderStyle, decl_prefix GTKMM_API) |
| 42 |
|
| 43 |
_WRAP_ENUM(BuiltinIconSize, GtkIconSize, decl_prefix GTKMM_API) |
| 44 |
_WRAP_ENUM(TextDirection, GtkTextDirection, decl_prefix GTKMM_API) |
| 45 |
_WRAP_ENUM(Justification, GtkJustification, decl_prefix GTKMM_API) |
| 46 |
_WRAP_ENUM(MenuDirectionType, GtkMenuDirectionType, decl_prefix GTKMM_API) |
| 47 |
_WRAP_ENUM(MessageType, GtkMessageType, decl_prefix GTKMM_API) |
| 48 |
_WRAP_ENUM(MovementStep, GtkMovementStep, decl_prefix GTKMM_API) |
| 49 |
_WRAP_ENUM(Orientation, GtkOrientation, decl_prefix GTKMM_API) |
| 50 |
_WRAP_ENUM(CornerType, GtkCornerType, decl_prefix GTKMM_API) |
| 51 |
_WRAP_ENUM(PackType, GtkPackType, decl_prefix GTKMM_API) |
| 52 |
_WRAP_ENUM(PathPriorityType, GtkPathPriorityType, decl_prefix GTKMM_API) |
| 53 |
_WRAP_ENUM(PathType, GtkPathType, decl_prefix GTKMM_API) |
| 54 |
_WRAP_ENUM(PlacesOpenFlags, GtkPlacesOpenFlags, decl_prefix GTKMM_API) |
| 55 |
_WRAP_ENUM(PolicyType, GtkPolicyType, decl_prefix GTKMM_API) |
| 56 |
_WRAP_ENUM(PositionType, GtkPositionType, decl_prefix GTKMM_API) |
| 57 |
_WRAP_ENUM(ReliefStyle, GtkReliefStyle, decl_prefix GTKMM_API) |
| 58 |
_WRAP_ENUM(ResizeMode, GtkResizeMode, decl_prefix GTKMM_API) |
| 59 |
_WRAP_ENUM(RevealerTransitionType, GtkRevealerTransitionType, decl_prefix GTKMM_API) |
| 60 |
_WRAP_ENUM(ScrollType, GtkScrollType, decl_prefix GTKMM_API) |
| 61 |
_WRAP_ENUM(SelectionMode, GtkSelectionMode, decl_prefix GTKMM_API) |
| 62 |
_WRAP_ENUM(ShadowType, GtkShadowType, decl_prefix GTKMM_API) |
| 63 |
_WRAP_ENUM(StackTransitionType, GtkStackTransitionType, decl_prefix GTKMM_API) |
| 64 |
_WRAP_ENUM(StateType, GtkStateType, decl_prefix GTKMM_API) |
| 65 |
_WRAP_ENUM(TargetFlags, GtkTargetFlags, decl_prefix GTKMM_API) |
| 66 |
_WRAP_ENUM(ToolbarStyle, GtkToolbarStyle, decl_prefix GTKMM_API) |
| 67 |
_WRAP_ENUM(WindowPosition,GtkWindowPosition, decl_prefix GTKMM_API) |
| 68 |
_WRAP_ENUM(WindowType,GtkWindowType, decl_prefix GTKMM_API) |
| 69 |
_WRAP_ENUM(WrapMode, GtkWrapMode, decl_prefix GTKMM_API) |
| 70 |
_WRAP_ENUM(SortType, GtkSortType, decl_prefix GTKMM_API) |
| 71 |
_WRAP_ENUM(PageOrientation, GtkPageOrientation, decl_prefix GTKMM_API) |
| 72 |
_WRAP_ENUM(SensitivityType, GtkSensitivityType, decl_prefix GTKMM_API) |
| 73 |
_WRAP_ENUM(SizeRequestMode, GtkSizeRequestMode, decl_prefix GTKMM_API) |
| 74 |
_WRAP_ENUM(RegionFlags, GtkRegionFlags, decl_prefix GTKMM_API) |
| 75 |
_WRAP_ENUM(JunctionSides, GtkJunctionSides, decl_prefix GTKMM_API) |
| 76 |
_WRAP_ENUM(StateFlags, GtkStateFlags, decl_prefix GTKMM_API) |
| 77 |
_WRAP_ENUM(InputPurpose, GtkInputPurpose, decl_prefix GTKMM_API) |
| 78 |
_WRAP_ENUM(InputHints, GtkInputHints, decl_prefix GTKMM_API) |
| 79 |
_WRAP_ENUM(BaselinePosition, GtkBaselinePosition, decl_prefix GTKMM_API) |
| 80 |
|
| 81 |
|
| 82 |
/* We use a class to implement the GtkIconSize enum, because you can register |
| 83 |
* new "enum" values. The strict type rules of C++ don't allow using an enum |
| 84 |
* like that. Gtk::BuiltinIconSize is the actual GtkIconSize wrapper enum. |
| 85 |
*/ |
| 86 |
|
| 87 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 88 |
class GTKMM_API Settings; |
| 89 |
#endif //DOXYGEN_SHOULD_SKIP_THIS |
| 90 |
|
| 91 |
/** |
| 92 |
* Represents registered icon sizes. |
| 93 |
* You can also use a Gtk::BuiltinIconSize instead of an IconSize. |
| 94 |
*/ |
| 95 |
class GTKMM_API IconSize |
| 96 |
{ |
| 97 |
private: |
| 98 |
int size_; |
| 99 |
|
| 100 |
public: |
| 101 |
IconSize() : size_ (0) {} |
| 102 |
IconSize(BuiltinIconSize size) : size_ (size) {} |
| 103 |
|
| 104 |
// Behave like an ordinary enum. |
| 105 |
explicit IconSize(int size) : size_ (size) {} |
| 106 |
operator int() const { return size_; } |
| 107 |
|
| 108 |
/** Obtains the pixel size of a semantic icon size, possibly modified by user preferences for the default Gtk::Settings. |
| 109 |
* Normally size would be Gtk::ICON_SIZE_MENU, Gtk::ICON_SIZE_BUTTON, etc. |
| 110 |
* This function isn't normally needed because Gtk::Widget::render_icon() is the usual way to get an icon for |
| 111 |
* rendering - then just look at the size of the rendered pixbuf. The rendered pixbuf may not even correspond |
| 112 |
* to the width/height returned by IconSize::lookup(), because themes are free to render the pixbuf however they |
| 113 |
* like, including changing the usual size. |
| 114 |
* |
| 115 |
* @param size An icon size. |
| 116 |
* @param width Location to store icon width. |
| 117 |
* @param height Location to store icon height. |
| 118 |
* @result true if size was a valid size. |
| 119 |
*/ |
| 120 |
static bool lookup(IconSize size, int& width, int& height); |
| 121 |
|
| 122 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 123 |
/** Obtains the pixel size of a semantic icon size, possibly modified by user preferences for a particular |
| 124 |
* Gtk::Settings. Normally size would be Gtk::ICON_SIZE_MENU, Gtk::ICON_SIZE_BUTTON, etc. |
| 125 |
* This function isn't normally needed because Gtk::Widget::render_icon() is the usual way to get an icon for |
| 126 |
* rendering - then just look at the size of the rendered pixbuf. The rendered pixbuf may not even correspond |
| 127 |
* to the width/height returned by IconSize::lookup(), because themes are free to render the pixbuf however they |
| 128 |
* like, including changing the usual size. |
| 129 |
* |
| 130 |
* @param size An icon size. |
| 131 |
* @param width Location to store icon width. |
| 132 |
* @param height Location to store icon height. |
| 133 |
* @param settings A Gtk::Settings object, used to determine which set of user preferences to used. |
| 134 |
* @result true if size was a valid size. |
| 135 |
* |
| 136 |
* @deprecated Use IconSize::lookup() without the @a settings parameter instead. |
| 137 |
* @newin{2,14} |
| 138 |
*/ |
| 139 |
static bool lookup(IconSize size, int& width, int& height, const Glib::RefPtr<Gtk::Settings>& settings); |
| 140 |
#endif //GTKMM_DISABLE_DEPRECATED |
| 141 |
|
| 142 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 143 |
/** Registers a new icon size, along the same lines as ICON_SIZE_MENU, etc. Returns the integer value for the size. |
| 144 |
* |
| 145 |
* @param name Name of the icon size. |
| 146 |
* @param width The icon width. |
| 147 |
* @param height The icon height. |
| 148 |
* @result Integer value representing the size. |
| 149 |
* @deprecated Use Gtk::IconTheme instead. |
| 150 |
*/ |
| 151 |
static IconSize register_new(const Glib::ustring& name, int width, int height); |
| 152 |
#endif //GTKMM_DISABLE_DEPRECATED |
| 153 |
|
| 154 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 155 |
/** Registers @a alias as another name for @a target so calling from_name() with @a alias as argument will return @a target. |
| 156 |
* |
| 157 |
* @param alias An alias for target. |
| 158 |
* @param target An existing icon size. |
| 159 |
* @deprecated Use Gtk::IconTheme instead. |
| 160 |
*/ |
| 161 |
static void register_alias(const Glib::ustring& alias, IconSize target); |
| 162 |
#endif //GTKMM_DISABLE_DEPRECATED |
| 163 |
|
| 164 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 165 |
/** Looks up the icon size associated with @a name. |
| 166 |
* |
| 167 |
* @param name the name to look up. |
| 168 |
* @result The icon size with the given name. |
| 169 |
* @deprecated Use Gtk::IconTheme instead. |
| 170 |
*/ |
| 171 |
static IconSize from_name(const Glib::ustring& name); |
| 172 |
#endif //GTKMM_DISABLE_DEPRECATED |
| 173 |
|
| 174 |
#ifndef GTKMM_DISABLE_DEPRECATED |
| 175 |
/** Gets the canonical name of the given icon size. |
| 176 |
* |
| 177 |
* @param size size AnIconSize. |
| 178 |
* @result The name of the given icon size. |
| 179 |
* @deprecated Use Gtk::IconTheme instead. |
| 180 |
*/ |
| 181 |
static Glib::ustring get_name(IconSize size); |
| 182 |
#endif //GTKMM_DISABLE_DEPRECATED |
| 183 |
}; |
| 184 |
|
| 185 |
|
| 186 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 187 |
struct IconSizeTraits |
| 188 |
{ |
| 189 |
typedef Gtk::IconSize CppType; |
| 190 |
typedef GtkIconSize CType; |
| 191 |
typedef GtkIconSize CTypeNonConst; |
| 192 |
|
| 193 |
static CType to_c_type (CType c_obj) { return c_obj; } |
| 194 |
static void release_c_type (CType) {} |
| 195 |
static CType to_c_type (const CppType& cpp_obj) { int value (cpp_obj); return static_cast<CType> (value); } |
| 196 |
static CppType to_cpp_type (CType c_obj) { return CppType (c_obj); } |
| 197 |
}; |
| 198 |
#endif //DOXYGEN_SHOULD_SKIP_THIS |
| 199 |
|
| 200 |
} // namespace Gtk |
| 201 |
|
| 202 |
|
| 203 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 204 |
namespace Glib |
| 205 |
{ |
| 206 |
|
| 207 |
template <> |
| 208 |
class GTKMM_API Value<Gtk::IconSize> : public Glib::Value_Enum<Gtk::IconSize> |
| 209 |
{ |
| 210 |
public: |
| 211 |
static GType value_type() G_GNUC_CONST; |
| 212 |
}; |
| 213 |
|
| 214 |
} // namespace Glib |
| 215 |
#endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 216 |
|
| 217 |
namespace Gtk |
| 218 |
{ |
| 219 |
|
| 220 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 221 |
//We need this because we can't just use floats for enum value. |
| 222 |
GTKMM_API |
| 223 |
float _gtkmm_align_float_from_enum(Align value); |
| 224 |
#endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 225 |
|
| 226 |
} //namespace Gtk |