[libchamplainmm] Label: Add documentation and add unset_ methods
- From: Juan R. Garcia Blanco <juanrgar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplainmm] Label: Add documentation and add unset_ methods
- Date: Sun, 2 Mar 2014 11:20:23 +0000 (UTC)
commit ee704006fe789610c207f7572094644363289c27
Author: Juan R. GarcĂa Blanco <juanrgar gmail com>
Date: Sun Mar 2 12:18:17 2014 +0100
Label: Add documentation and add unset_ methods
* Add documentation for create() methods.
* Add unset_*() methods appropiately.
* Fix some non-const methods.
* Reorganise methods layout.
champlain/src/label.ccg | 72 +++++++++++++++++++++--
champlain/src/label.hg | 116 +++++++++++++++++++++++++++++---------
tools/m4/convert_libchamplain.m4 | 3 -
3 files changed, 156 insertions(+), 35 deletions(-)
---
diff --git a/champlain/src/label.ccg b/champlain/src/label.ccg
index 383759e..bfd2d6e 100644
--- a/champlain/src/label.ccg
+++ b/champlain/src/label.ccg
@@ -36,12 +36,52 @@ Glib::RefPtr<Label> Label::create(const Glib::ustring& text,
return label;
}
-Glib::RefPtr<Label> Label::create(const std::string& filename)
-{
- const Glib::RefPtr<Label> label(new Label());
-
- return label;
-}
+//Glib::RefPtr<Label> Label::create(const std::string& filename)
+//{
+// const Glib::RefPtr<Label> label(new Label());
+//
+//
+// ChamplainLabel *label = CHAMPLAIN_LABEL (champlain_label_new ());
+//
+// ClutterActor *actor;
+// GdkPixbuf *pixbuf;
+// ClutterContent *content;
+// gfloat width, height;
+//
+// if (filename == NULL)
+// return CLUTTER_ACTOR (label);
+//
+// pixbuf = gdk_pixbuf_new_from_file (filename, error);
+// if (pixbuf == NULL)
+// return CLUTTER_ACTOR (label);
+//
+// content = clutter_image_new ();
+// clutter_image_set_data (CLUTTER_IMAGE (content),
+// gdk_pixbuf_get_pixels (pixbuf),
+// gdk_pixbuf_get_has_alpha (pixbuf)
+// ? COGL_PIXEL_FORMAT_RGBA_8888
+// : COGL_PIXEL_FORMAT_RGB_888,
+// gdk_pixbuf_get_width (pixbuf),
+// gdk_pixbuf_get_height (pixbuf),
+// gdk_pixbuf_get_rowstride (pixbuf),
+// error);
+// g_object_unref (pixbuf);
+//
+// actor = clutter_actor_new ();
+// clutter_content_get_preferred_size (content, &width, &height);
+// clutter_actor_set_size (actor, width, height);
+// clutter_actor_set_content (actor, content);
+// clutter_content_invalidate (content);
+// g_object_unref (content);
+//
+// champlain_label_set_image (label, actor);
+//
+// return CLUTTER_ACTOR (label);
+//
+//
+//
+// return label;
+//}
Glib::RefPtr<Label> Label::create(const Glib::RefPtr<Clutter::Actor>& actor)
{
@@ -63,4 +103,24 @@ Glib::RefPtr<Label> Label::create(const Glib::ustring& text,
return label;
}
+void Label::unset_color()
+{
+ champlain_label_set_color(gobj(), NULL);
+}
+
+void Label::unset_font_name()
+{
+ champlain_label_set_font_name(gobj(), NULL);
+}
+
+void Label::unset_image()
+{
+ champlain_label_set_image(gobj(), NULL);
+}
+
+void Label::unset_text_color()
+{
+ champlain_label_set_text_color(gobj(), NULL);
+}
+
} // namespace Champlain
diff --git a/champlain/src/label.hg b/champlain/src/label.hg
index 0d08a85..ed38732 100644
--- a/champlain/src/label.hg
+++ b/champlain/src/label.hg
@@ -60,7 +60,6 @@ protected:
explicit Label(const Glib::RefPtr<Clutter::Actor>& actor);
_IGNORE(champlain_label_new_with_image)
-//TODO
/** Creates a new instance of Label with image loaded from file.
*
* @param filename The filename of the image.
@@ -83,55 +82,120 @@ protected:
public:
_WRAP_CREATE()
-//TODO
+
+ /** Creates a new instance of Label with text value.
+ *
+ * @param text The text of the label
+ * @param font The font to use to draw the text, for example "Courrier Bold 11"
+ * @param text_color A Clutter::Color, the color of the text; default is {0xee, 0xee, 0xee, 0xff}
+ * @param label_color A Clutter::Color, the color of the label; default is {0x33, 0x33, 0x33, 0xff}
+ *
+ * @newin{0,10}
+ */
static Glib::RefPtr<Label> create(const Glib::ustring& text,
const Glib::ustring& font = Glib::ustring("Sans 11"),
const Clutter::Color& text_color = Clutter::Color(0xee, 0xee, 0xee,
0xff),
const Clutter::Color& label_color = Clutter::Color(0x33, 0x33, 0x33,
0xff));
- static Glib::RefPtr<Label> create(const std::string & filename);
+
+ /** Creates a new instance of Label with image.
+ *
+ * @param actor The image as a Clutter::Actor.
+ *
+ * @newin{0,10}
+ */
static Glib::RefPtr<Label> create(const Glib::RefPtr<Clutter::Actor>& actor);
+
+//TODO
+// /** Creates a new instance of Label with image loaded from file.
+// *
+// * @param filename The filename of the image.
+// *
+// * @newin{0,10}
+// */
+// static Glib::RefPtr<Label> create(const std::string & filename);
+
+ /** Creates a new instance of Label consisting of a custom Clutter::Actor.
+ *
+ * @param text The text of the label
+ * @param actor The image as a Clutter::Actor
+ *
+ * @newin{0,10}
+ */
static Glib::RefPtr<Label> create(const Glib::ustring& text,
const Glib::RefPtr<Clutter::Actor>& actor);
- _WRAP_METHOD(Pango::Alignment get_alignment(), champlain_label_get_alignment)
+ _WRAP_METHOD(Pango::Alignment get_alignment() const, champlain_label_get_alignment)
+ _WRAP_METHOD(void set_alignment(Pango::Alignment alignment), champlain_label_set_alignment)
+
_WRAP_METHOD(Pango::EllipsizeMode get_ellipsize() const, champlain_label_get_ellipsize)
+ _WRAP_METHOD(void set_ellipsize(Pango::EllipsizeMode ellipsize_mode = Pango::ELLIPSIZE_NONE),
champlain_label_set_ellipsize)
+
_WRAP_METHOD(Clutter::Color get_color() const, champlain_label_get_color)
+ _WRAP_METHOD(void set_color(const Clutter::Color& color), champlain_label_set_color)
+ /** Resets background to default color.
+ *
+ * @newin{0,10}
+ */
+ void unset_color();
+
_WRAP_METHOD(bool get_draw_background() const, champlain_label_get_draw_background)
- _WRAP_METHOD(std::string get_font_name() const, champlain_label_get_font_name)
+ _WRAP_METHOD(void set_draw_background(bool draw_background = true), champlain_label_set_draw_background)
+
+ _WRAP_METHOD(Glib::ustring get_font_name() const, champlain_label_get_font_name)
+ _WRAP_METHOD(void set_font_name(const Glib::ustring& font_name), champlain_label_set_font_name)
+ /** Resets fonr to default value.
+ *
+ * @newin{0,10}
+ */
+ void unset_font_name();
+
_WRAP_METHOD(Glib::RefPtr<Clutter::Actor> get_image(), champlain_label_get_image)
+ _WRAP_METHOD(Glib::RefPtr<const Clutter::Actor> get_image() const, champlain_label_get_image, constversion)
+ _WRAP_METHOD(void set_image(const Glib::RefPtr<Clutter::Actor>& image), champlain_label_set_image)
+ /** Removes current image.
+ *
+ * @newin{0,10}
+ */
+ void unset_image();
+
_WRAP_METHOD(Glib::ustring get_text() const, champlain_label_get_text)
+ _WRAP_METHOD(void set_text(const Glib::ustring& text), champlain_label_set_text)
+
_WRAP_METHOD(Clutter::Color get_text_color() const, champlain_label_get_text_color)
+ _WRAP_METHOD(void set_text_color(const Clutter::Color& text_color), champlain_label_set_text_color)
+ /** Resets text to default color.
+ *
+ * @newin{0,10}
+ */
+ void unset_text_color();
+
_WRAP_METHOD(bool get_single_line_mode() const, champlain_label_get_single_line_mode)
+ _WRAP_METHOD(void set_single_line_mode(bool single_line_mode = true), champlain_label_set_single_line_mode)
+
_WRAP_METHOD(bool get_use_markup() const, champlain_label_get_use_markup)
- _WRAP_METHOD(bool get_wrap(), champlain_label_get_wrap)
- _WRAP_METHOD(Pango::WrapMode get_wrap_mode(), champlain_label_get_wrap_mode)
+ _WRAP_METHOD(void set_use_markup(bool use_markup = true), champlain_label_set_use_markup)
- _WRAP_METHOD(void set_alignment(Pango::Alignment alignment), champlain_label_set_alignment)
- _WRAP_METHOD(void set_attributes(Pango::AttrList & attributes), champlain_label_set_attributes)
- _WRAP_METHOD(void set_ellipsize(Pango::EllipsizeMode ellipsize_mode), champlain_label_set_ellipsize)
- _WRAP_METHOD(void set_color(const Clutter::Color & color), champlain_label_set_color)
- _WRAP_METHOD(void set_draw_background(bool setting=true), champlain_label_set_draw_background)
- _WRAP_METHOD(void set_font_name(const std::string & font_name), champlain_label_set_font_name)
- _WRAP_METHOD(void set_image(const Glib::RefPtr<Clutter::Actor> & image), champlain_label_set_image)
- _WRAP_METHOD(void set_text(const Glib::ustring & text), champlain_label_set_text)
- _WRAP_METHOD(void set_text_color(const Clutter::Color & text_color), champlain_label_set_text_color)
- _WRAP_METHOD(void set_single_line_mode(bool setting=true), champlain_label_set_single_line_mode)
- _WRAP_METHOD(void set_use_markup(bool setting=true), champlain_label_set_use_markup)
- _WRAP_METHOD(void set_wrap(bool setting=true), champlain_label_set_wrap)
+ _WRAP_METHOD(bool get_wrap() const, champlain_label_get_wrap)
+ _WRAP_METHOD(void set_wrap(bool wrap = true), champlain_label_set_wrap)
+
+ _WRAP_METHOD(Pango::WrapMode get_wrap_mode() const, champlain_label_get_wrap_mode)
_WRAP_METHOD(void set_wrap_mode(Pango::WrapMode wrap_mode), champlain_label_set_wrap_mode)
+ _WRAP_METHOD(Pango::AttrList get_attributes() const, champlain_label_get_attributes)
+ _WRAP_METHOD(void set_attributes(Pango::AttrList& attributes), champlain_label_set_attributes)
+
+ _WRAP_PROPERTY("text", Glib::ustring)
+ _WRAP_PROPERTY("image", Glib::RefPtr<Clutter::Actor>)
+ _WRAP_PROPERTY("use-markup", bool)
_WRAP_PROPERTY("alignment", Pango::Alignment)
_WRAP_PROPERTY("color", Clutter::Color)
- _WRAP_PROPERTY("draw-background", bool)
- _WRAP_PROPERTY("ellipsize", Pango::EllipsizeMode)
- _WRAP_PROPERTY("font-name", std::string)
- _WRAP_PROPERTY("image", Glib::RefPtr<Clutter::Actor>)
- _WRAP_PROPERTY("single-line-mode", bool)
- _WRAP_PROPERTY("text", Glib::ustring)
_WRAP_PROPERTY("text-color", Clutter::Color)
- _WRAP_PROPERTY("use-markup", bool)
+ _WRAP_PROPERTY("font-name", Glib::ustring)
_WRAP_PROPERTY("wrap", bool)
_WRAP_PROPERTY("wrap-mode", Pango::WrapMode)
+ _WRAP_PROPERTY("ellipsize", Pango::EllipsizeMode)
+ _WRAP_PROPERTY("draw-background", bool)
+ _WRAP_PROPERTY("single-line-mode", bool)
};
} // namespace Champlain
diff --git a/tools/m4/convert_libchamplain.m4 b/tools/m4/convert_libchamplain.m4
index 899151d..ce8b6db 100644
--- a/tools/m4/convert_libchamplain.m4
+++ b/tools/m4/convert_libchamplain.m4
@@ -20,9 +20,6 @@ _CONVERSION(`Clutter::Event&',`ClutterEvent*',`&$3')
_CONVERSION(`const GTimeVal*',`Glib::TimeVal',`$2(*$3)')
_CONVERSION(`const Glib::TimeVal&', `const GTimeVal*', static_cast<$2>(&$3))
-# Pango
-#_CONVERSION(`Pango::AttrList&',`PangoAttrList*',__FR2P)
-
# BaseMarker
_CONVERSION(`ChamplainBaseMarker*',`Glib::RefPtr<BaseMarker>',`Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<BaseMarker>&',`ChamplainBaseMarker*',__CONVERT_REFPTR_TO_P)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]