Merge with default

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
kaetemi 11 years ago
commit f75ba5b5e3

@ -147,6 +147,7 @@ external_stlport
*.lnk
thumbs.db
Thumbs.db
.Sync*
# build
code/nel/build/*

@ -2,7 +2,7 @@
#
# NeL
# Authors: Nevrax and the NeL Community
# Version: 0.8.0
# Version: 0.9.0
#
# Notes:
# * Changing install location: add -DCMAKE_INSTALL_PREFIX:PATH=/my/new/path
@ -41,16 +41,18 @@ INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
# Force out of source builds.
CHECK_OUT_OF_SOURCE()
# Specify Mac OS X deployment target before including Darwin.cmake
IF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.6")
ENDIF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(RyzomCore CXX C)
SET(NL_VERSION_MAJOR 0)
SET(NL_VERSION_MINOR 8)
SET(NL_VERSION_MINOR 9)
SET(NL_VERSION_PATCH 0)
SET(NL_VERSION "${NL_VERSION_MAJOR}.${NL_VERSION_MINOR}.${NL_VERSION_PATCH}")
NL_SETUP_BUILD()
NL_SETUP_BUILD_FLAGS()
#-----------------------------------------------------------------------------
# Redirect output files
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
@ -87,6 +89,9 @@ RYZOM_SETUP_PREFIX_PATHS()
NL_CONFIGURE_CHECKS()
NL_SETUP_BUILD()
NL_SETUP_BUILD_FLAGS()
#-----------------------------------------------------------------------------
#Platform specifics
@ -106,15 +111,18 @@ FIND_PACKAGE(LibXml2 REQUIRED)
FIND_PACKAGE(PNG REQUIRED)
FIND_PACKAGE(Jpeg)
IF(WITH_STATIC_LIBXML2)
SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC)
ENDIF(WITH_STATIC_LIBXML2)
IF(WITH_STATIC)
# libxml2 could need winsock2 library
SET(LIBXML2_DEFINITIONS ${LIBXML2_DEFINITIONS} -DLIBXML_STATIC)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${WINSOCK2_LIB})
# on Mac OS X libxml2 requieres iconv
# on Mac OS X libxml2 requires iconv and liblzma
IF(APPLE)
FIND_PACKAGE(Iconv REQUIRED)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES})
FIND_PACKAGE(LibLZMA REQUIRED)
SET(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} ${ICONV_LIBRARIES} ${LIBLZMA_LIBRARIES})
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
ENDIF(APPLE)
ENDIF(WITH_STATIC)
@ -134,6 +142,10 @@ IF(WITH_NEL)
FIND_PACKAGE(CppTest)
ENDIF(WITH_NEL_TESTS)
IF(WITH_GUI)
FIND_PACKAGE(Libwww REQUIRED)
ENDIF(WITH_GUI)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/nel/include ${LIBXML2_INCLUDE_DIR})
ADD_DEFINITIONS(${LIBXML2_DEFINITIONS})
ADD_SUBDIRECTORY(nel)
@ -230,7 +242,7 @@ IF(WIN32)
"${QT_LIBRARY_DIR}/../bin/QtGuid4.dll"
"${QT_LIBRARY_DIR}/../bin/QtXmld4.dll"
"${QT_LIBRARY_DIR}/../bin/QtCored4.dll"
DESTINATION bin)
DESTINATION ${NL_BIN_PREFIX})
ENDIF(WITH_QT)
ELSE(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
IF(WITH_QT)
@ -239,18 +251,18 @@ IF(WIN32)
"${QT_LIBRARY_DIR}/../bin/QtGui4.dll"
"${QT_LIBRARY_DIR}/../bin/QtXml4.dll"
"${QT_LIBRARY_DIR}/../bin/QtCore4.dll"
DESTINATION bin)
DESTINATION ${NL_BIN_PREFIX})
ENDIF(WITH_QT)
ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "Release")
# Install CEGUI and its dependencies.
IF(WITH_NEL_CEGUI)
INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIBase.dll" DESTINATION bin)
INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIDevilImageCodec.dll" DESTINATION bin)
INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIExpatParser.dll" DESTINATION bin)
INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIFalagardWRBase.dll" DESTINATION bin)
INSTALL(FILES "${CEGUI_LIB_DIR}/Devil.dll" DESTINATION bin)
INSTALL(FILES "${CEGUI_LIB_DIR}/ILU.dll" DESTINATION bin)
INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIBase.dll" DESTINATION ${NL_BIN_PREFIX})
INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIDevilImageCodec.dll" DESTINATION ${NL_BIN_PREFIX})
INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIExpatParser.dll" DESTINATION ${NL_BIN_PREFIX})
INSTALL(FILES "${CEGUI_LIB_DIR}/CEGUIFalagardWRBase.dll" DESTINATION ${NL_BIN_PREFIX})
INSTALL(FILES "${CEGUI_LIB_DIR}/Devil.dll" DESTINATION ${NL_BIN_PREFIX})
INSTALL(FILES "${CEGUI_LIB_DIR}/ILU.dll" DESTINATION ${NL_BIN_PREFIX})
ENDIF(WITH_NEL_CEGUI)
# Only the tools require MFC.

@ -58,6 +58,7 @@ MACRO(FIND_WWW_LIBRARY MYLIBRARY OPTION)
PATHS
/usr/local/lib
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/local/X11R6/lib
/usr/X11R6/lib
/sw/lib

@ -60,7 +60,7 @@ IF(Mercurial_HG_EXECUTABLE)
"\\1" Mercurial_VERSION_HG "${Mercurial_VERSION_HG}")
MACRO(Mercurial_WC_INFO dir prefix)
EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip
EXECUTE_PROCESS(COMMAND ${Mercurial_HG_EXECUTABLE} tip --template "{rev};{node};{tags};{author}"
WORKING_DIRECTORY ${dir}
OUTPUT_VARIABLE ${prefix}_WC_INFO
ERROR_VARIABLE Mercurial_hg_info_error
@ -70,18 +70,18 @@ IF(Mercurial_HG_EXECUTABLE)
IF(NOT ${Mercurial_hg_info_result} EQUAL 0)
MESSAGE(SEND_ERROR "Command \"${Mercurial_HG_EXECUTABLE} tip\" failed with output:\n${Mercurial_hg_info_error}")
ELSE(NOT ${Mercurial_hg_info_result} EQUAL 0)
STRING(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*"
"\\2" ${prefix}_WC_ROOT "${${prefix}_WC_INFO}")
STRING(REGEX REPLACE "^(.*\n)?changeset: *([0-9]+).*"
"\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}")
STRING(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}")
STRING(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}")
STRING(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*"
"\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}")
LIST(LENGTH ${prefix}_WC_INFO _COUNT)
IF(_COUNT EQUAL 4)
LIST(GET ${prefix}_WC_INFO 0 ${prefix}_WC_REVISION)
LIST(GET ${prefix}_WC_INFO 1 ${prefix}_WC_CHANGESET)
LIST(GET ${prefix}_WC_INFO 2 ${prefix}_WC_BRANCH)
LIST(GET ${prefix}_WC_INFO 3 ${prefix}_WC_LAST_CHANGED_AUTHOR)
ELSE(_COUNT EQUAL 4)
MESSAGE(STATUS "Bad output from HG")
SET(${prefix}_WC_REVISION "unknown")
SET(${prefix}_WC_CHANGESET "unknown")
SET(${prefix}_WC_BRANCH "unknown")
ENDIF(_COUNT EQUAL 4)
ENDIF(NOT ${Mercurial_hg_info_result} EQUAL 0)
ENDMACRO(Mercurial_WC_INFO)

@ -67,6 +67,11 @@ IF(SQUISH_FOUND)
IF(NOT SQUISH_FIND_QUIETLY)
MESSAGE(STATUS "Found Squish: ${SQUISH_LIBRARIES}")
ENDIF(NOT SQUISH_FIND_QUIETLY)
FILE(STRINGS ${SQUISH_INCLUDE_DIR}/squish.h METRIC REGEX "metric = 0")
IF(METRIC)
SET(SQUISH_COMPRESS_HAS_METRIC ON)
SET(SQUISH_DEFINITIONS -DSQUISH_COMPRESS_HAS_METRIC)
ENDIF(METRIC)
ELSE(SQUISH_FOUND)
IF(NOT SQUISH_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Squish!")

@ -2,47 +2,86 @@
# Find the Windows includes
#
# WINSDK_INCLUDE_DIR - where to find Windows.h
# WINSDK_INCLUDE_DIRS - where to find all Windows headers
# WINSDK_LIBRARY_DIR - where to find libraries
# WINSDK_FOUND - True if Windows SDK found.
IF(WINSDK_INCLUDE_DIR)
# Already in cache, be silent
SET(WINSDK_FIND_QUIETLY TRUE)
SET(WindowsSDK_FIND_QUIETLY TRUE)
ENDIF(WINSDK_INCLUDE_DIR)
# TODO: add the possibility to use a specific Windows SDK
IF(MSVC11)
GET_FILENAME_COMPONENT(WINSDK8_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;InstallationFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDK8_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v8.0;ProductVersion]" NAME)
IF(WINSDK8_DIR)
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDK8_VERSION} in ${WINSDK8_DIR}")
ENDIF(NOT WindowsSDK_FIND_QUIETLY)
IF(TARGET_ARM)
SET(WINSDK8_SUFFIX "arm")
ELSEIF(TARGET_X64)
SET(WINSDK8_SUFFIX "x64")
ELSEIF(TARGET_X86)
SET(WINSDK8_SUFFIX "x86")
ENDIF(TARGET_ARM)
ENDIF(WINSDK8_DIR)
ENDIF(MSVC11)
GET_FILENAME_COMPONENT(WINSDK71_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;InstallationFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDK71_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;ProductVersion]" NAME)
IF(WINSDK71_DIR)
IF(NOT WINSDK_FIND_QUIETLY)
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDK71_VERSION} in ${WINSDK71_DIR}")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ENDIF(WINSDK71_DIR)
GET_FILENAME_COMPONENT(WINSDKCURRENT_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentInstallFolder]" ABSOLUTE CACHE)
GET_FILENAME_COMPONENT(WINSDKCURRENT_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows;CurrentVersion]" NAME)
IF(WINSDKCURRENT_DIR)
IF(NOT WINSDK_FIND_QUIETLY)
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Found Windows SDK ${WINSDKCURRENT_VERSION} in ${WINSDKCURRENT_DIR}")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ENDIF(WINSDKCURRENT_DIR)
FIND_PATH(WINSDK_INCLUDE_DIR Windows.h
PATHS
HINTS
${WINSDK8_DIR}/Include/um
${WINSDK71_DIR}/Include
${WINSDKCURRENT_DIR}/Include
)
FIND_PATH(WINSDK_SHARED_INCLUDE_DIR d3d9.h
HINTS
${WINSDK8_DIR}/Include/shared
${WINSDK71_DIR}/Include
${WINSDKCURRENT_DIR}/Include
)
FIND_PATH(WINSDK_LIBRARY_DIR ComCtl32.lib
HINTS
${WINSDK8_DIR}/Lib/win8/um/${WINSDK8_SUFFIX}
${WINSDK71_DIR}/Lib
${WINSDKCURRENT_DIR}/Lib
)
FIND_PROGRAM(WINSDK_SIGNTOOL signtool
PATHS
HINTS
${WINSDK8_DIR}/Bin/x86
${WINSDK71_DIR}/Bin
${WINSDKCURRENT_DIR}/Bin
)
IF(WINSDK_INCLUDE_DIR)
SET(WINSDK_FOUND TRUE)
SET(WINSDK_INCLUDE_DIRS ${WINSDK_INCLUDE_DIR} ${WINSDK_SHARED_INCLUDE_DIR})
ELSE(WINSDK_INCLUDE_DIR)
IF(NOT WINSDK_FIND_QUIETLY)
IF(NOT WindowsSDK_FIND_QUIETLY)
MESSAGE(STATUS "Warning: Unable to find Windows SDK!")
ENDIF(NOT WINSDK_FIND_QUIETLY)
ENDIF(NOT WindowsSDK_FIND_QUIETLY)
ENDIF(WINSDK_INCLUDE_DIR)

@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3)
# ROOT_DIR should be set to root of the repository (where to find the .svn or .hg directory)
# SOURCE_DIR should be set to root of your code (where to find CMakeLists.txt)
IF(SOURCE_DIR)
# Replace spaces by semi-columns
IF(CMAKE_MODULE_PATH)
STRING(REPLACE " " ";" CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
@ -17,6 +18,9 @@ ENDIF(NOT ROOT_DIR AND SOURCE_DIR)
IF(NOT SOURCE_DIR AND ROOT_DIR)
SET(SOURCE_DIR ${ROOT_DIR})
ENDIF(NOT SOURCE_DIR AND ROOT_DIR)
ELSE(SOURCE_DIR)
SET(ROOT_DIR ${CMAKE_SOURCE_DIR})
ENDIF(SOURCE_DIR)
MACRO(NOW RESULT)
IF (WIN32)
@ -53,10 +57,11 @@ IF(EXISTS "${ROOT_DIR}/.hg/")
ENDIF(MERCURIAL_FOUND)
ENDIF(EXISTS "${ROOT_DIR}/.hg/")
IF(DEFINED REVISION)
IF(SOURCE_DIR AND DEFINED REVISION)
IF(EXISTS ${SOURCE_DIR}/revision.h.in)
MESSAGE(STATUS "Revision: ${REVISION}")
NOW(BUILD_DATE)
CONFIGURE_FILE(${SOURCE_DIR}/revision.h.in revision.h.txt)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy revision.h.txt revision.h) # copy_if_different
ENDIF(EXISTS ${SOURCE_DIR}/revision.h.in)
ENDIF(DEFINED REVISION)
ENDIF(SOURCE_DIR AND DEFINED REVISION)

@ -17,13 +17,11 @@ ELSE(MSVC)
ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE gcc_compiler_version)
IF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
IF(gcc_compiler_version MATCHES "^4\\.1(\\.[0-9]+)?")
SET(PCHSupport_FOUND FALSE)
ELSEIF(gcc_compiler_version MATCHES "^4\\.[0-9]+(\\.[0-9]+)?")
SET(PCHSupport_FOUND TRUE)
ELSE(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
IF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
SET(PCHSupport_FOUND TRUE)
ENDIF(gcc_compiler_version MATCHES "3\\.4\\.[0-9]")
ENDIF(gcc_compiler_version MATCHES "4\\.[0-9]\\.[0-9]")
ENDIF(gcc_compiler_version MATCHES "^4\\.1(\\.[0-9]+)?")
ELSE(CMAKE_COMPILER_IS_GNUCXX)
# TODO: make tests for other compilers than GCC
SET(PCHSupport_FOUND TRUE)
@ -32,41 +30,123 @@ ELSE(MSVC)
SET(_PCH_include_prefix "-I")
ENDIF(MSVC)
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
SET(${_out_compile_flags} ${${_flags_var_name}} )
# Set PCH_FLAGS for common flags, PCH_ARCH_XXX_FLAGS for specific archs flags and PCH_ARCHS for archs
MACRO(PCH_SET_COMPILE_FLAGS _target)
SET(PCH_FLAGS)
SET(PCH_ARCHS)
SET(FLAGS)
LIST(APPEND _FLAGS ${CMAKE_CXX_FLAGS})
STRING(TOUPPER "${CMAKE_BUILD_TYPE}" _UPPER_BUILD)
LIST(APPEND _FLAGS " ${CMAKE_CXX_FLAGS_${_UPPER_BUILD}}")
IF(NOT MSVC)
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
IF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
LIST(APPEND ${_out_compile_flags} "-fPIC")
LIST(APPEND _FLAGS " -fPIC")
ENDIF(${_targetType} STREQUAL SHARED_LIBRARY OR ${_targetType} STREQUAL MODULE_LIBRARY)
ENDIF(NOT MSVC)
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES)
FOREACH(item ${DIRINC})
LIST(APPEND ${_out_compile_flags} " ${_PCH_include_prefix}\"${item}\"")
LIST(APPEND _FLAGS " ${_PCH_include_prefix}\"${item}\"")
ENDFOREACH(item)
# Required for CMake 2.6
SET(GLOBAL_DEFINITIONS "")
SET(GLOBAL_DEFINITIONS)
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS)
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS -D${item})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
GET_DIRECTORY_PROPERTY(DEFINITIONS COMPILE_DEFINITIONS_${_UPPER_BUILD})
FOREACH(item ${DEFINITIONS})
LIST(APPEND GLOBAL_DEFINITIONS " -D${item}")
ENDFOREACH(item)
GET_TARGET_PROPERTY(oldProps ${_target} COMPILE_FLAGS)
IF(oldProps)
LIST(APPEND _FLAGS " ${oldProps}")
ENDIF(oldProps)
GET_TARGET_PROPERTY(oldPropsBuild ${_target} COMPILE_FLAGS_${_UPPER_BUILD})
IF(oldPropsBuild)
LIST(APPEND _FLAGS " ${oldPropsBuild}")
ENDIF(oldPropsBuild)
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS)
GET_DIRECTORY_PROPERTY(_directory_definitions DIRECTORY ${CMAKE_SOURCE_DIR} DEFINITIONS)
LIST(APPEND ${_out_compile_flags} ${GLOBAL_DEFINITIONS})
LIST(APPEND ${_out_compile_flags} ${_directory_flags})
LIST(APPEND ${_out_compile_flags} ${_directory_definitions})
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS})
LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}")
LIST(APPEND _FLAGS " ${_directory_flags}")
LIST(APPEND _FLAGS " ${_directory_definitions}")
STRING(REGEX REPLACE " +" " " _FLAGS ${_FLAGS})
# Format definitions
SEPARATE_ARGUMENTS(${_out_compile_flags})
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
SEPARATE_ARGUMENTS(_FLAGS)
IF(CLANG)
# Determining all architectures and get common flags
SET(_ARCH_NEXT)
SET(_XARCH_NEXT)
FOREACH(item ${_FLAGS})
IF(_ARCH_NEXT)
LIST(FIND PCH_ARCHS ${item} ITEM_FOUND)
IF(ITEM_FOUND EQUAL -1)
LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF(ITEM_FOUND EQUAL -1)
SET(_ARCH_NEXT OFF)
ELSEIF(_XARCH_NEXT)
SET(_XARCH_NEXT OFF)
ELSE(_ARCH_NEXT)
IF(item MATCHES "^-arch")
SET(_ARCH_NEXT ON)
ELSEIF(item MATCHES "^-Xarch_")
STRING(REGEX REPLACE "-Xarch_([a-z0-9_]+)" "\\1" item ${item})
LIST(FIND PCH_ARCHS ${item} ITEM_FOUND)
IF(ITEM_FOUND EQUAL -1)
LIST(APPEND PCH_ARCHS ${item})
STRING(TOUPPER "${item}" _UPPER_ARCH)
SET(PCH_ARCH_${_UPPER_ARCH}_FLAGS "-arch" ${item})
ENDIF(ITEM_FOUND EQUAL -1)
SET(_XARCH_NEXT ON)
ELSE(item MATCHES "^-arch")
LIST(APPEND PCH_FLAGS ${item})
ENDIF(item MATCHES "^-arch")
ENDIF(_ARCH_NEXT)
ENDFOREACH(item)
MACRO(_PCH_GET_PDB_FILENAME out_filename _target)
# Get architcture specific flags
SET(_XARCH_NEXT)
FOREACH(item ${_FLAGS})
IF(_XARCH_NEXT)
STRING(TOUPPER "${_XARCH_NEXT}" _UPPER_XARCH)
LIST(APPEND PCH_ARCH_${_UPPER_XARCH}_FLAGS ${item})
SET(_XARCH_NEXT OFF)
ELSE(_XARCH_NEXT)
IF(item MATCHES "^-Xarch_")
STRING(SUBSTRING "${item}" 7 -1 _XARCH_NEXT)
ENDIF(item MATCHES "^-Xarch_")
ENDIF(_XARCH_NEXT)
ENDFOREACH(item)
# Remove duplicated architectures
IF(_ARCHS AND PCH_ARCHS)
LIST(REMOVE_DUPLICATES PCH_ARCHS)
ENDIF(_ARCHS AND PCH_ARCHS)
ELSE(CLANG)
SET(PCH_FLAGS ${_FLAGS})
ENDIF(CLANG)
IF(PCH_FLAGS)
LIST(REMOVE_DUPLICATES PCH_FLAGS)
ENDIF(PCH_FLAGS)
ENDMACRO(PCH_SET_COMPILE_FLAGS)
MACRO(GET_PDB_FILENAME _out_filename _target)
# determine output directory based on target type
GET_TARGET_PROPERTY(_targetType ${_target} TYPE)
IF(${_targetType} STREQUAL EXECUTABLE)
@ -84,10 +164,10 @@ MACRO(_PCH_GET_PDB_FILENAME out_filename _target)
SET(_targetPostfix "")
ENDIF(${_targetPostfix} MATCHES NOTFOUND)
SET(${out_filename} "${_targetOutput}/${_target}${_targetPostfix}.pdb")
ENDMACRO(_PCH_GET_PDB_FILENAME)
SET(${_out_filename} "${_targetOutput}/${_target}${_targetPostfix}.pdb")
ENDMACRO(GET_PDB_FILENAME)
MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _inputcpp _output)
MACRO(PCH_SET_COMPILE_COMMAND _inputcpp _compile_FLAGS)
IF(CMAKE_CXX_COMPILER_ARG1)
# remove leading space in compiler argument
STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
@ -96,56 +176,117 @@ MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _inputcpp _output)
ENDIF(CMAKE_CXX_COMPILER_ARG1)
IF(MSVC)
_PCH_GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target})
SET(${out_command} ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp\"${_output}\" ${_inputcpp} /c /Fd\"${PDB_FILE}\")
GET_PDB_FILENAME(PDB_FILE ${_PCH_current_target})
SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} /Yc /Fp"${PCH_OUTPUT}" ${_inputcpp} /Fd"${PDB_FILE}" /c /Fo"${PCH_OUTPUT}.obj")
ELSE(MSVC)
SET(HEADER_FORMAT "c++-header")
SET(_FLAGS "")
IF(APPLE)
SET(HEADER_FORMAT "objective-${HEADER_FORMAT}")
SET(_FLAGS -fobjc-abi-version=2 -fobjc-legacy-dispatch)
ENDIF(APPLE)
SET(${out_command} ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} -x ${HEADER_FORMAT} -o ${_output} -c ${_input})
SET(PCH_COMMAND ${CMAKE_CXX_COMPILER} ${pchsupport_compiler_cxx_arg1} ${_compile_FLAGS} ${_FLAGS} -x ${HEADER_FORMAT} -o ${PCH_OUTPUT} -c ${PCH_INPUT})
ENDIF(MSVC)
ENDMACRO(_PCH_GET_COMPILE_COMMAND)
ENDMACRO(PCH_SET_COMPILE_COMMAND)
MACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT _targetName _input _arch _language)
SET(_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch")
MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
IF(MSVC)
FILE(MAKE_DIRECTORY ${_OUTPUT_DIR})
GET_FILENAME_COMPONENT(_name ${_input} NAME_WE)
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.pch")
SET(PCH_INPUT ${_input})
SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.pch")
ELSE(MSVC)
IF(NOT "${_arch}" STREQUAL "")
SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_arch}")
ENDIF(NOT "${_arch}" STREQUAL "")
IF(NOT "${_language}" STREQUAL "")
SET(_OUTPUT_DIR "${_OUTPUT_DIR}_${_language}")
ENDIF(NOT "${_language}" STREQUAL "")
GET_FILENAME_COMPONENT(_name ${_input} NAME)
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch")
# Copy .h to output dir
SET(PCH_INPUT "${_OUTPUT_DIR}/${_name}")
ADD_CUSTOM_COMMAND(OUTPUT ${PCH_INPUT}
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_input} ${PCH_INPUT}
DEPENDS ${_input}
COMMENT "[${_targetName}] Update precompiled header - done"
)
IF(CLANG)
SET(PCH_EXT "pth")
ELSE(CLANG)
SET(PCH_EXT "gch")
ENDIF(CLANG)
# For GCC and Clang, PCH needs to be in the same directory as .h
SET(PCH_OUTPUT "${_OUTPUT_DIR}/${_name}.${PCH_EXT}")
ENDIF(MSVC)
ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
ENDMACRO(PCH_SET_PRECOMPILED_HEADER_OUTPUT)
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
# Add common flags
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName)
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
IF(MSVC)
SET(_target_cflags "${oldProps} /Yu\"${_input}\" /FI\"${_input}\" /Fp\"${_pch_output_to_use}\"")
SET(_target_cflags "${oldProps} /Yu\"${PCH_INPUT}\" /FI\"${PCH_INPUT}\" /Fp\"${PCH_OUTPUT}\"")
ELSE(MSVC)
# to do: test whether compiler flags match between target _targetName
# and _pch_output_to_use
FILE(TO_NATIVE_PATH ${_pch_output_to_use} _native_pch_path)
# for use with distcc and gcc >4.0.1 if preprocessed files are accessible
# on all remote machines set
# PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS}-include ${_input} -Winvalid-pch")
SET(PCH_ADDITIONAL_COMPILER_FLAGS)
LIST(LENGTH PCH_ARCHS PCH_ARCHS_COUNT)
# If no arch is specified, create common flags
IF(PCH_ARCHS_COUNT LESS 2)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-include ${PCH_INPUT} ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(PCH_ARCHS_COUNT LESS 2)
IF(APPLE)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-fobjc-abi-version=2 -fobjc-legacy-dispatch -x objective-c++ ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(APPLE)
IF(WITH_PCH_DEBUG)
SET(PCH_ADDITIONAL_COMPILER_FLAGS "-H ${PCH_ADDITIONAL_COMPILER_FLAGS}")
ENDIF(WITH_PCH_DEBUG)
SET(_target_cflags "${oldProps} ${PCH_ADDITIONAL_COMPILER_FLAGS} -Winvalid-pch")
ENDIF(MSVC)
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_target_cflags})
IF(oldProps)
SET_TARGET_PROPERTIES(${_targetName}_pch_dephelp PROPERTIES COMPILE_FLAGS ${oldProps})
ENDIF(oldProps)
ADD_CUSTOM_TARGET(pch_Generate_${_targetName} DEPENDS ${_pch_output_to_use})
ADD_DEPENDENCIES(${_targetName} pch_Generate_${_targetName})
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
# Add specific flags for an arch
MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH _targetName _arch)
LIST(LENGTH PCH_ARCHS PCH_ARCHS_COUNT)
IF(PCH_ARCHS_COUNT GREATER 1)
GET_TARGET_PROPERTY(_FLAGS ${_targetName} COMPILE_FLAGS)
IF(${_FLAGS} MATCHES NOTFOUND)
SET(_FLAGS "")
ENDIF(${_FLAGS} MATCHES NOTFOUND)
SET(_FLAGS "${_FLAGS} -Xarch_${_arch} -include${PCH_INPUT}")
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS ${_FLAGS})
ENDIF(PCH_ARCHS_COUNT GREATER 1)
ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH)
MACRO(PCH_CREATE_TARGET _targetName _targetNamePCH)
ADD_CUSTOM_COMMAND(OUTPUT ${PCH_OUTPUT} COMMAND ${PCH_COMMAND} COMMENT "Generating ${_targetNamePCH}" DEPENDS ${PCH_INPUT})
ADD_CUSTOM_TARGET(${_targetNamePCH} DEPENDS ${PCH_INPUT} ${PCH_OUTPUT})
ADD_DEPENDENCIES(${_targetName} ${_targetNamePCH})
ENDMACRO(PCH_CREATE_TARGET _targetName _inputh _inputcpp)
MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET(_PCH_current_target ${_targetName})
IF(NOT CMAKE_BUILD_TYPE)
@ -155,38 +296,50 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
)
ENDIF(NOT CMAKE_BUILD_TYPE)
GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_inputh} _output)
PCH_SET_COMPILE_FLAGS(${_targetName})
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
IF(PCH_ARCHS)
SET(PCH_OUTPUTS)
FOREACH(_ARCH ${PCH_ARCHS})
STRING(TOUPPER "${_ARCH}" _UPPER_ARCH)
# always build static library because it doesn't need linking
ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_inputcpp})
PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} ${_ARCH} "")
LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT})
_PCH_GET_COMPILE_FLAGS(_compile_FLAGS)
PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_ARCH_${_UPPER_ARCH}_FLAGS};${PCH_FLAGS}")
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch_${_ARCH})
SET_SOURCE_FILES_PROPERTIES(${_inputh} PROPERTIES GENERATED 1)
ADD_PRECOMPILED_HEADER_TO_TARGET_ARCH(${_targetName} ${_ARCH})
ENDFOREACH(_ARCH)
ELSE(PCH_ARCHS)
PCH_SET_PRECOMPILED_HEADER_OUTPUT(${_targetName} ${_inputh} "" "")
LIST(APPEND PCH_OUTPUTS ${PCH_OUTPUT})
_PCH_GET_COMPILE_COMMAND(_command ${_inputh} ${_inputcpp} ${_output})
PCH_SET_COMPILE_COMMAND(${_inputcpp} "${PCH_FLAGS}")
PCH_CREATE_TARGET(${_targetName} ${_targetName}_pch)
ENDIF(PCH_ARCHS)
ADD_CUSTOM_COMMAND(
OUTPUT ${_output}
COMMAND ${_command}
DEPENDS ${_inputh} ${_targetName}_pch_dephelp
)
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName})
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_inputh} ${_output})
SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PCH_OUTPUTS}")
ENDMACRO(ADD_PRECOMPILED_HEADER)
# Macro to move PCH creation file to the front of files list
# or remove .cpp from library/executable to avoid warning
MACRO(FIX_PRECOMPILED_HEADER _files _pch)
# Remove .cpp creating PCH from the list
LIST(REMOVE_ITEM ${_files} ${_pch})
IF(MSVC)
# Prepend .cpp creating PCH to the list
LIST(INSERT ${_files} 0 ${_pch})
ENDIF(MSVC)
ENDMACRO(FIX_PRECOMPILED_HEADER)
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
SET(PCH_METHOD 0)
IF(NOT PCHSupport_FOUND)
MESSAGE(STATUS "PCH disabled because compiler doesn't support them")
RETURN()
ENDIF(NOT PCHSupport_FOUND)
# 0 => creating a new target for PCH, works for all makefiles
# 1 => setting PCH for VC++ project, works for VC++ projects
@ -199,6 +352,8 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
# SET(PCH_METHOD 1)
ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
SET(PCH_METHOD 2)
ELSE(CMAKE_GENERATOR MATCHES "Visual Studio")
SET(PCH_METHOD 0)
ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio")
IF(PCH_METHOD EQUAL 1)
@ -220,11 +375,6 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
# For Xcode, cmake needs my patch to process
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
IF(${oldProps} MATCHES NOTFOUND)
SET(oldProps "")
ENDIF(${oldProps} MATCHES NOTFOUND)
# When buiding out of the tree, precompiled may not be located
# Use full path instead.
GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE)
@ -236,4 +386,7 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp})
ENDIF(PCH_METHOD EQUAL 1)
IF(TARGET ${_targetName}_static)
ADD_NATIVE_PRECOMPILED_HEADER(${_targetName}_static ${_inputh} ${_inputcpp})
ENDIF(TARGET ${_targetName}_static)
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)

@ -13,11 +13,7 @@ ENDIF(NOT CMAKE_BUILD_TYPE)
MACRO(NL_GEN_PC name)
IF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
CONFIGURE_FILE(${name}.in "${CMAKE_CURRENT_BINARY_DIR}/${name}")
IF(CMAKE_LIBRARY_ARCHITECTURE)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig)
ELSE(CMAKE_LIBRARY_ARCHITECTURE)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION lib/pkgconfig)
ENDIF(CMAKE_LIBRARY_ARCHITECTURE)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${name}" DESTINATION ${NL_LIB_PREFIX}/pkgconfig)
ENDIF(NOT WIN32 AND WITH_INSTALL_LIBRARIES)
ENDMACRO(NL_GEN_PC)
@ -26,25 +22,52 @@ ENDMACRO(NL_GEN_PC)
###
MACRO(NL_GEN_REVISION_H)
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_REVISION_H)
SET(TOOL_FOUND OFF)
IF(EXISTS "${CMAKE_SOURCE_DIR}/../.svn/")
FIND_PACKAGE(Subversion)
IF(SUBVERSION_FOUND)
SET(TOOL_FOUND ON)
ENDIF(SUBVERSION_FOUND)
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../.svn/")
IF(EXISTS "${CMAKE_SOURCE_DIR}/../.hg/")
FIND_PACKAGE(Mercurial)
IF(MERCURIAL_FOUND)
SET(TOOL_FOUND ON)
ENDIF(MERCURIAL_FOUND)
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/../.hg/")
# if already generated
IF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
# copy it
MESSAGE(STATUS "Copying provided revision.h...")
FILE(COPY ${CMAKE_SOURCE_DIR}/revision.h DESTINATION ${CMAKE_BINARY_DIR})
SET(HAVE_REVISION_H ON)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h)
IF(TOOL_FOUND)
# a custom target that is always built
ADD_CUSTOM_TARGET(revision ALL
DEPENDS ${CMAKE_BINARY_DIR}/revision.h)
# creates revision.h using cmake script
ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_BINARY_DIR}/revision.h
COMMAND ${CMAKE_COMMAND}
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
-DROOT_DIR=${CMAKE_SOURCE_DIR}/..
-DCMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/CMakeModules
-P ${CMAKE_SOURCE_DIR}/CMakeModules/GetRevision.cmake)
# revision.h is a generated file
SET_SOURCE_FILES_PROPERTIES(${CMAKE_BINARY_DIR}/revision.h
PROPERTIES GENERATED TRUE
HEADER_FILE_ONLY TRUE)
SET(HAVE_REVISION_H ON)
ENDIF(TOOL_FOUND)
IF(HAVE_REVISION_H)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_REVISION_H)
ENDIF(HAVE_REVISION_H)
ENDIF(EXISTS ${CMAKE_SOURCE_DIR}/revision.h.in)
ENDMACRO(NL_GEN_REVISION_H)
@ -76,6 +99,11 @@ ENDMACRO(NL_TARGET_DRIVER)
# Argument:
###
MACRO(NL_DEFAULT_PROPS name label)
IF(HAVE_REVISION_H)
# explicitly say that the target depends on revision.h
ADD_DEPENDENCIES(${name} revision)
ENDIF(HAVE_REVISION_H)
# Note: This is just a workaround for a CMake bug generating VS10 files with a colon in the project name.
# CMake Bug ID: http://www.cmake.org/Bug/view.php?id=11819
STRING(REGEX REPLACE "\\:" " -" proj_label ${label})
@ -219,6 +247,11 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
ELSE(WIN32)
OPTION(WITH_STATIC "With static libraries." OFF)
ENDIF(WIN32)
IF (WITH_STATIC)
OPTION(WITH_STATIC_LIBXML2 "With static libxml2" ON )
ELSE(WITH_STATIC)
OPTION(WITH_STATIC_LIBXML2 "With static libxml2" OFF)
ENDIF(WITH_STATIC)
OPTION(WITH_STATIC_DRIVERS "With static drivers." OFF)
IF(WIN32)
OPTION(WITH_EXTERNAL "With provided external." ON )
@ -243,16 +276,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
###
# Optional support
###
# Check if CMake is launched from a Debian packaging script
SET(DEB_HOST_GNU_CPU $ENV{DEB_HOST_GNU_CPU})
# Don't strip if generating a .deb
IF(DEB_HOST_GNU_CPU)
OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" ON )
ELSE(DEB_HOST_GNU_CPU)
OPTION(WITH_SYMBOLS "Keep debug symbols in binaries" OFF)
ENDIF(DEB_HOST_GNU_CPU)
IF(WIN32)
OPTION(WITH_STLPORT "With STLport support." ON )
@ -274,6 +298,7 @@ MACRO(NL_SETUP_NEL_DEFAULT_OPTIONS)
###
OPTION(WITH_NET "Build NLNET" ON )
OPTION(WITH_3D "Build NL3D" ON )
OPTION(WITH_GUI "Build GUI" ON )
OPTION(WITH_PACS "Build NLPACS" ON )
OPTION(WITH_GEORGES "Build NLGEORGES" ON )
OPTION(WITH_LIGO "Build NLLIGO" ON )
@ -332,6 +357,11 @@ MACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
OPTION(WITH_SNOWBALLS_SERVER "Build Snowballs Services" ON )
ENDMACRO(NL_SETUP_SNOWBALLS_DEFAULT_OPTIONS)
MACRO(ADD_PLATFORM_FLAGS _FLAGS)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} ${_FLAGS}")
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} ${_FLAGS}")
ENDMACRO(ADD_PLATFORM_FLAGS)
MACRO(NL_SETUP_BUILD)
#-----------------------------------------------------------------------------
@ -364,9 +394,6 @@ MACRO(NL_SETUP_BUILD)
ENDIF(HOST_CPU MATCHES "amd64")
# Determine target CPU
IF(NOT TARGET_CPU)
SET(TARGET_CPU $ENV{DEB_HOST_GNU_CPU})
ENDIF(NOT TARGET_CPU)
# If not specified, use the same CPU as host
IF(NOT TARGET_CPU)
@ -379,9 +406,6 @@ MACRO(NL_SETUP_BUILD)
SET(TARGET_CPU "x86")
ENDIF(TARGET_CPU MATCHES "amd64")
# DEB_HOST_ARCH_ENDIAN is 'little' or 'big'
# DEB_HOST_ARCH_BITS is '32' or '64'
IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
SET(CLANG ON)
MESSAGE(STATUS "Using Clang compiler")
@ -393,7 +417,7 @@ MACRO(NL_SETUP_BUILD)
ENDIF(CMAKE_GENERATOR MATCHES "Xcode")
# If target and host CPU are the same
IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}")
IF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
# x86-compatible CPU
IF(HOST_CPU MATCHES "x86")
IF(NOT CMAKE_SIZEOF_VOID_P)
@ -414,75 +438,145 @@ MACRO(NL_SETUP_BUILD)
MESSAGE(STATUS "Unknown architecture: ${HOST_CPU}")
ENDIF(HOST_CPU MATCHES "x86")
# TODO: add checks for PPC
ELSE("${HOST_CPU}" STREQUAL "${TARGET_CPU}")
ELSE("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
MESSAGE(STATUS "Compiling on ${HOST_CPU} for ${TARGET_CPU}")
ENDIF("${HOST_CPU}" STREQUAL "${TARGET_CPU}")
ENDIF("${HOST_CPU}" STREQUAL "${TARGET_CPU}" AND NOT CMAKE_CROSSCOMPILING)
# Use values from environment variables
SET(PLATFORM_CFLAGS "$ENV{CFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CFLAGS}")
SET(PLATFORM_CXXFLAGS "$ENV{CXXFLAGS} $ENV{CPPFLAGS} ${PLATFORM_CXXFLAGS}")
SET(PLATFORM_LINKFLAGS "$ENV{LDFLAGS} ${PLATFORM_LINKFLAGS}")
# Remove -g and -O flag because we are managing them ourself
STRING(REPLACE "-g" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS})
STRING(REPLACE "-g" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS})
STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CFLAGS ${PLATFORM_CFLAGS})
STRING(REGEX REPLACE "-O[0-9s]" "" PLATFORM_CXXFLAGS ${PLATFORM_CXXFLAGS})
# Strip spaces
STRING(STRIP ${PLATFORM_CFLAGS} PLATFORM_CFLAGS)
STRING(STRIP ${PLATFORM_CXXFLAGS} PLATFORM_CXXFLAGS)
STRING(STRIP ${PLATFORM_LINKFLAGS} PLATFORM_LINKFLAGS)
IF(NOT CMAKE_OSX_ARCHITECTURES)
IF(TARGET_CPU STREQUAL "x86_64")
SET(TARGET_X64 1)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_X86_64")
SET(TARGET_X86 1)
ELSEIF(TARGET_CPU STREQUAL "x86")
SET(TARGET_X86 1)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_X86")
ELSEIF(TARGET_CPU STREQUAL "armv7s")
SET(TARGET_ARM 1)
SET(TARGET_ARMV7S 1)
ELSEIF(TARGET_CPU STREQUAL "armv7")
SET(TARGET_ARM 1)
SET(TARGET_ARMV7 1)
ELSEIF(TARGET_CPU STREQUAL "armv6")
SET(TARGET_ARM 1)
SET(TARGET_ARMV6 1)
ELSEIF(TARGET_CPU STREQUAL "armv5")
SET(TARGET_ARM 1)
SET(TARGET_ARMV5 1)
ELSEIF(TARGET_CPU STREQUAL "arm")
SET(TARGET_ARM 1)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DHAVE_ARM")
ELSEIF(TARGET_CPU STREQUAL "mips")
SET(TARGET_MIPS 1)
ENDIF(TARGET_CPU STREQUAL "x86_64")
# Fix library paths suffixes for Debian MultiArch
SET(DEBIAN_MULTIARCH $ENV{DEB_HOST_MULTIARCH})
IF(TARGET_ARM)
IF(TARGET_ARMV7S)
ADD_PLATFORM_FLAGS("-DHAVE_ARMV7S")
ENDIF(TARGET_ARMV7S)
IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-DHAVE_ARMV7")
ENDIF(TARGET_ARMV7)
IF(TARGET_ARMV6)
ADD_PLATFORM_FLAGS("-HAVE_ARMV6")
ENDIF(TARGET_ARMV6)
ADD_PLATFORM_FLAGS("-DHAVE_ARM")
ENDIF(TARGET_ARM)
IF(TARGET_X86)
ADD_PLATFORM_FLAGS("-DHAVE_X86")
ENDIF(TARGET_X86)
IF(TARGET_X64)
ADD_PLATFORM_FLAGS("-DHAVE_X64 -DHAVE_X86_64")
ENDIF(TARGET_X64)
IF(DEBIAN_MULTIARCH)
SET(CMAKE_LIBRARY_ARCHITECTURE ${DEBIAN_MULTIARCH})
ENDIF(DEBIAN_MULTIARCH)
IF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-DHAVE_MIPS")
ENDIF(TARGET_MIPS)
ENDIF(NOT CMAKE_OSX_ARCHITECTURES)
IF(CMAKE_LIBRARY_ARCHITECTURE)
SET(CMAKE_LIBRARY_PATH /lib/${CMAKE_LIBRARY_ARCHITECTURE} /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH})
# Fix library paths suffixes for Debian MultiArch
IF(LIBRARY_ARCHITECTURE)
SET(CMAKE_LIBRARY_PATH /lib/${LIBRARY_ARCHITECTURE} /usr/lib/${LIBRARY_ARCHITECTURE} ${CMAKE_LIBRARY_PATH})
IF(TARGET_X64)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib64 /usr/lib64)
ENDIF(TARGET_X64)
IF(TARGET_X86)
ELSEIF(TARGET_X86)
SET(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib32 /usr/lib32)
ENDIF(TARGET_X86)
ENDIF(CMAKE_LIBRARY_ARCHITECTURE)
ENDIF(TARGET_X64)
ENDIF(LIBRARY_ARCHITECTURE)
IF(APPLE AND NOT IOS)
SET(CMAKE_INCLUDE_PATH /opt/local/include ${CMAKE_INCLUDE_PATH})
SET(CMAKE_LIBRARY_PATH /opt/local/lib ${CMAKE_LIBRARY_PATH})
ENDIF(APPLE AND NOT IOS)
IF(WITH_LOGGING)
ADD_PLATFORM_FLAGS("-DENABLE_LOGS")
ENDIF(WITH_LOGGING)
IF(MSVC)
IF(MSVC10)
IF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11)
SET(MSVC11 ON)
ENDIF(MSVC_VERSION EQUAL "1700" AND NOT MSVC11)
IF(MSVC11)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2010, but custom optimizations don't exist
SET(SPEED_OPTIMIZATIONS "/Ox /GF /GS-")
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(MIN_OPTIMIZATIONS "/Od /Ob1")
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC10)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# /Ox is working with VC++ 2010, but custom optimizations don't exist
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(DEBUG_CFLAGS "/Od /Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC90)
ADD_PLATFORM_FLAGS("/Gy- /MP")
# don't use a /O[012x] flag if you want custom optimizations
SET(SPEED_OPTIMIZATIONS "/Ob2 /Oi /Ot /Oy /GT /GF /GS-")
SET(RELEASE_CFLAGS "/Ob2 /Oi /Ot /Oy /GT /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(MIN_OPTIMIZATIONS "/Ob1")
SET(DEBUG_CFLAGS "/Ob1 /GF- ${DEBUG_CFLAGS}")
ELSEIF(MSVC80)
ADD_PLATFORM_FLAGS("/Gy- /Wp64")
# don't use a /O[012x] flag if you want custom optimizations
SET(SPEED_OPTIMIZATIONS "/Ox /GF /GS-")
SET(RELEASE_CFLAGS "/Ox /GF /GS- ${RELEASE_CFLAGS}")
# without inlining it's unusable, use custom optimizations again
SET(MIN_OPTIMIZATIONS "/Od /Ob1")
ELSE(MSVC10)
SET(DEBUG_CFLAGS "/Od /Ob1 ${DEBUG_CFLAGS}")
ELSE(MSVC11)
MESSAGE(FATAL_ERROR "Can't determine compiler version ${MSVC_VERSION}")
ENDIF(MSVC10)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zm1000 /MP /Gy-")
ENDIF(MSVC11)
# Common link flags
SET(PLATFORM_LINKFLAGS "")
ADD_PLATFORM_FLAGS("/D_CRT_SECURE_NO_DEPRECATE /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_WARNINGS /DWIN32 /D_WINDOWS /Zm1000 /wd4250")
IF(TARGET_X64)
# Fix a bug with Intellisense
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /D_WIN64")
ADD_PLATFORM_FLAGS("/D_WIN64")
# Fix a compilation error for some big C++ files
SET(MIN_OPTIMIZATIONS "${MIN_OPTIMIZATIONS} /bigobj")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} /bigobj")
ELSE(TARGET_X64)
# Allows 32 bits applications to use 3 GB of RAM
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} /LARGEADDRESSAWARE")
ENDIF(TARGET_X64)
# Exceptions are only set for C++
SET(PLATFORM_CXXFLAGS "${PLATFORM_CFLAGS} /EHa")
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} /EHa")
IF(WITH_SYMBOLS)
SET(NL_RELEASE_CFLAGS "/Zi ${NL_RELEASE_CFLAGS}")
@ -491,88 +585,292 @@ MACRO(NL_SETUP_BUILD)
SET(NL_RELEASE_LINKFLAGS "/RELEASE ${NL_RELEASE_LINKFLAGS}")
ENDIF(WITH_SYMBOLS)
SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS} ${NL_DEBUG_CFLAGS}")
SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${SPEED_OPTIMIZATIONS} ${NL_RELEASE_CFLAGS}")
SET(NL_DEBUG_CFLAGS "/Zi /MDd /RTC1 /D_DEBUG ${DEBUG_CFLAGS} ${NL_DEBUG_CFLAGS}")
SET(NL_RELEASE_CFLAGS "/MD /DNDEBUG ${RELEASE_CFLAGS} ${NL_RELEASE_CFLAGS}")
SET(NL_DEBUG_LINKFLAGS "/DEBUG /OPT:NOREF /OPT:NOICF /NODEFAULTLIB:msvcrt /INCREMENTAL:YES ${NL_DEBUG_LINKFLAGS}")
SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO ${NL_RELEASE_LINKFLAGS}")
IF(WITH_WARNINGS)
SET(DEBUG_CFLAGS "/W4 ${DEBUG_CFLAGS}")
ELSE(WITH_WARNINGS)
SET(DEBUG_CFLAGS "/W3 ${DEBUG_CFLAGS}")
ENDIF(WITH_WARNINGS)
ELSE(MSVC)
IF(WIN32)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -DWIN32 -D_WIN32")
ADD_PLATFORM_FLAGS("-DWIN32 -D_WIN32")
IF(CLANG)
ADD_PLATFORM_FLAGS("-nobuiltininc")
ENDIF(CLANG)
ENDIF(WIN32)
IF(APPLE)
IF(TARGET_CPU STREQUAL "x86")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -arch i386")
ENDIF(TARGET_CPU STREQUAL "x86")
IF(NOT XCODE)
IF(CMAKE_OSX_ARCHITECTURES)
SET(TARGETS_COUNT 0)
SET(_ARCHS)
FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES})
IF(_ARCH STREQUAL "i386")
SET(_ARCHS "${_ARCHS} i386")
SET(TARGET_X86 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSEIF(_ARCH STREQUAL "x86_64")
SET(_ARCHS "${_ARCHS} x86_64")
SET(TARGET_X64 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSEIF(_ARCH STREQUAL "armv7s")
SET(_ARCHS "${_ARCHS} armv7s")
SET(TARGET_ARMV7S 1)
SET(TARGET_ARM 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSEIF(_ARCH STREQUAL "armv7")
SET(_ARCHS "${_ARCHS} armv7")
SET(TARGET_ARMV7 1)
SET(TARGET_ARM 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSEIF(_ARCH STREQUAL "armv6")
SET(_ARCHS "${_ARCHS} armv6")
SET(TARGET_ARMV6 1)
SET(TARGET_ARM 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSEIF(_ARCH STREQUAL "mips")
SET(_ARCHS "${_ARCHS} mips")
SET(TARGET_MIPS 1)
MATH(EXPR TARGETS_COUNT "${TARGETS_COUNT}+1")
ELSE(_ARCH STREQUAL "i386")
SET(_ARCHS "${_ARCHS} unknwon(${_ARCH})")
ENDIF(_ARCH STREQUAL "i386")
ENDFOREACH(_ARCH)
MESSAGE(STATUS "Compiling under Mac OS X for ${TARGETS_COUNT} architectures: ${_ARCHS}")
ELSE(CMAKE_OSX_ARCHITECTURES)
SET(TARGETS_COUNT 0)
ENDIF(CMAKE_OSX_ARCHITECTURES)
IF(TARGET_CPU STREQUAL "x86_64")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -arch x86_64")
ENDIF(TARGET_CPU STREQUAL "x86_64")
ELSE(APPLE)
IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m32 -march=i686")
ENDIF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
IF(TARGETS_COUNT EQUAL 1)
IF(TARGET_ARM)
IF(TARGET_ARMV7S)
ADD_PLATFORM_FLAGS("-arch armv7s -DHAVE_ARMV7S")
ENDIF(TARGET_ARMV7S)
IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -m64")
ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
ENDIF(APPLE)
IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-arch armv7 -DHAVE_ARMV7")
ENDIF(TARGET_ARMV7)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -D_REENTRANT -pipe -ftemplate-depth-48 -Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing")
IF(TARGET_ARMV6)
ADD_PLATFORM_FLAGS("-arch armv6 -DHAVE_ARMV6")
ENDIF(TARGET_ARMV6)
IF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -ansi")
ENDIF(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
IF(TARGET_ARMV5)
ADD_PLATFORM_FLAGS("-arch armv5 -DHAVE_ARMV5")
ENDIF(TARGET_ARMV5)
IF(WITH_COVERAGE)
SET(PLATFORM_CFLAGS "-fprofile-arcs -ftest-coverage ${PLATFORM_CFLAGS}")
ENDIF(WITH_COVERAGE)
ADD_PLATFORM_FLAGS("-mthumb -DHAVE_ARM")
ENDIF(TARGET_ARM)
IF(APPLE)
SET(PLATFORM_CFLAGS "-gdwarf-2 ${PLATFORM_CFLAGS}")
ENDIF(APPLE)
IF(TARGET_X64)
ADD_PLATFORM_FLAGS("-arch x86_64 -DHAVE_X64 -DHAVE_X86_64 -DHAVE_X86")
ELSEIF(TARGET_X86)
ADD_PLATFORM_FLAGS("-arch i386 -DHAVE_X86")
ENDIF(TARGET_X64)
IF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-arch mips -DHAVE_MIPS")
ENDIF(TARGET_MIPS)
ELSEIF(TARGETS_COUNT EQUAL 0)
# Not using CMAKE_OSX_ARCHITECTURES, HAVE_XXX already defined before
IF(TARGET_ARM)
IF(TARGET_ARMV7S)
ADD_PLATFORM_FLAGS("-arch armv7s")
ENDIF(TARGET_ARMV7S)
IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-arch armv7")
ENDIF(TARGET_ARMV7)
IF(TARGET_ARMV6)
ADD_PLATFORM_FLAGS("-arch armv6")
ENDIF(TARGET_ARMV6)
IF(APPLE AND XCODE)
SET(CMAKE_OSX_SYSROOT "macosx" CACHE PATH "" FORCE)
ELSEIF(APPLE AND NOT XCODE)
IF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.6")
ENDIF(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
IF(TARGET_ARMV5)
ADD_PLATFORM_FLAGS("-arch armv5")
ENDIF(TARGET_ARMV5)
FOREACH(_SDK ${_CMAKE_OSX_SDKS})
IF(${_SDK} MATCHES "MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}\\.sdk")
SET(CMAKE_OSX_SYSROOT ${_SDK} CACHE PATH "" FORCE)
ENDIF(${_SDK} MATCHES "MacOSX${CMAKE_OSX_DEPLOYMENT_TARGET}\\.sdk")
ENDFOREACH(_SDK)
ADD_PLATFORM_FLAGS("-mthumb")
ENDIF(TARGET_ARM)
IF(TARGET_X64)
ADD_PLATFORM_FLAGS("-arch x86_64")
ELSEIF(TARGET_X86)
ADD_PLATFORM_FLAGS("-arch i386")
ENDIF(TARGET_X64)
IF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-arch mips")
ENDIF(TARGET_MIPS)
ELSE(TARGETS_COUNT EQUAL 1)
IF(TARGET_ARMV6)
ADD_PLATFORM_FLAGS("-Xarch_armv6 -mthumb -Xarch_armv6 -DHAVE_ARM -Xarch_armv6 -DHAVE_ARMV6")
ENDIF(TARGET_ARMV6)
IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-Xarch_armv7 -mthumb -Xarch_armv7 -DHAVE_ARM -Xarch_armv7 -DHAVE_ARMV7")
ENDIF(TARGET_ARMV7)
IF(TARGET_X86)
ADD_PLATFORM_FLAGS("-Xarch_i386 -DHAVE_X86")
ENDIF(TARGET_X86)
IF(TARGET_X64)
ADD_PLATFORM_FLAGS("-Xarch_x86_64 -DHAVE_X64 -Xarch_x86_64 -DHAVE_X86_64")
ENDIF(TARGET_X64)
IF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-Xarch_mips -DHAVE_MIPS")
ENDIF(TARGET_MIPS)
ENDIF(TARGETS_COUNT EQUAL 1)
IF(IOS)
SET(CMAKE_OSX_SYSROOT "" CACHE PATH "" FORCE)
IF(IOS_VERSION)
PARSE_VERSION_STRING(${IOS_VERSION} IOS_VERSION_MAJOR IOS_VERSION_MINOR IOS_VERSION_PATCH)
CONVERT_VERSION_NUMBER(${IOS_VERSION_MAJOR} ${IOS_VERSION_MINOR} ${IOS_VERSION_PATCH} IOS_VERSION_NUMBER)
ADD_PLATFORM_FLAGS("-D__IPHONE_OS_VERSION_MIN_REQUIRED=${IOS_VERSION_NUMBER}")
ENDIF(IOS_VERSION)
IF(CMAKE_IOS_SYSROOT)
IF(TARGET_ARMV7S)
IF(TARGETS_COUNT GREATER 1)
SET(XARCH "-Xarch_armv7s ")
ENDIF(TARGETS_COUNT GREATER 1)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF(TARGET_ARMV7S)
IF(TARGET_ARMV7)
IF(TARGETS_COUNT GREATER 1)
SET(XARCH "-Xarch_armv7 ")
ENDIF(TARGETS_COUNT GREATER 1)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF(TARGET_ARMV7)
IF(TARGET_ARMV6)
IF(TARGETS_COUNT GREATER 1)
SET(XARCH "-Xarch_armv6 ")
ENDIF(TARGETS_COUNT GREATER 1)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-miphoneos-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-iphoneos_version_min,${IOS_VERSION}")
ENDIF(TARGET_ARMV6)
ENDIF(CMAKE_IOS_SYSROOT)
IF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)
IF(TARGETS_COUNT GREATER 1)
SET(XARCH "-Xarch_i386 ")
ENDIF(TARGETS_COUNT GREATER 1)
ADD_PLATFORM_FLAGS("${XARCH}-isysroot${CMAKE_IOS_SIMULATOR_SYSROOT}")
ADD_PLATFORM_FLAGS("${XARCH}-mios-simulator-version-min=${IOS_VERSION}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} ${XARCH}-Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
ENDIF(CMAKE_IOS_SIMULATOR_SYSROOT AND TARGET_X86)
ELSE(IOS)
IF(CMAKE_OSX_SYSROOT)
SET(PLATFORM_CFLAGS "-isysroot ${CMAKE_OSX_SYSROOT} ${PLATFORM_CFLAGS}")
ELSE(CMAKE_OSX_SYSROOT)
MESSAGE(FATAL_ERROR "CMAKE_OSX_SYSROOT can't be determinated")
ADD_PLATFORM_FLAGS("-isysroot ${CMAKE_OSX_SYSROOT}")
ENDIF(CMAKE_OSX_SYSROOT)
IF(CMAKE_OSX_ARCHITECTURES)
FOREACH(_ARCH ${CMAKE_OSX_ARCHITECTURES})
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -arch ${_ARCH}")
ENDFOREACH(_ARCH)
ENDIF(CMAKE_OSX_ARCHITECTURES)
IF(CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG)
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
ENDIF(CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG)
# Always force -mmacosx-version-min to override environement variable
ADD_PLATFORM_FLAGS("-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-macosx_version_min,${CMAKE_OSX_DEPLOYMENT_TARGET}")
ENDIF(IOS)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-headerpad_max_install_names")
IF(HAVE_FLAG_SEARCH_PATHS_FIRST)
SET(PLATFORM_LINKFLAGS "-Wl,-search_paths_first ${PLATFORM_LINKFLAGS}")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-search_paths_first")
ENDIF(HAVE_FLAG_SEARCH_PATHS_FIRST)
ENDIF(APPLE AND XCODE)
ENDIF(NOT XCODE)
ELSE(APPLE)
IF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
ADD_PLATFORM_FLAGS("-m32 -march=i686")
ENDIF(HOST_CPU STREQUAL "x86_64" AND TARGET_CPU STREQUAL "x86")
IF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
ADD_PLATFORM_FLAGS("-m64")
ENDIF(HOST_CPU STREQUAL "x86" AND TARGET_CPU STREQUAL "x86_64")
ENDIF(APPLE)
ADD_PLATFORM_FLAGS("-D_REENTRANT -pipe -fno-strict-aliasing")
IF(WITH_COVERAGE)
ADD_PLATFORM_FLAGS("-fprofile-arcs -ftest-coverage")
ENDIF(WITH_COVERAGE)
IF(WITH_WARNINGS)
ADD_PLATFORM_FLAGS("-Wall -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused")
IF(CLANG)
ADD_PLATFORM_FLAGS("-std=gnu99")
ELSE(CLANG)
ADD_PLATFORM_FLAGS("-ansi")
ENDIF(CLANG)
ENDIF(WITH_WARNINGS)
IF(ANDROID)
ADD_PLATFORM_FLAGS("--sysroot=${PLATFORM_ROOT}")
ADD_PLATFORM_FLAGS("-ffunction-sections -funwind-tables")
ADD_PLATFORM_FLAGS("-DANDROID")
ADD_PLATFORM_FLAGS("-Wa,--noexecstack")
IF(TARGET_ARM)
ADD_PLATFORM_FLAGS("-fpic -fstack-protector")
ADD_PLATFORM_FLAGS("-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__")
IF(TARGET_ARMV7)
ADD_PLATFORM_FLAGS("-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -march=armv7-a -Wl,--fix-cortex-a8")
ELSEIF(TARGET_ARMV5)
ADD_PLATFORM_FLAGS("-march=armv5te -mtune=xscale -msoft-float")
ENDIF(TARGET_ARMV7)
SET(TARGET_THUMB ON)
IF(TARGET_THUMB)
ADD_PLATFORM_FLAGS("-mthumb -fno-strict-aliasing -finline-limit=64")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -marm")
ELSE(TARGET_THUMB)
ADD_PLATFORM_FLAGS("-funswitch-loops -finline-limit=300")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing")
ENDIF(TARGET_THUMB)
ELSEIF(TARGET_X86)
# Optimizations for Intel Atom
ADD_PLATFORM_FLAGS("-march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32 -flto -ffast-math -funroll-loops")
ADD_PLATFORM_FLAGS("-fstack-protector -funswitch-loops -finline-limit=300")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -fstrict-aliasing")
SET(DEBUG_CFLAGS "${DEBUG_CFLAGS} -fno-strict-aliasing")
ELSEIF(TARGET_MIPS)
ADD_PLATFORM_FLAGS("-fpic -finline-functions -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -fno-strict-aliasing")
SET(RELEASE_CFLAGS "${RELEASE_CFLAGS} -funswitch-loops -finline-limit=300")
ENDIF(TARGET_ARM)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -L${PLATFORM_ROOT}/usr/lib")
ENDIF(ANDROID)
IF(APPLE)
ADD_PLATFORM_FLAGS("-gdwarf-2")
ENDIF(APPLE)
# Fix "relocation R_X86_64_32 against.." error on x64 platforms
IF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS)
SET(PLATFORM_CFLAGS "-fPIC ${PLATFORM_CFLAGS}")
ADD_PLATFORM_FLAGS("-fPIC")
ENDIF(TARGET_X64 AND WITH_STATIC AND NOT WITH_STATIC_DRIVERS)
SET(PLATFORM_CXXFLAGS ${PLATFORM_CFLAGS})
SET(PLATFORM_CXXFLAGS "${PLATFORM_CXXFLAGS} -ftemplate-depth-48")
IF(NOT APPLE)
SET(PLATFORM_LINKFLAGS "${PLATFORM_LINKFLAGS} -Wl,--no-undefined -Wl,--as-needed")
@ -612,125 +910,146 @@ MACRO(NL_SETUP_BUILD_FLAGS)
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE)
ENDMACRO(NL_SETUP_BUILD_FLAGS)
# Macro to create x_ABSOLUTE_PREFIX from x_PREFIX
MACRO(NL_MAKE_ABSOLUTE_PREFIX NAME_RELATIVE NAME_ABSOLUTE)
IF(IS_ABSOLUTE "${${NAME_RELATIVE}}")
SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
ELSE(IS_ABSOLUTE "${${NAME_RELATIVE}}")
IF(WIN32)
SET(${NAME_ABSOLUTE} ${${NAME_RELATIVE}})
ELSE(WIN32)
SET(${NAME_ABSOLUTE} ${CMAKE_INSTALL_PREFIX}/${${NAME_RELATIVE}})
ENDIF(WIN32)
ENDIF(IS_ABSOLUTE "${${NAME_RELATIVE}}")
ENDMACRO(NL_MAKE_ABSOLUTE_PREFIX)
MACRO(NL_SETUP_PREFIX_PATHS)
## Allow override of install_prefix/etc path.
IF(NOT NL_ETC_PREFIX)
IF(WIN32)
SET(NL_ETC_PREFIX "../etc/nel" CACHE PATH "Installation path for configurations")
SET(NL_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
ELSE(WIN32)
SET(NL_ETC_PREFIX "${CMAKE_INSTALL_PREFIX}/etc/nel" CACHE PATH "Installation path for configurations")
SET(NL_ETC_PREFIX "etc/nel" CACHE PATH "Installation path for configurations")
ENDIF(WIN32)
ENDIF(NOT NL_ETC_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(NL_ETC_PREFIX NL_ETC_ABSOLUTE_PREFIX)
## Allow override of install_prefix/share path.
IF(NOT NL_SHARE_PREFIX)
IF(WIN32)
SET(NL_SHARE_PREFIX "../share/nel" CACHE PATH "Installation path for data.")
SET(NL_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
ELSE(WIN32)
SET(NL_SHARE_PREFIX "${CMAKE_INSTALL_PREFIX}/share/nel" CACHE PATH "Installation path for data.")
SET(NL_SHARE_PREFIX "share/nel" CACHE PATH "Installation path for data.")
ENDIF(WIN32)
ENDIF(NOT NL_SHARE_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(NL_SHARE_PREFIX NL_SHARE_ABSOLUTE_PREFIX)
## Allow override of install_prefix/sbin path.
IF(NOT NL_SBIN_PREFIX)
IF(WIN32)
SET(NL_SBIN_PREFIX "../sbin" CACHE PATH "Installation path for admin tools and services.")
SET(NL_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ELSE(WIN32)
SET(NL_SBIN_PREFIX "${CMAKE_INSTALL_PREFIX}/sbin" CACHE PATH "Installation path for admin tools and services.")
SET(NL_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.")
ENDIF(WIN32)
ENDIF(NOT NL_SBIN_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(NL_SBIN_PREFIX NL_SBIN_ABSOLUTE_PREFIX)
## Allow override of install_prefix/bin path.
IF(NOT NL_BIN_PREFIX)
IF(WIN32)
SET(NL_BIN_PREFIX "../bin" CACHE PATH "Installation path for tools and applications.")
SET(NL_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ELSE(WIN32)
SET(NL_BIN_PREFIX "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation path for tools and applications.")
SET(NL_BIN_PREFIX "bin" CACHE PATH "Installation path for tools and applications.")
ENDIF(WIN32)
ENDIF(NOT NL_BIN_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(NL_BIN_PREFIX NL_BIN_ABSOLUTE_PREFIX)
## Allow override of install_prefix/lib path.
IF(NOT NL_LIB_PREFIX)
IF(WIN32)
SET(NL_LIB_PREFIX "../lib" CACHE PATH "Installation path for libraries.")
ELSE(WIN32)
IF(CMAKE_LIBRARY_ARCHITECTURE)
SET(NL_LIB_PREFIX "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
ELSE(CMAKE_LIBRARY_ARCHITECTURE)
SET(NL_LIB_PREFIX "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation path for libraries.")
ENDIF(CMAKE_LIBRARY_ARCHITECTURE)
ENDIF(WIN32)
IF(LIBRARY_ARCHITECTURE)
SET(NL_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
ELSE(LIBRARY_ARCHITECTURE)
SET(NL_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.")
ENDIF(LIBRARY_ARCHITECTURE)
ENDIF(NOT NL_LIB_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(NL_LIB_PREFIX NL_LIB_ABSOLUTE_PREFIX)
## Allow override of install_prefix/lib path.
IF(NOT NL_DRIVER_PREFIX)
IF(WIN32)
SET(NL_DRIVER_PREFIX "../lib" CACHE PATH "Installation path for drivers.")
SET(NL_DRIVER_PREFIX "." CACHE PATH "Installation path for drivers.")
ELSE(WIN32)
IF(CMAKE_LIBRARY_ARCHITECTURE)
SET(NL_DRIVER_PREFIX "${CMAKE_INSTALL_PREFIX}/lib/${CMAKE_LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.")
ELSE(CMAKE_LIBRARY_ARCHITECTURE)
SET(NL_DRIVER_PREFIX "${CMAKE_INSTALL_PREFIX}/lib/nel" CACHE PATH "Installation path for drivers.")
ENDIF(CMAKE_LIBRARY_ARCHITECTURE)
IF(LIBRARY_ARCHITECTURE)
SET(NL_DRIVER_PREFIX "lib/${LIBRARY_ARCHITECTURE}/nel" CACHE PATH "Installation path for drivers.")
ELSE(LIBRARY_ARCHITECTURE)
SET(NL_DRIVER_PREFIX "lib/nel" CACHE PATH "Installation path for drivers.")
ENDIF(LIBRARY_ARCHITECTURE)
ENDIF(WIN32)
ENDIF(NOT NL_DRIVER_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(NL_DRIVER_PREFIX NL_DRIVER_ABSOLUTE_PREFIX)
ENDMACRO(NL_SETUP_PREFIX_PATHS)
MACRO(RYZOM_SETUP_PREFIX_PATHS)
## Allow override of install_prefix path.
IF(NOT RYZOM_PREFIX)
IF(WIN32)
SET(RYZOM_PREFIX "." CACHE PATH "Installation path")
ELSE(WIN32)
SET(RYZOM_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Installation path")
ENDIF(WIN32)
ENDIF(NOT RYZOM_PREFIX)
## Allow override of install_prefix/etc path.
IF(NOT RYZOM_ETC_PREFIX)
IF(WIN32)
SET(RYZOM_ETC_PREFIX "." CACHE PATH "Installation path for configurations")
ELSE(WIN32)
SET(RYZOM_ETC_PREFIX "${RYZOM_PREFIX}/etc/ryzom" CACHE PATH "Installation path for configurations")
SET(RYZOM_ETC_PREFIX "etc/ryzom" CACHE PATH "Installation path for configurations")
ENDIF(WIN32)
ENDIF(NOT RYZOM_ETC_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_ETC_PREFIX RYZOM_ETC_ABSOLUTE_PREFIX)
## Allow override of install_prefix/share path.
IF(NOT RYZOM_SHARE_PREFIX)
IF(WIN32)
SET(RYZOM_SHARE_PREFIX "." CACHE PATH "Installation path for data.")
ELSE(WIN32)
SET(RYZOM_SHARE_PREFIX "${RYZOM_PREFIX}/share/ryzom" CACHE PATH "Installation path for data.")
SET(RYZOM_SHARE_PREFIX "share/ryzom" CACHE PATH "Installation path for data.")
ENDIF(WIN32)
ENDIF(NOT RYZOM_SHARE_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SHARE_PREFIX RYZOM_SHARE_ABSOLUTE_PREFIX)
## Allow override of install_prefix/sbin path.
IF(NOT RYZOM_SBIN_PREFIX)
IF(WIN32)
SET(RYZOM_SBIN_PREFIX "." CACHE PATH "Installation path for admin tools and services.")
ELSE(WIN32)
SET(RYZOM_SBIN_PREFIX "${RYZOM_PREFIX}/sbin" CACHE PATH "Installation path for admin tools and services.")
SET(RYZOM_SBIN_PREFIX "sbin" CACHE PATH "Installation path for admin tools and services.")
ENDIF(WIN32)
ENDIF(NOT RYZOM_SBIN_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_SBIN_PREFIX RYZOM_SBIN_ABSOLUTE_PREFIX)
## Allow override of install_prefix/bin path.
IF(NOT RYZOM_BIN_PREFIX)
IF(WIN32)
SET(RYZOM_BIN_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ELSE(WIN32)
SET(RYZOM_BIN_PREFIX "${RYZOM_PREFIX}/bin" CACHE PATH "Installation path for tools.")
SET(RYZOM_BIN_PREFIX "bin" CACHE PATH "Installation path for tools.")
ENDIF(WIN32)
ENDIF(NOT RYZOM_BIN_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_BIN_PREFIX RYZOM_BIN_ABSOLUTE_PREFIX)
## Allow override of install_prefix/lib path.
IF(NOT RYZOM_LIB_PREFIX)
IF(LIBRARY_ARCHITECTURE)
SET(RYZOM_LIB_PREFIX "lib/${LIBRARY_ARCHITECTURE}" CACHE PATH "Installation path for libraries.")
ELSE(LIBRARY_ARCHITECTURE)
SET(RYZOM_LIB_PREFIX "lib" CACHE PATH "Installation path for libraries.")
ENDIF(LIBRARY_ARCHITECTURE)
ENDIF(NOT RYZOM_LIB_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_LIB_PREFIX RYZOM_LIB_ABSOLUTE_PREFIX)
## Allow override of install_prefix/games path.
IF(NOT RYZOM_GAMES_PREFIX)
IF(WIN32)
SET(RYZOM_GAMES_PREFIX "." CACHE PATH "Installation path for tools and applications.")
ELSE(WIN32)
SET(RYZOM_GAMES_PREFIX "${RYZOM_PREFIX}/games" CACHE PATH "Installation path for client.")
SET(RYZOM_GAMES_PREFIX "games" CACHE PATH "Installation path for client.")
ENDIF(WIN32)
ENDIF(NOT RYZOM_GAMES_PREFIX)
NL_MAKE_ABSOLUTE_PREFIX(RYZOM_GAMES_PREFIX RYZOM_GAMES_ABSOLUTE_PREFIX)
ENDMACRO(RYZOM_SETUP_PREFIX_PATHS)
@ -742,11 +1061,41 @@ MACRO(SETUP_EXTERNAL)
IF(WIN32)
FIND_PACKAGE(External REQUIRED)
IF(MSVC10)
IF(NOT MSVC10_REDIST_DIR)
IF(NOT VC_DIR)
SET(VC_DIR $ENV{VC_DIR})
ENDIF(NOT VC_DIR)
IF(MSVC11)
IF(NOT MSVC_REDIST_DIR)
# If you have VC++ 2012 Express, put x64/Microsoft.VC110.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC_REDIST_DIR)
IF(NOT VC_DIR)
IF(NOT VC_ROOT_DIR)
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\11.0_Config;InstallDir]" ABSOLUTE)
# VC_ROOT_DIR is set to "registry" when a key is not found
IF(VC_ROOT_DIR MATCHES "registry")
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\WDExpress\\11.0_Config\\Setup\\VC;InstallDir]" ABSOLUTE)
IF(VC_ROOT_DIR MATCHES "registry")
SET(VS110COMNTOOLS $ENV{VS110COMNTOOLS})
IF(VS110COMNTOOLS)
FILE(TO_CMAKE_PATH ${VS110COMNTOOLS} VC_ROOT_DIR)
ENDIF(VS110COMNTOOLS)
IF(NOT VC_ROOT_DIR)
MESSAGE(FATAL_ERROR "Unable to find VC++ 2012 directory!")
ENDIF(NOT VC_ROOT_DIR)
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(VC_ROOT_DIR MATCHES "registry")
ENDIF(NOT VC_ROOT_DIR)
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR})
ENDIF(NOT VC_DIR)
ELSEIF(MSVC10)
IF(NOT MSVC_REDIST_DIR)
# If you have VC++ 2010 Express, put x64/Microsoft.VC100.CRT/*.dll in ${EXTERNAL_PATH}/redist
SET(MSVC10_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC10_REDIST_DIR)
SET(MSVC_REDIST_DIR "${EXTERNAL_PATH}/redist")
ENDIF(NOT MSVC_REDIST_DIR)
IF(NOT VC_DIR)
IF(NOT VC_ROOT_DIR)
@ -755,7 +1104,10 @@ MACRO(SETUP_EXTERNAL)
IF(VC_ROOT_DIR MATCHES "registry")
GET_FILENAME_COMPONENT(VC_ROOT_DIR "[HKEY_CURRENT_USER\\Software\\Microsoft\\VCExpress\\10.0_Config;InstallDir]" ABSOLUTE)
IF(VC_ROOT_DIR MATCHES "registry")
FILE(TO_CMAKE_PATH $ENV{VS100COMNTOOLS} VC_ROOT_DIR)
SET(VS100COMNTOOLS $ENV{VS100COMNTOOLS})
IF(VS100COMNTOOLS)
FILE(TO_CMAKE_PATH ${VS100COMNTOOLS} VC_ROOT_DIR)
ENDIF(VS100COMNTOOLS)
IF(NOT VC_ROOT_DIR)
MESSAGE(FATAL_ERROR "Unable to find VC++ 2010 directory!")
ENDIF(NOT VC_ROOT_DIR)
@ -765,7 +1117,7 @@ MACRO(SETUP_EXTERNAL)
# convert IDE fullpath to VC++ path
STRING(REGEX REPLACE "Common7/.*" "VC" VC_DIR ${VC_ROOT_DIR})
ENDIF(NOT VC_DIR)
ELSE(MSVC10)
ELSE(MSVC11)
IF(NOT VC_DIR)
IF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
# convert IDE fullpath to VC++ path
@ -775,7 +1127,7 @@ MACRO(SETUP_EXTERNAL)
STRING(REGEX REPLACE "VC/bin/.+" "VC" VC_DIR ${CMAKE_CXX_COMPILER})
ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES "Common7")
ENDIF(NOT VC_DIR)
ENDIF(MSVC10)
ENDIF(MSVC11)
ELSE(WIN32)
IF(APPLE)
IF(WITH_STATIC_EXTERNAL)
@ -800,7 +1152,7 @@ MACRO(SETUP_EXTERNAL)
FIND_PACKAGE(WindowsSDK REQUIRED)
# use VC++ and Windows SDK include paths
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIR})
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIRS})
ENDIF(MSVC)
ENDIF(WITH_STLPORT)
ENDMACRO(SETUP_EXTERNAL)

@ -43,15 +43,14 @@
#cmakedefine NL_DSOUND_AVAILABLE ${NL_DSOUND_AVAILABLE}
#cmakedefine NL_XAUDIO2_AVAILABLE ${NL_XAUDIO2_AVAILABLE}
#cmakedefine NL_BIN_PREFIX "${NL_BIN_PREFIX}"
#cmakedefine NL_ETC_PREFIX "${NL_ETC_PREFIX}"
#cmakedefine NL_SHARE_PREFIX "${NL_SHARE_PREFIX}"
#cmakedefine NL_LIB_PREFIX "${NL_LIB_PREFIX}"
#cmakedefine NL_DRIVER_PREFIX "${NL_DRIVER_PREFIX}"
#cmakedefine NL_BIN_PREFIX "${NL_BIN_ABSOLUTE_PREFIX}"
#cmakedefine NL_ETC_PREFIX "${NL_ETC_ABSOLUTE_PREFIX}"
#cmakedefine NL_SHARE_PREFIX "${NL_SHARE_ABSOLUTE_PREFIX}"
#cmakedefine NL_LIB_PREFIX "${NL_LIB_ABSOLUTE_PREFIX}"
#cmakedefine NL_DRIVER_PREFIX "${NL_DRIVER_ABSOLUTE_PREFIX}"
#cmakedefine RYZOM_PREFIX "${RYZOM_PREFIX}"
#cmakedefine RYZOM_BIN_PREFIX "${RYZOM_BIN_PREFIX}"
#cmakedefine RYZOM_ETC_PREFIX "${RYZOM_ETC_PREFIX}"
#cmakedefine RYZOM_SHARE_PREFIX "${RYZOM_SHARE_PREFIX}"
#cmakedefine RYZOM_BIN_PREFIX "${RYZOM_BIN_ABSOLUTE_PREFIX}"
#cmakedefine RYZOM_ETC_PREFIX "${RYZOM_ETC_ABSOLUTE_PREFIX}"
#cmakedefine RYZOM_SHARE_PREFIX "${RYZOM_SHARE_ABSOLUTE_PREFIX}"
#endif // CONFIG_H

@ -44,8 +44,8 @@ ENDIF(WITH_GTK)
IF(WITH_INSTALL_LIBRARIES)
IF(UNIX)
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
SET(libdir ${CMAKE_INSTALL_PREFIX}/lib)
SET(exec_prefix ${NL_BIN_ABSOLUTE_PREFIX})
SET(libdir ${NL_LIB_ABSOLUTE_PREFIX})
SET(includedir ${CMAKE_INSTALL_PREFIX}/include)
SET(enable_ligo ${WITH_LIGO})
SET(enable_logic ${WITH_LOGIC})
@ -56,7 +56,7 @@ IF(WITH_INSTALL_LIBRARIES)
SET(enable_sound ${WITH_SOUND})
CONFIGURE_FILE(nel-config.in ${CMAKE_CURRENT_BINARY_DIR}/nel-config)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/nel-config DESTINATION bin)
INSTALL(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/nel-config DESTINATION ${NL_BIN_PREFIX})
ENDIF(UNIX)
ADD_SUBDIRECTORY(include)

@ -71,7 +71,7 @@ public:
// For clipTrav. cleared at beginning of CClipTrav::traverse
void clearVisibleList();
// For ClipTrav only. NB: list is cleared at begining of traverse(). NB: only CTransform are supported
// For ClipTrav only. NB: list is cleared at begininng of traverse(). NB: only CTransform are supported
void addVisibleModel(CTransform *model)
{
_VisibleList[_CurrentNumVisibleModels]= model;

@ -68,7 +68,7 @@ public:
class CCamera : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();

@ -93,7 +93,7 @@ public:
/// \name Visible List mgt. Those visible models are updated each traverse().
//@{
// NB: list is cleared at begining of traverse().
// NB: list is cleared at beginning of traverse().
void addVisibleModel(CTransform *model)
{
model->_IndexInVisibleList= _CurrentNumVisibleModels;

@ -293,6 +293,11 @@ public:
*/
virtual void forceDXTCCompression(bool dxtcComp)=0;
/** if different from 0, enable anisotropic filter on textures. -1 enables max value.
* Default is 0.
*/
virtual void setAnisotropicFilter(sint filter)=0;
/** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..)
* to be divided by Divisor (2, 4, 8...)
* Default is 1.

@ -471,6 +471,7 @@ public:
virtual void delete3dMouseListener (U3dMouseListener *listener);
virtual TPolygonMode getPolygonMode ();
virtual void forceDXTCCompression(bool dxtcComp);
virtual void setAnisotropicFilter(sint filter);
virtual void forceTextureResize(uint divisor);
virtual void forceNativeFragmentPrograms(bool nativeOnly);
virtual bool setMonitorColorProperties (const CMonitorColorProperties &properties);

@ -81,14 +81,14 @@ class IDriver;
class CLandscapeGlobals
{
public:
// LANDSCAPE RENDERING CONTEXT. Landscape must setup it at the begining at refine()/render().
// LANDSCAPE RENDERING CONTEXT. Landscape must setup it at the beginning at refine()/render().
// The current date of LandScape for refine only.
static sint CurrentDate;
// The current date of LandScape for render only.
static sint CurrentRenderDate;
// The center view for refinement.
static CVector RefineCenter;
// What is the treshold for tessellation.
// What is the threshold for tessellation.
static float RefineThreshold;
// Guess.
static float OORefineThreshold;
@ -143,7 +143,7 @@ public:
static CLandscapeVBAllocator *CurrentTileVBAllocator;
// PATCH GLOBAL INTERFACE. patch must setup them at the begining at refine()/render().
// PATCH GLOBAL INTERFACE. patch must setup them at the beginning at refine()/render().
// NO!!! REMIND: can't have any patch global, since a propagated split()/updateErrorMetric()
// can arise. must use Patch pointer.
@ -158,7 +158,7 @@ public:
// ***************************************************************************
// Out of CLandscapeGlobals, because myabe used in __asm{}
// Out of CLandscapeGlobals, because maybe used in __asm{}
extern uint NL3D_LandscapeGlobals_PassNTri;
extern void *NL3D_LandscapeGlobals_PassTriCurPtr;
extern CIndexBuffer::TFormat NL3D_LandscapeGlobals_PassTriFormat;

@ -42,7 +42,7 @@ const NLMISC::CClassId LandscapeModelId=NLMISC::CClassId(0x5a573b55, 0x6b395829
class CLandscapeModel : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -165,7 +165,7 @@ public:
// For clipTrav. cleared at beginning of CClipTrav::traverse
void clearVisibleList();
// For ClipTrav only. NB: list is cleared at begining of traverse().
// For ClipTrav only. NB: list is cleared at beginning of traverse().
void addVisibleModel(CTransform *model)
{
_VisibleList[_CurrentNumVisibleModels]= model;

@ -53,7 +53,7 @@ const NLMISC::CClassId MeshBaseInstanceId=NLMISC::CClassId(0xef44331, 0x739f6bc
class CMeshBaseInstance : public CTransformShape
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -49,7 +49,7 @@ const NLMISC::CClassId MeshInstanceId=NLMISC::CClassId(0x6bfe0a34, 0x23b26dc9);
class CMeshInstance : public CMeshBaseInstance
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -49,7 +49,7 @@ const NLMISC::CClassId MeshMRMInstanceId=NLMISC::CClassId(0xec608f3, 0x1111c33)
class CMeshMRMInstance : public CMeshBaseInstance
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
protected:

@ -49,7 +49,7 @@ const NLMISC::CClassId MeshMRMSkinnedInstanceId=NLMISC::CClassId(0x6cfd2619, 0x
class CMeshMRMSkinnedInstance : public CMeshBaseInstance
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
protected:

@ -61,7 +61,7 @@ public:
Lod0Blend = 0x1,
};
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
/// Last Matrix date for Lods

@ -29,7 +29,7 @@ namespace NL3D {
/**
* This vertex program is used to perform perpixel lighting with meshs. Its ouputs are :
* This vertex program is used to perform perpixel lighting with meshs. Its outputs are :
*
* Coord Tex 0 : duplicate the tex Coord 0 set from the v.b.
* Coord Tex 1 : The light vector in tangent space.

@ -808,7 +808,7 @@ private:
CTessFarVertex BaseFarVertices[4];
// Local info for CTessFace tiles. CPatch must setup them at the begining at refine()/render().
// Local info for CTessFace tiles. CPatch must setup them at the beginning at refine()/render().
// For Far Texture coordinates.
float Far0UScale, Far0VScale, Far0UBias, Far0VBias;
float Far1UScale, Far1VScale, Far1UBias, Far1VBias;

@ -55,7 +55,7 @@ const NLMISC::CClassId PointLightModelId=NLMISC::CClassId(0x7e842eba, 0x140b6c6
class CPointLightModel : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();

@ -128,7 +128,7 @@ inline uint32 CPSAttribMakerBinOp<uint32>::getMinValue(void) const
{
uint32 lhs = _Arg[0]->getMinValue();
uint32 rhs = _Arg[1]->getMaxValue();
return rhs > rhs ? 0 : lhs - rhs;
return lhs > rhs ? 0 : lhs - rhs;
}
break;
default:
@ -153,7 +153,7 @@ inline uint32 CPSAttribMakerBinOp<uint32>::getMaxValue(void) const
{
uint32 lhs = _Arg[0]->getMaxValue();
uint32 rhs = _Arg[1]->getMinValue();
return rhs > rhs ? 0 : lhs - rhs;
return lhs > rhs ? 0 : lhs - rhs;
}
break;
default:

@ -29,7 +29,7 @@ namespace NL3D {
/*
* In this file, we define several template that helps to create attributes maker such as gradient (of float, int, vector etc)
* attributes maker are used in the particle system to generate values, such as size, color etc. see ps_attrib_maker.h
* for more informations
* for more information
*/

@ -55,7 +55,7 @@ const NLMISC::CClassId QuadGridClipManagerId=NLMISC::CClassId(0x1ffb079a, 0x6c5
class CQuadGridClipManager : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -227,7 +227,7 @@ public:
enum {MaxVPLight= 4};
/** reset the lighting setup in the driver (all lights are disabled).
* called at begining of traverse(). Must be called by any model (before and after rendering)
* called at beginning of traverse(). Must be called by any model (before and after rendering)
* that wish to use CDriver::setLight() instead of the standard behavior with changeLightSetup()
*/
void resetLightSetup();

@ -39,7 +39,7 @@ const NLMISC::CClassId RootModelId=NLMISC::CClassId(0x25f0505d, 0x75c69f9);
class CRootModel : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();

@ -54,7 +54,7 @@ public:
CSegRemanence(CSegRemanence &other);
CSegRemanence &operator = (CSegRemanence &other);
//@}
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
/// to instanciate that model from a scene
static CTransform *creator() { return new CSegRemanence; }

@ -79,7 +79,7 @@ public:
/// max number of bones supported in skeleton
enum { MaxNumBones = 256 };
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -90,7 +90,7 @@ const NLMISC::CClassId TransformId=NLMISC::CClassId(0x174750cb, 0xf952024);
class CTransform : public ITransformable
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
/// get the scene which has created us
@ -113,7 +113,7 @@ public:
/**
* Extra init for a model. this method is called by the framework at the very end of CScene::createModel()
* Warning! if the model is a CTransformShape, then when initModel() is called, Shape and other related member/setup
* of IShape::createInstance() are not yet done (because createModel() is called at the begining in createInstance()).
* of IShape::createInstance() are not yet done (because createModel() is called at the beginning in createInstance()).
*
* Because initModel() is called at the very end, deriver could implement anything like creating other models,
* but not deleting this model...

@ -55,7 +55,7 @@ const NLMISC::CClassId TransformShapeId=NLMISC::CClassId(0x1e6115e6, 0x63502517
class CTransformShape : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -660,6 +660,11 @@ public:
*/
virtual void forceDXTCCompression(bool dxtcComp)=0;
/** if different from 0, enable anisotropic filter on textures. -1 enables max value.
* Default is 0.
*/
virtual void setAnisotropicFilter(sint filter)=0;
/** if !=1, force mostly all the textures (but TextureFonts lightmaps, interfaces etc..)
* to be divided by Divisor (2, 4, 8...)
* Default is 1.

@ -48,7 +48,7 @@ const NLMISC::CClassId VegetableBlendLayerModelId=NLMISC::CClassId(0x77375163,
class CVegetableBlendLayerModel : public CTransform
{
public:
/// Call at the begining of the program, to register the model
/// Call at the beginning of the program, to register the model
static void registerBasic();
public:

@ -188,7 +188,7 @@ public:
* \warning: Only syntax is checked. It doesn't check that a register has been initialised before use.
* \param src The input text of a vertex program, in OpenGL format.
* \param result The result program.
* \param errorOuput If parsing failed, contains the reason
* \param errorOutput If parsing failed, contains the reason
* \result true if the parsing succeeded
*/
bool parse(const char *src, TProgram &result, std::string &errorOutput);

@ -4,6 +4,10 @@ IF(WITH_3D)
SUBDIRS(3d)
ENDIF(WITH_3D)
IF(WITH_GUI)
ADD_SUBDIRECTORY(gui)
ENDIF(WITH_GUI)
IF(WITH_GEORGES)
SUBDIRS(georges)
ENDIF(WITH_GEORGES)

@ -19,6 +19,9 @@
#include "nel/misc/types_nl.h"
// Include from libxml2
#include <libxml/parser.h>
namespace NLGEORGES
{

@ -0,0 +1,3 @@
FILE(GLOB HEADERS *.h)
INSTALL(FILES ${HEADERS} DESTINATION include/nel/gui COMPONENT headers)

@ -0,0 +1,156 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_ACTION_HANDLER_H
#define NL_ACTION_HANDLER_H
#include "nel/misc/types_nl.h"
#include <libxml/parser.h>
#include "nel/misc/types_nl.h"
#include "nel/misc/debug.h"
#include "nel/misc/xml_auto_ptr.h"
#include <map>
namespace NLGUI
{
class CCtrlBase;
/**
* interface for action handlers
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class IActionHandler
{
public:
// Execute the answer to the action
// Params has the following form : paramName=theParam|paramName2=theParam2|...
virtual void execute (CCtrlBase * /* pCaller */, const std::string &/* sParams */) { }
virtual ~IActionHandler() {}
static std::string getParam (const std::string &Params, const std::string &ParamName);
static void getAllParams (const std::string &Params, std::vector< std::pair<std::string,std::string> > &AllParams);
};
/**
interface for action handlers factory
no release in this factory : a handler must be destroyed by the control that created it
*/
class CAHManager
{
public:
typedef std::map< std::string, IActionHandler* > TFactoryMap;
typedef std::map< IActionHandler*, std::string > TNameMap;
static CAHManager* getInstance()
{
if (_GlobalInstance == NULL)
_GlobalInstance = new CAHManager;
return _GlobalInstance;
}
/// return pointer to action handler or null if it doesn't exist
IActionHandler *getActionHandler(const std::string &name) const
{
if( name.empty() )
return NULL;
TFactoryMap::const_iterator it = FactoryMap.find(name);
if( it == FactoryMap.end() )
{
nlwarning( "Couldn't find action handler %s", name.c_str() );
return NULL;
}
else
return it->second;
}
/// Return the name of the action handler given its pointer
const std::string &getActionHandlerName(IActionHandler *pAH) const
{
TNameMap::const_iterator it = NameMap.find(pAH);
return it != NameMap.end() ? it->second : EmptyName;
}
/// map of action handler factories
TFactoryMap FactoryMap;
TNameMap NameMap;
std::string EmptyName;
/// return the Action Handler 'name'. if name is of form 'ah:params', then params are filled (NB: else not changed)
IActionHandler *getAH(const std::string &name, std::string &params);
IActionHandler *getAH(const std::string &name, class CStringShared &params);
/** common method to parse Action Handler from a xml node
* \param ahId eg: "onclick_l"
* \param paramId eg: "params_l".
* \param params returned parameters.
* NB: if paramId is NULL, empty or does not exist in the xmlNode, then the optional param in ahId (eg: "show:phrase_book")
* is taken
* NB: if none of the optional param in ahId, or the specified param are filled/found, then params is not changed
*/
void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, std::string &params);
void parseAH(xmlNodePtr cur, const char *ahId, const char *paramId, IActionHandler *&ahRet, class CStringShared &params);
/// Get the AH name from ptr
const std::string &getAHName(IActionHandler *pAH){ return getActionHandlerName(pAH); }
void runActionHandler(const std::string &AHName, CCtrlBase *pCaller, const std::string &Params=std::string("") );
void runActionHandler(IActionHandler *ah, CCtrlBase *pCaller, const std::string &Params=std::string("") );
// Submit a generic event
void submitEvent( const std::string &evt );
static void setEditorMode( bool b ){ editorMode = b; }
private:
CAHManager(){}
static CAHManager *_GlobalInstance;
static bool editorMode;
};
/// Ah name must all be lower case
#define REGISTER_ACTION_HANDLER(handler ,name) \
class handler##Factory : public handler \
{ \
public: \
handler##Factory () \
{ \
nlassert(name!=NULL); \
const char *c= name; \
while(*c!='\0') \
{ \
nlassert(islower(*c) || !isalpha(*c)); \
c++; \
} \
CAHManager *pAHFM = CAHManager::getInstance(); \
pAHFM->FactoryMap.insert(CAHManager::TFactoryMap::value_type(name,this)); \
pAHFM->NameMap.insert(CAHManager::TNameMap::value_type(this,name)); \
}; \
}; \
handler##Factory handler##FactoryInstance ; \
\
}
#endif //NL_ACTION_HANDLER_H

@ -0,0 +1,190 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_BASE_H
#define RZ_CTRL_BASE_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_base.h"
#include "nel/gui/event_descriptor.h"
namespace NLGUI
{
class CCtrlBase : public CViewBase
{
public:
// Tooltip mode
enum TToolTipParentType
{
TTMouse= 0, // The tooltip is displayed relatively to the mouse when it appears
TTCtrl= 1, // The tooltip is displayed relatively to the ctrl it comes from when it apeears
TTWindow= 2, // The tooltip is displayed relatively to the window where the control lies.
TTSpecialWindow= 3, // The tooltip is displayed relatively to a special user window
NumToolTipParentRef
};
public:
/// Constructor
CCtrlBase(const TCtorParam &param) : CViewBase(param)
{
_ToolTipInstant= true;
_ToolTipParent= TTCtrl;
// see interface.txt for meaning of auto
_ToolTipParentPosRef= Hotspot_TTAuto;
_ToolTipPosRef= Hotspot_TTAuto;
resizer = false;
}
/// Destructor
virtual ~CCtrlBase();
static std::string tooltipParentToString( TToolTipParentType type );
static TToolTipParentType stringToToolTipParent( const std::string &str );
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// special parse
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
/// Handle all events (implemented by derived classes) (return true to signal event handled)
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
/// Debug
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
/// Get the ContextHelp for this control. Default is to return _ContextHelp
virtual void getContextHelp(ucstring &help) const {help= _ContextHelp;}
/// Get the ContextHelp for this control, with tooltip specific code. Default behaviour is identical to getContextHelp.
virtual void getContextHelpToolTip(ucstring &help) const { getContextHelp(help); }
// Get the name of the context help window. Default to "context_help"
virtual std::string getContextHelpWindowName() const;
/// Get the ContextHelp ActionHandler. If "", noop
const std::string &getContextHelpActionHandler() const {return _OnContextHelp;}
/// Get the ContextHelp ActionHandler Params
const std::string &getContextHelpAHParams() const {return _OnContextHelpParams;}
/// true if both are empty
bool emptyContextHelp() const;
// Should return true if the context help should be displayed instantly
bool wantInstantContextHelp() const { return _ToolTipInstant; }
/// Set true if ToolTip should be displayed instantly
void setInstantContextHelp(bool instant) { _ToolTipInstant = instant;}
/** If ctrl has a non rectangle shape, perform further test to know
* if control should be taken in account for context help
*/
virtual bool preciseHitTest(sint32 /* x */, sint32 /* y */) const { return true; }
/// return the type of anchor for the tooltip of this control
TToolTipParentType getToolTipParent() const { return _ToolTipParent;}
const std::string &getToolTipSpecialParent() const {return _ToolTipSpecialParent.toString();}
/// Set the type of anchor for the tooltip of this control
void setToolTipParent(TToolTipParentType type) { _ToolTipParent = type; }
void setToolTipSpecialParent(const std::string &parent) { _ToolTipSpecialParent = parent; }
/// Get the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse)
THotSpot getToolTipParentPosRef() const { return _ToolTipParentPosRef;}
THotSpot getToolTipPosRef() const { return _ToolTipPosRef;}
THotSpot getToolTipParentPosRefAlt() const { return _ToolTipParentPosRefAlt;}
THotSpot getToolTipPosRefAlt() const { return _ToolTipPosRefAlt;}
/// Set the ToolTip pos references (parent relevant only if getToolTipParent()!=TTMouse)
void setToolTipParentPosRef(THotSpot pos) { _ToolTipParentPosRef = pos;}
void setToolTipPosRef(THotSpot pos) { _ToolTipPosRef = pos;}
/// replace the default contextHelp
ucstring getDefaultContextHelp() const {return _ContextHelp;}
void setDefaultContextHelp(const ucstring &help) {_ContextHelp= help;}
void setOnContextHelp(const std::string &help) {_OnContextHelp= help;}
void setOnContextHelpAHParams(const std::string &p) {_OnContextHelpParams= p;}
// called when this element or a son has been captured
virtual void elementCaptured(CCtrlBase * /* capturedElement */) {}
virtual bool isCtrl() const { return true; }
// Made for CtrlResizer to take the precedence over son controls.
virtual uint getDeltaDepth() const { return 0; }
// true if this ctrl is capturable (true by default, false for tooltip)
virtual bool isCapturable() const {return true;}
bool isResizer() const{ return resizer; }
// from CInterfaceElement
virtual void visit(CInterfaceElementVisitor *visitor);
/** test if virtual desktop change is possible while this element is captured by the mouse
* Useful for resizers
*/
virtual bool canChangeVirtualDesktop() const { return true; }
// called when keyboard capture has been lost
virtual void onKeyboardCaptureLost() {}
REFLECT_EXPORT_START(CCtrlBase, CViewBase)
REFLECT_UCSTRING("tooltip", getDefaultContextHelp, setDefaultContextHelp);
REFLECT_EXPORT_END
// special for mouse over : return true and fill the name of the cursor to display
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
virtual void serial(NLMISC::IStream &f);
uint32 getDepth( CInterfaceGroup *group );
protected:
// This is the ContextHelp filled by default in parse()
ucstring _ContextHelp;
CStringShared _OnContextHelp;
CStringShared _OnContextHelpParams;
CStringShared _ToolTipSpecialParent;
TToolTipParentType _ToolTipParent;
bool _ToolTipInstant : 1;
THotSpot _ToolTipParentPosRef : 6;
THotSpot _ToolTipPosRef : 6;
THotSpot _ToolTipParentPosRefAlt : 6;
THotSpot _ToolTipPosRefAlt : 6;
protected:
void convertTooltipHotSpot(const char *prop, THotSpot &parentHS, THotSpot &childHS);
static std::string TooltipHotSpotToString( THotSpot parent, THotSpot child );
void mapAHString( const std::string &key, const std::string &value );
std::string getAHString( const std::string &key ) const;
static std::map< std::string, std::map< std::string, std::string > > AHCache;
bool resizer;
};
}
#endif // RZ_VIEW_BASE_H
/* End of ctrl_base.h */

@ -0,0 +1,270 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_CTRL_BASE_BUTTON_H
#define NL_CTRL_BASE_BUTTON_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/action_handler.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Base Class For Buttons.
* \author Lionel Berenguier
* \author Nevrax France
* \date 2003
*/
class CCtrlBaseButton : public CCtrlBase
{
public:
enum EType { PushButton = 0, ToggleButton, RadioButton, ButtonTypeCount };
/// Constructor
CCtrlBaseButton(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual bool handleEvent (const NLGUI::CEventDescriptor& event);
/// \name Misc
// @{
void setType (EType t) { _Type = t; }
EType getType() { return _Type; }
std::string getTypeString() const;
void setTypeFromString( const std::string &type );
void setClickWhenPushed(bool click) { _ClickWhenPushed = click; }
bool getClickWhenPushed() const { return _ClickWhenPushed; }
void setPushed (bool state);
bool getPushed () const { return _Pushed; }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
// Set half tone mode for the display of frozen buttons. Default is true.
void setFrozenHalfTone(bool enabled);
bool getFrozenHalfTone() const { return _FrozenHalfTone; }
// if the radio is a radio button, then all radio button are unselected
void unselect();
// @}
/// \name Colors
// @{
void setColor(NLMISC::CRGBA col) { _ColorNormal = col; }
void setColorPushed(NLMISC::CRGBA col) { _ColorPushed = col; }
void setColorOver(NLMISC::CRGBA col) { _ColorOver = col; }
NLMISC::CRGBA getColor() const { return _ColorNormal; }
NLMISC::CRGBA getColorPushed() const { return _ColorPushed; }
NLMISC::CRGBA getColorOver() const { return _ColorOver; }
// Override because mustupdate 3 states
void setModulateGlobalColorAll(bool state);
void setModulateGlobalColorNormal(bool state) {_ModulateGlobalColorNormal= state;}
void setModulateGlobalColorPushed(bool state) {_ModulateGlobalColorPushed= state;}
void setModulateGlobalColorOver(bool state) {_ModulateGlobalColorOver= state;}
virtual sint32 getAlpha() const { return _ColorNormal.A; }
virtual void setAlpha (sint32 a) { _ColorOver.A = _ColorNormal.A = _ColorPushed.A = (uint8)a; }
std::string getColorAsString() const
{ return NLMISC::toString(_ColorNormal.R) + " " + NLMISC::toString(_ColorNormal.G) + " " +
NLMISC::toString(_ColorNormal.B) + " " + NLMISC::toString(_ColorNormal.A); }
std::string getColorOverAsString() const
{ return NLMISC::toString(_ColorOver.R) + " " + NLMISC::toString(_ColorOver.G) + " " +
NLMISC::toString(_ColorOver.B) + " " + NLMISC::toString(_ColorOver.A); }
std::string getColorPushedAsString() const
{ return NLMISC::toString(_ColorPushed.R) + " " + NLMISC::toString(_ColorPushed.G) + " " +
NLMISC::toString(_ColorPushed.B) + " " + NLMISC::toString(_ColorPushed.A); }
void setColorAsString(const std::string &col) { _ColorNormal = convertColor (col.c_str()); }
void setColorOverAsString(const std::string &col) { _ColorOver = convertColor (col.c_str()); }
void setColorPushedAsString(const std::string &col) { _ColorPushed = convertColor (col.c_str()); }
// @}
///\name radio button specific
//@{
/** Initialize radio button reference
* Advanced:
* NB: must call initRBRef() for radio button if button is created without parse().
* NB: setParent() must be called before (else assert)
*/
void initRBRef();
//@}
void initRBRefFromRadioButton(CCtrlBaseButton * pBut);
/// \name Handlers
// @{
// Event part
void setActionOnLeftClick (const std::string &actionHandlerName) { _AHOnLeftClickString = actionHandlerName; _AHOnLeftClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHLeftClickParams); }
void setActionOnLeftClickParams(const std::string &params) { _AHOnLeftClickStringParams = params; }
void setActionOnRightClick (const std::string &actionHandlerName) { _AHOnRightClick = CAHManager::getInstance()->getAH(actionHandlerName, _AHRightClickParams); }
void setActionOnClockTick (const std::string &ahName) { _AHOnClockTick = CAHManager::getInstance()->getAH(ahName, _AHClockTickParams); }
void setParamsOnLeftClick (const std::string &paramsHandlerName) { _AHLeftClickParams = paramsHandlerName; }
void setParamsOnRightClick (const std::string &paramsHandlerName) { _AHRightClickParams = paramsHandlerName; }
void setParamsOnClockTick (const std::string &ahParamsName) { _AHClockTickParams = ahParamsName; }
// get Event part
std::string _getActionOnOver() const{ return CAHManager::getInstance()->getAHName( _AHOnOver ); }
std::string _getActionOnLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftClick ); }
std::string _getActionOnLeftLongClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftLongClick ); }
std::string _getActionOnDblLeftClick() const { return CAHManager::getInstance()->getAHName( _AHOnLeftDblClick ); }
std::string _getActionOnRightClick() const { return CAHManager::getInstance()->getAHName( _AHOnRightClick ); }
std::string _getActionOnClockTick() const { return CAHManager::getInstance()->getAHName( _AHOnClockTick ); }
IActionHandler *getActionOnLeftClick () const { return _AHOnLeftClick; }
IActionHandler *getActionOnRightClick () const { return _AHOnRightClick; }
IActionHandler *getActionOnClockTick () const { return _AHOnClockTick; }
std::string _getParamsOnOver() const{ return _AHOverParams.toString(); }
std::string _getParamsOnLeftClick () const { return _AHLeftClickParams.toString(); }
const std::string &getParamsOnLeftClick () const { return _AHLeftClickParams; }
const std::string &getParamsOnRightClick () const { return _AHRightClickParams; }
const std::string &getParamsOnClockTick () const { return _AHClockTickParams; }
// run action on left click
void runLeftClickAction();
// Context menu accessor/ One for each button
void setListMenuLeft (const std::string &cm) { _ListMenuLeft = cm; }
void setListMenuRight (const std::string &cm) { _ListMenuRight = cm; }
void setListMenuBoth (const std::string &cm) { _ListMenuLeft= _ListMenuRight= cm; }
std::string getListMenuLeft () { return _ListMenuLeft.toString(); }
std::string getListMenuRight () { return _ListMenuRight.toString(); }
// @}
int luaRunLeftClickAction(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlBaseButton, CCtrlBase)
REFLECT_BOOL("pushed", getPushed, setPushed);
REFLECT_STRING("col_normal", getColorAsString, setColorAsString);
REFLECT_STRING("col_over", getColorOverAsString, setColorOverAsString);
REFLECT_STRING("col_pushed", getColorPushedAsString, setColorPushedAsString);
REFLECT_RGBA("col_normal_rgba", getColor, setColor);
REFLECT_RGBA("col_over_rgba", getColorOver, setColorOver);
REFLECT_RGBA("col_pushed_rgba", getColorPushed, setColorPushed);
REFLECT_BOOL("frozen", getFrozen, setFrozen);
REFLECT_BOOL("frozen_half_tone", getFrozenHalfTone, setFrozenHalfTone);
REFLECT_STRING("onclick_l", _getActionOnLeftClick, setActionOnLeftClick);
REFLECT_STRING("params_l", _getParamsOnLeftClick, setParamsOnLeftClick);
REFLECT_LUA_METHOD("runLeftClickAction", luaRunLeftClickAction);
REFLECT_EXPORT_END
protected:
EType _Type;
// State
bool _Pushed : 1;
bool _Over : 1;
bool _OverWhenPushed : 1;
bool _Frozen : 1;
bool _FrozenHalfTone : 1;
bool _ClickWhenPushed : 1;
bool _ModulateGlobalColorNormal : 1;
bool _ModulateGlobalColorPushed : 1;
bool _ModulateGlobalColorOver : 1;
bool _LeftLongClickHandled : 1; // Is it already handled ?
bool _LeftDblClickHandled : 1;
///\name radio button specific
//@{
CCtrlBaseButton *_RBRefBut; // The reference button. If NULL the control do not own the reference
// There is only one radio button per group that own the reference (the first one)
CCtrlBaseButton **_RBRef; // The pointer onto the reference button
//@}
// Colors
NLMISC::CRGBA _ColorNormal;
NLMISC::CRGBA _ColorPushed;
NLMISC::CRGBA _ColorOver;
///\name Long click specific
//@{
sint64 _LeftLongClickDate; // Time we left click down
//@}
// for double click : last date at which last left click occurred
static sint64 _LastLeftClickDate;
static NLMISC::CRefPtr<CCtrlBaseButton> _LastLeftClickButton;
///\name Action Handler
//@{
IActionHandler *_AHOnOver;
CStringShared _AHOverParams;
std::string _AHOnLeftClickString;
std::string _AHOnLeftClickStringParams;
IActionHandler *_AHOnLeftClick;
CStringShared _AHLeftClickParams;
IActionHandler *_AHOnLeftDblClick;
CStringShared _AHLeftDblClickParams;
IActionHandler *_AHOnRightClick;
CStringShared _AHRightClickParams;
IActionHandler *_AHOnClockTick;
CStringShared _AHClockTickParams;
IActionHandler *_AHOnLeftLongClick;
CStringShared _AHLeftLongClickParams;
//@}
CStringShared _ListMenuLeft;
CStringShared _ListMenuRight;
// get the colors modulated on request
NLMISC::CRGBA getCurrentColorNormal(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorNormal;
if(_ModulateGlobalColorNormal)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorPushed(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorPushed;
if(_ModulateGlobalColorPushed)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
NLMISC::CRGBA getCurrentColorOver(NLMISC::CRGBA globalColor) const
{
NLMISC::CRGBA rgba = _ColorOver;
if(_ModulateGlobalColorOver)
rgba.modulateFromColor(rgba, globalColor);
return rgba;
}
// call it at draw
void updateOver(bool &lastOver);
virtual void elementCaptured(CCtrlBase *capturedElement);
};
}
#endif // NL_CTRL_BASE_BUTTON_H
/* End of ctrl_base_button.h */

@ -0,0 +1,109 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_BUTTON_H
#define RZ_CTRL_BUTTON_H
#include "nel/gui/ctrl_base_button.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI
{
class CEventDescriptor;
/**
* <Class description>
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CCtrlButton : public CCtrlBaseButton
{
public:
DECLARE_UI_CLASS( CCtrlButton )
/// Constructor
CCtrlButton(const TCtorParam &param) : CCtrlBaseButton(param)
{
_Scale = false;
_Align = 0;
}
void setAlignFromString( const std::string &s );
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// Init part
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */);
// Display part
virtual void draw();
void setTexture (const std::string&name);
void setTexturePushed (const std::string&name);
void setTextureOver (const std::string&name);
void fitTexture();
std::string getTexture () const;
std::string getTexturePushed () const;
std::string getTextureOver() const;
bool isTextureValid() const { return _TextureIdNormal != -1; }
// test if the texture must scale
bool getScale() const { return _Scale; }
void setScale(bool scale) { _Scale = scale; }
/// \from CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
REFLECT_EXPORT_START(CCtrlButton, CCtrlBaseButton)
REFLECT_STRING("texture", getTexture, setTexture);
REFLECT_STRING("texture_pushed", getTexturePushed, setTexturePushed);
REFLECT_STRING("texture_over", getTextureOver, setTextureOver);
REFLECT_BOOL("scale", getScale, setScale);
REFLECT_EXPORT_END
protected:
CViewRenderer::CTextureId _TextureIdNormal;
CViewRenderer::CTextureId _TextureIdPushed;
CViewRenderer::CTextureId _TextureIdOver;
private:
bool _Scale;
sint32 _Align; /// 1st bit - Left/Right (0/1) 2nd bit - Bottom/Top (0/1)
};
}
#endif // RZ_CTRL_BUTTON_H
/* End of ctrl_button.h */

@ -0,0 +1,111 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_COL_PICK_H
#define RZ_CTRL_COL_PICK_H
#include "nel/misc/types_nl.h"
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
/**
* Class handling a Color Picker
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2003
*/
class CCtrlColPick : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlColPick )
CCtrlColPick(const TCtorParam &param);
~CCtrlColPick();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
sint32 getColorR () const { return _ColorSelect.R; }
sint32 getColorG () const { return _ColorSelect.G; }
sint32 getColorB () const { return _ColorSelect.B; }
sint32 getColorA () const { return _ColorSelect.A; }
void setColorR (sint32 r) { _ColorSelect.R = (uint8)r; }
void setColorG (sint32 g) { _ColorSelect.G = (uint8)g; }
void setColorB (sint32 b) { _ColorSelect.B = (uint8)b; }
void setColorA (sint32 a) { _ColorSelect.A = (uint8)a; }
std::string getColor () const; // Get Color Selected
void setColor (const std::string &col); // Set Color Selected
std::string getColorOver () const; // Get Color Over
void setColorOver (const std::string &col); // Set Color Over
REFLECT_EXPORT_START(CCtrlColPick, CCtrlBase)
REFLECT_SINT32("r", getColorR, setColorR);
REFLECT_SINT32("g", getColorG, setColorG);
REFLECT_SINT32("b", getColorB, setColorB);
REFLECT_SINT32("a", getColorA, setColorA);
REFLECT_STRING("color", getColor, setColor);
REFLECT_STRING("color_over", getColorOver, setColorOver);
REFLECT_EXPORT_END
protected:
void selectColor (sint32 x, sint32 y);
NLMISC::CRGBA getColor (sint32 x, sint32 y);
protected:
bool _MouseDown;
sint32 _Texture;
NLMISC::CRGBA _ColorSelect; // Last Color selected
NLMISC::CRGBA _ColorOver; // Color Under Mouse Pointer
std::string _AHOnChange;
std::string _AHOnChangeParams;
CInterfaceProperty _ColSelR;
CInterfaceProperty _ColSelG;
CInterfaceProperty _ColSelB;
CInterfaceProperty _ColSelA;
};
}
#endif // RZ_CTRL_COL_PICK_H
/* End of ctrl_col_pick.h */

@ -0,0 +1,64 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CTRL_DRAGGABLE_H
#define CTRL_DRAGGABLE_H
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
class CCtrlDraggable : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlDraggable )
CCtrlDraggable( const TCtorParam &param );
virtual ~CCtrlDraggable(){};
static CCtrlDraggable *getDraggedSheet(){ return _LastDraggedSheet; }
bool isDragged() const{ return dragged; }
void setDragged( bool dragged ){ this->dragged = dragged; }
bool isDraggable() const{ return draggable; }
void setDraggable( bool draggable ){ this->draggable = draggable; }
void abortDragging()
{
dragged = false;
_LastDraggedSheet = NULL;
}
// Necessary because of reflection, no other purpose
void draw(){}
REFLECT_EXPORT_START(CCtrlDraggable, CCtrlBase)
REFLECT_BOOL("dragable", isDraggable, setDraggable);
REFLECT_EXPORT_END
protected:
static void setDraggedSheet( CCtrlDraggable *draggable ){ _LastDraggedSheet = draggable; }
private:
static CCtrlDraggable *_LastDraggedSheet;
bool dragged;
bool draggable;
};
}
#endif

@ -0,0 +1,95 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_POLYGON_H
#define RZ_CTRL_POLYGON_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
#include "nel/misc/polygon.h"
namespace NLMISC
{
class CVector2f;
}
namespace NLGUI
{
/** Display of an arbitrary polygon in the ui.
* polygons are clipped & batched.
*
* Derives from CCtrlBase in order to provide button / tooltip capability
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 1/2006
*/
class CCtrlPolygon : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlPolygon )
CCtrlPolygon( const TCtorParam &param );
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords();
virtual void draw();
/** Change the vertices. This is costly because concav / complex polys are split in a list of triangles
*/
void setVertices(const std::vector<NLMISC::CVector> &vertices);
const std::vector<NLMISC::CVector> &getVertices() const { return _Poly.Vertices; }
// test if current position in inside the current (transformed) poly (in window space)
bool contains(const NLMISC::CVector2f &pos) const;
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha(sint32 a);
/** Change the matrix for this poly. Changing the matrix is usually cheaper than changing
* The vertices because complex poly do not have to be split again
*/
//void setMatrix(const NLMISC::CMatrix &mat);
//const NLMISC::CMatrix &getMatrix() const { return _Matrix; }
// test if last call to 'setVertices' was for a valid poly (e.g one that doesn't overlapp itself)
bool isValid() const { return _Valid; }
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
// no capturable by default (just tooltip capability wanted)
virtual bool isCapturable() const { return false; }
private:
NLMISC::CPolygon _Poly;
NLMISC::CPolygon2D _XFormPoly;
//NLMISC::CMatrix _Matrix;
bool _Valid;
bool _Touched;
NLMISC::CRGBA _Color;
std::vector<NLMISC::CTriangle> _Tris;
std::vector<NLMISC::CTriangle> _RealTris; // clipped tris in screen coordinates
private:
void updateBoudingRect();
protected:
// TMP TMP : have to solve matrix imprecision for display in map -> do the full computation for now ...
virtual void computeScaledVertex(NLMISC::CVector2f &dest, const NLMISC::CVector2f &src);
public:
void touch();
};
}
#endif

@ -0,0 +1,118 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_QUAD_H
#define RZ_CTRL_QUAD_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/view_renderer.h"
#include "nel/misc/geom_ext.h"
namespace NLGUI
{
/** Display of an arbitrary textured quad in the UI. The applied texture is filtered.
* Unlike CViewBitmap, the texture is always scaled here, and this ui element coordinates
* are driven by the quad vertices coordinates (see setQuad).
*
* Derives from CCtrlBase for tooltipping support
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 12/2005
*/
class CCtrlQuad : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlQuad )
enum TWrapMode { Repeat = 0, Clamp, CustomUVs, WrapModeCount };
CCtrlQuad( const TCtorParam &param );
// from CInterfaceElement
bool parse(xmlNodePtr cur,CInterfaceGroup *parentGroup);
virtual void updateCoords();
virtual void draw();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
// from CViewBase
virtual sint32 getAlpha() const { return (sint32) _Color.A; }
virtual void setAlpha (sint32 a);
// texture
void setTexture(const std::string &texName);
std::string getTexture () const;
// color
void setColorRGBA(NLMISC::CRGBA col) { _Color = col; }
NLMISC::CRGBA getColorRGBA() const { return _Color; }
/** Set a new quad relative to parent pos
* x,y, w, h & hotspot are updated to fit the bounding rect of the quad
*/
void setQuad(const NLMISC::CQuad &quad);
void setQuad(const NLMISC::CVector &start, const NLMISC::CVector &end, float thickness);
/** Fit the given texture size (no hotspot for now, always centered)
* NB : current texture is not modified.
*/
void setQuad(const std::string &texName, const NLMISC::CVector &pos, float angle = 0.f, float offCenter = 0.f);
void setQuad(const NLMISC::CVector &pos, float radius, float angle = 0.f);
const NLMISC::CQuad &getQuad() const { return _Quad; }
void setAdditif(bool additif);
bool getAdditif() const { return _Additif; }
void setFiltered(bool filtered);
bool getFiltered() const { return _Filtered; }
void setPattern(float umin, float umax, TWrapMode wrapMode);
/** Set uvs for each corners -> this will change the wrap mode to CustomUVs
* Use setPattern(0.f, 0.f, CCtrlQuad::Repeat) to return to previous behavior
*/
void setCustomUVs(const NLMISC::CUV uvs[4]);
// from CCtrlBase, no op by default
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
// see if this control contains the given point (in parent coords)
bool contains(const NLMISC::CVector2f &pos) const;
// no capturable by default (just tooltip capability wanted)
virtual bool isCapturable() const { return false; }
private:
NLMISC::CRGBA _Color;
NLMISC::CQuad _Quad;
NLMISC::CQuadUV _RealQuad; // absolute coords
float _ClampedUCorrection;
CViewRenderer::CTextureId _TextureId; /// Accelerator
bool _Additif;
bool _Filtered;
float _UMin;
float _UMax;
TWrapMode _WrapMode;
NLMISC::CUV _CustomUVs[4];
};
}
#endif

@ -0,0 +1,206 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_SCROLL_H
#define RZ_CTRL_SCROLL_H
#include "nel/misc/types_nl.h"
#include "nel/gui/ctrl_scroll_base.h"
namespace NLGUI
{
/**
* Class handling scollbar function
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CCtrlScroll : public CCtrlScrollBase, public NLMISC::ICDBNode::IPropertyObserver
{
public:
DECLARE_UI_CLASS( CCtrlScroll )
CCtrlScroll(const TCtorParam &param);
~CCtrlScroll();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void setTarget (CInterfaceGroup *pIG);
// Return the delta value the track has moved
sint32 moveTrackX (sint32 dx);
sint32 moveTrackY (sint32 dy);
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
*/
void moveTargetX (sint32 dx);
void moveTargetY (sint32 dy);
void setAlign (sint32 nAlign) { _Aligned = nAlign; }
// invert the factor for target
void setInverted(bool invert) { _Inverted = invert; }
void setTextureBottomOrLeft (const std::string &txName);
void setTextureMiddle (const std::string &txName);
void setTextureTopOrRight (const std::string &txName);
std::string getTextureBottomOrLeft() const;
std::string getTextureMiddle() const;
std::string getTextureTopOrRight() const;
void setTextureBottomOrLeft (sint32 txid) { _TxIdB = txid; }
void setTextureMiddle (sint32 txid) { _TxIdM = txid; }
void setTextureMiddleTile (uint8 tile) { _TileM = tile; } // 0 - not tiled (1 BL) (2 BR) (3 TL) (4 TR)
void setTextureTopOrRight (sint32 txid) { _TxIdT = txid; }
// number scroller
sint32 getValue() const { return _IsDBLink ? _DBLink.getSInt32() : _Value; }
// NB: the value is clamped (see setMinMax) and stepped (see setStepValue())
void setValue(sint32 value);
void setMinMax(sint32 nMin, sint32 nMax) { _Min = nMin; _Max = nMax; }
void setStepValue(uint32 step) { _StepValue= step; }
void setTrackPos(sint32 pos);
sint32 getTrackPos() const { return _TrackPos; }
sint32 getTrackSize() const { return _TrackSize; }
// dummy set for track size (forlua export)
void setTrackSize(sint32 /* trackSize */) { throw NLMISC::Exception("TrackSize is read-only"); }
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
int luaSetTarget(CLuaState &ls);
int luaEnsureVisible(CLuaState &ls);
// name
void setName(const std::string & val) {_Name = val;}
std::string getName() const {return _Name;}
// max
void setMax(sint32 max) {_Max = max;}
sint32 getMax() const {return _Max;}
REFLECT_EXPORT_START(CCtrlScroll, CCtrlScrollBase)
REFLECT_LUA_METHOD("setTarget", luaSetTarget)
REFLECT_LUA_METHOD("ensureVisible", luaEnsureVisible);
REFLECT_SINT32("value", getValue, setValue);
REFLECT_SINT32("trackPos", getTrackPos, setTrackPos);
REFLECT_SINT32("trackSize", getTrackSize, setTrackSize);
REFLECT_STRING("name", getName, setName);
REFLECT_SINT32("max", getMax, setMax);
REFLECT_EXPORT_END
/** Ensure that a child element be visible into the frame through which
* its parent group is displayed.
* Example : Had we a list of items for which we want some item 'itemPtr' to have its top position
* matching the middle of the list, we would do :
* this->ensureVisible(itemPtr, Hotspot_Tx, Hotspot_Mx);
*
* The scrollbar will be moved accordingly.
*/
void ensureVisible(CInterfaceElement *childElement, THotSpot childHotSpot, THotSpot parentHotSpot);
protected:
CInterfaceProperty _DBLink; // If this is a value scroller we can link it with db
sint32 _Value; // Or we can use a normal value
sint32 _InitialValue;
sint32 _Min, _Max;
std::string _AHOnScroll;
std::string _AHOnScrollParams;
//
std::string _AHOnScrollEnd;
std::string _AHOnScrollEndParams;
//
//
std::string _AHOnScrollCancel;
std::string _AHOnScrollCancelParams;
sint32 _Aligned; // 0-Top 1-Bottom 2-Left 3-Right
sint32 _TrackDispPos;
sint32 _TrackPos;
sint32 _TrackSize;
sint32 _TrackSizeMin;
sint32 _MouseDownOffsetX;
sint32 _MouseDownOffsetY;
sint32 _TxIdB; // Same as Left if Horizontal sb
sint32 _TxIdM;
sint32 _TxIdT; // Same as Right if Horizontal sb
uint8 _TileM;
sint32 _LastTargetHReal;
sint32 _LastTargetMaxHReal;
sint32 _LastTargetOfsY;
sint32 _LastTargetWReal;
sint32 _LastTargetMaxWReal;
sint32 _LastTargetOfsX;
bool _Vertical : 1; // true if vertical track bar
bool _IsDBLink : 1;
bool _ObserverOn : 1;
bool _Inverted : 1;
bool _MouseDown : 1;
bool _CallingAH : 1;
bool _Cancelable : 1; // true if the slider may be cancelled when pressed on the mouse right button
bool _Frozen : 1;
// For Target Scroller only: the target offset step in pixel.
sint32 _TargetStepX;
sint32 _TargetStepY;
// For Value Scroller only: indicate the step the scroll bar has. 0 or 1 means no step
uint32 _StepValue;
// Slider's name
std::string _Name;
void computeTargetOfsFromPos();
// from IPropertyObserver
virtual void update(NLMISC::ICDBNode *node);
// step the value, and clamp it
void normalizeValue(sint32 &value);
void runAH(const std::string &name, const std::string &params);
};
}
#endif // RZ_CTRL_SCROLL_H
/* End of ctrl_scroll.h */

@ -0,0 +1,60 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CTRL_SCROLL_BASE_H
#define CTRL_SCROLL_BASE_H
#include "nel/gui/ctrl_base.h"
namespace NLGUI
{
class CInterfaceGroup;
class CCtrlScrollBase : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlScrollBase )
CCtrlScrollBase( const TCtorParam &param );
virtual ~CCtrlScrollBase();
virtual void setTarget( CInterfaceGroup *pIG );
CInterfaceGroup* getTarget(){ return _Target; }
virtual sint32 moveTrackX( sint32 dx );
virtual sint32 moveTrackY( sint32 dy );
/** Move the Target Ofs with a Delta, and recompute TrackPos from this Ofs.
* Useful for finer controled group scrolling when the list is very big (with mouseWheel or scroll buttons)
*/
virtual void moveTargetX( sint32 dx );
virtual void moveTargetY( sint32 dy );
// Necessary because of reflection, no other purpose
void draw(){}
protected:
CInterfaceGroup *_Target; // If NULL the scroller is a value scroller
private:
};
}
#endif

@ -0,0 +1,83 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_SHEET_CTRL_SELECTION_H
#define CL_SHEET_CTRL_SELECTION_H
namespace NLGUI
{
class IActionHandler;
/** Infos about a selection group
*/
class CSheetSelectionGroup
{
public:
CSheetSelectionGroup(std::string name) : _Name(name), _Active(false), _TextureIndex(-1), _Color(NLMISC::CRGBA::White), _GlobalColorEnabled(true) {}
void setTexture(const std::string &texName);
sint32 getTextureIndex() const { return _TextureIndex; }
sint32 getTextureWidth() const { return _TextureWidth; }
sint32 getTextureHeight() const { return _TextureHeight; }
void setColor(NLMISC::CRGBA color) { _Color = color; }
NLMISC::CRGBA getColor() const { return _Color; }
void setActive(bool active) { _Active = active; }
bool isActive() const { return _Active; }
const std::string &getName() const { return _Name; }
void enableGlobalColor(bool enabled) { _GlobalColorEnabled = enabled; }
bool isGlobalColorEnabled() const { return _GlobalColorEnabled; }
private:
std::string _Name;
bool _Active;
sint32 _TextureIndex; // index for the selection texture
sint32 _TextureWidth;
sint32 _TextureHeight;
NLMISC::CRGBA _Color; // color that modulate the texture of selection
bool _GlobalColorEnabled;
};
/** Class to manage selection of sheet.
* Sheet are managed by groups, identified by their ID.
*/
class CCtrlSheetSelection
{
public:
// Add a group, and returns its index, or -1 if already created.
sint addGroup(const std::string &name);
// Get a group by its name (must exist)
CSheetSelectionGroup *getGroup(const std::string &name);
const CSheetSelectionGroup *getGroup(const std::string &name) const;
// Get a group by its index
CSheetSelectionGroup *getGroup(uint index);
const CSheetSelectionGroup *getGroup(uint index) const;
// Get the index of a group from its name, return -1 if not a group
sint getGroupIndex(const std::string &name) const;
// Deactivate all groups
void deactivateAll();
// delete all groups
void deleteGroups();
private:
//
typedef std::vector<CSheetSelectionGroup> TGroupVect;
typedef std::map<std::string, uint> TGroupNameToIndex;
private:
TGroupVect _Groups;
TGroupNameToIndex _GroupNameToIndex;
};
}
#endif

@ -0,0 +1,171 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_CTRL_TEXT_BUTTON_H
#define NL_CTRL_TEXT_BUTTON_H
#include "nel/gui/ctrl_base_button.h"
#include "nel/gui/view_renderer.h"
namespace NLGUI
{
class CEventDescriptor;
class CViewText;
// ***************************************************************************
/**
* Text Button that can be either Push or Toggle button. Localized, auto-resize
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CCtrlTextButton : public CCtrlBaseButton
{
public:
DECLARE_UI_CLASS( CCtrlTextButton )
/// Constructor
CCtrlTextButton(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// Init part
virtual bool parse (xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual void updateCoords();
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
// Display part
virtual void draw();
// Hide/Show the text also.
virtual void setActive(bool state);
// Add also our ViewText
virtual void onAddToGroup();
/// \from CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
// Special Text Colors accessors
// Colors
NLMISC::CRGBA getTextColorNormal() const {return _TextColorNormal;}
void setTextColorNormal(NLMISC::CRGBA v) {_TextColorNormal= v;}
NLMISC::CRGBA getTextColorPushed() const {return _TextColorPushed;}
void setTextColorPushed(NLMISC::CRGBA v) {_TextColorPushed= v;}
NLMISC::CRGBA getTextColorOver() const {return _TextColorOver;}
void setTextColorOver(NLMISC::CRGBA v) {_TextColorOver= v;}
// Shadow Colors
NLMISC::CRGBA getTextShadowColorNormal() const {return _TextShadowColorNormal;}
void setTextShadowColorNormal(NLMISC::CRGBA v) {_TextShadowColorNormal= v;}
NLMISC::CRGBA getTextShadowColorPushed() const {return _TextShadowColorPushed;}
void setTextShadowColorPushed(NLMISC::CRGBA v) {_TextShadowColorPushed= v;}
NLMISC::CRGBA getTextShadowColorOver() const {return _TextShadowColorOver;}
void setTextShadowColorOver(NLMISC::CRGBA v) {_TextShadowColorOver= v;}
// Global Modulate Colors
bool getTextModulateGlobalColorNormal() const {return _TextModulateGlobalColorNormal;}
void setTextModulateGlobalColorNormal(bool v) {_TextModulateGlobalColorNormal= v;}
bool getTextModulateGlobalColorPushed() const {return _TextModulateGlobalColorPushed;}
void setTextModulateGlobalColorPushed(bool v) {_TextModulateGlobalColorPushed= v;}
bool getTextModulateGlobalColorOver() const {return _TextModulateGlobalColorOver;}
void setTextModulateGlobalColorOver(bool v) {_TextModulateGlobalColorOver= v;}
// Set text (noop if text id)
void setText (const ucstring &text);
ucstring getText () const;
void setHardText (const std::string &text);
std::string getHardText () const;
CViewText* getViewText();
void setViewText(CViewText* text) {_ViewText=text;}
void setTextX(sint32 x);
sint32 getTextX() const { return _TextX; }
void setWMargin(sint32 w) { _WMargin = w; }
sint32 getWMargin() const { return _WMargin; }
sint32 getWMin() const { return _WMin; }
void setWMin( sint32 wmin ) { _WMin = wmin; }
// Compute Size according to bitmap and Text (Ensure as big as possible button)
sint32 getWMax() const;
int luaGetViewText(CLuaState &ls);
REFLECT_EXPORT_START(CCtrlTextButton, CCtrlBaseButton)
REFLECT_UCSTRING("uc_hardtext", getText, setText);
REFLECT_STRING("hardtext", getHardText, setHardText);
REFLECT_SINT32("text_x", getTextX, setTextX)
REFLECT_SINT32("wmargin", getWMargin, setWMargin)
REFLECT_SINT32("wmin", getWMin, setWMin)
REFLECT_LUA_METHOD("getViewText", luaGetViewText)
REFLECT_EXPORT_END
protected:
enum {NumTexture= 3};
CViewRenderer::CTextureId _TextureIdNormal[NumTexture];
CViewRenderer::CTextureId _TextureIdPushed[NumTexture];
CViewRenderer::CTextureId _TextureIdOver[NumTexture];
// setup
void setup();
private:
CViewText *_ViewText;
bool _Setuped;
bool _IsViewTextId;
bool _ForceTextOver; // text is displayed over the "over" texture
// Size of Bitmaps
sint32 _BmpLeftW, _BmpMiddleW, _BmpRightW, _BmpH;
// Value to add to TextW to get button W.
sint32 _WMargin;
// Min W Value
sint32 _WMin;
sint32 _TextY;
sint32 _TextX;
THotSpot _TextPosRef;
THotSpot _TextParentPosRef;
// Special Colors for text
NLMISC::CRGBA _TextColorNormal;
NLMISC::CRGBA _TextColorPushed;
NLMISC::CRGBA _TextColorOver;
NLMISC::CRGBA _TextShadowColorNormal;
NLMISC::CRGBA _TextShadowColorPushed;
NLMISC::CRGBA _TextShadowColorOver;
bool _TextModulateGlobalColorNormal;
bool _TextModulateGlobalColorPushed;
bool _TextModulateGlobalColorOver;
bool _TextHeaderColor;
};
}
#endif // NL_CTRL_TEXT_BUTTON_H
/* End of ctrl_text_button.h */

@ -19,11 +19,13 @@
#ifndef RZ_CTRL_TOOLTIP_H
#define RZ_CTRL_TOOLTIP_H
#include "ctrl_base.h"
#include "nel/gui/ctrl_base.h"
#include "nel/3d/u_texture.h"
namespace NLGUI
{
class CEventDescriptor;
class CInterfaceManager;
/**
* \author Matthieu 'Mr TRAP' Besson
@ -37,8 +39,9 @@ public:
/// Constructor
CCtrlToolTip(const TCtorParam &param) : CCtrlBase(param) {}
virtual bool handleEvent (const CEventDescriptor& eventDesc);
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void draw();
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
// Can do nothing with tooltip (but display it :) )
virtual bool isCapturable() const {return false;}
@ -48,6 +51,9 @@ public:
};
}
#endif // RZ_CTRL_TOOLTIP_H
/* End of ctrl_tooltip.h */

@ -0,0 +1,71 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef DBMANAGER_H
#define DBMANAGER_H
#include "nel/misc/cdb_manager.h"
namespace NLGUI
{
/**
Database Manager
Provides access to a simple CDB based tree hierarchical data store
*/
class CDBManager : public NLMISC::CCDBManager
{
public:
static CDBManager* getInstance();
static void release();
/**
Retrieves a leaf node from the database.
@param name - name of the data leaf node we are querying.
@param create - when true if a node cannot be found it is created.
*/
NLMISC::CCDBNodeLeaf* getDbProp( const std::string &name, bool create = true );
/**
Deletes a node from the database.
@param name - name of the node.
*/
void delDbProp( const std::string &name );
/**
Returns a leaf node's content as an sint32
@param name - name of the leaf node.
*/
sint32 getDbValue32( const std::string &name );
/**
Returns the root branch of the database.
*/
NLMISC::CCDBNodeBranch* getDB() const;
private:
CDBManager();
~CDBManager();
static CDBManager *instance;
};
}
#endif

@ -0,0 +1,170 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DBGROUP_COMBO_BOX_H
#define NL_DBGROUP_COMBO_BOX_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CViewText;
class CGroupMenu;
// ***************************************************************************
/**
* Widget: ComboBox of text
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBGroupComboBox : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CDBGroupComboBox )
/// Constructor
CDBGroupComboBox(const TCtorParam &param);
~CDBGroupComboBox();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords ();
// Combo Texts
void resetTexts();
void addText(const ucstring &text);
void setText(uint i, const ucstring &text);
void insertText(uint i, const ucstring &text);
const ucstring &getText(uint i) const;
const uint &getTextId(uint i) const;
uint getTextPos(uint nId) const;
const ucstring &getTexture(uint i) const;
void removeText(uint nPos);
uint getNumTexts() const {return (uint)_Texts.size();}
void sortText();
// selection
void setSelection(sint32 val);
void setSelectionNoTrigger(sint32 val);
sint32 getSelection() const;
// selection number
void setSelectionNb(sint32 /* val */){}
sint32 getSelectionNb() const {return (sint32)_Texts.size();}
// selection text
void setSelectionText(const std::string & val);
std::string getSelectionText() const;
// view text
void setViewText(const ucstring & text);
ucstring getViewText() const;
void setTexture(uint i, const ucstring &texture);
sint32 evalContentWidth() const;
int luaAddText(CLuaState &ls);
int luaRemoveSelection(CLuaState &ls);
int luaRemoveText(CLuaState &ls);
int luaRemoveTextByIndex(CLuaState &ls);
int luaResetTexts(CLuaState &ls);
int luaSetText(CLuaState &ls);
int luaInsertText(CLuaState &ls);
int luaGetText(CLuaState &ls);
int luaGetNumTexts(CLuaState &ls);
int luaSetTexture(CLuaState &ls);
REFLECT_EXPORT_START(CDBGroupComboBox, CInterfaceGroup)
REFLECT_SINT32("selection", getSelection, setSelection)
REFLECT_LUA_METHOD("addText", luaAddText)
REFLECT_LUA_METHOD("setText", luaSetText)
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("setTexture", luaSetTexture)
REFLECT_LUA_METHOD("getText", luaGetText)
REFLECT_LUA_METHOD("getNumTexts", luaGetNumTexts)
REFLECT_LUA_METHOD("removeSelection", luaRemoveSelection)
REFLECT_LUA_METHOD("removeText", luaRemoveText)
REFLECT_LUA_METHOD("removeTextByIndex", luaRemoveTextByIndex)
REFLECT_LUA_METHOD("resetTexts", luaResetTexts)
REFLECT_SINT32 ("selectionNb", getSelectionNb, setSelectionNb)
REFLECT_STRING ("selection_text", getSelectionText, setSelectionText)
REFLECT_UCSTRING ("view_text", getViewText, setViewText)
REFLECT_EXPORT_END
protected:
friend class CHandlerComboBoxSelectStart;
bool _LinkedToDB; // if not linked to db, then _NotLinkedToDBSelection is used instead
bool _Setuped;
bool _DirtySelection;
sint32 _CacheSelection;
// sint32
CInterfaceProperty _Selection;
sint32 _NotLinkedToDBSelection;
std::vector<std::pair<uint, ucstring> > _Texts;
std::vector<ucstring> _Textures;
// Action Handler called on combo click
std::string _AHOnSelectStart;
// Action handler called when the content is changed
std::string _AHOnChange;
std::string _AHOnChangeParams;
bool _CallingOnChangeActionHandler; // avoid infinite loop here
// Children
CViewText *_ViewText;
CCtrlBaseButton *_SelectButton;
bool _IsExternViewText;
ucstring _ExternViewText;
private:
void setup();
void dirt();
public:
// private : fill a menu with current content
void fillMenu(CGroupMenu *groupMenu) const;
static std::string measureMenu;
static std::string selectMenu;
static std::string selectMenuOut;
};
}
#endif // NL_DBGROUP_COMBO_BOX_H
/* End of dbgroup_combo_box.h */

@ -0,0 +1,101 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DBGROUP_SELECT_NUMBER_H
#define NL_DBGROUP_SELECT_NUMBER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CViewText;
class CViewBitmap;
// ***************************************************************************
/**
* Widget to select a number
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBGroupSelectNumber : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CDBGroupSelectNumber )
/// Constructor
CDBGroupSelectNumber(const TCtorParam &param);
~CDBGroupSelectNumber();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords();
virtual void draw ();
virtual void clearViews ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
// mod interface
void changeValue(sint delta);
sint32 getMinValue () const { return _MinValue; }
void setMinValue (sint32 m) { _MinValue = m; }
sint32 getMaxValue () const { return _MaxValue; }
void setMaxValue (sint32 m) { _MaxValue = m; }
sint32 getCurrentValue () const { return _Number.getSInt32(); }
void setCurrentValue (sint32 val) { _Number.setSInt32(val); }
REFLECT_EXPORT_START(CDBGroupSelectNumber, CInterfaceGroup)
REFLECT_SINT32("min", getMinValue, setMinValue);
REFLECT_SINT32("max", getMaxValue, setMaxValue);
REFLECT_EXPORT_END
protected:
// sint32
CInterfaceProperty _Number;
bool _LoopMode;
sint _MinValue;
sint _MaxValue;
sint _DeltaMultiplier;
// Children
CViewBitmap *_SlotNumber;
CViewText *_TextNumber;
CCtrlBaseButton *_ButtonUp;
CCtrlBaseButton *_ButtonDown;
private:
void setup();
};
}
#endif // NL_DBGROUP_SELECT_NUMBER_H
/* End of dbgroup_select_number.h */

@ -0,0 +1,116 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_DBVIEW_BAR_H
#define RZ_DBVIEW_BAR_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_bitmap.h"
namespace NLGUI
{
/**
* class implementing a bitmap used as the front texture of a progress bar
* the bitmap is drawn from _X to _W * _Range/_RangeMax
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CDBViewBar : public CViewBitmap
{
public:
enum TViewBar { ViewBar_UltraMini, ViewBar_Mini, ViewBar_Normal, ViewBar_MiniThick };
public:
DECLARE_UI_CLASS( CDBViewBar )
/// Constructor
CDBViewBar(const TCtorParam &param)
: CViewBitmap(param),
_Slot(TCtorParam())
{
_Color= NLMISC::CRGBA::White;
_ValueInt= 0;
_RangeInt = 255;
_ReferenceInt= 0;
_Type = ViewBar_Normal;
}
void setType (TViewBar vb);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords ();
virtual void draw ();
/// Nbs: Values by Int are not used if the Links are setuped
void setValue (sint32 r) { _ValueInt = r; }
void setRange (sint32 r) { _RangeInt = r; }
void setReference (sint32 r) { _ReferenceInt = r; }
sint32 getValue () const { return _ValueInt; }
sint32 getRange () const { return _RangeInt; }
sint32 getReference () const { return _ReferenceInt; }
void setValueDbLink (const std::string &r);
void setRangeDbLink (const std::string &r);
void setReferenceDbLink (const std::string &r);
std::string getValueDbLink () const;
std::string getRangeDbLink () const;
std::string getReferenceDbLink () const;
// Reflect ValueInt (ie not used if the link is setuped)
REFLECT_EXPORT_START(CDBViewBar, CViewBitmap)
REFLECT_SINT32 ("value", getValue, setValue);
REFLECT_SINT32 ("range", getRange, setRange);
REFLECT_SINT32 ("reference", getReference, setReference);
REFLECT_STRING ("value_dblink", getValueDbLink, setValueDbLink);
REFLECT_STRING ("range_dblink", getRangeDbLink, setRangeDbLink);
REFLECT_STRING ("reference_dblink", getReferenceDbLink, setReferenceDbLink);
REFLECT_EXPORT_END
protected:
CViewBitmap _Slot;
TViewBar _Type;
sint32 _HBar;
NLMISC::CRGBA _ColorNegative;
// Value of the progression in arbitrary units. should be integer
CInterfaceProperty _Value;
// Max range of the progression in arbitrary units. should be integer
CInterfaceProperty _Range;
// Reference of the progression (substracted from value and range).
CInterfaceProperty _Reference;
/// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links
sint32 _ValueInt;
sint32 _RangeInt;
sint32 _ReferenceInt;
void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name);
sint64 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp);
};
}
#endif // RZ_DBVIEW_BAR_H
/* End of dbview_bar.h */

@ -0,0 +1,111 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_DBVIEW_BAR3_H
#define RZ_DBVIEW_BAR3_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_bitmap.h"
namespace NLGUI
{
/**
* class implementing a 3 Bar widget
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CDBViewBar3 : public CViewBitmap
{
public:
DECLARE_UI_CLASS( CDBViewBar3 )
/// Constructor
CDBViewBar3(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void updateCoords ();
void setMini (bool mini);
virtual void draw ();
/// Nbs: Values by Int are not used if the Links are setuped
void setValue0 (sint32 r) { _ValueInt[0] = r; }
void setValue1 (sint32 r) { _ValueInt[1] = r; }
void setValue2 (sint32 r) { _ValueInt[2] = r; }
void setRange0 (sint32 r) { _RangeInt[0] = r; }
void setRange1 (sint32 r) { _RangeInt[1] = r; }
void setRange2 (sint32 r) { _RangeInt[2] = r; }
sint32 getValue0 () const { return _ValueInt[0]; }
sint32 getValue1 () const { return _ValueInt[1]; }
sint32 getValue2 () const { return _ValueInt[2]; }
sint32 getRange0 () const { return _RangeInt[0]; }
sint32 getRange1 () const { return _RangeInt[1]; }
sint32 getRange2 () const { return _RangeInt[2]; }
// Reflect ValueInt (ie not used if the link is setuped)
REFLECT_EXPORT_START(CDBViewBar3, CViewBitmap)
REFLECT_SINT32 ("value1", getValue0, setValue0);
REFLECT_SINT32 ("value2", getValue1, setValue1);
REFLECT_SINT32 ("value3", getValue2, setValue2);
REFLECT_SINT32 ("range1", getRange0, setRange0);
REFLECT_SINT32 ("range2", getRange1, setRange1);
REFLECT_SINT32 ("range3", getRange2, setRange2);
REFLECT_EXPORT_END
static void forceLink();
protected:
CViewBitmap _Slot;
// Value of the progression in arbitrary units. should be integer
CInterfaceProperty _Value[3];
// Max range of the progression in arbitrary units. should be integer
CInterfaceProperty _Range[3];
/// Nbs: Values by Int are not used if the Links are setuped. NB: not overwritten by links
sint32 _ValueInt[3];
sint32 _RangeInt[3];
NLMISC::CRGBA _Colors[3];
NLMISC::CRGBA _ColorsNegative[3];
bool _Mini;
// Height of the bitmap
sint32 _BarH;
void parseValProp(xmlNodePtr cur, CInterfaceProperty &dbProp, sint32 &intProp, const char *name);
void setValProp( const std::string &value, CInterfaceProperty &dbProp, sint32 &intProp );
sint32 getCurrentValProp(const CInterfaceProperty &dbProp, sint32 intProp);
std::string getValProp( const CInterfaceProperty &prop, sint32 intProp ) const;
};
}
#endif // RZ_DBVIEW_BAR3_H
/* End of dbview_bar3.h */

@ -0,0 +1,68 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_DIGIT_H
#define NL_DBVIEW_DIGIT_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_base.h"
namespace NLGUI
{
// ***************************************************************************
/**
* A number displayed with special bitmaps
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewDigit : public CViewBase
{
public:
DECLARE_UI_CLASS( CDBViewDigit )
/// Constructor
CDBViewDigit(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void draw ();
virtual void updateCoords();
protected:
CInterfaceProperty _Number;
sint32 _Cache;
sint32 _NumDigit;
NLMISC::CRGBA _Color;
// space between each digit
sint32 _WSpace;
// The texture digit for the current number
sint32 _DigitId[10];
uint _DivBase;
};
}
#endif // NL_DBVIEW_DIGIT_H
/* End of dbview_digit.h */

@ -0,0 +1,78 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_NUMBER_H
#define NL_DBVIEW_NUMBER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Display a text from a database number
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewNumber : public CViewText
{
public:
DECLARE_UI_CLASS( CDBViewNumber )
/// Constructor
CDBViewNumber(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void checkCoords();
virtual void draw ();
void link (const std::string &dbprop)
{
_Number.link (dbprop.c_str());
}
static void forceLink();
protected:
sint64 getVal() { if (_Modulo == 0) return (_Number.getSInt64() / _Divisor);
else return (_Number.getSInt64() / _Divisor)%_Modulo; }
protected:
CInterfaceProperty _Number;
sint64 _Cache;
bool _Positive; // only positive values are displayed
bool _Format; // the number will be formatted (like "1,000,000") if >= 10k
sint64 _Divisor, _Modulo;
// string to append to the value (eg: meters)
CStringShared _Suffix;
CStringShared _Prefix;
};
}
#endif // NL_DBVIEW_NUMBER_H
/* End of dbview_number.h */

@ -0,0 +1,66 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_QUANTITY_H
#define NL_DBVIEW_QUANTITY_H
#include "nel/misc/types_nl.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Display a text in the form of val / max or "empty"
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewQuantity : public CViewText
{
public:
DECLARE_UI_CLASS( CDBViewQuantity )
/// Constructor
CDBViewQuantity(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void draw ();
static void forceLink();
protected:
CInterfaceProperty _Number;
CInterfaceProperty _NumberMax;
sint32 _Cache;
sint32 _CacheMax;
ucstring _EmptyText;
void buildTextFromCache();
};
}
#endif // NL_DBVIEW_QUANTITY_H
/* End of dbview_quantity.h */

@ -20,7 +20,10 @@
#define RZ_EVENT_DESCRIPTOR_H
#include "nel/misc/types_nl.h"
#include "nel/misc/events.h"
namespace NLGUI
{
// ----------------------------------------------------------------------------
class CEventDescriptor
@ -247,6 +250,8 @@ protected:
bool _HasFocus;
};
}
#endif // RZ_EVENT_DESCRIPTOR_H
/* End of event_descriptor.h */

@ -0,0 +1,44 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef EVENT_LISTENER
#define EVENT_LISTENER
#include "nel/misc/event_listener.h"
#include "nel/gui/input_handler.h"
namespace NLGUI
{
class CEventListener : public NLMISC::IEventListener
{
public:
CEventListener();
~CEventListener();
void addToServer( NLMISC::CEventServer *server );
void removeFromServer();
void operator()( const NLMISC::CEvent &evnt );
private:
NLGUI::CInputHandler inputHandler;
NLMISC::CEventServer *eventServer;
};
}
#endif

@ -0,0 +1,664 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_GROUP_CONTAINER_H
#define RZ_GROUP_CONTAINER_H
#include "nel/gui/interface_group.h"
#include "nel/gui/group_container_base.h"
#include "nel/misc/smart_ptr.h"
namespace NLGUI
{
class CEventDescriptorLocalised;
class CCtrlButton;
class CCtrlScroll;
class CViewText;
class CViewBitmap;
class CGroupList;
class COptionsContainerInsertion;
class COptionsContainerMove;
class COptionsLayer;
class CGroupContainer;
// ***************************************************************************
/**
* class describing a resizer for the container
* \author Matthieu 'TrapII' Besson
* \date 2003
*/
class CCtrlResizer : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlResizer )
CCtrlResizer(const TCtorParam &param);
virtual void draw ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
// Add a big delta so when the user is over the Resizer, always take it whatever other controls under
virtual uint getDeltaDepth() const { return 100; }
// get real resizer pos : if parent has pop_min_w == pop_max_w, then horizontal resizer will be discarded
// if parent has pop_min_h == pop_max_h, then vertical resizer will be discarded
THotSpot getRealResizerPos() const;
THotSpot getResizerPos() const { return _ResizerPos; }
void setResizerPos(THotSpot resizerPos) { _ResizerPos = resizerPos; }
bool IsMaxH; // Do this resizer is a MaxH resizer ?
// Max sizes for the parent
sint32 WMin, WMax;
sint32 HMin, HMax;
// from CCtrlBase
virtual bool canChangeVirtualDesktop() const { return !_MouseDown; }
private:
sint32 resizeW (sint32 dx);
sint32 resizeH (sint32 dy);
private:
THotSpot _ResizerPos; // how the resizer should resize its parent
bool _MouseDown;
sint32 _MouseDownX;
sint32 _MouseDownY;
sint32 _XBias;
sint32 _YBias;
};
// ***************************************************************************
/**
* Class describing a Mover for the container
* Clicking on it can also open the container
* This can be used to move a container if it is movable.
* If the container is popable, it will first pull it of the hierarchy, then it becomes movable.
* It can also be used to change the position of a group container that is inserted in the list of another container.
* \author Lionel Berenguier
* \date 2003
*/
class CCtrlMover : public CCtrlBase
{
public:
DECLARE_UI_CLASS( CCtrlMover )
CCtrlMover(const TCtorParam &param, bool canMove = true, bool canOpen = true );
~CCtrlMover();
virtual void draw ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
bool canMove() { return _CanMove; }
bool isMoving() const {return _Moving;}
bool isMovingInParentList() const { return _MovingInParentList; }
// from CCtrlBase
virtual bool canChangeVirtualDesktop() const { return !_Moving; }
private:
sint32 _MoveStartX, _MoveStartY;
sint32 _MoveDeltaXReal, _MoveDeltaYReal;
sint64 _ScrollTime;
sint32 _StartIndex;
sint32 _InsertionIndex;
// clip window from parent list
sint32 _ParentListTop;
sint32 _ParentListBottom;
//
sint64 _WaitToOpenCloseDate;
//
bool _CanMove : 1;
bool _CanOpen : 1;
bool _Moving : 1;
bool _MovingInParentList : 1;
bool _HasMoved : 1;
bool _ParentScrollingUp : 1;
bool _ParentScrollingDown : 1;
bool _StopScrolling : 1; // stop scrolling at next draw
bool _WaitToOpenClose : 1;
//
static COptionsContainerInsertion *getInsertionOptions();
private:
void setPoped(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc);
void setMovingInParent(CGroupContainer *gc, sint32 x, sint32 y, const NLGUI::CEventDescriptorMouse &eventDesc);
void updateInsertionIndex(const CGroupList *gl, sint32 posY);
void stopMove();
bool runTitleActionHandler();
void handleScrolling();
};
// ***************************************************************************
/**
* class describing a group of views controls and other groups
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CGroupContainer : public CGroupContainerBase
{
public:
enum { NumResizers = 8 };
public:
// observer to know when children have moved. This can be used to keep external datas in sync
struct IChildrenObs
{
virtual void childrenMoved(uint srcIndex, uint destIndex, CGroupContainer *children) = 0;
};
public:
DECLARE_UI_CLASS( CGroupContainer )
CGroupContainer(const TCtorParam &param);
~CGroupContainer();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void draw ();
virtual void clearViews ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
virtual void launch ();
virtual void setActive (bool state);
virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CViewBase*> &vVB); // Return true if x,y under the group
virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CCtrlBase*> &vICL);
void open();
void close();
void setup(); // Create the container
/** If insertion order is -1, pIC is added at the end of the container
* otherwise it is inserted after containers of a lower order
*/
void attachContainer (CGroupContainer *pIC, sint insertionOrder = -1);
// Insert a container at the given index.
bool attachContainerAtIndex(CGroupContainer *pIC, uint index);
// Before a container is detached from parent, it should be pop in
void detachContainer (CGroupContainer *pIC);
void removeAllContainers();
void setOpen(bool opened)
{
if (opened)
{
open();
}
else
{
close();
}
}
bool isOpen() const { return _Opened; }
// Force Open for container setActive and open()
virtual void forceOpen();
/// Set the title open and close
virtual bool isMovable() const {return _Movable;}
void setMovable(bool b);
void setContent (CInterfaceGroup *pC);
std::string getTitle () const;
void setTitle (const std::string &title);
std::string getTitleOpened () const;
void setTitleOpened (const std::string &title);
std::string getTitleClosed () const;
void setTitleClosed (const std::string &title);
std::string getTitleColorAsString() const;
void setTitleColorAsString(const std::string &col);
void setHeaderColor (const std::string &ptr) { _HeaderColor.link(ptr.c_str()); }
// Get the header color draw. NB: depends if grayed, and if active.
NLMISC::CRGBA getDrawnHeaderColor () const;
ucstring getUCTitleOpened () const;
void setUCTitleOpened (const ucstring &title);
ucstring getUCTitleClosed () const;
void setUCTitleClosed (const ucstring &title);
ucstring getUCTitle () const;
void setUCTitle (const ucstring &title);
void setPopable(bool popable) { _Popable = popable; }
bool isPopable() const { return _Popable; }
bool isPopuped() const { return _Poped; }
void setMovableInParentList(bool /* movable */) { _MovableInParentList = true; }
bool isMovableInParentList() const { return _MovableInParentList; }
// high light the border of the container
void setHighLighted(bool hightlighted, uint8 alpha=255) { _HighLighted = hightlighted; _HighLightedAlpha = alpha; }
bool isHighLighted() const { return _HighLighted; }
// y offset for content of container
sint32 getContentYOffset() const { return (sint32) _ContentYOffset; }
void setContentYOffset(sint32 value);
// Window requires attention
void requireAttention();
// Lua exports
int luaBlink(CLuaState &ls);
int luaSetHeaderColor(CLuaState &ls);
REFLECT_EXPORT_START(CGroupContainer, CGroupContainerBase)
REFLECT_LUA_METHOD("blink", luaBlink);
REFLECT_LUA_METHOD("setHeaderColor", luaSetHeaderColor);
REFLECT_STRING("title", getTitle, setTitle);
REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened);
REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed);
REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened);
REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed);
REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle);
REFLECT_STRING("title_color", getTitleColorAsString, setTitleColorAsString);
REFLECT_SINT32("pop_min_h", getPopupMinH, setPopupMinH);
REFLECT_SINT32("pop_max_h", getPopupMaxH, setPopupMaxH);
REFLECT_SINT32("pop_min_w", getPopupMinW, setPopupMinW);
REFLECT_SINT32("pop_max_w", getPopupMaxW, setPopupMaxW);
REFLECT_SINT32("title_delta_max_w", getTitleDeltaMaxW, setTitleDeltaMaxW);
REFLECT_SINT32("content_y_offset", getContentYOffset, setContentYOffset);
REFLECT_BOOL("openable", isOpenable, setOpenable);
REFLECT_BOOL("opened", isOpen, setOpen);
REFLECT_BOOL("lockable", isLockable, setLockable);
REFLECT_BOOL("locked", isLocked, setLocked);
REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive);
REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled);
REFLECT_EXPORT_END
sint32 getLayerSetup() const { return _LayerSetup; }
// if this window is popable, pop it at its actual position
void popupCurrentPos();
// Popup at previous memorized position
void popup();
/** Popin the window and possibly put it back in its father container, using the order defined in the list of the container.
* \param putBackInFather When true, put the window back in its former father container, otherwise, the container is unliked from the hierachy (parents are NULL)
* \param insertPos If this is equal to -1, then the window is inserted at its previous position. Otherwise it is inserted before the given position in the list
*/
void popin(sint32 insertPos = -1, bool putBackInFatherContainer = true);
// get the mover control associated with that control, or NULL if none
CCtrlMover *getCtrlMover() const { return _Mover; }
// true if there is a mover and if the window is being moved
bool isMoving() const { return _Mover && _Mover->isMoving(); }
/** Force the container to blink (to tell the user that an event has happened).
* This uses the global color, so the container must use it
* This state is automatically disabled if the container is opened
* \param numBlinks 0 If the container should blink endlessly, the number of blink otherwise
*/
virtual void enableBlink(uint numBlinks = 0);
virtual void disableBlink();
virtual bool isBlinking() const { return _Blinking; }
CGroupList *getList() const { return _List; }
CInterfaceGroup *getHeaderOpened() const { return _HeaderOpened; }
CInterfaceGroup *getHeaderClosed() const { return _HeaderClosed; }
CInterfaceGroup *getContent() const { return _Content; }
void setChildrenObs(IChildrenObs *obs) { _ChildrenObs = obs; }
IChildrenObs *getChildrenObs() const { return _ChildrenObs; }
// Get current father container (if any).
CGroupContainer *getFatherContainer() const;
// Get current father container (if any). If the container is popup, it gives the proprietary container
CGroupContainer *getProprietaryContainer() const;
bool isOpenable() const { return _Openable; }
void setOpenable(bool openable);
bool getHeaderActive() const { return _HeaderActive; }
void setHeaderActive(bool active) { _HeaderActive = active; }
bool getRightButtonEnabled() const { return _EnabledRightButton; }
void setRightButtonEnabled(bool enabled);
CCtrlScroll *getScroll() const { return _ScrollBar; }
bool isSavable() const { return _Savable; }
void setSavable(bool savable) { _Savable = savable; }
bool isActiveSavable() const { return _ActiveSavable; }
bool isLocalize() const { return _Localize; }
void setLocalize(bool localize) { _Localize = localize; }
void setPopupX(sint32 x) { _PopupX = x; }
void setPopupY(sint32 y) { _PopupY = y; }
void setPopupW(sint32 w) { _PopupW = w; }
void setPopupH(sint32 h) { _PopupH = h; }
sint32 getPopupX() const { return _PopupX; }
sint32 getPopupY() const { return _PopupY; }
sint32 getPopupW() const { return _PopupW; }
sint32 getPopupH() const { return _PopupH; }
sint32 getRefW() const { return _RefW; }
/** Increase the rollover alpha for the current frame.
* Example of use : an edit box that has focus in a group container
*/
void rollOverAlphaUp();
// force the rollover alpha to its max value, depending on there's keyboard focus or not
void forceRolloverAlpha();
bool isOpenWhenPopup() const { return _OpenWhenPopup; }
/// Locking of window (prevent it from being moved)
void setLockable(bool lockable);
bool isLockable() const { return _Lockable; }
void setLocked(bool locked);
// to be called by the 'deactive check' handler
static void validateCanDeactivate(bool validate) { _ValidateCanDeactivate = validate; }
const std::string &getAHOnDeactiveCheck() const { return CAHManager::getInstance()->getAHName(_AHOnDeactiveCheck); }
const std::string &getAHOnDeactiveCheckParams() const { return _AHOnDeactiveCheckParams; }
//
const std::string &getAHOnCloseButton() const { return CAHManager::getInstance()->getAHName(_AHOnCloseButton); }
const std::string &getAHOnCloseButtonParams() const { return _AHOnCloseButtonParams; }
//
IActionHandler *getAHOnMovePtr() const { return _AHOnMove; }
const std::string &getAHOnMove() const { return CAHManager::getInstance()->getAHName(_AHOnMove); }
const std::string &getAHOnMoveParams() const { return _AHOnMoveParams; }
//
IActionHandler *getAHOnResizePtr() const { return _AHOnResize; }
const std::string &getAHOnResize() const { return CAHManager::getInstance()->getAHName(_AHOnResize); }
const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; }
//
IActionHandler *getAHOnBeginMovePtr() const { return _AHOnBeginMove; }
const std::string &getAHOnBeginMove() const { return CAHManager::getInstance()->getAHName(_AHOnBeginMove); }
const std::string &getAHOnBeginMoveParams() const { return _AHOnBeginMoveParams; }
//
void setOnCloseButtonHandler(const std::string &h) { _AHOnCloseButton = CAHManager::getInstance()->getAH(h,_AHOnCloseButtonParams); }
void setOnCloseButtonParams(const std::string &p) { _AHOnCloseButtonParams = p; }
void setModalParentList (const std::string &name);
bool checkIfModal(const NLGUI::CEventDescriptor& event); // Return true if we can handle the event (and prevent from selecting a window)
bool isGrayed() const;
bool blinkAllSons();
// true if the resizer is enabled.
bool getEnabledResizer() const {return _EnabledResizer;}
sint32 getPopupMinW() const {return _PopupMinW;}
sint32 getPopupMaxW() const {return _PopupMaxW;}
sint32 getPopupMinH() const {return _PopupMinH;}
sint32 getPopupMaxH() const {return _PopupMaxH;}
sint32 getMinW() const {return _MinW;}
void setMinW(sint32 minW) { _MinW = minW;}
void setMaxW(sint32 maxW) { _MaxW = maxW;}
sint32 getMaxW() const {return _MaxW;}
void setPopupMinW(sint32 minW);
void setPopupMaxW(sint32 maxW);
void setPopupMinH(sint32 minW);
void setPopupMaxH(sint32 maxW);
// backup the current position of this container
void backupPosition();
// restore the current position of this container
void restorePosition();
// get x for backup position
sint32 getBackupX() const { return _BackupX; }
sint32 getBackupY() const { return _BackupY; }
// Set backup position
void setBackupPosition(sint32 x, sint32 y);
// clear backup
void clearBackup() { _PositionBackuped = false; }
// Test if position has been backuped (flag cleared by 'restorePosition()')
bool isPositionBackuped() const { return _PositionBackuped; }
// check if the container has been moved, resized, or popuped by the user (and eventually clear that flag)
bool getTouchFlag(bool clearFlag) const;
// from CInterfaceGroup
virtual void restoreAllContainersBackupPosition() { restorePosition(); }
// when isModal() is true, the whole interface cannot switch desktop
bool isModal() const { return _Modal; }
void setModal(bool modal) { _Modal = modal; }
// return true if the container has a modal parent window setuped => the whole interface cannot switch desktop
bool isModalSon() const { return !_ModalParents.empty(); }
// return the help web page of this container. "" if none
const std::string &getHelpPage() const { return _HelpPage; }
// set the help web page of this container. "" if none. NB: the help button is not updated
void setHelpPage(const std::string &newPage);
void setTitleDeltaMaxW(sint32 delta) { _TitleDeltaMaxW = delta; }
sint32 getTitleDeltaMaxW() const { return _TitleDeltaMaxW; }
protected:
uint8 _ICurrentRolloverAlphaContainer;
uint8 _HighLightedAlpha;
float _CurrentRolloverAlphaContainer;
float _CurrentRolloverAlphaContent;
sint32 _LayerSetup;
ucstring _TitleTextOpened;
ucstring _TitleTextClosed;
CViewText *_TitleOpened;
CViewText *_TitleClosed;
sint32 _TitleDeltaMaxW;
CViewBitmap *_ViewOpenState; // Arrow showing if we are opened or not (if we are openable)
CCtrlButton *_RightButton; // Multi usage button : deactive or popup or popin
CCtrlButton *_HelpButton; // Help button
CGroupList *_List;
CCtrlScroll *_ScrollBar;
CGroupContainer *_OldFatherContainer;
// NB: _ModalParentNames is a list of modal parent, separated by '|'
std::string _ModalParentNames; // Modal handling between container (container can be linked together,
std::vector<CGroupContainer*> _ModalSons; // when the son is active the parent is not active
std::vector<CGroupContainer*> _ModalParents; // (but the rest of the interface is))
uint _InsertionOrder;
uint _BlinkDT;
uint _NumBlinks;
CInterfaceGroup *_Content; // Read From Script
CInterfaceGroup *_HeaderOpened; // Read From Script
CInterfaceGroup *_HeaderClosed; // Read From Script
CCtrlResizer *_Resizer[NumResizers]; // up to 8 resizers are available
//
CCtrlMover *_Mover;
IChildrenObs *_Obs;
// If layer==0 constraint on resize
sint32 _PopupMinW;
sint32 _PopupMaxW;
sint32 _PopupMinH;
sint32 _PopupMaxH;
// If layer>0 constraint on resize
sint32 _MinW;
sint32 _MaxW;
// backuped position
sint32 _BackupX;
sint32 _BackupY;
// old position at which the window was popup, -1 values means that the window hasn't been turned into a popup yet
sint32 _PopupX;
sint32 _PopupY;
sint32 _PopupW;
sint32 _PopupH;
//
sint32 _RefW;
sint32 _MoverDeltaW;
// action handler
IActionHandler *_AHOnOpen;
CStringShared _AHOnOpenParams;
IActionHandler *_AHOnClose;
CStringShared _AHOnCloseParams;
IActionHandler *_AHOnCloseButton;
CStringShared _AHOnCloseButtonParams;
IActionHandler *_AHOnMove;
CStringShared _AHOnMoveParams;
IActionHandler *_AHOnResize;
CStringShared _AHOnResizeParams;
IActionHandler *_AHOnBeginMove;
CStringShared _AHOnBeginMoveParams;
// action handler to test whether the windows can be deactivated (when the close button is pressed)
IActionHandler *_AHOnDeactiveCheck;
CStringShared _AHOnDeactiveCheckParams;
// Observer to know when children have moved
IChildrenObs *_ChildrenObs;
// list of container that are poped up
std::vector<CGroupContainer *> _PopedCont;
// Open management
bool _Openable : 1; // Is the container can be manually opened or closed ?
bool _Opened : 1; // Is the container currently opened or closed ?
bool _OpenWhenPopup : 1; // Does the container must open when poped up ? (layer>0)
// and close when poped in...
bool _OpenAtStart : 1; // Mgt : to setup _Opened state at start
bool _OpenedBeforePopup : 1; // Mgt : Is the container opened before poped up ? (layer>0)
// Move management
bool _Movable : 1; // Is the container movable ?
bool _MovableInParentList: 1;
bool _Lockable : 1;
bool _MovingInParentList : 1; // Mgt : currently moving ?
// Pop up / pop in
bool _Popable : 1;
bool _Poped : 1;
bool _EnabledResizer : 1;
bool _HighLighted : 1;
bool _Blinking : 1;
bool _BlinkState : 1;
bool _Savable : 1;
bool _ActiveSavable : 1;
// Display title background or not
bool _HeaderActive : 1;
bool _EnabledRightButton : 1; // Is the Button Deactive/Popup/Popin is enabled ?
//
enum TTileClass {TitleText=0, TitleTextFormated, TitleTextId, TitleTextDynString};
uint8 _TitleClass : 2;
//
mutable bool _TouchFlag : 1;
bool _PositionBackuped : 1;
bool _Modal : 1; // the container is modal and prevent from switching virtual desktop
//
bool _EnabledHelpButton : 1; // Is the Button Help is enabled ?
//
bool _TitleOverExtendViewText : 1; // Does the title over extend view text
bool _Localize : 1;
CInterfaceProperty _HeaderColor;
sint8 _ContentYOffset;
// Special Top Resizer Height (for Inventory and ChatGroup). <0 (default) => take default option value
sint8 _ResizerTopSize;
uint8 _ICurrentRolloverAlphaContent;
static bool _ValidateCanDeactivate;
CStringShared _OptionsName;
// Web Page used for help
CStringShared _HelpPage;
private:
sint32 getLayer();
void updateResizerSize(CCtrlResizer *cr);
void updateRightButton();
void updateHelpButton();
void updateMover();
void updateViewOpenState();
void updateTitle();
void createResizer(uint index, THotSpot posRef, THotSpot type, sint32 offsetX, sint32 offsetY, bool bMaxH);
void createResizerMaxH();
void removeResizerMaxH();
TTileClass convertTitleClass(const char *ptr);
static COptionsContainerMove *getMoveOptions();
COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used
bool hasKeyboardFocus() const;
// private for modal system
void addModalParent (CGroupContainer *pParent);
void addModalSon (CGroupContainer *pSon);
// Avoid each frame setup layer0, layer1 etc...
enum {NumLayerName=10};
static const std::string _OptionLayerName[NumLayerName];
public:
// for use by CCtrlMover
// Tell that this group is moving in its parent list
void setMovingInParentList(bool enable);
CGroupList *getPreviousParentList() const { return _OldFatherContainer ? _OldFatherContainer->_List : NULL; }
CCtrlScroll *getPreviousParentScrollBar() const { return _OldFatherContainer ? _OldFatherContainer->_ScrollBar : NULL; }
CGroupContainer *getPreviousContainer() const { return _OldFatherContainer; }
// set the 'hasMoved' flag
void touch(bool touched = true) { _TouchFlag = touched; }
friend class CICDeactive;
};
}
#endif // RZ_INTERFACE_CONTAINER_H
/* End of interface_container.h */

@ -0,0 +1,117 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef GROUP_CONTAINER_BASE_H
#define GROUP_CONTAINER_BASE_H
#include "nel/gui/interface_group.h"
#include "nel/misc/rgba.h"
namespace NLGUI
{
class CGroupContainerBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupContainerBase )
CGroupContainerBase( const TCtorParam &param );
virtual ~CGroupContainerBase();
virtual void removeAllContainers();
virtual void setLocked( bool locked );
bool isLocked() const { return _Locked; }
uint8 getContainerAlpha() const { return _ContainerAlpha; }
uint8 getContentAlpha() const { return _ContentAlpha; }
uint8 getRolloverAlphaContent() const { return _RolloverAlphaContent; }
uint8 getRolloverAlphaContainer() const { return _RolloverAlphaContainer; }
void setContainerAlpha( uint8 alpha );
void setContentAlpha( uint8 alpha );
void setRolloverAlphaContent( uint8 alpha );
void setRolloverAlphaContainer( uint8 alpha );
// for export
sint32 getContainerAlphaAsSInt32() const{ return (sint32)_ContainerAlpha; }
sint32 getContentAlphaAsSInt32() const{ return (sint32)_ContentAlpha; }
sint32 getRolloverAlphaContentAsSInt32() const{ return (sint32)_RolloverAlphaContent; }
sint32 getRolloverAlphaContainerAsSInt32() const{ return (sint32)_RolloverAlphaContainer; }
// sin32 versions for export
void setContainerAlpha( sint32 alpha ){ setContainerAlpha((uint8) alpha); }
void setContentAlpha( sint32 alpha ){ setContentAlpha((uint8) alpha); }
void setRolloverAlphaContent( sint32 alpha ){ setRolloverAlphaContent((uint8) alpha); }
void setRolloverAlphaContainer( sint32 alpha ){ setRolloverAlphaContainer((uint8) alpha); }
void setUseGlobalAlpha( bool use );
bool isUsingGlobalAlpha() const{ return _UseGlobalAlpha; }
std::string getAHOnAlphaSettingsChanged() const{ return CAHManager::getInstance()->getAHName( _AHOnAlphaSettingsChanged ); }
std::string getAHOnAlphaSettingsChangedParams() const{ return _AHOnAlphaSettingsChangedParams; }
void setAHOnAlphaSettingsChanged( const std::string &h ){ _AHOnAlphaSettingsChanged = CAHManager::getInstance()->getAH( h, _AHOnAlphaSettingsChangedParams ); }
void setAHOnAlphaSettingsChangedParams( const std::string &p ){ _AHOnAlphaSettingsChangedParams = p; }
REFLECT_EXPORT_START( CGroupContainerBase, CInterfaceGroup )
REFLECT_SINT32("container_alpha", getContainerAlphaAsSInt32, setContainerAlpha);
REFLECT_SINT32("content_alpha", getContentAlphaAsSInt32, setContentAlpha);
REFLECT_SINT32("rollover_content_alpha", getRolloverAlphaContentAsSInt32, setRolloverAlphaContent);
REFLECT_SINT32("rollover_container_alpha", getRolloverAlphaContainerAsSInt32, setRolloverAlphaContainer);
REFLECT_BOOL("use_global_alpha_settings", isUsingGlobalAlpha, setUseGlobalAlpha);
REFLECT_STRING("on_alpha_settings_changed", getAHOnAlphaSettingsChanged, setAHOnAlphaSettingsChanged);
REFLECT_STRING("on_alpha_settings_changed_aparams", getAHOnAlphaSettingsChangedParams, setAHOnAlphaSettingsChangedParams);
REFLECT_EXPORT_END
virtual bool isMoving() const{ return false; }
// Get the header color draw. NB: depends if grayed, and if active.
virtual NLMISC::CRGBA getDrawnHeaderColor () const{ return NLMISC::CRGBA(); };
uint8 getCurrentContainerAlpha() const{ return _CurrentContainerAlpha; }
uint8 getCurrentContentAlpha() const{ return _CurrentContentAlpha; }
virtual bool isGrayed() const{ return false; }
virtual bool getTouchFlag(bool clearFlag) const{ return false; }
virtual void backupPosition(){}
virtual void restorePosition(){}
protected:
void triggerAlphaSettingsChangedAH();
uint8 _CurrentContainerAlpha;
uint8 _CurrentContentAlpha;
uint8 _ContainerAlpha;
uint8 _ContentAlpha;
uint8 _RolloverAlphaContainer; // Alpha for the window when mouse not over it
uint8 _RolloverAlphaContent; // Alpha for the content when mouse not over it
bool _Locked : 1; // Is the container locked (ie override movable, openable ...)
bool _UseGlobalAlpha : 1;
IActionHandler *_AHOnAlphaSettingsChanged;
CStringShared _AHOnAlphaSettingsChangedParams;
private:
};
}
#endif

@ -0,0 +1,368 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_CTRL_EDITBOX_H
#define RZ_CTRL_EDITBOX_H
#include "nel/gui/interface_group.h"
#include "nel/gui/group_editbox_base.h"
#include "nel/3d/u_texture.h"
namespace NLGUI
{
class CEventDescriptor;
class CViewText;
// ----------------------------------------------------------------------------
class CGroupEditBox : public CGroupEditBoxBase
{
public:
DECLARE_UI_CLASS( CGroupEditBox )
class IComboKeyHandler
{
public:
virtual ~IComboKeyHandler(){}
virtual bool isComboKeyChat( const NLGUI::CEventDescriptorKey &edk ) const = 0;
};
enum TEntryType { Text, Integer, PositiveInteger, Float, PositiveFloat, Alpha, AlphaNum, AlphaNumSpace, Password, Filename, PlayerName }; // the type of entry this edit bot can deal with
/// Constructor
CGroupEditBox(const TCtorParam &param);
/// Dtor
~CGroupEditBox();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
bool parse(xmlNodePtr cur,CInterfaceGroup * parentGroup);
virtual uint32 getMemory() { return (uint32)(sizeof(*this)+_Id.size()); }
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
/// Accessors
ucstring getInputString() const { return _InputString; }
const ucstring &getInputStringRef() const { return _InputString; }
const ucstring &getPrompt() const { return _Prompt; }
/** Set the prompt
* NB : line returns are encoded as '\n', not '\r\n'
*/
void setPrompt(const ucstring &s) { _Prompt = s; }
void setInputString(const ucstring &str);
void setInputStringRef(const ucstring &str) {_InputString = str; };
void setInputStringAsInt(sint32 val);
sint32 getInputStringAsInt() const;
void setInputStringAsInt64(sint64 val);
sint64 getInputStringAsInt64() const;
void setInputStringAsFloat(float val);
float getInputStringAsFloat() const;
void setInputStringAsStdString(const std::string &str);
std::string getInputStringAsStdString() const;
void setInputStringAsUtf8(const std::string &str);
std::string getInputStringAsUtf8() const;
void setColor(NLMISC::CRGBA col);
/// force the selection of all the text
void setSelectionAll();
virtual void checkCoords();
virtual void updateCoords();
virtual void clearViews ();
virtual void setActive (bool state);
static CGroupEditBox *getMenuFather() { return _MenuFather; }
void setCommand(const ucstring &command, bool execute);
// Stop parent from blinking
void stopParentBlink() { if (_Parent) _Parent->disableBlink(); }
// Get / set cursor position
sint32 getCursorPos () const {return _CursorPos;}
void setCursorPos (sint32 pos) {_CursorPos=pos;}
// Get / set cursor at previous line end
bool isCursorAtPreviousLineEnd () const {return _CursorAtPreviousLineEnd;}
void setCursorAtPreviousLineEnd (bool setCursor) {_CursorAtPreviousLineEnd=setCursor;}
// Get / set current selection position
static sint32 getSelectCursorPos () {return _SelectCursorPos;}
static void setSelectCursorPos (sint32 pos) {_SelectCursorPos=pos;}
// Get the view text
const CViewText *getViewText () const {return _ViewText;}
// Get the historic information
sint32 getMaxHistoric() const {return _MaxHistoric;}
sint32 getCurrentHistoricIndex () const {return _CurrentHistoricIndex;}
void setCurrentHistoricIndex (sint32 index) {_CurrentHistoricIndex=index;}
const ucstring &getHistoric(uint32 index) const {return _Historic[index];}
uint32 getNumHistoric() const {return (uint32)_Historic.size ();}
// Get on change action handler
const std::string &getAHOnChange() const {return _AHOnChange;}
const std::string &getParamsOnChange() const {return _ParamsOnChange;}
void cutSelection();
/// From CInterfaceElement
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
// Copy the selection into buffer
void copy();
// Paste the selection into buffer
void paste();
// Write the string into buffer
void writeString(const ucstring &str, bool replace = true, bool atEnd = true);
// Expand the expression (true if there was a '/' at the start of the line)
bool expand();
// Back space
void back();
// ignore the next char/key event -> useful when a key set the focus on an editbox (keydown is received, the focus, then keychar is received by the editbox again, but is irrelevant)
void bypassNextKey() { _BypassNextKey = true; }
// True if the editBox loose the focus on enter
bool getLooseFocusOnEnter() const {return _LooseFocusOnEnter;}
//
virtual void clearAllEditBox();
// From CInterfaceElement
virtual bool wantSerialConfig() const;
// From CInterfaceElement
virtual void serialConfig(NLMISC::IStream &f);
// From CInterfaceElement
virtual void onQuit();
// From CInterfaceElement
virtual void onLoadConfig();
// from CCtrlBase
virtual void elementCaptured(CCtrlBase *capturedElement);
// from CCtrlBase
virtual void onKeyboardCaptureLost();
// set the input string as "default". will be reseted at first click (used for user information)
void setDefaultInputString(const ucstring &str);
// For Interger and PositiveInteger, can specify min and max values
void setIntegerMinValue(sint32 minValue) {_IntegerMinValue=minValue;}
void setIntegerMaxValue(sint32 maxValue) {_IntegerMaxValue=maxValue;}
void setPositiveIntegerMinValue(uint32 minValue) {_PositiveIntegerMinValue=minValue;}
void setPositiveIntegerMaxValue(uint32 maxValue) {_PositiveIntegerMaxValue=maxValue;}
void setFocusOnText();
int luaSetSelectionAll(CLuaState &ls);
int luaSetupDisplayText(CLuaState &ls);
int luaSetFocusOnText(CLuaState &ls);
int luaCancelFocusOnText(CLuaState &ls);
REFLECT_EXPORT_START(CGroupEditBox, CGroupEditBoxBase)
REFLECT_LUA_METHOD("setupDisplayText", luaSetupDisplayText);
REFLECT_LUA_METHOD("setSelectionAll", luaSetSelectionAll);
REFLECT_LUA_METHOD("setFocusOnText", luaSetFocusOnText);
REFLECT_LUA_METHOD("cancelFocusOnText", luaCancelFocusOnText);
REFLECT_STRING("input_string", getInputStringAsStdString, setInputStringAsStdString);
REFLECT_UCSTRING("uc_input_string", getInputString, setInputString);
REFLECT_EXPORT_END
/** Restore the original value of the edit box.
* This value is captured when the edit box get focus
* (return true if no undo was available)
* Will always fails ifthe edito box do not have the focus
*/
bool undo();
/** Cancel last undo operation
* Return true if redo operation is available
*/
bool redo();
/// freeze the control (loose focus, and cannot edit)
void setFrozen (bool state);
bool getFrozen () const { return _Frozen; }
protected:
// Cursor infos
float _BlinkTime;
sint32 _CursorPos;
uint32 _MaxNumChar;
uint32 _MaxNumReturn;
uint32 _MaxFloatPrec; // used in setInputStringAsFloat() only
sint32 _MaxCharsSize;
sint32 _FirstVisibleChar;
sint32 _LastVisibleChar;
// Text selection
static sint32 _SelectCursorPos;
bool _SelectingText;
NLMISC::CRGBA _TextSelectColor;
NLMISC::CRGBA _BackSelectColor;
// Text info
ucstring _Prompt;
ucstring _InputString;
CViewText *_ViewText;
// undo / redo
ucstring _StartInputString; // value of the input string when focus was acuired first
ucstring _ModifiedInputString;
// Historic info
typedef std::deque<ucstring> THistoric;
THistoric _Historic;
uint32 _MaxHistoric;
sint32 _CurrentHistoricIndex;
sint32 _PrevNumLine;
// Action Handler
std::string _AHOnChange;
std::string _ParamsOnChange;
std::string _ListMenuRight;
std::string _AHOnFocusLost;
std::string _AHOnFocusLostParams;
// entry type
TEntryType _EntryType;
bool _Setupped : 1; // setup
bool _BypassNextKey : 1;
bool _BlinkState : 1;
bool _CursorAtPreviousLineEnd : 1; // force the cursor to be displayed at the end of the previous line end (if END has beeen pressed while in a string split accross 2 lines)
bool _LooseFocusOnEnter : 1;
bool _ResetFocusOnHide : 1;
bool _BackupFatherContainerPos : 1; // Backup father container position when characters are typed.
// If the edit box is at the bottom of the screen and if it expands on y
// because of multiline, thz parent container will be moved to top
// The good position can be restored by a press on enter then
bool _WantReturn : 1; // Want return char, don't call the enter action handler
bool _Savable : 1; // should content be saved ?
bool _DefaultInputString : 1; // Is the current input string the default one (should not be edited)
bool _Frozen : 1; // is the control frozen? (cannot edit in it)
bool _CanRedo : 1;
bool _CanUndo : 1;
std::vector<char> _NegativeFilter;
sint _CursorTexID;
sint32 _CursorWidth;
sint32 _IntegerMinValue;
sint32 _IntegerMaxValue;
uint32 _PositiveIntegerMinValue;
uint32 _PositiveIntegerMaxValue;
sint32 _ViewTextDeltaX;
private:
void setupDisplayText();
void makeTopWindow();
void handleEventChar(const NLGUI::CEventDescriptorKey &event);
void handleEventString(const NLGUI::CEventDescriptorKey &event);
void setup();
void triggerOnChangeAH();
void appendStringFromClipboard(const ucstring &str);
ucstring getSelection();
static CGroupEditBox *_MenuFather;
static bool isValidAlphaNumSpace(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= '0' && ac <= '9') ||
(ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z') ||
ac==' ';
}
static bool isValidAlphaNum(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= '0' && ac <= '9') ||
(ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z');
}
static bool isValidAlpha(ucchar c)
{
if (c > 255) return false;
char ac = (char) c;
return (ac >= 'a' && ac <= 'z') ||
(ac >= 'A' && ac <= 'Z');
}
static bool isValidPlayerNameChar(ucchar c)
{
// valid player name (with possible shard prefix / suffix format
return isValidAlpha(c) || c=='.' || c=='(' || c==')';
}
static bool isValidFilenameChar(ucchar c)
{
if (c == '\\' ||
c == '/' ||
c == ':' ||
c == '*' ||
c == '?' ||
c == '\"' ||
c == '<' ||
c == '>' ||
c == '|') return false;
return true;
}
//
bool isFiltered(ucchar c)
{
uint length = (uint)_NegativeFilter.size();
for (uint k = 0; k < length; ++k)
{
if ((ucchar) _NegativeFilter[k] == c) return true;
}
return false;
}
static IComboKeyHandler *comboKeyHandler;
public:
static void setComboKeyHandler( IComboKeyHandler *handler ){ comboKeyHandler = handler; }
};
}
#endif // RZ_CTRL_EDITBOX_H
/* End of ctrl_editbox.h */

@ -0,0 +1,67 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef GROUP_EDITBOX_BASE_H
#define GROUP_EDITBOX_BASE_H
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CGroupEditBoxBase : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupEditBoxBase )
CGroupEditBoxBase( const TCtorParam &param );
~CGroupEditBoxBase();
// True if the editBox can recover the focus on enter. if not, it does not erase OldCapturedKeyboard when loose focus
bool getRecoverFocusOnEnter() const{ return _RecoverFocusOnEnter; }
void setRecoverFocusOnEnter( bool state ){ _RecoverFocusOnEnter = state; }
std::string getAHOnFocus(){ return _AHOnFocus; }
std::string getAHOnFocusParams(){ return _AHOnFocusParams; }
// disable any current selection
static void disableSelection(){ _CurrSelection = NULL; }
// Get / set current selection
static CGroupEditBoxBase *getCurrSelection(){ return _CurrSelection; }
static void setCurrSelection( CGroupEditBoxBase *selection ){ _CurrSelection = selection; }
void draw(){}
REFLECT_EXPORT_START( CGroupEditBoxBase, CInterfaceGroup )
REFLECT_BOOL( "enter_recover_focus", getRecoverFocusOnEnter, setRecoverFocusOnEnter );
REFLECT_EXPORT_END
protected:
bool _RecoverFocusOnEnter : 1;
std::string _AHOnFocus;
std::string _AHOnFocusParams;
static CGroupEditBoxBase *_CurrSelection; // the edit box for which the selection is currently active, or NULL if there's none
};
}
#endif

@ -0,0 +1,119 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_FRAME_H
#define NL_GROUP_FRAME_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
// ***************************************************************************
/** A Group with a background and a frame displayed
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupFrame : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupFrame )
/// Constructor
CGroupFrame(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void draw ();
void copyOptionFrom(const CGroupFrame &other);
void setupOptions();
void setColorAsString(const std::string & col);
std::string getColorAsString() const;
REFLECT_EXPORT_START(CGroupFrame, CInterfaceGroup)
REFLECT_STRING ("color", getColorAsString, setColorAsString);
REFLECT_EXPORT_END
static void resetDisplayTypes() { _DispTypes.clear(); }
// ******************
protected:
bool _DisplayFrame;
NLMISC::CRGBA _Color;
uint8 _DispType;
std::string _Options;
// Fields Defined in the XML => must not herit them from extends=""
bool _DisplayFrameDefined : 1;
bool _ColorDefined : 1;
bool _DispTypeDefined : 1;
// Static stuff
enum
{
TextTL= 0,
TextTM,
TextTR,
TextML,
TextMM,
TextMR,
TextBL,
TextBM,
TextBR
};
struct SDisplayType
{
std::string Name;
sint32 BorderIds[9];
uint8 TileBorder[9]; // Dont works for TextTL, TextTR, TextBL, TextBR
sint32 LeftBorder; // enum
sint32 RightBorder;
sint32 TopBorder;
sint32 BottomBorder;
// -----------------------
SDisplayType()
{
for (uint i = 0; i < 9; ++i)
TileBorder[i] = 0;
}
};
static std::vector<SDisplayType> _DispTypes;
};
}
#endif // NL_GROUP_FRAME_H
/* End of group_frame.h */

@ -0,0 +1,97 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_HEADER_H
#define CL_GROUP_HEADER_H
#include "nel/gui/group_list.h"
namespace NLGUI
{
class CGroupHeaderEntry;
// *****************************************************************************************************************
/** Display a header with movable entries.
* Usually used with a table to change the size of each column (much like the windows file explorer in 'details' mode)
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2006
*/
class CGroupHeader : public CGroupList
{
public:
DECLARE_UI_CLASS( CGroupHeader )
REFLECT_EXPORT_START(CGroupHeader, CGroupList)
REFLECT_LUA_METHOD("enlargeColumns", luaEnlargeColumns);
REFLECT_LUA_METHOD("resizeColumnsAndContainer", luaResizeColumnsAndContainer);
REFLECT_EXPORT_END
CGroupHeader(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// from CInterfaceGroup
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
sint32 getHeaderMaxSize() const { return _HeaderMaxSize; }
// get the entries in this header
void getEntries(std::vector<CGroupHeaderEntry *> &dest);
// ensure that max. content of columns is visible (without the total width becoming more than 'getHeaderMaxSize()'
void enlargeColumns(sint32 margin);
// ensure that content of each column is visible
void resizeColumnsAndContainer(sint32 margin);
private:
sint32 _HeaderMaxSize;
int luaEnlargeColumns(CLuaState &ls);
int luaResizeColumnsAndContainer(CLuaState &ls);
};
// *****************************************************************************************************************
// an entry in a header, includes a "mover control" to move it inside its parent header
// NOTE : when not used inside a CGroupHeader, will work, but there will be no 'max_size'
class CGroupHeaderEntry : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupHeaderEntry )
CGroupHeaderEntry(const TCtorParam &param);
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// from CInterfaceGroup
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
sint32 getMinSize() const { return _MinSize; }
virtual void updateCoords();
CInterfaceGroup *getTargetColumn() const;
const std::string &getAHOnResize() const { return _AHOnResize; }
const std::string &getAHOnResizeParams() const { return _AHOnResizeParams; }
private:
sint32 _MinSize;
sint32 _ResizerSize;
std::string _TargetColumnId;
std::string _AHOnResize;
std::string _AHOnResizeParams;
};
}
#endif

@ -0,0 +1,673 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H
#define CURL_STATICLIB 1
#include <curl/curl.h>
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/group_scrolltext.h"
#include "nel/gui/group_tree.h"
#include "nel/gui/ctrl_button.h"
#include "nel/gui/group_table.h"
typedef std::map<std::string, std::string> TStyle;
extern "C"
{
#include "WWWInit.h"
}
namespace NLGUI
{
class CCtrlButton;
class CCtrlScroll;
class CGroupList;
class CDBGroupComboBox;
class CGroupParagraph;
// HTML group
/**
* Widget to have a resizable scrolltext and its scrollbar
* \author Cyril 'Hulud' Corvazier
* \author Nevrax France
* \date 2002
*/
class CGroupHTML : public CGroupScrollText
{
public:
DECLARE_UI_CLASS( CGroupHTML )
friend void TextAdd (struct _HText *me, const char * buf, int len);
friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value);
friend void TextEndElement (_HText *me, int element_number);
friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value);
friend void TextBuild (HText * me, HTextStatus status);
friend void TextBeginUnparsedElement(HText *me, const char *buffer, int length);
friend void TextEndUnparsedElement(HText *me, const char *buffer, int length);
friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status);
/// Web browser options for CGroupHTML
struct SWebOptions
{
public:
/// Id of the browser ( e.g.: Chrome, Firefox, Ryzom )
std::string appName;
/// Version of the browser
std::string appVersion;
/// Language code of the browser( e.g.: en, hu )
std::string languageCode;
/// List of domains the widget can consider secure.
std::vector< std::string > trustedDomains;
SWebOptions()
{
}
};
static SWebOptions options;
// Constructor
CGroupHTML(const TCtorParam &param);
~CGroupHTML();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void draw ();
// Events
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
// Browse
virtual void browse (const char *url);
// Refresh
void refresh();
// submit form
void submitForm (uint formId, const char *submitButtonName);
// Browse error
void browseError (const char *msg);
// stop browse
void stopBrowse ();
bool isBrowsing();
void clean() { stopBrowse(); updateRefreshButton(); removeContent(); }
// Update coords
void updateCoords();
// New paragraph
void newParagraph(uint beginSpace);
// End of the paragraph
void endParagraph();
// Timeout
void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);}
float getTimeout() const {return (float)_TimeoutValue;}
// Some constants
NLMISC::CRGBA BgColor;
NLMISC::CRGBA ErrorColor;
NLMISC::CRGBA LinkColor;
NLMISC::CRGBA TextColor;
NLMISC::CRGBA H1Color;
NLMISC::CRGBA H2Color;
NLMISC::CRGBA H3Color;
NLMISC::CRGBA H4Color;
NLMISC::CRGBA H5Color;
NLMISC::CRGBA H6Color;
bool ErrorColorGlobalColor;
bool LinkColorGlobalColor;
bool TextColorGlobalColor;
bool H1ColorGlobalColor;
bool H2ColorGlobalColor;
bool H3ColorGlobalColor;
bool H4ColorGlobalColor;
bool H5ColorGlobalColor;
bool H6ColorGlobalColor;
uint TextFontSize;
uint H1FontSize;
uint H2FontSize;
uint H3FontSize;
uint H4FontSize;
uint H5FontSize;
uint H6FontSize;
uint TDBeginSpace;
uint PBeginSpace;
uint LIBeginSpace;
uint ULBeginSpace;
uint LIIndent;
uint ULIndent;
float LineSpaceFontFactor;
std::string DefaultButtonGroup;
std::string DefaultFormTextGroup;
std::string DefaultFormTextAreaGroup;
std::string DefaultFormSelectGroup;
std::string DefaultCheckBoxBitmapNormal;
std::string DefaultCheckBoxBitmapPushed;
std::string DefaultCheckBoxBitmapOver;
std::string DefaultBackgroundBitmapView;
std::string CurrentLinkTitle;
// Browser home
std::string Home;
// Undo browse: Browse the precedent url browsed. no op if none
void browseUndo ();
// Redo browse: Browse the precedent url undoed. no op if none
void browseRedo ();
// clear undo/redo
void clearUndoRedo();
std::string getURL() const { return _URL; }
void setURL(const std::string &url);
int luaBrowse(CLuaState &ls);
int luaRefresh(CLuaState &ls);
int luaRemoveContent(CLuaState &ls);
int luaInsertText(CLuaState &ls);
int luaAddString(CLuaState &ls);
int luaAddImage(CLuaState &ls);
int luaBeginElement(CLuaState &ls);
int luaEndElement(CLuaState &ls);
int luaShowDiv(CLuaState &ls);
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
REFLECT_LUA_METHOD("browse", luaBrowse)
REFLECT_LUA_METHOD("refresh", luaRefresh)
REFLECT_LUA_METHOD("removeContent", luaRemoveContent)
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("addString", luaAddString)
REFLECT_LUA_METHOD("addImage", luaAddImage)
REFLECT_LUA_METHOD("beginElement", luaBeginElement)
REFLECT_LUA_METHOD("endElement", luaEndElement)
REFLECT_LUA_METHOD("showDiv", luaShowDiv)
REFLECT_STRING("url", getURL, setURL)
REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_EXPORT_END
protected :
// \name callback from libwww
// Begin of the parsing of a HTML document
virtual void beginBuild ();
// End of the parsing of a HTML document
virtual void endBuild ();
// A new text block has been parsed
virtual void addText (const char * buf, int len);
// A link has been parsed
virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value);
// A new begin HTML element has been parsed (<IMG> for exemple)
virtual void beginElement (uint element_number, const BOOL *present, const char **value);
// A new end HTML element has been parsed (</IMG> for exemple)
virtual void endElement (uint element_number);
// A new begin unparsed element has been found
virtual void beginUnparsedElement(const char *buffer, int length);
// A new end unparsed element has been found
virtual void endUnparsedElement(const char *buffer, int length);
// Add GET params to the url
virtual void addHTTPGetParams (std::string &url, bool trustedDomain);
// Add POST params to the libwww list
virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain);
// the current request is terminated
virtual void requestTerminated(HTRequest *request);
// Get Home URL
virtual std::string home();
// Parse style html tag
TStyle parseStyle(const std::string &str_styles);
// Handle some work at each pass
virtual void handle ();
// \name internal methods
// Add a group in the current parent group
void addGroup (CInterfaceGroup *group, uint beginSpace);
// Get the current parent group
CInterfaceGroup *getCurrentGroup();
// Update current paragraph dependent data
void paragraphChange ();
// Clear the contexts info
void clearContext();
// Translate a char
bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const;
// Add a string in the current paragraph
void addString(const ucstring &str);
// Add an image in the current paragraph
void addImage(const char *image, bool globalColor, bool reloadImg=false);
// Add a text area in the current paragraph
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content);
// Add a combo box in the current paragraph
CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name);
// Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL.
CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap,
const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip);
// Set the background color
void setBackgroundColor (const NLMISC::CRGBA &bgcolor);
// Set the background
void setBackground (const std::string &bgtex, bool scale, bool tile);
// Force the current string to be in a single string
void flushString();
// Set the title
void setTitle (const ucstring &title);
// Lookup a url in local file system
bool lookupLocalFile (std::string &result, const char *url, bool isUrl);
// Delete page content and prepare next page
void removeContent ();
// Current URL
std::string _URL;
// Current DOMAIN
bool _TrustedDomain;
// Title prefix
ucstring _TitlePrefix;
// Title string
ucstring _TitleString;
// Need to browse next update coords..
bool _BrowseNextTime;
bool _PostNextTime;
uint _PostFormId;
std::string _PostFormSubmitButton;
// Browsing..
bool _Browsing;
bool _Connecting;
double _TimeoutValue; // the timeout in seconds
double _ConnectingTimeout;
// minimal embeded lua script support
// Note : any embeded script is executed immediately after the closing
// element has been found
// True when the <lua> element has been encountered
bool _ParsingLua;
bool _IgnoreText;
// the script to execute
std::string _LuaScript;
bool _Object;
std::string _ObjectScript;
// Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client.
static CGroupHTML *_ConnectingLock;
// LibWWW data
class CLibWWWData *_LibWWW;
// Current paragraph
std::string _DivName;
CGroupParagraph* _Paragraph;
inline CGroupParagraph *getParagraph()
{
return _Paragraph;
/*if (_Paragraph.empty())
return NULL;
return _Paragraph.back();*/
}
// PRE mode
std::vector<bool> _PRE;
inline bool getPRE() const
{
if (_PRE.empty())
return false;
return _PRE.back();
}
// UL mode
std::vector<bool> _UL;
inline bool getUL() const
{
if (_UL.empty())
return false;
return _UL.back();
}
// A mode
std::vector<bool> _A;
inline bool getA() const
{
if (_A.empty())
return false;
return _A.back();
}
// IL mode
bool _LI;
// Current text color
std::vector<NLMISC::CRGBA> _TextColor;
inline const NLMISC::CRGBA &getTextColor() const
{
if (_TextColor.empty())
return TextColor;
return _TextColor.back();
}
// Current global color flag
std::vector<bool> _GlobalColor;
inline bool getGlobalColor() const
{
if (_GlobalColor.empty())
return false;
return _GlobalColor.back();
}
// Current font size
std::vector<uint> _FontSize;
inline uint getFontSize() const
{
if (_FontSize.empty())
return TextFontSize;
return _FontSize.back();
}
// Current link
std::vector<std::string> _Link;
inline const char *getLink() const
{
if (_Link.empty())
return "";
return _Link.back().c_str();
}
std::vector<std::string> _LinkTitle;
inline const char *getLinkTitle() const
{
if (_LinkTitle.empty())
return "";
return _LinkTitle.back().c_str();
}
std::vector<std::string> _LinkClass;
inline const char *getLinkClass() const
{
if (_LinkClass.empty())
return "";
return _LinkClass.back().c_str();
}
// Divs (i.e. interface group)
std::vector<class CInterfaceGroup*> _Divs;
inline CInterfaceGroup *getDiv() const
{
if (_Divs.empty())
return NULL;
return _Divs.back();
}
// Tables
std::vector<class CGroupTable*> _Tables;
inline CGroupTable *getTable() const
{
if (_Tables.empty())
return NULL;
return _Tables.back();
}
// Cells
std::vector<class CGroupCell*> _Cells;
// TR
std::vector<bool> _TR;
inline bool getTR() const
{
if (_TR.empty())
return false;
return _TR.back();
}
// Forms
class CForm
{
public:
class CEntry
{
public:
CEntry ()
{
TextArea = NULL;
Checkbox = NULL;
ComboBox = NULL;
InitialSelection = 0;
}
// Variable name
std::string Name;
// Variable value
ucstring Value;
// Text area group
CInterfaceGroup *TextArea;
// Checkbox
CCtrlButton *Checkbox;
// Combobox group
CDBGroupComboBox *ComboBox;
// select values (for the <select> tag)
std::vector<std::string> SelectValues;
sint InitialSelection; // initial selection for the combo box
};
// The action the form has to perform
std::string Action;
// The text area associated with the form
std::vector<CEntry> Entries;
};
std::vector<CForm> _Forms;
std::vector<CInterfaceGroup *> _Groups;
// Cells parameters
class CCellParams
{
public:
CCellParams () : BgColor(0,0,0,0)
{
Align = CGroupCell::Left;
VAlign = CGroupCell::Top;
LeftMargin = 0;
NoWrap = false;
}
NLMISC::CRGBA BgColor;
std::string Style;
CGroupCell::TAlign Align;
CGroupCell::TVAlign VAlign;
sint32 LeftMargin;
bool NoWrap;
};
std::vector<CCellParams> _CellParams;
// Indentation
uint _Indent;
// Current node is a title
bool _Title;
// Current node must be localized
bool _Localize;
// Current node is a text area
bool _TextArea;
std::string _TextAreaTemplate;
ucstring _TextAreaContent;
std::string _TextAreaName;
uint _TextAreaRow;
uint _TextAreaCols;
// current mode is in select option
bool _SelectOption;
ucstring _SelectOptionStr;
// Current node is a object
std::string _ObjectType;
std::string _ObjectData;
std::string _ObjectMD5Sum;
std::string _ObjectAction;
std::string _TextAreaScript;
// Get last char
ucchar getLastChar() const;
// Current link view
class CViewLink *_CurrentViewLink;
class CViewBitmap *_CurrentViewImage;
// Current group table
class CGroupCell *_CurrentCell;
// The main group
class CGroupListAdaptor *_GroupListAdaptor;
// For auto selecting the node in a BrowseTree bound to this HTML web page
std::string _BrowseTree;
// select the tree node that has the correct url
const std::string &selectTreeNodeRecurs(CGroupTree::SNode *node, const std::string &url);
// search if the action / params match the url. look recurs into procedures
bool actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url);
// Browse undo and redo
enum {MaxUrlUndoRedo= 256};
std::string _BrowseUndoButton;
std::string _BrowseRedoButton;
std::string _BrowseRefreshButton;
// _BrowseUrl is different from _URL, in that _URL may change in handle()
std::string _AskedUrl;
std::deque<std::string> _BrowseUndo;
std::deque<std::string> _BrowseRedo;
void pushUrlUndoRedo(const std::string &url);
void doBrowse(const char *url);
void updateUndoRedoButtons();
void updateRefreshButton();
// For Killing request. Associate each CGroupHTML object with a unique ID.
uint32 _GroupHtmlUID;
static uint32 _GroupHtmlUIDPool;
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID;
private:
// decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str);
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
struct CDataDownload
{
CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m) : curl(c), url(u), luaScript(s), md5sum(m), type(t), fp(f)
{
if (t == ImgType) imgs.push_back(i);
}
CURL *curl;
std::string url;
std::string luaScript;
std::string md5sum;
TDataType type;
FILE *fp;
std::vector<CViewBase *> imgs;
};
std::vector<CDataDownload> Curls;
CURLM *MultiCurl;
int RunningCurls;
void initImageDownload();
void checkImageDownload();
void addImageDownload(const std::string &url, CViewBase *img);
std::string localImageName(const std::string &url);
bool isTrustedDomain(const std::string &domain);
void setImage(CViewBase *view, const std::string &file);
// BnpDownload system
void initBnpDownload();
void checkBnpDownload();
bool addBnpDownload(const std::string &url, const std::string &action, const std::string &script, const std::string &md5sum);
std::string localBnpName(const std::string &url);
void releaseDownloads();
void checkDownloads();
};
// adapter group that store y offset for inputs inside an html form
class CGroupHTMLInputOffset : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupHTMLInputOffset )
sint32 Offset;
CGroupHTMLInputOffset(const TCtorParam &param);
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
};
}
#endif

@ -0,0 +1,272 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_LIST_H
#define NL_GROUP_LIST_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
namespace NLGUI
{
// ----------------------------------------------------------------------------
class CGroupList : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupList )
enum EAlign
{
Bottom = 0,
Top,
Left,
Right
};
///constructor
CGroupList(const TCtorParam &param);
// dtor
~CGroupList();
/**
* add a child element to the group at the last position
* 'order' of the element is set to the last order + 1
* \param child : pointer to the child element
*/
void addChild (CViewBase* child, bool deleteOnRemove=true);
/** add a child before the element at the given index.
* 'order' of the element is set to 0
* \return true if there was enough room for that child
*/
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
* \param color : text color
*/
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
*/
void addTextChild (const ucstring& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true);
// the same, but with id taken from the database
void addTextChildID (const std::string &dbPath, bool multiLine = true);
bool delChild (CViewBase* child, bool noWarning=false, bool forceDontDelete = false);
bool delChild(uint index, bool forceDontDelete = false);
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
int luaGetChild(CLuaState &ls);
void deleteAllChildren();
void removeHead();
// Get the number of children
uint getNumChildren() const { return (uint)_Elements.size(); }
// Get the number of active children
uint getNumActiveChildren() const;
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
void setTextTemplate(const CViewText& templ);
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
CViewText * getTextTemplatePtr()
{
return &_Templ;
}
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
/**
* parse the element and initalize it
* \paral cur : pointer to the node describing this element
* \param parentGroup : the parent group of this element
* \return true if success
*/
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
//virtual uint32 getMemory();
/**
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
*/
virtual void updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void clearViews();
virtual void clearControls();
virtual void clearGroups();
void setSpace (sint32 s) { _Space = s; }
virtual CInterfaceElement* getElement (const std::string &id)
{ return CInterfaceGroup::getElement (id); }
sint32 getNbElement() { return (sint32)_Elements.size(); }
sint32 getSpace() { return _Space; }
void setDynamicDisplaySize (bool dds) { _DynamicDisplaySize = dds; }
bool getDynamicDisplaySize() { return _DynamicDisplaySize; }
void forceSizeW (sint32 newSizeW);
void forceSizeH (sint32 newSizeH);
void setMinW(sint32 minW);
void setMinH(sint32 minH);
sint32 getMinW() const {return _MinW;}
sint32 getMinH() const {return _MinH;}
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
uint getOrder(uint index) const { return _Elements[index].Order; }
// get element of index or -1 if not found
sint32 getElementIndex(CViewBase* child) const;
int luaGetElementIndex(CLuaState &ls);
// swap 2 entries in the list (and also their orders)
void swapChildren(uint index1, uint index2);
int luaUpChild(CLuaState &ls);
int luaDownChild(CLuaState &ls);
// deleteOnRemove flag
void setDelOnRemove(uint index, bool delOnRemove);
bool getDelOnRemove(uint index) const;
// children number
void setChildrenNb(sint32 /* val */){}
sint32 getChildrenNb() const {return (sint32)_Elements.size();}
int luaAddChild(CLuaState &ls);
int luaAddChildAtIndex(CLuaState &ls);
int luaDetachChild(CLuaState &ls);
int luaClear(CLuaState &ls); // synonimous for deleteAllChildren
int luaAddTextChild(CLuaState &ls);
int luaAddColoredTextChild(CLuaState &ls);
int luaDelChild(CLuaState &ls);
REFLECT_EXPORT_START(CGroupList, CInterfaceGroup)
REFLECT_LUA_METHOD("addTextChild", luaAddTextChild)
REFLECT_LUA_METHOD("addColoredTextChild", luaAddColoredTextChild)
REFLECT_LUA_METHOD("addChild", luaAddChild);
REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex);
REFLECT_LUA_METHOD("detachChild", luaDetachChild);
REFLECT_LUA_METHOD("clear", luaClear);
REFLECT_LUA_METHOD("delChild", luaDelChild);
REFLECT_LUA_METHOD("upChild", luaUpChild);
REFLECT_LUA_METHOD("downChild", luaDownChild);
REFLECT_LUA_METHOD("getChild", luaGetChild);
REFLECT_LUA_METHOD("getElementIndex", luaGetElementIndex);
REFLECT_SINT32 ("childrenNb", getChildrenNb, setChildrenNb);
REFLECT_EXPORT_END
protected:
std::string _HardText;
uint32 _TextId;
//max number of elements
sint32 _MaxElements;
// Where to add next element
EAlign _AddElt;
// Where to align the newly added element
EAlign _Align;
// Space between two elements in pixel
sint32 _Space;
// Text template
CViewText _Templ;
// Current id of the view
sint32 _IdCounter;
// Used for context menu to display the same size as the whole content
bool _DynamicDisplaySize;
// Do we have a color under the element pointed by the mouse
bool _Over;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;
// Current elt over the pointer
sint32 _OverElt;
struct CElementInfo
{
uint Order; // Used to sort the window by their insertion order.
// This is used to put back a window at the right place if it was turned into a popup.
CViewBase *Element;
bool EltDeleteOnRemove;
};
friend struct CRemoveViewPred;
friend struct CRemoveCtrlPred;
friend struct CRemoveGroupPred;
// The list is forced to be at least this size in updateCoords().
sint32 _MinW;
sint32 _MinH;
// To conserve elements in the order they have been added
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
std::vector<CElementInfo> _Elements;
private:
void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
void setupSizes();
void onTextChanged();
};
}
#endif // NL_GROUP_LIST_H
/* End of group_list.h */

@ -0,0 +1,404 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_GROUP_MENU_H
#define RZ_GROUP_MENU_H
#include "nel/gui/interface_group.h"
#include "nel/gui/group_modal.h"
#include "nel/gui/group_submenu_base.h"
#include "nel/gui/view_text.h"
#include "nel/gui/ctrl_text_button.h"
namespace NLGUI
{
class CCtrlScroll;
class CViewBitmap;
class CGroupList;
class CGroupMenu;
/**
* CViewTextMenu is an element of a sub menu
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CViewTextMenu : public CViewText
{
public:
DECLARE_UI_CLASS( CViewTextMenu )
CViewTextMenu(const TCtorParam &param) : CViewText(param)
{
_Grayed = false;
_Checked = false;
_Checkable = false;
_CheckBox = NULL;
Over = false;
}
bool getGrayed() const;
void setGrayed (bool g);
bool getChecked() const { return _Checked; }
void setChecked(bool c);
bool getCheckable() const { return _Checkable; }
void setCheckable(bool c);
void setCheckBox(CViewBitmap *checkBox) { _CheckBox = checkBox; }
CViewBitmap * getCheckBox() const { return _CheckBox; }
bool getFormatted () const { return getMultiLine (); }
virtual sint32 getAlpha() const;
virtual void setAlpha (sint32 a);
REFLECT_EXPORT_START(CViewTextMenu, CViewText)
REFLECT_BOOL("grayed", getGrayed, setGrayed);
REFLECT_BOOL("checked", getChecked, setChecked);
REFLECT_EXPORT_END
public:
bool Over;
NLMISC::CRGBA OldColor;
NLMISC::CRGBA OldShadowColor;
NLMISC::CRGBA OldColorOver;
NLMISC::CRGBA OldShadowColorOver;
NLMISC::CRGBA OldColorGrayed;
NLMISC::CRGBA OldShadowColorGrayed;
private:
CViewBitmap *_CheckBox;
bool _Grayed;
bool _Checked;
bool _Checkable;
};
/**
* CGroupSubMenu describe an element of a contextual menu (contains text lines and sub menu)
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CGroupSubMenu : public CGroupSubMenuBase
{
public:
DECLARE_UI_CLASS( CGroupSubMenu )
CGroupSubMenu(const TCtorParam &param);
virtual ~CGroupSubMenu();
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parent=NULL);
virtual void checkCoords();
virtual void updateCoords ();
virtual void draw ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
virtual CInterfaceElement* getElement (const std::string &id);
// retrieve the index of a line from its id (-1 if not found)
sint getLineFromId(const std::string &id);
CViewTextMenu* addLine (const ucstring &name, const std::string &ah,
const std::string &params, const std::string &id="",
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false, bool formatted = false
);
CViewTextMenu* addLineAtIndex(uint index, const ucstring &name, const std::string &ah,
const std::string &params, const std::string &id="",
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false, bool formatted = false
);
void addSeparator(const std::string &id = "");
void addSeparatorAtIndex(uint index, const std::string &id = "");
uint getNumLine() const { return (uint)_Lines.size(); }
void removeLine(uint index);
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
void openSubMenu (sint32 nb);
void hideSubMenus ();
// reset all entries of the sub menu
void reset();
virtual void setActive (bool state);
// Tell if the line is a separator or not
bool isSeparator (uint i) const;
/** Set a user defined group at the given line
* 'ownership' tells whether this menu should remove the group when it is deleted
* Setting a user group on a line with a separator is illegal
*/
void setUserGroupRight(uint line, CInterfaceGroup *group, bool ownership);
CInterfaceGroup *getUserGroupRight(uint line) const;
//
void setUserGroupLeft(uint line, CInterfaceGroup *group, bool ownership);
CInterfaceGroup *getUserGroupLeft(uint line) const;
void removeAllUserGroups();
uint getNumLines() const { return (uint)_Lines.size(); }
// return pointer to submenu or NULL if there's none
CGroupSubMenu *getSubMenu(uint index) const;
void setSubMenu(uint index, CGroupSubMenu *sub);
// if a menu isn't selectable, can't click on it, and there's no selection when the mouse is over it (but can click on its widgets, such as a usergroup)
void setSelectable(uint lineIndex, bool selectable);
bool getSelectable(uint lineIndex) const;
// Gray a line.
void setGrayedLine(uint line, bool g);
// Hide a line.
void setHiddenLine(uint line, bool h);
// Max Visible Line (-1 == no limit)
void setMaxVisibleLine(sint32 mvl);
sint32 getMaxVisibleLine() { return _MaxVisibleLine; }
// Get the Line Id (not the full Id)
const std::string &getLineId(uint index);
int luaGetNumLine(CLuaState &ls);
int luaGetSubMenu(CLuaState &ls);
int luaAddSubMenu(CLuaState &ls);
int luaGetLineId(CLuaState &ls);
int luaGetLineFromId(CLuaState &ls);
int luaIsSeparator(CLuaState &ls);
int luaAddLine(CLuaState &ls);
int luaAddLineAtIndex(CLuaState &ls);
int luaAddSeparator(CLuaState &ls);
int luaAddSeparatorAtIndex(CLuaState &ls);
int luaRemoveLine(CLuaState &ls);
int luaSetUserGroupRight(CLuaState &ls);
int luaGetUserGroupRight(CLuaState &ls);
int luaSetUserGroupLeft(CLuaState &ls);
int luaGetUserGroupLeft(CLuaState &ls);
int luaReset(CLuaState &ls);
int luaSetMaxVisibleLine(CLuaState &ls);
//
REFLECT_EXPORT_START(CGroupSubMenu, CGroupSubMenuBase)
REFLECT_LUA_METHOD("getNumLine", luaGetNumLine);
REFLECT_LUA_METHOD("getLineId", luaGetLineId); // return the id of a line from its index
REFLECT_LUA_METHOD("getLineFromId", luaGetLineFromId); // return -1 if line with id is not found
REFLECT_LUA_METHOD("getSubMenu", luaGetSubMenu);
REFLECT_LUA_METHOD("addSubMenu", luaAddSubMenu);
REFLECT_LUA_METHOD("isSeparator", luaIsSeparator);
REFLECT_LUA_METHOD("addLine", luaAddLine); // name, ah, ah_params, id
REFLECT_LUA_METHOD("addLineAtIndex", luaAddLineAtIndex); // index, name, ah, ah_params, id
REFLECT_LUA_METHOD("addSeparator", luaAddSeparator);
REFLECT_LUA_METHOD("addSeparatorAtIndex", luaAddSeparatorAtIndex);
REFLECT_LUA_METHOD("removeLine", luaRemoveLine);
REFLECT_LUA_METHOD("reset", luaReset);
REFLECT_LUA_METHOD("setUserGroupRight", luaSetUserGroupRight); // line, group ptr
REFLECT_LUA_METHOD("getUserGroupRight", luaGetUserGroupRight); // line
REFLECT_LUA_METHOD("setUserGroupLeft", luaSetUserGroupLeft); // line, group ptr
REFLECT_LUA_METHOD("getUserGroupLeft", luaGetUserGroupLeft);// line
REFLECT_LUA_METHOD("setMaxVisibleLine", luaSetMaxVisibleLine);
REFLECT_EXPORT_END
protected:
struct SSubMenuEntry
{
CViewTextMenu *ViewText; // Backup of the children that are in grouplist
CInterfaceGroup *Separator;
std::string AHName;
std::string AHParams;
std::string Id;
std::string Cond; // condition to know if the entry is grayed
CViewBitmap *CheckBox;
CViewBitmap *RightArrow;
CInterfaceGroup *UserGroupRight; // not for separator, inserted before checkbox & submenu arrow
CInterfaceGroup *UserGroupLeft;
bool UserGroupRightOwnership;
bool UserGroupLeftOwnership;
bool Selectable;
sint32 HReal; // max H of the view text and the other user group
sint32 TextDY; // Y of the view text to set
SSubMenuEntry()
{
ViewText = NULL;
Separator = NULL;
CheckBox = NULL;
RightArrow = NULL;
UserGroupRight = NULL;
UserGroupLeft = NULL;
UserGroupRightOwnership = false;
Selectable = true;
HReal= 0;
TextDY= 0;
}
};
protected:
CGroupList *_GroupList;
CCtrlScroll *_ScrollBar;
CViewBitmap *_SelectionView;
std::vector<SSubMenuEntry> _Lines;
std::vector<CGroupSubMenu*> _SubMenus;
CGroupMenu *_GroupMenu; // Master parent
sint32 _Selected;
sint32 _MaxVisibleLine; // -1 == no limit
friend class CGroupMenu;
private:
/** Clone this menu, and set its new father
* If appendToMenu is NULL, the menu is just copied
* otherwise, no copy is made, but this menu entries are appended to the already created 'appendMenu' menu.
* NB : user groups are not duplicated
*/
CGroupSubMenu *cloneMenu(CGroupSubMenu *appendToMenu, CGroupMenu *newFather, CInterfaceGroup *initGroup = NULL) const;
void initOptions(CInterfaceGroup *parent);
CViewBitmap *createCheckBox(bool checked);
CViewBitmap *createRightArrow(CInterfaceElement *parentPos, bool center);
};
/**
* class describing a menu composed of one or more CGroupListSubMenu
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CGroupMenu : public CGroupModal
{
public:
DECLARE_UI_CLASS( CGroupMenu )
CGroupMenu(const TCtorParam &param);
virtual ~CGroupMenu();
TCaseMode getCaseMode() { return _CaseMode; }
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void draw ();
void recurseDraw(CGroupSubMenu *pSubMenu);
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
virtual CInterfaceElement* getElement (const std::string &id);
virtual void setActive (bool state);
virtual bool isWindowUnder (sint32 x, sint32 y);
// add line with a string, for backward compatibility
void addLine (const std::string &name, const std::string &ah, const std::string &params,
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false);
uint getNumLine() const;
void deleteLine(uint index);
const std::string getActionHandler(uint lineIndex) const;
const std::string getActionHandlerParam(uint lineIndex) const;
void addLine (const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false
);
void addLineAtIndex (uint index, const ucstring &name, const std::string &ah = "", const std::string &params = "",
const std::string &id = std::string(),
const std::string &cond = std::string(), const std::string &texture="",
bool checkable = false, bool checked = false
);
void setUserGroupRight(uint line, CInterfaceGroup *gr, bool ownerShip = true);
void setUserGroupLeft(uint line, CInterfaceGroup *gr, bool ownerShip = true);
// clear all sub menus
void reset ();
// set the minW of the RootMenu.
void setMinW(sint32 minW);
// Gray a line on the RootMenu
void setGrayedLine(uint line, bool g);
CGroupSubMenu *getRootMenu() const { return _RootMenu; }
// Max Visible Line (-1 == no limit)
void setMaxVisibleLine(sint32 mvl) { _RootMenu->setMaxVisibleLine(mvl); }
sint32 getMaxVisibleLine() { return _RootMenu->getMaxVisibleLine(); }
// special for menu launched from a modal....
bool getCloseSubMenuUsingPopModal() const {return _CloseSubMenuUsingPopModal;}
void setCloseSubMenuUsingPopModal(bool state) {_CloseSubMenuUsingPopModal= state;}
int luaGetRootMenu(CLuaState &ls);
int luaSetMinW(CLuaState &ls);
REFLECT_EXPORT_START(CGroupMenu, CGroupModal)
REFLECT_LUA_METHOD("getRootMenu", luaGetRootMenu);
REFLECT_LUA_METHOD("setMinW", luaSetMinW);
REFLECT_EXPORT_END
protected:
TCaseMode _CaseMode;
CGroupSubMenu *_RootMenu;
std::string _Extends;
// Text lookup
NLMISC::CRGBA _Color;
NLMISC::CRGBA _ShadowColor;
bool _CloseSubMenuUsingPopModal;
bool _Shadow;
bool _Formatted;
uint8 _Space;
sint32 _FontSize;
NLMISC::CRGBA _ColorOver; // Color of the text when the mouse is over it
NLMISC::CRGBA _ShadowColorOver; // Color of the shadow when the mouse is over it
NLMISC::CRGBA _HighLightOver; // Background color of the selection
NLMISC::CRGBA _ColorGrayed; // Color of the text when it is unusable
NLMISC::CRGBA _ShadowColorGrayed; // Color of the shadow when it is unusable
friend class CGroupSubMenu;
};
}
#endif // RZ_GROUP_MENU_H
/* End of group_menu.h */

@ -0,0 +1,79 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_MODAL_H
#define NL_GROUP_MODAL_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
namespace NLGUI
{
// ***************************************************************************
/**
* A group with special modal options
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CGroupModal : public CGroupFrame
{
public:
DECLARE_UI_CLASS( CGroupModal )
bool SpawnOnMousePos : 1;
bool ExitClickOut : 1;
bool ExitClickL : 1;
bool ExitClickR : 1;
bool ForceInsideScreen : 1;
bool ExitKeyPushed : 1;
sint32 SpawnMouseX, SpawnMouseY;
std::string Category;
std::string OnClickOut; // Launched when clicking out of the window, and BEFORE a new control has been cpatured
std::string OnClickOutParams;
std::string OnPostClickOut; // Launched when clicking out of the window, and AFTER a new control has been captured
std::string OnPostClickOutParams;
public:
/// Constructor
CGroupModal(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
void setBaseX(sint32 x) { _MouseDeltaX = x;}
void setBaseY(sint32 y) { _MouseDeltaY = y;}
REFLECT_EXPORT_START(CGroupModal, CGroupFrame)
REFLECT_EXPORT_END
// ******************
protected:
sint32 _MouseDeltaX, _MouseDeltaY;
};
}
#endif // NL_GROUP_MODAL_H
/* End of group_modal.h */

@ -0,0 +1,317 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_PARAGRAPH_H
#define NL_GROUP_PARAGRAPH_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
#include "nel/gui/view_link.h"
#include "nel/gui/ctrl_button.h"
namespace NLGUI
{
class CCtrlLink : public CCtrlButton
{
public:
DECLARE_UI_CLASS( CCtrlLink )
CCtrlLink (const TCtorParam &param) : CCtrlButton(param)
{}
};
// ----------------------------------------------------------------------------
class CGroupParagraph : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupParagraph )
enum EAlign
{
Bottom = 0,
Top,
Left,
Right
};
///constructor
CGroupParagraph(const TCtorParam &param);
// dtor
~CGroupParagraph();
/**
* add a child element to the group at the last position
* 'order' of the element is set to the last order + 1
* \param child : pointer to the child element
*/
void addChild (CViewBase* child, bool deleteOnRemove=true);
/**
* add a link element to the group at the last position
* \param child : pointer to the child element
*/
void addChildLink (CViewLink* child, bool deleteOnRemove=true);
/** add a child before the element at the given index.
* 'order' of the element is set to 0
* \return true if there was enough room for that child
*/
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
* \param color : text color
*/
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
*/
void addTextChild (const ucstring& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true);
// the same, but with id taken from the database
void addTextChildID (const std::string &dbPath, bool multiLine = true);
protected:
void delChild (CViewBase* child);
void delChild(uint index);
public:
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
void deleteAllChildren();
// void removeHead();
// Get the number of children
uint getNumChildren() const { return (uint)_Elements.size(); }
// Get the number of active children
uint getNumActiveChildren() const;
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
void setTextTemplate(const CViewText& templ);
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
CViewText * getTextTemplatePtr()
{
return &_Templ;
}
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
/**
* parse the element and initalize it
* \paral cur : pointer to the node describing this element
* \param parentGroup : the parent group of this element
* \return true if success
*/
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
//virtual uint32 getMemory();
/**
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
*/
virtual void updateCoords();
virtual void checkCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void clearViews();
virtual void clearControls();
virtual void clearGroups();
void setSpace (sint32 s) { _Space = s; }
virtual CInterfaceElement* getElement (const std::string &id)
{ return CInterfaceGroup::getElement (id); }
sint32 getNbElement() { return (sint32)_Elements.size(); }
sint32 getSpace() { return _Space; }
void forceSizeW (sint32 newSizeW);
void forceSizeH (sint32 newSizeH);
void setMinW(sint32 minW);
void setMinH(sint32 minH);
sint32 getMinW() const {return _MinW;}
sint32 getMinH() const {return _MinH;}
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
uint getOrder(uint index) const { return _Elements[index].Order; }
// get element of index or -1 if not found
sint32 getElementIndex(CViewBase* child) const;
// swap 2 entries in the list (and also their orders)
// void swapChildren(uint index1, uint index2);
// deleteOnRemove flag
void setDelOnRemove(uint index, bool delOnRemove);
bool getDelOnRemove(uint index) const;
void setTopSpace(uint topSpace)
{
_TopSpace = topSpace;
setResizeFromChildHMargin(topSpace);
invalidateContent();
};
uint getTopSpace()
{
return _TopSpace;
};
void setIndent(uint indent) { _Indent = indent; }
void setFirstViewIndent(sint indent)
{
_FirstViewIndentView = indent;
invalidateContent();
}
// Set the HTML group used for links
void setBrowseGroup (CInterfaceElement *group)
{
_BrowseGroup = group;
}
/// \from CInterfaceElement
void onInvalidateContent();
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
protected:
// Content validated
bool _ContentValidated;
// Where to add next element
EAlign _AddElt;
// Where to align the newly added element
EAlign _Align;
// Space between two elements in pixel
sint32 _Space;
// Text template
CViewText _Templ;
// Current id of the view
sint32 _IdCounter;
// Do we have a color under the element pointed by the mouse
bool _Over;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;
// Current elt over the pointer
sint32 _OverElt;
struct CElementInfo
{
uint Order; // Used to sort the window by their insertion order.
// This is used to put back a window at the right place if it was turned into a popup.
CViewBase *Element;
bool EltDeleteOnRemove;
};
friend struct CRemoveViewPred;
friend struct CRemoveCtrlPred;
friend struct CRemoveGroupPred;
// The list is forced to be at least this size in updateCoords().
sint32 _MinW;
sint32 _MinH;
// To conserve elements in the order they have been added
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
std::vector<CElementInfo> _Elements;
// Last parent width
sint32 _LastW;
// Top space
uint _TopSpace;
// Indent
uint _Indent; // Left margin
sint _FirstViewIndentView; // Additionnal left margin for the first view
// A link structure
class CLink
{
public:
CLink(CViewLink *link);
// The link view
CViewLink *Link;
// The three control button
CCtrlLink *CtrlLink[3];
};
// The links
std::vector<CLink> _Links;
// The HTML group used
CInterfaceElement *_BrowseGroup;
private:
std::string _HardText;
uint32 _TextId;
void setupSizes();
void onTextChanged();
// void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
// void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
};
}
#endif // NL_GROUP_PARAGRAPH_H
/* End of group_paragraph.h */

@ -0,0 +1,92 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_SCROLLTEXT_H
#define CL_GROUP_SCROLLTEXT_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
class CGroupList;
// Can be used to build a chat window or anything that displays sequences of strings
/**
* Widget to have a resizable scrolltext and its scrollbar
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CGroupScrollText : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupScrollText )
/// Constructor
CGroupScrollText(const TCtorParam &param);
~CGroupScrollText();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
/// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
virtual void checkCoords ();
virtual void draw ();
virtual void clearViews ();
virtual bool handleEvent (const NLGUI::CEventDescriptor &eventDesc);
// get the list associated to this group
CGroupList *getList() const { return _List; }
// Get the scroll bar
CCtrlScroll *getScrollBar() const { return _ScrollBar; }
// from CCtrlBase
virtual void elementCaptured(CCtrlBase *capturedElement);
REFLECT_EXPORT_START(CGroupScrollText, CInterfaceGroup)
REFLECT_EXPORT_END
private:
CGroupList *_List;
CCtrlScroll *_ScrollBar;
CCtrlBaseButton *_ButtonAdd;
CCtrlBaseButton *_ButtonSub;
bool _Settuped;
bool _InvertScrollBar;
sint32 _ListHeight;
protected:
void setup();
void updateScrollBar();
public:
// private use for action handlers
sint32 _StartHeight;
sint64 _EllapsedTime;
};
}
#endif

@ -0,0 +1,48 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef GROUP_SUBMENU_BASE
#define GROUP_SUBMENU_BASE
#include "nel/gui/group_frame.h"
namespace NLGUI
{
class CGroupSubMenuBase : public CGroupFrame
{
public:
DECLARE_UI_CLASS( CGroupSubMenuBase )
CGroupSubMenuBase( const TCtorParam &param );
~CGroupSubMenuBase();
virtual void openSubMenu( sint32 nb );
virtual void hideSubMenus();
REFLECT_EXPORT_START( CGroupSubMenuBase, CGroupFrame )
REFLECT_EXPORT_END
protected:
private:
};
}
#endif

@ -0,0 +1,190 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_TAB_H
#define NL_GROUP_TAB_H
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/ctrl_text_button.h"
namespace NLGUI
{
class CCtrlTabButton;
// ***************************************************************************
/**
* Group handling Ctrl Tab, to easily simulate Tab ctrl.
* NB: controlled groups doesn't have to be child of the GroupTab, they are searched in order:
* - in this group
* - in the parent group
* - in global
* \author Lionel Berenguier
* \author Nevrax France
* \date 2003
*/
class CGroupTab : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupTab )
/// Constructor
CGroupTab(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void updateCoords ();
// select the ctrl tab. -1 will invalidate all.
void select(sint index);
sint getSelection() const;
// select with a CCtrlTabButton ptr
void selectFromCtrl(CCtrlTabButton *button);
// select a default activated tab, if the current is a special ctrlTab
void selectDefault(CCtrlTabButton *ifSelectionIs);
// select a default activated tab, if the current is hid
void selectDefaultIfCurrentHid();
// add new tab
void addTab(CCtrlTabButton *tabB);
void addTab(CCtrlTabButton *tabB, sint index);
int luaAddTab(CLuaState &ls);
int luaAddTabWithOrder(CLuaState &ls);
// remove selected tab
void removeTab(sint index);
int luaRemoveTab(CLuaState &ls);
// remove all tabs
void removeAll();
int luaRemoveAll(CLuaState &ls);
// tab number
void setTabButtonNb(sint32 /* val */){}
sint32 getTabButtonNb() const {return (sint32)_Buttons.size();}
// selection index
void setIndexSelection(sint32 val){select((sint)val);}
sint32 getIndexSelection() const {return (sint32)_NextSelection;}
// selection index
void setAssociatedGroupSelection(const std::string & /* assG */){}
std::string getAssociatedGroupSelection() const;
// get group from index
CInterfaceGroup* getGroup(sint index);
int luaGetGroup(CLuaState &ls);
// get tab from index
CCtrlTabButton* getTabButton(sint index);
int luaGetTabButton(CLuaState &ls);
// first showed tab button
sint32 getFirstTabButton() const {return (sint32)_FirstTabIndex;}
// last showed tab button
sint32 getLastTabButton() const {return (sint32)_LastTabIndex;}
// update showed tab buttons on function of GroupTab width
void updateFirstTabButton();
int luaShowTabButton(CLuaState &ls);
void dummySet(sint32 /* value */){}
REFLECT_EXPORT_START(CGroupTab, CInterfaceGroup)
REFLECT_LUA_METHOD("addTab", luaAddTab)
REFLECT_LUA_METHOD("addTabWithOrder", luaAddTabWithOrder)
REFLECT_LUA_METHOD("removeTab", luaRemoveTab)
REFLECT_LUA_METHOD("removeAll", luaRemoveAll)
REFLECT_LUA_METHOD("getGroup", luaGetGroup)
REFLECT_LUA_METHOD("getTabButton", luaGetTabButton)
REFLECT_LUA_METHOD("showTabButton", luaShowTabButton)
REFLECT_SINT32 ("tabButtonNb", getTabButtonNb, setTabButtonNb)
REFLECT_SINT32 ("selection", getIndexSelection, setIndexSelection)
REFLECT_SINT32 ("firstTabButton", getFirstTabButton, dummySet)
REFLECT_SINT32 ("lastTabButton", getLastTabButton, dummySet)
REFLECT_STRING ("associatedGroupSelection", getAssociatedGroupSelection, setAssociatedGroupSelection)
REFLECT_EXPORT_END
private:
std::vector<CCtrlTabButton*> _Buttons; // can't be NULL.
std::vector<CInterfaceGroup*> _Groups; // may be NULL
sint _Selection;
sint _NextSelection;
sint _BaseRenderLayer;
bool _Setuped;
bool _HideOutTabs;
sint _FirstTabIndex;
sint _LastTabIndex;
std::string _AHOnChange;
std::string _ParamsOnChange;
void setup();
};
// ***************************************************************************
/**
* Used with CGroupTab
*/
class CCtrlTabButton : public CCtrlTextButton
{
public:
DECLARE_UI_CLASS( CCtrlTabButton )
CCtrlTabButton(const TCtorParam &param);
void setProperty( const std::string &name, const std::string &value );
std::string getProperty( const std::string &name ) const;
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void setActive(bool state);
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void setBlink (bool b);
std::string _AssociatedGroup;
IActionHandler *_AHOnLeftClick2;
private:
sint32 _DefaultX;
bool _Blinking;
NLMISC::CRGBA _TextColorNormalBlink;
bool _TextModulateGlobalColorNormalBlink;
sint64 _BlinkDate;
bool _BlinkState;
};
}
#endif // NL_GROUP_TAB_H
/* End of group_tab.h */

@ -0,0 +1,227 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_TABLE_H
#define NL_GROUP_TABLE_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
#include "nel/gui/ctrl_button.h"
namespace NLGUI
{
/**
* This group is used to simulate HTML cells.
* They have specific parameters to be aligned like HTML cells.
* (Percent of the table size
*/
class CGroupCell: public CInterfaceGroup
{
friend class CGroupTable;
public:
DECLARE_UI_CLASS( CGroupCell )
CGroupCell(const TCtorParam &param);
enum TAlign
{
Left,
Center,
Right
};
enum TVAlign
{
Top,
Middle,
Bottom
};
/// \from CInterfaceElement
virtual void draw();
virtual sint32 getMaxUsedW() const;
virtual sint32 getMinUsedW() const;
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
// to be called by CGroupTable
bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup, uint columnIndex, uint rowIndex);
// If the cell is a new line. This is the first <td> after a <tr>
bool NewLine;
bool IgnoreMaxWidth;
bool IgnoreMinWidth;
bool AddChildW;
// The table width cell ratio. This is the <td width="50%"> parameter
float TableRatio;
// The Width you want in pixel. This is the <td width="100"> parameter
sint32 WidthWanted;
// The min height of the cell
sint32 Height;
// Memorize max width
sint32 WidthMax;
// The cell color
NLMISC::CRGBA BgColor;
// Texture
CViewRenderer::CTextureId _TextureId; /// Accelerator
bool _UserTexture;
bool _TextureTiled;
bool _TextureScaled;
// Alignment
TAlign Align;
TVAlign VAlign;
sint32 LeftMargin;
// The cell group
CInterfaceGroup *Group;
// The cell is nowrap
bool NoWrap;
void setTexture(const std::string & TxName);
void setTextureTile(bool tiled);
void setTextureScale(bool scaled);
static void setDebugUICell( bool d ){ DebugUICell = d; }
static bool getDebugUICell(){ return DebugUICell; }
private:
void setEnclosedGroupDefaultParams();
static bool DebugUICell;
};
/**
* This group is used to simulate HTML table. Support "percent of the parent width" sizeRef mode.
*/
class CGroupTable : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupTable )
///constructor
CGroupTable(const TCtorParam &param);
// dtor
~CGroupTable();
// Add a cell in the table
void addChild (CGroupCell* child);
// The ratio you want [0 ~1]. This is the <table width="50%"> parameter
float TableRatio;
// The Width you want in pixel. This is the <table width="100"> parameter
sint32 ForceWidthMin;
// Table borders
sint32 Border;
sint32 CellPadding;
sint32 CellSpacing;
// The table color
NLMISC::CRGBA BgColor;
uint8 CurrentAlpha;
bool ContinuousUpdate;
std::string getProperties( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
protected:
/// \from CInterfaceElement
void onInvalidateContent();
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
void draw ();
/**
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
*/
virtual void updateCoords();
virtual void checkCoords();
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
// Content validated
bool _ContentValidated;
// Last parent width
sint32 _LastParentW;
// Children
std::vector<CGroupCell *> _Cells;
// Table column
class CColumn
{
public:
CColumn()
{
Width = 0;
WidthMax = 0;
WidthWanted = 0;
TableRatio = 0;
Height = 0;
}
sint32 Width;
sint32 Height;
sint32 WidthWanted;
sint32 WidthMax;
float TableRatio;
};
// Table row
class CRow
{
public:
CRow()
{
Height = 0;
}
sint32 Height;
};
// Column table
std::vector<CColumn> _Columns;
// Column table
std::vector<CRow> _Rows;
};
}
#endif // NL_GROUP_TABLE_H
/* End of group_table.h */

@ -0,0 +1,382 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_GROUP_TREE_H
#define NL_GROUP_TREE_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/misc/smart_ptr.h"
namespace NLGUI
{
class CViewText;
class CViewBitmap;
// ----------------------------------------------------------------------------
class CGroupTree : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CGroupTree )
struct SNode;
// optional callback that is called when a node has been added
struct INodeAddedCallback
{
/** A node has just been added in the CGroupTree object
* \param node The logic node from which the ui node was built
* \param interfaceElement The ui node that was built
*/
virtual void nodeAdded(SNode *node, CInterfaceElement *interfaceElement) = 0;
};
// Logic structure to initialize the group tree (root node is not displayed and is always opened)
struct SNode : public CReflectableRefPtrTarget
{
typedef NLMISC::CRefPtr<SNode> TRefPtr;
// Common
std::string Id; // If not present auto-generated
bool Opened;
bool DisplayText; // If false instanciate a template
bool Show; // If false, the node is not displayed (true default, Root ignored)
sint32 YDecal;
// Text
ucstring Text; // Internationalized displayed text
sint32 FontSize; // If -1 (default), then take the groupTree one
NLMISC::CRGBA Color;
// Template
NLMISC::CSmartPtr<CInterfaceGroup> Template;
// Actions Handlers (for left button)
std::string AHName;
std::string AHCond;
std::string AHParams;
// Actions Handlers (for right button)
std::string AHNameRight;
std::string AHParamsRight;
// Actions Handlers (close/open node)
std::string AHNameClose;
std::string AHParamsClose;
// bitmap at this level of hierarchy
std::string Bitmap; // additionnal bitmap
// Hierarchy
std::vector<SNode*> Children;
SNode *Father;
// updated at display
SNode *LastVisibleSon; // filled at build time, meaningfull only if son is shown and opened, undefined otherwise
// Node added callback
INodeAddedCallback *NodeAddedCallback;
//
CGroupTree *ParentTree;
// ----------------------------
SNode();
~SNode();
void updateLastVisibleSon();
void detachChild(SNode *pNode);
void deleteChild(SNode *pNode);
void addChild (SNode *pNode);
bool isChild(SNode *pNode) const;
void addChildFront (SNode *pNode);
void addChildAtIndex (SNode *pNode, sint index);
void addChildSorted(SNode *pNode);
void addChildSortedByBitmap(SNode *pNode);
void setParentTree(CGroupTree *parent);
void setFather(SNode *father);
void closeAll();
void makeOrphan();
bool parse (xmlNodePtr cur, CGroupTree *parentGroup);
uint getNumBitmap() const { return Bitmap.empty() ? 0 : 1; }
SNode *getNodeFromId(const std::string &id);
// accessors
void setBitmap(const std::string &bitmap) { Bitmap = bitmap; }
std::string getBitmap() const { return Bitmap; }
void setOpened(bool opened) { Opened = opened; }
bool getOpened() const { return Opened; }
void setText(const ucstring &text) { Text = text; }
const ucstring& getText() const { return Text; }
sint32 getFontSize() const { return FontSize; }
void setFontSize(sint32 value) { FontSize = value; }
sint32 getYDecal() const { return YDecal; }
void setYDecal(sint32 value) { YDecal = value; }
std::string getId() const { return Id; }
void setId(const std::string &value) { Id = value; }
bool getShow() const { return Show; }
void setShow(bool value) { Show = value; }
std::string getAHName() const { return AHName; }
void setAHName(const std::string &value) { AHName = value; }
std::string getAHCond() const { return AHCond; }
void setAHCond(const std::string &value) { AHCond = value; }
std::string getAHParams() const { return AHParams; }
void setAHParams(const std::string &value) { AHParams = value; }
std::string getAHNameRight() const { return AHNameRight; }
void setAHNameRight(const std::string &value) { AHNameRight = value; }
std::string getAHParamsRight() const { return AHParamsRight; }
void setAHParamsRight(const std::string &value) { AHParamsRight = value; }
std::string getAHNameClose() const { return AHNameClose; }
void setAHNameClose(const std::string &value) { AHNameClose = value; }
std::string getAHParamsClose() const { return AHParamsClose; }
void setAHParamsClose(const std::string &value) { AHParamsClose = value; }
NLMISC::CRGBA getColor() const { return Color; }
void setColor(NLMISC::CRGBA color) { Color = color; }
// sort branch & sons alphabetically
void sort();
// sort branch & sons alphabetically & by bitmap name (blank bitmap being the first)
void sortByBitmap();
// lua bindings
int luaGetNumChildren(CLuaState &ls);
int luaGetChild(CLuaState &ls);
int luaDetachChild(CLuaState &ls);
int luaDeleteChild(CLuaState &ls);
int luaAddChild(CLuaState &ls);
int luaAddChildSorted(CLuaState &ls);
int luaAddChildSortedByBitmap(CLuaState &ls);
int luaIsChild(CLuaState &ls);
int luaAddChildFront (CLuaState &ls);
int luaAddChildAtIndex (CLuaState &ls);
int luaCloseAll(CLuaState &ls);
int luaGetFather(CLuaState &ls);
int luaSort(CLuaState &ls);
int luaSortByBitmap(CLuaState &ls);
int luaGetNodeFromId(CLuaState &ls);
int luaGetParentTree(CLuaState &ls);
// get node from first parameter on lua stack and throw necessary exception if not present
static SNode *luaGetNodeOnStack(CLuaState &ls, const char *funcName);
REFLECT_EXPORT_START(CGroupTree::SNode, CReflectable)
REFLECT_STRING("Id", getId, setId);
REFLECT_STRING("Bitmap", getBitmap, setBitmap);
REFLECT_SINT32("FontSize", getFontSize, setFontSize);
REFLECT_SINT32("YDecal", getYDecal, setYDecal);
REFLECT_STRING("AHName", getAHName, setAHName);
REFLECT_STRING("AHCond", getAHCond, setAHCond);
REFLECT_RGBA("Color", getColor, setColor);
REFLECT_STRING("AHParams", getAHParams, setAHParams);
REFLECT_STRING("AHNameRight", getAHNameRight, setAHNameRight);
REFLECT_STRING("AHParamsRight", getAHParamsRight, setAHParamsRight);
REFLECT_STRING("AHNameClose", getAHNameClose, setAHNameClose);
REFLECT_STRING("AHParamsClose", getAHParamsClose, setAHParamsClose);
REFLECT_BOOL("Opened", getOpened, setOpened);
REFLECT_BOOL("Show", getShow, setShow);
REFLECT_UCSTRING("Text", getText, setText);
// lua
REFLECT_LUA_METHOD("getNumChildren", luaGetNumChildren);
REFLECT_LUA_METHOD("getChild", luaGetChild);
REFLECT_LUA_METHOD("detachChild", luaDetachChild);
REFLECT_LUA_METHOD("deleteChild", luaDeleteChild);
REFLECT_LUA_METHOD("addChild", luaAddChild);
REFLECT_LUA_METHOD("addChildSorted", luaAddChildSorted);
REFLECT_LUA_METHOD("addChildSortedByBitmap", luaAddChildSortedByBitmap);
REFLECT_LUA_METHOD("addChildFront", luaAddChildFront);
REFLECT_LUA_METHOD("addChildAtIndex", luaAddChildAtIndex);
REFLECT_LUA_METHOD("isChild", luaIsChild);
REFLECT_LUA_METHOD("closeAll", luaCloseAll);
REFLECT_LUA_METHOD("getFather", luaGetFather);
REFLECT_LUA_METHOD("sort", luaSort);
REFLECT_LUA_METHOD("sortByBitmap", luaSortByBitmap);
REFLECT_LUA_METHOD("getNodeFromId", luaGetNodeFromId);
REFLECT_LUA_METHOD("getParentTree", luaGetParentTree);
REFLECT_EXPORT_END
};
public:
///constructor
CGroupTree(const TCtorParam &param);
// dtor
virtual ~CGroupTree();
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void checkCoords();
virtual void updateCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
void reset();
// force rebuild the tree at next updateCoords()
void forceRebuild();
// For SNode
sint32 getIdNumber() { _IdGenerator++; return _IdGenerator; }
sint32 getFontSize() { return _FontSize; }
sint32 getYDecal() { return _YDecal; }
// Set root node and delete the last one the user must not delete all allocated sub node. Nb: selection is reseted
void setRootNode (SNode *);
// Remove all lines bitmaps and templates or texts
void removeAll();
// unselect current node in tree
void unselect();
// Select a node by its line index (depends on opened nodes). no-op if not possible (AH not here, line>size)
void selectLine(uint line, bool runAH = true);
// simulate right button click on the given line (this also select the line)
bool rightButton(uint line);
// Get the Selected Node Id. empty if none selected
const std::string &getSelectedNodeId() const;
// Select by the node Id. return false if not found (selection is not reseted)
// NB: if the node was already selected, no-op (no action handler launched)
bool selectNodeById(const std::string &nodeId, bool triggerAH = true);
// Get the root node (Opened State represent the current state)
SNode *getRootNode () const {return _RootNode;}
// get current SNode under the mouse (possibly NULL)
SNode *getNodeUnderMouse() const;
// Get/Change the NavigateOneBrnahc option. if false, then perform a reset before
bool getNavigateOneBranch() const {return _NavigateOneBranch;}
void changeNavigateOneBranch(bool newState);
// should be called by action handler when thy want to cancel the selection of the line that triggered them
void cancelNextSelectLine();
// Get selected node
SNode * getSelectedNode() { return _SelectedNode;}
// lua bindings
int luaGetRootNode(CLuaState &ls);
int luaSetRootNode(CLuaState &ls);
int luaForceRebuild(CLuaState &ls);
int luaSelectNodeById(CLuaState &ls);
int luaGetSelectedNodeId(CLuaState &ls);
int luaSelectLine(CLuaState &ls);
int luaUnselect(CLuaState &ls);
int luaGetNodeUnderMouse(CLuaState &ls);
int luaCancelNextSelectLine(CLuaState &ls);
// Reflection
REFLECT_EXPORT_START(CGroupTree, CInterfaceGroup)
REFLECT_BOOL ("navigate_one_branch", getNavigateOneBranch, changeNavigateOneBranch);
REFLECT_LUA_METHOD("getRootNode", luaGetRootNode);
REFLECT_LUA_METHOD("setRootNode", luaSetRootNode);
REFLECT_LUA_METHOD("forceRebuild", luaForceRebuild);
REFLECT_LUA_METHOD("getSelectedNodeId", luaGetSelectedNodeId);
REFLECT_LUA_METHOD("selectNodeById", luaSelectNodeById);
REFLECT_LUA_METHOD("selectLine", luaSelectLine);
REFLECT_LUA_METHOD("unselect", luaUnselect);
REFLECT_LUA_METHOD("getNodeUnderMouse", luaGetNodeUnderMouse);
REFLECT_LUA_METHOD("cancelNextSelectLine", luaCancelNextSelectLine);
REFLECT_EXPORT_END
private:
void setupArbo();
sint32 _BmpW, _BmpH, _FontSize, _YDecal;
sint32 _XExtend;
private:
// Display structure
struct SLine
{
CViewBase *TextOrTemplate;
std::vector<CViewBitmap*> Bmps;
SNode::TRefPtr Node;
uint8 Depth;
SLine()
{
TextOrTemplate = NULL;
}
~SLine()
{
Bmps.clear();
}
uint getNumAdditionnalBitmap() const;
};
protected:
void rebuild();
void addTextLine (uint8 nDepth, SNode *pNode);
void addHierarchyBitmaps();
SNode *selectNodeByIdRecurse(SNode *pNode, const std::string &nodeId);
SNode *_RootNode;
sint32 _IdGenerator;
bool _MustRebuild;
std::vector<SLine> _Lines;
sint32 _OverLine;
NLMISC::CRGBA _OverColor;
NLMISC::CRGBA _OverColorBack;
SNode *_SelectedNode;
sint32 _SelectedLine;
NLMISC::CRGBA _SelectedColor;
// If a node is closed and a son of this node was selected, then this option force the ancestor being the new selection
bool _SelectAncestorOnClose;
bool _NavigateOneBranch;
bool _AvoidSelectNodeByIdIR;
// when an action handler is run, it can call 'cancelSelectLine' if no selection should be done for real
bool _CancelNextSelectLine;
// Bitmap For arbo
std::string _ArboOpenFirst;
std::string _ArboCloseJustOne;
std::string _ArboSonWithoutSon;
std::string _ArboSonLast;
std::string _ArboSon;
std::string _ArboLevel;
std::string _ArboXExtend;
// Special rectangle
bool _RectangleOutlineMode;
sint32 _RectangleX, _RectangleY;
sint32 _RectangleW, _RectangleH;
sint32 _RectangleDeltaRL;
sint32 getHrcIconXStart(sint32 depth);
sint32 getHrcIconXEnd(sint32 depth);
void drawSelection(sint x, sint y, sint w, NLMISC::CRGBA col);
CViewBitmap *createViewBitmap(uint line, const std::string &idPrefix, const std::string &texture);
};
}
#endif // NL_GROUP_TREE_H
/* End of group_tree.h */

@ -0,0 +1,52 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_GROUP_CONTAINER_H
#define RZ_GROUP_CONTAINER_H
#include "nel/gui/interface_group.h"
namespace NLGUI
{
// Special group to handle the mouse wheel message
class CInterfaceGroupWheel : public CInterfaceGroup
{
public:
DECLARE_UI_CLASS( CInterfaceGroupWheel )
/// Constructor
CInterfaceGroupWheel(const TCtorParam &param);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
/// Coming from CInterfaceElement
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
private:
IActionHandler *_AHWheelUp;
CStringShared _AHWheelUpParams;
IActionHandler *_AHWheelDown;
CStringShared _AHWheelDownParams;
};
}
#endif

@ -0,0 +1,36 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef INPUTEVENTLISTENER_H
#define INPUTEVENTLISTENER_H
#include "nel/misc/types_nl.h"
#include "nel/gui/event_descriptor.h"
namespace NLGUI
{
/**
@brief Interface for accepting GUI input events.
*/
class IInputEventListener
{
public:
virtual ~IInputEventListener(){}
virtual bool handleEvent( const CEventDescriptor &eventDesc ) = 0;
};
}
#endif

@ -0,0 +1,57 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef INPUT_HANDLER_H
#define INPUT_HANDLER_H
#include "nel/misc/events.h"
#include "nel/gui/event_descriptor.h"
#include "nel/gui/input_event_listener.h"
namespace NLGUI{
/**
@brief The input event entry point of the GUI library.
Translates the NEL input events and forwards them.
*/
class CInputHandler
{
public:
CInputHandler();
~CInputHandler();
bool handleEvent( const NLMISC::CEvent &evnt );
bool handleSetFocusEvent( const NLMISC::CEvent &evnt );
bool handleKeyboardEvent( const NLMISC::CEvent &evnt );
bool handleMouseEvent( const NLMISC::CEvent &evnt );
bool handleMouseMoveEvent( const NLMISC::CEvent &evnt );
bool handleMouseButtonDownEvent( const NLMISC::CEvent &evnt );
bool handleMouseButtonUpEvent( const NLMISC::CEvent &evnt );
bool handleMouseDblClickEvent( const NLMISC::CEvent &evnt );
bool handleMouseWheelEvent( const NLMISC::CEvent &evnt );
void setListener( IInputEventListener* listener );
private:
IInputEventListener *listener;
};
}
#endif

@ -0,0 +1,135 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_INTERFACE_ANIM_H
#define RZ_INTERFACE_ANIM_H
#include "nel/gui/interface_property.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/interface_link.h"
#include "nel/3d/animation_time.h"
#include "nel/3d/u_track.h"
namespace NLGUI
{
/**
* class managing an animation track
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2003
*/
class CInterfaceTrack
{
public:
CInterfaceTrack();
virtual ~CInterfaceTrack();
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
void update (double currentTime);
bool isDynamic () { return _Dynamic; }
void eval(); // Evaluate dynamic keys
private:
enum ETrackType
{
Track_Linear,
Track_TCB,
Track_Bezier
};
struct SDynKey
{
std::string Time;
std::string Value;
std::string InTan;
std::string OutTan;
std::string Step;
std::string Tension;
std::string Continuity;
std::string Bias;
std::string EaseTo;
std::string EaseFrom;
};
bool _Dynamic;
std::vector<SDynKey> _DynKeys;
ETrackType _Type;
NL3D::UTrackKeyframer *_TrackKeyFramer;
std::vector<CInterfaceLink::CTargetInfo> _Targets;
};
/**
* class managing an animation of the interface
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2003
*/
class CInterfaceAnim
{
public:
CInterfaceAnim();
virtual ~CInterfaceAnim();
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
void update();
void start();
void stop();
bool isFinished() { return _Finished; }
bool isDisableButtons() { return _DisableButtons; }
protected:
CInterfaceGroup *_Parent;
// Parsed properties
double _Duration;
bool _DisableButtons;
std::string _AHOnFinish;
std::string _AHOnFinishParams;
std::string _Id;
std::vector<CInterfaceTrack*> _Tracks;
// Current anim
double _CurrentTime;
bool _Finished;
bool _AnimHasToBeStopped;
};
}
#endif // NL_INTERFACE_ANIM_H
/* End of interface_anim.h */

@ -0,0 +1,68 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef INTERFACE_COMMON_H
#define INTERFACE_COMMON_H
enum WindowsPriority
{
WIN_PRIORITY_WORLD_SPACE = 0,
WIN_PRIORITY_LOWEST = 1,
WIN_PRIORITY_LOW = 2,
WIN_PRIORITY_NORMAL = 3,
WIN_PRIORITY_HIGH = 4,
WIN_PRIORITY_HIGHEST = 5,
WIN_PRIORITY_MAX = 8
};
enum THotSpot
{
Hotspot_BL = 36, // 100100,
Hotspot_BM = 34, // 100010,
Hotspot_BR = 33, // 100001,
Hotspot_ML = 20, // 010100,
Hotspot_MM = 18, // 010010
Hotspot_MR = 17, // 010001
Hotspot_TL = 12, // 001100
Hotspot_TM = 10, // 001010
Hotspot_TR = 9, // 001001
Hotspot_xR = 1, // 000001
Hotspot_xM = 2, // 000010
Hotspot_xL = 4, // 000100
Hotspot_Bx = 32, // 100000
Hotspot_Mx = 16, // 010000
Hotspot_Tx = 8, // 001000
Hotspot_TTAuto = 0, // Special For Tooltip PosRef. Auto mode. see CCtrlBase and tooltip info
};
#define DECLARE_UI_CLASS(_class_) \
virtual std::string getClassName() {return #_class_;} \
static NLMISC::IClassable *creator() {return new _class_(CViewBase::TCtorParam());}
#define REGISTER_UI_CLASS(_class_) \
class CRegisterUIClassHelper_##_class_ \
{ \
public: \
CRegisterUIClassHelper_##_class_() \
{ \
NLMISC::CClassRegistry::init(); \
NLMISC::CClassRegistry::registerClass(#_class_, _class_::creator, typeid(_class_).name()); \
} \
} RegisterUIClassHelper_##_class_;
#endif

@ -0,0 +1,637 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_INTERFACE_ELEMENT_H
#define NL_INTERFACE_ELEMENT_H
#include "nel/misc/types_nl.h"
#include "nel/misc/string_mapper.h"
#include "nel/misc/smart_ptr.h"
#include "nel/misc/vector.h"
#include "nel/gui/interface_property.h"
#include "nel/gui/reflect.h"
#include "nel/gui/interface_common.h"
namespace NLGUI
{
class CGroupList;
class CInterfaceLink;
class CInterfaceElement;
class CInterfaceGroup;
class CViewBase;
class CCtrlBase;
class IActionHandler;
class CGroupParagraph;
/**
* A visitor to walk a tree of interface elements and apply a teartment on them.
*
* For each vsited element, visitElement() is called
* If the element is a control, then visitCtrl() is called, and then visitElement()
* If the element is a view, then visitView() is called, and then visitElement()
* If the element is a group, then visitGoup() is called, and then visitElement()
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2003
*/
class CInterfaceElementVisitor
{
public:
virtual void visit(CInterfaceElement * /* elem */) {}
virtual void visitGroup(CInterfaceGroup * /* group */) {}
virtual void visitView(CViewBase * /* view */) {}
virtual void visitCtrl(CCtrlBase * /* ctrl */) {}
};
/**
* class describing a localisable interface element, i.e. : an element with coordinates
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CInterfaceElement : public CReflectableRefPtrTarget, public NLMISC::IStreamable
{
public:
enum EStrech
{
none=0,
width=1,
height=2
};
/// Constructor
CInterfaceElement()
{
_Parent = NULL;
_XReal = _YReal = _WReal = _HReal = 0;
_X = _Y = _W = _H = 0;
//_Snap = 1;
_PosRef = Hotspot_BL;
_ParentPosRef = Hotspot_BL;
_ParentPos = NULL;
_SizeRef = 0;
_SizeDivW = 10;
_SizeDivH = 10;
_ParentSize = NULL;
_Links = NULL;
_Active= true;
// default to 3 pass
_InvalidCoords= 3;
_ModulateGlobalColor= true;
_RenderLayer= 0;
_AvoidResizeParent= false;
editorSelected = false;
serializable = true;
}
// dtor
virtual ~CInterfaceElement();
/** Cloning
* Cloning is actually performed using a serial / unserial in a memory stream
* NB Nico : if too slow, should use a CFastStream version instead, that is designedto work in memory only
*/
virtual CInterfaceElement *clone();
// help to serialize an action handler
static void serialAH(NLMISC::IStream &f, IActionHandler *&ah);
static std::string stripId( const std::string &fullId );
virtual std::string getProperty( const std::string &name ) const;
virtual void setProperty( const std::string &name, const std::string &value );
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
/// Parse the element and initalize it
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
/// Debug info on memory
virtual uint32 getMemory () { return (uint32)(sizeof(*this)+_Id.size()); }
/// helper: display a parse error with the id of the lement
void parseError (CInterfaceGroup *parentGroup, const char *reason = NULL);
/// Accessors : GET
const std::string& getId() const { return _Id; }
std::string getShortId() const;
std::string getIdByValue() const { return _Id; }
CInterfaceGroup* getParent() const { return _Parent; }
CInterfaceElement* getParentPos() const { return _ParentPos; }
CInterfaceElement* getParentSize() const { return _ParentSize; }
/// Get the master group of this element (recurs call.
CInterfaceElement* getMasterGroup() const;
// get a possible group container
CInterfaceGroup* getParentContainer();
bool getActive() const { return _Active; }
sint32 getX() const { return _X; }
sint32 getY() const { return _Y; }
sint32 getW() const { return (_Active?_W:0); }
sint32 getW(bool bTestActive) const { return (bTestActive?(_Active?_W:0):_W); }
sint32 getH() const { return (_Active?_H:0); }
sint32 getH(bool bTestActive) const { return (bTestActive?(_Active?_H:0):_H); }
/**
* Get the max width used by the window.
*
* The view must return the largest width its content can take if it will be resized at maximum.
* Typical use : for a CTextView multiline, it returns the size of the whole string.
*
* This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm.
*/
virtual sint32 getMaxUsedW() const { return INT_MAX; };
/**
* Get the min width used by the window.
*
* The view must return the smallest width its content can take if it will be resized at minimum.
* Typical use : for a CTextView multiline without word clipping, it returns the size of the largest word.
*
* This method is used by the container CCGroupTable that need to know this information about its children in its resizing algorithm.
*/
virtual sint32 getMinUsedW() const { return 0; };
//bool isSnapped() const { return (_Snap>1); }
//sint32 getSnapping() const { return _Snap; }
sint32 getXReal() const { return _XReal; }
sint32 getYReal() const { return _YReal; }
sint32 getWReal() const { return (_Active?_WReal:0); }
sint32 getHReal() const { return (_Active?_HReal:0); }
THotSpot getPosRef () const { return _PosRef; }
THotSpot getParentPosRef () const { return _ParentPosRef; }
sint32 getSizeRef() const { return _SizeRef; } // none == 0, w == 1, h == 2, wh == 3
void setSizeRef(sint32 value) { _SizeRef = value; }
/// Accessors : SET
void setId (const std::string &newID) { _Id = newID; }
inline void setName(const std::string &name) { _Name = name; }
inline const std::string& getName() { return _Name; }
virtual void setIdRecurse(const std::string &newID);
void setParent (CInterfaceGroup *pIG) { _Parent = pIG; }
void setParentPos (CInterfaceElement *pIG) { _ParentPos = pIG; }
void setParentSize (CInterfaceElement *pIG) { _ParentSize = pIG; }
virtual void setActive (bool state);
void setX (sint32 x) { _X = x; }
void setXAndInvalidateCoords (sint32 x) { _X = x; invalidateCoords(); }
void setY (sint32 y) { _Y = y; }
void setYAndInvalidateCoords (sint32 y) { _Y = y; invalidateCoords(); }
void setW (sint32 w);
void setWAndInvalidateCoords (sint32 w) { setW(w); invalidateCoords(); }
void setH (sint32 h);
void setHAndInvalidateCoords (sint32 h) { setH(h); invalidateCoords(); }
void setPosRef (THotSpot hs) { _PosRef = hs; }
void setParentPosRef (THotSpot hs) { _ParentPosRef = hs; }
// Get the coordinate of a corner on screen
void getCorner(sint32 &px, sint32 &py, THotSpot hotSpot);
/** Test if the given coordinates are inside this element
*/
bool isIn(sint x, sint y) const;
/** Test if the given box intersect the element
*/
bool isIn(sint x, sint y, uint width, uint height) const;
/** Test if another interface element intersect this one
*/
bool isIn(const CInterfaceElement &other) const;
/**
* get the window containing the element
* \return NULL if the element is not on the window, otherwise returns a pointer to the window
*/
CInterfaceGroup* getRootWindow();
/** get the element Depth, ie the number of parent he has (0 if _Parent==NULL)
* \warning slow test. don't take into account CCtrlBase::getDeltaDepth() (since method not virtual)
*/
uint getParentDepth() const;
/**
* true if the element and all its parents are active (recurs up to the root window)
*/
bool isActiveThroughParents() const;
/**
* move the element (add dx and dy to its coords)
* \param dx : value added to _X
* \param dy : value added to _Y
*/
virtual void move (sint32 dx, sint32 dy);
//void resizeBR (sint32 sizex, sint32 sizey);
//void stopResizeBR();
//void startResizeBR();
// Some tools
void relativeSInt64Read (CInterfaceProperty &rIP, const std::string &prop, const char *val,
const std::string &defVal);
void relativeSInt32Read (CInterfaceProperty &rIP, const std::string &prop, const char *val,
const std::string &defVal);
void relativeBoolRead (CInterfaceProperty &rIP, const std::string &prop, const char *val,
const std::string &defVal);
void relativeRGBARead (CInterfaceProperty &rIP, const std::string &prop, const char *val,
const std::string &defVal);
// Parse tools
static std::string HotSpotToString( THotSpot spot );
static std::string HotSpotCoupleToString( THotSpot parentPosRef, THotSpot posRef );
static THotSpot convertHotSpot (const char *ptr); //
static void convertHotSpotCouple (const char *ptr, THotSpot &parentPosRef, THotSpot &posRef);
static NLMISC::CRGBA convertColor (const char *ptr);
static bool convertBool (const char *ptr);
static NLMISC::CVector convertVector (const char *ptr);
/** Convert a value that is in the form like width="50" or width="10%"
* if the value is absolute like '50' then 'pixels' is filled, else
* the ratio is remapped to the [0, 1] range and is copied in 'ratio'
*/
static void convertPixelsOrRatio(const char *ptr, sint32 &pixels, float &ratio);
// add an interface link to that element (kept in a smart ptr)
void addLink(CInterfaceLink *link);
// remove a link from that element; There's one less reference on the link (which is referenced by a smart ptr)
void removeLink(CInterfaceLink *link);
/** Update all links for this instance and its sons.
* Derivers should override this to update their sons.
*/
virtual void updateAllLinks();
/** This allow to force opening an element. By default it just activate the element.
* It allow to have different behaviour on more complex containers
*/
virtual void forceOpen() { setActive(true); }
virtual void enableBlink(uint /* numBlinks */ = 0) {}
virtual void disableBlink() {}
virtual bool getBlink() const { return false; }
// Options for views to be modulated by interface global color or not. Parsed with "global_color". Default: true
void setModulateGlobalColor(bool state) {_ModulateGlobalColor= state;}
bool getModulateGlobalColor() const {return _ModulateGlobalColor;}
void dummySet(sint32 value);
void dummySet(const std::string &value);
// lua methods
int luaUpdateCoords(CLuaState &ls);
int luaInvalidateCoords(CLuaState &ls);
int luaInvalidateContent(CLuaState &ls);
int luaCenter(CLuaState &ls);
int luaSetPosRef(CLuaState &ls);
int luaSetParentPos(CLuaState &ls);
// set sizeref as a string, like "wh", "wh5" ....
void setSizeRef(const std::string &sizeref);
std::string getSizeRefAsString() const;
std::string getSizeRefAsString( const sint32 &sizeRef, const sint32 &sizeDivW, const sint32 &sizeDivH ) const;
// export some properties
REFLECT_EXPORT_START(CInterfaceElement, CReflectable)
REFLECT_BOOL ("active", getActive, setActive);
REFLECT_BOOL ("global_color", getModulateGlobalColor, setModulateGlobalColor);
REFLECT_SINT32 ("x", getX, setXAndInvalidateCoords);
REFLECT_SINT32 ("y", getY, setYAndInvalidateCoords);
REFLECT_SINT32 ("w", getW, setWAndInvalidateCoords);
REFLECT_SINT32 ("h", getH, setHAndInvalidateCoords);
REFLECT_SINT32 ("x_real", getXReal, dummySet);
REFLECT_SINT32 ("y_real", getYReal, dummySet);
REFLECT_SINT32 ("w_real", getWReal, dummySet);
REFLECT_SINT32 ("h_real", getHReal, dummySet);
REFLECT_STRING ("id", getIdByValue, dummySet);
REFLECT_STRING ("sizeref", getSizeRefAsString, setSizeRef);
REFLECT_LUA_METHOD("updateCoords", luaUpdateCoords);
REFLECT_LUA_METHOD("invalidateCoords", luaInvalidateCoords);
REFLECT_LUA_METHOD("invalidateContent", luaInvalidateContent);
REFLECT_LUA_METHOD("center", luaCenter);
REFLECT_LUA_METHOD("setPosRef", luaSetPosRef);
REFLECT_LUA_METHOD("setParentPos", luaSetParentPos);
REFLECT_EXPORT_END
/* invalidate coords. set numPass==1 if you are SURE that only XReal/YReal need to be updated
* Default 3 is needed for:
* 1: update _W/_H and _WReal/_HReal according to Sons
* 2: update XReal/YReal (eg: according to Scroll offset)
*/
void invalidateCoords(uint8 numPass= 2);
uint8 getInvalidCoords() const {return _InvalidCoords;}
/* Invalidates the content of the window. This method invalidate the content of the window (for CViewText or CGroupTable).
* It invalidates the content of the parent too.
*/
void invalidateContent();
/* This call back is called when the content or the content of a child is been invalidated.
*/
virtual void onInvalidateContent() {}
// called by interfaceManager for master window only
void resetInvalidCoords();
/// Update the elements coords convert x,y,w,h (parentpos coord) to xreal,yreal,wreal,hreal (BL coord)
virtual void updateCoords();
/// Called each frame before draw to possibly invalidateCoords().
virtual void checkCoords();
/// Test if this element is son of the given element
bool isSonOf(const CInterfaceElement *other) const;
/// Called after first frame initialised
virtual void launch () {}
void setRenderLayer(sint8 rl) {_RenderLayer= rl;}
sint8 getRenderLayer() const { return _RenderLayer; }
void copyOptionFrom(const CInterfaceElement &other);
// center the element in middle of screen
void center();
// for debug only: draw wired quad to see where groups and hotspots are
enum TRenderWired
{
RenderView,
RenderCtrl,
RenderGroup
};
// if uiFilter is not empty, draw a quad only if the element id match
virtual void renderWiredQuads(TRenderWired type, const std::string &uiFilter);
void drawHotSpot(THotSpot hs, NLMISC::CRGBA col);
// Returns 'true' if that element can be downcasted to a view
virtual bool isView() const { return false; }
// Returns 'true' if that element can be downcasted to a ctrl
virtual bool isCtrl() const { return false; }
// Returns 'true' if that element can be downcasted to an interface group
virtual bool isGroup() const { return false; }
/** This is called before the config loading begins. This is the place to restore default state for config info.
*/
virtual void onLoadConfig() {}
/** Tells whether that element wants to save info in a config stream. If this returns true, then serialConfig
* is called.
*/
virtual bool wantSerialConfig() const { return false; }
// Serial config info about that element. This is called only if wantSerialConfig() returns true
virtual void serialConfig(NLMISC::IStream &f);
// visit the node of the ui tree
virtual void visit(CInterfaceElementVisitor *visitor);
/** When user is quitting the interface, this is called. Then the interface config is saved
* This is where the element get the opportunity to do some cleanup.
*/
virtual void onQuit() {}
/// Whent an element is added to a CInterfaceGroup via addCtrl, addGroup or addView, this is called after the add.
virtual void onAddToGroup() {}
/** typically used only in conjunction with CGroupInScene. Such groups move every Frames. so
* this function is called on each children elements to move the XReal/Yreal only (with a delta)
*/
virtual void onFrameUpdateWindowPos(sint dx, sint dy);
/// if true, InterfaceGroup child resize won't take this element into account
bool avoidResizeParent() const {return _AvoidResizeParent;}
void setAvoidResizeParent(bool state) {_AvoidResizeParent= state;}
virtual std::string getClassName()
{
nlassert(0); // forgot to implement serial & to register the class ?
return "";
}
bool isInGroup( CInterfaceGroup *group );
static void setEditorMode( bool b ){ editorMode = b; }
void setEditorSelected( bool b ){ editorSelected = b; }
bool isEditorSelected() const{ return editorSelected; }
void setPosParent( const std::string &id );
void setSizeParent( const std::string &id );
void setSerializable( bool b ){ serializable = b; }
bool IsSerializable() const{ return serializable; }
protected:
bool editorSelected;
static bool editorMode;
///the parent
CInterfaceGroup* _Parent;
///the id of the element
std::string _Id;
std::string _Name;
///is the element active?
bool _Active;
// if 0, don't need updateCoords(), else tell the number of pass needed
uint8 _InvalidCoords;
// Real display coords
sint32 _XReal, _YReal, _WReal, _HReal;
// Relative coords
sint32 _X;
sint32 _Y;
sint32 _W;
sint32 _H;
//sint32 _Snap;
// position references e.g. : _PosRef=BL, _ParentPosref=MM : the bottom left corner of the element
// will be placed on the center (middle middle) of the parent window
THotSpot _PosRef;
THotSpot _ParentPosRef;
NLMISC::CRefPtr<CInterfaceElement> _ParentPos; // RefPtr in case of group destroyed in a parent group with posref on it
sint32 _SizeRef; // none == 0, w == 1, h == 2, wh == 3
sint32 _SizeDivW, _SizeDivH;
NLMISC::CRefPtr<CInterfaceElement> _ParentSize; // RefPtr in case of group destroyed in a parent group with posref on it
// Friend Class
friend class CGroupList;
friend class CGroupParagraph;
// True if must modulate the global color with the view
bool _ModulateGlobalColor;
// Index of layer to render it.
sint8 _RenderLayer;
// Used for CInterfaceGroup ChildResize feature
bool _AvoidResizeParent;
virtual void serial(NLMISC::IStream &f);
void parseSizeRef(const char *sizeRef);
void parseSizeRef(const char *sizeRefStr, sint32 &sizeref, sint32 &sizeDivW, sint32 &sizeDivH);
private:
//void snapSize();
bool serializable;
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
typedef std::vector<TLinkSmartPtr> TLinkVect;
TLinkVect *_Links; // links, or NULL if no link
};
/**
* class to compress string usage in the interface
* \author Matthieu 'Trap' Besson
* \author Nevrax France
* \date October 2003
*/
class CStringShared
{
public:
CStringShared()
{
_Id = NLMISC::CStringMapper::emptyId();
}
const CStringShared& operator=(const std::string &str)
{
_Id = _UIStringMapper->localMap(str);
return *this;
}
const CStringShared& operator=(const CStringShared &str)
{
_Id = str._Id;
return *this;
}
const std::string &toString() const
{
return _UIStringMapper->localUnmap(_Id);
}
operator const std::string &() const
{
return _UIStringMapper->localUnmap(_Id);
}
bool empty() const
{
return _Id == NLMISC::CStringMapper::emptyId();
}
static CStringShared emptyString()
{
return CStringShared();
}
NLMISC::TStringId getStringId() const { return _Id; }
void serial(NLMISC::IStream &f)
{
std::string str;
if (f.isReading())
{
f.serial(str);
*this = str;
}
else
{
str = this->toString();
f.serial(str);
}
}
static void createStringMapper();
static void deleteStringMapper();
private:
NLMISC::TStringId _Id;
static NLMISC::CStringMapper *_UIStringMapper;
};
inline bool operator==(const CStringShared &lhs, const CStringShared &rhs) { return lhs.getStringId() == rhs.getStringId(); }
inline bool operator!=(const CStringShared &lhs, const CStringShared &rhs) { return !(lhs == rhs); }
}
using namespace NLGUI;
#endif // NL_INTERFACE_ELEMENT_H
/* End of interface_element.h */

@ -0,0 +1,239 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_INTERFACE_EXPR_H
#define CL_INTERFACE_EXPR_H
#include "nel/misc/ucstring.h"
#include "nel/misc/rgba.h"
namespace NLMISC{
class ICDBNode;
class CCDBNodeLeaf;
class CCDBNodeBranch;
}
namespace NLGUI
{
struct CInterfaceExprUserType;
class CInterfaceExprNode;
/** a value that can be returned by a CInterfaceExpr instance
* It supports basic type;
* It can be extended by user defined types
*/
class CInterfaceExprValue
{
public:
enum TType { Boolean = 0, Integer, Double, String, RGBA, UserType, NoType };
public:
// default ctor
CInterfaceExprValue() : _Type(NoType) {}
// copy ctor
CInterfaceExprValue(const CInterfaceExprValue &other);
// assignment operator
CInterfaceExprValue &operator = (const CInterfaceExprValue &other);
// dtor
~CInterfaceExprValue() { clean(); }
TType getType() const { return _Type; }
// get. Should be used only if the type is valid
bool getBool() const;
sint64 getInteger() const;
double getDouble() const;
std::string getString() const;
NLMISC::CRGBA getRGBA() const;
const ucstring &getUCString() const;
CInterfaceExprUserType *getUserType() const;
// set
void setBool(bool value) { clean(); _Type = Boolean; _BoolValue = value; }
void setInteger(sint64 value) { clean(); _Type = Integer; _IntegerValue = value; }
void setDouble(double value) { clean(); _Type = Double; _DoubleValue = value; }
void setString(const std::string &value) { clean(); _Type = String; _StringValue = value; }
void setUCString(const ucstring &value) { clean(); _Type = String; _StringValue = value; }
void setRGBA(NLMISC::CRGBA value) { clean(); _Type = RGBA; _RGBAValue = (uint32)(value.R+(value.G<<8)+(value.B<<16)+(value.A<<24)); }
void setUserType(CInterfaceExprUserType *value);
// reset this object to initial state (no type)
void clean();
// conversions. They return true if success
bool toBool();
bool toInteger();
bool toDouble();
bool toString();
bool toType(TType type);
bool toRGBA();
// test if the value if a bool, double, or integer
bool isNumerical() const;
/** evaluate a from a string
* \param expr : where to start the evaluation
* \return the position following the token, or NULL if the parsing failed
*/
const char *initFromString(const char *expr);
/////////////////////////////////////////////////////////////////////////////////////////////
private:
TType _Type;
union
{
bool _BoolValue;
sint64 _IntegerValue;
double _DoubleValue;
CInterfaceExprUserType *_UserTypeValue;
uint32 _RGBAValue;
};
ucstring _StringValue; // well, can't fit in union, unless we do some horrible hack..
private:
const char *evalBoolean(const char *expr);
const char *evalNumber(const char *expr);
const char *evalString(const char *expr);
};
/**
* Base class for user defined types that are use by the 'CInterfaceExprValue' class
* Derivers should include the 'clone' method
*
* CInterfaceExprValue instances have ownership of this object.
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2003
*/
struct CInterfaceExprUserType
{
// cloning method
virtual CInterfaceExprUserType *clone() const = 0;
// dtor
virtual ~CInterfaceExprUserType() {}
};
/** Evaluate expressions used in interface.
* It can retrieve values from the database.
* It can also build a list of database values it depends of.
*
* An expression can be :
*
* - a string : 'toto', 'abcd', 'a\nbcd', 'a\\t', the escape sequences are the one of C
* - a integer 1, 2, 3
* - a double 1.1, 2.2
* - a database entry : @ui:interface:toto:truc. If the address is a leaf, it returns the leaf value and put an observer on it. If not a leaf, it returns 0, but put an observer on it.
* - a database indirection @db:value[db:index] is replaced by @db:value0 if db:index == 0 for example
* - a user function call : fct(expr0, epxr1, ...).
*
* NB : The lua language has been integrated since then (2005), and should be more suited
* for most of the tasks.
*
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CInterfaceExpr
{
public:
// list of argument for a function
typedef std::vector<CInterfaceExprValue> TArgList;
/** prototype of a user callable function
* It should return true if the result is meaningful. If not, the rest of the evaluation is stopped
*/
typedef bool (* TUserFct) (TArgList &args, CInterfaceExprValue &result);
public:
// release memory
static void release();
/** This try to eval the provided expression.
* - This returns a result
* - This eventually fill a vector with a set of database entries it has dependencies on
* \param expr The expression to evaluate
* \param result The result value
* \param nodes If not NULL, will be filled with the database nodes this expression depends on
* Node will only be inserted once, so we end up with a set of node (not ordered)
* \param noFctCalls when set to true, the terminal function calls will not be made, so the evaluation is only used to see which database entries the expression depends on.
*/
static bool eval(const std::string &expr, CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> *nodes = NULL, bool noFctCalls = false);
/** Build a tree from the given expression so that it can be evaluated quickly.
* This is useful for a fixed expression that must be evaluated often
*/
static CInterfaceExprNode *buildExprTree(const std::string &expr);
/** Register a function that can have several arguments
* // NB : this is case sensitive
*/
static void registerUserFct(const char *name, TUserFct fct);
// Simple evaluations
static bool evalAsInt(const std::string &expr, sint64 &dest);
static bool evalAsDouble(const std::string &expr, double &dest);
static bool evalAsBool(const std::string &expr, bool &dest);
static bool evalAsString(const std::string &expr, std::string &dest);
/////////////////////////////////////////////////////////////////////////////////////////////
private:
// map of user functions
typedef std::map<std::string, TUserFct> TUserFctMap;
private:
static TUserFctMap *_UserFct;
private:
/** eval the value of a single expression
* \return position to the next valid character
*/
static const char *evalExpr(const char *expr, CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> *nodes, bool noFctCalls);
static const char *evalFct(const char *expr,CInterfaceExprValue &result,std::vector<NLMISC::ICDBNode *> *nodes, bool noFctCalls);
static const char *evalDBEntry(const char *expr,CInterfaceExprValue &result,std::vector<NLMISC::ICDBNode *> *nodes);
public:
static const char *unpackDBentry(const char *expr, std::vector<NLMISC::ICDBNode *> *nodes, std::string &dest, bool *hasIndirections = NULL);
/** Build tree of a single expression
* \return position to the next valid character
*/
private:
static const char *buildExprTree(const char *expr, CInterfaceExprNode *&result);
static const char *buildFctNode(const char *expr, CInterfaceExprNode *&result);
static const char *buildDBEntryNode(const char *expr,CInterfaceExprNode *&result);
};
// helper macro to register user functions at startup
#define REGISTER_INTERFACE_USER_FCT(name, fct) \
const struct __InterUserFctRegister__##fct\
{\
__InterUserFctRegister__##fct() { CInterfaceExpr::registerUserFct(name, fct); }\
} __InterUserFctRegisterInstance__##fct;
// helper macro to declare a user function
// the code must follow
// arguments are available in 'args', result should be put in 'result'
#define DECLARE_INTERFACE_USER_FCT(name) \
bool name(CInterfaceExpr::TArgList &args, CInterfaceExprValue &result)
// helper macro to declare a C constant mirroring
#define DECLARE_INTERFACE_CONSTANT(_name, _cconst) \
static DECLARE_INTERFACE_USER_FCT(_name) \
{ \
result.setInteger(_cconst); \
return true; \
} \
REGISTER_INTERFACE_USER_FCT(#_name, _name)
}
#endif

@ -0,0 +1,118 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_INTERFACE_EXPR_NODE_H
#define CL_INTERFACE_EXPR_NODE_H
#include "interface_expr.h"
namespace NLGUI
{
/** Base node of an interface expression parse tree
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2003
*/
class CInterfaceExprNode
{
public:
virtual ~CInterfaceExprNode() {}
// eval result of expression, and eventually get the nodes the epression depends on
virtual void eval(CInterfaceExprValue &result) = 0;
// The same, but get db nodes the expression depends on (appended to vector)
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes) = 0;
// Get dependencies of the node (appended to vector)
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes) = 0;
};
// *******************************************************************************************************
/** A constant value already parsed by interface (in a interface expr parse tree)
*/
class CInterfaceExprNodeValue : public CInterfaceExprNode
{
public:
CInterfaceExprValue Value;
public:
virtual void eval(CInterfaceExprValue &result);
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
};
// *******************************************************************************************************
/** A fct call (in a interface expr parse tree)
*/
class CInterfaceExprNodeValueFnCall : public CInterfaceExprNode
{
public:
CInterfaceExpr::TUserFct Func;
// list of parameters
std::vector<CInterfaceExprNode *> Params;
public:
virtual void eval(CInterfaceExprValue &result);
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
virtual ~CInterfaceExprNodeValueFnCall();
};
// *******************************************************************************************************
/** A db leaf read (in a interface expr parse tree)
*/
class CInterfaceExprNodeDBLeaf : public CInterfaceExprNode
{
public:
class NLMISC::CCDBNodeLeaf *Leaf;
public:
virtual void eval(CInterfaceExprValue &result);
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
};
// *******************************************************************************************************
/** A db branch read (in a interface expr parse tree)
*/
class CInterfaceExprNodeDBBranch : public CInterfaceExprNode
{
public:
class NLMISC::CCDBNodeBranch *Branch;
public:
virtual void eval(CInterfaceExprValue &result);
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
};
// *******************************************************************************************************
/** A dependant db read (in a interface expr parse tree)
* This is rarely used so no real optim there..
*/
class CInterfaceExprNodeDependantDBRead : public CInterfaceExprNode
{
public:
std::string Expr;
public:
virtual void eval(CInterfaceExprValue &result);
virtual void evalWithDepends(CInterfaceExprValue &result, std::vector<NLMISC::ICDBNode *> &nodes);
virtual void getDepends(std::vector<NLMISC::ICDBNode *> &nodes);
};
}
#endif

@ -0,0 +1,422 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_INTERFACE_GROUP_H
#define NL_INTERFACE_GROUP_H
#include "nel/gui/ctrl_base.h"
#include "nel/gui/action_handler.h"
namespace NLGUI
{
class CInterfaceGroup : public CCtrlBase
{
public:
DECLARE_UI_CLASS(CInterfaceGroup)
/// Constructor
CInterfaceGroup(const TCtorParam &param);
/// Destructor
virtual ~CInterfaceGroup();
virtual void setIdRecurse(const std::string &id);
/// Coming from CInterfaceElement
virtual bool parse(xmlNodePtr cur, CInterfaceGroup * parentGroup);
std::string getProperty( const std::string &name ) const;
void setProperty( const std::string &name, const std::string &value );
xmlNodePtr serialize( xmlNodePtr parentNode, const char *type ) const;
xmlNodePtr serializeGroup( xmlNodePtr parentNode, const char *type ) const;
xmlNodePtr serializeSubGroups( xmlNodePtr parentNode ) const;
xmlNodePtr serializeControls( xmlNodePtr parentNode ) const;
xmlNodePtr serializeViews( xmlNodePtr parentNode ) const;
virtual xmlNodePtr serializeTreeData( xmlNodePtr parentNode ) const;
bool serializeLinks( xmlNodePtr parentNode ) const;
virtual uint32 getMemory ();
virtual CInterfaceElement* getElement (const std::string &id);
CInterfaceElement* findFromShortId(const std::string &id);
/// Dynamic creation
virtual void addView (CViewBase *child , sint eltOrder = -1);
virtual void addCtrl (CCtrlBase *child, sint eltOrder = -1);
virtual void addGroup (CInterfaceGroup *child, sint eltOrder = -1);
CViewBase* getView (const std::string &id);
CCtrlBase* getCtrl (const std::string &id);
CInterfaceGroup* getGroup(const std::string &id) const;
// Delete know type by ptr (return true if found and removed)
virtual bool delView (CViewBase *child, bool dontDelete = false);
virtual bool delCtrl (CCtrlBase *child, bool dontDelete = false);
virtual bool delGroup (CInterfaceGroup * child, bool dontDelete = false);
// Delete know type by name (return true if found and removed)
virtual bool delView (const std::string &id, bool dontDelete = false);
virtual bool delCtrl (const std::string &id, bool dontDelete = false);
virtual bool delGroup (const std::string &id, bool dontDelete = false);
// Delete unknow type by name or ptr. NB: additionaly, if it's a group, unmakeWindow() is called as necessary
bool delElement (const std::string &id, bool noWarning=false);
bool delElement (CInterfaceElement *pIE, bool noWarning=false);
uint getNumGroup() const { return (uint)_ChildrenGroups.size(); }
CInterfaceGroup *getGroup(uint index) const;
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
/// Coming from CCtrlBase
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
void executeControl (const std::string &sControlName);
const std::vector<CInterfaceGroup*> & getGroups () { return _ChildrenGroups; }
const std::vector<CCtrlBase*> & getControls() { return _Controls; }
const std::vector<CViewBase*> & getViews() { return _Views; }
// test is a group is a direct child of this interface group
bool isChildGroup(const CInterfaceGroup *group) const;
virtual bool isWindowUnder (sint32 x, sint32 y); // Virtual for menu that is not square
CInterfaceGroup *getGroupUnder (sint32 x, sint32 y);
virtual bool getViewsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CViewBase*> &vVB); // Return true if x,y under the group
virtual bool getCtrlsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CCtrlBase*> &vICL);
virtual bool getGroupsUnder (sint32 x, sint32 y, sint32 clipX, sint32 clipY, sint32 clipW, sint32 clipH, std::vector<CInterfaceGroup *> &vIGL);
void absoluteToRelative (sint32 &x, sint32 &y);
/// Coming from CViewBase
virtual void draw ();
// Draw with no clip (if clip is done by parent)
virtual void drawNoClip();
/// Tool function to draw a single Element that should exist in the group (clipped by the group)
void drawElement (CViewBase *el);
/**
* update the elements coords
*/
virtual void checkCoords();
virtual void updateCoords();
/// remove all views
virtual void clearViews();
/// remove all controls
virtual void clearControls();
/// remove all groups
virtual void clearGroups();
void setParentSizeMax(CInterfaceElement *pIE) { _ParentSizeMax = pIE; }
void setMaxW (sint32 maxw) { _MaxW = maxw; }
void setMaxH (sint32 maxh) { _MaxH = maxh; }
void setOfsX (sint32 x) { _OffsetX = x; }
void setOfsY (sint32 y) { _OffsetY = y; }
bool moveSBTrackY (CInterfaceGroup *target, sint32 dy);
bool moveSBTargetY (CInterfaceGroup *target, sint32 dy);
void setResizeFromChildW(bool resize) { _ResizeFromChildW = resize; }
void setResizeFromChildH(bool resize) { _ResizeFromChildH = resize; }
// Valid only for windows InterfaceGroup.
// escapable
void setEscapable(bool b) { _Escapable= b; }
bool getEscapable() const { return _Escapable; }
void setAHOnEscape(const std::string &ah) { _AHOnEscape = CAHManager::getInstance()->getAH(ah, _AHOnEscapeParams); }
const std::string &getAHOnEscape() const { return CAHManager::getInstance()->getAHName(_AHOnEscape); }
void setAHOnEscapeParams(const std::string &ah) { _AHOnEscapeParams = ah; }
const std::string &getAHOnEscapeParams() const { return _AHOnEscapeParams; }
// enterable
void setAHOnEnter(const std::string &ah) { _AHOnEnter = CAHManager::getInstance()->getAH(ah, _AHOnEnterParams); }
const std::string &getAHOnEnter() const { return CAHManager::getInstance()->getAHName(_AHOnEnter); }
void setAHOnEnterParams(const std::string &ah) { _AHOnEnterParams = ah; }
const std::string &getAHOnEnterParams() const { return _AHOnEnterParams; }
uint8 getPriority() const { return _Priority; }
void setPriority(uint8 nprio);
sint32 getMaxW () const { return _MaxW; }
sint32 getMaxH () const { return _MaxH; }
sint32 getMaxWReal () const { return _Active ? _MaxWReal : 0; }
sint32 getMaxHReal () const { return _Active ? _MaxHReal : 0; }
sint32 getOfsX () const { return _OffsetX; }
sint32 getOfsY () const { return _OffsetY; }
bool getResizeFromChildW() const { return _ResizeFromChildW; }
bool getResizeFromChildH() const { return _ResizeFromChildH; }
sint32 getResizeFromChildWMargin() const { return _ResizeFromChildWMargin; }
sint32 getResizeFromChildHMargin() const { return _ResizeFromChildHMargin; }
void setResizeFromChildWMargin(sint32 margin) { _ResizeFromChildWMargin = margin; }
void setResizeFromChildHMargin(sint32 margin) { _ResizeFromChildHMargin = margin; }
bool getOverlappable() const { return _Overlappable; }
virtual void setActive (bool state);
// eval dimension of children bbox
void evalChildrenBBox(bool resizeFromChildW, bool resizeFromChildH, sint &width, sint &height) const;
virtual void launch ();
// right & left clicks handler
void setLeftClickHandler(const std::string &handler);
void setRightClickHandler(const std::string &handler);
void setLeftClickHandlerParams(const std::string &params) { _AHOnLeftClickParams = params; }
void setRightClickHandlerParams(const std::string &params) { _AHOnRightClickParams = params; }
void setOnActiveHandler(const std::string &h) { _AHOnActive = CAHManager::getInstance()->getAH(h,_AHOnActiveParams); }
void setOnActiveParams(const std::string &p) { _AHOnActiveParams = p; }
void setOnDeactiveHandler(const std::string &h) { _AHOnDeactive = CAHManager::getInstance()->getAH(h,_AHOnDeactiveParams); }
void setOnDeactiveParams(const std::string &p) { _AHOnDeactiveParams = p; }
const std::string &getLeftClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnLeftClick); }
const std::string &getLeftClickHandlerParams() const { return _AHOnLeftClickParams; }
const std::string &getRightClickHandler() const { return CAHManager::getInstance()->getAHName(_AHOnRightClick); }
const std::string &getRightClickHandlerParams() const { return _AHOnRightClickParams; }
const std::string &getOnActiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnActive); }
const std::string &getOnActiveParams() const { return _AHOnActiveParams; }
const std::string &getOnDeactiveHandler() const { return CAHManager::getInstance()->getAHName(_AHOnDeactive); }
const std::string &getOnDeactiveParams() const { return _AHOnDeactiveParams; }
// find a sub view/ctrl/group in this group from its id
int luaFind(CLuaState &ls);
int luaGetEnclosingContainer(CLuaState &ls);
int luaDeleteLUAEnvTable(CLuaState &ls);
int luaAddGroup(CLuaState &ls);
int luaDelGroup(CLuaState &ls);
int luaGetNumGroups(CLuaState &ls);
int luaGetGroup(CLuaState &ls);
void setMaxSizeRef(const std::string &maxSizeRef);
std::string getMaxSizeRefAsString() const;
REFLECT_EXPORT_START(CInterfaceGroup, CCtrlBase)
REFLECT_LUA_METHOD("find", luaFind);
REFLECT_LUA_METHOD("deleteLUAEnvTable", luaDeleteLUAEnvTable);
REFLECT_LUA_METHOD("getEnclosingContainer", luaGetEnclosingContainer);
REFLECT_LUA_METHOD("addGroup", luaAddGroup);
REFLECT_LUA_METHOD("delGroup", luaDelGroup);
REFLECT_LUA_METHOD("getNumGroups", luaGetNumGroups);
REFLECT_LUA_METHOD("getGroup", luaGetGroup);
REFLECT_STRING ("left_click", getLeftClickHandler, setLeftClickHandler);
REFLECT_STRING ("right_click", getRightClickHandler, setRightClickHandler);
REFLECT_STRING ("left_click_params", getLeftClickHandlerParams, setLeftClickHandlerParams);
REFLECT_STRING ("right_click_params", getRightClickHandlerParams, setRightClickHandlerParams);
REFLECT_STRING ("on_active", getOnActiveHandler, setOnActiveHandler);
REFLECT_STRING ("on_active_params", getOnActiveParams, setOnActiveParams);
REFLECT_STRING ("on_deactive", getOnDeactiveHandler, setOnDeactiveHandler);
REFLECT_STRING ("on_deactive_params", getOnDeactiveParams, setOnDeactiveParams);
REFLECT_STRING ("on_enter", getAHOnEnter, setAHOnEnter);
REFLECT_STRING ("on_enter_params", getAHOnEnterParams, setAHOnEnterParams);
REFLECT_STRING ("on_escape", getAHOnEscape, setAHOnEscape);
REFLECT_STRING ("on_escape_params", getAHOnEscapeParams, setAHOnEscapeParams);
REFLECT_SINT32 ("ofsx", getOfsX, setOfsX);
REFLECT_SINT32 ("ofsy", getOfsY, setOfsY);
REFLECT_BOOL("child_resize_w", getResizeFromChildW, setResizeFromChildW);
REFLECT_SINT32("child_resize_wmargin", getResizeFromChildWMargin, setResizeFromChildWMargin);
REFLECT_BOOL("child_resize_h", getResizeFromChildH, setResizeFromChildH);
REFLECT_SINT32("child_resize_hmargin", getResizeFromChildHMargin, setResizeFromChildHMargin);
REFLECT_SINT32 ("ofsy", getOfsY, setOfsY);
REFLECT_STRING("max_sizeref", getMaxSizeRefAsString, setMaxSizeRef);
REFLECT_SINT32 ("max_w", getMaxW, setMaxW);
REFLECT_SINT32 ("max_h", getMaxH, setMaxH);
REFLECT_SINT32 ("max_w_real", getMaxWReal, dummySet);
REFLECT_SINT32 ("max_h_real", getMaxHReal, dummySet);
REFLECT_EXPORT_END
// From CCtrlBase
virtual void updateAllLinks();
/// return true for some containers. false by default
virtual bool isMovable() const {return false;}
virtual sint32 getAlpha() const;
virtual void setAlpha (sint32 a);
/// Eval current clip coords. This is not incremental as with makeNewClip, and thus more slow. This also doesn't change the current clip window.
void getClip(sint32 &x, sint32 &y, sint32 &w, sint32 &h) const;
// quick way to know if the group is a CGroupContainer
bool isGroupContainer() const { return _IsGroupContainer; }
bool isGroupScrollText() const{ return _IsGroupScrollText; }
bool isGroupInScene() const{ return _IsGroupInScene; }
bool isGroupList() const{ return _IsGroupList; }
CInterfaceGroup* getEnclosingContainer();
sint getInsertionOrder(CViewBase *vb) const;
// for debug only
void dumpGroups();
void dumpEltsOrder();
virtual void renderWiredQuads(CInterfaceElement::TRenderWired type, const std::string &uiFilter);
virtual bool isGroup() const { return true; }
// clear all edit box in the ui
virtual void clearAllEditBox();
// restore all backuped positions for containers
virtual void restoreAllContainersBackupPosition();
virtual void dumpSize(uint depth = 0) const;
// From CInterfaceElement
virtual void visit(CInterfaceElementVisitor *visitor);
/// Visits only this group's sub-groups and then the group itself
virtual void visitGroupAndChildren( CInterfaceElementVisitor *visitor );
// Check cursor
void setUseCursor(bool use);
bool getUseCursor() const { return _UseCursor; }
// From CInterfaceElement
virtual void onFrameUpdateWindowPos(sint dx, sint dy);
// true for CGroupInScene for instance
bool isNeedFrameUpdatePos() const {return _NeedFrameUpdatePos;}
/// \name LUA specific
// @{
// Create a LUA Environement if don't exist, then push it on the LUA stack
void pushLUAEnvTable();
// Free the LUA Env Table
void deleteLUAEnvTable(bool recurse = false);
// Set the LUA script to execute at checkCoords time (empty to reset)
void setLuaScriptOnDraw(const std::string &script);
//
void executeLuaScriptOnDraw();
// Set the LUA script to execute when a list of DB change (of forms: "@DB1,@DB2" ....). The dbList is the key
void addLuaScriptOnDBChange(const std::string &dbList, const std::string &script);
// Remove the LUA script to execute when a list of DB change
void removeLuaScriptOnDBChange(const std::string &dbList);
// @}
virtual CInterfaceElement *clone();
virtual void serial(NLMISC::IStream &f);
// Return the current Depth, with no ZBias applied.
float getDepthForZSort() const { return _DepthForZSort; }
protected:
void makeNewClip (sint32 &oldClipX, sint32 &oldClipY, sint32 &oldClipW, sint32 &oldClipH);
void restoreClip (sint32 oldSciX, sint32 oldSciY, sint32 oldSciW, sint32 oldSciH);
// Compute clip contribution for current window, and a previous clipping rectangle. This doesn't change the clip window in the driver.
void computeCurrentClipContribution(sint32 prevX, sint32 prevY, sint32 prevW, sint32 prevH,
sint32 &newX, sint32 &newY, sint32 &newW, sint32 &newH) const;
void delEltOrder (CViewBase *pElt);
// update coords one time
void doUpdateCoords();
// notify children controls & groups that 'active' has been called on one of their parent
void notifyActiveCalled(const NLGUI::CEventDescriptorActiveCalledOnParent &desc);
protected:
/// children interface elements
std::vector<CInterfaceGroup*> _ChildrenGroups;
std::vector<CCtrlBase*> _Controls;
std::vector<CViewBase*> _Views;
std::vector<CViewBase*> _EltOrder;
/// Scroll properties
NLMISC::CRefPtr<CInterfaceElement> _ParentSizeMax; // RefPtr in case of group destroyed in a parent group with posref on it
sint32 _MaxW, _MaxH;
sint32 _MaxWReal, _MaxHReal;
sint32 _OffsetX, _OffsetY;
uint8 _Priority;
// Misc prop
bool _Overlappable : 1;
bool _ResizeFromChildW : 1;
bool _ResizeFromChildH : 1;
bool _Escapable : 1;
bool _UseCursor : 1;
bool _IsGroupContainer : 1; // faster than a virual call
bool _IsGroupScrollText : 1;
bool _IsGroupInScene : 1;
bool _IsGroupList : 1;
bool _NeedFrameUpdatePos : 1; // typically For CGroupInScene
sint32 _ResizeFromChildWMargin;
sint32 _ResizeFromChildHMargin;
sint32 _GroupSizeRef;
// Projected Depth with no ZBias applied
float _DepthForZSort;
// handler for activation
IActionHandler *_AHOnActive;
CStringShared _AHOnActiveParams;
IActionHandler *_AHOnDeactive;
CStringShared _AHOnDeactiveParams;
// right & left clicks
IActionHandler *_AHOnLeftClick;
CStringShared _AHOnLeftClickParams;
IActionHandler *_AHOnRightClick;
CStringShared _AHOnRightClickParams;
// enter params.
IActionHandler *_AHOnEnter;
CStringShared _AHOnEnterParams;
// escape AH
IActionHandler *_AHOnEscape;
CStringShared _AHOnEscapeParams;
private:
void addToEltOrder(CViewBase *view, sint order);
/// \name LUA specific
// @{
// Lua Env Table created. Table is in the LUA_REGISTRYINDEX, with key as this CInterfaceGroup* userdata
bool _LUAEnvTableCreated;
// The LUA script to be executed on Draw (checkCoords)
CStringShared _LUAOnDraw;
// The InterfaceLink created specialy for Lua Script to be executed at some DB change
typedef std::map<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLUAOnDbChange;
TLUAOnDbChange _LUAOnDbChange;
void removeAllLUAOnDbChange();
protected:
void parseMaxSizeRef(const char *ptr);
// @}
};
}
#endif // NL_INTERFACE_GROUP_H
/* End of interface_group.h */

@ -0,0 +1,186 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_INTERFACE_LINK_H
#define CL_INTERFACE_LINK_H
#include "nel/misc/cdb_branch.h"
#include "nel/misc/cdb_branch_observing_handler.h"
namespace NLGUI
{
class CReflectedProperty;
class CInterfaceExprValue;
class CInterfaceExprNode;
class CInterfaceElement;
class CInterfaceGroup;
/** A link in an interface.
* A link is an object that can read one or several values from the database, that can evaluate an expression
* on these database entries (simple computation, using the CInterfaceExpr class), and that can affect the result to
* an interface property that has been exported by an interface element (the export system uses reflect.h).
* The first time it is created, it places observers on the database entries that are needed by the expression, so each
* time a database value changes, the link is marked as 'triggered'
* When updateTrigeredLinks() is called, all links are effectively updated.
*
* Example of use : connecting a change in the db tree to the 'active' state of a window
*
* NB : an additionnal action handler can be provided
* NB : The links are owned by the interface element (using a smart pointer)
* NB : Several targets may be used.
*
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2002
*/
class CInterfaceLink : public NLMISC::ICDBNode::IPropertyObserver
{
public:
#ifdef NL_DEBUG
// for debugging purposes : if this link is 'named' e.g is owner by CInterfaceManager
// and was created by calling CInterfaceManager::addLink, contains the name of this link
std::string LinkName;
#endif
public:
struct CTargetInfo
{
CInterfaceElement *Elem;
std::string PropertyName;
/** Affect a value to this target.
* \return true if the affectation could be made
*/
bool affect(const CInterfaceExprValue &value);
};
/// Updates triggered interface links when triggered by the observed branch
class CInterfaceLinkUpdater : public NLMISC::CCDBBranchObservingHandler::IBranchObserverCallFlushObserver
{
public:
CInterfaceLinkUpdater();
~CInterfaceLinkUpdater();
void onObserverCallFlush();
};
public:
CInterfaceLink();
~CInterfaceLink(); // this object should only be destroyed by a CInterfaceElement
/** Make a link between the given interface element properties and a value that depends on database entries.
* The link is automatically added in the link list of the targets element (it calls CInterfaceElement::addLink), so when all target elements are removed, the link is.
* If there are no target element, the link is permanent (removed at exit)
* NB : The target is not updated during this call.
*/
bool init(const std::vector<CTargetInfo> &targets, const std::string &expr, const std::string &actionHandler, const std::string &ahParams, const std::string &ahCond, CInterfaceGroup *parent);
// force all the links that have been created to update their targets. This can be called when the interface has been loaded, and when the databse entries have been retrieved.
static void updateAllLinks();
// force all trigered links to be updated
static void updateTrigeredLinks();
// remove from the _LinksWithNoTarget list if the link has no target
void uninit();
// Force an update of the target of this link
void update();
/** Remove a target element. It won't be updated anymore by that link
* NB : this don't call removeLink() on the target
*/
void removeTarget(CInterfaceElement *elem);
// Get the number of targets of this link
uint getNumTargets() const { return (uint)_Targets.size(); }
// Get the i-th target
CInterfaceElement *getTarget(uint index) const { return _Targets[index]._InterfaceElement; }
static void removeAllLinks();
static void setTargetProperty (const std::string & Target, const CInterfaceExprValue &val);
static bool isUpdatingAllLinks() { return _UpdateAllLinks; }
/** From a target name of a link, retrieve the target element and its target target property
* \return true if the target is valid
*/
static bool splitLinkTarget(const std::string &target, CInterfaceGroup *parentGroup, std::string &propertyName, CInterfaceElement *&targetElm);
/** From several target names of a link (seprated by ','), retrieve the target elements and their target properties
* \return true if all targets are valid
*/
static bool splitLinkTargets(const std::string &targets, CInterfaceGroup *parentGroup, std::vector<CInterfaceLink::CTargetInfo> &targetsVect);
////////////////////////////////////////////////////////////////////////////////////////////////////////
private:
friend struct CRemoveTargetPred;
// a target property
struct CTarget
{
CInterfaceElement *_InterfaceElement;
const CReflectedProperty *_Property;
};
private:
typedef std::list<CInterfaceLink *> TLinkList;
typedef NLMISC::CSmartPtr<CInterfaceLink> TLinkSmartPtr;
typedef std::vector<TLinkSmartPtr> TLinkVect;
typedef std::vector<NLMISC::ICDBNode *> TNodeVect;
private:
std::vector<CTarget> _Targets;
TNodeVect _ObservedNodes;
std::string _Expr;
CInterfaceExprNode *_ParseTree;
std::string _ActionHandler;
std::string _AHParams;
std::string _AHCond;
CInterfaceGroup *_AHParent;
static TLinkList _LinkList;
TLinkList::iterator _ListEntry;
bool _On;
static TLinkVect _LinksWithNoTarget; // there should be an owner for links with no targets
static bool _UpdateAllLinks;
///\ name triggered link mgt
//@{
// next/previous link that was trigered. NULL means end or start of list
// each ptr is duplicated because with manage 2 lists : one list in which links are added, and one list in which we update links.
// This way one link can trigger another with no prb
CInterfaceLink *_PrevTriggeredLink[2];
CInterfaceLink *_NextTriggeredLink[2];
bool _Triggered[2];
// global lists
static CInterfaceLink *_FirstTriggeredLink[2];
static CInterfaceLink *_LastTriggeredLink[2];
// iterators in current list being updated : they're global so that deleting a CInterfaceLink instance prevent them from becoming dangling pointers
static CInterfaceLink *_CurrUpdatedLink;
static CInterfaceLink *_NextUpdatedLink;
// Index of the list in which triggered link must be inserted
static uint _CurrentTriggeredLinkList;
//
void linkInTriggerList(uint list);
void unlinkFromTriggerList(uint list);
//@}
private:
/** Inherited from ICDBNode::IPropertyObserver
* This doesn't update the node directly, but mark it as 'triggered'
* The node is really updated during the call to 'updateTrigeredLinks()'
*/
virtual void update(NLMISC::ICDBNode *node);
void createObservers(const TNodeVect &nodes);
void removeObservers(const TNodeVect &nodes);
// debug : check that there are as many targets as reference to a link
void checkNbRefs();
};
}
#endif

@ -0,0 +1,225 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_INTERFACE_LAYER_H
#define RZ_INTERFACE_LAYER_H
#include "nel/misc/debug.h"
#include "nel/misc/smart_ptr.h"
#include "nel/misc/rgba.h"
#include "libxml/globals.h"
#include "nel/misc/xml_auto_ptr.h"
namespace NL3D
{
class UAnimationSet;
}
namespace NLGUI
{
// ***************************************************************************
class CInterfaceOptionValue
{
public:
CInterfaceOptionValue()
{
_Color= NLMISC::CRGBA::White;
_Int= 0;
_Float= 0;
_Boolean= false;
}
const std::string &getValStr () const {return _Str;}
sint32 getValSInt32() const {return _Int;}
float getValFloat () const {return _Float;}
NLMISC::CRGBA getValColor () const {return _Color;}
bool getValBool () const {return _Boolean;}
void init(const std::string &str);
// returned when InterfaceOptions param not found
static const CInterfaceOptionValue NullValue;
private:
std::string _Str;
NLMISC::CRGBA _Color;
sint32 _Int;
float _Float;
bool _Boolean;
};
// ***************************************************************************
class CInterfaceOptions : public NLMISC::CRefCount
{
public:
// for factory construction
struct TCtorParam
{
};
CInterfaceOptions( const TCtorParam &/* param */ );
virtual ~CInterfaceOptions();
virtual bool parse (xmlNodePtr cur);
virtual xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
// return NullValue if param not found
const CInterfaceOptionValue &getValue(const std::string &sParamName) const;
// shortcuts to getValue(paramName).getValXXX()
const std::string &getValStr (const std::string &sParamName) const;
sint32 getValSInt32 (const std::string &sParamName) const;
float getValFloat (const std::string &sParamName) const;
NLMISC::CRGBA getValColor (const std::string &sParamName) const;
bool getValBool (const std::string &sParamName) const;
// copy basic map only from other CInterfaceOptions (non virtual method)
void copyBasicMap(const CInterfaceOptions &other);
protected:
std::map<std::string, CInterfaceOptionValue> _ParamValue;
};
// ***************************************************************************
class COptionsLayer : public CInterfaceOptions
{
public:
COptionsLayer( const TCtorParam &/* param */ );
~COptionsLayer();
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
virtual bool parse (xmlNodePtr cur);
// Container optimizer
sint32 Tile_Blank;
sint32 Tile_M_Header, Tile_M_Scrollbar;
sint32 Tile_T, Tile_B, Tile_L, Tile_R;
sint32 Tile_B_Open, Tile_EM_Open, Tile_M_Open;
sint32 Scrollbar_Offset_X;
sint32 Scrollbar_W;
sint32 TxId_B_Scrollbar, W_B_Scrollbar, H_B_Scrollbar;
sint32 TxId_M_Scrollbar, W_M_Scrollbar, H_M_Scrollbar;
sint32 TxId_T_Scrollbar, W_T_Scrollbar, H_T_Scrollbar;
sint32 TxId_L_Header, W_L_Header, H_L_Header;
sint32 TxId_M_Header, W_M_Header, H_M_Header;
sint32 TxId_R_Header, W_R_Header, H_R_Header;
sint32 TxId_TL, W_TL, H_TL;
sint32 TxId_T, W_T, H_T;
sint32 TxId_TR, W_TR, H_TR;
sint32 TxId_L, W_L, H_L;
sint32 TxId_R, W_R, H_R;
sint32 TxId_Blank, W_Blank, H_Blank;
sint32 TxId_BL, W_BL, H_BL;
sint32 TxId_B, W_B, H_B;
sint32 TxId_BR, W_BR, H_BR;
sint32 TxId_BL_Open, W_BL_Open, H_BL_Open;
sint32 TxId_B_Open, W_B_Open, H_B_Open;
sint32 TxId_BR_Open, W_BR_Open, H_BR_Open;
sint32 TxId_EL_Open, W_EL_Open, H_EL_Open;
sint32 TxId_EM_Open, W_EM_Open, H_EM_Open;
sint32 TxId_ER_Open, W_ER_Open, H_ER_Open;
sint32 TxId_E_Open, W_E_Open, H_E_Open;
sint32 TxId_M_Open, W_M_Open, H_M_Open;
sint32 TxId_TL_HighLight;
sint32 TxId_T_HighLight;
sint32 TxId_TR_HighLight;
sint32 TxId_L_HighLight;
sint32 TxId_R_HighLight;
sint32 TxId_BL_HighLight;
sint32 TxId_B_HighLight;
sint32 TxId_BR_HighLight;
sint32 HeaderH;
};
// ***************************************************************************
class COptionsContainerInsertion : public CInterfaceOptions
{
public:
COptionsContainerInsertion( const TCtorParam &/* param */ );
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
virtual bool parse (xmlNodePtr cur);
sint32 TxId_R_Arrow;
sint32 TxId_L_Arrow;
sint32 TxId_T_Arrow;
sint32 TxId_B_Arrow;
sint32 TxId_InsertionBar;
};
// ***************************************************************************
class COptionsContainerMove : public CInterfaceOptions
{
public:
COptionsContainerMove( const TCtorParam &/* param */ );
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
virtual bool parse (xmlNodePtr cur);
sint32 TrackW;
sint32 TrackH;
sint32 TrackY;
sint32 TrackYWithTopResizer;
sint32 TrackHWithTopResizer;
sint32 ResizerSize;
};
// ***************************************************************************
/**
* read a list of <param> with no name. id auto incremented
*/
class COptionsList : public CInterfaceOptions
{
public:
COptionsList( const TCtorParam &/* param */ );
xmlNodePtr serialize( xmlNodePtr parentNode, const std::string &name ) const;
virtual bool parse (xmlNodePtr cur);
uint getNumParams() const {return _NumParams;}
// get a value by its index (from 0 to numParams)
const CInterfaceOptionValue &getValue(uint paramId) const;
private:
uint _NumParams;
};
}
#endif // NL_INTERFACE_LAYER_H
/* End of interface_layer.h */

@ -0,0 +1,389 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_INTERFACE_PARSER_H
#define RZ_INTERFACE_PARSER_H
#include "nel/misc/types_nl.h"
#include "nel/3d/u_texture.h"
#include "nel/gui/ctrl_sheet_selection.h"
#include "nel/gui/interface_link.h"
#include "nel/misc/smart_ptr.h"
#include "nel/gui/lua_helper.h"
#include "nel/gui/proc.h"
#include "nel/gui/widget_manager.h"
#include "nel/gui/link_data.h"
namespace NLGUI
{
class CInterfaceElement;
class CInterfaceGroup;
class CInterfaceOptions;
class CInterfaceLink;
class CCtrlBase;
class CGroupList;
class CGroupContainer;
class CInterfaceAnim;
class CViewPointer;
// ***************************************************************************
/**
* class managing the interface parsing
* \author Matthieu 'TrapII' Besson
* \author Nevrax France
* \date 2002
*/
class CInterfaceParser : public IParser
{
public:
/// Interface for parser modules
/// Such modules can be plugged into CInterfaceParser, and
/// the modules then can parse GUI XMLs for widget classes that are not
/// generic enough to be in the GUI library.
class IParserModule
{
public:
/// Various parsing stages
enum ParsingStage
{
None = 0, /// module cannot parse in any stage.
Unresolved = 1, /// module can parse in the first stage when styles, templates, etc have not been resolved yet
Resolved = 2, /// module can parse after resolving styles and templates
GroupChildren = 4 /// module can parse when parsing the group children
};
IParserModule(){
parser = NULL;
parsingStage = None;
}
virtual ~IParserModule(){}
bool canParseInStage( ParsingStage stage )
{
if( ( parsingStage & static_cast< uint >( stage ) ) != 0 )
return true;
else
return false;
}
virtual bool parse( xmlNodePtr cur, CInterfaceGroup *parentGroup ) = 0;
void setParser( CInterfaceParser *p ){ parser = p; }
protected:
CInterfaceParser *parser;
uint parsingStage;
};
/// Interface for event handlers which can be called when setting up the options.
class ISetupOptionCallbackClass
{
public:
virtual void setupOptions() = 0;
};
struct VariableData
{
std::string entry;
std::string type;
std::string value;
uint32 size;
VariableData()
{
size = 0;
}
};
CInterfaceParser();
virtual ~CInterfaceParser();
public:
/**
* Parsing methods
*/
/** Load a set of xml files
* \param isFilename true if xmlFileNames array contains the names of the xml file, false, if each
* array is a script itself
*/
bool parseInterface (const std::vector<std::string> &xmlFileNames, bool reload, bool isFilename = true, bool checkInData = false);
bool parseXMLDocument (xmlNodePtr root, bool reload);
bool parseTemplateNode (xmlNodePtr node,xmlNodePtr instance,xmlNodePtr templ);
bool parseInstance(xmlNodePtr cur);
bool parseVector (xmlNodePtr cur);
bool parseVariable (xmlNodePtr cur, CInterfaceGroup * parentGroup);
bool parseOptions (xmlNodePtr cur, CInterfaceGroup * parentGroup);
bool parseGroup (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
bool parseGroupChildren(xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
bool parseControl (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
bool parseLink (xmlNodePtr cur, CInterfaceGroup * parentGroup);
bool parseView (xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload);
bool parseTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup);
bool parseTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup);
bool parseDefine(xmlNodePtr cur);
bool parseProcedure(xmlNodePtr cur, bool reload);
bool parseSheetSelection(xmlNodePtr cur);
bool parseAnim(xmlNodePtr cur, CInterfaceGroup * parentGroup);
bool parseStyle(xmlNodePtr cur);
bool parseLUAScript (xmlNodePtr cur);
bool setupTree (xmlNodePtr cur, CWidgetManager::SMasterGroup *parentGroup);
bool setupTreeNode (xmlNodePtr cur, CGroupContainer *parentGroup);
void savePointerSettings( xmlNodePtr node );
void saveKeySettings( xmlNodePtr node );
void addModule( std::string name, IParserModule *module );
IParserModule* getModuleFor( std::string name ) const;
void removeAllModules();
// Called by each parse in parseXMLDocument
bool solveDefine(xmlNodePtr cur);
bool solveStyle(xmlNodePtr cur);
// Solve All define in a string. return false if some define not founs (defError contains this define)
bool solveDefine(const std::string &propVal, std::string &newPropVal, std::string &defError);
// Called after template & options parsing
void setupOptions();
/**
* Initializer
*/
bool initCoordsAndLuaScript ();
/// Association builders : associate an element of the interface with the string ID of
/// another element used as reference for position values
void addParentPositionAssociation (CInterfaceElement *element, const std::string &parentID);
std::string getParentPosAssociation( CInterfaceElement *element ) const;
void addParentSizeAssociation (CInterfaceElement *element, const std::string &parentID);
std::string getParentSizeAssociation( CInterfaceElement *element ) const;
void addParentSizeMaxAssociation (CInterfaceElement *element, const std::string &parentID);
std::string getParentSizeMaxAssociation( CInterfaceElement *element ) const;
/// LUA Class Association builder : associate a lua script to a group (called for each group after every document parsed)
void addLuaClassAssociation(CInterfaceGroup *group, const std::string &luaScript);
std::string getLuaClassAssociation( CInterfaceGroup *group ) const;
/**
* Accessors
*/
// access to control sheet selection
CCtrlSheetSelection &getCtrlSheetSelection() { return _CtrlSheetSelection; }
/// \name Parameter variable
// @{
const std::string& getDefine(const std::string &id) const;
bool isDefineExist(const std::string &id) const;
void setDefine(const std::string &id, const std::string &value);
// @}
/// \name Dynamic links mgt
// @{
/** Associate the given dynamic link with an ID
* \return true if succesful
*/
bool addLink(CInterfaceLink *link, const std::string &id);
/** remove the given link from its ID
* \return true if succesful
*/
bool removeLink(const std::string &id);
// @}
/** create a template from an instance consisting of a single group
* \param templateName name of the template in the xml
* \param templateParams array containing each template parameter and its name
* \param number of template parameters in the array
*/
CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, const std::pair<std::string, std::string> *templateParams, uint numParams, bool updateLinks = true);
CInterfaceGroup *createGroupInstance(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &templateParams, bool updateLinks = true)
{
if (templateParams.size() > 0)
return createGroupInstance(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks);
else
return createGroupInstance(templateName, parentID, NULL, 0, updateLinks);
}
/** create a template from an instance consisting of a single control or group
* \param templateName name of the template in the xml
* \param templateParams array containing each template parameter and its name
* \param number of template parameters in the array
*/
CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, const std::pair<std::string,std::string> *templateParams, uint numParams, bool updateLinks /* = true */);
CInterfaceElement *createUIElement(const std::string &templateName, const std::string &parentID, std::vector<std::pair<std::string, std::string> > &templateParams, bool updateLinks = true)
{
if (templateParams.size() > 0)
return createUIElement(templateName, parentID, &templateParams[0], (uint)templateParams.size(), updateLinks);
else
return createUIElement(templateName, parentID, NULL, 0, updateLinks);
}
static void freeXMLNodeAndSibblings(xmlNodePtr node);
// search a "tree" node in the hierarchy that match node. may return root! NULL if not found
static xmlNodePtr searchTreeNodeInHierarchy(xmlNodePtr root, const char *node);
/// \name Clearing mgt
// @{
void removeAllLinks();
void removeAllProcedures();
void removeAllDefines();
void removeAllTemplates();
void removeAllAnims();
void removeAll();
// @}
protected:
/// Procedure list
typedef TProcedureMap::iterator ItProcedureMap;
typedef TProcedureMap::const_iterator CstItProcedureMap;
TProcedureMap _ProcedureMap;
public:
// get info on procedure. return 0 if procedure not found
uint getProcedureNumActions( const std::string &procName ) const;
// return false if procedure not found, or if bad action index. return false if has some param variable (@0...)
bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string &params ) const;
void setCacheUIParsing( bool b ){ cacheUIParsing = b; }
CInterfaceAnim* getAnim( const std::string &name ) const;
CProcedure* getProc( const std::string &name );
const TProcedureMap& getProcMap() const{ return _ProcedureMap; }
protected:
/**
* Temporary data for init
*/
/// vector storing parsed templates during init. At the end of init, only used template are kept
std::vector<xmlNodePtr> _Templates;
// map linking an element to its parent position used during init only
std::map<CInterfaceElement*,std::string> _ParentPositionsMap;
std::map<CInterfaceElement*,std::string> _ParentSizesMap;
std::map<CInterfaceElement*,std::string> _ParentSizesMaxMap;
// map linking a group to its lua script. used during init only
std::map<CInterfaceGroup*,std::string> _LuaClassAssociation;
/**
* Data of initialized interface
*/
/// Define Variable list
typedef std::map<std::string, std::string> TVarMap;
typedef TVarMap::iterator ItVarMap;
typedef TVarMap::const_iterator CstItVarMap;
TVarMap _DefineMap;
bool validDefineChar(char c) const;
class CStyleProperty
{
public:
std::string Name;
std::string Value;
};
class CStyle
{
public:
std::vector<CStyleProperty> Properties;
};
// mgt of sheet selections (inventory, buy, sell..)
CCtrlSheetSelection _CtrlSheetSelection;
// Map of dynamic links
typedef std::map<std::string, NLMISC::CSmartPtr<CInterfaceLink> > TLinkMap;
TLinkMap _LinkMap;
// Map of anims
typedef std::map<std::string, CInterfaceAnim *> TAnimMap;
TAnimMap _AnimMap;
// Map of styles.
typedef std::map<std::string, CStyle> TStyleMap;
TStyleMap _StyleMap;
protected:
std::map< std::string, IParserModule* > moduleMap;
// List of script loaded (for reloadLua command)
std::set<std::string> _LuaFileScripts;
bool cacheUIParsing;
bool luaInitialized;
ISetupOptionCallbackClass *setupCallback;
uint32 linkId;
std::map< uint32, SLinkData > links;
bool editorMode;
std::map< std::string, VariableData > variableCache;
std::map< std::string, std::string > pointerSettings;
std::map< std::string, std::map< std::string, std::string > > keySettings;
public:
void initLUA();
void uninitLUA();
bool isLuaInitialized() const{ return luaInitialized; }
/// Load A .lua. false if parse error. string 'error' contains the eventual error desc (but warning still displayed)
bool loadLUA( const std::string &luaFile, std::string &error );
/// Reload all LUA scripts inserted through <lua>
void reloadAllLuaFileScripts();
void setSetupOptionsCallback( ISetupOptionCallbackClass *cb ){ setupCallback = cb; }
bool hasProc( const std::string &name ) const;
bool addProc( const std::string &name );
bool removeProc( const std::string &name );
const std::map< uint32, SLinkData >& getLinkMap() const{ return links; }
uint32 addLinkData( SLinkData &linkData );
void removeLinkData( uint32 id );
bool getLinkData( uint32 id, SLinkData &linkData );
void updateLinkData( uint32 id, const SLinkData &linkData );
void setEditorMode( bool b ){ editorMode = b; }
bool serializeVariables( xmlNodePtr parentNode ) const;
bool serializeProcs( xmlNodePtr parentNode ) const;
bool serializePointerSettings( xmlNodePtr parentNode ) const;
bool serializeKeySettings( xmlNodePtr parentNode ) const;
};
}
#endif // RZ_INTERFACE_PARSER_H

@ -0,0 +1,106 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_INTERFACE_PROPERTY_H
#define NL_INTERFACE_PROPERTY_H
#include "nel/misc/types_nl.h"
#include "nel/misc/rgba.h"
#include "nel/misc/cdb.h"
#include "nel/misc/cdb_leaf.h"
#include "nel/misc/cdb_branch.h"
namespace NLGUI
{
/**
* interface property
* class used to managed all the interface member values
* As the database contains only sint64, several methods are needed to do the conversion
* \author Nicolas Brigand
* \author Nevrax France
* \date 2002
*/
class CInterfaceProperty
{
public:
//enum defining a hot spot
/// Constructor
CInterfaceProperty()
{
_VolatileValue = NULL;
}
NLMISC::CCDBNodeLeaf* getNodePtr() const
{
return _VolatileValue;
}
void setNodePtr(NLMISC::CCDBNodeLeaf *ptr)
{
_VolatileValue = ptr;
}
bool link (const char *DBProp);
bool link( NLMISC::CCDBNodeLeaf *dbNode );
bool link( NLMISC::CCDBNodeBranch *dbNode, const std::string &leafId, NLMISC::CCDBNodeLeaf *defaultLeaf = NULL );
/// float operations
void setDouble (double value) {setSInt64((sint64&) value);}
double getDouble () const {sint64 i = getSInt64(); return (double &) i; }
void readDouble (const char* value, const std::string& id);
/// sint32 operations
void setSInt32 (sint32 value) {_VolatileValue->setValue32 (value);}
sint32 getSInt32 () const {return _VolatileValue->getValue32();}
void readSInt32(const char* value, const std::string& id);
/// sint64 operations
void setSInt64 (sint64 value) {_VolatileValue->setValue64(value);}
sint64 getSInt64 () const {return _VolatileValue->getValue64();}
void readSInt64(const char* value, const std::string& id);
/// CRGBA operations
void setRGBA (const NLMISC::CRGBA & value);
NLMISC::CRGBA getRGBA () const;
void readRGBA (const char* value, const std::string& id);
/// HotSpot operations
void readHotSpot (const char* value, const std::string& id);
/// bool operations
void setBool (bool value);
bool getBool () const;
void readBool (const char* value, const std::string& id);
// Swap the content of this 2 property (no-op if one is NULL)
void swap32(CInterfaceProperty &o);
private:
/// volatile value of the property (pointer to a leaf of the database)
NLMISC::CCDBNodeLeaf* _VolatileValue;
};
}
#endif // NL_INTERFACE_PROPERTY_H
/* End of interface_property.h */

@ -0,0 +1,283 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_LIB_WWW_H
#define CL_LIB_WWW_H
extern "C"
{
#include "WWWInit.h"
}
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
class CGroupList;
// ***************************************************************************
// Init the libwww
void initLibWWW();
// Get an url and setup a local domain
const std::string &setCurrentDomain(const std::string &url);
extern std::string CurrentCookie;
// ***************************************************************************
// Some DTD table
// Here, modify the DTD table to change the HTML parser (add new tags for exemples)
#undef HTML_ATTR
#define HTML_ATTR(t,a) MY_HTML_##t##_##a
enum
{
HTML_ATTR(A,ACCESSKEY) = 0,
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTR(A,Z_ACTION_CATEGORY),
HTML_ATTR(A,Z_ACTION_PARAMS),
HTML_ATTR(A,Z_ACTION_SHORTCUT),
};
enum
{
HTML_ATTR(TABLE,ALIGN) = 0,
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,L_MARGIN),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,NOWRAP),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,VALIGN),
HTML_ATTR(TABLE,WIDTH)
};
enum
{
HTML_ATTR(TR,ALIGN) = 0,
HTML_ATTR(TR,BGCOLOR),
HTML_ATTR(TR,L_MARGIN),
HTML_ATTR(TR,NOWRAP),
HTML_ATTR(TR,VALIGN),
};
enum
{
HTML_ATTR(TD,ABBR) = 0,
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,L_MARGIN),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
};
enum
{
HTML_ATTR(IMG,ALIGN) = 0,
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,GLOBAL_COLOR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
};
enum
{
HTML_ATTR(INPUT,ACCEPT) = 0,
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,GLOBAL_COLOR),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTR(INPUT,Z_BTN_TMPL),
HTML_ATTR(INPUT,Z_INPUT_TMPL),
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
};
enum
{
HTML_ATTR(TEXTAREA,CLASS) = 0,
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
};
enum
{
HTML_ATTR(P,QUICK_HELP_CONDITION) = 0,
HTML_ATTR(P,QUICK_HELP_EVENTS),
HTML_ATTR(P,QUICK_HELP_LINK),
HTML_ATTR(P,NAME),
};
enum
{
HTML_ATTR(DIV,CLASS) = 0,
HTML_ATTR(DIV,ID),
HTML_ATTR(DIV,NAME),
HTML_ATTR(DIV,STYLE),
};
#undef HTML_ATTR
// ***************************************************************************
// A smart ptr for LibWWW strings
class C3WSmartPtr
{
public:
C3WSmartPtr ()
{
_Ptr = NULL;
}
C3WSmartPtr (const char *ptr)
{
_Ptr = ptr;
}
~C3WSmartPtr ()
{
clear();
}
void operator=(const char *str)
{
clear ();
_Ptr = str;
}
operator const char *() const
{
return _Ptr;
}
void clear()
{
if (_Ptr)
{
void *ptr = (void*)_Ptr;
HT_FREE(ptr);
}
_Ptr = NULL;
}
private:
const char *_Ptr;
};
// ***************************************************************************
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
bool getPercentage (sint32 &width, float &percent, const char *str);
// ***************************************************************************
// Parse a HTML color
NLMISC::CRGBA getColor (const char *color);
// ***************************************************************************
void _VerifyLibWWW(const char *function, bool ok, const char *file, int line);
#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__)
// ***************************************************************************
// Standard request terminator
int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status) ;
// ***************************************************************************
}
#endif

@ -23,8 +23,6 @@
#include "HTProt.h"
extern "C" HTProtCallback HTLoadNeLFile;
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
void * param, int mode);
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode);
#endif // LIBWWW_NEL_STREAM_H

@ -14,45 +14,29 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_DBVIEW_QUANTITY_H
#define NL_DBVIEW_QUANTITY_H
#ifndef LINKDATA_H
#define LINKDATA_H
#include "nel/misc/types_nl.h"
#include <string>
#include "view_text.h"
namespace NLGUI
{
// ***************************************************************************
/**
* Display a text in the form of val / max or "empty"
* \author Lionel Berenguier
* \author Nevrax France
* \date 2002
*/
class CDBViewQuantity : public CViewText
struct SLinkData
{
public:
/// Constructor
CDBViewQuantity(const TCtorParam &param);
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
virtual void draw ();
protected:
CInterfaceProperty _Number;
CInterfaceProperty _NumberMax;
sint32 _Cache;
sint32 _CacheMax;
ucstring _EmptyText;
void buildTextFromCache();
uint32 id;
std::string parent;
std::string expr;
std::string target;
std::string action;
std::string params;
std::string cond;
};
#endif // NL_DBVIEW_QUANTITY_H
}
/* End of dbview_quantity.h */
#endif

@ -0,0 +1,391 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef RZ_LUA_HELPER_H
#define RZ_LUA_HELPER_H
#include "nel/misc/types_nl.h"
#include "nel/misc/smart_ptr.h"
extern "C"
{
#include "lua_loadlib.h"
}
namespace NLGUI
{
class CLuaState;
namespace LuaHelperStuff
{
void formatLuaStackContext( std::string &stackContext );
std::string formatLuaErrorSysInfo( const std::string &error );
std::string formatLuaErrorNlWarn( const std::string &error );
}
// ***************************************************************************
/** Helper class to see if a stack is restored at its initial size (or with n return results).
* Check that the stack size remains unchanged when the object goes out of scope
*/
class CLuaStackChecker
{
public:
CLuaStackChecker(CLuaState *state, int numWantedResults = 0);
~CLuaStackChecker();
/** Increment exception context counter
* When an exception is thrown, lua stack checker do any assert bu will
* rather restore the lua stack at its original size, and will
* let the exception a chance to propagate
*/
static void incrementExceptionContextCounter();
static void decrementExceptionContextCounter();
private:
CLuaState *_State;
int _FinalWantedSize;
static uint _ExceptionContextCounter;
};
// **************************************************************************
/** Helper class to restore the lua stack to the desired size when this object goes out of scope
*/
class CLuaStackRestorer
{
public:
CLuaStackRestorer(CLuaState *state, int finalSize);
~CLuaStackRestorer();
private:
int _FinalSize;
CLuaState *_State;
};
////////////////
// EXCEPTIONS //
////////////////
class ELuaError : public NLMISC::Exception
{
public:
ELuaError() { CLuaStackChecker::incrementExceptionContextCounter(); }
virtual ~ELuaError() throw() { CLuaStackChecker::decrementExceptionContextCounter(); }
ELuaError(const std::string &reason) : Exception(reason) { CLuaStackChecker::incrementExceptionContextCounter(); }
// what(), plus append the Reason
virtual std::string luaWhat() const throw() {return NLMISC::toString("LUAError: %s", what());}
};
// A parse error occured
class ELuaParseError : public ELuaError
{
public:
ELuaParseError() {}
ELuaParseError(const std::string &reason) : ELuaError(reason) {}
virtual ~ELuaParseError() throw() { }
// what(), plus append the Reason
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaParseError: %s", what());}
};
/** Exception thrown when something went wrong inside a wrapped function called by lua
*/
class ELuaWrappedFunctionException : public ELuaError
{
public:
ELuaWrappedFunctionException(CLuaState *luaState);
ELuaWrappedFunctionException(CLuaState *luaState, const std::string &reason);
ELuaWrappedFunctionException(CLuaState *luaState, const char *format, ...);
virtual ~ELuaWrappedFunctionException() throw() { }
virtual const char *what() const throw() {return _Reason.c_str();}
protected:
void init(CLuaState *ls, const std::string &reason);
protected:
std::string _Reason;
};
// A execution error occured
class ELuaExecuteError : public ELuaError
{
public:
ELuaExecuteError() {}
ELuaExecuteError(const std::string &reason) : ELuaError(reason) {}
virtual ~ELuaExecuteError() throw() { }
// what(), plus append the Reason
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaExecuteError: %s", what());}
};
// A bad cast occured when using lua_checkcast
class ELuaBadCast : public ELuaError
{
public:
ELuaBadCast() {}
ELuaBadCast(const std::string &reason) : ELuaError(reason) {}
// what(), plus append the Reason
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaBadCast: %s", what());}
};
// Error when trying to indexate an object that is not a table
class ELuaNotATable : public ELuaError
{
public:
ELuaNotATable() {}
ELuaNotATable(const std::string &reason) : ELuaError(reason) {}
// what(), plus append the Reason
virtual std::string luaWhat() const throw() {return NLMISC::toString("ELuaNotATable: %s", what());}
};
// ***************************************************************************
// a function to be used with a CLuaState instance
typedef int (* TLuaWrappedFunction) (CLuaState &ls);
// ***************************************************************************
/** C++ version of a lua state
*/
class CLuaState : public NLMISC::CRefCount
{
public:
typedef NLMISC::CRefPtr<CLuaState> TRefPtr;
// Create a new environement
CLuaState( bool debugger = false );
~CLuaState();
/// \name Registering
// @{
// register a wrapped function
void registerFunc(const char *name, TLuaWrappedFunction function);
// @}
/// \name Script execution
// @{
/** Parse a script and push as a function in top of the LUA stack
* \throw ELuaParseError
* \param dbgSrc is a string for debug. Should be a filename (preceded with '@'), or a short script.
*/
void loadScript(const std::string &code, const std::string &dbgSrc);
/** Execute a script from a string, possibly throwing an exception if there's a parse error
* \throw ELuaParseError, ELuaExecuteError
*/
void executeScript(const std::string &code, int numRet = 0);
/** Execute a script from a string. If an errors occurs it is printed in the log
* \return true if script execution was successful
*/
bool executeScriptNoThrow(const std::string &code, int numRet = 0);
/** Load a Script from a File (maybe in a BNP), and execute it
* \return false if file not found
* \throw ELuaParseError, ELuaExecuteError
*/
bool executeFile(const std::string &pathName);
/** execute a very Small Script (a function call for instance)
* It is different from doString() in such there is a cache (where the key is the script itself)
* so that the second time this script is executed, there is no parsing
* Note: I experienced optim with about 10 times faster than a executeScript() on a simple "a= a+1;" script
* \throw ELuaParseError, ELuaExecuteError
*/
void executeSmallScript(const std::string &script);
// @}
/// \name Stack Manipulation
// @{
// stack manipulation (indices start at 1)
void setTop(int index); // set new size of stack
void clear() { setTop(0); }
int getTop();
bool empty() { return getTop() == 0; }
void pushGlobalTable();
void pushValue(int index); // copie nth element of stack to the top of the stack
void remove(int index); // remove nth element of stack
void insert(int index); // insert last element of the stack before the given position
void replace(int index); // replace nth element of the stack with the top of the stack
void pop(int numElem = 1); // remove n elements from the top of the stack
// test the type of an element in the stack
// return one of the following values :
// LUA_TNIL
// LUA_TNUMBER
// LUA_TBOOLEAN
// LUA_TSTRING
// LUA_TTABLE
// LUA_TFUNCTION
// LUA_TUSERDATA
// LUA_TTHREAD
// LUA_TLIGHTUSERDATA
int type(int index = -1);
const char *getTypename(int type);
bool isNil(int index = -1);
bool isBoolean(int index = -1);
bool isNumber(int index = -1);
bool isString(int index = -1);
bool isTable(int index = -1);
bool isFunction(int index = -1);
bool isCFunction(int index = -1);
bool isUserData(int index = -1);
bool isLightUserData(int index = -1);
// converting then getting a value from the stack
bool toBoolean(int index = -1);
lua_Number toNumber(int index = -1);
const char *toString(int index = -1);
void toString(int index, std::string &str); // convert to a std::string, with a NULL check.
size_t strlen(int index = -1);
lua_CFunction toCFunction(int index = -1);
void *toUserData(int index = -1);
const void *toPointer(int index = -1);
/** Helper functions : get value of the wanted type in the top table after conversion
* A default value is used if the stack entry is NULL.
* If conversion fails then an exception is thrown (with optional msg)
*/
bool getTableBooleanValue(const char *name, bool defaultValue= false);
double getTableNumberValue(const char *name, double defaultValue= 0);
const char *getTableStringValue(const char *name, const char *defaultValue= NULL);
// pushing value onto the stack
void push(bool value);
void push(lua_Number value);
void push(const char *str);
void push(const char *str, int length);
void push(const std::string &str);
void pushNil();
void push(lua_CFunction f);
void push(TLuaWrappedFunction function);
void pushLightUserData(void *); // push a light user data (use newUserData to push a full userdata)
// metatables
bool getMetaTable(int index = -1);
bool setMetaTable(int index = -1); // set the metatable at top of stack to the object at 'index' (usually -2), then pop the metatable
// even if asignment failed
// comparison
bool equal(int index1, int index2);
bool rawEqual(int index1, int index2);
bool lessThan(int index1, int index2);
// concatenation of the n element at the top of the stack (using lua semantic)
void concat(int numElem);
// tables
void newTable(); // create a new table at top of the stack
void getTable(int index); // get value from a table at index 'index' (key is at top)
void rawGet(int index);
void setTable(int index); // set (key, value) from top of the stack into the given table
// both key and value are poped
void rawSet(int index);
bool next(int index); // table traversal
// UserData
void *newUserData(uint size);
// seting value by int index in a table
void rawSetI(int index, int n);
void rawGetI(int index, int n);
/** Calling functions (it's up to the caller to clear the results)
* The function should have been pushed on the stack
*/
void call(int nargs, int nresults);
int pcall(int nargs, int nresults, int errfunc = 0);
/** Helper : Execute a function by name. Lookup for the function is done in the table at the index 'funcTableIndex'
* the behaviour is the same than with call of pcall.
*/
int pcallByNameGlobal(const char *functionName, int nargs, int nresults, int errfunc = 0);
int pcallByName(const char *functionName, int nargs, int nresults, int funcTableIndex, int errfunc = 0);
// push a C closure (pop n element from the stack and associate with the function)
void pushCClosure(lua_CFunction function, int n);
// @}
/// \name Misc
// @{
/** Retrieve pointer to a CLuaState environment from its lua_State pointer, or NULL
* if there no such environment
*/
static CLuaState *fromStatePointer(lua_State *state);
// Get state pointer. The state should not be closed (this object has ownership)
lua_State *getStatePointer() const {return _State;}
// check that an index is valid when accessing the stack
// an assertion is raised if the index is not valid
void checkIndex(int index);
// registering C function to use with a lua state pointer
void registerFunc(const char *name, lua_CFunction function);
// Garbage collector
int getGCCount(); // get memory in use in KB
int getGCThreshold(); // get max memory in KB
void setGCThreshold(int kb); // set max memory in KB (no-op with ref-counted version)
// handle garbage collector for ref-counted version of lua (no-op with standard version, in which case gc handling is automatic)
void handleGC();
/** For Debug: get the Stack context of execution (filename / line)
* \param stackLevel: get the context of execution of the given stackLevel.
* 0 for the current function
* 1 for the function that called 0
* 2 ....
* NB: if called from a C function called from LUA, remember that stackLevel 0 is the current function.
* Hence if you want to know what LUA context called you, pass stackLevel=1!
* \param ret string cleared if any error, else filled with formated FileName / LineNumber
*/
void getStackContext(std::string &ret, uint stackLevel);
// @}
// for debug : dump the current content of the stack (no recursion)
void dumpStack();
static void dumpStack(lua_State *ls);
void getStackAsString(std::string &dest);
private:
lua_State *_State;
#ifdef LUA_NEVRAX_VERSION
int _GCThreshold; // if refcounted gc is used, then garbage collector is handled manually
#endif
// Small Script Cache
uint _SmallScriptPool;
typedef std::map<std::string, uint> TSmallScriptCache;
TSmallScriptCache _SmallScriptCache;
static const char * _NELSmallScriptTableName;
private:
// this object isn't intended to be copied
CLuaState(const CLuaState &/* other */):NLMISC::CRefCount() { nlassert(0); }
CLuaState &operator=(const CLuaState &/* other */) { nlassert(0); return *this; }
void executeScriptInternal(const std::string &code, const std::string &dbgSrc, int numRet = 0);
int pcallByNameInternal(const char *functionName, int nargs, int nresults, int errfunc, int initialStackSize);
};
// Access to lua function
// one should not include lua.h directly because if a debugger is present, lua
// function pointer will be taken from a dynamic library.
//=============================================================================================
// include implementation
#define RZ_INCLUDE_LUA_HELPER_INLINE
#include "lua_helper_inline.h"
#undef RZ_INCLUDE_LUA_HELPER_INLINE
}
#endif

@ -42,10 +42,16 @@ inline void CLuaState::checkIndex(int index)
//H_AUTO(Lua_CLuaState_checkIndex)
// NB : more restrictive test that in the documentation there, because
// we don't expose the check stack function
#if LUA_VERSION_NUM >= 502
nlassert( (index!=0 && abs(index) <= getTop())
|| index == LUA_REGISTRYINDEX
);
#else
nlassert( (index!=0 && abs(index) <= getTop())
|| index == LUA_REGISTRYINDEX
|| index == LUA_GLOBALSINDEX
);
#endif
}
//================================================================================
@ -75,6 +81,18 @@ inline void CLuaState::setTop(int index)
lua_settop(_State, index);
}
//================================================================================
inline void CLuaState::pushGlobalTable()
{
//H_AUTO(Lua_CLuaState_pushGlobalTable)
#if LUA_VERSION_NUM >= 502
lua_pushglobaltable(_State);
#else
checkIndex(LUA_GLOBALSINDEX);
lua_pushvalue(_State, LUA_GLOBALSINDEX);
#endif
}
//================================================================================
inline void CLuaState::pushValue(int index)
{
@ -243,7 +261,11 @@ inline size_t CLuaState::strlen(int index)
{
//H_AUTO(Lua_CLuaState_strlen)
checkIndex(index);
#if LUA_VERSION_NUM >= 502
return lua_rawlen(_State, index);
#else
return lua_strlen(_State, index);
#endif
}
//================================================================================
@ -342,7 +364,11 @@ inline bool CLuaState::equal(int index1, int index2)
//H_AUTO(Lua_CLuaState_equal)
checkIndex(index1);
checkIndex(index2);
#if LUA_VERSION_NUM >= 502
return lua_compare(_State, index1, index2, LUA_OPEQ) != 0;
#else
return lua_equal(_State, index1, index2) != 0;
#endif
}
//================================================================================
@ -376,7 +402,11 @@ inline bool CLuaState::lessThan(int index1, int index2)
//H_AUTO(Lua_CLuaState_lessThan)
checkIndex(index1);
checkIndex(index2);
#if LUA_VERSION_NUM >= 502
return lua_compare(_State, index1, index2, LUA_OPLT) != 0;
#else
return lua_lessthan(_State, index1, index2) != 0;
#endif
}

@ -0,0 +1,193 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef NL_LUA_IHM_H
#define NL_LUA_IHM_H
#include "nel/misc/types_nl.h"
#include "nel/gui/lua_helper.h"
#include "nel/gui/interface_element.h"
#define IHM_LUA_METATABLE "__ui_metatable"
#define IHM_LUA_ENVTABLE "__ui_envtable"
namespace NLMISC
{
class CPolygon2D;
class CVector2f;
class CRGBA;
}
namespace NLGUI
{
class CReflectable;
class CReflectedProperty;
// ***************************************************************************
/* Use this Exception for all LUA Error (eg: scripted passes bad number of paramters).
* Does not herit from Exception because avoid nlinfo, because sent twice (catch then resent)
* This is special to lua and IHM since it works with CLuaStackChecker, and also append to the error msg
* the FileName/LineNumber
*/
class ELuaIHMException : public ELuaWrappedFunctionException
{
private:
static CLuaState *getLuaState();
public:
ELuaIHMException() : ELuaWrappedFunctionException(getLuaState())
{
}
ELuaIHMException(const std::string &reason) : ELuaWrappedFunctionException(getLuaState(), reason)
{
}
ELuaIHMException(const char *format, ...) : ELuaWrappedFunctionException(getLuaState())
{
std::string reason;
NLMISC_CONVERT_VARGS (reason, format, NLMISC::MaxCStringSize);
init(getLuaState(), reason);
}
};
// ***************************************************************************
/**
* Define Functions to export from C to LUA
* \author Lionel Berenguier
* \author Nevrax France
* \date 2004
*/
class CLuaIHM
{
public:
static void registerAll(CLuaState &ls);
/** CReflectableInterfaceElement management on stack, stored by a CRefPtr.
* May be called as well for ui element, because they derive from CReflectableRefPtrTarget
*/
static void pushReflectableOnStack(CLuaState &ls, class CReflectableRefPtrTarget *pRPT);
static bool isReflectableOnStack(CLuaState &ls, sint index);
static CReflectableRefPtrTarget *getReflectableOnStack(CLuaState &ls, sint index);
// ucstring
static bool pop(CLuaState &ls, ucstring &dest);
static void push(CLuaState &ls, const ucstring &value);
static bool isUCStringOnStack(CLuaState &ls, sint index);
static bool getUCStringOnStack(CLuaState &ls, sint index, ucstring &dest);
// RGBA
static bool pop(CLuaState &ls, NLMISC::CRGBA &dest);
// CVector2f
static bool pop(CLuaState &ls, NLMISC::CVector2f &dest);
// helper : get a 2D poly (a table of cvector2f) from a lua table (throw on fail)
static void getPoly2DOnStack(CLuaState &ls, sint index, NLMISC::CPolygon2D &dest);
// argument checkin helpers
static void checkArgCount(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is exactly the one required
static void checkArgMin(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at least the one required
static void checkArgMax(CLuaState &ls, const char* funcName, uint nArgs); // check that number of argument is at most the one required
static void check(CLuaState &ls, bool ok, const std::string &failReason);
static void checkArgType(CLuaState &ls, const char *funcName, uint index, int argType);
static void checkArgTypeRGBA(CLuaState &ls, const char *funcName, uint index);
static void checkArgTypeUCString(CLuaState &ls, const char *funcName, uint index);
/** throw a lua expection (inside a C function called from lua) with the given reason, and the current call stack
* The various check... function call this function when their test fails
*/
static void fails(CLuaState &ls, const char *format, ...);
// pop a sint32 from a lua stack, throw an exception on fail
static bool popSINT32(CLuaState &ls, sint32 & dest);
bool popString(CLuaState &ls, std::string & dest);
/** read/write between values on a lua stack & a property exported from a 'CReflectable' derived object
* (throws on error)
*/
static void luaValueToReflectedProperty(CLuaState &ls, int stackIndex, CReflectable &target, const CReflectedProperty &property) throw(ELuaIHMException);
// push a reflected property on the stack
// NB : no check is done that 'property' is part of the class info of 'reflectedObject'
static void luaValueFromReflectedProperty(CLuaState &ls, CReflectable &reflectedObject, const CReflectedProperty &property);
private:
// Functions for the ui metatable
static class CInterfaceElement* getUIRelative( CInterfaceElement *pIE, const std::string &propName );
static int luaUIIndex( CLuaState &ls );
static int luaUINewIndex( CLuaState &ls );
static int luaUIEq( CLuaState &ls );
static int luaUINext( CLuaState &ls );
static int luaUIDtor( CLuaState &ls );
static void registerBasics(CLuaState &ls);
static void registerIHM(CLuaState &ls);
static void createLuaEnumTable(CLuaState &ls, const std::string &str);
public:
static void pushUIOnStack(CLuaState &ls, CInterfaceElement *pIE);
static bool isUIOnStack(CLuaState &ls, sint index);
static CInterfaceElement *getUIOnStack(CLuaState &ls, sint index);
static void checkArgTypeUIElement(CLuaState &ls, const char *funcName, uint index);
private:
//////////////////////////////////////////// Exported functions //////////////////////////////////////////////////////
static uint32 getLocalTime();
static double getPreciseLocalTime();
static std::string findReplaceAll(const std::string &str, const std::string &search, const std::string &replace);
static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const ucstring &replace);
static ucstring findReplaceAll(const ucstring &str, const std::string &search, const std::string &replace);
static ucstring findReplaceAll(const ucstring &str, const std::string &search, const ucstring &replace);
static ucstring findReplaceAll(const ucstring &str, const ucstring &search, const std::string &replace);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static int luaMethodCall(lua_State *ls);
static int setOnDraw(CLuaState &ls); // params: CInterfaceGroup*, "script". return: none
static int addOnDbChange(CLuaState &ls); // params: CInterfaceGroup*, "dblist", "script". return: none
static int removeOnDbChange(CLuaState &ls);// params: CInterfaceGroup*. return: none
static int setCaptureKeyboard(CLuaState &ls);
static int resetCaptureKeyboard(CLuaState &ls);
static int getUIId(CLuaState &ls); // params: CInterfaceElement*. return: ui id (empty if error)
static int runAH(CLuaState &ls); // params: CInterfaceElement *, "ah", "params". return: none
static int getWindowSize(CLuaState &ls);
static int setTopWindow(CLuaState &ls); // set the top window
static int getTextureSize(CLuaState &ls);
static int disableModalWindow(CLuaState &ls);
static int deleteUI(CLuaState &ls); // params: CInterfaceElement*.... return: none
static int deleteReflectable(CLuaState &ls); // params: CInterfaceElement*.... return: none
static int getCurrentWindowUnder(CLuaState &ls); // params: none. return: CInterfaceElement* (nil if none)
static bool fileExists(const std::string &fileName);
static int runExprAndPushResult(CLuaState &ls, const std::string &expr); // Used by runExpr and runFct
static int runExpr(CLuaState &ls); // params: "expr". return: any of: nil,bool,string,number, RGBA, UCString
static int runFct(CLuaState &ls); // params: "expr", param1, param2.... return: any of: nil,bool,string,number, RGBA, UCString
static int runCommand(CLuaState &ls); // params: "command name", param1, param2 ... return true or false
static int isUCString(CLuaState &ls);
static int concatUCString(CLuaState &ls); // workaround for + operator that don't work in luabind for ucstrings ...
static int concatString(CLuaState &ls); // speedup concatenation of several strings
static int tableToString(CLuaState &ls); // concat element of a table to build a string
static int getPathContent(CLuaState &ls);
};
}
#endif // NL_LUA_IHM_H
/* End of lua_ihm.h */

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

Loading…
Cancel
Save