| 1 |
/* Copyright (C) 1998-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 |
#include <gtkmm/frame.h> |
| 18 |
_DEFS(gtkmm,gtk) |
| 19 |
_PINCLUDE(gtkmm/private/frame_p.h) |
| 20 |
|
| 21 |
namespace Gtk |
| 22 |
{ |
| 23 |
|
| 24 |
/** A frame that constrains its child to a particular aspect ratio. |
| 25 |
* |
| 26 |
* The Gtk::AspectFrame is useful when you want pack a widget so that it can |
| 27 |
* resize but always retains the same aspect ratio. For instance, one might |
| 28 |
* be drawing a small preview of a larger image. Because it derives from |
| 29 |
* Gtk::Frame, it can draw a label and a frame around the child. The frame |
| 30 |
* will be "shrink-wrapped" to the size of the child. |
| 31 |
* |
| 32 |
* @ingroup Widgets |
| 33 |
* @ingroup Containers |
| 34 |
*/ |
| 35 |
class GTKMM_API AspectFrame : public Frame |
| 36 |
{ |
| 37 |
_CLASS_GTKOBJECT(AspectFrame,GtkAspectFrame,GTK_ASPECT_FRAME,Gtk::Frame,GtkFrame,,,GTKMM_API) |
| 38 |
|
| 39 |
public: |
| 40 |
|
| 41 |
/** Constructor to create a new AspectFrame object. |
| 42 |
* @param label Label text. |
| 43 |
* @param xalign Horizontal alignment of the child within the allocation of this |
| 44 |
* AspectFrame. For possible values, see Gtk::Align. |
| 45 |
* @param yalign Vertical alignment of the child within the allocation of this |
| 46 |
* AspectFrame. For possible values, see Gtk::Align. |
| 47 |
* @param ratio The desired aspect ratio. |
| 48 |
* @param obey_child If <tt>true</tt>, @a ratio is ignored and the aspect ratio |
| 49 |
* is taken from the requisition of the child. |
| 50 |
*/ |
| 51 |
_WRAP_CTOR(AspectFrame(const Glib::ustring& label = Glib::ustring(), |
| 52 |
Align xalign = Gtk::ALIGN_CENTER, Align yalign = Gtk::ALIGN_CENTER, |
| 53 |
float ratio = 1.0, bool obey_child = false), gtk_aspect_frame_new) |
| 54 |
|
| 55 |
/** Constructor to create a new AspectFrame object. |
| 56 |
* @param label Label text. |
| 57 |
* @param xalign Horizontal alignment of the child within the allocation of this |
| 58 |
* AspectFrame. This ranges from 0.0 (left aligned) to 1.0 (right aligned). |
| 59 |
* @param yalign Vertical alignment of the child within the allocation of this |
| 60 |
* AspectFrame. This ranges from 0.0 (top aligned) to 1.0 (bottom aligned). |
| 61 |
* @param ratio The desired aspect ratio. |
| 62 |
* @param obey_child If <tt>true</tt>, @a ratio is ignored and the aspect ratio |
| 63 |
* is taken from the requisition of the child. |
| 64 |
*/ |
| 65 |
_WRAP_CTOR(AspectFrame(const Glib::ustring& label, |
| 66 |
float xalign, float yalign, |
| 67 |
float ratio = 1.0, bool obey_child = false), gtk_aspect_frame_new) |
| 68 |
|
| 69 |
//TODO: Is "obey_child = true" a good default? |
| 70 |
/** Set the properties of this AspectFrame. |
| 71 |
* @param xalign Horizontal alignment of the child within the allocation of this |
| 72 |
* AspectFrame. This ranges from 0.0 (left aligned) to 1.0 (right aligned). |
| 73 |
* @param yalign Vertical alignment of the child within the allocation of this |
| 74 |
* AspectFrame. This ranges from 0.0 (top aligned) to 1.0 (bottom aligned). |
| 75 |
* @param ratio The desired aspect ratio. |
| 76 |
* @param obey_child If <tt>true</tt>, @a ratio is ignored and the aspect ratio |
| 77 |
* is taken from the requisition of the child. |
| 78 |
*/ |
| 79 |
_WRAP_METHOD(void set(float xalign, float yalign, float ratio, bool obey_child = true), gtk_aspect_frame_set) |
| 80 |
|
| 81 |
/** Set the properties of this AspectFrame. |
| 82 |
* @param xalign Horizontal alignment of the child within the allocation of this |
| 83 |
* AspectFrame. For possible values, see Gtk::Align. |
| 84 |
* @param yalign Vertical alignment of the child within the allocation of this |
| 85 |
* AspectFrame. For possible values, see Gtk::Align. |
| 86 |
* @param ratio The desired aspect ratio. |
| 87 |
* @param obey_child If <tt>true</tt>, @a ratio is ignored and the aspect ratio |
| 88 |
* is taken from the requisition of the child. |
| 89 |
*/ |
| 90 |
_WRAP_METHOD(void set(Align xalign, Align yalign, float ratio, bool obey_child = true), gtk_aspect_frame_set) |
| 91 |
|
| 92 |
_WRAP_PROPERTY("xalign", float) |
| 93 |
_WRAP_PROPERTY("yalign", float) |
| 94 |
_WRAP_PROPERTY("ratio", float) |
| 95 |
_WRAP_PROPERTY("obey-child", bool) |
| 96 |
}; |
| 97 |
|
| 98 |
} //namespace Gtk |