Merge branch 'sdl_android' of github.com:pelya/commandergenius into sdl_android
This commit is contained in:
24
build.sh
24
build.sh
@@ -84,20 +84,36 @@ rm -r -f project/bin/* # New Android SDK introduced some lame-ass optimizations
|
||||
|
||||
cd project && env PATH=$NDKBUILDPATH BUILD_NUM_CPUS=$NCPU nice -n19 ndk-build -j$NCPU V=1 && \
|
||||
{ grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
echo Stripping libapplication.so by hand && \
|
||||
echo Stripping libapplication-armeabi.so by hand && \
|
||||
rm obj/local/armeabi/libapplication.so && \
|
||||
cp jni/application/src/libapplication.so obj/local/armeabi/ && \
|
||||
cp jni/application/src/libapplication.so libs/armeabi/ && \
|
||||
cp jni/application/src/libapplication-armeabi.so obj/local/armeabi/libapplication.so && \
|
||||
cp jni/application/src/libapplication-armeabi.so libs/armeabi/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi/libapplication.so \
|
||||
|| true ; } && \
|
||||
{ grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "y\\|armeabi-v7a" > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "y\\|all\\|armeabi-v7a" > /dev/null && \
|
||||
echo Stripping libapplication-armeabi-v7a.so by hand && \
|
||||
rm obj/local/armeabi-v7a/libapplication.so && \
|
||||
cp jni/application/src/libapplication-armeabi-v7a.so obj/local/armeabi-v7a/libapplication.so && \
|
||||
cp jni/application/src/libapplication-armeabi-v7a.so libs/armeabi-v7a/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.6/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi-v7a/libapplication.so \
|
||||
|| true ; } && \
|
||||
{ grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "all\\|mips" > /dev/null && \
|
||||
echo Stripping libapplication-mips.so by hand && \
|
||||
rm obj/local/mips/libapplication.so && \
|
||||
cp jni/application/src/libapplication-mips.so obj/local/mips/libapplication.so && \
|
||||
cp jni/application/src/libapplication-mips.so libs/mips/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/mipsel-linux-android-4.6/prebuilt/$MYARCH/bin/mipsel-linux-android-strip --strip-unneeded libs/mips/libapplication.so \
|
||||
|| true ; } && \
|
||||
{ grep "CustomBuildScript=y" ../AndroidAppSettings.cfg > /dev/null && \
|
||||
grep "MultiABI=" ../AndroidAppSettings.cfg | grep "all\\|x86" > /dev/null && \
|
||||
echo Stripping libapplication-x86.so by hand && \
|
||||
rm obj/local/x86/libapplication.so && \
|
||||
cp jni/application/src/libapplication-x86.so obj/local/x86/libapplication.so && \
|
||||
cp jni/application/src/libapplication-x86.so libs/x86/libapplication.so && \
|
||||
`which ndk-build | sed 's@/ndk-build@@'`/toolchains/x86-4.6/prebuilt/$MYARCH/bin/i686-linux-android-strip --strip-unneeded libs/x86/libapplication.so \
|
||||
|| true ; } && \
|
||||
cd .. && ./copyAssets.sh && cd project && \
|
||||
{ if $build_release ; then \
|
||||
ant release || exit 1 ; \
|
||||
|
||||
@@ -4,16 +4,5 @@ include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := android
|
||||
|
||||
ifneq ($(NDK_R5_TOOLCHAIN),)
|
||||
LOCAL_SRC_FILES := lib$(LOCAL_MODULE).so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
else
|
||||
LOCAL_SRC_FILES := dummy.c
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
$(abspath $(LOCAL_PATH)/../../obj/local/armeabi/lib$(LOCAL_MODULE).a): $(LOCAL_PATH)/lib$(LOCAL_MODULE).a OVERRIDE_CUSTOM_LIB
|
||||
cp -f $< $@
|
||||
$(abspath $(LOCAL_PATH)/../../obj/local/armeabi-v7a/lib$(LOCAL_MODULE).a): $(LOCAL_PATH)/lib$(LOCAL_MODULE).a OVERRIDE_CUSTOM_LIB
|
||||
cp -f $< $@
|
||||
.PHONY: OVERRIDE_CUSTOM_LIB
|
||||
OVERRIDE_CUSTOM_LIB:
|
||||
endif
|
||||
|
||||
@@ -50,53 +50,14 @@ LOCAL_STATIC_LIBRARIES := $(filter $(APP_AVAILABLE_STATIC_LIBS), $(COMPILED_LIBR
|
||||
|
||||
APP_STL := gnustl_static
|
||||
|
||||
#LOCAL_STATIC_LIBRARIES += gnustl_static
|
||||
|
||||
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog -lz # -lgnustl_static
|
||||
|
||||
LOCAL_LDFLAGS := -Lobj/local/armeabi
|
||||
LOCAL_LDFLAGS := -Lobj/local/$(TARGET_ARCH_ABI)
|
||||
|
||||
|
||||
LOCAL_LDFLAGS += $(APPLICATION_ADDITIONAL_LDFLAGS)
|
||||
|
||||
#ifneq ($NDK_R8B_TOOLCHAIN,) # They've changed the path, yet again
|
||||
#LOCAL_C_INCLUDES += $(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/include $(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/include
|
||||
#LOCAL_LDLIBS += -L$(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/$(NDK_TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI) -lgnustl_static
|
||||
#else
|
||||
ifneq ($(NDK_R7_TOOLCHAIN)$(CRYSTAX_R7_TOOLCHAIN),) # NDK r7 broke it even more
|
||||
#LOCAL_C_INCLUDES += $(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/include
|
||||
#LOCAL_LDLIBS += -L$(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/libs/$(TARGET_ARCH_ABI) -lgnustl_static
|
||||
# You can have multiple C++ file extensions starting from NDK r7
|
||||
LOCAL_CPP_EXTENSION := .cpp .cxx .cc
|
||||
else
|
||||
ifneq ($(NDK_R6_TOOLCHAIN),) # NDK r6 broke it
|
||||
LOCAL_C_INCLUDES += $(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/include
|
||||
LOCAL_LDLIBS += -L$(NDK_PATH)/sources/cxx-stl/gnu-libstdc++/libs/$(TARGET_ARCH_ABI) -lstdc++
|
||||
endif
|
||||
endif
|
||||
#endif
|
||||
|
||||
#LIBS_WITH_LONG_SYMBOLS := $(strip $(shell \
|
||||
# for f in $(LOCAL_PATH)/../../obj/local/armeabi/*.so ; do \
|
||||
# if echo $$f | grep "libapplication[.]so" > /dev/null ; then \
|
||||
# continue ; \
|
||||
# fi ; \
|
||||
# if [ -e "$$f" ] ; then \
|
||||
# if nm -g $$f | cut -c 12- | egrep '.{128}' > /dev/null ; then \
|
||||
# echo $$f | grep -o 'lib[^/]*[.]so' ; \
|
||||
# fi ; \
|
||||
# fi ; \
|
||||
# done \
|
||||
#) )
|
||||
#
|
||||
#ifneq "$(LIBS_WITH_LONG_SYMBOLS)" ""
|
||||
#$(foreach F, $(LIBS_WITH_LONG_SYMBOLS), \
|
||||
#$(info Library $(F): abusing symbol names are: \
|
||||
#$(shell nm -g $(LOCAL_PATH)/../../obj/local/armeabi/$(F) | cut -c 12- | egrep '.{128}' ) ) \
|
||||
#$(info Library $(F) contains symbol names longer than 128 bytes, \
|
||||
#YOUR CODE WILL DEADLOCK WITHOUT ANY WARNING when you'll access such function - \
|
||||
#please make this library static to avoid problems. ) )
|
||||
#$(error Detected libraries with too long symbol names. Remove all files under project/obj/local/armeabi, make these libs static, and recompile)
|
||||
#endif
|
||||
|
||||
SDL_APP_LIB_DEPENDS := $(LOCAL_PATH)/src/AndroidBuild.sh $(LOCAL_PATH)/src/AndroidAppSettings.cfg
|
||||
SDL_APP_LIB_DEPENDS += $(foreach LIB, $(LOCAL_SHARED_LIBRARIES), obj/local/$(TARGET_ARCH_ABI)/lib$(LIB).so)
|
||||
@@ -111,21 +72,30 @@ ifneq ($(APPLICATION_CUSTOM_BUILD_SCRIPT),)
|
||||
# Also I cannot just launch AndroidBuild.sh from makefile because other libraries are not rebuilt and linking will fail
|
||||
.PHONY: OVERRIDE_CUSTOM_LIB
|
||||
OVERRIDE_CUSTOM_LIB:
|
||||
# Prevent ./AndroidBuild.sh to be invoked in parallel for different architectures, it may do things like downloading files which work poorly when launched in parallel
|
||||
.NOTPARALLEL: $(LOCAL_PATH)/src/libapplication-armeabi.so $(LOCAL_PATH)/src/libapplication-armeabi-v7a.so $(LOCAL_PATH)/src/libapplication-mips.so $(LOCAL_PATH)/src/libapplication-x86.so
|
||||
|
||||
LOCAL_PATH_SDL_APPLICATION := $(LOCAL_PATH)
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi)
|
||||
obj/local/armeabi/libapplication.so: $(LOCAL_PATH)/src/libapplication.so
|
||||
obj/local/armeabi/libapplication.so: $(LOCAL_PATH)/src/libapplication-armeabi.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication.so: $(SDL_APP_LIB_DEPENDS) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && ./AndroidBuild.sh armeabi
|
||||
endif
|
||||
$(LOCAL_PATH)/src/libapplication-armeabi.so: $(SDL_APP_LIB_DEPENDS) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && ./AndroidBuild.sh armeabi arm-linux-androideabi && \
|
||||
{ [ -e libapplication.so ] && ln -s libapplication.so libapplication-armeabi.so || true ; }
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
obj/local/armeabi-v7a/libapplication.so: $(LOCAL_PATH)/src/libapplication-armeabi-v7a.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-armeabi-v7a.so: $(SDL_APP_LIB_DEPENDS) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && ./AndroidBuild.sh armeabi-v7a
|
||||
endif
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && ./AndroidBuild.sh armeabi-v7a arm-linux-androideabi
|
||||
|
||||
endif
|
||||
obj/local/mips/libapplication.so: $(LOCAL_PATH)/src/libapplication-mips.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-mips.so: $(SDL_APP_LIB_DEPENDS) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && ./AndroidBuild.sh mips mipsel-linux-android
|
||||
|
||||
obj/local/x86/libapplication.so: $(LOCAL_PATH)/src/libapplication-x86.so
|
||||
|
||||
$(LOCAL_PATH)/src/libapplication-x86.so: $(SDL_APP_LIB_DEPENDS) OVERRIDE_CUSTOM_LIB
|
||||
cd $(LOCAL_PATH_SDL_APPLICATION)/src && ./AndroidBuild.sh x86 i686-linux-android
|
||||
|
||||
endif # $(APPLICATION_CUSTOM_BUILD_SCRIPT)
|
||||
|
||||
@@ -166,7 +166,7 @@ FirstStartMenuOptions=''
|
||||
|
||||
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
|
||||
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
|
||||
MultiABI=y
|
||||
MultiABI=all
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=0
|
||||
|
||||
@@ -1,53 +1,233 @@
|
||||
# The application settings for Android libSDL port
|
||||
AppSettingVersion=17
|
||||
|
||||
AppSettingVersion=19
|
||||
|
||||
# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2)
|
||||
LibSdlVersion=1.2
|
||||
|
||||
# Specify application name (e.x. My Application)
|
||||
AppName="DosBox"
|
||||
|
||||
# Specify reversed site name of application (e.x. com.mysite.myapp)
|
||||
AppFullName=com.dosbox.sdl
|
||||
|
||||
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
|
||||
ScreenOrientation=h
|
||||
|
||||
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
|
||||
InhibitSuspend=y
|
||||
|
||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
|
||||
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by build system
|
||||
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
|
||||
AppDataDownloadUrl="Data size is 1 Mb|dosbox-data.zip"
|
||||
|
||||
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
|
||||
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
|
||||
VideoDepthBpp=16
|
||||
|
||||
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedDepthBuffer=n
|
||||
|
||||
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedStencilBuffer=n
|
||||
|
||||
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles2=n
|
||||
|
||||
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
|
||||
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
|
||||
SwVideoMode=y
|
||||
|
||||
# Application video output will be resized to fit into native device screen (y)/(n)
|
||||
SdlVideoResize=y
|
||||
|
||||
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
|
||||
SdlVideoResizeKeepAspect=n
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
|
||||
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
|
||||
CompatibilityHacks=n
|
||||
|
||||
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
|
||||
CompatibilityHacksStaticInit=n
|
||||
|
||||
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
|
||||
CompatibilityHacksTextInputEmulatesHwKeyboard=n
|
||||
|
||||
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
|
||||
CompatibilityHacksPreventAudioChopping=n
|
||||
|
||||
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
|
||||
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
||||
|
||||
# Hack for VCMI: preload additional shared libraries before aplication start
|
||||
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
|
||||
|
||||
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
|
||||
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
|
||||
CompatibilityHacksSlowCompatibleEventQueue=n
|
||||
|
||||
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
|
||||
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
|
||||
|
||||
# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects.
|
||||
# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n)
|
||||
CompatibilityHacksProperUsageOfSDL_UpdateRects=
|
||||
|
||||
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
|
||||
AppUsesMouse=y
|
||||
|
||||
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
|
||||
AppNeedsTwoButtonMouse=y
|
||||
|
||||
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
|
||||
ShowMouseCursor=n
|
||||
|
||||
# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)
|
||||
GenerateSubframeTouchEvents=
|
||||
|
||||
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
|
||||
ForceRelativeMouseMode=n
|
||||
|
||||
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
|
||||
AppNeedsArrowKeys=y
|
||||
|
||||
# Application needs text input (y) or (n), enables button for text input on screen
|
||||
AppNeedsTextInput=y
|
||||
|
||||
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
|
||||
AppUsesJoystick=n
|
||||
|
||||
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
|
||||
AppUsesSecondJoystick=n
|
||||
|
||||
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
|
||||
AppUsesAccelerometer=n
|
||||
|
||||
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
|
||||
AppUsesGyroscope=n
|
||||
|
||||
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
|
||||
AppUsesMultitouch=n
|
||||
|
||||
# Application records audio (it will use any available source, such a s microphone)
|
||||
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
|
||||
# This option will add additional permission to Android manifest (y)/(n)
|
||||
AppRecordsAudio=n
|
||||
|
||||
# Application implements Android-specific routines to put to background, and will not draw anything to screen
|
||||
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
|
||||
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
|
||||
# This option is reported to be buggy, sometimes failing to restore video state
|
||||
NonBlockingSwapBuffers=n
|
||||
|
||||
# Redefine common hardware keys to SDL keysyms
|
||||
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
|
||||
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
|
||||
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
|
||||
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
|
||||
RedefinedKeys="SPACE RETURN NO_REMAP NO_REMAP RETURN ESCAPE"
|
||||
|
||||
# Number of virtual keyboard keys (currently 6 is maximum)
|
||||
AppTouchscreenKeyboardKeysAmount=1
|
||||
|
||||
# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
|
||||
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
|
||||
RedefinedKeysScreenKb="RETURN"
|
||||
|
||||
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
|
||||
RedefinedKeysScreenKbNames="RETURN"
|
||||
|
||||
# On-screen keys theme
|
||||
# 0 = Ultimate Droid by Sean Stieber (green, with gamepad joystick)
|
||||
# 1 = Simple Theme by Beholder (white, with gamepad joystick)
|
||||
# 2 = Sun by Sirea (yellow, with round joystick)
|
||||
# 3 = Keen by Gerstrong (multicolor, with round joystick)
|
||||
TouchscreenKeysTheme=1
|
||||
|
||||
# Redefine gamepad keys to SDL keysyms, button order is:
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb
|
||||
RedefinedKeysGamepad="RETURN"
|
||||
|
||||
# How long to show startup menu button, in msec, 0 to disable startup menu
|
||||
StartupMenuButtonTimeout=3000
|
||||
HiddenMenuOptions='OptionalDownloadConfig'
|
||||
|
||||
# Menu items to hide from startup menu, available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
|
||||
HiddenMenuOptions='SettingsMenuMisc.OptionalDownloadConfig'
|
||||
|
||||
# Menu items to show at startup - this is Java code snippet, leave empty for default
|
||||
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
|
||||
# Available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
|
||||
FirstStartMenuOptions=''
|
||||
MultiABI=n
|
||||
|
||||
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
|
||||
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
|
||||
MultiABI=all
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=0
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=07403
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="0.74.03"
|
||||
|
||||
# Reset SDL config when updating application to the new version (y) / (n)
|
||||
ResetSdlConfigForThisVersion=y
|
||||
|
||||
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
|
||||
DeleteFilesOnUpgrade="%"
|
||||
|
||||
# Optional shared libraries to compile - removing some of them will save space
|
||||
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
|
||||
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
|
||||
CompiledLibraries="jpeg png sdl_mixer sdl_net sdl_sound"
|
||||
|
||||
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
|
||||
CustomBuildScript=y
|
||||
|
||||
# Aditional CFLAGS for application
|
||||
AppCflags=''
|
||||
|
||||
# Additional LDFLAGS for application
|
||||
AppLdflags=''
|
||||
|
||||
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
|
||||
AppOverlapsSystemHeaders=
|
||||
|
||||
# Build only following subdirs (empty will build all dirs, ignored with custom script)
|
||||
AppSubdirsBuild=''
|
||||
|
||||
# Exclude these files from build
|
||||
AppBuildExclude=''
|
||||
|
||||
# Application command line parameters, including app name as 0-th param
|
||||
AppCmdline='dosbox'
|
||||
|
||||
# Here you may type readme text, which will be shown during startup. Format is:
|
||||
# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?)
|
||||
ReadmeText='^You may press "Home" now - the data will be downloaded in background'
|
||||
|
||||
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
|
||||
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
|
||||
MinimumScreenSize=s
|
||||
|
||||
# Your AdMob Publisher ID, (n) if you don't want advertisements
|
||||
AdmobPublisherId=n
|
||||
|
||||
# Your AdMob test device ID, to receive a test ad
|
||||
AdmobTestDeviceId=
|
||||
|
||||
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
|
||||
AdmobBannerSize=
|
||||
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
#!/bin/sh
|
||||
|
||||
ln -sf libsdl-1.2.so ../../../obj/local/$1/libSDL.so
|
||||
ln -sf libsdl_net.so ../../../obj/local/$1/libSDL_net.so
|
||||
ln -sf libsdl_sound.so ../../../obj/local/$1/libSDL_sound.so
|
||||
|
||||
LOCAL_PATH=`dirname $0`
|
||||
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
|
||||
[ -e $1/dosbox-0.74 ] || {
|
||||
mkdir -p $1
|
||||
cd $1 && curl -L http://sourceforge.net/projects/dosbox/files/dosbox/0.74/dosbox-0.74.tar.gz | tar xvz && patch -p0 < ../dosbox-0.74-androidSDL.diff && cd .. || exit 1
|
||||
} || exit 1
|
||||
|
||||
ln -sf libsdl-1.2.so $LOCAL_PATH/../../../obj/local/armeabi/libSDL.so
|
||||
ln -sf libsdl_net.so $LOCAL_PATH/../../../obj/local/armeabi/libSDL_net.so
|
||||
ln -sf libsdl_sound.so $LOCAL_PATH/../../../obj/local/armeabi/libSDL_sound.so
|
||||
|
||||
if [ \! -d dosbox-0.74 ] ; then
|
||||
wget http://sourceforge.net/projects/dosbox/files/dosbox/0.74/dosbox-0.74.tar.gz && tar xvf dosbox-0.74.tar.gz && patch -p0 < dosbox-0.74-androidSDL.diff || exit 1
|
||||
fi
|
||||
|
||||
if [ \! -f dosbox-0.74/configure ] ; then
|
||||
sh -c "cd dosbox-0.74 && ./autogen.sh" || exit 1
|
||||
fi
|
||||
|
||||
if [ \! -f dosbox-0.74/Makefile ] ; then
|
||||
[ -e $1/dosbox-0.74/Makefile ] || {
|
||||
sh -c "cd $1/dosbox-0.74 && ./autogen.sh" || exit 1
|
||||
env CFLAGS="-frtti -fexceptions" LDFLAGS="-frtti -fexceptions" \
|
||||
../setEnvironment.sh sh -c "cd dosbox-0.74 && ./configure --build=x86_64-unknown-linux-gnu --host=arm-linux-androideabi" || exit 1
|
||||
fi
|
||||
../setEnvironment-$1.sh sh -c "cd $1/dosbox-0.74 && ./configure --build=x86_64-unknown-linux-gnu --host=$2" || exit 1
|
||||
} || exit 1
|
||||
|
||||
../setEnvironment.sh sh -c "cd dosbox-0.74 && make -j4 VERBOSE=1 STRIP='' LIBS='-lsdl-1.2 -lpng -lgcc -lz -lc -lgnustl_static -lsupc++'" && cp -f dosbox-0.74/src/dosbox libapplication.so || exit 1
|
||||
../setEnvironment-$1.sh sh -c "cd $1/dosbox-0.74 && make -j4 VERBOSE=1 STRIP='' LIBS='-lsdl-1.2 -lpng -lgcc -lz -lc -lgnustl_static -lsupc++'" && cp -f $1/dosbox-0.74/src/dosbox libapplication-$1.so || exit 1
|
||||
exit 0
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
Build instructions
|
||||
|
||||
unpack dosbox-0.74-cfg-pelyaSDL.tar.gz into ~/commandergenius/project/jni/application
|
||||
Download http://sourceforge.net/projects/dosbox/files/dosbox/0.74/dosbox-0.74.tar.gz/download
|
||||
unpack dosbox-0.74.tar.gz into ~/commandergenius/project/jni/application/dosbox
|
||||
apply patch dosbox-0.74-androidSDL.diff
|
||||
|
||||
cd ~/commandergenius/project/jni/application
|
||||
rm src
|
||||
ln -s dosbox src
|
||||
cd ~/commandergenius
|
||||
./build.sh
|
||||
@@ -1,18 +1,18 @@
|
||||
diff -r -u old/dosbox-0.74/config.sub dosbox-0.74/config.sub
|
||||
--- old/dosbox-0.74/config.sub 2010-05-10 20:43:54.000000000 +0300
|
||||
+++ dosbox-0.74/config.sub 2012-11-21 21:14:48.428064682 +0200
|
||||
diff -u -r ../dosbox-0.74/config.sub dosbox-0.74/config.sub
|
||||
--- ../dosbox-0.74/config.sub 2010-05-10 20:43:54.000000000 +0300
|
||||
+++ dosbox-0.74/config.sub 2013-11-28 19:20:33.285066723 +0200
|
||||
@@ -1298,7 +1298,7 @@
|
||||
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
|
||||
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
- | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
+ | -udi* | -eabi* | -androideabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
+ | -udi* | -eabi* | -android* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -chorusos* | -chorusrdb* | -cegcc* \
|
||||
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
|
||||
diff -r -u old/dosbox-0.74/src/dos/drive_local.cpp dosbox-0.74/src/dos/drive_local.cpp
|
||||
--- old/dosbox-0.74/src/dos/drive_local.cpp 2010-05-10 20:43:54.000000000 +0300
|
||||
+++ dosbox-0.74/src/dos/drive_local.cpp 2012-11-21 21:14:48.428064682 +0200
|
||||
diff -u -r ../dosbox-0.74/src/dos/drive_local.cpp dosbox-0.74/src/dos/drive_local.cpp
|
||||
--- ../dosbox-0.74/src/dos/drive_local.cpp 2010-05-10 20:43:54.000000000 +0300
|
||||
+++ dosbox-0.74/src/dos/drive_local.cpp 2013-11-28 19:20:33.285066723 +0200
|
||||
@@ -273,7 +273,7 @@
|
||||
|
||||
find_size=(Bit32u) stat_block.st_size;
|
||||
@@ -40,9 +40,9 @@ diff -r -u old/dosbox-0.74/src/dos/drive_local.cpp dosbox-0.74/src/dos/drive_loc
|
||||
time=DOS_PackTime((Bit16u)ltime->tm_hour,(Bit16u)ltime->tm_min,(Bit16u)ltime->tm_sec);
|
||||
date=DOS_PackDate((Bit16u)(ltime->tm_year+1900),(Bit16u)(ltime->tm_mon+1),(Bit16u)ltime->tm_mday);
|
||||
} else {
|
||||
diff -r -u old/dosbox-0.74/src/gui/sdlmain.cpp dosbox-0.74/src/gui/sdlmain.cpp
|
||||
--- old/dosbox-0.74/src/gui/sdlmain.cpp 2010-05-10 20:43:54.000000000 +0300
|
||||
+++ dosbox-0.74/src/gui/sdlmain.cpp 2012-11-21 21:51:37.128044459 +0200
|
||||
diff -u -r ../dosbox-0.74/src/gui/sdlmain.cpp dosbox-0.74/src/gui/sdlmain.cpp
|
||||
--- ../dosbox-0.74/src/gui/sdlmain.cpp 2010-05-10 20:43:54.000000000 +0300
|
||||
+++ dosbox-0.74/src/gui/sdlmain.cpp 2013-11-28 19:23:09.782280538 +0200
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <signal.h>
|
||||
#include <process.h>
|
||||
@@ -68,6 +68,15 @@ diff -r -u old/dosbox-0.74/src/gui/sdlmain.cpp dosbox-0.74/src/gui/sdlmain.cpp
|
||||
}
|
||||
|
||||
|
||||
@@ -1529,7 +1531,7 @@
|
||||
if ( !sdl.inited && SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0 ) textonly = true;
|
||||
sdl.inited = true;
|
||||
#endif
|
||||
- printf(message);
|
||||
+ printf("%s", message);
|
||||
if(textonly) return;
|
||||
if(!sdl.surface) sdl.surface = SDL_SetVideoMode(640,400,0,0);
|
||||
if(!sdl.surface) return;
|
||||
@@ -1743,8 +1745,7 @@
|
||||
#if SDL_VERSION_ATLEAST(1, 2, 14)
|
||||
putenv(const_cast<char*>("SDL_DISABLE_LOCK_KEYS=1"));
|
||||
@@ -78,3 +87,15 @@ diff -r -u old/dosbox-0.74/src/gui/sdlmain.cpp dosbox-0.74/src/gui/sdlmain.cpp
|
||||
) < 0 ) E_Exit("Can't init SDL %s",SDL_GetError());
|
||||
sdl.inited = true;
|
||||
|
||||
diff -u ../dosbox-0.74/src/cpu/core_dyn_x86/risc_x86.h dosbox-0.74/src/cpu/core_dyn_x86/risc_x86.h
|
||||
--- ../dosbox-0.74/src/cpu/core_dyn_x86/risc_x86.h 2010-05-10 20:43:54.000000000 +0300
|
||||
+++ dosbox-0.74/src/cpu/core_dyn_x86/risc_x86.h 2013-11-28 19:54:35.678624476 +0200
|
||||
@@ -112,7 +112,7 @@
|
||||
pop ebx
|
||||
mov [retval],eax
|
||||
}
|
||||
-#elif defined (MACOSX)
|
||||
+#elif defined (MACOSX) || defined(__ANDROID__)
|
||||
register Bit32u tempflags=reg_flags & FMASK_TEST;
|
||||
__asm__ volatile (
|
||||
"pushl %%ebx \n"
|
||||
|
||||
233
project/jni/application/guichan-widgets/AndroidAppSettings.cfg
Normal file
233
project/jni/application/guichan-widgets/AndroidAppSettings.cfg
Normal file
@@ -0,0 +1,233 @@
|
||||
# The application settings for Android libSDL port
|
||||
|
||||
AppSettingVersion=19
|
||||
|
||||
# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2)
|
||||
LibSdlVersion=1.2
|
||||
|
||||
# Specify application name (e.x. My Application)
|
||||
AppName="GuiChan"
|
||||
|
||||
# Specify reversed site name of application (e.x. com.mysite.myapp)
|
||||
AppFullName=com.guichan.sdl
|
||||
|
||||
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
|
||||
ScreenOrientation=h
|
||||
|
||||
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
|
||||
InhibitSuspend=n
|
||||
|
||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
|
||||
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by build system
|
||||
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
|
||||
AppDataDownloadUrl="data file|files.zip"
|
||||
|
||||
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
|
||||
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
|
||||
VideoDepthBpp=16
|
||||
|
||||
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedDepthBuffer=n
|
||||
|
||||
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedStencilBuffer=n
|
||||
|
||||
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles2=n
|
||||
|
||||
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
|
||||
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
|
||||
SwVideoMode=y
|
||||
|
||||
# Application video output will be resized to fit into native device screen (y)/(n)
|
||||
SdlVideoResize=y
|
||||
|
||||
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
|
||||
SdlVideoResizeKeepAspect=n
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
|
||||
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
|
||||
CompatibilityHacks=n
|
||||
|
||||
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
|
||||
CompatibilityHacksStaticInit=n
|
||||
|
||||
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
|
||||
CompatibilityHacksTextInputEmulatesHwKeyboard=y
|
||||
|
||||
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
|
||||
CompatibilityHacksPreventAudioChopping=n
|
||||
|
||||
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
|
||||
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
||||
|
||||
# Hack for VCMI: preload additional shared libraries before aplication start
|
||||
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
|
||||
|
||||
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
|
||||
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
|
||||
CompatibilityHacksSlowCompatibleEventQueue=n
|
||||
|
||||
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
|
||||
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
|
||||
|
||||
# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects.
|
||||
# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n)
|
||||
CompatibilityHacksProperUsageOfSDL_UpdateRects=
|
||||
|
||||
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
|
||||
AppUsesMouse=y
|
||||
|
||||
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
|
||||
AppNeedsTwoButtonMouse=y
|
||||
|
||||
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
|
||||
ShowMouseCursor=n
|
||||
|
||||
# Generate more touch events, by default SDL generates one event per one video frame, this is useful for drawing apps (y) or (n)
|
||||
GenerateSubframeTouchEvents=
|
||||
|
||||
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
|
||||
ForceRelativeMouseMode=n
|
||||
|
||||
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
|
||||
AppNeedsArrowKeys=n
|
||||
|
||||
# Application needs text input (y) or (n), enables button for text input on screen
|
||||
AppNeedsTextInput=y
|
||||
|
||||
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
|
||||
AppUsesJoystick=n
|
||||
|
||||
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
|
||||
AppUsesSecondJoystick=n
|
||||
|
||||
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
|
||||
AppUsesAccelerometer=n
|
||||
|
||||
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
|
||||
AppUsesGyroscope=n
|
||||
|
||||
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
|
||||
AppUsesMultitouch=n
|
||||
|
||||
# Application records audio (it will use any available source, such a s microphone)
|
||||
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
|
||||
# This option will add additional permission to Android manifest (y)/(n)
|
||||
AppRecordsAudio=n
|
||||
|
||||
# Application implements Android-specific routines to put to background, and will not draw anything to screen
|
||||
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
|
||||
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
|
||||
# This option is reported to be buggy, sometimes failing to restore video state
|
||||
NonBlockingSwapBuffers=y
|
||||
|
||||
# Redefine common hardware keys to SDL keysyms
|
||||
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
|
||||
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
|
||||
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
|
||||
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
|
||||
RedefinedKeys="SPACE"
|
||||
|
||||
# Number of virtual keyboard keys (currently 6 is maximum)
|
||||
AppTouchscreenKeyboardKeysAmount=0
|
||||
|
||||
# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
|
||||
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
|
||||
RedefinedKeysScreenKb="1 2 3 4 5 6 1 2 3 4"
|
||||
|
||||
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
|
||||
RedefinedKeysScreenKbNames="1 2 3 4 5 6 1 2 3 4"
|
||||
|
||||
# On-screen keys theme
|
||||
# 0 = Ultimate Droid by Sean Stieber (green, with gamepad joystick)
|
||||
# 1 = Simple Theme by Beholder (white, with gamepad joystick)
|
||||
# 2 = Sun by Sirea (yellow, with round joystick)
|
||||
# 3 = Keen by Gerstrong (multicolor, with round joystick)
|
||||
TouchscreenKeysTheme=2
|
||||
|
||||
# Redefine gamepad keys to SDL keysyms, button order is:
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb
|
||||
RedefinedKeysGamepad="1 2 3 4 5 6 1 2 3 4"
|
||||
|
||||
# How long to show startup menu button, in msec, 0 to disable startup menu
|
||||
StartupMenuButtonTimeout=3000
|
||||
|
||||
# Menu items to hide from startup menu, available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
|
||||
HiddenMenuOptions=''
|
||||
|
||||
# Menu items to show at startup - this is Java code snippet, leave empty for default
|
||||
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
|
||||
# Available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
|
||||
FirstStartMenuOptions=''
|
||||
|
||||
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
|
||||
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
|
||||
MultiABI=all
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=256
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=101
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="1.01"
|
||||
|
||||
# Reset SDL config when updating application to the new version (y) / (n)
|
||||
ResetSdlConfigForThisVersion=n
|
||||
|
||||
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
|
||||
DeleteFilesOnUpgrade="%"
|
||||
|
||||
# Optional shared libraries to compile - removing some of them will save space
|
||||
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
|
||||
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
|
||||
CompiledLibraries="sdl_image guichan"
|
||||
|
||||
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
|
||||
CustomBuildScript=n
|
||||
|
||||
# Aditional CFLAGS for application
|
||||
AppCflags='-Wall -Wno-unused'
|
||||
|
||||
# Additional LDFLAGS for application
|
||||
AppLdflags=''
|
||||
|
||||
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
|
||||
AppOverlapsSystemHeaders=
|
||||
|
||||
# Build only following subdirs (empty will build all dirs, ignored with custom script)
|
||||
AppSubdirsBuild=''
|
||||
|
||||
# Exclude these files from build
|
||||
AppBuildExclude=''
|
||||
|
||||
# Application command line parameters, including app name as 0-th param
|
||||
AppCmdline=''
|
||||
|
||||
# Here you may type readme text, which will be shown during startup. Format is:
|
||||
# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?)
|
||||
ReadmeText='^Readme text'
|
||||
|
||||
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
|
||||
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
|
||||
MinimumScreenSize=s
|
||||
|
||||
# Your AdMob Publisher ID, (n) if you don't want advertisements
|
||||
AdmobPublisherId=n
|
||||
|
||||
# Your AdMob test device ID, to receive a test ad
|
||||
AdmobTestDeviceId=
|
||||
|
||||
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
|
||||
AdmobBannerSize=
|
||||
|
||||
BIN
project/jni/application/guichan-widgets/AndroidData/files.zip
Normal file
BIN
project/jni/application/guichan-widgets/AndroidData/files.zip
Normal file
Binary file not shown.
23
project/jni/application/guichan-widgets/gui.xml
Normal file
23
project/jni/application/guichan-widgets/gui.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<container name="top" width="640" height="480">
|
||||
<label name="logo_text" caption="Simple example of using XmlGui" />
|
||||
<button x="5" y="20" name="exit" caption="Please click to exit" />
|
||||
<icon name="logo" x="250" y="160" image="darkbitslogo_by_haiko.bmp" />
|
||||
<dropdown name="dp" x="100" y="100">
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
</dropdown>
|
||||
<listbox name="lb" x="200" y="100">
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
</listbox>
|
||||
<textfield name="tf" text="simple text" x="5" y="300" />
|
||||
<scrollarea name="sc" x="300" y="5" width="100" height="100">
|
||||
<textbox name="tb" text="simple textbox
|
||||
ddjdjd" />
|
||||
</scrollarea>
|
||||
<window name="wnd" caption="Drag me!" x="100" y="200">
|
||||
<icon name="logo_in_wnd" x="0" y="0" image="darkbitslogo_by_haiko.bmp" />
|
||||
</window>
|
||||
</container>
|
||||
BIN
project/jni/application/guichan-widgets/icon.png
Normal file
BIN
project/jni/application/guichan-widgets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
120
project/jni/application/guichan-widgets/sdl.hpp
Normal file
120
project/jni/application/guichan-widgets/sdl.hpp
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Code that sets up an SDL application with Guichan using the
|
||||
* Guichan SDL back end.
|
||||
*/
|
||||
|
||||
#include <guichan.hpp>
|
||||
#include <guichan/sdl.hpp>
|
||||
|
||||
namespace sdl
|
||||
{
|
||||
bool running = true;
|
||||
SDL_Surface* screen;
|
||||
|
||||
// All back ends contain objects to make Guichan work on a
|
||||
// specific target - in this case SDL - and they are a Graphics
|
||||
// object to make Guichan able to draw itself using SDL, an
|
||||
// input objec to make Guichan able to get user input using SDL
|
||||
// and an ImageLoader object to make Guichan able to load images
|
||||
// using SDL.
|
||||
gcn::SDLGraphics* graphics;
|
||||
gcn::SDLInput* input;
|
||||
gcn::SDLImageLoader* imageLoader;
|
||||
|
||||
/**
|
||||
* Initialises the SDL application. This function creates the global
|
||||
* Gui object that can be populated by various examples.
|
||||
*/
|
||||
void init()
|
||||
{
|
||||
// We simply initialise SDL as we would do with any SDL application.
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE);
|
||||
// We want unicode for the SDLInput object to function properly.
|
||||
SDL_EnableUNICODE(1);
|
||||
// We also want to enable key repeat.
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
|
||||
// Now it's time to initialise the Guichan SDL back end.
|
||||
|
||||
imageLoader = new gcn::SDLImageLoader();
|
||||
// The ImageLoader Guichan should use needs to be passed to the Image object
|
||||
// using a static function.
|
||||
gcn::Image::setImageLoader(imageLoader);
|
||||
graphics = new gcn::SDLGraphics();
|
||||
// The Graphics object needs a target to draw to, in this case it's the
|
||||
// screen surface, but any surface will do, it doesn't have to be the screen.
|
||||
graphics->setTarget(screen);
|
||||
input = new gcn::SDLInput();
|
||||
|
||||
// Now we create the Gui object to be used with this SDL application.
|
||||
globals::gui = new gcn::Gui();
|
||||
// The Gui object needs a Graphics to be able to draw itself and an Input
|
||||
// object to be able to check for user input. In this case we provide the
|
||||
// Gui object with SDL implementations of these objects hence making Guichan
|
||||
// able to utilise SDL.
|
||||
globals::gui->setGraphics(graphics);
|
||||
globals::gui->setInput(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* Halts the SDL application.
|
||||
*/
|
||||
void halt()
|
||||
{
|
||||
delete globals::gui;
|
||||
|
||||
delete imageLoader;
|
||||
delete input;
|
||||
delete graphics;
|
||||
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the SDL application.
|
||||
*/
|
||||
void run()
|
||||
{
|
||||
// The main loop
|
||||
while(running)
|
||||
{
|
||||
// Check user input
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE)
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_f)
|
||||
{
|
||||
if (event.key.keysym.mod & KMOD_CTRL)
|
||||
{
|
||||
// Works with X11 only
|
||||
SDL_WM_ToggleFullScreen(screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(event.type == SDL_QUIT)
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
|
||||
// After we have manually checked user input with SDL for
|
||||
// any attempt by the user to halt the application we feed
|
||||
// the input to Guichan by pushing the input to the Input
|
||||
// object.
|
||||
input->pushInput(event);
|
||||
}
|
||||
// Now we let the Gui object perform its logic.
|
||||
globals::gui->logic();
|
||||
// Now we let the Gui object draw itself.
|
||||
globals::gui->draw();
|
||||
// Finally we update the screen.
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
58
project/jni/application/guichan-widgets/sdlwidgets.cpp
Normal file
58
project/jni/application/guichan-widgets/sdlwidgets.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* This is an example that shows of the widgets present in
|
||||
* Guichan. The example uses the SDL back end.
|
||||
*/
|
||||
|
||||
#include <guichan.hpp>
|
||||
#include <iostream>
|
||||
|
||||
// Here we store a global Gui object. We make it global
|
||||
// so it's easily accessable. Of course, global variables
|
||||
// should normally be avioded when it comes to OOP, but
|
||||
// this examples is not an example that shows how to make a
|
||||
// good and clean C++ application but merely an example
|
||||
// that shows how to use Guichan.
|
||||
namespace globals
|
||||
{
|
||||
gcn::Gui* gui;
|
||||
}
|
||||
|
||||
// Include code to set up an SDL application with Guichan.
|
||||
// The sdl.hpp file is responsible for creating and deleting
|
||||
// the global Gui object.
|
||||
#include "sdl.hpp"
|
||||
// Include code to set up a Guichan GUI with all the widgets
|
||||
// of Guichan. The code populates the global Gui object.
|
||||
#include "widgets.hpp"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
sdl::init();
|
||||
widgets::init();
|
||||
sdl::run();
|
||||
widgets::halt();
|
||||
sdl::halt();
|
||||
}
|
||||
// Catch all Guichan exceptions.
|
||||
catch (gcn::Exception e)
|
||||
{
|
||||
std::cerr << e.getMessage() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
// Catch all Std exceptions.
|
||||
catch (std::exception e)
|
||||
{
|
||||
std::cerr << "Std exception: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
// Catch all unknown exceptions.
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Unknown exception" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
182
project/jni/application/guichan-widgets/widgets.hpp
Normal file
182
project/jni/application/guichan-widgets/widgets.hpp
Normal file
@@ -0,0 +1,182 @@
|
||||
/**
|
||||
* Code to populate a global Gui object with all the widgets
|
||||
* of Guichan.
|
||||
*/
|
||||
|
||||
namespace widgets
|
||||
{
|
||||
gcn::ImageFont* font;
|
||||
gcn::Container* top;
|
||||
gcn::Label* label;
|
||||
gcn::Icon* icon;
|
||||
gcn::Button* button;
|
||||
gcn::TextField* textField;
|
||||
gcn::TextBox* textBox;
|
||||
gcn::ScrollArea* textBoxScrollArea;
|
||||
gcn::ListBox* listBox;
|
||||
gcn::DropDown* dropDown;
|
||||
gcn::CheckBox* checkBox1;
|
||||
gcn::CheckBox* checkBox2;
|
||||
gcn::RadioButton* radioButton1;
|
||||
gcn::RadioButton* radioButton2;
|
||||
gcn::RadioButton* radioButton3;
|
||||
gcn::Slider* slider;
|
||||
gcn::Image *image;
|
||||
gcn::Window *window;
|
||||
gcn::Image *darkbitsImage;
|
||||
gcn::Icon* darkbitsIcon;
|
||||
gcn::TabbedArea* tabbedArea;
|
||||
gcn::Button* tabOneButton;
|
||||
gcn::CheckBox* tabTwoCheckBox;
|
||||
|
||||
/*
|
||||
* List boxes and drop downs need an instance of a list model
|
||||
* in order to display a list.
|
||||
*/
|
||||
class DemoListModel : public gcn::ListModel
|
||||
{
|
||||
public:
|
||||
int getNumberOfElements()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
std::string getElementAt(int i)
|
||||
{
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
return std::string("zero");
|
||||
case 1:
|
||||
return std::string("one");
|
||||
case 2:
|
||||
return std::string("two");
|
||||
case 3:
|
||||
return std::string("three");
|
||||
case 4:
|
||||
return std::string("four");
|
||||
default: // Just to keep warnings away
|
||||
return std::string("");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DemoListModel demoListModel;
|
||||
|
||||
/**
|
||||
* Initialises the widgets example by populating the global Gui
|
||||
* object.
|
||||
*/
|
||||
void init()
|
||||
{
|
||||
// We first create a container to be used as the top widget.
|
||||
// The top widget in Guichan can be any kind of widget, but
|
||||
// in order to make the Gui contain more than one widget we
|
||||
// make the top widget a container.
|
||||
top = new gcn::Container();
|
||||
// We set the dimension of the top container to match the screen.
|
||||
top->setDimension(gcn::Rectangle(0, 0, 640, 480));
|
||||
// Finally we pass the top widget to the Gui object.
|
||||
globals::gui->setTop(top);
|
||||
|
||||
// Now we load the font used in this example.
|
||||
font = new gcn::ImageFont("fixedfont.bmp", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
||||
// Widgets may have a global font so we don't need to pass the
|
||||
// font object to every created widget. The global font is static.
|
||||
gcn::Widget::setGlobalFont(font);
|
||||
|
||||
// Now we create the widgets
|
||||
|
||||
label = new gcn::Label("Label");
|
||||
|
||||
image = gcn::Image::load("gui-chan.bmp");
|
||||
icon = new gcn::Icon(image);
|
||||
|
||||
button = new gcn::Button("Button");
|
||||
|
||||
textField = new gcn::TextField("Text field");
|
||||
|
||||
textBox = new gcn::TextBox("Multiline\nText box");
|
||||
textBoxScrollArea = new gcn::ScrollArea(textBox);
|
||||
textBoxScrollArea->setWidth(200);
|
||||
textBoxScrollArea->setHeight(100);
|
||||
textBoxScrollArea->setFrameSize(1);
|
||||
|
||||
listBox = new gcn::ListBox(&demoListModel);
|
||||
listBox->setFrameSize(1);
|
||||
dropDown = new gcn::DropDown(&demoListModel);
|
||||
|
||||
checkBox1 = new gcn::CheckBox("Checkbox 1");
|
||||
checkBox2 = new gcn::CheckBox("Checkbox 2");
|
||||
|
||||
radioButton1 = new gcn::RadioButton("RadioButton 1", "radiogroup", true);
|
||||
radioButton2 = new gcn::RadioButton("RadioButton 2", "radiogroup");
|
||||
radioButton3 = new gcn::RadioButton("RadioButton 3", "radiogroup");
|
||||
|
||||
slider = new gcn::Slider(0, 10);
|
||||
slider->setSize(100, 10);
|
||||
|
||||
window = new gcn::Window("I am a window Drag me");
|
||||
window->setBaseColor(gcn::Color(255, 150, 200, 190));
|
||||
|
||||
darkbitsImage = gcn::Image::load("darkbitslogo_by_haiko.bmp");
|
||||
darkbitsIcon = new gcn::Icon(darkbitsImage);
|
||||
window->add(darkbitsIcon);
|
||||
window->resizeToContent();
|
||||
|
||||
tabbedArea = new gcn::TabbedArea();
|
||||
tabbedArea->setSize(200, 100);
|
||||
tabOneButton = new gcn::Button("A button in tab 1");
|
||||
tabbedArea->addTab("Tab 1", tabOneButton);
|
||||
tabTwoCheckBox = new gcn::CheckBox("A check box in tab 2");
|
||||
tabbedArea->addTab("Tab 2", tabTwoCheckBox);
|
||||
|
||||
// Now it's time to add the widgets to the top container
|
||||
// so they will be conected to the GUI.
|
||||
|
||||
top->add(label, 10, 10);
|
||||
top->add(icon, 10, 30);
|
||||
top->add(button, 200, 10);
|
||||
top->add(textField, 250, 10);
|
||||
top->add(textBoxScrollArea, 200, 50);
|
||||
top->add(listBox, 200, 200);
|
||||
top->add(dropDown, 500, 10);
|
||||
top->add(checkBox1, 500, 130);
|
||||
top->add(checkBox2, 500, 150);
|
||||
top->add(radioButton1, 500, 200);
|
||||
top->add(radioButton2, 500, 220);
|
||||
top->add(radioButton3, 500, 240);
|
||||
top->add(slider, 500, 300);
|
||||
top->add(window, 50, 350);
|
||||
top->add(tabbedArea, 400, 350);
|
||||
}
|
||||
|
||||
/**
|
||||
* Halts the widgets example.
|
||||
*/
|
||||
void halt()
|
||||
{
|
||||
delete font;
|
||||
delete top;
|
||||
delete label;
|
||||
delete icon;
|
||||
delete button;
|
||||
delete textField;
|
||||
delete textBox;
|
||||
delete textBoxScrollArea;
|
||||
delete listBox;
|
||||
delete dropDown;
|
||||
delete checkBox1;
|
||||
delete checkBox2;
|
||||
delete radioButton1;
|
||||
delete radioButton2;
|
||||
delete radioButton3;
|
||||
delete slider;
|
||||
delete window;
|
||||
delete darkbitsIcon;
|
||||
delete darkbitsImage;
|
||||
delete tabbedArea;
|
||||
delete tabOneButton;
|
||||
delete tabTwoCheckBox;
|
||||
}
|
||||
}
|
||||
226
project/jni/application/guichan-xml/AndroidAppSettings.cfg
Normal file
226
project/jni/application/guichan-xml/AndroidAppSettings.cfg
Normal file
@@ -0,0 +1,226 @@
|
||||
# The application settings for Android libSDL port
|
||||
|
||||
AppSettingVersion=19
|
||||
|
||||
# libSDL version to use (1.2 or 1.3, specify 1.3 for SDL2)
|
||||
LibSdlVersion=1.2
|
||||
|
||||
# Specify application name (e.x. My Application)
|
||||
AppName="XMLGuiChan"
|
||||
|
||||
# Specify reversed site name of application (e.x. com.mysite.myapp)
|
||||
AppFullName=com.guichan.xml
|
||||
|
||||
# Specify screen orientation: (v)ertical/(p)ortrait or (h)orizontal/(l)andscape
|
||||
ScreenOrientation=h
|
||||
|
||||
# Do not allow device to sleep when the application is in foreground, set this for video players or apps which use accelerometer
|
||||
InhibitSuspend=n
|
||||
|
||||
# Specify path to download application data in zip archive in the form 'Description|URL|MirrorURL^Description2|URL2|MirrorURL2^...'
|
||||
# If you'll start Description with '!' symbol it will be enabled by default, other downloads should be selected by user from startup config menu
|
||||
# If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped
|
||||
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by build system
|
||||
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
|
||||
AppDataDownloadUrl="data file|files.zip"
|
||||
|
||||
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
|
||||
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
|
||||
VideoDepthBpp=16
|
||||
|
||||
# Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedDepthBuffer=n
|
||||
|
||||
# Enable OpenGL stencil buffer (needed only for 3-d applications, small speed decrease) (y) or (n)
|
||||
NeedStencilBuffer=n
|
||||
|
||||
# Try to use GLES 2.x context - will revert to GLES 1.X if unsupported by device
|
||||
# you need this option only if you're developing 3-d app (y) or (n)
|
||||
NeedGles2=n
|
||||
|
||||
# Application uses software video buffer - you're calling SDL_SetVideoMode() without SDL_HWSURFACE and without SDL_OPENGL,
|
||||
# this will allow small speed optimization. Enable this even when you're using SDL_HWSURFACE. (y) or (n)
|
||||
SwVideoMode=y
|
||||
|
||||
# Application video output will be resized to fit into native device screen (y)/(n)
|
||||
SdlVideoResize=y
|
||||
|
||||
# Application resizing will keep 4:3 aspect ratio, with black bars at sides (y)/(n)
|
||||
SdlVideoResizeKeepAspect=n
|
||||
|
||||
# Application does not call SDL_Flip() or SDL_UpdateRects() appropriately, or draws from non-main thread -
|
||||
# enabling the compatibility mode will force screen update every 100 milliseconds, which is laggy and inefficient (y) or (n)
|
||||
CompatibilityHacks=n
|
||||
|
||||
# Application initializes SDL audio/video inside static constructors (which is bad, you won't be able to run ndk-gdb) (y)/(n)
|
||||
CompatibilityHacksStaticInit=n
|
||||
|
||||
# On-screen Android soft text input emulates hardware keyboard, this will only work with Hackers Keyboard app (y)/(n)
|
||||
CompatibilityHacksTextInputEmulatesHwKeyboard=y
|
||||
|
||||
# Hack for broken devices: prevent audio chopping, by sleeping a bit after pushing each audio chunk (y)/(n)
|
||||
CompatibilityHacksPreventAudioChopping=n
|
||||
|
||||
# Hack for broken apps: application ignores audio buffer size returned by SDL (y)/(n)
|
||||
CompatibilityHacksAppIgnoresAudioBufferSize=n
|
||||
|
||||
# Hack for VCMI: preload additional shared libraries before aplication start
|
||||
CompatibilityHacksAdditionalPreloadedSharedLibraries=""
|
||||
|
||||
# Hack for Free Heroes 2, which redraws the screen inside SDL_PumpEvents(): slow and compatible SDL event queue -
|
||||
# do not use it with accelerometer/gyroscope, or your app may freeze at random (y)/(n)
|
||||
CompatibilityHacksSlowCompatibleEventQueue=n
|
||||
|
||||
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
|
||||
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
|
||||
|
||||
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
|
||||
AppUsesMouse=y
|
||||
|
||||
# Application needs two-button mouse, will also enable advanced point-and-click features (y) or (n)
|
||||
AppNeedsTwoButtonMouse=y
|
||||
|
||||
# Show SDL mouse cursor, for applications that do not draw cursor at all (y) or (n)
|
||||
ShowMouseCursor=n
|
||||
|
||||
# Force relative (laptop) mouse movement mode, useful when both on-screen keyboard and mouse are needed (y) or (n)
|
||||
ForceRelativeMouseMode=n
|
||||
|
||||
# Application needs arrow keys (y) or (n), will show on-screen dpad/joystick (y) or (n)
|
||||
AppNeedsArrowKeys=n
|
||||
|
||||
# Application needs text input (y) or (n), enables button for text input on screen
|
||||
AppNeedsTextInput=y
|
||||
|
||||
# Application uses joystick (y) or (n), the on-screen DPAD will be used as joystick 0 axes 0-1
|
||||
AppUsesJoystick=n
|
||||
|
||||
# Application uses second on-screen joystick, as SDL joystick 0 axes 2-3 (y)/(n)
|
||||
AppUsesSecondJoystick=n
|
||||
|
||||
# Application uses accelerometer (y) or (n), the accelerometer will be used as joystick 1 axes 0-1 and 5-7
|
||||
AppUsesAccelerometer=n
|
||||
|
||||
# Application uses gyroscope (y) or (n), the gyroscope will be used as joystick 1 axes 2-4
|
||||
AppUsesGyroscope=n
|
||||
|
||||
# Application uses multitouch (y) or (n), multitouch events are passed as SDL_JOYBALLMOTION events for the joystick 0
|
||||
AppUsesMultitouch=n
|
||||
|
||||
# Application records audio (it will use any available source, such a s microphone)
|
||||
# API is defined in file SDL_android.h: int SDL_ANDROID_OpenAudioRecording(SDL_AudioSpec *spec); void SDL_ANDROID_CloseAudioRecording(void);
|
||||
# This option will add additional permission to Android manifest (y)/(n)
|
||||
AppRecordsAudio=n
|
||||
|
||||
# Application implements Android-specific routines to put to background, and will not draw anything to screen
|
||||
# between SDL_ACTIVEEVENT lost / gained notifications - you should check for them
|
||||
# rigth after SDL_Flip(), if (n) then SDL_Flip() will block till app in background (y) or (n)
|
||||
# This option is reported to be buggy, sometimes failing to restore video state
|
||||
NonBlockingSwapBuffers=y
|
||||
|
||||
# Redefine common hardware keys to SDL keysyms
|
||||
# BACK hardware key is available on all devices, MENU is available on pre-ICS devices, other keys may be absent
|
||||
# SEARCH and CALL by default return same keycode as DPAD_CENTER - one of those keys is available on most devices
|
||||
# Use word NO_REMAP if you want to preserve native functionality for certain key (volume keys are 3-rd and 4-th)
|
||||
# Keys: TOUCHSCREEN (works only when AppUsesMouse=n), DPAD_CENTER/SEARCH, VOLUMEUP, VOLUMEDOWN, MENU, BACK, CAMERA
|
||||
RedefinedKeys="SPACE"
|
||||
|
||||
# Number of virtual keyboard keys (currently 6 is maximum)
|
||||
AppTouchscreenKeyboardKeysAmount=0
|
||||
|
||||
# Number of virtual keyboard keys that support autofire (currently 2 is maximum)
|
||||
AppTouchscreenKeyboardKeysAmountAutoFire=0
|
||||
|
||||
# Redefine on-screen keyboard keys to SDL keysyms - 6 keyboard keys + 4 multitouch gestures (zoom in/out and rotate left/right)
|
||||
RedefinedKeysScreenKb="1 2 3 4 5 6 1 2 3 4"
|
||||
|
||||
# Names for on-screen keyboard keys, such as Fire, Jump, Run etc, separated by spaces, they are used in SDL config menu
|
||||
RedefinedKeysScreenKbNames="1 2 3 4 5 6 1 2 3 4"
|
||||
|
||||
# On-screen keys theme
|
||||
# 0 = Ultimate Droid by Sean Stieber (green, with gamepad joystick)
|
||||
# 1 = Simple Theme by Beholder (white, with gamepad joystick)
|
||||
# 2 = Sun by Sirea (yellow, with round joystick)
|
||||
# 3 = Keen by Gerstrong (multicolor, with round joystick)
|
||||
TouchscreenKeysTheme=2
|
||||
|
||||
# Redefine gamepad keys to SDL keysyms, button order is:
|
||||
# A B X Y L1 R1 L2 R2 LThumb RThumb
|
||||
RedefinedKeysGamepad="1 2 3 4 5 6 1 2 3 4"
|
||||
|
||||
# How long to show startup menu button, in msec, 0 to disable startup menu
|
||||
StartupMenuButtonTimeout=3000
|
||||
|
||||
# Menu items to hide from startup menu, available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
|
||||
HiddenMenuOptions=''
|
||||
|
||||
# Menu items to show at startup - this is Java code snippet, leave empty for default
|
||||
# new SettingsMenuMisc.ShowReadme(), (AppUsesMouse \&\& \! ForceRelativeMouseMode \? new SettingsMenuMouse.DisplaySizeConfig(true) : new SettingsMenu.DummyMenu()), new SettingsMenuMisc.OptionalDownloadConfig(true), new SettingsMenuMisc.GyroscopeCalibration()
|
||||
# Available menu items:
|
||||
# SettingsMenu.OkButton SettingsMenu.DummyMenu SettingsMenu.MainMenu SettingsMenuMisc.DownloadConfig SettingsMenuMisc.OptionalDownloadConfig SettingsMenuMisc.AudioConfig SettingsMenuMisc.VideoSettingsConfig SettingsMenuMisc.ShowReadme SettingsMenuMisc.GyroscopeCalibration SettingsMenuMisc.ResetToDefaultsConfig SettingsMenuMouse.MouseConfigMainMenu SettingsMenuMouse.DisplaySizeConfig SettingsMenuMouse.LeftClickConfig SettingsMenuMouse.RightClickConfig SettingsMenuMouse.AdditionalMouseConfig SettingsMenuMouse.JoystickMouseConfig SettingsMenuMouse.TouchPressureMeasurementTool SettingsMenuMouse.CalibrateTouchscreenMenu SettingsMenuKeyboard.KeyboardConfigMainMenu SettingsMenuKeyboard.ScreenKeyboardSizeConfig SettingsMenuKeyboard.ScreenKeyboardDrawSizeConfig SettingsMenuKeyboard.ScreenKeyboardThemeConfig SettingsMenuKeyboard.ScreenKeyboardTransparencyConfig SettingsMenuKeyboard.RemapHwKeysConfig SettingsMenuKeyboard.RemapScreenKbConfig SettingsMenuKeyboard.ScreenGesturesConfig SettingsMenuKeyboard.CustomizeScreenKbLayout
|
||||
FirstStartMenuOptions=''
|
||||
|
||||
# Enable multi-ABI binary, with hardware FPU support - it will also work on old devices,
|
||||
# but .apk size is 2x bigger (y) / (n) / (x86) / (all)
|
||||
MultiABI=n
|
||||
|
||||
# Minimum amount of RAM application requires, in Mb, SDL will print warning to user if it's lower
|
||||
AppMinimumRAM=256
|
||||
|
||||
# Application version code (integer)
|
||||
AppVersionCode=101
|
||||
|
||||
# Application user-visible version name (string)
|
||||
AppVersionName="1.01"
|
||||
|
||||
# Reset SDL config when updating application to the new version (y) / (n)
|
||||
ResetSdlConfigForThisVersion=n
|
||||
|
||||
# Delete application data files when upgrading (specify file/dir paths separated by spaces)
|
||||
DeleteFilesOnUpgrade=""
|
||||
|
||||
# Optional shared libraries to compile - removing some of them will save space
|
||||
# MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed
|
||||
# Available libraries: mad (GPL-ed!) sdl_mixer sdl_image sdl_ttf sdl_net sdl_blitpool sdl_gfx sdl_sound intl xml2 lua jpeg png ogg flac tremor vorbis freetype xerces curl theora fluidsynth lzma lzo2 mikmod openal timidity zzip bzip2 yaml-cpp python boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread glu avcodec avdevice avfilter avformat avresample avutil swscale swresample bzip2
|
||||
CompiledLibraries="sdl_image guichan"
|
||||
|
||||
# Application uses custom build script AndroidBuild.sh instead of Android.mk (y) or (n)
|
||||
CustomBuildScript=n
|
||||
|
||||
# Aditional CFLAGS for application
|
||||
AppCflags='-Wall -Wno-unused -DGUICHAN_BUILD -fexceptions'
|
||||
|
||||
# Additional LDFLAGS for application
|
||||
AppLdflags=''
|
||||
|
||||
# If application has headers with the same name as system headers, this option tries to fix compiler flags to make it compilable
|
||||
AppOverlapsSystemHeaders=
|
||||
|
||||
# Build only following subdirs (empty will build all dirs, ignored with custom script)
|
||||
AppSubdirsBuild=''
|
||||
|
||||
# Exclude these files from build
|
||||
AppBuildExclude=''
|
||||
|
||||
# Application command line parameters, including app name as 0-th param
|
||||
AppCmdline=''
|
||||
|
||||
# Here you may type readme text, which will be shown during startup. Format is:
|
||||
# Text in English, use \\\\n to separate lines^de:Text in Deutsch^ru:Text in Russian, and so on (that's four backslashes, nice isn't it?)
|
||||
ReadmeText='^Readme text'
|
||||
|
||||
# Screen size is used by Google Play to prevent an app to be installed on devices with smaller screens
|
||||
# Minimum screen size that application supports: (s)mall / (m)edium / (l)arge
|
||||
MinimumScreenSize=s
|
||||
|
||||
# Your AdMob Publisher ID, (n) if you don't want advertisements
|
||||
AdmobPublisherId=n
|
||||
|
||||
# Your AdMob test device ID, to receive a test ad
|
||||
AdmobTestDeviceId=
|
||||
|
||||
# Your AdMob banner size (BANNER/IAB_BANNER/IAB_LEADERBOARD/IAB_MRECT/IAB_WIDE_SKYSCRAPER/SMART_BANNER)
|
||||
AdmobBannerSize=
|
||||
|
||||
BIN
project/jni/application/guichan-xml/AndroidData/files.zip
Normal file
BIN
project/jni/application/guichan-xml/AndroidData/files.zip
Normal file
Binary file not shown.
23
project/jni/application/guichan-xml/gui.xml
Normal file
23
project/jni/application/guichan-xml/gui.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<container name="top" width="640" height="480">
|
||||
<label name="logo_text" caption="Simple example of using XmlGui" />
|
||||
<button x="5" y="20" name="exit" caption="Please click to exit" />
|
||||
<icon name="logo" x="250" y="160" image="darkbitslogo_by_haiko.bmp" />
|
||||
<dropdown name="dp" x="100" y="100">
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
</dropdown>
|
||||
<listbox name="lb" x="200" y="100">
|
||||
<li>Item 1</li>
|
||||
<li>Item 2</li>
|
||||
<li>Item 3</li>
|
||||
</listbox>
|
||||
<textfield name="tf" text="simple text" x="5" y="300" />
|
||||
<scrollarea name="sc" x="300" y="5" width="100" height="100">
|
||||
<textbox name="tb" text="simple textbox
|
||||
ddjdjd" />
|
||||
</scrollarea>
|
||||
<window name="wnd" caption="Drag me!" x="100" y="200">
|
||||
<icon name="logo_in_wnd" x="0" y="0" image="darkbitslogo_by_haiko.bmp" />
|
||||
</window>
|
||||
</container>
|
||||
BIN
project/jni/application/guichan-xml/icon.png
Normal file
BIN
project/jni/application/guichan-xml/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
208
project/jni/application/guichan-xml/sdlguiexample.cpp
Normal file
208
project/jni/application/guichan-xml/sdlguiexample.cpp
Normal file
@@ -0,0 +1,208 @@
|
||||
/**
|
||||
* SDL Hello World example for Guichan.
|
||||
*/
|
||||
|
||||
// Include all necessary headers.
|
||||
#include <iostream>
|
||||
#include <guichan.hpp>
|
||||
#include <guichan/sdl.hpp>
|
||||
#include <SDL/SDL.h>
|
||||
#include "xmlgui.h"
|
||||
/*
|
||||
* Common stuff we need
|
||||
*/
|
||||
bool running = true;
|
||||
|
||||
/*
|
||||
* SDL Stuff we need
|
||||
*/
|
||||
SDL_Surface* screen;
|
||||
SDL_Event event;
|
||||
|
||||
/*
|
||||
* Guichan SDL stuff we need
|
||||
*/
|
||||
gcn::SDLInput* input; // Input driver
|
||||
gcn::SDLGraphics* graphics; // Graphics driver
|
||||
gcn::SDLImageLoader* imageLoader; // For loading images
|
||||
|
||||
/*
|
||||
* Guichan stuff we need
|
||||
*/
|
||||
gcn::Gui* gui; // A Gui object - binds it all together
|
||||
gcn::Container* top; // A top container
|
||||
gcn::ImageFont* font; // A font
|
||||
|
||||
//XmlGui stuff
|
||||
XmlGui *xmlgui = new XmlGui();
|
||||
|
||||
/**
|
||||
* Initializes the Hello World
|
||||
*/
|
||||
void init()
|
||||
{
|
||||
/*
|
||||
* Here we initialize SDL as we would do with any SDL application.
|
||||
*/
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE);
|
||||
// We want unicode
|
||||
SDL_EnableUNICODE(1);
|
||||
// We want to enable key repeat
|
||||
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
|
||||
|
||||
/*
|
||||
* Now it's time for Guichan SDL stuff
|
||||
*/
|
||||
imageLoader = new gcn::SDLImageLoader();
|
||||
// The ImageLoader in use is static and must be set to be
|
||||
// able to load images
|
||||
gcn::Image::setImageLoader(imageLoader);
|
||||
graphics = new gcn::SDLGraphics();
|
||||
// Set the target for the graphics object to be the screen.
|
||||
// In other words, we will draw to the screen.
|
||||
// Note, any surface will do, it doesn't have to be the screen.
|
||||
graphics->setTarget(screen);
|
||||
input = new gcn::SDLInput();
|
||||
|
||||
/*
|
||||
* Last but not least it's time to initialize and create the gui
|
||||
* with Guichan stuff.
|
||||
*/
|
||||
gui = new gcn::Gui();
|
||||
// Set gui to use the SDLGraphics object.
|
||||
gui->setGraphics(graphics);
|
||||
// Set gui to use the SDLInput object
|
||||
gui->setInput(input);
|
||||
// Set the top container
|
||||
gui->setTop(top);
|
||||
// Load the image font.
|
||||
font = new gcn::ImageFont("fixedfont.bmp", " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
||||
// The global font is static and must be set.
|
||||
gcn::Widget::setGlobalFont(font);
|
||||
|
||||
xmlgui = new XmlGui();
|
||||
xmlgui->parse("gui.xml");
|
||||
gui->setTop(xmlgui->getWidget("top"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Halts the application
|
||||
*/
|
||||
void halt()
|
||||
{
|
||||
/*
|
||||
* Destroy Guichan stuff
|
||||
*/
|
||||
delete xmlgui;
|
||||
delete font;
|
||||
delete top;
|
||||
delete gui;
|
||||
|
||||
/*
|
||||
* Destroy Guichan SDL stuff
|
||||
*/
|
||||
delete input;
|
||||
delete graphics;
|
||||
delete imageLoader;
|
||||
|
||||
/*
|
||||
* Destroy SDL stuff
|
||||
*/
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks input. On escape halt the application.
|
||||
*/
|
||||
void checkInput()
|
||||
{
|
||||
/*
|
||||
* Poll SDL events
|
||||
*/
|
||||
while(SDL_PollEvent(&event))
|
||||
{
|
||||
if (event.type == SDL_KEYDOWN)
|
||||
{
|
||||
if (event.key.keysym.sym == SDLK_ESCAPE)
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
if (event.key.keysym.sym == SDLK_f)
|
||||
{
|
||||
if (event.key.keysym.mod & KMOD_CTRL)
|
||||
{
|
||||
// Works with X11 only
|
||||
SDL_WM_ToggleFullScreen(screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(event.type == SDL_QUIT)
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now that we are done polling and using SDL events we pass
|
||||
* the leftovers to the SDLInput object to later be handled by
|
||||
* the Gui. (This example doesn't require us to do this 'cause a
|
||||
* label doesn't use input. But will do it anyway to show how to
|
||||
* set up an SDL application with Guichan.)
|
||||
*/
|
||||
input->pushInput(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the application
|
||||
*/
|
||||
void run()
|
||||
{
|
||||
while(running)
|
||||
{
|
||||
// Poll input
|
||||
checkInput();
|
||||
// Let the gui perform it's logic (like handle input)
|
||||
gui->logic();
|
||||
// Draw the gui
|
||||
gui->draw();
|
||||
// Update the screen
|
||||
SDL_Flip(screen);
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
init();
|
||||
run();
|
||||
halt();
|
||||
}
|
||||
/*
|
||||
* Catch all Guichan exceptions
|
||||
*/
|
||||
catch (gcn::Exception e)
|
||||
{
|
||||
std::cerr << e.getMessage() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
* Catch all Std exceptions
|
||||
*/
|
||||
catch (std::exception e)
|
||||
{
|
||||
std::cerr << "Std exception: " << e.what() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
* Catch all Unknown exceptions
|
||||
*/
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Unknown exception" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
796
project/jni/application/guichan-xml/tinyxml.cpp
Normal file
796
project/jni/application/guichan-xml/tinyxml.cpp
Normal file
@@ -0,0 +1,796 @@
|
||||
/*
|
||||
Copyright (c) 2000 Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#include "tinyxml.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
TiXmlNode::TiXmlNode( NodeType _type )
|
||||
{
|
||||
parent = 0;
|
||||
type = _type;
|
||||
firstChild = 0;
|
||||
lastChild = 0;
|
||||
prev = 0;
|
||||
next = 0;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode::~TiXmlNode()
|
||||
{
|
||||
TiXmlNode* node = firstChild;
|
||||
TiXmlNode* temp = 0;
|
||||
|
||||
while ( node )
|
||||
{
|
||||
temp = node;
|
||||
node = node->next;
|
||||
delete temp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TiXmlNode::Clear()
|
||||
{
|
||||
TiXmlNode* node = firstChild;
|
||||
TiXmlNode* temp = 0;
|
||||
|
||||
while ( node )
|
||||
{
|
||||
temp = node;
|
||||
node = node->next;
|
||||
delete temp;
|
||||
}
|
||||
|
||||
firstChild = 0;
|
||||
lastChild = 0;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
|
||||
{
|
||||
node->parent = this;
|
||||
|
||||
node->prev = lastChild;
|
||||
node->next = 0;
|
||||
|
||||
if ( lastChild )
|
||||
lastChild->next = node;
|
||||
else
|
||||
firstChild = node; // it was an empty list.
|
||||
|
||||
lastChild = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
|
||||
{
|
||||
TiXmlNode* node = addThis.Clone();
|
||||
if ( !node )
|
||||
return 0;
|
||||
|
||||
return LinkEndChild( node );
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis )
|
||||
{
|
||||
if ( beforeThis->parent != this )
|
||||
return 0;
|
||||
|
||||
TiXmlNode* node = addThis.Clone();
|
||||
if ( !node )
|
||||
return 0;
|
||||
node->parent = this;
|
||||
|
||||
node->next = beforeThis;
|
||||
node->prev = beforeThis->prev;
|
||||
beforeThis->prev->next = node;
|
||||
beforeThis->prev = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis )
|
||||
{
|
||||
if ( afterThis->parent != this )
|
||||
return 0;
|
||||
|
||||
TiXmlNode* node = addThis.Clone();
|
||||
if ( !node )
|
||||
return 0;
|
||||
node->parent = this;
|
||||
|
||||
node->prev = afterThis;
|
||||
node->next = afterThis->next;
|
||||
afterThis->next->prev = node;
|
||||
afterThis->next = node;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
|
||||
{
|
||||
if ( replaceThis->parent != this )
|
||||
return 0;
|
||||
|
||||
TiXmlNode* node = withThis.Clone();
|
||||
if ( !node )
|
||||
return 0;
|
||||
|
||||
node->next = replaceThis->next;
|
||||
node->prev = replaceThis->prev;
|
||||
|
||||
if ( replaceThis->next )
|
||||
replaceThis->next->prev = node;
|
||||
else
|
||||
lastChild = node;
|
||||
|
||||
if ( replaceThis->prev )
|
||||
replaceThis->prev->next = node;
|
||||
else
|
||||
firstChild = node;
|
||||
|
||||
delete replaceThis;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
|
||||
{
|
||||
if ( removeThis->parent != this )
|
||||
{
|
||||
assert( 0 );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( removeThis->next )
|
||||
removeThis->next->prev = removeThis->prev;
|
||||
else
|
||||
lastChild = removeThis->prev;
|
||||
|
||||
if ( removeThis->prev )
|
||||
removeThis->prev->next = removeThis->next;
|
||||
else
|
||||
firstChild = removeThis->next;
|
||||
|
||||
delete removeThis;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::FirstChild( const std::string& value ) const
|
||||
{
|
||||
TiXmlNode* node;
|
||||
for ( node = firstChild; node; node = node->next )
|
||||
{
|
||||
if ( node->Value() == value )
|
||||
return node;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::LastChild( const std::string& value ) const
|
||||
{
|
||||
TiXmlNode* node;
|
||||
for ( node = lastChild; node; node = node->prev )
|
||||
{
|
||||
if ( node->Value() == value )
|
||||
return node;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous )
|
||||
{
|
||||
if ( !previous )
|
||||
{
|
||||
return FirstChild();
|
||||
}
|
||||
else
|
||||
{
|
||||
//commented due Issue 1 (thanks copesetic)
|
||||
//assert( previous->parent == this );
|
||||
return previous->NextSibling();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::IterateChildren( const std::string& val, TiXmlNode* previous )
|
||||
{
|
||||
if ( !previous )
|
||||
{
|
||||
return FirstChild( val );
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( previous->parent == this );
|
||||
return previous->NextSibling( val );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::NextSibling( const std::string& value ) const
|
||||
{
|
||||
TiXmlNode* node;
|
||||
for ( node = next; node; node = node->next )
|
||||
{
|
||||
if ( node->Value() == value )
|
||||
return node;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::PreviousSibling( const std::string& value ) const
|
||||
{
|
||||
TiXmlNode* node;
|
||||
for ( node = prev; node; node = node->prev )
|
||||
{
|
||||
if ( node->Value() == value )
|
||||
return node;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void TiXmlElement::RemoveAttribute( const std::string& name )
|
||||
{
|
||||
TiXmlAttribute* node = attributeSet.Find( name );
|
||||
if ( node )
|
||||
{
|
||||
attributeSet.Remove( node );
|
||||
delete node;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiXmlElement* TiXmlNode::FirstChildElement() const
|
||||
{
|
||||
TiXmlNode* node;
|
||||
|
||||
for ( node = FirstChild();
|
||||
node;
|
||||
node = node->NextSibling() )
|
||||
{
|
||||
if ( node->ToElement() )
|
||||
return node->ToElement();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TiXmlElement* TiXmlNode::FirstChildElement( const std::string& value ) const
|
||||
{
|
||||
TiXmlNode* node;
|
||||
|
||||
for ( node = FirstChild( value );
|
||||
node;
|
||||
node = node->NextSibling( value ) )
|
||||
{
|
||||
if ( node->ToElement() )
|
||||
return node->ToElement();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TiXmlElement* TiXmlNode::NextSiblingElement() const
|
||||
{
|
||||
TiXmlNode* node;
|
||||
|
||||
for ( node = NextSibling();
|
||||
node;
|
||||
node = node->NextSibling() )
|
||||
{
|
||||
if ( node->ToElement() )
|
||||
return node->ToElement();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
TiXmlElement* TiXmlNode::NextSiblingElement( const std::string& value ) const
|
||||
{
|
||||
TiXmlNode* node;
|
||||
|
||||
for ( node = NextSibling( value );
|
||||
node;
|
||||
node = node->NextSibling( value ) )
|
||||
{
|
||||
if ( node->ToElement() )
|
||||
return node->ToElement();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
TiXmlDocument* TiXmlNode::GetDocument() const
|
||||
{
|
||||
const TiXmlNode* node;
|
||||
|
||||
for( node = this; node; node = node->parent )
|
||||
{
|
||||
if ( node->ToDocument() )
|
||||
return node->ToDocument();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// TiXmlElement::TiXmlElement()
|
||||
// : TiXmlNode( TiXmlNode::ELEMENT )
|
||||
// {
|
||||
// }
|
||||
|
||||
TiXmlElement::TiXmlElement( const std::string& _value )
|
||||
: TiXmlNode( TiXmlNode::ELEMENT )
|
||||
{
|
||||
firstChild = lastChild = 0;
|
||||
value = _value;
|
||||
}
|
||||
|
||||
TiXmlElement::~TiXmlElement()
|
||||
{
|
||||
while( attributeSet.First() )
|
||||
{
|
||||
TiXmlAttribute* node = attributeSet.First();
|
||||
attributeSet.Remove( node );
|
||||
delete node;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string* TiXmlElement::Attribute( const std::string& name ) const
|
||||
{
|
||||
TiXmlAttribute* node = attributeSet.Find( name );
|
||||
|
||||
if ( node )
|
||||
return &(node->Value() );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const
|
||||
{
|
||||
const std::string* s = Attribute( name );
|
||||
if ( s )
|
||||
*i = atoi( s->c_str() );
|
||||
else
|
||||
*i = 0;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
void TiXmlElement::SetAttribute( const std::string& name, int val )
|
||||
{
|
||||
char buf[64];
|
||||
sprintf( buf, "%d", val );
|
||||
|
||||
std::string v = buf;
|
||||
|
||||
SetAttribute( name, v );
|
||||
}
|
||||
|
||||
|
||||
void TiXmlElement::SetAttribute( const std::string& name, const std::string& value )
|
||||
{
|
||||
TiXmlAttribute* node = attributeSet.Find( name );
|
||||
if ( node )
|
||||
{
|
||||
node->SetValue( value );
|
||||
return;
|
||||
}
|
||||
|
||||
TiXmlAttribute* attrib = new TiXmlAttribute( name, value );
|
||||
if ( attrib )
|
||||
{
|
||||
attributeSet.Add( attrib );
|
||||
}
|
||||
else
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TiXmlElement::Print( FILE* fp, int depth )
|
||||
{
|
||||
int i;
|
||||
for ( i=0; i<depth; i++ )
|
||||
fprintf( fp, " " );
|
||||
|
||||
fprintf( fp, "<%s", value.c_str() );
|
||||
|
||||
TiXmlAttribute* attrib;
|
||||
for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
|
||||
{
|
||||
fprintf( fp, " " );
|
||||
attrib->Print( fp, 0 );
|
||||
}
|
||||
// If this node has children, give it a closing tag. Else
|
||||
// make it an empty tag.
|
||||
TiXmlNode* node;
|
||||
if ( firstChild )
|
||||
{
|
||||
fprintf( fp, ">" );
|
||||
|
||||
for ( node = firstChild; node; node=node->NextSibling() )
|
||||
{
|
||||
if ( !node->ToText() )
|
||||
fprintf( fp, "\n" );
|
||||
node->Print( fp, depth+1 );
|
||||
}
|
||||
fprintf( fp, "\n" );
|
||||
for ( i=0; i<depth; i++ )
|
||||
fprintf( fp, " " );
|
||||
fprintf( fp, "</%s>", value.c_str() );
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf( fp, " />" );
|
||||
}
|
||||
}
|
||||
|
||||
TiXmlNode* TiXmlElement::Clone() const
|
||||
{
|
||||
TiXmlElement* clone = new TiXmlElement( Value() );
|
||||
|
||||
if ( !clone )
|
||||
return 0;
|
||||
|
||||
CopyToClone( clone );
|
||||
|
||||
// Clone the attributes, then clone the children.
|
||||
TiXmlAttribute* attribute = 0;
|
||||
for( attribute = attributeSet.First();
|
||||
attribute;
|
||||
attribute = attribute->Next() )
|
||||
{
|
||||
clone->SetAttribute( attribute->Name(), attribute->Value() );
|
||||
}
|
||||
|
||||
TiXmlNode* node = 0;
|
||||
for ( node = firstChild; node; node = node->NextSibling() )
|
||||
{
|
||||
clone->LinkEndChild( node->Clone() );
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT )
|
||||
{
|
||||
error = false;
|
||||
// factory = new TiXmlFactory();
|
||||
}
|
||||
|
||||
|
||||
TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
|
||||
{
|
||||
// factory = new TiXmlFactory();
|
||||
value = documentName;
|
||||
error = false;
|
||||
}
|
||||
|
||||
// void TiXmlDocument::SetFactory( TiXmlFactory* f )
|
||||
// {
|
||||
// delete factory;
|
||||
// factory = f;
|
||||
// }
|
||||
|
||||
|
||||
bool TiXmlDocument::LoadFile()
|
||||
{
|
||||
return LoadFile( value );
|
||||
}
|
||||
|
||||
|
||||
bool TiXmlDocument::SaveFile()
|
||||
{
|
||||
return SaveFile( value );
|
||||
}
|
||||
|
||||
|
||||
bool TiXmlDocument::LoadFile( const std::string& filename )
|
||||
{
|
||||
// Delete the existing data:
|
||||
Clear();
|
||||
|
||||
// Load the new data:
|
||||
FILE* fp = fopen( filename.c_str(), "r" );
|
||||
if ( fp )
|
||||
{
|
||||
unsigned size;
|
||||
fseek( fp, 0, SEEK_END );
|
||||
size = ftell( fp );
|
||||
fseek( fp, 0, SEEK_SET );
|
||||
|
||||
char* buf = new char[size+1];
|
||||
char* p = buf;
|
||||
while( fgets( p, size, fp ) )
|
||||
{
|
||||
p = strchr( p, 0 );
|
||||
}
|
||||
fclose( fp );
|
||||
|
||||
Parse( buf );
|
||||
delete [] buf;
|
||||
|
||||
if ( !Error() )
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetError( TIXML_ERROR_OPENING_FILE );
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool TiXmlDocument::SaveFile( const std::string& filename )
|
||||
{
|
||||
FILE* fp = fopen( filename.c_str(), "w" );
|
||||
if ( fp )
|
||||
{
|
||||
Print( fp, 0 );
|
||||
fclose( fp );
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlDocument::Clone() const
|
||||
{
|
||||
TiXmlDocument* clone = new TiXmlDocument();
|
||||
if ( !clone )
|
||||
return 0;
|
||||
|
||||
CopyToClone( clone );
|
||||
clone->error = error;
|
||||
clone->errorDesc = errorDesc;
|
||||
|
||||
TiXmlNode* node = 0;
|
||||
for ( node = firstChild; node; node = node->NextSibling() )
|
||||
{
|
||||
clone->LinkEndChild( node->Clone() );
|
||||
}
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
void TiXmlDocument::Print( FILE* fp, int )
|
||||
{
|
||||
TiXmlNode* node;
|
||||
for ( node=FirstChild(); node; node=node->NextSibling() )
|
||||
{
|
||||
node->Print( fp, 0 );
|
||||
fprintf( fp, "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiXmlAttribute* TiXmlAttribute::Next()
|
||||
{
|
||||
// We are using knowledge of the sentinel. The sentinel
|
||||
// have a value or name.
|
||||
if ( next->value.empty() && next->name.empty() )
|
||||
return 0;
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
TiXmlAttribute* TiXmlAttribute::Previous()
|
||||
{
|
||||
// We are using knowledge of the sentinel. The sentinel
|
||||
// have a value or name.
|
||||
if ( prev->value.empty() && prev->name.empty() )
|
||||
return 0;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
void TiXmlAttribute::Print( FILE* fp, int )
|
||||
{
|
||||
if ( value.find( '\"' ) != std::string::npos )
|
||||
fprintf( fp, "%s='%s'", name.c_str(), value.c_str() );
|
||||
else
|
||||
fprintf( fp, "%s=\"%s\"", name.c_str(), value.c_str() );
|
||||
}
|
||||
|
||||
|
||||
void TiXmlComment::Print( FILE* fp, int depth )
|
||||
{
|
||||
for ( int i=0; i<depth; i++ )
|
||||
fprintf( fp, " " );
|
||||
fprintf( fp, "<!--%s-->", value.c_str() );
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlComment::Clone() const
|
||||
{
|
||||
TiXmlComment* clone = new TiXmlComment();
|
||||
|
||||
if ( !clone )
|
||||
return 0;
|
||||
|
||||
CopyToClone( clone );
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
void TiXmlText::Print( FILE* fp, int )
|
||||
{
|
||||
fprintf( fp, "%s", value.c_str() );
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlText::Clone() const
|
||||
{
|
||||
TiXmlText* clone = 0;
|
||||
clone = new TiXmlText();
|
||||
|
||||
if ( !clone )
|
||||
return 0;
|
||||
|
||||
CopyToClone( clone );
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
TiXmlDeclaration::TiXmlDeclaration( const std::string& _version,
|
||||
const std::string& _encoding,
|
||||
const std::string& _standalone )
|
||||
: TiXmlNode( TiXmlNode::DECLARATION )
|
||||
{
|
||||
version = _version;
|
||||
encoding = _encoding;
|
||||
standalone = _standalone;
|
||||
}
|
||||
|
||||
|
||||
void TiXmlDeclaration::Print( FILE* fp, int )
|
||||
{
|
||||
std::string out = "<?xml ";
|
||||
|
||||
if ( !version.empty() )
|
||||
{
|
||||
out += "version=\"";
|
||||
out += version;
|
||||
out += "\" ";
|
||||
}
|
||||
if ( !encoding.empty() )
|
||||
{
|
||||
out += "encoding=\"";
|
||||
out += encoding;
|
||||
out += "\" ";
|
||||
}
|
||||
if ( !standalone.empty() )
|
||||
{
|
||||
out += "standalone=\"";
|
||||
out += standalone;
|
||||
out += "\" ";
|
||||
}
|
||||
out += "?>";
|
||||
|
||||
fprintf( fp, "%s", out.c_str() );
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlDeclaration::Clone() const
|
||||
{
|
||||
TiXmlDeclaration* clone = new TiXmlDeclaration();
|
||||
|
||||
if ( !clone )
|
||||
return 0;
|
||||
|
||||
CopyToClone( clone );
|
||||
clone->version = version;
|
||||
clone->encoding = encoding;
|
||||
clone->standalone = standalone;
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
void TiXmlUnknown::Print( FILE* fp, int depth )
|
||||
{
|
||||
for ( int i=0; i<depth; i++ )
|
||||
fprintf( fp, " " );
|
||||
fprintf( fp, "<%s>", value.c_str() );
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlUnknown::Clone() const
|
||||
{
|
||||
TiXmlUnknown* clone = new TiXmlUnknown();
|
||||
|
||||
if ( !clone )
|
||||
return 0;
|
||||
|
||||
CopyToClone( clone );
|
||||
return clone;
|
||||
}
|
||||
|
||||
|
||||
TiXmlAttributeSet::TiXmlAttributeSet()
|
||||
{
|
||||
sentinel.next = &sentinel;
|
||||
sentinel.prev = &sentinel;
|
||||
}
|
||||
|
||||
|
||||
TiXmlAttributeSet::~TiXmlAttributeSet()
|
||||
{
|
||||
assert( sentinel.next == &sentinel );
|
||||
assert( sentinel.prev == &sentinel );
|
||||
}
|
||||
|
||||
|
||||
void TiXmlAttributeSet::Add( TiXmlAttribute* addMe )
|
||||
{
|
||||
assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set.
|
||||
|
||||
addMe->next = &sentinel;
|
||||
addMe->prev = sentinel.prev;
|
||||
|
||||
sentinel.prev->next = addMe;
|
||||
sentinel.prev = addMe;
|
||||
}
|
||||
|
||||
void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
|
||||
{
|
||||
TiXmlAttribute* node;
|
||||
|
||||
for( node = sentinel.next; node != &sentinel; node = node->next )
|
||||
{
|
||||
if ( node == removeMe )
|
||||
{
|
||||
node->prev->next = node->next;
|
||||
node->next->prev = node->prev;
|
||||
node->next = 0;
|
||||
node->prev = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
assert( 0 ); // we tried to remove a non-linked attribute.
|
||||
}
|
||||
|
||||
|
||||
TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
|
||||
{
|
||||
TiXmlAttribute* node;
|
||||
|
||||
for( node = sentinel.next; node != &sentinel; node = node->next )
|
||||
{
|
||||
if ( node->Name() == name )
|
||||
return node;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
613
project/jni/application/guichan-xml/tinyxml.h
Normal file
613
project/jni/application/guichan-xml/tinyxml.h
Normal file
@@ -0,0 +1,613 @@
|
||||
/*
|
||||
Copyright (c) 2000 Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#ifndef TINYXML_INCLUDED
|
||||
#define TINYXML_INCLUDED
|
||||
|
||||
#pragma warning( disable : 4530 )
|
||||
#pragma warning( disable : 4786 )
|
||||
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
class TiXmlDocument;
|
||||
class TiXmlElement;
|
||||
class TiXmlComment;
|
||||
class TiXmlUnknown;
|
||||
class TiXmlAttribute;
|
||||
class TiXmlText;
|
||||
class TiXmlDeclaration;
|
||||
|
||||
|
||||
/** TiXmlBase is a base class for every class in TinyXml.
|
||||
It does little except to establist that TinyXml classes
|
||||
can be printed and provide some utility functions.
|
||||
|
||||
In XML, the document and elements can contain
|
||||
other elements and other types of nodes.
|
||||
|
||||
@verbatim
|
||||
A Document can contain: Element (container or leaf)
|
||||
Comment (leaf)
|
||||
Unknown (leaf)
|
||||
Declaration( leaf )
|
||||
|
||||
An Element can contain: Element (container or leaf)
|
||||
Text (leaf)
|
||||
Attributes (not on tree)
|
||||
Comment (leaf)
|
||||
Unknown (leaf)
|
||||
|
||||
A Decleration contains: Attributes (not on tree)
|
||||
@endverbatim
|
||||
*/
|
||||
class TiXmlBase
|
||||
{
|
||||
friend class TiXmlNode;
|
||||
friend class TiXmlElement;
|
||||
friend class TiXmlDocument;
|
||||
|
||||
public:
|
||||
TiXmlBase() {}
|
||||
virtual ~TiXmlBase() {}
|
||||
|
||||
/* All TinyXml classes can print themselves to a filestream.
|
||||
*/
|
||||
virtual void Print( FILE* fp, int depth ) = 0;
|
||||
|
||||
protected:
|
||||
/* General parsing helper method. Takes a pointer in,
|
||||
skips all the white space it finds, and returns a pointer
|
||||
to the first non-whitespace data.
|
||||
*/
|
||||
static const char* SkipWhiteSpace( const char* p );
|
||||
|
||||
/* Reads an XML name into the string provided. Returns
|
||||
a pointer just past the last character of the name,
|
||||
or 0 if the function has an error.
|
||||
*/
|
||||
static const char* ReadName( const char* p, std::string* name );
|
||||
|
||||
enum
|
||||
{
|
||||
TIXML_NO_ERROR = 0,
|
||||
TIXML_ERROR_OPENING_FILE,
|
||||
TIXML_ERROR_OUT_OF_MEMORY,
|
||||
TIXML_ERROR_PARSING_ELEMENT,
|
||||
TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
|
||||
TIXML_ERROR_READING_ELEMENT_VALUE,
|
||||
TIXML_ERROR_READING_ATTRIBUTES,
|
||||
TIXML_ERROR_PARSING_EMPTY,
|
||||
TIXML_ERROR_READING_END_TAG,
|
||||
TIXML_ERROR_PARSING_UNKNOWN,
|
||||
TIXML_ERROR_PARSING_COMMENT,
|
||||
TIXML_ERROR_PARSING_DECLARATION,
|
||||
|
||||
TIXML_ERROR_STRING_COUNT
|
||||
};
|
||||
static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
|
||||
};
|
||||
|
||||
|
||||
/** The parent class for everything in the Document Object Model.
|
||||
(Except for attributes, which are contained in elements.)
|
||||
Nodes have siblings, a parent, and children. A node can be
|
||||
in a document, or stand on its own. The type of a TyXmlNode
|
||||
can be queried, and it can be cast to its more defined type.
|
||||
*/
|
||||
class TiXmlNode : public TiXmlBase
|
||||
{
|
||||
public:
|
||||
/** The types of XML nodes supported by TinyXml. (All the
|
||||
unsupported types are picked up by UNKNOWN.)
|
||||
*/
|
||||
enum NodeType
|
||||
{
|
||||
DOCUMENT, ELEMENT, COMMENT, UNKNOWN, TEXT, DECLARATION, TYPECOUNT
|
||||
};
|
||||
|
||||
virtual ~TiXmlNode();
|
||||
|
||||
/** The meaning of 'value' changes for the specific type of
|
||||
TiXmlNode.
|
||||
@verbatim
|
||||
Document: filename of the xml file
|
||||
Element: name of the element
|
||||
Comment: the comment text
|
||||
Unknown: the tag contents
|
||||
Text: the text string
|
||||
@endverbatim
|
||||
|
||||
The subclasses will wrap this function.
|
||||
*/
|
||||
const std::string& Value() const { return value; }
|
||||
|
||||
/** Changes the value of the node. Defined as:
|
||||
@verbatim
|
||||
Document: filename of the xml file
|
||||
Element: name of the element
|
||||
Comment: the comment text
|
||||
Unknown: the tag contents
|
||||
Text: the text string
|
||||
@endverbatim
|
||||
*/
|
||||
void SetValue( const std::string& _value ) { value = _value; }
|
||||
|
||||
/// Delete all the children of this node. Does not affect 'this'.
|
||||
void Clear();
|
||||
|
||||
/// One step up the DOM.
|
||||
TiXmlNode* Parent() const { return parent; }
|
||||
|
||||
TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children.
|
||||
TiXmlNode* FirstChild( const std::string& value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found.
|
||||
|
||||
TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children.
|
||||
TiXmlNode* LastChild( const std::string& value ) const; /// The last child of this node matching 'value'. Will be null if there are no children.
|
||||
|
||||
/** An alternate way to walk the children of a node.
|
||||
One way to iterate over nodes is:
|
||||
@verbatim
|
||||
for( child = parent->FirstChild(); child; child = child->NextSibling() )
|
||||
@endverbatim
|
||||
|
||||
IterateChildren does the same thing with the syntax:
|
||||
@verbatim
|
||||
child = 0;
|
||||
while( child = parent->IterateChildren( child ) )
|
||||
@endverbatim
|
||||
|
||||
IterateChildren takes the previous child as input and finds
|
||||
the next one. If the previous child is null, it returns the
|
||||
first. IterateChildren will return null when done.
|
||||
*/
|
||||
TiXmlNode* IterateChildren( TiXmlNode* previous );
|
||||
|
||||
/// This flavor of IterateChildren searches for children with a particular 'value'
|
||||
TiXmlNode* IterateChildren( const std::string& value, TiXmlNode* previous );
|
||||
|
||||
/** Add a new node related to this. Adds a child past the LastChild.
|
||||
Returns a pointer to the new object or NULL if an error occured.
|
||||
*/
|
||||
TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
|
||||
|
||||
/** Add a new node related to this. Adds a child before the specified child.
|
||||
Returns a pointer to the new object or NULL if an error occured.
|
||||
*/
|
||||
TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
|
||||
|
||||
/** Add a new node related to this. Adds a child after the specified child.
|
||||
Returns a pointer to the new object or NULL if an error occured.
|
||||
*/
|
||||
TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis );
|
||||
|
||||
/** Replace a child of this node.
|
||||
Returns a pointer to the new object or NULL if an error occured.
|
||||
*/
|
||||
TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
|
||||
|
||||
/// Delete a child of this node.
|
||||
bool RemoveChild( TiXmlNode* removeThis );
|
||||
|
||||
/// Navigate to a sibling node.
|
||||
TiXmlNode* PreviousSibling() const { return prev; }
|
||||
|
||||
/// Navigate to a sibling node.
|
||||
TiXmlNode* PreviousSibling( const std::string& ) const;
|
||||
|
||||
/// Navigate to a sibling node.
|
||||
TiXmlNode* NextSibling() const { return next; }
|
||||
|
||||
/// Navigate to a sibling node with the given 'value'.
|
||||
TiXmlNode* NextSibling( const std::string& ) const;
|
||||
|
||||
/** Convenience function to get through elements.
|
||||
Calls NextSibling and ToElement. Will skip all non-Element
|
||||
nodes. Returns 0 if there is not another element.
|
||||
*/
|
||||
TiXmlElement* NextSiblingElement() const;
|
||||
|
||||
/** Convenience function to get through elements.
|
||||
Calls NextSibling and ToElement. Will skip all non-Element
|
||||
nodes. Returns 0 if there is not another element.
|
||||
*/
|
||||
TiXmlElement* NextSiblingElement( const std::string& ) const;
|
||||
|
||||
/// Convenience function to get through elements.
|
||||
TiXmlElement* FirstChildElement() const;
|
||||
|
||||
/// Convenience function to get through elements.
|
||||
TiXmlElement* FirstChildElement( const std::string& value ) const;
|
||||
|
||||
/// Query the type (as an enumerated value, above) of this node.
|
||||
virtual int Type() { return type; }
|
||||
|
||||
/** Return a pointer to the Document this node lives in.
|
||||
Returns null if not in a document.
|
||||
*/
|
||||
TiXmlDocument* GetDocument() const;
|
||||
|
||||
TiXmlDocument* ToDocument() const { return ( type == DOCUMENT ) ? (TiXmlDocument*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
TiXmlElement* ToElement() const { return ( type == ELEMENT ) ? (TiXmlElement*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
TiXmlComment* ToComment() const { return ( type == COMMENT ) ? (TiXmlComment*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
TiXmlUnknown* ToUnknown() const { return ( type == UNKNOWN ) ? (TiXmlUnknown*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
TiXmlText* ToText() const { return ( type == TEXT ) ? (TiXmlText*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
TiXmlDeclaration* ToDeclaration() const { return ( type == DECLARATION ) ? (TiXmlDeclaration*) this : 0; } ///< Cast to a more defined type. Will return null not of the requested type.
|
||||
|
||||
virtual TiXmlNode* Clone() const = 0;
|
||||
|
||||
protected:
|
||||
TiXmlNode( NodeType type );
|
||||
virtual const char* Parse( const char* ) = 0;
|
||||
|
||||
// The node is passed in by ownership. This object will delete it.
|
||||
TiXmlNode* LinkEndChild( TiXmlNode* addThis );
|
||||
|
||||
// Figure out what is at *p, and parse it. Return a node if
|
||||
// successful, and update p.
|
||||
TiXmlNode* IdentifyAndParse( const char** p );
|
||||
|
||||
void CopyToClone( TiXmlNode* target ) const { target->value = value; }
|
||||
|
||||
TiXmlNode* parent;
|
||||
NodeType type;
|
||||
|
||||
TiXmlNode* firstChild;
|
||||
TiXmlNode* lastChild;
|
||||
|
||||
std::string value;
|
||||
|
||||
TiXmlNode* prev;
|
||||
TiXmlNode* next;
|
||||
};
|
||||
|
||||
|
||||
/** An attribute is a name-value pair. Elements have an arbitrary
|
||||
number of attributes, each with a unique name.
|
||||
|
||||
@note The attributes are not TiXmlNodes, since they are not
|
||||
part of the tinyXML document object model. There are other
|
||||
suggested ways to look at this problem.
|
||||
|
||||
@note Attributes have a parent
|
||||
*/
|
||||
class TiXmlAttribute : public TiXmlBase
|
||||
{
|
||||
friend class TiXmlAttributeSet;
|
||||
|
||||
public:
|
||||
/// Construct an empty attribute.
|
||||
TiXmlAttribute() : prev( 0 ), next( 0 ) {}
|
||||
|
||||
/// Construct an attribute with a name and value.
|
||||
TiXmlAttribute( const std::string& _name, const std::string& _value ) : name( _name ), value( _value ), prev( 0 ), next( 0 ) {}
|
||||
|
||||
const std::string& Name() const { return name; } ///< Return the name of this attribute.
|
||||
const std::string& Value() const { return value; } ///< Return the value of this attribute.
|
||||
|
||||
void SetName( const std::string& _name ) { name = _name; } ///< Set the name of this attribute.
|
||||
void SetValue( const std::string& _value ) { value = _value; } ///< Set the value.
|
||||
|
||||
/// Get the next sibling attribute in the DOM. Returns null at end.
|
||||
TiXmlAttribute* Next();
|
||||
/// Get the previous sibling attribute in the DOM. Returns null at beginning.
|
||||
TiXmlAttribute* Previous();
|
||||
|
||||
bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
|
||||
bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; }
|
||||
bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; }
|
||||
|
||||
/* [internal use]
|
||||
Attribtue parsing starts: first letter of the name
|
||||
returns: the next char after the value end quote
|
||||
*/
|
||||
const char* Parse( const char* );
|
||||
|
||||
// [internal use]
|
||||
virtual void Print( FILE* fp, int depth );
|
||||
|
||||
// [internal use]
|
||||
// Set the document pointer so the attribute can report errors.
|
||||
void SetDocument( TiXmlDocument* doc ) { document = doc; }
|
||||
|
||||
private:
|
||||
TiXmlDocument* document; // A pointer back to a document, for error reporting.
|
||||
std::string name;
|
||||
std::string value;
|
||||
|
||||
TiXmlAttribute* prev;
|
||||
TiXmlAttribute* next;
|
||||
};
|
||||
|
||||
|
||||
/* A class used to manage a group of attributes.
|
||||
It is only used internally, both by the ELEMENT and the DECLARATION.
|
||||
|
||||
The set can be changed transparent to the Element and Declaration
|
||||
classes that use it, but NOT transparent to the Attribute
|
||||
which has to implement a next() and previous() method. Which makes
|
||||
it a bit problematic and prevents the use of STL.
|
||||
|
||||
This version is implemented with circular lists because:
|
||||
- I like circular lists
|
||||
- it demonstrates some independence from the (typical) doubly linked list.
|
||||
*/
|
||||
class TiXmlAttributeSet
|
||||
{
|
||||
public:
|
||||
TiXmlAttributeSet();
|
||||
~TiXmlAttributeSet();
|
||||
|
||||
void Add( TiXmlAttribute* attribute );
|
||||
void Remove( TiXmlAttribute* attribute );
|
||||
|
||||
TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
|
||||
TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
|
||||
|
||||
TiXmlAttribute* Find( const std::string& name ) const;
|
||||
|
||||
private:
|
||||
TiXmlAttribute sentinel;
|
||||
};
|
||||
|
||||
|
||||
/** The element is a container class. It has a value, the element name,
|
||||
and can contain other elements, text, comments, and unknowns.
|
||||
Elements also contain an arbitrary number of attributes.
|
||||
*/
|
||||
class TiXmlElement : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
/// Construct an element.
|
||||
TiXmlElement( const std::string& value );
|
||||
|
||||
virtual ~TiXmlElement();
|
||||
|
||||
/** Given an attribute name, attribute returns the value
|
||||
for the attribute of that name, or null if none exists.
|
||||
*/
|
||||
const std::string* Attribute( const std::string& name ) const;
|
||||
|
||||
/** Given an attribute name, attribute returns the value
|
||||
for the attribute of that name, or null if none exists.
|
||||
*/
|
||||
const std::string* Attribute( const std::string& name, int* i ) const;
|
||||
|
||||
/** Sets an attribute of name to a given value. The attribute
|
||||
will be created if it does not exist, or changed if it does.
|
||||
*/
|
||||
void SetAttribute( const std::string& name,
|
||||
const std::string& value );
|
||||
|
||||
/** Sets an attribute of name to a given value. The attribute
|
||||
will be created if it does not exist, or changed if it does.
|
||||
*/
|
||||
void SetAttribute( const std::string& name,
|
||||
int value );
|
||||
|
||||
/** Deletes an attribute with the given name.
|
||||
*/
|
||||
void RemoveAttribute( const std::string& name );
|
||||
|
||||
TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } ///< Access the first attribute in this element.
|
||||
TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } ///< Access the last attribute in this element.
|
||||
|
||||
// [internal use] Creates a new Element and returs it.
|
||||
virtual TiXmlNode* Clone() const;
|
||||
// [internal use]
|
||||
virtual void Print( FILE* fp, int depth );
|
||||
|
||||
protected:
|
||||
/* [internal use]
|
||||
Attribtue parsing starts: next char past '<'
|
||||
returns: next char past '>'
|
||||
*/
|
||||
virtual const char* Parse( const char* );
|
||||
const char* ReadValue( const char* p );
|
||||
|
||||
private:
|
||||
TiXmlAttributeSet attributeSet;
|
||||
};
|
||||
|
||||
|
||||
/** An XML comment.
|
||||
*/
|
||||
class TiXmlComment : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
/// Constructs an empty comment.
|
||||
TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
|
||||
virtual ~TiXmlComment() {}
|
||||
|
||||
// [internal use] Creates a new Element and returs it.
|
||||
virtual TiXmlNode* Clone() const;
|
||||
// [internal use]
|
||||
virtual void Print( FILE* fp, int depth );
|
||||
|
||||
protected:
|
||||
/* [internal use]
|
||||
Attribtue parsing starts: at the ! of the !--
|
||||
returns: next char past '>'
|
||||
*/
|
||||
virtual const char* Parse( const char* );
|
||||
};
|
||||
|
||||
|
||||
/** XML text. Contained in an element.
|
||||
*/
|
||||
class TiXmlText : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
TiXmlText() : TiXmlNode( TiXmlNode::TEXT ) {}
|
||||
virtual ~TiXmlText() {}
|
||||
|
||||
|
||||
// [internal use] Creates a new Element and returns it.
|
||||
virtual TiXmlNode* Clone() const;
|
||||
// [internal use]
|
||||
virtual void Print( FILE* fp, int depth );
|
||||
// [internal use]
|
||||
bool Blank(); // returns true if all white space and new lines
|
||||
|
||||
/* [internal use]
|
||||
Attribtue parsing starts: First char of the text
|
||||
returns: next char past '>'
|
||||
*/
|
||||
virtual const char* Parse( const char* );
|
||||
};
|
||||
|
||||
|
||||
/** In correct XML the declaration is the first entry in the file.
|
||||
@verbatim
|
||||
<?xml version="1.0" standalone="yes"?>
|
||||
@endverbatim
|
||||
|
||||
TinyXml will happily read or write files without a declaration,
|
||||
however. There are 3 possible attributes to the declaration:
|
||||
version, encoding, and standalone.
|
||||
|
||||
Note: In this version of the code, the attributes are
|
||||
handled as special cases, not generic attributes, simply
|
||||
because there can only be at most 3 and they are always the same.
|
||||
*/
|
||||
class TiXmlDeclaration : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
/// Construct an empty declaration.
|
||||
TiXmlDeclaration() : TiXmlNode( TiXmlNode::DECLARATION ) {}
|
||||
|
||||
/// Construct.
|
||||
TiXmlDeclaration( const std::string& version,
|
||||
const std::string& encoding,
|
||||
const std::string& standalone );
|
||||
|
||||
virtual ~TiXmlDeclaration() {}
|
||||
|
||||
/// Version. Will return empty if none was found.
|
||||
const std::string& Version() { return version; }
|
||||
/// Encoding. Will return empty if none was found.
|
||||
const std::string& Encoding() { return encoding; }
|
||||
/// Is this a standalone document?
|
||||
const std::string& Standalone() { return standalone; }
|
||||
|
||||
// [internal use] Creates a new Element and returs it.
|
||||
virtual TiXmlNode* Clone() const;
|
||||
// [internal use]
|
||||
virtual void Print( FILE* fp, int depth );
|
||||
|
||||
protected:
|
||||
// [internal use]
|
||||
// Attribtue parsing starts: next char past '<'
|
||||
// returns: next char past '>'
|
||||
|
||||
virtual const char* Parse( const char* );
|
||||
|
||||
private:
|
||||
std::string version;
|
||||
std::string encoding;
|
||||
std::string standalone;
|
||||
};
|
||||
|
||||
|
||||
/** Any tag that tinyXml doesn't recognize is save as an
|
||||
unknown. It is a tag of text, but should not be modified.
|
||||
It will be written back to the XML, unchanged, when the file
|
||||
is saved.
|
||||
*/
|
||||
class TiXmlUnknown : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN ) {}
|
||||
virtual ~TiXmlUnknown() {}
|
||||
|
||||
// [internal use]
|
||||
virtual TiXmlNode* Clone() const;
|
||||
// [internal use]
|
||||
virtual void Print( FILE* fp, int depth );
|
||||
|
||||
protected:
|
||||
/* [internal use]
|
||||
Attribute parsing starts: First char of the text
|
||||
returns: next char past '>'
|
||||
*/
|
||||
virtual const char* Parse( const char* );
|
||||
};
|
||||
|
||||
|
||||
/** Always the top level node. A document binds together all the
|
||||
XML pieces. It can be saved, loaded, and printed to the screen.
|
||||
The 'value' of a document node is the xml file name.
|
||||
*/
|
||||
class TiXmlDocument : public TiXmlNode
|
||||
{
|
||||
public:
|
||||
/// Create an empty document, that has no name.
|
||||
TiXmlDocument();
|
||||
/// Create a document with a name. The name of the document is also the filename of the xml.
|
||||
TiXmlDocument( const std::string& documentName );
|
||||
|
||||
virtual ~TiXmlDocument() {}
|
||||
|
||||
/** Load a file using the current document value.
|
||||
Returns true if successful. Will delete any existing
|
||||
document data before loading.
|
||||
*/
|
||||
bool LoadFile();
|
||||
/// Save a file using the current document value. Returns true if successful.
|
||||
bool SaveFile();
|
||||
/// Load a file using the given filename. Returns true if successful.
|
||||
bool LoadFile( const std::string& filename );
|
||||
/// Save a file using the given filename. Returns true if successful.
|
||||
bool SaveFile( const std::string& filename );
|
||||
|
||||
/// Parse the given null terminated block of xml data.
|
||||
const char* Parse( const char* );
|
||||
|
||||
/// If, during parsing, a error occurs, Error will be set to true.
|
||||
bool Error() { return error; }
|
||||
/// Contains a textual (english) description of the error if one occurs.
|
||||
const std::string& ErrorDesc() { return errorDesc; }
|
||||
|
||||
/// Write the document to a file -- usually invoked by SaveFile.
|
||||
virtual void Print( FILE* fp, int depth = 0 );
|
||||
/// Dump the document to standard out.
|
||||
void Print() { Print( stdout, 0 ); }
|
||||
|
||||
// [internal use]
|
||||
virtual TiXmlNode* Clone() const;
|
||||
// [internal use]
|
||||
void SetError( int err ) { assert( err > 0 && err < TIXML_ERROR_STRING_COUNT );
|
||||
error = true;
|
||||
errorId = err;
|
||||
errorDesc = errorString[ errorId ]; }
|
||||
|
||||
private:
|
||||
bool error;
|
||||
int errorId;
|
||||
std::string errorDesc;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
24
project/jni/application/guichan-xml/tinyxmlerror.cpp
Normal file
24
project/jni/application/guichan-xml/tinyxmlerror.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#include "tinyxml.h"
|
||||
|
||||
// The goal of the seperate error file is to make the first
|
||||
// step towards localization. tinyxml (currently) only supports
|
||||
// latin-1, but at least the error messages could now be translated.
|
||||
//
|
||||
// It also cleans up the code a bit.
|
||||
|
||||
const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
|
||||
{
|
||||
"No error",
|
||||
"Failed to open file",
|
||||
"Memory allocation failed.",
|
||||
"Error parsing Element.",
|
||||
"Failed to read Element name",
|
||||
"Error reading Element value.",
|
||||
"Error reading Attributes.",
|
||||
"Error: empty tag.",
|
||||
"Error reading end tag.",
|
||||
"Error parsing Unknown.",
|
||||
"Error parsing Comment.",
|
||||
"Error parsing Declaration.",
|
||||
};
|
||||
|
||||
535
project/jni/application/guichan-xml/tinyxmlparser.cpp
Normal file
535
project/jni/application/guichan-xml/tinyxmlparser.cpp
Normal file
@@ -0,0 +1,535 @@
|
||||
/*
|
||||
Copyright (c) 2000 Lee Thomason (www.grinninglizard.com)
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any
|
||||
purpose, including commercial applications, and to alter it and
|
||||
redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and
|
||||
must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include "tinyxml.h"
|
||||
#include <ctype.h>
|
||||
|
||||
const char* TiXmlBase::SkipWhiteSpace( const char* p )
|
||||
{
|
||||
while ( p && *p &&
|
||||
( isspace( *p ) || *p == '\n' || *p == '\r' ) )
|
||||
p++;
|
||||
return p;
|
||||
}
|
||||
|
||||
const char* TiXmlBase::ReadName( const char* p, std::string* name )
|
||||
{
|
||||
*name = "";
|
||||
const char* start = p;
|
||||
|
||||
// Names start with letters or underscores.
|
||||
// After that, they can be letters, underscores, numbers,
|
||||
// hyphens, or colons. (Colons are valid ony for namespaces,
|
||||
// but tinyxml can't tell namespaces from names.)
|
||||
if ( p && ( isalpha( *p ) || *p == '_' ) )
|
||||
{
|
||||
p++;
|
||||
while( p && *p &&
|
||||
( isalnum( *p )
|
||||
|| *p == '_'
|
||||
|| *p == '-'
|
||||
|| *p == ':' ) )
|
||||
{
|
||||
p++;
|
||||
}
|
||||
name->append( start, p - start );
|
||||
return p;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char* TiXmlDocument::Parse( const char* start )
|
||||
{
|
||||
// Parse away, at the document level. Since a document
|
||||
// contains nothing but other tags, most of what happens
|
||||
// here is skipping white space.
|
||||
|
||||
const char* p = start;
|
||||
|
||||
p = SkipWhiteSpace( p );
|
||||
if ( !p || !*p )
|
||||
{
|
||||
error = true;
|
||||
errorDesc = "Document empty.";
|
||||
}
|
||||
|
||||
while ( p && *p )
|
||||
{
|
||||
if ( *p != '<' )
|
||||
{
|
||||
error = true;
|
||||
errorDesc = "The '<' symbol that starts a tag was not found.";
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
TiXmlNode* node = IdentifyAndParse( &p );
|
||||
if ( node )
|
||||
{
|
||||
LinkEndChild( node );
|
||||
}
|
||||
}
|
||||
p = SkipWhiteSpace( p );
|
||||
}
|
||||
return 0; // Return null is fine for a document: once it is read, the parsing is over.
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode* TiXmlNode::IdentifyAndParse( const char** where )
|
||||
{
|
||||
const char* p = *where;
|
||||
TiXmlNode* returnNode = 0;
|
||||
assert( *p == '<' );
|
||||
TiXmlDocument* doc = GetDocument();
|
||||
|
||||
p = SkipWhiteSpace( p+1 );
|
||||
|
||||
// What is this thing?
|
||||
// - Elements start with a letter or underscore, but xml is reserved.
|
||||
// - Comments: <!--
|
||||
// - Everthing else is unknown to tinyxml.
|
||||
//
|
||||
if ( tolower( *(p+0) ) == '?'
|
||||
&& tolower( *(p+1) ) == 'x'
|
||||
&& tolower( *(p+2) ) == 'm'
|
||||
&& tolower( *(p+3) ) == 'l' )
|
||||
{
|
||||
#ifdef DEBUG_PARSER
|
||||
printf( "XML parsing Declaration\n" );
|
||||
#endif
|
||||
returnNode = new TiXmlDeclaration();
|
||||
}
|
||||
else if ( isalpha( *p ) || *p == '_' )
|
||||
{
|
||||
#ifdef DEBUG_PARSER
|
||||
printf( "XML parsing Element\n" );
|
||||
#endif
|
||||
returnNode = new TiXmlElement( "" );
|
||||
}
|
||||
else if ( *(p+0) == '!'
|
||||
&& *(p+1) == '-'
|
||||
&& *(p+2) == '-' )
|
||||
{
|
||||
#ifdef DEBUG_PARSER
|
||||
printf( "XML parsing Comment\n" );
|
||||
#endif
|
||||
returnNode = new TiXmlComment();
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef DEBUG_PARSER
|
||||
printf( "XML parsing Comment\n" );
|
||||
#endif
|
||||
returnNode = new TiXmlUnknown();
|
||||
}
|
||||
|
||||
if ( returnNode )
|
||||
{
|
||||
// Set the parent, so it can report errors
|
||||
returnNode->parent = this;
|
||||
p = returnNode->Parse( p );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( doc )
|
||||
doc->SetError( TIXML_ERROR_OUT_OF_MEMORY );
|
||||
p = 0;
|
||||
}
|
||||
*where = p;
|
||||
return returnNode;
|
||||
}
|
||||
|
||||
|
||||
const char* TiXmlElement::Parse( const char* p )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
p = SkipWhiteSpace( p );
|
||||
if ( !p || !*p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT );
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Read the name.
|
||||
p = ReadName( p, &value );
|
||||
if ( !p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME );
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string endTag = "</";
|
||||
endTag += value;
|
||||
endTag += ">";
|
||||
|
||||
// Check for and read attributes. Also look for an empty
|
||||
// tag or an end tag.
|
||||
while ( p && *p )
|
||||
{
|
||||
p = SkipWhiteSpace( p );
|
||||
if ( !p || !*p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES );
|
||||
return 0;
|
||||
}
|
||||
if ( *p == '/' )
|
||||
{
|
||||
// Empty tag.
|
||||
if ( *(p+1) != '>' )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY );
|
||||
return 0;
|
||||
}
|
||||
return p+2;
|
||||
}
|
||||
else if ( *p == '>' )
|
||||
{
|
||||
// Done with attributes (if there were any.)
|
||||
// Read the value -- which can include other
|
||||
// elements -- read the end tag, and return.
|
||||
p = ReadValue( p+1 ); // Note this is an Element method, and will set the error if one happens.
|
||||
if ( !p )
|
||||
return 0;
|
||||
|
||||
// We should find the end tag now
|
||||
std::string buf( p, endTag.size() );
|
||||
if ( endTag == buf )
|
||||
{
|
||||
return p+endTag.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG );
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try to read an element:
|
||||
TiXmlAttribute attrib;
|
||||
attrib.SetDocument( document );
|
||||
p = attrib.Parse( p );
|
||||
|
||||
if ( p )
|
||||
{
|
||||
SetAttribute( attrib.Name(), attrib.Value() );
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char* TiXmlElement::ReadValue( const char* p )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
|
||||
// Read in text and elements in any order.
|
||||
p = SkipWhiteSpace( p );
|
||||
while ( p && *p )
|
||||
{
|
||||
const char* start = p;
|
||||
while ( *p && *p != '<' )
|
||||
p++;
|
||||
|
||||
if ( !*p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE );
|
||||
return 0;
|
||||
}
|
||||
if ( p != start )
|
||||
{
|
||||
// Take what we have, make a text element.
|
||||
TiXmlText* text = new TiXmlText();
|
||||
|
||||
if ( !text )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY );
|
||||
return 0;
|
||||
}
|
||||
text->Parse( start );
|
||||
if ( !text->Blank() )
|
||||
LinkEndChild( text );
|
||||
else
|
||||
delete text;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We hit a '<'
|
||||
// Have we hit a new element or an end tag?
|
||||
if ( *(p+1) == '/' )
|
||||
{
|
||||
return p; // end tag
|
||||
}
|
||||
else
|
||||
{
|
||||
// TiXmlElement* element = new TiXmlElement( "" );
|
||||
//
|
||||
// if ( element )
|
||||
// {
|
||||
// p = element->Parse( p+1 );
|
||||
// if ( p )
|
||||
// LinkEndChild( element );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if ( document ) document->SetError( ERROR_OUT_OF_MEMORY );
|
||||
// return 0;
|
||||
// }
|
||||
TiXmlNode* node = IdentifyAndParse( &p );
|
||||
if ( node )
|
||||
{
|
||||
LinkEndChild( node );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
const char* TiXmlUnknown::Parse( const char* p )
|
||||
{
|
||||
const char* end = strchr( p, '>' );
|
||||
if ( !end )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
if ( document )
|
||||
document->SetError( TIXML_ERROR_PARSING_UNKNOWN );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = std::string( p, end-p );
|
||||
// value.resize( end - p );
|
||||
return end + 1; // return just past the '>'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char* TiXmlComment::Parse( const char* p )
|
||||
{
|
||||
assert( *p == '!' && *(p+1) == '-' && *(p+2) == '-' );
|
||||
|
||||
// Find the end, copy the parts between to the value of
|
||||
// this object, and return.
|
||||
const char* start = p+3;
|
||||
const char* end = strstr( p, "-->" );
|
||||
if ( !end )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
if ( document )
|
||||
document->SetError( TIXML_ERROR_PARSING_COMMENT );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Assemble the comment, removing the white space.
|
||||
bool whiteSpace = false;
|
||||
|
||||
const char* q;
|
||||
for( q=start; q<end; q++ )
|
||||
{
|
||||
if ( isspace( *q ) )
|
||||
{
|
||||
if ( !whiteSpace )
|
||||
{
|
||||
value += ' ';
|
||||
whiteSpace = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
value += *q;
|
||||
whiteSpace = false;
|
||||
}
|
||||
}
|
||||
// value = std::string( start, end-start );
|
||||
return end + 3; // return just past the '>'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const char* TiXmlAttribute::Parse( const char* p )
|
||||
{
|
||||
// Read the name, the '=' and the value.
|
||||
p = ReadName( p, &name );
|
||||
if ( !p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES );
|
||||
return 0;
|
||||
}
|
||||
p = SkipWhiteSpace( p );
|
||||
if ( !p || *p != '=' )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
p = SkipWhiteSpace( p+1 );
|
||||
if ( !p || !*p )
|
||||
{
|
||||
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES );
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char* end = 0;
|
||||
const char* start = p+1;
|
||||
const char* past = 0;
|
||||
|
||||
if ( *p == '\'' )
|
||||
{
|
||||
end = strchr( start, '\'' );
|
||||
past = end+1;
|
||||
}
|
||||
else if ( *p == '"' )
|
||||
{
|
||||
end = strchr( start, '"' );
|
||||
past = end+1;
|
||||
}
|
||||
else
|
||||
{
|
||||
// All attribute values should be in single or double quotes.
|
||||
// But this is such a common error that the parser will try
|
||||
// its best, even without them.
|
||||
start--;
|
||||
for ( end = start; *end; end++ )
|
||||
{
|
||||
if ( isspace( *end ) || *end == '/' || *end == '>' )
|
||||
break;
|
||||
}
|
||||
past = end;
|
||||
}
|
||||
value = std::string( start, end-start );
|
||||
return past;
|
||||
}
|
||||
|
||||
|
||||
const char* TiXmlText::Parse( const char* p )
|
||||
{
|
||||
value = "";
|
||||
bool whitespace = false;
|
||||
|
||||
// Remove leading white space:
|
||||
p = SkipWhiteSpace( p );
|
||||
while ( *p && *p != '<' )
|
||||
{
|
||||
if ( *p == '\r' || *p == '\n' )
|
||||
{
|
||||
whitespace = true;
|
||||
}
|
||||
else if ( isspace( *p ) )
|
||||
{
|
||||
whitespace = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we've found whitespace, add it before the
|
||||
// new character. Any whitespace just becomes a space.
|
||||
if ( whitespace )
|
||||
{
|
||||
value += ' ';
|
||||
whitespace = false;
|
||||
}
|
||||
value += *p;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
// Keep white space before the '<'
|
||||
if ( whitespace )
|
||||
value += ' ';
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
const char* TiXmlDeclaration::Parse( const char* p )
|
||||
{
|
||||
// Find the beginning, find the end, and look for
|
||||
// the stuff in-between.
|
||||
const char* start = p+4;
|
||||
const char* end = strstr( start, "?>" );
|
||||
|
||||
// Be nice to the user:
|
||||
if ( !end )
|
||||
{
|
||||
end = strstr( start, ">" );
|
||||
end++;
|
||||
}
|
||||
else
|
||||
{
|
||||
end += 2;
|
||||
}
|
||||
|
||||
if ( !end )
|
||||
{
|
||||
TiXmlDocument* document = GetDocument();
|
||||
if ( document )
|
||||
document->SetError( TIXML_ERROR_PARSING_DECLARATION );
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char* p;
|
||||
|
||||
p = strstr( start, "version" );
|
||||
if ( p && p < end )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
attrib.Parse( p );
|
||||
version = attrib.Value();
|
||||
}
|
||||
|
||||
p = strstr( start, "encoding" );
|
||||
if ( p && p < end )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
attrib.Parse( p );
|
||||
encoding = attrib.Value();
|
||||
}
|
||||
|
||||
p = strstr( start, "standalone" );
|
||||
if ( p && p < end )
|
||||
{
|
||||
TiXmlAttribute attrib;
|
||||
attrib.Parse( p );
|
||||
standalone = attrib.Value();
|
||||
}
|
||||
}
|
||||
return end;
|
||||
}
|
||||
|
||||
bool TiXmlText::Blank()
|
||||
{
|
||||
for ( unsigned i=0; i<value.size(); i++ )
|
||||
if ( !isspace( value[i] ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
865
project/jni/application/guichan-xml/xmlgui.cpp
Normal file
865
project/jni/application/guichan-xml/xmlgui.cpp
Normal file
@@ -0,0 +1,865 @@
|
||||
#include "xmlgui.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
XmlGui::XmlGui()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool XmlGui::parse(const std::string &filename)
|
||||
{
|
||||
TiXmlElement *element = NULL;
|
||||
TiXmlNode *node = NULL;
|
||||
|
||||
doc = new TiXmlDocument(filename.c_str());
|
||||
|
||||
bool loadOkay = doc->LoadFile();
|
||||
|
||||
if ( !loadOkay )
|
||||
{
|
||||
throw GCN_EXCEPTION("Error parsing xml file.");
|
||||
}
|
||||
node = doc->FirstChild();
|
||||
|
||||
if(node == NULL)
|
||||
{
|
||||
throw GCN_EXCEPTION("Xml document is null or has errors.");
|
||||
}
|
||||
|
||||
while(node!=NULL)
|
||||
{
|
||||
element = node->ToElement();
|
||||
parseWidgets(element,NULL);
|
||||
node = doc->IterateChildren(node);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void XmlGui::addToParent(gcn::Widget *widget,gcn::Widget *parent)
|
||||
{
|
||||
if(!parent) return;
|
||||
|
||||
gcn::Container* top = dynamic_cast<gcn::Container *>(parent);
|
||||
|
||||
if(top)
|
||||
{
|
||||
top->add(widget);
|
||||
}
|
||||
else
|
||||
{
|
||||
gcn::Window* window = dynamic_cast<gcn::Window *>(parent);
|
||||
|
||||
if(window)
|
||||
// window->setContent(widget);
|
||||
window->add(widget);
|
||||
else
|
||||
{
|
||||
gcn::ScrollArea* scrollarea = dynamic_cast<gcn::ScrollArea *>(parent);
|
||||
scrollarea->setContent(widget);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void XmlGui::parseWidgets(TiXmlElement *element, gcn::Widget *parent)
|
||||
{
|
||||
if(!element) return;
|
||||
|
||||
std::string value = element->Value();
|
||||
|
||||
if(value == "container")
|
||||
parseContainer(element,parent);
|
||||
if(value == "label")
|
||||
parseLabel(element,parent);
|
||||
else if(value == "radiobutton")
|
||||
parseRadioButton(element,parent);
|
||||
else if(value == "button")
|
||||
parseButton(element,parent);
|
||||
else if(value == "checkbox")
|
||||
parseCheckBox(element,parent);
|
||||
else if(value == "icon")
|
||||
parseIcon(element,parent);
|
||||
else if(value == "textbox")
|
||||
parseTextBox(element,parent);
|
||||
else if(value == "textfield")
|
||||
parseTextField(element,parent);
|
||||
else if(value == "slider")
|
||||
parseSlider(element,parent);
|
||||
else if(value == "window")
|
||||
parseWindow(element,parent);
|
||||
else if(value == "scrollarea")
|
||||
parseScrollArea(element,parent);
|
||||
else if(value == "dropdown")
|
||||
parseDropdown(element,parent);
|
||||
else if(value == "listbox")
|
||||
parseListbox(element,parent);
|
||||
}
|
||||
|
||||
void XmlGui::parseDefaults(TiXmlElement *element, gcn::Widget *widget)
|
||||
{
|
||||
if(!element) return;
|
||||
|
||||
|
||||
if(element->Attribute("x"))
|
||||
{
|
||||
int x = atoi(element->Attribute("x")->c_str());
|
||||
widget->setX(x);
|
||||
}
|
||||
|
||||
|
||||
if(element->Attribute("y"))
|
||||
{
|
||||
int y = atoi(element->Attribute("y")->c_str());
|
||||
widget->setY(y);
|
||||
}
|
||||
|
||||
|
||||
if(element->Attribute("width"))
|
||||
{
|
||||
int w = atoi(element->Attribute("width")->c_str());
|
||||
widget->setWidth(w);
|
||||
}
|
||||
|
||||
if(element->Attribute("height"))
|
||||
{
|
||||
int h = atoi(element->Attribute("height")->c_str());
|
||||
widget->setHeight(h);
|
||||
}
|
||||
|
||||
if(element->Attribute("basecolor"))
|
||||
{
|
||||
int color;
|
||||
sscanf(element->Attribute("basecolor")->c_str(),"%x",&color);
|
||||
widget->setBaseColor(gcn::Color(color));
|
||||
}
|
||||
|
||||
if(element->Attribute("foregroundcolor"))
|
||||
{
|
||||
int color;
|
||||
sscanf(element->Attribute("foregroundcolor")->c_str(),"%x",&color);
|
||||
widget->setForegroundColor(gcn::Color(color));
|
||||
}
|
||||
|
||||
if(element->Attribute("backgroundcolor"))
|
||||
{
|
||||
int color;
|
||||
sscanf(element->Attribute("backgroundcolor")->c_str(),"%x",&color);
|
||||
widget->setBackgroundColor(gcn::Color(color));
|
||||
}
|
||||
|
||||
|
||||
if(element->Attribute("frame"))
|
||||
{
|
||||
int b = atoi(element->Attribute("framesize")->c_str());
|
||||
widget->setFrameSize(b);
|
||||
}
|
||||
|
||||
if(element->Attribute("font"))
|
||||
{
|
||||
if(fonts[*element->Attribute("font")])
|
||||
widget->setFont(fonts[*element->Attribute("visible")]);
|
||||
}
|
||||
|
||||
if(element->Attribute("visible"))
|
||||
widget->setVisible(checkBool(*element->Attribute("visible")));
|
||||
|
||||
if(element->Attribute("focusable"))
|
||||
widget->setFocusable(checkBool(*element->Attribute("focusable")));
|
||||
|
||||
if(element->Attribute("enabled"))
|
||||
widget->setEnabled(checkBool(*element->Attribute("enabled")));
|
||||
|
||||
if(element->Attribute("tabin"))
|
||||
widget->setTabInEnabled(checkBool(*element->Attribute("tabin")));
|
||||
|
||||
if(element->Attribute("tabout"))
|
||||
widget->setTabOutEnabled(checkBool(*element->Attribute("tabout")));
|
||||
|
||||
if(element->Attribute("eventId"))
|
||||
widget->setActionEventId(*element->Attribute("eventId"));
|
||||
|
||||
if(element->Attribute("actionListener"))
|
||||
widget->addActionListener(actions[*element->Attribute("actionListener")]);
|
||||
}
|
||||
|
||||
void XmlGui::parseContainer(TiXmlElement *element, gcn::Widget *parent)
|
||||
{
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("Container Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::Container *c = new gcn::Container();
|
||||
|
||||
|
||||
if(element->Attribute("opaque"))
|
||||
c->setOpaque(checkBool(*element->Attribute("opaque")));
|
||||
|
||||
|
||||
parseDefaults(element,c);
|
||||
|
||||
//parsing child elements
|
||||
TiXmlNode *child = element->FirstChild();
|
||||
|
||||
if(child)
|
||||
{
|
||||
while(child)
|
||||
{
|
||||
TiXmlElement *e = child->ToElement();
|
||||
|
||||
parseWidgets(e,c);
|
||||
|
||||
child = doc->IterateChildren(child);
|
||||
}
|
||||
}
|
||||
|
||||
addToParent(c,parent);
|
||||
widgets[name] = c;
|
||||
}
|
||||
|
||||
void XmlGui::parseLabel(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = *element->Attribute("name");
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("Label Widget must have a unique name");
|
||||
}
|
||||
|
||||
|
||||
gcn::Label *label = new gcn::Label;
|
||||
|
||||
|
||||
if(element->Attribute("caption"))
|
||||
{
|
||||
label->setCaption(*element->Attribute("caption"));
|
||||
}
|
||||
|
||||
label->adjustSize();
|
||||
|
||||
if(element->Attribute("align"))
|
||||
{
|
||||
if(*element->Attribute("align") == "center" || *element->Attribute("align") == "CENTER")
|
||||
{
|
||||
label->setAlignment(gcn::Graphics::CENTER);
|
||||
}else if(*element->Attribute("align") == "left" || *element->Attribute("align") == "LEFT")
|
||||
{
|
||||
label->setAlignment(gcn::Graphics::LEFT);
|
||||
}else
|
||||
{
|
||||
label->setAlignment(gcn::Graphics::RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
parseDefaults(element,label);
|
||||
|
||||
addToParent(label,parent);
|
||||
widgets[name] = label;
|
||||
}
|
||||
|
||||
void XmlGui::parseButton(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("Button Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::Button *button = new gcn::Button;
|
||||
|
||||
|
||||
if(element->Attribute("caption"))
|
||||
{
|
||||
button->setCaption(*element->Attribute("caption"));
|
||||
}
|
||||
|
||||
if(element->Attribute("align"))
|
||||
{
|
||||
if(*element->Attribute("align") == "center" || *element->Attribute("align") == "CENTER")
|
||||
{
|
||||
button->setAlignment(gcn::Graphics::CENTER);
|
||||
}else if(*element->Attribute("align") == "left" || *element->Attribute("align") == "LEFT")
|
||||
{
|
||||
button->setAlignment(gcn::Graphics::LEFT);
|
||||
}else
|
||||
{
|
||||
button->setAlignment(gcn::Graphics::RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
button->adjustSize();
|
||||
|
||||
parseDefaults(element,button);
|
||||
|
||||
// button->lostFocus(); //fix: this call must't exists
|
||||
//?????
|
||||
|
||||
addToParent(button,parent);
|
||||
|
||||
widgets[name] = button;
|
||||
}
|
||||
|
||||
void XmlGui::parseCheckBox(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("Checkbox Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::CheckBox *checkbox = new gcn::CheckBox;
|
||||
|
||||
|
||||
if(element->Attribute("caption"))
|
||||
{
|
||||
checkbox->setCaption(*element->Attribute("caption"));
|
||||
}
|
||||
|
||||
checkbox->adjustSize();
|
||||
|
||||
|
||||
if(element->Attribute("selected"))
|
||||
checkbox->setSelected(checkBool(*element->Attribute("selected")));
|
||||
|
||||
parseDefaults(element,checkbox);
|
||||
|
||||
|
||||
addToParent(checkbox,parent);
|
||||
|
||||
widgets[name] = checkbox;
|
||||
}
|
||||
|
||||
|
||||
void XmlGui::parseRadioButton(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("RadioButton Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::RadioButton *radio = new gcn::RadioButton;
|
||||
|
||||
if(element->Attribute("caption"))
|
||||
{
|
||||
radio->setCaption(*element->Attribute("caption"));
|
||||
}
|
||||
|
||||
radio->adjustSize();
|
||||
|
||||
|
||||
if(element->Attribute("selected"))
|
||||
radio->setSelected(checkBool(*element->Attribute("selected")));
|
||||
|
||||
if(element->Attribute("group"))
|
||||
radio->setGroup(*element->Attribute("group"));
|
||||
|
||||
parseDefaults(element,radio);
|
||||
|
||||
addToParent(radio,parent);
|
||||
|
||||
widgets[name] = radio;
|
||||
}
|
||||
|
||||
void XmlGui::parseIcon(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("Icon Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::Icon *icon;
|
||||
|
||||
gcn::Image *image;
|
||||
|
||||
if(element->Attribute("image"))
|
||||
{
|
||||
// image = new gcn::Image(*element->Attribute("image"));
|
||||
image = gcn::Image::load(*element->Attribute("image"));
|
||||
}
|
||||
|
||||
if(image)
|
||||
{
|
||||
icon = new gcn::Icon(image);
|
||||
}
|
||||
|
||||
parseDefaults(element,icon);
|
||||
|
||||
addToParent(icon,parent);
|
||||
widgets[name] = icon;
|
||||
}
|
||||
|
||||
|
||||
void XmlGui::parseTextBox(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("TextBox Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::TextBox *textbox = new gcn::TextBox;
|
||||
|
||||
if(element->Attribute("editable"))
|
||||
textbox->setEditable(checkBool(*element->Attribute("editable")));
|
||||
|
||||
if(element->Attribute("text"))
|
||||
{
|
||||
textbox->setText(*element->Attribute("text"));
|
||||
}
|
||||
|
||||
if(element->Attribute("opaque"))
|
||||
textbox->setOpaque(checkBool(*element->Attribute("opaque")));
|
||||
|
||||
parseDefaults(element,textbox);
|
||||
|
||||
addToParent(textbox,parent);
|
||||
|
||||
widgets[name] = textbox;
|
||||
}
|
||||
|
||||
void XmlGui::parseTextField(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("TextField Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::TextField *textfield = new gcn::TextField;
|
||||
|
||||
if(element->Attribute("text"))
|
||||
{
|
||||
textfield->setText(*element->Attribute("text"));
|
||||
}
|
||||
|
||||
parseDefaults(element,textfield);
|
||||
|
||||
addToParent(textfield,parent);
|
||||
|
||||
widgets[name] = textfield;
|
||||
}
|
||||
|
||||
void XmlGui::parseSlider(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("Slider Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::Slider *slider = new gcn::Slider;
|
||||
|
||||
if(element->Attribute("start"))
|
||||
{
|
||||
int start = atoi(element->Attribute("start")->c_str());
|
||||
|
||||
slider->setScaleStart(start);
|
||||
}
|
||||
|
||||
if(element->Attribute("end"))
|
||||
{
|
||||
int end = atoi(element->Attribute("end")->c_str());
|
||||
slider->setScaleEnd(end);
|
||||
}
|
||||
|
||||
if(element->Attribute("value"))
|
||||
{
|
||||
int value = atoi(element->Attribute("value")->c_str());
|
||||
slider->setValue(value);
|
||||
}
|
||||
|
||||
if(element->Attribute("markerLength"))
|
||||
{
|
||||
int l = atoi(element->Attribute("markerLength")->c_str());
|
||||
slider->setMarkerLength(l);
|
||||
}
|
||||
|
||||
if(element->Attribute("stepLength"))
|
||||
{
|
||||
int l = atoi(element->Attribute("stepLength")->c_str());
|
||||
slider->setStepLength(l);
|
||||
}
|
||||
|
||||
if(element->Attribute("orientation"))
|
||||
{
|
||||
if(*element->Attribute("orientation") == "HORIZONTAL" || *element->Attribute("orientation") == "horizontal")
|
||||
slider->setOrientation(gcn::Slider::HORIZONTAL);
|
||||
else slider->setOrientation(gcn::Slider::VERTICAL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
parseDefaults(element,slider);
|
||||
|
||||
addToParent(slider,parent);
|
||||
|
||||
widgets[name] = slider;
|
||||
}
|
||||
|
||||
void XmlGui::parseWindow(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = *element->Attribute("name");
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("Window Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::Window *window = new gcn::Window;
|
||||
|
||||
|
||||
if(element->Attribute("caption"))
|
||||
{
|
||||
window->setCaption(*element->Attribute("caption"));
|
||||
}
|
||||
|
||||
if(element->Attribute("tabbing"))
|
||||
{
|
||||
window->setPadding(checkBool(*element->Attribute("tabbing")));
|
||||
}
|
||||
|
||||
if(element->Attribute("movable"))
|
||||
{
|
||||
window->setMovable(checkBool(*element->Attribute("movable")));
|
||||
}
|
||||
|
||||
if(element->Attribute("titleBarHeight"))
|
||||
{
|
||||
int h = atoi(element->Attribute("titleBarHeight")->c_str());
|
||||
window->setTitleBarHeight(h);
|
||||
}
|
||||
|
||||
|
||||
if(element->Attribute("opaque"))
|
||||
window->setOpaque(checkBool(*element->Attribute("opaque")));
|
||||
|
||||
|
||||
parseDefaults(element,window);
|
||||
|
||||
//parsing child elements
|
||||
TiXmlNode *child = element->FirstChild();
|
||||
|
||||
if(child)
|
||||
{
|
||||
while(child)
|
||||
{
|
||||
TiXmlElement *e = child->ToElement();
|
||||
parseWidgets(e,window);
|
||||
child = doc->IterateChildren(child);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
window->resizeToContent();
|
||||
|
||||
addToParent(window,parent);
|
||||
|
||||
widgets[name] = window;
|
||||
}
|
||||
|
||||
|
||||
void XmlGui::parseScrollArea(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("ScrollArea Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::ScrollArea *scroll = new gcn::ScrollArea;
|
||||
|
||||
|
||||
if(element->Attribute("hPolicy"))
|
||||
{
|
||||
if(*element->Attribute("hPolicy") == "ALWAYS" || *element->Attribute("hPolicy") == "always")
|
||||
scroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
|
||||
else if(*element->Attribute("hPolicy") == "NEVER" || *element->Attribute("hPolicy") == "never")
|
||||
scroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
|
||||
}
|
||||
|
||||
if(element->Attribute("vPolicy"))
|
||||
{
|
||||
if(*element->Attribute("vPolicy") == "ALWAYS" || *element->Attribute("vPolicy") == "always")
|
||||
scroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_ALWAYS);
|
||||
else if(*element->Attribute("vPolicy") == "NEVER" || *element->Attribute("vPolicy") == "never")
|
||||
scroll->setVerticalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
|
||||
}
|
||||
|
||||
if(element->Attribute("vScrollAmount"))
|
||||
{
|
||||
int h;
|
||||
sscanf(element->Attribute("vScrollAmount")->c_str(),"%d",&h);
|
||||
scroll->setVerticalScrollAmount(h);
|
||||
}
|
||||
|
||||
if(element->Attribute("hScrollAmount"))
|
||||
{
|
||||
int h = atoi(element->Attribute("hScrollAmount")->c_str());
|
||||
scroll->setHorizontalScrollAmount(h);
|
||||
}
|
||||
|
||||
if(element->Attribute("scrollBarWidth"))
|
||||
{
|
||||
int w = atoi(element->Attribute("scrollbarWidth")->c_str());
|
||||
scroll->setScrollbarWidth(w);
|
||||
}
|
||||
|
||||
if(element->Attribute("content"))
|
||||
{
|
||||
gcn::Widget *content = getWidget(*element->Attribute("content"));
|
||||
if(content)
|
||||
{
|
||||
scroll->setContent(content);
|
||||
}
|
||||
}
|
||||
|
||||
parseDefaults(element,scroll);
|
||||
|
||||
if(!scroll->getContent())
|
||||
{
|
||||
|
||||
//parsing child elements
|
||||
TiXmlNode *child = element->FirstChild();
|
||||
|
||||
if(child)
|
||||
{
|
||||
while(child)
|
||||
{
|
||||
TiXmlElement *e = child->ToElement();
|
||||
|
||||
parseWidgets(e,scroll);
|
||||
|
||||
child = doc->IterateChildren(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
addToParent(scroll,parent);
|
||||
|
||||
widgets[name] = scroll;
|
||||
}
|
||||
|
||||
void XmlGui::parseDropdown(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("DropDown Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::DropDown *dropdown = new gcn::DropDown;
|
||||
|
||||
|
||||
parseDefaults(element,dropdown);
|
||||
|
||||
XmlListModel *listmodel;
|
||||
//parsing child elements
|
||||
TiXmlNode *child = element->FirstChild();
|
||||
|
||||
if(child)
|
||||
{
|
||||
|
||||
listmodel = new XmlListModel;
|
||||
|
||||
while(child)
|
||||
{
|
||||
TiXmlElement *e = child->ToElement();
|
||||
if(e->Value() == "li")
|
||||
{
|
||||
listmodel->items.push_back(e->FirstChild()->Value());
|
||||
}
|
||||
child = doc->IterateChildren(child);
|
||||
}
|
||||
}
|
||||
|
||||
if(listmodel)
|
||||
dropdown->setListModel(listmodel);
|
||||
|
||||
if(element->Attribute("selected"))
|
||||
{
|
||||
int s = atoi(element->Attribute("selected")->c_str());
|
||||
dropdown->setSelected(s);
|
||||
}
|
||||
|
||||
addToParent(dropdown,parent);
|
||||
widgets[name] = dropdown;
|
||||
}
|
||||
|
||||
void XmlGui::parseListbox(TiXmlElement *element,gcn::Widget *parent)
|
||||
{
|
||||
if(!element)
|
||||
return;
|
||||
|
||||
|
||||
std::string name;
|
||||
if(element->Attribute("name"))
|
||||
{
|
||||
name = element->Attribute("name")->c_str();
|
||||
}else
|
||||
{
|
||||
throw GCN_EXCEPTION("ListBox Widget must have a unique name");
|
||||
}
|
||||
|
||||
gcn::ListBox *listbox = new gcn::ListBox;
|
||||
|
||||
|
||||
parseDefaults(element,listbox);
|
||||
|
||||
XmlListModel *listmodel;
|
||||
//parsing child elements
|
||||
TiXmlNode *child = element->FirstChild();
|
||||
|
||||
if(child)
|
||||
{
|
||||
|
||||
listmodel = new XmlListModel;
|
||||
|
||||
while(child)
|
||||
{
|
||||
TiXmlElement *e = child->ToElement();
|
||||
if(e->Value() == "li")
|
||||
{
|
||||
listmodel->items.push_back(e->FirstChild()->Value());
|
||||
}
|
||||
child = doc->IterateChildren(child);
|
||||
}
|
||||
}
|
||||
|
||||
if(listmodel)
|
||||
listbox->setListModel(listmodel);
|
||||
|
||||
if(element->Attribute("selected"))
|
||||
{
|
||||
int s = atoi(element->Attribute("selected")->c_str());
|
||||
listbox->setSelected(s);
|
||||
}
|
||||
|
||||
addToParent(listbox,parent);
|
||||
widgets[name] = listbox;
|
||||
}
|
||||
|
||||
|
||||
gcn::Widget *XmlGui::getWidget(const std::string &name)
|
||||
{
|
||||
|
||||
std::map<std::string,gcn::Widget*>::iterator it = widgets.find(name);
|
||||
if(it == widgets.end()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return widgets[name];
|
||||
}
|
||||
|
||||
bool XmlGui::checkBool(const std::string &value)
|
||||
{
|
||||
return (value == "1" || value == "true" || value == "True");
|
||||
}
|
||||
|
||||
void XmlGui::addActionListener(const std::string &name, gcn::ActionListener *al)
|
||||
{
|
||||
if(al)
|
||||
actions[name] = al;
|
||||
}
|
||||
|
||||
void XmlGui::addFont(const std::string &name, gcn::Font *font)
|
||||
{
|
||||
if(font)
|
||||
fonts[name] = font;
|
||||
}
|
||||
|
||||
|
||||
int XmlListModel::getNumberOfElements()
|
||||
{
|
||||
return items.size();
|
||||
}
|
||||
|
||||
std::string XmlListModel::getElementAt(int i)
|
||||
{
|
||||
return items[i];
|
||||
}
|
||||
|
||||
155
project/jni/application/guichan-xml/xmlgui.h
Normal file
155
project/jni/application/guichan-xml/xmlgui.h
Normal file
@@ -0,0 +1,155 @@
|
||||
/* XmlGui - xml parsing class for guichan (http://guichan.sourceforge.net)
|
||||
* author - quard (quard8@gmail.com)
|
||||
* Changes:
|
||||
* v. 0.4 - fixed bug in Visual Studio .NET 2003, when compiler option /GR is not enabled;
|
||||
fixed widget allocation, when attribute "name" is't exists
|
||||
deleted all "return false" after GCN_EXCEPTION, because they not used ever
|
||||
* v. 0.3.5 - fixed stupid bug, when widgets not parsed if parent widget is NULL
|
||||
* v. 0.3 - added parsing method for widget,
|
||||
* now checking widget node is in one function
|
||||
* v. 0.2 - small bug fix
|
||||
* - added parsing widgets under 'container'
|
||||
* - changed sscanf to atoi
|
||||
* v. 0.1 - first public release
|
||||
*/
|
||||
|
||||
|
||||
#ifndef XML_GUI_H
|
||||
#define XML_GUI_H
|
||||
|
||||
#include <guichan.hpp>
|
||||
#include "tinyxml.h"
|
||||
#include <map>
|
||||
|
||||
//!XmlGui class for loading gui widget from xml file
|
||||
class XmlGui
|
||||
{
|
||||
public:
|
||||
//!constructor
|
||||
XmlGui();
|
||||
//!parse xml file
|
||||
//@param filename the file name to parse
|
||||
//@return true if loaded ok
|
||||
bool parse(const std::string &filename);
|
||||
|
||||
//@param name th widget name
|
||||
//@return widget by name
|
||||
gcn::Widget *getWidget(const std::string &name);
|
||||
|
||||
//!parse default parameters for all widgets
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseDefaults(TiXmlElement *element, gcn::Widget *widget);
|
||||
|
||||
//!parse container widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseContainer(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse label widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseLabel(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse button widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseButton(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse checkbox widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseCheckBox(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse radiobutton widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseRadioButton(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse icon widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseIcon(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse textbox widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseTextBox(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse textfield widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseTextField(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse slider widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseSlider(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse window widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseWindow(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!parse scrollarea widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseScrollArea(TiXmlElement *element,gcn::Widget *parent);
|
||||
|
||||
//!parse dropdown widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseDropdown(TiXmlElement *element,gcn::Widget *parent);
|
||||
|
||||
//!parse listbox widget
|
||||
//@param element the xml element
|
||||
//@param widget the current widget
|
||||
void parseListbox(TiXmlElement *element,gcn::Widget *parent);
|
||||
|
||||
//!add actionlistener to array
|
||||
//@param name the actionlistener name
|
||||
//@param al the pointer to actionlistener class
|
||||
void addActionListener(const std::string &name,gcn::ActionListener *al);
|
||||
|
||||
//!add font
|
||||
//@param name the font name
|
||||
//@param al the pointer to font class
|
||||
void addFont(const std::string &name,gcn::Font *font);
|
||||
|
||||
|
||||
private:
|
||||
//!parse xml node
|
||||
//@param element - xml element
|
||||
//@param parent - the parent widget
|
||||
void parseWidgets(TiXmlElement *element, gcn::Widget *parent);
|
||||
|
||||
//!adding widget to parent
|
||||
//!parent widget can be Container,ScrollArea,Window. this function get class and set widget or add widget (for Container)
|
||||
//@param widget our widget
|
||||
//@param parent the parent widget
|
||||
void addToParent(gcn::Widget *widget, gcn::Widget *parent);
|
||||
|
||||
//!check string value for boolean value
|
||||
//@param value the string value
|
||||
//@return true if value are "1" or "true"
|
||||
bool checkBool(const std::string &value);
|
||||
|
||||
|
||||
std::map<std::string,gcn::Widget*> widgets;
|
||||
std::map<std::string,gcn::ActionListener*> actions;
|
||||
std::map<std::string,gcn::Font*> fonts;
|
||||
|
||||
//temporary xml document (need by some functions)
|
||||
TiXmlDocument *doc;
|
||||
};
|
||||
|
||||
class XmlListModel : public gcn::ListModel
|
||||
{
|
||||
public:
|
||||
virtual int getNumberOfElements();
|
||||
virtual std::string getElementAt(int i);
|
||||
std::vector<std::string> items;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -50,9 +50,10 @@ MISSING_LIB=
|
||||
|
||||
CFLAGS="\
|
||||
-fpic -ffunction-sections -funwind-tables -fstack-protector \
|
||||
-no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -mthumb \
|
||||
-fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -marm -fno-omit-frame-pointer \
|
||||
-DANDROID -DNDEBUG -O2 -g -finline-functions -Wa,--noexecstack -Wformat -Werror=format-security \
|
||||
-no-canonical-prefixes -march=armv7-a -mfloat-abi=softfp \
|
||||
-mfpu=vfpv3-d16 -mthumb -O2 -g -DNDEBUG \
|
||||
-fomit-frame-pointer -fno-strict-aliasing -finline-limit=300 \
|
||||
-DANDROID -Wall -Wno-unused -Wa,--noexecstack -Wformat -Werror=format-security \
|
||||
-isystem$NDK/platforms/$PLATFORMVER/arch-arm/usr/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH/include \
|
||||
@@ -93,7 +94,7 @@ $MISSING_LIB $LDFLAGS"
|
||||
|
||||
env PATH=$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin:$LOCAL_PATH:$PATH \
|
||||
CFLAGS="$CFLAGS" \
|
||||
CXXFLAGS="$CXXFLAGS $CFLAGS" \
|
||||
CXXFLAGS="$CXXFLAGS $CFLAGS -frtti -fexceptions" \
|
||||
LDFLAGS="$LDFLAGS" \
|
||||
CC="$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-gcc" \
|
||||
CXX="$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-g++" \
|
||||
|
||||
@@ -18,13 +18,19 @@ NDK=`which ndk-build`
|
||||
NDK=`dirname $NDK`
|
||||
NDK=`readlink -f $NDK`
|
||||
|
||||
grep "64.bit" "$NDK/RELEASE.TXT" >/dev/null 2>&1 && MYARCH="${MYARCH}_64"
|
||||
|
||||
#echo NDK $NDK
|
||||
GCCPREFIX=arm-linux-androideabi
|
||||
GCCVER=4.4.3
|
||||
PLATFORMVER=android-8
|
||||
GCCPREFIX=mipsel-linux-android
|
||||
[ -z "$GCCVER" ] && GCCVER=4.6
|
||||
[ -z "$PLATFORMVER" ] && PLATFORMVER=android-14
|
||||
LOCAL_PATH=`dirname $0`
|
||||
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
|
||||
#echo LOCAL_PATH $LOCAL_PATH
|
||||
if which realpath > /dev/null ; then
|
||||
LOCAL_PATH=`realpath $LOCAL_PATH`
|
||||
else
|
||||
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
|
||||
fi
|
||||
ARCH=mips
|
||||
|
||||
APP_MODULES=`grep 'APP_MODULES [:][=]' $LOCAL_PATH/../Settings.mk | sed 's@.*[=]\(.*\)@\1@'`
|
||||
APP_AVAILABLE_STATIC_LIBS=`grep 'APP_AVAILABLE_STATIC_LIBS [:][=]' $LOCAL_PATH/../Settings.mk | sed 's@.*[=]\(.*\)@\1@'`
|
||||
@@ -42,58 +48,54 @@ done
|
||||
MISSING_INCLUDE=
|
||||
MISSING_LIB=
|
||||
|
||||
#if [ -n "$CRYSTAX_WCHAR" ]; then
|
||||
# MISSING_INCLUDE="$MISSING_INCLUDE -isystem$NDK/sources/crystax/include"
|
||||
# MISSING_LIB="$MISSING_LIB $NDK/sources/crystax/libs/armeabi/libcrystax_static.a"
|
||||
#fi
|
||||
#if [ -n "$MISSING_LIBCXX_PATH" ]; then
|
||||
# MISSING_INCLUDE="$MISSING_INCLUDE -isystem$NDK/sources/cxx-stl/gnu-libstdc++/include"
|
||||
# MISSING_LIB="$MISSING_LIB -lgnustl_static -lsupc++"
|
||||
#fi
|
||||
|
||||
CFLAGS="\
|
||||
-fpic -ffunction-sections -funwind-tables -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi \
|
||||
-march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \
|
||||
-isystem$NDK/platforms/$PLATFORMVER/arch-arm/usr/include -Wa,--noexecstack \
|
||||
-DANDROID \
|
||||
-DNDEBUG -O2 -g \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include \
|
||||
-fpic -fno-strict-aliasing -finline-functions -ffunction-sections \
|
||||
-funwind-tables -fmessage-length=0 -fno-inline-functions-called-once \
|
||||
-fgcse-after-reload -frerun-cse-after-loop -frename-registers \
|
||||
-no-canonical-prefixes -O2 -g -DNDEBUG -fomit-frame-pointer \
|
||||
-funswitch-loops -finline-limit=300 \
|
||||
-DANDROID -Wall -Wno-unused -Wa,--noexecstack -Wformat -Werror=format-security \
|
||||
-isystem$NDK/platforms/$PLATFORMVER/arch-mips/usr/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include/backward \
|
||||
-isystem$LOCAL_PATH/../sdl-1.2/include \
|
||||
`echo $APP_MODULES | sed \"s@\([-a-zA-Z0-9_.]\+\)@-isystem$LOCAL_PATH/../\1/include@g\"` \
|
||||
$MISSING_INCLUDE $CFLAGS"
|
||||
|
||||
SHARED="-shared -Wl,-soname,libapplication.so"
|
||||
if [ -z "$SHARED_LIBRARY_NAME" ]; then
|
||||
SHARED_LIBRARY_NAME=libapplication.so
|
||||
fi
|
||||
UNRESOLVED="-Wl,--no-undefined"
|
||||
SHARED="-shared -Wl,-soname,$SHARED_LIBRARY_NAME"
|
||||
if [ -n "$BUILD_EXECUTABLE" ]; then
|
||||
SHARED=
|
||||
SHARED="-Wl,--gc-sections -Wl,-z,nocopyreloc"
|
||||
fi
|
||||
if [ -n "$NO_SHARED_LIBS" ]; then
|
||||
APP_SHARED_LIBS=
|
||||
fi
|
||||
|
||||
if [ -n "$ALLOW_UNRESOLVED_SYMBOLS" ]; then
|
||||
UNRESOLVED=
|
||||
fi
|
||||
|
||||
LDFLAGS="\
|
||||
$SHARED \
|
||||
--sysroot=$NDK/platforms/$PLATFORMVER/arch-arm \
|
||||
`echo $APP_SHARED_LIBS | sed \"s@\([-a-zA-Z0-9_.]\+\)@$LOCAL_PATH/../../obj/local/armeabi/lib\1.so@g\"` \
|
||||
$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libc.so \
|
||||
$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libm.so \
|
||||
$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libGLESv1_CM.so \
|
||||
$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libdl.so \
|
||||
$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/liblog.so \
|
||||
$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib/libz.so \
|
||||
-L$NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi \
|
||||
--sysroot=$NDK/platforms/$PLATFORMVER/arch-mips \
|
||||
-L$LOCAL_PATH/../../obj/local/$ARCH \
|
||||
`echo $APP_SHARED_LIBS | sed \"s@\([-a-zA-Z0-9_.]\+\)@$LOCAL_PATH/../../obj/local/$ARCH/lib\1.so@g\"` \
|
||||
-L$NDK/platforms/$PLATFORMVER/arch-mips/usr/lib \
|
||||
-lc -lm -lGLESv1_CM -ldl -llog -lz \
|
||||
-L$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH \
|
||||
-lgnustl_static \
|
||||
-L$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib \
|
||||
-L$LOCAL_PATH/../../obj/local/armeabi -Wl,--no-undefined -Wl,-z,noexecstack \
|
||||
-Wl,-rpath-link=$NDK/platforms/$PLATFORMVER/arch-arm/usr/lib -lsupc++ \
|
||||
-no-canonical-prefixes $UNRESOLVED -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now \
|
||||
-lsupc++ \
|
||||
$MISSING_LIB $LDFLAGS"
|
||||
|
||||
#echo env CFLAGS=\""$CFLAGS"\" LDFLAGS=\""$LDFLAGS"\" "$@"
|
||||
|
||||
env PATH=$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin:$LOCAL_PATH:$PATH \
|
||||
CFLAGS="$CFLAGS" \
|
||||
CXXFLAGS="$CXXFLAGS $CFLAGS" \
|
||||
CXXFLAGS="$CXXFLAGS $CFLAGS -frtti -fexceptions" \
|
||||
LDFLAGS="$LDFLAGS" \
|
||||
CC="$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-gcc" \
|
||||
CXX="$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-g++" \
|
||||
@@ -1,78 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
IFS='
|
||||
'
|
||||
|
||||
MYARCH=linux-x86
|
||||
if uname -s | grep -i "linux" > /dev/null ; then
|
||||
MYARCH=linux-x86
|
||||
fi
|
||||
if uname -s | grep -i "darwin" > /dev/null ; then
|
||||
MYARCH=darwin-x86
|
||||
fi
|
||||
if uname -s | grep -i "windows" > /dev/null ; then
|
||||
MYARCH=windows-x86
|
||||
fi
|
||||
|
||||
NDK=`which ndk-build`
|
||||
NDK=`dirname $NDK`
|
||||
NDK=`readlink -f $NDK`
|
||||
|
||||
GCCVER=4.4.0
|
||||
PLATFORMVER=android-8
|
||||
LOCAL_PATH=`dirname $0`
|
||||
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
|
||||
STL_INCLUDE="-I$LOCAL_PATH/../stlport/stlport -fno-exceptions -fno-rtti"
|
||||
STL_LIB="$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib/libstdc++.so $LOCAL_PATH/../../obj/local/armeabi/libstlport.a"
|
||||
if [ -n "`echo $NDK | grep '[-]crystax'`" ] ; then
|
||||
STL_INCLUDE="-fexceptions -frtti"
|
||||
STL_LIB="-lstdc++"
|
||||
fi
|
||||
|
||||
APP_MODULES=`grep 'APP_MODULES [:][=]' $LOCAL_PATH/../Settings.mk | sed 's@.*[=]\(.*\)@\1@'`
|
||||
APP_AVAILABLE_STATIC_LIBS=`grep 'APP_AVAILABLE_STATIC_LIBS [:][=]' $LOCAL_PATH/../Settings.mk | sed 's@.*[=]\(.*\)@\1@'`
|
||||
APP_SHARED_LIBS=$(
|
||||
echo $APP_MODULES | xargs -n 1 echo | while read LIB ; do
|
||||
STATIC=`echo $APP_AVAILABLE_STATIC_LIBS application sdl_main stlport stdout-test | grep "\\\\b$LIB\\\\b"`
|
||||
if [ -n "$STATIC" ] ; then true
|
||||
else
|
||||
echo $LIB
|
||||
fi
|
||||
done
|
||||
)
|
||||
|
||||
CFLAGS="-I$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/include \
|
||||
-fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums \
|
||||
-D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DANDROID \
|
||||
-Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -O2 \
|
||||
-fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \
|
||||
-Wa,--noexecstack -DNDEBUG -g \
|
||||
-I$LOCAL_PATH/../sdl-1.2/include $STL_INCLUDE \
|
||||
`echo $APP_MODULES | sed \"s@\([-a-zA-Z0-9_.]\+\)@-I$LOCAL_PATH/../\1/include@g\"`"
|
||||
|
||||
LDFLAGS="-nostdlib -Wl,-soname,libapplication.so -Wl,-shared,-Bsymbolic \
|
||||
-Wl,--whole-archive -Wl,--no-whole-archive \
|
||||
$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/lib/gcc/arm-eabi/4.4.0/libgcc.a \
|
||||
`echo $APP_SHARED_LIBS | sed \"s@\([-a-zA-Z0-9_.]\+\)@$LOCAL_PATH/../../obj/local/armeabi/lib\1.so@g\"` \
|
||||
$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib/libc.so \
|
||||
$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib/libm.so \
|
||||
-Wl,--no-undefined -Wl,-z,noexecstack \
|
||||
-L$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib \
|
||||
-lGLESv1_CM -ldl -llog -lz \
|
||||
-Wl,-rpath-link=$NDK/build/platforms/$PLATFORMVER/arch-arm/usr/lib \
|
||||
-L$LOCAL_PATH/../../obj/local/armeabi $STL_LIB"
|
||||
|
||||
env PATH=$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin:$LOCAL_PATH:$PATH \
|
||||
CFLAGS="$CFLAGS" \
|
||||
CXXFLAGS="$CFLAGS" \
|
||||
LDFLAGS="$LDFLAGS" \
|
||||
CC="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-gcc" \
|
||||
CXX="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-g++" \
|
||||
RANLIB="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-ranlib" \
|
||||
LD="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-gcc" \
|
||||
AR="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-ar" \
|
||||
CPP="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-cpp $CFLAGS" \
|
||||
NM="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-nm" \
|
||||
AS="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-as" \
|
||||
STRIP="$NDK/build/prebuilt/$MYARCH/arm-eabi-$GCCVER/bin/arm-eabi-strip" \
|
||||
"$@"
|
||||
108
project/jni/application/setEnvironment-x86.sh
Executable file
108
project/jni/application/setEnvironment-x86.sh
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/bin/sh
|
||||
|
||||
IFS='
|
||||
'
|
||||
|
||||
MYARCH=linux-x86
|
||||
if uname -s | grep -i "linux" > /dev/null ; then
|
||||
MYARCH=linux-x86
|
||||
fi
|
||||
if uname -s | grep -i "darwin" > /dev/null ; then
|
||||
MYARCH=darwin-x86
|
||||
fi
|
||||
if uname -s | grep -i "windows" > /dev/null ; then
|
||||
MYARCH=windows-x86
|
||||
fi
|
||||
|
||||
NDK=`which ndk-build`
|
||||
NDK=`dirname $NDK`
|
||||
NDK=`readlink -f $NDK`
|
||||
|
||||
grep "64.bit" "$NDK/RELEASE.TXT" >/dev/null 2>&1 && MYARCH="${MYARCH}_64"
|
||||
|
||||
#echo NDK $NDK
|
||||
GCCPREFIX=i686-linux-android
|
||||
[ -z "$GCCVER" ] && GCCVER=4.6
|
||||
[ -z "$PLATFORMVER" ] && PLATFORMVER=android-14
|
||||
LOCAL_PATH=`dirname $0`
|
||||
if which realpath > /dev/null ; then
|
||||
LOCAL_PATH=`realpath $LOCAL_PATH`
|
||||
else
|
||||
LOCAL_PATH=`cd $LOCAL_PATH && pwd`
|
||||
fi
|
||||
ARCH=x86
|
||||
|
||||
APP_MODULES=`grep 'APP_MODULES [:][=]' $LOCAL_PATH/../Settings.mk | sed 's@.*[=]\(.*\)@\1@'`
|
||||
APP_AVAILABLE_STATIC_LIBS=`grep 'APP_AVAILABLE_STATIC_LIBS [:][=]' $LOCAL_PATH/../Settings.mk | sed 's@.*[=]\(.*\)@\1@'`
|
||||
APP_SHARED_LIBS=$(
|
||||
echo $APP_MODULES | xargs -n 1 echo | while read LIB ; do
|
||||
STATIC=`echo $APP_AVAILABLE_STATIC_LIBS application sdl_main stlport stdout-test | grep "\\\\b$LIB\\\\b"`
|
||||
if [ -n "$STATIC" ] ; then true
|
||||
else
|
||||
echo $LIB
|
||||
fi
|
||||
done
|
||||
)
|
||||
|
||||
|
||||
MISSING_INCLUDE=
|
||||
MISSING_LIB=
|
||||
|
||||
CFLAGS="\
|
||||
-ffunction-sections -funwind-tables -no-canonical-prefixes \
|
||||
-fstack-protector -O2 -g -DNDEBUG \
|
||||
-fomit-frame-pointer -fstrict-aliasing -funswitch-loops \
|
||||
-finline-limit=300 \
|
||||
-DANDROID -Wall -Wno-unused -Wa,--noexecstack -Wformat -Werror=format-security \
|
||||
-isystem$NDK/platforms/$PLATFORMVER/arch-x86/usr/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include/backward \
|
||||
-isystem$LOCAL_PATH/../sdl-1.2/include \
|
||||
`echo $APP_MODULES | sed \"s@\([-a-zA-Z0-9_.]\+\)@-isystem$LOCAL_PATH/../\1/include@g\"` \
|
||||
$MISSING_INCLUDE $CFLAGS"
|
||||
|
||||
if [ -z "$SHARED_LIBRARY_NAME" ]; then
|
||||
SHARED_LIBRARY_NAME=libapplication.so
|
||||
fi
|
||||
UNRESOLVED="-Wl,--no-undefined"
|
||||
SHARED="-shared -Wl,-soname,$SHARED_LIBRARY_NAME"
|
||||
if [ -n "$BUILD_EXECUTABLE" ]; then
|
||||
SHARED="-Wl,--gc-sections -Wl,-z,nocopyreloc"
|
||||
fi
|
||||
if [ -n "$NO_SHARED_LIBS" ]; then
|
||||
APP_SHARED_LIBS=
|
||||
fi
|
||||
if [ -n "$ALLOW_UNRESOLVED_SYMBOLS" ]; then
|
||||
UNRESOLVED=
|
||||
fi
|
||||
|
||||
LDFLAGS="\
|
||||
$SHARED \
|
||||
--sysroot=$NDK/platforms/$PLATFORMVER/arch-x86 \
|
||||
-L$LOCAL_PATH/../../obj/local/$ARCH \
|
||||
`echo $APP_SHARED_LIBS | sed \"s@\([-a-zA-Z0-9_.]\+\)@$LOCAL_PATH/../../obj/local/$ARCH/lib\1.so@g\"` \
|
||||
-L$NDK/platforms/$PLATFORMVER/arch-x86/usr/lib \
|
||||
-lc -lm -lGLESv1_CM -ldl -llog -lz \
|
||||
-L$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH \
|
||||
-lgnustl_static \
|
||||
-no-canonical-prefixes $UNRESOLVED -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now \
|
||||
-lsupc++ \
|
||||
$MISSING_LIB $LDFLAGS"
|
||||
|
||||
#echo env CFLAGS=\""$CFLAGS"\" LDFLAGS=\""$LDFLAGS"\" "$@"
|
||||
|
||||
env PATH=$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin:$LOCAL_PATH:$PATH \
|
||||
CFLAGS="$CFLAGS" \
|
||||
CXXFLAGS="$CXXFLAGS $CFLAGS -frtti -fexceptions" \
|
||||
LDFLAGS="$LDFLAGS" \
|
||||
CC="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-gcc" \
|
||||
CXX="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-g++" \
|
||||
RANLIB="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-ranlib" \
|
||||
LD="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-g++" \
|
||||
AR="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-ar" \
|
||||
CPP="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-cpp $CFLAGS" \
|
||||
NM="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-nm" \
|
||||
AS="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-as" \
|
||||
STRIP="$NDK/toolchains/$ARCH-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-strip" \
|
||||
"$@"
|
||||
@@ -49,10 +49,11 @@ MISSING_INCLUDE=
|
||||
MISSING_LIB=
|
||||
|
||||
CFLAGS="\
|
||||
-fpic -ffunction-sections -funwind-tables -fstack-protector -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ \
|
||||
-no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float -mthumb \
|
||||
-fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 \
|
||||
-DANDROID -DNDEBUG -O2 -g -finline-functions -Wa,--noexecstack \
|
||||
-fpic -ffunction-sections -funwind-tables -fstack-protector \
|
||||
-no-canonical-prefixes -march=armv5te -mtune=xscale -msoft-float \
|
||||
-mthumb -O2 -g -DNDEBUG \
|
||||
-fomit-frame-pointer -fno-strict-aliasing -finline-limit=300 \
|
||||
-DANDROID -Wall -Wno-unused -Wa,--noexecstack -Wformat -Werror=format-security \
|
||||
-isystem$NDK/platforms/$PLATFORMVER/arch-arm/usr/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/include \
|
||||
-isystem$NDK/sources/cxx-stl/gnu-libstdc++/$GCCVER/libs/$ARCH/include \
|
||||
@@ -93,7 +94,7 @@ $MISSING_LIB $LDFLAGS"
|
||||
|
||||
env PATH=$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin:$LOCAL_PATH:$PATH \
|
||||
CFLAGS="$CFLAGS" \
|
||||
CXXFLAGS="$CXXFLAGS $CFLAGS" \
|
||||
CXXFLAGS="$CXXFLAGS $CFLAGS -frtti -fexceptions" \
|
||||
LDFLAGS="$LDFLAGS" \
|
||||
CC="$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-gcc" \
|
||||
CXX="$NDK/toolchains/$GCCPREFIX-$GCCVER/prebuilt/$MYARCH/bin/$GCCPREFIX-g++" \
|
||||
|
||||
@@ -2,6 +2,8 @@ LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
|
||||
LOCAL_MODULE := $(notdir $(LOCAL_PATH))
|
||||
ifneq ($(LOCAL_MODULE),boost)
|
||||
|
||||
@@ -11,3 +13,5 @@ LOCAL_SRC_FILES := lib/arm-linux-androideabi-4.6/lib$(LOCAL_MODULE).a
|
||||
include $(PREBUILT_STATIC_LIBRARY)
|
||||
|
||||
endif
|
||||
|
||||
endif # $(TARGET_ARCH),arm
|
||||
|
||||
@@ -1 +1 @@
|
||||
/home/gerstrong/Desktop/commandergenius/project/jni/boost
|
||||
boost
|
||||
@@ -5,6 +5,8 @@
|
||||
LOCAL_PATH:=$(call my-dir)
|
||||
#FFMPEG_REBUILD_FROM_SOURCE:=yes
|
||||
|
||||
ifeq ($(TARGET_ARCH),arm)
|
||||
|
||||
ifneq ($(FFMPEG_REBUILD_FROM_SOURCE),yes)
|
||||
|
||||
# FFMPEG compilation is hacky and buggy, so we're using prebuilt libraries by default
|
||||
@@ -626,5 +628,7 @@ ifeq ($(CONFIG_FFSERVER),yes)
|
||||
endif
|
||||
#========================================================================
|
||||
endif #CONFIG_FFMPEG_COMPILE_TOOLS
|
||||
endif
|
||||
endif
|
||||
|
||||
endif # notdir $(LOCAL_PATH)),ffmpeg
|
||||
endif # FFMPEG_REBUILD_FROM_SOURCE),yes
|
||||
endif # $(TARGET_ARCH),arm
|
||||
|
||||
2
project/jni/guichan/AUTHORS
Normal file
2
project/jni/guichan/AUTHORS
Normal file
@@ -0,0 +1,2 @@
|
||||
Per Larsson finalman at comhem dot se
|
||||
Olof Naessén jansem at darkbits dot org
|
||||
25
project/jni/guichan/Android.mk
Normal file
25
project/jni/guichan/Android.mk
Normal file
@@ -0,0 +1,25 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := guichan
|
||||
|
||||
APP_SUBDIRS := $(patsubst $(LOCAL_PATH)/%, %, $(shell find $(LOCAL_PATH)/src -type d))
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH) $(LOCAL_PATH)/../sdl-$(SDL_VERSION)/include $(LOCAL_PATH)/include \
|
||||
$(LOCAL_PATH)/../sdl_image/include
|
||||
LOCAL_CFLAGS := -DHAVE_CONFIG_H -D_GNU_SOURCE=1 -D_REENTRANT -fexceptions -frtti
|
||||
|
||||
LOCAL_CPP_EXTENSION := .cpp
|
||||
|
||||
LOCAL_SRC_FILES := $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.cpp))))
|
||||
LOCAL_SRC_FILES += $(foreach F, $(APP_SUBDIRS), $(addprefix $(F)/,$(notdir $(wildcard $(LOCAL_PATH)/$(F)/*.c))))
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := sdl-$(SDL_VERSION)
|
||||
LOCAL_SHARED_LIBRARIES += sdl_image
|
||||
|
||||
LOCAL_STATIC_LIBRARIES :=
|
||||
|
||||
LOCAL_LDLIBS :=
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
35
project/jni/guichan/COPYING
Normal file
35
project/jni/guichan/COPYING
Normal file
@@ -0,0 +1,35 @@
|
||||
Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
|
||||
Per Larsson a.k.a finalman
|
||||
Olof Naessén a.k.a jansem/yakslem
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided
|
||||
that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above
|
||||
copyright notice, this list of conditions and the
|
||||
following disclaimer.
|
||||
* Redistributions in binary form must reproduce the
|
||||
above copyright notice, this list of conditions and
|
||||
the following disclaimer in the documentation and/or
|
||||
other materials provided with the distribution.
|
||||
* Neither the name of Guichan nor the names of its
|
||||
contributors may be used to endorse or promote
|
||||
products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||||
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
|
||||
WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGE.
|
||||
211
project/jni/guichan/ChangeLog
Normal file
211
project/jni/guichan/ChangeLog
Normal file
@@ -0,0 +1,211 @@
|
||||
Version 0.6.1
|
||||
=============
|
||||
* The functions add, remove and clear have been removed from Widget.
|
||||
They now reside protected in basic container.
|
||||
* Inclusion of OpenGL headers has been fixed on Mac.
|
||||
|
||||
Version 0.6.0
|
||||
=============
|
||||
* A lot of function definitions from BasicContainer have been moved down to
|
||||
Widget, but Widget doesn't provide any useful implementations of these
|
||||
functions. Useful implementations still reside in BasicContainer.
|
||||
For container widget implementations inheriting from BasicContainer, as before,
|
||||
should work just fine. The reason for the move of definitions is to be able to
|
||||
consider a widget a container for the sake of simplicity when it comes to
|
||||
distribution of input.
|
||||
* The functions Widget::lostFocus andWidget::gotFocus have been renamed to
|
||||
Widget::focusLost and Widget::focusGained.
|
||||
* DeathListener is a new interface which can be used to listen for a widget's
|
||||
death. Because of the presence of death listeners the function
|
||||
BasicContainer::_announceDeath has been removed.
|
||||
* MouseListener now has the function mouseDragged which is called if a widget
|
||||
is dragged.
|
||||
* All distribution of input is now handled by the Gui class. Because of this
|
||||
all functions regarding input have been removed from the classes Widget
|
||||
and BasicContainer.
|
||||
* All functions of KeyListener and MouseListener have been renamed. The reason
|
||||
for this is that the functions now bear the names of the well known Java
|
||||
listeners which will hopefully be more intuitive for most people.
|
||||
* All input events can now be consumed making it easier to implement hot key
|
||||
bindings.
|
||||
* Mouse input (now called mouse events) are now distributed bottom up starting
|
||||
from the widget directly under the mouse.
|
||||
* Widgets can now ask for modal mouse input focus. A widget with modal mouse input
|
||||
focus will be the only widget recieving mouse input, no matter where the mouse
|
||||
input occurs. This can be very useful for some widgets, like a drop down which
|
||||
acquires modal mouse input focus when folded down to be able to fold back up as
|
||||
soon as the mouse is pressed outside of the drop down.
|
||||
* Events are now present in Guichan. All listener classes now take event classes
|
||||
as parameters which is a very big API change. The presence of events has propagated
|
||||
changes to all input classes to better reflect the new usage of events.
|
||||
* DropDown now acts on mouse wheel up and mouse wheel down when having focus.
|
||||
* ListBox now acts on mouse wheel up and mouse wheel down when having focus.
|
||||
* Widgets will no longer acquire focus if a mouse wheel up or a mouse wheel down
|
||||
occurs over a widget.
|
||||
* The header exception.hpp is now included properly in openglsdlimageloader.hpp.
|
||||
* Many small fixes.
|
||||
|
||||
Version 0.5.0
|
||||
=============
|
||||
* Slider now acts on the mouse wheel moving the slider to the left on
|
||||
mouse wheel down and to the right on mouse wheen up.
|
||||
* ListBox now has the ability to wrap keyboard selection. Wrapping means
|
||||
that if the key up is pressed and the first item is selected, then
|
||||
the last item will get selected. If the key down is pressed and the last
|
||||
item is selected, then the first item will get selected.
|
||||
* Redesign of the Image class. Image now has different subclasses for
|
||||
different Graphics objects. The static method load in the Image class
|
||||
loads the appropiate type of image if an ImageLoader is set.
|
||||
* The function action in ActionListener now takes a pointer to the
|
||||
Widget who called the function, it makes handling of action events,
|
||||
hopefully, cleaner.
|
||||
* ScrollArea now scrolls if the open space around the markers is clicked.
|
||||
* ScrollArea now has functions to set the amount to scroll when ScrollArea's
|
||||
buttons are pushed, each button can have it's own amount.
|
||||
* Changed the function name of Widget::hasFocus and FocusHandler::hasFocus
|
||||
to isFocused.
|
||||
* Moved a lot of common container functionality into BasicContainer.
|
||||
This made the code and API a lot cleaner. Affected classes are:
|
||||
BasicContainer - now holds a lot of common functionality for containers.
|
||||
Container - implementation is now a lot smaller.
|
||||
Window - window now inherits from Container and can have several child
|
||||
widgets.
|
||||
ScrollArea - smaller, nicer code.
|
||||
TextBox & ListBox - Takes advantage of the new Container API to get rid
|
||||
of a dynamic cast.
|
||||
* Added drawBackground to ScrollArea to simplify overloading.
|
||||
* Added functions for global KeyListeners in Gui. Global KeyListeners
|
||||
can be just about any object inheriting from KeyListener.
|
||||
* Fixed an offset by one error in AllegroGraphics::_beginDraw.
|
||||
The initial clip area is now correct.
|
||||
* Added alpha blending with SDL for 16bpp and 24 bpp mode.
|
||||
|
||||
Version 0.4.0
|
||||
=============
|
||||
* The GCN_EXCEPTION macro is now capable of determine the function in
|
||||
which the exception was thrown. Also, you can get the function name
|
||||
from the Exception class.
|
||||
* Added a fix to make both versions of drawImage in
|
||||
AllegroGraphics, OpenGLGraphics and SDLGraphics visible
|
||||
and usable.
|
||||
* Optimized fillRect in SDLGraphics slightly when using alpha
|
||||
blending. However, SDLGraphics still needs a lot of optimizing
|
||||
in other parts.
|
||||
* Removed the filename from the Image class, as it wasn't really
|
||||
used for anything.
|
||||
* Updated ImageFont with support for font images with several rows
|
||||
of glyphs.
|
||||
* Added modal focus to widgets. Widgets can now request modal focus
|
||||
stealing all input from other widgets. Can be useful when making
|
||||
dialog windows.
|
||||
* Many small fixes.
|
||||
|
||||
Version 0.3.0
|
||||
=============
|
||||
* Every Guichan library now contains a C function which can be
|
||||
used with autotools check, for instance the Guichan SDL library
|
||||
contains the function gcnSDL wich can be used when struggling
|
||||
with autoconf. Other functions are gcnAllegro in Guichan Allegro,
|
||||
gcnOpenGL in Guichan OpenGL and gcnGuichanVersion in the Guichan
|
||||
core.
|
||||
* Slider now stores only the current selected value and calculates
|
||||
everything from that value. It should take care of some resizing
|
||||
problems. Also, slider has now an orientation, which means you can
|
||||
create a slider which has a vertical or horizontal orientation.
|
||||
The previous slider had only a horizontal orientation.
|
||||
* Fixed alpha problem with images loaded and displayed with SDL.
|
||||
* Added a new widget, the window widget.
|
||||
* SDL.h is now included the proper way meaning you can install
|
||||
SDL anywhere and Guichan will include the right headers as long
|
||||
as sdl-config knows where the headers are.
|
||||
* Added ability to disable widgets.
|
||||
* Changed slightly how focus works. Focus is now applied after the
|
||||
input is processed. This resolved some problems when widgets
|
||||
fight over focus.
|
||||
* Changed the behaviour of the mouse handling. Widgets will get
|
||||
mouse input if the mouse is dragged outside of the widget,
|
||||
even if they don't have focus.
|
||||
* Many small fixes.
|
||||
|
||||
Version 0.2.0
|
||||
=============
|
||||
* Added isPressed() method to the Button.
|
||||
* Doubleclicking now works with SDL
|
||||
* Added --enable-force argument for Allegro, SDL, SDL Image and OpenGL
|
||||
to the configure script which forces Guichan to compile with the
|
||||
forced support.
|
||||
* Updated platform.hpp to be able to handle compilation with MinGW.
|
||||
* Splited DECLSPEC define into GCN_CORE_DECLSPEC and
|
||||
GCN_EXTENSION_DECLSPEC.
|
||||
* Fixed bugs in ScrollArea and DropDown involving focus and mouse input,
|
||||
* Changed the look when CheckBox is marked.
|
||||
* Changed the look when CheckBox and RadioButton are focused.
|
||||
They now draw a rectangle around their captions (common behaivour in Guis).
|
||||
* Removed unaccesary logic functions (which didn't do anything) in
|
||||
widget RadioButton and CheckBox.
|
||||
* Added a new widget called Slider, and it is a... slider!
|
||||
* Removed getWidth for glyphs in Font.
|
||||
* Removed function drawGlyph in Font and in addon SDLTrueTypeFont.
|
||||
Added drawGlyph function in ImageFont and DefaultFont.
|
||||
drawGlyph in Font is easy to missunderstand and could lead to
|
||||
strange implementations of Font.
|
||||
* Added getCurrentClipArea function in Graphics.
|
||||
* All functions in container are now virtual (thanks to Garo pointing this out).
|
||||
* Added function setSize in Widget.
|
||||
* Added an "addons" directory in the distrobution. It will contain
|
||||
usefull classes with Guichan that are not compiled into the library.
|
||||
They are not compiled because they need dependencies other then
|
||||
Guichans or are to specific. For now, "addons" only contain one
|
||||
class, SDLTrueTypeFont giving True Type Font abilities to Guichan
|
||||
through the SDL_ttf library and hence will only work with SDLGraphics.
|
||||
SDLTrueTypeFont was contributed by Walluce Pinkham (and edited by us).
|
||||
Thank you Walluce!
|
||||
* Added getColor function in Graphics. Implemented in SDLGraphics,
|
||||
AllegroGraphics and OpenGLGraphics.
|
||||
* Fixed a problem with the DropDown widget. When the widget was focused
|
||||
with a mouse press, you couldn't select elements with up and down keys.
|
||||
* Merged drawText, drawTextCenter and drawTextRight into one function
|
||||
drawText which takes an alignment parameter (thanks Ted!).
|
||||
Widgets taking advantage of this are Button and Label.
|
||||
* As a result of the added border support, almost every widget have
|
||||
been changed for the better, e.g removal of offsets.
|
||||
* Added support for borders. This is a major API change introducing
|
||||
some new functions to Widget.
|
||||
* Lots of small bugfixes
|
||||
|
||||
Version 0.1.0
|
||||
=============
|
||||
* Guichan_allegro MSVC 6 compatibility fix.
|
||||
* TextBox doesn't draw its caret if its not editable.
|
||||
* Better exception with more information in ImageFont,
|
||||
added row spacing and glyph spacing functions.
|
||||
* Fixed problem in ImageFont when loading a corrupt file.
|
||||
It will now throw an exception (thanks Terin!).
|
||||
* Implemented _getRawData() in AllegroImageLoader.
|
||||
* Fixed Image. It is now overloadable.
|
||||
* DropDown sets the colors for its internal widgets if they are
|
||||
not custom widgets (not given to the DropDown by the user).
|
||||
* Now all default widgets respect the alpha channel in the colors.
|
||||
* Non focusable widgets will now not recieve key input ever.
|
||||
In previous version, focused widgets would still remain focused
|
||||
after setting them to not be focusable.
|
||||
* Moved tab handling from Gui to the FocusHandler.
|
||||
* Splitted setTabable to setTabInEnabled and setTabOutEnabled.
|
||||
Widgets can now have different behaviours on tab in and tab out.
|
||||
The old setTabable is equivalent to setTabInEnabled.
|
||||
* isVisisble now checks if parent is visible
|
||||
* Added alpha channel support in AllegroGraphics for
|
||||
drawing primitives
|
||||
* Added experimental alpha channel support in SDLGraphics
|
||||
for 32 bpp
|
||||
* Added full alpha channel support in OpenGLGraphics
|
||||
* Fixed OpenGL graphics to disable GL_LIGHTING before draw
|
||||
* Fixed container problem. Nonvisible widgets no longer
|
||||
recieves mouse input.
|
||||
* Fixed mouse out problem with SDLInput
|
||||
* Fixed alpha problem with the SDLImageLoader
|
||||
|
||||
|
||||
Version 0.0.1
|
||||
=============
|
||||
* Initial release
|
||||
58
project/jni/guichan/NEWS
Normal file
58
project/jni/guichan/NEWS
Normal file
@@ -0,0 +1,58 @@
|
||||
2008-01-23 Eigth Beta release Guichan 0.6.1
|
||||
|
||||
A small update compared to the 0.6.0 release which fixes a prolem
|
||||
with inclusion OpenGL headers on Macintosh and removes some unneccesary
|
||||
container functions from Widget.
|
||||
|
||||
2007-01-14 Seventh Beta release Guichan 0.6.0
|
||||
|
||||
We are getting closer and closer to a final stable 1.0 release. This
|
||||
release introduced events to Guichan. The way Guichan handles input
|
||||
has been refactored and should now be powerfull and flexible.
|
||||
|
||||
2006-06-29 Sixth Beta release Guichan 0.5.0
|
||||
|
||||
After a long awating comes the sixth beta release of Guichan. The major
|
||||
change since the last version is a refactoring of the way Guichan handles
|
||||
images, it should now be easier to extend Guichan with backends for
|
||||
graphics handling. Also, containers have gone through a refactoring as
|
||||
well making it much easier to make container widgets of your own.
|
||||
|
||||
2005-05-17 Fith Beta release (and Norways national day) Guichan 0.4.0
|
||||
|
||||
And here comes yet yet another beta release of Guichan. The major
|
||||
feature add to this version is modal focus. For a complete list
|
||||
of changes, see the ChangeLog.
|
||||
|
||||
2005-03-18 Fourth Beta release Guichan 0.3.0
|
||||
|
||||
And here comes yet another beta release of Guichan. This time
|
||||
we have included everything we didn't have time to include for
|
||||
the 0.2.0 release. For a complete list of changes, see the
|
||||
ChangeLog.
|
||||
|
||||
Again a big thank you to Thorbjørn Lindeijer. This Guichan release
|
||||
contains many API improvements suggested by Thorbjørn.
|
||||
|
||||
2004-12-17 Third Beta release Guichan 0.2.0
|
||||
|
||||
Here comes a new version of Guichan! This could be seen as
|
||||
a "half release" of sorts, there were some things we would have
|
||||
liked to put in this release, but didn't. We felt it was more
|
||||
important to get a new version out before christmas, as a lot of
|
||||
bugs had been fixed. See the ChangeLog for further details.
|
||||
|
||||
Big thanks goes to Thorbjørn Lindeijer and the rest of
|
||||
"The Mana World"-team for helping in finding bugs, and suggesting
|
||||
API improvements (that you probably will see implemented in 0.3.0)
|
||||
|
||||
2004-09-24 Second Beta release Guichan 0.1.0
|
||||
|
||||
Ten days after the first Beta comes the second which contains
|
||||
some improvments, bug fixes and new implementations. For a
|
||||
complete list of changes, check out the ChangeLog.
|
||||
|
||||
2004-09-14 First Beta release Guichan 0.0.1
|
||||
|
||||
The first Guichan API is ready for testing and evaluation.
|
||||
Please send us feedbacks.
|
||||
58
project/jni/guichan/README
Normal file
58
project/jni/guichan/README
Normal file
@@ -0,0 +1,58 @@
|
||||
IMPORTANT!
|
||||
=========
|
||||
Guichan is currently in a beta stage. This means that the API is not fixed and may
|
||||
change in the future. Every API change will break compatibility between older
|
||||
versions of Guichan.
|
||||
|
||||
INTRODUCTON TO GUICHAN
|
||||
======================
|
||||
Guichan is a C++ GUI library designed for games. It comes with a standard set of
|
||||
'widgets' and can use several different objects for displaying graphics and
|
||||
capturing user input.
|
||||
Guichan has an abstract design which allows users of Guichan to use different
|
||||
objects for displaying of graphics and grabbing of user input. Guichan comes with
|
||||
three implemented graphics objects (SDLGraphics, OpenGLGraphics and AllegroGraphics)
|
||||
and two implemented input objects (SDLInput and AllegroInput). Due to Guichan's
|
||||
extendible nature, new objects can also be created by the developer to suit their
|
||||
needs.
|
||||
As Guichan is designed for games, Guichan lacks many features of more advanced GUI
|
||||
libraries (such as GTK and QT). However, a game developer may not normally require
|
||||
all the advanced features of the larger GUI libraries. Guichan aims to keep small
|
||||
and simple, thus avoiding the complication and large dependencies found with some
|
||||
other GUI libraries. Guichan is small but contains all basic GUI features making it
|
||||
ideal for games.
|
||||
|
||||
Guichan allows the developer control over the initialization of external libraries,
|
||||
giving a degree of freedom which is almost required in game development, but not
|
||||
provided by some GUI libraries. Guichan should not be considered a full GUI library
|
||||
but rather a tool or helper library for game development.
|
||||
|
||||
The basic nature of Guichan means that it comes with a small number of default
|
||||
widgets. There exists no themes or theme handling for Guichan, as their
|
||||
implementation would increase the size and complexity of the library unnecessarily.
|
||||
Instead, the developer creates their own new widgets by inheriting from the standard
|
||||
widgets or by overloading standard widget functions. This makes Guichan much more
|
||||
flexible for customisation than theme based GUIs, and more natural to use for C++
|
||||
developers, as they need only learn the API instead of a whole new theming system.
|
||||
|
||||
FOR MORE INFORMATION AND DOWNLOADS
|
||||
==================================
|
||||
For more general information about Guichan and/or downloads related to Guichan
|
||||
please visit the Guichan homepage at http://guichan.sourceforge.net.
|
||||
|
||||
GETTING HELP WITH GUICHAN
|
||||
=========================
|
||||
If you need help with Guichan, the best way to proceed is to ask questions either
|
||||
by joining the users mailing list or by joining our forum. Information about
|
||||
Guichan's mailing lists and our forum is found at the Guichan homepate at
|
||||
http://guichan.sourceforge.net.
|
||||
|
||||
|
||||
GETTING INVOLVED WITH GUICHAN DEVELOPMENT
|
||||
=========================================
|
||||
If you want to get involved with Guichan development, the best way to proceed is to
|
||||
suggest improvements to Guichan either by joining the developers mailing list or
|
||||
by joining our forum. Information about Guichan's mailing lists and our forum is
|
||||
found at the Guichan homepate at http://guichan.sourceforge.net.
|
||||
|
||||
By Olof Naessén 2006-06-30.
|
||||
75
project/jni/guichan/include/config.hpp
Normal file
75
project/jni/guichan/include/config.hpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/* include/config.hpp. Generated from config.hpp.in by configure. */
|
||||
/* include/config.hpp.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <allegro.h> header file. */
|
||||
/* #undef HAVE_ALLEGRO_H */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the <GL/gl.h> header file. */
|
||||
/* #undef HAVE_GL_GL_H */
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#define HAVE_MEMORY_H 1
|
||||
|
||||
/* Define to 1 if you have the <SDL/SDL.h> header file. */
|
||||
#define HAVE_SDL_SDL_H 1
|
||||
|
||||
/* Define to 1 if you have the <SDL/SDL_image.h> header file. */
|
||||
#define HAVE_SDL_SDL_IMAGE_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "guichan"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT "olof.naessen@gmail.com"
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "guichan"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "guichan 0.8.2"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "guichan"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "0.8.2"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.8.2"
|
||||
74
project/jni/guichan/include/config.hpp.in
Normal file
74
project/jni/guichan/include/config.hpp.in
Normal file
@@ -0,0 +1,74 @@
|
||||
/* include/config.hpp.in. Generated from configure.in by autoheader. */
|
||||
|
||||
/* Define to 1 if you have the <allegro.h> header file. */
|
||||
#undef HAVE_ALLEGRO_H
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <GL/gl.h> header file. */
|
||||
#undef HAVE_GL_GL_H
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define to 1 if you have the <SDL/SDL.h> header file. */
|
||||
#undef HAVE_SDL_SDL_H
|
||||
|
||||
/* Define to 1 if you have the <SDL/SDL_image.h> header file. */
|
||||
#undef HAVE_SDL_SDL_IMAGE_H
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
#undef LT_OBJDIR
|
||||
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#undef PACKAGE_URL
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
111
project/jni/guichan/include/guichan.hpp
Normal file
111
project/jni/guichan/include/guichan.hpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_GUICHAN_HPP
|
||||
#define GCN_GUICHAN_HPP
|
||||
|
||||
#include <guichan/actionevent.hpp>
|
||||
#include <guichan/actionlistener.hpp>
|
||||
#include <guichan/cliprectangle.hpp>
|
||||
#include <guichan/color.hpp>
|
||||
#include <guichan/deathlistener.hpp>
|
||||
#include <guichan/event.hpp>
|
||||
#include <guichan/exception.hpp>
|
||||
#include <guichan/focushandler.hpp>
|
||||
#include <guichan/focuslistener.hpp>
|
||||
#include <guichan/font.hpp>
|
||||
#include <guichan/genericinput.hpp>
|
||||
#include <guichan/graphics.hpp>
|
||||
#include <guichan/gui.hpp>
|
||||
#include <guichan/image.hpp>
|
||||
#include <guichan/imagefont.hpp>
|
||||
#include <guichan/imageloader.hpp>
|
||||
#include <guichan/input.hpp>
|
||||
#include <guichan/inputevent.hpp>
|
||||
#include <guichan/key.hpp>
|
||||
#include <guichan/keyevent.hpp>
|
||||
#include <guichan/keyinput.hpp>
|
||||
#include <guichan/keylistener.hpp>
|
||||
#include <guichan/listmodel.hpp>
|
||||
#include <guichan/mouseevent.hpp>
|
||||
#include <guichan/mouseinput.hpp>
|
||||
#include <guichan/mouselistener.hpp>
|
||||
#include <guichan/rectangle.hpp>
|
||||
#include <guichan/selectionevent.hpp>
|
||||
#include <guichan/selectionlistener.hpp>
|
||||
#include <guichan/widget.hpp>
|
||||
#include <guichan/widgetlistener.hpp>
|
||||
#include <guichan/widgets/button.hpp>
|
||||
#include <guichan/widgets/checkbox.hpp>
|
||||
#include <guichan/widgets/container.hpp>
|
||||
#include <guichan/widgets/dropdown.hpp>
|
||||
#include <guichan/widgets/icon.hpp>
|
||||
#include <guichan/widgets/imagebutton.hpp>
|
||||
#include <guichan/widgets/label.hpp>
|
||||
#include <guichan/widgets/listbox.hpp>
|
||||
#include <guichan/widgets/scrollarea.hpp>
|
||||
#include <guichan/widgets/slider.hpp>
|
||||
#include <guichan/widgets/radiobutton.hpp>
|
||||
#include <guichan/widgets/tab.hpp>
|
||||
#include <guichan/widgets/tabbedarea.hpp>
|
||||
#include <guichan/widgets/textbox.hpp>
|
||||
#include <guichan/widgets/textfield.hpp>
|
||||
#include <guichan/widgets/window.hpp>
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
|
||||
class Widget;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* Gets the the version of Guichan. As it is a C function
|
||||
* it can be used to check for Guichan with autotools.
|
||||
*
|
||||
* @return the version of Guichan.
|
||||
*/
|
||||
GCN_CORE_DECLSPEC extern const char* gcnGuichanVersion();
|
||||
}
|
||||
|
||||
#endif // end GCN_GUICHAN_HPP
|
||||
114
project/jni/guichan/include/guichan/actionevent.hpp
Normal file
114
project/jni/guichan/include/guichan/actionevent.hpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_ACTIONEVENT_HPP
|
||||
#define GCN_ACTIONEVENT_HPP
|
||||
|
||||
#include "guichan/event.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Widget;
|
||||
|
||||
/**
|
||||
* Represents an action event. An action event is an event
|
||||
* that can be fired by a widget whenever an action has occured.
|
||||
* What exactly an action is is up to the widget that fires
|
||||
* the action event. An example is a Button which fires an action
|
||||
* event as soon as the Button is clicked, another example is
|
||||
* TextField which fires an action event as soon as the enter
|
||||
* key is pressed.
|
||||
*
|
||||
* Any object can listen for actions from widgets by implementing
|
||||
* the ActionListener interface.
|
||||
*
|
||||
* If you have implement a widget of your own it's a good idea to
|
||||
* let the widget fire action events whenever you feel an action
|
||||
* has occured so action listeners of the widget can be informed
|
||||
* of the state of the widget.
|
||||
*
|
||||
* @see Widget::addActionListener, Widget::removeActionListener,
|
||||
* Widget::distributeActionEvent
|
||||
* @author Olof Naessén
|
||||
* @since 0.6.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ActionEvent: public Event
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source The source widget of the event.
|
||||
* @param id An identifier of the event.
|
||||
*/
|
||||
ActionEvent(Widget* source, const std::string& id);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ActionEvent();
|
||||
|
||||
/**
|
||||
* Gets the identifier of the event. An identifier can
|
||||
* be used to distinguish from two actions from the same
|
||||
* widget or to let many widgets fire the same widgets
|
||||
* that should be treated equally.
|
||||
*
|
||||
* @return The identifier of the event.
|
||||
*/
|
||||
const std::string& getId() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the identifier of the event.
|
||||
*/
|
||||
std::string mId;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // GCN_ACTIONEVENT_HPP
|
||||
|
||||
93
project/jni/guichan/include/guichan/actionlistener.hpp
Normal file
93
project/jni/guichan/include/guichan/actionlistener.hpp
Normal file
@@ -0,0 +1,93 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_ACTIONLISTENER_HPP
|
||||
#define GCN_ACTIONLISTENER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/actionevent.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Interface for listening for action events from widgets.
|
||||
*
|
||||
* @see Widget::addActionListener, Widget::removeActionListener,
|
||||
* ActionEvent
|
||||
* @author Olof Naessén
|
||||
* @author Per Larsson
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ActionListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ActionListener() { }
|
||||
|
||||
/**
|
||||
* Called when an action is recieved from a widget. It is used
|
||||
* to be able to recieve a notification that an action has
|
||||
* occured.
|
||||
*
|
||||
* @param actionEvent The event of the action.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void action(const ActionEvent& actionEvent) = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* You should not be able to make an instance of ActionListener,
|
||||
* therefore its constructor is protected.
|
||||
*/
|
||||
ActionListener() { }
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_ACTIONLISTENER_HPP
|
||||
63
project/jni/guichan/include/guichan/allegro.hpp
Normal file
63
project/jni/guichan/include/guichan/allegro.hpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_ALLEGRO_HPP
|
||||
#define GCN_ALLEGRO_HPP
|
||||
|
||||
#include <guichan/allegro/allegrofont.hpp>
|
||||
#include <guichan/allegro/allegrographics.hpp>
|
||||
#include <guichan/allegro/allegroimage.hpp>
|
||||
#include <guichan/allegro/allegroimageloader.hpp>
|
||||
#include <guichan/allegro/allegroinput.hpp>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* Exists to be able to check for Guichan Allegro with autotools.
|
||||
*
|
||||
* @bug Autotools is incapable of finding this function.
|
||||
*/
|
||||
extern void gcnAllegro();
|
||||
}
|
||||
|
||||
#endif // end GCN_ALLEGRO_HPP
|
||||
180
project/jni/guichan/include/guichan/basiccontainer.hpp
Normal file
180
project/jni/guichan/include/guichan/basiccontainer.hpp
Normal file
@@ -0,0 +1,180 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_BASICCONTAINER_HPP
|
||||
#define GCN_BASICCONTAINER_HPP
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "guichan/deathlistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widget.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* A base class for containers. The class implements the most
|
||||
* common things for a container. If you are implementing a
|
||||
* container, consider inheriting from this class.
|
||||
*
|
||||
* @see Container
|
||||
* @since 0.6.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC BasicContainer : public Widget, public DeathListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~BasicContainer();
|
||||
|
||||
/**
|
||||
* Shows a certain part of a widget in the basic container.
|
||||
* Used when widgets want a specific part to be visible in
|
||||
* its parent. An example is a TextArea that wants a specific
|
||||
* part of its text to be visible when a TextArea is a child
|
||||
* of a ScrollArea.
|
||||
*
|
||||
* @param widget The widget whom wants a specific part of
|
||||
* itself to be visible.
|
||||
* @param rectangle The rectangle to be visible.
|
||||
*/
|
||||
virtual void showWidgetPart(Widget* widget, Rectangle area);
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void moveToTop(Widget* widget);
|
||||
|
||||
virtual void moveToBottom(Widget* widget);
|
||||
|
||||
virtual Rectangle getChildrenArea();
|
||||
|
||||
virtual void focusNext();
|
||||
|
||||
virtual void focusPrevious();
|
||||
|
||||
virtual void logic();
|
||||
|
||||
virtual void _setFocusHandler(FocusHandler* focusHandler);
|
||||
|
||||
void setInternalFocusHandler(FocusHandler* focusHandler);
|
||||
|
||||
virtual Widget *getWidgetAt(int x, int y);
|
||||
|
||||
|
||||
// Inherited from DeathListener
|
||||
|
||||
virtual void death(const Event& event);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Adds a widget to the basic container.
|
||||
*
|
||||
* @param widget The widget to add.
|
||||
* @see remove, clear
|
||||
*/
|
||||
void add(Widget* widget);
|
||||
|
||||
/**
|
||||
* Removes a widget from the basic container.
|
||||
*
|
||||
* @param widget The widget to remove.
|
||||
* @see add, clear
|
||||
*/
|
||||
virtual void remove(Widget* widget);
|
||||
|
||||
/**
|
||||
* Clears the basic container from all widgets.
|
||||
*
|
||||
* @see remove, clear
|
||||
*/
|
||||
virtual void clear();
|
||||
|
||||
/**
|
||||
* Draws the children widgets of the basic container.
|
||||
*
|
||||
* @param graphics A graphics object to draw with.
|
||||
*/
|
||||
virtual void drawChildren(Graphics* graphics);
|
||||
|
||||
/**
|
||||
* Calls logic for the children widgets of the basic
|
||||
* container.
|
||||
*/
|
||||
virtual void logicChildren();
|
||||
|
||||
/**
|
||||
* Finds a widget given an id. This function can be useful
|
||||
* when implementing a GUI generator for Guichan, such as
|
||||
* the ability to create a Guichan GUI from an XML file.
|
||||
*
|
||||
* @param id The id to find a widget by.
|
||||
* @return The widget with the corrosponding id,
|
||||
NULL of no widget is found.
|
||||
*/
|
||||
virtual Widget* findWidgetById(const std::string& id);
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef std::list<Widget *> WidgetList;
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef WidgetList::iterator WidgetListIterator;
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef WidgetList::reverse_iterator WidgetListReverseIterator;
|
||||
|
||||
/**
|
||||
* Holds all widgets of the basic container.
|
||||
*/
|
||||
WidgetList mWidgets;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_BASICCONTAINER_HPP
|
||||
109
project/jni/guichan/include/guichan/cliprectangle.hpp
Normal file
109
project/jni/guichan/include/guichan/cliprectangle.hpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_CLIPRECTANGLE_HPP
|
||||
#define GCN_CLIPRECTANGLE_HPP
|
||||
|
||||
#include "guichan/rectangle.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* A rectangle used when dealing with clipping. A clip rectangle is
|
||||
* a regular rectangle extended with variables for x offsets and y
|
||||
* offsets. The offsets are used for calculations from relative
|
||||
* screen coordinates to actual screen coordinates.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ClipRectangle : public Rectangle
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
ClipRectangle();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param x The rectangle x coordinate.
|
||||
* @param y The rectangle y coordinate.
|
||||
* @param width The rectangle width.
|
||||
* @param height The rectangle height.
|
||||
* @param xOffset The offset of the x coordinate. Used to for
|
||||
* calculating the actual screen coordinate from
|
||||
* the relative screen coordinate.
|
||||
* @param yOffset The offset of the y coordinate. Used to for
|
||||
* calculating the actual screen coordinate from
|
||||
* the relative screen coordinate.
|
||||
*/
|
||||
ClipRectangle(int x,
|
||||
int y,
|
||||
int width,
|
||||
int height,
|
||||
int xOffset,
|
||||
int yOffset);
|
||||
|
||||
/**
|
||||
* Copy constructor. Copies x, y, width and height
|
||||
* field from a rectangle to a clip rectangle.
|
||||
*
|
||||
* @param other The rectangle to copy data from.
|
||||
* @returns A clip rectangle with data copyied from a rectangle.
|
||||
*/
|
||||
const ClipRectangle& operator=(const Rectangle& other);
|
||||
|
||||
/**
|
||||
* Holds the x offset of the x coordinate.
|
||||
*/
|
||||
int xOffset;
|
||||
|
||||
/**
|
||||
* Holds the y offset of the y coordinate.
|
||||
*/
|
||||
int yOffset;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_CLIPRECTANGLE_HPP
|
||||
173
project/jni/guichan/include/guichan/color.hpp
Normal file
173
project/jni/guichan/include/guichan/color.hpp
Normal file
@@ -0,0 +1,173 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_COLOR_HPP
|
||||
#define GCN_COLOR_HPP
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Represents a color with red, green, blue and alpha components.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Color
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Initializes the color to black.
|
||||
*/
|
||||
Color();
|
||||
|
||||
/**
|
||||
* Constructor. Constructs a color from the bytes in an integer.
|
||||
* Call it with a hexadecimal constant for HTML-style color representation.
|
||||
* The alpha component is 255 by default.
|
||||
*
|
||||
* EXAMPLE: Color(0xff50a0) constructs a very nice pinkish color.
|
||||
*
|
||||
* NOTE: Because of this constructor, integers will be automatically
|
||||
* casted to a color by your compiler.
|
||||
*
|
||||
* @param color The color to initialise the object with.
|
||||
*/
|
||||
Color(int color);
|
||||
|
||||
/**
|
||||
* Constructor. The default alpha value is 255.
|
||||
*
|
||||
* @param r Red color component (range 0-255).
|
||||
* @param g Green color component (range 0-255).
|
||||
* @param b Blue color component (range 0-255).
|
||||
* @param a Alpha, used for transparency. A value of 0 means
|
||||
* totaly transparent, 255 is totaly opaque.
|
||||
*/
|
||||
Color(int r, int g, int b, int a = 255);
|
||||
|
||||
/**
|
||||
* Adds the RGB values of two colors together. The values will be
|
||||
* clamped if they go out of range.
|
||||
*
|
||||
* WARNING: This function will reset the alpha value of the
|
||||
* returned color to 255.
|
||||
*
|
||||
* @param color A color to add to this color.
|
||||
* @return The added colors with an alpha value set to 255.
|
||||
*/
|
||||
Color operator+(const Color& color) const;
|
||||
|
||||
/**
|
||||
* Subtracts the RGB values of one color from another.
|
||||
* The values will be clamped if they go out of range.
|
||||
*
|
||||
* WARNING: This function will reset the alpha value of the
|
||||
* returned color to 255.
|
||||
*
|
||||
* @param color A color to subtract from this color.
|
||||
* @return The subtracted colors with an alpha value set to 255.
|
||||
*/
|
||||
Color operator-(const Color& color) const;
|
||||
|
||||
/**
|
||||
* Multiplies the RGB values of a color with a float value.
|
||||
* The values will be clamped if they go out of range.
|
||||
*
|
||||
* @param value The value to multiply the color with.
|
||||
* @return The multiplied colors. The alpha value will, unlike
|
||||
* the add and subtract operations, be multiplied as
|
||||
* well.
|
||||
*/
|
||||
Color operator*(float value) const;
|
||||
|
||||
/**
|
||||
* Compares two colors.
|
||||
*
|
||||
* @return True if the two colors have the same RGBA components
|
||||
* false otherwise.
|
||||
*/
|
||||
bool operator==(const Color& color) const;
|
||||
|
||||
/**
|
||||
* Compares two colors.
|
||||
*
|
||||
* @return True if the two colors have different RGBA components,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool operator!=(const Color& color) const;
|
||||
|
||||
/**
|
||||
* Output operator for output.
|
||||
*
|
||||
* @param out The stream to output to.
|
||||
* @param color The color to output.
|
||||
*/
|
||||
friend std::ostream& operator<<(std::ostream& out,
|
||||
const Color& Color);
|
||||
|
||||
/**
|
||||
* Holds the red color component (range 0-255).
|
||||
*/
|
||||
int r;
|
||||
|
||||
/**
|
||||
* Holds the green color component (range 0-255).
|
||||
*/
|
||||
int g;
|
||||
|
||||
/**
|
||||
* Holds the blue color component (range 0-255).
|
||||
*/
|
||||
int b;
|
||||
|
||||
/**
|
||||
* Holds the alpha color component. A value of 0 means totally
|
||||
* transparent while a value of 255 is considered opaque.
|
||||
*/
|
||||
int a;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_COLOR_HPP
|
||||
90
project/jni/guichan/include/guichan/deathlistener.hpp
Normal file
90
project/jni/guichan/include/guichan/deathlistener.hpp
Normal file
@@ -0,0 +1,90 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_DEATHLISTENER_HPP
|
||||
#define GCN_DEATHLISTENER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/event.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Interface for listening for death events from widgets.
|
||||
*
|
||||
* @see Widget::addDeathListener, Widget::removeDeathListener
|
||||
* @author Olof Naessén
|
||||
* @since 0.6.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC DeathListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~DeathListener() { }
|
||||
|
||||
/**
|
||||
* Called when a widget dies. It is used to be able to recieve
|
||||
* a notification when a death of a widget occurs.
|
||||
*
|
||||
* @param event The event of the death.
|
||||
*/
|
||||
virtual void death(const Event& event) = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* You should not be able to make an instance of DeathListener,
|
||||
* therefore its constructor is protected.
|
||||
*/
|
||||
DeathListener() { }
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_DEATHLISTENER_HPP
|
||||
95
project/jni/guichan/include/guichan/defaultfont.hpp
Normal file
95
project/jni/guichan/include/guichan/defaultfont.hpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_DEFAULTFONT_HPP
|
||||
#define GCN_DEFAULTFONT_HPP
|
||||
|
||||
#include "guichan/font.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* A font only capable of drawing rectangles. It is used by default
|
||||
* in Guichan if no font has been set merely to show that no font has
|
||||
* been set.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC DefaultFont : public Font
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~DefaultFont(){}
|
||||
|
||||
/**
|
||||
* Draws a glyph as a rectangle. The glyphs will always be drawn as
|
||||
* rectangles no matter the glyph.
|
||||
*
|
||||
* NOTE: You normally won't use this function to draw text since
|
||||
* the Graphics class contains better functions for drawing
|
||||
* text.
|
||||
*
|
||||
* @param graphics A Graphics object to be used for drawing.
|
||||
* @param glyph The glyph to draw.
|
||||
* @param x The x coordinate where to draw the glyph.
|
||||
* @param y The y coordinate where to draw the glyph.
|
||||
* @return The width of the drawn glyph in pixels.
|
||||
*/
|
||||
virtual int drawGlyph(Graphics* graphics, unsigned char glyph, int x, int y);
|
||||
|
||||
|
||||
// Inherited from Font
|
||||
|
||||
virtual void drawString(Graphics* graphics, const std::string& text, int x, int y);
|
||||
|
||||
virtual int getWidth(const std::string& text) const;
|
||||
|
||||
virtual int getHeight() const;
|
||||
|
||||
virtual int getStringIndexAt(const std::string& text, int x) const;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_DEFAULTFONT_HPP
|
||||
94
project/jni/guichan/include/guichan/event.hpp
Normal file
94
project/jni/guichan/include/guichan/event.hpp
Normal file
@@ -0,0 +1,94 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_EVENT_HPP
|
||||
#define GCN_EVENT_HPP
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Widget;
|
||||
|
||||
/**
|
||||
* Base class for all events. All events in Guichan should
|
||||
* inherit from this class.
|
||||
*
|
||||
* @author Olof Naessén
|
||||
* @since 0.6.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Event
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source The source widget of the event.
|
||||
*/
|
||||
Event(Widget* source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Event();
|
||||
|
||||
/**
|
||||
* Gets the source widget of the event. The function
|
||||
* is used to tell which widget fired an event.
|
||||
*
|
||||
* @return The source widget of the event.
|
||||
*/
|
||||
Widget* getSource() const;
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Holds the source widget of the event.
|
||||
*/
|
||||
Widget* mSource;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_EVENT_HPP
|
||||
177
project/jni/guichan/include/guichan/exception.hpp
Normal file
177
project/jni/guichan/include/guichan/exception.hpp
Normal file
@@ -0,0 +1,177 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_EXCEPTION_HPP
|
||||
#define GCN_EXCEPTION_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
#ifndef __FUNCTION__
|
||||
#define __FUNCTION__ "?"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* A macro used to create a standard exception object.
|
||||
* What it basicly does is that it creates a new exception
|
||||
* and automatically sets the filename and line number where
|
||||
* the exception occured by using other compiler macros.
|
||||
*/
|
||||
#define GCN_EXCEPTION(mess) gcn::Exception(mess, \
|
||||
__FUNCTION__, \
|
||||
__FILE__, \
|
||||
__LINE__)
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
|
||||
/**
|
||||
* An exception containing a message, a file and a line number
|
||||
* where the exception occured. Guichan will only throw exceptions
|
||||
* of this class.
|
||||
*
|
||||
* You can use this class for your own exceptions that has
|
||||
* something to do with a GUI exception. A nifty feature of the
|
||||
* excpetion class is that it can tell you from which line and
|
||||
* file it was thrown. To make things easier when throwing
|
||||
* exceptions there exists a macro for creating exceptions
|
||||
* which automatically sets the filename and line number.
|
||||
*
|
||||
* EXAMPLE: @code
|
||||
* throw GCN_EXCEPTION("my error message");
|
||||
* @endcode
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Exception
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Exception();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param message The error message of the exception.
|
||||
*/
|
||||
Exception(const std::string& message);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* NOTE: Don't use this constructor. Use the GCN_EXCEPTION macro instead.
|
||||
* This constructor merely exists for the GCN_EXCEPTION macro to
|
||||
* use.
|
||||
*
|
||||
* @param message The error message of the exception.
|
||||
* @param function The function name where the exception occured.
|
||||
* @param filename The name of the file where the exception occured.
|
||||
* @param line The line number in the source code where the exception
|
||||
* occured.
|
||||
*/
|
||||
Exception(const std::string& message,
|
||||
const std::string& function,
|
||||
const std::string& filename,
|
||||
unsigned int line);
|
||||
|
||||
/**
|
||||
* Gets the function name where the exception occured.
|
||||
*
|
||||
* @return The function name where the exception occured.
|
||||
*/
|
||||
const std::string& getFunction() const;
|
||||
|
||||
/**
|
||||
* Gets the error message of the exception.
|
||||
*
|
||||
* @return The error message of the exception.
|
||||
*/
|
||||
const std::string& getMessage() const;
|
||||
|
||||
/**
|
||||
* Gets the filename where the exception occured.
|
||||
*
|
||||
* @return The filename where the exception occured.
|
||||
*/
|
||||
const std::string& getFilename() const;
|
||||
|
||||
/**
|
||||
* Gets the line number where the exception occured.
|
||||
*
|
||||
* @return The line number where the exception occured.
|
||||
*/
|
||||
unsigned int getLine() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the name of the function name where the
|
||||
* exception occured.
|
||||
*/
|
||||
std::string mFunction;
|
||||
|
||||
/**
|
||||
* Holds the error message of the exception.
|
||||
*/
|
||||
std::string mMessage;
|
||||
|
||||
/**
|
||||
* Holds the filename where the exception occured.
|
||||
*/
|
||||
std::string mFilename;
|
||||
|
||||
/**
|
||||
* Holds the line number where the exception occured.
|
||||
*/
|
||||
unsigned int mLine;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_EXCEPTION_HPP
|
||||
|
||||
/*
|
||||
* "Final Fantasy XI is the BEST!... It's even better then water!"
|
||||
* - Astrolite
|
||||
* I believe it's WoW now days.
|
||||
*/
|
||||
398
project/jni/guichan/include/guichan/focushandler.hpp
Normal file
398
project/jni/guichan/include/guichan/focushandler.hpp
Normal file
@@ -0,0 +1,398 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_FOCUSHANDLER_HPP
|
||||
#define GCN_FOCUSHANDLER_HPP
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "guichan/event.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Widget;
|
||||
|
||||
/**
|
||||
* Handles focus for widgets in a Gui. Each Gui has at least one
|
||||
* focus handler.
|
||||
|
||||
* You will probably not use the focus handler directly as Widget
|
||||
* has functions that automatically uses the active focus handler.
|
||||
*
|
||||
* @see Widget::isFocus, Widget::isModalFocused,
|
||||
* Widget::isModalMouseInputFocused, Widget::requestFocus,
|
||||
* Widget::requestModalFocus, Widget::requestModalMouseInputFocus,
|
||||
* Widget::releaseModalFocus, Widget::relaseModalMouseInputFocus,
|
||||
* Widget::setFocusable, Widget::isFocusable, FocusListener
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC FocusHandler
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
FocusHandler();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~FocusHandler() { };
|
||||
|
||||
/**
|
||||
* Requests focus for a widget. Focus will only be granted to a widget
|
||||
* if it's focusable and if no other widget has modal focus.
|
||||
* If a widget receives focus a focus event will be sent to the
|
||||
* focus listeners of the widget.
|
||||
*
|
||||
* @param widget The widget to request focus for.
|
||||
* @see isFocused, Widget::requestFocus
|
||||
*/
|
||||
virtual void requestFocus(Widget* widget);
|
||||
|
||||
/**
|
||||
* Requests modal focus for a widget. Focus will only be granted
|
||||
* to a widget if it's focusable and if no other widget has modal
|
||||
* focus.
|
||||
*
|
||||
* @param widget The widget to request modal focus for.
|
||||
* @throws Exception when another widget already has modal focus.
|
||||
* @see releaseModalFocus, Widget::requestModalFocus
|
||||
*/
|
||||
virtual void requestModalFocus(Widget* widget);
|
||||
|
||||
/**
|
||||
* Requests modal mouse input focus for a widget. Focus will only
|
||||
* be granted to a widget if it's focusable and if no other widget
|
||||
* has modal mouse input focus.
|
||||
*
|
||||
* Modal mouse input focus means no other widget then the widget with
|
||||
* modal mouse input focus will receive mouse input. The widget with
|
||||
* modal mouse input focus will also receive mouse input no matter what
|
||||
* the mouse input is or where the mouse input occurs.
|
||||
*
|
||||
* @param widget The widget to focus for modal mouse input focus.
|
||||
* @throws Exception when another widget already has modal mouse input
|
||||
* focus.
|
||||
* @see releaseModalMouseInputFocus, Widget::requestModalMouseInputFocus
|
||||
*/
|
||||
virtual void requestModalMouseInputFocus(Widget* widget);
|
||||
|
||||
/**
|
||||
* Releases modal focus if the widget has modal focus.
|
||||
* If the widget doesn't have modal focus no relase will occur.
|
||||
*
|
||||
* @param widget The widget to release modal focus for.
|
||||
* @see reuqestModalFocus, Widget::releaseModalFocus
|
||||
*/
|
||||
virtual void releaseModalFocus(Widget* widget);
|
||||
|
||||
/**
|
||||
* Releases modal mouse input focus if the widget has modal mouse input
|
||||
* focus. If the widget doesn't have modal mouse input focus no relase
|
||||
* will occur.
|
||||
*
|
||||
* @param widget the widget to release modal mouse input focus for.
|
||||
* @see requestModalMouseInputFocus, Widget::releaseModalMouseInputFocus
|
||||
*/
|
||||
virtual void releaseModalMouseInputFocus(Widget* widget);
|
||||
|
||||
/**
|
||||
* Checks if a widget is focused.
|
||||
*
|
||||
* @param widget The widget to check.
|
||||
* @return True if the widget is focused, false otherwise.
|
||||
* @see Widget::isFocused
|
||||
*/
|
||||
virtual bool isFocused(const Widget* widget) const;
|
||||
|
||||
/**
|
||||
* Gets the widget with focus.
|
||||
*
|
||||
* @return The widget with focus. NULL if no widget has focus.
|
||||
*/
|
||||
virtual Widget* getFocused() const;
|
||||
|
||||
/**
|
||||
* Gets the widget with modal focus.
|
||||
*
|
||||
* @return The widget with modal focus. NULL if no widget has
|
||||
* modal focus.
|
||||
*/
|
||||
virtual Widget* getModalFocused() const;
|
||||
|
||||
/**
|
||||
* Gets the widget with modal mouse input focus.
|
||||
*
|
||||
* @return The widget with modal mouse input focus. NULL if
|
||||
* no widget has modal mouse input focus.
|
||||
*/
|
||||
virtual Widget* getModalMouseInputFocused() const;
|
||||
|
||||
/**
|
||||
* Focuses the next widget added to a conainer.
|
||||
* If no widget has focus the first widget gets focus. The order
|
||||
* in which the widgets are focused is determined by the order
|
||||
* they were added to a container.
|
||||
*
|
||||
* @see focusPrevious
|
||||
*/
|
||||
virtual void focusNext();
|
||||
|
||||
/**
|
||||
* Focuses the previous widget added to a contaienr.
|
||||
* If no widget has focus the first widget gets focus. The order
|
||||
* in which the widgets are focused is determined by the order
|
||||
* they were added to a container.
|
||||
*
|
||||
* @see focusNext
|
||||
*/
|
||||
virtual void focusPrevious();
|
||||
|
||||
/**
|
||||
* Adds a widget to by handles by the focus handler.
|
||||
*
|
||||
* @param widget The widget to add.
|
||||
* @see remove
|
||||
*/
|
||||
virtual void add(Widget* widget);
|
||||
|
||||
/**
|
||||
* Removes a widget from the focus handler.
|
||||
*
|
||||
* @param widget The widget to remove.
|
||||
* @see add
|
||||
*/
|
||||
virtual void remove(Widget* widget);
|
||||
|
||||
/**
|
||||
* Focuses nothing. A focus event will also be sent to the
|
||||
* focused widget's focus listeners if a widget has focus.
|
||||
*/
|
||||
virtual void focusNone();
|
||||
|
||||
/**
|
||||
* Focuses the next widget which allows tabbing in unless
|
||||
* the current focused Widget disallows tabbing out.
|
||||
*
|
||||
* @see tabPrevious
|
||||
*/
|
||||
virtual void tabNext();
|
||||
|
||||
/**
|
||||
* Focuses the previous widget which allows tabbing in unless
|
||||
* current focused widget disallows tabbing out.
|
||||
*
|
||||
* @see tabNext
|
||||
*/
|
||||
virtual void tabPrevious();
|
||||
|
||||
/**
|
||||
* Gets the widget being dragged. Used by the Gui class to
|
||||
* keep track of the dragged widget.
|
||||
*
|
||||
* @return the widget being dragged.
|
||||
* @see setDraggedWidget
|
||||
*/
|
||||
virtual Widget* getDraggedWidget();
|
||||
|
||||
/**
|
||||
* Sets the widget being dragged. Used by the Gui class to
|
||||
* keep track of the dragged widget.
|
||||
*
|
||||
* @param draggedWidget The widget being dragged.
|
||||
* @see getDraggedWidget
|
||||
*/
|
||||
virtual void setDraggedWidget(Widget* draggedWidget);
|
||||
|
||||
/**
|
||||
* Gets the last widget with the mouse. Used by the Gui class
|
||||
* to keep track the last widget with the mouse.
|
||||
*
|
||||
* @return The last widget with the mouse.
|
||||
* @see setLastWidgetWithMouse
|
||||
*/
|
||||
virtual Widget* getLastWidgetWithMouse();
|
||||
|
||||
/**
|
||||
* Sets the last widget with the mouse. Used by the Gui class
|
||||
* to keep track the last widget with the mouse.
|
||||
*
|
||||
* @param lastWidgetWithMouse The last widget with the mouse.
|
||||
* @see getLastWidgetWithMouse
|
||||
*/
|
||||
virtual void setLastWidgetWithMouse(Widget* lastWidgetWithMouse);
|
||||
|
||||
/**
|
||||
* Gets the last widget with modal focus.
|
||||
*
|
||||
* @return The last widget with modal focus.
|
||||
* @see setLastWidgetWithModalFocus
|
||||
*/
|
||||
virtual Widget* getLastWidgetWithModalFocus();
|
||||
|
||||
/**
|
||||
* Sets the last widget with modal focus.
|
||||
*
|
||||
* @param lastWidgetWithModalFocus The last widget with modal focus.
|
||||
* @see getLastWidgetWithModalFocus
|
||||
*/
|
||||
virtual void setLastWidgetWithModalFocus(Widget* lastWidgetWithModalFocus);
|
||||
|
||||
/**
|
||||
* Gets the last widget with modal mouse input focus.
|
||||
*
|
||||
* @return The last widget with modal mouse input focus.
|
||||
* @see setLastWidgetWithModalMouseInputFocus
|
||||
*/
|
||||
virtual Widget* getLastWidgetWithModalMouseInputFocus();
|
||||
|
||||
/**
|
||||
* Sets the last widget with modal mouse input focus.
|
||||
*
|
||||
* @param lastMouseWithModalMouseInputFocus The last widget with
|
||||
* modal mouse input focus.
|
||||
* @see getLastWidgetWithModalMouseInputFocus
|
||||
*/
|
||||
virtual void setLastWidgetWithModalMouseInputFocus(Widget* lastWidgetWithModalMouseInputFocus);
|
||||
|
||||
/**
|
||||
* Gets the last widget pressed. Used by the Gui class to keep track
|
||||
* of pressed widgets.
|
||||
*
|
||||
* @return The last widget pressed.
|
||||
* @see setLastWidgetPressed
|
||||
*/
|
||||
virtual Widget* getLastWidgetPressed();
|
||||
|
||||
/**
|
||||
* Sets the last widget pressed. Used by the Gui class to keep track
|
||||
* of pressed widgets.
|
||||
*
|
||||
* @param lastWidgetPressed The last widget pressed.
|
||||
* @see getLastWidgetPressed
|
||||
*/
|
||||
virtual void setLastWidgetPressed(Widget* lastWidgetPressed);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Distributes a focus lost event.
|
||||
*
|
||||
* @param focusEvent the event to distribute.
|
||||
* @since 0.7.0
|
||||
*/
|
||||
virtual void distributeFocusLostEvent(const Event& focusEvent);
|
||||
|
||||
/**
|
||||
* Distributes a focus gained event.
|
||||
*
|
||||
* @param focusEvent the event to distribute.
|
||||
* @since 0.7.0
|
||||
*/
|
||||
virtual void distributeFocusGainedEvent(const Event& focusEvent);
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef std::vector<Widget*> WidgetVector;
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef WidgetVector::iterator WidgetIterator;
|
||||
|
||||
/**
|
||||
* Holds the widgets currently being handled by the
|
||||
* focus handler.
|
||||
*/
|
||||
WidgetVector mWidgets;
|
||||
|
||||
/**
|
||||
* Holds the focused widget. NULL if no widget has focus.
|
||||
*/
|
||||
Widget* mFocusedWidget;
|
||||
|
||||
/**
|
||||
* Holds the modal focused widget. NULL if no widget has
|
||||
* modal focused.
|
||||
*/
|
||||
Widget* mModalFocusedWidget;
|
||||
|
||||
/**
|
||||
* Holds the modal mouse input focused widget. NULL if no widget
|
||||
* is being dragged.
|
||||
*/
|
||||
Widget* mModalMouseInputFocusedWidget;
|
||||
|
||||
/**
|
||||
* Holds the dragged widget. NULL if no widget is
|
||||
* being dragged.
|
||||
*/
|
||||
Widget* mDraggedWidget;
|
||||
|
||||
/**
|
||||
* Holds the last widget with the mouse.
|
||||
*/
|
||||
Widget* mLastWidgetWithMouse;
|
||||
|
||||
/**
|
||||
* Holds the last widget with modal focus.
|
||||
*/
|
||||
Widget* mLastWidgetWithModalFocus;
|
||||
|
||||
/**
|
||||
* Holds the last widget with modal mouse input focus.
|
||||
*/
|
||||
Widget* mLastWidgetWithModalMouseInputFocus;
|
||||
|
||||
/**
|
||||
* Holds the last widget pressed.
|
||||
*/
|
||||
Widget* mLastWidgetPressed;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_FOCUSHANDLER_HPP
|
||||
95
project/jni/guichan/include/guichan/focuslistener.hpp
Normal file
95
project/jni/guichan/include/guichan/focuslistener.hpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_FOCUSLISTENER_HPP
|
||||
#define GCN_FOCUSLISTENER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/event.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Interface for listening for focus events from widgets.
|
||||
*
|
||||
* @see Widget::addFocusListener, Widget::removeFocusListener
|
||||
* @author Olof Naessén
|
||||
* @since 0.7.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC FocusListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~FocusListener() { }
|
||||
|
||||
/**
|
||||
* Called when a widget gains focus.
|
||||
*
|
||||
* @param event Discribes the event.
|
||||
*/
|
||||
virtual void focusGained(const Event& event) { };
|
||||
|
||||
/**
|
||||
* Called when a widget loses focus.
|
||||
*
|
||||
* @param event Discribes the event.
|
||||
*/
|
||||
virtual void focusLost(const Event& event) { };
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* You should not be able to make an instance of FocusListener,
|
||||
* therefore its constructor is protected.
|
||||
*/
|
||||
FocusListener() { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_FOCUSLISTENER_HPP
|
||||
111
project/jni/guichan/include/guichan/font.hpp
Normal file
111
project/jni/guichan/include/guichan/font.hpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_FONT_HPP
|
||||
#define GCN_FONT_HPP
|
||||
|
||||
#include <string>
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Graphics;
|
||||
|
||||
/**
|
||||
* Interface for a font.
|
||||
*
|
||||
* @see ImageFont
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Font
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Font(){ }
|
||||
|
||||
/**
|
||||
* Gets the width of a string. The width of a string is not necesserily
|
||||
* the sum of all the widths of it's glyphs.
|
||||
*
|
||||
* @param text The string to return the width of.
|
||||
* @return The width of a string.
|
||||
*/
|
||||
virtual int getWidth(const std::string& text) const = 0;
|
||||
|
||||
/**
|
||||
* Gets the height of the glyphs in the font.
|
||||
*
|
||||
* @return The height of the glyphs int the font.
|
||||
*/
|
||||
virtual int getHeight() const = 0;
|
||||
|
||||
/**
|
||||
* Gets a string index in a string providing an x coordinate.
|
||||
* Used to retrive a string index (for a character in a
|
||||
* string) at a certain x position. It is especially useful
|
||||
* when a mouse clicks in a TextField and you want to know which
|
||||
* character was clicked.
|
||||
*
|
||||
* @return A string index in a string providing an x coordinate.
|
||||
*/
|
||||
virtual int getStringIndexAt(const std::string& text, int x) const;
|
||||
|
||||
/**
|
||||
* Draws a string.
|
||||
*
|
||||
* NOTE: You normally won't use this function to draw text since
|
||||
* Graphics contains better functions for drawing text.
|
||||
*
|
||||
* @param graphics A Graphics object to use for drawing.
|
||||
* @param text The string to draw.
|
||||
* @param x The x coordinate where to draw the string.
|
||||
* @param y The y coordinate where to draw the string.
|
||||
*/
|
||||
virtual void drawString(Graphics* graphics, const std::string& text,
|
||||
int x, int y) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_FONT_HPP
|
||||
163
project/jni/guichan/include/guichan/genericinput.hpp
Normal file
163
project/jni/guichan/include/guichan/genericinput.hpp
Normal file
@@ -0,0 +1,163 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_GENERICINPUT_HPP
|
||||
#define GCN_GENERICINPUT_HPP
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "guichan/input.hpp"
|
||||
#include "guichan/keyinput.hpp"
|
||||
#include "guichan/mouseinput.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Key;
|
||||
|
||||
/**
|
||||
* Implementation of a generic input which can be used with any
|
||||
* back end.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC GenericInput: public Input
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
GenericInput();
|
||||
|
||||
/**
|
||||
* Pushes a key pressed event.
|
||||
*
|
||||
* NOTE: If a special key is pressed, like the F1 key,
|
||||
* the corresponding Guichan key value found
|
||||
* in the enum in Key should be pushed as the
|
||||
* unicode value.
|
||||
*
|
||||
* @param unicode The unicode value of the key.
|
||||
*/
|
||||
void pushKeyPressed(int unicode);
|
||||
|
||||
/**
|
||||
* Pushes a key released event.
|
||||
*
|
||||
* NOTE: If a special key is pressed, like the F1 key,
|
||||
* the corresponding Guichan key value found
|
||||
* in the enum in Key should be pushed as the
|
||||
* unicode value.
|
||||
*
|
||||
* @param unicode The unicode value of the key.
|
||||
*/
|
||||
void pushKeyReleased(int unicode);
|
||||
|
||||
/**
|
||||
* Pushes a mouse button pressed event.
|
||||
*
|
||||
* @param x The x coordinate of the mouse event.
|
||||
* @param y The y coordinate of the mouse event.
|
||||
* @param button The button of the mouse event.
|
||||
*/
|
||||
void pushMouseButtonPressed(int x, int y, int button);
|
||||
|
||||
/**
|
||||
* Pushes a mouse button released event.
|
||||
*
|
||||
* @param x The x coordinate of the mouse event.
|
||||
* @param y The y coordinate of the mouse event.
|
||||
* @param button The button of the mouse event.
|
||||
*/
|
||||
void pushMouseButtonReleased(int x, int y, int button);
|
||||
|
||||
/**
|
||||
* Pushes a mouse wheel moved up event.
|
||||
*
|
||||
* @param x The x coordinate of the mouse event.
|
||||
* @param y The y coordinate of the mouse event.
|
||||
*/
|
||||
void pushMouseWheelMovedUp(int x, int y);
|
||||
|
||||
/**
|
||||
* Pushes a mouse wheel moved down event.
|
||||
*
|
||||
* @param x The x coordinate of the mouse event.
|
||||
* @param y The y coordinate of the mouse event.
|
||||
*/
|
||||
void pushMouseWheelMovedDown(int x, int y);
|
||||
|
||||
/**
|
||||
* Pushes a mouse moved event.
|
||||
*
|
||||
* @param x The x coordinate of the mouse event.
|
||||
* @param y The y coordinate of the mouse event.
|
||||
*/
|
||||
void pushMouseMoved(int x, int y);
|
||||
|
||||
|
||||
// Inherited from Input
|
||||
|
||||
virtual bool isKeyQueueEmpty();
|
||||
|
||||
virtual KeyInput dequeueKeyInput();
|
||||
|
||||
virtual bool isMouseQueueEmpty();
|
||||
|
||||
virtual MouseInput dequeueMouseInput();
|
||||
|
||||
virtual void _pollInput();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the key input queue.
|
||||
*/
|
||||
std::queue<KeyInput> mKeyInputQueue;
|
||||
|
||||
/**
|
||||
* Holds the mouse input queue.
|
||||
*/
|
||||
std::queue<MouseInput> mMouseInputQueue;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_INPUT_HPP
|
||||
59
project/jni/guichan/include/guichan/glut.hpp
Normal file
59
project/jni/guichan/include/guichan/glut.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_GLUT_HPP
|
||||
#define GCN_GLUT_HPP
|
||||
|
||||
#include <guichan/glut/glutinput.hpp>
|
||||
|
||||
#include "platform.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* Exists to be able to check for Guichan GLUT with autotools.
|
||||
*/
|
||||
GCN_EXTENSION_DECLSPEC extern void gcnGLUT();
|
||||
}
|
||||
|
||||
#endif // end GCN_GLUT_HPP
|
||||
291
project/jni/guichan/include/guichan/graphics.hpp
Normal file
291
project/jni/guichan/include/guichan/graphics.hpp
Normal file
@@ -0,0 +1,291 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_GRAPHICS_HPP
|
||||
#define GCN_GRAPHICS_HPP
|
||||
|
||||
#include <iosfwd>
|
||||
#include <stack>
|
||||
|
||||
#include "guichan/cliprectangle.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Color;
|
||||
class Font;
|
||||
class Image;
|
||||
|
||||
/**
|
||||
* Abstract class for providing drawing primitve functions.
|
||||
* It contains all vital functions for drawing.
|
||||
*
|
||||
* Guichan contains implementations of Graphics for common
|
||||
* libraries like the Allegro library, the HGE library,
|
||||
* the OpenGL library, the OpenLayer library, and the SDL library.
|
||||
* To make Guichan usable with other libraries, a Graphics class
|
||||
* must be implemented.
|
||||
*
|
||||
* In Graphics you can set clip areas to limit drawing to certain
|
||||
* areas of the screen. Clip areas are put on a stack, which
|
||||
* means that you can push smaller and smaller clip areas onto the
|
||||
* stack. All coordinates will be relative to the top most clip area.
|
||||
* In most cases you won't have to worry about the clip areas,
|
||||
* unless you want to implement some really complex widget.
|
||||
* Pushing and poping of clip areas are handled automatically by
|
||||
* container widgets when their child widgets are drawn.
|
||||
*
|
||||
* IMPORTANT: Remember to pop each clip area that you pushed on the stack
|
||||
* after you are done with it.
|
||||
*
|
||||
* If you feel that Graphics is to restrictive for your needs,
|
||||
* there is no one stopping you from using your own code for drawing
|
||||
* in widgets. You could for instance use pure SDL in the drawing of
|
||||
* widgets bypassing Graphics. This might however hurt portability of
|
||||
* your application.
|
||||
*
|
||||
* If you implement a Graphics class not present in Guichan we would
|
||||
* be very happy to add it to Guichan.
|
||||
*
|
||||
* @see AllegroGraphics, HGEGraphics, OpenLayerGraphics, OpenGLGraphics,
|
||||
* SDLGraphics, Image
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Graphics
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Alignments for text drawing.
|
||||
*/
|
||||
enum Alignment
|
||||
{
|
||||
LEFT = 0,
|
||||
CENTER,
|
||||
RIGHT
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Graphics();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Graphics() { }
|
||||
|
||||
/**
|
||||
* Initializes drawing. Called by the Gui when Gui::draw() is called.
|
||||
* It is needed by some implementations of Graphics to perform
|
||||
* preparations before drawing. An example of such an implementation
|
||||
* is the OpenGLGraphics.
|
||||
*
|
||||
* NOTE: You will never need to call this function yourself, unless
|
||||
* you use a Graphics object outside of Guichan.
|
||||
*
|
||||
* @see _endDraw, Gui::draw
|
||||
*/
|
||||
virtual void _beginDraw() { }
|
||||
|
||||
/**
|
||||
* Deinitializes drawing. Called by the Gui when a Gui::draw() is done.
|
||||
* done. It should reset any state changes made by _beginDraw().
|
||||
*
|
||||
* NOTE: You will never need to call this function yourself, unless
|
||||
* you use a Graphics object outside of Guichan.
|
||||
*
|
||||
* @see _beginDraw, Gui::draw
|
||||
*/
|
||||
virtual void _endDraw() { }
|
||||
|
||||
/**
|
||||
* Pushes a clip area onto the stack. The x and y coordinates in the
|
||||
* rectangle is relative to the last pushed clip area.
|
||||
* If the new area falls outside the current clip area, it will be
|
||||
* clipped as necessary.
|
||||
*
|
||||
* If a clip area is outside of the top clip area a clip area with
|
||||
* zero width and height will be pushed.
|
||||
*
|
||||
* @param area The clip area to be pushed onto the stack.
|
||||
* @return False if the the new area lays outside the current clip
|
||||
* area.
|
||||
*/
|
||||
virtual bool pushClipArea(Rectangle area);
|
||||
|
||||
/**
|
||||
* Removes the top most clip area from the stack.
|
||||
*
|
||||
* @throws Exception if the stack is empty.
|
||||
*/
|
||||
virtual void popClipArea();
|
||||
|
||||
/**
|
||||
* Gets the current clip area. Usefull if you want to do drawing
|
||||
* bypassing Graphics.
|
||||
*
|
||||
* @return The current clip area.
|
||||
*/
|
||||
virtual const ClipRectangle& getCurrentClipArea();
|
||||
|
||||
/**
|
||||
* Draws a part of an image.
|
||||
*
|
||||
* NOTE: Width and height arguments will not scale the image but
|
||||
* specifies the size of the part to be drawn. If you want
|
||||
* to draw the whole image there is a simplified version of
|
||||
* this function.
|
||||
*
|
||||
* EXAMPLE: @code drawImage(myImage, 10, 10, 20, 20, 40, 40); @endcode
|
||||
* Will draw a rectangular piece of myImage starting at
|
||||
* coordinate (10, 10) in myImage, with width and height 40.
|
||||
* The piece will be drawn with it's top left corner at
|
||||
* coordinate (20, 20).
|
||||
*
|
||||
* @param image The image to draw.
|
||||
* @param srcX The source image x coordinate.
|
||||
* @param srcY The source image y coordinate.
|
||||
* @param dstX The destination x coordinate.
|
||||
* @param dstY The destination y coordinate.
|
||||
* @param width The width of the piece.
|
||||
* @param height The height of the piece.
|
||||
*/
|
||||
virtual void drawImage(const Image* image,
|
||||
int srcX,
|
||||
int srcY,
|
||||
int dstX,
|
||||
int dstY,
|
||||
int width,
|
||||
int height) = 0;
|
||||
/**
|
||||
* Draws an image. A simplified version of the other drawImage.
|
||||
* It will draw a whole image at the coordinate you specify.
|
||||
* It is equivalent to calling:
|
||||
* @code drawImage(myImage, 0, 0, dstX, dstY, image->getWidth(), \
|
||||
image->getHeight()); @endcode
|
||||
*/
|
||||
virtual void drawImage(const Image* image, int dstX, int dstY);
|
||||
|
||||
/**
|
||||
* Draws a single point/pixel.
|
||||
*
|
||||
* @param x The x coordinate.
|
||||
* @param y The y coordinate.
|
||||
*/
|
||||
virtual void drawPoint(int x, int y) = 0;
|
||||
|
||||
/**
|
||||
* Ddraws a line.
|
||||
*
|
||||
* @param x1 The first x coordinate.
|
||||
* @param y1 The first y coordinate.
|
||||
* @param x2 The second x coordinate.
|
||||
* @param y2 The second y coordinate.
|
||||
*/
|
||||
virtual void drawLine(int x1, int y1, int x2, int y2) = 0;
|
||||
|
||||
/**
|
||||
* Draws a simple, non-filled, rectangle with a one pixel width.
|
||||
*
|
||||
* @param rectangle The rectangle to draw.
|
||||
*/
|
||||
virtual void drawRectangle(const Rectangle& rectangle) = 0;
|
||||
|
||||
/**
|
||||
* Draws a filled rectangle.
|
||||
*
|
||||
* @param rectangle The filled rectangle to draw.
|
||||
*/
|
||||
virtual void fillRectangle(const Rectangle& rectangle) = 0;
|
||||
|
||||
/**
|
||||
* Sets the color to use when drawing.
|
||||
*
|
||||
* @param color A color.
|
||||
* @see getColor
|
||||
*/
|
||||
virtual void setColor(const Color& color) = 0;
|
||||
|
||||
/**
|
||||
* Gets the color to use when drawing.
|
||||
*
|
||||
* @return The color used when drawing.
|
||||
* @see setColor
|
||||
*/
|
||||
virtual const Color& getColor() const = 0;
|
||||
|
||||
/**
|
||||
* Sets the font to use when drawing text.
|
||||
*
|
||||
* @param font The font to use when drawing.
|
||||
*/
|
||||
virtual void setFont(Font* font);
|
||||
|
||||
/**
|
||||
* Draws text.
|
||||
*
|
||||
* @param text The text to draw.
|
||||
* @param x The x coordinate where to draw the text.
|
||||
* @param y The y coordinate where to draw the text.
|
||||
* @param alignment The alignemnt to use when drawing.
|
||||
* @throws Exception when no font has been set.
|
||||
*/
|
||||
virtual void drawText(const std::string& text,
|
||||
int x,
|
||||
int y,
|
||||
Alignment alignment = LEFT);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the clip area stack.
|
||||
*/
|
||||
std::stack<ClipRectangle> mClipStack;
|
||||
|
||||
/**
|
||||
* Holds the current font.
|
||||
*/
|
||||
Font* mFont;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_GRAPHICS_HPP
|
||||
504
project/jni/guichan/include/guichan/gui.hpp
Normal file
504
project/jni/guichan/include/guichan/gui.hpp
Normal file
@@ -0,0 +1,504 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_GUI_HPP
|
||||
#define GCN_GUI_HPP
|
||||
|
||||
#include <list>
|
||||
#include <deque>
|
||||
|
||||
#include "guichan/keyevent.hpp"
|
||||
#include "guichan/mouseevent.hpp"
|
||||
#include "guichan/mouseinput.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class FocusHandler;
|
||||
class Graphics;
|
||||
class Input;
|
||||
class KeyListener;
|
||||
class Widget;
|
||||
|
||||
// The following comment will appear in the doxygen main page.
|
||||
/**
|
||||
* @mainpage
|
||||
* @section Introduction
|
||||
* This documentation is mostly intended as a reference to the API. If you want to get started with Guichan, we suggest you check out the programs in the examples directory of the Guichan release.
|
||||
* @n
|
||||
* @n
|
||||
* This documentation is, and will always be, work in progress. If you find any errors, typos or inconsistencies, or if you feel something needs to be explained in more detail - don't hesitate to tell us.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contains a Guichan GUI. This is the core class of Guichan to which
|
||||
* implementations of back ends are passed, to make Guichan work with
|
||||
* a specific library, and to where the top widget (root widget of GUI)
|
||||
* is added. If you want to be able to have more then one widget in your
|
||||
* GUI, the top widget should be a container.
|
||||
*
|
||||
* A Gui object cannot work properly without passing back end
|
||||
* implementations to it. A Gui object must have an implementation of a
|
||||
* Graphics and an implementation of Input.
|
||||
*
|
||||
* NOTE: A complete GUI also must have the ability to load images.
|
||||
* Images are loaded with the Image class, so to make Guichan
|
||||
* able to load images an implementation of ImageLoader must be
|
||||
* passed to Image.
|
||||
*
|
||||
* @see Graphics, Input, Image
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Gui
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Gui();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Gui();
|
||||
|
||||
/**
|
||||
* Sets the top widget. The top widget is the root widget
|
||||
* of the GUI. If you want a GUI to be able to contain more
|
||||
* than one widget the top widget should be a container.
|
||||
*
|
||||
* @param top The top widget.
|
||||
* @see Container
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual void setTop(Widget* top);
|
||||
|
||||
/**
|
||||
* Gets the top widget. The top widget is the root widget
|
||||
* of the GUI.
|
||||
*
|
||||
* @return The top widget. NULL if no top widget has been set.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual Widget* getTop() const;
|
||||
|
||||
/**
|
||||
* Sets the graphics object to use for drawing.
|
||||
*
|
||||
* @param graphics The graphics object to use for drawing.
|
||||
* @see getGraphics, AllegroGraphics, HGEGraphics,
|
||||
* OpenLayerGraphics, OpenGLGraphics, SDLGraphics
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual void setGraphics(Graphics* graphics);
|
||||
|
||||
/**
|
||||
* Gets the graphics object used for drawing.
|
||||
*
|
||||
* @return The graphics object used for drawing. NULL if no
|
||||
* graphics object has been set.
|
||||
* @see setGraphics, AllegroGraphics, HGEGraphics,
|
||||
* OpenLayerGraphics, OpenGLGraphics, SDLGraphics
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual Graphics* getGraphics() const;
|
||||
|
||||
/**
|
||||
* Sets the input object to use for input handling.
|
||||
*
|
||||
* @param input The input object to use for input handling.
|
||||
* @see getInput, AllegroInput, HGEInput, OpenLayerInput,
|
||||
* SDLInput
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual void setInput(Input* input);
|
||||
|
||||
/**
|
||||
* Gets the input object being used for input handling.
|
||||
*
|
||||
* @return The input object used for handling input. NULL if no
|
||||
* input object has been set.
|
||||
* @see setInput, AllegroInput, HGEInput, OpenLayerInput,
|
||||
* SDLInput
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual Input* getInput() const;
|
||||
|
||||
/**
|
||||
* Performs logic of the GUI. By calling this function all logic
|
||||
* functions down in the GUI heirarchy will be called. When logic
|
||||
* is called for Gui, user input will be handled.
|
||||
*
|
||||
* @see Widget::logic
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual void logic();
|
||||
|
||||
/**
|
||||
* Draws the GUI. By calling this funcion all draw functions
|
||||
* down in the GUI hierarchy will be called. When draw is called
|
||||
* the used Graphics object will be initialised and drawing of
|
||||
* the top widget will commence.
|
||||
*
|
||||
* @see Widget::draw
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual void draw();
|
||||
|
||||
/**
|
||||
* Focuses none of the widgets in the Gui.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual void focusNone();
|
||||
|
||||
/**
|
||||
* Sets tabbing enabled, or not. Tabbing is the usage of
|
||||
* changing focus by utilising the tab key.
|
||||
*
|
||||
* @param tabbing True if tabbing should be enabled, false
|
||||
* otherwise.
|
||||
* @see isTabbingEnabled
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual void setTabbingEnabled(bool tabbing);
|
||||
|
||||
/**
|
||||
* Checks if tabbing is enabled.
|
||||
*
|
||||
* @return True if tabbing is enabled, false otherwise.
|
||||
* @see setTabbingEnabled
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual bool isTabbingEnabled();
|
||||
|
||||
/**
|
||||
* Adds a global key listener to the Gui. A global key listener
|
||||
* will receive all key events generated from the GUI and global
|
||||
* key listeners will receive the events before key listeners
|
||||
* of widgets.
|
||||
*
|
||||
* @param keyListener The key listener to add.
|
||||
* @see removeGlobalKeyListener
|
||||
* @since 0.5.0
|
||||
*/
|
||||
virtual void addGlobalKeyListener(KeyListener* keyListener);
|
||||
|
||||
/**
|
||||
* Removes global key listener from the Gui.
|
||||
*
|
||||
* @param keyListener The key listener to remove.
|
||||
* @throws Exception if the key listener hasn't been added.
|
||||
* @see addGlobalKeyListener
|
||||
* @since 0.5.0
|
||||
*/
|
||||
virtual void removeGlobalKeyListener(KeyListener* keyListener);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Handles all mouse input.
|
||||
*
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void handleMouseInput();
|
||||
|
||||
/**
|
||||
* Handles key input.
|
||||
*
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void handleKeyInput();
|
||||
|
||||
/**
|
||||
* Handles mouse moved input.
|
||||
*
|
||||
* @param mouseInput The mouse input to handle.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void handleMouseMoved(const MouseInput& mouseInput);
|
||||
|
||||
/**
|
||||
* Handles mouse pressed input.
|
||||
*
|
||||
* @param mouseInput The mouse input to handle.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void handleMousePressed(const MouseInput& mouseInput);
|
||||
|
||||
/**
|
||||
*
|
||||
* Handles mouse wheel moved down input.
|
||||
*
|
||||
* @param mouseInput The mouse input to handle.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void handleMouseWheelMovedDown(const MouseInput& mouseInput);
|
||||
|
||||
/**
|
||||
* Handles mouse wheel moved up input.
|
||||
*
|
||||
* @param mouseInput The mouse input to handle.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void handleMouseWheelMovedUp(const MouseInput& mouseInput);
|
||||
|
||||
/**
|
||||
* Handles mouse released input.
|
||||
*
|
||||
* @param mouseInput The mouse input to handle.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void handleMouseReleased(const MouseInput& mouseInput);
|
||||
|
||||
/**
|
||||
* Handles modal focus. Modal focus needs to be checked at
|
||||
* each logic iteration as it might be necessary to distribute
|
||||
* mouse entered or mouse exited events.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void handleModalFocus();
|
||||
|
||||
/**
|
||||
* Handles modal mouse input focus. Modal mouse input focus needs
|
||||
* to be checked at each logic iteration as it might be necessary to
|
||||
* distribute mouse entered or mouse exited events.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void handleModalMouseInputFocus();
|
||||
|
||||
/**
|
||||
* Handles modal focus gained. If modal focus has been gained it might
|
||||
* be necessary to distribute mouse entered or mouse exited events.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void handleModalFocusGained();
|
||||
|
||||
/**
|
||||
* Handles modal mouse input focus gained. If modal focus has been
|
||||
* gained it might be necessary to distribute mouse entered or mouse
|
||||
* exited events.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void handleModalFocusReleased();
|
||||
|
||||
/**
|
||||
* Distributes a mouse event.
|
||||
*
|
||||
* @param type The type of the event to distribute,
|
||||
* @param button The button of the event (if any used) to distribute.
|
||||
* @param x The x coordinate of the event.
|
||||
* @param y The y coordinate of the event.
|
||||
* @param fource indicates whether the distribution should be forced or not.
|
||||
* A forced distribution distributes the event even if a widget
|
||||
* is not enabled, not visible, another widget has modal
|
||||
* focus or another widget has modal mouse input focus.
|
||||
* Default value is false.
|
||||
* @param toSourceOnly indicates whether the distribution should be to the
|
||||
* source widget only or to it's parent's mouse listeners
|
||||
* as well.
|
||||
*
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void distributeMouseEvent(Widget* source,
|
||||
int type,
|
||||
int button,
|
||||
int x,
|
||||
int y,
|
||||
bool force = false,
|
||||
bool toSourceOnly = false);
|
||||
|
||||
/**
|
||||
* Distributes a key event.
|
||||
*
|
||||
* @param keyEvent The key event to distribute.
|
||||
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void distributeKeyEvent(KeyEvent& keyEvent);
|
||||
|
||||
/**
|
||||
* Distributes a key event to the global key listeners.
|
||||
*
|
||||
* @param keyEvent The key event to distribute.
|
||||
*
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void distributeKeyEventToGlobalKeyListeners(KeyEvent& keyEvent);
|
||||
|
||||
/**
|
||||
* Gets the widget at a certain position.
|
||||
*
|
||||
* @return The widget at a certain position.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual Widget* getWidgetAt(int x, int y);
|
||||
|
||||
/**
|
||||
* Gets the source of the mouse event.
|
||||
*
|
||||
* @return The source widget of the mouse event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual Widget* getMouseEventSource(int x, int y);
|
||||
|
||||
/**
|
||||
* Gets the source of the key event.
|
||||
*
|
||||
* @return The source widget of the key event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual Widget* getKeyEventSource();
|
||||
|
||||
/**
|
||||
* Holds the top widget.
|
||||
*/
|
||||
Widget* mTop;
|
||||
|
||||
/**
|
||||
* Holds the graphics implementation used.
|
||||
*/
|
||||
Graphics* mGraphics;
|
||||
|
||||
/**
|
||||
* Holds the input implementation used.
|
||||
*/
|
||||
Input* mInput;
|
||||
|
||||
/**
|
||||
* Holds the focus handler for the Gui.
|
||||
*/
|
||||
FocusHandler* mFocusHandler;
|
||||
|
||||
/**
|
||||
* True if tabbing is enabled, false otherwise.
|
||||
*/
|
||||
bool mTabbing;
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef std::list<KeyListener*> KeyListenerList;
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef KeyListenerList::iterator KeyListenerListIterator;
|
||||
|
||||
/**
|
||||
* Holds the global key listeners of the Gui.
|
||||
*/
|
||||
KeyListenerList mKeyListeners;
|
||||
|
||||
/**
|
||||
* True if shift is pressed, false otherwise.
|
||||
*/
|
||||
bool mShiftPressed;
|
||||
|
||||
/**
|
||||
* True if meta is pressed, false otherwise.
|
||||
*/
|
||||
bool mMetaPressed;
|
||||
|
||||
/**
|
||||
* True if control is pressed, false otherwise.
|
||||
*/
|
||||
bool mControlPressed;
|
||||
|
||||
/**
|
||||
* True if alt is pressed, false otherwise.
|
||||
*/
|
||||
bool mAltPressed;
|
||||
|
||||
/**
|
||||
* Holds the last mouse button pressed.
|
||||
*/
|
||||
unsigned int mLastMousePressButton;
|
||||
|
||||
/**
|
||||
* Holds the last mouse press time stamp.
|
||||
*/
|
||||
int mLastMousePressTimeStamp;
|
||||
|
||||
/**
|
||||
* Holds the last mouse x coordinate.
|
||||
*/
|
||||
int mLastMouseX;
|
||||
|
||||
/**
|
||||
* Holds the last mouse y coordinate.
|
||||
*/
|
||||
int mLastMouseY;
|
||||
|
||||
/**
|
||||
* Holds the current click count. Used to keep track
|
||||
* of clicks for a the last pressed button.
|
||||
*/
|
||||
int mClickCount;
|
||||
|
||||
/**
|
||||
* Holds the last button used when a drag of a widget
|
||||
* was initiated. Used to be able to release a drag
|
||||
* when the same button is released.
|
||||
*/
|
||||
int mLastMouseDragButton;
|
||||
|
||||
/**
|
||||
* Holds a stack with all the widgets with the mouse.
|
||||
* Used to properly distribute mouse events.
|
||||
*/
|
||||
std::deque<Widget*> mWidgetWithMouseQueue;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_GUI_HPP
|
||||
|
||||
/* yakslem - "Women, it's a constant struggle."
|
||||
* finalman - "Yes, but sometimes they succeed with their guesses."
|
||||
* yaklsem - "...eh...I was talking about love."
|
||||
* finalman - "Oh...ok..."
|
||||
* An awkward silence followed.
|
||||
*/
|
||||
53
project/jni/guichan/include/guichan/hge.hpp
Normal file
53
project/jni/guichan/include/guichan/hge.hpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_HGE_HPP
|
||||
#define GCN_HGE_HPP
|
||||
|
||||
#include <guichan/hge/hgegraphics.hpp>
|
||||
#include <guichan/hge/hgeimage.hpp>
|
||||
#include <guichan/hge/hgeimagefont.hpp>
|
||||
#include <guichan/hge/hgeimageloader.hpp>
|
||||
#include <guichan/hge/hgeinput.hpp>
|
||||
|
||||
#endif // end GCN_HGE_HPP
|
||||
190
project/jni/guichan/include/guichan/image.hpp
Normal file
190
project/jni/guichan/include/guichan/image.hpp
Normal file
@@ -0,0 +1,190 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_IMAGE_HPP
|
||||
#define GCN_IMAGE_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Color;
|
||||
class ImageLoader;
|
||||
|
||||
/**
|
||||
* Holds an image. To be able to use this class you must first set an
|
||||
* ImageLoader in Image by calling
|
||||
* @code Image::setImageLoader(myImageLoader) @endcode
|
||||
* The function is static. If this is not done, the constructor taking a
|
||||
* filename will throw an exception. The ImageLoader you use must be
|
||||
* compatible with the Graphics object you use.
|
||||
*
|
||||
* EXAMPLE: If you use SDLGraphics you should use SDLImageLoader.
|
||||
* Otherwise your program might crash in a most bizarre way.
|
||||
* @see AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader,
|
||||
* OpenGLAllegroImageLoader, OpenGLSDLImageLoader, SDLImageLoader
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Image
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Image();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Image();
|
||||
|
||||
/**
|
||||
* Loads an image by using the class' image laoder. All image loaders implemented
|
||||
* in Guichan return a newly instantiated image which must be deleted in
|
||||
* order to avoid a memory leak.
|
||||
*
|
||||
* NOTE: The functions getPixel and putPixel are only guaranteed to work
|
||||
* before an image has been converted to display format.
|
||||
*
|
||||
* @param filename The file to load.
|
||||
* @param convertToDisplayFormat True if the image should be converted
|
||||
* to display, false otherwise.
|
||||
* @since 0.5.0
|
||||
*/
|
||||
static Image* load(const std::string& filename, bool convertToDisplayFormat = true);
|
||||
|
||||
/**
|
||||
* Gets the image loader used for loading images.
|
||||
*
|
||||
* @return The image loader used for loading images.
|
||||
* @see setImageLoader, AllegroImageLoader, HGEImageLoader,
|
||||
* OpenLayerImageLoader, OpenGLAllegroImageLoader,
|
||||
* OpenGLSDLImageLoader, SDLImageLoader
|
||||
* @since 0.1.0
|
||||
*/
|
||||
static ImageLoader* getImageLoader();
|
||||
|
||||
/**
|
||||
* Sets the ImageLoader to be used for loading images.
|
||||
*
|
||||
* IMPORTANT: The image loader is static and MUST be set before
|
||||
* loading images!
|
||||
*
|
||||
* @param imageLoader The image loader to be used for loading images.
|
||||
* @see getImageLoader, AllegroImageLoader, HGEImageLoader,
|
||||
* OpenLayerImageLoader, OpenGLAllegroImageLoader,
|
||||
* OpenGLSDLImageLoader, SDLImageLoader
|
||||
* @since 0.1.0
|
||||
*/
|
||||
static void setImageLoader(ImageLoader* imageLoader);
|
||||
|
||||
/**
|
||||
* Frees an image.
|
||||
*
|
||||
* @since 0.5.0
|
||||
*/
|
||||
virtual void free() = 0;
|
||||
|
||||
/**
|
||||
* Gets the width of the image.
|
||||
*
|
||||
* @return The width of the image.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual int getWidth() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the height of the image.
|
||||
*
|
||||
* @return The height of the image.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
virtual int getHeight() const = 0;
|
||||
|
||||
/**
|
||||
* Gets the color of a pixel at coordinate (x, y) in the image.
|
||||
*
|
||||
* IMPORTANT: Only guaranteed to work before the image has been
|
||||
* converted to display format.
|
||||
*
|
||||
* @param x The x coordinate.
|
||||
* @param y The y coordinate.
|
||||
* @return The color of the pixel.
|
||||
*
|
||||
* @since 0.5.0
|
||||
*/
|
||||
virtual Color getPixel(int x, int y) = 0;
|
||||
|
||||
/**
|
||||
* Puts a pixel with a certain color at coordinate (x, y).
|
||||
*
|
||||
* @param x The x coordinate.
|
||||
* @param y The y coordinate.
|
||||
* @param color The color of the pixel to put.
|
||||
* @since 0.5.0
|
||||
*/
|
||||
virtual void putPixel(int x, int y, const Color& color) = 0;
|
||||
|
||||
/**
|
||||
* Converts the image, if possible, to display format.
|
||||
*
|
||||
* IMPORTANT: Only guaranteed to work before the image has been
|
||||
* converted to display format.
|
||||
* @since 0.5.0
|
||||
*/
|
||||
virtual void convertToDisplayFormat() = 0;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the image loader to be used when loading images.
|
||||
*/
|
||||
static ImageLoader* mImageLoader;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_IMAGE_HPP
|
||||
257
project/jni/guichan/include/guichan/imagefont.hpp
Normal file
257
project/jni/guichan/include/guichan/imagefont.hpp
Normal file
@@ -0,0 +1,257 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_IMAGEFONT_HPP
|
||||
#define GCN_IMAGEFONT_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/font.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/rectangle.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Color;
|
||||
class Graphics;
|
||||
class Image;
|
||||
|
||||
/**
|
||||
* A font using an image containing the font data. ImageFont can be used
|
||||
* with any image supported by the currently used ImageLoader.
|
||||
*
|
||||
* These are two examples of an image containing a font.
|
||||
* \image html imagefontexample.bmp
|
||||
* \image html imagefontexample2.bmp
|
||||
*
|
||||
* The first pixel at coordinate (0,0) tells which color the image font
|
||||
* looks for when seperating glyphs. The glyphs in the image is provided
|
||||
* to the image font's constructor in the order they appear in the image.
|
||||
*
|
||||
* To create an ImageFont from the first image example above the following
|
||||
* constructor call should be made:
|
||||
* @code gcn::ImageFont imageFont("fixedfont_big.bmp"," abcdefghijklmno\
|
||||
pqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"); @endcode
|
||||
*
|
||||
* Noteworthy is that the first glyph actually gives the width of space.
|
||||
* Glyphs can, as seen in the second image example above, be seperated with
|
||||
* horizontal lines making it possible to draw glyphs on more then one
|
||||
* line in the image. However, these horizontal lines must have a height of
|
||||
* one pixel!
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ImageFont: public Font
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. Takes an image file containing the font and
|
||||
* a string containing the glyphs. The glyphs in the string should
|
||||
* be in the same order as they appear in the font image.
|
||||
*
|
||||
* @param filename The filename of the image.
|
||||
* @param glyphs The glyphs found in the image.
|
||||
* @throws Exception when glyph list is incorrect or the font file is
|
||||
* corrupt or if no ImageLoader exists.
|
||||
*/
|
||||
ImageFont(const std::string& filename, const std::string& glyphs);
|
||||
|
||||
/**
|
||||
* Constructor. Takes an image containing the font and
|
||||
* a string containing the glyphs. The glyphs in the string should
|
||||
* be in the same order as they appear in the font image.
|
||||
* The image will be deleted in the destructor.
|
||||
*
|
||||
* @param image The image with font glyphs.
|
||||
* @param glyphs The glyphs found in the image.
|
||||
* @throws Exception when glyph list is incorrect or the font image is
|
||||
* is missing.
|
||||
*/
|
||||
ImageFont(Image* image, const std::string& glyphs);
|
||||
|
||||
/**
|
||||
* Constructor. Takes an image file containing the font and
|
||||
* two boundaries of ASCII values. The font image should include
|
||||
* all glyphs specified with the boundaries in increasing ASCII
|
||||
* order. The boundaries are inclusive.
|
||||
*
|
||||
* @param filename The filename of the image.
|
||||
* @param glyphsFrom The ASCII value of the first glyph found in the
|
||||
* image.
|
||||
* @param glyphsTo The ASCII value of the last glyph found in the
|
||||
* image.
|
||||
* @throws Exception when glyph bondaries are incorrect or the font
|
||||
* file is corrupt or if no ImageLoader exists.
|
||||
*/
|
||||
ImageFont(const std::string& filename,
|
||||
unsigned char glyphsFrom=32,
|
||||
unsigned char glyphsTo=126);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ImageFont();
|
||||
|
||||
/**
|
||||
* Draws a glyph.
|
||||
*
|
||||
* NOTE: You normally won't use this function to draw text since
|
||||
* the Graphics class contains better functions for drawing
|
||||
* text.
|
||||
*
|
||||
* @param graphics A graphics object used for drawing.
|
||||
* @param glyph A glyph to draw.
|
||||
* @param x The x coordinate where to draw the glyph.
|
||||
* @param y The y coordinate where to draw the glyph.
|
||||
* @return The width of the glyph in pixels.
|
||||
*/
|
||||
virtual int drawGlyph(Graphics* graphics, unsigned char glyph,
|
||||
int x, int y);
|
||||
|
||||
/**
|
||||
* Sets the space between rows in pixels. Default is 0 pixels.
|
||||
* The space can be negative.
|
||||
*
|
||||
* @param spacing The space between rows in pixels.
|
||||
* @see getRowSpacing
|
||||
*/
|
||||
virtual void setRowSpacing(int spacing);
|
||||
|
||||
/**
|
||||
* Gets the space between rows in pixels.
|
||||
*
|
||||
* @return The space between rows in pixels.
|
||||
* @see setRowSpacing
|
||||
*/
|
||||
virtual int getRowSpacing();
|
||||
|
||||
/**
|
||||
* Sets the spacing between glyphs in pixels. Default is 0 pixels.
|
||||
* The space can be negative.
|
||||
*
|
||||
* @param spacing The glyph space in pixels.
|
||||
* @see getGlyphSpacing
|
||||
*/
|
||||
virtual void setGlyphSpacing(int spacing);
|
||||
|
||||
/**
|
||||
* Gets the spacing between letters in pixels.
|
||||
*
|
||||
* @return the spacing.
|
||||
* @see setGlyphSpacing
|
||||
*/
|
||||
virtual int getGlyphSpacing();
|
||||
|
||||
/**
|
||||
* Gets a width of a glyph in pixels.
|
||||
*
|
||||
* @param glyph The glyph which width will be returned.
|
||||
* @return The width of a glyph in pixels.
|
||||
*/
|
||||
virtual int getWidth(unsigned char glyph) const;
|
||||
|
||||
|
||||
// Inherited from Font
|
||||
|
||||
virtual int getWidth(const std::string& text) const;
|
||||
|
||||
virtual void drawString(Graphics* graphics, const std::string& text,
|
||||
int x, int y);
|
||||
|
||||
virtual int getHeight() const;
|
||||
|
||||
virtual int getStringIndexAt(const std::string& text, int x) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Scans for a certain glyph.
|
||||
*
|
||||
* @param glyph The glyph to scan for. Used for exception messages.
|
||||
* @param x The x coordinate where to begin the scan. The coordinate
|
||||
* will be updated with the end x coordinate of the glyph
|
||||
* when the scan is complete.
|
||||
* @param y The y coordinate where to begin the scan. The coordinate
|
||||
* will be updated with the end y coordinate of the glyph
|
||||
* when the scan is complete.
|
||||
* @param separator The color separator to look for where the glyph ends.
|
||||
* @return A rectangle with the found glyph dimension in the image
|
||||
* with the font.
|
||||
* @throws Exception when no glyph is found.
|
||||
*/
|
||||
Rectangle scanForGlyph(unsigned char glyph,
|
||||
int x,
|
||||
int y,
|
||||
const Color& separator);
|
||||
|
||||
/**
|
||||
* Holds the glyphs areas in the image.
|
||||
*/
|
||||
Rectangle mGlyph[256];
|
||||
|
||||
/**
|
||||
* Holds the height of the image font.
|
||||
*/
|
||||
int mHeight;
|
||||
|
||||
/**
|
||||
* Holds the glyph spacing of the image font.
|
||||
*/
|
||||
int mGlyphSpacing;
|
||||
|
||||
/**
|
||||
* Holds the row spacing of the image font.
|
||||
*/
|
||||
int mRowSpacing;
|
||||
|
||||
/**
|
||||
* Holds the image with the font data.
|
||||
*/
|
||||
Image* mImage;
|
||||
|
||||
/**
|
||||
* Holds the filename of the image with the font data.
|
||||
*/
|
||||
std::string mFilename;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_IMAGEFONT_HPP
|
||||
98
project/jni/guichan/include/guichan/imageloader.hpp
Normal file
98
project/jni/guichan/include/guichan/imageloader.hpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_IMAGELOADER_HPP
|
||||
#define GCN_IMAGELOADER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Image;
|
||||
|
||||
/**
|
||||
* Abstract class for providing functions for loading images.
|
||||
*
|
||||
* Guichan contains implementations of ImageLoader for common
|
||||
* libraries like the Allegro library, the HGE library,
|
||||
* he OpenLayer library, and the SDL library.
|
||||
* To make Guichan usable with other libraries, an ImageLoader
|
||||
* class must be implemented.
|
||||
*
|
||||
* To make Guichan use an image loader, the image loader needs
|
||||
* to be passed to the Image class using the static method
|
||||
* Image::setImageLoader.
|
||||
*
|
||||
* @see Image::setImageLoader, Image::getImageLoader,
|
||||
* AllegroImageLoader, HGEImageLoader, OpenLayerImageLoader,
|
||||
* OpenGLAllegroImageLoader, OpenGLSDLImageLoader,
|
||||
* SDLImageLoader
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ImageLoader
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ImageLoader() { }
|
||||
|
||||
/**
|
||||
* Loads an image.
|
||||
*
|
||||
* NOTE: The functions Image::getPixel and Image::putPixel
|
||||
* are only guaranteed to work before an image has
|
||||
* been converted to display format.
|
||||
*
|
||||
* @param filename The filename of the image to load.
|
||||
* @param convertToDisplayFormat True if the image should be converted
|
||||
* to display, false otherwise.
|
||||
*/
|
||||
virtual Image* load(const std::string& filename, bool convertToDisplayFormat = true) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_IMAGELOADER_HPP
|
||||
115
project/jni/guichan/include/guichan/input.hpp
Normal file
115
project/jni/guichan/include/guichan/input.hpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_INPUT_HPP
|
||||
#define GCN_INPUT_HPP
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class KeyInput;
|
||||
class MouseInput;
|
||||
|
||||
/**
|
||||
* Abstract class for providing functions for user input.
|
||||
*
|
||||
* Guichan contains implementations of Input for common
|
||||
* libraries like the Allegro library, the HGE library,
|
||||
* and the SDL library.
|
||||
* To make Guichan usable with other libraries, an Input
|
||||
* class must be implemented.
|
||||
*
|
||||
* @see AllegroInput, HGEInput, OpenLayerInput,
|
||||
* SDLInput
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Input
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Input(){ }
|
||||
|
||||
/**
|
||||
* Checks if the key queue is empty, or not.
|
||||
*
|
||||
* @return True if the key queue is empty,
|
||||
* false otherwise.
|
||||
*/
|
||||
virtual bool isKeyQueueEmpty() = 0;
|
||||
|
||||
/**
|
||||
* Dequeues the key input queue.
|
||||
*
|
||||
* @return The first key input in the key input queue.
|
||||
*/
|
||||
virtual KeyInput dequeueKeyInput() = 0;
|
||||
|
||||
/**
|
||||
* Checks if the mouse queue is empyt, or not.
|
||||
*
|
||||
* @return True if the mouse queue is empty,
|
||||
* false otherwise.
|
||||
*/
|
||||
virtual bool isMouseQueueEmpty() = 0;
|
||||
|
||||
/**
|
||||
* Dequeues the mouse input queue.
|
||||
*
|
||||
* @return The first mouse input in the mouse input queue.
|
||||
*/
|
||||
virtual MouseInput dequeueMouseInput() = 0;
|
||||
|
||||
/**
|
||||
* Polls all exsisting input. Called when input should
|
||||
* be polled. The function exists for compatibility reason
|
||||
* where some libraries need to poll input at a certain
|
||||
* logic rate.
|
||||
*/
|
||||
virtual void _pollInput() = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_INPUT_HPP
|
||||
159
project/jni/guichan/include/guichan/inputevent.hpp
Normal file
159
project/jni/guichan/include/guichan/inputevent.hpp
Normal file
@@ -0,0 +1,159 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_INPUTEVENT_HPP
|
||||
#define GCN_INPUTEVENT_HPP
|
||||
|
||||
#include "guichan/event.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Base class for all events concerning input.
|
||||
*
|
||||
* @author Olof Naessén
|
||||
* @since 0.6.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC InputEvent: public Event
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source The source widget of the event.
|
||||
* @param isShiftPressed True if shift is pressed, false otherwise.
|
||||
* @param isControlPressed True if control is pressed, false otherwise.
|
||||
* @param isAltPressed True if alt is pressed, false otherwise.
|
||||
* @param isMetaPressed True if meta is pressed, false otherwise.
|
||||
*/
|
||||
InputEvent(Widget* source,
|
||||
bool isShiftPressed,
|
||||
bool isControlPressed,
|
||||
bool isAltPressed,
|
||||
bool isMetaPressed);
|
||||
|
||||
/**
|
||||
* Checks if shift is pressed.
|
||||
*
|
||||
* @return True if shift was pressed at the same time as the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool isShiftPressed() const;
|
||||
|
||||
/**
|
||||
* Checks if control is pressed.
|
||||
*
|
||||
* @return True if control was pressed at the same time as the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool isControlPressed() const;
|
||||
|
||||
/**
|
||||
* Checks if alt is pressed.
|
||||
*
|
||||
* @return True if alt was pressed at the same time as the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool isAltPressed() const;
|
||||
|
||||
/**
|
||||
* Checks whether meta is pressed.
|
||||
*
|
||||
* @return True if meta was pressed at the same time as the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool isMetaPressed() const;
|
||||
|
||||
/**
|
||||
* Marks the event as consumed. Input event listeners may discard
|
||||
* consumed input or act on consumed input. An example of a widget
|
||||
* that discards consumed input is the ScrollArea widget that
|
||||
* discards consumed mouse wheel events so the ScrollArea will not
|
||||
* scroll if for instance a Slider's value inside the ScrollArea was
|
||||
* changed with the mouse wheel.
|
||||
*
|
||||
* @see isConsumed
|
||||
*/
|
||||
void consume();
|
||||
|
||||
/**
|
||||
* Checks if the input event is consumed.
|
||||
*
|
||||
* @return True if the input event is consumed,
|
||||
* false otherwise.
|
||||
* @see consume
|
||||
*/
|
||||
bool isConsumed() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* True if shift is pressed, false otherwise.
|
||||
*/
|
||||
bool mShiftPressed;
|
||||
|
||||
/**
|
||||
* True if control is pressed, false otherwise.
|
||||
*/
|
||||
bool mControlPressed;
|
||||
|
||||
/**
|
||||
* True if alt is pressed, false otherwise.
|
||||
*/
|
||||
bool mAltPressed;
|
||||
|
||||
/**
|
||||
* True if meta is pressed, false otherwise.
|
||||
*/
|
||||
bool mMetaPressed;
|
||||
|
||||
/**
|
||||
* True if the input event is consumed,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool mIsConsumed;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_INPUTEVENT_HPP
|
||||
182
project/jni/guichan/include/guichan/key.hpp
Normal file
182
project/jni/guichan/include/guichan/key.hpp
Normal file
@@ -0,0 +1,182 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_KEY_HPP
|
||||
#define GCN_KEY_HPP
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
// windows.h defines DELETE which breaks this file as we have a constant named
|
||||
// DELETE, hence we undefine DELETE if it is defined and hope people don't use
|
||||
// that windows define with Guichan.
|
||||
#if defined (_WIN32) && defined(DELETE)
|
||||
#undef DELETE
|
||||
#endif
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Represents a key or a character.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Key
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param value The ascii or enum value for the key.
|
||||
*/
|
||||
Key(int value = 0);
|
||||
|
||||
/**
|
||||
* Checks if a key is a character.
|
||||
*
|
||||
* @return True if the key is a letter, number or whitespace,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool isCharacter() const;
|
||||
|
||||
/**
|
||||
* Checks if a key is a number.
|
||||
*
|
||||
* @return True if the key is a number (0-9),
|
||||
* false otherwise.
|
||||
*/
|
||||
bool isNumber() const;
|
||||
|
||||
/**
|
||||
* Checks if a key is a letter.
|
||||
*
|
||||
* @return True if the key is a letter (a-z,A-Z),
|
||||
* false otherwise.
|
||||
*/
|
||||
bool isLetter() const;
|
||||
|
||||
/**
|
||||
* Gets the value of the key. If an ascii value exists it
|
||||
* will be returned. Otherwise an enum value will be returned.
|
||||
*
|
||||
* @return the value of the key.
|
||||
*/
|
||||
int getValue() const;
|
||||
|
||||
/**
|
||||
* Compares two keys.
|
||||
*
|
||||
* @param key The key to compare this key with.
|
||||
* @return True if the keys are equal, false otherwise.
|
||||
*/
|
||||
bool operator==(const Key& key) const;
|
||||
|
||||
/**
|
||||
* Compares two keys.
|
||||
*
|
||||
* @param key The key to compare this key with.
|
||||
* @return True if the keys are not equal, false otherwise.
|
||||
*/
|
||||
bool operator!=(const Key& key) const;
|
||||
|
||||
/**
|
||||
* An enum with key values.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
SPACE = ' ',
|
||||
TAB = '\t',
|
||||
ENTER = '\n',
|
||||
LEFT_ALT = 1000,
|
||||
RIGHT_ALT,
|
||||
LEFT_SHIFT,
|
||||
RIGHT_SHIFT,
|
||||
LEFT_CONTROL,
|
||||
RIGHT_CONTROL,
|
||||
LEFT_META,
|
||||
RIGHT_META,
|
||||
LEFT_SUPER,
|
||||
RIGHT_SUPER,
|
||||
INSERT,
|
||||
HOME,
|
||||
PAGE_UP,
|
||||
DELETE,
|
||||
END,
|
||||
PAGE_DOWN,
|
||||
ESCAPE,
|
||||
CAPS_LOCK,
|
||||
BACKSPACE,
|
||||
F1,
|
||||
F2,
|
||||
F3,
|
||||
F4,
|
||||
F5,
|
||||
F6,
|
||||
F7,
|
||||
F8,
|
||||
F9,
|
||||
F10,
|
||||
F11,
|
||||
F12,
|
||||
F13,
|
||||
F14,
|
||||
F15,
|
||||
PRINT_SCREEN,
|
||||
SCROLL_LOCK,
|
||||
PAUSE,
|
||||
NUM_LOCK,
|
||||
ALT_GR,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
UP,
|
||||
DOWN
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the value of the key. It may be an ascii value
|
||||
* or an enum value.
|
||||
*/
|
||||
int mValue;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_KEY_HPP
|
||||
138
project/jni/guichan/include/guichan/keyevent.hpp
Normal file
138
project/jni/guichan/include/guichan/keyevent.hpp
Normal file
@@ -0,0 +1,138 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_KEYEVENT_HPP
|
||||
#define GCN_KEYEVENT_HPP
|
||||
|
||||
#include "guichan/inputevent.hpp"
|
||||
#include "guichan/key.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Widget;
|
||||
|
||||
/**
|
||||
* Represents a key event.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC KeyEvent: public InputEvent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Key event types.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
PRESSED = 0,
|
||||
RELEASED
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source The source widget of the event.
|
||||
* @param isShiftPressed True if shift is pressed, false otherwise.
|
||||
* @param isControlPressed True if control is pressed, false otherwise.
|
||||
* @param isAltPressed True if alt is pressed, false otherwise.
|
||||
* @param isMetaPressed True if meta is pressed, false otherwise.
|
||||
* @param type The type of the event. A value from KeyEventType.
|
||||
* @param isNumericPad True if the event occured on the numeric pad,
|
||||
* false otherwise.
|
||||
* @param key The key of the event.
|
||||
*/
|
||||
KeyEvent(Widget* source,
|
||||
bool isShiftPressed,
|
||||
bool isControlPressed,
|
||||
bool isAltPressed,
|
||||
bool isMetaPressed,
|
||||
unsigned int type,
|
||||
bool isNumericPad,
|
||||
const Key& key);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~KeyEvent();
|
||||
|
||||
/**
|
||||
* Gets the type of the event.
|
||||
*
|
||||
* @return The type of the event.
|
||||
*/
|
||||
unsigned int getType() const;
|
||||
|
||||
/**
|
||||
* Checks if the key event occured on the numeric pad.
|
||||
*
|
||||
* @return True if key event occured on the numeric pad,
|
||||
* false otherwise.
|
||||
*
|
||||
*/
|
||||
bool isNumericPad() const;
|
||||
|
||||
/**
|
||||
* Gets the key of the event.
|
||||
*
|
||||
* @return The key of the event.
|
||||
*/
|
||||
const Key& getKey() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the type of the key event.
|
||||
*/
|
||||
unsigned int mType;
|
||||
|
||||
/**
|
||||
* True if the numeric pad was used, false otherwise.
|
||||
*/
|
||||
bool mIsNumericPad;
|
||||
|
||||
/**
|
||||
* Holds the key of the key event.
|
||||
*/
|
||||
Key mKey;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_KEYEVENT_HPP
|
||||
263
project/jni/guichan/include/guichan/keyinput.hpp
Normal file
263
project/jni/guichan/include/guichan/keyinput.hpp
Normal file
@@ -0,0 +1,263 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_KEYINPUT_HPP
|
||||
#define GCN_KEYINPUT_HPP
|
||||
|
||||
#include "guichan/key.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Internal class that represents key input. Generally you won't have to
|
||||
* bother using this class unless you implement an Input class for
|
||||
* a back end.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC KeyInput
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
KeyInput() { };
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param key The key of the key input.
|
||||
* @param type The type of key input.
|
||||
*/
|
||||
KeyInput(const Key& key, unsigned int type);
|
||||
|
||||
/**
|
||||
* Sets the type of the key input.
|
||||
*
|
||||
* @param type The type of key input.
|
||||
* @see getType
|
||||
*/
|
||||
void setType(unsigned int type);
|
||||
|
||||
/**
|
||||
* Gets the type of the key input.
|
||||
*
|
||||
* @return the input type.
|
||||
* @see setType
|
||||
*/
|
||||
int getType() const;
|
||||
|
||||
/**
|
||||
* Sets the key of the key input.
|
||||
*
|
||||
* @param key The key of the key input.
|
||||
* @see getKey
|
||||
*/
|
||||
void setKey(const Key& key);
|
||||
|
||||
/**
|
||||
* Gets the key of the key input.
|
||||
*
|
||||
* @return The key of the key input.
|
||||
* @see setKey
|
||||
*/
|
||||
const Key& getKey() const;
|
||||
|
||||
/**
|
||||
* Checks if shift is pressed.
|
||||
*
|
||||
* @return True if shift was pressed at the same
|
||||
* time as the key, false otherwise.
|
||||
* @see setShiftPressed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
bool isShiftPressed() const;
|
||||
|
||||
/**
|
||||
* Sets shift to be pressed at the same time as the key,
|
||||
* or not.
|
||||
*
|
||||
* @param pressed True if shift is pressed, false otherwise.
|
||||
* @see isShiftPressed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
void setShiftPressed(bool pressed);
|
||||
|
||||
/**
|
||||
* Checks if control is pressed.
|
||||
*
|
||||
* @return True if control was pressed at the same
|
||||
* time as the key, false otherwise.
|
||||
* @see setControlPressed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
bool isControlPressed() const;
|
||||
|
||||
/**
|
||||
* Sets control to be pressed at the same time as the key,
|
||||
* or not.
|
||||
*
|
||||
* @param pressed True if control is pressed, false otherwise.
|
||||
* @see isControlPressed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
void setControlPressed(bool pressed);
|
||||
|
||||
/**
|
||||
* Checks if alt is pressed.
|
||||
*
|
||||
* @return True if alt was pressed at the same
|
||||
* time as the key, false otherwise.
|
||||
* @see setAltPressed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
bool isAltPressed() const;
|
||||
|
||||
/**
|
||||
* Sets the alt to be pressed at the same time as the key,
|
||||
* or not.
|
||||
*
|
||||
* @param pressed True if alt is pressed at the same
|
||||
* time as the key, , false otherwise.
|
||||
* @see isAltPressed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
void setAltPressed(bool pressed);
|
||||
|
||||
/**
|
||||
* Checks if meta is pressed.
|
||||
*
|
||||
* @return True if meta was pressed at the same
|
||||
* time as the key, false otherwise.
|
||||
* @see setMetaPressed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
bool isMetaPressed() const;
|
||||
|
||||
/**
|
||||
* Sets meta to be pressed at the same time as the key,
|
||||
* or not.
|
||||
*
|
||||
* @param pressed True if meta is pressed at the same
|
||||
* time as the key, false otherwise.
|
||||
* @see isMetaPressed
|
||||
* @since 0.6.0
|
||||
*/
|
||||
void setMetaPressed(bool pressed);
|
||||
|
||||
/**
|
||||
* Checks if the key was pressed at the numeric pad.
|
||||
*
|
||||
* @return True if key pressed at the numeric pad,
|
||||
* false otherwise.
|
||||
* @setNumericPad
|
||||
* @since 0.6.0
|
||||
*/
|
||||
bool isNumericPad() const;
|
||||
|
||||
/**
|
||||
* Sets the key to be pressed at the numeric pad.
|
||||
*
|
||||
* @param numpad True if the key was pressed at the numeric
|
||||
* pad, false otherwise.
|
||||
* @see isNumericPad
|
||||
* @since 0.6.0
|
||||
*/
|
||||
void setNumericPad(bool numpad);
|
||||
|
||||
/**
|
||||
* Key input types. This enum corresponds to the enum with event
|
||||
* types on KeyEvent for easy mapping.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
PRESSED = 0,
|
||||
RELEASED
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the key of the key input.
|
||||
*/
|
||||
Key mKey;
|
||||
|
||||
/**
|
||||
* Holds the type of the key input.
|
||||
*/
|
||||
unsigned int mType;
|
||||
|
||||
/**
|
||||
* True if shift was pressed at the same time as the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool mShiftPressed;
|
||||
|
||||
/**
|
||||
* True if control was pressed at the same time as the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool mControlPressed;
|
||||
|
||||
/**
|
||||
* True if alt was pressed at the same time as the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool mAltPressed;
|
||||
|
||||
/**
|
||||
* True if meta was pressed at the same time as the key,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool mMetaPressed;
|
||||
|
||||
/**
|
||||
* True if the numeric pad was used when the key was pressed,
|
||||
* false otherwise.
|
||||
*/
|
||||
bool mNumericPad;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_KEYINPUT_HPP
|
||||
95
project/jni/guichan/include/guichan/keylistener.hpp
Normal file
95
project/jni/guichan/include/guichan/keylistener.hpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_KEYLISTENER_HPP
|
||||
#define GCN_KEYLISTENER_HPP
|
||||
|
||||
#include "guichan/keyevent.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Key;
|
||||
|
||||
/**
|
||||
* Interface for listening for key events from widgets.
|
||||
*
|
||||
* @see Widget::addKeyListener, Widget::removeKeyListener
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC KeyListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~KeyListener() { }
|
||||
|
||||
/**
|
||||
* Called if a key is pressed when the widget has keyboard focus.
|
||||
* If a key is held down the widget will generate multiple key
|
||||
* presses.
|
||||
*
|
||||
* @param keyEvent Discribes the event.
|
||||
*/
|
||||
virtual void keyPressed(KeyEvent& keyEvent) { }
|
||||
|
||||
/**
|
||||
* Called if a key is released when the widget has keyboard focus.
|
||||
*
|
||||
* @param keyEvent Discribes the event.
|
||||
*/
|
||||
virtual void keyReleased(KeyEvent& keyEvent) { }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* You should not be able to make an instance of KeyListener,
|
||||
* therefore its constructor is protected.
|
||||
*/
|
||||
KeyListener() { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_KEYLISTENER_HPP
|
||||
86
project/jni/guichan/include/guichan/listmodel.hpp
Normal file
86
project/jni/guichan/include/guichan/listmodel.hpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_LISTMODEL_HPP
|
||||
#define GCN_LISTMODEL_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* An interface for a model that represents a list. It is
|
||||
* used in certain widgets, like the ListBox, to handle a
|
||||
* lists with string elements. If you want to use widgets
|
||||
* like ListBox, make a derived class from this class that
|
||||
* represents your list.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ListModel
|
||||
{
|
||||
|
||||
public:
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ListModel() { }
|
||||
|
||||
/**
|
||||
* Gets the number of elements in the list.
|
||||
*
|
||||
* @return The number of elements in the list
|
||||
*/
|
||||
virtual int getNumberOfElements() = 0;
|
||||
|
||||
/**
|
||||
* Gets an element at a certain index in the list.
|
||||
*
|
||||
* @param i An index in the list.
|
||||
* @return An element as a string at the a certain index.
|
||||
*/
|
||||
virtual std::string getElementAt(int i) = 0;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_LISTMODEL_HPP
|
||||
200
project/jni/guichan/include/guichan/mouseevent.hpp
Normal file
200
project/jni/guichan/include/guichan/mouseevent.hpp
Normal file
@@ -0,0 +1,200 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_MOUSEEVENT_HPP
|
||||
#define GCN_MOUSEEVENT_HPP
|
||||
|
||||
#include "guichan/inputevent.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Gui;
|
||||
class Widget;
|
||||
|
||||
/**
|
||||
* Represents a mouse event.
|
||||
*
|
||||
* @author Olof Naessén
|
||||
* @since 0.6.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC MouseEvent: public InputEvent
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source The source widget of the mouse event.
|
||||
* @param isShiftPressed True if shift is pressed, false otherwise.
|
||||
* @param isControlPressed True if control is pressed, false otherwise.
|
||||
* @param isAltPressed True if alt is pressed, false otherwise.
|
||||
* @param isMetaPressed True if meta is pressed, false otherwise.
|
||||
* @param type The type of the mouse event.
|
||||
* @param button The button of the mouse event.
|
||||
* @param x The x coordinate of the event relative to the source widget.
|
||||
* @param y The y coordinate of the event relative the source widget.
|
||||
* @param clickCount The number of clicks generated with the same button.
|
||||
* It's set to zero if another button is used.
|
||||
*/
|
||||
MouseEvent(Widget* source,
|
||||
bool isShiftPressed,
|
||||
bool isControlPressed,
|
||||
bool isAltPressed,
|
||||
bool isMetaPressed,
|
||||
unsigned int type,
|
||||
unsigned int button,
|
||||
int x,
|
||||
int y,
|
||||
int clickCount);
|
||||
|
||||
/**
|
||||
* Gets the button of the mouse event.
|
||||
*
|
||||
* @return The button of the mouse event.
|
||||
*/
|
||||
unsigned int getButton() const;
|
||||
|
||||
/**
|
||||
* Gets the x coordinate of the mouse event.
|
||||
* The coordinate relative to widget the mouse listener
|
||||
* receiving the events have registered to.
|
||||
*
|
||||
* @return The x coordinate of the mouse event.
|
||||
* @see Widget::addMouseListener, Widget::removeMouseListener
|
||||
*/
|
||||
int getX() const;
|
||||
|
||||
/**
|
||||
* Gets the y coordinate of the mouse event.
|
||||
* The coordinate relative to widget the mouse listener
|
||||
* receiving the events have registered to.
|
||||
*
|
||||
* @return The y coordinate of the mouse event.
|
||||
* @see Widget::addMouseListener, Widget::removeMouseListener
|
||||
*/
|
||||
int getY() const;
|
||||
|
||||
/**
|
||||
* Gets the number of clicks generated with the same button.
|
||||
* It's set to zero if another button is used.
|
||||
*
|
||||
* @return The number of clicks generated with the same button.
|
||||
*/
|
||||
int getClickCount() const;
|
||||
|
||||
/**
|
||||
* Gets the type of the event.
|
||||
*
|
||||
* @return The type of the event.
|
||||
*/
|
||||
unsigned int getType() const;
|
||||
|
||||
/**
|
||||
* Mouse event types.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
MOVED = 0,
|
||||
PRESSED,
|
||||
RELEASED,
|
||||
WHEEL_MOVED_DOWN,
|
||||
WHEEL_MOVED_UP,
|
||||
CLICKED,
|
||||
ENTERED,
|
||||
EXITED,
|
||||
DRAGGED
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Mouse button types.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
EMPTY = 0,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
MIDDLE
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the type of the mouse event.
|
||||
*/
|
||||
unsigned int mType;
|
||||
|
||||
/**
|
||||
* Holds the button of the mouse event.
|
||||
*/
|
||||
unsigned int mButton;
|
||||
|
||||
/**
|
||||
* Holds the x-coordinate of the mouse event.
|
||||
*/
|
||||
int mX;
|
||||
|
||||
/**
|
||||
* Holds the y-coordinate of the mouse event.
|
||||
*/
|
||||
int mY;
|
||||
|
||||
/**
|
||||
* The number of clicks generated with the same button.
|
||||
* It's set to zero if another button is used.
|
||||
*/
|
||||
int mClickCount;
|
||||
|
||||
/**
|
||||
* Gui is a friend of this class in order to be able to manipulate
|
||||
* the protected member variables of this class and at the same time
|
||||
* keep the MouseEvent class as const as possible. Gui needs to
|
||||
* update the x och y coordinates for the coordinates to be relative
|
||||
* to widget the mouse listener receiving the events have registered
|
||||
* to.
|
||||
*/
|
||||
friend class Gui;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // GCN_MOUSEEVENT_HPP
|
||||
235
project/jni/guichan/include/guichan/mouseinput.hpp
Normal file
235
project/jni/guichan/include/guichan/mouseinput.hpp
Normal file
@@ -0,0 +1,235 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_MOUSEINPUT_HPP
|
||||
#define GCN_MOUSEINPUT_HPP
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
|
||||
/**
|
||||
* Internal class that represents mouse input. Generally you won't have to
|
||||
* bother using this class unless you implement an Input class for
|
||||
* a back end.
|
||||
*
|
||||
* @author Olof Naessén
|
||||
* @author Per Larsson
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC MouseInput
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
MouseInput() { };
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param button The button pressed.
|
||||
* @param type The type of mouse input.
|
||||
* @param x The mouse x coordinate.
|
||||
* @param y The mouse y coordinate.
|
||||
* @param timeStamp The timestamp of the mouse input. Used to
|
||||
* check for double clicks.
|
||||
*/
|
||||
MouseInput(unsigned int button,
|
||||
unsigned int type,
|
||||
int x,
|
||||
int y,
|
||||
int timeStamp);
|
||||
|
||||
/**
|
||||
* Sets the type of the mouse input.
|
||||
*
|
||||
* @param type The type of the mouse input. Should be a value from the
|
||||
* mouse event type enum
|
||||
* @see getType
|
||||
* @since 0.1.0
|
||||
*/
|
||||
void setType(unsigned int type);
|
||||
|
||||
/**
|
||||
* Gets the type of the mouse input.
|
||||
*
|
||||
* @return The type of the mouse input. A value from the mouse event
|
||||
* type enum.
|
||||
* @see setType
|
||||
* @since 0.1.0
|
||||
*/
|
||||
unsigned int getType() const;
|
||||
|
||||
/**
|
||||
* Sets the button pressed.
|
||||
*
|
||||
* @param button The button pressed. Should be one of the values
|
||||
* in the mouse event button enum.
|
||||
* @see getButton.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
void setButton(unsigned int button);
|
||||
|
||||
/**
|
||||
* Gets the button pressed.
|
||||
*
|
||||
* @return The button pressed. A value from the mouse event
|
||||
* button enum.
|
||||
* @see setButton
|
||||
* @since 0.1.0
|
||||
*/
|
||||
unsigned int getButton() const;
|
||||
|
||||
/**
|
||||
* Sets the timestamp for the mouse input.
|
||||
* Used to check for double clicks.
|
||||
*
|
||||
* @param timeStamp The timestamp of the mouse input.
|
||||
* @see getTimeStamp
|
||||
* @since 0.1.0
|
||||
*/
|
||||
void setTimeStamp(int timeStamp);
|
||||
|
||||
/**
|
||||
* Gets the time stamp of the input.
|
||||
* Used to check for double clicks.
|
||||
*
|
||||
* @return The time stamp of the mouse input.
|
||||
* @see setTimeStamp
|
||||
* @since 0.1.0
|
||||
*/
|
||||
int getTimeStamp() const;
|
||||
|
||||
/**
|
||||
* Sets the x coordinate of the mouse input.
|
||||
*
|
||||
* @param x The x coordinate of the mouse input.
|
||||
* @see getX
|
||||
* @since 0.6.0
|
||||
*/
|
||||
void setX(int x);
|
||||
|
||||
/**
|
||||
* Gets the x coordinate of the mouse input.
|
||||
*
|
||||
* @return The x coordinate of the mouse input.
|
||||
* @see setX
|
||||
* @since 0.6.0
|
||||
*/
|
||||
int getX() const;
|
||||
|
||||
/**
|
||||
* Sets the y coordinate of the mouse input.
|
||||
*
|
||||
* @param y The y coordinate of the mouse input.
|
||||
* @see getY
|
||||
* @since 0.6.0
|
||||
*/
|
||||
void setY(int y);
|
||||
|
||||
/**
|
||||
* Gets the y coordinate of the mouse input.
|
||||
*
|
||||
* @return The y coordinate of the mouse input.
|
||||
* @see setY
|
||||
* @since 0.6.0
|
||||
*/
|
||||
int getY() const;
|
||||
|
||||
/**
|
||||
* Mouse input event types. This enum partially corresponds
|
||||
* to the enum with event types in MouseEvent for easy mapping.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
MOVED = 0,
|
||||
PRESSED,
|
||||
RELEASED,
|
||||
WHEEL_MOVED_DOWN,
|
||||
WHEEL_MOVED_UP
|
||||
};
|
||||
|
||||
/**
|
||||
* Mouse button types.
|
||||
*/
|
||||
enum
|
||||
{
|
||||
EMPTY = 0,
|
||||
LEFT,
|
||||
RIGHT,
|
||||
MIDDLE
|
||||
};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the type of the mouse input.
|
||||
*/
|
||||
unsigned int mType;
|
||||
|
||||
/**
|
||||
* Holds the button of the mouse input.
|
||||
*/
|
||||
unsigned int mButton;
|
||||
|
||||
/**
|
||||
* Holds the timestamp of the mouse input. Used to
|
||||
* check for double clicks.
|
||||
*/
|
||||
int mTimeStamp;
|
||||
|
||||
/**
|
||||
* Holds the x coordinate of the mouse input.
|
||||
*/
|
||||
int mX;
|
||||
|
||||
/**
|
||||
* Holds the y coordinate of the mouse input.
|
||||
*/
|
||||
int mY;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_MOUSEINPUT_HPP
|
||||
183
project/jni/guichan/include/guichan/mouselistener.hpp
Normal file
183
project/jni/guichan/include/guichan/mouselistener.hpp
Normal file
@@ -0,0 +1,183 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_MOUSELISTENER_HPP
|
||||
#define GCN_MOUSELISTENER_HPP
|
||||
|
||||
#include "guichan/mouseevent.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Interface for listening for mouse events from widgets.
|
||||
*
|
||||
* @see Widget::addMouseListener, Widget::removeMouseListener
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC MouseListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~MouseListener() { }
|
||||
|
||||
/**
|
||||
* Called when the mouse has entered into the widget area.
|
||||
*
|
||||
* @param mouseEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mouseEntered(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse has exited the widget area.
|
||||
*
|
||||
* @param mouseEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mouseExited(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a mouse button has been pressed on the widget area.
|
||||
*
|
||||
* NOTE: A mouse press is NOT equal to a mouse click.
|
||||
* Use mouseClickMessage to check for mouse clicks.
|
||||
*
|
||||
* @param mouseEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mousePressed(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a mouse button has been released on the widget area.
|
||||
*
|
||||
* @param mouseEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mouseReleased(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a mouse button is pressed and released (clicked) on
|
||||
* the widget area.
|
||||
*
|
||||
* @param mouseEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mouseClicked(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse wheel has moved up on the widget area.
|
||||
*
|
||||
* @param mouseEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse wheel has moved down on the widget area.
|
||||
*
|
||||
* @param mousEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse has moved in the widget area and no mouse button
|
||||
* has been pressed (i.e no widget is being dragged).
|
||||
*
|
||||
* @param mouseEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mouseMoved(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the mouse has moved and the mouse has previously been
|
||||
* pressed on the widget.
|
||||
*
|
||||
* @param mouseEvent Describes the event.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
virtual void mouseDragged(MouseEvent& mouseEvent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* You should not be able to make an instance of MouseListener,
|
||||
* therefore its constructor is protected.
|
||||
*/
|
||||
MouseListener() { }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_MOUSELISTENER_HPP
|
||||
60
project/jni/guichan/include/guichan/opengl.hpp
Normal file
60
project/jni/guichan/include/guichan/opengl.hpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_OPENGL_HPP
|
||||
#define GCN_OPENGL_HPP
|
||||
|
||||
#include <guichan/opengl/openglgraphics.hpp>
|
||||
#include <guichan/opengl/openglimage.hpp>
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* Exists to be able to check for Guichan OpenGL with autotools.
|
||||
*/
|
||||
GCN_EXTENSION_DECLSPEC extern void gcnOpenGL();
|
||||
}
|
||||
|
||||
#endif // end GCN_OPENGL_HPP
|
||||
64
project/jni/guichan/include/guichan/openlayer.hpp
Normal file
64
project/jni/guichan/include/guichan/openlayer.hpp
Normal file
@@ -0,0 +1,64 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_OPENLAYER_HPP
|
||||
#define GCN_OPENLAYER_HPP
|
||||
|
||||
#include <guichan/openlayer/openlayerinput.hpp>
|
||||
#include <guichan/openlayer/openlayerfont.hpp>
|
||||
#include <guichan/openlayer/openlayerimageloader.hpp>
|
||||
#include <guichan/openlayer/openlayergraphics.hpp>
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* Exists to be able to check for Guichan Open Layer
|
||||
* with autotools.
|
||||
*/
|
||||
GCN_EXTENSION_DECLSPEC extern void gcnOpenLayer();
|
||||
}
|
||||
|
||||
#endif // end GCN_OPENLAYER_HPP
|
||||
79
project/jni/guichan/include/guichan/platform.hpp
Normal file
79
project/jni/guichan/include/guichan/platform.hpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_PLATFORM_HPP
|
||||
#define GCN_PLATFORM_HPP
|
||||
|
||||
#if defined (__MINGW32__) && defined(GUICHAN_BUILD)
|
||||
#define GCN_CORE_DECLSPEC __declspec(dllexport)
|
||||
|
||||
#elif defined (__MINGW32__) && defined(GUICHAN_EXTENSION_BUILD)
|
||||
#define GCN_EXTENSION_DECLSPEC __declspec(dllexport)
|
||||
#define GCN_CORE_DECLSPEC __declspec(dllimport)
|
||||
|
||||
#elif defined (__MINGW32__) && defined(GUICHAN_DLL_IMPORT)
|
||||
#define GCN_CORE_DECLSPEC __declspec(dllimport)
|
||||
#define GCN_EXTENSION_DECLSPEC __declspec(dllimport)
|
||||
|
||||
#elif defined(_MSC_VER) && defined(GUICHAN_BUILD)
|
||||
#define GCN_CORE_DECLSPEC _declspec(dllexport)
|
||||
|
||||
#elif defined(_MSC_VER) && defined(GUICHAN_EXTENSION_BUILD)
|
||||
#define GCN_CORE_DECLSPEC _declspec(dllimport)
|
||||
#define GCN_EXTENSION_DECLSPEC _declspec(dllexport)
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef GCN_CORE_DECLSPEC
|
||||
#define GCN_CORE_DECLSPEC
|
||||
#endif
|
||||
|
||||
#ifndef GCN_EXTENSION_DECLSPEC
|
||||
#define GCN_EXTENSION_DECLSPEC
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#endif // end GCN_PLATFORM_HPP
|
||||
140
project/jni/guichan/include/guichan/rectangle.hpp
Normal file
140
project/jni/guichan/include/guichan/rectangle.hpp
Normal file
@@ -0,0 +1,140 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_RECTANGLE_HPP
|
||||
#define GCN_RECTANGLE_HPP
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Represents a rectangle.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Rectangle
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. The default rectangle is an empty rectangle
|
||||
* at the coordinates (0,0).
|
||||
*/
|
||||
Rectangle();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param x The x coordinate of the rectangle.
|
||||
* @param y The y coordinate of the rectangle.
|
||||
* @param width The width of the rectangle.
|
||||
* @param height The height of the rectangle.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
Rectangle(int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Sets the dimension of a rectangle.
|
||||
*
|
||||
* @param x The x coordinate of the rectangle.
|
||||
* @param y The y coordinate of the rectangle.
|
||||
* @param width The width of the rectangle.
|
||||
* @param height The height of the rectangle.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
void setAll(int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* Checks if another rectangle intersects with the rectangle.
|
||||
*
|
||||
* @param rectangle Another rectangle to check for intersection.
|
||||
* @return True if the rectangles intersect, false otherwise.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
bool isIntersecting(const Rectangle& rectangle) const;
|
||||
|
||||
/**
|
||||
* Checks if a point is inside the rectangle
|
||||
*
|
||||
* @param x The x coordinate of the point.
|
||||
* @param y The y coordinate of the point.
|
||||
* @return True if the point is inside the rectangle.
|
||||
* @since 0.1.0
|
||||
*/
|
||||
bool isPointInRect(int x, int y) const;
|
||||
|
||||
/**
|
||||
* Output operator for output.
|
||||
*
|
||||
* @param out The stream to output to.
|
||||
* @param rectangle The rectangle to output.
|
||||
*/
|
||||
friend std::ostream& operator<<(std::ostream& out,
|
||||
const Rectangle& rectangle);
|
||||
|
||||
/**
|
||||
* Holds the x coordinate of the rectangle.
|
||||
*/
|
||||
int x;
|
||||
|
||||
/**
|
||||
* Holds the x coordinate of the rectangle.
|
||||
*/
|
||||
int y;
|
||||
|
||||
/**
|
||||
* Holds the width of the rectangle.
|
||||
*/
|
||||
int width;
|
||||
|
||||
/**
|
||||
* Holds the height of the rectangle.
|
||||
*/
|
||||
int height;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_RECTANGEL_HPP
|
||||
62
project/jni/guichan/include/guichan/sdl.hpp
Normal file
62
project/jni/guichan/include/guichan/sdl.hpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SDL_HPP
|
||||
#define GCN_SDL_HPP
|
||||
|
||||
#include <guichan/sdl/sdlgraphics.hpp>
|
||||
#include <guichan/sdl/sdlimage.hpp>
|
||||
#include <guichan/sdl/sdlimageloader.hpp>
|
||||
#include <guichan/sdl/sdlinput.hpp>
|
||||
|
||||
#include "platform.hpp"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
/**
|
||||
* Exists to be able to check for Guichan SDL with autotools.
|
||||
*/
|
||||
GCN_EXTENSION_DECLSPEC extern void gcnSDL();
|
||||
}
|
||||
|
||||
#endif // end GCN_SDL_HPP
|
||||
156
project/jni/guichan/include/guichan/sdl/sdlgraphics.hpp
Normal file
156
project/jni/guichan/include/guichan/sdl/sdlgraphics.hpp
Normal file
@@ -0,0 +1,156 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SDLGRAPHICS_HPP
|
||||
#define GCN_SDLGRAPHICS_HPP
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "guichan/color.hpp"
|
||||
#include "guichan/graphics.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Image;
|
||||
class Rectangle;
|
||||
|
||||
/**
|
||||
* SDL implementation of the Graphics.
|
||||
*/
|
||||
class GCN_EXTENSION_DECLSPEC SDLGraphics : public Graphics
|
||||
{
|
||||
public:
|
||||
|
||||
// Needed so that drawImage(gcn::Image *, int, int) is visible.
|
||||
using Graphics::drawImage;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
SDLGraphics();
|
||||
|
||||
/**
|
||||
* Sets the target SDL_Surface to draw to. The target can be any
|
||||
* SDL_Surface. This funtion also pushes a clip areas corresponding to
|
||||
* the dimension of the target.
|
||||
*
|
||||
* @param target the target to draw to.
|
||||
*/
|
||||
virtual void setTarget(SDL_Surface* target);
|
||||
|
||||
/**
|
||||
* Gets the target SDL_Surface.
|
||||
*
|
||||
* @return the target SDL_Surface.
|
||||
*/
|
||||
virtual SDL_Surface* getTarget() const;
|
||||
|
||||
/**
|
||||
* Draws an SDL_Surface on the target surface. Normaly you'll
|
||||
* use drawImage, but if you want to write SDL specific code
|
||||
* this function might come in handy.
|
||||
*
|
||||
* NOTE: The clip areas will be taken into account.
|
||||
*/
|
||||
virtual void drawSDLSurface(SDL_Surface* surface,
|
||||
SDL_Rect source,
|
||||
SDL_Rect destination);
|
||||
|
||||
|
||||
// Inherited from Graphics
|
||||
|
||||
virtual void _beginDraw();
|
||||
|
||||
virtual void _endDraw();
|
||||
|
||||
virtual bool pushClipArea(Rectangle area);
|
||||
|
||||
virtual void popClipArea();
|
||||
|
||||
virtual void drawImage(const Image* image,
|
||||
int srcX,
|
||||
int srcY,
|
||||
int dstX,
|
||||
int dstY,
|
||||
int width,
|
||||
int height);
|
||||
|
||||
virtual void drawPoint(int x, int y);
|
||||
|
||||
virtual void drawLine(int x1, int y1, int x2, int y2);
|
||||
|
||||
virtual void drawRectangle(const Rectangle& rectangle);
|
||||
|
||||
virtual void fillRectangle(const Rectangle& rectangle);
|
||||
|
||||
virtual void setColor(const Color& color);
|
||||
|
||||
virtual const Color& getColor() const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Draws a horizontal line.
|
||||
*
|
||||
* @param x1 the start coordinate of the line.
|
||||
* @param y the y coordinate of the line.
|
||||
* @param x2 the end coordinate of the line.
|
||||
*/
|
||||
virtual void drawHLine(int x1, int y, int x2);
|
||||
|
||||
/**
|
||||
* Draws a vertical line.
|
||||
*
|
||||
* @param x the x coordinate of the line.
|
||||
* @param y1 the start coordinate of the line.
|
||||
* @param y2 the end coordinate of the line.
|
||||
*/
|
||||
virtual void drawVLine(int x, int y1, int y2);
|
||||
|
||||
SDL_Surface* mTarget;
|
||||
Color mColor;
|
||||
bool mAlpha;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_SDLGRAPHICS_HPP
|
||||
107
project/jni/guichan/include/guichan/sdl/sdlimage.hpp
Normal file
107
project/jni/guichan/include/guichan/sdl/sdlimage.hpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SDLIMAGE_HPP
|
||||
#define GCN_SDLIMAGE_HPP
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/color.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/image.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* SDL implementation of Image.
|
||||
*/
|
||||
class GCN_EXTENSION_DECLSPEC SDLImage : public Image
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor. Load an image from an SDL surface.
|
||||
*
|
||||
* NOTE: The functions getPixel and putPixel are only guaranteed to work
|
||||
* before an image has been converted to display format.
|
||||
*
|
||||
* @param surface the surface from which to load.
|
||||
* @param autoFree true if the surface should automatically be deleted.
|
||||
*/
|
||||
SDLImage(SDL_Surface* surface, bool autoFree);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~SDLImage();
|
||||
|
||||
/**
|
||||
* Gets the SDL surface for the image.
|
||||
*
|
||||
* @return the SDL surface for the image.
|
||||
*/
|
||||
virtual SDL_Surface* getSurface() const;
|
||||
|
||||
|
||||
// Inherited from Image
|
||||
|
||||
virtual void free();
|
||||
|
||||
virtual int getWidth() const;
|
||||
|
||||
virtual int getHeight() const;
|
||||
|
||||
virtual Color getPixel(int x, int y);
|
||||
|
||||
virtual void putPixel(int x, int y, const Color& color);
|
||||
|
||||
virtual void convertToDisplayFormat();
|
||||
|
||||
protected:
|
||||
SDL_Surface* mSurface;
|
||||
bool mAutoFree;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_SDLIMAGE_HPP
|
||||
73
project/jni/guichan/include/guichan/sdl/sdlimageloader.hpp
Normal file
73
project/jni/guichan/include/guichan/sdl/sdlimageloader.hpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SDLIMAGELOADER_HPP
|
||||
#define GCN_SDLIMAGELOADER_HPP
|
||||
|
||||
#include "guichan/imageloader.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Image;
|
||||
|
||||
/**
|
||||
* SDL implementation of ImageLoader.
|
||||
*/
|
||||
class GCN_EXTENSION_DECLSPEC SDLImageLoader : public ImageLoader
|
||||
{
|
||||
public:
|
||||
|
||||
// Inherited from ImageLoader
|
||||
|
||||
virtual Image* load(const std::string& filename, bool convertToDisplayFormat = true);
|
||||
|
||||
protected:
|
||||
virtual SDL_Surface* loadSDLSurface(const std::string& filename);
|
||||
virtual SDL_Surface* convertToStandardFormat(SDL_Surface* surface);
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_SDLIMAGELOADER_HPP
|
||||
125
project/jni/guichan/include/guichan/sdl/sdlinput.hpp
Normal file
125
project/jni/guichan/include/guichan/sdl/sdlinput.hpp
Normal file
@@ -0,0 +1,125 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SDLINPUT_HPP
|
||||
#define GCN_SDLINPUT_HPP
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "guichan/input.hpp"
|
||||
#include "guichan/keyinput.hpp"
|
||||
#include "guichan/mouseinput.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Key;
|
||||
|
||||
/**
|
||||
* SDL implementation of Input.
|
||||
*/
|
||||
class GCN_EXTENSION_DECLSPEC SDLInput : public Input
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
SDLInput();
|
||||
|
||||
/**
|
||||
* Pushes an SDL event. It should be called at least once per frame to
|
||||
* update input with user input.
|
||||
*
|
||||
* @param event an event from SDL.
|
||||
*/
|
||||
virtual void pushInput(SDL_Event event);
|
||||
|
||||
/**
|
||||
* Polls all input. It exists for input driver compatibility. If you
|
||||
* only use SDL and plan sticking with SDL you can safely ignore this
|
||||
* function as it in the SDL case does nothing.
|
||||
*/
|
||||
virtual void _pollInput() { }
|
||||
|
||||
|
||||
// Inherited from Input
|
||||
|
||||
virtual bool isKeyQueueEmpty();
|
||||
|
||||
virtual KeyInput dequeueKeyInput();
|
||||
|
||||
virtual bool isMouseQueueEmpty();
|
||||
|
||||
virtual MouseInput dequeueMouseInput();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Converts a mouse button from SDL to a Guichan mouse button
|
||||
* representation.
|
||||
*
|
||||
* @param button an SDL mouse button.
|
||||
* @return a Guichan mouse button.
|
||||
*/
|
||||
int convertMouseButton(int button);
|
||||
|
||||
/**
|
||||
* Converts an SDL event to a Guichan key value.
|
||||
*
|
||||
* @param keysym The SDL event to convert.
|
||||
* @return A Guichan key value. -1 if no conversion took place.
|
||||
* @see Key
|
||||
*/
|
||||
int convertSDLEventToGuichanKeyValue(SDL_Event event);
|
||||
|
||||
std::queue<KeyInput> mKeyInputQueue;
|
||||
std::queue<MouseInput> mMouseInputQueue;
|
||||
|
||||
bool mMouseDown;
|
||||
bool mMouseInWindow;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_SDLINPUT_HPP
|
||||
260
project/jni/guichan/include/guichan/sdl/sdlpixel.hpp
Normal file
260
project/jni/guichan/include/guichan/sdl/sdlpixel.hpp
Normal file
@@ -0,0 +1,260 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SDLPIXEL_HPP
|
||||
#define GCN_SDLPIXEL_HPP
|
||||
|
||||
#include "SDL.h"
|
||||
#include "guichan/color.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
|
||||
/**
|
||||
* Checks a pixels color of an SDL_Surface.
|
||||
*
|
||||
* @param surface an SDL_Surface where to check for a pixel color.
|
||||
* @param x the x coordinate on the surface.
|
||||
* @param y the y coordinate on the surface.
|
||||
* @return a color of a pixel.
|
||||
*/
|
||||
inline const Color SDLgetPixel(SDL_Surface* surface, int x, int y)
|
||||
{
|
||||
int bpp = surface->format->BytesPerPixel;
|
||||
|
||||
SDL_LockSurface(surface);
|
||||
|
||||
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||
|
||||
unsigned int color = 0;
|
||||
|
||||
switch(bpp)
|
||||
{
|
||||
case 1:
|
||||
color = *p;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
color = *(Uint16 *)p;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
{
|
||||
color = p[0] << 16 | p[1] << 8 | p[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
color = p[0] | p[1] << 8 | p[2] << 16;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
color = *(Uint32 *)p;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
unsigned char r,g,b,a;
|
||||
|
||||
SDL_GetRGBA(color, surface->format, &r, &g, &b, &a);
|
||||
SDL_UnlockSurface(surface);
|
||||
|
||||
return Color(r,g,b,a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a pixel on an SDL_Surface.
|
||||
*
|
||||
* @param x the x coordinate on the surface.
|
||||
* @param y the y coordinate on the surface.
|
||||
* @param color the color the pixel should be in.
|
||||
*/
|
||||
inline void SDLputPixel(SDL_Surface* surface, int x, int y, const Color& color)
|
||||
{
|
||||
int bpp = surface->format->BytesPerPixel;
|
||||
|
||||
SDL_LockSurface(surface);
|
||||
|
||||
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||
|
||||
Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b);
|
||||
|
||||
switch(bpp)
|
||||
{
|
||||
case 1:
|
||||
*p = pixel;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*(Uint16 *)p = pixel;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
{
|
||||
p[0] = (pixel >> 16) & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = pixel & 0xff;
|
||||
}
|
||||
else
|
||||
{
|
||||
p[0] = pixel & 0xff;
|
||||
p[1] = (pixel >> 8) & 0xff;
|
||||
p[2] = (pixel >> 16) & 0xff;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*(Uint32 *)p = pixel;
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blends two 32 bit colors together.
|
||||
*
|
||||
* @param src the source color.
|
||||
* @param dst the destination color.
|
||||
* @param a alpha.
|
||||
*/
|
||||
inline unsigned int SDLAlpha32(unsigned int src, unsigned int dst, unsigned char a)
|
||||
{
|
||||
unsigned int b = ((src & 0xff) * a + (dst & 0xff) * (255 - a)) >> 8;
|
||||
unsigned int g = ((src & 0xff00) * a + (dst & 0xff00) * (255 - a)) >> 8;
|
||||
unsigned int r = ((src & 0xff0000) * a + (dst & 0xff0000) * (255 - a)) >> 8;
|
||||
|
||||
return (b & 0xff) | (g & 0xff00) | (r & 0xff0000);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blends two 16 bit colors together.
|
||||
*
|
||||
* @param src the source color.
|
||||
* @param dst the destination color.
|
||||
* @param a alpha.
|
||||
*/
|
||||
inline unsigned short SDLAlpha16(unsigned short src, unsigned short dst, unsigned char a, const SDL_PixelFormat *f)
|
||||
{
|
||||
unsigned int b = ((src & f->Rmask) * a + (dst & f->Rmask) * (255 - a)) >> 8;
|
||||
unsigned int g = ((src & f->Gmask) * a + (dst & f->Gmask) * (255 - a)) >> 8;
|
||||
unsigned int r = ((src & f->Bmask) * a + (dst & f->Bmask) * (255 - a)) >> 8;
|
||||
|
||||
return (unsigned short)((b & f->Rmask) | (g & f->Gmask) | (r & f->Bmask));
|
||||
}
|
||||
|
||||
/*
|
||||
typedef struct{
|
||||
SDL_Palette *palette;
|
||||
Uint8 BitsPerPixel;
|
||||
Uint8 BytesPerPixel;
|
||||
Uint32 Rmask, Gmask, Bmask, Amask;
|
||||
Uint8 Rshift, Gshift, Bshift, Ashift;
|
||||
Uint8 Rloss, Gloss, Bloss, Aloss;
|
||||
Uint32 colorkey;
|
||||
Uint8 alpha;
|
||||
} SDL_PixelFormat;
|
||||
*/
|
||||
|
||||
/**
|
||||
* Puts a pixel on an SDL_Surface with alpha
|
||||
*
|
||||
* @param x the x coordinate on the surface.
|
||||
* @param y the y coordinate on the surface.
|
||||
* @param color the color the pixel should be in.
|
||||
*/
|
||||
inline void SDLputPixelAlpha(SDL_Surface* surface, int x, int y, const Color& color)
|
||||
{
|
||||
int bpp = surface->format->BytesPerPixel;
|
||||
|
||||
SDL_LockSurface(surface);
|
||||
|
||||
Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp;
|
||||
|
||||
Uint32 pixel = SDL_MapRGB(surface->format, color.r, color.g, color.b);
|
||||
|
||||
switch(bpp)
|
||||
{
|
||||
case 1:
|
||||
*p = pixel;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
*(Uint16 *)p = SDLAlpha16(pixel, *(Uint32 *)p, color.a, surface->format);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
|
||||
{
|
||||
unsigned int r = (p[0] * (255 - color.a) + color.r * color.a) >> 8;
|
||||
unsigned int g = (p[1] * (255 - color.a) + color.g * color.a) >> 8;
|
||||
unsigned int b = (p[2] * (255 - color.a) + color.b * color.a) >> 8;
|
||||
|
||||
p[2] = b;
|
||||
p[1] = g;
|
||||
p[0] = r;
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int r = (p[2] * (255 - color.a) + color.r * color.a) >> 8;
|
||||
unsigned int g = (p[1] * (255 - color.a) + color.g * color.a) >> 8;
|
||||
unsigned int b = (p[0] * (255 - color.a) + color.b * color.a) >> 8;
|
||||
|
||||
p[0] = b;
|
||||
p[1] = g;
|
||||
p[2] = r;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
*(Uint32 *)p = SDLAlpha32(pixel, *(Uint32 *)p, color.a);
|
||||
break;
|
||||
}
|
||||
|
||||
SDL_UnlockSurface(surface);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // end GCN_SDLPIXEL_HPP
|
||||
78
project/jni/guichan/include/guichan/selectionevent.hpp
Normal file
78
project/jni/guichan/include/guichan/selectionevent.hpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SELECTIONEVENT_HPP
|
||||
#define GCN_SELECTIONEVENT_HPP
|
||||
|
||||
#include "guichan/event.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Widget;
|
||||
|
||||
/**
|
||||
* Represents a selection event.
|
||||
*
|
||||
* @author Olof Naessén
|
||||
* @since 0.8.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC SelectionEvent: public Event
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param source source The widget of the selection event.
|
||||
*/
|
||||
SelectionEvent(Widget* source);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~SelectionEvent();
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_SELECTIONEVENT_HPP
|
||||
95
project/jni/guichan/include/guichan/selectionlistener.hpp
Normal file
95
project/jni/guichan/include/guichan/selectionlistener.hpp
Normal file
@@ -0,0 +1,95 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SELECTIONLISTENER_HPP
|
||||
#define GCN_SELECTIONLISTENER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/selectionevent.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Interface for listening for selection events from widgets.
|
||||
*
|
||||
* @see ListBox::addSelectionListener,
|
||||
* ListBox::removeSelectionListener,
|
||||
* DropDown::addSelectionListener,
|
||||
* DropDown::removeSelectionListener
|
||||
* @author Olof Naessén
|
||||
* @since 0.8.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC SelectionListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~SelectionListener() { }
|
||||
|
||||
/**
|
||||
* Called when the value of a selection has been changed in a Widget.
|
||||
* It is used to be able to recieve a notification that a value has
|
||||
* been changed.
|
||||
*
|
||||
* @param event The event of the value change.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void valueChanged(const SelectionEvent& event) { };
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* You should not be able to make an instance of SelectionListener,
|
||||
* therefore its constructor is protected.
|
||||
*/
|
||||
SelectionListener() { }
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_SELECTIONLISTENER_HPP
|
||||
1194
project/jni/guichan/include/guichan/widget.hpp
Normal file
1194
project/jni/guichan/include/guichan/widget.hpp
Normal file
File diff suppressed because it is too large
Load Diff
118
project/jni/guichan/include/guichan/widgetlistener.hpp
Normal file
118
project/jni/guichan/include/guichan/widgetlistener.hpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_WIDGETLISTENER_HPP
|
||||
#define GCN_WIDGETLISTENER_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/event.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Interface for listening for events from widgets. When a widget's size,
|
||||
* location or visibility changes, the relevant method of the listener is
|
||||
* invoked.
|
||||
*
|
||||
* @see Widget::addWidgetListener, Widget::removeWidgetListener
|
||||
* @author Olof Naessén
|
||||
* @since 0.8.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC WidgetListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~WidgetListener() { }
|
||||
|
||||
/**
|
||||
* Invoked when a widget changes its size.
|
||||
*
|
||||
* @param event Describes the event.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void widgetResized(const Event& event) { }
|
||||
|
||||
/**
|
||||
* Invoked when a widget is moved.
|
||||
*
|
||||
* @param event Describes the event.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void widgetMoved(const Event& event) { }
|
||||
|
||||
/**
|
||||
* Invoked when a widget is hidden, i.e it's set to be
|
||||
* not visible.
|
||||
*
|
||||
* @param event Describes the event.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void widgetHidden(const Event& event) { }
|
||||
|
||||
/**
|
||||
* Invoked when a widget is shown, i.e it's set to be
|
||||
* visible.
|
||||
*
|
||||
* @param event Describes the event.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual void widgetShown(const Event& event) { }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* You should not be able to make an instance of WidgetListener,
|
||||
* therefore its constructor is protected.
|
||||
*/
|
||||
WidgetListener() { }
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_WIDGETLISTENER_HPP
|
||||
214
project/jni/guichan/include/guichan/widgets/button.hpp
Normal file
214
project/jni/guichan/include/guichan/widgets/button.hpp
Normal file
@@ -0,0 +1,214 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_BUTTON_HPP
|
||||
#define GCN_BUTTON_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/focuslistener.hpp"
|
||||
#include "guichan/graphics.hpp"
|
||||
#include "guichan/keylistener.hpp"
|
||||
#include "guichan/mouseevent.hpp"
|
||||
#include "guichan/mouselistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widget.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* An implementation of a regular clickable button. A button is capable of
|
||||
* displaying a caption.
|
||||
*
|
||||
* If a button is clicked an action event will be sent to all action listener's
|
||||
* of the button.
|
||||
*
|
||||
* @see ImageButton
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Button : public Widget,
|
||||
public MouseListener,
|
||||
public KeyListener,
|
||||
public FocusListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Button();
|
||||
|
||||
/**
|
||||
* Constructor. The button will be automatically resized
|
||||
* to fit the caption.
|
||||
*
|
||||
* @param caption The caption of the button.
|
||||
*/
|
||||
Button(const std::string& caption);
|
||||
|
||||
/**
|
||||
* Sets the caption of the button. It's advisable to call
|
||||
* adjustSize after setting of the caption to adjust the
|
||||
* button's size to fit the caption.
|
||||
*
|
||||
* @param caption The caption of the button.
|
||||
* @see getCaption, adjustSize
|
||||
*/
|
||||
void setCaption(const std::string& caption);
|
||||
|
||||
/**
|
||||
* Gets the caption of the button.
|
||||
*
|
||||
* @return The caption of the button.
|
||||
*/
|
||||
const std::string& getCaption() const;
|
||||
|
||||
/**
|
||||
* Sets the alignment of the caption. The alignment is relative
|
||||
* to the center of the button.
|
||||
*
|
||||
* @param alignment The alignment of the caption.
|
||||
* @see getAlignment, Graphics
|
||||
*/
|
||||
void setAlignment(Graphics::Alignment alignment);
|
||||
|
||||
/**
|
||||
* Gets the alignment of the caption.
|
||||
*
|
||||
* @return The alignment of the caption.
|
||||
* @see setAlignment, Graphics
|
||||
*/
|
||||
Graphics::Alignment getAlignment() const;
|
||||
|
||||
/**
|
||||
* Sets the spacing between the border of the button and its caption.
|
||||
*
|
||||
* @param spacing The default value for spacing is 4 and can be changed
|
||||
* using this method.
|
||||
* @see getSpacing
|
||||
*/
|
||||
void setSpacing(unsigned int spacing);
|
||||
|
||||
/**
|
||||
* Gets the spacing between the border of the button and its caption.
|
||||
*
|
||||
* @return spacing.
|
||||
* @see setSpacing
|
||||
*/
|
||||
unsigned int getSpacing() const;
|
||||
|
||||
/**
|
||||
* Adjusts the button's size to fit the caption.
|
||||
*/
|
||||
void adjustSize();
|
||||
|
||||
|
||||
//Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
|
||||
// Inherited from FocusListener
|
||||
|
||||
virtual void focusLost(const Event& event);
|
||||
|
||||
|
||||
// Inherited from MouseListener
|
||||
|
||||
virtual void mousePressed(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseReleased(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseEntered(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseExited(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseDragged(MouseEvent& mouseEvent);
|
||||
|
||||
|
||||
// Inherited from KeyListener
|
||||
|
||||
virtual void keyPressed(KeyEvent& keyEvent);
|
||||
|
||||
virtual void keyReleased(KeyEvent& keyEvent);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Checks if the button is pressed. Convenient method to use
|
||||
* when overloading the draw method of the button.
|
||||
*
|
||||
* @return True if the button is pressed, false otherwise.
|
||||
*/
|
||||
bool isPressed() const;
|
||||
|
||||
/**
|
||||
* Holds the caption of the button.
|
||||
*/
|
||||
std::string mCaption;
|
||||
|
||||
/**
|
||||
* True if the mouse is ontop of the button, false otherwise.
|
||||
*/
|
||||
bool mHasMouse;
|
||||
|
||||
/**
|
||||
* True if a key has been pressed, false otherwise.
|
||||
*/
|
||||
bool mKeyPressed;
|
||||
|
||||
/**
|
||||
* True if a mouse has been pressed, false otherwise.
|
||||
*/
|
||||
bool mMousePressed;
|
||||
|
||||
/**
|
||||
* Holds the alignment of the caption.
|
||||
*/
|
||||
Graphics::Alignment mAlignment;
|
||||
|
||||
/**
|
||||
* Holds the spacing between the border and the caption.
|
||||
*/
|
||||
unsigned int mSpacing;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_BUTTON_HPP
|
||||
173
project/jni/guichan/include/guichan/widgets/checkbox.hpp
Normal file
173
project/jni/guichan/include/guichan/widgets/checkbox.hpp
Normal file
@@ -0,0 +1,173 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_CHECKBOX_HPP
|
||||
#define GCN_CHECKBOX_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/keylistener.hpp"
|
||||
#include "guichan/mouselistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widget.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* An implementation of a check box where a user can select or deselect
|
||||
* the check box and where the status of the check box is displayed to the user.
|
||||
* A check box is capable of displaying a caption.
|
||||
*
|
||||
* If a check box's state changes an action event will be sent to all action
|
||||
* listeners of the check box.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC CheckBox :
|
||||
public Widget,
|
||||
public MouseListener,
|
||||
public KeyListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Contructor.
|
||||
*/
|
||||
CheckBox();
|
||||
|
||||
/**
|
||||
* Constructor. The check box will be automatically resized
|
||||
* to fit the caption.
|
||||
*
|
||||
* @param caption The caption of the check box.
|
||||
* @param marked True if the check box is selected, false otherwise.
|
||||
*/
|
||||
CheckBox(const std::string &caption, bool selected = false);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~CheckBox() { }
|
||||
|
||||
/**
|
||||
* Checks if the check box is selected.
|
||||
*
|
||||
* @return True if the check box is selected, false otherwise.
|
||||
* @see setSelected
|
||||
*/
|
||||
bool isSelected() const;
|
||||
|
||||
/**
|
||||
* Sets the check box to be selected or not.
|
||||
*
|
||||
* @param selected True if the check box should be set as selected.
|
||||
* @see isSelected
|
||||
*/
|
||||
void setSelected(bool selected);
|
||||
|
||||
/**
|
||||
* Gets the caption of the check box.
|
||||
*
|
||||
* @return The caption of the check box.
|
||||
* @see setCaption
|
||||
*/
|
||||
const std::string &getCaption() const;
|
||||
|
||||
/**
|
||||
* Sets the caption of the check box. It's advisable to call
|
||||
* adjustSize after setting of the caption to adjust the
|
||||
* check box's size to fit the caption.
|
||||
*
|
||||
* @param caption The caption of the check box.
|
||||
* @see getCaption, adjustSize
|
||||
*/
|
||||
void setCaption(const std::string& caption);
|
||||
|
||||
/**
|
||||
* Adjusts the check box's size to fit the caption.
|
||||
*/
|
||||
void adjustSize();
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
|
||||
// Inherited from KeyListener
|
||||
|
||||
virtual void keyPressed(KeyEvent& keyEvent);
|
||||
|
||||
|
||||
// Inherited from MouseListener
|
||||
|
||||
virtual void mouseClicked(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseDragged(MouseEvent& mouseEvent);
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Draws the box of the check box.
|
||||
*
|
||||
* @param graphics A Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawBox(Graphics *graphics);
|
||||
|
||||
/**
|
||||
* Toggles the check box between being selected and
|
||||
* not being selected.
|
||||
*/
|
||||
virtual void toggleSelected();
|
||||
|
||||
/**
|
||||
* True if the check box is selected, false otherwise.
|
||||
*/
|
||||
bool mSelected;
|
||||
|
||||
/**
|
||||
* Holds the caption of the check box.
|
||||
*/
|
||||
std::string mCaption;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_CHECKBOX_HPP
|
||||
162
project/jni/guichan/include/guichan/widgets/container.hpp
Normal file
162
project/jni/guichan/include/guichan/widgets/container.hpp
Normal file
@@ -0,0 +1,162 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_CONTAINER_HPP
|
||||
#define GCN_CONTAINER_HPP
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "guichan/basiccontainer.hpp"
|
||||
#include "guichan/graphics.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* An implementation of a container able to contain other widgets. A widget's
|
||||
* position in the container is relative to the container itself and not the screen.
|
||||
* A container is the most common widget to use as the Gui's top widget as makes the Gui
|
||||
* able to contain more than one widget.
|
||||
*
|
||||
* @see Gui::setTop
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Container: public BasicContainer
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor. A container is opauqe as default, if you want a
|
||||
* none opaque container call setQpaque(false).
|
||||
*
|
||||
* @see setOpaque, isOpaque
|
||||
*/
|
||||
Container();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Container();
|
||||
|
||||
/**
|
||||
* Sets the container to be opaque or not. If the container
|
||||
* is opaque its background will be drawn, if it's not opaque
|
||||
* its background will not be drawn, and thus making the container
|
||||
* completely transparent.
|
||||
*
|
||||
* NOTE: This is not the same as to set visibility. A non visible
|
||||
* container will not itself nor will it draw its content.
|
||||
*
|
||||
* @param opaque True if the container should be opaque, false otherwise.
|
||||
* @see isOpaque
|
||||
*/
|
||||
void setOpaque(bool opaque);
|
||||
|
||||
/**
|
||||
* Checks if the container is opaque or not.
|
||||
*
|
||||
* @return True if the container is opaque, false otherwise.
|
||||
* @see setOpaque
|
||||
*/
|
||||
bool isOpaque() const;
|
||||
|
||||
/**
|
||||
* Adds a widget to the container.
|
||||
*
|
||||
* @param widget The widget to add.
|
||||
* @see remove, clear
|
||||
*/
|
||||
virtual void add(Widget* widget);
|
||||
|
||||
/**
|
||||
* Adds a widget to the container and also specifies the widget's
|
||||
* position in the container. The position is relative to the container
|
||||
* and not relative to the screen.
|
||||
*
|
||||
* @param widget The widget to add.
|
||||
* @param x The x coordinate for the widget.
|
||||
* @param y The y coordinate for the widget.
|
||||
* @see remove, clear
|
||||
*/
|
||||
virtual void add(Widget* widget, int x, int y);
|
||||
|
||||
/**
|
||||
* Removes a widget from the Container.
|
||||
*
|
||||
* @param widget The widget to remove.
|
||||
* @throws Exception when the widget has not been added to the
|
||||
* container.
|
||||
* @see add, clear
|
||||
*/
|
||||
virtual void remove(Widget* widget);
|
||||
|
||||
/**
|
||||
* Clears the container of all widgets.
|
||||
*
|
||||
* @see add, remove
|
||||
*/
|
||||
virtual void clear();
|
||||
|
||||
/**
|
||||
* Finds a widget given an id.
|
||||
*
|
||||
* @param id The id to find a widget by.
|
||||
* @return A widget with a corrosponding id, NULL if no widget
|
||||
* is found.
|
||||
* @see Widget::setId
|
||||
*/
|
||||
virtual Widget* findWidgetById(const std::string &id);
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* True if the container is opaque, false otherwise.
|
||||
*/
|
||||
bool mOpaque;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_CONTAINER_HPP
|
||||
318
project/jni/guichan/include/guichan/widgets/dropdown.hpp
Normal file
318
project/jni/guichan/include/guichan/widgets/dropdown.hpp
Normal file
@@ -0,0 +1,318 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_DROPDOWN_HPP
|
||||
#define GCN_DROPDOWN_HPP
|
||||
|
||||
#include "guichan/actionlistener.hpp"
|
||||
#include "guichan/basiccontainer.hpp"
|
||||
#include "guichan/deathlistener.hpp"
|
||||
#include "guichan/focushandler.hpp"
|
||||
#include "guichan/focuslistener.hpp"
|
||||
#include "guichan/keylistener.hpp"
|
||||
#include "guichan/listmodel.hpp"
|
||||
#include "guichan/mouselistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/selectionlistener.hpp"
|
||||
#include "guichan/widgets/listbox.hpp"
|
||||
#include "guichan/widgets/scrollarea.hpp"
|
||||
|
||||
namespace gcn {
|
||||
/**
|
||||
* An implementation of a drop downable list from which an item can be
|
||||
* selected. The drop down consists of an internal ScrollArea and an
|
||||
* internal ListBox. The drop down also uses an internal FocusHandler to
|
||||
* handle the focus of the internal ScollArea and the internal ListBox. The
|
||||
* scroll area and the list box can be passed to the drop down if a custom
|
||||
* scroll area and or a custom list box is preferable.
|
||||
*
|
||||
* To be able display a list the drop down uses a user provided list model.
|
||||
* A list model can be any class that implements the ListModel interface.
|
||||
*
|
||||
* If an item is selected in the drop down a select event will be sent to
|
||||
* all selection listeners of the drop down. If an item is selected by
|
||||
* using a mouse click or by using the enter or space key an action event
|
||||
* will be sent to all action listeners of the drop down.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC DropDown :
|
||||
public ActionListener,
|
||||
public BasicContainer,
|
||||
public KeyListener,
|
||||
public MouseListener,
|
||||
public FocusListener,
|
||||
public SelectionListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Contructor.
|
||||
*
|
||||
* @param listModel the ListModel to use.
|
||||
* @param scrollArea the ScrollArea to use.
|
||||
* @param listBox the listBox to use.
|
||||
* @see ListModel, ScrollArea, ListBox.
|
||||
*/
|
||||
DropDown(ListModel *listModel = NULL,
|
||||
ScrollArea *scrollArea = NULL,
|
||||
ListBox *listBox = NULL);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~DropDown();
|
||||
|
||||
/**
|
||||
* Gets the selected item as an index in the list model.
|
||||
*
|
||||
* @return the selected item as an index in the list model.
|
||||
* @see setSelected
|
||||
*/
|
||||
int getSelected() const;
|
||||
|
||||
/**
|
||||
* Sets the selected item. The selected item is represented by
|
||||
* an index from the list model.
|
||||
*
|
||||
* @param selected the selected item as an index from the list model.
|
||||
* @see getSelected
|
||||
*/
|
||||
void setSelected(int selected);
|
||||
|
||||
/**
|
||||
* Sets the list model to use when displaying the list.
|
||||
*
|
||||
* @param listModel the list model to use.
|
||||
* @see getListModel
|
||||
*/
|
||||
void setListModel(ListModel *listModel);
|
||||
|
||||
/**
|
||||
* Gets the list model used.
|
||||
*
|
||||
* @return the ListModel used.
|
||||
* @see setListModel
|
||||
*/
|
||||
ListModel *getListModel();
|
||||
|
||||
/**
|
||||
* Adjusts the height of the drop down to fit the height of the
|
||||
* drop down's parent's height. It's used to not make the drop down
|
||||
* draw itself outside of it's parent if folded down.
|
||||
*/
|
||||
void adjustHeight();
|
||||
|
||||
/**
|
||||
* Adds a selection listener to the drop down. When the selection
|
||||
* changes an event will be sent to all selection listeners of the
|
||||
* drop down.
|
||||
*
|
||||
* If you delete your selection listener, be sure to also remove it
|
||||
* using removeSelectionListener().
|
||||
*
|
||||
* @param selectionListener the selection listener to add.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
void addSelectionListener(SelectionListener* selectionListener);
|
||||
|
||||
/**
|
||||
* Removes a selection listener from the drop down.
|
||||
*
|
||||
* @param selectionListener the selection listener to remove.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
void removeSelectionListener(SelectionListener* selectionListener);
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
void setBaseColor(const Color& color);
|
||||
|
||||
void setBackgroundColor(const Color& color);
|
||||
|
||||
void setForegroundColor(const Color& color);
|
||||
|
||||
void setFont(Font *font);
|
||||
|
||||
void setSelectionColor(const Color& color);
|
||||
|
||||
|
||||
// Inherited from BasicContainer
|
||||
|
||||
virtual Rectangle getChildrenArea();
|
||||
|
||||
|
||||
// Inherited from FocusListener
|
||||
|
||||
virtual void focusLost(const Event& event);
|
||||
|
||||
|
||||
// Inherited from ActionListener
|
||||
|
||||
virtual void action(const ActionEvent& actionEvent);
|
||||
|
||||
|
||||
// Inherited from DeathListener
|
||||
|
||||
virtual void death(const Event& event);
|
||||
|
||||
|
||||
// Inherited from KeyListener
|
||||
|
||||
virtual void keyPressed(KeyEvent& keyEvent);
|
||||
|
||||
|
||||
// Inherited from MouseListener
|
||||
|
||||
virtual void mousePressed(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseReleased(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseDragged(MouseEvent& mouseEvent);
|
||||
|
||||
|
||||
// Inherited from SelectionListener
|
||||
|
||||
virtual void valueChanged(const SelectionEvent& event);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Draws the button of the drop down.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawButton(Graphics *graphics);
|
||||
|
||||
/**
|
||||
* Sets the drop down to be dropped down.
|
||||
*/
|
||||
virtual void dropDown();
|
||||
|
||||
/**
|
||||
* Sets the drop down to be folded up.
|
||||
*/
|
||||
virtual void foldUp();
|
||||
|
||||
/**
|
||||
* Distributes a value changed event to all selection listeners
|
||||
* of the drop down.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
void distributeValueChangedEvent();
|
||||
|
||||
/**
|
||||
* True if the drop down is dropped down, false otherwise.
|
||||
*/
|
||||
bool mDroppedDown;
|
||||
|
||||
/**
|
||||
* True if the drop down has been pushed with the mouse, false
|
||||
* otherwise.
|
||||
*/
|
||||
bool mPushed;
|
||||
|
||||
/**
|
||||
* Holds what the height is if the drop down is folded up. Used when
|
||||
* checking if the list of the drop down was clicked or if the upper
|
||||
* part of the drop down was clicked on a mouse click.
|
||||
*/
|
||||
int mFoldedUpHeight;
|
||||
|
||||
/**
|
||||
* The scroll area used.
|
||||
*/
|
||||
ScrollArea* mScrollArea;
|
||||
|
||||
/**
|
||||
* The list box used.
|
||||
*/
|
||||
ListBox* mListBox;
|
||||
|
||||
/**
|
||||
* The internal focus handler used to keep track of focus for the
|
||||
* internal list box.
|
||||
*/
|
||||
FocusHandler mInternalFocusHandler;
|
||||
|
||||
/**
|
||||
* True if an internal scroll area is used, false if a scroll area
|
||||
* has been passed to the drop down which the drop down should not
|
||||
* deleted in it's destructor.
|
||||
*/
|
||||
bool mInternalScrollArea;
|
||||
|
||||
/**
|
||||
* True if an internal list box is used, false if a list box
|
||||
* has been passed to the drop down which the drop down should not
|
||||
* deleted in it's destructor.
|
||||
*/
|
||||
bool mInternalListBox;
|
||||
|
||||
/**
|
||||
* True if the drop down is dragged.
|
||||
*/
|
||||
bool mIsDragged;
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef std::list<SelectionListener*> SelectionListenerList;
|
||||
|
||||
/**
|
||||
* The selection listener's of the drop down.
|
||||
*/
|
||||
SelectionListenerList mSelectionListeners;
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef SelectionListenerList::iterator SelectionListenerIterator;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_DROPDOWN_HPP
|
||||
118
project/jni/guichan/include/guichan/widgets/icon.hpp
Normal file
118
project/jni/guichan/include/guichan/widgets/icon.hpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_ICON_HPP
|
||||
#define GCN_ICON_HPP
|
||||
|
||||
#include "guichan/image.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widget.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Implements an icon capable of displaying an image.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Icon: public Widget
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
Icon();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param filename The filename of the image to display.
|
||||
*/
|
||||
Icon(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param image The image to display.
|
||||
*/
|
||||
Icon(const Image* image);
|
||||
|
||||
/**
|
||||
* Descructor.
|
||||
*/
|
||||
virtual ~Icon();
|
||||
|
||||
/**
|
||||
* Sets the image to display. Existing image is freed automatically
|
||||
* if it was loaded internally.
|
||||
*
|
||||
* @param image The image to display.
|
||||
*/
|
||||
void setImage(const Image* image);
|
||||
|
||||
/**
|
||||
* Gets the current image.
|
||||
*
|
||||
* @return The current image.
|
||||
*/
|
||||
const Image* getImage() const;
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The image to display.
|
||||
*/
|
||||
const Image* mImage;
|
||||
|
||||
/**
|
||||
* True if the image has been loaded internally, false otherwise.
|
||||
* An image not loaded internally should not be deleted in the
|
||||
* destructor.
|
||||
*/
|
||||
bool mInternalImage;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_ICON_HPP
|
||||
123
project/jni/guichan/include/guichan/widgets/imagebutton.hpp
Normal file
123
project/jni/guichan/include/guichan/widgets/imagebutton.hpp
Normal file
@@ -0,0 +1,123 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_IMAGEBUTTON_HPP
|
||||
#define GCN_IMAGEBUTTON_HPP
|
||||
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widgets/button.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Image;
|
||||
|
||||
/**
|
||||
* An implementation of a regular clickable button. Unlike a normal button an image
|
||||
* button is capable of displaying an image instead of a simple text caption.
|
||||
* Whenever an image button is clicked an action event will be sent to the action
|
||||
* listener's of the image button.
|
||||
*
|
||||
* @see Button
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ImageButton : public gcn::Button
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Default constructor.
|
||||
*/
|
||||
ImageButton();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param filename The filename of the image to display.
|
||||
*/
|
||||
ImageButton(const std::string& filename);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param image The image to display.
|
||||
*/
|
||||
ImageButton(const Image* image);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ImageButton();
|
||||
|
||||
/**
|
||||
* Sets the image to display. Existing Image is freed automatically,
|
||||
* if it was loaded internally.
|
||||
*
|
||||
* @param image The image to display.
|
||||
*/
|
||||
void setImage(const Image* image);
|
||||
|
||||
/**
|
||||
* Gets current image.
|
||||
*
|
||||
* @return The current image.
|
||||
*/
|
||||
const Image* getImage() const;
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
void draw(gcn::Graphics* graphics);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* The image to display.
|
||||
*/
|
||||
const Image* mImage;
|
||||
|
||||
/**
|
||||
* True if the image has been loaded internally, false otherwise.
|
||||
* An image not loaded internally should not be deleted in the
|
||||
* destructor.
|
||||
*/
|
||||
bool mInternalImage;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
133
project/jni/guichan/include/guichan/widgets/label.hpp
Normal file
133
project/jni/guichan/include/guichan/widgets/label.hpp
Normal file
@@ -0,0 +1,133 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_LABEL_HPP
|
||||
#define GCN_LABEL_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/graphics.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widget.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Implementation of a label capable of displaying a caption.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Label: public Widget
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Label();
|
||||
|
||||
/**
|
||||
* Constructor. The label will be automatically resized
|
||||
* to fit the caption.
|
||||
*
|
||||
* @param caption The caption of the label.
|
||||
*/
|
||||
Label(const std::string& caption);
|
||||
|
||||
/**
|
||||
* Gets the caption of the label.
|
||||
*
|
||||
* @return The caption of the label.
|
||||
* @see setCaption
|
||||
*/
|
||||
const std::string &getCaption() const;
|
||||
|
||||
/**
|
||||
* Sets the caption of the label. It's advisable to call
|
||||
* adjustSize after setting of the caption to adjust the
|
||||
* label's size to fit the caption.
|
||||
*
|
||||
* @param caption The caption of the label.
|
||||
* @see getCaption, adjustSize
|
||||
*/
|
||||
void setCaption(const std::string& caption);
|
||||
|
||||
/**
|
||||
* Sets the alignment of the caption. The alignment is relative
|
||||
* to the center of the label.
|
||||
*
|
||||
* @param alignemnt The alignment of the caption of the label.
|
||||
* @see getAlignment, Graphics
|
||||
*/
|
||||
void setAlignment(Graphics::Alignment alignment);
|
||||
|
||||
/**
|
||||
* Gets the alignment of the caption. The alignment is relative to
|
||||
* the center of the label.
|
||||
*
|
||||
* @return The alignment of caption of the label.
|
||||
* @see setAlignmentm Graphics
|
||||
*/
|
||||
Graphics::Alignment getAlignment() const;
|
||||
|
||||
/**
|
||||
* Adjusts the label's size to fit the caption.
|
||||
*/
|
||||
void adjustSize();
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the caption of the label.
|
||||
*/
|
||||
std::string mCaption;
|
||||
|
||||
/**
|
||||
* Holds the alignment of the caption.
|
||||
*/
|
||||
Graphics::Alignment mAlignment;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_LABEL_HPP
|
||||
253
project/jni/guichan/include/guichan/widgets/listbox.hpp
Normal file
253
project/jni/guichan/include/guichan/widgets/listbox.hpp
Normal file
@@ -0,0 +1,253 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_LISTBOX_HPP
|
||||
#define GCN_LISTBOX_HPP
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "guichan/keylistener.hpp"
|
||||
#include "guichan/listmodel.hpp"
|
||||
#include "guichan/mouselistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widget.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class SelectionListener;
|
||||
|
||||
/**
|
||||
* An implementation of a list box where an item can be selected.
|
||||
*
|
||||
* To be able display a list the list box uses a user provided list model.
|
||||
* A list model can be any class that implements the ListModel interface.
|
||||
*
|
||||
* If an item is selected in the list box a select event will be sent to
|
||||
* all selection listeners of the list box. If an item is selected by using
|
||||
* a mouse click or by using the enter or space key an action event will be
|
||||
* sent to all action listeners of the list box.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ListBox :
|
||||
public Widget,
|
||||
public MouseListener,
|
||||
public KeyListener
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
ListBox();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param listModel the list model to use.
|
||||
*/
|
||||
ListBox(ListModel *listModel);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ListBox() { }
|
||||
|
||||
/**
|
||||
* Gets the selected item as an index in the list model.
|
||||
*
|
||||
* @return the selected item as an index in the list model.
|
||||
* @see setSelected
|
||||
*/
|
||||
int getSelected() const;
|
||||
|
||||
/**
|
||||
* Sets the selected item. The selected item is represented by
|
||||
* an index from the list model.
|
||||
*
|
||||
* @param selected the selected item as an index from the list model.
|
||||
* @see getSelected
|
||||
*/
|
||||
void setSelected(int selected);
|
||||
|
||||
/**
|
||||
* Sets the list model to use.
|
||||
*
|
||||
* @param listModel the list model to use.
|
||||
* @see getListModel
|
||||
*/
|
||||
void setListModel(ListModel *listModel);
|
||||
|
||||
/**
|
||||
* Gets the list model used.
|
||||
*
|
||||
* @return the list model used.
|
||||
* @see setListModel
|
||||
*/
|
||||
ListModel *getListModel();
|
||||
|
||||
/**
|
||||
* Adjusts the size of the list box to fit it's list model.
|
||||
*/
|
||||
void adjustSize();
|
||||
|
||||
/**
|
||||
* Checks whether the list box wraps when selecting items with a
|
||||
* keyboard.
|
||||
*
|
||||
* Wrapping means that the selection of items will be wrapped. That is,
|
||||
* if the first item is selected and up is pressed, the last item will
|
||||
* get selected. If the last item is selected and down is pressed, the
|
||||
* first item will get selected.
|
||||
*
|
||||
* @return true if wrapping is enabled, fasle otherwise.
|
||||
* @see setWrappingEnabled
|
||||
*/
|
||||
bool isWrappingEnabled() const;
|
||||
|
||||
/**
|
||||
* Sets the list box to wrap or not when selecting items with a
|
||||
* keyboard.
|
||||
*
|
||||
* Wrapping means that the selection of items will be wrapped. That is,
|
||||
* if the first item is selected and up is pressed, the last item will
|
||||
* get selected. If the last item is selected and down is pressed, the
|
||||
* first item will get selected.
|
||||
*
|
||||
* @see isWrappingEnabled
|
||||
*/
|
||||
void setWrappingEnabled(bool wrappingEnabled);
|
||||
|
||||
/**
|
||||
* Adds a selection listener to the list box. When the selection
|
||||
* changes an event will be sent to all selection listeners of the
|
||||
* list box.
|
||||
*
|
||||
* If you delete your selection listener, be sure to also remove it
|
||||
* using removeSelectionListener().
|
||||
*
|
||||
* @param selectionListener The selection listener to add.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
void addSelectionListener(SelectionListener* selectionListener);
|
||||
|
||||
/**
|
||||
* Removes a selection listener from the list box.
|
||||
*
|
||||
* @param selectionListener The selection listener to remove.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
void removeSelectionListener(SelectionListener* selectionListener);
|
||||
|
||||
/**
|
||||
* Gets the height of a row. Should be overridden if another row
|
||||
* height than the font height is preferred.
|
||||
*
|
||||
* @return The height of a row.
|
||||
* @since 0.8.0
|
||||
*/
|
||||
virtual unsigned int getRowHeight() const;
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
virtual void logic();
|
||||
|
||||
|
||||
// Inherited from KeyListener
|
||||
|
||||
virtual void keyPressed(KeyEvent& keyEvent);
|
||||
|
||||
|
||||
// Inherited from MouseListener
|
||||
|
||||
virtual void mousePressed(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseDragged(MouseEvent& mouseEvent);
|
||||
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Distributes a value changed event to all selection listeners
|
||||
* of the list box.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
void distributeValueChangedEvent();
|
||||
|
||||
/**
|
||||
* The selected item as an index in the list model.
|
||||
*/
|
||||
int mSelected;
|
||||
|
||||
/**
|
||||
* The list model to use.
|
||||
*/
|
||||
ListModel *mListModel;
|
||||
|
||||
/**
|
||||
* True if wrapping is enabled, false otherwise.
|
||||
*/
|
||||
bool mWrappingEnabled;
|
||||
|
||||
/**
|
||||
* Typdef.
|
||||
*/
|
||||
typedef std::list<SelectionListener*> SelectionListenerList;
|
||||
|
||||
/**
|
||||
* The selection listeners of the list box.
|
||||
*/
|
||||
SelectionListenerList mSelectionListeners;
|
||||
|
||||
/**
|
||||
* Typedef.
|
||||
*/
|
||||
typedef SelectionListenerList::iterator SelectionListenerIterator;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_LISTBOX_HPP
|
||||
211
project/jni/guichan/include/guichan/widgets/radiobutton.hpp
Normal file
211
project/jni/guichan/include/guichan/widgets/radiobutton.hpp
Normal file
@@ -0,0 +1,211 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_RADIOBUTTON_HPP
|
||||
#define GCN_RADIOBUTTON_HPP
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "guichan/keylistener.hpp"
|
||||
#include "guichan/mouselistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widget.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* An implementation of a radio button where a user can select or deselect
|
||||
* the radio button and where the status of the radio button is displayed to the user.
|
||||
* A radio button can belong to a group and when a radio button belongs to a
|
||||
* group only one radio button can be selected in the group. A radio button is
|
||||
* capable of displaying a caption.
|
||||
*
|
||||
* If a radio button's state changes an action event will be sent to all action
|
||||
* listeners of the check box.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC RadioButton :
|
||||
public Widget,
|
||||
public MouseListener,
|
||||
public KeyListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
RadioButton();
|
||||
|
||||
/**
|
||||
* Constructor. The radio button will be automatically resized
|
||||
* to fit the caption.
|
||||
*
|
||||
* @param caption The caption of the radio button.
|
||||
* @param group The group the radio button should belong to.
|
||||
* @param selected True if the radio button should be selected.
|
||||
*/
|
||||
RadioButton(const std::string &caption,
|
||||
const std::string &group,
|
||||
bool selected = false);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~RadioButton();
|
||||
|
||||
/**
|
||||
* Checks if the radio button is selected.
|
||||
*
|
||||
* @return True if the radio button is selecte, false otherwise.
|
||||
* @see setSelected
|
||||
*/
|
||||
bool isSelected() const;
|
||||
|
||||
/**
|
||||
* Sets the radio button to selected or not.
|
||||
*
|
||||
* @param selected True if the radio button should be selected,
|
||||
* false otherwise.
|
||||
* @see isSelected
|
||||
*/
|
||||
void setSelected(bool selected);
|
||||
|
||||
/**
|
||||
* Gets the caption of the radio button.
|
||||
*
|
||||
* @return The caption of the radio button.
|
||||
* @see setCaption
|
||||
*/
|
||||
const std::string &getCaption() const;
|
||||
|
||||
/**
|
||||
* Sets the caption of the radio button. It's advisable to call
|
||||
* adjustSize after setting of the caption to adjust the
|
||||
* radio button's size to fit the caption.
|
||||
*
|
||||
* @param caption The caption of the radio button.
|
||||
* @see getCaption, adjustSize
|
||||
*/
|
||||
void setCaption(const std::string caption);
|
||||
|
||||
/**
|
||||
* Sets the group the radio button should belong to. Note that
|
||||
* a radio button group is unique per application, not per Gui object
|
||||
* as the group is stored in a static map.
|
||||
*
|
||||
* @param group The name of the group.
|
||||
* @see getGroup
|
||||
*/
|
||||
void setGroup(const std::string &group);
|
||||
|
||||
/**
|
||||
* Gets the group the radio button belongs to.
|
||||
*
|
||||
* @return The group the radio button belongs to.
|
||||
* @see setGroup
|
||||
*/
|
||||
const std::string &getGroup() const;
|
||||
|
||||
/**
|
||||
* Adjusts the radio button's size to fit the caption.
|
||||
*/
|
||||
void adjustSize();
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
|
||||
// Inherited from KeyListener
|
||||
|
||||
virtual void keyPressed(KeyEvent& keyEvent);
|
||||
|
||||
|
||||
// Inherited from MouseListener
|
||||
|
||||
virtual void mouseClicked(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseDragged(MouseEvent& mouseEvent);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Draws the box.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawBox(Graphics *graphics);
|
||||
|
||||
/**
|
||||
* True if the radio button is selected, false otherwise.
|
||||
*/
|
||||
bool mSelected;
|
||||
|
||||
/**
|
||||
* Holds the caption of the radio button.
|
||||
*/
|
||||
std::string mCaption;
|
||||
|
||||
/**
|
||||
* Holds the group of the radio button.
|
||||
*/
|
||||
std::string mGroup;
|
||||
|
||||
/**
|
||||
* Typdef.
|
||||
*/
|
||||
typedef std::multimap<std::string, RadioButton *> GroupMap;
|
||||
|
||||
/**
|
||||
* Typdef.
|
||||
*/
|
||||
typedef GroupMap::iterator GroupIterator;
|
||||
|
||||
/**
|
||||
* Holds all available radio button groups.
|
||||
*/
|
||||
static GroupMap mGroupMap;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_RADIOBUTTON_HPP
|
||||
590
project/jni/guichan/include/guichan/widgets/scrollarea.hpp
Normal file
590
project/jni/guichan/include/guichan/widgets/scrollarea.hpp
Normal file
@@ -0,0 +1,590 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SCROLLAREA_HPP
|
||||
#define GCN_SCROLLAREA_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "guichan/basiccontainer.hpp"
|
||||
#include "guichan/mouselistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* Implementation if a scrollable area used to view widgets larger than the scroll area.
|
||||
* A scroll area can be customized to always show scroll bars or to show them only when
|
||||
* necessary.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC ScrollArea:
|
||||
public BasicContainer,
|
||||
public MouseListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Scrollpolicies for the horizontal and vertical scrollbar.
|
||||
* The policies are:
|
||||
*
|
||||
* SHOW_ALWAYS - Always show the scrollbars no matter what.
|
||||
* SHOW_NEVER - Never show the scrollbars no matter waht.
|
||||
* SHOW_AUTO - Show the scrollbars only when needed. That is if the
|
||||
* content grows larger then the ScrollArea.
|
||||
*/
|
||||
enum ScrollPolicy
|
||||
{
|
||||
SHOW_ALWAYS = 0,
|
||||
SHOW_NEVER,
|
||||
SHOW_AUTO
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
ScrollArea();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param content The content of the scroll area.
|
||||
*/
|
||||
ScrollArea(Widget *content);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param content The content of the scroll area.
|
||||
* @param hPolicy The policy for the horizontal scrollbar. See enum with
|
||||
* policies.
|
||||
* @param vPolicy The policy for the vertical scrollbar. See enum with
|
||||
* policies.
|
||||
*/
|
||||
ScrollArea(Widget *content,
|
||||
ScrollPolicy hPolicy,
|
||||
ScrollPolicy vPolicy);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~ScrollArea();
|
||||
|
||||
/**
|
||||
* Sets the content.
|
||||
*
|
||||
* @param widget The content of the scroll area.
|
||||
*/
|
||||
void setContent(Widget* widget);
|
||||
|
||||
/**
|
||||
* Gets the content.
|
||||
*
|
||||
* @return The content of the scroll area.
|
||||
*/
|
||||
Widget* getContent();
|
||||
|
||||
/**
|
||||
* Sets the horizontal scrollbar policy. See enum with policies.
|
||||
*
|
||||
* @param hPolicy The policy for the horizontal scrollbar.
|
||||
* @see getHorizontalScrollPolicy
|
||||
*/
|
||||
void setHorizontalScrollPolicy(ScrollPolicy hPolicy);
|
||||
|
||||
/**
|
||||
* Gets the horizontal scrollbar policy. See enum with policies.
|
||||
*
|
||||
* @return The policy for the horizontal scrollbar policy.
|
||||
* @see setHorizontalScrollPolicy, setScrollPolicy
|
||||
*/
|
||||
ScrollPolicy getHorizontalScrollPolicy() const;
|
||||
|
||||
/**
|
||||
* Sets the vertical scrollbar policy. See enum with policies.
|
||||
*
|
||||
* @param vPolicy The policy for the vertical scrollbar.
|
||||
* @see getVerticalScrollPolicy
|
||||
*/
|
||||
void setVerticalScrollPolicy(ScrollPolicy vPolicy);
|
||||
|
||||
/**
|
||||
* Gets the vertical scrollbar policy. See enum with policies.
|
||||
*
|
||||
* @return The policy for the vertical scrollbar.
|
||||
* @see setVerticalScrollPolicy, setScrollPolicy
|
||||
*/
|
||||
ScrollPolicy getVerticalScrollPolicy() const;
|
||||
|
||||
/**
|
||||
* Sets the horizontal and vertical scrollbar policy.
|
||||
*
|
||||
* @param hPolicy The policy for the horizontal scrollbar.
|
||||
* @param vPolicy The policy for the vertical scrollbar.
|
||||
* @see getVerticalScrollPolicy, getHorizontalScrollPolicy
|
||||
*/
|
||||
void setScrollPolicy(ScrollPolicy hPolicy, ScrollPolicy vPolicy);
|
||||
|
||||
/**
|
||||
* Sets the amount to scroll vertically.
|
||||
*
|
||||
* @param vScroll The amount to scroll.
|
||||
* @see getVerticalScrollAmount
|
||||
*/
|
||||
void setVerticalScrollAmount(int vScroll);
|
||||
|
||||
/**
|
||||
* Gets the amount that is scrolled vertically.
|
||||
*
|
||||
* @return The scroll amount on vertical scroll.
|
||||
* @see setVerticalScrollAmount, setScrollAmount
|
||||
*/
|
||||
int getVerticalScrollAmount() const;
|
||||
|
||||
/**
|
||||
* Sets the amount to scroll horizontally.
|
||||
*
|
||||
* @param hScroll The amount to scroll.
|
||||
* @see getHorizontalScrollAmount
|
||||
*/
|
||||
void setHorizontalScrollAmount(int hScroll);
|
||||
|
||||
/**
|
||||
* Gets the amount that is scrolled horizontally.
|
||||
*
|
||||
* @return The scroll amount on horizontal scroll.
|
||||
* @see setHorizontalScrollAmount, setScrollAmount
|
||||
*/
|
||||
int getHorizontalScrollAmount() const;
|
||||
|
||||
/**
|
||||
* Sets the amount to scroll horizontally and vertically.
|
||||
*
|
||||
* @param hScroll The amount to scroll on horizontal scroll.
|
||||
* @param vScroll The amount to scroll on vertical scroll.
|
||||
* @see getHorizontalScrollAmount, getVerticalScrollAmount
|
||||
*/
|
||||
void setScrollAmount(int hScroll, int vScroll);
|
||||
|
||||
/**
|
||||
* Gets the maximum amount of horizontal scroll.
|
||||
*
|
||||
* @return The horizontal max scroll.
|
||||
*/
|
||||
int getHorizontalMaxScroll();
|
||||
|
||||
/**
|
||||
* Gets the maximum amount of vertical scroll.
|
||||
*
|
||||
* @return The vertical max scroll.
|
||||
*/
|
||||
int getVerticalMaxScroll();
|
||||
|
||||
/**
|
||||
* Sets the width of the scroll bars.
|
||||
*
|
||||
* @param width The width of the scroll bars.
|
||||
* @see getScrollbarWidth
|
||||
*/
|
||||
void setScrollbarWidth(int width);
|
||||
|
||||
/**
|
||||
* Gets the width of the scroll bars.
|
||||
*
|
||||
* @return the width of the ScrollBar.
|
||||
* @see setScrollbarWidth
|
||||
*/
|
||||
int getScrollbarWidth() const;
|
||||
|
||||
/**
|
||||
* Sets the amount to scroll in pixels when the left scroll button is
|
||||
* pushed.
|
||||
*
|
||||
* @param amount The amount to scroll in pixels.
|
||||
* @see getLeftButtonScrollAmount
|
||||
*/
|
||||
void setLeftButtonScrollAmount(int amount);
|
||||
|
||||
/**
|
||||
* Sets the amount to scroll in pixels when the right scroll button is
|
||||
* pushed.
|
||||
*
|
||||
* @param amount The amount to scroll in pixels.
|
||||
* @see getRightButtonScrollAmount
|
||||
*/
|
||||
void setRightButtonScrollAmount(int amount);
|
||||
|
||||
/**
|
||||
* Sets the amount to scroll in pixels when the up scroll button is
|
||||
* pushed.
|
||||
*
|
||||
* @param amount The amount to scroll in pixels.
|
||||
* @see getUpButtonScrollAmount
|
||||
*/
|
||||
void setUpButtonScrollAmount(int amount);
|
||||
|
||||
/**
|
||||
* Sets the amount to scroll in pixels when the down scroll button is
|
||||
* pushed.
|
||||
*
|
||||
* @param amount The amount to scroll in pixels.
|
||||
* @see getDownButtonScrollAmount
|
||||
*/
|
||||
void setDownButtonScrollAmount(int amount);
|
||||
|
||||
/**
|
||||
* Gets the amount to scroll in pixels when the left scroll button is
|
||||
* pushed.
|
||||
*
|
||||
* @return The amount to scroll in pixels.
|
||||
* @see setLeftButtonScrollAmount
|
||||
*/
|
||||
int getLeftButtonScrollAmount() const;
|
||||
|
||||
/**
|
||||
* Gets the amount to scroll in pixels when the right scroll button is
|
||||
* pushed.
|
||||
*
|
||||
* @return The amount to scroll in pixels.
|
||||
* @see setRightButtonScrollAmount
|
||||
*/
|
||||
int getRightButtonScrollAmount() const;
|
||||
|
||||
/**
|
||||
* Gets the amount to scroll in pixels when the up scroll button is
|
||||
* pushed.
|
||||
*
|
||||
* @return The amount to scroll in pixels.
|
||||
* @see setUpButtonScrollAmount
|
||||
*/
|
||||
int getUpButtonScrollAmount() const;
|
||||
|
||||
/**
|
||||
* Gets the amount to scroll in pixels when the down scroll button is
|
||||
* pushed.
|
||||
*
|
||||
* @return The amount to scroll in pixels.
|
||||
* @see setDownButtonScrollAmount
|
||||
*/
|
||||
int getDownButtonScrollAmount() const;
|
||||
|
||||
/**
|
||||
* Sets the scroll area to be opaque, that is sets the scoll area
|
||||
* to display its background.
|
||||
*
|
||||
* @param opaque True if the scoll area should be opaque, false otherwise.
|
||||
*/
|
||||
void setOpaque(bool opaque);
|
||||
|
||||
/**
|
||||
* Checks if the scroll area is opaque, that is if the scroll area
|
||||
* displays its background.
|
||||
*
|
||||
* @return True if the scroll area is opaque, false otherwise.
|
||||
*/
|
||||
bool isOpaque() const;
|
||||
|
||||
|
||||
// Inherited from BasicContainer
|
||||
|
||||
virtual void showWidgetPart(Widget* widget, Rectangle area);
|
||||
|
||||
virtual Rectangle getChildrenArea();
|
||||
|
||||
virtual Widget *getWidgetAt(int x, int y);
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics *graphics);
|
||||
|
||||
virtual void logic();
|
||||
|
||||
void setWidth(int width);
|
||||
|
||||
void setHeight(int height);
|
||||
|
||||
void setDimension(const Rectangle& dimension);
|
||||
|
||||
|
||||
// Inherited from MouseListener
|
||||
|
||||
virtual void mousePressed(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseReleased(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseDragged(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Draws the background of the scroll area, that is
|
||||
* the area behind the content.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawBackground(Graphics *graphics);
|
||||
|
||||
/**
|
||||
* Draws the up button.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawUpButton(Graphics *graphics);
|
||||
|
||||
/**
|
||||
* Draws the down button.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawDownButton(Graphics *graphics);
|
||||
|
||||
/**
|
||||
* Draws the left button.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawLeftButton(Graphics *graphics);
|
||||
|
||||
/**
|
||||
* Draws the right button.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawRightButton(Graphics *graphics);
|
||||
|
||||
/**
|
||||
* Draws the vertical scroll bar.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawVBar(Graphics* graphics);
|
||||
|
||||
/**
|
||||
* Draws the horizontal scroll bar.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawHBar(Graphics* graphics);
|
||||
|
||||
/**
|
||||
* Draws the vertical marker.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawVMarker(Graphics* graphics);
|
||||
|
||||
/**
|
||||
* Draws the horizontal marker.
|
||||
*
|
||||
* @param graphics a Graphics object to draw with.
|
||||
*/
|
||||
virtual void drawHMarker(Graphics* graphics);
|
||||
|
||||
/**
|
||||
* Checks the policies for the scroll bars.
|
||||
*/
|
||||
virtual void checkPolicies();
|
||||
|
||||
/**
|
||||
* Gets the up button dimension.
|
||||
*
|
||||
* @return the dimension of the up button.
|
||||
*/
|
||||
Rectangle getUpButtonDimension();
|
||||
|
||||
/**
|
||||
* Gets the down button dimension.
|
||||
*
|
||||
* @return the dimension of the down button.
|
||||
*/
|
||||
Rectangle getDownButtonDimension();
|
||||
|
||||
/**
|
||||
* Gets the left button dimension.
|
||||
*
|
||||
* @return the dimension of the left button.
|
||||
*/
|
||||
Rectangle getLeftButtonDimension();
|
||||
|
||||
/**
|
||||
* Gets the right button dimension.
|
||||
*
|
||||
* @return the dimension of the right button.
|
||||
*/
|
||||
Rectangle getRightButtonDimension();
|
||||
|
||||
/**
|
||||
* Gets the vertical scrollbar dimension.
|
||||
*
|
||||
* @return the dimension of the vertical scrollbar.
|
||||
*/
|
||||
Rectangle getVerticalBarDimension();
|
||||
|
||||
/**
|
||||
* Gets the horizontal scrollbar dimension.
|
||||
*
|
||||
* @return the dimension of the horizontal scrollbar.
|
||||
*/
|
||||
Rectangle getHorizontalBarDimension();
|
||||
|
||||
/**
|
||||
* Gets the vertical marker dimension.
|
||||
*
|
||||
* @return the dimension of the vertical marker.
|
||||
*/
|
||||
Rectangle getVerticalMarkerDimension();
|
||||
|
||||
/**
|
||||
* Gets the horizontal marker dimension.
|
||||
*
|
||||
* @return the dimension of the horizontal marker.
|
||||
*/
|
||||
Rectangle getHorizontalMarkerDimension();
|
||||
|
||||
/**
|
||||
* Holds the vertical scroll amount.
|
||||
*/
|
||||
int mVScroll;
|
||||
|
||||
/**
|
||||
* Holds the horizontal scroll amount.
|
||||
*/
|
||||
int mHScroll;
|
||||
|
||||
/**
|
||||
* Holds the width of the scroll bars.
|
||||
*/
|
||||
int mScrollbarWidth;
|
||||
|
||||
/**
|
||||
* Holds the horizontal scroll bar policy.
|
||||
*/
|
||||
ScrollPolicy mHPolicy;
|
||||
|
||||
/**
|
||||
* Holds the vertical scroll bar policy.
|
||||
*/
|
||||
ScrollPolicy mVPolicy;
|
||||
|
||||
/**
|
||||
* True if the vertical scroll bar is visible, false otherwise.
|
||||
*/
|
||||
bool mVBarVisible;
|
||||
|
||||
/**
|
||||
* True if the horizontal scroll bar is visible, false otherwise.
|
||||
*/
|
||||
bool mHBarVisible;
|
||||
|
||||
/**
|
||||
* True if the up button is pressed, false otherwise.
|
||||
*/
|
||||
bool mUpButtonPressed;
|
||||
|
||||
/**
|
||||
* True if the down button is pressed, false otherwise.
|
||||
*/
|
||||
bool mDownButtonPressed;
|
||||
|
||||
/**
|
||||
* True if the left button is pressed, false otherwise.
|
||||
*/
|
||||
bool mLeftButtonPressed;
|
||||
|
||||
/**
|
||||
* True if the right button is pressed, false otherwise.
|
||||
*/
|
||||
bool mRightButtonPressed;
|
||||
|
||||
/**
|
||||
* Holds the up button scroll amount.
|
||||
*/
|
||||
int mUpButtonScrollAmount;
|
||||
|
||||
/**
|
||||
* Holds the down button scroll amount.
|
||||
*/
|
||||
int mDownButtonScrollAmount;
|
||||
|
||||
/**
|
||||
* Holds the left button scroll amount.
|
||||
*/
|
||||
int mLeftButtonScrollAmount;
|
||||
|
||||
/**
|
||||
* Holds the right button scroll amount.
|
||||
*/
|
||||
int mRightButtonScrollAmount;
|
||||
|
||||
/**
|
||||
* True if the vertical marked is dragged.
|
||||
*/
|
||||
bool mIsVerticalMarkerDragged;
|
||||
|
||||
/**
|
||||
* True if the horizontal marked is dragged.
|
||||
*/
|
||||
bool mIsHorizontalMarkerDragged;
|
||||
|
||||
/**
|
||||
* Holds the horizontal markers drag offset.
|
||||
*/
|
||||
int mHorizontalMarkerDragOffset;
|
||||
|
||||
/**
|
||||
* Holds the vertical markers drag offset.
|
||||
*/
|
||||
int mVerticalMarkerDragOffset;
|
||||
|
||||
/**
|
||||
* True if the scroll area should be opaque (that is
|
||||
* display its background), false otherwise.
|
||||
*/
|
||||
bool mOpaque;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_SCROLLAREA_HPP
|
||||
300
project/jni/guichan/include/guichan/widgets/slider.hpp
Normal file
300
project/jni/guichan/include/guichan/widgets/slider.hpp
Normal file
@@ -0,0 +1,300 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_SLIDER_HPP
|
||||
#define GCN_SLIDER_HPP
|
||||
|
||||
#include "guichan/keylistener.hpp"
|
||||
#include "guichan/mouselistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
#include "guichan/widget.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
/**
|
||||
* An implementation of a slider where a user can select different values by
|
||||
* sliding between a start value and an end value of a scale.
|
||||
*
|
||||
* If the selected value is changed an action event will be sent to all
|
||||
* action listeners of the slider.
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Slider :
|
||||
public Widget,
|
||||
public MouseListener,
|
||||
public KeyListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Draw orientations for the slider. A slider can be drawn vertically or
|
||||
* horizontally.
|
||||
*/
|
||||
enum Orientation
|
||||
{
|
||||
HORIZONTAL = 0,
|
||||
VERTICAL
|
||||
};
|
||||
|
||||
/**
|
||||
* Constructor. The default start value of the slider scale is zero.
|
||||
*
|
||||
* @param scaleEnd The end value of the slider scale.
|
||||
*/
|
||||
Slider(double scaleEnd = 1.0);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param scaleStart The start value of the slider scale.
|
||||
* @param scaleEnd The end value of the slider scale.
|
||||
*/
|
||||
Slider(double scaleStart, double scaleEnd);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Slider() { }
|
||||
|
||||
/**
|
||||
* Sets the scale of the slider.
|
||||
*
|
||||
* @param scaleStart The start value of the scale.
|
||||
* @param scaleEnd tThe end of value the scale.
|
||||
* @see getScaleStart, getScaleEnd
|
||||
*/
|
||||
void setScale(double scaleStart, double scaleEnd);
|
||||
|
||||
/**
|
||||
* Gets the start value of the scale.
|
||||
*
|
||||
* @return The start value of the scale.
|
||||
* @see setScaleStart, setScale
|
||||
*/
|
||||
double getScaleStart() const;
|
||||
|
||||
/**
|
||||
* Sets the start value of the scale.
|
||||
*
|
||||
* @param scaleStart The start value of the scale.
|
||||
* @see getScaleStart
|
||||
*/
|
||||
void setScaleStart(double scaleStart);
|
||||
|
||||
/**
|
||||
* Gets the end value of the scale.
|
||||
*
|
||||
* @return The end value of the scale.
|
||||
* @see setScaleEnd, setScale
|
||||
*/
|
||||
double getScaleEnd() const;
|
||||
|
||||
/**
|
||||
* Sets the end value of the scale.
|
||||
*
|
||||
* @param scaleEnd The end value of the scale.
|
||||
* @see getScaleEnd
|
||||
*/
|
||||
void setScaleEnd(double scaleEnd);
|
||||
|
||||
/**
|
||||
* Gets the current selected value.
|
||||
*
|
||||
* @return The current selected value.
|
||||
* @see setValue
|
||||
*/
|
||||
double getValue() const;
|
||||
|
||||
/**
|
||||
* Sets the current selected value.
|
||||
*
|
||||
* @param value The current selected value.
|
||||
* @see getValue
|
||||
*/
|
||||
void setValue(double value);
|
||||
|
||||
/**
|
||||
* Sets the length of the marker.
|
||||
*
|
||||
* @param length The length for the marker.
|
||||
* @see getMarkerLength
|
||||
*/
|
||||
void setMarkerLength(int length);
|
||||
|
||||
/**
|
||||
* Gets the length of the marker.
|
||||
*
|
||||
* @return The length of the marker.
|
||||
* @see setMarkerLength
|
||||
*/
|
||||
int getMarkerLength() const;
|
||||
|
||||
/**
|
||||
* Sets the orientation of the slider. A slider can be drawn vertically
|
||||
* or horizontally.
|
||||
*
|
||||
* @param orientation The orientation of the slider.
|
||||
* @see getOrientation
|
||||
*/
|
||||
void setOrientation(Orientation orientation);
|
||||
|
||||
/**
|
||||
* Gets the orientation of the slider. A slider can be drawn vertically
|
||||
* or horizontally.
|
||||
*
|
||||
* @return The orientation of the slider.
|
||||
* @see setOrientation
|
||||
*/
|
||||
Orientation getOrientation() const;
|
||||
|
||||
/**
|
||||
* Sets the step length. The step length is used when the keys LEFT
|
||||
* and RIGHT are pressed to step in the scale.
|
||||
*
|
||||
* @param length The step length.
|
||||
* @see getStepLength
|
||||
*/
|
||||
void setStepLength(double length);
|
||||
|
||||
/**
|
||||
* Gets the step length. The step length is used when the keys LEFT
|
||||
* and RIGHT are pressed to step in the scale.
|
||||
*
|
||||
* @return the step length.
|
||||
* @see setStepLength
|
||||
*/
|
||||
double getStepLength() const;
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics* graphics);
|
||||
|
||||
|
||||
// Inherited from MouseListener.
|
||||
|
||||
virtual void mousePressed(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseDragged(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseWheelMovedUp(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseWheelMovedDown(MouseEvent& mouseEvent);
|
||||
|
||||
|
||||
// Inherited from KeyListener
|
||||
|
||||
virtual void keyPressed(KeyEvent& keyEvent);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Draws the marker.
|
||||
*
|
||||
* @param graphics A graphics object to draw with.
|
||||
*/
|
||||
virtual void drawMarker(gcn::Graphics* graphics);
|
||||
|
||||
/**
|
||||
* Converts a marker position to a value in the scale.
|
||||
*
|
||||
* @param position The position to convert.
|
||||
* @return A scale value corresponding to the position.
|
||||
* @see valueToMarkerPosition
|
||||
*/
|
||||
virtual double markerPositionToValue(int position) const;
|
||||
|
||||
/**
|
||||
* Converts a value to a marker position.
|
||||
*
|
||||
* @param value The value to convert.
|
||||
* @return A marker position corresponding to the value.
|
||||
* @see markerPositionToValue
|
||||
*/
|
||||
virtual int valueToMarkerPosition(double value) const;
|
||||
|
||||
/**
|
||||
* Gets the marker position of the current selected value.
|
||||
*
|
||||
* @return The marker position of the current selected value.
|
||||
*/
|
||||
virtual int getMarkerPosition() const;
|
||||
|
||||
/**
|
||||
* True if the slider is dragged, false otherwise.
|
||||
*/
|
||||
bool mDragged;
|
||||
|
||||
/**
|
||||
* Holds the current selected value.
|
||||
*/
|
||||
double mValue;
|
||||
|
||||
/**
|
||||
* Holds the step length. The step length is used when the keys LEFT
|
||||
* and RIGHT are pressed to step in the scale.
|
||||
*/
|
||||
double mStepLength;
|
||||
|
||||
/**
|
||||
* Holds the length of the marker.
|
||||
*/
|
||||
int mMarkerLength;
|
||||
|
||||
/**
|
||||
* Holds the start value of the scale.
|
||||
*/
|
||||
double mScaleStart;
|
||||
|
||||
/**
|
||||
* Holds the end value of the scale.
|
||||
*/
|
||||
double mScaleEnd;
|
||||
|
||||
/**
|
||||
* Holds the orientation of the slider. A slider can be drawn
|
||||
* vertically or horizontally.
|
||||
*/
|
||||
Orientation mOrientation;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_SLIDER_HPP
|
||||
151
project/jni/guichan/include/guichan/widgets/tab.hpp
Normal file
151
project/jni/guichan/include/guichan/widgets/tab.hpp
Normal file
@@ -0,0 +1,151 @@
|
||||
/* _______ __ __ __ ______ __ __ _______ __ __
|
||||
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
|
||||
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
|
||||
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
|
||||
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
|
||||
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
|
||||
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
|
||||
*
|
||||
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
|
||||
*
|
||||
*
|
||||
* Per Larsson a.k.a finalman
|
||||
* Olof Naessén a.k.a jansem/yakslem
|
||||
*
|
||||
* Visit: http://guichan.sourceforge.net
|
||||
*
|
||||
* License: (BSD)
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Guichan nor the names of its contributors may
|
||||
* be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef GCN_TAB_HPP
|
||||
#define GCN_TAB_HPP
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "guichan/basiccontainer.hpp"
|
||||
#include "guichan/mouselistener.hpp"
|
||||
#include "guichan/platform.hpp"
|
||||
|
||||
namespace gcn
|
||||
{
|
||||
class Label;
|
||||
class TabbedArea;
|
||||
|
||||
/**
|
||||
* An implementation of a simple tab to be used in a tabbed area.
|
||||
*
|
||||
* @see TabbedArea
|
||||
* @since 0.8.0
|
||||
*/
|
||||
class GCN_CORE_DECLSPEC Tab:
|
||||
public BasicContainer,
|
||||
public MouseListener
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Tab();
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*/
|
||||
virtual ~Tab();
|
||||
|
||||
/**
|
||||
* Adjusts the size of the tab to fit the caption. If this tab was
|
||||
* added to a TabbedArea, it will also adjust the tab positions.
|
||||
*/
|
||||
void adjustSize();
|
||||
|
||||
/**
|
||||
* Sets the tabbed area the tab should be a part of.
|
||||
*
|
||||
* @param tabbedArea The tabbed area the tab should be a part of.
|
||||
* @see getTabbedArea
|
||||
*/
|
||||
void setTabbedArea(TabbedArea* tabbedArea);
|
||||
|
||||
/**
|
||||
* Gets the tabbed are the tab is a part of.
|
||||
*
|
||||
* @return The tabbed are the tab is a part of.
|
||||
* @see setTabbedArea
|
||||
*/
|
||||
TabbedArea* getTabbedArea();
|
||||
|
||||
/**
|
||||
* Sets the caption of the tab. It's advisable to call
|
||||
* adjustSize after setting the caption to make the tab
|
||||
* fit the caption.
|
||||
*
|
||||
* @param caption The caption of the tab.
|
||||
* @see getCaption, adjustSize
|
||||
*/
|
||||
void setCaption(const std::string& caption);
|
||||
|
||||
/**
|
||||
* Gets the caption of the tab.
|
||||
*
|
||||
* @return The caption of the tab.
|
||||
* @see setCaption
|
||||
*/
|
||||
const std::string& getCaption() const;
|
||||
|
||||
|
||||
// Inherited from Widget
|
||||
|
||||
virtual void draw(Graphics *graphics);
|
||||
|
||||
|
||||
// Inherited from MouseListener
|
||||
|
||||
virtual void mouseEntered(MouseEvent& mouseEvent);
|
||||
|
||||
virtual void mouseExited(MouseEvent& mouseEvent);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Holds the label of the tab.
|
||||
*/
|
||||
Label* mLabel;
|
||||
|
||||
/**
|
||||
* True if the tab has the mouse, false otherwise.
|
||||
*/
|
||||
bool mHasMouse;
|
||||
|
||||
/**
|
||||
* Holds the tabbed area the tab is a part of.
|
||||
*/
|
||||
TabbedArea* mTabbedArea;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // end GCN_TABBEDAREA_HPP
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user