Compare commits

..

No commits in common. "main" and "0.2.1" have entirely different histories.
main ... 0.2.1

941 changed files with 181160 additions and 36844 deletions

2
.gitignore vendored
View File

@ -60,5 +60,3 @@ ewol_release
ehthumbs.db
Icon?
Thumbs.db
Sources/libewol/ewol/os/AndroidAbstraction.cpp
org_ewol_EwolConstants.h

View File

@ -1,95 +0,0 @@
language: cpp
sudo: required
dist: trusty
branches:
only:
- master
- dev
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
- expect
- binutils-mingw-w64-x86-64 # 64bit MinGW
- gcc-mingw-w64-x86-64
- g++-mingw-w64-x86-64
matrix:
include:
- os: linux
env: CONF=release BUILDER=gcc TARGET=Linux TAG=Linux COMPILATOR_OPTION="--compilator-version=4.9"
compiler: gcc
- os: linux
env: CONF=debug BUILDER=clang TARGET=Linux
compiler: clang
- os: linux
env: CONF=release BUILDER=gcc TARGET=Windows TAG=Mingw
compiler: x86_64-w64-mingw32-gcc
- os: linux
env: CONF=release BUILDER=gcc TARGET=Android TAG=Android DISABLE_PACKAGE=-p
compiler: gcc
- os: osx
env: CONF=release BUILDER=clang TARGET=MacOs TAG=MacOs
compiler: clang
- os: osx
env: CONF=release BUILDER=clang TARGET=IOs TAG=IOs
compiler: clang
install:
- cd ..
- pip install --user lutin
- if [ "$TAG" == "Android" ]; then
git clone --depth 1 --branch master https://github.com/HeeroYui/android-download-tool;
./android-download-tool/dl-android.sh;
fi
- git clone --depth 1 --branch master https://github.com/atria-soft/ci.git
- cd -
before_script:
- cd ..
- mkdir bin
- curl https://storage.googleapis.com/git-repo-downloads/repo > bin/repo
- chmod a+x bin/repo
- git config --global user.email "travis@travis.com"
- git config --global user.name "Travis"
- git config --global color.ui "auto"
- git config --global core.editor "vi"
- mkdir WORKING_DIRECTORY
- cd WORKING_DIRECTORY
- ../bin/repo init -u https://github.com/atria-soft/manifest.git
- ../bin/repo sync -j4
- ../bin/repo forall -c git checkout master
- ../bin/repo forall -c git checkout $TRAVIS_BRANCH; STATUS=$?
- rm -rf atria-soft/ewol
- cd ..
- pwd
- ls -l
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then
export PATH=$PATH:/Users/travis/Library/Python/2.7/bin/;
fi
- ./ci/build_send.py --tag=$TAG --status=START;
script:
- lutin -w -j4 -C -P -t$TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF $GCOV $DISABLE_PACKAGE ewol-test ewol-sample-*; STATUS=$?
- ./ci/build_send.py --tag=$TAG --status="$STATUS";
after_script:
- if [ "$GCOV" != "" ]; then
./ci/warning_send.py --find-path ./out/Linux_x86_64/$CONF/build/$BUILDER/ewol/;
fi
- ./out/Linux_x86_64/$CONF/staging/$BUILDER/ewol-test/ewol-test.app/bin/ewol-test --elog-level=6 | tee out_test.txt
- if [ "$GCOV" != "" ]; then
./ci/test_send.py --file=out_test.txt;
lutin -C -P -t $TARGET -c $BUILDER $COMPILATOR_OPTION $BUS -m $CONF -p ewol?gcov;
./ci/coverage_send.py --json=out/Linux_x86_64/$CONF/build/$BUILDER/ewol/ewol_coverage.json;
fi
notifications:
email:
- yui.heero@gmail.com

61
Build/Makefile.Android.mk Normal file
View File

@ -0,0 +1,61 @@
include $(EWOL_FOLDER)/Build/Makefile.common.mk
PROJECT_PACKAGE=$(PROJECT_NAME)package
JAVA_FOLDER=src/com/$(PROJECT_VENDOR)/$(PROJECT_NAME)
all:
@echo $(CADRE_HAUT_BAS)
@echo $(CADRE_COTERS)
@echo ' DEBUT DE COMPILATION DU PROGRAMME :'$(CADRE_COTERS)
@echo ' Project name : $(F_BLUE)$(PROJECT_NAME)$(F_NORMALE)'$(CADRE_COTERS)
@echo ' Project Vendor : $(F_CYAN)$(PROJECT_VENDOR)$(F_NORMALE)'$(CADRE_COTERS)
@echo ' Build date : $(F_ROUGE)$(BUILD_TIME) $(F_NORMALE)'$(CADRE_COTERS)
@echo ' Tag : $(F_VIOLET)$(PROJECT_VERSION_TAG) $(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
@rm -rf bin
@echo $(F_ROUGE)" (sh) Clear previous sources "$(F_NORMALE)
@rm -rf src jni/ewolAndroidAbstraction.cpp
@echo $(F_ROUGE)" (sh) Create folder : $(JAVA_FOLDER)/ "$(F_NORMALE)
@mkdir -p $(JAVA_FOLDER)/
@echo $(F_ROUGE)" (sh) copy the java File : "$(F_NORMALE)
@cp $(EWOL_FOLDER)/Java/PROJECT_NAME.java $(JAVA_FOLDER)/$(PROJECT_NAME).java
@echo $(F_ROUGE)" (sh) Replace __PROJECT_VENDOR__, __PROJECT_NAME__ and __PROJECT_PACKAGE__ with the correct intance "$(F_NORMALE)
@sed -i "s|__PROJECT_VENDOR__|$(PROJECT_VENDOR)|" $(JAVA_FOLDER)/$(PROJECT_NAME).java
@sed -i "s|__PROJECT_NAME__|$(PROJECT_NAME)|" $(JAVA_FOLDER)/$(PROJECT_NAME).java
@sed -i "s|__PROJECT_PACKAGE__|$(PROJECT_PACKAGE)|" $(JAVA_FOLDER)/$(PROJECT_NAME).java
@echo $(F_ROUGE)" (sh) copy the cpp for jni File : $(EWOL_FOLDER)/SourcesJava/ewolAndroidAbstraction.cpp"$(F_NORMALE)
@cp $(EWOL_FOLDER)/Java/ewolAndroidAbstraction.cpp jni/
@echo $(F_ROUGE)" (sh) Replace __PROJECT_VENDOR__, __PROJECT_NAME__ and __PROJECT_PACKAGE__ with the correct intance "$(F_NORMALE)
@sed -i "s|__PROJECT_VENDOR__|$(PROJECT_VENDOR)|" jni/ewolAndroidAbstraction.cpp
@sed -i "s|__PROJECT_NAME__|$(PROJECT_NAME)|" jni/ewolAndroidAbstraction.cpp
@sed -i "s|__PROJECT_PACKAGE__|$(PROJECT_PACKAGE)|" jni/ewolAndroidAbstraction.cpp
@echo $(F_ROUGE)" (ndk-build) build native code"$(F_NORMALE)
cd $(PROJECT_NDK) ; NDK_PROJECT_PATH=$(PROJECT_PATH) NDK_MODULE_PATH=$(PROJECT_MODULE) ./ndk-build
@echo $(F_ROUGE)" (ant) build java code"$(F_NORMALE)
PATH=$(PROJECT_SDK)/tools/:$(PROJECT_SDK)/platform-tools/:$(PATH) ant -Dsdk.dir=$(PROJECT_SDK) debug
@echo $(F_ROUGE)" (sh) Clear previous sources "$(F_NORMALE)
@rm -rf src jni/ewolAndroidAbstraction.cpp
install: all
@echo $(CADRE_HAUT_BAS)
@echo ' INSTALL : $(F_VIOLET)./bin/$(PROJECT_NAME)-debug.apk$(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
@# $(PROJECT_SDK)/platform-tools/adb kill-server
@# install application
$(PROJECT_SDK)/platform-tools/adb install -r ./bin/$(PROJECT_NAME)-debug.apk
clean:
@echo $(CADRE_HAUT_BAS)
@echo ' CLEANING : bin libs gen obj'$(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
rm -rf bin libs gen obj

39
Build/Makefile.Linux.mk Normal file
View File

@ -0,0 +1,39 @@
include $(EWOL_FOLDER)/Build/coreLinux/main.mk
#include $(EWOL_FOLDER)/Build/Makefile.common.mk
#all:
# @echo $(CADRE_HAUT_BAS)
# @echo $(CADRE_COTERS)
# @echo ' DEBUT DE COMPILATION DU PROGRAMME :'$(CADRE_COTERS)
# @echo ' Project name : $(F_BLUE)$(PROJECT_NAME)$(F_NORMALE)'$(CADRE_COTERS)
# @echo ' Project Vendor : $(F_CYAN)$(PROJECT_VENDOR)$(F_NORMALE)'$(CADRE_COTERS)
# @echo ' Build date : $(F_ROUGE)$(BUILD_TIME) $(F_NORMALE)'$(CADRE_COTERS)
# @echo ' Tag : $(F_VIOLET)$(PROJECT_VERSION_TAG) $(F_NORMALE)'$(CADRE_COTERS)
# @echo $(CADRE_COTERS)
# @echo $(CADRE_HAUT_BAS)
#
# @echo $(F_ROUGE)" (ndk-build) build native code"$(F_NORMALE)
# cd $(PROJECT_NDK) ; NDK_PROJECT_PATH=$(PROJECT_PATH) NDK_MODULE_PATH=$(PROJECT_MODULE) ./ndk-build
# #cd $(PROJECT_NDK) ; NDK_PROJECT_PATH=$(PROJECT_PATH) NDK_MODULE_PATH=$(PROJECT_MODULE) NDK_LOG=~/.ndklog.txt make -f $(EWOL_FOLDER)/Build/coreLinux/build-local.mk
#install: all
# @echo $(CADRE_HAUT_BAS)
# @echo ' INSTALL : $(F_VIOLET)./bin/$(PROJECT_NAME)-debug.apk$(F_NORMALE)'$(CADRE_COTERS)
# @echo $(CADRE_HAUT_BAS)
# # TODO : Later ....
#clean:
# @echo $(CADRE_HAUT_BAS)
# @echo ' CLEANING : bin libs gen obj'$(CADRE_COTERS)
# @echo $(CADRE_HAUT_BAS)
# # TODO : Later ....

194
Build/Makefile.Linux_old.mk Normal file
View File

@ -0,0 +1,194 @@
include $(EWOL_FOLDER)/Build/Makefile.common.mk
#include $(EWOL_FOLDER)/Build/ewol.mk
###############################################################################
### Compilateur base system ###
###############################################################################
CXX=g++
CC=gcc
AR=ar
X11FLAGS= -lGL -lGLU
# some X11 mode availlable :
# install package : libxxf86vm-dev
X11FLAGS+= -lX11 -DEWOL_X11_MODE__XF86V -lXxf86vm
# install package : libxrender-dev
#X11FLAGS+= -lX11 -DEWOL_X11_MODE__XRENDER -lXrandr
ifeq ($(shell if `pkg-config --exists freetype2` ; then echo "yes"; else echo "no"; fi), yes)
FREETYPE_CFLAGS= `pkg-config --cflags freetype2` -DEWOL_USE_FREE_TYPE
FREETYPE_LDFLAGS= `pkg-config --libs freetype2` -DEWOL_USE_FREE_TYPE
else
FREETYPE_CFLAGS=
FREETYPE_LDFLAGS=
$(Info libFreeType-dev is not installed)
endif
OBJECT_DIR=Object_$(PLATFORM)
ifeq ("$(DEBUG)", "0")
OBJECT_DIRECTORY=$(OBJECT_DIR)/release
OUTPUT_NAME = $(OUTPUT_NAME_RELEASE)
else
OBJECT_DIRECTORY=$(OBJECT_DIR)/debug
OUTPUT_NAME = $(OUTPUT_NAME_DEBUG)
endif
###############################################################################
### Basic C flags ###
###############################################################################
# basic X11 librairy ==> show if we can une under lib ...
CXXFLAGS= $(X11FLAGS) $(FREETYPE_CFLAGS) -D__PLATFORM__$(PLATFORM) $(PROJECT_CXXFLAGS)
ifeq ("$(DEBUG)", "0")
CXXFLAGS+= -O2
else
# Enable debug (cgdb ***)
CXXFLAGS+= -g -O0
endif
# display all flags
CXXFLAGS+= -Wall
# ...
CXXFLAGS+= -D_REENTRANT
# internal defines
CXXFLAGS+= $(DEFINE)
# remove warning from the convertion char*
CXXFLAGS+= -Wno-write-strings
CXXFLAGS+= -DPROJECT_NAME="$(PROJECT_NAME)"
CFLAGS= $(CXXFLAGS) -std=c99
# basic extern librairy
LDFLAGS= $(X11FLAGS) $(FREETYPE_LDFLAGS) $(PROJECT_LDFLAGS)
# Dynamic connection of the CALLBACK of the GUI
LDFLAGS+= -Wl,--export-dynamic
# TODO : add the prefix ...
CXXFILES = $(PROJECT_SOURCES)
# create the list of module :
LISTE_MODULES = $(sort $(dir $(CXXFILES)))
###############################################################################
### Build Object Files List ###
###############################################################################
OBJ = $(addprefix $(OBJECT_DIRECTORY)/, $(CXXFILES:.cpp=.o))
###############################################################################
### Main Part of Makefile ###
###############################################################################
all: $(PROJECT_NAME)
-include $(OBJ:.o=.d)
.ewol:
@cd $(EWOL_FOLDER) ; make -s PLATFORM=$(PLATFORM) DEBUG=$(DEBUG)
.ewol-clean:
@cd $(EWOL_FOLDER) ; make -s PLATFORM=$(PLATFORM) clean
.encadrer:
@echo $(CADRE_HAUT_BAS)
@echo $(CADRE_COTERS)
@echo ' DEBUT DE COMPILATION DU PROGRAMME :'$(CADRE_COTERS)
@echo ' Repertoire Sources : $(PROJECT_FILE_DIRECTORY)/'$(CADRE_COTERS)
@echo ' Repertoire object : $(OBJECT_DIRECTORY)/'$(CADRE_COTERS)
@echo ' Binaire de sortie : $(F_VIOLET)$(PROJECT_NAME) $(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
@mkdir -p $(addprefix $(OBJECT_DIRECTORY)/, $(LISTE_MODULES))
$(info PROJECT_FILE_DIRECTORY=$(PROJECT_FILE_DIRECTORY) ; OBJECT_DIRECTORY=$(OBJECT_DIRECTORY))
# build C++
$(OBJECT_DIRECTORY)/%.o: $(PROJECT_FILE_DIRECTORY)/%.cpp $(MAKE_DEPENDENCE)
@echo $(F_VERT)" (.o) $<"$(F_NORMALE)
@$(CXX) $< -c -o $@ $(INCLUDE_DIRECTORY) $(CXXFLAGS) -MMD
# build binary Release Mode
$(PROJECT_NAME): .ewol .encadrer $(PROJECT_LIB_DEPENDENCY) $(OBJ) $(MAKE_DEPENDENCE)
@echo $(F_ROUGE)" (bin) $(PROJECT_NAME) "$(F_NORMALE)
@$(CXX) $(OBJ) $(EWOL_FOLDER)/libewol.a $(LDFLAGS) -o $@
clean: .ewol-clean
@echo $(CADRE_HAUT_BAS)
@echo ' CLEANING : $(F_VIOLET)$(OUTPUT_NAME)$(F_NORMALE)'$(CADRE_COTERS)
@echo $(CADRE_HAUT_BAS)
@echo $(F_VERT)" (rm) $(OBJECT_DIR)"$(F_NORMALE)
@rm -rf $(OBJECT_DIR)
@echo $(F_VERT)" (rm) $(PROJECT_NAME) $(OUTPUT_NAME_DEBUG) $(OUTPUT_NAME_RELEASE)"$(F_NORMALE)
@rm -f $(PROJECT_NAME) $(OUTPUT_NAME_DEBUG) $(OUTPUT_NAME_RELEASE)
@echo $(F_VERT)" (rm) doxygen/*"$(F_NORMALE)
@rm -rf doxygen
@rm -f doxygen.log
@echo $(F_VERT)" (rm) *.bck"$(F_NORMALE)
@rm -f `find . -name "*.bck"`
count:
wc -l Makefile `find $(FILE_DIRECTORY)/ -name "*.cpp"` `find $(PROJECT_FILE_DIRECTORY)/ -name "*.h"`
install: .encadrer .versionFile $(PROJECT_NAME)
@echo ' INSTALL : $(OUTPUT_NAME_RELEASE)=>$(PROJECT_NAME)'
@echo " (stripped) $(OUTPUT_NAME_RELEASE) => $(PROJECT_NAME) "
@cp $(OUTPUT_NAME_RELEASE) $(PROJECT_NAME)
@strip -s $(PROJECT_NAME)
@echo " (copy) $(PROJECT_NAME) /usr/bin/ "
@cp -vf $(PROJECT_NAME) /usr/bin/
@echo " (data) data/* ==> /usr/share/$(PROJECT_NAME)/ "
@mkdir -p /usr/share/$(PROJECT_NAME)/
@rm -rf /usr/share/$(PROJECT_NAME)/*
@cp -vf assets/* /usr/share/$(PROJECT_NAME)/
# http://alp.developpez.com/tutoriels/debian/creer-paquet/
package: .encadrer
@echo 'Create Folders ...'
@mkdir -p package/$(PROJECT_NAME)/DEBIAN/
@mkdir -p package/$(PROJECT_NAME)/usr/bin/
@mkdir -p package/$(PROJECT_NAME)/usr/share/doc/
@mkdir -p package/$(PROJECT_NAME)/usr/share/edn/
# Create the control file
@echo "Package: "$(PROJECT_NAME) > package/$(PROJECT_NAME)/DEBIAN/control
@echo "Version: "$(VERSION_TAG_SHORT) >> package/$(PROJECT_NAME)/DEBIAN/control
@echo "Section: Development,Editors" >> package/$(PROJECT_NAME)/DEBIAN/control
@echo "Priority: optional" >>package/$(PROJECT_NAME)/DEBIAN/control
@echo "Architecture: all" >> package/$(PROJECT_NAME)/DEBIAN/control
@echo "Depends: bash" >> package/$(PROJECT_NAME)/DEBIAN/control
@echo "Maintainer: Mr DUPIN Edouard <yui.heero@gmail.com>" >> package/$(PROJECT_NAME)/DEBIAN/control
@echo "Description: Text editor for sources code with ctags management" >> package/$(PROJECT_NAME)/DEBIAN/control
@echo "" >> package/$(PROJECT_NAME)/DEBIAN/control
# Create the PostRm
@echo "#!/bin/bash" > package/$(PROJECT_NAME)/DEBIAN/postrm
@echo "rm ~/."$(PROJECT_NAME) >> package/$(PROJECT_NAME)/DEBIAN/postrm
@echo "" >> package/$(PROJECT_NAME)/DEBIAN/postrm
# Enable Execution in script
@chmod 755 package/$(PROJECT_NAME)/DEBIAN/post*
@#chmod 755 package/$(PROJECT_NAME)/DEBIAN/pre*
# copy licence and information :
@cp README package/$(PROJECT_NAME)/usr/share/doc/README
@cp licence.txt package/$(PROJECT_NAME)/usr/share/doc/copyright
@echo "First generation in progress" >> package/$(PROJECT_NAME)/usr/share/doc/changelog
@cp -vf $(PROJECT_NAME) package/$(PROJECT_NAME)/usr/bin/
@cp -vf data/*.xml package/$(PROJECT_NAME)/usr/share/edn/
@cd package; dpkg-deb --build $(PROJECT_NAME)

56
Build/Makefile.common.mk Normal file
View File

@ -0,0 +1,56 @@
##################################################################################################################
# #
# Fichier : Makefile.common #
# #
# Type : common part of the ewol Makefile #
# #
# Auteur : Heero Yui #
# #
# Evolutions : Date Auteur Raison #
# 2011-12-15 Heero Yui Mise en place du système de couleur et d'encart #
# #
##################################################################################################################
export F_GRAS=
export F_INVERSER=
export F_SOUSLIGNER=
export F_NORMALE=
export F_NOIR=
export F_ROUGE=
export F_VERT=
export F_MARRON=
export F_BLUE=
export F_VIOLET=
export F_CYAN=
export F_GRIS=
export CADRE_HAUT_BAS=' $(F_INVERSER) $(F_NORMALE)'
export CADRE_COTERS=' $(F_INVERSER) $(F_NORMALE) $(F_INVERSER) $(F_NORMALE)'
###############################################################################
### Platform specificity : ###
###############################################################################
SUPPORTED_PLATFORM=Linux IMac IPhone IPad Android AndroidTablet
DEFAULT_PLATFORM=Linux
# default platform can be overridden
PLATFORM?=$(DEFAULT_PLATFORM)
ifeq ($(PLATFORM), Linux)
CXXFILES += base/guiX11.cpp
else ifeq ($(PLATFORM), IMac)
CXXFILES += base/guiIMac.cpp
else ifeq ($(PLATFORM), IPhone)
CXXFILES += base/guiIPhone.cpp
else ifeq ($(PLATFORM), IPad)
CXXFILES += base/guiIPad.cpp
else ifeq ($(PLATFORM), Android)
CXXFILES += base/guiAndroid.cpp
else ifeq ($(PLATFORM), AndroidTablet)
CXXFILES += base/guiAndroidTablet.cpp
else
$(error you must specify a corect platform : make PLATFORM=$(SUPPORTED_PLATFORM))
endif
BUILD_TIME=$(shell date)

View File

@ -0,0 +1,76 @@
###############################################################################
## @file clearvars.mk
## @author Y.M. Morgan
## @date 2011/05/14
##
## Clear out values of all variables used by rule templates.
###############################################################################
# Do NOT clear LOCAL_PATH, it is set BEFORE including this makefile
# Name of what's supposed to be generated
LOCAL_MODULE :=
# Source files to compile
LOCAL_SRC_FILES :=
# Files to copy verbatim
LOCAL_COPY_FILES :=
# Static libraries that you want to include in your module
LOCAL_STATIC_LIBRARIES :=
# Libraries you directly link against
# Specify the name without the suffix
LOCAL_SHARED_LIBRARIES :=
# Additional directories to instruct the C/C++ compilers to look for header files in.
# Format : -I<fullpath>
LOCAL_C_INCLUDES :=
# Additional flags to pass into the C or C++ compiler
LOCAL_CFLAGS :=
# Additional flags to pass into only the C++ compiler
LOCAL_CPPFLAGS :=
# Additional flags to pass into the static library generator
LOCAL_ARFLAGS :=
# Additional flags to pass into the resource compiler (Windows only)
LOCAL_RCFLAGS :=
# Additional flags to pass into the linker
LOCAL_LDFLAGS :=
# Additional libraries to pass into the linker
# Format : -l<name>
LOCAL_LDLIBS :=
# Resource list file
LOCAL_RESLIST :=
# Xrc file
LOCAL_XRC :=
# Additionnal dependecies for rc files
LOCAL_RC_DEPS :=
# Precompiled file
LOCAL_PRECOMPILED_FILE :=
# Other variables used internally
LOCAL_BUILT_MODULE :=
LOCAL_INSTALLED_MODULE :=
LOCAL_INTERMEDIATE_TARGETS :=
LOCAL_MODULE_SUFFIX :=
LOCAL_BUILDING_STATIC_LIBRARY :=
LOCAL_BUILDING_SHARED_LIBRARY :=
LOCAL_BUILDING_EXECUTABLE :=
# Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
# iterate over thousands of entries every time.
# Leave the current makefile to make sure we don't break anything
# that expects to be able to find the name of the current makefile.
MAKEFILE_LIST := $(lastword $(MAKEFILE_LIST))

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>$(SolutionDir)out_vc10\$(Configuration)\</OutDir>
<IntDir>$(SolutionDir)build_vc10\$(Configuration)\$(ProjectName)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<WarningLevel>Level4</WarningLevel>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup />
</Project>

109
Build/coreLinux/config.mk Normal file
View File

@ -0,0 +1,109 @@
###############################################################################
## @file config.mk
## @author Y.M. Morgan
## @date 2011/05/14
###############################################################################
###############################################################################
## Make sure that there are no spaces in the absolute path; the build system
## can't deal with them.
###############################################################################
ifneq ("$(words $(shell pwd))","1")
$(error Top directory contains space characters)
endif
###############################################################################
## OS type.
###############################################################################
# set MingW32 flags
ifneq ("$(shell echo $$OSTYPE | grep msys)","")
OS_MINGW32 := 1
DIR_SUFFIX := _mingw
else
OS_MINGW32 := 0
DIR_SUFFIX :=
endif
# Exe/dll suffix under mingw
TARGET_STATIC_LIB_SUFFIX := .a
ifeq ("$(OS_MINGW32)","1")
TARGET_EXE_SUFFIX := .exe
TARGET_SHARED_LIB_SUFFIX := .dll
else
TARGET_EXE_SUFFIX :=
TARGET_SHARED_LIB_SUFFIX := .so
endif
ifeq ("$(OS_MINGW32)","1")
TARGET_GLOBAL_CFLAGS += -D__MINGW_FEATURES__=0
endif
###############################################################################
## Variables based on DEBUG/STATIC.
###############################################################################
ifeq ("$(DEBUG)","0")
TARGET_GLOBAL_CFLAGS += -O2 -g0 -DNDEBUG -DUNICODE -D_UNICODE
TARGET_GLOBAL_LDFLAGS += -Wl,--strip-all
TARGET_OUT_INTERMEDIATES := $(TOP_DIR)/linux/obj$(DIR_SUFFIX)/release
TARGET_OUT := $(TOP_DIR)/linux/bin$(DIR_SUFFIX)/release
else
TARGET_GLOBAL_CFLAGS += -O0 -g2 -DDEBUG -D_DEBUG -DUNICODE -D_UNICODE
TARGET_GLOBAL_LDFLAGS +=
TARGET_OUT_INTERMEDIATES := $(TOP_DIR)/linux/obj$(DIR_SUFFIX)/debug
TARGET_OUT := $(TOP_DIR)/linux/bin$(DIR_SUFFIX)/debug
endif
###############################################################################
## wxWidgets configuration.
###############################################################################
# wx-config script
WX_CONFIG := wx-config
ifeq ("$(shell which $(WX_CONFIG))","")
$(warning Unable to find $(WX_CONFIG))
$(error Please make sure wxWidgets development package is installed)
endif
# Argument for debug
ifeq ("$(DEBUG)","0")
WX_CONFIG_ARGS += --debug=no
else
WX_CONFIG_ARGS += --debug=yes
endif
# Argument for unicode
WX_CONFIG_ARGS += --unicode=yes
# Argument for static
ifeq ("$(STATIC)","0")
WX_CONFIG_ARGS += --static=no
else
WX_CONFIG_ARGS += --static=yes
endif
# Get wxWidgets configuration
WX_LIBS := $(shell $(WX_CONFIG) --libs $(WX_CONFIG_ARGS))
WX_FLAGS := $(shell $(WX_CONFIG) --cppflags $(WX_CONFIG_ARGS))
WX_VERSION := $(shell $(WX_CONFIG) --version $(WX_CONFIG_ARGS))
# Check that the configuration exists
ifeq ("$(WX_LIBS)","")
$(error wxWidgets configuration not supported: $(WX_CONFIG_ARGS))
endif
# wxWidgets >= 2.8.10 required
ifeq (0,$(shell expr $(WX_VERSION) \>= 2.8.10))
$(error Unsupported version of wxWidgets: $(WX_VERSION))
endif
###############################################################################
## Determine gcc path and version.
###############################################################################
GCC_PATH := $(shell which $(GCC))
GCC_VERSION := $(shell $(GCC) --version | head -1 \
| sed "s/.*\([0-9]\.[0-9]\.[0-9]\).*/\1/")

176
Build/coreLinux/defs.mk Normal file
View File

@ -0,0 +1,176 @@
###############################################################################
## @file defs.mk
## @author Y.M. Morgan
## @date 2011/05/14
##
## This file contains macros used by other makefiles.
###############################################################################
###############################################################################
## Figure out where we are.
###############################################################################
define my-dir
$(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST),$(MAKEFILE_LIST))))
endef
###############################################################################
## Commands for running gcc to generate a precompiled file.
###############################################################################
define transform-h-to-gch
@mkdir -p $(dir $@)
@echo "Precompile: $(PRIVATE_MODULE) <= $<"
$(Q)$(GXX) \
$(TARGET_PROJECT_INCLUDES) $(TARGET_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(GXX_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \
-c -MMD -MP -o $@ $<
endef
###############################################################################
## Commands for running gcc to compile a C++ file.
###############################################################################
define transform-cpp-to-o
@mkdir -p $(dir $@)
@echo "C++: $(PRIVATE_MODULE) <= $<"
$(Q)$(GXX) \
$(TARGET_PROJECT_INCLUDES) $(TARGET_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS) $(TARGET_GLOBAL_CPPFLAGS) $(GXX_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) $(PRIVATE_CPPFLAGS) \
-c -MMD -MP -o $@ $<
endef
###############################################################################
## Commands for running gcc to compile a C file.
###############################################################################
define transform-c-to-o
@echo "C: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
$(Q)$(GCC) \
$(TARGET_PROJECT_INCLUDES) $(TARGET_C_INCLUDES) $(PRIVATE_C_INCLUDES) \
$(TARGET_GLOBAL_CFLAGS) $(GCC_FLAGS_WARNINGS) \
$(PRIVATE_CFLAGS) \
-c -MMD -MP -o $@ $<
endef
###############################################################################
## Commands for compiling rc files.
###############################################################################
define transform-rc-to-o
@echo "RC: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
@rm -f $@
$(Q)$(WINDRES) \
--use-temp-file -i$< -o$@ -I$(dir $<) \
$(filter -D%, $(TARGET_GLOBAL_CFLAGS)) \
$(filter -D%, $(PRIVATE_CFLAGS)) \
$(TARGET_GLOBAL_RCFLAGS) $(PRIVATE_RCFLAGS)
endef
###############################################################################
## Commands for running ar.
###############################################################################
# Explicitly delete the archive first so that ar doesn't
# try to add to an existing archive.
define transform-o-to-static-lib
@mkdir -p $(dir $@)
@echo "StaticLib: $(PRIVATE_MODULE) ($@)"
@rm -f $@
$(Q)$(AR) $(TARGET_GLOBAL_ARFLAGS) $(PRIVATE_ARFLAGS) $@ $^
endef
###############################################################################
## Commands for running gcc to link a shared library.
###############################################################################
define transform-o-to-shared-lib
@mkdir -p $(dir $@)
@echo "SharedLib: $(PRIVATE_MODULE) ($@)"
$(Q)$(GXX) \
$(TARGET_GLOBAL_LDFLAGS) \
-Wl,-Map -Wl,$(basename $@).map \
-shared \
-Wl,-soname -Wl,$(notdir $@) \
-Wl,--unresolved-symbols=ignore-in-shared-libs \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--no-whole-archive \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
-o $@ \
$(PRIVATE_LDLIBS)
endef
###############################################################################
## Commands for running gcc to link an executable.
###############################################################################
define transform-o-to-executable
@mkdir -p $(dir $@)
@echo "Executable: $(PRIVATE_MODULE) ($@)"
$(Q)$(GXX) \
-Wl,-Map -Wl,$(basename $@).map \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--no-whole-archive \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
$(TARGET_GLOBAL_LDFLAGS) \
$(PRIVATE_LDFLAGS) \
-o $@ \
$(PRIVATE_LDLIBS)
endef
###############################################################################
## Commands to generate resource list
###############################################################################
# $(1) : ResListMaker full path
# $(2) : source directory
# $(3) : destination directory
define transform-reslist
@mkdir -p $(dir $@)
@echo "ResList: $(PRIVATE_MODULE) ($@)"
$(Q)$(1) $(2)/ResList.txt $(3)/ResList.h $(3)/ResList.c $(2)
$(Q)date | cat > $@
endef
# $(1) : source directory
# $(2) : destination directory
define generate-reslistmaker
@mkdir -p $(dir $@)
@echo "ResListMaker: $(PRIVATE_MODULE) ($@)"
$(Q)$(GCC) -O2 -g0 -c -o $(2)/ResListMaker.o $(1)/ResListMaker.c
$(Q)$(GCC) -o $@ $(2)/ResListMaker.o
endef
###############################################################################
## Commands for copying files.
###############################################################################
# Copy a single file from one place to another, preserving permissions and
# overwriting any existing file.
define copy-file-to-target
@mkdir -p $(dir $@)
$(Q)cp -fp $< $@
endef
# Define a rule to copy a file. For use via $(eval).
# $(1): source file
# $(2): destination file
define copy-one-file
$(2): $(1)
@echo "Copy: $$@"
$$(copy-file-to-target)
endef
###############################################################################
## Commands for importing module files.
###############################################################################
import-module = \
$(eval include $(shell find $(PROJECT_MODULE)$1 -name Linux.mk))

View File

@ -0,0 +1,16 @@
###############################################################################
## @file executable.mk
## @author Y.M. Morgan
## @date 2011/05/14
##
## Build an executable.
###############################################################################
LOCAL_MODULE_SUFFIX := $(TARGET_EXECUTABLE_SUFFIX)
LOCAL_BUILDING_EXECUTABLE := 1
include $(RULES)
$(LOCAL_BUILT_MODULE): $(all_libraries) $(all_objects)
$(transform-o-to-executable)

179
Build/coreLinux/main.mk Normal file
View File

@ -0,0 +1,179 @@
###############################################################################
## @file main.mk
## @author Y.M. Morgan
## @date 2011/05/14
##
## Main Makefile.
###############################################################################
# Make sure SHELL is correctly set
SHELL := /bin/bash
# Turns off suffix rules built into make
.SUFFIXES:
# Installation variables
PACKAGE := fsanalyser
DESTDIR :=
PREFIX := /usr/local
# Tools
GCC := gcc
GXX := g++
AR := ar
LD := ld
WINDRES := windres
# Overridable settings
V := 0
W := 0
DEBUG := 0
STATIC := 0
# Quiet command if V is not 1
ifneq ("$(V)","1")
Q := @
endif
# Directories
TOP_DIR := .
#BUILD_SYSTEM := $(TOP_DIR)/Build/coreLinux
BUILD_SYSTEM := $(PROJECT_NDK)/Build/coreLinux/
# This is the default target. It must be the first declared target.
all:
# Global variables
TARGET_PROJECT_INCLUDES :=
TARGET_C_INCLUDES :=
TARGET_GLOBAL_CFLAGS := -fno-exceptions -fstrict-aliasing
TARGET_GLOBAL_CPPFLAGS :=
TARGET_GLOBAL_RCFLAGS :=
TARGET_GLOBAL_ARFLAGS := -rcs
TARGET_GLOBAL_LDFLAGS := -Wl,--gc-sections -Wl,--warn-common -Wl,--warn-constructors
ALL_MODULES :=
# To be able to load automatically .so libraries located in the same
# folder than the application, we need to add $ORIGIN to DT_RPATH
# '\' is to escape the '$' in the shell command
# '$$' is to escape the '$' in the makefile
TARGET_GLOBAL_LDFLAGS += -Wl,-rpath,\$$ORIGIN
###############################################################################
# Version
###############################################################################
VERSION_MAJOR := 111
VERSION_MINOR := 2222
VERSION_REVISION := 3453
VERSION := $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION)
###############################################################################
###############################################################################
# Setup macros definitions
include $(BUILD_SYSTEM)/defs.mk
# Setup configuration
include $(BUILD_SYSTEM)/config.mk
# Names of makefiles that can be included by "local.mk" Makefiles
CLEAR_VARS := $(BUILD_SYSTEM)/clearvars.mk
BUILD_STATIC_LIBRARY := $(BUILD_SYSTEM)/static.mk
BUILD_SHARED_LIBRARY := $(BUILD_SYSTEM)/shared.mk
BUILD_EXECUTABLE := $(BUILD_SYSTEM)/executable.mk
RULES := $(BUILD_SYSTEM)/rules.mk
###############################################################################
## Flags to activate warnings.
###############################################################################
COMMON_FLAGS_WARNINGS :=
GCC_FLAGS_WARNINGS :=
GXX_FLAGS_WARNINGS :=
COMMON_FLAGS_WARNINGS += -Wall
# Add common flags to specific flags
GCC_FLAGS_WARNINGS += $(COMMON_FLAGS_WARNINGS)
GXX_FLAGS_WARNINGS += $(COMMON_FLAGS_WARNINGS)
###############################################################################
###############################################################################
# Get the list of all makefiles available and include them
makefiles += $(shell find $(TOP_DIR) -name Linux.mk)
include $(makefiles)
TARGET_GLOBAL_CPPFLAGS := $(addprefix -I, $(LIB_EXTERN_C_INCLUDE))
TARGET_GLOBAL_LDFLAGS := $(TARGET_GLOBAL_LDFLAGS) $(LIB_EXTERN_LDLIBS)
###############################################################################
# Main rules.
###############################################################################
.PHONY: all
all: $(foreach m,$(ALL_MODULES),$(m))
.PHONY: clean
clean: $(foreach m,$(ALL_MODULES),clean-$(m))
.PHONY: distclean
distclean: clean
.PHONY: test
test:
.PHONY: install
install: $(foreach m,$(ALL_MODULES),install-$(m))
###############################################################################
# debian package generation.
###############################################################################
.PHONY: deb
deb:
@chmod +x debian/rules
$(Q)fakeroot debian/rules binary
.PHONY: deb-clean
deb-clean:
@chmod +x debian/rules
$(Q)fakeroot debian/rules clean
###############################################################################
# source/binary pakage generation.
###############################################################################
# Generate archive with source files from git
SRCZIP_NAME := $(PACKAGE)-src-$(VERSION)
.PHONY: src-zip
src-zip:
@rm -f $(SRCZIP_NAME).tar
@rm -f $(SRCZIP_NAME).tar.bz2
$(Q)git archive --format=tar --prefix=$(SRCZIP_NAME)/ \
-o $(SRCZIP_NAME).tar HEAD
$(Q)bzip2 $(SRCZIP_NAME).tar
# Generate archive with binary files
BINZIP_NAME := $(PACKAGE)-bin-$(VERSION)
.PHONY: bin-zip
bin-zip:
@rm -f $(BINZIP_NAME).tar
@rm -f $(BINZIP_NAME).tar.bz2
$(Q)tar -cf $(BINZIP_NAME).tar -C $(TARGET_OUT) \
--transform "s/\.\(\/.*\)/$(BINZIP_NAME)\\1/" .
$(Q)bzip2 $(BINZIP_NAME).tar
###############################################################################
# Display configuration.
###############################################################################
$(info ----------------------------------------------------------------------)
$(info + VERSION = $(VERSION))
$(info + DEBUG = $(DEBUG))
$(info + STATIC = $(STATIC))
$(info + TARGET_OUT_INTERMEDIATES = $(TARGET_OUT_INTERMEDIATES))
$(info + TARGET_OUT = $(TARGET_OUT))
$(info + GCC_PATH = $(GCC_PATH))
$(info + GCC_VERSION = $(GCC_VERSION))
$(info ----------------------------------------------------------------------)

232
Build/coreLinux/rules.mk Normal file
View File

@ -0,0 +1,232 @@
###############################################################################
## @file rules.mk
## @author Y.M. Morgan
## @date 2011/05/14
##
## Generate rules for building an executable or library.
###############################################################################
# Make sure LOCAL_MODULE is defined and not empty
LOCAL_MODULE := $(strip $(LOCAL_MODULE))
ifeq ("$(LOCAL_MODULE)","")
$(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
endif
# Intermediates directory
intermediates := $(TARGET_OUT_INTERMEDIATES)/$(LOCAL_MODULE)
# Full path to build module
LOCAL_BUILT_MODULE := $(intermediates)/$(LOCAL_MODULE)$(LOCAL_MODULE_SUFFIX)
# Full path to final module
LOCAL_FINAL_MODULE := $(TARGET_OUT)/$(LOCAL_MODULE)$(LOCAL_MODULE_SUFFIX)
# Assemble the list of targets to create PRIVATE_ variables for.
LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
# Prepend some directories in include list
LOCAL_C_INCLUDES := -I$(intermediates) -I$(TOP_DIR)/$(LOCAL_PATH) $(LOCAL_C_INCLUDES)
# Register the module
ALL_MODULES += $(LOCAL_MODULE)
###############################################################################
## List of sources, objects and libraries.
###############################################################################
cpp_sources := $(filter %.cpp,$(LOCAL_SRC_FILES))
cpp_objects := $(addprefix $(intermediates)/,$(cpp_sources:.cpp=.o))
cxx_sources := $(filter %.cxx,$(LOCAL_SRC_FILES))
cxx_objects := $(addprefix $(intermediates)/,$(cxx_sources:.cxx=.o))
c_sources := $(filter %.c,$(LOCAL_SRC_FILES))
c_objects := $(addprefix $(intermediates)/,$(c_sources:.c=.o))
# rc files are used only under Mingw32
ifeq ("$(OS_MINGW32)","1")
rc_sources := $(filter %.rc,$(LOCAL_SRC_FILES))
rc_objects := $(addprefix $(intermediates)/,$(rc_sources:.rc=.rc.o))
endif
all_objects := \
$(cpp_objects) \
$(cxx_objects) \
$(c_objects) \
$(rc_objects) \
# Under mingw32, use .dll.a to link against shared libraries instead of .so
ifeq ("$(OS_MINGW32)","1")
shared_suffix := $(TARGET_SHARED_LIB_SUFFIX)$(TARGET_STATIC_LIB_SUFFIX)
else
shared_suffix := $(TARGET_SHARED_LIB_SUFFIX)
endif
built_shared_libraries := \
$(foreach lib,$(LOCAL_SHARED_LIBRARIES), \
$(TARGET_OUT_INTERMEDIATES)/$(lib)/$(lib)$(shared_suffix))
built_static_libraries := \
$(foreach lib,$(LOCAL_STATIC_LIBRARIES), \
$(TARGET_OUT_INTERMEDIATES)/$(lib)/$(lib)$(TARGET_STATIC_LIB_SUFFIX))
# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
all_libraries := \
$(built_shared_libraries) \
$(built_static_libraries) \
###############################################################################
## Resource list management.
###############################################################################
LOCAL_RESLIST := $(strip $(LOCAL_RESLIST))
ifneq ("$(LOCAL_RESLIST)","")
# This makes sure resource list is created before compilation (order prerequisite)
$(all_objects): | $(intermediates)/ResList
# Additional dependencies
$(intermediates)/ResList.h: $(intermediates)/ResList
$(intermediates)/ResList.c: $(intermediates)/ResList
$(intermediates)/ResList: $(TOP_DIR)/$(LOCAL_PATH)/$(LOCAL_XRC)
reslist := $(TOP_DIR)/$(LOCAL_PATH)/$(LOCAL_RESLIST)
reslistsrc := $(shell dirname $(reslist))
reslistdst := $(intermediates)
reslistmaker := $(reslistdst)/ResListMaker/ResListMaker$(TARGET_EXE_SUFFIX)
# Generate resource list
$(intermediates)/ResList: $(reslist) $(reslistmaker)
$(call transform-reslist, $(reslistmaker), $(reslistsrc), $(reslistdst))
# Generate resource list maker
$(reslistmaker): $(reslistsrc)/ResListMaker.c
$(call generate-reslistmaker, $(reslistsrc), $(dir $(reslistmaker)))
endif
###############################################################################
## Actual rules.
###############################################################################
# Final copy (not for static libraries)
$(LOCAL_FINAL_MODULE): $(LOCAL_BUILT_MODULE)
ifeq ("$(LOCAL_BUILDING_STATIC_LIBRARY)","")
@echo "Copy: $@"
$(copy-file-to-target)
endif
# cpp files
ifneq ("$(strip $(cpp_objects))","")
$(cpp_objects): $(intermediates)/%.o: $(LOCAL_PATH)/%.cpp
$(transform-cpp-to-o)
-include $(cpp_objects:%.o=%.d)
endif
# cxx files
ifneq ("$(strip $(cxx_objects))","")
$(cxx_objects): $(intermediates)/%.o: $(LOCAL_PATH)/%.cxx
$(transform-cpp-to-o)
-include $(cxx_objects:%.o=%.d)
endif
# c files
ifneq ("$(strip $(c_objects))","")
$(c_objects): $(intermediates)/%.o: $(LOCAL_PATH)/%.c
$(transform-c-to-o)
-include $(c_objects:%.o=%.d)
endif
# rc files
ifneq ("$(strip $(rc_objects))","")
$(rc_objects): $(addprefix $(LOCAL_PATH)/,$(LOCAL_RC_DEPS))
$(rc_objects): $(intermediates)/%.rc.o: $(TOP_DIR)/$(LOCAL_PATH)/%.rc
$(transform-rc-to-o)
endif
# copy files verbatim to target (flat copy in output directory)
copy_files :=
$(foreach f,$(LOCAL_COPY_FILES), \
$(eval _src := $(TOP_DIR)/$(LOCAL_PATH)/$(f)) \
$(eval _dst := $(TARGET_OUT)/$(notdir $(f))) \
$(eval copy_files += $(_dst)) \
$(eval $(call copy-one-file,$(_src),$(_dst))) \
)
$(LOCAL_BUILT_MODULE): $(copy_files)
# clean- targets
cleantarget := clean-$(LOCAL_MODULE)
$(cleantarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
$(cleantarget) : PRIVATE_CLEAN_FILES := \
$(PRIVATE_CLEAN_FILES) \
$(LOCAL_BUILT_MODULE) \
$(LOCAL_FINAL_MODULE) \
$(copy_files) \
$(intermediates)
$(cleantarget)::
@echo "Clean: $(PRIVATE_MODULE)"
$(Q)rm -rf $(PRIVATE_CLEAN_FILES)
# install- targets
installtarget := install-$(LOCAL_MODULE)
$(installtarget) : PRIVATE_MODULE := $(LOCAL_MODULE)
$(installtarget) : PRIVATE_FINAL_MODULE := $(LOCAL_FINAL_MODULE)
$(installtarget) : PRIVATE_COPY_FILES := $(copy_files)
$(installtarget) ::
@echo "Install: $(PRIVATE_MODULE)"
# create directories
$(Q)install -d $(DESTDIR)$(PREFIX)/bin
$(Q)install -d $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)
# install executables and shared libraries in lib/<package> directory
ifeq ("$(LOCAL_BUILDING_STATIC_LIBRARY)","")
$(Q)install $(PRIVATE_FINAL_MODULE) $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)
endif
# install files copied verbatim
ifneq ("$(strip $(copy_files))","")
$(Q)install $(PRIVATE_COPY_FILES) $(DESTDIR)$(PREFIX)/lib/$(PACKAGE)
endif
# create a link for executables in bin
ifeq ("$(LOCAL_BUILDING_EXECUTABLE)","1")
$(Q)ln -s ../lib/$(PACKAGE)/$(PRIVATE_MODULE) $(DESTDIR)$(PREFIX)/bin/$(PRIVATE_MODULE)
endif
## Provide a short-hand for building this module.
.PHONY: $(LOCAL_MODULE)
$(LOCAL_MODULE): $(LOCAL_BUILT_MODULE) $(LOCAL_FINAL_MODULE)
###############################################################################
## Precompiled headers.
###############################################################################
LOCAL_PRECOMPILED_FILE := $(strip $(LOCAL_PRECOMPILED_FILE))
ifneq ("$(LOCAL_PRECOMPILED_FILE)","")
gch_file := $(intermediates)/$(LOCAL_PRECOMPILED_FILE).gch
# All objects will depends on the precompiled file
$(all_objects): $(gch_file)
# Generate the precompiled file
$(gch_file): $(TOP_DIR)/$(LOCAL_PATH)/$(LOCAL_PRECOMPILED_FILE)
$(transform-h-to-gch)
-include $(gch_file:%.gch=%.d)
endif
###############################################################################
# Rule-specific variable definitions.
###############################################################################
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_PATH := $(LOCAL_PATH)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_MODULE := $(LOCAL_MODULE)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(LOCAL_CFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(LOCAL_C_INCLUDES)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(LOCAL_CPPFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RCFLAGS := $(LOCAL_RCFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(LOCAL_ARFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(LOCAL_LDFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(LOCAL_LDLIBS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(all_objects)

22
Build/coreLinux/shared.mk Normal file
View File

@ -0,0 +1,22 @@
###############################################################################
## @file shared.mk
## @author Y.M. Morgan
## @date 2011/05/14
##
## Build a shared library.
###############################################################################
LOCAL_MODULE_SUFFIX := $(TARGET_SHARED_LIB_SUFFIX)
LOCAL_BUILDING_SHARED_LIBRARY := 1
include $(RULES)
# Generate .dll.a file under mingw32
ifeq ("$(OS_MINGW32)","1")
$(LOCAL_BUILT_MODULE)$(TARGET_STATIC_LIB_SUFFIX): $(LOCAL_BUILT_MODULE)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS += \
-Wl,--out-implib -Wl,$(LOCAL_BUILT_MODULE)$(TARGET_STATIC_LIB_SUFFIX)
endif
$(LOCAL_BUILT_MODULE): $(all_objects) $(all_libraries)
$(transform-o-to-shared-lib)

19
Build/coreLinux/static.mk Normal file
View File

@ -0,0 +1,19 @@
###############################################################################
## @file static.mk
## @author Y.M. Morgan
## @date 2011/05/14
##
## Build a static library.
###############################################################################
LOCAL_MODULE_SUFFIX := $(TARGET_STATIC_LIB_SUFFIX)
LOCAL_BUILDING_STATIC_LIBRARY := 1
include $(RULES)
#$(info plopppppp=$(LOCAL_BUILT_MODULE)= $(all_libraries))
$(LOCAL_BUILT_MODULE): $(all_libraries) $(all_objects)
$(transform-o-to-static-lib)
LIB_EXTERN_C_INCLUDE := $(LIB_EXTERN_C_INCLUDE) $(LOCAL_EXPORT_C_INCLUDES)
LIB_EXTERN_LDLIBS := $(LIB_EXTERN_LDLIBS) $(LOCAL_EXPORT_LDLIBS)

79
Build/ewol.mk Normal file
View File

@ -0,0 +1,79 @@
EWOL_VERSION_TAG=$(shell cd $(EWOL_FOLDER); git describe --tags)
#$(info $(VERSION_TAG))
EWOL_VERSION_TAG_SHORT=$(shell cd $(EWOL_FOLDER); git describe --tags --abbrev=0)
#$(info $(VERSION_TAG_SHORT))
###############################################################################
### Compilation Define ###
###############################################################################
ifeq ("$(DEBUG)", "0")
EWOL_CXXFLAGS = -DETK_DEBUG_LEVEL=1
EWOL_CXXFLAGS+= -DEWOL_DEBUG_LEVEL=1
EWOL_CXXFLAGS+= -DNDEBUG
EWOL_CXXFLAGS+= -DEWOL_VERSION_TAG_NAME="\"$(EWOL_VERSION_TAG)-release\""
else
EWOL_CXXFLAGS = -DETK_DEBUG_LEVEL=3
EWOL_CXXFLAGS+= -DEWOL_DEBUG_LEVEL=3
EWOL_CXXFLAGS+= -DEWOL_VERSION_TAG_NAME="\"$(EWOL_VERSION_TAG)-debug\""
endif
EWOL_CXXFLAGS+= -DVERSION_BUILD_TIME="\"$(BUILD_TIME)\""
# tiny XML (extern OPEN Sources) :
EWOL_CXXFILES += tinyXML/tinyxml.cpp \
tinyXML/tinyxmlparser.cpp \
tinyXML/tinyxmlerror.cpp \
tinyXML/tinystr.cpp
# Ewol Tool Kit :
EWOL_CXXFILES += etk/Debug.cpp \
etk/DebugInternal.cpp \
etk/Memory.cpp \
etk/String.cpp \
etk/Stream.cpp \
etk/File.cpp \
etk/RegExp.cpp
# Ewol Sources :
EWOL_CXXFILES += ewol/ewol.cpp \
ewol/Debug.cpp \
ewol/OObject.cpp \
ewol/OObject/2DText.cpp \
ewol/OObject/2DColored.cpp \
ewol/OObject/2DTextured.cpp \
ewol/Texture.cpp
ifeq ("$(FREETYPE_CFLAGS)", "")
EWOL_CXXFILES += ewol/FontBitmap.cpp
else
EWOL_CXXFILES += ewol/FontFreeType.cpp
endif
EWOL_CXXFILES += ewol/Widget.cpp \
ewol/WidgetManager.cpp \
ewol/Windows.cpp
# list of widgets :
EWOL_CXXFILES += ewol/widget/Button.cpp \
ewol/widget/CheckBox.cpp \
ewol/widget/Entry.cpp \
ewol/widget/List.cpp \
ewol/widget/SizerHori.cpp \
ewol/widget/SizerVert.cpp
# only to test son internal element ...
EWOL_CXXFILES += ewol/widget/Test.cpp
# theme management :
EWOL_CXXFILES += ewol/themeManager.cpp \
ewol/theme/Theme.cpp \
ewol/theme/EolElement.cpp \
ewol/theme/EolElementFrame.cpp \
ewol/theme/EolColor.cpp \
ewol/theme/EolBase.cpp \
ewol/theme/EolBaseCircle.cpp \
ewol/theme/EolBaseCirclePart.cpp \
ewol/theme/EolBaseLine.cpp \
ewol/theme/EolBasePolygone.cpp \
ewol/theme/EolBaseRect.cpp \
ewol/theme/EolBaseTriangle.cpp

231
Java/PROJECT_NAME.java Normal file
View File

@ -0,0 +1,231 @@
package com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.app.Activity;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.KeyEvent;
// For No Title :
import android.view.Window;
// For the full screen :
import android.view.WindowManager;
import java.io.File;
import android.content.Context;
import android.content.res.Configuration;
// For the getting apk name :
import android.content.pm.ActivityInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.res.AssetFileDescriptor;
import android.content.res.AssetManager;
/**
* @brief Class :
*
*/
public class __PROJECT_NAME__ extends Activity {
private static native void ActivityOnCreate();
private static native void ActivityOnStart();
private static native void ActivityOnReStart();
private static native void ActivityOnResume();
private static native void ActivityOnPause();
private static native void ActivityOnStop();
private static native void ActivityOnDestroy();
private static native void ActivityParamSetArchiveDir(int mode, String myString);
private GLSurfaceView mGLView;
static {
System.loadLibrary("__PROJECT_PACKAGE__");
}
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the application directory
ActivityParamSetArchiveDir(1, getFilesDir().toString());
ActivityParamSetArchiveDir(2, getCacheDir().toString());
// to enable extarnal storage: add in the manifest the restriction needed ...
//ActivityParamSetArchiveDir(3, getExternalCacheDir().toString());
// return apk file path (or null on error)
String apkFilePath = null;
ApplicationInfo appInfo = null;
PackageManager packMgmr = getPackageManager();
try {
appInfo = packMgmr.getApplicationInfo("com.__PROJECT_VENDOR__.__PROJECT_PACKAGE__", 0);
} catch (NameNotFoundException e) {
e.printStackTrace();
throw new RuntimeException("Unable to locate assets, aborting...");
}
apkFilePath = appInfo.sourceDir;
ActivityParamSetArchiveDir(0, apkFilePath);
// call C init ...
ActivityOnCreate();
// Remove the title of the current display :
requestWindowFeature(Window.FEATURE_NO_TITLE);
// set full screen Mode :
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
//Force landscape
//setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
// create bsurface system
mGLView = new EwolGLSurfaceView(this);
setContentView(mGLView);
}
@Override protected void onStart() {
super.onStart();
// call C
ActivityOnStart();
}
@Override protected void onRestart() {
super.onRestart();
// call C
ActivityOnReStart();
}
@Override protected void onResume() {
super.onResume();
mGLView.onResume();
// call C
ActivityOnResume();
}
@Override protected void onPause() {
super.onPause();
mGLView.onPause();
// call C
ActivityOnPause();
}
@Override protected void onStop() {
super.onStop();
// call C
ActivityOnStop();
}
@Override protected void onDestroy() {
super.onDestroy();
// call C
ActivityOnDestroy();
}
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
}
/**
* @brief Class :
*
*/
class EwolGLSurfaceView extends GLSurfaceView {
private static native void nativeApplicationInit();
private static native void nativeApplicationUnInit();
private static native void nativeEventInputMotion(int pointerID, float x, float y);
private static native void nativeEventInputState(int pointerID, boolean isDown, float x, float y);
private static native void nativeEventUnknow(int eventID);
public EwolGLSurfaceView(Context context) {
// super must be first statement in constructor
super(context);
// je n'ai pas compris ...
mRenderer = new EwolRenderer();
setRenderer(mRenderer);
nativeApplicationInit();
}
private boolean InputDown1 = false;
private boolean InputDown2 = false;
private boolean InputDown3 = false;
public boolean onTouchEvent(final MotionEvent event) {
// Wrapper on input events :
int tmpActionType = event.getAction();
if (tmpActionType == MotionEvent.ACTION_MOVE) {
final int pointerCount = event.getPointerCount();
for (int p = 0; p < pointerCount; p++) {
nativeEventInputMotion(event.getPointerId(p), (float)event.getX(p), (float)event.getY(p));
}
} else if( tmpActionType == MotionEvent.ACTION_POINTER_1_DOWN
|| tmpActionType == MotionEvent.ACTION_DOWN) {
nativeEventInputState(event.getPointerId(0), true, (float)event.getX(0), (float)event.getY(0));
InputDown1 = true;
} else if(tmpActionType == MotionEvent.ACTION_POINTER_1_UP) {
nativeEventInputState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
InputDown1 = false;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_2_DOWN) {
nativeEventInputState(event.getPointerId(1), true, (float)event.getX(1), (float)event.getY(1));
InputDown2 = true;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_2_UP) {
nativeEventInputState(event.getPointerId(1), false, (float)event.getX(1), (float)event.getY(1));
InputDown2 = false;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_3_DOWN) {
nativeEventInputState(event.getPointerId(2), true, (float)event.getX(2), (float)event.getY(2));
InputDown3 = true;
} else if (tmpActionType == MotionEvent.ACTION_POINTER_3_UP) {
nativeEventInputState(event.getPointerId(2), false, (float)event.getX(2), (float)event.getY(2));
InputDown3 = false;
} else if(tmpActionType == MotionEvent.ACTION_UP){
if (InputDown1) {
nativeEventInputState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
InputDown1 = false;
} else if (InputDown2) {
nativeEventInputState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
InputDown2 = false;
} else {
nativeEventInputState(event.getPointerId(0), false, (float)event.getX(0), (float)event.getY(0));
InputDown3 = false;
}
}
return true;
}
public boolean onKeyDown (int keyCode, KeyEvent event){
// TODO ...
return true;
}
EwolRenderer mRenderer;
}
/**
* @brief Class :
*
*/
class EwolRenderer implements GLSurfaceView.Renderer {
private static native void nativeInit();
private static native void nativeResize(int w, int h);
private static native void nativeRender();
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
nativeInit();
}
public void onSurfaceChanged(GL10 gl, int w, int h) {
nativeResize(w, h);
}
public void onDrawFrame(GL10 gl) {
nativeRender();
}
}

View File

@ -0,0 +1,148 @@
/**
*******************************************************************************
* @file ewolAndroidAbstraction.cpp
* @brief User abstraction for Android (Sources)
* @author Edouard DUPIN
* @date 14/12/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <jni.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <pthread.h>
#include <tools_debug.h>
#include <ewol/threadMsg.h>
// declaration of the ewol android abstraction ...
void EWOL_SystemStart(void);
void EWOL_SystemStop(void);
void EWOL_ThreadSetArchiveDir(int mode, const char* str);
void EWOL_ThreadResize(int w, int h );
void EWOL_ThreadEventInputMotion(int pointerID, float x, float y);
void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y);
void EWOL_NativeRender(void);
void EWOL_NativeGLDestroy(void);
extern "C"
{
/* Call to initialize the graphics state */
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityParamSetArchiveDir( JNIEnv* env, jobject thiz, jint mode, jstring myString)
{
// direct setting of the date in the string system ...
const char* str = env->GetStringUTFChars(myString,0);
EWOL_ThreadSetArchiveDir(mode, str);
//env->ReleaseStringUTFChars(str,myString,0);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnCreate( JNIEnv* env )
{
EDN_DEBUG("*******************************************");
EDN_DEBUG("** Activity On Create **");
EDN_DEBUG("*******************************************");
EWOL_SystemStart();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnStart( JNIEnv* env )
{
EDN_DEBUG("*******************************************");
EDN_DEBUG("** Activity On Start **");
EDN_DEBUG("*******************************************");
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnReStart( JNIEnv* env )
{
EDN_DEBUG("*******************************************");
EDN_DEBUG("** Activity On Re-Start **");
EDN_DEBUG("*******************************************");
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnResume( JNIEnv* env )
{
EDN_DEBUG("*******************************************");
EDN_DEBUG("** Activity On Resume **");
EDN_DEBUG("*******************************************");
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnPause( JNIEnv* env )
{
EDN_DEBUG("*******************************************");
EDN_DEBUG("** Activity On Pause **");
EDN_DEBUG("*******************************************");
// All the openGl has been destroyed ...
// TODO : Mark all the texture to be reloaded ...
EWOL_NativeGLDestroy();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnStop( JNIEnv* env )
{
EDN_DEBUG("*******************************************");
EDN_DEBUG("** Activity On Stop **");
EDN_DEBUG("*******************************************");
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE_____PROJECT_NAME___ActivityOnDestroy( JNIEnv* env )
{
EDN_DEBUG("*******************************************");
EDN_DEBUG("** Activity On Destroy **");
EDN_DEBUG("*******************************************");
EWOL_SystemStop();
}
/* Call to initialize the graphics state */
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolRenderer_nativeInit( JNIEnv* env )
{
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolRenderer_nativeResize( JNIEnv* env, jobject thiz, jint w, jint h )
{
EWOL_ThreadResize(w, h);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeEventInputMotion( JNIEnv* env, jobject thiz, jint pointerID, jfloat x, jfloat y )
{
EWOL_ThreadEventInputMotion(pointerID+1, x, y);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeEventInputState( JNIEnv* env, jobject thiz, jint pointerID, jboolean isUp, jfloat x, jfloat y )
{
EWOL_ThreadEventInputState(pointerID+1, isUp, x, y);
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeApplicationInit( JNIEnv* env)
{
//ewol::threadMsg::SendMessage(androidJniMsg, JNI_APP_INIT);
//EWOL_NativeApplicationInit();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolGLSurfaceView_nativeApplicationUnInit( JNIEnv* env)
{
//ewol::threadMsg::SendMessage(androidJniMsg, JNI_APP_UN_INIT);
//EWOL_NativeApplicationUnInit();
}
void Java_com___PROJECT_VENDOR_____PROJECT_PACKAGE___EwolRenderer_nativeRender( JNIEnv* env )
{
EWOL_NativeRender();
}
}

373
LICENSE
View File

@ -1,373 +0,0 @@
Mozilla Public License Version 2.0
==================================
1. Definitions
--------------
1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
by a Contributor and that particular Contributor's Contribution.
1.3. "Contribution"
means Covered Software of a particular Contributor.
1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
1.5. "Incompatible With Secondary Licenses"
means
(a) that the initial Contributor has attached the notice described
in Exhibit B to the Covered Software; or
(b) that the Covered Software was made available under the terms of
version 1.1 or earlier of the License, but not also under the
terms of a Secondary License.
1.6. "Executable Form"
means any form of the work other than Source Code Form.
1.7. "Larger Work"
means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
1.8. "License"
means this document.
1.9. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
1.10. "Modifications"
means any of the following:
(a) any file in Source Code Form that results from an addition to,
deletion from, or modification of the contents of Covered
Software; or
(b) any new file in Source Code Form that contains any Covered
Software.
1.11. "Patent Claims" of a Contributor
means any patent claim(s), including without limitation, method,
process, and apparatus claims, in any patent Licensable by such
Contributor that would be infringed, but for the grant of the
License, by the making, using, selling, offering for sale, having
made, import, or transfer of either its Contributions or its
Contributor Version.
1.12. "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
1.13. "Source Code Form"
means the form of the work preferred for making modifications.
1.14. "You" (or "Your")
means an individual or a legal entity exercising rights under this
License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
2. License Grants and Conditions
--------------------------------
2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
non-exclusive license:
(a) under intellectual property rights (other than patent or trademark)
Licensable by such Contributor to use, reproduce, make available,
modify, display, perform, distribute, and otherwise exploit its
Contributions, either on an unmodified basis, with Modifications, or
as part of a Larger Work; and
(b) under Patent Claims of such Contributor to make, use, sell, offer
for sale, have made, import, and otherwise transfer either its
Contributions or its Contributor Version.
2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
become effective for each Contribution on the date the Contributor first
distributes such Contribution.
2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
distribution or licensing of Covered Software under this License.
Notwithstanding Section 2.1(b) above, no patent license is granted by a
Contributor:
(a) for any code that a Contributor has removed from Covered Software;
or
(b) for infringements caused by: (i) Your and any other third party's
modifications of Covered Software, or (ii) the combination of its
Contributions with other software (except as part of its Contributor
Version); or
(c) under Patent Claims infringed by Covered Software in the absence of
its Contributions.
This License does not grant any rights in the trademarks, service marks,
or logos of any Contributor (except as may be necessary to comply with
the notice requirements in Section 3.4).
2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
License (see Section 10.2) or under the terms of a Secondary License (if
permitted under the terms of Section 3.3).
2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
3. Responsibilities
-------------------
3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
attempt to alter or restrict the recipients' rights in the Source Code
Form.
3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
(b) You may distribute such Executable Form under the terms of this
License, or sublicense it under different terms, provided that the
license for the Executable Form does not attempt to limit or alter
the recipients' rights in the Source Code Form under this License.
3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
the Covered Software. If the Larger Work is a combination of Covered
Software with a work governed by one or more Secondary Licenses, and the
Covered Software is not Incompatible With Secondary Licenses, this
License permits You to additionally distribute such Covered Software
under the terms of such Secondary License(s), so that the recipient of
the Larger Work may, at their option, further distribute the Covered
Software under the terms of either this License or such Secondary
License(s).
3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
3.5. Application of Additional Terms
You may choose to offer, and to charge a fee for, warranty, support,
indemnity or liability obligations to one or more recipients of Covered
Software. However, You may do so only on Your own behalf, and not on
behalf of any Contributor. You must make it absolutely clear that any
such warranty, support, indemnity, or liability obligation is offered by
You alone, and You hereby agree to indemnify every Contributor for any
liability incurred by such Contributor as a result of warranty, support,
indemnity or liability terms You offer. You may include additional
disclaimers of warranty and limitations of liability specific to any
jurisdiction.
4. Inability to Comply Due to Statute or Regulation
---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
5. Termination
--------------
5.1. The rights granted under this License will terminate automatically
if You fail to comply with any of its terms. However, if You become
compliant, then the rights granted under this License from a particular
Contributor are reinstated (a) provisionally, unless and until such
Contributor explicitly and finally terminates Your grants, and (b) on an
ongoing basis, if such Contributor fails to notify You of the
non-compliance by some reasonable means prior to 60 days after You have
come back into compliance. Moreover, Your grants from a particular
Contributor are reinstated on an ongoing basis if such Contributor
notifies You of the non-compliance by some reasonable means, this is the
first time You have received notice of non-compliance with this License
from such Contributor, and You become compliant prior to 30 days after
Your receipt of the notice.
5.2. If You initiate litigation against any entity by asserting a patent
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
directly or indirectly infringes any patent, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
************************************************************************
* *
* 6. Disclaimer of Warranty *
* ------------------------- *
* *
* Covered Software is provided under this License on an "as is" *
* basis, without warranty of any kind, either expressed, implied, or *
* statutory, including, without limitation, warranties that the *
* Covered Software is free of defects, merchantable, fit for a *
* particular purpose or non-infringing. The entire risk as to the *
* quality and performance of the Covered Software is with You. *
* Should any Covered Software prove defective in any respect, You *
* (not any Contributor) assume the cost of any necessary servicing, *
* repair, or correction. This disclaimer of warranty constitutes an *
* essential part of this License. No use of any Covered Software is *
* authorized under this License except under this disclaimer. *
* *
************************************************************************
************************************************************************
* *
* 7. Limitation of Liability *
* -------------------------- *
* *
* Under no circumstances and under no legal theory, whether tort *
* (including negligence), contract, or otherwise, shall any *
* Contributor, or anyone who distributes Covered Software as *
* permitted above, be liable to You for any direct, indirect, *
* special, incidental, or consequential damages of any character *
* including, without limitation, damages for lost profits, loss of *
* goodwill, work stoppage, computer failure or malfunction, or any *
* and all other commercial damages or losses, even if such party *
* shall have been informed of the possibility of such damages. This *
* limitation of liability shall not apply to liability for death or *
* personal injury resulting from such party's negligence to the *
* extent applicable law prohibits such limitation. Some *
* jurisdictions do not allow the exclusion or limitation of *
* incidental or consequential damages, so this exclusion and *
* limitation may not apply to You. *
* *
************************************************************************
8. Litigation
-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
Nothing in this Section shall prevent a party's ability to bring
cross-claims or counter-claims.
9. Miscellaneous
----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
10. Versions of the License
---------------------------
10.1. New Versions
Mozilla Foundation is the license steward. Except as provided in Section
10.3, no one other than the license steward has the right to modify or
publish new versions of this License. Each version will be given a
distinguishing version number.
10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
10.4. Distributing Source Code Form that is Incompatible With Secondary
Licenses
If You choose to distribute Source Code Form that is Incompatible With
Secondary Licenses under the terms of this version of the License, the
notice described in Exhibit B of this License must be attached.
Exhibit A - Source Code Form License Notice
-------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
Exhibit B - "Incompatible With Secondary Licenses" Notice
---------------------------------------------------------
This Source Code Form is "Incompatible With Secondary Licenses", as
defined by the Mozilla Public License, v. 2.0.

137
README.md
View File

@ -1,128 +1,41 @@
Ewol
Edn
====
`Ewol` (Edn Widget OpenGl Layer) is a FREE software.
Release (master)
----------------
[![Build Status](https://travis-ci.org/atria-soft/ewol.svg?branch=master)](https://travis-ci.org/atria-soft/ewol)
[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/ewol.svg?branch=master)](http://atria-soft.com/ci/atria-soft/ewol)
[![Test Status](http://atria-soft.com/ci/test/atria-soft/ewol.svg?branch=master)](http://atria-soft.com/ci/atria-soft/ewol)
[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/ewol.svg?branch=master)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=master&tag=Linux)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=master&tag=MacOs)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=master&tag=Mingw)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=master&tag=Android)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=master&tag=IOs)](http://atria-soft.com/ci/atria-soft/ewol)
Developement (dev)
------------------
[![Build Status](https://travis-ci.org/atria-soft/ewol.svg?branch=dev)](https://travis-ci.org/atria-soft/ewol)
[![Coverage Status](http://atria-soft.com/ci/coverage/atria-soft/ewol.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/ewol)
[![Test Status](http://atria-soft.com/ci/test/atria-soft/ewol.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/ewol)
[![Warning Status](http://atria-soft.com/ci/warning/atria-soft/ewol.svg?branch=dev)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=dev&tag=Linux)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=dev&tag=MacOs)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=dev&tag=Mingw)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=dev&tag=Android)](http://atria-soft.com/ci/atria-soft/ewol)
[![Build Status](http://atria-soft.com/ci/build/atria-soft/ewol.svg?branch=dev&tag=IOs)](http://atria-soft.com/ci/atria-soft/ewol)
This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.
Instructions
============
download Build system:
----------------------
download the software :
sudo pip install lutin
sudo pip install pillow
git clone git://github.com/HeeroYui/ewol.git
cd edn
need google repo:
-----------------
Compile software and install :
see: http://source.android.com/source/downloading.html#installing-repo
sudo make DEBUG=0 install
mkdir ~/.bin
PATH=~/.bin:$PATH
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/.bin/repo
chmod a+x ~/.bin/repo
Run Software :
???
download the software:
----------------------
License
=======
mkdir WORKING_DIRECTORY
cd WORKING_DIRECTORY
repo init -u git://github.com/atria-soft/manifest.git
repo sync -j8
Compile software and test:
--------------------------
lutin ewol-*
Dependency packages
===================
Ubuntu Or Debian:
sudo apt-get install g++ libgl1-mesa-dev zlib1g-dev libasound2-dev
# Compile with Clang:
sudo apt-get install clang
# For andoid compilation (jdk 7 does not work...):
sudo apt-get install javacc openjdk-6-jdk
# Cross compile for windows:
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-mingw-w64
# On 64 bits processor for compatibility:
sudo apt-get install ia32-libs
sudo apt-get install g++-multilib libc6-dev-i386
Arch-linux:
# Cross compile for windows:
pacman -S mingw-w64-gcc
You can:
- Redistribute the sources code and binaries.
- Modify the Sources code.
- Use a part of the sources (less than 50%) in an other software, just write somewhere "Edn is great" visible by the user (on your product or on your website with a link to my page).
- Redistribute the modification only if you want.
- Send me the bug-fix (it could be great).
- Pay me a beer or some other things.
- Print the source code on WC paper ...
You can NOT:
- Earn money with this Software (But I can).
- Add malware in the Sources.
- Do something bad with the sources.
- Use it to travel in the space with a toaster.
# Cross compile for Android:
in /etc/pacman.conf file uncomment:
[multilib]
Include = /etc/pacman.d/mirrorlist
# update the system:
Pacman -Syu
# install lib C:
pacman -S lib32-glibc lib32-zlib lib32-gcc-libs
# install open-jdk 7.0
pacman -S jdk7-openjdk
# connect adb: (and you can do a "android/sdk/platform-tools/adb shell" to enable computer key on device)
pacman -S android-udev
Simple framework overview
=========================
![overview](overview.svg)
License (MPL v2.0)
==================
Copyright ewol Edouard DUPIN
Licensed under the Mozilla Public License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.mozilla.org/MPL/2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
I reserve the right to change this licence. If it change the version of the copy you have keep its own license

2
Sources/Android.mk Normal file
View File

@ -0,0 +1,2 @@
LOCAL_PATH := $(call my-dir)
include $(call all-subdir-makefiles)

32
Sources/libetk/Android.mk Normal file
View File

@ -0,0 +1,32 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := etk
LOCAL_STATIC_LIBRARIES := libzip
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CFLAGS := -D__PLATFORM__Android \
-Wno-write-strings \
-DDATA_IN_APK \
-DETK_DEBUG_LEVEL=3
LOCAL_SRC_FILES := $(FILE_LIST)
# Ewol Test Software :
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz
include $(BUILD_STATIC_LIBRARY)

41
Sources/libetk/Linux.mk Normal file
View File

@ -0,0 +1,41 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := etk
LOCAL_STATIC_LIBRARIES := libzip
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS :=
ifeq ($(DEBUG),1)
LOCAL_CFLAGS := -D__PLATFORM__Linux \
-Wno-write-strings \
-DETK_DEBUG_LEVEL=3 \
-DEWOL_DEBUG_LEVEL=3 \
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
-DVERSION_BUILD_TIME="\"pasd_heure\""
else
LOCAL_CFLAGS := -D__PLATFORM__Linux \
-Wno-write-strings \
-DETK_DEBUG_LEVEL=1 \
-DEWOL_DEBUG_LEVEL=1 \
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
-DVERSION_BUILD_TIME="\"pasd_heure\""
endif
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_SRC_FILES := $(FILE_LIST)
#for freetype : https://github.com/cdave1/freetype2-android
# Ewol Test Software :
LOCAL_LDLIBS :=
include $(BUILD_STATIC_LIBRARY)

View File

@ -0,0 +1,75 @@
/**
*******************************************************************************
* @file etk/Debug.h
* @brief Ewol Tool Kit : log implementation
* @author Edouard DUPIN
* @date 08/06/2010
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Debug.h>
#include <time.h>
// Max string size : (wide screan console nb caractere)
#define EDN_LOG_MAX_LENGTH 250
#define FUNCTION_NAME_SIZE (70)
void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName)
{
char tmpName[FUNCTION_NAME_SIZE] = "";
if (NULL == className) {
if (NULL == libName) {
snprintf(tmpName, FUNCTION_NAME_SIZE, "???????? | (l=%5d) %s ",ligne, funcName);
} else {
snprintf(tmpName, FUNCTION_NAME_SIZE, "%s | (l=%5d) %s ",libName, ligne, funcName);
}
} else {
if (NULL == libName) {
snprintf(tmpName, FUNCTION_NAME_SIZE, "???????? | (l=%5d) %s::%s ",ligne, className, funcName);
} else {
snprintf(tmpName, FUNCTION_NAME_SIZE, "%s | (l=%5d) %s::%s ", libName, ligne, className, funcName);
}
}
tmpName[FUNCTION_NAME_SIZE-4] = ' ';
tmpName[FUNCTION_NAME_SIZE-3] = '|';
tmpName[FUNCTION_NAME_SIZE-2] = ' ';
tmpName[FUNCTION_NAME_SIZE-1] = '\0';
etk::cout << tmpName;
}
void TOOLS_DisplayTime(void)
{
char tmpdata[50];
#ifdef __PLATFORM__Android
struct timeval now;
gettimeofday(&now, NULL);
sprintf(tmpdata, " %2dh %2dmin %2ds | ", (int32_t)(now.tv_sec/3600)%24, (int32_t)(now.tv_sec/60)%60, (int32_t)(now.tv_sec%60));
#else
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(tmpdata, " %2dh %2dmin %2ds | ", (timeinfo->tm_hour)%24, timeinfo->tm_min, timeinfo->tm_sec);
#endif
etk::cout << tmpdata ;
}

View File

@ -0,0 +1,97 @@
/**
*******************************************************************************
* @file etk/Debug.h
* @brief Ewol Tool Kit : log implementation
* @author Edouard DUPIN
* @date 08/06/2010
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_DEBUG_H__
#define __ETK_DEBUG_H__
#include <etk/Stream.h>
#include <etk/Types.h>
// Log Message System For EDN
void TOOLS_DisplayFuncName(int32_t ligne, const char* className, const char* funcName, const char* libName);
void TOOLS_DisplayTime(void);
//regular colors
#define ETK_BASH_COLOR_BLACK "\e[0;30m"
#define ETK_BASH_COLOR_RED "\e[0;31m"
#define ETK_BASH_COLOR_GREEN "\e[0;32m"
#define ETK_BASH_COLOR_YELLOW "\e[0;33m"
#define ETK_BASH_COLOR_BLUE "\e[0;34m"
#define ETK_BASH_COLOR_MAGENTA "\e[0;35m"
#define ETK_BASH_COLOR_CYAN "\e[0;36m"
#define ETK_BASH_COLOR_WHITE "\e[0;37m"
//emphasized (bolded) colors
#define ETK_BASH_COLOR_BOLD_BLACK "\e[1;30m"
#define ETK_BASH_COLOR_BOLD_RED "\e[1;31m"
#define ETK_BASH_COLOR_BOLD_GREEN "\e[1;32m"
#define ETK_BASH_COLOR_BOLD_YELLOW "\e[1;33m"
#define ETK_BASH_COLOR_BOLD_BLUE "\e[1;34m"
#define ETK_BASH_COLOR_BOLD_MAGENTA "\e[1;35m"
#define ETK_BASH_COLOR_BOLD_CYAN "\e[1;36m"
#define ETK_BASH_COLOR_BOLD_WHITE "\e[1;37m"
//background colors
#define ETK_BASH_COLOR_BG_BLACK "\e[40m"
#define ETK_BASH_COLOR_BG_RED "\e[41m"
#define ETK_BASH_COLOR_BG_GREEN "\e[42m"
#define ETK_BASH_COLOR_BG_YELLOW "\e[43m"
#define ETK_BASH_COLOR_BG_BLUE "\e[44m"
#define ETK_BASH_COLOR_BG_MAGENTA "\e[45m"
#define ETK_BASH_COLOR_BG_CYAN "\e[46m"
#define ETK_BASH_COLOR_BG_WHITE "\e[47m"
// Return to the normal color setings
#define ETK_BASH_COLOR_NORMAL "\e[0m"
//go to the Top of bash
#define ETK_BASH_GO_TOP "\e[0;0f"
#undef __class__
#define __class__ (NULL)
#define ETK_DBG_COMMON(libName, color, info, data) do { \
etk::cout << etk::cstart << color; \
TOOLS_DisplayTime(); \
TOOLS_DisplayFuncName(__LINE__, __class__, __func__, libName); \
etk::cout << "[" << info << "] " << data; \
etk::cout << ETK_BASH_COLOR_NORMAL <<etk::endl; \
}while(0)
#define ETK_CRITICAL(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_BOLD_RED, 'C', data)
#define ETK_WARNING(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_MAGENTA, 'W', data)
#define ETK_ERROR(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_BOLD_RED, 'E', data)
#define ETK_INFO(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_CYAN, 'I', data)
#define ETK_DEBUG(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_YELLOW, 'D', data)
#define ETK_VERBOSE(libName, data) ETK_DBG_COMMON(libName, ETK_BASH_COLOR_WHITE, 'V', data)
#define ETK_ASSERT(libName, cond, data) do { \
if (!(cond)) { \
ETK_CRITICAL(libName, data); \
assert(!#cond); \
} \
} while (0)
#define ETK_CHECK_INOUT_ASSERT(libName, cond) ETK_ASSERT(libName, (cond), "Internal input error : "#cond)
#define ETK_CHECK_INOUT_WARNING(libName, cond) do { \
if (!(cond)) { \
ETK_CRITICAL(libName, "Internal input error : "#cond); \
} \
} while (0)
#define ETK_CHECK_MAGIC(libName, cond) ETK_ASSERT(libName, (cond), "MAGIC check error : "#cond)
#endif

View File

@ -0,0 +1,25 @@
/**
*******************************************************************************
* @file etk/DebugInternal.cpp
* @brief Ewol Tool Kit : log wrapper (sources)
* @author Edouard DUPIN
* @date 19/10/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
const char * etkLibName = "Etk ";

View File

@ -0,0 +1,71 @@
/**
*******************************************************************************
* @file etk/DebugInternal.h
* @brief Ewol Tool Kit : log wrapper (header)
* @author Edouard DUPIN
* @date 19/10/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_DEBUG_INTERNAL_H__
#define __ETK_DEBUG_INTERNAL_H__
#include "etk/Debug.h"
extern const char * etkLibName;
#define TK_CRITICAL(data) ETK_CRITICAL(etkLibName, data)
// General
#if ETK_DEBUG_LEVEL > 0
# define TK_WARNING(data) ETK_WARNING(etkLibName, data)
# define TK_ERROR(data) ETK_ERROR(etkLibName, data)
#else
# define TK_WARNING(data) do {}while(0)
# define TK_ERROR(data) do {}while(0)
#endif
#if ETK_DEBUG_LEVEL > 1
# define TK_INFO(data) ETK_INFO(etkLibName, data)
#else
# define TK_INFO(data) do {}while(0)
#endif
#if ETK_DEBUG_LEVEL > 2
# define TK_DEBUG(data) ETK_DEBUG(etkLibName, data)
#else
# define TK_DEBUG(data) do {}while(0)
#endif
#if ETK_DEBUG_LEVEL > 3
# define TK_VERBOSE(data) ETK_VERBOSE(etkLibName, data)
#else
# define TK_VERBOSE(data) do {}while(0)
#endif
#define TK_ASSERT(cond, data) ETK_ASSERT(etkLibName, cond, data)
#if ETK_DEBUG_LEVEL > 1
# define TK_CHECK_INOUT(cond) ETK_CHECK_INOUT_ASSERT(etkLibName, cond)
#elif ETK_DEBUG_LEVEL > 0
# define TK_CHECK_INOUT(cond) ETK_CHECK_INOUT_WARNING(etkLibName, cond)
#else
# define TK_CHECK_INOUT(cond) do { } while (0)
#endif
#endif

699
Sources/libetk/etk/File.cpp Normal file
View File

@ -0,0 +1,699 @@
/**
*******************************************************************************
* @file etk/File.cpp
* @brief Ewol Tool Kit : File folder and name abstraction (Sources)
* @author Edouard DUPIN
* @date 16/07/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Types.h>
#include <etk/DebugInternal.h>
#include <etk/File.h>
#include <unistd.h>
#if defined(DATA_IN_APK)
# include <stdio.h>
# include <zip/zip.h>
#endif
#undef __class__
#define __class__ "etk::File"
etk::CCout& etk::operator <<(etk::CCout &os, const etk::File &obj)
{
os << obj.m_folder;
os << "/";
os << obj.m_shortFilename;
return os;
}
etk::File::File(etk::UString &filename, etk::FileType_te type, int32_t LineNumber)
{
m_lineNumberOpen = LineNumber;
m_PointerFile = NULL;
SetCompleateName(filename, type);
}
etk::File::File(const char *filename, etk::FileType_te type, int32_t LineNumber)
{
etk::UString tmpString = filename;
m_lineNumberOpen = LineNumber;
m_PointerFile = NULL;
SetCompleateName(tmpString, type);
}
etk::File::File(etk::UString &filename, etk::UString &folder, etk::FileType_te type, int32_t lineNumber)
{
etk::UString tmpString = folder;
tmpString += "/";
tmpString += filename;
m_PointerFile = NULL;
SetCompleateName(tmpString, type);
m_lineNumberOpen = lineNumber;
}
etk::File::~File(void)
{
// nothing to do ...
if (NULL != m_PointerFile) {
TK_ERROR("Missing close the file : \"" << GetCompleateName() << "\"");
fClose();
}
}
etk::UString etk::File::GetFolder(void) const
{
return m_folder;
}
etk::UString etk::File::GetShortFilename(void) const
{
return m_shortFilename;
}
etk::UString etk::File::GetCompleateName(void) const
{
etk::UString out;
out = m_folder;
out += "/";
out += m_shortFilename;
return out;
}
const etk::File& etk::File::operator= (const etk::File &etkF )
{
if( this != &etkF ) // avoid copy to itself
{
m_folder = etkF.m_folder;
m_shortFilename = etkF.m_shortFilename;
m_lineNumberOpen = etkF.m_lineNumberOpen;
m_type = etkF.m_type;
if (NULL != m_PointerFile) {
TK_ERROR("Missing close the file : \"" << GetCompleateName() << "\"");
fClose();
}
#if defined(DATA_IN_APK)
m_idZipFile = etkF.m_idZipFile;
m_zipData = NULL;
m_zipDataSize = 0;
m_zipReadingOffset = 0;
//m_zipPointerFile = NULL;
#endif
}
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::File::operator== (const etk::File &etkF) const
{
if( this != &etkF ) {
if (etkF.GetCompleateName() == GetCompleateName() ) {
return true;
} else {
return false;
}
return true;
}
return true;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::File::operator!= (const etk::File &etkF) const
{
return !(*this == etkF);
}
etk::UString baseFolderData = "assets/";
#ifdef DATA_IN_APK
static etk::UString s_fileAPK = "";
static struct zip * s_APKArchive = NULL;
static int32_t s_APKnbFiles = 0;
static void loadAPK(etk::UString& apkPath)
{
TK_DEBUG("Loading APK \"" << apkPath << "\"");
s_APKArchive = zip_open(apkPath.Utf8Data(), 0, NULL);
TK_ASSERT(s_APKArchive != NULL, "Error loading APK ... \"" << apkPath << "\"");
//Just for debug, print APK contents
s_APKnbFiles = zip_get_num_files(s_APKArchive);
TK_INFO("List all files in the APK : " << s_APKnbFiles << " files");
for (int iii=0; iii<s_APKnbFiles; iii++) {
const char* name = zip_get_name(s_APKArchive, iii, 0);
if (name == NULL) {
TK_ERROR("Error reading zip file name at index " << iii << " : \"" << zip_strerror(s_APKArchive) << "\"");
return;
}
TK_INFO(" File " << iii << " : \"" << name << "\"");
}
}
#endif
etk::UString baseFolderDataUser = "~/.tmp/userData/";
etk::UString baseFolderCache = "~/.tmp/cache/";
// for specific device contraint :
void etk::SetBaseFolderData(const char * folder)
{
#if defined(DATA_IN_APK)
baseFolderData = "assets/";
s_fileAPK = folder;
loadAPK(s_fileAPK);
#else
baseFolderData = folder;
#endif
}
void etk::SetBaseFolderDataUser(const char * folder)
{
baseFolderDataUser = folder;
}
void etk::SetBaseFolderCache(const char * folder)
{
baseFolderCache = folder;
}
void etk::File::SetCompleateName(etk::UString &newFilename, etk::FileType_te type)
{
char buf[MAX_FILE_NAME];
memset(buf, 0, MAX_FILE_NAME);
char * ok;
#if defined(DATA_IN_APK)
m_idZipFile = -1;
m_zipData = NULL;
m_zipDataSize = 0;
m_zipReadingOffset = 0;
//m_zipPointerFile = NULL;
#endif
// Reset ALL DATA :
m_folder = "";
m_shortFilename = "";
m_lineNumberOpen = 0;
TK_DEBUG("1 :Set Name : " << newFilename );
etk::UString destFilename;
if (newFilename.Size() == 0) {
destFilename = "no-name";
} else {
destFilename = newFilename;
}
TK_DEBUG("2 : Get file Name : " << destFilename << "start with '/'=" << destFilename.StartWith('/'));
if (true == destFilename.StartWith('/')) {
m_type = etk::FILE_TYPE_DIRECT;
if (type != etk::FILE_TYPE_DIRECT) {
TK_DEBUG("Incompatible type with a file=\"" << newFilename << "\" ==> force it in direct mode ...");
}
} else {
if (type == etk::FILE_TYPE_DIRECT) {
//TK_WARNING("Incompatible type with a file=\"" << newFilename << "\" ==> force it in FILE_TYPE_DATA mode ...");
//m_type = etk::FILE_TYPE_DATA;
m_type = etk::FILE_TYPE_DIRECT;
// add current path :
// Get the command came from the running of the program :
char cCurrentPath[FILENAME_MAX];
if (!getcwd(cCurrentPath, FILENAME_MAX)) {
return;
}
cCurrentPath[FILENAME_MAX - 1] = '\0';
etk::UString tmpFilename = destFilename;
destFilename = cCurrentPath;
destFilename += "/";
destFilename += tmpFilename;
} else {
m_type = type;
}
}
bool needUnpack = false;
#if ETK_DEBUG_LEVEL > 2
char *mode = NULL;
#endif
switch (m_type)
{
case etk::FILE_TYPE_DATA:
{
#if ETK_DEBUG_LEVEL > 2
mode = "FILE_TYPE_DATA";
#endif
#if defined(DATA_IN_APK)
etk::UString tmpFilename = baseFolderData + destFilename;
for (int iii=0; iii<s_APKnbFiles; iii++) {
const char* name = zip_get_name(s_APKArchive, iii, 0);
if (name == NULL) {
return;
}
if (tmpFilename == name) {
m_idZipFile = iii;
break;
}
}
if (-1 == m_idZipFile) {
TK_ERROR("File Does not existed ... in APK : \"" << tmpFilename << "\"");
} else {
TK_INFO("File existed ... in APK : \"" << tmpFilename << "\" ==> id=" << m_idZipFile);
}
#else
//etk::UString tmpFilename = destFilename;
//destFilename = baseFolderData;
//destFilename += tmpFilename;
#endif
}
break;
case etk::FILE_TYPE_USER_DATA:
{
#if ETK_DEBUG_LEVEL > 2
mode = "FILE_TYPE_USER_DATA";
#endif
etk::UString tmpFilename = destFilename;
destFilename = baseFolderDataUser;
destFilename += tmpFilename;
}
needUnpack = true;
break;
case etk::FILE_TYPE_CACHE:
{
#if ETK_DEBUG_LEVEL > 2
mode = "FILE_TYPE_CACHE";
#endif
etk::UString tmpFilename = destFilename;
destFilename = baseFolderCache;
destFilename += tmpFilename;
}
needUnpack = true;
break;
default:
// nothing to do ...
#if ETK_DEBUG_LEVEL > 2
mode = "FILE_TYPE_DIRECT";
#endif
needUnpack = true;
break;
}
TK_DEBUG("3 : Get file Name : " << destFilename );
if (true == needUnpack) {
// Get the real Path of the current File
ok = realpath(destFilename.Utf8Data(), buf);
if (!ok) {
int32_t lastPos = destFilename.FindBack('/');
if (-1 != lastPos) {
// Get the FileName
etk::UString tmpFilename = destFilename.Extract(lastPos+1);
destFilename.Remove(lastPos, destFilename.Size() - lastPos);
TK_DEBUG("try to find :\"" << destFilename << "\" / \"" << tmpFilename << "\" ");
ok = realpath(destFilename.Utf8Data(), buf);
if (!ok) {
TK_DEBUG("Can not find real Path name of \"" << destFilename << "\"");
m_shortFilename = tmpFilename;
m_folder = destFilename;
} else {
// ALL is OK ...
m_shortFilename = tmpFilename;
m_folder = destFilename;
}
} else {
TK_DEBUG("file : \"" << destFilename << "\" ==> No data???");
// Basic ERROR ...
m_shortFilename = destFilename;
}
} else {
destFilename = buf;
int32_t lastPos = destFilename.FindBack('/');
if (-1 != lastPos) {
m_shortFilename = destFilename.Extract(lastPos+1);
m_folder = destFilename.Extract(0, lastPos);
} else {
// Basic ERROR ...
TK_DEBUG("file : \"" << destFilename << "\" ==> No data???");
m_shortFilename = destFilename;
}
}
} else {
int32_t lastPos = destFilename.FindBack('/');
if (-1 != lastPos) {
m_shortFilename = destFilename.Extract(lastPos+1);
m_folder = destFilename.Extract(0, lastPos);
} else {
// Basic ERROR ...
TK_DEBUG("file : \"" << destFilename << "\" ==> No data???");
m_shortFilename = destFilename;
}
}
TK_DEBUG("Set FileName :\"" << m_folder << "\" / \"" << m_shortFilename << "\" mode=" << mode);
}
int32_t etk::File::GetLineNumber(void)
{
return m_lineNumberOpen;
}
void etk::File::SetLineNumber(int32_t newline)
{
m_lineNumberOpen = newline;
}
bool etk::File::HasExtention(void)
{
int32_t lastPos = m_shortFilename.FindBack('.');
if( -1 != lastPos // not find the .
&& 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file
&& m_shortFilename.Size() != lastPos ) // Remove file ended with .
{
return true;
} else {
return false;
}
}
etk::UString etk::File::GetExtention(void)
{
etk::UString tmpExt = "";
int32_t lastPos = m_shortFilename.FindBack('.');
if( -1 != lastPos // not find the .
&& 0 != lastPos // Find a . at the fist position .jdlskjdfklj ==> hiden file
&& m_shortFilename.Size() != lastPos ) // Remove file ended with .
{
// Get the FileName
tmpExt = m_shortFilename.Extract(lastPos+1);
}
return tmpExt;
}
#ifdef DATA_IN_APK
bool etk::File::LoadDataZip(void)
{
if (NULL != m_zipData) {
return true;
} else {
struct zip_file * m_zipPointerFile= zip_fopen_index(s_APKArchive, m_idZipFile, 0);
if (NULL == m_zipPointerFile) {
TK_ERROR("Can not find the file name=\"" << GetCompleateName() << "\"");
return false;
}
// get the fileSize .... end read all the data from the zip files
struct zip_stat zipFileProperty;
zip_stat_init(&zipFileProperty);
zip_stat_index(s_APKArchive, m_idZipFile, 0, &zipFileProperty);
TK_DEBUG("LOAD data from the files : \"" << GetCompleateName() << "\"");
/*
TK_DEBUG(" name=" << zipFileProperty.name);
TK_DEBUG(" index=" << zipFileProperty.index);
TK_DEBUG(" crc=" << zipFileProperty.crc);
TK_DEBUG(" mtime=" << zipFileProperty.mtime);
TK_DEBUG(" size=" << zipFileProperty.size);
TK_DEBUG(" comp_size=" << zipFileProperty.comp_size);
TK_DEBUG(" comp_method=" << zipFileProperty.comp_method);
TK_DEBUG(" encryption_method=" << zipFileProperty.encryption_method);
*/
m_zipDataSize = zipFileProperty.size;
m_zipData = new char[m_zipDataSize +10];
if (NULL == m_zipData) {
TK_ERROR("File allocation ERROR : \"" << GetCompleateName() << "\"");
zip_fclose(m_zipPointerFile);
return false;
}
memset(m_zipData, 0, m_zipDataSize +10);
int32_t sizeTmp = zip_fread(m_zipPointerFile, m_zipData, m_zipDataSize);
if (sizeTmp != m_zipDataSize) {
TK_ERROR("File load data ERROR : \"" << GetCompleateName() << "\"");
zip_fclose(m_zipPointerFile);
delete[] m_zipData;
return false;
}
zip_fclose(m_zipPointerFile);
m_zipPointerFile = NULL;
return true;
}
}
#endif
int32_t etk::File::Size(void)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
if (true == LoadDataZip()) {
return m_zipDataSize;
}
return 0;
}
#endif
FILE *myFile=NULL;
etk::UString myCompleateName = baseFolderData + GetCompleateName();
myFile=fopen(myCompleateName.Utf8Data(),"rb");
if(NULL == myFile) {
//EWOL_ERROR("Can not find the file name=\"" << m_folder << "\" / \"" << m_shortFilename << "\"");
return -1;
}
int32_t size = 0;
fseek(myFile, 0, SEEK_END);
size = ftell(myFile);
fseek(myFile, 0, SEEK_SET);
fclose(myFile);
return size;
}
bool etk::File::Exist(void)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
if (m_idZipFile >= -1 && m_idZipFile < s_APKnbFiles) {
return true;
}
return false;
}
#endif
FILE *myFile=NULL;
etk::UString myCompleateName = baseFolderData + GetCompleateName();
myFile=fopen(myCompleateName.Utf8Data(),"rb");
if(NULL == myFile) {
return false;
}
fclose(myFile);
return true;
}
bool etk::File::fOpenRead(void)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
return LoadDataZip();
}
#endif
if (NULL != m_PointerFile) {
TK_CRITICAL("File Already open : \"" << GetCompleateName() << "\"");
return true;
}
etk::UString myCompleateName = baseFolderData + GetCompleateName();
m_PointerFile=fopen(myCompleateName.Utf8Data(),"rb");
if(NULL == m_PointerFile) {
TK_ERROR("Can not find the file name=\"" << GetCompleateName() << "\"");
return false;
}
return true;
}
bool etk::File::fOpenWrite(void)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
return false;
}
#endif
if (NULL != m_PointerFile) {
TK_CRITICAL("File Already open : \"" << GetCompleateName() << "\"");
return true;
}
etk::UString myCompleateName = baseFolderData + GetCompleateName();
m_PointerFile=fopen(myCompleateName.Utf8Data(),"wb");
if(NULL == m_PointerFile) {
TK_ERROR("Can not find the file name=\"" << GetCompleateName() << "\"");
return false;
}
return true;
}
bool etk::File::fClose(void)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
if (NULL == m_zipData) {
TK_CRITICAL("File Already closed : \"" << GetCompleateName() << "\"");
return false;
}
delete[] m_zipData;
m_zipData = NULL;
m_zipDataSize = 0;
m_zipReadingOffset = 0;
return true;
}
#endif
if (NULL == m_PointerFile) {
TK_CRITICAL("File Already closed : \"" << GetCompleateName() << "\"");
return false;
}
fclose(m_PointerFile);
m_PointerFile = NULL;
return true;
}
char * etk::File::fGets(char * elementLine, int32_t maxData)
{
memset(elementLine, 0, maxData);
#if defined(DATA_IN_APK)
char * element = elementLine;
if (etk::FILE_TYPE_DATA == m_type) {//char * tmpData = internalDataFiles[iii].data + m_readingOffset;
if (NULL == m_zipData) {
element[0] = '\0';
return NULL;
}
if (m_zipReadingOffset>m_zipDataSize) {
element[0] = '\0';
return NULL;
}
while (m_zipData[m_zipReadingOffset] != '\0') {
if( m_zipData[m_zipReadingOffset] == '\n'
|| m_zipData[m_zipReadingOffset] == '\r')
{
*element = m_zipData[m_zipReadingOffset];
element++;
m_zipReadingOffset++;
*element = '\0';
return elementLine;
}
*element = m_zipData[m_zipReadingOffset];
element++;
m_zipReadingOffset++;
if (m_zipReadingOffset>m_zipDataSize) {
*element = '\0';
return elementLine;
}
}
return NULL;
}
#endif
return fgets(elementLine, maxData, m_PointerFile);
}
int32_t etk::File::fRead(void * data, int32_t blockSize, int32_t nbBlock)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
if (NULL == m_zipData) {
((char*)data)[0] = '\0';
return 0;
}
int32_t dataToRead = blockSize * nbBlock;
if (dataToRead + m_zipReadingOffset > m_zipDataSize) {
nbBlock = ((m_zipDataSize - m_zipReadingOffset) / blockSize);
dataToRead = blockSize * nbBlock;
}
memcpy(data, &m_zipData[m_zipReadingOffset], dataToRead);
m_zipReadingOffset += dataToRead;
return nbBlock;
}
#endif
return fread(data, blockSize, nbBlock, m_PointerFile);
}
int32_t etk::File::fWrite(void * data, int32_t blockSize, int32_t nbBlock)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
TK_CRITICAL("Can not write on data inside APK : \"" << GetCompleateName() << "\"");
return 0;
}
#endif
return fwrite(data, blockSize, nbBlock, m_PointerFile);
}
bool etk::File::fSeek(long int offset, int origin)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
if (NULL == m_zipData) {
return false;
}
int32_t positionEnd = 0;
switch(origin) {
case SEEK_END:
positionEnd = m_zipDataSize;
break;
case SEEK_CUR:
positionEnd = m_zipReadingOffset;
break;
default:
positionEnd = 0;
break;
}
positionEnd += offset;
if (positionEnd < 0) {
positionEnd = 0;
} else if (positionEnd > m_zipDataSize) {
positionEnd = m_zipDataSize;
}
m_zipReadingOffset = positionEnd;
return true;
}
#endif
fseek(m_PointerFile, offset, origin);
if(ferror(m_PointerFile)) {
return false;
} else {
return true;
}
}
char * etk::File::GetDirectPointer(void)
{
#if defined(DATA_IN_APK)
if (etk::FILE_TYPE_DATA == m_type) {
if (NULL == m_zipData) {
return NULL;
}
return m_zipData;
}
#endif
return NULL;
}

118
Sources/libetk/etk/File.h Normal file
View File

@ -0,0 +1,118 @@
/**
*******************************************************************************
* @file etk/File.h
* @brief Ewol Tool Kit : File folder and name abstraction (header)
* @author Edouard DUPIN
* @date 16/07/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_FILE_H__
#define __ETK_FILE_H__
#include <etk/UString.h>
#define MAX_FILE_NAME (10240)
//http://developer.android.com/guide/topics/data/data-storage.html
namespace etk
{
typedef enum {
// user might done abstraction ==> acces of the sdcard when possible ...
FILE_TYPE_DIRECT,
// depend of the case
// - PC : /usr/shared/programName/
// - Android : Internal at the executable file (pointer on static area)
// - Apple : Internal at the executable file
FILE_TYPE_DATA,
// depend on case
// - PC : ~/.programName/
// - Android : /data/data/programName/files/
// - Apple : ????
FILE_TYPE_USER_DATA,
// depend on case
// - PC : ~/.programName/cache/
// - Android : /data/data/programName/cache/
// - Apple : ????
FILE_TYPE_CACHE,
} FileType_te;
class File
{
public:
File(void) { m_lineNumberOpen=0; m_type = etk::FILE_TYPE_DIRECT; m_PointerFile = NULL;}
File(etk::UString &filename, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t LineNumber = 0);
File(const char *filename, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t LineNumber = 0);
File(etk::UString &filename, etk::UString &folder, etk::FileType_te type = etk::FILE_TYPE_DIRECT, int32_t lineNumber = 0);
~File(void);
etk::UString GetFolder(void) const;
etk::UString GetShortFilename(void) const;
etk::UString GetCompleateName(void) const;
bool HasExtention(void);
etk::UString GetExtention(void);
int32_t Size(void);
bool Exist(void);
int32_t GetLineNumber(void);
void SetLineNumber(int32_t newline);
void SetCompleateName(etk::UString &newFilename, etk::FileType_te type);
const etk::File& operator= (const etk::File &etkF );
bool operator== (const etk::File &etkF ) const;
bool operator!= (const etk::File &etkF ) const;
friend etk::CCout& operator <<( etk::CCout &os,const etk::File &obj);
FileType_te GetTypeAccess(void) { return m_type; };
char * GetDirectPointer(void);
// TODO : IO access of the file :
bool fOpenRead(void);
bool fOpenWrite(void);
bool fClose(void);
char * fGets(char * elementLine, int32_t maxData);
int32_t fRead(void * data, int32_t blockSize, int32_t nbBlock);
int32_t fWrite(void * data, int32_t blockSize, int32_t nbBlock);
bool fSeek(long int offset, int origin);
private :
etk::FileType_te m_type;
FILE * m_PointerFile;
#if defined(DATA_IN_APK)
bool LoadDataZip(void);
int32_t m_idZipFile;
char * m_zipData;
int32_t m_zipDataSize;
int32_t m_zipReadingOffset;
#endif
etk::UString m_folder;
etk::UString m_shortFilename;
int32_t m_lineNumberOpen;
};
etk::CCout& operator <<(etk::CCout &os, const etk::File &obj);
void SetBaseFolderData(const char * folder);
void SetBaseFolderDataUser(const char * folder);
void SetBaseFolderCache(const char * folder);
}
#endif

View File

@ -0,0 +1,51 @@
/**
*******************************************************************************
* @file etk/Memory.cpp
* @brief Ewol Tool Kit : Memory implementation (Sources)
* @author Edouard DUPIN
* @date 19/10/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Types.h>
#include <etk/Memory.h>
// General
#if ETK_MEMORY_CHECKER > 0
void etk::MemFree( void * pointerData, const char * variableName, const char * functionName, int32_t line, const char * fileName )
{
TK_CRITICAL(" MEM FREE is not written ==> TODO...");
if (NULL != pointerData) {
free(pointerData);
}
}
void * etk::MemMalloc( size_t num, size_t size, uint8_t init, const char * variableName, const char * functionName, int32_t line, const char * fileName )
{
TK_CRITICAL(" MEM ALLOCATOR is not written ==> TODO...");
return calloc(num, size);
}
void etk::MemShowLogs( void )
{
TK_CRITICAL(" MEM DISPLAY is not written ==> TODO...");
}
#endif

View File

@ -0,0 +1,96 @@
/**
*******************************************************************************
* @file etk/Memory.h
* @brief Ewol Tool Kit : Memory implementation (headers)
* @author Edouard DUPIN
* @date 12/01/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_TOOLS_MEMORY_H__
#define __ETK_TOOLS_MEMORY_H__
#ifndef ETK_MEMORY_CHECKER
#define ETK_MEMORY_CHECKER 0
#endif
// General
#if ETK_MEMORY_CHECKER > 0
namespace etk {
void MemFree( void * pointerData, const char * variableName, const char * functionName, int32_t line, const char * fileName );
void * MemMalloc( size_t num, size_t size, uint8_t init, const char * variableName, const char * functionName, int32_t line, const char * fileName );
void MemShowLogs( void );
};
# define ETK_MALLOC(pointerData, nbElements, dataType) do { \
pointerData = (dataType *)etk::MemMalloc( (nbElements), sizeof(dataType), 0, #pointerData, __func__, __LINE__, __FILE__); \
}while(0)
# define ETK_MALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
pointerData = (cast)etk::MemMalloc( (nbElements), sizeof(dataType), 0, #pointerData, __func__, __LINE__, __FILE__); \
}while(0)
# define ETK_CALLOC(pointerData, nbElements, dataType) do { \
pointerData = (dataType *)etk::MemMalloc( (nbElements), sizeof(dataType), 1, #pointerData, __func__, __LINE__, __FILE__); \
}while(0)
# define ETK_CALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
pointerData = (cast)etk::MemMalloc( (nbElements), sizeof(dataType), 1, #pointerData, __func__, __LINE__, __FILE__); \
}while(0)
# define ETK_FREE(pointerData) do { \
etk::MemFree( (pointerData) , #pointerData, __func__, __LINE__, __FILE__); \
(pointerData) = NULL; \
}while(0)
# define ETK_MEM_SHOW_LOG() do { \
etk::MemShowLogs(); \
}while(0)
#else
# define ETK_MALLOC(pointerData, nbElements, dataType) do { \
(pointerData) = (dataType *)malloc( (nbElements) * sizeof(dataType) ); \
}while(0)
# define ETK_MALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
(pointerData) = (cast)malloc( (nbElements) * sizeof(dataType) ); \
}while(0)
# define ETK_CALLOC(pointerData, nbElements, dataType) do { \
(pointerData) = (dataType *)calloc( (nbElements), sizeof(dataType) ); \
}while(0)
# define ETK_CALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
(pointerData) = (cast)calloc( (nbElements), sizeof(dataType) ); \
}while(0)
# define ETK_REALLOC(pointerData, nbElements, dataType) do { \
(pointerData) = (dataType *)realloc( (pointerData), (nbElements)* sizeof(dataType) ); \
}while(0)
# define ETK_REALLOC_CAST(pointerData, nbElements, dataType, cast) do { \
(pointerData) = (cast)realloc( (pointerData), (nbElements) * sizeof(dataType) ); \
}while(0)
# define ETK_FREE(pointerData) do { \
free( pointerData ); \
(pointerData) = NULL; \
}while(0)
# define ETK_MEM_SHOW_LOG() do { \
TK_DEBUG("No Memory check availlable"); \
}while(0)
#endif
#endif

View File

@ -0,0 +1,484 @@
/**
*******************************************************************************
* @file etk/RegExp.cpp
* @brief Ewol Tool Kit : Regular expression annalyser (sources)
* @author Edouard DUPIN
* @date 04/04/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/RegExp.h>
const etk::convertionTable_ts etk::constConvertionTable[] = {
// haveBackSlash, inputValue, newValue
{ false , '(' , REGEXP_OPCODE_PTHESE_IN},
{ true , '(' , (int16_t)'('},
{ false , ')' , REGEXP_OPCODE_PTHESE_OUT},
{ true , ')' , (int16_t)')'},
{ false , '[' , REGEXP_OPCODE_BRACKET_IN},
{ true , '[' , (int16_t)'['},
{ false , ']' , REGEXP_OPCODE_BRACKET_OUT},
{ true , ']' , (int16_t)']'},
{ false , '{' , REGEXP_OPCODE_BRACE_IN},
{ true , '{' , (int16_t)'{'},
{ false , '}' , REGEXP_OPCODE_BRACE_OUT},
{ true , '}' , (int16_t)'}'},
{ false , '-' , REGEXP_OPCODE_TO},
{ true , '-' , (int16_t)'-'},
{ false , '*' , REGEXP_OPCODE_STAR},
{ true , '*' , (int16_t)'*'},
{ false , '.' , REGEXP_OPCODE_DOT},
{ true , '.' , (int16_t)'.'},
{ false , '?' , REGEXP_OPCODE_QUESTION},
{ true , '?' , (int16_t)'?'},
{ false , '+' , REGEXP_OPCODE_PLUS},
{ true , '+' , (int16_t)'+'},
{ false , '|' , REGEXP_OPCODE_PIPE},
{ true , '|' , (int16_t)'|'},
{ false , '^' , REGEXP_OPCODE_START_OF_LINE},
{ true , '^' , (int16_t)'^'},
{ false , '$' , REGEXP_OPCODE_END_OF_LINE},
{ true , '$' , (int16_t)'$'},
{ true , 'd' , REGEXP_OPCODE_DIGIT},
{ true , 'D' , REGEXP_OPCODE_DIGIT_NOT},
{ true , 'l' , REGEXP_OPCODE_LETTER},
{ true , 'L' , REGEXP_OPCODE_LETTER_NOT},
{ true , 's' , REGEXP_OPCODE_SPACE},
{ true , 'S' , REGEXP_OPCODE_SPACE_NOT},
{ true , 'w' , REGEXP_OPCODE_WORD},
{ true , 'W' , REGEXP_OPCODE_WORD_NOT},
{ true , 'a' , (int16_t)'\a'},
{ true , 'b' , (int16_t)'\b'},
{ true , 'e' , 0x001B}, // Escape character <Esc>
{ true , 'f' , (int16_t)'\f'},
{ true , 'n' , (int16_t)'\n'},
{ true , 'r' , (int16_t)'\r'},
{ true , 't' , (int16_t)'\t'},
{ true , 'v' , (int16_t)'\v'},
{ true , '\\' , (int16_t)'\\'},
{ true , '&' , (int16_t)'&'},
{ true , '0' , (int16_t)'\0'},
{ true , '@' , REGEXP_OPCODE_NO_CHAR},
};
const int32_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ;
/**
* @brief Display the internal data of a node
*
* @param[in] data element do display in the console
*
* @return ---
*
*/
void etk::DisplayData(etk::VectorType<char> &data)
{
int32_t i;
for (i=0; i<(int32_t)data.Size() ; i++) {
etk::cout<< (char)(data[i]&0x00FF );
}
}
/**
* @brief Display of a part of the Regexp element
*
* @param[in] data Vector where data is constain
* @param[in] start Position where the display might start
* @param[in] stop Position where the display might stop
*
* @return ---
*
*/
void etk::DisplayElem(etk::VectorType<int16_t> &data, int32_t start, int32_t stop)
{
int32_t i;
etk::cout<< ETK_BASH_COLOR_NORMAL;
for (i=start; i<(int32_t)data.Size() && i<stop ; i++) {
switch(data[i])
{
case REGEXP_OPCODE_PTHESE_IN: etk::cout<<ETK_BASH_COLOR_RED << (char*)"(" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_PTHESE_OUT: etk::cout<<ETK_BASH_COLOR_RED << (char*)")" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_BRACKET_IN: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"[" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_BRACKET_OUT: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"]" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_TO: etk::cout<<ETK_BASH_COLOR_YELLOW << (char*)"-" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_BRACE_IN: etk::cout<<ETK_BASH_COLOR_GREEN << (char*)"{" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_BRACE_OUT: etk::cout<<ETK_BASH_COLOR_GREEN << (char*)"}" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_STAR: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"*" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_DOT: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"." << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_QUESTION: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"?" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_PLUS: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"+" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_PIPE: etk::cout<<ETK_BASH_COLOR_BLUE << (char*)"|" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_NO_CHAR: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"@" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_START_OF_LINE: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"^" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_END_OF_LINE: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"$" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_DIGIT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\d" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_DIGIT_NOT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\D" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_LETTER: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\l" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_LETTER_NOT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\L" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_SPACE: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\s" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_SPACE_NOT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\S" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_WORD: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\w" << ETK_BASH_COLOR_NORMAL; break;
case REGEXP_OPCODE_WORD_NOT: etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\W" << ETK_BASH_COLOR_NORMAL; break;
case '\n': etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\n" << ETK_BASH_COLOR_NORMAL; break;
case '\t': etk::cout<<ETK_BASH_COLOR_MAGENTA << (char*)"\\t" << ETK_BASH_COLOR_NORMAL; break;
default: etk::cout<< (char)(data[i]&0x00FF ); break;
}
}
}
char * etk::levelSpace(int32_t level)
{
switch(level)
{
case 0: return (char*)"";
case 1: return (char*)" ";
case 2: return (char*)" ";
case 3: return (char*)" ";
case 4: return (char*)" ";
case 5: return (char*)" ";
case 6: return (char*)" ";
case 7: return (char*)" ";
case 8: return (char*)" ";
case 9: return (char*)" ";
case 10: return (char*)" ";
case 11: return (char*)" ";
case 12: return (char*)" ";
case 13: return (char*)" ";
case 14: return (char*)" ";
case 15: return (char*)" ";
case 16: return (char*)" ";
default: return (char*)" ";
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t etk::GetLenOfPTheseElem(etk::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
int32_t nbOpen = 0;
// special case of the (...) or | ==> we search '|' or ')'
if( REGEXP_OPCODE_PTHESE_OUT == data[pos]
|| REGEXP_OPCODE_PIPE == data[pos]) {
return 0;
}
// find size ...
while (pos < (int32_t)data.Size() ) {
if(REGEXP_OPCODE_PTHESE_IN == data[pos]) {
// find a sub section :
nbOpen++;
} else if(0 < nbOpen) {
if (REGEXP_OPCODE_PTHESE_OUT == data[pos])
{
nbOpen--;
if (0 > nbOpen) {
TK_ERROR("Error in the (...) find element at "<< pos);
return -1;
}
}
} else if( REGEXP_OPCODE_PTHESE_OUT == data[pos]
|| REGEXP_OPCODE_PIPE == data[pos])
{
// Find the end of the (...)
// just return the size inside
int32_t sizeInside = pos - startPos;
if (0 >= sizeInside) {
TK_ERROR("Error in the (...) no data at "<< pos-1);
return -1;
} else {
return sizeInside;
}
}
pos++;
}
return pos - startPos;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t etk::GetLenOfPThese(etk::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
int32_t nbOpen = 0;
// special case of the (...) or | ==> we search '|' or ')'
if( REGEXP_OPCODE_PTHESE_OUT == data[pos]) {
return 0;
} else if( REGEXP_OPCODE_PTHESE_IN == data[pos])
{
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(REGEXP_OPCODE_PTHESE_IN == data[pos]) {
// find a sub section :
nbOpen++;
} else if(0 < nbOpen) {
if (REGEXP_OPCODE_PTHESE_OUT == data[pos])
{
nbOpen--;
if (0 > nbOpen) {
TK_ERROR("Error in the (...) find element at "<< pos);
return -1;
}
}
} else if( REGEXP_OPCODE_PTHESE_OUT == data[pos])
{
// Find the end of the (...)
// just return the size inside
int32_t sizeInside = pos - startPos-1;
if (0 >= sizeInside) {
TK_ERROR("Error in the (...) no data at "<< pos-1);
return -1;
} else {
return sizeInside;
}
}
pos++;
}
} else {
return -1;
}
return 0;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t etk::GetLenOfBracket(etk::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// special case of the (...) or | ==> we search '|' or ')'
if( REGEXP_OPCODE_BRACKET_OUT == data[pos]) {
return 0;
} else if( REGEXP_OPCODE_BRACKET_IN == data[pos]) {
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(REGEXP_OPCODE_BRACKET_OUT == data[pos]) {
// Find the end of the [...]
// just return the size inside
int32_t sizeInside = pos - startPos -1 ;
if (0 >= sizeInside) {
TK_ERROR("Error in the [...] no data at "<< pos-1);
return sizeInside;
} else {
return sizeInside;
}
} else if( REGEXP_OPCODE_TO != data[pos]
&& ( 0 > data[pos]
|| 0xFF < data[pos]) )
{
TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)data[pos] << "'");
return false;
}
pos++;
}
} else {
return -1;
}
return 0;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t etk::GetLenOfBrace(etk::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// special case of the (...) or | ==> we search '|' or ')'
if( REGEXP_OPCODE_BRACE_OUT == data[pos]) {
return 0;
} else if( REGEXP_OPCODE_BRACE_IN == data[pos]) {
pos++;
// find size ...
while (pos < (int32_t)data.Size() ) {
if(REGEXP_OPCODE_BRACE_OUT == data[pos]) {
// Find the end of the [...]
// just return the size inside
int32_t sizeInside = pos - startPos -1 ;
if (0 >= sizeInside) {
TK_ERROR("Error in the {...} no data at "<< pos-1);
return sizeInside;
} else {
return sizeInside;
}
} else if( ',' != data[pos]
&& ( '0' > data[pos]
|| '9' < data[pos]) )
{
TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << (char)data[pos] << "'");
return false;
}
pos++;
}
} else {
return -1;
}
return 0;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t etk::GetLenOfNormal(etk::VectorType<int16_t> &data, int32_t startPos)
{
int32_t pos = startPos;
// find size ...
while (pos < (int32_t)data.Size() ) {
switch(data[pos])
{
case REGEXP_OPCODE_PTHESE_IN:
case REGEXP_OPCODE_PTHESE_OUT:
case REGEXP_OPCODE_BRACKET_IN:
case REGEXP_OPCODE_BRACKET_OUT:
case REGEXP_OPCODE_BRACE_IN:
case REGEXP_OPCODE_BRACE_OUT:
case REGEXP_OPCODE_TO:
case REGEXP_OPCODE_STAR:
case REGEXP_OPCODE_DOT:
case REGEXP_OPCODE_QUESTION:
case REGEXP_OPCODE_PLUS:
case REGEXP_OPCODE_PIPE:
case REGEXP_OPCODE_START_OF_LINE:
case REGEXP_OPCODE_END_OF_LINE:
case REGEXP_OPCODE_DIGIT:
case REGEXP_OPCODE_DIGIT_NOT:
case REGEXP_OPCODE_LETTER:
case REGEXP_OPCODE_LETTER_NOT:
case REGEXP_OPCODE_SPACE:
case REGEXP_OPCODE_SPACE_NOT:
case REGEXP_OPCODE_WORD:
case REGEXP_OPCODE_WORD_NOT:
{
// just return the size inside
int32_t sizeInside = pos - startPos;
if (0 >= sizeInside) {
TK_ERROR("Error in the normal data : no data ...");
}
return sizeInside;
}
break;
default :
// nothing to do ...
break;
}
pos++;
}
return pos - startPos ;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
bool etk::ParseBrace(etk::VectorType<int16_t> &data, int32_t &min, int32_t &max)
{
//TK_INFO("parse {...} in "; DisplayElem(data); );
int32_t k=0;
int32_t firstElement = 0;
int32_t SecondElement = 0;
while(k<data.Size()) {
if (',' == (char)data[k]) {
k++;
break;
} if ('}' == (char)data[k]) {
SecondElement = firstElement;
goto allIsSet;
} else if ('0' <= (char)data[k] && '9' >= (char)data[k]) {
firstElement *=10;
firstElement += (char)data[k] - '0';
} else {
TK_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k);
return false;
}
k++;
}
if (k==data.Size()) {
SecondElement = firstElement;
}
while(k<data.Size()) {
if (',' == (char)data[k]) {
TK_ERROR("Can not find a second , in {} at pos " << k);
return false;
} if ('}' == (char)data[k]) {
goto allIsSet;
} else if ('0' <= (char)data[k] && '9' >= (char)data[k]) {
SecondElement *=10;
SecondElement += (char)data[k] - '0';
} else {
TK_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k);
return false;
}
k++;
}
allIsSet:
if (SecondElement == 0 && firstElement != 0) {
min = 0;
max = firstElement;
} else {
min = firstElement;
max = SecondElement;
}
if (min > max) {
TK_ERROR("Minimum=" << min << " can not be < maximum=" << max );
return false;
}
return true;
}

2122
Sources/libetk/etk/RegExp.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,32 @@
/**
*******************************************************************************
* @file etk/Stream.cpp
* @brief Ewol Tool Kit : Basic etk::Stream for Log system ... (Sources)
* @author Edouard DUPIN
* @date 02/12/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Stream.h>
etk::CCout etk::cout;
etk::CEndl etk::endl;
etk::CHex etk::hex;
etk::CStart etk::cstart;

175
Sources/libetk/etk/Stream.h Normal file
View File

@ -0,0 +1,175 @@
/**
*******************************************************************************
* @file etk/Stream.h
* @brief Ewol Tool Kit : Basic etk::Stream for Log system ... (header)
* @author Edouard DUPIN
* @date 02/12/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_STREAM_H__
#define __ETK_STREAM_H__
#include <cstdio>
#include <typeinfo>
#include <string.h>
#include <pthread.h>
#include <etk/Types.h>
#if defined(__PLATFORM__Android)
# include <android/log.h>
# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "====> EWOL", __VA_ARGS__))
# define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "====> EWOL", __VA_ARGS__))
# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "====> EWOL", __VA_ARGS__))
#endif
#define MAX_LOG_SIZE (16000)
#define MAX_LOG_SIZE_TMP (512)
namespace etk{
class CEndl{};
class CHex{};
class CStart{};
class CCout{
private:
bool hex;
public:
private:
char m_tmpChar[MAX_LOG_SIZE+1];
char tmp[MAX_LOG_SIZE_TMP];
pthread_mutex_t m_mutex;
public:
CCout(){
hex=false;
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
pthread_mutex_init(&m_mutex, NULL);
};
~CCout() {
pthread_mutex_destroy(&m_mutex);
};
CCout& operator << (int t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (unsigned int t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
/*
CCout& operator << (uniChar_t t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
*/
CCout& operator << (long t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (long long t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (double t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (float t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (char * t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (const char * t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (char t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (bool t) {
if (t) {
strncat(m_tmpChar, "true", MAX_LOG_SIZE);
} else {
strncat(m_tmpChar, "false", MAX_LOG_SIZE);
}
return *this;
}
CCout& operator << (coord2D_ts t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f)", t.x, t.y);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (coord3D_ts t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(%f,%f,%f)", t.x, t.y, t.z);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (texCoord_ts t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "{%f,%f}", t.u, t.v);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (color_ts t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "(r=%f,g=%f,b=%f,a=%f)", t.red, t.green, t.blue, t.alpha);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (clipping_ts t) {
snprintf(tmp, MAX_LOG_SIZE_TMP, "origin=(%f,%f) size=(%f,%f)", t.x, t.y, t.w, t.h);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
CCout& operator << (CStart ccc) {
pthread_mutex_lock(&m_mutex);
return *this;
}
CCout& operator << (etk::CEndl t) {
strncat(m_tmpChar, "\n", MAX_LOG_SIZE);
m_tmpChar[MAX_LOG_SIZE] = '\0';
#if defined(__PLATFORM__Android)
LOGI("%s", m_tmpChar);
#else
printf("%s", m_tmpChar);
#endif
memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char));
pthread_mutex_unlock(&m_mutex);
return *this;
}
};
extern etk::CCout cout;
extern etk::CEndl endl;
extern etk::CHex hex;
extern etk::CStart cstart;
}
#endif

108
Sources/libetk/etk/Types.h Normal file
View File

@ -0,0 +1,108 @@
/**
*******************************************************************************
* @file etk/Types.h
* @brief Ewol Tool Kit : generique define type
* @author Edouard DUPIN
* @date 08/06/2010
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_TYPES_H__
#define __ETK_TYPES_H__
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <assert.h>
#ifndef __int8_t_defined
# define __int8_t_defined
typedef signed char int8_t;
typedef signed short int int16_t;
typedef int int32_t;
typedef signed long long int int64_t;
#endif
#ifndef __uint8_t_defined
# define __uint8_t_defined
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
# if __WORDSIZE == 64
typedef unsigned long int uint64_t;
# else
typedef unsigned long long int uint64_t;
# endif
#endif
typedef uint32_t uniChar_t;
#define etk_min(elemA, elemB) ((elemA)<(elemB)) ? (elemA) : (elemB)
#define etk_max(elemA, elemB) ((elemA)<(elemB)) ? (elemB) : (elemA)
#define etk_avg(minimim, elem, maximum) ((minimim)>(elem)) ? (minimim) : ((maximum)<(elem)) ? (maximum) : (elem)
extern "C"
{
#ifdef EWOL_PECISION_DOUBLE
typedef double etkFloat_t;
#define oglTypeFloat_t GL_DOUBLE
#else
typedef float etkFloat_t;
#define oglTypeFloat_t GL_FLOAT
#endif
typedef struct {
etkFloat_t x;
etkFloat_t y;
etkFloat_t z;
}coord3D_ts;
typedef struct {
etkFloat_t x;
etkFloat_t y;
}coord2D_ts;
typedef struct {
etkFloat_t u;
etkFloat_t v;
}texCoord_ts;
typedef struct {
etkFloat_t x;
etkFloat_t y;
etkFloat_t w;
etkFloat_t h;
}clipping_ts;
typedef struct {
etkFloat_t red;
etkFloat_t green;
etkFloat_t blue;
etkFloat_t alpha;
}color_ts;
}
#endif

View File

@ -0,0 +1,731 @@
/**
*******************************************************************************
* @file etk/UString.cpp
* @brief Ewol Tool Kit : normal Unicode string management... (sources)
* @author Edouard DUPIN
* @date 14/02/2012
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/UString.h>
#include <etk/Memory.h>
#include <etk/unicode.h>
int32_t strlen(const uniChar_t * data)
{
if (NULL == data) {
return 0;
}
int32_t iii=0;
while (*data != 0) {
data++;
iii++;
if (iii > 0x7FFFFFF0) {
return iii;
}
}
return iii;
}
#undef __class__
#define __class__ "etk::UString"
etk::CCout& etk::operator <<(etk::CCout &os, const etk::UString &obj)
{
etk::VectorType<char> output_UTF8;
unicode::convertUnicodeToUtf8(obj.m_data, output_UTF8);
output_UTF8.PushBack('\0');
os << &output_UTF8[0];
return os;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::UString::~UString(void)
{
m_data.Clear();
m_dataUtf8.Clear();
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::UString::UString(void)
{
//TK_INFO("new etk::UString()");
m_data.Clear();
m_data.PushBack('\0');
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::UString::UString(const char* inputData, int32_t len)
{
m_data.Clear();
m_data.PushBack('\0');
Set(inputData, len);
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::UString::UString(const uniChar_t* inputData, int32_t len)
{
m_data.Clear();
m_data.PushBack('\0');
Set(inputData, len);
}
void etk::UString::Set(const char * inputData, int32_t len)
{
if (NULL == inputData) {
// nothing to add ...
return;
}
// overwrite the len if needed :
if ((-1) == len) {
len = strlen(inputData);
}
// convert the string
etk::VectorType<char> tmpChar;
for (int32_t iii=0; iii<len; iii++) {
tmpChar.PushBack(inputData[iii]);
}
// add it ...
if (len != 0) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
unicode::convertUtf8ToUnicode(tmpChar, m_data);
// add the last '\0'
m_data.PushBack('\0');
}
}
void etk::UString::Set(const uniChar_t * inputData, int32_t len)
{
if (NULL == inputData) {
// nothing to add ...
return;
}
// overwrite the len if needed :
if ((-1) == len) {
len = strlen(inputData);
}
if (len != 0) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
m_data.PushBack(inputData, len);
// add the last '\0'
m_data.PushBack('\0');
}
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::UString::UString(char inputData)
{
char tmpVal[2];
// generate the UString :
sprintf(tmpVal, "%c", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
etk::UString::UString(int inputData)
{
char tmpVal[256];
// generate the UString :
sprintf(tmpVal, "%d", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::UString::UString(unsigned int inputData)
{
char tmpVal[256];
// generate the UString :
sprintf(tmpVal, "%d", inputData);
// set the internal data :
m_data.Clear();
m_data.PushBack('\0');
Set(tmpVal);
}
etk::UString::UString(const etk::UString &etkS)
{
//etk_INFO("Constructeur de recopie");
m_data = etkS.m_data;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::UString& etk::UString::operator= (const etk::UString &etkS )
{
//TK_INFO("OPERATOR de recopie");
if( this != &etkS ) {
m_data = etkS.m_data;
}
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::UString& etk::UString::operator= (etk::VectorType<char> inputData)
{
etk::VectorType<uniChar_t> output_Unicode;
unicode::convertUtf8ToUnicode(inputData, output_Unicode);
*this = output_Unicode;
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::UString& etk::UString::operator= (etk::VectorType<uniChar_t> inputData)
{
m_data = inputData;
if (m_data.Size()>0) {
if (m_data[m_data.Size()-1] != '\0') {
m_data.PushBack('\0');
}
}
//TK_DEBUG("m_dataLen="<<m_dataLen << " m_dataLenUTF8="<<m_dataLenUTF8 << " description=" << m_data);
return *this;
}
uniChar_t changeOrder(uniChar_t elemA)
{
if (elemA >= 'A' && elemA <= 'Z') {
return (elemA - (uniChar_t)'A')*2 + 'A';
}
if (elemA >= 'a' && elemA <= 'z') {
return (elemA - (uniChar_t)'a')*2 + 'A' + 1;
}
if (elemA >= ':' && elemA <= '@') {
return elemA + 52;
}
if (elemA >= '[' && elemA <= '`') {
return elemA +26;
}
return elemA;
}
bool etk::UString::operator> (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
//TK_DEBUG(" compare : '" << (char)m_data[iii] << "'>'" << (char)etkS.m_data[iii] << "' ==> " << changeOrder(m_data[iii]) << ">" << changeOrder(etkS.m_data[iii]) << "");
uniChar_t elemA = changeOrder(m_data[iii]);
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
if (elemA != elemB) {
if (elemA > elemB) {
return true;
}
return false;
}
}
if (m_data.Size() > etkS.m_data.Size()) {
return true;
}
}
return false;
}
bool etk::UString::operator>= (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
uniChar_t elemA = changeOrder(m_data[iii]);
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
if (elemA != elemB) {
if (elemA > elemB) {
return true;
}
return false;
}
}
if (m_data.Size() >= etkS.m_data.Size()) {
return true;
}
}
return false;
}
bool etk::UString::operator< (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
uniChar_t elemA = changeOrder(m_data[iii]);
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
if (elemA != elemB) {
if (elemA < elemB) {
return true;
}
return false;
}
}
if (m_data.Size() < etkS.m_data.Size()) {
return true;
}
}
return false;
}
bool etk::UString::operator<= (const etk::UString& etkS) const
{
if( this != &etkS ) {
for (int32_t iii=0; iii < m_data.Size() && iii < etkS.m_data.Size(); iii++) {
uniChar_t elemA = changeOrder(m_data[iii]);
uniChar_t elemB = changeOrder(etkS.m_data[iii]);
if (elemA != elemB) {
if (elemA < elemB) {
return true;
}
return false;
}
}
if (m_data.Size() <= etkS.m_data.Size()) {
return true;
}
}
return false;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::UString::operator== (const etk::UString& etkS) const
{
if( this != &etkS ) {
if (etkS.m_data.Size() != m_data.Size()) {
//TK_DEBUG(" not the same size : " << etkS.m_data.Size() << "!=" << m_data.Size());
return false;
}
for (int32_t iii= 0; iii<m_data.Size(); iii++) {
//TK_DEBUG(" check : " << etkS.m_data[iii] << "!=" << m_data[iii]);
if (etkS.m_data[iii]!= m_data[iii]){
return false;
}
}
return true;
}
return true;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::UString::operator!= (const etk::UString& etkS) const
{
return !(*this == etkS);
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
const etk::UString& etk::UString::operator+= (const etk::UString &etkS)
{
if (0 < etkS.Size()) {
// remove the last '\0'
m_data.PopBack();
// copy the data ...
m_data += etkS.m_data;
// This previous include the \0 in case of the 2 UString are different...
if( this == &etkS ) {
// add the removed end UString
m_data.PushBack('\0');
}
}
return *this;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
etk::UString etk::UString::operator+ (const etk::UString &etkS)
{
etk::UString temp;
//TK_INFO(" UString(arg) : \"" << etkS.m_data << "\"");
//TK_INFO(" UString(direct) : \"" << m_data << "\"");
temp += *this;
temp += etkS;
return temp;
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
bool etk::UString::IsEmpty(void) const
{
if(1 >= m_data.Size() ) {
return true;
} else {
return false;
}
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
int32_t etk::UString::Size(void) const
{
if (m_data.Size() == 0) {
return 0;
} else {
return m_data.Size() - 1;
}
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
void etk::UString::Add(int32_t currentID, const char* inputData)
{
etk::UString tmpString(inputData);
Add(currentID, tmpString.pointer() );
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
void etk::UString::Add(int32_t currentID, const uniChar_t* inputData)
{
// get the input lenght
int32_t len = strlen(inputData);
if (0 == len) {
TK_WARNING("no data to add on the current UString");
return;
} else if (currentID < 0) {
TK_WARNING("Curent ID(" << currentID << ") < 0 ==> Add at the start");
currentID = 0;
} else if (currentID > Size() ) {
TK_ERROR("Curent ID(" << currentID << ") > maxSize ... (" << Size() << ") ==> add at the end ...");
m_data.PushBack(inputData, len);
return;
}
m_data.Insert(currentID, inputData, len);
}
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
void etk::UString::Remove(int32_t currentID, int32_t len)
{
if (0 >= len) {
TK_ERROR("no data to remove on the current UString");
return;
}
// TODO : check the size of the data
m_data.EraseLen(currentID, len);
}
/**
* @brief Remove all element in the UString
*
* @param ---
*
* @return ---
*
*/
void etk::UString::Clear(void)
{
m_data.Clear();
m_data.PushBack('\0');
}
/**
* @brief find the first accurence after the position indicated
*
* @param[in] element Element that might be find in the UString
* @param[in] startPos Stert position to begin the search
*
* @return the position of the first occurence or -1 if not find...
*
*/
int32_t etk::UString::FindForward(const char element, int32_t startPos)
{
return FindForward((uniChar_t)element, startPos);
}
int32_t etk::UString::FindForward(const uniChar_t element, int32_t startPos)
{
if (startPos < 0) {
startPos = 0;
} else if (startPos >= Size() ) {
return -1;
}
for (int32_t iii=startPos; iii< Size(); iii++) {
if (m_data[iii] == element) {
return iii;
}
}
return -1;
}
/**
* @brief find the first accurence before the position indicated.
*
* @param[in] element Element that might be find in the UString
* @param[in] startPos Stert position to begin the search
*
* @return the position of the first occurence begining by the end or -1 if not find...
*
*/
int32_t etk::UString::FindBack(const char element, int32_t startPos)
{
return FindBack((uniChar_t)element, startPos);
}
int32_t etk::UString::FindBack(const uniChar_t element, int32_t startPos)
{
if (startPos < 0) {
return -1;
} else if (startPos >= Size() ) {
startPos = Size();
}
for (int32_t iii=startPos; iii>=0; iii--) {
if (m_data[iii] == element) {
return iii;
}
}
return -1;
}
/**
* @brief Extract data from the data between two position
*
* @param[in] posStart Start position where to extract data
* @param[in] posEnd End position where to extract data
*
* @return the extracted UString
*
*/
etk::UString etk::UString::Extract(int32_t posStart, int32_t posEnd)
{
etk::UString out;
if (posStart < 0) {
posStart = 0;
} else if (posStart >= Size() ) {
return out;
}
if (posEnd < 0) {
return out;
} else if (posEnd >= Size() ) {
posEnd = Size();
}
out.m_data = m_data.Extract(posStart, posEnd);
out.m_data.PushBack('\0');
return out;
}
/**
* @brief Get a basic vector in int8 data with no \0 at the end of the UString
*
* @param ---
*
* @return The desired vector with data
*
*/
etk::VectorType<uniChar_t> etk::UString::GetVector(void)
{
etk::VectorType<uniChar_t> out = m_data;
out.PopBack();
return out;
}
// Start With ...
bool etk::UString::StartWith(const etk::UString& data)
{
if (data.Size() == 0) {
return false;
}
if (data.Size() > Size()) {
return false;
}
for (int32_t iii=0; iii<data.Size(); iii++) {
if (data[iii] != m_data[iii]) {
return false;
}
}
return true;
}
bool etk::UString::EndWith(const etk::UString& data)
{
if (data.Size() == 0) {
return false;
}
if (data.Size() > Size()) {
return false;
}
for( int32_t iii=Size()-1, jjj=data.Size()-1;
iii>=0 && jjj>=0;
iii--, jjj--) {
if (data[jjj] != m_data[iii]) {
return false;
}
}
return true;
}
char * etk::UString::Utf8Data(void)
{
// UTF8 generation :
m_dataUtf8.Clear();
unicode::convertUnicodeToUtf8(m_data, m_dataUtf8);
m_dataUtf8.PushBack('\0');
return &m_dataUtf8[0];
}

View File

@ -0,0 +1,151 @@
/**
*******************************************************************************
* @file etk/String.h
* @brief Ewol Tool Kit : normal sting management... (header)
* @author Edouard DUPIN
* @date 26/01/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_USTRING_H__
#define __ETK_USTRING_H__
#include <etk/Stream.h>
#include <etk/VectorType.h>
namespace etk
{
class UString
{
public:
// Constructeurs
UString(void);
UString(const uniChar_t* inputData, int32_t len = -1);
UString(const char* inputData, int32_t len = -1);
void Set(const uniChar_t* inputData, int32_t len=-1);
void Set(const char* inputData, int32_t len=-1);
// basic convertion integer en string
UString(char inputData);
UString(int inputData);
UString(unsigned int inputData);
UString(const etk::UString &etkS);
// destructor :
~UString(void);
/*****************************************************
* = assigment
*****************************************************/
const etk::UString& operator= (const etk::UString &etkS );
const etk::UString& operator= (etk::VectorType<char> inputData);
const etk::UString& operator= (etk::VectorType<uniChar_t> inputData);
/*****************************************************
* == operator
*****************************************************/
bool operator== (const etk::UString& etkS) const;
/*****************************************************
* != operator
*****************************************************/
bool operator!= (const etk::UString& etkS) const;
/*****************************************************
* > < >= <= operator
*****************************************************/
bool operator> (const etk::UString& etkS) const;
bool operator>= (const etk::UString& etkS) const;
bool operator< (const etk::UString& etkS) const;
bool operator<= (const etk::UString& etkS) const;
/*****************************************************
* += operator
*****************************************************/
const etk::UString& operator+= (const etk::UString &etkS);
/*****************************************************
* + operator
*****************************************************/
etk::UString operator+ (const etk::UString &etkS);
/*****************************************************
* << operator
*****************************************************/
/*
const etk::UString& operator <<= (const char input);
const etk::UString& operator <<= (const int input);
const etk::UString& operator <<= (const unsigned int input);
*/
/*****************************************************
* >> operator
*****************************************************/
/*****************************************************
* Cout << operator
*****************************************************/
friend etk::CCout& operator <<( etk::CCout &os,const etk::UString &obj);
/*****************************************************
* [] operator
*****************************************************/
const uniChar_t& operator[] (int32_t pos) const {
return m_data[pos];
}
uniChar_t& operator[] (int32_t pos) {
return m_data[pos];
}
/*****************************************************
* toolbox
*****************************************************/
// Start With ...
bool StartWith(const etk::UString& data);
// End With ...
bool EndWith(const etk::UString& data);
// Find element
int32_t FindForward(const char data, int32_t startPos=0);
int32_t FindForward(const uniChar_t data, int32_t startPos=0);
int32_t FindBack(const char data, int32_t startPos=0x7FFFFFFF);
int32_t FindBack(const uniChar_t data, int32_t startPos=0x7FFFFFFF);
bool IsEmpty(void) const;
int32_t Size(void) const;
/*****************************************************
* Generic modification function
*****************************************************/
void Add(int32_t currentID, const char* inputData);
void Add(int32_t currentID, const uniChar_t* inputData);
void Remove(int32_t currentID, int32_t len);
void Clear(void);
etk::VectorType<uniChar_t> GetVector(void);
uniChar_t * pointer(void) { return &m_data[0]; };
// generate temporary allocation (auto unallocated...)
char * Utf8Data(void);
// Sting operation :
etk::UString Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF);
private :
etk::VectorType<uniChar_t> m_data; //!< internal data is stored in the Unicode properties ...
etk::VectorType<char> m_dataUtf8; //!< Tmp data for the Utf8Data() function
};
etk::CCout& operator <<(etk::CCout &os, const etk::UString &obj);
}
int32_t strlen(const uniChar_t * data);
#endif

323
Sources/libetk/etk/Vector.h Normal file
View File

@ -0,0 +1,323 @@
/**
*******************************************************************************
* @file etk/Vector.h
* @brief Ewol Tool Kit : Basic etk::Vector (template)
* @author Edouard DUPIN
* @date 07/04/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_VECTOR_H__
#define __ETK_VECTOR_H__
#include <etk/Types.h>
#include <etk/DebugInternal.h>
#include <etk/Memory.h>
#undef __class__
#define __class__ "etk::Vector"
/**
* @brief etkVector classes ...
*
* @tparam[in] T The type of objects to store.
* @tparam[in] INC Incrementation mode (0 : Exponential to 200 and increment by stemp of 200)
*
* @todo : Need to add : popBack / Assign / Insert / Erase / Swap / Clear
*
* m_data
* ---------- |-----------------------|
* | 0 |-------->| Class Data |
* |--------| |-----------------------|
* | 1 |----|
* |--------| |
* | 2 |====|==============| |-----------------------|
* |--------| | --->| Class Data |
* m_count | 3 |-| | |-----------------------|
* |--------| | |
* | x | | | |-----------------------|
* |--------| | -------->| Class Data |
* | x | | |-----------------------|
* |--------| |
* | x | |
* |--------| | |-----------------------|
* | x | --------------------->| Class Data |
* |--------| |-----------------------|
* | x |
* |--------|
* | x |
* |--------|
* m_size | x |
* ----------
*
*/
namespace etk
{
template<class T, int32_t INC=0> class Vector
{
public:
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Vector(int count = 0):
m_data(NULL),
m_count(0),
m_size(0)
{
Resize(count);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Vector(const etk::Vector<T> & myVector):
m_size(myVector.m_size),
m_count(myVector.m_count),
m_data(NULL)
{
int32_t i;
ETK_MALLOC_CAST(m_data, m_size, T, T*);//reinterpret_cast<T*>);
for(i=0; i<m_count; i++) {
new (&m_data[i]) T(myVector[i]);
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
~Vector()
{
Destroy();
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Vector& operator=(const etk::Vector<T> & etkVector)
{
int32_t i;
this->~etkVector();
m_size = etkVector.m_size;
m_count = etkVector.m_count;
ETK_MALLOC_CAST(m_data, m_size, T, T*);//reinterpret_cast<T*>);
for(i=0; i<m_count; i++) {
new (&m_data[i]) T(etkVector[i]);
}
return *this;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int32_t Size()
{
return m_count;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
T& Get(int32_t pos)
{
return m_data[pos];
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
T& operator[] (int32_t pos)
{
return Get(pos);
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
const T& operator[] (int32_t pos) const
{
return m_data[pos];
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
int IndexOf(const T * item) const
{
int32_t res = item - m_data;
if( 0 > res
|| res >= Size())
{
return -1;
} else {
return res;
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void PushBack(const T& item)
{
int32_t idx = Size();
Resize(idx+1);
Get(idx) = item;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Resize(int32_t count)
{
int32_t i;
// Reallocate memory
if (count > m_size) {
ChangeAllocation(count);
}
// Remove deprecated element
for(i=count; i<m_count; i++) {
m_data[i].~T();
}
// Create nex item
for(i=m_count;i<count;i++) {
new (&m_data[i]) T();
}
m_count = count;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void ChangeAllocation(int count)
{
if (count > m_size) {
// generate new size
while(count > m_size) {
if (INC) {
m_size = (m_size + INC);
} else if (m_size==0) {
m_size = 1;
} else {
m_size = m_size * 2;
}
}
// Allocate the curent element
T * data = NULL;
ETK_MALLOC_CAST(data, m_size, T, T*);//reinterpret_cast<T*>);
for(int i=0; i<m_count; i++) {
new (&data[i]) T(m_data[i]);
}
Destroy();
m_data = data;
}
}
private:
T * m_data; //!< pointer on the current Data
int32_t m_count; //!< number of element
int32_t m_size; //!< current allocated size
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Destroy()
{
for(int i=0; i<m_count; i++) {
m_data[i].~T();
}
if (m_data) {
ETK_FREE(m_data);
}
}
};
}
#undef __class__
#define __class__ NULL
#endif

View File

@ -0,0 +1,672 @@
/**
*******************************************************************************
* @file etk/VectorType.h
* @brief Ewol Tool Kit : Basic VectorType for direct data insertion (template)
* @author Edouard DUPIN
* @date 07/04/2011
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __ETK_VECTOR_TYPE_H__
#define __ETK_VECTOR_TYPE_H__
#include <etk/Types.h>
#include <etk/DebugInternal.h>
#include <etk/Memory.h>
#undef __class__
#define __class__ "etk::VectorType"
/**
* @brief VectorType classes ...
*
* @tparam[in] SIZE Size of the current element.
*
* m_data
* <------------ m_dataSize ------------>
* ----------------------------------------
* | 0 |
* |--------------------------------------|
* | 1 |
* |--------------------------------------|
* | 2 |
* |--------------------------------------|
* m_size | 3 |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* | x |
* |--------------------------------------|
* m_allocated | x |
* ----------------------------------------
*
*/
namespace etk
{
template<typename MY_TYPE=int32_t> class VectorType
{
public:
class Iterator
{
// Private data :
private:
int32_t m_current; //!< curent Id on the vector
VectorType<MY_TYPE> * m_VectorType; //!< Pointer on the curent element of the vectorBin
public:
/**
* @brief Basic itarator constructor with no link with an etkVector
*/
Iterator():
m_current(-1),
m_VectorType(NULL)
{
// nothing to do ...
}
/**
* @brief Recopy constructor on a specific etkVector.
* @param[in] otherIterator The Iterator that might be copy
*/
Iterator(const Iterator & otherIterator):
m_current(otherIterator.m_current),
m_VectorType(otherIterator.m_VectorType)
{
// nothing to do ...
}
/**
* @brief Asignation operator.
* @param[in] otherIterator The Iterator that might be copy
* @return reference on the curent Iterator
*/
Iterator& operator=(const Iterator & otherIterator)
{
m_current = otherIterator.m_current;
m_VectorType = otherIterator.m_VectorType;
return *this;
}
/**
* @brief Basic destructor
*/
~Iterator()
{
m_current = -1;
m_VectorType = NULL;
}
/**
* @brief basic boolean cast
* @return true if the element is present in the etkVector size
*/
operator bool ()
{
if( 0 <= m_current
&& m_current < m_VectorType->Size() )
{
return true;
} else {
return false;
}
}
/**
* @brief Incremental operator
* @return Reference on the current iterator incremented
*/
Iterator& operator++ ()
{
if( NULL != m_VectorType
&& m_current < m_VectorType->Size() )
{
m_current++;
}
return *this;
}
/**
* @brief Decremental operator
* @return Reference on the current iterator decremented
*/
Iterator& operator-- ()
{
if (m_current >= 0) {
m_current--;
}
return *this;
}
/**
* @brief Incremental operator
* @return Reference on a new iterator and increment the other one
*/
Iterator operator++ (int32_t)
{
Iterator it(*this);
++(*this);
return it;
}
/**
* @brief Decremental operator
* @return Reference on a new iterator and decrement the other one
*/
Iterator operator-- (int32_t)
{
Iterator it(*this);
--(*this);
return it;
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
MY_TYPE & operator-> () const
{
TK_CHECK_INOUT(m_current >= 0 && m_current < m_VectorType->Size());
return &m_VectorType->Get(m_current);
}
/**
* @brief Get reference on the current Element
* @return the reference on the current Element
*/
MY_TYPE & operator* () const
{
TK_CHECK_INOUT(m_current >= 0 && m_current < m_VectorType->Size());
return m_VectorType->Get(m_current);
}
private:
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
Iterator(VectorType<MY_TYPE> * Evb, int32_t pos):
m_current(pos),
m_VectorType(Evb)
{
// nothing to do ...
}
friend class VectorType;
};
private:
MY_TYPE * m_data; //!< pointer on the curetn table of Data
int32_t m_size; //!< nb Element in the buffer
int32_t m_allocated; //!< Current allocated size
int32_t m_increment; //!< methode of increment
public:
/**
* @brief Create an empty vector
* @param[in] count Minimum request size of the Buffer
*/
VectorType(int32_t count = 0):
m_data(NULL),
m_size(0),
m_allocated(0),
m_increment(1)
{
ChangeAllocation(count);
}
/**
* @brief Re-copy constructor (copy all needed data)
* @param[in] Evb Vector that might be copy
*/
VectorType(const etk::VectorType<MY_TYPE> & Evb)
{
m_allocated = Evb.m_allocated;
m_size = Evb.m_size;
m_increment = Evb.m_increment;
m_data = NULL;
//TK_DEBUG("USE Specific vector allocator ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment);
// allocate all same data
ETK_MALLOC(m_data, m_allocated, MY_TYPE);
TK_ASSERT(NULL!=m_data, "Error in data allocation");
// Copy all data ...
memcpy(m_data, Evb.m_data, m_allocated * sizeof(MY_TYPE) );
}
/**
* @brief Destructor of the current Class
*/
~VectorType()
{
if (NULL!=m_data) {
ETK_FREE(m_data);
m_data = NULL;
}
m_allocated = 0;
m_size = 0;
m_increment = 0;
}
/**
* @brief Re-copy operator
* @param[in] Evb Vector that might be copy
* @return reference on the curent re-copy vector
*/
VectorType& operator=(const etk::VectorType<MY_TYPE> & Evb)
{
//TK_DEBUG("USE RECOPY vector ... Evb.m_size=" << Evb.m_size << " Evb.m_increment=" << Evb.m_increment);
if( this != &Evb ) // avoid copy to itself
{
if (NULL!=m_data) {
ETK_FREE(m_data);
m_data = NULL;
}
// Set the new value
m_allocated = Evb.m_allocated;
m_size = Evb.m_size;
m_increment = Evb.m_increment;
// allocate all same data
ETK_MALLOC(m_data, m_allocated, MY_TYPE);
TK_ASSERT(NULL!=m_data, "Error in data allocation");
// Copy all data ...
memcpy(m_data, Evb.m_data, m_allocated * sizeof(MY_TYPE) );
}
// Return the curent pointer
return *this;
}
/**
* @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector
*/
VectorType& operator+= (const etk::VectorType<MY_TYPE> & Evb) // += operator
{
int32_t nbElememt = Evb.Size();
int32_t idx = m_size;
Resize(m_size+nbElememt);
memcpy(&m_data[idx], &Evb.m_data[0], nbElememt*sizeof(MY_TYPE) );
// Return the curent pointer
return *this;
}
/**
* @brief Set increment mode of this vector (default it match corectly with the number of element inside)
* @param[in] newIncrementNumber methode requested
*/
void SetIncrement(int32_t newIncrementNumber)
{
m_increment = newIncrementNumber;
}
/**
* @brief Get the number of element in the vector
* @return The number requested
*/
int32_t Size() const
{
return m_size;
}
/**
* @brief Get the Allocated size in the vector
* @return The size of allocation
*/
int32_t AllocatedSize() const
{
return m_allocated;
}
/**
* @brief Get a current element in the vector
* @param[in] pos Desired position read
* @return Reference on the Element
*/
MY_TYPE& Get(int32_t pos)
{
return m_data[pos];
}
/**
* @brief Get an copy Element an a special position
* @param[in] pos Position in the vector that might be get [0..Size()]
* @return An reference on the copy of selected element
*/
MY_TYPE& operator[] (int32_t pos)
{
return Get(pos);
}
/**
* @brief Get an Element an a special position
* @param[in] pos Position in the vector that might be get [0..Size()]
* @return An reference on the selected element
*/
const MY_TYPE& operator[] (int32_t pos) const
{
return m_data[pos];
}
/**
* @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector
*/
void PushBack(const MY_TYPE& item)
{
int32_t idx = m_size;
Resize(m_size+1);
m_data[idx] = item;
}
/**
* @brief Add at the Last position of the Vector
* @param[in] item Element to add at the end of vector
*/
void PushBack(const MY_TYPE * item, int32_t nbElement)
{
if (NULL == item) {
return;
}
int32_t idx = m_size;
Resize(m_size+nbElement);
memcpy(&m_data[idx], item, nbElement*sizeof(MY_TYPE) );
}
/**
* @brief Remove the last element of the vector
*/
void PopBack(void)
{
if(m_size>0) {
Resize(m_size-1);
}
}
/**
* @brief Remove all alement in the current vector
*/
void Clear(void)
{
if(m_size>0) {
Resize(0);
}
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Insert(int32_t pos, const MY_TYPE& item)
{
if (pos>m_size) {
TK_ERROR(" can not insert Element at this position : " << pos << " > " << m_size<< " add it at the end ... ");
PushBack(item);
return;
}
int32_t tmpSize = m_size;
// Request resize of the current buffer
Resize(m_size+1);
// move curent data
memmove((m_data + pos + 1), (m_data + pos), (tmpSize - pos)*sizeof(MY_TYPE) );
// affectation of the current element
m_data[pos] = item;
}
/**
* @brief
*
* @param[in,out] ---
*
* @return ---
*
*/
void Insert(int32_t pos, const MY_TYPE * item, int32_t nbElement)
{
if (pos>m_size) {
TK_WARNING(" can not insert Element at this position : " << pos << " > " << m_size << " add it at the end ... ");
PushBack(item, nbElement);
return;
}
int32_t tmpSize = m_size;
// Request resize of the current buffer
Resize(m_size+nbElement);
// move curent data (after the position)
memmove((m_data + pos + nbElement), (m_data + pos), (tmpSize - pos)*sizeof(MY_TYPE) );
// affectation of all input element
memcpy(&m_data[pos], item, nbElement*sizeof(MY_TYPE) );
}
/**
* @brief Remove one element
*
* @param[in] pos Position to remove the data
*
* @return ---
*
*/
void Erase(int32_t pos)
{
if (pos<0 || (uint32_t)pos>m_size) {
TK_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size);
return;
}
int32_t tmpSize = m_size;
// move curent data
memmove((m_data + pos), (m_data + pos + 1), (tmpSize - (pos+1))*sizeof(MY_TYPE) );
// Request resize of the current buffer
Resize(m_size-1);
}
/**
* @brief Remove N elements
*
* @param[in] pos Position to remove the data
* @param[in] posEnd Last position number
*
* @return ---
*
*/
void Erase(int32_t pos, int32_t posEnd)
{
if (pos>m_size) {
TK_ERROR(" can not Erase Element at this position : " << pos << " > " << m_size);
return;
}
if (posEnd>m_size) {
posEnd = m_size;
}
int32_t nbElement = m_size - pos;
int32_t tmpSize = m_size;
// move curent data
memmove((m_data + pos), (m_data + pos + nbElement), (tmpSize - (pos+nbElement))*sizeof(MY_TYPE) );
// Request resize of the current buffer
Resize(m_size-nbElement);
}
/**
* @brief Remove N element
*
* @param[in] pos Position to remove the data
* @param[in] nbElement number of element to remove
*
* @return ---
*
*/
void EraseLen(int32_t pos, int32_t nbElement)
{
if (pos>m_size) {
TK_ERROR(" can not Erase Len Element at this position : " << pos << " > " << m_size);
return;
}
if (pos+nbElement>m_size) {
nbElement = m_size - pos;
}
int32_t tmpSize = m_size;
// move curent data
memmove((m_data + pos), (m_data + pos + nbElement), (tmpSize - (pos+nbElement))*sizeof(MY_TYPE) );
// Request resize of the current buffer
Resize(m_size-nbElement);
}
/**
* @brief extract data between two point :
* @param[in] posStart start position to extract data
* @param[in] posEnd End position to extract data
* @return the extracted vector
*/
VectorType Extract(int32_t posStart = 0, int32_t posEnd=0x7FFFFFFF)
{
VectorType<MY_TYPE> out;
if (posStart < 0) {
posStart = 0;
} else if (posStart >= Size() ) {
return out;
}
if (posEnd < 0) {
return out;
} else if (posEnd >= Size() ) {
posEnd = Size();
}
out.PushBack(&m_data[posStart], posEnd-posStart);
return out;
}
/**
* @brief Set the minimum allocation in memory for the curent vector ==> reallocate the
* buffer to fit exactly the mumber of element needed
*/
void Fit(void)
{
if (m_size > m_allocated) {
// Reallocate the curent data to the correct size ...
ETK_REALLOC(m_data, m_size, MY_TYPE);
}
// Check result with assert :
TK_ASSERT(NULL!=m_data, "Error in data Fitting");
m_allocated = m_size;
}
/**
* @brief Get an iterator an an specific position
* @param[in] pos Requested position of the iterator in the vector
* @return The Iterator
*/
Iterator Position(int32_t pos)
{
return Iterator(this, pos);
}
/**
* @brief Get an Iterator on the start position of the Vector
* @return The Iterator
*/
Iterator Begin(void)
{
return Position(0);
}
/**
* @brief Get an Iterator on the end position of the Vector
* @return The Iterator
*/
Iterator End(void)
{
return Position( Size()-1 );
}
private:
/**
* @brief Change the current size of the vector
* @param[in] newSize New requested size of element in the vector
*/
void Resize(int32_t newSize)
{
// Reallocate memory
if (newSize > m_allocated) {
ChangeAllocation(newSize);
}
m_size = newSize;
}
/**
* @brief Change the current allocation to the corect one (depend on the current size)
* @param[in] newSize Minimum number of element needed
*/
void ChangeAllocation(int32_t newSize)
{
// set the minimal size to 1
if(newSize <= 0) {
newSize = 1;
}
int32_t requestSize = m_allocated;
// set the size with the corect chose type :
if (newSize == m_allocated) {
return;
} else if (newSize < requestSize) {
// down the size of the vector:
if (0==m_increment) {
// never down size...
} else {
int32_t devide = m_increment;
if (devide == 0) {
devide = 1;
}
int32_t numberOfStep = m_allocated / devide;
if (newSize< ((numberOfStep-2)*devide + devide/2) ) {
//Allow Reallocation of a new size shorter
requestSize = ((newSize / devide)+1) * devide;
}
}
} else {
while(newSize > requestSize) {
if (0 == requestSize) {
requestSize = 1;
} else if (0==m_increment) {
requestSize = requestSize * 2;
} else {
requestSize = (requestSize + m_increment);
}
}
}
// No reallocation needed :
if (requestSize == m_allocated) {
return;
}
// check if something is allocated :
if (NULL == m_data) {
// no data allocated ==> request an allocation (might be the first)
ETK_MALLOC(m_data, requestSize, MY_TYPE);
} else {
// move datas
ETK_REALLOC(m_data, requestSize, MY_TYPE);
}
// Check result with assert :
TK_ASSERT(NULL!=m_data, "Error in data allocation");
// set the new allocation size
m_allocated = requestSize;
}
};
}
#undef __class__
#define __class__ NULL
#endif

View File

@ -0,0 +1,677 @@
/**
*******************************************************************************
* @file unicode.cpp
* @brief Editeur De N'ours : Abstraction Charset layer (Sources)
* @author Edouard DUPIN
* @date 18/01/2012
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
// cf : http://unicode.org/fr/charts/symbols.html#CombiningDiacriticalMarks
#include <etk/Types.h>
#include <etk/Debug.h>
#include <etk/unicodeTable.h>
#include <etk/unicode.h>
// transform ISO <==> Unicode
void unicode::convertIsoToUnicode(charset_te inputCharset, char input_ISO, uniChar_t & output_Unicode)
{
switch(inputCharset)
{
case EDN_CHARSET_ISO_8859_1: output_Unicode = TableIso8859_1[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_2: output_Unicode = TableIso8859_2[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_3: output_Unicode = TableIso8859_3[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_4: output_Unicode = TableIso8859_4[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_5: output_Unicode = TableIso8859_5[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_6: output_Unicode = TableIso8859_6[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_7: output_Unicode = TableIso8859_7[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_8: output_Unicode = TableIso8859_8[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_9: output_Unicode = TableIso8859_9[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_10: output_Unicode = TableIso8859_10[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_11: output_Unicode = TableIso8859_11[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_13: output_Unicode = TableIso8859_13[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_14: output_Unicode = TableIso8859_14[(uint32_t)input_ISO&0xFF]; break;
case EDN_CHARSET_ISO_8859_15:
output_Unicode = TableIso8859_15[(uint32_t)input_ISO&0xFF];
#if 0
if ((uint32_t)input_ISO&0xFF == 0xb0) {
printf("Change Element : 0x%02x ==> 0x%08x \n", (uint32_t)input_ISO&0xFF, output_Unicode);
}
#endif
break;
default :
TK_WARNING("Unknow charset ... " << inputCharset);
output_Unicode = '?';
break;
}
}
void unicode::convertUnicodeToIso(charset_te inputCharset, uniChar_t input_Unicode, char & output_ISO)
{
const uniChar_t *tmpTable = NULL;
switch(inputCharset)
{
case EDN_CHARSET_ISO_8859_1: tmpTable = TableIso8859_1; break;
case EDN_CHARSET_ISO_8859_2: tmpTable = TableIso8859_2; break;
case EDN_CHARSET_ISO_8859_3: tmpTable = TableIso8859_3; break;
case EDN_CHARSET_ISO_8859_4: tmpTable = TableIso8859_4; break;
case EDN_CHARSET_ISO_8859_5: tmpTable = TableIso8859_5; break;
case EDN_CHARSET_ISO_8859_6: tmpTable = TableIso8859_6; break;
case EDN_CHARSET_ISO_8859_7: tmpTable = TableIso8859_7; break;
case EDN_CHARSET_ISO_8859_8: tmpTable = TableIso8859_8; break;
case EDN_CHARSET_ISO_8859_9: tmpTable = TableIso8859_9; break;
case EDN_CHARSET_ISO_8859_10: tmpTable = TableIso8859_10; break;
case EDN_CHARSET_ISO_8859_11: tmpTable = TableIso8859_11; break;
case EDN_CHARSET_ISO_8859_13: tmpTable = TableIso8859_13; break;
case EDN_CHARSET_ISO_8859_14: tmpTable = TableIso8859_14; break;
case EDN_CHARSET_ISO_8859_15: tmpTable = TableIso8859_15; break;
default :
TK_WARNING("Unknow charset ... " << inputCharset);
output_ISO = '?';
return;
}
int32_t i;
for (i=0; i<256; i++) {
if (tmpTable[i] == input_Unicode) {
output_ISO = (char)i;
return;
}
}
}
int32_t unicode::convertIsoToUnicode(charset_te inputCharset, etk::VectorType<char>& input_ISO, etk::VectorType<uniChar_t>& output_Unicode)
{
TK_WARNING("TODO : not coded...");
return 0;
}
int32_t unicode::convertUnicodeToIso(charset_te inputCharset, etk::VectorType<uniChar_t>& input_Unicode, etk::VectorType<char>& output_ISO)
{
TK_WARNING("TODO : not coded...");
return 0;
}
static uint32_t unicodeToUtf8(uniChar_t value)
{
uint32_t output = 0;
if (127 >= value) {
output = value;
} else if (2047 >= value) {
// output ==> 00000000 00000000 110xxxxx 10xxxxxx
// input ==> -------- -------- -----222 22111111
output = 0x0000C080;
output+= (value & 0x000007C0)<<2;
output+= value & 0x0000003F;
} else if (65535 >= value) {
// output ==> 00000000 1110xxxx 10xxxxxx 10xxxxxx
// input ==> -------- -------- 33332222 22111111
output = 0x00E08080;
output+= (value & 0x0000F000)<<4;
output+= (value & 0x00000FC0)<<2;
output+= value & 0x0000003F;
} else if (1114111 >= value) {
// output ==> 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx
// input ==> -------- ---44433 33332222 22111111
output = 0xF0808080;
output+= (value & 0x001C0000)<<6;
output+= (value & 0x0003F000)<<4;
output+= (value & 0x00000FC0)<<2;
output+= value & 0x0000003F;
} else {
TK_ERROR("NON UTF8 caracter input...");
return 0;
}
//printf("utf8convertion : %d=%08x ==> %08x\n",value, value, output);
return output;
}
// Transform UTF-8 <==> Unicode
void unicode::convertUnicodeToUtf8(uniChar_t input_Unicode, char * output_UTF8)
{
uint32_t value = unicodeToUtf8(input_Unicode);
if (0xFF >= value) {
output_UTF8[0] = (char)value;
output_UTF8[1] = '\0';
} else if (0xFFFF >= value) {
output_UTF8[0] = (char)((value>>8) & 0x000000FF);
output_UTF8[1] = (char)value;
output_UTF8[2] = '\0';
} else if (0xFFFFFF >= value) {
output_UTF8[0] = (char)((value>>16) & 0x000000FF);
output_UTF8[1] = (char)((value>>8) & 0x000000FF);
output_UTF8[2] = (char)value;
output_UTF8[3] = '\0';
} else {
output_UTF8[0] = (char)((value>>24) & 0x000000FF);
output_UTF8[1] = (char)((value>>16) & 0x000000FF);
output_UTF8[2] = (char)((value>>8) & 0x000000FF);
output_UTF8[3] = (char)value;
output_UTF8[4] = '\0';
}
}
void unicode::convertUtf8ToUnicode(char * input_UTF8, uniChar_t &output_Unicode)
{
int32_t len = strlen(input_UTF8);
output_Unicode = 0;
switch (len) {
case 1:
output_Unicode = (uint8_t)(input_UTF8[0]) & 0x7F;
break;
case 2:
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x1F)<< 6;
output_Unicode += ((uint8_t)input_UTF8[1]) & 0x3F;
break;
case 3:
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x0F)<< 12;
output_Unicode += (((uint8_t)input_UTF8[1]) & 0x3F)<< 6;
output_Unicode += ((uint8_t)input_UTF8[2]) & 0x3F;
break;
default:
output_Unicode = (((uint8_t)input_UTF8[0]) & 0x07)<< 18;
output_Unicode += (((uint8_t)input_UTF8[1]) & 0x3F)<< 12;
output_Unicode += (((uint8_t)input_UTF8[2]) & 0x3F)<< 6;
output_Unicode += ((uint8_t)input_UTF8[3]) & 0x3F;
break;
}
}
int32_t unicode::convertUnicodeToUtf8(const etk::VectorType<uniChar_t>& input_Unicode, etk::VectorType<char>& output_UTF8)
{
char output[10];
for (int32_t iii=0; iii<input_Unicode.Size(); iii++) {
unicode::convertUnicodeToUtf8(input_Unicode[iii], output);
char * tmp = output ;
while (*tmp != '\0') {
output_UTF8.PushBack(*tmp);
tmp++;
}
}
output_UTF8.PushBack('\0');
return output_UTF8.Size()-1;
}
int32_t unicode::convertUtf8ToUnicode(etk::VectorType<char>& input_UTF8, etk::VectorType<uniChar_t>& output_Unicode)
{
char tmpData[20];
int32_t pos = 0;
while (pos < input_UTF8.Size()) {
int32_t lenMax = input_UTF8.Size() - pos;
//4 case
if( 1<=lenMax
&& 0x00 == (input_UTF8[pos+0] & 0x80) )
{
tmpData[0] = input_UTF8[pos+0];
tmpData[1] = '\0';
pos += 1;
} else if( 2<=lenMax
&& 0xC0 == (input_UTF8[pos+0] & 0xE0)
&& 0x80 == (input_UTF8[pos+1] & 0xC0) ) {
tmpData[0] = input_UTF8[pos+0];
tmpData[1] = input_UTF8[pos+1];
tmpData[2] = '\0';
pos += 2;
} else if( 3<=lenMax
&& 0xE0 == (input_UTF8[pos+0] & 0xF0)
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
&& 0x80 == (input_UTF8[pos+2] & 0xC0)) {
tmpData[0] = input_UTF8[pos+0];
tmpData[1] = input_UTF8[pos+1];
tmpData[2] = input_UTF8[pos+2];
tmpData[3] = '\0';
pos += 3;
} else if( 4<=lenMax
&& 0xF0 == (input_UTF8[pos+0] & 0xF8)
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
&& 0x80 == (input_UTF8[pos+2] & 0xC0)
&& 0x80 == (input_UTF8[pos+3] & 0xC0)) {
tmpData[0] = input_UTF8[pos+0];
tmpData[1] = input_UTF8[pos+1];
tmpData[2] = input_UTF8[pos+2];
tmpData[3] = input_UTF8[pos+3];
tmpData[4] = '\0';
pos += 4;
} else {
tmpData[0] = '\0';
pos += 1;
}
uniChar_t tmpUnicode;
convertUtf8ToUnicode(tmpData, tmpUnicode);
output_Unicode.PushBack(tmpUnicode);
}
return 0;
}
int32_t unicode::convertUtf8ToUnicode(char * input_UTF8, etk::VectorType<uniChar_t>& output_Unicode)
{
char tmpData[20];
int32_t pos = 0;
if (NULL == input_UTF8) {
return 0;
}
int32_t len = strlen(input_UTF8);
while (pos < len) {
int32_t lenMax = len - pos;
//4 case
if( 1<=lenMax
&& 0x00 == (input_UTF8[pos+0] & 0x80) )
{
tmpData[0] = input_UTF8[pos+0];
tmpData[1] = '\0';
pos += 1;
} else if( 2<=lenMax
&& 0xC0 == (input_UTF8[pos+0] & 0xE0)
&& 0x80 == (input_UTF8[pos+1] & 0xC0) ) {
tmpData[0] = input_UTF8[pos+0];
tmpData[1] = input_UTF8[pos+1];
tmpData[2] = '\0';
pos += 2;
} else if( 3<=lenMax
&& 0xE0 == (input_UTF8[pos+0] & 0xF0)
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
&& 0x80 == (input_UTF8[pos+2] & 0xC0)) {
tmpData[0] = input_UTF8[pos+0];
tmpData[1] = input_UTF8[pos+1];
tmpData[2] = input_UTF8[pos+2];
tmpData[3] = '\0';
pos += 3;
} else if( 4<=lenMax
&& 0xF0 == (input_UTF8[pos+0] & 0xF8)
&& 0x80 == (input_UTF8[pos+1] & 0xC0)
&& 0x80 == (input_UTF8[pos+2] & 0xC0)
&& 0x80 == (input_UTF8[pos+3] & 0xC0)) {
tmpData[0] = input_UTF8[pos+0];
tmpData[1] = input_UTF8[pos+1];
tmpData[2] = input_UTF8[pos+2];
tmpData[3] = input_UTF8[pos+3];
tmpData[4] = '\0';
pos += 4;
} else {
tmpData[0] = '\0';
pos += 1;
}
uniChar_t tmpUnicode;
convertUtf8ToUnicode(tmpData, tmpUnicode);
output_Unicode.PushBack(tmpUnicode);
}
return 0;
}
// Transform ISO <==> UTF-8
void unicode::convertIsoToUtf8(charset_te inputCharset, char input_ISO, char * output_UTF8)
{
uniChar_t tmpUnicode;
// concert Iso in UniCode
convertIsoToUnicode(inputCharset, input_ISO, tmpUnicode );
// convert UniCode in Utf-8
convertUnicodeToUtf8(tmpUnicode, output_UTF8);
}
void unicode::convertUtf8ToIso(charset_te inputCharset, char * input_UTF8, char & output_ISO)
{
uniChar_t tmpUnicode;
// convert Utf-8 in UniCode
convertUtf8ToUnicode(input_UTF8, tmpUnicode);
// concert UniCode in Iso
convertUnicodeToIso(inputCharset, tmpUnicode, output_ISO);
}
int32_t unicode::convertIsoToUtf8(charset_te inputCharset, etk::VectorType<char>& input_ISO, etk::VectorType<char>& output_UTF8)
{
TK_WARNING("TODO : not coded...");
return 0;
}
int32_t unicode::convertUtf8ToIso(charset_te inputCharset, etk::VectorType<char>& input_UTF8, etk::VectorType<char>& output_ISO)
{
TK_WARNING("TODO : not coded...");
return 0;
}
/**
* @brief Get the number of element of the curent UTF8 char (in the curent Buffer)
*
* @param[in] data pointer on the curent CHAR string (pointer on the allocated buffer)
* @param[out] size Nb of char use in this UTF8 [0..4]
* @param[out] baseValid true : the ase format of the UTF8 is CORRECT
*
* @return ---
*
*/
void unicode::Utf8_SizeElement(const char * data, int32_t lenMax , uint8_t &size, bool &baseValid)
{
TK_ASSERT(0 <= lenMax, "size can not be < 0 ...");
if (0 > lenMax) {
size = 0;
baseValid = false;
return;
}
//4 case
if ( 1<=lenMax
&& 0x00 == (data[0] & 0x80) ) {
// One Char Element
size = 1;
baseValid = true;
} else if( 2<=lenMax
&& 0xC0 == (data[0] & 0xE0)
&& 0x80 == (data[1] & 0xC0) ) {
size = 2;
baseValid = true;
} else if( 3<=lenMax
&& 0xE0 == (data[0] & 0xF0)
&& 0x80 == (data[1] & 0xC0)
&& 0x80 == (data[2] & 0xC0)) {
size = 3;
baseValid = true;
} else if( 4<=lenMax
&& 0xF0 == (data[0] & 0xF8)
&& 0x80 == (data[1] & 0xC0)
&& 0x80 == (data[2] & 0xC0)
&& 0x80 == (data[3] & 0xC0)) {
size = 4;
baseValid = true;
} else {
// return only one error Caracter ...
baseValid = false;
size = 1;
}
}
#if 0 // Remove for the moment ...
/**
* @brief Get the number of element of the previous UTF8 char (in the curent Buffer)
*
* @param[in] data pointer on the curent CHAR string (pointer on the allocated buffer) (the curent char is not check)
* @param[out] size Nb of char use in this UTF8 [0..4]
* @param[out] baseValid true : the ase format of the UTF8 is CORRECT
*
* @return ---
*
*/
static void Utf8_SizePreviousElement(const char * data, int32_t lenMax, uint8_t &size, bool &baseValid)
{
EDN_ASSERT(0 <= lenMax, "size can not be < 0 ...");
if (0 > lenMax) {
size = 0;
baseValid = false;
return;
}
//4 case
if ( 1<=lenMax
&& 0x00 == (data[-1] & 0x80) ) {
// One Char Element
size = 1;
baseValid = true;
} else if( 2<=lenMax
&& 0xC0 == (data[-2] & 0xE0)
&& 0x80 == (data[-1] & 0xC0) ) {
size = 2;
baseValid = true;
} else if( 3<=lenMax
&& 0xE0 == (data[-3] & 0xF0)
&& 0x80 == (data[-2] & 0xC0)
&& 0x80 == (data[-1] & 0xC0)) {
size = 3;
baseValid = true;
} else if( 4<=lenMax
&& 0xF0 == (data[-4] & 0xF8)
&& 0x80 == (data[-3] & 0xC0)
&& 0x80 == (data[-2] & 0xC0)
&& 0x80 == (data[-1] & 0xC0)) {
size = 4;
baseValid = true;
} else {
// return only one error Caracter ...
baseValid = false;
size = 1;
}
}
#endif
/**
* @brief
*
* @param[in,out]
*
* @return
*
*/
/*
static uint32_t Utf8_GetValue(UTF8Element_ts &Element)
{
uint32_t value = 0;
const char * data = m_data + Element.CharPosition;
//4 case
switch(Element.CharSize)
{
case 1:
value = data[0] & 0x7F;
break;
case 2:
value = (data[0] & 0x1F)<< 6;
value += data[1] & 0x3F;
break;
case 3:
value = (data[0] & 0x0F)<< 12;
value += (data[1] & 0x3F)<< 6;
value += data[2] & 0x3F;
break;
case 4:
value = (data[0] & 0x07)<< 18;
value += (data[1] & 0x3F)<< 12;
value += (data[2] & 0x3F)<< 6;
value += data[3] & 0x3F;
break;
default:
// return only one error Caracter ...
EDN_ASSERT(false, "impossible case....");
break;
}
// check the validity of the UTF8 ...
if( ( 0xD800 <= value
&& 0xDFFF >= value )
|| ( 0xFDD0 <= value
&& 0xFDEF >= value )
|| ( 0xFFFE <= value
&& 0xFFFF >= value )
|| ( 0x1FFFE <= value
&& 0x1FFFF >= value )
|| ( 0x2FFFE <= value
&& 0xDFFFF >= value )
|| ( 0xEFFFE <= value
&& 0xEFFFF >= value )
|| ( 0xFFFFE <= value
&& 0xFFFFF >= value )
|| ( 0x10FFFE <= value
&& 0x10FFFF >= value ) )
{
// overwrite the UTF8 validity ==> this is not a diaplayable element
Element.ValidUTF8 = false;
return value;
}
return value;
}
*/
int32_t unicode::strUtf8Len(const char *input_UTF8)
{
int32_t count = 0;
int32_t size = strlen(input_UTF8);
uint8_t tmpSize;
bool baseValid;
while (size > 0) {
Utf8_SizeElement(input_UTF8, size , tmpSize, baseValid);
input_UTF8 += tmpSize;
size -= tmpSize;
count++;
}
return count;
}
// **************************************************************************************************************
// simple convertion optention
// **************************************************************************************************************
#if 0
Procedure de recuperation des charset sans ce casser les ...
// generate the basic file
FILE * mfile = NULL;
mfile = fopen("fichierIsoBase", "wb");
if (NULL == mfile) {
EDN_ERROR("Error to create file");
return false;
}
char newline = '\n';
for(int32_t i=0x20; i<0x100; i++) {
char plop = i;
fwrite(&plop, sizeof(char), 1, mfile);
fwrite(&newline, sizeof(char), 1, mfile);
}
fclose(mfile);
// console script to convert files :
iconv -c --from-code=ISO-8859-1 --to-code=UTF-8 -o fichierUTF8_iso-1 fichierIsoBase
iconv -c --from-code=ISO-8859-2 --to-code=UTF-8 -o fichierUTF8_iso-2 fichierIsoBase
iconv -c --from-code=ISO-8859-3 --to-code=UTF-8 -o fichierUTF8_iso-3 fichierIsoBase
iconv -c --from-code=ISO-8859-4 --to-code=UTF-8 -o fichierUTF8_iso-4 fichierIsoBase
iconv -c --from-code=ISO-8859-5 --to-code=UTF-8 -o fichierUTF8_iso-5 fichierIsoBase
iconv -c --from-code=ISO-8859-6 --to-code=UTF-8 -o fichierUTF8_iso-6 fichierIsoBase
iconv -c --from-code=ISO-8859-7 --to-code=UTF-8 -o fichierUTF8_iso-7 fichierIsoBase
iconv -c --from-code=ISO-8859-8 --to-code=UTF-8 -o fichierUTF8_iso-8 fichierIsoBase
iconv -c --from-code=ISO-8859-9 --to-code=UTF-8 -o fichierUTF8_iso-9 fichierIsoBase
iconv -c --from-code=ISO-8859-10 --to-code=UTF-8 -o fichierUTF8_iso-10 fichierIsoBase
iconv -c --from-code=ISO-8859-11 --to-code=UTF-8 -o fichierUTF8_iso-11 fichierIsoBase
iconv -c --from-code=ISO-8859-12 --to-code=UTF-8 -o fichierUTF8_iso-12 fichierIsoBase
iconv -c --from-code=ISO-8859-13 --to-code=UTF-8 -o fichierUTF8_iso-13 fichierIsoBase
iconv -c --from-code=ISO-8859-14 --to-code=UTF-8 -o fichierUTF8_iso-14 fichierIsoBase
iconv -c --from-code=ISO-8859-15 --to-code=UTF-8 -o fichierUTF8_iso-15 fichierIsoBase
// NOTE : Le format 12 n'existe pas ...
FILE * mfileout = NULL;
mfileout = fopen("outputGeneration.c", "wb");
if (NULL == mfileout) {
EDN_ERROR("Error to create file");
return false;
}
char * inputFileData[] = {
"fichierUTF8_iso-1",
"fichierUTF8_iso-2",
// "fichierUTF8_iso-3",
"fichierUTF8_iso-4",
"fichierUTF8_iso-5",
/* "fichierUTF8_iso-6",
"fichierUTF8_iso-7",
"fichierUTF8_iso-8",
"fichierUTF8_iso-9",
"fichierUTF8_iso-10",
"fichierUTF8_iso-11",
"fichierUTF8_iso-13",
"fichierUTF8_iso-14",
*/
"fichierUTF8_iso-15"
};
for (int32_t k=0; k<5; k++) {
FILE * mfile = NULL;
mfile = fopen(inputFileData[k], "rb");
if (NULL == mfile) {
EDN_ERROR("Error to open file");
return false;
}
char data[255] ;
fprintf(mfileout, "\tTYPESTRUCT_TS %s[] = {\n\t\t", inputFileData[k]);
for(int32_t i=0x0; i<0x10; i++) {
fprintf(mfileout, "0x%08X, ", i);
}
fprintf(mfileout, "\n\t\t");
for(int32_t i=0x10; i<0x20; i++) {
fprintf(mfileout, "0x%08X, ", i);
}
for(int32_t i=0x20; i<0x100; i++) {
if (0==i%16) {
fprintf(mfileout, "\n\t\t");
}
fgets(data, 25, mfile );
data[strlen(data)-1] = '\0';
EDN_INFO("sizeofLine=" << strlen(data) << " data=\"" << data << "\"");
// convert in int :
int32_t valUTF8 = 0;
int32_t valUnicode = 0;
switch (strlen(data)) {
case 1:
valUTF8 = (uint8_t) (data[0]);
valUnicode = (uint8_t)(data[0]) & 0x7F;
break;
case 2:
valUTF8 = (uint8_t) (data[0]) << 8;
valUTF8 += (uint8_t) (data[1]);
valUnicode = (((uint8_t)data[0]) & 0x1F)<< 6;
valUnicode += ((uint8_t)data[1]) & 0x3F;
break;
case 3:
valUTF8 = (uint8_t) (data[0]) << 16;
valUTF8 += (uint8_t) (data[1]) << 8;
valUTF8 += (uint8_t) (data[2]);
valUnicode = (((uint8_t)data[0]) & 0x0F)<< 12;
valUnicode += (((uint8_t)data[1]) & 0x3F)<< 6;
valUnicode += ((uint8_t)data[2]) & 0x3F;
break;
default:
valUTF8 = (uint8_t) (data[0]) <<24;
valUTF8 += (uint8_t) (data[1]) << 16;
valUTF8 += (uint8_t) (data[2]) << 8;
valUTF8 += (uint8_t) (data[3]);
valUnicode = (((uint8_t)data[0]) & 0x07)<< 18;
valUnicode += (((uint8_t)data[1]) & 0x3F)<< 12;
valUnicode += (((uint8_t)data[2]) & 0x3F)<< 6;
valUnicode += ((uint8_t)data[3]) & 0x3F;
break;
}
fprintf(mfileout, "0x%08X, ", valUnicode);
}
fprintf(mfileout, "\n\t};\n\n");
fclose(mfile);
}
fclose(mfileout);
#endif

View File

@ -0,0 +1,71 @@
/**
*******************************************************************************
* @file unicode.h
* @brief Editeur De N'ours : Abstraction Charset layer (header)
* @author Edouard DUPIN
* @date 18/01/2012
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __UNICODE_H__
#define __UNICODE_H__
#include <etk/Types.h>
#include <etk/VectorType.h>
namespace unicode {
typedef enum {
EDN_CHARSET_UTF8,
EDN_CHARSET_ISO_8859_1,
EDN_CHARSET_ISO_8859_2,
EDN_CHARSET_ISO_8859_3,
EDN_CHARSET_ISO_8859_4,
EDN_CHARSET_ISO_8859_5,
EDN_CHARSET_ISO_8859_6,
EDN_CHARSET_ISO_8859_7,
EDN_CHARSET_ISO_8859_8,
EDN_CHARSET_ISO_8859_9,
EDN_CHARSET_ISO_8859_10,
EDN_CHARSET_ISO_8859_11,
EDN_CHARSET_ISO_8859_13,
EDN_CHARSET_ISO_8859_14,
EDN_CHARSET_ISO_8859_15,
} charset_te;
// transform ISO <==> Unicode
void convertIsoToUnicode(charset_te inputCharset, char input_ISO, uniChar_t & output_Unicode);
void convertUnicodeToIso(charset_te inputCharset, uniChar_t input_Unicode, char & output_ISO);
int32_t convertIsoToUnicode(charset_te inputCharset, etk::VectorType<char>& input_ISO, etk::VectorType<uniChar_t>& output_Unicode);
int32_t convertUnicodeToIso(charset_te inputCharset, etk::VectorType<uniChar_t>& input_Unicode, etk::VectorType<char>& output_ISO);
// Transform UTF-8 <==> Unicode
void convertUnicodeToUtf8( uniChar_t input_Unicode, char * output_UTF8);
void convertUtf8ToUnicode( char * input_UTF8, uniChar_t& output_Unicode);
int32_t convertUnicodeToUtf8( const etk::VectorType<uniChar_t>& input_Unicode, etk::VectorType<char>& output_UTF8);
int32_t convertUtf8ToUnicode( etk::VectorType<char>& input_UTF8, etk::VectorType<uniChar_t>& output_Unicode);
int32_t convertUtf8ToUnicode( char * input_UTF8, etk::VectorType<uniChar_t>& output_Unicode);
// Transform ISO <==> UTF-8
void convertIsoToUtf8( charset_te inputCharset, char input_ISO, char * output_UTF8);
void convertUtf8ToIso( charset_te inputCharset, char * input_UTF8, char & output_ISO);
int32_t convertIsoToUtf8( charset_te inputCharset, etk::VectorType<char>& input_ISO, etk::VectorType<char>& output_UTF8);
int32_t convertUtf8ToIso( charset_te inputCharset, etk::VectorType<char>& input_UTF8, etk::VectorType<char>& output_ISO);
void Utf8_SizeElement(const char * data, int32_t lenMax , uint8_t &size, bool &baseValid);
int32_t strUtf8Len(const char *input_UTF8);
}
#endif

View File

@ -0,0 +1,299 @@
/**
*******************************************************************************
* @file unicodeTable.cpp
* @brief Editeur De N'ours : Table of all charset convertions (Sources)
* @author Edouard DUPIN
* @date 18/01/2012
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Types.h>
#include <etk/Debug.h>
#include <etk/unicodeTable.h>
extern "C" {
const uniChar_t TableIso8859_1[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x000000A1, 0x000000A2, 0x000000A3, 0x000000A4, 0x000000A5, 0x000000A6, 0x000000A7, 0x000000A8, 0x000000A9, 0x000000AA, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000AF,
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x000000B4, 0x000000B5, 0x000000B6, 0x000000B7, 0x000000B8, 0x000000B9, 0x000000BA, 0x000000BB, 0x000000BC, 0x000000BD, 0x000000BE, 0x000000BF,
0x000000C0, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
0x000000D0, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x000000DD, 0x000000DE, 0x000000DF,
0x000000E0, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
0x000000F0, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x000000FF
};
const uniChar_t TableIso8859_2[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00000104, 0x000002D8, 0x00000141, 0x000000A4, 0x0000013D, 0x0000015A, 0x000000A7, 0x000000A8, 0x00000160, 0x0000015E, 0x00000164, 0x00000179, 0x000000AD, 0x0000017D, 0x0000017B,
0x000000B0, 0x00000105, 0x000002DB, 0x00000142, 0x000000B4, 0x0000013E, 0x0000015B, 0x000002C7, 0x000000B8, 0x00000161, 0x0000015F, 0x00000165, 0x0000017A, 0x000002DD, 0x0000017E, 0x0000017C,
0x00000154, 0x000000C1, 0x000000C2, 0x00000102, 0x000000C4, 0x00000139, 0x00000106, 0x000000C7, 0x0000010C, 0x000000C9, 0x00000118, 0x000000CB, 0x0000011A, 0x000000CD, 0x000000CE, 0x0000010E,
0x00000110, 0x00000143, 0x00000147, 0x000000D3, 0x000000D4, 0x00000150, 0x000000D6, 0x000000D7, 0x00000158, 0x0000016E, 0x000000DA, 0x00000170, 0x000000DC, 0x000000DD, 0x00000162, 0x000000DF,
0x00000155, 0x000000E1, 0x000000E2, 0x00000103, 0x000000E4, 0x0000013A, 0x00000107, 0x000000E7, 0x0000010D, 0x000000E9, 0x00000119, 0x000000EB, 0x0000011B, 0x000000ED, 0x000000EE, 0x0000010F,
0x00000111, 0x00000144, 0x00000148, 0x000000F3, 0x000000F4, 0x00000151, 0x000000F6, 0x000000F7, 0x00000159, 0x0000016F, 0x000000FA, 0x00000171, 0x000000FC, 0x000000FD, 0x00000163, 0x000002D9
};
const uniChar_t TableIso8859_3[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00000126, 0x000002D8, 0x000000A3, 0x000000A4, 0x00000000, 0x00000124, 0x000000A7, 0x000000A8, 0x00000130, 0x0000015E, 0x0000011E, 0x00000134, 0x000000AD, 0x00000000, 0x0000017B,
0x000000B0, 0x00000127, 0x000000B2, 0x000000B3, 0x000000B4, 0x000000B5, 0x00000125, 0x000000B7, 0x000000B8, 0x00000131, 0x0000015F, 0x0000011F, 0x00000135, 0x000000BD, 0x00000000, 0x0000017C,
0x000000C0, 0x000000C1, 0x000000C2, 0x00000000, 0x000000C4, 0x0000010A, 0x00000108, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
0x00000000, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x00000120, 0x000000D6, 0x000000D7, 0x0000011C, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x0000016C, 0x0000015C, 0x000000DF,
0x000000E0, 0x000000E1, 0x000000E2, 0x00000000, 0x000000E4, 0x0000010B, 0x00000109, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
0x00000000, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x00000121, 0x000000F6, 0x000000F7, 0x0000011D, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x0000016D, 0x0000015D, 0x000002D9
};
const uniChar_t TableIso8859_4[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00000104, 0x00000138, 0x00000156, 0x000000A4, 0x00000128, 0x0000013B, 0x000000A7, 0x000000A8, 0x00000160, 0x00000112, 0x00000122, 0x00000166, 0x000000AD, 0x0000017D, 0x000000AF,
0x000000B0, 0x00000105, 0x000002DB, 0x00000157, 0x000000B4, 0x00000129, 0x0000013C, 0x000002C7, 0x000000B8, 0x00000161, 0x00000113, 0x00000123, 0x00000167, 0x0000014A, 0x0000017E, 0x0000014B,
0x00000100, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x0000012E, 0x0000010C, 0x000000C9, 0x00000118, 0x000000CB, 0x00000116, 0x000000CD, 0x000000CE, 0x0000012A,
0x00000110, 0x00000145, 0x0000014C, 0x00000136, 0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x00000172, 0x000000DA, 0x000000DB, 0x000000DC, 0x00000168, 0x0000016A, 0x000000DF,
0x00000101, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x0000012F, 0x0000010D, 0x000000E9, 0x00000119, 0x000000EB, 0x00000117, 0x000000ED, 0x000000EE, 0x0000012B,
0x00000111, 0x00000146, 0x0000014D, 0x00000137, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x00000173, 0x000000FA, 0x000000FB, 0x000000FC, 0x00000169, 0x0000016B, 0x000002D9
};
const uniChar_t TableIso8859_5[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00000401, 0x00000402, 0x00000403, 0x00000404, 0x00000405, 0x00000406, 0x00000407, 0x00000408, 0x00000409, 0x0000040A, 0x0000040B, 0x0000040C, 0x000000AD, 0x0000040E, 0x0000040F,
0x00000410, 0x00000411, 0x00000412, 0x00000413, 0x00000414, 0x00000415, 0x00000416, 0x00000417, 0x00000418, 0x00000419, 0x0000041A, 0x0000041B, 0x0000041C, 0x0000041D, 0x0000041E, 0x0000041F,
0x00000420, 0x00000421, 0x00000422, 0x00000423, 0x00000424, 0x00000425, 0x00000426, 0x00000427, 0x00000428, 0x00000429, 0x0000042A, 0x0000042B, 0x0000042C, 0x0000042D, 0x0000042E, 0x0000042F,
0x00000430, 0x00000431, 0x00000432, 0x00000433, 0x00000434, 0x00000435, 0x00000436, 0x00000437, 0x00000438, 0x00000439, 0x0000043A, 0x0000043B, 0x0000043C, 0x0000043D, 0x0000043E, 0x0000043F,
0x00000440, 0x00000441, 0x00000442, 0x00000443, 0x00000444, 0x00000445, 0x00000446, 0x00000447, 0x00000448, 0x00000449, 0x0000044A, 0x0000044B, 0x0000044C, 0x0000044D, 0x0000044E, 0x0000044F,
0x00002116, 0x00000451, 0x00000452, 0x00000453, 0x00000454, 0x00000455, 0x00000456, 0x00000457, 0x00000458, 0x00000459, 0x0000045A, 0x0000045B, 0x0000045C, 0x000000A7, 0x0000045E, 0x0000045F
};
const uniChar_t TableIso8859_6[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00000000, 0x00000000, 0x00000000, 0x000000A4, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000060C, 0x000000AD, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x0000061B, 0x00000000, 0x00000000, 0x00000000, 0x0000061F,
0x00000000, 0x00000621, 0x00000622, 0x00000623, 0x00000624, 0x00000625, 0x00000626, 0x00000627, 0x00000628, 0x00000629, 0x0000062A, 0x0000062B, 0x0000062C, 0x0000062D, 0x0000062E, 0x0000062F,
0x00000630, 0x00000631, 0x00000632, 0x00000633, 0x00000634, 0x00000635, 0x00000636, 0x00000637, 0x00000638, 0x00000639, 0x0000063A, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000640, 0x00000641, 0x00000642, 0x00000643, 0x00000644, 0x00000645, 0x00000646, 0x00000647, 0x00000648, 0x00000649, 0x0000064A, 0x0000064B, 0x0000064C, 0x0000064D, 0x0000064E, 0x0000064F,
0x00000650, 0x00000651, 0x00000652, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000
};
const uniChar_t TableIso8859_7[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00002018, 0x00002019, 0x000000A3, 0x000020AC, 0x000020AF, 0x000000A6, 0x000000A7, 0x000000A8, 0x000000A9, 0x0000037A, 0x000000AB, 0x000000AC, 0x000000AD, 0x00000000, 0x00002015,
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x00000384, 0x00000385, 0x00000386, 0x000000B7, 0x00000388, 0x00000389, 0x0000038A, 0x000000BB, 0x0000038C, 0x000000BD, 0x0000038E, 0x0000038F,
0x00000390, 0x00000391, 0x00000392, 0x00000393, 0x00000394, 0x00000395, 0x00000396, 0x00000397, 0x00000398, 0x00000399, 0x0000039A, 0x0000039B, 0x0000039C, 0x0000039D, 0x0000039E, 0x0000039F,
0x000003A0, 0x000003A1, 0x00000000, 0x000003A3, 0x000003A4, 0x000003A5, 0x000003A6, 0x000003A7, 0x000003A8, 0x000003A9, 0x000003AA, 0x000003AB, 0x000003AC, 0x000003AD, 0x000003AE, 0x000003AF,
0x000003B0, 0x000003B1, 0x000003B2, 0x000003B3, 0x000003B4, 0x000003B5, 0x000003B6, 0x000003B7, 0x000003B8, 0x000003B9, 0x000003BA, 0x000003BB, 0x000003BC, 0x000003BD, 0x000003BE, 0x000003BF,
0x000003C0, 0x000003C1, 0x000003C2, 0x000003C3, 0x000003C4, 0x000003C5, 0x000003C6, 0x000003C7, 0x000003C8, 0x000003C9, 0x000003CA, 0x000003CB, 0x000003CC, 0x000003CD, 0x000003CE, 0x00000000
};
const uniChar_t TableIso8859_8[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00000000, 0x000000A2, 0x000000A3, 0x000000A4, 0x000000A5, 0x000000A6, 0x000000A7, 0x000000A8, 0x000000A9, 0x000000D7, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000AF,
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x000000B4, 0x000000B5, 0x000000B6, 0x000000B7, 0x000000B8, 0x000000B9, 0x000000F7, 0x000000BB, 0x000000BC, 0x000000BD, 0x000000BE, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00002017,
0x000005D0, 0x000005D1, 0x000005D2, 0x000005D3, 0x000005D4, 0x000005D5, 0x000005D6, 0x000005D7, 0x000005D8, 0x000005D9, 0x000005DA, 0x000005DB, 0x000005DC, 0x000005DD, 0x000005DE, 0x000005DF,
0x000005E0, 0x000005E1, 0x000005E2, 0x000005E3, 0x000005E4, 0x000005E5, 0x000005E6, 0x000005E7, 0x000005E8, 0x000005E9, 0x000005EA, 0x00000000, 0x00000000, 0x0000200E, 0x0000200F, 0x000003C0
};
const uniChar_t TableIso8859_9[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x000000A1, 0x000000A2, 0x000000A3, 0x000000A4, 0x000000A5, 0x000000A6, 0x000000A7, 0x000000A8, 0x000000A9, 0x000000AA, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000AF,
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x000000B4, 0x000000B5, 0x000000B6, 0x000000B7, 0x000000B8, 0x000000B9, 0x000000BA, 0x000000BB, 0x000000BC, 0x000000BD, 0x000000BE, 0x000000BF,
0x000000C0, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
0x0000011E, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x00000130, 0x0000015E, 0x000000DF,
0x000000E0, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
0x0000011F, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x00000131, 0x0000015F, 0x000000FF
};
const uniChar_t TableIso8859_10[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00000104, 0x00000112, 0x00000122, 0x0000012A, 0x00000128, 0x00000136, 0x000000A7, 0x0000013B, 0x00000110, 0x00000160, 0x00000166, 0x0000017D, 0x000000AD, 0x0000016A, 0x0000014A,
0x000000B0, 0x00000105, 0x00000113, 0x00000123, 0x0000012B, 0x00000129, 0x00000137, 0x000000B7, 0x0000013C, 0x00000111, 0x00000161, 0x00000167, 0x0000017E, 0x00002015, 0x0000016B, 0x0000014B,
0x00000100, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x0000012E, 0x0000010C, 0x000000C9, 0x00000118, 0x000000CB, 0x00000116, 0x000000CD, 0x000000CE, 0x000000CF,
0x000000D0, 0x00000145, 0x0000014C, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x00000168, 0x000000D8, 0x00000172, 0x000000DA, 0x000000DB, 0x000000DC, 0x000000DD, 0x000000DE, 0x000000DF,
0x00000101, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x0000012F, 0x0000010D, 0x000000E9, 0x00000119, 0x000000EB, 0x00000117, 0x000000ED, 0x000000EE, 0x000000EF,
0x000000F0, 0x00000146, 0x0000014D, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x00000169, 0x000000F8, 0x00000173, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x00000138
};
const uniChar_t TableIso8859_11[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00000E01, 0x00000E02, 0x00000E03, 0x00000E04, 0x00000E05, 0x00000E06, 0x00000E07, 0x00000E08, 0x00000E09, 0x00000E0A, 0x00000E0B, 0x00000E0C, 0x00000E0D, 0x00000E0E, 0x00000E0F,
0x00000E10, 0x00000E11, 0x00000E12, 0x00000E13, 0x00000E14, 0x00000E15, 0x00000E16, 0x00000E17, 0x00000E18, 0x00000E19, 0x00000E1A, 0x00000E1B, 0x00000E1C, 0x00000E1D, 0x00000E1E, 0x00000E1F,
0x00000E20, 0x00000E21, 0x00000E22, 0x00000E23, 0x00000E24, 0x00000E25, 0x00000E26, 0x00000E27, 0x00000E28, 0x00000E29, 0x00000E2A, 0x00000E2B, 0x00000E2C, 0x00000E2D, 0x00000E2E, 0x00000E2F,
0x00000E30, 0x00000E31, 0x00000E32, 0x00000E33, 0x00000E34, 0x00000E35, 0x00000E36, 0x00000E37, 0x00000E38, 0x00000E39, 0x00000E3A, 0x00000E80, 0x00000E80, 0x00000E80, 0x00000E80, 0x00000E3F,
0x00000E40, 0x00000E41, 0x00000E42, 0x00000E43, 0x00000E44, 0x00000E45, 0x00000E46, 0x00000E47, 0x00000E48, 0x00000E49, 0x00000E4A, 0x00000E4B, 0x00000E4C, 0x00000E4D, 0x00000E4E, 0x00000E4F,
0x00000E50, 0x00000E51, 0x00000E52, 0x00000E53, 0x00000E54, 0x00000E55, 0x00000E56, 0x00000E57, 0x00000E58, 0x00000E59, 0x00000E5A, 0x00000E5B, 0x000006C0, 0x000006C0, 0x000006C0, 0x000006C0
};
const uniChar_t TableIso8859_13[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x0000201D, 0x000000A2, 0x000000A3, 0x000000A4, 0x0000201E, 0x000000A6, 0x000000A7, 0x000000D8, 0x000000A9, 0x00000156, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000C6,
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x0000201C, 0x000000B5, 0x000000B6, 0x000000B7, 0x000000F8, 0x000000B9, 0x00000157, 0x000000BB, 0x000000BC, 0x000000BD, 0x000000BE, 0x000000E6,
0x00000104, 0x0000012E, 0x00000100, 0x00000106, 0x000000C4, 0x000000C5, 0x00000118, 0x00000112, 0x0000010C, 0x000000C9, 0x00000179, 0x00000116, 0x00000122, 0x00000136, 0x0000012A, 0x0000013B,
0x00000160, 0x00000143, 0x00000145, 0x000000D3, 0x0000014C, 0x000000D5, 0x000000D6, 0x000000D7, 0x00000172, 0x00000141, 0x0000015A, 0x0000016A, 0x000000DC, 0x0000017B, 0x0000017D, 0x000000DF,
0x00000105, 0x0000012F, 0x00000101, 0x00000107, 0x000000E4, 0x000000E5, 0x00000119, 0x00000113, 0x0000010D, 0x000000E9, 0x0000017A, 0x00000117, 0x00000123, 0x00000137, 0x0000012B, 0x0000013C,
0x00000161, 0x00000144, 0x00000146, 0x000000F3, 0x0000014D, 0x000000F5, 0x000000F6, 0x000000F7, 0x00000173, 0x00000142, 0x0000015B, 0x0000016B, 0x000000FC, 0x0000017C, 0x0000017E, 0x00002019
};
const uniChar_t TableIso8859_14[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x00001E02, 0x00001E03, 0x000000A3, 0x0000010A, 0x0000010B, 0x00001E0A, 0x000000A7, 0x00001E80, 0x000000A9, 0x00001E82, 0x00001E0B, 0x00001EF2, 0x000000AD, 0x000000AE, 0x00000178,
0x00001E1E, 0x00001E1F, 0x00000120, 0x00000121, 0x00001E40, 0x00001E41, 0x000000B6, 0x00001E56, 0x00001E81, 0x00001E57, 0x00001E83, 0x00001E60, 0x00001EF3, 0x00001E84, 0x00001E85, 0x00001E61,
0x000000C0, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
0x00000174, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x00001E6A, 0x000000D8, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x000000DD, 0x00000176, 0x000000DF,
0x000000E0, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
0x00000175, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x00001E6B, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x00000177, 0x000000FF
};
const uniChar_t TableIso8859_15[] = {
0x00000000, 0x00000001, 0x00000002, 0x00000003, 0x00000004, 0x00000005, 0x00000006, 0x00000007, 0x00000008, 0x00000009, 0x0000000A, 0x0000000B, 0x0000000C, 0x0000000D, 0x0000000E, 0x0000000F,
0x00000010, 0x00000011, 0x00000012, 0x00000013, 0x00000014, 0x00000015, 0x00000016, 0x00000017, 0x00000018, 0x00000019, 0x0000001A, 0x0000001B, 0x0000001C, 0x0000001D, 0x0000001E, 0x0000001F,
0x00000020, 0x00000021, 0x00000022, 0x00000023, 0x00000024, 0x00000025, 0x00000026, 0x00000027, 0x00000028, 0x00000029, 0x0000002A, 0x0000002B, 0x0000002C, 0x0000002D, 0x0000002E, 0x0000002F,
0x00000030, 0x00000031, 0x00000032, 0x00000033, 0x00000034, 0x00000035, 0x00000036, 0x00000037, 0x00000038, 0x00000039, 0x0000003A, 0x0000003B, 0x0000003C, 0x0000003D, 0x0000003E, 0x0000003F,
0x00000040, 0x00000041, 0x00000042, 0x00000043, 0x00000044, 0x00000045, 0x00000046, 0x00000047, 0x00000048, 0x00000049, 0x0000004A, 0x0000004B, 0x0000004C, 0x0000004D, 0x0000004E, 0x0000004F,
0x00000050, 0x00000051, 0x00000052, 0x00000053, 0x00000054, 0x00000055, 0x00000056, 0x00000057, 0x00000058, 0x00000059, 0x0000005A, 0x0000005B, 0x0000005C, 0x0000005D, 0x0000005E, 0x0000005F,
0x00000060, 0x00000061, 0x00000062, 0x00000063, 0x00000064, 0x00000065, 0x00000066, 0x00000067, 0x00000068, 0x00000069, 0x0000006A, 0x0000006B, 0x0000006C, 0x0000006D, 0x0000006E, 0x0000006F,
0x00000070, 0x00000071, 0x00000072, 0x00000073, 0x00000074, 0x00000075, 0x00000076, 0x00000077, 0x00000078, 0x00000079, 0x0000007A, 0x0000007B, 0x0000007C, 0x0000007D, 0x0000007E, 0x0000007F,
0x00000080, 0x00000081, 0x00000082, 0x00000083, 0x00000084, 0x00000085, 0x00000086, 0x00000087, 0x00000088, 0x00000089, 0x0000008A, 0x0000008B, 0x0000008C, 0x0000008D, 0x0000008E, 0x0000008F,
0x00000090, 0x00000091, 0x00000092, 0x00000093, 0x00000094, 0x00000095, 0x00000096, 0x00000097, 0x00000098, 0x00000099, 0x0000009A, 0x0000009B, 0x0000009C, 0x0000009D, 0x0000009E, 0x0000009F,
0x000000A0, 0x000000A1, 0x000000A2, 0x000000A3, 0x000020AC, 0x000000A5, 0x00000160, 0x000000A7, 0x00000161, 0x000000A9, 0x000000AA, 0x000000AB, 0x000000AC, 0x000000AD, 0x000000AE, 0x000000AF,
0x000000B0, 0x000000B1, 0x000000B2, 0x000000B3, 0x0000017D, 0x000000B5, 0x000000B6, 0x000000B7, 0x0000017E, 0x000000B9, 0x000000BA, 0x000000BB, 0x00000152, 0x00000153, 0x00000178, 0x000000BF,
0x000000C0, 0x000000C1, 0x000000C2, 0x000000C3, 0x000000C4, 0x000000C5, 0x000000C6, 0x000000C7, 0x000000C8, 0x000000C9, 0x000000CA, 0x000000CB, 0x000000CC, 0x000000CD, 0x000000CE, 0x000000CF,
0x000000D0, 0x000000D1, 0x000000D2, 0x000000D3, 0x000000D4, 0x000000D5, 0x000000D6, 0x000000D7, 0x000000D8, 0x000000D9, 0x000000DA, 0x000000DB, 0x000000DC, 0x000000DD, 0x000000DE, 0x000000DF,
0x000000E0, 0x000000E1, 0x000000E2, 0x000000E3, 0x000000E4, 0x000000E5, 0x000000E6, 0x000000E7, 0x000000E8, 0x000000E9, 0x000000EA, 0x000000EB, 0x000000EC, 0x000000ED, 0x000000EE, 0x000000EF,
0x000000F0, 0x000000F1, 0x000000F2, 0x000000F3, 0x000000F4, 0x000000F5, 0x000000F6, 0x000000F7, 0x000000F8, 0x000000F9, 0x000000FA, 0x000000FB, 0x000000FC, 0x000000FD, 0x000000FE, 0x000000FF
};
}

View File

@ -0,0 +1,50 @@
/**
*******************************************************************************
* @file unicodeTable.h
* @brief ETK : Table of all charset convertions (Header)
* @author Edouard DUPIN
* @date 18/01/2012
* @par Project
* Ewol TK
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __UNICODE_TABLE_H__
#define __UNICODE_TABLE_H__
extern "C" {
extern const uniChar_t TableIso8859_1[];
extern const uniChar_t TableIso8859_2[];
extern const uniChar_t TableIso8859_3[];
extern const uniChar_t TableIso8859_4[];
extern const uniChar_t TableIso8859_5[];
extern const uniChar_t TableIso8859_6[];
extern const uniChar_t TableIso8859_7[];
extern const uniChar_t TableIso8859_8[];
extern const uniChar_t TableIso8859_9[];
extern const uniChar_t TableIso8859_10[];
extern const uniChar_t TableIso8859_11[];
extern const uniChar_t TableIso8859_13[];
extern const uniChar_t TableIso8859_14[];
extern const uniChar_t TableIso8859_15[];
;
}
#endif

14
Sources/libetk/file.mk Normal file
View File

@ -0,0 +1,14 @@
FILE_LIST = \
etk/Debug.cpp \
etk/DebugInternal.cpp \
etk/Memory.cpp \
etk/unicode.cpp \
etk/unicodeTable.cpp \
etk/UString.cpp \
etk/Stream.cpp \
etk/File.cpp \
etk/RegExp.cpp

View File

@ -0,0 +1,34 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ewol
LOCAL_STATIC_LIBRARIES := libetk libtinyxml libzip libpng libfreetype
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lGLESv1_CM -ldl -llog -lz
LOCAL_CFLAGS := -D__PLATFORM__Android \
-D__MODE__Touch \
-Wno-write-strings \
-DETK_DEBUG_LEVEL=3 \
-DEWOL_DEBUG_LEVEL=3 \
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
-DVERSION_BUILD_TIME="\"pasd_heure\"" \
-DEWOL_USE_FREE_TYPE \
-DDATA_IN_APK \
-frtti
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_SRC_FILES := ewol/base/guiAndroid.cpp $(FILE_LIST)
# Ewol Test Software :
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz
include $(BUILD_STATIC_LIBRARY)

44
Sources/libewol/Linux.mk Normal file
View File

@ -0,0 +1,44 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ewol
LOCAL_STATIC_LIBRARIES := etk libfreetype tinyxml libzip libpng
LOCAL_C_INCLUDES := -I$(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
LOCAL_EXPORT_LDLIBS := -lGL -lGLU -lz -lX11
ifeq ($(DEBUG),1)
LOCAL_CFLAGS := -D__PLATFORM__Linux \
-Wno-write-strings \
-DETK_DEBUG_LEVEL=3 \
-DEWOL_DEBUG_LEVEL=3 \
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
-DVERSION_BUILD_TIME="\"pasd_heure\"" \
-DEWOL_USE_FREE_TYPE
else
LOCAL_CFLAGS := -D__PLATFORM__Linux \
-Wno-write-strings \
-DETK_DEBUG_LEVEL=1 \
-DEWOL_DEBUG_LEVEL=1 \
-DEWOL_VERSION_TAG_NAME="\"UNKNOW-debug\"" \
-DVERSION_BUILD_TIME="\"pasd_heure\"" \
-DEWOL_USE_FREE_TYPE
endif
# load the common sources file of the platform
include $(LOCAL_PATH)/file.mk
LOCAL_SRC_FILES := \
ewol/base/guiX11.cpp \
$(FILE_LIST)
#for freetype : https://github.com/cdave1/freetype2-android
# Ewol Test Software :
LOCAL_LDLIBS := -lGL -lGLU -lz -lX11
include $(BUILD_STATIC_LIBRARY)

View File

@ -0,0 +1,28 @@
/**
*******************************************************************************
* @file ewol/Debug.h
* @brief Ewol : log wrapper (Sources)
* @author Edouard DUPIN
* @date 19/10/2010
* @par Project
* Ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/Debug.h>
const char * ewolLibName = "ewol ";

View File

@ -0,0 +1,74 @@
/**
*******************************************************************************
* @file ewol/Debug.h
* @brief Ewol : log wrapper (header)
* @author Edouard DUPIN
* @date 19/10/2010
* @par Project
* Ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_DEBUG_H__
#define __EWOL_DEBUG_H__
#include <etk/Types.h>
#include <etk/Debug.h>
extern const char * ewolLibName;
#define EWOL_CRITICAL(data) ETK_CRITICAL(ewolLibName, data)
// General
#if EWOL_DEBUG_LEVEL > 0
# define EWOL_WARNING(data) ETK_WARNING(ewolLibName, data)
# define EWOL_ERROR(data) ETK_ERROR(ewolLibName, data)
#else
# define EWOL_WARNING(data) do {}while(0)
# define EWOL_ERROR(data) do {}while(0)
#endif
#if EWOL_DEBUG_LEVEL > 1
# define EWOL_INFO(data) ETK_INFO(ewolLibName, data)
#else
# define EWOL_INFO(data) do {}while(0)
#endif
#if EWOL_DEBUG_LEVEL > 2
# define EWOL_DEBUG(data) ETK_DEBUG(ewolLibName, data)
#else
# define EWOL_DEBUG(data) do {}while(0)
#endif
#if EWOL_DEBUG_LEVEL > 3
# define EWOL_VERBOSE(data) ETK_VERBOSE(ewolLibName, data)
#else
# define EWOL_VERBOSE(data) do {}while(0)
#endif
#define EWOL_TODO(data) EWOL_WARNING("TODO : " << data)
#define EWOL_ASSERT(cond, data) ETK_ASSERT(ewolLibName, cond, data)
#if EWOL_DEBUG_LEVEL > 1
# define EWOL_CHECK_INOUT(cond) ETK_CHECK_INOUT_ASSERT(ewolLibName, cond)
#elif EWOL_DEBUG_LEVEL > 0
# define EWOL_CHECK_INOUT(cond) ETK_CHECK_INOUT_WARNING(ewolLibName, cond)
#else
# define EWOL_CHECK_INOUT(cond) do { } while (0)
#endif
#endif

View File

@ -0,0 +1,283 @@
/**
*******************************************************************************
* @file ewol/EObject.cpp
* @brief basic ewol object (Sources)
* @author Edouard DUPIN
* @date 24/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/EObject.h>
#include <ewol/EObjectManager.h>
#include <ewol/Debug.h>
#undef __class__
#define __class__ "EObjectMessageMultiCast"
extern "C" {
typedef struct {
const char* message;
ewol::EObject* object;
} messageList_ts;
};
// internal element of the widget manager :
static etk::VectorType<messageList_ts> m_messageList; // all widget allocated ==> all time increment ... never removed ...
void ewol::EObjectMessageMultiCast::Init(void)
{
EWOL_INFO("EObject message Multi-Cast");
m_messageList.Clear();
}
void ewol::EObjectMessageMultiCast::UnInit(void)
{
EWOL_INFO("EObject message Multi-Cast");
m_messageList.Clear();
}
static void MultiCastAdd(ewol::EObject* object, const char* const message)
{
if (NULL == object) {
EWOL_ERROR("Add with NULL object");
return;
}
if (NULL == message) {
EWOL_ERROR("Add with NULL Message");
return;
}
messageList_ts tmpMessage;
tmpMessage.object = object;
tmpMessage.message = message;
m_messageList.PushBack(tmpMessage);
EWOL_DEBUG("SendMulticast ADD listener :" << object->GetId() << " on \"" << message << "\"" );
}
static void MultiCastRm(ewol::EObject* object)
{
if (NULL == object) {
EWOL_ERROR("Rm with NULL object");
return;
}
// send the message at all registered widget ...
for (int32_t iii=m_messageList.Size()-1; iii>=0; iii--) {
if(m_messageList[iii].object == object) {
EWOL_DEBUG("SendMulticast RM listener :" << object->GetId());
m_messageList[iii].message = NULL;
m_messageList[iii].object = NULL;
m_messageList.Erase(iii);
}
}
}
static void MultiCastSend(ewol::EObject* object, const char* const message, etk::UString& data)
{
EWOL_DEBUG("SendMulticast message \"" << message << "\" data=\"" << data << "\" to :");
// send the message at all registered widget ...
for (int32_t iii=0; iii<m_messageList.Size(); iii++) {
if( m_messageList[iii].message == message
&& m_messageList[iii].object != object)
{
if (NULL != m_messageList[iii].object) {
EWOL_DEBUG(" id = " << m_messageList[iii].object->GetId());
// generate event ...
m_messageList[iii].object->OnReceiveMessage(object, m_messageList[iii].message, data);
}
}
}
}
void ewol::EObjectMessageMultiCast::AnonymousSend(const char* const messageId, etk::UString& data)
{
MultiCastSend(NULL, messageId, data);
}
#undef __class__
#define __class__ "ewol::EObject"
/**
* @brief Constructor
*/
ewol::EObject::EObject(void)
{
static int32_t ss_globalUniqueId = 0;
// note this is nearly atomic ... (but it is enough)
m_uniqueId = ss_globalUniqueId++;
EWOL_DEBUG("new EObject : [" << m_uniqueId << "]");
ewol::EObjectManager::Add(this);
}
/**
* @brief Destructor
*/
ewol::EObject::~EObject(void)
{
ewol::EObjectManager::Rm(this);
MultiCastRm(this);
EWOL_DEBUG("delete EObject : [" << m_uniqueId << "]");
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) {
delete(m_externEvent[iii]);
m_externEvent[iii] = NULL;
}
}
m_externEvent.Clear();
m_availlableEventId.Clear();
m_uniqueId = -1;
}
/**
* @brief Get the UniqueId of the EObject
* @param ---
* @return the requested ID
*/
int32_t ewol::EObject::GetId(void)
{
return m_uniqueId;
};
/**
* @brief Add a specific event Id in the list to prevent wrong link on a EObject
* @param[in] generateEventId event Id to add
* @return ---
*/
void ewol::EObject::AddEventId(const char * generateEventId)
{
if (NULL != generateEventId) {
m_availlableEventId.PushBack(generateEventId);
}
}
/**
* @brief Generate event on all registered EObject
* @param[in] generateEventId event Id that is curetly generated
* @return ---
*/
void ewol::EObject::GenerateEventId(const char * generateEventId)
{
// for every element registered ...
for (int32_t iii=0; iii<m_externEvent.Size(); iii++) {
if (NULL!=m_externEvent[iii]) {
// if we find the event ...
if (m_externEvent[iii]->localEventId == generateEventId) {
if (NULL != m_externEvent[iii]->destEObject) {
m_externEvent[iii]->destEObject->OnReceiveMessage(this, m_externEvent[iii]->destEventId, m_externEvent[iii]->destData);
}
}
}
}
}
/**
* @brief Generate Multicast event on all EObject requested the event
* @param[in] messageId Event Id that is generated
* @param[in] data String that is send at all the destinations
* @return ---
*/
void ewol::EObject::SendMultiCast(const char* const messageId, etk::UString data)
{
MultiCastSend(this, messageId, data);
}
/**
* @brief Register of the arrival of a Multicast message
* @param[in] messageId Event Id waiting for...
* @return ---
*/
void ewol::EObject::RegisterMultiCast(const char* const messageId)
{
MultiCastAdd(this, messageId);
}
/**
* @brief Register an EObject over an other to get event on the second...
* @param[in] destinationObject pointer on the object that might be call when an event is generated
* @param[in] eventId Event generate inside the object
* @param[in] eventIdgenerated event generated when call the distant EObject.OnReceiveMessage(...)
* @param[in] data data associated with the event
* @return true if register corectly done
*/
void ewol::EObject::RegisterOnEvent(ewol::EObject * destinationObject, const char * eventId, const char * eventIdgenerated, etk::UString data)
{
if (NULL == destinationObject) {
EWOL_ERROR("Input ERROR NULL pointer EObject ...");
return;
}
if (NULL == eventId) {
EWOL_ERROR("Input ERROR NULL pointer Event Id...");
return;
}
if (NULL == eventIdgenerated) {
EWOL_ERROR("Input ERROR NULL pointer destination Event Id...");
return;
}
ewol::EventExtGen * tmpEvent = new ewol::EventExtGen();
if (NULL == tmpEvent) {
EWOL_ERROR("Allocation error in Register Event...");
return;
}
tmpEvent->localEventId = eventId;
tmpEvent->destEObject = destinationObject;
tmpEvent->destEventId = eventIdgenerated;
tmpEvent->destData = data;
m_externEvent.PushBack(tmpEvent);
}
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @return ---
*/
void ewol::EObject::OnObjectRemove(ewol::EObject * removeObject)
{
for(int32_t iii=m_externEvent.Size()-1; iii>=0; iii--) {
if (NULL==m_externEvent[iii]) {
m_externEvent.Erase(iii);
} else if (m_externEvent[iii]->destEObject == removeObject) {
m_externEvent.Erase(iii);
}
}
}
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
void ewol::EObject::OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data)
{
// here nothing to do ...
}

View File

@ -0,0 +1,147 @@
/**
*******************************************************************************
* @file ewol/EObject.h
* @brief basic ewol object (header)
* @author Edouard DUPIN
* @date 24/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_E_OBJECT_H__
#define __EWOL_E_OBJECT_H__
#include <etk/Types.h>
#include <etk/UString.h>
#include <etk/VectorType.h>
namespace ewol {
namespace EObjectMessageMultiCast {
void Init( void);
void UnInit(void);
void AnonymousSend(const char* const messageId, etk::UString& data);
};
class EObject;
/**
* local class for event generation
*/
class EventExtGen {
public:
const char* localEventId; //!< local event Id generation
ewol::EObject* destEObject; //!< destination widget that might be call
const char* destEventId; //!< Generated event ID on the distant widget
etk::UString destData; //!< destination data
};
/**
* @brief Basic message classes for ewol system
*
* this class mermit at every EObject to communicate between them.
*/
class EObject {
private:
int32_t m_uniqueId; //!< Object UniqueID ==> TODO : Check if it use is needed
etk::VectorType<EventExtGen*> m_externEvent; //!< Generic list of event generation for output link
etk::VectorType<const char*> m_availlableEventId; //!< List of all event availlable for this widget
public:
/**
* @brief Constructor
*/
EObject(void);
/**
* @brief Destructor
*/
virtual ~EObject(void);
/**
* @brief Get the UniqueId of the EObject
* @param ---
* @return the requested ID
*/
int32_t GetId(void);
protected:
/**
* @brief Add a specific event Id in the list to prevent wrong link on a EObject
* @param[in] generateEventId event Id to add
* @return ---
*/
void AddEventId(const char * generateEventId);
/**
* @brief Generate event on all registered EObject
* @param[in] generateEventId event Id that is curetly generated
* @return ---
*/
void GenerateEventId(const char * generateEventId);
/**
* @brief Generate Multicast event on all EObject requested the event
* @param[in] messageId Event Id that is generated
* @param[in] data String that is send at all the destinations
* @return ---
*/
//void SendMultiCast(const char* const messageId, etk::UString& data);
void SendMultiCast(const char* const messageId, etk::UString data = "");
/**
* @brief Register of the arrival of a Multicast message
* @param[in] messageId Event Id waiting for...
* @return ---
*/
void RegisterMultiCast(const char* const messageId);
public:
/**
* @brief Register an EObject over an other to get event on the second...
* @param[in] destinationObject pointer on the object that might be call when an event is generated
* @param[in] eventId Event generate inside the object
* @param[in] eventIdgenerated event generated when call the distant EObject.OnReceiveMessage(...)
* @param[in] data data associated with the event
* @return ---
*/
void RegisterOnEvent(ewol::EObject * destinationObject, const char * eventId, const char * eventIdgenerated = NULL, etk::UString data = "");
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
virtual void OnObjectRemove(ewol::EObject * removeObject);
/**
* @brief Receive a message from an other EObject with a specific eventId and data
* @param[in] CallerObject Pointer on the EObject that information came from
* @param[in] eventId Message registered by this class
* @param[in] data Data registered by this class
* @return ---
*/
virtual void OnReceiveMessage(ewol::EObject * CallerObject, const char * eventId, etk::UString data);
};
};
#endif

View File

@ -0,0 +1,154 @@
/**
*******************************************************************************
* @file ewol/EObjectManager.cpp
* @brief basic ewol Object Manager (Sources)
* @author Edouard DUPIN
* @date 27/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/EObjectManager.h>
#include <ewol/base/eventInputManagement.h>
#undef __class__
#define __class__ "EObjectManager"
static bool IsInit = false;
// internal element of the widget manager :
static etk::VectorType<ewol::EObject*> m_eObjectList; // all widget allocated ==> all time increment ... never removed ...
static etk::VectorType<ewol::EObject*> m_eObjectDeletedList; // all widget allocated
void ewol::EObjectManager::Init(void)
{
EWOL_DEBUG("==> Init EObject-Manager");
// Can create mlemory leak ... ==> but not predictable comportement otherwise ...
// TODO : Check if we can do sotthing better
m_eObjectDeletedList.Clear();
m_eObjectList.Clear();
IsInit = true;
}
void ewol::EObjectManager::UnInit(void)
{
EWOL_DEBUG("==> Un-Init EObject-Manager");
// Some call to permit to remove all the needed stack of EObject
for(int32_t iii=0; iii<128 ; iii++) {
ewol::EObjectManager::RemoveAllMark();
}
EWOL_INFO(" Remove missing user widget");
while(0<m_eObjectList.Size()) {
if (m_eObjectList[0]!=NULL) {
MarkToRemoved(m_eObjectList[0]);
} else {
m_eObjectList.Erase(0);
}
}
// local acces ==> this control the mutex Lock
ewol::EObjectManager::RemoveAllMark();
IsInit = false;
}
void ewol::EObjectManager::Add(ewol::EObject* object)
{
// TODO : Chek if not existed before ...
if (NULL != object) {
m_eObjectList.PushBack(object);
} else {
EWOL_ERROR("try to add an inexistant EObject in manager");
}
}
void ewol::EObjectManager::Rm(ewol::EObject* object)
{
if (NULL == object) {
EWOL_ERROR("Try to remove (NULL) EObject");
return;
}
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] == object) {
// Remove Element
m_eObjectList.Erase(iii);
EWOL_CRITICAL("EObject direct remove is really DANGEROUS due to the multithreading ...");
return;
}
}
for (int32_t iii=0; iii<m_eObjectDeletedList.Size(); iii++) {
if (m_eObjectDeletedList[iii] == object) {
// Remove Element
m_eObjectDeletedList.Erase(iii);
return;
}
}
EWOL_ERROR("EObject already removed ...");
}
void informOneObjectIsRemoved(ewol::EObject* object)
{
for (int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] != NULL) {
m_eObjectList[iii]->OnObjectRemove(object);
}
}
// call input event manager to remove linked widget ...
ewol::eventInput::OnObjectRemove(object);
}
void ewol::EObjectManager::MarkToRemoved(ewol::EObject* object)
{
if (object == NULL) {
EWOL_WARNING("try to remove a NULL Pointer on the EObject manager");
return;
}
int32_t findId = -1;
// check if the widget is not destroy :
for(int32_t iii=0; iii<m_eObjectList.Size(); iii++) {
if (m_eObjectList[iii] == object) {
findId = iii;
break;
}
}
if (-1 == findId) {
EWOL_CRITICAL("Try to mark remove an object already removed (or not registerd [imposible case])");
return;
}
m_eObjectList.Erase(findId);
m_eObjectDeletedList.PushBack(object);
// Informe all EObject to remove reference of this one ...
informOneObjectIsRemoved(object);
}
void ewol::EObjectManager::RemoveAllMark(void)
{
etk::VectorType<ewol::EObject*> m_tmpList = m_eObjectDeletedList;
// direct delete of the current list ...
for(int32_t iii=0; iii<m_tmpList.Size(); iii++) {
if (NULL != m_tmpList[iii]) {
delete(m_tmpList[iii]);
m_tmpList[iii] = NULL;
}
}
}

View File

@ -0,0 +1,44 @@
/**
*******************************************************************************
* @file ewol/EObjectManager.h
* @brief basic ewol Object Manager (Header)
* @author Edouard DUPIN
* @date 27/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_E_OBJECT_MANAGER_H__
#define __EWOL_E_OBJECT_MANAGER_H__
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/EObject.h>
namespace ewol {
namespace EObjectManager {
void Init( void);
void UnInit( void);
void Add( ewol::EObject* object);
void Rm( ewol::EObject* object);
void MarkToRemoved(ewol::EObject* object);
void RemoveAllMark(void);
};
};
#endif

View File

@ -0,0 +1,85 @@
/**
*******************************************************************************
* @file ewol/Font.h
* @brief ewol Font system (header)
* @author Edouard DUPIN
* @date 29/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_FONT_H__
#define __EWOL_FONT_H__
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <etk/File.h>
namespace ewol
{
// TODO : Create a subNameSpace:
/*
namespace font {
...
};
*/
// set default folder name of the font :
void SetFontFolder(etk::UString folderName);
void SetDefaultFont(etk::UString fontName, int32_t size);
// unload all font loaded
void InitFont(void);
void UnInitFont(void);
// load the fonts...
int32_t LoadFont(etk::UString fontName, int32_t size); // return ID of font
int32_t GetDefaultFontId(void);
void UnloadFont(int32_t id);
// get the size of a long string in UTF8 (note that \n and \r represent unknown char...)
int32_t GetWidth(int32_t fontID, const etk::UString& unicodeString);
int32_t GetHeight(int32_t fontID);
int32_t DrawText(int32_t fontID,
coord2D_ts textPos,
clipping_ts & drawClipping,
const etk::UString & unicodeString,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
int32_t DrawText(int32_t fontID,
coord2D_ts textPos,
clipping_ts & drawClipping,
const uniChar_t unicodeChar,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
int32_t DrawText(int32_t fontID,
coord2D_ts textPos,
const etk::UString & unicodeString,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
int32_t DrawText(int32_t fontID,
coord2D_ts textPos,
const uniChar_t unicodeChar,
int32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex);
int32_t LoadFont(etk::File fontFileName);
};
#endif

View File

@ -0,0 +1,526 @@
/**
*******************************************************************************
* @file ewol/FontBitmap.cpp
* @brief ewol Font system (sources)
* @author Edouard DUPIN
* @date 29/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef EWOL_USE_FREE_TYPE
#include <ewol/Font.h>
#include <ewol/Texture.h>
#include <etk/VectorType.h>
#include <ewol/importgl.h>
#undef __class__
#define __class__ "ewol::FontBitmap"
extern "C"
{
typedef struct {
uniChar_t unicodeCharVal;
int32_t width;
texCoord_ts posStart;
texCoord_ts posStop;
etkFloat_t ratio;
}UTF8Element_ts;
}
namespace ewol
{
class EbtFont
{
public:
EbtFont(etk::File newFile, etk::UString fontName, int32_t size)
{
m_loadedOK = false;
m_filename = newFile;
m_fontName = fontName;
m_size = size;
m_elements.Clear();
for (int32_t iii=0x0; iii<0x81; iii++) {
UTF8Element_ts tmpchar;
tmpchar.unicodeCharVal = iii;
tmpchar.width = 0;
tmpchar.posStart.u = 0;
tmpchar.posStart.v = 0;
tmpchar.posStop.u = 0;
tmpchar.posStop.v = 0;
tmpchar.ratio = 0;
m_elements.PushBack(tmpchar);
}
if(false == m_filename.fOpenRead()) {
EWOL_ERROR("Can not Open the file named=\"" << m_filename << "\"");
return;
}
// load all element of the file ...
char elementLine[2048];
int32_t lineID=1;
while (NULL != m_filename.fGets(elementLine, 2048) )
{
//EWOL_DEBUG(" Read file Line : " << elementLine);
if ( '\n' != elementLine[0] // EOL
&& '\0' != elementLine[0] // EOF
&& '#' != elementLine[0] // Comment line
)
{
if (0 == strncmp("name:", elementLine, 5)) {
char extractString[256] = "";
sscanf(elementLine, "name:%s", extractString);
m_fontName = extractString;
EWOL_INFO("Find font named : \"" << m_fontName << "\"");
} else if (0 == strncmp("source:", elementLine, 7)) {
char extractString[256] = "";
sscanf(elementLine, "source:%s", extractString);
m_bitmapName = extractString;
} else if (0 == strncmp("0x00", elementLine, 4)) {
int32_t GlyphPositionX;
int32_t GlyphPositionY;
int32_t GlyphSizeX;
int32_t GlyphSizeY;
sscanf(elementLine, "0x00 (%d,%d) (%d,%d)", &GlyphPositionX, &GlyphPositionY, &GlyphSizeX, &GlyphSizeY);
ClearAll(GlyphPositionX, GlyphPositionY, GlyphSizeX, GlyphSizeY);
} else if (0 == strncmp("0x", elementLine, 2)) {
uint32_t utf8Value;
int32_t GlyphPositionX;
int32_t GlyphPositionY;
int32_t GlyphSizeX;
int32_t GlyphSizeY;
sscanf(elementLine, "0x%x (%d,%d) (%d,%d)", &utf8Value, &GlyphPositionX, &GlyphPositionY, &GlyphSizeX, &GlyphSizeY);
SetGlyphID(utf8Value, lineID, GlyphPositionX, GlyphPositionY, GlyphSizeX, GlyphSizeY);
} else {
EWOL_ERROR("error when parsing the line : " << lineID << "\"" << elementLine << "\"");
}
}
lineID++;
}
// close the file at end of reading...
m_filename.fClose();
// Load Bitmap :
etk::UString bitmapRealFile = m_filename.GetFolder() + "/" + m_bitmapName;
EWOL_INFO("load text font image : \"" << bitmapRealFile << "\"");
etk::File tmpFile(bitmapRealFile, m_filename.GetTypeAccess());
m_textureId = ewol::LoadTexture(tmpFile);
m_textureLoaded = true;
m_loadedOK = true;
};
~EbtFont(void)
{
if (true == m_textureLoaded) {
ewol::UnLoadTexture(m_textureId);
}
};
bool loadedOK(void)
{
return m_loadedOK;
};
private:
void ClearAll(int32_t x, int32_t y, int32_t w, int32_t h)
{
EWOL_DEBUG("Find default font glyph : (" << x << "," << y << ") (" << w << "," << h << ") ");
for (int32_t iii=0; iii< 0x80; iii++) {
m_elements[iii].posStart.u = (etkFloat_t)x / 512.0;
m_elements[iii].posStart.v = (etkFloat_t)y / 512.0;
m_elements[iii].posStop.u = (etkFloat_t)(x+w) / 512.0;
m_elements[iii].posStop.v = (etkFloat_t)(y+h) / 512.0;
m_elements[iii].ratio = (etkFloat_t)w/(etkFloat_t)h;
m_elements[iii].width = m_size * 1.48 * m_elements[iii].ratio;
}
};
void SetGlyphID(int32_t utf8Value, int32_t lineID, int32_t x, int32_t y, int32_t w, int32_t h)
{
EWOL_DEBUG("Add font glyph : "<< utf8Value << " (" << x << "," << y << ") (" << w << "," << h << ") ");
if (utf8Value < 0x80) {
m_elements[utf8Value].posStart.u = (etkFloat_t)x / 512.0;
m_elements[utf8Value].posStart.v = (etkFloat_t)y / 512.0;
m_elements[utf8Value].posStop.u = (etkFloat_t)(x+w) / 512.0;
m_elements[utf8Value].posStop.v = (etkFloat_t)(y+h) / 512.0;
m_elements[utf8Value].ratio = (etkFloat_t)w/(etkFloat_t)h;
m_elements[utf8Value].width = m_size * 1.48 * m_elements[utf8Value].ratio;
} else {
EWOL_ERROR("not manage glyph with ID > 0x7F line : " << lineID);
}
};
public:
etk::File GetFileName(void)
{
return m_filename;
};
etk::UString GetName(void)
{
return m_fontName;
};
bool IsLoaded(void)
{
return m_textureLoaded;
};
bool Check(etk::UString fontName, int32_t size)
{
if (m_loadedOK == -1) {
return false;
}
if( m_fontName == fontName
&& m_size == size)
{
return true;
}
return false;
};
private:
etk::File m_filename;
bool m_loadedOK;
etk::UString m_fontName;
int32_t m_size;
uint32_t m_textureId;
bool m_textureLoaded;
etk::UString m_bitmapName;
etk::VectorType<UTF8Element_ts> m_elements; //
public:
etk::VectorType<UTF8Element_ts> & GetRefOnElement(void)
{
return m_elements;
};
uint32_t GetOglId(void)
{
return GetTextureGLID(m_textureId);
};
int32_t GetHeight(void)
{
return m_size*1.42;
};
int32_t GetSize(void)
{
return m_size;
};
};
};
static etk::VectorType<ewol::EbtFont*> s_listLoadedFonts;
static etk::UString s_currentFolderName = "";
static etk::UString s_currentDefaultFontName = "";
static int32_t s_currentDefaultFontId = -1;
void ewol::SetFontFolder(etk::UString folderName)
{
if (s_currentFolderName != "") {
EWOL_WARNING("Change the FontFolder, old=\"" << s_currentFolderName << "\"");
}
EWOL_TODO("Check if folder exist");
s_currentFolderName = folderName;
EWOL_INFO("New default font folder name=\"" << s_currentFolderName << "\"");
}
void ewol::InitFont(void)
{
// nothing to do ...
}
void ewol::UnInitFont(void)
{
EWOL_TODO("later");
}
void ewol::SetDefaultFont(etk::UString fontName, int32_t size)
{
if (s_currentDefaultFontName != "") {
EWOL_WARNING("Change the default Ewol Font, old=\"" << s_currentDefaultFontName << "\"");
}
EWOL_INFO("New default Font Name=\"" << fontName << "\"");
int32_t tmpId = ewol::LoadFont(fontName, size);
if (-1 == tmpId) {
if (s_currentDefaultFontName == "") {
EWOL_ASSERT(-1 != tmpId, "Error to load the default Font\"" << fontName << "\"");
} else {
EWOL_CRITICAL("Unable to load the new default font:\"" << fontName << "\"");
}
return;
}
// save the default font parameters ...
s_currentDefaultFontName = fontName;
s_currentDefaultFontId = tmpId;
}
int32_t ewol::GetDefaultFontId(void)
{
return s_currentDefaultFontId;
}
int32_t ewol::LoadFont(etk::UString fontName, int32_t size)
{
// check if folder file
etk::UString tmpFileName = s_currentFolderName + "/" + fontName + ".ebt";
etk::File fileName(tmpFileName, etk::FILE_TYPE_DATA);
if (false == fileName.Exist()) {
EWOL_ERROR("Font does not exist: \"" << fileName.GetCompleateName() << "\"");
return -1;
}
for (int32_t iii=0; iii < s_listLoadedFonts.Size(); iii++) {
if (true == s_listLoadedFonts[iii]->Check(fontName, size)) {
return iii;
}
}
EbtFont * tmpFont = new EbtFont(fileName, fontName, size);
s_listLoadedFonts.PushBack(tmpFont);
return s_listLoadedFonts.Size()-1;
}
void ewol::UnloadFont(int32_t id)
{
EWOL_TODO("I do not think it was a good idea... will be done later");
}
/*
void ewol::DrawText(int32_t fontID,
coord2D_ts & drawPosition,
const uniChar_t * unicodeString,
uint32_t & fontTextureId,
etk::VectorType<coord2D_ts> & coord,
etk::VectorType<texCoord_ts> & coordTex)
{
EWOL_TODO("previous code does not work at all");
if(fontID>=s_listLoadedFonts.Size() || fontID < 0) {
EWOL_WARNING("try to display text with an fontID that does not existed " << fontID);
return;
}
etk::VectorType<UTF8Element_ts> & listOfElement = s_listLoadedFonts[fontID]->GetRefOnElement();
fontTextureId = s_listLoadedFonts[fontID]->GetOglId();
EWOL_DEBUG("**************** plop " << fontTextureId);
int32_t size = s_listLoadedFonts[fontID]->GetHeight();
etkFloat_t posDrawX = drawPosition.x;
while(*unicodeString != 0) {
int32_t tmpChar = *unicodeString++;
if (tmpChar >= 0x80) {
tmpChar = 0;
}
etkFloat_t sizeWidth = listOfElement[tmpChar].width;
if (tmpChar != 0x20) {
// set texture coordonates :
coordTex.PushBack(listOfElement[tmpChar].posStart);
texCoord_ts tmpTex;
tmpTex.u = listOfElement[tmpChar].posStop.u;
tmpTex.v = listOfElement[tmpChar].posStart.v;
coordTex.PushBack(tmpTex);
coordTex.PushBack(listOfElement[tmpChar].posStop);
tmpTex.u = listOfElement[tmpChar].posStart.u;
tmpTex.v = listOfElement[tmpChar].posStop.v;
coordTex.PushBack(tmpTex);
// set display positions :
coord2D_ts tmpCoord;
tmpCoord.x = posDrawX;
tmpCoord.y = drawPosition.y;
coord.PushBack(tmpCoord);
tmpCoord.x = posDrawX + sizeWidth;
coord.PushBack(tmpCoord);
tmpCoord.y = drawPosition.y + size;
coord.PushBack(tmpCoord);
tmpCoord.x = posDrawX;
coord.PushBack(tmpCoord);
}
posDrawX += sizeWidth;
}
drawPosition.x = posDrawX;
}
*/
void ewol::DrawText(int32_t fontID, // Id of the desire font
coord2D_ts & drawPosition, // position to start the writing (can be < 0) ==> no check
coord2D_ts & clipSize, // clipping size
const char * utf8String, // my UTF8 string
uint32_t & fontTextureId, // return the fontID needed to display this string
etk::VectorType<coord2D_ts> & coord, // return the coordonates
etk::VectorType<texCoord_ts> & coordTex) // return the texture coordonates
{
// TODO : This code des not work, why ????
/*
int32_t tmpstringLen = strlen(utf8String);
int32_t * tmpUnicodeString = new int32_t(tmpstringLen+1);
// TODO : generate a better convertor...
for (int32_t iii=0; iii<tmpstringLen; iii++) {
tmpUnicodeString[iii] = utf8String[iii];
}
tmpUnicodeString[tmpstringLen] = 0;
// unicode display ...
//DrawText(fontID, drawPosition, tmpUnicodeString, fontTextureId, coord, coordTex);
// clean temporary data ..
delete [] tmpUnicodeString;
*/
if(fontID>=s_listLoadedFonts.Size() || fontID < 0) {
EWOL_WARNING("try to display text with an fontID that does not existed " << fontID);
return;
}
etk::VectorType<UTF8Element_ts> & listOfElement = s_listLoadedFonts[fontID]->GetRefOnElement();
char * tmpVal = (char*)utf8String;
fontTextureId = s_listLoadedFonts[fontID]->GetOglId();
//EWOL_DEBUG("**************** plop2 " << fontTextureId);
int32_t size = s_listLoadedFonts[fontID]->GetHeight();
etkFloat_t posDrawX = drawPosition.x;
while(*tmpVal != 0) {
int32_t tmpChar = *tmpVal++;
int32_t charIndex;
if (tmpChar >= 0x80) {
charIndex = 0;
} else if (tmpChar < 0x20) {
charIndex = 0;
} else if (tmpChar < 0x80) {
charIndex = tmpChar; // - 0x1F;
} else {
for (int32_t iii=0x80/*-0x20*/; iii < listOfElement.Size(); iii++) {
if (listOfElement[iii].unicodeCharVal == tmpChar) {
charIndex = iii;
break;
}
}
// TODO : Update if possible the mapping
charIndex = 0;
}
etkFloat_t sizeWidth = listOfElement[charIndex].width;
// check the clipping
if (clipSize.x>0 && posDrawX+sizeWidth > clipSize.x) {
// TODO : Create a better clipping methode ...
break;
}
// 0x01 == 0x20 == ' ';
if (tmpChar != 0x01) {
// NOTE : Android does not support the Quads elements ...
/* Step 1 :
* ********
* ******
* ****
* **
*
*/
// set texture coordonates :
coordTex.PushBack(listOfElement[charIndex].posStart);
texCoord_ts tmpTex;
tmpTex.u = listOfElement[charIndex].posStop.u;
tmpTex.v = listOfElement[charIndex].posStart.v;
coordTex.PushBack(tmpTex);
coordTex.PushBack(listOfElement[charIndex].posStop);
// set display positions :
coord2D_ts tmpCoord;
tmpCoord.x = posDrawX;
tmpCoord.y = drawPosition.y;
coord.PushBack(tmpCoord);
tmpCoord.x = posDrawX + sizeWidth;
coord.PushBack(tmpCoord);
tmpCoord.y = drawPosition.y + size;
coord.PushBack(tmpCoord);
/* Step 2 :
*
* **
* ****
* ******
* ********
*/
// set texture coordonates :
coordTex.PushBack(listOfElement[charIndex].posStart);
coordTex.PushBack(listOfElement[charIndex].posStop);
tmpTex.u = listOfElement[charIndex].posStart.u;
tmpTex.v = listOfElement[charIndex].posStop.v;
coordTex.PushBack(tmpTex);
// set display positions :
tmpCoord.x = posDrawX;
tmpCoord.y = drawPosition.y;
coord.PushBack(tmpCoord);
tmpCoord.x = posDrawX + sizeWidth;
tmpCoord.y = drawPosition.y + size;
coord.PushBack(tmpCoord);
tmpCoord.x = posDrawX;
coord.PushBack(tmpCoord);
}
posDrawX += sizeWidth;
}
drawPosition.x = posDrawX;
}
int32_t ewol::GetWidth(int32_t fontID, const char * utf8String)
{
if(fontID>=s_listLoadedFonts.Size() || fontID < 0) {
EWOL_WARNING("try to display text with an fontID that does not existed " << fontID);
return 0;
}
etk::VectorType<UTF8Element_ts> & listOfElement = s_listLoadedFonts[fontID]->GetRefOnElement();
char * tmpVal = (char*)utf8String;
etkFloat_t posDrawX = 0.0;
while(*tmpVal != 0) {
int32_t tmpChar = *tmpVal++;
int32_t charIndex;
if (tmpChar >= 0x80) {
charIndex = 0;
} else if (tmpChar < 0x20) {
charIndex = 0;
} else if (tmpChar < 0x80) {
charIndex = tmpChar /*- 0x1F*/;
} else {
for (int32_t iii=0x80/*-0x20*/; iii < listOfElement.Size(); iii++) {
if (listOfElement[iii].unicodeCharVal == tmpChar) {
charIndex = iii;
break;
}
}
// TODO : Update if possible the mapping
charIndex = 0;
}
posDrawX += listOfElement[charIndex].width;
}
return posDrawX;
}
int32_t ewol::GetHeight(int32_t fontID)
{
if(fontID>=s_listLoadedFonts.Size() || fontID < 0) {
EWOL_WARNING("try to display text with an fontID that does not existed " << fontID);
return 10;
}
return s_listLoadedFonts[fontID]->GetHeight();
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,46 @@
/**
*******************************************************************************
* @file ewol/OObject.cpp
* @brief ewol OpenGl Object system (Sources)
* @author Edouard DUPIN
* @date 24/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Types.h>
#include <etk/UString.h>
#include <ewol/OObject.h>
#include <ewol/importgl.h>
#undef __class__
#define __class__ "ewol::OObject"
ewol::OObject::OObject(void)
{
m_hasClipping = false;
// nothing to do ...
}
ewol::OObject::~OObject(void)
{
}

View File

@ -0,0 +1,65 @@
/**
*******************************************************************************
* @file ewol/OObject.h
* @brief ewol OpenGl Object system (header)
* @author Edouard DUPIN
* @date 24/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_O_OBJECT_H__
#define __EWOL_O_OBJECT_H__
#include <etk/Types.h>
#include <etk/File.h>
#include <ewol/Debug.h>
#include <ewol/Font.h>
#include <etk/VectorType.h>
namespace ewol {
extern "C" {
typedef struct {
int32_t f;
int32_t s;
int32_t t;
}linkCoord_ts;
};
class OObject
{
protected:
bool m_hasClipping;
clipping_ts m_clipping;
public:
OObject(void);
virtual ~OObject(void);
void clippingSet(clipping_ts clip) {m_clipping = clip; m_hasClipping = true;};
void clippingDisable(void) {m_hasClipping = false;};
void clippingEnable(void) {m_hasClipping = true;};
virtual void Draw(void) = 0;
};
};
#endif
#include <ewol/OObject/2DTextured.h>
#include <ewol/OObject/2DColored.h>
#include <ewol/OObject/2DText.h>
#include <ewol/OObject/2DTextColored.h>

View File

@ -0,0 +1,595 @@
/**
*******************************************************************************
* @file ewol/OObject/2DColored.cpp
* @brief ewol OpenGl Object system (Sources)
* @author Edouard DUPIN
* @date 09/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/OObject/2DColored.h>
#include <ewol/importgl.h>
#include <math.h>
#undef __class__
#define __class__ "ewol::OObject2DColored"
ewol::OObject2DColored::OObject2DColored(void)
{
m_triElement = 0;
SetColor(1.0, 1.0, 1.0, 1.0);
}
ewol::OObject2DColored::~OObject2DColored(void)
{
m_coord.Clear();
m_coordColor.Clear();
}
void ewol::OObject2DColored::Draw(void)
{
if (m_coord.Size()<=0) {
return;
}
// Enable Pointers
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
//glPushMatrix();
// Set the vertex pointer to our vertex data
glVertexPointer(2, oglTypeFloat_t, 0, &m_coord[0] );
glColorPointer(4, oglTypeFloat_t, 0, &m_coordColor[0] );
// Render : draw all of the triangles at once
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
//glDrawElements( GL_TRIANGLES, 0, m_coord.Size());
//EWOL_DEBUG("Draw ..." << m_coord.Size()/3 << " triangle(s)");
// Disable Pointers
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );
}
void ewol::OObject2DColored::Clear(void)
{
m_coord.Clear();
m_coordColor.Clear();
}
void generatePolyGone(etk::VectorType<coord2D_ts> & input, etk::VectorType<coord2D_ts> & output )
{
if (input.Size()<3) {
return;
}
coord2D_ts basePoint = input[0];
// TODO : Regenerate a linear poligone generation
for (int32_t iii=1; iii<input.Size()-1; iii++) {
output.PushBack(basePoint);
output.PushBack(input[iii]);
output.PushBack(input[iii+1]);
}
//EWOL_DEBUG("generate Plygone : " << input.Size() << " ==> " << output.Size() );
}
void SutherlandHodgman(etk::VectorType<coord2D_ts> & input, etk::VectorType<coord2D_ts> & output, etkFloat_t sx, etkFloat_t sy, etkFloat_t ex, etkFloat_t ey)
{
// with Sutherland-Hodgman-Algorithm
if (input.Size() <0) {
return;
}
//int32_t sizeInit=input.Size();
// last element :
coord2D_ts destPoint;
coord2D_ts lastElement = input[input.Size()-1];
bool inside = true;
if (lastElement.x < sx) {
inside = false;
}
//EWOL_DEBUG("generate an crop : ");
for(int32_t iii=0; iii<input.Size(); iii++) {
if(input[iii].x < sx) {
if(true == inside) {
//EWOL_DEBUG("element IN ==> OUT ");
//new point intersection ...
//y=aaax+bbb
etkFloat_t aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x);
etkFloat_t bbb = lastElement.y - (aaa*lastElement.x);
destPoint.y = aaa*sx + bbb;
destPoint.x = sx;
output.PushBack(destPoint);
} else {
//EWOL_DEBUG("element OUT ==> OUT ");
}
inside = false;
} else {
if(true == inside) {
//EWOL_DEBUG("element IN ==> IN ");
output.PushBack(input[iii]);
} else {
//EWOL_DEBUG("element OUT ==> IN ");
//new point intersection ...
//y=aaax+bbb
etkFloat_t aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x);
etkFloat_t bbb = lastElement.y - (aaa*lastElement.x);
destPoint.y = aaa*sx + bbb;
destPoint.x = sx;
output.PushBack(destPoint);
output.PushBack(input[iii]);
}
inside = true;
}
// update the last point position :
lastElement.x = input[iii].x;
lastElement.y = input[iii].y;
}
//EWOL_DEBUG("generate an crop on element : " << sizeInit << " ==> " << output.Size() << "intermediate (1)");
input = output;
output.Clear();
lastElement = input[input.Size()-1];
inside = true;
if (lastElement.y < sy) {
inside = false;
}
for(int32_t iii=0; iii<input.Size(); iii++) {
if(input[iii].y < sy) {
if(true == inside) {
//EWOL_DEBUG("element IN ==> OUT ");
//new point intersection ...
//x=aaay+bbb
etkFloat_t aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y);
etkFloat_t bbb = lastElement.x - (aaa*lastElement.y);
destPoint.y = sy;
destPoint.x = sy*aaa + bbb;
output.PushBack(destPoint);
} else {
//EWOL_DEBUG("element OUT ==> OUT ");
}
inside = false;
} else {
if(true == inside) {
//EWOL_DEBUG("element IN ==> IN ");
output.PushBack(input[iii]);
} else {
//EWOL_DEBUG("element OUT ==> IN ");
//new point intersection ...
//y=aaax+bbb
etkFloat_t aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y);
etkFloat_t bbb = lastElement.x - (aaa*lastElement.y);
destPoint.y = sy;
destPoint.x = sy*aaa + bbb;
output.PushBack(destPoint);
output.PushBack(input[iii]);
}
inside = true;
}
// update the last point position :
lastElement.x = input[iii].x;
lastElement.y = input[iii].y;
}
input = output;
output.Clear();
lastElement = input[input.Size()-1];
inside = true;
if (lastElement.x > ex) {
inside = false;
}
//EWOL_DEBUG("generate an crop : ");
for(int32_t iii=0; iii<input.Size(); iii++) {
if(input[iii].x > ex) {
if(true == inside) {
//EWOL_DEBUG("element IN ==> OUT ");
//new point intersection ...
//y=aaax+bbb
etkFloat_t aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x);
etkFloat_t bbb = lastElement.y - (aaa*lastElement.x);
destPoint.y = aaa*ex + bbb;
destPoint.x = ex;
output.PushBack(destPoint);
} else {
//EWOL_DEBUG("element OUT ==> OUT ");
}
inside = false;
} else {
if(true == inside) {
//EWOL_DEBUG("element IN ==> IN ");
output.PushBack(input[iii]);
} else {
//EWOL_DEBUG("element OUT ==> IN ");
//new point intersection ...
//y=aaax+bbb
etkFloat_t aaa = (lastElement.y-input[iii].y) / (lastElement.x-input[iii].x);
etkFloat_t bbb = lastElement.y - (aaa*lastElement.x);
destPoint.y = aaa*ex + bbb;
destPoint.x = ex;
output.PushBack(destPoint);
output.PushBack(input[iii]);
}
inside = true;
}
// update the last point position :
lastElement.x = input[iii].x;
lastElement.y = input[iii].y;
}
input = output;
output.Clear();
lastElement = input[input.Size()-1];
inside = true;
if (lastElement.y > ey) {
inside = false;
}
for(int32_t iii=0; iii<input.Size(); iii++) {
if(input[iii].y > ey) {
if(true == inside) {
//EWOL_DEBUG("element IN ==> OUT ");
//new point intersection ...
//x=aaay+bbb
etkFloat_t aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y);
etkFloat_t bbb = lastElement.x - (aaa*lastElement.y);
destPoint.y = ey;
destPoint.x = ey*aaa + bbb;
output.PushBack(destPoint);
} else {
//EWOL_DEBUG("element OUT ==> OUT ");
}
inside = false;
} else {
if(true == inside) {
//EWOL_DEBUG("element IN ==> IN ");
output.PushBack(input[iii]);
} else {
//EWOL_DEBUG("element OUT ==> IN ");
//new point intersection ...
//y=aaax+bbb
etkFloat_t aaa = (lastElement.x-input[iii].x) / (lastElement.y-input[iii].y);
etkFloat_t bbb = lastElement.x - (aaa*lastElement.y);
destPoint.y = ey;
destPoint.x = ey*aaa + bbb;
output.PushBack(destPoint);
output.PushBack(input[iii]);
}
inside = true;
}
// update the last point position :
lastElement.x = input[iii].x;
lastElement.y = input[iii].y;
}
//EWOL_DEBUG("generate an crop on element : " << sizeInit << " ==> " << output.Size() );
}
void ewol::OObject2DColored::GenerateTriangle(void)
{
m_triElement = 0;
m_coord.PushBack(m_triangle[0]);
m_coordColor.PushBack(m_color[0]);
m_coord.PushBack(m_triangle[1]);
m_coordColor.PushBack(m_color[1]);
m_coord.PushBack(m_triangle[2]);
m_coordColor.PushBack(m_color[2]);
}
void ewol::OObject2DColored::SetColor(color_ts color)
{
if (m_triElement < 1) {
m_color[0] = color;
}
if (m_triElement < 2) {
m_color[1] = color;
}
if (m_triElement < 3) {
m_color[2] = color;
}
}
void ewol::OObject2DColored::SetColor(etkFloat_t red, etkFloat_t green, etkFloat_t blue, etkFloat_t alpha)
{
if (m_triElement < 1) {
m_color[0].red = red;
m_color[0].green = green;
m_color[0].blue = blue;
m_color[0].alpha = alpha;
}
if (m_triElement < 2) {
m_color[1].red = red;
m_color[1].green = green;
m_color[1].blue = blue;
m_color[1].alpha = alpha;
}
if (m_triElement < 3) {
m_color[2].red = red;
m_color[2].green = green;
m_color[2].blue = blue;
m_color[2].alpha = alpha;
}
}
void ewol::OObject2DColored::SetPoint(coord2D_ts point)
{
m_triangle[m_triElement] = point;
m_triElement++;
if (m_triElement>=3) {
GenerateTriangle();
}
}
void ewol::OObject2DColored::SetPoint(etkFloat_t x, etkFloat_t y)
{
m_triangle[m_triElement].x = x;
m_triangle[m_triElement].y = y;
m_triElement++;
if (m_triElement>=3) {
GenerateTriangle();
}
}
void ewol::OObject2DColored::ResetCount(void)
{
m_triElement = 0;
m_color[1] = m_color[0];
m_color[2] = m_color[0];
}
void ewol::OObject2DColored::Line(etkFloat_t sx, etkFloat_t sy, etkFloat_t ex, etkFloat_t ey, etkFloat_t thickness)
{
ResetCount();
if (sx == ex && sy == ey) {
EWOL_WARNING("Try to draw an line width 0");
return;
}
//teta = tan-1(oposer/adjacent)
etkFloat_t teta = 0;
if (sx <= ex) {
teta = atan((ey-sy)/(ex-sx));
} else {
teta = M_PI + atan((ey-sy)/(ex-sx));
}
if (teta < 0) {
teta += 2*M_PI;
} else if (teta > 2*M_PI) {
teta -= 2*M_PI;
}
//EWOL_DEBUG("teta = " << (teta*180/(M_PI)) << " deg." );
etkFloat_t offsety = sin(teta-M_PI/2) * (thickness/2);
etkFloat_t offsetx = cos(teta-M_PI/2) * (thickness/2);
SetPoint(sx - offsetx, sy - offsety);
SetPoint(sx + offsetx, sy + offsety);
SetPoint(ex + offsetx, ey + offsety);
SetPoint(ex + offsetx, ey + offsety);
SetPoint(ex - offsetx, ey - offsety);
SetPoint(sx - offsetx, sy - offsety);
}
void ewol::OObject2DColored::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h)
{
ResetCount();
/* Bitmap position
* xA xB
* yC *------*
* | |
* | |
* yD *------*
*/
etkFloat_t dxA = x;
etkFloat_t dxB = x + w;
etkFloat_t dyC = y;
etkFloat_t dyD = y + h;
if (true == m_hasClipping) {
if (dxA < m_clipping.x) {
dxA = m_clipping.x;
}
if (dxB > m_clipping.x + m_clipping.w) {
dxB = m_clipping.x + m_clipping.w;
}
if (dyC < m_clipping.y) {
dyC = m_clipping.y;
}
if (dyD > m_clipping.y + m_clipping.h) {
dyD = m_clipping.y + m_clipping.h;
}
}
if( dyC >= dyD
|| dxA >= dxB) {
return;
}
SetPoint(dxA, dyD);
SetPoint(dxA, dyC);
SetPoint(dxB, dyC);
SetPoint(dxB, dyC);
SetPoint(dxB, dyD);
SetPoint(dxA, dyD);
}
void ewol::OObject2DColored::RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness)
{
// TODO : This did not manage the thickness of the line ...
Line(x, y, x+w, y, thickness);
Line(x+w, y, x+w, y+h, thickness);
Line(x+w, y+h, x, y+h, thickness);
Line(x, y+h, x, y, thickness);
}
void ewol::OObject2DColored::Circle(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness)
{
ResetCount();
if (radius<0) {
radius *= -1;
}
if (radius < thickness/2) {
Disc(x, y, thickness/2 + radius);
}
int32_t nbOcurence = radius;
if (nbOcurence < 10)
{
nbOcurence = 10;
}
for (int32_t iii=0; iii<nbOcurence; iii++) {
etkFloat_t angleOne = 2*M_PI* iii / nbOcurence ;
etkFloat_t offsetExty = sin(angleOne) * (radius+thickness/2);
etkFloat_t offsetExtx = cos(angleOne) * (radius+thickness/2);
etkFloat_t offsetInty = sin(angleOne) * (radius-thickness/2);
etkFloat_t offsetIntx = cos(angleOne) * (radius-thickness/2);
etkFloat_t angleTwo = 2*M_PI* (iii+1) / nbOcurence ;
etkFloat_t offsetExt2y = sin(angleTwo) * (radius+thickness/2);
etkFloat_t offsetExt2x = cos(angleTwo) * (radius+thickness/2);
etkFloat_t offsetInt2y = sin(angleTwo) * (radius-thickness/2);
etkFloat_t offsetInt2x = cos(angleTwo) * (radius-thickness/2);
SetPoint(x + offsetIntx, y + offsetInty);
SetPoint(x + offsetExtx, y + offsetExty);
SetPoint(x + offsetExt2x, y + offsetExt2y);
SetPoint(x + offsetExt2x, y + offsetExt2y);
SetPoint(x + offsetInt2x, y + offsetInt2y);
SetPoint(x + offsetIntx, y + offsetInty);
}
}
void ewol::OObject2DColored::CirclePart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness, etkFloat_t angleStart, etkFloat_t angleStop)
{
ResetCount();
if (radius<0) {
radius *= -1;
}
if (radius < thickness/2) {
Disc(x, y, thickness/2 + radius);
}
angleStart -= 90;
angleStop -= 90;
etkFloat_t AStart = angleStart * (M_PI)/180;
//etkFloat_t AStop = angleStop * (M_PI)/180;
etkFloat_t angleLinear = (angleStop-angleStart)* (M_PI)/180;
int32_t nbOcurence = radius;
if (nbOcurence < 10)
{
nbOcurence = 10;
}
for (int32_t iii=0; iii<nbOcurence; iii++) {
etkFloat_t angleOne = AStart + (angleLinear* iii / nbOcurence) ;
etkFloat_t offsetExty = sin(angleOne) * (radius+thickness/2);
etkFloat_t offsetExtx = cos(angleOne) * (radius+thickness/2);
etkFloat_t offsetInty = sin(angleOne) * (radius-thickness/2);
etkFloat_t offsetIntx = cos(angleOne) * (radius-thickness/2);
etkFloat_t angleTwo = AStart + (angleLinear* (iii+1) / nbOcurence );
etkFloat_t offsetExt2y = sin(angleTwo) * (radius+thickness/2);
etkFloat_t offsetExt2x = cos(angleTwo) * (radius+thickness/2);
etkFloat_t offsetInt2y = sin(angleTwo) * (radius-thickness/2);
etkFloat_t offsetInt2x = cos(angleTwo) * (radius-thickness/2);
SetPoint(x + offsetIntx, y + offsetInty);
SetPoint(x + offsetExtx, y + offsetExty);
SetPoint(x + offsetExt2x, y + offsetExt2y);
SetPoint(x + offsetExt2x, y + offsetExt2y);
SetPoint(x + offsetInt2x, y + offsetInt2y);
SetPoint(x + offsetIntx, y + offsetInty);
}
}
void ewol::OObject2DColored::Disc(etkFloat_t x, etkFloat_t y, etkFloat_t radius)
{
ResetCount();
if (radius<0) {
radius *= -1;
}
int32_t nbOcurence = radius*0.50;
if (nbOcurence < 15)
{
nbOcurence = 15;
}
// TODO : Generate a poligone instead if this ...
for (int32_t iii=0; iii<nbOcurence; iii++) {
SetPoint(x, y);
etkFloat_t angleOne = 2*M_PI* iii / nbOcurence ;
etkFloat_t offsety = sin(angleOne) * radius;
etkFloat_t offsetx = cos(angleOne) * radius;
SetPoint(x + offsetx, y + offsety);
etkFloat_t angleTwo = 2*M_PI* (iii+1) / nbOcurence ;
offsety = sin(angleTwo) * radius;
offsetx = cos(angleTwo) * radius;
SetPoint(x + offsetx, y + offsety);
}
}
void ewol::OObject2DColored::DiscPart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t angleStart, etkFloat_t angleStop)
{
ResetCount();
if (radius<0) {
radius *= -1;
}
angleStart -= 90;
angleStop -= 90;
etkFloat_t AStart = angleStart * (M_PI)/180;
//etkFloat_t AStop = angleStop * (M_PI)/180;
etkFloat_t angleLinear = (angleStop-angleStart)* (M_PI)/180;
//EWOL_DEBUG("Write a part of disk " << angleStart << " -> " << angleStop << " ocurence=" << (angleLinear*180/(M_PI)) );
int32_t nbOcurence = radius*0.50;
if (nbOcurence < 15)
{
nbOcurence = 15;
}
// TODO : Generate a poligone instead if this ...
for (int32_t iii=0; iii<nbOcurence; iii++) {
SetPoint(x, y);
etkFloat_t angleOne = AStart + (angleLinear* iii / nbOcurence) ;
etkFloat_t offsety = sin(angleOne) * radius;
etkFloat_t offsetx = cos(angleOne) * radius;
SetPoint(x + offsetx, y + offsety);
etkFloat_t angleTwo = AStart + (angleLinear* (iii+1) / nbOcurence) ;
offsety = sin(angleTwo) * radius;
offsetx = cos(angleTwo) * radius;
SetPoint(x + offsetx, y + offsety);
}
}

View File

@ -0,0 +1,64 @@
/**
*******************************************************************************
* @file ewol/OObject/2DColored.h
* @brief ewol OpenGl Object system (header)
* @author Edouard DUPIN
* @date 09/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_O_OBJECT_2D_COLORED_H__
#define __EWOL_O_OBJECT_2D_COLORED_H__
#include <ewol/OObject.h>
namespace ewol {
class OObject2DColored :public ewol::OObject
{
public:
OObject2DColored(void);
virtual ~OObject2DColored(void);
public:
virtual void Draw(void);
protected:
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
etk::VectorType<color_ts> m_coordColor; //!< internal color of the different point
//etk::VectorType<linkCoord_ts> m_linkCoord; //!< internal link between point to generate triangle
int32_t m_triElement;
color_ts m_color[3];
coord2D_ts m_triangle[3];
void GenerateTriangle(void);
void ResetCount(void);
public:
void Clear(void);
void SetColor(etkFloat_t red, etkFloat_t green, etkFloat_t blue, etkFloat_t alpha = 1.0);
void SetColor(color_ts color);
void SetPoint(coord2D_ts point);
void SetPoint(etkFloat_t x, etkFloat_t y);
void Line(etkFloat_t sx, etkFloat_t sy, etkFloat_t ex, etkFloat_t ey, etkFloat_t thickness);
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h);
void RectangleBorder(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t thickness);
void Circle(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness);
void CirclePart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t thickness, etkFloat_t angleStart, etkFloat_t angleStop);
void Disc(etkFloat_t x, etkFloat_t y, etkFloat_t radius);
void DiscPart(etkFloat_t x, etkFloat_t y, etkFloat_t radius, etkFloat_t angleStart, etkFloat_t angleStop);
};
};
#endif

View File

@ -0,0 +1,108 @@
/**
*******************************************************************************
* @file ewol/OObject/2DText.cpp
* @brief ewol OpenGl Object system (Sources)
* @author Edouard DUPIN
* @date 09/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/OObject/2DText.h>
#include <ewol/importgl.h>
#include <ewol/Texture.h>
#undef __class__
#define __class__ "ewol::OObject2DText"
ewol::OObject2DText::OObject2DText(etk::UString FontName, int32_t size, color_ts textColorFg)
{
m_textColorFg = textColorFg;
if (FontName == "") {
m_FontId = GetDefaultFontId();
} else {
EWOL_TODO("pas encore fait...");
//m_FontId = GetFontIdWithName(FontName);
m_FontId = -1;
return;
}
}
// open with default font ...
ewol::OObject2DText::OObject2DText(void)
{
m_textColorFg.red = 0.0;
m_textColorFg.green = 0.0;
m_textColorFg.blue = 0.0;
m_textColorFg.alpha = 1.0;
m_FontId = GetDefaultFontId();
}
ewol::OObject2DText::~OObject2DText(void)
{
}
void ewol::OObject2DText::Draw(void)
{
if (m_coord.Size()<=0) {
// TODO : a remètre ...
//EWOL_WARNING("Nothink to draw...");
return;
}
glColor4f(m_textColorFg.red, m_textColorFg.green, m_textColorFg.blue, m_textColorFg.alpha);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_FontTextureId));
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] );
glTexCoordPointer( 2, oglTypeFloat_t, 0, &m_coordTex[0] );
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
glDisable(GL_TEXTURE_2D);
}
void ewol::OObject2DText::Clear(void)
{
m_coord.Clear();
m_coordTex.Clear();
}
int32_t ewol::OObject2DText::Text(coord2D_ts textPos, clipping_ts drawClipping, const etk::UString& unicodeString)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return 0;
}
return ewol::DrawText(m_FontId, textPos, drawClipping, unicodeString, m_FontTextureId, m_coord, m_coordTex);
}
int32_t ewol::OObject2DText::Text(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t unicodeChar)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return 0;
}
return ewol::DrawText(m_FontId, textPos, drawClipping, unicodeChar, m_FontTextureId, m_coord, m_coordTex);
}

View File

@ -0,0 +1,54 @@
/**
*******************************************************************************
* @file ewol/OObject/2DText.h
* @brief ewol OpenGl Object system (header)
* @author Edouard DUPIN
* @date 09/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_O_OBJECT_2D_TEXT_H__
#define __EWOL_O_OBJECT_2D_TEXT_H__
#include <ewol/OObject.h>
#include <etk/UString.h>
namespace ewol {
class OObject2DText :public ewol::OObject
{
public:
OObject2DText(etk::UString FontName, int32_t size, color_ts textColorFg);
OObject2DText(void);
virtual ~OObject2DText(void);
public:
virtual void Draw(void);
// set a specific text
void Clear(void);
int32_t Text(coord2D_ts textPos, clipping_ts drawClipping, const etk::UString& unicodeString);
int32_t Text(coord2D_ts textPos, clipping_ts drawClipping, const uniChar_t unicodeChar);
protected:
int32_t m_FontId; //!< font internal ID
color_ts m_textColorFg; //!< text color ...
int32_t m_FontTextureId; //!< font internal Texture ID
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
};
};
#endif

View File

@ -0,0 +1,166 @@
/**
*******************************************************************************
* @file ewol/OObject/2DTextColored.cpp
* @brief ewol OpenGl Object system (Sources)
* @author Edouard DUPIN
* @date 16/01/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/OObject/2DTextColored.h>
#include <ewol/importgl.h>
#include <ewol/Texture.h>
#undef __class__
#define __class__ "ewol::OObject2DTextColored"
ewol::OObject2DTextColored::OObject2DTextColored(etk::UString FontName, int32_t size)
{
m_color.red = 0.0;
m_color.green = 0.0;
m_color.blue = 0.0;
m_color.alpha = 1.0;
if (FontName == "") {
m_FontId = GetDefaultFontId();
} else {
EWOL_TODO("pas encore fait...");
//m_FontId = GetFontIdWithName(FontName);
m_FontId = -1;
}
/*
m_coord.SetIncrement(50000);
m_coordTex.SetIncrement(50000);
m_coordColor.SetIncrement(50000);
*/
}
ewol::OObject2DTextColored::OObject2DTextColored(int32_t fontID)
{
m_color.red = 0.0;
m_color.green = 0.0;
m_color.blue = 0.0;
m_color.alpha = 1.0;
if (fontID < 0) {
m_FontId = GetDefaultFontId();
} else {
m_FontId = fontID;
}
}
// open with default font ...
ewol::OObject2DTextColored::OObject2DTextColored(void)
{
m_color.red = 0.0;
m_color.green = 0.0;
m_color.blue = 0.0;
m_color.alpha = 1.0;
m_FontId = GetDefaultFontId();
}
ewol::OObject2DTextColored::~OObject2DTextColored(void)
{
}
void ewol::OObject2DTextColored::Draw(void)
{
if (m_coord.Size()<=0) {
// TODO : a remètre ...
//EWOL_WARNING("Nothink to draw...");
return;
}
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_FontTextureId));
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
glEnableClientState( GL_COLOR_ARRAY ); // Enable Color Arrays
glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] );
glTexCoordPointer( 2, oglTypeFloat_t, 0, &m_coordTex[0] );
glColorPointer( 4, oglTypeFloat_t, 0, &m_coordColor[0] );
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
glDisableClientState( GL_COLOR_ARRAY ); // Disable Color Arrays
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
glDisable(GL_TEXTURE_2D);
}
void ewol::OObject2DTextColored::Clear(void)
{
m_coord.Clear();
m_coordTex.Clear();
m_coordColor.Clear();
}
int32_t ewol::OObject2DTextColored::Text(coord2D_ts textPos, const etk::UString& unicodeString)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return 0;
}
int32_t nbElementInTheArray = m_coord.Size();
int32_t size = 0;
if (true==m_hasClipping) {
size = ewol::DrawText(m_FontId, textPos, m_clipping, unicodeString, m_FontTextureId, m_coord, m_coordTex);
} else {
size = ewol::DrawText(m_FontId, textPos, unicodeString, m_FontTextureId, m_coord, m_coordTex);
}
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
m_coordColor.PushBack(m_color);
}
return size;
}
int32_t ewol::OObject2DTextColored::Text(coord2D_ts textPos, const uniChar_t unicodeChar)
{
m_FontTextureId = 0;
if (m_FontId == -1) {
EWOL_ERROR("Font Id is not corectly defined");
return 0;
}
int32_t nbElementInTheArray = m_coord.Size();
int32_t size = 0;
if (true==m_hasClipping) {
size = ewol::DrawText(m_FontId, textPos, m_clipping, unicodeChar, m_FontTextureId, m_coord, m_coordTex);
} else {
size = ewol::DrawText(m_FontId, textPos, unicodeChar, m_FontTextureId, m_coord, m_coordTex);
}
for (int32_t iii=nbElementInTheArray; iii<m_coord.Size(); iii++) {
m_coordColor.PushBack(m_color);
}
return size;
}
void ewol::OObject2DTextColored::SetColor(color_ts color)
{
m_color = color;
}
void ewol::OObject2DTextColored::SetColor(etkFloat_t red, etkFloat_t green, etkFloat_t blue, etkFloat_t alpha)
{
m_color.red = red;
m_color.green = green;
m_color.blue = blue;
m_color.alpha = alpha;
}

View File

@ -0,0 +1,60 @@
/**
*******************************************************************************
* @file ewol/OObject/2DTextColored.h
* @brief ewol OpenGl Object system (header)
* @author Edouard DUPIN
* @date 16/01/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_O_OBJECT_2D_TEXT_COLORED_H__
#define __EWOL_O_OBJECT_2D_TEXT_COLORED_H__
#include <ewol/OObject.h>
namespace ewol {
class OObject2DTextColored :public ewol::OObject
{
public:
OObject2DTextColored(etk::UString FontName, int32_t size);
OObject2DTextColored(int32_t fontID);
OObject2DTextColored(void);
virtual ~OObject2DTextColored(void);
public:
virtual void Draw(void);
void SetColor(etkFloat_t red, etkFloat_t green, etkFloat_t blue, etkFloat_t alpha = 1.0);
void SetColor(color_ts color);
// set a specific text
void Clear(void);
int32_t Text(coord2D_ts textPos, const etk::UString& unicodeString);
int32_t Text(coord2D_ts textPos, const uniChar_t unicodeChar);
protected:
int32_t m_FontId; //!< font internal ID
color_ts m_color; //!< tmp text color ...
int32_t m_FontTextureId; //!< font internal Texture ID
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
etk::VectorType<color_ts> m_coordColor; //!< internal color of the different point
public:
void SetFontID(int32_t fontID) { m_FontId = fontID; };
int32_t GetFontID(void) { return m_FontId; };
};
};
#endif

View File

@ -0,0 +1,111 @@
/**
*******************************************************************************
* @file ewol/OObject/2DTextured.cpp
* @brief ewol OpenGl Object system (Sources)
* @author Edouard DUPIN
* @date 09/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/OObject/2DTextured.h>
#include <ewol/Texture.h>
#include <ewol/importgl.h>
#undef __class__
#define __class__ "ewol::OObject2DTextured"
ewol::OObject2DTextured::OObject2DTextured(etk::File textureName)
{
EWOL_DEBUG("Create OObject textured : \"" << textureName << "\"");
m_textureId = ewol::LoadTexture(textureName);
}
ewol::OObject2DTextured::~OObject2DTextured(void)
{
ewol::UnLoadTexture(m_textureId);
}
void ewol::OObject2DTextured::Draw(void)
{
if (m_coord.Size()<=0) {
EWOL_WARNING("Nothink to draw...");
return;
}
glColor4f(1.0, 1.0, 1.0, 1.0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, ewol::GetTextureGLID(m_textureId));
glEnableClientState( GL_VERTEX_ARRAY ); // Enable Vertex Arrays
glEnableClientState( GL_TEXTURE_COORD_ARRAY ); // Enable Texture Coord Arrays
glVertexPointer( 2, oglTypeFloat_t, 0, &m_coord[0] );
glTexCoordPointer( 2, oglTypeFloat_t, 0, &m_coordTex[0] );
glDrawArrays( GL_TRIANGLES, 0, m_coord.Size());
//EWOL_DEBUG("request draw of " << m_coord.Size() << " elements");
glDisableClientState( GL_VERTEX_ARRAY ); // Disable Vertex Arrays
glDisableClientState( GL_TEXTURE_COORD_ARRAY ); // Disable Texture Coord Arrays
glDisable(GL_TEXTURE_2D);
}
void ewol::OObject2DTextured::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t texX, etkFloat_t texY, etkFloat_t texSX, etkFloat_t texSY)
{
//EWOL_DEBUG("Add rectangle : ...");
coord2D_ts point;
texCoord_ts tex;
tex.u = texX;
tex.v = texY;
point.x = x;
point.y = y;
m_coord.PushBack(point);
m_coordTex.PushBack(tex);
tex.u = texSX;
tex.v = texY;
point.x = x + w;
point.y = y;
m_coord.PushBack(point);
m_coordTex.PushBack(tex);
tex.u = texSX;
tex.v = texSY;
point.x = x + w;
point.y = y + h;
m_coord.PushBack(point);
m_coordTex.PushBack(tex);
m_coord.PushBack(point);
m_coordTex.PushBack(tex);
tex.u = texX;
tex.v = texSY;
point.x = x;
point.y = y + h;
m_coord.PushBack(point);
m_coordTex.PushBack(tex);
tex.u = texX;
tex.v = texY;
point.x = x;
point.y = y;
m_coord.PushBack(point);
m_coordTex.PushBack(tex);
}

View File

@ -0,0 +1,47 @@
/**
*******************************************************************************
* @file ewol/OObject/2DTextured.h
* @brief ewol OpenGl Object system (header)
* @author Edouard DUPIN
* @date 09/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_O_OBJECT_2D_TEXTURED_H__
#define __EWOL_O_OBJECT_2D_TEXTURED_H__
#include <ewol/OObject.h>
namespace ewol {
class OObject2DTextured :public ewol::OObject
{
public:
OObject2DTextured(etk::File textureName);
virtual ~OObject2DTextured(void);
public:
virtual void Draw(void);
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t texX=0.0, etkFloat_t texY=0.0, etkFloat_t texSX=1.0, etkFloat_t texSY=1.0);
protected:
int32_t m_textureId; //!< texture internal ID
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
etk::VectorType<texCoord_ts> m_coordTex; //!< internal texture coordinate for every point
};
};
#endif

View File

@ -0,0 +1,148 @@
/**
*******************************************************************************
* @file ewol/ShortCutManager.cpp
* @brief ewol shortCut manager (Sources)
* @author Edouard DUPIN
* @date 22/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/ShortCutManager.h>
#include <ewol/EObject.h>
#include <ewol/ewol.h>
class EventShortCut {
public:
const char * generateEventId; // event generate ID (to be unique it was pointer on the string name)
etk::UString eventData;
bool shift;
bool control;
bool alt;
bool meta;
uniChar_t UnicodeValue;
};
static etk::VectorType<EventShortCut *> l_inputShortCutEvent; //!< generic short-cut event
void ewol::shortCut::Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString data)
{
EventShortCut * newEvent = new EventShortCut();
if (NULL == newEvent) {
EWOL_ERROR("Allocation Error on the shortcut ...");
return;
}
newEvent->generateEventId = generateEventId;
newEvent->shift = shift;
newEvent->control = control;
newEvent->alt = alt;
newEvent->meta = meta;
newEvent->UnicodeValue = unicodeValue;
newEvent->eventData = data;
l_inputShortCutEvent.PushBack(newEvent);
return;
}
void ewol::shortCut::Add(const char * descriptiveString, const char * generateEventId, etk::UString data)
{
if( NULL==descriptiveString
|| 0==strlen(descriptiveString))
{
return;
}
bool shift = false;
bool control = false;
bool alt = false;
bool meta = false;
uint32_t UnicodeValue = 0;
// parsing of the string :
//"ctrl+shift+alt+meta+s"
const char * tmp = strstr(descriptiveString, "ctrl");
if(NULL != tmp) {
control = true;
}
tmp = strstr(descriptiveString, "shift");
if(NULL != tmp) {
shift = true;
}
tmp = strstr(descriptiveString, "alt");
if(NULL != tmp) {
alt = true;
}
tmp = strstr(descriptiveString, "meta");
if(NULL != tmp) {
meta = true;
}
UnicodeValue = descriptiveString[strlen(descriptiveString) -1];
// add with generic Adding function ...
ewol::shortCut::Add(shift, control, alt, meta, UnicodeValue, generateEventId, data);
}
void ewol::shortCut::Init(void)
{
if (l_inputShortCutEvent.Size()>0) {
EWOL_WARNING("Old element error in the shortCut system");
for(int32_t iii=0; iii< l_inputShortCutEvent.Size(); iii++) {
delete(l_inputShortCutEvent[iii]);
l_inputShortCutEvent[iii] = NULL;
}
}
l_inputShortCutEvent.Clear();
}
void ewol::shortCut::UnInit(void)
{
if (l_inputShortCutEvent.Size()>0) {
for(int32_t iii=0; iii< l_inputShortCutEvent.Size(); iii++) {
delete(l_inputShortCutEvent[iii]);
l_inputShortCutEvent[iii] = NULL;
}
}
l_inputShortCutEvent.Clear();
}
bool ewol::shortCut::Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, bool isDown)
{
if (unicodeValue >= 'A' && unicodeValue <='Z') {
unicodeValue += 'a' - 'A';
}
//EWOL_INFO("Try to find generic shortcut ...");
for(int32_t iii=l_inputShortCutEvent.Size()-1; iii>=0; iii--) {
if( l_inputShortCutEvent[iii]->shift == shift
&& l_inputShortCutEvent[iii]->control == control
&& l_inputShortCutEvent[iii]->alt == alt
&& l_inputShortCutEvent[iii]->meta == meta
&& l_inputShortCutEvent[iii]->UnicodeValue == unicodeValue)
{
if (isDown) {
ewol::EObjectMessageMultiCast::AnonymousSend(l_inputShortCutEvent[iii]->generateEventId, l_inputShortCutEvent[iii]->eventData);
} // no else
return true;
}
}
return false;
}

View File

@ -0,0 +1,42 @@
/**
*******************************************************************************
* @file ewol/ShortCutManager.h
* @brief ewol shortCut manager (Header)
* @author Edouard DUPIN
* @date 22/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_SHORT_CUT_MANAGER_H__
#define __EWOL_SHORT_CUT_MANAGER_H__
#include <etk/Types.h>
#include <etk/UString.h>
namespace ewol {
namespace shortCut {
void Init(void);
void UnInit(void);
bool Process(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, bool isDown);
};
};
#endif

View File

@ -0,0 +1,567 @@
/**
*******************************************************************************
* @file ewol/Texture.cpp
* @brief ewol Texture loading system (sources)
* @author Edouard DUPIN
* @date 28/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/Texture.h>
#include <ewol/importgl.h>
#include <ewol/ewol.h>
#include <pthread.h>
extern "C"
{
#pragma pack(push,1)
typedef struct
{
int16_t bfType;
int32_t bfSize;
int32_t bfReserved;
int32_t bfOffBits;
} bitmapFileHeader_ts;
typedef struct
{
int32_t biSize;
int32_t biWidth;
int32_t biHeight;
int16_t biPlanes;
int16_t biBitCount;
int32_t biCompression;
int32_t biSizeImage;
int32_t biXPelsPerMeter;
int32_t biYPelsPerMeter;
int32_t biClrUsed;
int32_t biClrImportant;
} bitmapInfoHeader_ts;
#pragma pack(pop)
typedef enum {
BITS_16_R5G6B5,
BITS_16_X1R5G5B5,
BITS_24_R8G8B8,
BITS_32_X8R8G8B8,
BITS_32_A8R8G8B8
} modeBitmap_te;
};
#undef __class__
#define __class__ "ewol::Bitmap"
class Bitmap
{
private:
modeBitmap_te m_dataMode;
int32_t m_width;
int32_t m_height;
int32_t m_size;
uint8_t * m_data;
uint8_t * m_dataGenerate;
bitmapFileHeader_ts m_FileHeader;
bitmapInfoHeader_ts m_InfoHeader;
public:
Bitmap(etk::File & fileName) : m_data(NULL), m_dataGenerate(NULL)
{
m_dataMode = BITS_16_R5G6B5;
m_width = 0;
m_height = 0;
m_size = 0;
// Get the fileSize ...
/*if (fileName.Size() < (int32_t)(sizeof(bitmapFileHeader_ts) + sizeof(bitmapInfoHeader_ts) ) ) {
EWOL_ERROR("not enought data in the file named=\"" << fileName << "\"");
return;
}*/
if(false == fileName.fOpenRead() ) {
EWOL_ERROR("Can not find the file name=\"" << fileName << "\"");
return;
}
// get the data :
if (fileName.fRead(&m_FileHeader,sizeof(bitmapFileHeader_ts),1) != 1) {
EWOL_ERROR("error loading file header");
fileName.fClose();
return;
}
if (fileName.fRead(&m_InfoHeader,sizeof(bitmapInfoHeader_ts),1) != 1) {
EWOL_ERROR("error loading file header");
fileName.fClose();
return;
}
if(false == fileName.fSeek(m_FileHeader.bfOffBits, SEEK_SET)) {
EWOL_ERROR("error with the 'bfOffBits' in the file named=\"" << fileName << "\"");
fileName.fClose();
return;
}
// Check the header error :
if (m_FileHeader.bfType != 0x4D42) {
EWOL_ERROR("the file=\"" << fileName << "\" is not a bitmap file ...");
fileName.fClose();
return;
}
if (m_FileHeader.bfReserved != 0x00000000) {
EWOL_ERROR("the bfReserved feald is not at 0 ==> not supported format ...");
fileName.fClose();
return;
}
if( m_InfoHeader.biBitCount == 16
&& m_InfoHeader.biCompression == 0)
{
m_dataMode = BITS_16_X1R5G5B5;
} else if( m_InfoHeader.biBitCount == 16
&& m_InfoHeader.biCompression == 3)
{
m_dataMode = BITS_16_R5G6B5;
} else if( m_InfoHeader.biBitCount == 24
&& m_InfoHeader.biCompression == 0)
{
m_dataMode = BITS_24_R8G8B8;
} else if( m_InfoHeader.biBitCount == 32
&& m_InfoHeader.biCompression == 3)
{
m_dataMode = BITS_32_X8R8G8B8;
} else if( m_InfoHeader.biBitCount == 32
&& m_InfoHeader.biCompression == 0)
{
m_dataMode = BITS_32_A8R8G8B8;
} else {
EWOL_ERROR("the biBitCount & biCompression fealds are unknow ==> not supported format ...");
fileName.fClose();;
return;
}
m_width = m_InfoHeader.biWidth;
m_height = m_InfoHeader.biHeight;
if(0 != m_InfoHeader.biSizeImage)
{
m_data=new uint8_t[m_InfoHeader.biSizeImage];
if (fileName.fRead(m_data,m_InfoHeader.biSizeImage,1) != 1){
EWOL_CRITICAL("Can not read the file with the good size...");
}
// allocate the destination data ...
m_dataGenerate=new uint8_t[m_width*m_height*4];
}
fileName.fClose();
// need now to generate RGBA data ...
switch(m_dataMode)
{
case BITS_16_R5G6B5:
{
uint16_t * pointer = (uint16_t*)m_data;
for(int32_t yyy=0; yyy<m_height; yyy++) {
for(int32_t xxx=0; xxx<m_width; xxx++) {
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = (int8_t)((*pointer & 0xF800) >> 8);
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = (int8_t)((*pointer & 0x07E0) >> 3);
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = (int8_t)(*pointer << 3);
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = 0xFF;
pointer++;
}
}
}
break;
case BITS_16_X1R5G5B5:
{
uint16_t * pointer = (uint16_t*)m_data;
for(int32_t yyy=0; yyy<m_height; yyy++) {
for(int32_t xxx=0; xxx<m_width; xxx++) {
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = (int8_t)((*pointer & 0x7C00) >> 7);
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = (int8_t)((*pointer & 0x03E0) >> 2);
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = (int8_t)(*pointer << 3);
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = 0xFF;
pointer++;
}
}
}
break;
case BITS_24_R8G8B8:
{
uint8_t * pointer = m_data;
for(int32_t yyy=0; yyy<m_height; yyy++) {
for(int32_t xxx=0; xxx<m_width; xxx++) {
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = 0xFF;
}
}
}
break;
case BITS_32_X8R8G8B8:
{
uint8_t * pointer = m_data;
for(int32_t yyy=0; yyy<m_height; yyy++) {
for(int32_t xxx=0; xxx<m_width; xxx++) {
pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = 0xFF;
}
}
}
break;
case BITS_32_A8R8G8B8:
{
uint8_t * pointer = m_data;
for(int32_t yyy=0; yyy<m_height; yyy++) {
for(int32_t xxx=0; xxx<m_width; xxx++) {
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 0] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 1] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 2] = *pointer++;
m_dataGenerate[4*((m_height-yyy-1) * m_width + xxx ) + 3] = *pointer++;
}
}
}
break;
default:
EWOL_DEBUG(" mode = ERROR");
break;
}
}
~Bitmap(void)
{
if (NULL != m_data) {
delete(m_data);
}
if (NULL != m_dataGenerate) {
delete(m_dataGenerate);
}
}
bool LoadOK(void) { if (NULL != m_dataGenerate) { return true; } else { return false; } };
int32_t Width(void) { return m_width; };
int32_t Height(void) { return m_height; };
uint8_t * Data(void) { return m_dataGenerate; };
void Display(void)
{
if (NULL == m_data) {
EWOL_ERROR("Might loading error of this Bitmap ...");
return;
}
EWOL_DEBUG(" -----------------------------------------------------------");
if (false) {
EWOL_DEBUG("Display caracteristic of the bitmap : ");
EWOL_DEBUG(" Header of file :");
EWOL_DEBUG(" bfType =" << m_FileHeader.bfType << " 19778 : must always be set to 'BM' to declare that this is a .bmp-file.");
EWOL_DEBUG(" bfSize =" << m_FileHeader.bfSize << " specifies the size of the file in bytes.");
EWOL_DEBUG(" bfReserved=" << m_FileHeader.bfReserved << " must always be set to zero.");
EWOL_DEBUG(" bfOffBits =" << m_FileHeader.bfOffBits << " 1078 : specifies the offset from the beginning of the file to the bitmap data.");
EWOL_DEBUG(" info header of file :");
EWOL_DEBUG(" biSize =" << m_InfoHeader.biSize << " specifies the size of the BITMAPINFOHEADER structure, in bytes.");
EWOL_DEBUG(" biWidth =" << m_InfoHeader.biWidth << " specifies the width of the image, in pixels.");
EWOL_DEBUG(" biHeight =" << m_InfoHeader.biHeight << " specifies the height of the image, in pixels.");
EWOL_DEBUG(" biPlanes =" << m_InfoHeader.biPlanes << " specifies the number of planes of the target device, must be set to zero.");
EWOL_DEBUG(" biBitCount =" << m_InfoHeader.biBitCount << " specifies the number of bits per pixel.");
EWOL_DEBUG(" biCompression =" << m_InfoHeader.biCompression << " Specifies the type of compression, usually set to zero (no compression).");
EWOL_DEBUG(" biSizeImage =" << m_InfoHeader.biSizeImage << " specifies the size of the image data, in bytes. If there is no compression, it is valid to set this member to zero.");
EWOL_DEBUG(" biXPelsPerMeter=" << m_InfoHeader.biXPelsPerMeter << " specifies the the horizontal pixels per meter on the designated targer device, usually set to zero.");
EWOL_DEBUG(" biYPelsPerMeter=" << m_InfoHeader.biYPelsPerMeter << " specifies the the vertical pixels per meter on the designated targer device, usually set to zero.");
EWOL_DEBUG(" biClrUsed =" << m_InfoHeader.biClrUsed << " speglTexImage2Dcifies the number of colors used in the bitmap, if set to zero the number of colors is calculated using the biBitCount member.");
EWOL_DEBUG(" biClrImportant =" << m_InfoHeader.biClrImportant << " specifies the number of color that are 'important' for the bitmap, if set to zero, all colors are important.");
}
EWOL_DEBUG("Bitmap : " << m_width << "x" << m_height);
switch(m_dataMode)
{
case BITS_16_R5G6B5:
EWOL_DEBUG(" mode = 16 bits R5G6B5");
break;
case BITS_16_X1R5G5B5:
EWOL_DEBUG(" mode = 16 bits X1R5G5B5");
break;
case BITS_24_R8G8B8:
EWOL_DEBUG(" mode = 24 bits R8G8B8");
break;
case BITS_32_X8R8G8B8:
EWOL_DEBUG(" mode = 32 bits X8R8G8B8");
break;
case BITS_32_A8R8G8B8:
EWOL_DEBUG(" mode = 32 bits A8R8G8B8");
break;
default:
EWOL_DEBUG(" mode = ERROR");
break;
}
}
};
class LoadedTexture
{
public:
etk::UString m_filename;
int32_t m_nbTimeLoaded;
// openGl configuration :
uint32_t m_openGlTextureID;
int32_t m_target;
int32_t m_level;
int32_t m_internalFormat;
int32_t m_width;
int32_t m_height;
int32_t m_border;
int32_t m_format;
int32_t m_type;
char* m_data;
int32_t m_nbBytes;
bool m_loaded;
bool m_destroy;
};
etk::VectorType<LoadedTexture*> listLoadedTexture;
#undef __class__
#define __class__ "ewol::texture"
static pthread_mutex_t localMutex;
void ewol::texture::Init(void)
{
EWOL_DEBUG("==> Init Texture-Manager");
// create interface mutex :
int ret = pthread_mutex_init(&localMutex, NULL);
EWOL_ASSERT(ret == 0, "Error creating Mutex ...");
}
void ewol::texture::UnInit(void)
{
EWOL_DEBUG("==> Un-Init Texture-Manager");
for (int32_t iii=0; iii<listLoadedTexture.Size(); iii++) {
if (listLoadedTexture[iii] != NULL) {
delete(listLoadedTexture[iii]);
}
listLoadedTexture[iii] = NULL;
}
listLoadedTexture.Clear();
int ret = pthread_mutex_destroy(&localMutex);
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
}
#undef __class__
#define __class__ "ewol"
void ewol::UpdateTextureContextIsDestroy(void)
{
pthread_mutex_lock(&localMutex);
for (int32_t iii=0; iii < listLoadedTexture.Size(); iii++) {
if( NULL != listLoadedTexture[iii]
&& NULL != listLoadedTexture[iii]->m_data)
{
listLoadedTexture[iii]->m_loaded = false;
EWOL_INFO("TEXTURE: Disable [" << iii << "]=(" << listLoadedTexture[iii]->m_width << "px," <<
listLoadedTexture[iii]->m_height << "px) in file:" <<
listLoadedTexture[iii]->m_filename << " OGl_Id=" <<listLoadedTexture[iii]->m_openGlTextureID);
//glDeleteTextures(1, &listLoadedTexture[iii]->m_openGlTextureID);
}
}
pthread_mutex_unlock(&localMutex);
}
void ewol::UpdateTextureContext(void)
{
bool needRedraw = false;
pthread_mutex_lock(&localMutex);
for (int32_t iii=0; iii < listLoadedTexture.Size(); iii++) {
if( NULL != listLoadedTexture[iii]
&& NULL != listLoadedTexture[iii]->m_data)
{
if( false == listLoadedTexture[iii]->m_destroy
&& false == listLoadedTexture[iii]->m_loaded)
{
GLuint textureid;
glGenTextures(1, &textureid);
glBindTexture(listLoadedTexture[iii]->m_target, textureid);
//glTexParameteri(tmpTex->m_target, GL_TEXTURE_WRAP_S, GL_REPEAT);
//glTexParameteri(tmpTex->m_target, GL_TEXTURE_WRAP_T, GL_REPEAT);
//--- mode nearest
//glTexParameteri(tmpTex->m_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//glTexParameteri(tmpTex->m_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
//--- Mode linear
glTexParameteri(listLoadedTexture[iii]->m_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(listLoadedTexture[iii]->m_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
EWOL_INFO("TEXTURE: Add [" << iii << "]=(" << listLoadedTexture[iii]->m_width << "px," <<
listLoadedTexture[iii]->m_height << "px) in file:" <<
listLoadedTexture[iii]->m_filename << " OGl_Id=" <<textureid);
glTexImage2D(listLoadedTexture[iii]->m_target,
listLoadedTexture[iii]->m_level,
listLoadedTexture[iii]->m_internalFormat,
listLoadedTexture[iii]->m_width,
listLoadedTexture[iii]->m_height,
listLoadedTexture[iii]->m_border,
listLoadedTexture[iii]->m_format,
listLoadedTexture[iii]->m_type,
listLoadedTexture[iii]->m_data);
listLoadedTexture[iii]->m_openGlTextureID = textureid;
listLoadedTexture[iii]->m_loaded = true;
needRedraw = true;
} else if ( true == listLoadedTexture[iii]->m_destroy
&& true == listLoadedTexture[iii]->m_loaded)
{
// Request remove texture ...
EWOL_DEBUG("TEXTURE: Rm [" << iii << "] file:" << listLoadedTexture[iii]->m_filename);
glDeleteTextures(1, &listLoadedTexture[iii]->m_openGlTextureID);
listLoadedTexture[iii]->m_loaded = false;
listLoadedTexture[iii]->m_openGlTextureID = -1;
if (NULL != listLoadedTexture[iii]->m_data) {
delete[] listLoadedTexture[iii]->m_data;
listLoadedTexture[iii]->m_data = NULL;
}
delete(listLoadedTexture[iii]);
listLoadedTexture[iii] = NULL;
}
}
}
pthread_mutex_unlock(&localMutex);
if (true == needRedraw) {
ewol::ForceRedrawAll();
}
}
int32_t ewol::LoadTexture(int32_t target,
int32_t level,
int32_t internalFormat,
int32_t width,
int32_t height,
int32_t border,
int32_t format,
int32_t type,
const void* data,
int32_t nbBytes,
etk::UString filename)
{
LoadedTexture *tmpTex = new LoadedTexture();
int32_t outTextureID = -1;
if (NULL == tmpTex){
EWOL_ERROR("Texture : Allocation ERROR... " << filename);
return -1;
}
tmpTex->m_filename = filename;
tmpTex->m_nbTimeLoaded = 1;
tmpTex->m_openGlTextureID = -1;
tmpTex->m_target = target;
tmpTex->m_level = level;
tmpTex->m_internalFormat = internalFormat;
tmpTex->m_width = width;
tmpTex->m_height = height;
tmpTex->m_border = border;
tmpTex->m_format = format;
tmpTex->m_type = type;
tmpTex->m_nbBytes = nbBytes;
tmpTex->m_data = new char[tmpTex->m_nbBytes+4096];
tmpTex->m_loaded = false;
tmpTex->m_destroy = false;
if (NULL == tmpTex->m_data) {
EWOL_ERROR("Texture : Data Allocation ERROR... " << filename);
return -1;
}
memcpy(tmpTex->m_data, data, sizeof(char) * tmpTex->m_nbBytes);
pthread_mutex_lock(&localMutex);
listLoadedTexture.PushBack(tmpTex);
outTextureID = listLoadedTexture.Size()-1;
pthread_mutex_unlock(&localMutex);
return outTextureID;
}
int32_t ewol::LoadTexture(etk::File fileName)
{
int32_t outTextureID = -1;
if (listLoadedTexture.Size()!=0) {
for (int32_t iii=0; iii<listLoadedTexture.Size(); iii++) {
if (NULL != listLoadedTexture[iii]) {
if (listLoadedTexture[iii]->m_filename == fileName.GetCompleateName()) {
listLoadedTexture[iii]->m_nbTimeLoaded++;
return iii;
}
}
}
}
etk::UString fileExtention = fileName.GetExtention();
if (fileExtention == "bmp") {
if (false == fileName.Exist()) {
EWOL_ERROR("File does not Exist ... " << fileName);
} else {
Bitmap * myBitmap = new Bitmap(fileName);
myBitmap->Display();
if (myBitmap->LoadOK() == true) {
if (myBitmap->Width()!= myBitmap->Height()) {
EWOL_ERROR("Texture can not have Width=" << myBitmap->Width() << "px different of height=" << myBitmap->Height() << "px in file:" << fileName);
return -1;
}
outTextureID = LoadTexture(GL_TEXTURE_2D, 0, GL_RGBA, myBitmap->Width(), myBitmap->Height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, myBitmap->Data(), myBitmap->Width()*myBitmap->Height()*4, fileName.GetCompleateName());
}
delete (myBitmap);
}
} else {
EWOL_ERROR("Extention not managed " << fileName << " Sopported extention : .bmp");
}
return outTextureID;
}
void ewol::UnLoadTexture(uint32_t textureID)
{
EWOL_INFO("Unload a specific tecture ID=" << textureID);
if (textureID>=0 && (int32_t)textureID<listLoadedTexture.Size()) {
if (NULL == listLoadedTexture[textureID]) {
EWOL_ERROR("Texture : " << textureID << " does not existe anymore...");
return;
}
listLoadedTexture[textureID]->m_nbTimeLoaded--;
if (0 == listLoadedTexture[textureID]->m_nbTimeLoaded) {
EWOL_DEBUG("Remove openGL texture ID=" << textureID << " file:" << listLoadedTexture[textureID]->m_filename);
listLoadedTexture[textureID]->m_destroy = true;
}
return;
}
EWOL_CRITICAL("Can not find TextureId=" << (int)textureID << " in the list of texture loaded...==> to remove it ...");
}
uint32_t ewol::GetTextureGLID(uint32_t textureID)
{
if (textureID>=0 && (int32_t)textureID<listLoadedTexture.Size()) {
return listLoadedTexture[textureID]->m_openGlTextureID;
}
return -1;
}
int32_t ewol::GetTextureSize(uint32_t textureID)
{
for (int32_t iii=0; iii<listLoadedTexture.Size(); iii++) {
if (listLoadedTexture[iii]->m_openGlTextureID == textureID) {
return listLoadedTexture[iii]->m_width;
}
}
EWOL_ERROR("Can not find TextureId=" << textureID << " in the list of texture loaded...");
return -1;
}

View File

@ -0,0 +1,57 @@
/**
*******************************************************************************
* @file ewol/Texture.h
* @brief ewol Texture loading system (header)
* @author Edouard DUPIN
* @date 28/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_TEXTURE_H__
#define __EWOL_TEXTURE_H__
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <etk/File.h>
namespace ewol
{
// TODO : Create a subNameSpace:
/*
namespace texture {
int32_t Load(etk::File fileName);
void UnLoad(uint32_t textureID);
int32_t GetSize(uint32_t textureID);
};
*/
namespace texture {
void Init(void);
void UnInit(void);
};
int32_t LoadTexture(etk::File fileName);
int32_t LoadTexture(int32_t target, int32_t level, int32_t internalFormat, int32_t width, int32_t height, int32_t border, int32_t format, int32_t type, const void* data, int32_t nbBytes, etk::UString filename);
void UnLoadTexture(uint32_t textureID);
int32_t GetTextureSize(uint32_t textureID);
uint32_t GetTextureGLID(uint32_t textureID);
void UpdateTextureContext(void);
void UpdateTextureContextIsDestroy(void);
void TextureOGLContext(bool enable);
};
#endif

View File

@ -0,0 +1,232 @@
/**
*******************************************************************************
* @file ewol/Widget.cpp
* @brief basic ewol Widget (Sources)
* @author Edouard DUPIN
* @date 18/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/Widget.h>
#include <ewol/EObjectManager.h>
#include <ewol/WidgetManager.h>
#include <ewol/ewol.h>
#include <ewol/importgl.h>
char* ewol::GetCharTypeMoveEvent(eventKbMoveType_te type)
{
char * returnValue = "?";
switch(type) {
case ewol::EVENT_KB_MOVE_TYPE_LEFT: returnValue = "LEFT"; break;
case ewol::EVENT_KB_MOVE_TYPE_RIGHT: returnValue = "RIGHT"; break;
case ewol::EVENT_KB_MOVE_TYPE_UP: returnValue = "UP"; break;
case ewol::EVENT_KB_MOVE_TYPE_DOWN: returnValue = "DOWN"; break;
case ewol::EVENT_KB_MOVE_TYPE_PAGE_UP: returnValue = "PAGE_UP"; break;
case ewol::EVENT_KB_MOVE_TYPE_PAGE_DOWN: returnValue = "PAGE_DOWN"; break;
case ewol::EVENT_KB_MOVE_TYPE_START: returnValue = "START"; break;
case ewol::EVENT_KB_MOVE_TYPE_END: returnValue = "END"; break;
case ewol::EVENT_KB_MOVE_TYPE_CENTER: returnValue = "CENTER"; break;
case ewol::EVENT_KB_MOVE_TYPE_ARRET_DEFIL: returnValue = "ARRET_DEFIL"; break;
case ewol::EVENT_KB_MOVE_TYPE_WAIT: returnValue = "WAIT"; break;
case ewol::EVENT_KB_MOVE_TYPE_INSERT: returnValue = "INSERT"; break;
case ewol::EVENT_KB_MOVE_TYPE_F1: returnValue = "F1"; break;
case ewol::EVENT_KB_MOVE_TYPE_F2: returnValue = "F2"; break;
case ewol::EVENT_KB_MOVE_TYPE_F3: returnValue = "F3"; break;
case ewol::EVENT_KB_MOVE_TYPE_F4: returnValue = "F4"; break;
case ewol::EVENT_KB_MOVE_TYPE_F5: returnValue = "F5"; break;
case ewol::EVENT_KB_MOVE_TYPE_F6: returnValue = "F6"; break;
case ewol::EVENT_KB_MOVE_TYPE_F7: returnValue = "F7"; break;
case ewol::EVENT_KB_MOVE_TYPE_F8: returnValue = "F8"; break;
case ewol::EVENT_KB_MOVE_TYPE_F9: returnValue = "F9"; break;
case ewol::EVENT_KB_MOVE_TYPE_F10: returnValue = "F10"; break;
case ewol::EVENT_KB_MOVE_TYPE_F11: returnValue = "F11"; break;
case ewol::EVENT_KB_MOVE_TYPE_F12: returnValue = "F12"; break;
case ewol::EVENT_KB_MOVE_TYPE_CAPLOCK: returnValue = "CAPLOCK"; break;
case ewol::EVENT_KB_MOVE_TYPE_SHIFT_LEFT: returnValue = "SHIFT_LEFT"; break;
case ewol::EVENT_KB_MOVE_TYPE_SHIFT_RIGHT: returnValue = "SHIFT_RIGHT"; break;
case ewol::EVENT_KB_MOVE_TYPE_CTRL_LEFT: returnValue = "CTRL_LEFT"; break;
case ewol::EVENT_KB_MOVE_TYPE_CTRL_RIGHT: returnValue = "CTRL_RIGHT"; break;
case ewol::EVENT_KB_MOVE_TYPE_META_LEFT: returnValue = "META_LEFT"; break;
case ewol::EVENT_KB_MOVE_TYPE_META_RIGHT: returnValue = "META_RIGHT"; break;
case ewol::EVENT_KB_MOVE_TYPE_ALT: returnValue = "ALT"; break;
case ewol::EVENT_KB_MOVE_TYPE_ALT_GR: returnValue = "ALT_GR"; break;
case ewol::EVENT_KB_MOVE_TYPE_CONTEXT_MENU: returnValue = "CONTEXT_MENU"; break;
case ewol::EVENT_KB_MOVE_TYPE_VER_NUM: returnValue = "VER_NUM"; break;
}
return returnValue;
}
#undef __class__
#define __class__ "Widget"
/**
* @brief Constructor of the widget classes
* @param ---
* @return (no execption generated (not managed in embended platform))
*/
ewol::Widget::Widget(void)
{
m_needRegenerateDisplay = true;
m_currentDrawId = 0;
m_currentCreateId = 1;
m_needFlipFlop = true;
m_origin.x = 0.0;
m_origin.y = 0.0;
m_size.x = 10.0;
m_size.y = 10.0;
m_minSize.x = -1.0;
m_minSize.y = -1.0;
// user settings :
m_userMinSize.x = -1.0;
m_userMinSize.y = -1.0;
SetExpendX();
SetExpendY();
SetFillX();
SetFillY();
m_canFocus = false;
m_hasFocus = false;
}
/**
* @brief This will be equivalent at the destructor @ref ~Widget
* @note this fuction "mark" the widget as removed an inform the widget manager that the widget has been removed by the user.
* @note All the EObject are inform that an other EObject is removed ... @ref ewol::EObject
* @param ---
* @return ---
*/
void ewol::Widget::MarkToRemove(void)
{
// Remove his own focus...
ewol::widgetManager::Rm(this);
// merk to remova at the next cycle
ewol::EObjectManager::MarkToRemoved(this);
}
/**
* @brief Parrent set the possible diplay size of the current widget whith his own possibilities
* By default this save the widget availlable size in the widget size
* @param[in] availlableX Availlable horisantal pixel size
* @param[in] availlableY Availlable vertical pixel size
* @return ---
*/
bool ewol::Widget::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
{
m_size.x = availlableX;
m_size.y = availlableY;
MarkToReedraw();
return true;
}
/**
* @brief Event generated to inform a flip-flop has occured on the current widget
* @param ---
* @return ---
*/
void ewol::Widget::OnFlipFlopEvent(void)
{
if (true == m_needFlipFlop) {
m_currentDrawId++;
if (NB_BOUBLE_BUFFER<=m_currentDrawId) {
m_currentDrawId = 0;
}
m_currentCreateId++;
if (NB_BOUBLE_BUFFER<=m_currentCreateId) {
m_currentCreateId = 0;
}
m_needFlipFlop = false;
}
}
/**
* @brief Set focus on this widget
* @param ---
* @return return true if the widget keep the focus
*/
bool ewol::Widget::SetFocus(void)
{
if (true == m_canFocus) {
m_hasFocus = true;
OnGetFocus();
return true;
}
return false;
}
/**
* @brief Remove the focus on this widget
* @param ---
* @return return true if the widget have release his focus (if he has it)
*/
bool ewol::Widget::RmFocus(void)
{
if (true == m_canFocus) {
m_hasFocus = false;
OnLostFocus();
return true;
}
return false;
}
/**
* @brief Set the capability to have the focus
* @param[in] canFocusState new focus capability
* @return ---
*/
void ewol::Widget::SetCanHaveFocus(bool canFocusState)
{
m_canFocus = canFocusState;
if (true == m_hasFocus) {
(void)RmFocus();
}
}
/**
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
* @param ---
* @return ---
*/
void ewol::Widget::GenDraw(void)
{
glPushMatrix();
// here we invert the reference of the standard OpenGl view because the reference in the common display is Top left and not buttom left
glViewport( m_origin.x,
ewol::GetCurrentHeight() - m_size.y - m_origin.y,
m_size.x,
m_size.y);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthoEwol(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1);
//glOrthoEwol(0., m_size.x, 0., -m_size.y, 1., 20.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
// Call the widget drawing methode
OnDraw();
glPopMatrix();
return;
}

View File

@ -0,0 +1,397 @@
/**
*******************************************************************************
* @file ewol/Widget.h
* @brief basic ewol Widget (header)
* @author Edouard DUPIN
* @date 18/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_WIDGET_H__
#define __EWOL_WIDGET_H__
#include <ewol/EObject.h>
#define NB_BOUBLE_BUFFER (2)
namespace ewol {
class Widget;
};
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/OObject.h>
#include <etk/VectorType.h>
namespace ewol {
typedef enum {
EVENT_INPUT_TYPE_DOWN,
EVENT_INPUT_TYPE_MOVE,
EVENT_INPUT_TYPE_SINGLE,
EVENT_INPUT_TYPE_DOUBLE,
EVENT_INPUT_TYPE_TRIPLE,
EVENT_INPUT_TYPE_UP,
EVENT_INPUT_TYPE_ENTER,
EVENT_INPUT_TYPE_LEAVE,
EVENT_INPUT_TYPE_ABORT, // SPecial event generate when an upper classes get an event ... (TBD)
} eventInputType_te;
typedef enum {
EVENT_KB_TYPE_DOWN,
EVENT_KB_TYPE_UP,
} eventKbType_te;
typedef enum {
EVENT_KB_MOVE_TYPE_LEFT,
EVENT_KB_MOVE_TYPE_RIGHT,
EVENT_KB_MOVE_TYPE_UP,
EVENT_KB_MOVE_TYPE_DOWN,
EVENT_KB_MOVE_TYPE_PAGE_UP,
EVENT_KB_MOVE_TYPE_PAGE_DOWN,
EVENT_KB_MOVE_TYPE_START,
EVENT_KB_MOVE_TYPE_END,
EVENT_KB_MOVE_TYPE_CENTER,
EVENT_KB_MOVE_TYPE_ARRET_DEFIL,
EVENT_KB_MOVE_TYPE_WAIT,
EVENT_KB_MOVE_TYPE_INSERT,
EVENT_KB_MOVE_TYPE_F1,
EVENT_KB_MOVE_TYPE_F2,
EVENT_KB_MOVE_TYPE_F3,
EVENT_KB_MOVE_TYPE_F4,
EVENT_KB_MOVE_TYPE_F5,
EVENT_KB_MOVE_TYPE_F6,
EVENT_KB_MOVE_TYPE_F7,
EVENT_KB_MOVE_TYPE_F8,
EVENT_KB_MOVE_TYPE_F9,
EVENT_KB_MOVE_TYPE_F10,
EVENT_KB_MOVE_TYPE_F11,
EVENT_KB_MOVE_TYPE_F12,
EVENT_KB_MOVE_TYPE_CAPLOCK,
EVENT_KB_MOVE_TYPE_SHIFT_LEFT,
EVENT_KB_MOVE_TYPE_SHIFT_RIGHT,
EVENT_KB_MOVE_TYPE_CTRL_LEFT,
EVENT_KB_MOVE_TYPE_CTRL_RIGHT,
EVENT_KB_MOVE_TYPE_META_LEFT,
EVENT_KB_MOVE_TYPE_META_RIGHT,
EVENT_KB_MOVE_TYPE_ALT,
EVENT_KB_MOVE_TYPE_ALT_GR,
EVENT_KB_MOVE_TYPE_CONTEXT_MENU,
EVENT_KB_MOVE_TYPE_VER_NUM,
} eventKbMoveType_te;
char* GetCharTypeMoveEvent(eventKbMoveType_te type);
class Widget : public EObject {
public:
/**
* @brief Constructor of the widget classes
* @param ---
* @return (no execption generated (not managed in embended platform))
*/
Widget(void);
/**
* @brief Destructor of the widget classes
* @note Use must never call this directly, when he will remove a widget he must call @ref MarkToRemove. This restriction is due to
* the internal system (one thread processing data, maybe one to regenerate the display(later) and one tha drawing on openGL)
* then when user want to remove a widget, it must be stored in the current pipe-line of ewol ...
* @param ---
* @return ---
*/
// TODO : Set this in private if possible ...
virtual ~Widget(void) { };
/**
* @brief This will be equivalent at the destructor @ref ~Widget
* @note this fuction "mark" the widget as removed an inform the widget manager that the widget has been removed by the user.
* @note All the EObject are inform that an other EObject is removed ... @ref ewol::EObject
* @param ---
* @return ---
*/
void MarkToRemove(void);
// ----------------------------------------------------------------------------------------------------------------
// -- Widget Size:
// ----------------------------------------------------------------------------------------------------------------
protected:
// internal element calculated by the system
coord2D_ts m_origin; //!< internal ... I do not really known how i can use it ...
coord2D_ts m_size; //!< internal : current size of the widget
coord2D_ts m_minSize; //!< user define the minimum size of the widget
// user configuaration
coord2D_ts m_userMinSize; //!< user define the minimum size of the widget
bool m_userExpendX;
bool m_userExpendY;
bool m_userFillX;
bool m_userFillY;
public:
/**
* @brief Set origin at the widget (must be an parrent widget that set this parameter).
* This represent the absolute origin in the program windows
* @param[in] x Position ot hte horizantal origin
* @param[in] y Position ot hte vertical origin
* @return ---
*/
void SetOrigin(etkFloat_t x, etkFloat_t y) { m_origin.x=x; m_origin.y=y;};
/**
* @brief Get the origin (obsolute position in the windows)
* @param ---
* @return coordonate of the origin requested
*/
coord2D_ts GetOrigin(void) { return m_origin; };
/**
* @brief Convert the absolute position in the local Position (Relative)
* @param[in] pos Absolute position that you request convertion
* @return the relative position
*/
coord2D_ts RelativePosition(coord2D_ts pos) { pos.x -= m_origin.x; pos.y -= m_origin.y; return pos; };
/**
* @brief Parrent set the possible diplay size of the current widget whith his own possibilities
* By default this save the widget availlable size in the widget size
* @param[in] availlableX Availlable horisantal pixel size
* @param[in] availlableY Availlable vertical pixel size
* @return ---
*/
// TODO : Remove bool ==> deprecated ...
// TODO : Rename in SetSize()
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY); // this generate the current size ...
//update the min Size ... and the expend parameters for the sizer
/**
* @brief Calculate the minimum size of the widget that is needed to display or the user requested)
* @param ---
* @return ---
*/
// TODO : Remove bool ==> deprecated ...
virtual bool CalculateMinSize(void) {m_minSize.x = m_userMinSize.x; m_minSize.y = m_userMinSize.y; MarkToReedraw(); return true; };
/**
* @brief User set the minimum size he want to set the display
* @param[in] x Set minimum horizontal size (-1 : no requested)
* @param[in] y Set minimum vertical size (-1 : no requested)
* @return ---
*/
virtual void SetMinSize(etkFloat_t x=-1, etkFloat_t y=-1) { m_userMinSize.x = x; m_userMinSize.y = y; };
/**
* @brief Get the current calculated min size
* @param ---
* @return re size requested
*/
coord2D_ts GetMinSize(void) { return m_minSize; };
/**
* @brief Get the widget size
* @param ---
* @return Requested size
*/
coord2D_ts GetSize(void) { return m_size; };
/**
* @brief Set the horizontal expend capacity
* @param[in] newExpend new Expend state
* @return ---
*/
virtual void SetExpendX(bool newExpend=false) { m_userExpendX = newExpend; };
/**
* @brief Get the horizontal expend capabilities
* @param ---
* @return boolean repensent the capacity to expend
*/
virtual bool CanExpentX(void) { return m_userExpendX; };
/**
* @brief Set the vertical expend capacity
* @param[in] newExpend new Expend state
* @return ---
*/
virtual void SetExpendY(bool newExpend=false) { m_userExpendY = newExpend; };
/**
* @brief Get the vertical expend capabilities
* @param ---
* @return boolean repensent the capacity to expend
*/
virtual bool CanExpentY(void) { return m_userExpendY; };
/**
* @brief Set the horizontal filling capacity
* @param[in] newFill new fill state
* @return ---
*/
virtual void SetFillX(bool newFill=false) { m_userFillX = newFill; };
/**
* @brief Get the horizontal filling capabilities
* @param ---
* @return boolean repensent the capacity to horizontal filling
*/
bool CanFillX(void) { return m_userFillX; };
/**
* @brief Set the vertical filling capacity
* @param[in] newFill new fill state
* @return ---
*/
virtual void SetFillY(bool newFill=false) { m_userFillY = newFill; };
/**
* @brief Get the vertical filling capabilities
* @param ---
* @return boolean repensent the capacity to vertical filling
*/
bool CanFillY(void) { return m_userFillY; };
// ----------------------------------------------------------------------------------------------------------------
// -- Focus Area
// ----------------------------------------------------------------------------------------------------------------
private:
bool m_hasFocus; //!< set the focus on this widget
bool m_canFocus; //!< the focus can be done on this widget
public:
/**
* @brief Get the focus state of the widget
* @param ---
* @return Focus state
*/
bool GetFocus(void) { return m_hasFocus;};
/**
* @brief Get the capability to have focus
* @param ---
* @return State capability to have focus
*/
bool CanHaveFocus(void) { return m_canFocus;};
/**
* @brief Set focus on this widget
* @param ---
* @return return true if the widget keep the focus
*/
bool SetFocus(void);
/**
* @brief Remove the focus on this widget
* @param ---
* @return return true if the widget have release his focus (if he has it)
*/
bool RmFocus(void);
/**
* @brief Set the capability to have the focus
* @param[in] canFocusState new focus capability
* @return ---
*/
void SetCanHaveFocus(bool canFocusState);
protected:
/**
* @brief Event of the focus has been grep by the current widget
* @param ---
* @return ---
*/
virtual void OnGetFocus(void) {};
/**
* @brief Event of the focus has been lost by the current widget
* @param ---
* @return ---
*/
virtual void OnLostFocus(void) {};
public:
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos) { return this; };
/**
* @brief Event on an input of this Widget
* @param[in] IdInput Id of the current Input (PC : left=1, right=2, middle=3, none=0 / Tactil : first finger=1 , second=2 (only on this widget, no knowledge at ouside finger))
* @param[in] typeEvent ewol type of event like EVENT_INPUT_TYPE_DOWN/EVENT_INPUT_TYPE_MOVE/EVENT_INPUT_TYPE_UP/EVENT_INPUT_TYPE_SINGLE/EVENT_INPUT_TYPE_DOUBLE/...
* @param[in] pos Absolute position of the event
* @return true the event is used
* @return false the event is not used
*/
virtual bool OnEventInput(int32_t IdInput, eventInputType_te typeEvent, coord2D_ts pos) { return false; };
/**
* @brief Event on a short-cut of this Widget (in case of return false, the event on the keyevent will arrive in the function @ref OnEventKb)
* @param[in] shift The key Shift (left or/and right) is pressed (if true)
* @param[in] control The key control (left or/and right) is pressed (if true)
* @param[in] alt The key Alt is pressed (if true)
* @param[in] meta The key Meta (windows key/Apple key) (left or/and right) is pressed (if true)
* @param[in] unicodeValue key pressed by the user
* @return true if the event has been used
* @return false if the event has not been used
*/
virtual bool OnEventShortCut(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue) { return false; };
/**
* @brief Event on the keybord (if no shortcut has been detected before).
* @param[in] type of the event (ewol::EVENT_KB_TYPE_DOWN or ewol::EVENT_KB_TYPE_UP)
* @param[in] unicodeValue key pressed by the user
* @return true if the event has been used
* @return false if the event has not been used
*/
virtual bool OnEventKb(eventKbType_te typeEvent, uniChar_t unicodeData) { return false; };
/**
* @brief Event on the keyboard that is not a printable key (if no shortcut has been detected before).
* @return true if the event has been used
* @return false if the event has not been used
*/
virtual bool OnEventKbMove(eventKbType_te typeEvent, eventKbMoveType_te moveTypeEvent) { return false; };
// ----------------------------------------------------------------------------------------------------------------
// -- Drawing : All drawing must be done in 2 separate buffer 1 for the current display and 1 for the working...
// ----------------------------------------------------------------------------------------------------------------
protected:
int8_t m_currentDrawId; //!< Id of the element that might be displayed by the Gui thread
int8_t m_currentCreateId; //!< Id of the element might be modify
bool m_needFlipFlop; //!< A flip flop need to be done
bool m_needRegenerateDisplay; //!< the display might be done the next regeneration
/**
* @brief The widget mark itself that it need to regenerate the nest time.
* @param ---
* @return ---
*/
void MarkToReedraw(void) { m_needRegenerateDisplay = true; };
/**
* @brief Get the need of the redrawing of the widget and reset it to false
* @param ---
* @return true if we need to redraw
* @return false if we have no need to redraw
*/
bool NeedRedraw(void) { bool tmpData=m_needRegenerateDisplay; m_needRegenerateDisplay=false; return tmpData; };
public:
/**
* @brief Event generated to inform a flip-flop has occured on the current widget
* @param ---
* @return ---
*/
virtual void OnFlipFlopEvent(void);
public:
/**
* @brief extern interface to request a draw ... (called by the drawing thread [Android, X11, ...])
* This function generate a clipping with the viewport openGL system. Like this a widget draw can not draw over an other widget
* @param ---
* @return ---
*/
void GenDraw(void);
protected:
/**
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
* @param ---
* @return ---
*/
virtual void OnDraw(void) { };
public:
/**
* @brief Event generated when a redraw is needed
* @param ---
* @return ---
*/
virtual void OnRegenerateDisplay(void) { };
}; // end of the class Widget declaration
};// end of namespace
#endif

View File

@ -0,0 +1,184 @@
/**
*******************************************************************************
* @file ewol/WidgetManager.cpp
* @brief basic ewol Widget Manager (Sources)
* @author Edouard DUPIN
* @date 13/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/WidgetManager.h>
#undef __class__
#define __class__ "WidgetManager"
static pthread_mutex_t localMutex;
static bool IsInit = false;
// For the focus Management
static ewol::Widget * m_focusWidgetDefault = NULL;
static ewol::Widget * m_focusWidgetCurrent = NULL;
void ewol::widgetManager::Init(void)
{
EWOL_DEBUG("==> Init Widget-Manager");
// create interface mutex :
int ret = pthread_mutex_init(&localMutex, NULL);
EWOL_ASSERT(ret == 0, "Error creating Mutex ...");
// prevent android error ==> can create memory leak but I prefer
m_focusWidgetDefault = NULL;
m_focusWidgetCurrent = NULL;
IsInit = true;
}
void ewol::widgetManager::UnInit(void)
{
EWOL_DEBUG("==> Un-Init Widget-Manager");
EWOL_INFO("Realease all FOCUS");
ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease();
IsInit = false;
int ret = pthread_mutex_destroy(&localMutex);
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
}
void ewol::widgetManager::Rm(ewol::Widget * newWidget)
{
FocusRemoveIfRemove(newWidget);
}
/* *************************************************************************
* Focus Area :
* *************************************************************************/
void ewol::widgetManager::FocusKeep(ewol::Widget * newWidget)
{
if (NULL == newWidget) {
// nothing to do ...
return;
}
if (false == newWidget->CanHaveFocus()) {
EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::Get(newWidget));
return;
}
if (newWidget == m_focusWidgetCurrent) {
// nothing to do ...
return;
}
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Rm Focus on WidgetID=" << m_focusWidgetCurrent->GetId() );
m_focusWidgetCurrent->RmFocus();
}
m_focusWidgetCurrent = newWidget;
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Set Focus on WidgetID=" << m_focusWidgetCurrent->GetId() );
m_focusWidgetCurrent->SetFocus();
}
}
void ewol::widgetManager::FocusSetDefault(ewol::Widget * newWidget)
{
if (NULL != newWidget && false == newWidget->CanHaveFocus()) {
EWOL_VERBOSE("Widget can not have Focus, id=" << newWidget->GetId() );
return;
}
if (m_focusWidgetDefault == m_focusWidgetCurrent) {
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Rm Focus on WidgetID=" << m_focusWidgetCurrent->GetId() );
m_focusWidgetCurrent->RmFocus();
}
m_focusWidgetCurrent = newWidget;
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Set Focus on WidgetID=" << m_focusWidgetCurrent->GetId() );
m_focusWidgetCurrent->SetFocus();
}
}
m_focusWidgetDefault = newWidget;
}
void ewol::widgetManager::FocusRelease(void)
{
if (m_focusWidgetDefault == m_focusWidgetCurrent) {
// nothink to do ...
return;
}
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Rm Focus on WidgetID=" << m_focusWidgetCurrent->GetId() );
m_focusWidgetCurrent->RmFocus();
}
m_focusWidgetCurrent = m_focusWidgetDefault;
if (NULL != m_focusWidgetCurrent) {
EWOL_DEBUG("Set Focus on WidgetID=" << m_focusWidgetCurrent->GetId() );
m_focusWidgetCurrent->SetFocus();
}
}
ewol::Widget * ewol::widgetManager::FocusGet(void)
{
return m_focusWidgetCurrent;
}
void ewol::widgetManager::FocusRemoveIfRemove(ewol::Widget * newWidget)
{
if (m_focusWidgetCurrent == newWidget) {
EWOL_WARNING("Release Focus when remove widget");
FocusRelease();
}
if (m_focusWidgetDefault == newWidget) {
EWOL_WARNING("Release default Focus when remove widget");
FocusSetDefault(NULL);
}
}
static bool needRedraw = true;
void ewol::widgetManager::DoubleBufferLock(void)
{
if (IsInit) {
pthread_mutex_lock(&localMutex);
}
}
void ewol::widgetManager::SetDoubleBufferNeedDraw(void)
{
needRedraw = true;
}
bool ewol::widgetManager::GetDoubleBufferNeedDraw(void)
{
if (true == needRedraw) {
needRedraw = false;
return true;
}
return false;
}
void ewol::widgetManager::DoubleBufferUnLock(void)
{
if (IsInit) {
pthread_mutex_unlock(&localMutex);
}
}

View File

@ -0,0 +1,58 @@
/**
*******************************************************************************
* @file ewol/WidgetManager.h
* @brief basic ewol Widget Manager (Header)
* @author Edouard DUPIN
* @date 13/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_WIDGET_MANAGER_H__
#define __EWOL_WIDGET_MANAGER_H__
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/OObject.h>
#include <etk/VectorType.h>
#include <ewol/Widget.h>
namespace ewol {
namespace widgetManager {
void Init( void);
void UnInit(void);
// need to call when remove a widget to clear all dependency of the focus system
void Rm( ewol::Widget * newWidget);
void FocusKeep( ewol::Widget * newWidget); // set the focus at the specific widget
void FocusSetDefault(ewol::Widget * newWidget); // select the default focus getter
void FocusRelease( void); // Release focus from the current widget to the default
ewol::Widget * FocusGet( void);
void FocusRemoveIfRemove(ewol::Widget * newWidget);
// TODO : Remove this from here ...
int32_t GetDoubleBufferCreate(void);
int32_t GetDoubleBufferDraw(void);
bool GetDoubleBufferNeedDraw(void);
void SetDoubleBufferNeedDraw(void);
void DoubleBufferLock(void);
void DoubleBufferUnLock(void);
};
};
#endif

View File

@ -0,0 +1,326 @@
/**
*******************************************************************************
* @file ewol/Windows.cpp
* @brief ewol window system (sources)
* @author Edouard DUPIN
* @date 20/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Types.h>
#include <etk/UString.h>
#include <ewol/Widget.h>
#include <ewol/Windows.h>
#include <ewol/OObject.h>
#include <ewol/Texture.h>
#include <ewol/Font.h>
#include <ewol/ewol.h>
#include <ewol/importgl.h>
#include <ewol/WidgetManager.h>
#undef __class__
#define __class__ "Windows"
//list of local events :
extern const char * const ewolEventWindowsHideKeyboard = "ewol Windows hideKeyboard";
ewol::Windows::Windows(void)
{
SetCanHaveFocus(true);
for(int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) {
m_subWidget[iii] = NULL;
}
m_keyBoardwidget = NULL;
SetDecorationDisable();
//KeyboardShow(KEYBOARD_MODE_CODE);
}
ewol::Windows::~Windows(void)
{
if (NULL != m_subWidget[m_currentCreateId]) {
m_subWidget[m_currentCreateId]->MarkToRemove();
m_subWidget[m_currentCreateId]=NULL;
}
for(int32_t iii=0; iii<m_popUpWidgetList[m_currentCreateId].Size(); iii++) {
if (NULL != m_popUpWidgetList[m_currentCreateId][iii]) {
m_popUpWidgetList[m_currentCreateId][iii]->MarkToRemove();
m_popUpWidgetList[m_currentCreateId][iii]=NULL;
}
}
m_popUpWidgetList[m_currentCreateId].Clear();
if (NULL != m_keyBoardwidget) {
m_keyBoardwidget->MarkToRemove();
m_keyBoardwidget=NULL;
}
}
bool ewol::Windows::CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY)
{
//EWOL_DEBUG("calculateMinSize on : " << m_currentCreateId);
m_size.x = availlableX;
m_size.y = availlableY;
int32_t keyboardHigh = 0;
if (NULL != m_keyBoardwidget && false == m_keyBoardwidget->IsHide() ) {
m_keyBoardwidget->CalculateMinSize();
coord2D_ts tmpSize = m_keyBoardwidget->GetMinSize();
keyboardHigh = (int32_t)tmpSize.y;
m_keyBoardwidget->SetOrigin(0, m_size.y - keyboardHigh);
m_keyBoardwidget->CalculateSize(m_size.x, keyboardHigh);
}
if (NULL != m_subWidget[m_currentCreateId]) {
m_subWidget[m_currentCreateId]->CalculateMinSize();
// TODO : Check if min Size is possible ...
// TODO : Herited from MinSize .. and expand ???
m_subWidget[m_currentCreateId]->CalculateSize(m_size.x, m_size.y - keyboardHigh);
}
for(int32_t iii=0; iii<m_popUpWidgetList[m_currentCreateId].Size(); iii++) {
if (NULL != m_popUpWidgetList[m_currentCreateId][iii]) {
m_popUpWidgetList[m_currentCreateId][iii]->CalculateMinSize();
m_popUpWidgetList[m_currentCreateId][iii]->CalculateSize(m_size.x, m_size.y - keyboardHigh);
}
}
return true;
}
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
ewol::Widget * ewol::Windows::GetWidgetAtPos(coord2D_ts pos)
{
// calculate relative position
coord2D_ts relativePos = RelativePosition(pos);
if (NULL != m_keyBoardwidget && false == m_keyBoardwidget->IsHide() ) {
coord2D_ts tmpSize = m_keyBoardwidget->GetMinSize();
if (relativePos.y > m_size.y - tmpSize.y) {
return m_keyBoardwidget->GetWidgetAtPos(pos);
}
}
// event go directly on the pop-up
if (0 < m_popUpWidgetList[m_currentCreateId].Size()) {
if (NULL == m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]) {
m_popUpWidgetList[m_currentCreateId].PopBack();
} else {
return m_popUpWidgetList[m_currentCreateId][m_popUpWidgetList[m_currentCreateId].Size()-1]->GetWidgetAtPos(pos);
}
// otherwise in the normal windows
} else if (NULL != m_subWidget[m_currentCreateId]) {
return m_subWidget[m_currentCreateId]->GetWidgetAtPos(pos);
}
// otherwise the event go to this widget ...
return this;
}
void ewol::Windows::SysDraw(void)
{
//EWOL_DEBUG("Drow on (" << m_size.x << "," << m_size.y << ")");
// set the size of the open GL system
glViewport(0,0,m_size.x,m_size.y);
/*
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrthoEwol(-m_size.x/2, m_size.x/2, m_size.y/2, -m_size.y/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-m_size.x/2, -m_size.y/2, -1.0);
#else
glOrtho(0., m_size.x, 0., -m_size.y, 1., 20.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, -m_size.y, -5);
#endif
*/
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
GenDraw();
glDisable(GL_BLEND);
return;
}
void ewol::Windows::OnRegenerateDisplay(void)
{
if (NULL != m_subWidget[m_currentCreateId]) {
m_subWidget[m_currentCreateId]->OnRegenerateDisplay();
}
for(int32_t iii=0; iii<m_popUpWidgetList[m_currentCreateId].Size(); iii++) {
if (NULL != m_popUpWidgetList[m_currentCreateId][iii]) {
m_popUpWidgetList[m_currentCreateId][iii]->OnRegenerateDisplay();
}
}
if (NULL != m_keyBoardwidget && false == m_keyBoardwidget->IsHide() ) {
m_keyBoardwidget->OnRegenerateDisplay();
}
}
void ewol::Windows::OnDraw(void)
{
// Clear the screen with transparency ...
glClearColor(0.750, 0.750, 0.750, 0.5);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//EWOL_WARNING(" WINDOWS draw on " << m_currentDrawId);
// first display the windows on the display
if (NULL != m_subWidget[m_currentDrawId]) {
m_subWidget[m_currentDrawId]->GenDraw();
//EWOL_DEBUG("Draw Windows");
}
// second display the pop-up
for(int32_t iii=0; iii<m_popUpWidgetList[m_currentDrawId].Size(); iii++) {
if (NULL != m_popUpWidgetList[m_currentDrawId][iii]) {
m_popUpWidgetList[m_currentDrawId][iii]->GenDraw();
//EWOL_DEBUG("Draw Pop-up");
}
}
if (NULL != m_keyBoardwidget && false == m_keyBoardwidget->IsHide() ) {
m_keyBoardwidget->GenDraw();
//EWOL_DEBUG("Draw kewboard");
}
}
void ewol::Windows::SetSubWidget(ewol::Widget * widget)
{
if (NULL != m_subWidget[m_currentCreateId]) {
EWOL_INFO("Remove current main windows Widget...");
m_subWidget[m_currentCreateId]->MarkToRemove();
m_subWidget[m_currentCreateId] = NULL;
}
m_subWidget[m_currentCreateId] = widget;
// Regenerate the size calculation :
CalculateSize(m_size.x, m_size.y);
m_needFlipFlop = true;
}
void ewol::Windows::PopUpWidgetPush(ewol::Widget * widget)
{
m_popUpWidgetList[m_currentCreateId].PushBack(widget);
// Regenerate the size calculation :
CalculateSize(m_size.x, m_size.y);
m_needFlipFlop = true;
}
void ewol::Windows::KeyboardShow(ewol::keyboardMode_te mode)
{
#if defined(__PLATFORM__Android)
if (NULL == m_keyBoardwidget) {
// Create the keyboard ...
m_keyBoardwidget = new ewol::Keyboard();
if (NULL == m_keyBoardwidget) {
EWOL_ERROR("Fail to initialize memory");
} else {
m_keyBoardwidget->ExternLinkOnEvent("ewol event Keyboard request hide", GetWidgetId(), ewolEventWindowsHideKeyboard );
m_keyBoardwidget->SetParrent(this);
}
}
if (NULL != m_keyBoardwidget) {
m_keyBoardwidget->Show();
}
CalculateSize(m_size.x, m_size.y);
#endif
}
void ewol::Windows::KeyboardHide(void)
{
EWOL_INFO("Request Hide keyboard");
if (NULL != m_keyBoardwidget) {
m_keyBoardwidget->Hide();
}
CalculateSize(m_size.x, m_size.y);
}
/**
* @brief Event generated to inform a flip-flop has occured on the current widget
* @param ---
* @return ---
*/
void ewol::Windows::OnFlipFlopEvent(void)
{
bool needFlipFlop = m_needFlipFlop;
// call herited classes
ewol::Widget::OnFlipFlopEvent();
// internal saving
if (true == needFlipFlop) {
m_subWidget[m_currentCreateId] = m_subWidget[m_currentDrawId];
m_popUpWidgetList[m_currentCreateId] = m_popUpWidgetList[m_currentDrawId];
}
// in every case, we propagate the flip-flop EVENT
if (NULL != m_subWidget[m_currentDrawId]) {
m_subWidget[m_currentDrawId]->OnFlipFlopEvent();
}
for(int32_t iii=0; iii<m_popUpWidgetList[m_currentDrawId].Size(); iii++) {
if(NULL != m_popUpWidgetList[m_currentDrawId][iii]) {
m_popUpWidgetList[m_currentDrawId][iii]->OnFlipFlopEvent();
}
}
}
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void ewol::Windows::OnObjectRemove(ewol::EObject * removeObject)
{
// First step call parrent :
ewol::Widget::OnObjectRemove(removeObject);
// second step find if in all the elements ...
if (m_subWidget[m_currentCreateId] == removeObject) {
EWOL_DEBUG("Remove main element of the windows ==> destroyed object");
m_subWidget[m_currentCreateId] = NULL;
m_needFlipFlop = true;
}
for(int32_t iii=m_popUpWidgetList[m_currentCreateId].Size()-1; iii>=0; iii--) {
if(m_popUpWidgetList[m_currentCreateId][iii] == removeObject) {
EWOL_DEBUG("Remove Pop-up [" << iii << "] element of the windows ==> destroyed object");
m_popUpWidgetList[m_currentCreateId][iii] = NULL;
m_popUpWidgetList[m_currentCreateId].Erase(iii);
m_needFlipFlop = true;
}
}
if (m_keyBoardwidget == removeObject) {
EWOL_DEBUG("Remove Keyboard element of the windows ==> destroyed object");
m_keyBoardwidget = NULL;
m_needFlipFlop = true;
}
}

View File

@ -0,0 +1,106 @@
/**
*******************************************************************************
* @file ewol/Windows.h
* @brief ewol window system (header)
* @author Edouard DUPIN
* @date 20/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_WINDOWS_H__
#define __EWOL_WINDOWS_H__
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <etk/VectorType.h>
#include <ewol/Widget.h>
#include <ewol/widgetMeta/Keyboard.h>
namespace ewol {
class Windows :public ewol::Widget
{
public:
Windows(void);
virtual ~Windows(void);
// internal event at ewol system :
public:
void SysDraw(void);
void SysOnShow(void) {};
void SysOnHide(void) {};
void SysOnKill(void) {};
public:
virtual void OnShow(void) { };
virtual void OnHide(void) { };
virtual bool OnKill(void) { return true; };
virtual void OnReduce(void) { };
virtual void On(void) { };
public:
virtual bool CalculateSize(etkFloat_t availlableX, etkFloat_t availlableY);
/**
* @brief Get the widget at the specific windows absolute position
* @param[in] pos gAbsolute position of the requested widget knowledge
* @return NULL No widget found
* @return pointer on the widget found
*/
virtual ewol::Widget * GetWidgetAtPos(coord2D_ts pos);
private:
bool m_hasDecoration;
public:
void SetDecorationDisable(void)
{
m_hasDecoration = false;
}
void SetDecorationEnable(void)
{
m_hasDecoration = true;
}
private:
ewol::Widget* m_subWidget[NB_BOUBLE_BUFFER];
etk::VectorType<ewol::Widget*> m_popUpWidgetList[NB_BOUBLE_BUFFER];
// TODO : Add flip flop ...
ewol::Keyboard* m_keyBoardwidget;
public:
void SetSubWidget(ewol::Widget * widget);
void PopUpWidgetPush(ewol::Widget * widget);
protected:
virtual void OnDraw(void);
public:
virtual void OnRegenerateDisplay(void);
public:
void KeyboardShow(ewol::keyboardMode_te mode);
void KeyboardHide(void);
/**
* @brief Event generated to inform a flip-flop has occured on the current widget
* @param ---
* @return ---
*/
virtual void OnFlipFlopEvent(void);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
virtual void OnObjectRemove(ewol::EObject * removeObject);
};
};
#endif

View File

@ -0,0 +1,344 @@
/**
*******************************************************************************
* @file MainThread.cpp
* @brief Main Ewol thread for the abstraction of the OS problematics (Sources)
* @author Edouard DUPIN
* @date 27/01/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <etk/Types.h>
#include <ewol/ewol.h>
#include <ewol/Debug.h>
#include <ewol/threadMsg.h>
#include <ewol/base/MainThread.h>
#include <ewol/base/gui.h>
#include <ewol/Texture.h>
#include <ewol/EObject.h>
#include <ewol/EObjectManager.h>
#include <ewol/WidgetManager.h>
#include <ewol/themeManager.h>
#include <ewol/ShortCutManager.h>
#include <ewol/base/eventInputManagement.h>
static ewol::threadMsg::threadMsg_ts androidJniMsg;
static pthread_t androidJniThread;
static pthread_attr_t androidJniThreadAttr;
enum {
THREAD_INIT,
THREAD_UN_INIT,
THREAD_RESIZE,
THREAD_HIDE,
THREAD_SHOW,
THREAD_INPUT_MOTION,
THREAD_INPUT_STATE,
THREAD_KEYBORAD_KEY,
THREAD_KEYBORAD_MOVE,
THREAD_JUST_DISPLAY,
};
#include <unistd.h>
typedef struct {
int w;
int h;
} eventResize_ts;
typedef struct {
int pointerID;
float x;
float y;
} eventInputMotion_ts;
typedef struct {
int pointerID;
bool state;
float x;
float y;
} eventInputState_ts;
void EWOL_NativeResize(int w, int h );
void EWOL_NativeRegenerateDisplay(void);
static void* BaseAppEntry(void* param)
{
bool requestEndProcessing = false;
EWOL_DEBUG("==> Init BThread (START)");
EWOL_INFO("v" EWOL_VERSION_TAG_NAME);
EWOL_INFO("Build Date: " VERSION_BUILD_TIME);
/*
struct sched_param pr;
int ret = 9;
int policy;
pthread_getschedparam(pthread_self(), &policy, &pr);
EWOL_INFO("Child Thread Up PL" << policy << " PRI" << pr.sched_priority); //The result here
policy = SCHED_RR;
pr.sched_priority = 19;
pthread_setschedparam(pthread_self(), policy, &pr);
sleep(1);
pthread_getschedparam(pthread_self(), &policy, &pr);
EWOL_INFO("Child Thread Up PL" << policy << " PRI" << pr.sched_priority); //The result Set
*/
ewol::EObjectManager::Init();
ewol::EObjectMessageMultiCast::Init();
ewol::eventInput::Init();
ewol::widgetManager::Init();
ewol::texture::Init();
ewol::theme::Init();
ewol::InitFont();
ewol::shortCut::Init();
APP_Init();
int32_t countNbEvent = 0;
EWOL_DEBUG("==> Init BThread (END)");
while(false == requestEndProcessing) {
ewol::threadMsg::threadMsgContent_ts data;
ewol::threadMsg::WaitMessage(androidJniMsg, data);
if (data.type != THREAD_JUST_DISPLAY) {
countNbEvent++;
//EWOL_DEBUG("EVENT");
switch (data.type) {
case THREAD_INIT:
EWOL_DEBUG("Receive MSG : THREAD_INIT");
break;
case THREAD_UN_INIT:
EWOL_DEBUG("Receive MSG : THREAD_UN_INIT");
requestEndProcessing = true;
break;
case THREAD_RESIZE:
//EWOL_DEBUG("Receive MSG : THREAD_RESIZE");
{
eventResize_ts * tmpData = (eventResize_ts*)data.data;
EWOL_NativeResize(tmpData->w, tmpData->h);
}
break;
case THREAD_INPUT_MOTION:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_MOTION");
{
eventInputMotion_ts * tmpData = (eventInputMotion_ts*)data.data;
coord2D_ts pos;
pos.x = tmpData->x;
pos.y = tmpData->y;
ewol::eventInput::Motion(tmpData->pointerID, pos);
}
break;
case THREAD_INPUT_STATE:
//EWOL_DEBUG("Receive MSG : THREAD_INPUT_STATE");
{
eventInputState_ts * tmpData = (eventInputState_ts*)data.data;
coord2D_ts pos;
pos.x = tmpData->x;
pos.y = tmpData->y;
ewol::eventInput::State(tmpData->pointerID, tmpData->state, pos);
}
break;
case THREAD_KEYBORAD_KEY:
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_KEY");
{
eventKeyboardKey_ts * tmpData = (eventKeyboardKey_ts*)data.data;
if (false==ewol::shortCut::Process(tmpData->special.shift, tmpData->special.ctrl, tmpData->special.alt, tmpData->special.meta, tmpData->myChar, tmpData->isDown)) {
guiAbstraction::SendKeyboardEvent(tmpData->isDown, tmpData->myChar);
}
}
break;
case THREAD_KEYBORAD_MOVE:
//EWOL_DEBUG("Receive MSG : THREAD_KEYBORAD_MOVE");
{
eventKeyboardMove_ts * tmpData = (eventKeyboardMove_ts*)data.data;
guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
}
break;
case THREAD_HIDE:
EWOL_DEBUG("Receive MSG : THREAD_HIDE");
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
//gui_uniqueWindows->SysOnHide();
break;
case THREAD_SHOW:
EWOL_DEBUG("Receive MSG : THREAD_SHOW");
//guiAbstraction::SendKeyboardEventMove(tmpData->isDown, tmpData->move);
//gui_uniqueWindows->SysOnShow();
break;
default:
EWOL_DEBUG("Receive MSG : UNKNOW");
break;
}
}
if (0 == ewol::threadMsg::WaitingMessage(androidJniMsg)) {
if (countNbEvent > 0) {
EWOL_NativeRegenerateDisplay();
countNbEvent = 0;
}
}
}
EWOL_DEBUG("==> Un-Init BThread (START)");
// unset all windows
ewol::DisplayWindows(NULL);
// call application to uninit
APP_UnInit();
ewol::shortCut::UnInit();
ewol::texture::UnInit();
ewol::UnInitFont();
ewol::widgetManager::UnInit();
ewol::EObjectMessageMultiCast::UnInit();
ewol::EObjectManager::UnInit();
ewol::theme::UnInit();
ewol::eventInput::UnInit();
EWOL_DEBUG("==> Un-Init BThread (END)");
pthread_exit(NULL);
}
void EWOL_ThreadSetArchiveDir(int mode, const char* str)
{
switch(mode)
{
case 0:
EWOL_DEBUG("Directory APK : path=" << str);
etk::SetBaseFolderData(str);
break;
case 1:
EWOL_DEBUG("Directory mode=FILE path=" << str);
etk::SetBaseFolderDataUser(str);
break;
case 2:
EWOL_DEBUG("Directory mode=CACHE path=" << str);
etk::SetBaseFolderCache(str);
break;
case 3:
EWOL_DEBUG("Directory mode=EXTERNAL_CACHE path=" << str);
break;
default:
EWOL_DEBUG("Directory mode=???? path=" << str);
break;
}
}
bool isGlobalSystemInit = false;
void EWOL_SystemStart(void)
{
if (false == isGlobalSystemInit) {
// create interface mutex :
EWOL_DEBUG("Init thread message system");
ewol::threadMsg::Init(androidJniMsg);
// init the thread :
EWOL_DEBUG("Create the thread");
pthread_attr_init(&androidJniThreadAttr);
pthread_attr_setdetachstate(&androidJniThreadAttr, PTHREAD_CREATE_JOINABLE);
//pthread_attr_setdetachstate(&androidJniThreadAttr, PTHREAD_CREATE_DETACHED);
//pthread_attr_setscope( &androidJniThreadAttr, PTHREAD_SCOPE_SYSTEM);
/* // note android does not permit to change the thread priority ...
// try to set prio :
struct sched_param pr;
pr.sched_priority = 10;
pthread_attr_setschedpolicy(&androidJniThreadAttr, SCHED_RR);
pthread_attr_setschedparam(&androidJniThreadAttr, &pr);
*/
pthread_setname_np(androidJniThread, "ewol_basic_thread");
pthread_create(&androidJniThread, &androidJniThreadAttr, BaseAppEntry, NULL);
//pthread_create(&androidJniThread, NULL, BaseAppEntry, NULL);
isGlobalSystemInit = true;
EWOL_DEBUG("Send Init message to the thread");
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
EWOL_DEBUG("end basic init");
}
}
void EWOL_SystemStop(void)
{
if (true == isGlobalSystemInit) {
isGlobalSystemInit = false;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_UN_INIT, ewol::threadMsg::MSG_PRIO_REAL_TIME);
EWOL_DEBUG("Wait end of the thread ...");
// Wait end of the thread
pthread_join(androidJniThread, NULL);
ewol::threadMsg::UnInit(androidJniMsg);
}
}
void EWOL_ThreadResize(int w, int h )
{
eventResize_ts tmpData;
tmpData.w = w;
tmpData.h = h;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_RESIZE, ewol::threadMsg::MSG_PRIO_MEDIUM, &tmpData, sizeof(eventResize_ts) );
}
void EWOL_ThreadEventInputMotion(int pointerID, float x, float y )
{
eventInputMotion_ts tmpData;
tmpData.pointerID = pointerID;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_MOTION, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputMotion_ts) );
}
void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y )
{
eventInputState_ts tmpData;
tmpData.pointerID = pointerID;
tmpData.state = isUp;
tmpData.x = x;
tmpData.y = y;
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_INPUT_STATE, ewol::threadMsg::MSG_PRIO_LOW, &tmpData, sizeof(eventInputState_ts) );
}
void EWOL_ThreadKeyboardEvent(eventKeyboardKey_ts& keyInput)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_KEY, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(eventKeyboardKey_ts) );
}
void EWOL_ThreadKeyboardEventMove(eventKeyboardMove_ts& keyInput)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_KEYBORAD_MOVE, ewol::threadMsg::MSG_PRIO_LOW, &keyInput, sizeof(eventKeyboardMove_ts) );
}
void EWOL_ThreadEventHide(void)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_HIDE, ewol::threadMsg::MSG_PRIO_LOW);
}
void EWOL_ThreadEventShow(void)
{
ewol::threadMsg::SendMessage(androidJniMsg, THREAD_SHOW, ewol::threadMsg::MSG_PRIO_LOW);
}
void EWOL_ThreadEventHasJustDisplay(void)
{
ewol::threadMsg::SendDisplayDone(androidJniMsg);
//ewol::threadMsg::SendMessage(androidJniMsg, THREAD_JUST_DISPLAY, ewol::threadMsg::MSG_PRIO_REAL_TIME);
}

View File

@ -0,0 +1,75 @@
/**
*******************************************************************************
* @file MainThread.h
* @brief Main Ewol thread for the abstraction of the OS problematics (Header)
* @author Edouard DUPIN
* @date 27/01/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*O
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_MAIN_TREAD_H__
#define __EWOL_MAIN_TREAD_H__
#include <pthread.h>
void EWOL_SystemStart(void);
void EWOL_SystemStop(void);
void EWOL_ThreadSetArchiveDir(int mode, const char* str);
void EWOL_ThreadResize(int w, int h );
void EWOL_ThreadEventInputMotion(int pointerID, float x, float y);
void EWOL_ThreadEventInputState(int pointerID, bool isUp, float x, float y);
typedef struct {
bool capLock;
bool shift;
bool ctrl;
bool meta;
bool alt;
bool altGr;
bool verNum;
bool insert;
} eventSpecialKey_ts;
typedef struct {
bool isDown;
uniChar_t myChar;
eventSpecialKey_ts special;
} eventKeyboardKey_ts;
typedef struct {
bool isDown;
ewol::eventKbMoveType_te move;
eventSpecialKey_ts special;
} eventKeyboardMove_ts;
void EWOL_ThreadKeyboardEvent(eventKeyboardKey_ts& keyInput);
void EWOL_ThreadKeyboardEventMove(eventKeyboardMove_ts& keyInput);
void EWOL_ThreadEventHide(void);
void EWOL_ThreadEventShow(void);
void EWOL_ThreadEventHasJustDisplay(void);
#endif

View File

@ -0,0 +1,281 @@
#include <etk/Types.h>
#include <ewol/Debug.h>
#include <ewol/OObject.h>
#include <ewol/Widget.h>
#include <ewol/Windows.h>
#include <ewol/base/gui.h>
#include <ewol/Debug.h>
#include <etk/UString.h>
#include <ewol/EObject.h>
#include <ewol/EObjectManager.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
#include <ewol/ewol.h>
#include <ewol/Texture.h>
#include <ewol/base/MainThread.h>
#include <ewol/base/eventInputManagement.h>
typedef struct {
bool isUsed;
int32_t destinationInputId;
int64_t lastTimeEvent;
ewol::Widget* curentWidgetEvent;
coord2D_ts origin;
coord2D_ts size;
coord2D_ts downStart;
bool isDown;
bool isInside;
int32_t nbClickEvent; // 0 .. 1 .. 2 .. 3
} InputPoperty_ts;
#define MAX_MANAGE_INPUT (10)
InputPoperty_ts eventInputSaved[MAX_MANAGE_INPUT];
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject removed ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void ewol::eventInput::OnObjectRemove(ewol::EObject * removeObject)
{
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
if (eventInputSaved[iii].curentWidgetEvent == removeObject) {
eventInputSaved[iii].curentWidgetEvent = NULL;
}
}
}
static void CleanInputElement(int32_t idInput)
{
eventInputSaved[idInput].isUsed = false;
eventInputSaved[idInput].destinationInputId = 0;
eventInputSaved[idInput].lastTimeEvent = 0;
eventInputSaved[idInput].curentWidgetEvent = NULL;
eventInputSaved[idInput].origin.x = 0;
eventInputSaved[idInput].origin.y = 0;
eventInputSaved[idInput].size.x = 99999999;
eventInputSaved[idInput].size.y = 99999999;
eventInputSaved[idInput].downStart.x = 0;
eventInputSaved[idInput].downStart.y = 0;
eventInputSaved[idInput].isDown = false;
eventInputSaved[idInput].isInside = true;
eventInputSaved[idInput].nbClickEvent = 0;
}
void ewol::eventInput::Init(void)
{
EWOL_INFO("Init");
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
eventInputSaved[iii].isUsed = false;
eventInputSaved[iii].destinationInputId = 0;
eventInputSaved[iii].lastTimeEvent = 0;
eventInputSaved[iii].curentWidgetEvent = NULL;
eventInputSaved[iii].origin.x = 0;
eventInputSaved[iii].origin.y = 0;
eventInputSaved[iii].size.x = 99999999;
eventInputSaved[iii].size.y = 99999999;
eventInputSaved[iii].downStart.x = 0;
eventInputSaved[iii].downStart.y = 0;
eventInputSaved[iii].isDown = false;
eventInputSaved[iii].isInside = true;
eventInputSaved[iii].nbClickEvent = 0;
}
}
void ewol::eventInput::UnInit(void)
{
EWOL_INFO("Un-Init");
}
extern ewol::Windows* gui_uniqueWindows;
static bool localEventInput(ewol::Widget* destWidget, int32_t IdInput, ewol::eventInputType_te typeEvent, coord2D_ts pos)
{
if (NULL != destWidget) {
return destWidget->OnEventInput(IdInput, typeEvent, pos);
}
return false;
}
/**
* @brief Convert the system event id in the correct EWOL id depending of the system management mode
*
* This function find the next input id unused on the specifiic widget ==> on PC, the ID does not change (IHM is not the same
*
* @param[in] destWidget Pointer of the widget destination
* @param[in] realInputId System Id
*
* @return the ewol input id
*/
static int32_t localGetDestinationId(ewol::Widget* destWidget, int32_t realInputId)
{
#ifdef __MODE__Touch
int32_t lastMinimum = 0;
for(int32_t iii=0; iii<MAX_MANAGE_INPUT; iii++) {
if (true==eventInputSaved[iii].isUsed) {
if (eventInputSaved[iii].curentWidgetEvent == destWidget) {
if (iii != realInputId) {
lastMinimum = etk_max(lastMinimum, eventInputSaved[iii].destinationInputId);
}
}
}
}
return lastMinimum+1;
#else
return realInputId;
#endif
}
// defined by the platform specific file :
extern int32_t separateClickTime;
extern int32_t offsetMoveClicked;
extern int32_t offsetMoveClickedDouble;
void ewol::eventInput::Motion(int pointerID, coord2D_ts pos)
{
if( pointerID > MAX_MANAGE_INPUT
|| pointerID <= 0) {
// not manage input
return;
}
if (true == eventInputSaved[pointerID].isUsed) {
if (true == eventInputSaved[pointerID].isInside) {
if( eventInputSaved[pointerID].origin.x > pos.x
|| eventInputSaved[pointerID].origin.y > pos.y
|| (eventInputSaved[pointerID].origin.x + eventInputSaved[pointerID].size.x) < pos.x
|| (eventInputSaved[pointerID].origin.y + eventInputSaved[pointerID].size.y) < pos.y) {
eventInputSaved[pointerID].isInside = false;
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [LEAVE] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, eventInputSaved[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_LEAVE, pos);
}
} else {
if( ( eventInputSaved[pointerID].origin.x <= pos.x
&& (eventInputSaved[pointerID].origin.x + eventInputSaved[pointerID].size.x) >= pos.x )
&& ( eventInputSaved[pointerID].origin.y <= pos.y
&& (eventInputSaved[pointerID].origin.y + eventInputSaved[pointerID].size.y) >= pos.y ) ) {
eventInputSaved[pointerID].isInside = true;
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [ENTER] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, eventInputSaved[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_ENTER, pos);
}
}
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [MOVE] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, eventInputSaved[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_MOVE, pos);
}
}
void ewol::eventInput::State(int pointerID, bool isDown, coord2D_ts pos)
{
if( pointerID > MAX_MANAGE_INPUT
|| pointerID <= 0) {
// not manage input
return;
}
// get the curent time ...
int64_t currentTime = GetCurrentTime();
if (true == isDown) {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [DOWN] " << pos);
if(true == eventInputSaved[pointerID].isUsed) {
// we have an event previously ... check delay between click and offset position
if (currentTime - eventInputSaved[pointerID].lastTimeEvent > separateClickTime) {
CleanInputElement(pointerID);
} else if( abs(eventInputSaved[pointerID].downStart.x - pos.x) >= offsetMoveClicked
|| abs(eventInputSaved[pointerID].downStart.y - pos.y) >= offsetMoveClicked ){
CleanInputElement(pointerID);
}
}
if(true == eventInputSaved[pointerID].isUsed) {
// save start time
eventInputSaved[pointerID].lastTimeEvent = currentTime;
// generate DOWN Event
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [DOWN] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, eventInputSaved[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_DOWN, pos);
} else {
// Mark it used :
eventInputSaved[pointerID].isUsed = true;
// Save current position :
eventInputSaved[pointerID].downStart = pos;
// save start time
eventInputSaved[pointerID].lastTimeEvent = currentTime;
// Set the element inside ...
eventInputSaved[pointerID].isInside = true;
// get destination widget :
if(NULL != gui_uniqueWindows) {
eventInputSaved[pointerID].curentWidgetEvent = gui_uniqueWindows->GetWidgetAtPos(pos);
} else {
eventInputSaved[pointerID].curentWidgetEvent = NULL;
}
if (NULL != eventInputSaved[pointerID].curentWidgetEvent) {
eventInputSaved[pointerID].origin = eventInputSaved[pointerID].curentWidgetEvent->GetOrigin();
eventInputSaved[pointerID].size = eventInputSaved[pointerID].curentWidgetEvent->GetSize();
eventInputSaved[pointerID].destinationInputId = localGetDestinationId(eventInputSaved[pointerID].curentWidgetEvent, pointerID);
} else {
eventInputSaved[pointerID].destinationInputId = -1;
}
// generate DOWN Event
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [DOWN] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, eventInputSaved[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_DOWN, pos);
}
} else {
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [UP] " << pos);
if(false == eventInputSaved[pointerID].isUsed) {
// bad case ... ???
EWOL_VERBOSE("Up event without previous down ... ");
// Mark it un-used :
eventInputSaved[pointerID].isUsed = false;
// revove the widget ...
eventInputSaved[pointerID].curentWidgetEvent = NULL;
} else {
// generate UP Event
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [UP] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, pointerID, ewol::EVENT_INPUT_TYPE_UP, pos);
// generate event (single)
if( abs(eventInputSaved[pointerID].downStart.x - pos.x) < offsetMoveClicked
&& abs(eventInputSaved[pointerID].downStart.y - pos.y) < offsetMoveClicked ){
// Save current position :
eventInputSaved[pointerID].downStart = pos;
// save start time
eventInputSaved[pointerID].lastTimeEvent = currentTime;
if (eventInputSaved[pointerID].nbClickEvent == 0) {
// generate event SINGLE :
eventInputSaved[pointerID].nbClickEvent++;
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [SINGLE] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, eventInputSaved[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_SINGLE, pos);
} else if (eventInputSaved[pointerID].nbClickEvent == 1) {
// generate event DOUBLE :
eventInputSaved[pointerID].nbClickEvent++;
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [DOUBLE] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, eventInputSaved[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_DOUBLE, pos);
} else if (eventInputSaved[pointerID].nbClickEvent == 2) {
// generate event TRIPLE :
eventInputSaved[pointerID].nbClickEvent++;
EWOL_VERBOSE("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [TRIPLE] " << pos);
localEventInput(eventInputSaved[pointerID].curentWidgetEvent, eventInputSaved[pointerID].destinationInputId, ewol::EVENT_INPUT_TYPE_TRIPLE, pos);
} else {
#if 0
eventInputSaved[pointerID].nbClickEvent++;
EWOL_DEBUG("GUI : Input ID=" << pointerID << "==>" << eventInputSaved[pointerID].destinationInputId << " [" << eventInputSaved[pointerID].nbClickEvent <<"] (" << pos.x << "," << pos.y << ")");
#else
eventInputSaved[pointerID].nbClickEvent = 0;
#endif
}
}
#ifdef __MODE__Touch
CleanInputElement(pointerID);
#endif
}
}
}

View File

@ -0,0 +1,28 @@
#ifndef __EWOL_EVENT_INPUT_MANAGEMENT_H__
#define __EWOL_EVENT_INPUT_MANAGEMENT_H__
namespace ewol
{
namespace eventInput
{
void Init(void);
void UnInit(void);
void Motion(int pointerID, coord2D_ts pos );
void State(int pointerID, bool isDown, coord2D_ts pos);
/**
* @brief Inform object that an other object is removed ...
* @param[in] removeObject Pointer on the EObject remeved ==> the user must remove all reference on this EObject
* @note : Sub classes must call this class
* @return ---
*/
void OnObjectRemove(ewol::EObject * removeObject);
}
}
#endif

View File

@ -0,0 +1,235 @@
/**
*******************************************************************************
* @file gui.cpp
* @brief Gui abstraction layer common part (Sources)
* @author Edouard DUPIN
* @date 01/02/2012
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/Debug.h>
#include <etk/UString.h>
#include <ewol/EObject.h>
#include <ewol/EObjectManager.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
#include <ewol/ewol.h>
#include <ewol/Texture.h>
#include <ewol/base/MainThread.h>
ewol::Windows* gui_uniqueWindows = NULL;
etkFloat_t gui_width = 320;
etkFloat_t gui_height = 480;
int32_t ewol::GetCurrentWidth(void)
{
return gui_width;
}
int32_t ewol::GetCurrentHeight(void)
{
return gui_height;
}
void ewol::PopUpWidgetPush(ewol::Widget * tmpWidget)
{
if (NULL != gui_uniqueWindows && NULL != tmpWidget) {
gui_uniqueWindows->PopUpWidgetPush(tmpWidget);
}
}
void EWOL_NativeResize(int w, int h )
{
gui_width = w;
gui_height = h;
//EWOL_INFO("Resize w=" << w << " h=" << h);
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->CalculateSize((etkFloat_t)gui_width, (etkFloat_t)gui_height);
gui_uniqueWindows->SetOrigin(0.0, 0.0);
}
}
void EWOL_NativeRegenerateDisplay(void)
{
//EWOL_INFO("Resize w=" << w << " h=" << h);
if (NULL != gui_uniqueWindows) {
// Redraw all needed elements
gui_uniqueWindows->OnRegenerateDisplay();
// Keep Inter-thread-lock-mutex
ewol::widgetManager::DoubleBufferLock();
// flip-flop all needed double-buffer in all widget
gui_uniqueWindows->OnFlipFlopEvent();
// Inform the main thread of openGl draw that somthing to display
ewol::widgetManager::SetDoubleBufferNeedDraw();
// Release Inter-thread-lock-mutex
ewol::widgetManager::DoubleBufferUnLock();
// Remove deprecated widget (which have no more reference in the system)
ewol::EObjectManager::RemoveAllMark();
}
}
void guiAbstraction::SetDisplayOnWindows(ewol::Windows * newWindows)
{
gui_uniqueWindows = newWindows;
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->CalculateSize((etkFloat_t)gui_width, (etkFloat_t)gui_height);
}
}
void guiAbstraction::ForceRedrawAll(void)
{
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->CalculateSize((etkFloat_t)gui_width, (etkFloat_t)gui_height);
}
}
void guiAbstraction::SendKeyboardEvent(bool isDown, uniChar_t keyInput)
{
// Get the current Focused Widget :
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
if (NULL != tmpWidget) {
if(true == isDown) {
EWOL_VERBOSE("GUI PRESSED : \"" << keyInput << "\"");
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_DOWN, keyInput);
} else {
EWOL_VERBOSE("GUI Release : \"" << keyInput << "\"");
tmpWidget->OnEventKb(ewol::EVENT_KB_TYPE_UP, keyInput);
}
}
}
void guiAbstraction::SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput)
{
// Get the current Focused Widget :
ewol::Widget * tmpWidget = ewol::widgetManager::FocusGet();
if (NULL != tmpWidget) {
if(true == isDown) {
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_DOWN, keyInput);
} else {
tmpWidget->OnEventKbMove(ewol::EVENT_KB_TYPE_UP, keyInput);
}
}
}
void guiAbstraction::KeyboardShow(ewol::keyboardMode_te mode)
{
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->KeyboardShow(mode);
}
}
void guiAbstraction::KeyboardHide(void)
{
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->KeyboardHide();
}
ForceRedrawAll();
}
static int64_t startTime = -1;
static int64_t nbCallTime = 0;
static int64_t nbDisplayTime = 0;
#define DISPLAY_PERIODE_MS (1000)
void EWOL_GenericDraw(bool everyTime)
{
bool display = false;
nbCallTime++;
if (startTime<0) {
startTime = GetCurrentTime();
}
int64_t currentTime = GetCurrentTime();
//EWOL_DEBUG("current : " << currentTime << "time diff : " << (currentTime - startTime));
if ( (currentTime - startTime) > DISPLAY_PERIODE_MS) {
display = true;
}
ewol::widgetManager::DoubleBufferLock();
if( true == ewol::widgetManager::GetDoubleBufferNeedDraw()
|| true == everyTime)
{
nbDisplayTime++;
gui_uniqueWindows->SysDraw();
//EWOL_WARNING("DRAW...");
}
ewol::widgetManager::DoubleBufferUnLock();
// send Message that we just finished a display ...
EWOL_ThreadEventHasJustDisplay();
if (true == display) {
EWOL_DEBUG("display property : " << (int32_t)((double)nbDisplayTime/(double)DISPLAY_PERIODE_MS*(double)1000) << "/" << (int32_t)((double)nbCallTime/(double)DISPLAY_PERIODE_MS*(double)1000) << "fps");
nbCallTime = 0;
nbDisplayTime = 0;
startTime = -1;
}
}
void EWOL_NativeGLDestroy(void)
{
ewol::UpdateTextureContextIsDestroy();
}
#include <ewol/importgl.h>
void glOrthoEwol(GLfloat left,
GLfloat right,
GLfloat bottom,
GLfloat top,
GLfloat nearVal,
GLfloat farVal)
{
GLfloat myMatrix[4*4];
int iii;
for(iii=0; iii<4*4 ; iii++) {
myMatrix[iii] = 0;
}
myMatrix[0] = 2.0 / (right - left);
myMatrix[5] = 2.0 / (top - bottom);
myMatrix[10] = -2.0 / (farVal - nearVal);
#if 1
myMatrix[3] = -1*(right + left) / (right - left);
myMatrix[7] = -1*(top + bottom) / (top - bottom);
myMatrix[11] = -1*(farVal + nearVal) / (farVal - nearVal);
#else
// test if matrix is not corectly instanciate ...
myMatrix[12] = -1*(right + left) / (right - left);
myMatrix[13] = -1*(top + bottom) / (top - bottom);
myMatrix[14] = -1*(farVal + nearVal) / (farVal - nearVal);
#endif
myMatrix[15] = 1;
glLoadMatrixf(myMatrix);
}

View File

@ -0,0 +1,59 @@
/**
*******************************************************************************
* @file gui.h
* @brief Gui abstraction layer (header)
* @author Edouard DUPIN
* @date 20/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __GUI_ABSTRACTION_H__
#define __GUI_ABSTRACTION_H__
#include <etk/Types.h>
#include <etk/UString.h>
#include <ewol/Windows.h>
void EWOL_NativeResize(int w, int h );
void EWOL_GenericDraw(bool everyTime);
void EWOL_NativeGLDestroy(void);
namespace guiAbstraction
{
void Stop(void);
void SetDisplayOnWindows(ewol::Windows * newOne);
void ChangeSize(int32_t w, int32_t h);
void ChangePos(int32_t x, int32_t y);
void GetAbsPos(int32_t & x, int32_t & y);
bool IsPressedInput(int32_t inputID);
void KeyboardShow(ewol::keyboardMode_te mode);
void KeyboardHide(void);
void ForceRedrawAll(void);
void SendKeyboardEvent(bool isDown, uniChar_t keyInput);
void SendKeyboardEventMove(bool isDown, ewol::eventKbMoveType_te &keyInput);
};
//!< must be define in CPP by the application ...
void APP_Init(void);
void APP_UnInit(void);
#define NB_MAX_INPUT (20)
#endif

View File

@ -0,0 +1,232 @@
/**
*******************************************************************************
* @file guiAndroid.cpp
* @brief Gui abstraction layer (Sources)
* @author Edouard DUPIN
* @date 20/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <jni.h>
#include <sys/time.h>
#include <time.h>
#include <android/log.h>
#include <stdint.h>
#include <ewol/Debug.h>
#include <etk/UString.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
#include <ewol/ewol.h>
#include <ewol/importgl.h>
#include <ewol/Texture.h>
#undef __class__
#define __class__ "AndroidJNI"
int32_t separateClickTime = 800;
int32_t offsetMoveClicked = 40;
int32_t offsetMoveClickedDouble = 300;
extern etkFloat_t gui_width;
extern etkFloat_t gui_height;
extern ewol::Windows* gui_uniqueWindows;
int64_t GetCurrentTime(void)
{
struct timeval now;
gettimeofday(&now, NULL);
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000 + (int64_t)now.tv_usec/(int64_t)1000);
}
void Draw(void);
#define OFFSET_MOVE_CLICKED (20)
#define OFFSET_MOVE_CLICKED_DOUBLE (40)
#undef SEPARATED_CLICK_TIME
#define SEPARATED_CLICK_TIME (300)
//bool inputIsPressed[NB_MAX_INPUT];// = {false, false, false};
int32_t m_previousBouttonId = -1;
int32_t m_previousDown_x = -1;
int32_t m_previousDown_y = -1;
int32_t m_previous_x = -1;
int32_t m_previous_y = -1;
int64_t m_previousTime = 0;
bool m_previousDouble = false;
static etkFloat_t gTriangleVertices[] = { 0.0f, 0.0f, 200.0f, 0.0f, 0.0f, 200.0f };
static etkFloat_t gTriangleVertices5[] = { 200.0f, 200.0f, 100.0f, 200.0f, 200.0f, 100.0f,
200.0f, 200.0f, 300.0f, 200.0f, 200.0f, 300.0f };
void EWOL_NativeRender(void)
{
ewol::UpdateTextureContext();
//EWOL_DEBUG("redraw (" << gui_width << "," << gui_height << ")");
if(NULL == gui_uniqueWindows) {
// set the size of the open GL system
glViewport(0,0,gui_width,gui_height);
// Clear the screen with transparency ...
glClearColor(0.0,0.0,0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
//glOrtho(0., width, 0., -height, 1., 20.);
glOrthoEwol(-gui_width/2, gui_width/2, gui_height/2, -gui_height/2, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//glTranslatef(0, -height/2, -5);
glTranslatef(-gui_width/2, -gui_height/2, -1.0);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_DST_ALPHA);
//glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);
glEnableClientState( GL_VERTEX_ARRAY );
//LOGI("engine_draw_frame (%d,%d)",width,height);
glColor4f(0.0, 1.0, 1.0, 1.0);
glVertexPointer(2, oglTypeFloat_t, 0, gTriangleVertices5 );
glDrawArrays( GL_TRIANGLES, 0, 6);
static int vallllll = 0;
static float transparency = 0.0;
if (vallllll <= 1) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 0.0, 0.0, 1.0);
} else {
glColor4f(1.0, 0.0, 0.0, transparency);
}
} else if (vallllll <= 2) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(1.0, 1.0, 0.0, 1.0);
} else {
glColor4f(1.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 3) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 0.0, 1.0);
} else {
glColor4f(0.0, 1.0, 0.0, transparency);
}
} else if (vallllll <= 4) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 1.0, 1.0, 1.0);
} else {
glColor4f(0.0, 1.0, 1.0, transparency);
}
} else if (vallllll <= 5) {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll++;
transparency = 0.0;
glColor4f(0.0, 0.0, 1.0, 1.0);
} else {
glColor4f(0.0, 0.0, 1.0, transparency);
}
} else {
transparency +=0.025;
if (transparency >= 1.0) {
vallllll = 0;
transparency = 0.0;
glColor4f(1.0, 0.0, 1.0, 1.0);
} else {
glColor4f(1.0, 0.0, 1.0, transparency);
}
}
glVertexPointer(2, oglTypeFloat_t, 0, gTriangleVertices );
glDrawArrays( GL_TRIANGLES, 0, 3);
glDisableClientState( GL_VERTEX_ARRAY );
glDisable(GL_BLEND);
} else {
EWOL_GenericDraw(true);
//EWOL_GenericDraw(false);
}
glFlush();
}
#undef __class__
#define __class__ "guiAbstraction"
void guiAbstraction::Stop(void)
{
// TODo : send a message to the android system to stop ...
}
void guiAbstraction::ChangeSize(int32_t w, int32_t h)
{
// nothing to do with Android
}
void guiAbstraction::ChangePos(int32_t x, int32_t y)
{
// nothing to do with Android
}
void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y)
{
}
bool guiAbstraction::IsPressedInput(int32_t inputID)
{
//if (true == guiAbstractionIsInit) {
// return myX11Access->IsPressedInput(inputID);
//} else {
// EWOL_CRITICAL("X11 ==> not init ... ");
return false;
//}
}
#include <ewol/ewol.h>
int32_t ewol::CmdLineNb(void)
{
return 0;
}
etk::UString ewol::CmdLineGet(int32_t id)
{
return "";
}

View File

@ -0,0 +1,46 @@
/**
*******************************************************************************
* @file guiDoubleBuffer.cpp
* @brief Gui abstraction layer (Sources)
* @author Edouard DUPIN
* @date 20/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/Debug.h>
#include <base/guiDoubleBuffer.h>
#undef __class__
#define __class__ "guiAbstraction"
void guiAbstraction::Init(int32_t argc, char *argv[])
{
EWOL_INFO("INIT for DoubleBuffer environement");
}
void guiAbstraction::Run(void)
{
EWOL_INFO("Start Running");
EWOL_INFO("Stop Running");
}
void guiAbstraction::UnInit(void)
{
EWOL_INFO("UN-INIT for DoubleBuffer environement");
}

View File

@ -0,0 +1,46 @@
/**
*******************************************************************************
* @file guiIPhone.cpp
* @brief Gui abstraction layer (Sources)
* @author Edouard DUPIN
* @date 20/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/Debug.h>
#include <base/guiIPhone.h>
#undef __class__
#define __class__ "guiAbstraction"
void guiAbstraction::Init(int32_t argc, char *argv[])
{
EWOL_INFO("INIT for IPhone environement");
}
void guiAbstraction::Run(void)
{
EWOL_INFO("Start Running");
EWOL_INFO("Stop Running");
}
void guiAbstraction::UnInit(void)
{
EWOL_INFO("UN-INIT for IPhone environement");
}

View File

@ -0,0 +1,765 @@
/**
*******************************************************************************
* @file guiX11.cpp
* @brief Gui abstraction layer (Sources)
* @author Edouard DUPIN
* @date 20/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/Debug.h>
#include <etk/UString.h>
#include <etk/unicode.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
#include <ewol/Texture.h>
#include <ewol/base/MainThread.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <GL/glx.h>
#include <X11/Xatom.h>
#include <sys/times.h>
int64_t GetCurrentTime(void)
{
struct timespec now;
int ret = clock_gettime(CLOCK_REALTIME, &now);
if (ret != 0) {
// Error to get the time ...
now.tv_sec = time(NULL);
now.tv_nsec = 0;
}
//EWOL_VERBOSE("current time : " << now.tv_sec << "s " << now.tv_usec << "us");
return (int64_t)((int64_t)now.tv_sec*(int64_t)1000 + (int64_t)now.tv_nsec/(int64_t)1000000);
}
#undef __class__
#define __class__ "guiAbstraction"
// attributes for a single buffered visual in RGBA format with at least 4 bits per color and a 16 bit depth buffer
static int attrListSgl[] = {
GLX_RGBA,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_DEPTH_SIZE, 16,
None
};
// attributes for a double buffered visual in RGBA format with at least 4 bits per color and a 16 bit depth buffer
static int attrListDbl[] = {
GLX_RGBA,
GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 4,
GLX_GREEN_SIZE, 4,
GLX_BLUE_SIZE, 4,
GLX_DEPTH_SIZE, 16,
None
};
static eventSpecialKey_ts guiKeyBoardMode;
extern "C" {
typedef struct Hints
{
unsigned long flags;
unsigned long functions;
unsigned long decorations;
long inputMode;
unsigned long status;
} Hints;
}
// for double and triple click selection, we need to save the previous click up and down position , and the previous time ...
int32_t m_previousBouttonId = -1;
int32_t m_previousDown_x = 0;
int32_t m_previousDown_y = 0;
int32_t m_previous_x = 0;
int32_t m_previous_y = 0;
int64_t m_previousTime = 0;
bool m_previousDouble = 0;
Atom m_delAtom;
Display * m_display = NULL;;
Window WindowHandle;
int32_t m_originX = 0;
int32_t m_originY = 0;
int32_t m_cursorEventX = 0;
int32_t m_cursorEventY = 0;
XVisualInfo * m_visual = NULL;
bool m_doubleBuffered = 0;
bool m_run = 0;
extern ewol::Windows* gui_uniqueWindows;
extern etkFloat_t gui_width;
extern etkFloat_t gui_height;
int32_t separateClickTime = 300;
int32_t offsetMoveClicked = 10;
int32_t offsetMoveClickedDouble = 20;
bool inputIsPressed[20];
static void X11_ChangeSize(int32_t w, int32_t h);
static void X11_ChangePos(int32_t x, int32_t y);
static void X11_GetAbsPos(int32_t & x, int32_t & y);
bool CreateX11Context(void)
{
int x,y, attr_mask;
XSizeHints hints;
XWMHints *StartupState;
XTextProperty textprop;
XSetWindowAttributes attr;
static char *title = (char*)"APPLICATION Title ... (todo)";
EWOL_INFO("X11 Mode XF86 Video");
// Connect to the X server
m_display = XOpenDisplay(NULL);
if(NULL == m_display) {
EWOL_CRITICAL("Could not open display X.");
exit(-1);
} else {
EWOL_INFO("Display opened.");
}
int Xscreen = DefaultScreen(m_display);
// get an appropriate visual
m_visual = glXChooseVisual(m_display, Xscreen, attrListDbl);
if (NULL == m_visual) {
m_visual = glXChooseVisual(m_display, Xscreen, attrListSgl);
m_doubleBuffered = false;
EWOL_INFO("GL-X singlebuffered rendering will be used, no doublebuffering available");
} else {
m_doubleBuffered = true;
EWOL_INFO("GL-X doublebuffered rendering available");
}
{
int32_t glxMajor, glxMinor;
glXQueryVersion(m_display, &glxMajor, &glxMinor);
EWOL_INFO("GLX-Version " << glxMajor << "." << glxMinor);
}
// Create a colormap - only needed on some X clients, eg. IRIX
Window Xroot = RootWindow(m_display, Xscreen);
attr.colormap = XCreateColormap(m_display, Xroot, m_visual->visual, AllocNone);
attr.border_pixel = 0;
attr.event_mask = StructureNotifyMask
| SubstructureNotifyMask
| EnterWindowMask
| LeaveWindowMask
| ExposureMask
| ButtonPressMask
| ButtonReleaseMask
| OwnerGrabButtonMask
| KeyPressMask
| KeyReleaseMask
| PointerMotionMask
| FocusChangeMask
| SubstructureRedirectMask;
// set no background at the gui
attr.background_pixmap = None;
// select internal attribute
attr_mask = CWBackPixmap | CWColormap | CWBorderPixel | CWEventMask;
// Create the window
int32_t tmp_width = DisplayWidth(m_display, DefaultScreen(m_display))/2;
int32_t tmp_height = DisplayHeight(m_display, DefaultScreen(m_display))/2;
EWOL_NativeResize(tmp_width, tmp_height);
x=tmp_width/2;
y=tmp_height/4;
// Real create of the window
WindowHandle = XCreateWindow(m_display,
Xroot,
x, y, tmp_width, tmp_height,
1,
m_visual->depth,
InputOutput,
m_visual->visual,
attr_mask, &attr);
if( !WindowHandle ) {
EWOL_CRITICAL("Couldn't create the window");
exit(-1);
}
/* Configure it... (ok, ok, this next bit isn't "minimal") */
textprop.value = (unsigned char*)title;
textprop.encoding = XA_STRING;
textprop.format = 8;
textprop.nitems = strlen(title);
hints.x = x;
hints.y = y;
hints.width = tmp_width;
hints.height = tmp_height;
hints.flags = USPosition|USSize;
StartupState = XAllocWMHints();
StartupState->initial_state = NormalState;
StartupState->flags = StateHint;
XSetWMProperties(m_display, WindowHandle,&textprop, &textprop,/* Window title/icon title*/
NULL, 0,/* Argv[], argc for program*/
&hints, /* Start position/size*/
StartupState,/* Iconised/not flag */
NULL);
XFree(StartupState);
/* Open it, wait for it to appear */
XMapWindow(m_display, WindowHandle);
//XIfEvent(m_display, &event, WaitForMapNotify, (char*)&WindowHandle);
// Set the kill atom so we get a message when the user tries to close the window
if ((m_delAtom = XInternAtom(m_display, "WM_DELETE_WINDOW", 0)) != None) {
XSetWMProtocols(m_display, WindowHandle, &m_delAtom, 1);
}
X11_ChangeSize(400, 300);
return true;
}
void RemoveDecoration(void)
{
Hints hints;
Atom property;
hints.flags = 2;// Specify that we're changing the window decorations.
hints.decorations = 0;// 0 (false) means that window decorations should go bye-bye
property = XInternAtom(m_display, "_MOTIF_WM_HINTS", true);
if (0 != property) {
XChangeProperty(m_display,WindowHandle,property,property,32,PropModeReplace,(unsigned char *)&hints,5);
XMapWindow(m_display, WindowHandle);
} else {
EWOL_ERROR("Can not get the property for the rmoving decoration of the X11 system ....");
}
}
void AddDecoration(void)
{
Hints hints;
Atom property;
hints.flags = 2;// Specify that we're changing the window decorations.
hints.decorations = 1;// 1 (true) means that window decorations should enable
property = XInternAtom(m_display, "_MOTIF_WM_HINTS", true);
if (0 != property) {
XChangeProperty(m_display,WindowHandle,property,property,32,PropModeReplace,(unsigned char *)&hints,5);
XMapWindow(m_display, WindowHandle);
} else {
EWOL_ERROR("Can not get the property for the rmoving decoration of the X11 system ....");
}
}
bool CreateOGlContext(void)
{
/* create a GLX context */
GLXContext RenderContext = glXCreateContext(m_display, m_visual, 0, GL_TRUE);
/* connect the glx-context to the window */
glXMakeCurrent(m_display, WindowHandle, RenderContext);
if (glXIsDirect(m_display, RenderContext)) {
EWOL_INFO("XF86 DRI enabled\n");
} else {
EWOL_INFO("XF86 DRI NOT available\n");
}
return true;
}
void EWOL_NativeRender(void)
{
ewol::UpdateTextureContext();
//EWOL_DEBUG("redraw (" << gui_width << "," << gui_height << ")");
if(NULL == gui_uniqueWindows) {
//EWOL_DEBUG("Has No Windows set...");
// set the size of the open GL system
glViewport(0,0,gui_width,gui_height);
// Clear the screen with transparency ...
glClearColor(0.750, 0.750, 0.750, 0.5);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0., (etkFloat_t)gui_width, 0., (etkFloat_t)gui_height, 1., 20.);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0, 0, -5);
glBegin(GL_QUADS);
glColor3f(1., 0., 0.); glVertex3f( .25*(etkFloat_t)gui_width, .25*(etkFloat_t)gui_height, 0.);
glColor3f(0., 1., 0.); glVertex3f( .75*(etkFloat_t)gui_width, .25*(etkFloat_t)gui_height, 0.);
glColor3f(0., 0., 1.); glVertex3f( .75*(etkFloat_t)gui_width, .75*(etkFloat_t)gui_height, 0.);
glColor3f(1., 1., 0.); glVertex3f( .25*(etkFloat_t)gui_width, .75*(etkFloat_t)gui_height, 0.);
glEnd();
} else {
EWOL_GenericDraw(false);
}
glFlush();
if (m_doubleBuffered) {
glXSwapBuffers(m_display, WindowHandle);
}
}
void X11_Init(void)
{
m_visual = NULL;
m_previousBouttonId = 0;
m_previousDown_x = -1;
m_previousDown_y = -1;
m_previous_x = -1;
m_previous_y = -1;
m_previousTime = 0;
m_previousDouble = false;
m_originX = 0;
m_originY = 0;
m_cursorEventX = 0;
m_cursorEventY = 0;
for (int32_t iii=0; iii<NB_MAX_INPUT; iii++) {
inputIsPressed[iii] = false;
}
CreateX11Context();
CreateOGlContext();
m_run = true;
}
void X11_Run(void)
{
// main cycle
while(true == m_run) {
//EWOL_ERROR("plop1");
XEvent event;
// main X boucle :
while (XPending(m_display)) {
//EWOL_ERROR("plop 22222");
XNextEvent(m_display, &event);
switch (event.type)
{
case ClientMessage:
{
Atom atom = XInternAtom(m_display, "WM_DELETE_WINDOW", false);
if((int64_t)atom == (int64_t)event.xclient.data.l[0]) {
if (NULL != gui_uniqueWindows) {
gui_uniqueWindows->SysOnKill();
}
m_run = false;
}
}
break;
case Expose:
EWOL_DEBUG("X11 event Expose");
break;
case GraphicsExpose:
EWOL_DEBUG("X11 event GraphicsExpose");
break;
case NoExpose:
EWOL_DEBUG("X11 event NoExpose");
break;
case CreateNotify:
EWOL_DEBUG("X11 event CreateNotify");
break;
case DestroyNotify:
EWOL_DEBUG("X11 event DestroyNotify");
break;
case GravityNotify:
EWOL_DEBUG("X11 event GravityNotify");
break;
case VisibilityNotify:
EWOL_DEBUG("X11 event VisibilityNotify");
break;
case CirculateNotify:
EWOL_DEBUG("X11 event CirculateNotify");
break;
case ReparentNotify:
EWOL_DEBUG("X11 event ReparentNotify");
break;
case PropertyNotify:
EWOL_DEBUG("X11 event PropertyNotify");
break;
case ConfigureNotify:
m_originX = event.xconfigure.x;
m_originY = event.xconfigure.y;
EWOL_ThreadResize(event.xconfigure.width, event.xconfigure.height);
break;
case ButtonPress:
m_cursorEventX = event.xbutton.x;
m_cursorEventY = event.xbutton.y;
if (event.xbutton.button < NB_MAX_INPUT) {
inputIsPressed[event.xbutton.button] = true;
}
EWOL_ThreadEventInputState(event.xbutton.button, true, (float)event.xbutton.x, (float)event.xbutton.y);
break;
case ButtonRelease:
m_cursorEventX = event.xbutton.x;
m_cursorEventY = event.xbutton.y;
if (event.xbutton.button < NB_MAX_INPUT) {
inputIsPressed[event.xbutton.button] = false;
}
EWOL_ThreadEventInputState(event.xbutton.button, false, (float)event.xbutton.x, (float)event.xbutton.y);
break;
case EnterNotify:
m_cursorEventX = event.xcrossing.x;
m_cursorEventY = event.xcrossing.y;
//EWOL_DEBUG("X11 event : " << event.type << " = \"EnterNotify\" (" << (etkFloat_t)event.xcrossing.x << "," << (etkFloat_t)event.xcrossing.y << ")");
//gui_uniqueWindows->GenEventInput(0, ewol::EVENT_INPUT_TYPE_ENTER, (etkFloat_t)event.xcrossing.x, (etkFloat_t)event.xcrossing.y);
break;
case LeaveNotify:
m_cursorEventX = event.xcrossing.x;
m_cursorEventY = event.xcrossing.y;
//EWOL_DEBUG("X11 event : " << event.type << " = \"LeaveNotify\" (" << (etkFloat_t)event.xcrossing.x << "," << (etkFloat_t)event.xcrossing.y << ")");
break;
case MotionNotify:
m_cursorEventX = event.xmotion.x;
m_cursorEventY = event.xmotion.y;
{
// For compatibility of the Android system :
bool findOne = false;
for (int32_t iii=0; iii<NB_MAX_INPUT ; iii++) {
if (true == inputIsPressed[iii]) {
EWOL_VERBOSE("X11 event: bt=" << iii << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")");
EWOL_ThreadEventInputMotion(iii, (float)event.xmotion.x, (float)event.xmotion.y);
findOne = true;
}
}
if (false == findOne) {
EWOL_VERBOSE("X11 event: bt=" << 0 << " " << event.type << " = \"MotionNotify\" (" << (etkFloat_t)event.xmotion.x << "," << (etkFloat_t)event.xmotion.y << ")");
EWOL_ThreadEventInputMotion(0, (float)event.xmotion.x, (float)event.xmotion.y);
}
}
break;
case FocusIn:
EWOL_VERBOSE("X11 event : " << event.type << " = \"FocusIn\"");
break;
case FocusOut:
EWOL_VERBOSE("X11 event : " << event.type << " = \"FocusOut\"");
break;
case KeyPress:
case KeyRelease:
//EWOL_DEBUG("X11 event : " << event.type << " = \"KeyPress/KeyRelease\" ");
{
EWOL_DEBUG("eventKey : " << event.xkey.keycode << " state : " << event.xkey.state);
if (event.xkey.state & (1<<0) ) {
//EWOL_DEBUG(" Special Key : SHIFT");
guiKeyBoardMode.shift = true;
} else {
guiKeyBoardMode.shift = false;
}
if (event.xkey.state & (1<<1) ) {
//EWOL_DEBUG(" Special Key : CAPS_LOCK");
guiKeyBoardMode.capLock = true;
} else {
guiKeyBoardMode.capLock = false;
}
if (event.xkey.state & (1<<2) ) {
//EWOL_DEBUG(" Special Key : Ctrl");
guiKeyBoardMode.ctrl = true;
} else {
guiKeyBoardMode.ctrl = false;
}
if (event.xkey.state & (1<<3) ) {
//EWOL_DEBUG(" Special Key : Alt");
guiKeyBoardMode.alt = true;
} else {
guiKeyBoardMode.alt = false;
}
if (event.xkey.state & (1<<4) ) {
//EWOL_DEBUG(" Special Key : VER_num");
guiKeyBoardMode.verNum = true;
} else {
guiKeyBoardMode.verNum = false;
}
if (event.xkey.state & (1<<5) ) {
EWOL_DEBUG(" Special Key : MOD");
}
if (event.xkey.state & (1<<6) ) {
//EWOL_DEBUG(" Special Key : META");
guiKeyBoardMode.meta = true;
} else {
guiKeyBoardMode.meta = false;
}
if (event.xkey.state & (1<<7) ) {
//EWOL_DEBUG(" Special Key : ALT_GR");
guiKeyBoardMode.altGr = true;
} else {
guiKeyBoardMode.altGr = false;
}
bool find = true;
ewol::eventKbMoveType_te keyInput;
switch (event.xkey.keycode) {
//case 80: // keypad
case 111: keyInput = ewol::EVENT_KB_MOVE_TYPE_UP; break;
//case 83: // keypad
case 113: keyInput = ewol::EVENT_KB_MOVE_TYPE_LEFT; break;
//case 85: // keypad
case 114: keyInput = ewol::EVENT_KB_MOVE_TYPE_RIGHT; break;
//case 88: // keypad
case 116: keyInput = ewol::EVENT_KB_MOVE_TYPE_DOWN; break;
//case 81: // keypad
case 112: keyInput = ewol::EVENT_KB_MOVE_TYPE_PAGE_UP; break;
//case 89: // keypad
case 117: keyInput = ewol::EVENT_KB_MOVE_TYPE_PAGE_DOWN; break;
//case 79: // keypad
case 110: keyInput = ewol::EVENT_KB_MOVE_TYPE_START; break;
//case 87: // keypad
case 115: keyInput = ewol::EVENT_KB_MOVE_TYPE_END; break;
case 78: keyInput = ewol::EVENT_KB_MOVE_TYPE_ARRET_DEFIL; break;
case 127: keyInput = ewol::EVENT_KB_MOVE_TYPE_WAIT; break;
//case 90: // keypad
case 118:
keyInput = ewol::EVENT_KB_MOVE_TYPE_INSERT;
if(event.type == KeyRelease) {
if (true == guiKeyBoardMode.insert) {
guiKeyBoardMode.insert = false;
} else {
guiKeyBoardMode.insert = true;
}
}
break;
//case 84: keyInput = ewol::EVENT_KB_MOVE_TYPE_CENTER; break; // Keypad
case 67: keyInput = ewol::EVENT_KB_MOVE_TYPE_F1; break;
case 68: keyInput = ewol::EVENT_KB_MOVE_TYPE_F2; break;
case 69: keyInput = ewol::EVENT_KB_MOVE_TYPE_F3; break;
case 70: keyInput = ewol::EVENT_KB_MOVE_TYPE_F4; break;
case 71: keyInput = ewol::EVENT_KB_MOVE_TYPE_F5; break;
case 72: keyInput = ewol::EVENT_KB_MOVE_TYPE_F6; break;
case 73: keyInput = ewol::EVENT_KB_MOVE_TYPE_F7; break;
case 74: keyInput = ewol::EVENT_KB_MOVE_TYPE_F8; break;
case 75: keyInput = ewol::EVENT_KB_MOVE_TYPE_F9; break;
case 76: keyInput = ewol::EVENT_KB_MOVE_TYPE_F10; break;
case 95: keyInput = ewol::EVENT_KB_MOVE_TYPE_F11; break;
case 96: keyInput = ewol::EVENT_KB_MOVE_TYPE_F12; break;
case 66: keyInput = ewol::EVENT_KB_MOVE_TYPE_CAPLOCK; break;
case 50: keyInput = ewol::EVENT_KB_MOVE_TYPE_SHIFT_LEFT; break;
case 62: keyInput = ewol::EVENT_KB_MOVE_TYPE_SHIFT_RIGHT; break;
case 37: keyInput = ewol::EVENT_KB_MOVE_TYPE_CTRL_LEFT; break;
case 105: keyInput = ewol::EVENT_KB_MOVE_TYPE_CTRL_RIGHT; break;
case 133: keyInput = ewol::EVENT_KB_MOVE_TYPE_META_LEFT; break;
case 134: keyInput = ewol::EVENT_KB_MOVE_TYPE_META_RIGHT; break;
case 64: keyInput = ewol::EVENT_KB_MOVE_TYPE_ALT; break;
case 108: keyInput = ewol::EVENT_KB_MOVE_TYPE_ALT_GR; break;
case 135: keyInput = ewol::EVENT_KB_MOVE_TYPE_CONTEXT_MENU; break;
case 77: keyInput = ewol::EVENT_KB_MOVE_TYPE_VER_NUM; break;
case 91: // Suppr on keypad
find = false;
{
eventKeyboardKey_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
specialEvent.myChar = 0x0000007F;
if(event.type == KeyPress) {
specialEvent.isDown = true;
} else {
specialEvent.isDown = false;
}
EWOL_ThreadKeyboardEvent(specialEvent);
}
default:
find = false;
{
char buf[11];
EWOL_DEBUG("Keycode: " << event.xkey.keycode);
// change keystate for simple reson of the ctrl error...
int32_t keyStateSave = event.xkey.state;
if (event.xkey.state & (1<<2) ) {
event.xkey.state = event.xkey.state & 0xFFFFFFFB;
}
KeySym keysym;
XComposeStatus status;
int count = XLookupString(&event.xkey, buf, 10, &keysym, &status);
// retreave real keystate
event.xkey.state = keyStateSave;
buf[count] = '\0';
// Replace \r error ...
if (buf[0] == '\r') {
buf[0] = '\n';
buf[1] = '\0';
}
if (count>0) {
// transform iun unicode
eventKeyboardKey_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
unicode::convertIsoToUnicode(unicode::EDN_CHARSET_ISO_8859_15, buf[0], specialEvent.myChar);
//EWOL_INFO("event Key : " << event.xkey.keycode << " char=\"" << buf << "\"'len=" << strlen(buf) << " unicode=" << unicodeValue);
if(event.type == KeyPress) {
specialEvent.isDown = true;
} else {
specialEvent.isDown = false;
}
EWOL_ThreadKeyboardEvent(specialEvent);
} else {
EWOL_WARNING("Unknow event Key : " << event.xkey.keycode);
}
}
break;
}
if (true == find) {
EWOL_DEBUG("eventKey Move type : " << GetCharTypeMoveEvent(keyInput) );
eventKeyboardMove_ts specialEvent;
specialEvent.special = guiKeyBoardMode;
if(event.type == KeyPress) {
specialEvent.isDown = true;
} else {
specialEvent.isDown = false;
}
specialEvent.move = keyInput;
EWOL_ThreadKeyboardEventMove(specialEvent);
}
break;
}
//case DestroyNotify:
// break;
case MapNotify:
EWOL_VERBOSE("X11 event : " << event.type << " = \"MapNotify\"");
EWOL_ThreadEventShow();
break;
case UnmapNotify:
EWOL_VERBOSE("X11 event : " << event.type << " = \"UnmapNotify\"");
EWOL_ThreadEventHide();
break;
default:
EWOL_DEBUG("X11 event : " << event.type << " = \"???\"");
}
}
EWOL_NativeRender();
}
};
void X11_ChangeSize(int32_t w, int32_t h)
{
XResizeWindow(m_display, WindowHandle, w, h);
};
void X11_ChangePos(int32_t x, int32_t y)
{
XMoveWindow(m_display, WindowHandle, x, y);
};
void X11_GetAbsPos(int32_t & x, int32_t & y)
{
int tmp;
unsigned int tmp2;
Window fromroot, tmpwin;
XQueryPointer(m_display, WindowHandle, &fromroot, &tmpwin, &x, &y, &tmp, &tmp, &tmp2);
};
#undef __class__
#define __class__ "guiAbstraction"
void guiAbstraction::Stop(void)
{
m_run = false;
}
void guiAbstraction::ChangeSize(int32_t w, int32_t h)
{
X11_ChangeSize(w, h);
}
void guiAbstraction::ChangePos(int32_t x, int32_t y)
{
X11_ChangePos(x, y);
}
void guiAbstraction::GetAbsPos(int32_t & x, int32_t & y)
{
X11_GetAbsPos(x, y);
}
bool guiAbstraction::IsPressedInput(int32_t inputID)
{
if( NB_MAX_INPUT > inputID
&& 0 <= inputID)
{
return inputIsPressed[inputID];
} else {
EWOL_WARNING("Wrong input ID : " << inputID);
return false;
}
}
#include <ewol/ewol.h>
static etk::VectorType<etk::UString*> listArgs;
int32_t ewol::CmdLineNb(void)
{
return listArgs.Size();
}
etk::UString ewol::CmdLineGet(int32_t id)
{
if (id<0 && id>=listArgs.Size()) {
return "";
}
if (NULL == listArgs[id]) {
return "";
}
return *listArgs[id];
}
int main(int argc, char *argv[])
{
for( int32_t i=1 ; i<argc; i++) {
EWOL_INFO("CmdLine : \"" << argv[i] << "\"" );
etk::UString* tmpString = new etk::UString(argv[i]);
if (NULL != tmpString) {
listArgs.PushBack(tmpString);
}
}
// start X11 thread ...
X11_Init();
//start the basic thread :
EWOL_SystemStart();
usleep(500);
// Run ...
X11_Run();
// close X11 :
guiAbstraction::Stop();
// uninit ALL :
EWOL_SystemStop();
for (int32_t iii=0; iii<listArgs.Size(); iii++) {
if (NULL != listArgs[iii]) {
delete listArgs[iii];
listArgs[iii] = NULL;
}
}
listArgs.Clear();
return 0;
}

View File

@ -0,0 +1,138 @@
/**
*******************************************************************************
* @file ewol/ewol.cpp
* @brief Main code of ewol (sources)
* @author Edouard DUPIN
* @date 17/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/ewol.h>
#include <ewol/WidgetManager.h>
#include <ewol/base/gui.h>
#undef __class__
#define __class__ "ewol"
void ewol::DisplayWindows(ewol::Windows * windows)
{
// Remove current Focus :
ewol::widgetManager::FocusSetDefault(NULL);
ewol::widgetManager::FocusRelease();
// set display of the windows :
guiAbstraction::SetDisplayOnWindows(windows);
// Set the new default Focus :
ewol::widgetManager::FocusSetDefault(windows);
}
void ewol::Stop(void)
{
guiAbstraction::Stop();
}
void ewol::ChangeSize(int32_t w, int32_t h)
{
guiAbstraction::ChangeSize(w, h);
}
void ewol::ChangePos(int32_t x, int32_t y)
{
guiAbstraction::ChangePos(x, y);
}
void ewol::GetAbsPos(int32_t & x, int32_t & y)
{
guiAbstraction::GetAbsPos(x, y);
}
bool ewol::IsPressedInput(int32_t inputID)
{
return guiAbstraction::IsPressedInput(inputID);
}
void ewol::KeyboardShow(ewol::keyboardMode_te mode)
{
guiAbstraction::KeyboardShow(mode);
}
void ewol::KeyboardHide(void)
{
guiAbstraction::KeyboardHide();
}
void ewol::ForceRedrawAll(void)
{
guiAbstraction::ForceRedrawAll();
}
bool guiKeyBoardMode_CapLock = false;
bool ewol::IsSetCapsLock(void)
{
return guiKeyBoardMode_CapLock;
}
bool guiKeyBoardMode_Shift = false;
bool ewol::IsSetShift(void)
{
return guiKeyBoardMode_Shift;
}
bool guiKeyBoardMode_Ctrl = false;
bool ewol::IsSetCtrl(void)
{
return guiKeyBoardMode_Ctrl;
}
bool guiKeyBoardMode_Meta = false;
bool ewol::IsSetMeta(void)
{
return guiKeyBoardMode_Meta;
}
bool guiKeyBoardMode_Alt = false;
bool ewol::IsSetAlt(void)
{
return guiKeyBoardMode_Alt;
}
bool guiKeyBoardMode_AltGr = false;
bool ewol::IsSetAltGr(void)
{
return guiKeyBoardMode_AltGr;
}
bool guiKeyBoardMode_VerNum = false;
bool ewol::IsSetVerNum(void)
{
return guiKeyBoardMode_VerNum;
}
bool guiKeyBoardMode_Insert = false;
bool ewol::IsSetInsert(void)
{
return guiKeyBoardMode_Insert;
}

View File

@ -0,0 +1,75 @@
/**
*******************************************************************************
* @file ewol/ewol.h
* @brief Main include of ewol (header)
* @author Edouard DUPIN
* @date 17/10/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_H__
#define __EWOL_H__
#include <etk/Types.h>
#include <etk/UString.h>
#include <ewol/Widget.h>
#include <ewol/Windows.h>
namespace ewol {
void Stop(void);
void DisplayWindows(ewol::Windows * windows);
// only on computer
void ChangeSize(int32_t w, int32_t h);
void ChangePos(int32_t x, int32_t y);
// TODO : Deprecated used FOR???
void GetAbsPos(int32_t & x, int32_t & y);
// TODO : Deprecated remove it ...
bool IsPressedInput(int32_t inputID);
void KeyboardShow(ewol::keyboardMode_te mode);
void KeyboardHide(void);
void ForceRedrawAll(void);
void PopUpWidgetPush(ewol::Widget * tmpWidget);
int32_t CmdLineNb(void);
etk::UString CmdLineGet(int32_t id);
// TODO : This might be deprecated ...
bool IsSetCapsLock(void);
bool IsSetShift(void);
bool IsSetCtrl(void);
bool IsSetMeta(void);
bool IsSetAlt(void);
bool IsSetAltGr(void);
bool IsSetVerNum(void);
bool IsSetInsert(void);
// basic shortcut setting (set default value, the configutration file will overloaded it automaticly
namespace shortCut {
void Add(bool shift, bool control, bool alt, bool meta, uniChar_t unicodeValue, const char * generateEventId, etk::UString data);
void Add(const char * descriptiveString, const char * generateEventId, etk::UString data);
};
// TODO : This is dangerous and might be deprecated ... Soon
int32_t GetCurrentWidth(void);
int32_t GetCurrentHeight(void);
};
// get current time in ms...
int64_t GetCurrentTime(void);
#endif

View File

@ -0,0 +1,33 @@
#ifndef __IMPORTGL_H__
#define __IMPORTGL_H__
#ifdef __cplusplus
extern "C" {
#endif
#if defined(__PLATFORM__Linux)
#include <GL/gl.h>
#include <GL/glu.h>
#elif defined(__PLATFORM__DoubleBuffer)
#elif defined(__PLATFORM__Android)
#include <GLES/gl.h>
#elif defined(__PLATFORM__AndroidTablet)
#include <GLES/gl.h>
#elif defined(__PLATFORM__IPhone)
#elif defined(__PLATFORM__IPad)
#else
#error you need to specify a platform ...
#endif
void glOrthoEwol(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat nearVal, GLfloat farVal);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,47 @@
/**
*******************************************************************************
* @file ewol/theme/EolBase.cpp
* @brief basic ewol theme eol file basic element Virtual Classes (Sources)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/theme/Theme.h>
#include <ewol/theme/EolBase.h>
#undef __class__
#define __class__ "ewol::theme::EolBase"
ewol::theme::EolBase::EolBase(void)
{
//EWOL_DEBUG("new...");
}
ewol::theme::EolBase::~EolBase(void)
{
}
/*
void ewol::theme::EolBase::Parse(TiXmlNode * pNode)
{
EWOL_INFO("Element Base .. Generic ... nothing to parse..." );
}
*/

View File

@ -0,0 +1,50 @@
/**
*******************************************************************************
* @file ewol/theme/EolBase.h
* @brief basic ewol theme eol file basic element virtual Classes (Header)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#ifndef __EWOL_THEME_EOL_BASE__H__
#define __EWOL_THEME_EOL_BASE__H__
#include <etk/Types.h>
#include <etk/UString.h>
#include <ewol/OObject.h>
#include <tinyXML/tinyxml.h>
namespace ewol {
namespace theme {
class EolBase {
public:
EolBase(void);
virtual ~EolBase(void);
virtual void Parse(TiXmlNode * pNode) = 0;
virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY) = 0;
};
};
};
#endif

View File

@ -0,0 +1,119 @@
/**
*******************************************************************************
* @file ewol/theme/EolBasicCircle.cpp
* @brief basic ewol theme eol file basic element type=Circle (Sources)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/theme/Theme.h>
#include <ewol/theme/EolBaseCircle.h>
#undef __class__
#define __class__ "ewol::theme::EolBaseCircle"
ewol::theme::EolBaseCircle::EolBaseCircle(void)
{
//EWOL_DEBUG("new element Base : Circle/Disk ...");
}
ewol::theme::EolBaseCircle::~EolBaseCircle(void)
{
}
void ewol::theme::EolBaseCircle::Parse(TiXmlNode * pNode)
{
m_colorBG = pNode->ToElement()->Attribute("colorBG");
m_colorBorder = pNode->ToElement()->Attribute("colorBorder");
const char * tmp = pNode->ToElement()->Attribute("position");
if (NULL == tmp) {
m_posCenter.x=0;
m_posCenter.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_posCenter.x=xxx;
m_posCenter.y=yyy;
}
tmp = pNode->ToElement()->Attribute("radius");
if (NULL == tmp) {
m_radius=0;
} else {
double tmpVal;
// optimize for multiple type input ...
sscanf(tmp, "%lf", &tmpVal);
m_radius=tmpVal;
}
tmp = pNode->ToElement()->Attribute("thickness");
if (NULL == tmp) {
m_thickness=0.01;
} else {
double tmpVal;
// optimize for multiple type input ...
sscanf(tmp, "%lf", &tmpVal);
m_thickness=tmpVal;
}
EWOL_DEBUG("(l " << pNode->Row() << ") Parse Base Element : \"Circle\" : pos(" << m_posCenter.x << "," << m_posCenter.y << ") radius=" << m_radius
<< " colorBG=\"" << m_colorBG << "\" colorBorder=\"" << m_colorBorder << "\" thickness=" << m_thickness);
}
void ewol::theme::EolBaseCircle::Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
{
if (m_colorBG != "") {
color_ts selectedColorBG = {1.0, 1.0, 1.0, 1.0};
bool res = false;
if (NULL != myElement) {
res = myElement->GetColor(m_colorBG, selectedColorBG);
}
// try from theme if not existed
if( false == res
&& NULL != myTheme ) {
myElement->GetColor(m_colorBG, selectedColorBG);
}
newObject.SetColor(selectedColorBG);
newObject.Disc(posX + m_posCenter.x*sizeX, posY + m_posCenter.y*sizeY, m_radius*(sizeX+sizeY)/2);
}
if (m_colorBorder != "") {
color_ts selectedColorBorder = {0.0, 0.0, 0.0, 1.0};
bool res = false;
// try get color for current element
if (NULL != myElement) {
res = myElement->GetColor(m_colorBorder, selectedColorBorder);
}
// try from theme if not existed
if( false == res
&& NULL != myTheme ) {
myElement->GetColor(m_colorBorder, selectedColorBorder);
}
newObject.SetColor(selectedColorBorder);
newObject.Circle(posX + m_posCenter.x*sizeX, posY + m_posCenter.y*sizeY, m_radius*(sizeX+sizeY)/2, m_thickness*(sizeX+sizeY)/2);
}
}

View File

@ -0,0 +1,57 @@
/**
*******************************************************************************
* @file ewol/theme/EolBasicCircle.h
* @brief basic ewol theme eol file basic element type=Circle (Header)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/theme/EolBase.h>
#include <ewol/theme/EolColor.h>
#ifndef __EWOL_THEME_EOL_BASE_CIRCLE_H__
#define __EWOL_THEME_EOL_BASE_CIRCLE_H__
namespace ewol {
namespace theme {
class EolBaseCircle : public EolBase {
public:
EolBaseCircle(void);
virtual ~EolBaseCircle(void);
/*
<circle colorBG="..." ==> generate condition to display background ...
colorBorder="..." ==> generate condition to display border ...
position="0.53;0.56"
radius="0.2"
thickness="0.05" ==> only if neededd by border, default 0.01
/>
*/
virtual void Parse(TiXmlNode * pNode);
virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
private:
etk::UString m_colorBG;
etk::UString m_colorBorder;
coord2D_ts m_posCenter;
etkFloat_t m_radius;
etkFloat_t m_thickness;
};
};
};
#endif

View File

@ -0,0 +1,28 @@
/**
*******************************************************************************
* @file ewol/theme/EolBasicCirclePart.cpp
* @brief basic ewol theme eol file basic element type=CirclePart (Sources)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#undef __class__
#define __class__ "ewol::theme::EolBaseCirclePart"

View File

@ -0,0 +1,32 @@
/**
*******************************************************************************
* @file ewol/theme/EolBasicCirclePart.h
* @brief basic ewol theme eol file basic element type=CirclePart (Header)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/theme/EolBase.h>
#ifndef __EWOL_THEME_EOL_BASE_CIRCLE_PART_H__
#define __EWOL_THEME_EOL_BASE_CIRCLE_PART_H__
#endif

View File

@ -0,0 +1,101 @@
/**
*******************************************************************************
* @file ewol/theme/EolBaseLine.cpp
* @brief basic ewol theme eol file basic element type=Line (Sources)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/theme/Theme.h>
#include <ewol/theme/EolBaseLine.h>
#undef __class__
#define __class__ "ewol::theme::EolBaseLine"
ewol::theme::EolBaseLine::EolBaseLine(void)
{
//EWOL_DEBUG("new element Base : Line ...");
}
ewol::theme::EolBaseLine::~EolBaseLine(void)
{
}
void ewol::theme::EolBaseLine::Parse(TiXmlNode * pNode)
{
m_color = pNode->ToElement()->Attribute("color");
const char * tmp = pNode->ToElement()->Attribute("positionStart");
if (NULL == tmp) {
m_posStart.x=0;
m_posStart.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_posStart.x=xxx;
m_posStart.y=yyy;
}
tmp = pNode->ToElement()->Attribute("positionStop");
if (NULL == tmp) {
m_posStop.x=0;
m_posStop.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_posStop.x=xxx;
m_posStop.y=yyy;
}
tmp = pNode->ToElement()->Attribute("thickness");
if (NULL == tmp) {
m_thickness=0.01;
} else {
double tmpVal;
// optimize for multiple type input ...
sscanf(tmp, "%lf", &tmpVal);
m_thickness=tmpVal;
}
EWOL_DEBUG("(l " << pNode->Row() << ") Parse Base Element : \"line\" : pos(" << m_posStart.x << "," << m_posStart.y << ") to pos(" << m_posStop.x << "," << m_posStop.y << ") thickness=" << m_thickness);
}
void ewol::theme::EolBaseLine::Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
{
bool res = false;
color_ts selectedColor = {0.0, 0.0, 0.0, 1.0};
// try get color for current element
if (NULL != myElement) {
res = myElement->GetColor(m_color, selectedColor);
}
// try from theme if not existed
if( false == res
&& NULL != myTheme ) {
myElement->GetColor(m_color, selectedColor);
}
newObject.SetColor(selectedColor);
newObject.Line(posX + m_posStart.x*sizeX, posY + m_posStart.y*sizeY, posX + m_posStop.x*sizeX, posY + m_posStop.y*sizeY, m_thickness*(sizeX+sizeY)/2);
}

View File

@ -0,0 +1,58 @@
/**
*******************************************************************************
* @file ewol/theme/EolBaseLine.h
* @brief basic ewol theme eol file basic element type=Line (Header)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/theme/EolBase.h>
#include <ewol/theme/EolColor.h>
#ifndef __EWOL_THEME_EOL_BASE_LINE_H__
#define __EWOL_THEME_EOL_BASE_LINE_H__
namespace ewol {
namespace theme {
class EolBaseLine : public EolBase {
public:
EolBaseLine(void);
virtual ~EolBaseLine(void);
/*
<line color="..."
positionStart="0.53;0.56"
positionStop="0.22;0.11"
thickness="0.05"
/>
*/
virtual void Parse(TiXmlNode * pNode);
virtual void Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY);
private:
etk::UString m_color;
coord2D_ts m_posStart;
coord2D_ts m_posStop;
etkFloat_t m_thickness;
};
};
};
#endif

View File

@ -0,0 +1,28 @@
/**
*******************************************************************************
* @file ewol/theme/EolBasePolygone.cpp
* @brief basic ewol theme eol file basic element type=polygone (Sources)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#undef __class__
#define __class__ "ewol::theme::EolBasePolygone"

View File

@ -0,0 +1,32 @@
/**
*******************************************************************************
* @file ewol/theme/EolBasePolygone.h
* @brief basic ewol theme eol file basic element type=polygone (Header)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/theme/EolBase.h>
#ifndef __EWOL_THEME_EOL_BASE_POLYGONE_H__
#define __EWOL_THEME_EOL_BASE_POLYGONE_H__
#endif

View File

@ -0,0 +1,117 @@
/**
*******************************************************************************
* @file ewol/theme/EolBaseRect.cpp
* @brief basic ewol theme eol file basic element type=rectangle (Sources)
* @author Edouard DUPIN
* @date 23/11/2011
* @par Project
* ewol
*
* @par Copyright
* Copyright 2011 Edouard DUPIN, all right reserved
*
* This software is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY.
*
* Licence summary :
* You can modify and redistribute the sources code and binaries.
* You can send me the bug-fix
*
* Term of the licence in in the file licence.txt.
*
*******************************************************************************
*/
#include <ewol/theme/Theme.h>
#include <ewol/theme/EolBaseRect.h>
#undef __class__
#define __class__ "ewol::theme::EolBaseRect"
ewol::theme::EolBaseRect::EolBaseRect(void)
{
//EWOL_DEBUG("new element Base : Rectangle ...");
}
ewol::theme::EolBaseRect::~EolBaseRect(void)
{
}
void ewol::theme::EolBaseRect::Parse(TiXmlNode * pNode)
{
const char * tmp = pNode->ToElement()->Attribute("position");
if (NULL == tmp) {
m_position.x=0;
m_position.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_position.x=xxx;
m_position.y=yyy;
}
tmp = pNode->ToElement()->Attribute("size");
if (NULL == tmp) {
m_size.x=0;
m_size.y=0;
} else {
double xxx,yyy;
// optimize for multiple type input ...
sscanf(tmp, "%lf;%lf", &xxx,&yyy);
m_size.x=xxx;
m_size.y=yyy;
}
tmp = pNode->ToElement()->Attribute("thickness");
if (NULL == tmp) {
m_thickness=0.01;
} else {
double tmpVal;
// optimize for multiple type input ...
sscanf(tmp, "%lf", &tmpVal);
m_thickness=tmpVal;
}
m_colorBG = pNode->ToElement()->Attribute("colorBG");
m_colorBorder = pNode->ToElement()->Attribute("colorBorder");
EWOL_DEBUG("(l " << pNode->Row() << ") Parse Base Element : \"rect\" : pos(" << m_position.x << "," << m_position.y << ") "
<< "size(" << m_size.x << "," << m_size.y << ") colorBG=\"" << m_colorBG << "\" colorBorder=\"" << m_colorBorder << "\" thickness=" << m_thickness);
}
void ewol::theme::EolBaseRect::Generate(const ewol::theme::Theme * myTheme, const ewol::theme::EolElement * myElement, ewol::OObject2DColored & newObject, etkFloat_t posX, etkFloat_t posY, etkFloat_t sizeX, etkFloat_t sizeY)
{
if (m_colorBG != "") {
color_ts selectedColorBG = {1.0, 1.0, 1.0, 1.0};
bool res = false;
if (NULL != myElement) {
res = myElement->GetColor(m_colorBG, selectedColorBG);
}
// try from theme if not existed
if( false == res
&& NULL != myTheme ) {
myElement->GetColor(m_colorBG, selectedColorBG);
}
newObject.SetColor(selectedColorBG);
newObject.Rectangle(posX + m_position.x*sizeX, posY + m_position.y*sizeY, m_size.x*sizeX, m_size.y*sizeY);
}
if (m_colorBorder != "") {
color_ts selectedColorBorder = {0.0, 0.0, 0.0, 1.0};
bool res = false;
// try get color for current element
if (NULL != myElement) {
res = myElement->GetColor(m_colorBorder, selectedColorBorder);
}
// try from theme if not existed
if( false == res
&& NULL != myTheme ) {
myElement->GetColor(m_colorBorder, selectedColorBorder);
}
newObject.SetColor(selectedColorBorder);
newObject.RectangleBorder(posX + m_position.x*sizeX, posY + m_position.y*sizeY, m_size.x*sizeX, m_size.y*sizeY, m_thickness*(sizeX+sizeY)/2);
}
}

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