Initial import of ClutterEntry, a text-entry actor
This commit is contained in:
parent
984ce646a5
commit
e725b0c7fa
28
ChangeLog
28
ChangeLog
@ -1,3 +1,31 @@
|
|||||||
|
2007-05-31 Neil J Patel <njp@o-hand.com>
|
||||||
|
|
||||||
|
* clutter/Makefile.am:
|
||||||
|
* clutter/clutter-entry.c: (clutter_entry_set_property),
|
||||||
|
(clutter_entry_get_property), (clutter_entry_ensure_layout),
|
||||||
|
(clutter_entry_clear_layout),
|
||||||
|
(clutter_entry_ensure_cursor_position), (clutter_entry_paint),
|
||||||
|
(clutter_entry_request_coords), (clutter_entry_dispose),
|
||||||
|
(clutter_entry_finalize), (clutter_entry_class_init),
|
||||||
|
(clutter_entry_init), (clutter_entry_new_with_text),
|
||||||
|
(clutter_entry_new_full), (clutter_entry_new),
|
||||||
|
(clutter_entry_get_text), (clutter_entry_set_text),
|
||||||
|
(clutter_entry_get_font_name), (clutter_entry_set_font_name),
|
||||||
|
(clutter_entry_set_color), (clutter_entry_get_color),
|
||||||
|
(clutter_entry_get_layout), (clutter_entry_set_alignment),
|
||||||
|
(clutter_entry_get_alignment), (clutter_entry_set_position),
|
||||||
|
(clutter_entry_get_position), (clutter_entry_add),
|
||||||
|
(clutter_entry_remove), (clutter_entry_insert_text),
|
||||||
|
(clutter_entry_delete_text), (clutter_entry_set_visible_cursor),
|
||||||
|
(clutter_entry_get_visible_cursor):
|
||||||
|
* clutter/clutter-entry.h:
|
||||||
|
* clutter/clutter.h:
|
||||||
|
* examples/Makefile.am:
|
||||||
|
Initial import of ClutterEntry actor.
|
||||||
|
|
||||||
|
* examples/test-entry.c: (on_key_release_cb), (main):
|
||||||
|
A basic test for ClutterEntry
|
||||||
|
|
||||||
2007-05-31 Tomas Frydrych <tf@openedhand.com>
|
2007-05-31 Tomas Frydrych <tf@openedhand.com>
|
||||||
|
|
||||||
* clutter/clutter-actor.c:
|
* clutter/clutter-actor.c:
|
||||||
|
@ -48,6 +48,7 @@ source_h = \
|
|||||||
$(srcdir)/clutter-clone-texture.h \
|
$(srcdir)/clutter-clone-texture.h \
|
||||||
$(srcdir)/clutter-color.h \
|
$(srcdir)/clutter-color.h \
|
||||||
$(srcdir)/clutter-event.h \
|
$(srcdir)/clutter-event.h \
|
||||||
|
$(srcdir)/clutter-entry.h \
|
||||||
$(srcdir)/clutter-feature.h \
|
$(srcdir)/clutter-feature.h \
|
||||||
$(srcdir)/clutter-fixed.h \
|
$(srcdir)/clutter-fixed.h \
|
||||||
$(srcdir)/clutter-group.h \
|
$(srcdir)/clutter-group.h \
|
||||||
@ -137,6 +138,7 @@ source_c = \
|
|||||||
clutter-clone-texture.c \
|
clutter-clone-texture.c \
|
||||||
clutter-enum-types.c \
|
clutter-enum-types.c \
|
||||||
clutter-event.c \
|
clutter-event.c \
|
||||||
|
clutter-entry.c \
|
||||||
clutter-feature.c \
|
clutter-feature.c \
|
||||||
clutter-fixed.c \
|
clutter-fixed.c \
|
||||||
clutter-group.c \
|
clutter-group.c \
|
||||||
|
1015
clutter/clutter-entry.c
Normal file
1015
clutter/clutter-entry.c
Normal file
File diff suppressed because it is too large
Load Diff
124
clutter/clutter-entry.h
Normal file
124
clutter/clutter-entry.h
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
/*
|
||||||
|
* Clutter.
|
||||||
|
*
|
||||||
|
* An OpenGL based 'interactive canvas' library.
|
||||||
|
*
|
||||||
|
* Authored By Matthew Allum <mallum@openedhand.com>
|
||||||
|
* Neil Jagdish Patel <njp@o-hand.com
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006 OpenedHand
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library 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
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _HAVE_CLUTTER_ENTRY_H
|
||||||
|
#define _HAVE_CLUTTER_ENTRY_H
|
||||||
|
|
||||||
|
#include <clutter/clutter-actor.h>
|
||||||
|
#include <clutter/clutter-color.h>
|
||||||
|
#include <pango/pango.h>
|
||||||
|
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define CLUTTER_TYPE_ENTRY (clutter_entry_get_type ())
|
||||||
|
|
||||||
|
#define CLUTTER_ENTRY(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
|
||||||
|
CLUTTER_TYPE_ENTRY, ClutterEntry))
|
||||||
|
|
||||||
|
#define CLUTTER_ENTRY_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_CAST ((klass), \
|
||||||
|
CLUTTER_TYPE_ENTRY, ClutterEntryClass))
|
||||||
|
|
||||||
|
#define CLUTTER_IS_ENTRY(obj) \
|
||||||
|
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
|
||||||
|
CLUTTER_TYPE_ENTRY))
|
||||||
|
|
||||||
|
#define CLUTTER_IS_ENTRY_CLASS(klass) \
|
||||||
|
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
|
||||||
|
CLUTTER_TYPE_ENTRY))
|
||||||
|
|
||||||
|
#define CLUTTER_ENTRY_GET_CLASS(obj) \
|
||||||
|
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
|
||||||
|
CLUTTER_TYPE_ENTRY, ClutterEntryClass))
|
||||||
|
|
||||||
|
typedef struct _ClutterEntry ClutterEntry;
|
||||||
|
typedef struct _ClutterEntryClass ClutterEntryClass;
|
||||||
|
typedef struct _ClutterEntryPrivate ClutterEntryPrivate;
|
||||||
|
|
||||||
|
struct _ClutterEntry
|
||||||
|
{
|
||||||
|
ClutterActor parent;
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
ClutterEntryPrivate *priv;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _ClutterEntryClass
|
||||||
|
{
|
||||||
|
/*< private >*/
|
||||||
|
ClutterActorClass parent_class;
|
||||||
|
|
||||||
|
void (*_clutter_entry_1) (void);
|
||||||
|
void (*_clutter_entry_2) (void);
|
||||||
|
void (*_clutter_entry_3) (void);
|
||||||
|
void (*_clutter_entry_4) (void);
|
||||||
|
};
|
||||||
|
|
||||||
|
GType clutter_entry_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
ClutterActor * clutter_entry_new (void);
|
||||||
|
|
||||||
|
ClutterActor* clutter_entry_new_full (const gchar *font_name,
|
||||||
|
const gchar *text,
|
||||||
|
ClutterColor *color);
|
||||||
|
|
||||||
|
ClutterActor * clutter_entry_new_with_text (const gchar *font_name,
|
||||||
|
const gchar *text);
|
||||||
|
void clutter_entry_set_text (ClutterEntry *entry,
|
||||||
|
const gchar *text);
|
||||||
|
G_CONST_RETURN gchar *clutter_entry_get_text (ClutterEntry *entry);
|
||||||
|
void clutter_entry_set_font_name (ClutterEntry *entry,
|
||||||
|
const gchar *font_name);
|
||||||
|
G_CONST_RETURN gchar *clutter_entry_get_font_name (ClutterEntry *entry);
|
||||||
|
void clutter_entry_set_color (ClutterEntry *entry,
|
||||||
|
const ClutterColor *color);
|
||||||
|
void clutter_entry_get_color (ClutterEntry *entry,
|
||||||
|
ClutterColor *color);
|
||||||
|
PangoLayout * clutter_entry_get_layout (ClutterEntry *entry);
|
||||||
|
void clutter_entry_set_alignment (ClutterEntry *entry,
|
||||||
|
PangoAlignment alignment);
|
||||||
|
PangoAlignment clutter_entry_get_alignment (ClutterEntry *entry);
|
||||||
|
void clutter_entry_set_position (ClutterEntry *entry,
|
||||||
|
gint position);
|
||||||
|
gint clutter_entry_get_position (ClutterEntry *entry);
|
||||||
|
void clutter_entry_add (ClutterEntry *entry,
|
||||||
|
gunichar wc);
|
||||||
|
void clutter_entry_remove (ClutterEntry *entry,
|
||||||
|
guint len);
|
||||||
|
void clutter_entry_insert_text (ClutterEntry *entry,
|
||||||
|
const gchar *text,
|
||||||
|
gssize position);
|
||||||
|
void clutter_entry_delete_text (ClutterEntry *entry,
|
||||||
|
gssize start_pos,
|
||||||
|
gssize end_pos);
|
||||||
|
void clutter_entry_set_visible_cursor (ClutterEntry *entry,
|
||||||
|
gboolean visible);
|
||||||
|
gboolean clutter_entry_get_visible_cursor (ClutterEntry *entry);
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* _HAVE_CLUTTER_ENTRY_H */
|
@ -31,6 +31,7 @@
|
|||||||
#include "clutter-color.h"
|
#include "clutter-color.h"
|
||||||
#include "clutter-util.h"
|
#include "clutter-util.h"
|
||||||
#include "clutter-event.h"
|
#include "clutter-event.h"
|
||||||
|
#include "clutter-entry.h"
|
||||||
#include "clutter-timeline.h"
|
#include "clutter-timeline.h"
|
||||||
#include "clutter-behaviour.h"
|
#include "clutter-behaviour.h"
|
||||||
#include "clutter-behaviour-bspline.h"
|
#include "clutter-behaviour-bspline.h"
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
2007-05-31 Neil J Patel <njp@o-hand.com>
|
||||||
|
|
||||||
|
* clutter-docs.sgml:
|
||||||
|
* clutter-sections.txt:
|
||||||
|
* tmpl/clutter-entry.sgml:
|
||||||
|
Added ClutterEntry
|
||||||
|
|
||||||
2007-05-31 Tomas Frydrych <tf@openedhand.com>
|
2007-05-31 Tomas Frydrych <tf@openedhand.com>
|
||||||
|
|
||||||
* tmpl/clutter-behaviour-ellipse.sgml:
|
* tmpl/clutter-behaviour-ellipse.sgml:
|
||||||
|
@ -74,6 +74,7 @@
|
|||||||
<xi:include href="xml/clutter-label.xml"/>
|
<xi:include href="xml/clutter-label.xml"/>
|
||||||
<xi:include href="xml/clutter-timeline.xml"/>
|
<xi:include href="xml/clutter-timeline.xml"/>
|
||||||
<xi:include href="xml/clutter-media.xml"/>
|
<xi:include href="xml/clutter-media.xml"/>
|
||||||
|
<xi:include href="xml/clutter-entry.xml"/>
|
||||||
</chapter>
|
</chapter>
|
||||||
<chapter>
|
<chapter>
|
||||||
<title>Clutter Behaviours</title>
|
<title>Clutter Behaviours</title>
|
||||||
|
@ -756,3 +756,40 @@ CLUTTER_VERSION_HEX
|
|||||||
CLUTTER_CHECK_VERSION
|
CLUTTER_CHECK_VERSION
|
||||||
CLUTTER_FLAVOUR
|
CLUTTER_FLAVOUR
|
||||||
</SECTION>
|
</SECTION>
|
||||||
|
|
||||||
|
<SECTION>
|
||||||
|
<FILE>clutter-entry</FILE>
|
||||||
|
<TITLE>ClutterEntry</TITLE>
|
||||||
|
ClutterEntry
|
||||||
|
ClutterEntryClass
|
||||||
|
clutter_entry_new
|
||||||
|
clutter_entry_new_with_text
|
||||||
|
clutter_entry_new_full
|
||||||
|
clutter_entry_set_text
|
||||||
|
clutter_entry_get_text
|
||||||
|
clutter_entry_set_font_name
|
||||||
|
clutter_entry_get_font_name
|
||||||
|
clutter_entry_set_color
|
||||||
|
clutter_entry_get_color
|
||||||
|
clutter_entry_get_layout
|
||||||
|
clutter_entry_set_alignment
|
||||||
|
clutter_entry_get_alignment
|
||||||
|
clutter_entry_set_position
|
||||||
|
clutter_entry_get_position
|
||||||
|
clutter_entry_add
|
||||||
|
clutter_entry_remove
|
||||||
|
clutter_entry_insert_text
|
||||||
|
clutter_entry_delete_text
|
||||||
|
clutter_entry_set_visible_cursor
|
||||||
|
clutter_entry_get_visible_cursor
|
||||||
|
<SUBSECTION Standard>
|
||||||
|
CLUTTER_ENTRY
|
||||||
|
CLUTTER_IS_ENTRY
|
||||||
|
CLUTTER_TYPE_ENTRY
|
||||||
|
CLUTTER_ENTRY_CLASS
|
||||||
|
CLUTTER_IS_ENTRY_CLASS
|
||||||
|
CLUTTER_ENTRY_GET_CLASS
|
||||||
|
<SUBSECTION Private>
|
||||||
|
ClutterEntryPrivate
|
||||||
|
clutter_entry_get_type
|
||||||
|
</SECTION>
|
||||||
|
216
doc/reference/tmpl/clutter-entry.sgml
Normal file
216
doc/reference/tmpl/clutter-entry.sgml
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
<!-- ##### SECTION Title ##### -->
|
||||||
|
ClutterEntry
|
||||||
|
|
||||||
|
<!-- ##### SECTION Short_Description ##### -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### SECTION Long_Description ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION See_Also ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<!-- ##### SECTION Stability_Level ##### -->
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### STRUCT ClutterEntry ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@parent:
|
||||||
|
|
||||||
|
<!-- ##### STRUCT ClutterEntryClass ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_new ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_new_with_text ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@font_name:
|
||||||
|
@text:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_new_full ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@font_name:
|
||||||
|
@text:
|
||||||
|
@color:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_set_text ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@text:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_get_text ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_set_font_name ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@font_name:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_get_font_name ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_set_color ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@color:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_get_color ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@color:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_get_layout ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_set_alignment ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@alignment:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_get_alignment ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_set_position ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@position:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_get_position ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_add ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@wc:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_remove ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@len:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_insert_text ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@text:
|
||||||
|
@position:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_delete_text ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@start_pos:
|
||||||
|
@end_pos:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_set_visible_cursor ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@visible:
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### FUNCTION clutter_entry_get_visible_cursor ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
@entry:
|
||||||
|
@Returns:
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
noinst_PROGRAMS = test super-oh behave test-text slider
|
noinst_PROGRAMS = test super-oh behave test-text slider test-entry
|
||||||
|
|
||||||
INCLUDES = -I$(top_srcdir)/
|
INCLUDES = -I$(top_srcdir)/
|
||||||
LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la
|
LDADD = $(top_builddir)/clutter/libclutter-@CLUTTER_FLAVOUR@-@CLUTTER_MAJORMINOR@.la
|
||||||
@ -29,6 +29,12 @@ behave_LDFLAGS = \
|
|||||||
test_text_SOURCES = test-text.c
|
test_text_SOURCES = test-text.c
|
||||||
test_text_CFLAGS = $(CLUTTER_CFLAGS) $(GCONF_CFLAGS)
|
test_text_CFLAGS = $(CLUTTER_CFLAGS) $(GCONF_CFLAGS)
|
||||||
test_text_LDFLAGS = \
|
test_text_LDFLAGS = \
|
||||||
|
$(CLUTTER_LIBS) \
|
||||||
|
$(GCONF_LIBS)
|
||||||
|
|
||||||
|
test_entry_SOURCES = test-entry.c
|
||||||
|
test_entry_CFLAGS = $(CLUTTER_CFLAGS) $(GCONF_CFLAGS)
|
||||||
|
test_entry_LDFLAGS = \
|
||||||
$(CLUTTER_LIBS) \
|
$(CLUTTER_LIBS) \
|
||||||
$(GCONF_LIBS)
|
$(GCONF_LIBS)
|
||||||
|
|
||||||
|
90
examples/test-entry.c
Normal file
90
examples/test-entry.c
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#include <clutter/clutter.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
on_key_release_cb (ClutterStage *stage, ClutterEvent *event, ClutterEntry *entry)
|
||||||
|
{
|
||||||
|
if (event->type == CLUTTER_KEY_RELEASE) {
|
||||||
|
ClutterKeyEvent* kev = (ClutterKeyEvent *) event;
|
||||||
|
guint key = clutter_key_event_symbol (kev);
|
||||||
|
|
||||||
|
gint pos = clutter_entry_get_position (entry);
|
||||||
|
gint len = g_utf8_strlen (clutter_entry_get_text (entry), -1);
|
||||||
|
|
||||||
|
switch (key)
|
||||||
|
{
|
||||||
|
case CLUTTER_Return:
|
||||||
|
case CLUTTER_KP_Enter:
|
||||||
|
case CLUTTER_ISO_Enter:
|
||||||
|
break;
|
||||||
|
case CLUTTER_Escape:
|
||||||
|
clutter_main_quit ();
|
||||||
|
break;
|
||||||
|
case CLUTTER_BackSpace:
|
||||||
|
clutter_entry_remove (entry, 1);
|
||||||
|
break;
|
||||||
|
case CLUTTER_Left:
|
||||||
|
if (pos != 0)
|
||||||
|
{
|
||||||
|
if (pos == -1)
|
||||||
|
{
|
||||||
|
clutter_entry_set_position (entry, len-1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
clutter_entry_set_position (entry, pos - 1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CLUTTER_Right:
|
||||||
|
if (pos != -1)
|
||||||
|
{
|
||||||
|
if (pos != len)
|
||||||
|
clutter_entry_set_position (entry, pos +1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CLUTTER_Up:
|
||||||
|
clutter_entry_insert_text (entry, "insert", 5);
|
||||||
|
break;
|
||||||
|
case CLUTTER_Down:
|
||||||
|
clutter_entry_delete_text (entry, 5, 11);
|
||||||
|
default:
|
||||||
|
clutter_entry_add (entry, clutter_key_event_unicode (kev));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
ClutterTimeline *timeline;
|
||||||
|
ClutterActor *entry;
|
||||||
|
ClutterActor *stage;
|
||||||
|
gchar *text;
|
||||||
|
gsize size;
|
||||||
|
ClutterColor stage_color = { 0x00, 0x00, 0x00, 0xff };
|
||||||
|
ClutterColor entry_color = { 0x33, 0xdd, 0xff, 0xff };
|
||||||
|
|
||||||
|
clutter_init (&argc, &argv);
|
||||||
|
|
||||||
|
stage = clutter_stage_get_default ();
|
||||||
|
|
||||||
|
clutter_actor_set_size (stage, 800, 600);
|
||||||
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
||||||
|
|
||||||
|
entry = clutter_entry_new_with_text ("Sans 14",
|
||||||
|
"Type something, be sure to use the "
|
||||||
|
"left/right arrow keys to move the "
|
||||||
|
"cursor position.");
|
||||||
|
clutter_entry_set_color (CLUTTER_ENTRY (entry), &entry_color);
|
||||||
|
clutter_actor_set_size (entry, 600, 50);
|
||||||
|
clutter_actor_set_position (entry, 100, 100);
|
||||||
|
|
||||||
|
clutter_group_add (CLUTTER_GROUP (stage), entry);
|
||||||
|
clutter_group_show_all (CLUTTER_GROUP (stage));
|
||||||
|
|
||||||
|
g_signal_connect (stage, "key-release-event",
|
||||||
|
G_CALLBACK (on_key_release_cb), (gpointer)entry);
|
||||||
|
|
||||||
|
clutter_main();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user