[clutter-tutorial] Added section for ClutterText
- From: Johannes Schmid <jhs src gnome org>
- To: svn-commits-list gnome org
- Subject: [clutter-tutorial] Added section for ClutterText
- Date: Wed, 29 Apr 2009 06:44:56 -0400 (EDT)
commit b374a5f6febb300328bd504fbd8c14e8ab7202c3
Author: Johannes Schmid <jhs gnome org>
Date: Wed Apr 29 12:44:20 2009 +0200
Added section for ClutterText
Added a section and an example for ClutterText. Moved scrolling section
to normal section from appendix.
---
ChangeLog | 11 +++
docs/tutorial/clutter-tut.xml | 152 ++++++++++++++++++++++++++++------------
docs/tutorial/figures/text.png | Bin 0 -> 9177 bytes
examples/Makefile.am | 2 +-
examples/text/main.c | 61 ++++++++++++++++
5 files changed, 180 insertions(+), 46 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f1b3aed..fbf52ab 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2009-04-29 Johannes Schmid <jschmid openismus com>
+ * examples/text/main.c:
+ * examples/Makefile.am:
+ * docs/tutorial/clutter-tut.xml:
+ * docs/tutorial/figures/text.png:
+ Added section for ClutterText
+
+ Added a section and an example for ClutterText. Moved scrolling section
+ to normal section from appendix.
+
+2009-04-29 Johannes Schmid <jschmid openismus com>
+
* examples/scrolling/main.c:
* examples/scrolling/Makefile.am:
* docs/tutorial/clutter-tut.xml:
diff --git a/docs/tutorial/clutter-tut.xml b/docs/tutorial/clutter-tut.xml
index e7f2138..fddcfa8 100644
--- a/docs/tutorial/clutter-tut.xml
+++ b/docs/tutorial/clutter-tut.xml
@@ -774,6 +774,113 @@ This simply moves the rectangle from the top-left to the bottom-right of the can
</chapter>
+<chapter id="text editing">
+<title>Text editing</title>
+<sect1 id="clutter-text"><title>ClutterText</title>
+<para>
+Clutter contains a powerful widget to display and edit text. It doesn't support
+all the fancy things that <classname>GtkTextView</classname> supports but it is
+enough for displaying all kind of information and for simple text inserting operations.
+The use-case of this widget is to act like a <classname>GtkLabel</classname> or an
+extended <classname>GtkEntry</classname> that support multi line editing
+</para>
+<para>
+There are three things you can use a <classname>ClutterText</classname> actor for:
+<itemizedlist>
+ <listitem>
+ <para>
+ As a simple label use <function>clutter_text_new_with_text()</function> or
+ <function>clutter_text_set_markup()</function> to display text. To make it non-editable
+ use <function>clutter_text_set_editable()</function>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ For use-cases where you would use a <classname>GtkEntry</classname> in a normal
+ >k; application, create a <classname>ClutterText</classname> using
+ <function>clutter_text_new()</function> and <function>clutter_text_set_single_line_mode()
+ </function>. In this case it could be interesting to use <function>clutter_text_set_activatable()</function>
+ and connect to the <literal>activate</literal> signal which will be emitted when
+ the user presses <literal>Enter</literal>.
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ The third use case is a full-features multi-line text editing widget. <classname>ClutterText</classname>
+ gives you access to the cursor position using <function>clutter_text_get/set_cursor_*()</function> and to
+ the selection using <function>clutter_text_get/set_selection*()</function>. You can also add and
+ remove text at any position.
+ </para>
+ </listitem>
+</itemizedlist>
+When you want to have an editable <classname>ClutterText</classname> it is important
+to give it key focus using <function>clutter_stage_set_key_focus()</function>.
+</para>
+
+<para><ulink url="&url_refdocs_base_clutter;Text.html">ClutterText Reference</ulink></para>
+</sect1>
+
+<sect1 id="text-example"><title>Example</title>
+<para>
+This is a very basic example showing how to implement a multi-line text
+editing widget.
+</para>
+
+<figure id="figure-text-example">
+ <title>ClutterText</title>
+ <screenshot>
+ <graphic format="PNG" fileref="&url_figures_base;text.png"/>
+ </screenshot>
+</figure>
+
+<para><ulink url="&url_examples_base;text">Source Code</ulink></para>
+</sect1>
+
+</chapter>
+
+<chapter id="implementing-scrolling">
+<title>Scrolling</title>
+
+<sect1 id="actor-scrolling">
+<title>GtkClutterViewport</title>
+<para>
+When integrating <classname>ClutterActor</classname>s into >k; it can become
+necessary to implement scrolling due to limited screen space. Normally you would
+add a widget inside a <classname>GtkScrolledWindow</classname> to add scrolling
+capabilities. As clutter is accessing the graphic hardware directly bypassing the
+normal >k; drawing this is not possible with <classname>GtkClutterEmbed</classname>.
+</para>
+<para>
+Instead you have to use a <classname>GtkClutterViewport</classname> which will
+take care of the scrolling. The <classname>GtkClutterViewport</classname> does
+not draw any scrollbars itself instead it uses a <classname>GtkAdjustment</classname> to
+determine the current scrolling position. Usually you will connect the
+<classname>GtkAdjustment</classname> to a <classname>GtkScrollbar</classname> but
+it is also possible to change it directly or to connect it to some other widget
+derived from <classname>GtkRuler</classname>.
+</para>
+<para><ulink url="&url_refdocs_base_clutter_gtk;GtkClutterViewport.html">Reference</ulink></para>
+</sect1>
+
+<sect1 id="scrolling-actor-example"><title>Example</title>
+<para>
+This example is simple image viewer that allows scrolling the image.
+Esspecially interesting is the layout of the <classname>GtkTable</classname> with the two scrollbars as it
+is a quite common case and probably a good starting point for implementing basic
+scrolling in an application.
+</para>
+
+<figure id="figure-scrolling-container">
+ <title>Scrolling Actor</title>
+ <screenshot>
+ <graphic format="PNG" fileref="&url_figures_base;scrolling.png"/>
+ </screenshot>
+</figure>
+
+<para><ulink url="&url_examples_base;scrolling">Source Code</ulink></para>
+</sect1>
+
+</chapter>
<chapter id="sec-full-example">
<title>Full Example</title>
@@ -969,51 +1076,6 @@ space, or align differently inside the container.
</appendix>
-<appendix id="appendix-implementing-scrolling">
-<title>Implementing Scrolling</title>
-
-<sect1 id="actor-scrolling">
-<title>GtkClutterViewport</title>
-<para>
-When integrating <classname>ClutterActor</classname>s into >k; it can become
-necessary to implement scrolling due to limited screen space. Normally you would
-add a widget inside a <classname>GtkScrolledWindow</classname> to add scrolling
-capabilities. As clutter is accessing the graphic hardware directly bypassing the
-normal >k; drawing this is not possible with <classname>GtkClutterEmbed</classname>.
-</para>
-<para>
-Instead you have to use a <classname>GtkClutterViewport</classname> which will
-take care of the scrolling. The <classname>GtkClutterViewport</classname> does
-not draw any scrollbars itself instead it uses a <classname>GtkAdjustment</classname> to
-determine the current scrolling position. Usually you will connect the
-<classname>GtkAdjustment</classname> to a <classname>GtkScrollbar</classname> but
-it is also possible to change it directly or to connect it to some other widget
-derived from <classname>GtkRuler</classname>.
-</para>
-<para><ulink url="&url_refdocs_base_clutter_gtk;GtkClutterViewport.html">Reference</ulink></para>
-</sect1>
-
-<sect1 id="scrolling-actor-example"><title>Example</title>
-<para>
-This example is simple image viewer that allows scrolling the image.
-Esspecially interesting is the layout of the <classname>GtkTable</classname> with the two scrollbars as it
-is a quite common case and probably a good starting point for implementing basic
-scrolling in an application.
-</para>
-
-<figure id="figure-scrolling-container">
- <title>Scrolling Actor</title>
- <screenshot>
- <graphic format="PNG" fileref="&url_figures_base;scrolling.png"/>
- </screenshot>
-</figure>
-
-<para><ulink url="&url_examples_base;scrolling">Source Code</ulink></para>
-</sect1>
-
-</appendix>
-
-
<chapter id="sec-Contributing">
<title>Contributing</title>
<para>
diff --git a/docs/tutorial/figures/text.png b/docs/tutorial/figures/text.png
new file mode 100644
index 0000000..69394bb
Binary files /dev/null and b/docs/tutorial/figures/text.png differ
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 92dbff4..bafdd8a 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -1,7 +1,7 @@
include $(top_srcdir)/Makefile_web.am_fragment
example_dirs = actor actor_events actor_group actor_transformations behaviour \
- custom_actor custom_container animation entry stage stage_widget \
+ custom_actor custom_container animation text stage stage_widget \
timeline score full_example \
scrolling
diff --git a/examples/text/main.c b/examples/text/main.c
new file mode 100644
index 0000000..8972cac
--- /dev/null
+++ b/examples/text/main.c
@@ -0,0 +1,61 @@
+/* Copyright 2007 Openismus GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <clutter/clutter.h>
+#include <stdlib.h>
+
+ClutterActor *text = NULL;
+
+int main(int argc, char *argv[])
+{
+ ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
+ ClutterColor actor_color = { 0xff, 0xff, 0xcc, 0xff };
+
+ clutter_init (&argc, &argv);
+
+ /* Get the stage and set its size and color: */
+ ClutterActor *stage = clutter_stage_get_default ();
+ clutter_actor_set_size (stage, 600, 200);
+ clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
+
+ /* Add a text actor to the stage: */
+ text = clutter_text_new ();
+
+ /* Setup text properties */
+ clutter_text_set_color (CLUTTER_TEXT (text), &actor_color);
+ clutter_text_set_text (CLUTTER_TEXT (text),
+ "Wizard imps and sweat sock pimps, interstellar mongrel nymphs.");
+ clutter_text_set_font_name (CLUTTER_TEXT (text), "Sans 12");
+ clutter_text_set_editable (CLUTTER_TEXT (text), TRUE);
+ clutter_text_set_line_wrap (CLUTTER_TEXT (text), TRUE);
+
+ clutter_actor_set_size (text, 590, 100);
+ clutter_actor_set_position (text, 5, 5);
+ clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
+ clutter_actor_show (text);
+
+ /* Set focus to handle key presses on the stage: */
+ clutter_stage_set_key_focus (CLUTTER_STAGE (stage), text);
+
+ /* Show the stage: */
+ clutter_actor_show (stage);
+
+ /* Start the main loop, so we can respond to events: */
+ clutter_main ();
+
+ return EXIT_SUCCESS;
+
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]