Exactness: initial commit.

(Commit message by TAsn):
Exactness is a pixel perfect test suite for elm/evas/edje.
Exactness lets you write tests, and then record a specific interaction
with them, while taking windowshots in the process. The tests can later
be played back (windowshots will be automatically taken) and the
pictures will be compared for differences (usage of fail_if is also
      supported).
There is a premade set of tests and recordings for all (most?) of the
elementary widgets in various scenarios.
Because of the nature of this test suite, it doesn't handle well any
tests with continued running animations/viedos (timing can never be 100%
      right). But you can use it to test widgets with transition
animations. Bottom line: just give it a go.

Read the README for more inforamtion.

I hope it'll be deployed on our servers soon, as we really need
automatic testing.

Signed-off-by: Aharon Hillel <a.hillel@partner.samsung.com>

SVN revision: 65961
This commit is contained in:
Aharon Hillel 2011-12-06 16:05:14 +00:00 committed by Tom Hacohen
parent a197970fb9
commit e820a4033d
158 changed files with 25246 additions and 1 deletions

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
Aharon Hillel <a.hillel@partner.samsung.com>

25
COPYING Normal file
View File

@ -0,0 +1,25 @@
Copyright notice for exactness:
Copyright (C) 2011 by various contributors (see AUTHORS)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0
ChangeLog Normal file
View File

365
INSTALL Normal file
View File

@ -0,0 +1,365 @@
Installation Instructions
*************************
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Copying and distribution of this file, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. This file is offered as-is,
without warranty of any kind.
Basic Installation
==================
Briefly, the shell commands `./configure; make; make install' should
configure, build, and install this package. The following
more-detailed instructions are generic; see the `README' file for
instructions specific to this package. Some packages provide this
`INSTALL' file but do not implement all of the features documented
below. The lack of an optional feature in a given package is not
necessarily a bug. More recommendations for GNU packages can be found
in *note Makefile Conventions: (standards)Makefile Conventions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, and a
file `config.log' containing compiler output (useful mainly for
debugging `configure').
It can also use an optional file (typically called `config.cache'
and enabled with `--cache-file=config.cache' or simply `-C') that saves
the results of its tests to speed up reconfiguring. Caching is
disabled by default to prevent problems with accidental use of stale
cache files.
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If you are using the cache, and at
some point `config.cache' contains results you don't want to keep, you
may remove or edit it.
The file `configure.ac' (or `configure.in') is used to create
`configure' by a program called `autoconf'. You need `configure.ac' if
you want to change it or regenerate `configure' using a newer version
of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system.
Running `configure' might take a while. While running, it prints
some messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.
4. Type `make install' to install the programs and any data files and
documentation. When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular
user, and only the `make install' phase executed with root
privileges.
5. Optionally, type `make installcheck' to repeat any self-tests, but
this time using the binaries in their final installed location.
This target does not install anything. Running this target as a
regular user, particularly if the prior `make install' required
root privileges, verifies that the installation completed
correctly.
6. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
7. Often, you can also type `make uninstall' to remove the installed
files again. In practice, not all packages have tested that
uninstallation works correctly, even though it is required by the
GNU Coding Standards.
8. Some packages, particularly those that use Automake, provide `make
distcheck', which can by used by developers to test that all other
targets like `make install' and `make uninstall' work correctly.
This target is generally not run by end users.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. Run `./configure --help'
for details on some of the pertinent environment variables.
You can give `configure' initial values for configuration parameters
by setting variables in the command line or in the environment. Here
is an example:
./configure CC=c99 CFLAGS=-g LIBS=-lposix
*Note Defining Variables::, for more details.
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you can use GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'. This
is known as a "VPATH" build.
With a non-GNU `make', it is safer to compile the package for one
architecture at a time in the source code directory. After you have
installed the package for one architecture, use `make distclean' before
reconfiguring for another architecture.
On MacOS X 10.5 and later systems, you can create libraries and
executables that work on multiple system types--known as "fat" or
"universal" binaries--by specifying multiple `-arch' options to the
compiler but only a single `-arch' option to the preprocessor. Like
this:
./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
CPP="gcc -E" CXXCPP="g++ -E"
This is not guaranteed to produce working output in all cases, you
may have to build one architecture at a time and combine the results
using the `lipo' tool if you have problems.
Installation Names
==================
By default, `make install' installs the package's commands under
`/usr/local/bin', include files under `/usr/local/include', etc. You
can specify an installation prefix other than `/usr/local' by giving
`configure' the option `--prefix=PREFIX', where PREFIX must be an
absolute file name.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
pass the option `--exec-prefix=PREFIX' to `configure', the package uses
PREFIX as the prefix for installing programs and libraries.
Documentation and other data files still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=DIR' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them. In general, the
default for these options is expressed in terms of `${prefix}', so that
specifying just `--prefix' will affect all of the other directory
specifications that were not explicitly provided.
The most portable way to affect installation locations is to pass the
correct locations to `configure'; however, many packages provide one or
both of the following shortcuts of passing variable assignments to the
`make install' command line to change installation locations without
having to reconfigure or recompile.
The first method involves providing an override variable for each
affected directory. For example, `make install
prefix=/alternate/directory' will choose an alternate location for all
directory configuration variables that were expressed in terms of
`${prefix}'. Any directories that were specified during `configure',
but not in terms of `${prefix}', must each be overridden at install
time for the entire installation to be relocated. The approach of
makefile variable overrides for each directory variable is required by
the GNU Coding Standards, and ideally causes no recompilation.
However, some platforms have known limitations with the semantics of
shared libraries that end up requiring recompilation when using this
method, particularly noticeable in packages that use GNU Libtool.
The second method involves providing the `DESTDIR' variable. For
example, `make install DESTDIR=/alternate/directory' will prepend
`/alternate/directory' before all installation names. The approach of
`DESTDIR' overrides is not required by the GNU Coding Standards, and
does not work on platforms that have drive letters. On the other hand,
it does better at avoiding recompilation issues, and works well even
when some directory options were not specified in terms of `${prefix}'
at `configure' time.
Optional Features
=================
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Some packages offer the ability to configure how verbose the
execution of `make' will be. For these packages, running `./configure
--enable-silent-rules' sets the default to minimal output, which can be
overridden with `make V=1'; while running `./configure
--disable-silent-rules' sets the default to verbose, which can be
overridden with `make V=0'.
Particular systems
==================
On HP-UX, the default C compiler is not ANSI C compatible. If GNU
CC is not installed, it is recommended to use the following options in
order to use an ANSI C compiler:
./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
and if that doesn't work, install pre-built binaries of GCC for HP-UX.
On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
parse its `<wchar.h>' header file. The option `-nodtk' can be used as
a workaround. If GNU CC is not installed, it is therefore recommended
to try
./configure CC="cc"
and if that doesn't work, try
./configure CC="cc -nodtk"
On Solaris, don't put `/usr/ucb' early in your `PATH'. This
directory contains several dysfunctional programs; working variants of
these programs are available in `/usr/bin'. So, if you need `/usr/ucb'
in your `PATH', put it _after_ `/usr/bin'.
On Haiku, software installed for all users goes in `/boot/common',
not `/usr/local'. It is recommended to use the following options:
./configure --prefix=/boot/common
Specifying the System Type
==========================
There may be some features `configure' cannot figure out
automatically, but needs to determine by the type of machine the package
will run on. Usually, assuming the package is built to be run on the
_same_ architectures, `configure' can figure that out, but if it prints
a message saying it cannot guess the machine type, give it the
`--build=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name which has the form:
CPU-COMPANY-SYSTEM
where SYSTEM can have one of these forms:
OS
KERNEL-OS
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the machine type.
If you are _building_ compiler tools for cross-compiling, you should
use the option `--target=TYPE' to select the type of system they will
produce code for.
If you want to _use_ a cross compiler, that generates code for a
platform different from the build platform, you should specify the
"host" platform (i.e., that on which the generated programs will
eventually be run) with `--host=TYPE'.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Defining Variables
==================
Variables not defined in a site shell script can be set in the
environment passed to `configure'. However, some packages may run
configure again during the build, and the customized values of these
variables may be lost. In order to avoid this problem, you should set
them in the `configure' command line, using `VAR=value'. For example:
./configure CC=/usr/local2/bin/gcc
causes the specified `gcc' to be used as the C compiler (unless it is
overridden in the site shell script).
Unfortunately, this technique does not work for `CONFIG_SHELL' due to
an Autoconf bug. Until the bug is fixed you can use this workaround:
CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
`configure' Invocation
======================
`configure' recognizes the following options to control how it
operates.
`--help'
`-h'
Print a summary of all of the options to `configure', and exit.
`--help=short'
`--help=recursive'
Print a summary of the options unique to this package's
`configure', and exit. The `short' variant lists options used
only in the top level, while the `recursive' variant lists options
also present in any nested packages.
`--version'
`-V'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`--cache-file=FILE'
Enable the cache: use and save the results of the tests in FILE,
traditionally `config.cache'. FILE defaults to `/dev/null' to
disable caching.
`--config-cache'
`-C'
Alias for `--cache-file=config.cache'.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--prefix=DIR'
Use DIR as the installation prefix. *note Installation Names::
for more details, including other options available for fine-tuning
the installation locations.
`--no-create'
`-n'
Run the configure checks, but stop before creating any output
files.
`configure' also accepts some other, not widely useful, options. Run
`configure --help' for more details.

18
Makefile.am Normal file
View File

@ -0,0 +1,18 @@
MAINTAINERCLEANFILES = \
Makefile.in \
aclocal.m4 \
config.guess \
config.h.in \
config.sub \
configure \
install-sh \
depcomp \
libtool \
missing
EXTRA_DIST = README AUTHORS COPYING
SUBDIRS = src
ACLOCAL_AMFLAGS = -I m4

0
NEWS Normal file
View File

103
README Normal file
View File

@ -0,0 +1,103 @@
exactness is a software package aimed to automate Elementary testing
after updating elm code.
The testing process is composed of running widget test,
cycling through API functions, and screenshot are taken on each stage of test.
(on user request with F2 key).
Next, these screenshots are compared with screenshots of widget test
done before the code update.
When exactness detects difference in screenshot comparison,
it means widget layout was changed.
Unexpected layout changes may reveal that something is broken
in the new implementation.
Testing with exactness composed of the following stages:
1. Test Recording.
Done once and exactness user most likely does not need to do this.
A set of pre-recorded tests already resides under 'data/recording' folder.
To record a test just issue the command:
exactness -r
Example:
exactness -r test_hover
The record file will be produced in the current-working-directory as:
test_hover.rec
In case you tried to run exactness with specific TestName
and nothing happens, this means you misspelled the test name.
You may review test names as it appears in tsuite.c source file.
NOTE: omitting the test name causes recording all tests one after another.
Do this if you only mean it.
This rule applies to ALL proceeding stages as well.
As widget test run you may press F2 at any point to set a screenshot.
(screenshot procduced in 'play' stage, set timing of screenshot here)
However, don't do this while animation is ongoing
or you get inconsistent PNG output each time test played.
NOTE: You may change screenshot key from F2 to any other key
with TSUITE_SHOT_KEY env var.
2. Test Initiation.
The final stage of testing process is based on PNG image comparison
of original screenshots with current screenshots produced after code change.
To start you need to produce original screenshot set before code change.
To do that just issue the command:
exactness -i TestName1 [TestName2 ...]
This command will play the test (TestName.rec file) and place PNG files
under 'orig' folders created in current-working-directory.
You need to do this just once.
Again, omitting the TestName will play and produce PNG files for all tests.
Example:
exactness -i test_hover
This will produce PNG files such orig/test_hover_1.png
3. Test playing, producing current state PNG files.
After doing Test Initiation (2) and updating elementary code,
you may run tests for current state of elm:
exactness -p [-d DestDir] TestName1 [TestName2 ...]
Omitting DestDir param will cause exactness place all PNG files
under (default) folder named 'current'.
4. Comparing PNG files.
This is the final stage of testing in which we compare output
before code update and after the update.
Matching PNG files from 'orig' and 'current' folder are compared.
When all comparisons done you get final report of (N) files did not match.
In case difference was found, you may look at comp_*.png files in DestDir.
To run a comparison:
exactness -c [-d DestDir] TestName1 [TestName2 ...]
All comp_*.png files will reside in DestDir.
Omitting DestDir cause exactness to use default of 'current' folder name.
Optional:
You may also do play and compare in a single command:
exactness -p -c [-d DestDir] TestName1 [TestName2 ...]
5. fail_if(expr) macro:
You may use fail_if(expr); macro to verify variable value on-the-fly.
For example, if your code contains:
char *p;
...
fail_if(p == NULL);
In case (p == NULL), a "fail_TestName.txt" file is crated
current working directory with a comment specifying the expr/line failed.
fail_*.txt files are produced only for when expr fails when running.
When tests completed, the user gets notification message if any tests failed.
In such case, please review the fail_*.txt files.
6. To view exactness help issue the command:
exactness --help
or
exactness -h

18
autogen.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
rm -rf autom4te.cache
rm -f aclocal.m4 ltmain.sh
rm -f config.cache
touch README
touch ABOUT-NLS
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"
fi

48
configure.ac Normal file
View File

@ -0,0 +1,48 @@
dnl Process this file with autoconf to produce a configure script.
AC_INIT([exactness], [0.1.0], [enlightenment-devel@lists.sourceforge.net])
AC_PREREQ([2.52])
AC_CONFIG_SRCDIR([configure.ac])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([1.6 dist-bzip2])
AM_CONFIG_HEADER([config.h])
AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_C_CONST
PKG_PROG_PKG_CONFIG
AC_PROG_LIBTOOL
dnl Checking for __attribute__ support
AC_MSG_CHECKING([for __attribute__])
AC_CACHE_VAL([_cv_have___attribute__],
[
AC_TRY_COMPILE([#include <stdlib.h>],
[int func(int x); int foo(int x __attribute__ ((unused))) { exit(1); }],
[_cv_have___attribute__="yes"],
[_cv_have___attribute__="no"])
])
if test "x${_cv_have___attribute__}" = "xyes" ; then
AC_DEFINE([HAVE___ATTRIBUTE__], [1], [Define to 1 if your compiler has __attribute__])
fi
AC_MSG_RESULT([${_cv_have___attribute__}])
PKG_CHECK_MODULES([EFL],
[
elementary >= 0.7.0
])
AC_OUTPUT([
Makefile
src/Makefile
src/bin/Makefile
src/lib/Makefile
src/scripts/Makefile
])

BIN
data/recording/test_3d.rec Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

4
src/Makefile.am Normal file
View File

@ -0,0 +1,4 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = bin lib scripts

80
src/bin/Makefile.am Normal file
View File

@ -0,0 +1,80 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = \
-I$(top_srcdir)/src/lib \
-DPACKAGE_BIN_DIR=\"$(bindir)\" \
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
-DLOCALE_DIR=\"$(datadir)/locale\" \
@EFL_CFLAGS@
bin_PROGRAMS = exactness_raw
exactness_raw_SOURCES = \
tsuite.c \
../lib/tsuite_file_data.c \
test_3d.c \
test_actionslider.c \
test_focus2.c \
test_panel.c \
test_anchorblock.c \
test_focus3.c \
test_panes.c \
test_anchorview.c \
test_focus.c \
test_photo.c \
test_bg.c \
test_gengrid.c \
test_photocam.c \
test_box.c \
test_genlist.c \
test_progressbar.c \
test_bubble.c \
test_radio.c \
test_button.c \
test_scaling.c \
test_calendar.c \
test_grid.c \
test_segment_control.c \
test_check.c \
test_hover.c \
test_separator.c \
test_hoversel.c \
test_slider.c \
test_colorselector.c \
test_conform.c \
test_spinner.c \
test_ctxpopup.c \
test_index.c \
test_table.c \
test_cursor.c \
test_inwin.c \
test_thumb.c \
test_diskselector.c \
test_label.c \
test_toggle.c \
test_entry.c \
test_toolbar.c \
test_fileselector_button.c \
test_tooltip.c \
test_fileselector.c \
test_list.c \
test_fileselector_entry.c \
test_map.c \
test_weather.c \
test_menu.c \
test_win_inline.c \
test_naviframe.c \
test_win_state.c \
test_notify.c \
test_floating.c \
test_scroller.c \
test_pager.c
exactness_raw_LDADD = @EFL_LIBS@
EXTRA_DIST = \
tsuite.h

338
src/bin/test_3d.c Normal file
View File

@ -0,0 +1,338 @@
#include <Elementary.h>
#include "tsuite.h"
typedef struct _Point
{
Evas_Coord x, y, z, u, v;
} Point;
typedef struct _Side
{
Evas_Object *o;
Point pt[4];
} Side;
typedef struct _Cube
{
Side side[6];
} Cube;
static Cube *cube;
static double rotx = 0.0, roty = 0.0, rotz = 0.0;
static double cxo = 0.0, cyo = 0.0, focv = 256.0, z0v = 0.0;
#define POINT(n, p, xx, yy, zz, uu, vv) \
c->side[n].pt[p].x = xx; \
c->side[n].pt[p].y = yy; \
c->side[n].pt[p].z = zz; \
c->side[n].pt[p].u = uu; \
c->side[n].pt[p].v = vv
static Cube *
_cube_new(Evas *evas, Evas_Coord w, Evas_Coord h, Evas_Coord d)
{
Cube *c;
int i;
w -= (w / 2);
h -= (h / 2);
d -= (d / 2);
c = calloc(1, sizeof(Cube));
for (i = 0; i < 6; i++)
{
Evas_Object *o;
char buf[PATH_MAX];
o = evas_object_image_add(evas);
c->side[i].o = o;
snprintf(buf, sizeof(buf), "%s/images/%s",
elm_app_data_dir_get(), "twofish.jpg");
evas_object_image_file_set(o, buf, NULL);
evas_object_image_fill_set(o, 0, 0, 256, 256);
evas_object_resize(o, 256, 256);
evas_object_image_smooth_scale_set(o, 0);
evas_object_show(o);
}
POINT(0, 0, -w, -h, -d, 0, 0);
POINT(0, 1, w, -h, -d, 256, 0);
POINT(0, 2, w, h, -d, 256, 256);
POINT(0, 3, -w, h, -d, 0, 256);
POINT(1, 0, w, -h, -d, 0, 0);
POINT(1, 1, w, -h, d, 256, 0);
POINT(1, 2, w, h, d, 256, 256);
POINT(1, 3, w, h, -d, 0, 256);
POINT(2, 0, w, -h, d, 0, 0);
POINT(2, 1, -w, -h, d, 256, 0);
POINT(2, 2, -w, h, d, 256, 256);
POINT(2, 3, w, h, d, 0, 256);
POINT(3, 0, -w, -h, d, 0, 0);
POINT(3, 1, -w, -h, -d, 256, 0);
POINT(3, 2, -w, h, -d, 256, 256);
POINT(3, 3, -w, h, d, 0, 256);
POINT(4, 0, -w, -h, d, 0, 0);
POINT(4, 1, w, -h, d, 256, 0);
POINT(4, 2, w, -h, -d, 256, 256);
POINT(4, 3, -w, -h, -d, 0, 256);
POINT(5, 0, -w, h, -d, 0, 0);
POINT(5, 1, w, h, -d, 256, 0);
POINT(5, 2, w, h, d, 256, 256);
POINT(5, 3, -w, h, d, 0, 256);
return c;
}
static void
_cube_pos(Cube *c,
Evas_Coord x, Evas_Coord y, Evas_Coord z,
double dx, double dy, double dz,
Evas_Coord cx, Evas_Coord cy, Evas_Coord foc, Evas_Coord z0)
{
Evas_Map *m;
int i, j, order[6], sorted;
Evas_Coord mz[6];
m = evas_map_new(4);
evas_map_smooth_set(m, 0);
for (i = 0; i < 6; i++)
{
Evas_Coord tz[4];
for (j = 0; j < 4; j++)
{
evas_map_point_coord_set(m, j,
c->side[i].pt[j].x + x,
c->side[i].pt[j].y + y,
c->side[i].pt[j].z + z);
evas_map_point_image_uv_set(m, j,
c->side[i].pt[j].u,
c->side[i].pt[j].v);
evas_map_point_color_set(m, j, 255, 255, 255, 255);
}
evas_map_util_3d_rotate(m, dx, dy, dz, x, y, z);
evas_map_util_3d_lighting(m, -1000, -1000, -1000,
255, 255, 255,
20, 20, 20);
evas_map_util_3d_perspective(m, cx, cy, foc, z0);
if (evas_map_util_clockwise_get(m))
{
evas_object_map_enable_set(c->side[i].o, 1);
evas_object_map_set(c->side[i].o, m);
evas_object_show(c->side[i].o);
}
else
evas_object_hide(c->side[i].o);
order[i] = i;
for (j = 0; j < 4; j++)
evas_map_point_coord_get(m, j, NULL, NULL, &(tz[j]));
mz[i] = (tz[0] + tz[1] + tz[2] + tz[3]) / 4;
}
sorted = 0;
do
{
sorted = 1;
for (i = 0; i < 5; i++)
{
if (mz[order[i]] > mz[order[i + 1]])
{
j = order[i];
order[i] = order[i + 1];
order[i + 1] = j;
sorted = 0;
}
}
}
while (!sorted);
evas_object_raise(c->side[order[0]].o);
for (i = 1; i < 6; i++)
evas_object_stack_below(c->side[order[i]].o, c->side[order[i - 1]].o);
evas_map_free(m);
}
/*
static void
_cube_free(Cube *c)
{
int i;
for (i = 0; i < 6; i++) evas_object_del(c->side[i].o);
free(c);
}
*/
static void
_cube_update(Evas_Object *win, Cube *c)
{
Evas_Coord w, h;
evas_object_geometry_get(win, NULL, NULL, &w, &h);
_cube_pos(c,
(w / 2), (h / 2), 512,
rotx, roty, rotz,
(w / 2) + cxo, (h / 2) + cyo, z0v, focv);
}
void
_ch_rot_x(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *win = data;
rotx = elm_slider_value_get(obj);
_cube_update(win, cube);
}
void
_ch_rot_y(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *win = data;
roty = elm_slider_value_get(obj);
_cube_update(win, cube);
}
void
_ch_rot_z(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *win = data;
rotz = elm_slider_value_get(obj);
_cube_update(win, cube);
}
void
_ch_cx(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *win = data;
cxo = elm_slider_value_get(obj);
_cube_update(win, cube);
}
void
_ch_cy(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *win = data;
cyo = elm_slider_value_get(obj);
_cube_update(win, cube);
}
void
_ch_foc(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *win = data;
focv = elm_slider_value_get(obj);
_cube_update(win, cube);
}
void
_ch_z0(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *win = data;
z0v = elm_slider_value_get(obj);
_cube_update(win, cube);
}
TEST_START(test_3d)
{
Evas_Object *bg, *bx, *sl;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
cube = _cube_new(evas_object_evas_get(win), 240, 240, 240);
bx = elm_box_add(win);
evas_object_layer_set(bx, 10);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
sl = elm_slider_add(win);
elm_object_text_set(sl, "Rot X");
elm_slider_unit_format_set(sl, "%1.0f units");
elm_slider_span_size_set(sl, 360);
elm_slider_min_max_set(sl, 0, 360);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, sl);
evas_object_smart_callback_add(sl, "changed", _ch_rot_x, win);
evas_object_show(sl);
sl = elm_slider_add(win);
elm_object_text_set(sl, "Rot Y");
elm_slider_unit_format_set(sl, "%1.0f units");
elm_slider_span_size_set(sl, 360);
elm_slider_min_max_set(sl, 0, 360);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, sl);
evas_object_smart_callback_add(sl, "changed", _ch_rot_y, win);
evas_object_show(sl);
sl = elm_slider_add(win);
elm_object_text_set(sl, "Rot Z");
elm_slider_unit_format_set(sl, "%1.0f units");
elm_slider_span_size_set(sl, 360);
elm_slider_min_max_set(sl, 0, 360);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, sl);
evas_object_smart_callback_add(sl, "changed", _ch_rot_z, win);
evas_object_show(sl);
sl = elm_slider_add(win);
elm_object_text_set(sl, "CX Off");
elm_slider_unit_format_set(sl, "%1.0f units");
elm_slider_span_size_set(sl, 360);
elm_slider_min_max_set(sl, -320, 320);
elm_slider_value_set(sl, cxo);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, sl);
evas_object_smart_callback_add(sl, "changed", _ch_cx, win);
evas_object_show(sl);
sl = elm_slider_add(win);
elm_object_text_set(sl, "CY Off");
elm_slider_unit_format_set(sl, "%1.0f units");
elm_slider_span_size_set(sl, 360);
elm_slider_min_max_set(sl, -320, 320);
elm_slider_value_set(sl, cyo);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, sl);
evas_object_smart_callback_add(sl, "changed", _ch_cy, win);
evas_object_show(sl);
sl = elm_slider_add(win);
elm_object_text_set(sl, "Foc");
elm_slider_unit_format_set(sl, "%1.0f units");
elm_slider_span_size_set(sl, 360);
elm_slider_min_max_set(sl, 1, 2000);
elm_slider_value_set(sl, focv);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, sl);
evas_object_smart_callback_add(sl, "changed", _ch_foc, win);
evas_object_show(sl);
sl = elm_slider_add(win);
elm_object_text_set(sl, "Z0");
elm_slider_unit_format_set(sl, "%1.0f units");
elm_slider_span_size_set(sl, 360);
elm_slider_min_max_set(sl, -2000, 2000);
elm_slider_value_set(sl, z0v);
evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, sl);
evas_object_smart_callback_add(sl, "changed", _ch_z0, win);
evas_object_show(sl);
evas_object_resize(win, 480, 480);
_cube_update(win, cube);
evas_object_show(win);
}
TEST_END

175
src/bin/test_actionslider.c Normal file
View File

@ -0,0 +1,175 @@
#include <Elementary.h>
#include "tsuite.h"
static void _pos_selected_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info)
{
printf("Selection: %s\n", (char *)event_info);
printf("Label selected: %s\n", elm_actionslider_selected_label_get(obj));
}
static void
_position_change_magnetic_cb(void *data __UNUSED__, Evas_Object * obj, void *event_info)
{
if (!strcmp((char *)event_info, "left"))
elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_LEFT);
else if (!strcmp((char *)event_info, "right"))
elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_RIGHT);
}
static void
_magnet_enable_disable_cb(void *data __UNUSED__, Evas_Object *obj, void *event_info)
{
if (!strcmp((char *)event_info, "left"))
elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_CENTER);
else if (!strcmp((char *)event_info, "right"))
elm_actionslider_magnet_pos_set(obj, ELM_ACTIONSLIDER_NONE);
}
enum _api_state
{
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
switch(api->state)
{ /* Put all api-changes under switch */
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
a->state++;
set_api_state(a);
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
TEST_START(test_actionslider)
{
Evas_Object *bg, *bx, *as;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, 0);
evas_object_show(bg);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
as = elm_actionslider_add(win);
evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_RIGHT);
elm_object_part_text_set(as, "left", "Snooze");
elm_object_part_text_set(as, "center", NULL);
elm_object_part_text_set(as, "right", "Stop");
elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
ELM_ACTIONSLIDER_RIGHT);
evas_object_smart_callback_add(as, "pos_changed",
_position_change_magnetic_cb, NULL);
evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
evas_object_show(as);
elm_box_pack_end(bx, as);
as = elm_actionslider_add(win);
evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_CENTER);
elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER);
elm_object_part_text_set(as, "left", "Snooze");
elm_object_part_text_set(as, "center", NULL);
elm_object_part_text_set(as, "right", "Stop");
elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_LEFT |
ELM_ACTIONSLIDER_RIGHT);
evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
evas_object_show(as);
elm_box_pack_end(bx, as);
as = elm_actionslider_add(win);
elm_object_style_set(as, "bar");
evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER|
ELM_ACTIONSLIDER_RIGHT);
elm_actionslider_enabled_pos_set(as, ELM_ACTIONSLIDER_CENTER |
ELM_ACTIONSLIDER_RIGHT);
elm_object_part_text_set(as, "left", NULL);
elm_object_part_text_set(as, "center", "Accept");
elm_object_part_text_set(as, "right", "Reject");
evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
evas_object_show(as);
elm_box_pack_end(bx, as);
as = elm_actionslider_add(win);
elm_object_style_set(as, "bar");
evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_LEFT);
elm_object_part_text_set(as, "left", NULL);
elm_object_part_text_set(as, "center", "Accept");
elm_object_part_text_set(as, "right", "Reject");
elm_object_text_set(as, "Go");
evas_object_smart_callback_add(as, "pos_changed",
_position_change_magnetic_cb, NULL);
evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
evas_object_show(as);
elm_box_pack_end(bx, as);
as = elm_actionslider_add(win);
evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_LEFT);
elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_ALL);
elm_object_part_text_set(as, "left", "Left");
elm_object_part_text_set(as, "center", "Center");
elm_object_part_text_set(as, "right", "Right");
elm_object_text_set(as, "Go");
evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
evas_object_show(as);
elm_box_pack_end(bx, as);
as = elm_actionslider_add(win);
evas_object_size_hint_weight_set(as, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_align_set(as, EVAS_HINT_FILL, 0);
elm_actionslider_indicator_pos_set(as, ELM_ACTIONSLIDER_CENTER);
elm_actionslider_magnet_pos_set(as, ELM_ACTIONSLIDER_CENTER);
elm_object_part_text_set(as, "left", "Enable");
elm_object_part_text_set(as, "center", "Magnet");
elm_object_part_text_set(as, "right", "Disable");
evas_object_smart_callback_add(as, "pos_changed",
_magnet_enable_disable_cb, NULL);
evas_object_smart_callback_add(as, "selected", _pos_selected_cb, NULL);
evas_object_show(as);
elm_box_pack_end(bx, as);
evas_object_resize(win, 320, 400);
evas_object_show(win);
}
TEST_END

275
src/bin/test_anchorblock.c Normal file
View File

@ -0,0 +1,275 @@
#include <Elementary.h>
#include "tsuite.h"
static void
_print_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
printf("bubble clicked\n");
}
static void
my_anchorblock_bt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *av = data;
elm_anchorblock_hover_end(av);
}
static void
my_anchorblock_anchor(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *av = data;
Elm_Entry_Anchorblock_Info *ei = event_info;
Evas_Object *bt, *bx;
bt = elm_button_add(obj);
elm_object_text_set(bt, ei->name);
elm_hover_content_set(ei->hover, "middle", bt);
evas_object_show(bt);
// hints as to where we probably should put hover contents (buttons etc.).
if (ei->hover_top)
{
bx = elm_box_add(obj);
bt = elm_button_add(obj);
elm_object_text_set(bt, "Top 1");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
bt = elm_button_add(obj);
elm_object_text_set(bt, "Top 2");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
bt = elm_button_add(obj);
elm_object_text_set(bt, "Top 3");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
elm_hover_content_set(ei->hover, "top", bx);
evas_object_show(bx);
}
if (ei->hover_bottom)
{
bt = elm_button_add(obj);
elm_object_text_set(bt, "Bot");
elm_hover_content_set(ei->hover, "bottom", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
}
if (ei->hover_left)
{
bt = elm_button_add(obj);
elm_object_text_set(bt, "Left");
elm_hover_content_set(ei->hover, "left", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
}
if (ei->hover_right)
{
bt = elm_button_add(obj);
elm_object_text_set(bt, "Right");
elm_hover_content_set(ei->hover, "right", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorblock_bt, av);
evas_object_show(bt);
}
}
static void
my_anchorblock_edge_left(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
printf("left\n");
}
static void
my_anchorblock_edge_right(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
printf("right\n");
}
static void
my_anchorblock_edge_top(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
printf("top\n");
}
static void
my_anchorblock_edge_bottom(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
printf("bottom\n");
}
static void
my_anchorblock_scroll(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Coord x, y, w, h, vw, vh;
elm_scroller_region_get(obj, &x, &y, &w, &h);
elm_scroller_child_size_get(obj, &vw, &vh);
printf("scroll %ix%i +%i+%i in %ix%i\n", w, h, x, y, vw, vh);
}
enum _api_state
{
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
switch(api->state)
{ /* Put all api-changes under switch */
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
a->state++;
set_api_state(a);
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
TEST_START(test_anchorblock)
{
Evas_Object *bg, *av, *sc, *bx, *bb, *ic;
char buf[PATH_MAX];
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
sc = elm_scroller_add(win);
evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, sc);
evas_object_smart_callback_add(sc, "edge_left", my_anchorblock_edge_left, NULL);
evas_object_smart_callback_add(sc, "edge_right", my_anchorblock_edge_right, NULL);
evas_object_smart_callback_add(sc, "edge_top", my_anchorblock_edge_top, NULL);
evas_object_smart_callback_add(sc, "edge_bottom", my_anchorblock_edge_bottom, NULL);
evas_object_smart_callback_add(sc, "scroll", my_anchorblock_scroll, NULL);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
bb = elm_bubble_add(win);
elm_object_text_set(bb, "Message 3");
elm_object_part_text_set(bb, "info", "10:32 4/11/2008");
elm_bubble_icon_set(bb, ic);
evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
evas_object_show(ic);
evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
av = elm_anchorblock_add(win);
elm_anchorblock_hover_style_set(av, "popout");
elm_anchorblock_hover_parent_set(av, win);
elm_object_text_set(av,
"Hi there. This is the most recent message in the "
"list of messages. It has one <a href=tel:+614321234>+61 432 1234</a> "
"(phone number) to click on.");
evas_object_smart_callback_add(av, "anchor,clicked",
my_anchorblock_anchor, av);
elm_object_content_set(bb, av);
evas_object_show(av);
elm_box_pack_end(bx, bb);
evas_object_show(bb);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bb = elm_bubble_add(win);
elm_object_text_set(bb, "Message 2");
elm_object_part_text_set(bb, "info", "7:16 27/10/2008");
elm_bubble_icon_set(bb, ic);
evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
evas_object_show(ic);
evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
av = elm_anchorblock_add(win);
elm_anchorblock_hover_style_set(av, "popout");
elm_anchorblock_hover_parent_set(av, win);
elm_object_text_set(av,
"Hey what are you doing? This is the second last message "
"Hi there. This is the most recent message in the "
"list. It's a longer one so it can wrap more and "
"contains a <a href=contact:john>John</a> contact "
"link in it to test popups on links. The idea is that "
"all SMS's are scanned for things that look like phone "
"numbers or names that are in your contacts list, and "
"if they are, they become clickable links that pop up "
"a menus of obvious actions to perform on this piece "
"of information. This of course can be later explicitly "
"done by links maybe running local apps or even being "
"web URL's too that launch the web browser and point it "
"to that URL. <item relsize=16x16 vsize=full href=emoticon/omg></item>");
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorblock_anchor, av);
elm_object_content_set(bb, av);
evas_object_show(av);
elm_box_pack_end(bx, bb);
evas_object_show(bb);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
bb = elm_bubble_add(win);
elm_object_text_set(bb, "Message 1");
elm_object_part_text_set(bb, "info", "20:47 18/6/2008");
elm_bubble_icon_set(bb, ic);
evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
evas_object_show(ic);
evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
av = elm_anchorblock_add(win);
elm_anchorblock_hover_style_set(av, "popout");
elm_anchorblock_hover_parent_set(av, win);
elm_object_text_set(av, "This is a short message. <item relsize=16x16 vsize=full href=emoticon/haha></item>");
evas_object_smart_callback_add(av, "anchor,clicked",
my_anchorblock_anchor, av);
elm_object_content_set(bb, av);
evas_object_show(av);
elm_box_pack_end(bx, bb);
evas_object_show(bb);
elm_object_content_set(sc, bx);
evas_object_show(bx);
evas_object_show(sc);
evas_object_resize(win, 320, 520);
elm_object_focus_set(win, EINA_TRUE);
evas_object_show(win);
}
TEST_END

148
src/bin/test_anchorview.c Normal file
View File

@ -0,0 +1,148 @@
#include <Elementary.h>
#include "tsuite.h"
static void
my_anchorview_bt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *av = data;
elm_anchorview_hover_end(av);
}
static void
my_anchorview_anchor(void *data, Evas_Object *obj, void *event_info)
{
Evas_Object *av = data;
Elm_Entry_Anchorview_Info *ei = event_info;
Evas_Object *bt, *bx;
bt = elm_button_add(obj);
elm_object_text_set(bt, ei->name);
elm_hover_content_set(ei->hover, "middle", bt);
evas_object_show(bt);
// hints as to where we probably should put hover contents (buttons etc.).
if (ei->hover_top)
{
bx = elm_box_add(obj);
bt = elm_button_add(obj);
elm_object_text_set(bt, "Top 1");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
bt = elm_button_add(obj);
elm_object_text_set(bt, "Top 2");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
bt = elm_button_add(obj);
elm_object_text_set(bt, "Top 3");
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
elm_hover_content_set(ei->hover, "top", bx);
evas_object_show(bx);
}
if (ei->hover_bottom)
{
bt = elm_button_add(obj);
elm_object_text_set(bt, "Bot");
elm_hover_content_set(ei->hover, "bottom", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
}
if (ei->hover_left)
{
bt = elm_button_add(obj);
elm_object_text_set(bt, "Left");
elm_hover_content_set(ei->hover, "left", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
}
if (ei->hover_right)
{
bt = elm_button_add(obj);
elm_object_text_set(bt, "Right");
elm_hover_content_set(ei->hover, "right", bt);
evas_object_smart_callback_add(bt, "clicked", my_anchorview_bt, av);
evas_object_show(bt);
}
}
enum _api_state
{
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
switch(api->state)
{ /* Put all api-changes under switch */
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
a->state++;
set_api_state(a);
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
TEST_START(test_anchorview)
{
Evas_Object *bg, *bx, *av;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bx = elm_box_add(win);
elm_win_resize_object_add(win, bx); /* Resize BOX to size of window */
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
av = elm_anchorview_add(win);
elm_anchorview_hover_style_set(av, "popout");
elm_anchorview_hover_parent_set(av, win);
elm_object_text_set(av,
"This is an entry widget in this window that<br>"
"uses markup <b>like this</> for styling and<br>"
"formatting <em>like this</>, as well as<br>"
"<a href=X><link>links in the text</></a>, so enter text<br>"
"in here to edit it. By the way, links are<br>"
"called <a href=anc-02>Anchors</a> so you will need<br>"
"to refer to them this way. <item relsize=16x16 vsize=full href=emoticon/guilty-smile></item>");
evas_object_size_hint_weight_set(av, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(av, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(av, "anchor,clicked", my_anchorview_anchor, av);
elm_box_pack_end(bx, av);
evas_object_show(av);
evas_object_show(bx);
evas_object_resize(win, 320, 300);
elm_object_focus_set(win, EINA_TRUE);
evas_object_show(win);
}
TEST_END

194
src/bin/test_bg.c Normal file
View File

@ -0,0 +1,194 @@
#include <Elementary.h>
#include "tsuite.h"
static void
_cb_radio_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
{
Evas_Object *o_bg = data;
elm_bg_option_set(o_bg, elm_radio_value_get((Evas_Object *)obj));
}
static void
_cb_overlay_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
{
Evas_Object *o_bg = data;
if (elm_check_state_get(obj))
{
Evas_Object *parent, *over;
char buff[PATH_MAX];
snprintf(buff, sizeof(buff), "%s/objects/test.edj", elm_app_data_dir_get());
parent = elm_object_parent_widget_get(o_bg);
over = edje_object_add(evas_object_evas_get(parent));
edje_object_file_set(over, buff, "bg_overlay");
elm_object_content_set(o_bg, over);
}
else
elm_object_content_set(o_bg, NULL);
}
static void
_cb_color_changed(void *data, Evas_Object *obj, void *event __UNUSED__)
{
Evas_Object *o_bg = data;
double val = 0.0;
val = elm_spinner_value_get(obj);
if (val == 1.0)
elm_bg_color_set(o_bg, 255, 255, 255);
else if (val == 2.0)
elm_bg_color_set(o_bg, 255, 0, 0);
else if (val == 3.0)
elm_bg_color_set(o_bg, 0, 0, 255);
else if (val == 4.0)
elm_bg_color_set(o_bg, 0, 255, 0);
}
TEST_START(test_bg_plain)
{
Evas_Object *bg;
bg = elm_bg_add(win);
/* allow bg to expand in x & y */
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
/* set size hints. a minimum size for the bg. this should propagate back
* to the window thus limiting its size based off the bg as the bg is one
* of the window's resize objects. */
evas_object_size_hint_min_set(bg, 160, 160);
/* and set a maximum size. not needed very often. normally used together
* with evas_object_size_hint_min_set() at the same size to make a
* window not resizable */
evas_object_size_hint_max_set(bg, 640, 640);
/* and now just resize the window to a size you want. normally widgets
* will determine the initial size though */
evas_object_resize(win, 320, 320);
/* and show the window */
evas_object_show(win);
}
TEST_END
TEST_START(test_bg_image)
{
Evas_Object *bg;
char buf[PATH_MAX];
bg = elm_bg_add(win);
snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
elm_bg_file_set(bg, buf, NULL);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
evas_object_size_hint_min_set(bg, 160, 160);
evas_object_size_hint_max_set(bg, 640, 640);
evas_object_resize(win, 320, 320);
evas_object_show(win);
}
TEST_END
TEST_START(test_bg_options)
{
Evas_Object *bg;
Evas_Object *box, *hbox, *o_bg;
Evas_Object *rd, *rdg;
char buf[PATH_MAX];
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
box = elm_box_add(win);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, box);
evas_object_show(box);
o_bg = elm_bg_add(win);
snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
elm_bg_file_set(o_bg, buf, NULL);
evas_object_size_hint_weight_set(o_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o_bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, o_bg);
evas_object_show(o_bg);
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_size_hint_align_set(hbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
rd = elm_radio_add(win);
elm_radio_state_value_set(rd, ELM_BG_OPTION_CENTER);
elm_object_text_set(rd, "Center");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
rdg = rd;
rd = elm_radio_add(win);
elm_radio_state_value_set(rd, ELM_BG_OPTION_SCALE);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "Scale");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
rd = elm_radio_add(win);
elm_radio_state_value_set(rd, ELM_BG_OPTION_STRETCH);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "Stretch");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
rd = elm_radio_add(win);
elm_radio_state_value_set(rd, ELM_BG_OPTION_TILE);
elm_radio_group_add(rd, rdg);
elm_object_text_set(rd, "Tile");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_radio_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
elm_radio_value_set(rdg, ELM_BG_OPTION_SCALE);
rd = elm_check_add(win);
elm_object_text_set(rd, "Show Overlay");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_overlay_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
/* color choices ... this is ghetto, but we don't have a 'colorpicker'
* widget yet :( */
rd = elm_spinner_add(win);
elm_object_style_set(rd, "vertical");
elm_spinner_min_max_set(rd, 1, 4);
elm_spinner_label_format_set(rd, "%.0f");
elm_spinner_editable_set(rd, EINA_FALSE);
elm_spinner_special_value_add(rd, 1, "White");
elm_spinner_special_value_add(rd, 2, "Red");
elm_spinner_special_value_add(rd, 3, "Blue");
elm_spinner_special_value_add(rd, 4, "Green");
evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(rd, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(rd, "changed", _cb_color_changed, o_bg);
elm_box_pack_end(hbox, rd);
evas_object_show(rd);
elm_box_pack_end(box, hbox);
evas_object_show(hbox);
evas_object_size_hint_min_set(bg, 160, 160);
evas_object_size_hint_max_set(bg, 640, 640);
evas_object_resize(win, 320, 320);
evas_object_show(win);
}
TEST_END

393
src/bin/test_box.c Normal file
View File

@ -0,0 +1,393 @@
#include <Elementary.h>
#include "tsuite.h"
enum _api_state
{
BOX_PACK_START,
BOX_PACK_BEFORE,
BOX_PACK_AFTER,
BOX_PADDING_SET,
BOX_ALIGN_SET,
BOX_HOMOGENEOUS_SET,
BOX_UNPACK_ALL,
BOX_CLEAR,
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
const Eina_List *items = elm_box_children_get(api->data);
if(!eina_list_count(items))
return;
/* use elm_box_children_get() to get list of children */
switch(api->state)
{ /* Put all api-changes under switch */
case BOX_PACK_START: /* Move last item to begining */
elm_box_unpack(api->data, eina_list_data_get(eina_list_last(items)));
elm_box_pack_start(api->data, eina_list_data_get(eina_list_last(items)));
break;
case BOX_PACK_BEFORE:
if(eina_list_count(items) > 1)
{ /* Put last item before the one preceeding it */
elm_box_unpack(api->data, eina_list_data_get(eina_list_last(items)));
elm_box_pack_before(api->data,
eina_list_data_get(eina_list_last(items)),
eina_list_nth(items, eina_list_count(items)-2));
}
break;
case BOX_PACK_AFTER:
if(eina_list_count(items) > 1)
{ /* Put item before last to last */
elm_box_unpack(api->data, eina_list_nth(items,
eina_list_count(items)-2));
elm_box_pack_after(api->data,
eina_list_nth(items, eina_list_count(items)-2),
eina_list_data_get(eina_list_last(items)));
}
break;
case BOX_PADDING_SET:
elm_box_padding_set(api->data, 30, 15);
break;
case BOX_ALIGN_SET:
elm_box_align_set(api->data, 0.25, 0.75);
break;
case BOX_HOMOGENEOUS_SET:
elm_box_homogeneous_set(api->data, EINA_TRUE);
break;
case BOX_UNPACK_ALL:
{
Eina_List *l;
Evas_Object *data;
elm_box_unpack_all(api->data);
EINA_LIST_REVERSE_FOREACH(items, l, data)
elm_box_pack_end(api->data, data);
}
break;
case BOX_CLEAR:
elm_box_clear(api->data);
break;
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
TEST_START(test_box_vert)
{
Evas_Object *bg, *bx, *bxx, *ic;
char buf[PATH_MAX];
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
bx = elm_box_add(win);
api->data = bx;
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, bx);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_01.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_align_set(ic, 0.5, 0.5);
elm_box_pack_end(bx, ic);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_02.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_align_set(ic, 0.0, 0.5);
elm_box_pack_end(bx, ic);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_03.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_align_set(ic, EVAS_HINT_EXPAND, 0.5);
elm_box_pack_end(bx, ic);
evas_object_show(ic);
evas_object_show(win);
}
TEST_END
static void
_del_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
elm_box_unpack(data, obj);
evas_object_move(obj, 0, 0);
evas_object_color_set(obj, 128, 64, 0, 128);
// evas_object_del(obj);
}
TEST_START(test_box_vert2)
{
Evas_Object *bg, *bx, *bt;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bx = elm_box_add(win);
elm_win_resize_object_add(win, bx);
elm_box_padding_set(bx, 10, 10);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bx);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 1");
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, 0.0, 0.0);
evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 2");
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, 0.0, 0.0);
evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 3");
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, 0.0, 0.0);
evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 4");
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, 0.0, 0.0);
evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 5");
evas_object_size_hint_align_set(bt, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(bt, 0.0, 0.0);
evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(win);
}
TEST_END
TEST_START(test_box_horiz)
{
Evas_Object *bg, *bx, *bxx, *ic;
char buf[PATH_MAX];
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
bx = elm_box_add(win);
elm_box_horizontal_set(bx, EINA_TRUE);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
api->data = bx;
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, bx);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_01.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_align_set(ic, 0.5, 0.5);
elm_box_pack_end(bx, ic);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_02.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_align_set(ic, 0.5, 0.0);
elm_box_pack_end(bx, ic);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/icon_03.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_align_set(ic, 0.0, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, ic);
evas_object_show(ic);
evas_object_show(win);
}
TEST_END
typedef struct
{
Eina_List *transitions;
Evas_Object *box;
Evas_Object_Box_Layout last_layout;
} Transitions_Data;
static void
_test_box_transition_change(void *data)
{
Transitions_Data *tdata = data;
Elm_Box_Transition *layout_data;
Evas_Object_Box_Layout next_layout;
if (!data) return;
next_layout = eina_list_data_get(tdata->transitions);
layout_data = elm_box_transition_new(2.0, tdata->last_layout,
NULL, NULL, next_layout, NULL, NULL,
_test_box_transition_change, tdata);
elm_box_layout_set(tdata->box, elm_box_layout_transition, layout_data, elm_box_transition_free);
tdata->last_layout = next_layout;
tdata->transitions = eina_list_demote_list(tdata->transitions, tdata->transitions);
}
static void
_win_del(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Transitions_Data *tdata = data;
if (!data) return;
free(tdata);
}
void
test_box_transition(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *win, *bg, *bx, *bt;
Transitions_Data *tdata;
win = elm_win_add(NULL, "box-transition", ELM_WIN_BASIC);
elm_win_title_set(win, "Box Transition");
elm_win_autodel_set(win, EINA_TRUE);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, 1.0, 1.0);
evas_object_show(bg);
bx = elm_box_add(win);
elm_win_resize_object_add(win, bx);
evas_object_size_hint_weight_set(bx, 1.0, 1.0);
evas_object_show(bx);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 1");
evas_object_size_hint_weight_set(bt, 1.0, 1.0);
evas_object_size_hint_align_set(bt, -1.0, -1.0);
evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
elm_box_pack_end(bx, bt);
evas_object_resize(bt, 100, 100);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 2");
evas_object_size_hint_weight_set(bt, 1.0, 1.0);
evas_object_size_hint_align_set(bt, -1.0, -1.0);
evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
elm_box_pack_end(bx, bt);
evas_object_resize(bt, 100, 100);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Button 3");
evas_object_size_hint_weight_set(bt, 1.0, 1.0);
evas_object_size_hint_align_set(bt, -1.0, -1.0);
evas_object_smart_callback_add(bt, "clicked", _del_cb, bx);
elm_box_pack_end(bx, bt);
evas_object_resize(bt, 100, 100);
evas_object_show(bt);
tdata = calloc(1, sizeof(Transitions_Data));
tdata->box = bx;
tdata->last_layout = evas_object_box_layout_horizontal;
tdata->transitions = eina_list_append(tdata->transitions,
evas_object_box_layout_vertical);
tdata->transitions = eina_list_append(tdata->transitions,
evas_object_box_layout_horizontal);
tdata->transitions = eina_list_append(tdata->transitions,
evas_object_box_layout_stack);
tdata->transitions = eina_list_append(tdata->transitions,
evas_object_box_layout_homogeneous_vertical);
tdata->transitions = eina_list_append(tdata->transitions,
evas_object_box_layout_homogeneous_horizontal);
tdata->transitions = eina_list_append(tdata->transitions,
evas_object_box_layout_flow_vertical);
tdata->transitions = eina_list_append(tdata->transitions,
evas_object_box_layout_flow_horizontal);
tdata->transitions = eina_list_append(tdata->transitions,
evas_object_box_layout_stack);
evas_object_resize(win, 300, 300);
evas_object_resize(bx, 300, 300);
evas_object_smart_callback_add(win, "delete,request", _win_del, tdata);
evas_object_show(win);
elm_box_layout_set(bx, evas_object_box_layout_horizontal, NULL, NULL);
_test_box_transition_change(tdata);
}

155
src/bin/test_bubble.c Normal file
View File

@ -0,0 +1,155 @@
#include <Elementary.h>
#include "tsuite.h"
static void
_print_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
printf("bubble clicked\n");
}
enum _api_state
{
BUBBLE_SET_CORNER_1,
BUBBLE_SET_CORNER_2,
BUBBLE_SET_ICON_CONTENT,
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
const Eina_List *items = elm_box_children_get(api->data);
if(!eina_list_count(items))
return;
switch(api->state)
{ /* Put all api-changes under switch */
case BUBBLE_SET_CORNER_1:
elm_bubble_corner_set(eina_list_nth(items, 0), "bottom_left");
elm_object_text_set(elm_object_content_get(eina_list_nth(items, 0)),
"Corner: base (bottom-left) - with icon");
elm_bubble_corner_set(eina_list_nth(items, 1), "top_right");
elm_object_text_set(elm_object_content_get(eina_list_nth(items, 1)),
"Corner: base (top-right) - no icon");
break;
case BUBBLE_SET_CORNER_2:
elm_bubble_corner_set(eina_list_nth(items, 0), "top_right");
elm_object_text_set(elm_object_content_get(eina_list_nth(items, 0)),
"Corner: base (top-right) - with icon");
elm_bubble_corner_set(eina_list_nth(items, 1), "bottom_left");
elm_object_text_set(elm_object_content_get(eina_list_nth(items, 1)),
"Corner: base (bottom-left) - no icon");
break;
case BUBBLE_SET_ICON_CONTENT:
{
char buf[PATH_MAX];
Evas_Object *ct, *ic = elm_icon_add(api->win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
elm_object_content_set(eina_list_nth(items, 0), ic);
ct = elm_label_add(api->win);
elm_object_text_set(ct, "Using icon as top-bubble content");
elm_object_content_set(eina_list_nth(items, 1), ct);
evas_object_size_hint_align_set(ic, 0.5, 0.5);
evas_object_show(ic);
}
break;
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
TEST_START(test_bubble)
{
Evas_Object *bg, *bx, *bxx, *ic, *bb, *ct;
char buf[PATH_MAX];
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
api->data = bx;
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, bx);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
bb = elm_bubble_add(win);
elm_object_text_set(bb, "Message 1");
elm_object_part_text_set(bb, "info", "Corner: bottom_right");
elm_bubble_icon_set(bb, ic);
elm_bubble_corner_set(bb, "bottom_right");
evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
evas_object_show(ic);
evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
ct = elm_label_add(win);
elm_object_text_set(ct,
"\"The future of the art: R or G or B?\", by Rusty");
elm_object_content_set(bb, ct);
elm_box_pack_end(bx, bb);
evas_object_show(bb);
bb = elm_bubble_add(win);
elm_object_text_set(bb, "Message 2");
elm_object_part_text_set(bb, "info", "10:32 4/11/2008");
evas_object_smart_callback_add(bb, "clicked", _print_clicked, NULL);
evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
ct = elm_label_add(win);
elm_object_text_set(ct, "Corner: base (top-left) - no icon");
elm_object_content_set(bb, ct);
elm_box_pack_end(bx, bb);
evas_object_show(bb);
evas_object_show(win);
}
TEST_END

206
src/bin/test_button.c Normal file
View File

@ -0,0 +1,206 @@
#include <Elementary.h>
#include "tsuite.h"
static void
_bt_repeated(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
static int count;
char buf[16];
snprintf(buf, sizeof(buf), "count=%d", count++);
if (count >= 10000)
count = 0;
elm_object_text_set(obj, buf);
}
static void
_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
int param = (int)(data);
printf("clicked event on Button:%d\n", param);
}
static void
_bt_unpressed(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
int param = (int)(data);
printf("unpressed event on Button:%d\n", param);
}
enum _api_state
{
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api __UNUSED__)
{
return;
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
TEST_START(test_button)
{
Evas_Object *bg, *bx, *bxx, *scr,*ic, *bt;
char buf[PATH_MAX];
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
scr = elm_scroller_add(win);
elm_scroller_bounce_set(scr, EINA_FALSE, EINA_TRUE);
elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
evas_object_show(scr);
evas_object_size_hint_weight_set(scr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_content_set(scr, bx);
api->data = bx;
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, bx);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_text_set(bt, "Icon sized to button");
elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)1);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)1);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
ic = elm_icon_add(bx);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
bt = elm_button_add(win);
elm_object_text_set(bt, "Icon no scale");
elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)2);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)2);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_text_set(bt, "Disabled Button");
elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)3);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)3);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)4);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)4);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
bt = elm_button_add(win);
elm_object_text_set(bt, "Label Only");
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)5);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)5);
elm_box_pack_end(bx, bt);
evas_object_smart_callback_add(bt, "repeated", _bt_repeated, NULL);
elm_button_autorepeat_set(bt, 1);
elm_button_autorepeat_initial_timeout_set(bt, 2.0);
elm_button_autorepeat_gap_timeout_set(bt, 0.5);
evas_object_show(bt);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
bt = elm_button_add(win);
elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)6);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)6);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
bt = elm_button_add(win);
elm_object_style_set(bt, "anchor");
elm_object_text_set(bt, "Anchor style");
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)7);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)7);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_style_set(bt, "anchor");
elm_object_content_set(bt, ic);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)8);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)8);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
bt = elm_button_add(win);
elm_object_access_info_set(bt, "This is some custom text describing this widget");
elm_object_style_set(bt, "anchor");
elm_object_content_set(bt, ic);
elm_object_disabled_set(bt, 1);
evas_object_smart_callback_add(bt, "clicked", _bt_clicked, (void *)9);
evas_object_smart_callback_add(bt, "unpressed", _bt_unpressed, (void *)9);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
evas_object_show(ic);
}
TEST_END

306
src/bin/test_calendar.c Normal file
View File

@ -0,0 +1,306 @@
#include <Elementary.h>
#include "tsuite.h"
enum _api_state
{
STATE_MARK_MONTHLY,
STATE_MARK_WEEKLY,
STATE_SUNDAY_HIGHLIGHT,
STATE_SELECT_DATE_DISABLED_WITH_MARKS,
STATE_SELECT_DATE_DISABLED_NO_MARKS,
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
const Eina_List *items = elm_box_children_get(api->data);
static Elm_Calendar_Mark *m = NULL;
if(!eina_list_count(items))
return;
switch(api->state)
{ /* Put all api-changes under switch */
case STATE_MARK_MONTHLY:
{
Evas_Object *cal = eina_list_nth(items, 0);
time_t sec_per_day = (60*60*24);
time_t sec_per_year = sec_per_day * 365;
time_t the_time = (sec_per_year * 41) + (sec_per_day * 9); /* Set date to DEC 31, 2010 */
elm_calendar_min_max_year_set(cal, 2010, 2011);
m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_MONTHLY);
elm_calendar_selected_time_set(cal, gmtime(&the_time));
}
break;
case STATE_MARK_WEEKLY:
{
Evas_Object *cal = eina_list_nth(items, 0);
time_t sec_per_day = (60*60*24);
time_t sec_per_year = sec_per_day * 365;
time_t the_time = (sec_per_year * 41) + (sec_per_day * 4); /* Set date to DEC 26, 2010 */
elm_calendar_mark_del(m);
m = elm_calendar_mark_add(cal, "checked", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
elm_calendar_selected_time_set(cal, gmtime(&the_time));
}
break;
case STATE_SUNDAY_HIGHLIGHT:
{
Evas_Object *cal = eina_list_nth(items, 0);
time_t sec_per_day = (60*60*24);
time_t sec_per_year = sec_per_day * 365;
time_t the_time = (sec_per_year * 41) + (sec_per_day * 3); /* Set date to DEC 25, 2010 */
/* elm_calendar_mark_del(m); */
m = elm_calendar_mark_add(cal, "holiday", gmtime(&the_time), ELM_CALENDAR_WEEKLY);
elm_calendar_selected_time_set(cal, gmtime(&the_time));
}
break;
case STATE_SELECT_DATE_DISABLED_WITH_MARKS:
{
Evas_Object *cal = eina_list_nth(items, 0);
time_t sec_per_day = (60*60*24);
time_t sec_per_year = sec_per_day * 365;
time_t the_time = (sec_per_year * 41) + (sec_per_day * 10); /* Set date to JAN 01, 2011 */
elm_calendar_day_selection_enabled_set(cal, EINA_FALSE);
elm_calendar_selected_time_set(cal, gmtime(&the_time));
}
break;
case STATE_SELECT_DATE_DISABLED_NO_MARKS:
{
Evas_Object *cal = eina_list_nth(items, 0);
time_t sec_per_day = (60*60*24);
time_t sec_per_year = sec_per_day * 365;
time_t the_time = (sec_per_year * 41) + (sec_per_day * 40); /* Set date to FEB 01, 2011 */
elm_calendar_marks_clear(cal);
elm_calendar_day_selection_enabled_set(cal, EINA_FALSE);
elm_calendar_selected_time_set(cal, gmtime(&the_time));
}
break;
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
/* A simple test, just displaying calendar in it's default state */
TEST_START(test_calendar)
{
Evas_Object *bg, *bx, *bxx, *cal;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
api->data = bx;
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, bx);
cal = elm_calendar_add(win);
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_pack_end(bx, cal);
time_t sec_per_day = (60*60*24);
time_t sec_per_year = sec_per_day * 365;
time_t the_time = (sec_per_year * 41) + (sec_per_day * 9); /* Set date to DEC 31, 2010 */
elm_calendar_selected_time_set(cal, gmtime(&the_time));
elm_calendar_min_max_year_set(cal, 2010, 2010);
evas_object_show(cal);
evas_object_show(win);
}
TEST_END
void
_print_cal_info(Evas_Object *cal, Evas_Object *en)
{
char info[1024];
double interval;
int year_min, year_max;
Eina_Bool sel_enabled;
const char **wds;
struct tm stime;
if (!elm_calendar_selected_time_get(cal, &stime))
return;
interval = elm_calendar_interval_get(cal);
elm_calendar_min_max_year_get(cal, &year_min, &year_max);
sel_enabled = elm_calendar_day_selection_enabled_get(cal);
wds = elm_calendar_weekdays_names_get(cal);
snprintf(info, sizeof(info),
" Day: %i, Mon: %i, Year %i, WeekDay: %i<br>"
" Interval: %0.2f, Year_Min: %i, Year_Max %i, Sel Enabled : %i<br>"
" Weekdays: %s, %s, %s, %s, %s, %s, %s<br>",
stime.tm_mday, stime.tm_mon, stime.tm_year + 1900, stime.tm_wday,
interval, year_min, year_max, sel_enabled,
wds[0], wds[1], wds[2], wds[3], wds[4], wds[5], wds[6]);
elm_entry_entry_set(en, info);
}
static void
_print_cal_info_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
_print_cal_info(obj, data);
}
static char *
_format_month_year(struct tm *stime)
{
char buf[32];
if (!strftime(buf, sizeof(buf), "%b %y", stime)) return NULL;
return strdup(buf);
}
/* A test intended to cover all the calendar api and much use cases as
possible */
TEST_START(test_calendar2)
{
Evas_Object *bg, *bx, *bxh, *bxx, *cal, *cal2, *cal3, *en;
Elm_Calendar_Mark *mark;
struct tm selected_time;
time_t current_time;
const char *weekdays[] =
{
"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"
};
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, EINA_TRUE); /* NOT USED at the Moment */
evas_object_show(api->bt);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bx);
api->data = bx;
elm_box_pack_end(bxx, bx);
bxh = elm_box_add(win);
elm_box_horizontal_set(bxh, EINA_TRUE);
evas_object_size_hint_weight_set(bxh, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bxh, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(bxh);
elm_box_pack_end(bx, bxh);
cal = elm_calendar_add(win);
evas_object_size_hint_weight_set(cal, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(cal, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(cal);
elm_box_pack_end(bx, cal);
cal2 = elm_calendar_add(win);
evas_object_size_hint_weight_set(cal2, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(cal2, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_calendar_day_selection_enabled_set(cal2, EINA_FALSE);
evas_object_show(cal2);
elm_box_pack_end(bxh, cal2);
cal3 = elm_calendar_add(win);
evas_object_size_hint_weight_set(cal3, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(cal3, EVAS_HINT_FILL, EVAS_HINT_FILL);
current_time = time(NULL) + 34 * 84600;
localtime_r(&current_time, &selected_time);
elm_calendar_selected_time_set(cal3, &selected_time);
current_time = time(NULL) + 1 * 84600;
localtime_r(&current_time, &selected_time);
elm_calendar_mark_add(cal3, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
elm_calendar_marks_clear(cal3);
current_time = time(NULL);
localtime_r(&current_time, &selected_time);
elm_calendar_mark_add(cal3, "checked", &selected_time, ELM_CALENDAR_DAILY);
elm_calendar_mark_add(cal3, "holiday", &selected_time, ELM_CALENDAR_DAILY);
elm_calendar_marks_draw(cal3);
evas_object_show(cal3);
elm_box_pack_end(bxh, cal3);
en = elm_entry_add(win);
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(en);
elm_box_pack_end(bx, en);
elm_entry_editable_set(en, EINA_FALSE);
evas_object_show(win);
elm_calendar_min_max_year_set(cal3, -1, -1);
elm_calendar_weekdays_names_set(cal, weekdays);
elm_calendar_interval_set(cal, 0.4);
elm_calendar_format_function_set(cal, _format_month_year);
elm_calendar_min_max_year_set(cal, 2010, 2020);
current_time = time(NULL) + 4 * 84600;
localtime_r(&current_time, &selected_time);
elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_ANNUALLY);
current_time = time(NULL) + 1 * 84600;
localtime_r(&current_time, &selected_time);
elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_UNIQUE);
current_time = time(NULL) - 363 * 84600;
localtime_r(&current_time, &selected_time);
elm_calendar_mark_add(cal, "checked", &selected_time, ELM_CALENDAR_MONTHLY);
current_time = time(NULL) - 5 * 84600;
localtime_r(&current_time, &selected_time);
mark = elm_calendar_mark_add(cal, "holiday", &selected_time,
ELM_CALENDAR_WEEKLY);
current_time = time(NULL) + 1 * 84600;
localtime_r(&current_time, &selected_time);
elm_calendar_mark_add(cal, "holiday", &selected_time, ELM_CALENDAR_WEEKLY);
elm_calendar_mark_del(mark);
elm_calendar_marks_draw(cal);
_print_cal_info(cal, en);
evas_object_smart_callback_add(cal, "changed", _print_cal_info_cb, en);
}
TEST_END

76
src/bin/test_check.c Normal file
View File

@ -0,0 +1,76 @@
#include <Elementary.h>
#include "tsuite.h"
TEST_START(test_check)
{
Evas_Object *bg, *bx, *ic, *ck;
char buf[PATH_MAX];
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
ck = elm_check_add(win);
evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
elm_object_text_set(ck, "Icon sized to check");
elm_object_content_set(ck, ic);
elm_check_state_set(ck, 1);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
ck = elm_check_add(win);
elm_object_text_set(ck, "Icon no scale");
elm_object_content_set(ck, ic);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
evas_object_show(ic);
ck = elm_check_add(win);
elm_object_text_set(ck, "Label Only");
elm_box_pack_end(bx, ck);
evas_object_show(ck);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
ck = elm_check_add(win);
evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
elm_object_text_set(ck, "Disabled check");
elm_object_content_set(ck, ic);
elm_check_state_set(ck, 1);
elm_box_pack_end(bx, ck);
elm_object_disabled_set(ck, 1);
evas_object_show(ck);
evas_object_show(ic);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 0, 0);
ck = elm_check_add(win);
elm_object_content_set(ck, ic);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
evas_object_show(ic);
evas_object_show(win);
}
TEST_END

239
src/bin/test_clock.c Normal file
View File

@ -0,0 +1,239 @@
#include <Elementary.h>
#include "tsuite.h"
enum _api_state
{
CLOCK_HIDE_SEC,
CLOCK_SHOW_AM_PM,
CLOCK_SHOW_SEC,
CLOCK_EDIT_MIN,
CLOCK_EDIT_HOUR,
CLOCK_EDIT_ALL,
CLOCK_EDIT_ALL_ARMY,
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
const Eina_List *items = elm_box_children_get(api->data);
Evas_Object *ck = eina_list_nth(items, 0);
if(!eina_list_count(items))
return;
/* use elm_box_children_get() to get list of children */
switch(api->state)
{ /* Put all api-changes under switch */
case CLOCK_HIDE_SEC:
elm_clock_show_seconds_set(ck, EINA_FALSE);
break;
case CLOCK_SHOW_AM_PM:
elm_clock_show_am_pm_set(ck, EINA_TRUE);
break;
case CLOCK_SHOW_SEC:
elm_clock_show_seconds_set(ck, EINA_TRUE);
break;
case CLOCK_EDIT_MIN:
elm_clock_edit_set(ck, ELM_CLOCK_MIN_DECIMAL | ELM_CLOCK_MIN_UNIT);
break;
case CLOCK_EDIT_HOUR:
elm_clock_edit_set(ck, ELM_CLOCK_NONE);
elm_clock_edit_set(ck, ELM_CLOCK_HOUR_DECIMAL | ELM_CLOCK_HOUR_UNIT);
break;
case CLOCK_EDIT_ALL:
elm_clock_edit_set(ck, ELM_CLOCK_ALL);
break;
case CLOCK_EDIT_ALL_ARMY:
elm_clock_show_am_pm_set(ck, EINA_FALSE);
break;
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
TEST_START(test_clock)
{
Evas_Object *bg, *bx, *bxx, *ck;
unsigned int digedit;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
bx = elm_box_add(win);
elm_win_resize_object_add(win, bx);
api->data = bx;
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, EINA_TRUE);
evas_object_show(api->bt);
elm_box_pack_end(bxx, bx);
ck = elm_clock_add(win);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
ck = elm_clock_add(win);
elm_clock_show_am_pm_set(ck, 1);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
ck = elm_clock_add(win);
elm_clock_show_seconds_set(ck, 1);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
ck = elm_clock_add(win);
elm_clock_show_seconds_set(ck, 1);
elm_clock_show_am_pm_set(ck, 1);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
ck = elm_clock_add(win);
elm_clock_show_seconds_set(ck, 1);
elm_clock_show_am_pm_set(ck, 0);
elm_clock_time_set(ck, 23, 59, 57);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
ck = elm_clock_add(win);
elm_clock_edit_set(ck, 1);
elm_clock_show_seconds_set(ck, 1);
elm_clock_show_am_pm_set(ck, 1);
elm_clock_time_set(ck, 10, 11, 12);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
ck = elm_clock_add(win);
elm_clock_show_seconds_set(ck, 1);
elm_clock_edit_set(ck, 1);
digedit = ELM_CLOCK_HOUR_UNIT | ELM_CLOCK_MIN_UNIT | ELM_CLOCK_SEC_UNIT;
elm_clock_digit_edit_set(ck, digedit);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
evas_object_show(win);
}
TEST_END
static void
_edit_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *ck = data;
if (!elm_clock_edit_get(ck)) {
elm_object_text_set(obj, "Done");
elm_clock_edit_set(ck, 1);
return;
}
elm_object_text_set(obj, "Edit");
elm_clock_edit_set(ck, 0);
}
static void
_hmode_bt_clicked(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *ck = data;
if (!elm_clock_show_am_pm_get(ck)) {
elm_object_text_set(obj, "24h");
elm_clock_show_am_pm_set(ck, 1);
return;
}
elm_object_text_set(obj, "12h");
elm_clock_show_am_pm_set(ck, 0);
}
TEST_START(test_clock2)
{
Evas_Object *bg, *bx, *bxx, *hbx, *ck, *bt;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
bx = elm_box_add(win);
elm_win_resize_object_add(win, bx);
api->data = bx;
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, bx);
ck = elm_clock_add(win);
elm_clock_time_set(ck, 0, 15, 3);
elm_clock_digit_edit_set(ck, ELM_CLOCK_NONE);
elm_clock_show_seconds_set(ck, 1);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
hbx = elm_box_add(win);
evas_object_size_hint_weight_set(hbx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_box_horizontal_set(hbx, EINA_TRUE);
elm_box_pack_end(bx, hbx);
evas_object_show(hbx);
bt = elm_button_add(win);
elm_object_text_set(bt, "Edit");
evas_object_smart_callback_add(bt, "clicked", _edit_bt_clicked, ck);
elm_box_pack_end(hbx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "24h");
evas_object_smart_callback_add(bt, "clicked", _hmode_bt_clicked, ck);
elm_box_pack_end(hbx, bt);
evas_object_show(bt);
evas_object_show(win);
}
TEST_END

View File

@ -0,0 +1,89 @@
#include <Elementary.h>
#include "tsuite.h"
static void
_colorselector_clicked_cb(void *data, Evas_Object *obj, void *event_info __UNUSED__)
{
Evas_Object *re = data;
int r, g, b, a;
elm_colorselector_color_get(obj, &r, &g, &b, &a);
printf("Current Color [r=%d g=%d b=%d a=%d]\n",r, g, b, a);
/* Fix Alpha pre multiplication by edje */
r = (r * a) / 255;
g = (g * a) / 255;
b = (b * a) / 255;
evas_object_color_set(re, r, g, b, a);
}
TEST_START(test_colorselector)
{
Evas_Object *bg, *bx, *cp, *fr, *ly, *re;
char buf[PATH_MAX];
int r, g, b, a;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_color_set(bg, 255, 255, 255, 255);
evas_object_show(bg);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
fr = elm_frame_add(win);
evas_object_size_hint_weight_set(fr, 1.0, 0.5);
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_text_set(fr, "Color View");
elm_box_pack_end(bx, fr);
evas_object_show(fr);
ly = elm_layout_add(win);
snprintf(buf, sizeof(buf), "%s/objects/colorpreview.edj", elm_app_data_dir_get());
elm_layout_file_set(ly, buf, "main");
evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_content_set(fr, ly);
evas_object_show(ly);
re = evas_object_rectangle_add(evas_object_evas_get(win));
evas_object_show(re);
elm_object_part_content_set(ly, "ColorPreview", re);
fr = elm_frame_add(win);
evas_object_size_hint_weight_set(fr, 1.0, 0);
evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, 0);
elm_object_text_set(fr, "Color Selector");
elm_box_pack_end(bx, fr);
evas_object_show(fr);
cp = elm_colorselector_add(win);
a = 180;
r = 255;
g = 160;
b = 132;
elm_colorselector_color_set(cp, r, g, b, a);
evas_object_size_hint_weight_set(cp, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(cp, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(fr, cp);
evas_object_show(cp);
evas_object_smart_callback_add(cp, "changed", _colorselector_clicked_cb, re);
elm_colorselector_color_get(cp, &r, &g, &b, &a);
/* Fix Alpha pre multiplication by edje */
r = (r * a) / 255;
g = (g * a) / 255;
b = (b * a) / 255;
evas_object_color_set(re, r, g, b, a);
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
TEST_END

200
src/bin/test_conform.c Normal file
View File

@ -0,0 +1,200 @@
#include <Elementary.h>
#include "tsuite.h"
TEST_START(test_conformant)
{
Evas_Object *bg, *conform, *btn, *bx, *en;
elm_win_conformant_set(win, 1);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
conform = elm_conformant_add(win);
elm_win_resize_object_add(win, conform);
evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(conform);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
en = elm_entry_add(win);
elm_entry_scrollable_set(en, EINA_TRUE);
elm_entry_single_line_set(en, 1);
elm_entry_bounce_set(en, 1, 0);
elm_entry_entry_set(en, "This is the top entry here");
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
evas_object_show(en);
elm_box_pack_end(bx, en);
btn = elm_button_add(win);
elm_object_text_set(btn, "Test Conformant");
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, btn);
evas_object_show(btn);
en = elm_entry_add(win);
elm_entry_scrollable_set(en, EINA_TRUE);
elm_entry_single_line_set(en, 1);
elm_entry_bounce_set(en, 1, 0);
elm_entry_entry_set(en, "This is the middle entry here");
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
evas_object_show(en);
elm_box_pack_end(bx, en);
btn = elm_button_add(win);
elm_object_text_set(btn, "Test Conformant");
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, btn);
evas_object_show(btn);
en = elm_entry_add(win);
elm_entry_scrollable_set(en, EINA_TRUE);
elm_entry_bounce_set(en, 0, 1);
elm_entry_entry_set(en,
"This is a multi-line entry at the bottom<br>"
"This can contain more than 1 line of text and be "
"scrolled around to allow for entering of lots of "
"content. It is also to test to see that autoscroll "
"moves to the right part of a larger multi-line "
"text entry that is inside of a scroller than can be "
"scrolled around, thus changing the expected position "
"as well as cursor changes updating auto-scroll when "
"it is enabled.");
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(en);
elm_box_pack_end(bx, en);
elm_object_content_set(conform, bx);
evas_object_show(bx);
evas_object_resize(win, 240, 240);
evas_object_show(win);
}
TEST_END
static void
popobj(void *data, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
{
elm_pager_content_pop(data);
}
TEST_START(test_conformant2)
{
Evas_Object *bg, *conform, *btn, *bx, *en, *pg;
elm_win_conformant_set(win, 1);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
en = elm_entry_add(win);
elm_entry_scrollable_set(en, EINA_TRUE);
elm_entry_single_line_set(en, 1);
elm_entry_bounce_set(en, 1, 0);
elm_entry_entry_set(en, "This is the top entry here");
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, en);
evas_object_show(en);
btn = elm_button_add(win);
elm_object_focus_allow_set(btn, 0);
elm_object_text_set(btn, "Delete Below");
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, btn);
evas_object_show(btn);
pg = elm_pager_add(win);
evas_object_size_hint_weight_set(pg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(pg, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, pg);
evas_object_show(pg);
evas_object_smart_callback_add(btn, "clicked", popobj, pg);
conform = elm_conformant_add(win);
evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_pager_content_push(pg, conform);
evas_object_show(conform);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
en = elm_entry_add(win);
elm_entry_scrollable_set(en, EINA_TRUE);
elm_entry_bounce_set(en, 0, 1);
elm_entry_entry_set(en, "This entry and button below get deleted.");
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(en);
elm_box_pack_end(bx, en);
btn = elm_button_add(win);
elm_object_focus_allow_set(btn, 0);
elm_object_text_set(btn, "Delete this bottom bit 1");
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, btn);
evas_object_show(btn);
evas_object_smart_callback_add(btn, "clicked", popobj, pg);
elm_object_content_set(conform, bx);
evas_object_show(bx);
conform = elm_conformant_add(win);
evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_pager_content_push(pg, conform);
evas_object_show(conform);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
en = elm_entry_add(win);
elm_entry_scrollable_set(en, EINA_TRUE);
elm_entry_bounce_set(en, 0, 1);
elm_entry_entry_set(en, "This entry and button below get deleted.");
evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(en);
elm_box_pack_end(bx, en);
btn = elm_button_add(win);
elm_object_focus_allow_set(btn, 0);
elm_object_text_set(btn, "Delete this bottom bit 2");
evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, btn);
evas_object_show(btn);
evas_object_smart_callback_add(btn, "clicked", popobj, pg);
elm_object_content_set(conform, bx);
evas_object_show(bx);
evas_object_resize(win, 240, 480);
evas_object_show(win);
}
TEST_END

240
src/bin/test_ctxpopup.c Normal file
View File

@ -0,0 +1,240 @@
#include <Elementary.h>
#include "tsuite.h"
static void
_dismissed(void *data __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
{
evas_object_del(obj);
}
static void
_print_current_dir(Evas_Object *obj)
{
Elm_Ctxpopup_Direction dir;
dir = elm_ctxpopup_direction_get(obj);
switch(dir)
{
case ELM_CTXPOPUP_DIRECTION_LEFT:
printf("ctxpopup direction: left!\n");
break;
case ELM_CTXPOPUP_DIRECTION_RIGHT:
printf("ctxpopup direction: right!\n");
break;
case ELM_CTXPOPUP_DIRECTION_UP:
printf("ctxpopup direction: up!\n");
break;
case ELM_CTXPOPUP_DIRECTION_DOWN:
printf("ctxpopup direction: down!\n");
break;
case ELM_CTXPOPUP_DIRECTION_UNKNOWN:
printf("ctxpopup direction: unknow!\n");
break;
}
}
static void
_ctxpopup_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
printf("ctxpopup item selected: %s\n",
elm_ctxpopup_item_label_get(event_info));
}
#define ITEM_NEW(_hov, _label, _icon) \
if(_icon) \
{ \
ic = elm_icon_add(obj); \
elm_icon_standard_set(ic, _icon); \
elm_icon_scale_set(ic, EINA_FALSE, EINA_FALSE); \
} \
else \
ic = NULL; \
it = elm_ctxpopup_item_append(_hov, _label, ic, _ctxpopup_item_cb, NULL); \
static void
_list_item_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Object_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup,
"dismissed",
_dismissed,
NULL);
ITEM_NEW(ctxpopup, "Go to home folder", "home");
ITEM_NEW(ctxpopup, "Save file", "file");
ITEM_NEW(ctxpopup, "Delete file", "delete");
ITEM_NEW(ctxpopup, "Navigate to folder", "folder");
elm_object_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(ctxpopup, "Edit entry", "edit");
ITEM_NEW(ctxpopup, "Set date and time", "clock");
elm_object_item_disabled_set(it, EINA_TRUE);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
_print_current_dir(ctxpopup);
}
static void
_list_item_cb2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Object_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup,
"dismissed",
_dismissed,
NULL);
ITEM_NEW(ctxpopup, NULL, "home");
ITEM_NEW(ctxpopup, NULL, "file");
ITEM_NEW(ctxpopup, NULL, "delete");
ITEM_NEW(ctxpopup, NULL, "folder");
ITEM_NEW(ctxpopup, NULL, "edit");
elm_object_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(ctxpopup, NULL, "clock");
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
_print_current_dir(ctxpopup);
}
static void
_list_item_cb3(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Object_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup,
"dismissed",
_dismissed,
NULL);
ITEM_NEW(ctxpopup, "Eina", NULL);
ITEM_NEW(ctxpopup, "Eet", NULL);
ITEM_NEW(ctxpopup, "Evas", NULL);
ITEM_NEW(ctxpopup, "Ecore", NULL);
elm_object_item_disabled_set(it, EINA_TRUE);
ITEM_NEW(ctxpopup, "Embryo", NULL);
ITEM_NEW(ctxpopup, "Edje", NULL);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
_print_current_dir(ctxpopup);
}
static void
_list_item_cb4(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *ic;
Elm_Object_Item *it;
Evas_Coord x,y;
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup,
"dismissed",
_dismissed,
NULL);
elm_ctxpopup_horizontal_set(ctxpopup, EINA_TRUE);
ITEM_NEW(ctxpopup, NULL, "home");
ITEM_NEW(ctxpopup, NULL, "file");
ITEM_NEW(ctxpopup, NULL, "delete");
ITEM_NEW(ctxpopup, NULL, "folder");
ITEM_NEW(ctxpopup, NULL, "edit");
ITEM_NEW(ctxpopup, NULL, "clock");
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_size_hint_max_set(ctxpopup, 240, 240);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
_print_current_dir(ctxpopup);
}
static void
_list_item_cb5(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{
Evas_Object *ctxpopup, *btn, *sc, *bx;
Evas_Coord x,y;
bx = elm_box_add(obj);
evas_object_size_hint_min_set(bx, 150, 150);
sc = elm_scroller_add(bx);
elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
evas_object_size_hint_fill_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(sc);
btn = elm_button_add(sc);
elm_object_text_set(btn, "Enlightenment");
evas_object_size_hint_min_set(btn, 140, 140);
elm_object_content_set(sc, btn);
elm_box_pack_end(bx, sc);
ctxpopup = elm_ctxpopup_add(obj);
evas_object_smart_callback_add(ctxpopup,
"dismissed",
_dismissed,
NULL);
elm_object_content_set(ctxpopup, bx);
evas_pointer_canvas_xy_get(evas_object_evas_get(obj), &x, &y);
evas_object_move(ctxpopup, x, y);
evas_object_show(ctxpopup);
_print_current_dir(ctxpopup);
}
static void _list_clicked(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
elm_list_item_selected_set(event_info, EINA_FALSE);
}
TEST_START(test_ctxpopup)
{
Evas_Object *bg, *list;
bg = elm_bg_add(win);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bg);
evas_object_show(bg);
list = elm_list_add(win);
elm_win_resize_object_add(win, list);
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_list_mode_set(list, ELM_LIST_COMPRESS);
evas_object_smart_callback_add(list, "selected", _list_clicked, NULL);
#undef ITEM_NEW
elm_list_item_append(list, "Ctxpopup with icons and labels", NULL, NULL,
_list_item_cb, NULL);
elm_list_item_append(list, "Ctxpopup with icons only", NULL, NULL,
_list_item_cb2, NULL);
elm_list_item_append(list, "Ctxpopup with labels only", NULL, NULL,
_list_item_cb3, NULL);
elm_list_item_append(list, "Ctxpopup at horizontal mode", NULL, NULL,
_list_item_cb4, NULL);
elm_list_item_append(list, "Ctxpopup with user content", NULL, NULL,
_list_item_cb5, NULL);
evas_object_show(list);
elm_list_go(list);
evas_object_resize(win, 400, 400);
evas_object_show(win);
}
TEST_END

450
src/bin/test_cursor.c Normal file
View File

@ -0,0 +1,450 @@
#include <Elementary.h>
#include <Elementary_Cursor.h>
#include "tsuite.h"
typedef struct _Testitem
{
Elm_Gengrid_Item *item;
const char *path;
int mode;
int onoff;
} Testitem;
static Elm_Gengrid_Item_Class gic;
char *
grd_lbl_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
{
const Testitem *ti = data;
char buf[256];
snprintf(buf, sizeof(buf), "Photo %s", ti->path);
return strdup(buf);
}
Evas_Object *
grd_content_get(void *data, Evas_Object *obj, const char *part)
{
const Testitem *ti = data;
if (!strcmp(part, "elm.swallow.icon"))
{
Evas_Object *icon = elm_bg_add(obj);
elm_bg_file_set(icon, ti->path, NULL);
evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL,
1, 1);
evas_object_show(icon);
return icon;
}
return NULL;
}
static Elm_Genlist_Item_Class itct;
static void
glt_exp(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
Elm_Genlist_Item *it = event_info;
Evas_Object *gl = elm_genlist_item_genlist_get(it);
int val = (int)(long)elm_genlist_item_data_get(it);
Elm_Genlist_Item *it1, *it2, *it3;
val *= 10;
it1 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 1), it,
ELM_GENLIST_ITEM_NONE, NULL, NULL);
it2 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 2), it,
ELM_GENLIST_ITEM_NONE, NULL, NULL);
it3 = elm_genlist_item_append(gl, &itct, (void *)(long)(val + 3), it,
ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
elm_genlist_item_cursor_set(it1, ELM_CURSOR_HAND2);
elm_genlist_item_cursor_set(it2, ELM_CURSOR_HAND2);
elm_genlist_item_cursor_set(it3, ELM_CURSOR_HAND1);
}
static void
glt_con(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
Elm_Genlist_Item *it = event_info;
elm_genlist_item_subitems_clear(it);
}
static void
glt_exp_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
Elm_Genlist_Item *it = event_info;
elm_genlist_item_expanded_set(it, 1);
}
static void
glt_con_req(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
Elm_Genlist_Item *it = event_info;
elm_genlist_item_expanded_set(it, 0);
}
char *
glt_text_get(void *data, Evas_Object *obj __UNUSED__, const char *part __UNUSED__)
{
char buf[256];
snprintf(buf, sizeof(buf), "Item mode %i", (int)(long)data);
return strdup(buf);
}
TEST_START(test_cursor)
{
Evas_Object *bg, *bx, *bt, *list, *entry, *ck;
Elm_List_Item *lit;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
elm_object_cursor_set(bg, ELM_CURSOR_CIRCLE);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
ck = elm_clock_add(win);
elm_object_cursor_set(ck, ELM_CURSOR_CLOCK);
elm_box_pack_end(bx, ck);
evas_object_show(ck);
bt = elm_button_add(win);
elm_object_cursor_set(bt, ELM_CURSOR_COFFEE_MUG);
elm_object_text_set(bt, "Coffee Mug");
elm_box_pack_end(bx, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_cursor_set(bt, ELM_CURSOR_CLOCK);
elm_object_text_set(bt, "Cursor unset");
elm_object_cursor_unset(bt);
elm_box_pack_end(bx, bt);
evas_object_show(bt);
list = elm_list_add(win);
elm_box_pack_end(bx, list);
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_cursor_set(list, ELM_CURSOR_WATCH);
lit = elm_list_item_append(list, "watch over list | hand1", NULL, NULL, NULL,
NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_HAND1);
lit = elm_list_item_append(list, "watch over list | hand2", NULL, NULL, NULL,
NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_HAND2);
elm_list_go(list);
evas_object_show(list);
entry = elm_entry_add(win);
elm_entry_scrollable_set(entry, EINA_TRUE);
elm_entry_entry_set(entry, "Xterm cursor");
elm_entry_single_line_set(entry, EINA_TRUE);
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0);
evas_object_size_hint_fill_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(bx, entry);
evas_object_show(entry);
elm_object_cursor_set(entry, ELM_CURSOR_XTERM);
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
TEST_END
TEST_START(test_cursor2)
{
Evas_Object *bg, *bx, *o, *grid, *gl;
Elm_Genlist_Item *it1, *it2, *it3;
Elm_Object_Item *tb_it;
Elm_List_Item *lit;
char buf[PATH_MAX];
static Testitem ti[144];
int i, n;
const char *img[9] =
{
"panel_01.jpg",
"plant_01.jpg",
"rock_01.jpg",
"rock_02.jpg",
"sky_01.jpg",
"sky_02.jpg",
"sky_03.jpg",
"sky_04.jpg",
"wood_01.jpg",
};
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
o = elm_toolbar_add(win);
elm_toolbar_homogeneous_set(o, 0);
evas_object_size_hint_weight_set(o, 0.0, 0.0);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL, 0.0);
tb_it = elm_toolbar_item_append(o, NULL, "Bogosity", NULL, NULL);
elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
tb_it = elm_toolbar_item_append(o, NULL, "Unset", NULL, NULL);
elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_BOGOSITY);
elm_toolbar_item_cursor_unset(tb_it);
tb_it = elm_toolbar_item_append(o, NULL, "Xterm", NULL, NULL);
elm_toolbar_item_cursor_set(tb_it, ELM_CURSOR_XTERM);
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_list_add(win);
elm_box_pack_end(bx, o);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
lit = elm_list_item_append(o, "cursor bogosity", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
lit = elm_list_item_append(o, "cursor unset", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_BOGOSITY);
elm_list_item_cursor_unset(lit);
lit = elm_list_item_append(o, "cursor xterm", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_XTERM);
elm_list_go(o);
evas_object_show(o);
gl = elm_genlist_add(win);
evas_object_size_hint_align_set(gl, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(gl, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(gl);
itct.item_style = "default";
itct.func.text_get = glt_text_get;
it1 = elm_genlist_item_append(gl, &itct, (void *) 1, NULL,
ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
it2 = elm_genlist_item_append(gl, &itct, (void *) 2, NULL,
ELM_GENLIST_ITEM_SUBITEMS, NULL, NULL);
it3 = elm_genlist_item_append(gl, &itct, (void *) 3, NULL,
ELM_GENLIST_ITEM_NONE, NULL, NULL);
elm_genlist_item_cursor_set(it1, ELM_CURSOR_HAND1);
elm_genlist_item_cursor_set(it2, ELM_CURSOR_HAND1);
elm_genlist_item_cursor_set(it3, ELM_CURSOR_CROSS);
evas_object_smart_callback_add(gl, "expand,request", glt_exp_req, gl);
evas_object_smart_callback_add(gl, "contract,request", glt_con_req, gl);
evas_object_smart_callback_add(gl, "expanded", glt_exp, gl);
evas_object_smart_callback_add(gl, "contracted", glt_con, gl);
elm_box_pack_end(bx, gl);
grid = elm_gengrid_add(win);
elm_gengrid_item_size_set(grid, 130, 130);
elm_gengrid_horizontal_set(grid, EINA_FALSE);
elm_gengrid_multi_select_set(grid, EINA_TRUE);
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
gic.item_style = "default";
gic.func.text_get = grd_lbl_get;
gic.func.content_get = grd_content_get;
n = 0;
for (i = 0; i < 3 * 3; i++)
{
snprintf(buf, sizeof(buf), "%s/images/%s", elm_app_data_dir_get(), img[n]);
n = (n + 1) % 9;
ti[i].mode = i;
ti[i].path = eina_stringshare_add(buf);
ti[i].item = elm_gengrid_item_append(grid, &gic, &(ti[i]), NULL, NULL);
if (n % 2)
elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_HAND1);
else
elm_gengrid_item_cursor_set(ti[i].item, ELM_CURSOR_CLOCK);
if (!(i % 5))
elm_gengrid_item_selected_set(ti[i].item, EINA_TRUE);
}
elm_box_pack_end(bx, grid);
evas_object_show(grid);
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
TEST_END
TEST_START(test_cursor3)
{
Evas_Object *bg, *bx, *o;
Elm_List_Item *lit;
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
elm_theme_extension_add(NULL, buf);
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
o = elm_button_add(win);
elm_object_cursor_set(o, ELM_CURSOR_HAND1);
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_object_text_set(o, "hand1");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, ELM_CURSOR_HAND2);
elm_object_text_set(o, "hand2 x");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, ELM_CURSOR_HAND2);
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_object_text_set(o, "hand2");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, "hand3");
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_object_text_set(o, "hand3");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, "hand3");
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_object_cursor_style_set(o, "transparent");
elm_object_text_set(o, "hand3 transparent");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, "hand3");
elm_object_cursor_engine_only_set(o, EINA_FALSE);
elm_object_cursor_unset(o);
elm_object_text_set(o, "unset");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_button_add(win);
elm_object_cursor_set(o, "hand4");
elm_object_text_set(o, "not existent");
elm_box_pack_end(bx, o);
evas_object_show(o);
elm_cursor_engine_only_set(0);
o = elm_button_add(win);
elm_object_cursor_set(o, "hand2");
elm_object_text_set(o, "hand 2 engine only config false");
elm_box_pack_end(bx, o);
evas_object_show(o);
elm_cursor_engine_only_set(1);
o = elm_button_add(win);
elm_object_cursor_set(o, "hand2");
elm_object_text_set(o, "hand 2 engine only config true");
elm_box_pack_end(bx, o);
evas_object_show(o);
o = elm_list_add(win);
elm_box_pack_end(bx, o);
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_fill_set(o, EVAS_HINT_FILL, EVAS_HINT_FILL);
lit = elm_list_item_append(o, "cursor hand2 x", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_HAND2);
lit = elm_list_item_append(o, "cursor hand2", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, ELM_CURSOR_HAND2);
elm_list_item_cursor_engine_only_set(lit, EINA_FALSE);
lit = elm_list_item_append(o, "cursor hand3", NULL, NULL, NULL, NULL);
elm_list_item_cursor_set(lit, "hand3");
elm_list_item_cursor_engine_only_set(lit, EINA_FALSE);
lit = elm_list_item_append(o, "cursor hand3 transparent", NULL, NULL,
NULL, NULL);
elm_list_item_cursor_set(lit, "hand3");
elm_list_item_cursor_style_set(lit, "transparent");
elm_list_item_cursor_engine_only_set(lit, EINA_FALSE);
elm_list_go(o);
evas_object_show(o);
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
TEST_END
TEST_START(test_cursor4)
{
Evas_Object *win, *bg, *bx, *ly, *bt;
char buf[PATH_MAX];
win = elm_win_add(NULL, "cursor layout", ELM_WIN_BASIC);
elm_win_title_set(win, "Cursor Layout");
elm_win_autodel_set(win, EINA_TRUE);
snprintf(buf, sizeof(buf), "%s/objects/cursors.edj", elm_app_data_dir_get());
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bx = elm_box_add(win);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_win_resize_object_add(win, bx);
evas_object_show(bx);
ly = elm_layout_add(win);
elm_layout_file_set(ly, buf, "test/layout/events");
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_cursor_set(ly, ELM_CURSOR_HAND1);
elm_box_pack_end(bx, ly);
evas_object_show(ly);
ly = elm_layout_add(win);
elm_layout_file_set(ly, buf, "test/layout/noevents");
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_cursor_set(ly, ELM_CURSOR_XTERM);
elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
elm_box_pack_end(bx, ly);
evas_object_show(ly);
ly = elm_layout_add(win);
elm_layout_file_set(ly, buf, "test/layout/parts2");
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_layout_part_cursor_set(ly, "top-left", ELM_CURSOR_CROSS);
elm_layout_part_cursor_set(ly, "bottom-left", ELM_CURSOR_PIRATE);
elm_layout_file_set(ly, buf, "test/layout/parts");
elm_box_pack_end(bx, ly);
evas_object_show(ly);
ly = elm_layout_add(win);
evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ly, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_layout_file_set(ly, buf, "test/layout/swallow");
bt = elm_button_add(win);
elm_object_text_set(bt, "Cursor over obj");
elm_object_part_content_set(ly, "swallow1", bt);
elm_object_cursor_set(bt, ELM_CURSOR_PIRATE);
bt = elm_button_add(win);
elm_object_text_set(bt, "Cursor over part");
elm_object_part_content_set(ly, "swallow2", bt);
elm_layout_part_cursor_set(ly, "swallow2", ELM_CURSOR_PIRATE);
elm_box_pack_end(bx, ly);
evas_object_show(ly);
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
TEST_END

333
src/bin/test_diskselector.c Normal file
View File

@ -0,0 +1,333 @@
#include <Elementary.h>
#include <Elementary_Cursor.h>
#include "tsuite.h"
static void
_disk_sel(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info)
{
Elm_Diskselector_Item *it = event_info;
printf("Equinox: %s\n", elm_diskselector_item_label_get(it));
}
static void
_disk_next(void *data __UNUSED__, Evas_Object * obj __UNUSED__, void *event_info)
{
Elm_Diskselector_Item *next, *prev, *it = event_info;
prev = elm_diskselector_item_prev_get(it);
next = elm_diskselector_item_next_get(it);
printf("Prev: %s, Next: %s\n", elm_diskselector_item_label_get(prev),
elm_diskselector_item_label_get(next));
}
static void
_print_disk_info_cb(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
{
Elm_Diskselector_Item *it = event_info;
printf("Selected label: %s\n", elm_diskselector_item_label_get(it));
}
static Evas_Object *
_disk_create(Evas_Object *win, Eina_Bool round)
{
Elm_Diskselector_Item *it;
Evas_Object *di;
di = elm_diskselector_add(win);
elm_diskselector_item_append(di, "January", NULL, NULL, NULL);
elm_diskselector_item_append(di, "February", NULL, _disk_next, NULL);
elm_diskselector_item_append(di, "March", NULL, _disk_sel, NULL);
elm_diskselector_item_append(di, "April", NULL, NULL, NULL);
elm_diskselector_item_append(di, "May", NULL, NULL, NULL);
elm_diskselector_item_append(di, "June", NULL, NULL, NULL);
elm_diskselector_item_append(di, "July", NULL, NULL, NULL);
it = elm_diskselector_item_append(di, "August", NULL, NULL, NULL);
elm_diskselector_item_append(di, "September", NULL, _disk_sel, NULL);
elm_diskselector_item_append(di, "October", NULL, NULL, NULL);
elm_diskselector_item_append(di, "November", NULL, NULL, NULL);
elm_diskselector_item_append(di, "December", NULL, NULL, NULL);
elm_diskselector_item_selected_set(it, EINA_TRUE);
elm_diskselector_round_set(di, round);
return di;
}
enum _api_state
{
SCROLLER_POLICY_SET_ON,
SCROLLER_POLICY_SET_OFF,
BOUNCE_SET,
ITEM_LABEL_SET,
TOOLTIP_TEXT_SET,
ITEM_TOOLTIP_UNSET,
ITEM_CURSOR_SET,
ITEM_CURSOR_UNSET,
ITEM_ICON_SET,
SELECTED_SET,
ITEM_PREV_GET,
ITEM_DEL_NOT_SELECTED,
ITEM_DEL, /* delete when selected */
CLEAR,
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
const Eina_List *disks = elm_box_children_get(api->data);
if(!eina_list_count(disks))
return;
switch(api->state)
{ /* Put all api-changes under switch */
case SCROLLER_POLICY_SET_ON: /* 0 */
{ /* Get first disk */
Evas_Object *disk = eina_list_nth(disks, 0);
elm_diskselector_scroller_policy_set(disk, ELM_SCROLLER_POLICY_ON, ELM_SCROLLER_POLICY_ON);
}
break;
case SCROLLER_POLICY_SET_OFF: /* 1 */
{ /* Get first disk */
Evas_Object *disk = eina_list_nth(disks, 0);
elm_diskselector_scroller_policy_set(disk, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
}
break;
case BOUNCE_SET: /* 2 */
{ /* Get second disk, cancel bounce */
Evas_Object *disk = eina_list_nth(disks, 1);
elm_diskselector_bounce_set(disk, EINA_FALSE, EINA_FALSE);
}
break;
case ITEM_LABEL_SET: /* 3 */
elm_diskselector_item_label_set(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)), "Label from API");
break;
case TOOLTIP_TEXT_SET: /* 4 */
elm_diskselector_item_tooltip_text_set(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)), "Tooltip from API");
break;
case ITEM_TOOLTIP_UNSET: /* 5 */
elm_diskselector_item_tooltip_unset(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)));
break;
case ITEM_CURSOR_SET: /* 6 */
elm_diskselector_item_cursor_set(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)), ELM_CURSOR_HAND2);
break;
case ITEM_CURSOR_UNSET: /* 7 */
elm_diskselector_item_cursor_unset(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)));
break;
case ITEM_ICON_SET: /* 8 */
{ /* Set icon of selected item in first disk */
char buf[PATH_MAX];
Evas_Object *ic = elm_icon_add(elm_object_parent_widget_get(eina_list_nth(disks, 0)));
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_diskselector_item_icon_set(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)), ic);
evas_object_show(ic);
}
break;
case SELECTED_SET: /* 9 */
{ /* Select NEXT item of first disk */
elm_diskselector_item_selected_set(elm_diskselector_item_next_get(elm_diskselector_selected_item_get(eina_list_nth(disks, 0))), EINA_TRUE);
}
break;
case ITEM_PREV_GET: /* 10 */
{ /* Select PREV item of first disk */
elm_diskselector_item_selected_set(elm_diskselector_item_prev_get(elm_diskselector_selected_item_get(eina_list_nth(disks, 0))), EINA_TRUE);
}
break;
case ITEM_DEL_NOT_SELECTED: /* 11 */
{ /* Remove selected item of first disk */
elm_diskselector_item_del(elm_diskselector_item_prev_get(elm_diskselector_selected_item_get(eina_list_nth(disks, 0))));
}
break;
case ITEM_DEL: /* 12 */
{ /* Remove selected item of first disk */
elm_diskselector_item_del(elm_diskselector_selected_item_get(eina_list_nth(disks, 0)));
}
break;
case CLEAR: /* 13 */
elm_diskselector_clear(eina_list_nth(disks, 0));
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
TEST_START(test_diskselector)
{
Evas_Object *bg, *bx, *bxx, *disk, *ic;
Elm_Diskselector_Item *it;
char buf[PATH_MAX];
int idx = 0;
char *month_list[] = {
"Jan", "Feb", "Mar",
"Apr", "May", "Jun",
"Jul", "Aug", "Sep",
"Oct", "Nov", "Dec"
};
char date[3];
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
bx = elm_box_add(win);
elm_win_resize_object_add(win, bx);
evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
api->data = bx;
evas_object_show(bx);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, bx);
disk = _disk_create(win, EINA_TRUE);
evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, disk);
evas_object_show(disk);
evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
it = elm_diskselector_selected_item_get(disk);
elm_diskselector_item_selected_set(it, EINA_FALSE);
disk = _disk_create(win, EINA_FALSE);
evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, disk);
evas_object_show(disk);
evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
it = elm_diskselector_first_item_get(disk);
it = elm_diskselector_item_next_get(it);
elm_diskselector_item_selected_set(it, EINA_TRUE);
disk = _disk_create(win, EINA_FALSE);
evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, disk);
evas_object_show(disk);
evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
elm_diskselector_side_label_length_set(disk, 4);
disk = elm_diskselector_add(win);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 1, 1);
elm_diskselector_item_append(disk, "Sunday", ic, NULL, NULL);
elm_diskselector_item_append(disk, "Monday", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "Tuesday", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "Wednesday", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "Thursday", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "Friday", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "Saturday", NULL, NULL, NULL);
elm_diskselector_round_set(disk, EINA_TRUE);
evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, disk);
evas_object_show(disk);
evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
disk = elm_diskselector_add(win);
ic = elm_icon_add(win);
snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
elm_icon_file_set(ic, buf, NULL);
elm_icon_scale_set(ic, 1, 1);
elm_diskselector_item_append(disk, "머리스타일", ic, NULL, NULL);
elm_diskselector_item_append(disk, "プロが伝授する", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "生上访要求政府", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "English", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "والشريعة", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "עִבְרִית", NULL, NULL, NULL);
elm_diskselector_item_append(disk, "Grüßen", NULL, NULL, NULL);
elm_diskselector_round_set(disk, EINA_TRUE);
evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, disk);
evas_object_show(disk);
evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
// displayed item number setting example
disk = elm_diskselector_add(win);
elm_diskselector_display_item_num_set(disk, 5);
printf("Number of Items in DiskSelector : %d\n", elm_diskselector_display_item_num_get(disk));
for (idx = 0; idx < (int)(sizeof(month_list) / sizeof(month_list[0])); idx++)
{
it = elm_diskselector_item_append(disk, month_list[idx], NULL, NULL, NULL);
}
elm_diskselector_item_selected_set(it, EINA_TRUE);
elm_diskselector_round_set(disk, EINA_TRUE);
evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, disk);
evas_object_show(disk);
evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
// displayed item number setting example
disk = elm_diskselector_add(win);
elm_diskselector_display_item_num_set(disk, 7);
printf("Number of Items in DiskSelector : %d\n", elm_diskselector_display_item_num_get(disk));
for (idx = 1; idx < 31; idx++)
{
snprintf(date, sizeof(date), "%d", idx);
it = elm_diskselector_item_append(disk, date, NULL, NULL, NULL);
}
elm_diskselector_item_selected_set(it, EINA_TRUE);
elm_diskselector_round_set(disk, EINA_TRUE);
evas_object_size_hint_weight_set(disk, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(disk, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, disk);
evas_object_show(disk);
evas_object_smart_callback_add(disk, "selected", _print_disk_info_cb, NULL);
evas_object_resize(win, 320, 480);
evas_object_show(win);
}
TEST_END

1673
src/bin/test_entry.c Normal file

File diff suppressed because it is too large Load Diff

281
src/bin/test_fileselector.c Normal file
View File

@ -0,0 +1,281 @@
#include <Elementary.h>
#include "tsuite.h"
static void
my_fileselector_done(void *data __UNUSED__,
Evas_Object *obj __UNUSED__,
void *event_info)
{
/* event_info conatin the full path of the selected file
* or NULL if none is selected or cancel is pressed */
const char *selected = event_info;
if (selected)
printf("Selected file: %s\n", selected);
/* else test window deleted in tsuite_cleanup
evas_object_del(data); delete the test window */
}
static void
my_fileselector_selected(void *data __UNUSED__,
Evas_Object *obj,
void *event_info)
{
/* event_info conatin the full path of the selected file */
const char *selected = event_info;
printf("Selected file: %s\n", selected);
/* or you can query the selection */
printf("or: %s\n", elm_fileselector_selected_get(obj));
}
static void
_is_save_clicked(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs = data;
printf("Toggle Is save\n");
if (elm_fileselector_is_save_get(fs))
elm_fileselector_is_save_set(fs, EINA_FALSE);
else
elm_fileselector_is_save_set(fs, EINA_TRUE);
}
static void
_folder_only_clicked(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs = data;
printf("Toggle Folder only\n");
if (elm_fileselector_folder_only_get(fs))
elm_fileselector_folder_only_set(fs, EINA_FALSE);
else
elm_fileselector_folder_only_set(fs, EINA_TRUE);
}
static void
_expandable_clicked(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs = data;
printf("Toggle Expandable\n");
if (elm_fileselector_expandable_get(fs))
elm_fileselector_expandable_set(fs, EINA_FALSE);
else
elm_fileselector_expandable_set(fs, EINA_TRUE);
}
static void
_sel_get_clicked(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs = data;
printf("Get Selected: %s\n", elm_fileselector_selected_get(fs));
}
static void
_path_get_clicked(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs = data;
printf("Get Path: %s\n", elm_fileselector_path_get(fs));
}
static void
_mode_cycle_clicked(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs = data;
Elm_Fileselector_Mode mode;
mode = (elm_fileselector_mode_get(fs) + 1) % ELM_FILESELECTOR_LAST;
elm_fileselector_mode_set(fs, mode);
printf("Setting mode to: %d\n", mode);
}
enum _api_state
{
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
const Eina_List *items = elm_box_children_get(api->data);
if(!eina_list_count(items))
return;
/* Get first item of list of vbox children
Evas_Object *fs_bt = eina_list_nth(items, 0); */
/* use elm_box_children_get() to get list of children */
switch(api->state)
{ /* Put all api-changes under switch */
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
static void
create_dir_struct(void)
{
FILE *fp;
mkdir("/tmp/test_fs_bt", S_IRWXU);
fp = fopen("/tmp/test_fs_bt/a_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/k_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/m_file.txt", "w");
if (fp) fclose(fp);
mkdir("/tmp/test_fs_bt/a_subdir", S_IRWXU);
fp = fopen("/tmp/test_fs_bt/a_subdir/d_sub_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/a_subdir/j_sub_file.txt", "w");
if (fp) fclose(fp);
}
TEST_START(test_fileselector)
{
Evas_Object *fs, *bg, *vbox, *hbox, *bxx, *bt, *sep;
/* Set the locale according to the system pref.
* If you dont do so the file selector will order the files list in
* a case sensitive manner
*/
setlocale(LC_ALL, "");
elm_need_ethumb();
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
vbox = elm_box_add(win);
api->data = vbox;
// elm_win_resize_object_add(win, vbox);
evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(vbox);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, vbox);
create_dir_struct(); /* Create a dir struct in /tmp */
fs = elm_fileselector_add(win);
/* enable the fs file name entry */
elm_fileselector_is_save_set(fs, EINA_TRUE);
/* make the file list a tree with dir expandable in place */
elm_fileselector_expandable_set(fs, EINA_FALSE);
/* start the fileselector in the test dir */
elm_fileselector_path_set(fs, "/tmp/test_fs_bt");
/* allow fs to expand in x & y */
evas_object_size_hint_weight_set(fs, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(fs, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(vbox, fs);
evas_object_show(fs); // TODO fix this is the widget
/* the 'done' cb is called when the user press ok/cancel */
evas_object_smart_callback_add(fs, "done", my_fileselector_done, win);
/* the 'selected' cb is called when the user click on a file/dir */
evas_object_smart_callback_add(fs, "selected", my_fileselector_selected,
win);
/* test buttons */
sep = elm_separator_add(win);
elm_separator_horizontal_set(sep, EINA_TRUE);
elm_box_pack_end(vbox, sep);
evas_object_show(sep);
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_pack_end(vbox, hbox);
evas_object_show(hbox);
bt = elm_check_add(win);
elm_object_text_set(bt, "is save");
elm_check_state_set(bt, elm_fileselector_is_save_get(fs));
evas_object_smart_callback_add(bt, "changed", _is_save_clicked, fs);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_check_add(win);
elm_object_text_set(bt, "folder only");
elm_check_state_set(bt, elm_fileselector_folder_only_get(fs));
evas_object_smart_callback_add(bt, "changed", _folder_only_clicked, fs);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_check_add(win);
elm_object_text_set(bt, "expandable");
elm_check_state_set(bt, elm_fileselector_expandable_get(fs));
evas_object_smart_callback_add(bt, "changed", _expandable_clicked, fs);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_pack_end(vbox, hbox);
evas_object_show(hbox);
bt = elm_button_add(win);
elm_object_text_set(bt, "selected get");
evas_object_smart_callback_add(bt, "clicked", _sel_get_clicked, fs);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "path get");
evas_object_smart_callback_add(bt, "clicked", _path_get_clicked, fs);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "mode cycle");
evas_object_smart_callback_add(bt, "clicked", _mode_cycle_clicked, fs);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
evas_object_resize(win, 240, 400);
evas_object_show(win);
}
TEST_END

View File

@ -0,0 +1,227 @@
#include <Elementary.h>
#include "tsuite.h"
static void
_file_chosen(void *data,
Evas_Object *obj __UNUSED__,
void *event_info)
{
Evas_Object *entry = data;
const char *file = event_info;
if (file)
{
elm_entry_entry_set(entry, file);
printf("File chosen: %s\n", file);
}
else
printf("File selection canceled.\n");
}
static void
_inwin_mode_toggle(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs_bt = data;
Eina_Bool value = elm_fileselector_button_inwin_mode_get(fs_bt);
elm_fileselector_button_inwin_mode_set(fs_bt, !value);
printf("Inwin mode set to: %s\n", value ? "false" : "true");
}
static void
_current_sel_toggle(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs_bt = data;
Eina_Bool value = elm_fileselector_button_is_save_get(fs_bt);
elm_fileselector_button_is_save_set(fs_bt, !value);
printf("Current selection editable entry set to: %s\n",
value ? "false" : "true");
}
static void
_folder_only_toggle(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs_bt = data;
Eina_Bool value = elm_fileselector_button_folder_only_get(fs_bt);
elm_fileselector_button_folder_only_set(fs_bt, !value);
printf("Folder only flag set to: %s\n", value ? "false" : "true");
}
static void
_expandable_toggle(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs_bt = data;
Eina_Bool value = elm_fileselector_button_expandable_get(fs_bt);
elm_fileselector_button_expandable_set(fs_bt, !value);
printf("Expandable flag set to: %s\n", value ? "false" : "true");
}
enum _api_state
{
ICON_UNSET,
WINDOW_TITLE_SET,
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
const Eina_List *items = elm_box_children_get(api->data);
if(!eina_list_count(items))
return;
/* Get first item of list of vbox children */
Evas_Object *fs_bt = eina_list_nth(items, 0);
/* use elm_box_children_get() to get list of children */
switch(api->state)
{ /* Put all api-changes under switch */
case ICON_UNSET:
elm_fileselector_button_icon_unset(fs_bt);
break;
case WINDOW_TITLE_SET:
elm_fileselector_button_window_title_set(fs_bt, "Custom title from API");
break;
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
static void
create_dir_struct(void)
{
FILE *fp;
mkdir("/tmp/test_fs_bt", S_IRWXU);
fp = fopen("/tmp/test_fs_bt/a_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/k_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/m_file.txt", "w");
if (fp) fclose(fp);
mkdir("/tmp/test_fs_bt/a_subdir", S_IRWXU);
fp = fopen("/tmp/test_fs_bt/a_subdir/d_sub_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/a_subdir/j_sub_file.txt", "w");
if (fp) fclose(fp);
}
TEST_START(test_fileselector_button)
{
Evas_Object *bg, *vbox, *hbox, *bxx, *ic, *bt, *fs_bt, *en, *lb;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
vbox = elm_box_add(win);
api->data = vbox;
evas_object_show(vbox);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, vbox);
create_dir_struct(); /* Create a dir struct in /tmp */
/* file selector button */
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "file");
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
fs_bt = elm_fileselector_button_add(win);
elm_object_text_set(fs_bt, "Select a file");
elm_fileselector_button_icon_set(fs_bt, ic);
elm_fileselector_button_path_set(fs_bt, "/tmp/test_fs_bt");
elm_box_pack_end(vbox, fs_bt);
evas_object_show(fs_bt);
evas_object_show(ic);
/* attribute setting buttons */
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_pack_end(vbox, hbox);
evas_object_show(hbox);
bt = elm_check_add(win);
elm_object_style_set(bt, "toggle");
elm_object_text_set(bt, "current selection text entry");
evas_object_smart_callback_add(bt, "changed", _current_sel_toggle, fs_bt);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_check_add(win);
elm_object_style_set(bt, "toggle");
elm_object_text_set(bt, "Inwin mode");
elm_check_state_set (bt, EINA_TRUE);
evas_object_smart_callback_add(bt, "changed", _inwin_mode_toggle, fs_bt);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_check_add(win);
elm_object_style_set(bt, "toggle");
elm_object_text_set(bt, "Folder only mode");
evas_object_smart_callback_add(bt, "changed", _folder_only_toggle, fs_bt);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_check_add(win);
elm_object_style_set(bt, "toggle");
elm_object_text_set(bt, "Expandable mode");
evas_object_smart_callback_add(bt, "changed", _expandable_toggle, fs_bt);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
lb = elm_label_add(win);
elm_object_text_set(lb, "Last selection:");
elm_box_pack_end(vbox, lb);
evas_object_show(lb);
en = elm_entry_add(win);
elm_entry_line_wrap_set(en, ELM_WRAP_NONE);
elm_entry_editable_set(en, EINA_FALSE);
evas_object_smart_callback_add(fs_bt, "file,chosen", _file_chosen, en);
elm_box_pack_end(vbox, en);
evas_object_show(en);
evas_object_resize(win, 400, 400);
evas_object_show(win);
}
TEST_END

View File

@ -0,0 +1,236 @@
#include <Elementary.h>
#include "tsuite.h"
static void
_file_chosen(void *data,
Evas_Object *obj __UNUSED__,
void *event_info)
{
Evas_Object *entry = data;
char *file = event_info;
elm_entry_entry_set(entry, file);
printf("File chosen: %s\n", file);
}
static void
_inwin_mode_toggle(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs_en = data;
Eina_Bool value = elm_fileselector_entry_inwin_mode_get(fs_en);
elm_fileselector_entry_inwin_mode_set(fs_en, !value);
printf("Inwin mode set to: %s\n", value ? "false" : "true");
}
static void
_folder_only_toggle(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs_en = data;
Evas_Object *ic = elm_fileselector_entry_button_icon_get(fs_en);
Eina_Bool value = elm_fileselector_entry_folder_only_get(fs_en);
elm_fileselector_entry_folder_only_set(fs_en, !value);
printf("Folder only flag set to: %s\n", value ? "false" : "true");
if (!value)
{
elm_icon_standard_set(ic, "folder");
elm_object_text_set(fs_en, "Select a folder");
}
else
{
elm_icon_standard_set(ic, "file");
elm_object_text_set(fs_en, "Select a file");
}
}
static void
_expandable_toggle(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs_en = data;
Eina_Bool value = elm_fileselector_entry_expandable_get(fs_en);
elm_fileselector_entry_expandable_set(fs_en, !value);
printf("Expandable flag set to: %s\n", value ? "false" : "true");
}
static void
_disabled_toggle(void *data,
Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
Evas_Object *fs_en = data;
Eina_Bool value = elm_object_disabled_get(fs_en);
elm_object_disabled_set(fs_en, !value);
printf("Disabled flag set to: %s\n", value ? "false" : "true");
}
enum _api_state
{
ICON_UNSET,
WINDOW_TITLE_SET,
API_STATE_LAST
};
typedef enum _api_state api_state;
static void
set_api_state(api_data *api)
{
const Eina_List *items = elm_box_children_get(api->data);
if(!eina_list_count(items))
return;
/* Get first item of list of vbox children */
Evas_Object *fs_bt = eina_list_nth(items, 0);
/* use elm_box_children_get() to get list of children */
switch(api->state)
{ /* Put all api-changes under switch */
case ICON_UNSET:
elm_fileselector_entry_button_icon_unset(fs_bt);
break;
case WINDOW_TITLE_SET:
elm_fileselector_entry_window_title_set(fs_bt, "Custom title from API");
break;
case API_STATE_LAST:
break;
default:
return;
}
}
static void
_api_bt_clicked(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
{ /* Will add here a SWITCH command containing code to modify test-object */
/* in accordance a->state value. */
api_data *a = data;
char str[128];
printf("clicked event on API Button: api_state=<%d>\n", a->state);
set_api_state(a);
a->state++;
sprintf(str, "Next API function (%u)", a->state);
elm_object_text_set(a->bt, str);
elm_object_disabled_set(a->bt, a->state == API_STATE_LAST);
}
static void
create_dir_struct(void)
{
FILE *fp;
mkdir("/tmp/test_fs_bt", S_IRWXU);
fp = fopen("/tmp/test_fs_bt/a_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/k_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/m_file.txt", "w");
if (fp) fclose(fp);
mkdir("/tmp/test_fs_bt/a_subdir", S_IRWXU);
fp = fopen("/tmp/test_fs_bt/a_subdir/d_sub_file.txt", "w");
if (fp) fclose(fp);
fp = fopen("/tmp/test_fs_bt/a_subdir/j_sub_file.txt", "w");
if (fp) fclose(fp);
}
TEST_START(test_fileselector_entry)
{
Evas_Object *bg, *vbox, *hbox, *bxx, *ic, *bt, *fs_en, *en, *lb;
bg = elm_bg_add(win);
elm_win_resize_object_add(win, bg);
evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bg);
bxx = elm_box_add(win);
elm_win_resize_object_add(win, bxx);
evas_object_size_hint_weight_set(bxx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(bxx);
vbox = elm_box_add(win);
evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
api->data = vbox;
evas_object_show(vbox);
api->bt = elm_button_add(win);
elm_object_text_set(api->bt, "Next API function");
evas_object_smart_callback_add(api->bt, "clicked", _api_bt_clicked, (void *) api);
elm_box_pack_end(bxx, api->bt);
elm_object_disabled_set(api->bt, api->state == API_STATE_LAST);
evas_object_show(api->bt);
elm_box_pack_end(bxx, vbox);
create_dir_struct(); /* Create a dir struct in /tmp */
/* file selector entry */
ic = elm_icon_add(win);
elm_icon_standard_set(ic, "file");
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
fs_en = elm_fileselector_entry_add(win);
elm_fileselector_entry_path_set(fs_en, "/tmp/test_fs_bt");
elm_object_text_set(fs_en, "Select a file");
elm_fileselector_entry_button_icon_set(fs_en, ic);
evas_object_size_hint_weight_set(fs_en, EVAS_HINT_EXPAND, 0.0);
evas_object_size_hint_align_set(fs_en, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(vbox, fs_en);
evas_object_show(fs_en);
evas_object_show(ic);
/* attribute setting buttons */
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_pack_end(vbox, hbox);
evas_object_show(hbox);
bt = elm_button_add(win);
elm_object_text_set(bt, "Toggle inwin mode");
evas_object_smart_callback_add(bt, "clicked", _inwin_mode_toggle, fs_en);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Toggle folder only mode");
evas_object_smart_callback_add(bt, "clicked", _folder_only_toggle, fs_en);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
bt = elm_button_add(win);
elm_object_text_set(bt, "Toggle expandable mode");
evas_object_smart_callback_add(bt, "clicked", _expandable_toggle, fs_en);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
lb = elm_label_add(win);
elm_object_text_set(lb, "Last selection:");
elm_box_pack_end(vbox, lb);
evas_object_show(lb);
hbox = elm_box_add(win);
elm_box_horizontal_set(hbox, EINA_TRUE);
elm_box_pack_end(vbox, hbox);
evas_object_show(hbox);
bt = elm_button_add(win);
elm_object_text_set(bt, "Toggle disabled");
evas_object_smart_callback_add(bt, "clicked", _disabled_toggle, fs_en);
elm_box_pack_end(hbox, bt);
evas_object_show(bt);
en = elm_entry_add(win);
elm_entry_line_wrap_set(en, ELM_WRAP_NONE);
elm_entry_editable_set(en, EINA_FALSE);
evas_object_smart_callback_add(fs_en, "file,chosen", _file_chosen, en);
elm_box_pack_end(vbox, en);
evas_object_show(en);
evas_object_resize(win, 400, 500);
evas_object_show(win);
}
TEST_END

Some files were not shown because too many files have changed in this diff Show More